forked from getfider/fider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (89 loc) · 4.2 KB
/
Makefile
File metadata and controls
139 lines (89 loc) · 4.2 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
## This is a self-documented Makefile. For usage information, run `make help`:
##
## For more information, refer to https://www.thapaliya.com/en/writings/well-documented-makefiles/
LDFLAGS += -X github.com/getfider/fider/app/pkg/env.commithash=${COMMITHASH}
LDFLAGS += -X github.com/getfider/fider/app/pkg/env.version=${VERSION}
##@ Running
run: ## Run Fider
godotenv -f .env ./fider
migrate: ## Run all database migrations
godotenv -f .env ./fider migrate
##@ Building
build: build-server build-ssr build-ui ## Build server and ui
build-server: ## Build server
go build -ldflags '-s -w $(LDFLAGS)' -o fider .
build-ui: ## Build all UI assets
NODE_ENV=production npx webpack-cli
build-ssr: ## Build SSR script and locales
npx lingui extract public/
npx lingui compile
NODE_ENV=production node esbuild.config.js
##@ Localization
locale-extract: ## Extract and overwrite English locale from source code
npx lingui extract --overwrite
locale-reset: ## Reset translation for specific keys in all non-English locales (use KEY="key.name" or KEYS="key1 key2 ...")
@if [ -z "$(KEY)$(KEYS)" ]; then \
echo "Error: KEY or KEYS variable is required."; \
echo "Usage: make locale-reset KEY=\"some.key\""; \
echo " or: make locale-reset KEYS=\"key1 key2 key3\""; \
exit 1; \
fi
@keys="$(KEY) $(KEYS)"; \
echo "Resetting translations for: $$keys"; \
for lang in ar cs de el es-ES fa fr it ja ko nl pl pt-BR ru si-LK sk sv-SE tr zh-CN; do \
echo " Updating $$lang..."; \
temp_file=$$(mktemp); \
jq_expr=""; \
for key in $$keys; do \
if [ -n "$$key" ]; then \
if [ -z "$$jq_expr" ]; then \
jq_expr=".[\""$$key"\"] = \"\""; \
else \
jq_expr="$$jq_expr | .[\""$$key"\"] = \"\""; \
fi; \
fi; \
done; \
jq "$$jq_expr" locale/$$lang/client.json > $$temp_file && \
mv $$temp_file locale/$$lang/client.json; \
done
@echo "Done!"
##@ Testing
test: test-server test-ui ## Test server and ui code
test-server: build-server build-ssr ## Run all server tests (set SHORT=false for full tests including network-dependent tests)
godotenv -f .test.env ./fider migrate
godotenv -f .test.env go test ./... -race $(if $(filter false,$(SHORT)),,-short)
test-ui: ## Run all UI tests
TZ=GMT npx jest ./public
coverage-server: build-server build-ssr ## Run all server tests (with code coverage, set SHORT=false for full tests)
godotenv -f .test.env ./fider migrate
godotenv -f .test.env go test ./... -coverprofile=cover.out -coverpkg=all -p=8 -race $(if $(filter false,$(SHORT)),,-short)
##@ E2E Testing
test-e2e-server: ## Run all E2E tests
npx cucumber-js e2e/features/server/**/*.feature --require-module ts-node/register --require 'e2e/**/*.ts' --publish-quiet
test-e2e-ui: ## Run all E2E tests
npx cucumber-js e2e/features/ui/**/*.feature --require-module ts-node/register --require 'e2e/**/*.ts' --publish-quiet
test-e2e-ui-headed: ## Run all E2E tests with visible browser
HEADED=true npx cucumber-js e2e/features/ui/**/*.feature --require-module ts-node/register --require 'e2e/**/*.ts' --publish-quiet
test-e2e-ui-scenario: ## Run specific E2E test scenario (use NAME="scenario name")
npx cucumber-js e2e/features/ui/**/*.feature --require-module ts-node/register --require 'e2e/**/*.ts' --publish-quiet --name "$(NAME)"
test-e2e-ui-scenario-headed: ## Run specific E2E test scenario with visible browser (use NAME="scenario name")
HEADED=true npx cucumber-js e2e/features/ui/**/*.feature --require-module ts-node/register --require 'e2e/**/*.ts' --publish-quiet --name "$(NAME)"
##@ Running (Watch Mode)
watch:
make -j4 watch-server watch-ui
watch-server: migrate ## Build and run server in watch mode
air -c air.conf
watch-ui: ## Build and run server in watch mode
npx webpack-cli -w
##@ Linting
lint: lint-server lint-ui ## Lint server and ui
lint-server: ## Lint server code
golangci-lint run --timeout 3m
lint-ui: ## Lint ui code
npx eslint .
##@ Miscellaneous
clean: ## Remove all build-generated content
rm -rf ./dist
rm -f ssr.js
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\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)