-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.toml
280 lines (240 loc) · 7.39 KB
/
Makefile.toml
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
[config]
init_task = "init"
default_to_workspace = false
[tasks.init]
description = "Initialization task run before all others"
run_task = { name = ["fnm_use", "npm_install"] }
[tasks.fnm_use]
description = "Run 'fnm use'"
condition.env_not_set = ["CI"]
install_crate = { crate_name = "fnm", binary = "fnm", test_arg = "--help" }
command = "fnm"
args = ["use", "--install-if-missing", "--silent-if-unchanged"]
[tasks.npm_install]
description = "Run 'npm install'"
condition_script = ["which npm"]
condition.files_modified = { input = ["./package.json"], output = [
"./package-lock.json"
] }
condition.env_not_set = ["CI"]
command = "npm"
args = ["install"]
[tasks.default]
alias = "dev"
[tasks.dev]
description = "Run the app and watch CSS on development"
run_task = { name = ["run-pre-build-scripts", "serve-and-watch-css"] }
[tasks.serve-and-watch-css]
description = "Run the app and watch CSS on development"
run_task = { name = ["serve-for-dev", "watch-css"], parallel = true }
[tasks.serve-for-dev]
description = "Serve the app on development"
install_crate = { crate_name = "trunk", binary = "trunk", test_arg = "--help" }
command = "trunk"
args = [
"serve",
"--watch",
".",
"--watch",
"../components",
"--watch",
"../macros",
"--watch",
"../simple-icons",
"--watch",
"../config",
"--ignore",
"./public/assets/js",
]
cwd = "./app"
[tasks.doc]
clear = true
description = "Open components documentation"
command = "cargo"
args = ["doc", "--open", "--no-deps"]
[tasks.format]
clear = true
description = "Format files"
run_task = { name = ["format-rust", "format-prettier"] }
[tasks.lint]
description = "Check format of files and run linters"
run_task = { name = ["lint-prettier", "lint-js", "lint-rust", "lint-css"] }
[tasks.test]
clear = true
description = "Run tests"
command = "npx"
args = ["playwright", "test", "--trace", "on", "${@}"]
cwd = "./end2end"
[tasks.watch-css]
description = "Build CSS with Tailwind on development"
command = "npx"
args = [
"tailwindcss",
"--input",
"./stylesheet.css",
"--output",
"./public/assets/stylesheet.css",
"--watch",
"--no-minify",
]
cwd = "."
[tasks.build]
clear = true
description = "Build the app for production"
install_crate = { crate_name = "trunk", binary = "trunk", test_arg = "--help" }
run_task = { name = [
"run-pre-build-scripts",
"build-css",
"minify-css",
"build-wasm"
] }
[tasks.build-wasm]
description = "Build the WASM app for production"
install_crate = { crate_name = "trunk", binary = "trunk", test_arg = "--help" }
command = "trunk"
args = ["--config", "Trunk.prod.toml", "build", "--release"]
cwd = "./app"
[tasks.build-css]
description = "Build CSS with TailwindCSS for production"
command = "npx"
args = [
"tailwindcss",
"--input",
"./stylesheet.css",
"--output",
"./public/assets/stylesheet.css",
]
cwd = "./app"
[tasks.minify-css]
description = "Minify CSS with LightningCSS"
command = "npx"
args = ["tsx", "scripts/minify-css.ts"]
[tasks.serve-for-prod]
description = "Serve the app with anywhere"
command = "npx"
args = ["anywhere", "-d", "dist"]
cwd = "./app"
[tasks.serve]
description = "Build for production and serve"
run_task = { name = ["build", "serve-for-prod"] }
[tasks.format-rust-code]
description = "Format Rust code with rustfmt"
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all"]
[tasks.clippy]
description = "Run clippy"
install_crate = "clippy"
command = "cargo"
args = ["clippy", "--", "-D", "warnings", "-D", "clippy::print_stdout"]
[tasks.lint-rust]
description = "Lint Rust code"
run_task = { name = [
"clippy",
"rustfmt-check",
"leptosfmt-check",
"cargo-machete"
] }
[tasks.rustfmt-check]
description = "Format Rust code with rustfmt"
install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--all", "--check"]
[tasks.leptosfmt-check]
description = "Check Leptos code format with leptosfmt"
install_crate = "leptosfmt"
command = "leptosfmt"
args = ["--check", "--quiet", "*/src/**/*.rs"]
[tasks.cargo-machete]
description = "Check for outdated dependencies"
install_crate = "cargo-machete"
command = "cargo"
args = ["machete"]
[tasks.format-leptos-code]
description = "Format leptos view! macros"
install_crate = "leptosfmt"
command = "leptosfmt"
args = ["--quiet", "*/src/**/*.rs"]
[tasks.format-rust]
description = "Format Rust code and leptos view! macros"
run_task = { name = ["format-rust-code", "format-leptos-code"] }
[tasks.lint-css]
description = "Lint CSS with stylelint"
command = "npx"
args = [
"stylelint",
"{components,app}/**/*.css",
"--ignore-path",
".prettierignore",
"--config",
"./.stylelintrc.json"
]
[tasks.format-prettier]
description = "Format non Rust files in the project with prettier"
command = "npx"
args = ["prettier", "--write", ".", "--log-level", "warn"]
[tasks.lint-prettier]
description = "Check formatting of non Rust files in the project with prettier"
command = "npx"
args = ["prettier", "--check", "."]
[tasks.lint-js]
description = "Lint JS and TS files in the project with ESLint"
command = "npx"
args = ["eslint", ".", "--ignore-path", ".gitignore"]
[tasks.build-js-libs]
description = "Build JS libraries for the web"
script_runner = "@duckscript"
script = '''
rm -r ./app/public/assets/js
mkdir ./app/public/assets/js
jslibs = set ./app/public/js-libs.html
writefile ${jslibs} ""
# fast-fuzzy
packagejson = readfile node_modules/fast-fuzzy/package.json
fast_fuzzy = json_parse ${packagejson}
exec npx esbuild ./components/src/controls/search/fast-fuzzy.js --bundle --outfile=./app/public/assets/js/fast-fuzzy-${fast_fuzzy.version}.js --minify
appendfile ${jslibs} "<script type=\"module\" src=\"/js/fast-fuzzy-${fast_fuzzy.version}.js\" defer></script>"
# svg-path-bbox
packagejson = readfile node_modules/svg-path-bbox/package.json
svg_path_bbox = json_parse ${packagejson}
exec npx esbuild ./components/src/js_libs/svg-path-bbox.js --bundle --outfile=./app/public/assets/js/svg-path-bbox-${svg_path_bbox.version}.js --minify
appendfile ${jslibs} "<script type=\"module\" src=\"/js/svg-path-bbox-${svg_path_bbox.version}.js\" defer></script>"
# pdfkit
packagejson = readfile node_modules/pdfkit/package.json
pdfkit = json_parse ${packagejson}
cp ./node_modules/pdfkit/js/pdfkit.standalone.js ./app/public/assets/js/pdfkit-${pdfkit.version}.js
# blob-stream
packagejson = readfile node_modules/blob-stream/package.json
blob_stream = json_parse ${packagejson}
cp ./node_modules/blob-stream/.js ./app/public/assets/js/blob-stream-${blob_stream.version}.js
'''
[tasks.copy-fonts]
description = "Copy fonts from @fontsource directory"
script_runner = "@duckscript"
script = '''
rm -r ./app/public/assets/fonts
mkdir ./app/public/assets/fonts
cp ./node_modules/@fontsource/roboto-mono/files/ ./app/public/assets/fonts
cp ./node_modules/@fontsource/open-sans/files/ ./app/public/assets/fonts
'''
[tasks.fetch-deprecated-icons]
description = "Fetch deprecated icons from simple-icons repository"
command = "npx"
args = ["tsx", "scripts/fetch-deprecated-icons.ts"]
[tasks.create-sitemap]
description = "Create sitemap.xml asset"
command = "npx"
args = ["tsx", "scripts/create-sitemap.ts"]
[tasks.create-cname]
description = "Create CNAME"
command = "npx"
args = ["tsx", "scripts/create-cname.ts"]
[tasks.run-pre-build-scripts]
description = "Run pre-build scripts"
run_task = { name = [
"build-js-libs",
"copy-fonts",
"fetch-deprecated-icons",
"create-sitemap",
"create-cname",
], parallel = true }