-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Justfile
237 lines (164 loc) · 6.07 KB
/
Justfile
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
export NODE_NO_WARNINGS := "1"
BUILD_DIR := "./dist"
NPM_DIR := "./node_modules"
SRC_DIR := "./src"
SYSTEM_DIR := "./system"
ESBUILD := "node system/Js/esbuild.mjs"
ELM_REVIEW := NPM_DIR + "/.bin/elm-review " + SRC_DIR + " --config system/Review --compiler " + NPM_DIR + "/.bin/elm --elm-format-path " + NPM_DIR + "/.bin/elm-format"
default: dev
# Tasks
# =====
@build: clean css elm copy-wasm js system license
echo "> Build completed ⚡"
@build-prod: quality clean (css "minify") elm-prod copy-wasm js-prod system license
echo "> Production build completed 🛳"
check-versions:
#!/usr/bin/env node
console.log("> Checking version numbers 🧮")
const pwd = "{{invocation_directory()}}"
const package = require(`${pwd}/package.json`)
const manifest = require(`${pwd}/src/Static/Manifests/manifest.json`)
if (package.version !== manifest.version) {
console.error(`The version from package.json doesn't match the one from the app manifest. The package version is '${package.version}' and the manifest version is '${manifest.version}'.`)
process.exit(1)
}
@clean:
echo "> Cleaning build directory"
rm -rf {{BUILD_DIR}} || true
mkdir -p {{BUILD_DIR}}
@copy-wasm:
echo "> Copying WASM files"
mkdir -p {{BUILD_DIR}}/wasm
cp {{NPM_DIR}}/mediainfo.js/dist/MediaInfoModule.wasm {{BUILD_DIR}}/wasm/media-info.wasm
@css minify="false":
echo "{{ if minify == "minify" { "> Compiling CSS (optimised)" } else { "> Compiling CSS" } }}"
{{NPM_DIR}}/.bin/tailwind \
--input {{SRC_DIR}}/Css/About.css \
--output {{BUILD_DIR}}/about.css \
--content {{SRC_DIR}}/Static/About/**/*.* \
--config {{SYSTEM_DIR}}/Css/Tailwind.js \
--postcss {{SYSTEM_DIR}}/Css/PostCSS.js \
--jit \
{{ if minify == "minify" { "--minify" } else { "" } }}
{{NPM_DIR}}/.bin/tailwind \
--input {{SRC_DIR}}/Css/Application.css \
--output {{BUILD_DIR}}/application.css \
--content "{{SRC_DIR}}/Static/Html/**/*.*,{{SRC_DIR}}/Core/Themes/**/*.elm,{{SRC_DIR}}/Core/UI/**/*.elm,{{SRC_DIR}}/Core/UI.elm,{{SRC_DIR}}/Library/**/*.elm,{{SRC_DIR}}/Javascript/**/*.ts" \
--config {{SYSTEM_DIR}}/Css/Tailwind.js \
--postcss {{SYSTEM_DIR}}/Css/PostCSS.js \
--jit \
{{ if minify == "minify" { "--minify" } else { "" } }}
@elm:
echo "> Compiling Elm application"
{{NPM_DIR}}/.bin/elm make {{SRC_DIR}}/Core/Brain.elm --output {{BUILD_DIR}}/js/brain.elm.js
{{NPM_DIR}}/.bin/elm make {{SRC_DIR}}/Core/UI.elm --output {{BUILD_DIR}}/js/ui.elm.js
@elm-prod:
echo "> Compiling Elm application (optimised)"
{{NPM_DIR}}/.bin/elm make {{SRC_DIR}}/Core/Brain.elm --output {{BUILD_DIR}}/js/brain.elm.js --optimize
{{NPM_DIR}}/.bin/elm make {{SRC_DIR}}/Core/UI.elm --output {{BUILD_DIR}}/js/ui.elm.js --optimize
{{NPM_DIR}}/.bin/esbuild {{BUILD_DIR}}/js/brain.elm.js \
--minify --outfile={{BUILD_DIR}}/js/brain.elm.tmp.js
{{NPM_DIR}}/.bin/esbuild {{BUILD_DIR}}/js/ui.elm.js \
--minify --outfile={{BUILD_DIR}}/js/ui.elm.tmp.js
rm {{BUILD_DIR}}/js/brain.elm.js
mv {{BUILD_DIR}}/js/brain.elm.tmp.js {{BUILD_DIR}}/js/brain.elm.js
rm {{BUILD_DIR}}/js/ui.elm.js
mv {{BUILD_DIR}}/js/ui.elm.tmp.js {{BUILD_DIR}}/js/ui.elm.js
js:
#!/usr/bin/env bash
build_timestamp="`date '+%s'`"
echo "> Compiling Javascript code"
# Workers
{{ESBUILD}} ./src/Javascript/Workers/search.ts \
--outfile={{BUILD_DIR}}/search.js
{{ESBUILD}} ./src/Javascript/Workers/service.ts \
--outfile={{BUILD_DIR}}/service-worker.js \
--define:BUILD_TIMESTAMP=$build_timestamp
{{ESBUILD}} ./src/Javascript/Brain/index.ts \
--outdir={{BUILD_DIR}}/js/brain/ \
--splitting \
--alias:brain.elm.js={{BUILD_DIR}}/js/brain.elm.js \
--inject:./system/Js/node-shims.js \
--alias:node:buffer=buffer/ \
--alias:node:stream=stream
# Main
{{ESBUILD}} ./src/Javascript/UI/index.ts \
--outdir={{BUILD_DIR}}/js/ui/ \
--define:BUILD_TIMESTAMP=$build_timestamp \
--splitting \
--alias:node:buffer=buffer/ \
--alias:node:stream=stream
js-prod:
#!/usr/bin/env bash
build_timestamp="`date '+%s'`"
echo "> Compiling Javascript code (optimised)"
# Workers
{{ESBUILD}} ./src/Javascript/Workers/search.ts \
--minify \
--outfile={{BUILD_DIR}}/search.js
{{ESBUILD}} ./src/Javascript/Workers/service.ts \
--minify \
--outfile={{BUILD_DIR}}/service-worker.js \
--define:BUILD_TIMESTAMP=$build_timestamp
{{ESBUILD}} ./src/Javascript/Brain/index.ts \
--outdir={{BUILD_DIR}}/js/brain/ \
--splitting \
--minify \
--alias:brain.elm.js={{BUILD_DIR}}/js/brain.elm.js \
--inject:./system/Js/node-shims.js \
--alias:node:buffer=buffer/ \
--alias:node:stream=stream
# Main
{{ESBUILD}} ./src/Javascript/UI/index.ts \
--outdir={{BUILD_DIR}}/js/ui/ \
--define:BUILD_TIMESTAMP=$build_timestamp \
--splitting \
--minify \
--alias:node:buffer=buffer/ \
--alias:node:stream=stream
@license:
echo "> Copying license file"
cp LICENSE {{BUILD_DIR}}/LICENSE
@system:
echo "> Compiling system"
{{NPM_DIR}}/.bin/gren make system/Build/Build.gren
node app
rm app
#
# Dev tasks
#
@dev: build
just watch & just server
@doc-tests:
echo "> Running documentation tests"
( cd src && \
find . -name "*.elm" -print0 | \
xargs -0 -n 1 -I % sh -c 'elm-proofread -- % || exit 255; echo "\n\n"' \
)
@elm-format:
echo "> Running elm-format"
{{NPM_DIR}}/.bin/elm-format {{SRC_DIR}} --yes
@elm-housekeeping: elm-format elm-review
@elm-review:
echo "> Running elm-review"
{{ELM_REVIEW}} --fix-all
@quality: check-versions
echo "> Running es-lint"
{{NPM_DIR}}/.bin/eslint src/Javascript/**/*
echo "> Running elm-review"
{{ELM_REVIEW}}
@server:
echo "> Booting up web server on port 8000"
{{NPM_DIR}}/.bin/serve {{BUILD_DIR}} -p 8000 --no-request-logging
@test: doc-tests
@watch:
echo "> Watching"
just watch-css & just watch-elm & just watch-js & just watch-system
@watch-css:
watchexec -p -w {{SRC_DIR}}/Css -w {{SYSTEM_DIR}}/Css -- just css js
@watch-elm:
watchexec -p -w {{SRC_DIR}} -e elm -- just elm js css
@watch-js:
watchexec -p -w {{SRC_DIR}} -e js,ts -- just js
@watch-system:
watchexec -p --ignore *.elm --ignore *.js --ignore *.ts --ignore *.css --ignore src-tauri/** -- just system js