|
| 1 | +# Updated Windows Makefile |
| 2 | + |
| 3 | +After analyzing both Makefile versions, here's an updated Windows Makefile that better aligns with the Mac/Linux version. This version includes all the targets and functionality while maintaining Windows compatibility. |
| 4 | + |
| 5 | +```makefile |
| 6 | +.PHONY: init dev lint deploy deploy-watch deploy-version version test coverage |
| 7 | +.DEFAULT_GOAL := help |
| 8 | + |
| 9 | +## @init: Target for initial setup |
| 10 | +init: ## Init the project, install dependencies |
| 11 | + echo %PYTHONPATH% |
| 12 | + python -m pip install -U pip |
| 13 | + python -m pip install poetry |
| 14 | + poetry shell |
| 15 | + poetry install --no-root |
| 16 | + |
| 17 | +## @test: Target for running tests |
| 18 | +test: ## Run tests |
| 19 | + python -m pytest tests/unit/ -v |
| 20 | + |
| 21 | +## @dev: Target for development |
| 22 | +dev: ## Run dev server |
| 23 | + npm run dev |
| 24 | + |
| 25 | +## @lint: Target for linting |
| 26 | +lint: ## Run linting |
| 27 | + pre-commit run --all-files |
| 28 | + npm run lint |
| 29 | + |
| 30 | +## @deploy: Target for deployment |
| 31 | +deploy: ## Deploy service |
| 32 | + npx cdk deploy --all |
| 33 | + |
| 34 | +## @deploy-watch: Target for deployment with watch |
| 35 | +deploy-watch: ## Deploy service with watch |
| 36 | + npx cdk watch --all |
| 37 | + |
| 38 | +## @deploy-version: Target for deployment with version |
| 39 | +deploy-version: ## Deploy with version |
| 40 | + @if "$(version)" == "" ( \ |
| 41 | + echo "Please provide a version" & \ |
| 42 | + exit /b 1 \ |
| 43 | + ) |
| 44 | + echo "Version: $(version)" |
| 45 | + powershell -Command "(Get-Content cdk.json) -Replace '\"service_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"', '\"service_version\": \"$(version)\"' | Set-Content cdk.json.tmp" |
| 46 | + move /Y cdk.json.tmp cdk.json |
| 47 | + |
| 48 | +## @version: Target for versioning |
| 49 | +version: ## Version service |
| 50 | + @if "$(version)" == "" ( \ |
| 51 | + echo "Please provide a version" & \ |
| 52 | + exit /b 1 \ |
| 53 | + ) |
| 54 | + echo "Version: $(version)" |
| 55 | + powershell -Command "(Get-Content cdk.json) -Replace '\"service_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"', '\"service_version\": \"$(version)\"' | Set-Content cdk.json.tmp" |
| 56 | + move /Y cdk.json.tmp cdk.json |
| 57 | + |
| 58 | +## @help: Target for help |
| 59 | +help: ## Show this help |
| 60 | + @echo Usage: make [target] |
| 61 | + @echo. |
| 62 | + @echo Targets: |
| 63 | + @powershell -Command "Get-Content Makefile_windows | Select-String -Pattern '##\s+@(.+):' | ForEach-Object { $_ -replace '##\s+@(.+):\s*(.+)', '$1|$2' } | ForEach-Object { Write-Host (' ' + $_.Split('|')[0]) -ForegroundColor Cyan -NoNewline; Write-Host (' ' + $_.Split('|')[1]) }" |
| 64 | + @echo. |
| 65 | + @echo Detailed help: |
| 66 | + @powershell -Command "Get-Content Makefile_windows | Select-String -Pattern '^[a-zA-Z_-]+:.*?## .*$$' | Sort-Object | ForEach-Object { $_ -replace '^([a-zA-Z_-]+):.*?## (.*)$$', ' $1|$2' } | ForEach-Object { Write-Host (' ' + $_.Split('|')[0].PadRight(30)) -ForegroundColor Cyan -NoNewline; Write-Host (' ' + $_.Split('|')[1]) }" |
| 67 | +``` |
| 68 | + |
| 69 | +## Key Differences Addressed |
| 70 | + |
| 71 | +1. **Added Missing Targets**: |
| 72 | + - Added `dev` target for running the dev server |
| 73 | + - Added `deploy-watch` target for CDK watch functionality |
| 74 | + |
| 75 | +2. **Environment Variables**: |
| 76 | + - Changed `${PYTHONPATH}` to `%PYTHONPATH%` for Windows |
| 77 | + - Changed variable references from `${version}` to `$(version)` which works better in Windows make |
| 78 | + |
| 79 | +3. **Shell Commands**: |
| 80 | + - Replaced Unix-based if-statements with Windows CMD if-statements |
| 81 | + - Replaced `sed` with PowerShell commands for file manipulation |
| 82 | + - Replaced `grep`, `awk`, etc. with PowerShell equivalents for the help target |
| 83 | + |
| 84 | +4. **Python Commands**: |
| 85 | + - Made Python commands consistent with `python -m pip` syntax which is more reliable on Windows |
| 86 | + - Maintained the `--no-root` flag for poetry install for consistency |
| 87 | + |
| 88 | +5. **Help Function**: |
| 89 | + - Created a Windows-compatible version of the help function that provides similar output formatting with PowerShell |
| 90 | + |
| 91 | +This updated Windows Makefile maintains all the functionality of the Linux/Mac version while using Windows-compatible syntax. The help target uses PowerShell to mimic the functionality of the grep/sed/awk commands in the Linux version. |
0 commit comments