-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
executable file
·229 lines (163 loc) · 5.4 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
BUILD_DIR := "./build"
NPM_DIR := "./node_modules"
SRC_DIR := "./src"
SYSTEM_DIR := "./system"
TEMPORARY_DIR := "./tmp"
default: dev
# Tasks
# =====
@build: clean system css elm js
echo "> Build completed ⚡"
@build-prod: quality clean system css-prod elm-prod js-prod
echo "> Production build completed 🛳"
@clean:
echo "> Cleaning build directory"
rm -rf {{BUILD_DIR}} || true
@css:
echo "> Compiling CSS"
mkdir -p {{BUILD_DIR}}
mkdir -p {{TEMPORARY_DIR}}
{{NPM_DIR}}/.bin/postcss \
"{{SRC_DIR}}/Css/About.css" \
--output "{{BUILD_DIR}}/about.css" \
--config "{{SYSTEM_DIR}}/Css/"
{{NPM_DIR}}/.bin/postcss \
"{{SRC_DIR}}/Css/Application.css" \
--output "{{BUILD_DIR}}/application.css" \
--config "{{SYSTEM_DIR}}/Css/"
@css-prod: css
echo "> Optimizing CSS"
{{NPM_DIR}}/.bin/purgecss \
--config {{SYSTEM_DIR}}/Css/purgecss.about.js \
--output {{BUILD_DIR}}
{{NPM_DIR}}/.bin/purgecss \
--config {{SYSTEM_DIR}}/Css/purgecss.application.js \
--output {{BUILD_DIR}}
{{NPM_DIR}}/.bin/csso \
"{{BUILD_DIR}}/about.css" \
--output "{{BUILD_DIR}}/about.css"
{{NPM_DIR}}/.bin/csso \
"{{BUILD_DIR}}/application.css" \
--output "{{BUILD_DIR}}/application.css"
@elm:
echo "> Compiling Elm application"
elm make {{SRC_DIR}}/Applications/Brain.elm --output {{BUILD_DIR}}/brain.elm.js
elm make {{SRC_DIR}}/Applications/UI.elm --output {{BUILD_DIR}}/ui.elm.js
@elm-prod:
echo "> Compiling Elm application (optimized)"
elm make {{SRC_DIR}}/Applications/Brain.elm --output {{BUILD_DIR}}/brain.elm.js --optimize
elm make {{SRC_DIR}}/Applications/UI.elm --output {{BUILD_DIR}}/ui.elm.js --optimize
{{NPM_DIR}}/.bin/terser {{BUILD_DIR}}/brain.elm.js \
--output {{BUILD_DIR}}/brain.elm.tmp.js \
--compress --mangle
{{NPM_DIR}}/.bin/terser {{BUILD_DIR}}/ui.elm.js \
--output {{BUILD_DIR}}/ui.elm.tmp.js \
--compress --mangle
rm {{BUILD_DIR}}/brain.elm.js
mv {{BUILD_DIR}}/brain.elm.tmp.js {{BUILD_DIR}}/brain.elm.js
rm {{BUILD_DIR}}/ui.elm.js
mv {{BUILD_DIR}}/ui.elm.tmp.js {{BUILD_DIR}}/ui.elm.js
@js: vendor-js
echo "> Compiling Javascript code"
# ...
cp {{NPM_DIR}}/subworkers/subworkers.js {{BUILD_DIR}}/subworkers.js
# Main builds
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/index.js \
--mode none \
--output {{BUILD_DIR}}/ui.js
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Brain/index.js \
--mode none \
--target webworker \
--output {{BUILD_DIR}}/brain.js
# Workers
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Workers/search.js \
--mode none \
--target webworker \
--output {{BUILD_DIR}}/search.js
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Workers/service.js \
--mode none \
--target webworker \
--output {{BUILD_DIR}}/service-worker.js
@js-prod: vendor-js
echo "> Compiling Javascript code (optimized)"
# ...
cp {{NPM_DIR}}/subworkers/subworkers.js {{BUILD_DIR}}/subworkers.js
# Main builds
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/index.js \
--mode production \
--output {{BUILD_DIR}}/ui.js
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Brain/index.js \
--mode production \
--target webworker \
--output {{BUILD_DIR}}/brain.js
# Workers
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Workers/search.js \
--mode production \
--target webworker \
--output {{BUILD_DIR}}/search.js
{{NPM_DIR}}/.bin/webpack-cli \
--entry ./src/Javascript/Workers/service.js \
--mode production \
--target webworker \
--output {{BUILD_DIR}}/service-worker.js
@system:
echo "> Compiling system"
stack build && stack exec build
@vendor-js:
mkdir -p {{BUILD_DIR}}/vendor
cp {{NPM_DIR}}/remotestoragejs/release/remotestorage.js {{BUILD_DIR}}/vendor/remotestorage.min.js
cp {{NPM_DIR}}/blockstack/blockstack.min.js {{BUILD_DIR}}/vendor/blockstack.min.js
{{NPM_DIR}}/.bin/terser {{NPM_DIR}}/pep/elm-pep.js \
--output {{BUILD_DIR}}/vendor/pep.js \
--compress --mangle
#
# Dev tasks
#
@dev: build
just watch-wo-build & 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-housekeeping: reset-elm-css
echo "> Running elm-impfix"
{{NPM_DIR}}/.bin/elm-impfix "{{SRC_DIR}}/**/*.elm" --replace
# echo "> Running elm-review"
{{NPM_DIR}}/.bin/elm-review {{SRC_DIR}} --config system/Review --fix-all
echo "> Running elm-format"
elm-format {{SRC_DIR}} --yes
@quality: reset-elm-css
echo "> Running es-lint"
{{NPM_DIR}}/.bin/eslint src/Javascript/**
echo "> Running elm-review"
{{NPM_DIR}}/.bin/elm-review {{SRC_DIR}} --config system/Review
@reset-elm-css:
# This removes the generated Elm module for the CSS selectors,
# and also the `tmp` dir which is related to that.
rm -rf {{TEMPORARY_DIR}}
rm -f {{SRC_DIR}}/Library/Css/Classes.elm
@server:
echo "> Booting up web server on port 5000"
devd --port 5000 --all --crossdomain --quiet --notfound=301.html {{BUILD_DIR}}
@test: doc-tests
@watch: build watch-wo-build
@watch-wo-build:
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
@watch-elm:
watchexec -p -w {{SRC_DIR}} -e elm -- just elm
@watch-js:
watchexec -p -w {{SRC_DIR}} -e js -- just js
@watch-system:
watchexec -p --ignore *.elm --ignore *.js --ignore *.css -- just system