Skip to content

Commit cdbfb55

Browse files
feat: add Makefile variants for Windows and Mac/Linux environments
1 parent e315865 commit cdbfb55

File tree

3 files changed

+201
-0
lines changed

3 files changed

+201
-0
lines changed

mac_linux_makefile.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Mac/Linux Makefile Contents
2+
3+
```makefile
4+
.PHONY: init dev lint deploy deploy-watch deploy-version version test coverage
5+
.DEFAULT_GOAL := help
6+
7+
## @init: Target for initial setup
8+
init: ## Init the project, install dependencies
9+
echo ${PYTHONPATH}
10+
pip install -U pip
11+
pip install pipenv
12+
pip install poetry
13+
poetry shell
14+
poetry install --no-root
15+
16+
17+
## @test: Target for running tests
18+
test: ## Run tests
19+
python -m pytest tests/unit/ -v
20+
21+
22+
## @dev: Target for development
23+
dev: ## Run dev server
24+
npm run dev
25+
26+
## @lint: Target for linting
27+
lint: ## Run linting
28+
pre-commit run --all-files
29+
npm run lint
30+
31+
32+
## @deploy: Target for deployment
33+
deploy: ## Deploy service
34+
npx cdk deploy --all
35+
36+
37+
## @deploy-watch: Target for deployment with watch
38+
deploy-watch: ## Deploy service with watch
39+
npx cdk watch --all
40+
41+
42+
## @deploy-version: Target for deployment with version
43+
deploy-version: ## Deploy with version
44+
npx cdk deploy --all --parameters ServiceVersion=${version}
45+
46+
47+
## @version: Target for versioning
48+
version: ## Version service
49+
@if [ -z ${version} ]; then\
50+
echo "Please provide a version";\
51+
exit 1;\
52+
fi
53+
echo "Version: ${version}"
54+
sed -i'.orig' -e 's/"service_version": "[0-9]*\.[0-9]*\.[0-9]*"/"service_version": "${version}"/g' cdk.json
55+
56+
57+
## @help: Target for help
58+
help: ## Show this help
59+
@echo "Usage: make [target]"
60+
@echo ""
61+
@echo "Targets:"
62+
@grep -E '^##\s+@(.+):' $(MAKEFILE_LIST) | sed -e 's/##\s\+\(@.+\): \([^:]*\):/\1|\2/' -E -e 's/^@(.*)/(\\033[36m\1\\033[0m)/' | column -t -s "|"
63+
@echo ""
64+
@echo "Detailed help:"
65+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\\033[36m%-30s\\033[0m %s\n", $$1, $$2}'
66+
```

updated_windows_makefile.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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.

windows_makefile.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Windows Makefile Contents
2+
3+
```makefile
4+
.PHONY: init dev lint deploy deploy-version version test coverage
5+
.DEFAULT_GOAL := help
6+
7+
init: ## Init the project, install dependencies
8+
python3 -m pip install --upgrade pip
9+
pip3 install poetry
10+
poetry install
11+
poetry shell
12+
13+
test: ## Run tests
14+
python -m pytest tests/unit/ -v
15+
16+
lint: ## Run lint
17+
pre-commit run --all-files
18+
npm run lint
19+
20+
deploy: ## Deploy service
21+
npx cdk deploy --all
22+
23+
deploy-version: ## Deploy with version
24+
@if [ -z ${version} ]; then\
25+
echo "Please provide a version";\
26+
exit 1;\
27+
fi
28+
npx cdk deploy --all --parameters ServiceVersion=${version}
29+
30+
version: ## Version service
31+
echo "Version: ${version}"
32+
sed -i'.orig' -e 's/"service_version": "[0-9]*\.[0-9]*\.[0-9]*"/"service_version": "${version}"/g' cdk.json
33+
34+
help:
35+
@echo "Usage: make [target]"
36+
@echo ""
37+
@echo "Targets:"
38+
@echo " init: Init the project, install dependencies"
39+
@echo " test: Run tests"
40+
@echo " lint: Run lint"
41+
@echo " deploy: Deploy service"
42+
@echo " deploy-version: Deploy with version"
43+
@echo " version: Version service"
44+
```

0 commit comments

Comments
 (0)