- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 60
 
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
      
      
            amazon-q-developer
  wants to merge
  2
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
Q-DEV-issue-805-1746506963
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 1 commit
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 | ||
| 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}' | ||
| ``` | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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" | ||
| ``` | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
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