Skip to content

Commit 033f250

Browse files
committed
feat: init
WIP WIP WIP
0 parents  commit 033f250

142 files changed

Lines changed: 37709 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/clippy.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Be strict but not masochistic
2+
warn = ["clippy::all", "clippy::pedantic"]
3+
4+
# Allow a few pedantic lints that are mostly noise in real code
5+
allow = [
6+
"clippy::module_name_repetitions",
7+
"clippy::missing_errors_doc",
8+
"clippy::missing_panics_doc",
9+
"clippy::must_use_candidate",
10+
"clippy::similar_names",
11+
"clippy::too_many_lines",
12+
"clippy::struct_excessive_bools",
13+
]
14+
15+
# Performance matters
16+
deny = [
17+
"clippy::inefficient_to_string",
18+
"clippy::unnecessary_collect",
19+
"clippy::large_enum_variant",
20+
]
21+
22+
# Style and readability tuning
23+
enum_variant_name_threshold = 3
24+
struct_field_name_threshold = 3
25+
type_complexity_threshold = 250
26+
27+
# Let wider lines exist
28+
too_many_arguments_threshold = 8
29+
max_fn_params_bools = 3
30+
31+
# Avoid annoying false positives
32+
single_char_lifetime_names = false
33+
34+
# Tests are a different universe soooooooo
35+
allow-unwrap-in-tests = true
36+
allow-expect-in-tests = true
37+
38+
# Docs
39+
doc-valid-idents = ["GitHub", "GitLab", "PostgreSQL", "TypeScript", "JavaScript", "WebAssembly"]

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.x86_64-pc-windows-msvc]
2+
rustflags = ["-C", "target-feature=+crt-static"]
3+
4+
[target.i686-pc-windows-msvc]
5+
rustflags = ["-C", "target-feature=+crt-static"]

.cargo/rustfmt.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# require the shorthand instead of it being optional
2+
use_field_init_shorthand = true
3+
newline_style = "Unix"
4+
max_width = 140
5+
chain_width = 100
6+
fn_call_width = 100
7+
# Format string literals where necessary
8+
format_strings = true
9+
# Format macro invocations
10+
format_macro_matchers = true
11+
# Reorder impl items
12+
reorder_impl_items = true
13+
# Format code inside macro declarations
14+
format_macro_bodies = true
15+
# Merge imports with the same prefix
16+
imports_granularity = "Crate"
17+
# Group imports
18+
group_imports = "StdExternalCrate"
19+
# Format type annotations
20+
format_code_in_doc_comments = true
21+
# Format doc comments
22+
doc_comment_code_block_width = 100
23+
# Format comments
24+
comment_width = 100
25+
wrap_comments = true

.github/renovate.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base",
5+
"group:allNonMajor",
6+
":preserveSemverRanges",
7+
":disablePeerDependencies"
8+
],
9+
"labels": ["dependencies"],
10+
"packageRules": [
11+
{
12+
"matchPackageNames": ["@napi/cli", "napi", "napi-build", "napi-derive"],
13+
"addLabels": ["napi-rs"],
14+
"groupName": "napi-rs"
15+
},
16+
{
17+
"matchPackagePatterns": ["^eslint", "^@typescript-eslint"],
18+
"groupName": "linter"
19+
}
20+
],
21+
"commitMessagePrefix": "chore: ",
22+
"commitMessageAction": "bump up",
23+
"commitMessageTopic": "{{depName}} version",
24+
"ignoreDeps": []
25+
}

.github/workflows/CI.yml

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
name: CI
2+
env:
3+
DEBUG: napi:*
4+
APP_NAME: oxc-jsx-dom-expressions
5+
MACOSX_DEPLOYMENT_TARGET: "10.13"
6+
CARGO_INCREMENTAL: "1"
7+
permissions:
8+
contents: write
9+
id-token: write
10+
"on":
11+
push:
12+
branches:
13+
- main
14+
tags-ignore:
15+
- "**"
16+
paths-ignore:
17+
- "**/*.md"
18+
- LICENSE
19+
- "**/*.gitignore"
20+
- .editorconfig
21+
- docs/**
22+
pull_request: null
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
jobs:
27+
lint:
28+
name: Lint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v6
32+
- name: setup pnpm
33+
uses: pnpm/action-setup@v5
34+
- name: Setup node
35+
uses: actions/setup-node@v6
36+
with:
37+
node-version: 22
38+
cache: pnpm
39+
- name: Install
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
components: clippy, rustfmt
43+
- name: Install dependencies
44+
run: pnpm install
45+
- name: Cargo fmt
46+
run: cargo fmt -- --check
47+
- name: Clippy
48+
run: cargo clippy
49+
build:
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
settings:
54+
- host: macos-latest
55+
target: x86_64-apple-darwin
56+
build: pnpm build --target x86_64-apple-darwin
57+
- host: windows-latest
58+
build: pnpm build --target x86_64-pc-windows-msvc
59+
target: x86_64-pc-windows-msvc
60+
- host: ubuntu-latest
61+
target: x86_64-unknown-linux-gnu
62+
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
63+
- host: macos-latest
64+
target: aarch64-apple-darwin
65+
build: pnpm build --target aarch64-apple-darwin
66+
name: stable - ${{ matrix.settings.target }} - node@20
67+
runs-on: ${{ matrix.settings.host }}
68+
steps:
69+
- uses: actions/checkout@v6
70+
- name: setup pnpm
71+
uses: pnpm/action-setup@v5
72+
- name: Setup node
73+
uses: actions/setup-node@v6
74+
with:
75+
node-version: 22
76+
cache: pnpm
77+
- name: Install
78+
uses: dtolnay/rust-toolchain@stable
79+
with:
80+
toolchain: stable
81+
targets: ${{ matrix.settings.target }}
82+
- name: Cache cargo
83+
uses: actions/cache@v5
84+
with:
85+
path: |
86+
~/.cargo/registry/index/
87+
~/.cargo/registry/cache/
88+
~/.cargo/git/db/
89+
~/.napi-rs
90+
.cargo-cache
91+
target/
92+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
93+
- uses: mlugg/setup-zig@v2
94+
if: ${{ contains(matrix.settings.target, 'musl') }}
95+
with:
96+
version: 0.15.2
97+
- name: Install cargo-zigbuild
98+
uses: taiki-e/install-action@v2
99+
if: ${{ contains(matrix.settings.target, 'musl') }}
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}
102+
with:
103+
tool: cargo-zigbuild
104+
- name: Setup toolchain
105+
run: ${{ matrix.settings.setup }}
106+
if: ${{ matrix.settings.setup }}
107+
shell: bash
108+
- name: Install dependencies
109+
run: pnpm install
110+
- name: Setup node x86
111+
uses: actions/setup-node@v6
112+
if: matrix.settings.target == 'i686-pc-windows-msvc'
113+
with:
114+
node-version: 22
115+
cache: pnpm
116+
architecture: x86
117+
- name: Build
118+
run: ${{ matrix.settings.build }}
119+
shell: bash
120+
- name: Upload artifact
121+
uses: actions/upload-artifact@v7
122+
if: matrix.settings.target != 'wasm32-wasip1-threads'
123+
with:
124+
name: bindings-${{ matrix.settings.target }}
125+
path: "*.node"
126+
if-no-files-found: error
127+
- name: Upload artifact
128+
uses: actions/upload-artifact@v7
129+
if: matrix.settings.target == 'wasm32-wasip1-threads'
130+
with:
131+
name: bindings-${{ matrix.settings.target }}
132+
path: "*.wasm"
133+
if-no-files-found: error
134+
test-macOS-windows-binding:
135+
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
136+
needs:
137+
- build
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
settings:
142+
- host: windows-latest
143+
target: x86_64-pc-windows-msvc
144+
architecture: x64
145+
- host: macos-latest
146+
target: x86_64-apple-darwin
147+
architecture: x64
148+
- host: macos-latest
149+
target: aarch64-apple-darwin
150+
architecture: arm64
151+
node:
152+
- "20"
153+
- "22"
154+
runs-on: ${{ matrix.settings.host }}
155+
steps:
156+
- uses: actions/checkout@v6
157+
- name: setup pnpm
158+
uses: pnpm/action-setup@v5
159+
- name: Setup node
160+
uses: actions/setup-node@v6
161+
with:
162+
node-version: ${{ matrix.node }}
163+
cache: pnpm
164+
architecture: ${{ matrix.settings.architecture }}
165+
- name: Install dependencies
166+
run: pnpm install
167+
- name: Download artifacts
168+
uses: actions/download-artifact@v8
169+
with:
170+
name: bindings-${{ matrix.settings.target }}
171+
path: .
172+
- name: List packages
173+
run: ls -R .
174+
shell: bash
175+
- name: Skip JS binding tests
176+
run: node -e "console.log('Skipping JS binding tests')"
177+
test-linux-binding:
178+
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
179+
needs:
180+
- build
181+
strategy:
182+
fail-fast: false
183+
matrix:
184+
target:
185+
- x86_64-unknown-linux-gnu
186+
node:
187+
- "20"
188+
- "22"
189+
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
190+
steps:
191+
- uses: actions/checkout@v6
192+
- name: setup pnpm
193+
uses: pnpm/action-setup@v5
194+
- name: Setup node
195+
uses: actions/setup-node@v6
196+
with:
197+
node-version: ${{ matrix.node }}
198+
cache: pnpm
199+
- name: Output docker params
200+
id: docker
201+
run: |
202+
node -e "
203+
if ('${{ matrix.target }}'.startsWith('aarch64')) {
204+
console.log('PLATFORM=linux/arm64')
205+
} else if ('${{ matrix.target }}'.startsWith('armv7')) {
206+
console.log('PLATFORM=linux/arm/v7')
207+
} else {
208+
console.log('PLATFORM=linux/amd64')
209+
}
210+
" >> $GITHUB_OUTPUT
211+
node -e "
212+
if ('${{ matrix.target }}'.endsWith('-musl')) {
213+
console.log('IMAGE=node:${{ matrix.node }}-alpine')
214+
} else {
215+
console.log('IMAGE=node:${{ matrix.node }}-slim')
216+
}
217+
" >> $GITHUB_OUTPUT
218+
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
219+
- name: Install dependencies
220+
run: pnpm install --force
221+
- name: Download artifacts
222+
uses: actions/download-artifact@v8
223+
with:
224+
name: bindings-${{ matrix.target }}
225+
path: .
226+
- name: List packages
227+
run: ls -R .
228+
shell: bash
229+
- name: Set up QEMU
230+
uses: docker/setup-qemu-action@v4
231+
if: ${{ contains(matrix.target, 'armv7') }}
232+
with:
233+
platforms: all
234+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
235+
if: ${{ contains(matrix.target, 'armv7') }}
236+
- name: Skip JS binding tests
237+
uses: tj-actions/docker-run@v2
238+
with:
239+
image: ${{ steps.docker.outputs.IMAGE }}
240+
name: test-binding
241+
options: "-v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}"
242+
args: node -e "console.log('Skipping JS binding tests')"
243+
publish:
244+
name: Publish
245+
runs-on: ubuntu-latest
246+
needs:
247+
- lint
248+
- test-macOS-windows-binding
249+
- test-linux-binding
250+
steps:
251+
- uses: actions/checkout@v6
252+
- name: setup pnpm
253+
uses: pnpm/action-setup@v5
254+
- name: Setup node
255+
uses: actions/setup-node@v6
256+
with:
257+
node-version: 22
258+
cache: pnpm
259+
- name: Install dependencies
260+
run: pnpm install
261+
- name: Download all artifacts
262+
uses: actions/download-artifact@v8
263+
with:
264+
path: artifacts
265+
- name: create npm dirs
266+
run: pnpm napi create-npm-dirs
267+
- name: Move artifacts
268+
run: pnpm artifacts
269+
- name: List packages
270+
run: ls -R ./npm
271+
shell: bash
272+
- name: Publish
273+
run: |
274+
npm config set provenance true
275+
if git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$";
276+
then
277+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
278+
npm publish --access public
279+
elif git log -1 --pretty=%B | grep "^v\?[0-9]\+\.[0-9]\+\.[0-9]\+";
280+
then
281+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
282+
npm publish --tag next --access public
283+
else
284+
echo "Not a release, skipping publish"
285+
fi
286+
env:
287+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
288+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)