-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
125 lines (111 loc) · 4.23 KB
/
Copy pathTaskfile.yml
File metadata and controls
125 lines (111 loc) · 4.23 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
version: "3"
tasks:
agent:sync:
desc: Sync web/package.json to AGENT_VERSION (run after editing that file)
# The script is long; echoing it would bury its own error messages.
silent: true
# AGENT_VERSION is the single source of truth for the appx-agent release, but
# npm resolves dependencies only from package.json, so that one range has to
# be written out. `npm install` alone will NOT do it — it resolves *within*
# the existing range, so a bumped AGENT_VERSION would silently leave the
# frontend on the old major.minor. `npm pkg set` rewrites the range itself.
#
# Caveat on DOWNGRADES: a caret range keeps a satisfying lockfile entry, so
# going 0.1.7 -> ^0.1.6 leaves 0.1.7 installed (it satisfies ^0.1.6). That is
# correct npm behaviour and harmless for the intended forward direction. To
# force an exact older resolution, follow up with:
# cd web && npm install @appx-org/agent-client@<version> --save-exact
cmds:
- |
set -eu
version="$(grep -v '^[[:space:]]*#' AGENT_VERSION | tr -d '[:space:]')"
[ -n "$version" ] || { echo "AGENT_VERSION is empty" >&2; exit 1; }
cd web
# Fail before touching anything if the version isn't published — npm pkg
# set writes package.json immediately, so without this check a typo'd or
# unreleased version leaves the repo half-synced (range bumped, lockfile
# stale, nothing installed).
if ! npm view "@appx-org/agent-client@$version" version >/dev/null 2>&1; then
echo "ERROR: @appx-org/agent-client@$version is not published." >&2
echo " Check AGENT_VERSION against the npm registry:" >&2
echo " npm view @appx-org/agent-client versions" >&2
exit 1
fi
# Restore package.json + lockfile if the install fails partway.
cp package.json .package.json.bak
cp package-lock.json .package-lock.json.bak
restore() {
mv .package.json.bak package.json
mv .package-lock.json.bak package-lock.json
echo "sync failed — restored package.json + lockfile" >&2
}
trap restore EXIT
npm pkg set "dependencies.@appx-org/agent-client=^$version"
npm install
trap - EXIT
rm -f .package.json.bak .package-lock.json.bak
echo "web/package.json + lockfile synced to agent ^$version"
web:
desc: Build frontend and copy to embed directory
cmds:
- cd web && npm install
- cd web && npm run build
- rm -rf cmd/appx/web/dist
- mkdir -p cmd/appx/web
- cp -r web/dist cmd/appx/web/dist
sources:
- web/src/**/*
- web/index.html
- web/package.json
- web/package-lock.json
- web/vite.config.ts
- web/tsconfig*.json
generates:
- cmd/appx/web/dist/**/*
build:
desc: Build frontend and Go binary (use `task build --force` to force a full rebuild)
deps: [web]
env:
GOCACHE: "{{.ROOT_DIR}}/.go-build-cache"
cmds:
- go build -o appx ./cmd/appx
local:
desc: Build and run appx in HTTP dev mode with sslip.io subdomain routing (use `task local --force` to force a full rebuild)
deps: [build]
cmds:
- ./appx --http --host 127.0.0.1.sslip.io
test:
desc: Run all Go tests
env:
GOCACHE: "{{.ROOT_DIR}}/.go-build-cache"
cmds:
- go test ./internal/...
lint:
desc: Lint frontend code
dir: web
cmds:
- npm run lint
clean:
desc: Remove build artifacts
cmds:
- rm -f appx
- rm -rf cmd/appx/web/dist
- rm -rf web/dist
server:bootstrap:
desc: First-time server setup — create users/dirs, install tools, build, start services
cmds:
- sudo ./deploy/bootstrap.sh
server:deploy:
desc: Pull latest, rebuild, install binary, update tools/config, restart services, verify
cmds:
- git pull
- task build
- sudo install -m 750 -o root -g appx ./appx /usr/local/bin/appx
- sudo ./deploy/tools-install.sh
- sudo ./deploy/system-setup.sh
- sudo systemctl restart appx
- sudo ./deploy/verify-installation.sh
server:verify:
desc: Run post-deploy verification suite
cmds:
- sudo ./deploy/verify-installation.sh