Repository navigation
Expand file tree
/
Copy pathdev-tools.ps1
More file actions
144 lines (124 loc) Β· 5.15 KB
/
Copy pathdev-tools.ps1
File metadata and controls
144 lines (124 loc) Β· 5.15 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
# PowerShell script for Edge Mining Development Tools (Windows alternative to Makefile)
param(
[Parameter(Position=0)]
[string]$Command = "help"
)
# Variables
$VENV_PATH = ".venv\Scripts"
$PYTHON = "$VENV_PATH\python.exe"
$PIP = "$VENV_PATH\pip.exe"
$PRE_COMMIT = "$VENV_PATH\pre-commit.exe"
function Show-Help {
Write-Host "Edge Mining Development Tools (PowerShell)" -ForegroundColor Green
Write-Host "==========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Available commands:" -ForegroundColor Yellow
Write-Host " setup - Set up development environment"
Write-Host " install - Install dependencies"
Write-Host " install-dev - Install development dependencies"
Write-Host " format - Format code with ruff"
Write-Host " lint - Run all linting checks"
Write-Host " lint-fix - Run linting and fix what can be auto-fixed"
Write-Host " test - Run tests"
Write-Host " test-cov - Run tests with coverage"
Write-Host " pre-commit - Run pre-commit hooks on all files"
Write-Host " pre-commit-install - Install pre-commit hooks"
Write-Host " clean - Clean cache and temporary files"
Write-Host ""
Write-Host "Usage: .\dev-tools.ps1 <command>" -ForegroundColor Cyan
Write-Host "Example: .\dev-tools.ps1 setup" -ForegroundColor Cyan
}
function Install-Dependencies {
Write-Host "π¦ Installing production dependencies..." -ForegroundColor Blue
& $PIP install -r requirements.txt
Write-Host "β
Production dependencies installed!" -ForegroundColor Green
}
function Install-DevDependencies {
Write-Host "π¦ Installing development dependencies..." -ForegroundColor Blue
& $PIP install -r requirements-dev.txt
Write-Host "β
Development dependencies installed!" -ForegroundColor Green
}
function Setup-Environment {
Install-DevDependencies
Install-PreCommitHooks
Write-Host "β
Development environment setup complete!" -ForegroundColor Green
}
function Format-Code {
Write-Host "π§ Formatting code..." -ForegroundColor Blue
& $PYTHON -m ruff format edge_mining/ tests/
Write-Host "β
Code formatting complete!" -ForegroundColor Green
}
function Run-Lint {
Write-Host "π Running linting checks..." -ForegroundColor Blue
& $PYTHON -m ruff check edge_mining/
& $PYTHON -m mypy edge_mining/
& $PYTHON -m bandit -r edge_mining/ --skip B311,B104
Write-Host "β
Linting complete!" -ForegroundColor Green
}
function Run-LintFix {
Write-Host "π§ Running auto-fixable linting..." -ForegroundColor Blue
& $PYTHON -m ruff check --fix edge_mining/
& $PYTHON -m ruff format edge_mining/
Write-Host "β
Auto-fix complete!" -ForegroundColor Green
}
function Run-Tests {
Write-Host "π§ͺ Running tests..." -ForegroundColor Blue
& $PYTHON -m pytest tests/ -v
Write-Host "β
Tests complete!" -ForegroundColor Green
}
function Run-TestsWithCoverage {
Write-Host "π§ͺ Running tests with coverage..." -ForegroundColor Blue
& $PYTHON -m pytest tests/ -v --cov=edge_mining --cov-report=html --cov-report=term
Write-Host "β
Tests with coverage complete!" -ForegroundColor Green
}
function Run-PreCommit {
Write-Host "π§ Running pre-commit hooks..." -ForegroundColor Blue
& $PRE_COMMIT run --all-files
Write-Host "β
Pre-commit complete!" -ForegroundColor Green
}
function Install-PreCommitHooks {
Write-Host "π§ Installing pre-commit hooks..." -ForegroundColor Blue
& $PRE_COMMIT install
Write-Host "β
Pre-commit hooks installed!" -ForegroundColor Green
}
function Clean-Cache {
Write-Host "π§Ή Cleaning cache and temporary files..." -ForegroundColor Blue
# Remove __pycache__ directories
Get-ChildItem -Path . -Recurse -Directory -Name "__pycache__" | ForEach-Object {
Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue
}
# Remove .pyc and .pyo files
Get-ChildItem -Path . -Recurse -Include "*.pyc", "*.pyo" | Remove-Item -Force -ErrorAction SilentlyContinue
# Remove .egg-info directories
Get-ChildItem -Path . -Recurse -Directory -Name "*.egg-info" | ForEach-Object {
Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue
}
# Remove build and dist directories
@("build", "dist", ".coverage", "htmlcov", ".pytest_cache") | ForEach-Object {
if (Test-Path $_) {
Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue
}
}
Write-Host "β
Cleanup complete!" -ForegroundColor Green
}
# Main command dispatcher
switch ($Command.ToLower()) {
"help" { Show-Help }
"setup" { Setup-Environment }
"install" { Install-Dependencies }
"install-dev" { Install-DevDependencies }
"format" { Format-Code }
"lint" { Run-Lint }
"lint-fix" { Run-LintFix }
"test" { Run-Tests }
"test-cov" { Run-TestsWithCoverage }
"pre-commit" { Run-PreCommit }
"pre-commit-install" { Install-PreCommitHooks }
"clean" { Clean-Cache }
default {
Write-Host "Unknown command: $Command" -ForegroundColor Red
Write-Host ""
Show-Help
exit 1
}
}