-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskfile.yml
More file actions
201 lines (177 loc) · 7.1 KB
/
Taskfile.yml
File metadata and controls
201 lines (177 loc) · 7.1 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
version: "3"
vars:
FRONTEND_DIR: frontend
FRONTEND_DIST: "{{.FRONTEND_DIR}}/dist"
VERSION: "{{.GIT_TAG}}"
tasks:
default:
cmds:
- task dev
clean:
desc: Cleans env for local development/CI
cmds:
- |
{{if eq OS "windows"}}
powershell -NoProfile -Command "try { Remove-Item -Recurse -Force -LiteralPath 'build/bin','frontend/node_modules' -ErrorAction Stop } catch { } ; exit 0"
{{else}}
rm -rf build/bin
rm -rf frontend/node_modules
{{end}}
ensure-dist:
desc: Ensure frontend/dist/.gitkeep exists
silent: true
cmds:
- |
{{if eq OS "windows"}}
powershell -NoProfile -Command "New-Item -ItemType Directory -Force -Path '{{.FRONTEND_DIST}}' | Out-Null; New-Item -ItemType File -Force -Path '{{.FRONTEND_DIST}}/.gitkeep' | Out-Null"
{{else}}
mkdir -p "{{.FRONTEND_DIST}}"
: > "{{.FRONTEND_DIST}}/.gitkeep"
{{end}}
dev:
desc: Start Wails dev server
cmds:
- |
{{if eq OS "windows"}}
task wails-dev-win
{{else}}
task wails-run ACTION=dev
{{end}}
build:
desc: Production build
deps:
- ensure-dist
cmds:
- |
{{if eq OS "windows"}}
powershell -NoProfile -Command "try { Remove-Item -Recurse -Force 'build/bin' -ErrorAction Stop } catch { } ; exit 0"
{{else}}
rm -rf build/bin
{{end}}
- |
{{if eq OS "windows"}}
task wails-build-win
{{else}}
task wails-run ACTION=build
{{end}}
test:
desc: Run Go tests
deps:
- ensure-dist
cmds:
- go test ./... -count=1 -coverprofile=cover.out
lint:
desc: Go vet + golangci-lint + optional frontend lint
cmds:
- go vet -unsafeptr=false ./...
- |
{{if eq OS "windows"}}
powershell -NoProfile -Command "if (Get-Command golangci-lint -ErrorAction SilentlyContinue) { golangci-lint run } else { Write-Host 'skipping: golangci-lint not installed' }"
{{else}}
bash -lc 'command -v golangci-lint >/dev/null && golangci-lint run || echo "skipping: golangci-lint not installed"'
{{end}}
- |
cd frontend
{{if eq OS "windows"}}
powershell -NoProfile -Command "if (Test-Path 'package.json') { npm run -s lint --if-present } else { Write-Host 'no frontend dir' }"
{{else}}
bash -lc 'if [ -f "package.json" ] && npm -s run | grep -q "^ lint"; then npm run -s lint; else echo "frontend: no lint script"; fi'
{{end}}
fmt:
desc: Format Go + frontend
cmds:
- |
{{if eq OS "windows"}}
powershell -NoProfile -Command "if (Get-Command gofumpt -ErrorAction SilentlyContinue) { gofumpt -w . } else { gofmt -s -w . }"
{{else}}
bash -lc 'command -v gofumpt >/dev/null && gofumpt -w . || gofmt -s -w .'
{{end}}
- |
cd frontend
{{if eq OS "windows"}}
powershell -NoProfile -Command "if (Test-Path 'package.json') { if (npm -s run | Select-String '^ fmt') { npm run -s fmt } else { npx -y prettier@latest --log-level warn --write '**/*.{ts,tsx,js,jsx,css,scss,html,json,md}' } }"
{{else}}
bash -lc 'if [ -f "package.json" ] && npm -s run | grep -q "^ fmt"; then npm run -s fmt; else npx -y prettier@latest --log-level warn --write "**/*.{ts,tsx,js,jsx,css,scss,html,json,md}"; fi'
{{end}}
# ------------------------------------------------------------
# Shared Wails runner for linux/darwin (computes tags + CGO once)
# Call with: task wails-run ACTION=dev
# task wails-run ACTION=build
# ------------------------------------------------------------
wails-run:
desc: Run Wails with computed tags (linux/darwin)
deps:
- ensure-dist
platforms: [linux, darwin]
vars:
ACTION: '{{.ACTION | default "dev"}}'
CGO_ENABLED:
sh: |
echo 1
# If env WAILS_TAGS is set (e.g. by GHA), use it.
# Otherwise, compute tags dynamically for local dev.
WAILS_TAGS:
sh: |
set -euo pipefail
if [ -n "${WAILS_TAGS+x}" ]; then
# env var exists (may be empty)
echo "${WAILS_TAGS}"
exit 0
fi
# --- dynamic fallback ---
if [ "{{OS}}" != "linux" ]; then
echo ""
exit 0
fi
tags=""
if [ "${XDG_SESSION_TYPE:-}" = "x11" ]; then
tags="x11"
fi
if command -v pkg-config >/dev/null 2>&1; then
if pkg-config --exists webkit2gtk-4.1; then
if [ -n "$tags" ]; then tags="$tags,webkit2_41"; else tags="webkit2_41"; fi
elif pkg-config --exists webkit2gtk-4.0; then
if [ -n "$tags" ]; then tags="$tags,webkit2_40"; else tags="webkit2_40"; fi
fi
fi
echo "$tags"
WAILS_TAG_ARGS:
sh: |
set -euo pipefail
tags='{{.WAILS_TAGS}}'
if [ -n "$tags" ]; then
echo "-tags=$tags"
else
echo ""
fi
cmds:
- |
set -euo pipefail
echo "ACTION={{.ACTION}}"
echo "CGO_ENABLED={{.CGO_ENABLED}}"
echo "WAILS_TAGS={{.WAILS_TAGS}}"
if [ "{{.ACTION}}" = "dev" ]; then
CGO_ENABLED={{.CGO_ENABLED}} wails dev {{.WAILS_TAG_ARGS}}
else
CGO_ENABLED={{.CGO_ENABLED}} wails build -clean {{.WAILS_TAG_ARGS}}
fi
wails-dev-win:
desc: Run wails dev (windows)
deps:
- ensure-dist
platforms: [windows]
cmds:
- wails dev
wails-build-win:
desc: Run wails build (windows)
deps:
- ensure-dist
platforms: [windows]
cmds:
- wails build -clean
package-default-skin:
desc: "Zips all files in SRC_DIR (excluding the folder itself) using Compress-Archive"
vars:
SRC_DIR: '{{.SRC_DIR | default ""}}'
cmds:
- powershell -Command "Compress-Archive -Path '{{.SRC_DIR}}\\*' -DestinationPath '.\skin\default-skin.zip' -Force"