11-include .env
22
33ROOT_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST ) ) ) /..)
4- ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
54PROJECT := InsecureWebApp
6- PROJECT_LOWER := $(shell echo $(PROJECT ) | tr '[:upper:]' '[:lower:]' )
7- PROJECTS := $(shell ls . | grep project)
5+ PROJECT_LOWER := $(call tolower, $(PROJECT ) )
6+ PROJECTS := $(filter % project% , $( wildcard * ) )
87VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || echo "1.0.0")
98COMMIT := $(shell git log -1 --pretty=format:"% H")
10- UNAME := $(shell uname)
119
1210FLASK_APP := iwa
1311
@@ -29,12 +27,7 @@ default: help
2927# generate help info from comments
3028.PHONY : help
3129help : # # help information about make commands
32- ifeq ($(OS ) ,Windows_NT)
33- @echo Running on Windows: $(OS)
34- else
35- @echo Running on Linux/UNIX: $(UNAME)
36- endif
37- @grep -h -P '^[a-zA-Z_-]+:.*?# # .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
30+ @python etc/print_makefile_help.py
3831
3932.PHONY : version
4033version : # # display the version of the service
@@ -44,6 +37,7 @@ version: ## display the version of the service
4437build : # # build the project
4538 @echo " Building $( PROJECT) ..."
4639 python -m venv .venv
40+ pip install -U flask
4741ifeq ($(OS ) ,Windows_NT)
4842 cmd /c .\.venv\Scripts\activate.bat
4943 .venv/Scripts/pip install -r requirements.txt
@@ -61,7 +55,7 @@ build-docker: ## build the project as a docker image
6155run : # # run the project
6256 @echo " Running $( PROJECT) ..."
6357ifeq ($(OS ) ,Windows_NT)
64- cmd /C "set FLASK_ENV=development && set FLASK_DEBUG=1 && set FLASK_APP=$(FLASK_APP) && flask run --host 0.0.0.0"
58+ cmd /C ".\.venv\Scripts\activate.bat && set FLASK_ENV=development && set FLASK_DEBUG=1 && set FLASK_APP=$(FLASK_APP) && flask run --host 0.0.0.0"
6559else
6660 FLASK_ENV=development FLASK_DEBUG=1 FLASK_APP=$(FLASK_APP) .venv/bin/flask run --host 0.0.0.0
6761endif
@@ -70,26 +64,27 @@ endif
7064run-production : # # run the project in production mode
7165 @echo " Running $( PROJECT) in production mode..."
7266ifeq ($(OS ) ,Windows_NT)
73- cmd /C "set FLASK_ENV=production && set FLASK_APP=$(FLASK_APP) && flask run --host 0.0.0.0"
67+ cmd /C ".\.venv\Scripts\activate.bat && set FLASK_ENV=production && set FLASK_APP=$(FLASK_APP) && flask run --host 0.0.0.0"
7468else
7569 FLASK_ENV=production FLASK_APP=$(FLASK_APP) .venv/bin/flask run --host 0.0.0.0
7670endif
7771
7872.PHONY : test
7973test : # # run unit tests for the project
8074 @echo " Testing $( PROJECT) ..."
75+ pip install -U pytest
8176ifeq ($(OS ) ,Windows_NT)
82- cmd /C "set FLASK_ENV=development && set FLASK_DEBUG=1 && set FLASK_APP=$(FLASK_APP) && pytest"
77+ cmd /C ".\.venv\Scripts\activate.bat && set FLASK_ENV=development && set FLASK_DEBUG=1 && set FLASK_APP=$(FLASK_APP) && pytest"
8378else
8479 FLASK_ENV=development FLASK_DEBUG=1 FLASK_APP=$(FLASK_APP) .venv/bin/pytest
8580endif
8681
8782.PHONY : clean
8883clean : # # remove temporary files
8984ifeq ($(OS ) ,Windows_NT)
90- cmd /c "rmdir /s /q instance .venv .fortify"
85+ cmd /c "rmdir /s /q instance .venv .fortify bandit-report.html "
9186else
92- rm -rf instance .venv .fortify
87+ rm -rf instance .venv .fortify bandit-report.html
9388endif
9489
9590.PHONY : bandit-scan
0 commit comments