-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake.ps1
More file actions
322 lines (286 loc) · 9.88 KB
/
make.ps1
File metadata and controls
322 lines (286 loc) · 9.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# PowerShell equivalent of Makefile for Windows users
# Usage: .\make.ps1 <target>
param(
[Parameter(Position=0)]
[string]$Target = "help"
)
# Project configuration
$PROJECT_NAME = "codin"
$PYTHON_VERSION = "3.13"
$SRC_DIR = "src"
$TESTS_DIR = "tests"
$DOCS_DIR = "docs"
$EXAMPLES_DIR = "examples"
# Colors for output
$Blue = "`e[34m"
$Green = "`e[32m"
$Yellow = "`e[33m"
$Red = "`e[31m"
$Reset = "`e[0m"
function Write-ColorOutput {
param($Color, $Message)
Write-Host "$Color$Message$Reset"
}
function Show-Help {
Write-ColorOutput $Blue "$PROJECT_NAME - Development Commands"
Write-Host ""
Write-ColorOutput $Green "Environment Management:"
Write-Host " install Install production dependencies"
Write-Host " install-dev Install development dependencies"
Write-Host " setup Setup development environment"
Write-Host ""
Write-ColorOutput $Green "Build and Distribution:"
Write-Host " build Build the package"
Write-Host " build-wheel Build wheel distribution only"
Write-Host " build-sdist Build source distribution only"
Write-Host " publish Publish to PyPI"
Write-Host " publish-test Publish to Test PyPI"
Write-Host ""
Write-ColorOutput $Green "Testing:"
Write-Host " test Run tests"
Write-Host " test-cov Run tests with coverage"
Write-Host " test-fast Run tests in parallel"
Write-Host ""
Write-ColorOutput $Green "Code Quality:"
Write-Host " lint Run linting checks"
Write-Host " lint-fix Run linting checks and fix issues"
Write-Host " format Format code"
Write-Host " format-check Check code formatting"
Write-Host " type-check Run type checking"
Write-Host " check Run all code quality checks"
Write-Host " fix Fix linting issues and format code"
Write-Host ""
Write-ColorOutput $Green "Cleaning:"
Write-Host " clean Clean build artifacts"
Write-Host " clean-all Clean all artifacts including venv"
Write-Host ""
Write-ColorOutput $Green "Development:"
Write-Host " run Run the CLI application"
Write-Host " run-dev Run in development mode"
Write-Host " examples Run example scripts"
Write-Host ""
Write-ColorOutput $Green "Utilities:"
Write-Host " upgrade Upgrade all dependencies"
Write-Host " lock Update lock file"
Write-Host " tree Show dependency tree"
Write-Host " info Show project information"
Write-Host " env Show environment information"
Write-Host ""
Write-ColorOutput $Green "Complete Workflows:"
Write-Host " ci Run CI pipeline"
Write-Host " release Prepare for release"
Write-Host ""
}
function Invoke-Install {
Write-ColorOutput $Blue "Installing production dependencies..."
uv sync --no-dev
}
function Invoke-InstallDev {
Write-ColorOutput $Blue "Installing development dependencies..."
uv sync
}
function Invoke-Setup {
Write-ColorOutput $Blue "Setting up development environment..."
uv sync
Write-ColorOutput $Green "✓ Virtual environment created and dependencies installed"
Write-ColorOutput $Yellow "Run '.venv\Scripts\activate' to activate the environment"
}
function Invoke-Build {
Invoke-Clean
Write-ColorOutput $Blue "Building package..."
uv build
}
function Invoke-BuildWheel {
Invoke-Clean
Write-ColorOutput $Blue "Building wheel..."
uv build --wheel
}
function Invoke-BuildSdist {
Invoke-Clean
Write-ColorOutput $Blue "Building source distribution..."
uv build --sdist
}
function Invoke-Publish {
Invoke-Build
Write-ColorOutput $Blue "Publishing to PyPI..."
uv publish
}
function Invoke-PublishTest {
Invoke-Build
Write-ColorOutput $Blue "Publishing to Test PyPI..."
uv publish --index-url https://test.pypi.org/simple/
}
function Invoke-Test {
Write-ColorOutput $Blue "Running tests..."
uv run pytest $TESTS_DIR
}
function Invoke-TestCov {
Write-ColorOutput $Blue "Running tests with coverage..."
uv run pytest $TESTS_DIR --cov=$SRC_DIR --cov-report=html --cov-report=term-missing
}
function Invoke-TestFast {
Write-ColorOutput $Blue "Running tests in parallel..."
try {
uv run pytest $TESTS_DIR -n auto
} catch {
uv run pytest $TESTS_DIR
}
}
function Invoke-Lint {
Write-ColorOutput $Blue "Running linting checks..."
uv run ruff check $SRC_DIR $TESTS_DIR
}
function Invoke-LintFix {
Write-ColorOutput $Blue "Running linting checks and fixing issues..."
uv run ruff check --fix $SRC_DIR $TESTS_DIR
}
function Invoke-Format {
Write-ColorOutput $Blue "Formatting code..."
uv run ruff format $SRC_DIR $TESTS_DIR
}
function Invoke-FormatCheck {
Write-ColorOutput $Blue "Checking code formatting..."
uv run ruff format --check $SRC_DIR $TESTS_DIR
}
function Invoke-TypeCheck {
Write-ColorOutput $Blue "Running type checks..."
uv run mypy $SRC_DIR
}
function Invoke-Check {
Invoke-Lint
Invoke-FormatCheck
Invoke-TypeCheck
Write-ColorOutput $Green "✓ All code quality checks passed"
}
function Invoke-Fix {
Invoke-LintFix
Invoke-Format
Write-ColorOutput $Green "✓ Code fixed and formatted"
}
function Invoke-Clean {
Write-ColorOutput $Blue "Cleaning build artifacts..."
if (Test-Path "build") { Remove-Item -Recurse -Force "build" }
if (Test-Path "dist") { Remove-Item -Recurse -Force "dist" }
Get-ChildItem -Path "." -Filter "*.egg-info" -Directory | Remove-Item -Recurse -Force
if (Test-Path ".pytest_cache") { Remove-Item -Recurse -Force ".pytest_cache" }
if (Test-Path ".coverage") { Remove-Item -Force ".coverage" }
if (Test-Path "htmlcov") { Remove-Item -Recurse -Force "htmlcov" }
if (Test-Path ".mypy_cache") { Remove-Item -Recurse -Force ".mypy_cache" }
if (Test-Path ".ruff_cache") { Remove-Item -Recurse -Force ".ruff_cache" }
Get-ChildItem -Path "." -Recurse -Name "*.pyc" | Remove-Item -Force
Get-ChildItem -Path "." -Recurse -Name "__pycache__" -Directory | Remove-Item -Recurse -Force
}
function Invoke-CleanAll {
Invoke-Clean
Write-ColorOutput $Blue "Cleaning all artifacts..."
if (Test-Path ".venv") { Remove-Item -Recurse -Force ".venv" }
}
function Invoke-Run {
Write-ColorOutput $Blue "Running $PROJECT_NAME..."
uv run codin
}
function Invoke-RunDev {
Write-ColorOutput $Blue "Running $PROJECT_NAME in development mode..."
uv run python -m codin.cli.commands
}
function Invoke-Examples {
Write-ColorOutput $Blue "Running examples..."
if (Test-Path $EXAMPLES_DIR) {
Get-ChildItem -Path $EXAMPLES_DIR -Filter "*.py" | ForEach-Object {
Write-ColorOutput $Yellow "Running $($_.FullName)..."
try {
uv run python $_.FullName
} catch {
Write-Host "Example failed, continuing..."
}
}
} else {
Write-ColorOutput $Yellow "No examples directory found."
}
}
function Invoke-Upgrade {
Write-ColorOutput $Blue "Upgrading dependencies..."
uv sync --upgrade
}
function Invoke-Lock {
Write-ColorOutput $Blue "Updating lock file..."
uv lock
}
function Invoke-Tree {
Write-ColorOutput $Blue "Dependency tree:"
uv tree
}
function Invoke-Info {
Write-ColorOutput $Blue "Project Information:"
Write-Host "Name: $PROJECT_NAME"
Write-Host "Python Version: $PYTHON_VERSION"
Write-Host "Source Directory: $SRC_DIR"
Write-Host "Tests Directory: $TESTS_DIR"
Write-Host ""
Write-ColorOutput $Blue "UV Information:"
uv --version
Write-Host ""
Write-ColorOutput $Blue "Virtual Environment:"
uv python list
}
function Invoke-Env {
Write-ColorOutput $Blue "Environment Information:"
uv run python --version
uv run python -c "import sys; print('Python executable:', sys.executable)"
uv run python -c "import sys; print('Python path:', sys.path)"
}
function Invoke-CI {
Invoke-Clean
Invoke-InstallDev
Invoke-Check
Invoke-Test
Write-ColorOutput $Green "✓ CI pipeline completed successfully"
}
function Invoke-Release {
Invoke-Clean
Invoke-Check
Invoke-Test
Invoke-Build
Write-ColorOutput $Green "✓ Release preparation completed"
Write-ColorOutput $Yellow "Ready to publish with '.\make.ps1 publish' or '.\make.ps1 publish-test'"
}
# Main switch
switch ($Target.ToLower()) {
"help" { Show-Help }
"install" { Invoke-Install }
"install-dev" { Invoke-InstallDev }
"setup" { Invoke-Setup }
"build" { Invoke-Build }
"build-wheel" { Invoke-BuildWheel }
"build-sdist" { Invoke-BuildSdist }
"publish" { Invoke-Publish }
"publish-test" { Invoke-PublishTest }
"test" { Invoke-Test }
"test-cov" { Invoke-TestCov }
"test-fast" { Invoke-TestFast }
"lint" { Invoke-Lint }
"lint-fix" { Invoke-LintFix }
"format" { Invoke-Format }
"format-check" { Invoke-FormatCheck }
"type-check" { Invoke-TypeCheck }
"check" { Invoke-Check }
"fix" { Invoke-Fix }
"clean" { Invoke-Clean }
"clean-all" { Invoke-CleanAll }
"run" { Invoke-Run }
"run-dev" { Invoke-RunDev }
"examples" { Invoke-Examples }
"upgrade" { Invoke-Upgrade }
"lock" { Invoke-Lock }
"tree" { Invoke-Tree }
"info" { Invoke-Info }
"env" { Invoke-Env }
"ci" { Invoke-CI }
"release" { Invoke-Release }
default {
Write-ColorOutput $Red "Unknown target: $Target"
Write-Host ""
Show-Help
exit 1
}
}