-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (104 loc) · 4.38 KB
/
Makefile
File metadata and controls
125 lines (104 loc) · 4.38 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
.PHONY: run_all run watch test test-server test-frontend lint clean prod_build deps dev_db fmt go_mod_sync
# When not using devcontainer, NVM initialization script may be located in home
# directory. In the devcontainer, it is in /usr/local/share/nvm/.
NVM_SCRIPT := $(shell \
if [ -s "$(HOME)/.nvm/nvm.sh" ]; then \
echo "$(HOME)/.nvm/nvm.sh"; \
elif [ -s "/usr/local/share/nvm/nvm.sh" ]; then \
echo "/usr/local/share/nvm/nvm.sh"; \
else \
echo "Error: nvm.sh not found in either location." >&2; \
exit 1; \
fi)
# Please keep versions in sync
# * package.json
# * all Dockerfiles
# * .github/workflows/main.yml
VUE_FRONTEND_NODE_VERSION := 16
REACT_FRONTEND_NODE_VERSION := 25
PNPM_VERSION := 10.32.1
# Runs the application (builds Vue.js files, starts Next.js dev server, starts Go server).
# As of January 2025, upgrading past Node 16 breaks old Vue dependencies.
run_all:
. $(NVM_SCRIPT) && \
export NEXT_PUBLIC_API_BASE_URL=http://localhost:8080; \
(cd frontend && nvm use $(VUE_FRONTEND_NODE_VERSION) && npm run dev-build); \
(cd frontend-v2 && nvm use $(REACT_FRONTEND_NODE_VERSION) && pnpm dev) &
$(MAKE) run
# Just start the go program without recompiling the JS.
run:
cd server/src && go install # Install first so that we keep cached build objects around.
set -a && . server/debug.env && set +a && \
cd server/src && \
go run main.go
# Builds the frontend Vue JS files.
js:
. $(NVM_SCRIPT) && nvm use $(VUE_FRONTEND_NODE_VERSION) && cd frontend && npm run dev-build
# Automatically rebuilds the Vue JS app when you edit a file. This is
# more convenient then manually running `make run_all` every time you
# update the JS. You'll need to do this in a separate terminal.
watch:
cd frontend && npm run watch
# Wipe and re-create the dev databases. See the readme for more
# details.
dev_db:
cd cli && go run . db create --dev-email="${DXE_DEV_EMAIL:-test-dev@directactioneverywhere.com}"
# Install all deps for this project.
# Note: PNPM must be installed separately for each version of NPM used, since it is installed within each NPM installation.
# Note: `go tool` cannot yet be used to install golang-migrate: https://github.com/golang-migrate/migrate/issues/1232
deps:
. $(NVM_SCRIPT) && nvm i 22 && npm i -g pnpm@$(PNPM_VERSION) && pnpm i
. $(NVM_SCRIPT) && cd frontend && nvm i $(VUE_FRONTEND_NODE_VERSION) && npm i --legacy-peer-deps
. $(NVM_SCRIPT) && cd frontend-v2 && nvm i $(REACT_FRONTEND_NODE_VERSION) && npm i -g pnpm@$(PNPM_VERSION) && pnpm i
cd pkg && go mod download
cd server/src && go mod download
cd cli && go mod download
go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
# Normalize module/workspace metadata across all Go modules. If go.mod/go.sum
# files are still changing after one run, run this target a second time.
go_mod_sync:
cd pkg && GOWORK=off go mod tidy
cd cli && GOWORK=off go mod tidy
cd server/src && GOWORK=off go mod tidy
go work sync
# Run all tests
test: test-server test-frontend
test-server:
cd server/src && go test ./...
test-frontend:
cd frontend-v2 && pnpm test --run
# Run golangci-lint on all Go modules.
# TODO: Run linter automatically once existing lint errors are fixed.
lint:
for mod in pkg cli server/src; do \
(cd $$mod && golangci-lint run ./...) || exit $$?; \
done
# Clean all built outputs
clean:
rm -f cli/adb
rm -f server/adb-server
rm -rf frontend/dist
rm -rf frontend-v2/out
rm -rf frontend-v2/.next
# Set git hooks
set_git_hooks:
if [ ! -h .git/hooks/pre-commit ] ; then ln -s ../../hooks/pre-commit .git/hooks/pre-commit ; fi
if [ ! -h .git/hooks/pre-push ] ; then ln -s ../../hooks/pre-push .git/hooks/pre-push ; fi
# Test docker image
# (Note, --net=host runs the container in the same network as the devcontainer created by the devcontainer's docker-compose config)
docker_run:
docker build . -t dxe/adb
docker container run --rm -p 8080:8080 --net=host -it --name adbtest --env-file docker-debug.env dxe/adb
# Open shell inside docker container while it's running
docker_shell:
docker exec -it adbtest /bin/ash
# Build the project for production.
prod_build:
docker build . -t dxe/adb
docker build . -f Dockerfile.frontend-v2 -t dxe/adb-next
docker build . -f Dockerfile.cli -t dxe/adb-cli
# Reformat source files.
# Keep in sync with hooks/pre-commit.
fmt:
cd server && gofmt -w `find . -name '*.go'`
. $(NVM_SCRIPT) && nvm use 22 && pnpx prettier --write .