forked from oxc-project/oxc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
executable file
·275 lines (212 loc) · 8.1 KB
/
justfile
File metadata and controls
executable file
·275 lines (212 loc) · 8.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
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
#!/usr/bin/env -S just --justfile
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
set shell := ["bash", "-cu"]
_default:
@just --list -u
# ==================== ALIASES ====================
alias r := ready
alias c := conformance
alias f := fix
# ==================== SETUP & INITIALIZATION ====================
# Initialize the project by installing all necessary tools
init:
# Rust related init
cargo binstall watchexec-cli cargo-insta typos-cli cargo-shear -y
# Node.js related init
pnpm install
# Clone or update submodules
submodules:
.github/scripts/clone-parallel.sh
just update-transformer-fixtures
# Install git pre-commit hook to format files
install-hook:
echo -e "#!/bin/sh\njust fmt" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# ==================== CORE DEVELOPMENT ====================
# When ready, run the same CI commands
ready:
git diff --exit-code --quiet
typos
just fmt
just check
just test
just lint
just doc
just ast
git status
# Run cargo check
check:
cargo ck
# Run all the tests
test:
cargo test --all-features
# Lint the whole project
lint:
cargo lint -- --deny warnings
# Format all files
fmt:
-cargo shear --fix # remove all unused dependencies
cargo fmt
node --run fmt
[unix]
doc:
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
[windows]
doc:
$Env:RUSTDOCFLAGS='-D warnings'; cargo doc --no-deps --document-private-items
# Fix all auto-fixable format and lint issues
fix:
cargo clippy --fix --allow-staged --no-deps
just fmt
typos -w
git status
# ==================== DEVELOPMENT TOOLS ====================
watch *args='':
watchexec --no-vcs-ignore {{args}}
watch-check:
just watch "'cargo check; cargo clippy'"
watch-example *args='':
just watch 'just example {{args}}'
# Run examples in parser, formatter, linter
example tool *args='':
cargo run -p oxc_{{tool}} --example {{tool}} -- {{args}}
# Run the benchmarks
benchmark:
cargo benchmark
# Run benchmarks for a single component
benchmark-one *args:
cargo benchmark --bench {{args}} --no-default-features --features {{ if args == "linter" { "linter" } else { "compiler" } }}
# ==================== TESTING & CONFORMANCE ====================
# Run all conformance tests
coverage:
cargo coverage
cargo run -p oxc_transform_conformance -- --exec
cargo run -p oxc_prettier_conformance
# Run Test262, Babel and TypeScript conformance suite
conformance *args='':
cargo coverage -- {{args}}
# Test ESTree
test-estree *args='':
cargo run -p oxc_coverage --profile coverage -- estree {{args}}
# Get code coverage
codecov:
cargo codecov --html
# ==================== AST & CODEGEN ====================
# Generate AST related boilerplate code.
# If fails first time, run with JS generators disabled first, and then again with JS generators enabled.
# This is necessary because JS generators use `oxc_*` crates (e.g. `oxc_minifier`), and those crates may not compile
# unless Rust code is generated first.
# See: https://github.com/oxc-project/oxc/issues/15564
ast:
cargo run -p oxc_ast_tools || { cargo run -p oxc_ast_tools --no-default-features && cargo run -p oxc_ast_tools; }
# ==================== PARSER ====================
# Parser-specific commands will be added here as needed
# ==================== LINTER ====================
# oxlint release build
oxlint:
cargo build -p oxlint --release --features allocator
# watch oxlint, e.g. `just watch-oxlint test.js`
watch-oxlint *args='':
just watch 'cargo run -p oxlint -- --disable-nested-config {{args}}'
# oxlint release build for node.js
oxlint-node:
pnpm -C apps/oxlint run build
watch-oxlint-node *args='':
just watch 'pnpm run -C apps/oxlint build-dev && node apps/oxlint/dist/cli.js --disable-nested-config {{args}}'
# Create a new lint rule for any plugin
new-rule name plugin='eslint':
cargo run -p rulegen {{name}} {{plugin}}
# Legacy aliases for backward compatibility
new-jest-rule name: (new-rule name "jest")
new-ts-rule name: (new-rule name "typescript")
new-unicorn-rule name: (new-rule name "unicorn")
new-import-rule name: (new-rule name "import")
new-react-rule name: (new-rule name "react")
new-jsx-a11y-rule name: (new-rule name "jsx-a11y")
new-oxc-rule name: (new-rule name "oxc")
new-nextjs-rule name: (new-rule name "nextjs")
new-jsdoc-rule name: (new-rule name "jsdoc")
new-react-perf-rule name: (new-rule name "react-perf")
new-n-rule name: (new-rule name "n")
new-promise-rule name: (new-rule name "promise")
new-vitest-rule name: (new-rule name "vitest")
new-vue-rule name: (new-rule name "vue")
# Alias for backward compatibility
alias new-typescript-rule := new-ts-rule
# ==================== FORMATTER ====================
# oxfmt release build
oxfmt:
cargo build -p oxfmt --release --features allocator
# watch oxfmt, e.g. `just watch-oxfmt test.js`
watch-oxfmt *args='':
just watch 'cargo run -p oxfmt -- {{args}}'
# Build oxfmt in release build
oxfmt-node:
pnpm -C apps/oxfmt run build
watch-oxfmt-node *args='':
just watch 'pnpm run -C apps/oxfmt build-dev && node apps/oxfmt/dist/cli.js {{args}}'
# ==================== TRANSFORMER ====================
# Test Transform
test-transform *args='':
cargo run -p oxc_transform_conformance -- --exec {{args}}
# Update transformer conformance test fixtures
update-transformer-fixtures:
cd tasks/coverage/babel; git reset --hard HEAD; git clean -f -q
node tasks/transform_conformance/update_fixtures.mjs
# ==================== MINIFIER ====================
# Update minifier size snapshots
minsize:
cargo minsize
just allocs
# Update memory allocation snapshots
allocs:
cargo allocs
# Generate minifier size comparison
minifier-diff:
#!/usr/bin/env bash
cargo minsize --compress-only pr
git checkout main
cargo minsize --compress-only main
for file in antd bundle.min d3 echarts jquery lodash moment react.development three typescript victory vue
do
echo $file.js >> diff
diff target/minifier/main/$file.js target/minifier/pr/$file.js >> diff
done
git checkout -
# ==================== PLAYGROUND ====================
# Install wasm32-wasip1-threads for playground
install-wasm:
rustup target add wasm32-wasip1-threads
build-playground:
pnpm --filter oxc-playground build
watch-playground:
just watch 'pnpm --filter oxc-playground build-dev'
# ==================== UTILITIES & ADVANCED ====================
# Generate website documentation, intended for updating the oxc-project.github.io site.
# Path should be the path to your clone of https://github.com/oxc-project/oxc-project.github.io
# When testing changes to the website documentation, you may also want to run `pnpm run fmt`
# in the website directory.
website path:
cargo run -p website_linter rules --table {{path}}/src/docs/guide/usage/linter/generated-rules.md --rule-docs {{path}}/src/docs/guide/usage/linter/rules --git-ref $(git rev-parse HEAD)
cargo run -p website_linter cli > {{path}}/src/docs/guide/usage/linter/generated-cli.md
cargo run -p website_linter schema-markdown > {{path}}/src/docs/guide/usage/linter/generated-config.md
cargo run -p website_formatter cli > {{path}}/src/docs/guide/usage/formatter/generated-cli.md
cargo run -p website_formatter schema-markdown > {{path}}/src/docs/guide/usage/formatter/generated-config.md
# Generate linter schema json for `npm/oxlint/configuration_schema.json`
linter-schema-json:
cargo run -p website_linter schema-json > npm/oxlint/configuration_schema.json
# Automatically DRY up Cargo.toml manifests in a workspace
autoinherit:
cargo binstall cargo-autoinherit
cargo autoinherit
# ==================== PLATFORM HELPERS ====================
[unix]
clone-submodule dir url sha:
cd {{dir}} || git init {{dir}}
cd {{dir}} && git remote add origin {{url}} || true
cd {{dir}} && git fetch --depth=1 origin {{sha}} && git reset --hard {{sha}} && git clean -f -q
[windows]
clone-submodule dir url sha:
if (-not (Test-Path {{dir}}/.git)) { git init {{dir}} }
cd {{dir}} ; if ((git remote) -notcontains 'origin') { git remote add origin {{url}} } else { git remote set-url origin {{url}} }
cd {{dir}} ; git fetch --depth=1 origin {{sha}} ; git reset --hard {{sha}} ; git clean -f -q