-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (61 loc) · 3.69 KB
/
Makefile
File metadata and controls
71 lines (61 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
default: help
###
## Add these lines to your .zshrc to have autocompletion for make commands
## zstyle ':completion:*:make:*:targets' call-command true
## zstyle ':completion:*:*:make:*' tag-order 'targets'
##
####################################################################################################
## MAIN COMMANDS
####################################################################################################
.PHONY: help
help: ## show this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: test
test: ## Run tests
go run github.com/rakyll/gotest -v -failfast ./...
analyze: ## Run static analyzer
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v2.10.1 golangci-lint run -v
install: ## Make a binary to ./bin folder
go build -o ./bin/mtools ./cmd/mtools/main.go
update-manifest: ## Update the manifest file
go run ./cmd/manifest/main.go
build-testproject: ## Build the example of a project
$(MAKE) install
./bin/mtools init --path=./testproj --name=testproj
./bin/mtools module install --proj-path=./testproj -m "pgx"
./bin/mtools module create --proj-path=./testproj --silent --path=internal --package=example
./bin/mtools db add --proj-path=./testproj --module=example --name=create_table
echo "-- migrate:up" > ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo "CREATE TABLE example (" >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo " id SERIAL PRIMARY KEY," >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo " name TEXT NOT NULL" >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo ");" >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo "-- migrate:down" >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo "DROP TABLE example;" >> ./testproj/internal/example/storage/migration/20241228085104_create_table.sql
echo "-- name: FindExamples :many" > ./testproj/internal/example/storage/query/example.sql
echo "SELECT * FROM example;" >> ./testproj/internal/example/storage/query/example.sql
./bin/mtools db update-sqlc-config --proj-path=./testproj
./bin/mtools db generate --proj-path=./testproj
./bin/mtools db migrate --proj-path=./testproj
./bin/mtools module install --proj-path=./testproj -m "dbmate migrator"
cd ./testproj && go run cmd/console/main.go migrator migrate
./bin/mtools module add-cli --proj-path=./testproj --module=example --name=hello-world
cd ./testproj && go run cmd/console/main.go hello-world
./bin/mtools module install --proj-path=./testproj --manifest="modules.json" -m "chi http"
./bin/mtools module add-json-api --proj-path=./testproj --module=example --uri=/hello-world --name=HelloWorld --method=GET --silent
./bin/mtools module install --proj-path=./testproj --manifest="modules.json" -m "gqlgen"
.PHONY: db-sqlc-generate
db-sqlc-generate: ## Generate sqlc files in all modules
sqlc -f auth/storage/sqlc.yaml generate
.PHONY: db-migrate
db-migrate: ## Run migrations in test database
$(MAKE) install
APP_ENV=test ./bin/mtools db migrate --local-manifest=modules-test.json
.PHONY: db-migrate
db-rollback: ## Rollback the last migration in test database
$(MAKE) install
APP_ENV=test ./bin/mtools db rollback --local-manifest=modules-test.json
.PHONY: translation-extract
translation-extract: ## Extract translations from source code
@echo "Extracting translations..."
go run github.com/go-modulus/xspreak@latest -D ./auth -p ./auth/locales -d auth