@napi-rs/cli 3.0.0-alpha.23 → 3.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/build.js +3 -3
- package/dist/api/build.js.map +1 -1
- package/dist/api/create-npm-dirs.js +8 -5
- package/dist/api/create-npm-dirs.js.map +1 -1
- package/dist/api/new.js +17 -9
- package/dist/api/new.js.map +1 -1
- package/dist/api/pre-publish.js +5 -4
- package/dist/api/pre-publish.js.map +1 -1
- package/dist/api/rename.js +1 -1
- package/dist/api/rename.js.map +1 -1
- package/dist/api/templates/ci-template.d.ts +2 -1
- package/dist/api/templates/ci-template.js +102 -110
- package/dist/api/templates/ci-template.js.map +1 -1
- package/dist/api/templates/ci.yml.d.ts +2 -1
- package/dist/api/templates/ci.yml.js +10 -2
- package/dist/api/templates/ci.yml.js.map +1 -1
- package/dist/api/templates/js-binding.js +15 -0
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/api/templates/load-wasi-template.js.map +1 -0
- package/dist/api/templates/package.json.d.ts +4 -2
- package/dist/api/templates/package.json.js +28 -4
- package/dist/api/templates/package.json.js.map +1 -1
- package/dist/api/templates/wasi-worker-template.js.map +1 -0
- package/dist/api/universalize.js +2 -2
- package/dist/api/universalize.js.map +1 -1
- package/dist/api/version.js +1 -1
- package/dist/api/version.js.map +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/new.js +13 -3
- package/dist/commands/new.js.map +1 -1
- package/dist/def/new.d.ts +22 -4
- package/dist/def/new.js +11 -1
- package/dist/def/new.js.map +1 -1
- package/dist/index.cjs +318 -267
- package/dist/utils/cargo.js +1 -1
- package/dist/utils/cargo.js.map +1 -1
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.js +2 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/metadata.js +2 -2
- package/dist/utils/metadata.js.map +1 -1
- package/dist/utils/misc.d.ts +1 -1
- package/dist/utils/misc.js +3 -3
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/target.d.ts +7 -4
- package/dist/utils/target.js +6 -1
- package/dist/utils/target.js.map +1 -1
- package/package.json +2 -2
- package/src/api/build.ts +3 -3
- package/src/api/create-npm-dirs.ts +9 -5
- package/src/api/new.ts +34 -21
- package/src/api/pre-publish.ts +6 -4
- package/src/api/rename.ts +1 -1
- package/src/api/templates/ci-template.ts +104 -110
- package/src/api/templates/ci.yml.ts +14 -2
- package/src/api/templates/js-binding.ts +15 -0
- package/src/api/templates/package.json.ts +51 -5
- package/src/api/universalize.ts +2 -2
- package/src/api/version.ts +1 -1
- package/src/commands/build.ts +1 -1
- package/src/commands/new.ts +13 -3
- package/src/def/new.ts +27 -2
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +7 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/cargo.ts +1 -1
- package/src/utils/config.ts +16 -0
- package/src/utils/metadata.ts +2 -2
- package/src/utils/misc.ts +11 -3
- package/src/utils/target.ts +9 -2
- package/dist/api/load-wasi-template.js.map +0 -1
- package/dist/api/wasi-worker-template.js.map +0 -1
- /package/dist/api/{load-wasi-template.d.ts → templates/load-wasi-template.d.ts} +0 -0
- /package/dist/api/{load-wasi-template.js → templates/load-wasi-template.js} +0 -0
- /package/dist/api/{wasi-worker-template.d.ts → templates/wasi-worker-template.d.ts} +0 -0
- /package/dist/api/{wasi-worker-template.js → templates/wasi-worker-template.js} +0 -0
- /package/src/api/{load-wasi-template.ts → templates/load-wasi-template.ts} +0 -0
- /package/src/api/{wasi-worker-template.ts → templates/wasi-worker-template.ts} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { SupportedPackageManager } from '../../utils/config.js'
|
|
2
|
+
|
|
3
|
+
export const YAML = (packageManager: SupportedPackageManager) => `
|
|
2
4
|
name: CI
|
|
3
5
|
|
|
4
6
|
env:
|
|
@@ -32,82 +34,53 @@ jobs:
|
|
|
32
34
|
settings:
|
|
33
35
|
- host: macos-latest
|
|
34
36
|
target: 'x86_64-apple-darwin'
|
|
35
|
-
build:
|
|
36
|
-
yarn build --platform
|
|
37
|
-
strip -x *.node
|
|
37
|
+
build: ${packageManager} build --platform
|
|
38
38
|
- host: windows-latest
|
|
39
|
-
build:
|
|
39
|
+
build: ${packageManager} build --platform
|
|
40
40
|
target: 'x86_64-pc-windows-msvc'
|
|
41
41
|
- host: windows-latest
|
|
42
42
|
build: |
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
${packageManager} build --platform --target i686-pc-windows-msvc
|
|
44
|
+
${packageManager} test
|
|
45
45
|
target: 'i686-pc-windows-msvc'
|
|
46
46
|
- host: ubuntu-latest
|
|
47
47
|
target: 'x86_64-unknown-linux-gnu'
|
|
48
|
-
|
|
49
|
-
build: >-
|
|
50
|
-
set -e &&\n
|
|
51
|
-
yarn build --platform --target x86_64-unknown-linux-gnu &&\n
|
|
52
|
-
strip *.node
|
|
48
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-gnu --use-napi-cross
|
|
53
49
|
- host: ubuntu-latest
|
|
54
50
|
target: 'x86_64-unknown-linux-musl'
|
|
55
|
-
|
|
56
|
-
build: >-
|
|
57
|
-
set -e &&
|
|
58
|
-
yarn build --platform &&
|
|
59
|
-
strip *.node
|
|
51
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-musl -x
|
|
60
52
|
- host: macos-latest
|
|
61
53
|
target: 'aarch64-apple-darwin'
|
|
62
|
-
build:
|
|
63
|
-
yarn build --platform --target aarch64-apple-darwin
|
|
64
|
-
strip -x *.node
|
|
54
|
+
build: ${packageManager} build --platform --target aarch64-apple-darwin
|
|
65
55
|
- host: ubuntu-latest
|
|
66
56
|
target: 'aarch64-unknown-linux-gnu'
|
|
67
|
-
|
|
68
|
-
build: >-
|
|
69
|
-
set -e &&\n
|
|
70
|
-
yarn build --platform --target aarch64-unknown-linux-gnu &&\n
|
|
71
|
-
aarch64-unknown-linux-gnu-strip *.node
|
|
57
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-gnu --use-napi-cross
|
|
72
58
|
- host: ubuntu-latest
|
|
73
59
|
target: 'armv7-unknown-linux-gnueabihf'
|
|
74
|
-
|
|
75
|
-
sudo apt-get update
|
|
76
|
-
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
77
|
-
build: |
|
|
78
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
79
|
-
arm-linux-gnueabihf-strip *.node
|
|
60
|
+
build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross
|
|
80
61
|
- host: ubuntu-latest
|
|
81
62
|
target: 'aarch64-linux-android'
|
|
82
|
-
build:
|
|
83
|
-
yarn build --platform --target aarch64-linux-android
|
|
84
|
-
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
63
|
+
build: ${packageManager} build --platform --target aarch64-linux-android
|
|
85
64
|
- host: ubuntu-latest
|
|
86
65
|
target: 'armv7-linux-androideabi'
|
|
87
|
-
build:
|
|
88
|
-
yarn build --platform --target armv7-linux-androideabi
|
|
89
|
-
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
66
|
+
build: ${packageManager} build --platform --target armv7-linux-androideabi
|
|
90
67
|
- host: ubuntu-latest
|
|
91
68
|
target: 'aarch64-unknown-linux-musl'
|
|
92
|
-
|
|
93
|
-
build: >-
|
|
94
|
-
set -e &&\n
|
|
95
|
-
rustup target add aarch64-unknown-linux-musl &&\n
|
|
96
|
-
yarn build --platform --target aarch64-unknown-linux-musl &&\n
|
|
97
|
-
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
|
|
69
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-musl -x
|
|
98
70
|
- host: windows-latest
|
|
99
71
|
target: 'aarch64-pc-windows-msvc'
|
|
100
|
-
build:
|
|
72
|
+
build: ${packageManager} build --platform --target aarch64-pc-windows-msvc
|
|
101
73
|
- host: ubuntu-latest
|
|
102
74
|
target: 'riscv64gc-unknown-linux-gnu'
|
|
103
75
|
setup: |
|
|
104
76
|
sudo apt-get update
|
|
105
77
|
sudo apt-get install gcc-riscv64-linux-gnu -y
|
|
106
|
-
build:
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
build: ${packageManager} build --platform --target riscv64gc-unknown-linux-gnu
|
|
79
|
+
- host: ubuntu-latest
|
|
80
|
+
target: 'wasm32-wasi-preview1-threads'
|
|
81
|
+
build: ${packageManager} build --platform --target wasm32-wasi-preview1-threads
|
|
109
82
|
|
|
110
|
-
name: stable - \${{ matrix.settings.target }} - node@
|
|
83
|
+
name: stable - \${{ matrix.settings.target }} - node@20
|
|
111
84
|
runs-on: \${{ matrix.settings.host }}
|
|
112
85
|
|
|
113
86
|
steps:
|
|
@@ -115,14 +88,12 @@ jobs:
|
|
|
115
88
|
|
|
116
89
|
- name: Setup node
|
|
117
90
|
uses: actions/setup-node@v4
|
|
118
|
-
if: \${{ !matrix.settings.docker }}
|
|
119
91
|
with:
|
|
120
|
-
node-version:
|
|
121
|
-
cache:
|
|
92
|
+
node-version: 20
|
|
93
|
+
cache: ${packageManager}
|
|
122
94
|
|
|
123
95
|
- name: Install
|
|
124
96
|
uses: dtolnay/rust-toolchain@stable
|
|
125
|
-
if: \${{ !matrix.settings.docker }}
|
|
126
97
|
with:
|
|
127
98
|
toolchain: stable
|
|
128
99
|
targets: \${{ matrix.settings.target }}
|
|
@@ -134,12 +105,13 @@ jobs:
|
|
|
134
105
|
~/.cargo/registry/index/
|
|
135
106
|
~/.cargo/registry/cache/
|
|
136
107
|
~/.cargo/git/db/
|
|
108
|
+
~/.napi-rs
|
|
137
109
|
.cargo-cache
|
|
138
110
|
target/
|
|
139
111
|
key: \${{ matrix.settings.target }}-cargo-\${{ matrix.settings.host }}
|
|
140
112
|
|
|
141
113
|
- uses: goto-bus-stop/setup-zig@v2
|
|
142
|
-
if: \${{ matrix.settings.target
|
|
114
|
+
if: \${{ contains(matrix.settings.target, 'musl') }}
|
|
143
115
|
with:
|
|
144
116
|
version: 0.11.0
|
|
145
117
|
|
|
@@ -154,36 +126,35 @@ jobs:
|
|
|
154
126
|
shell: bash
|
|
155
127
|
|
|
156
128
|
- name: 'Install dependencies'
|
|
157
|
-
run:
|
|
129
|
+
run: ${packageManager} install
|
|
158
130
|
|
|
159
131
|
- name: Setup node x86
|
|
160
132
|
uses: actions/setup-node@v4
|
|
161
133
|
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
162
134
|
with:
|
|
163
|
-
node-version:
|
|
164
|
-
cache: yarn
|
|
135
|
+
node-version: 20
|
|
165
136
|
architecture: x86
|
|
166
137
|
|
|
167
|
-
- name: Build in docker
|
|
168
|
-
uses: addnab/docker-run-action@v3
|
|
169
|
-
if: \${{ matrix.settings.docker }}
|
|
170
|
-
with:
|
|
171
|
-
image: \${{ matrix.settings.docker }}
|
|
172
|
-
options: --user 0:0 -v \${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v \${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v \${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v \${{ github.workspace }}:/build -w /build
|
|
173
|
-
run: \${{ matrix.settings.build }}
|
|
174
|
-
|
|
175
138
|
- name: 'Build'
|
|
176
139
|
run: \${{ matrix.settings.build }}
|
|
177
|
-
if: \${{ !matrix.settings.docker }}
|
|
178
140
|
shell: bash
|
|
179
141
|
|
|
180
142
|
- name: Upload artifact
|
|
181
|
-
uses: actions/upload-artifact@
|
|
143
|
+
uses: actions/upload-artifact@v4
|
|
144
|
+
if: matrix.settings.target != 'wasm32-wasi-preview1-threads'
|
|
182
145
|
with:
|
|
183
146
|
name: bindings-\${{ matrix.settings.target }}
|
|
184
147
|
path: "*.node"
|
|
185
148
|
if-no-files-found: error
|
|
186
149
|
|
|
150
|
+
- name: Upload artifact
|
|
151
|
+
uses: actions/upload-artifact@v4
|
|
152
|
+
if: matrix.settings.target == 'wasm32-wasi-preview1-threads'
|
|
153
|
+
with:
|
|
154
|
+
name: bindings-\${{ matrix.settings.target }}
|
|
155
|
+
path: "*.wasm"
|
|
156
|
+
if-no-files-found: error
|
|
157
|
+
|
|
187
158
|
build-freebsd:
|
|
188
159
|
runs-on: macos-12
|
|
189
160
|
name: Build FreeBSD
|
|
@@ -191,7 +162,8 @@ jobs:
|
|
|
191
162
|
- uses: actions/checkout@v4
|
|
192
163
|
- name: Build
|
|
193
164
|
id: build
|
|
194
|
-
uses: cross-platform-actions/action@v0.21.
|
|
165
|
+
uses: cross-platform-actions/action@v0.21.1
|
|
166
|
+
timeout-minutes: 30
|
|
195
167
|
env:
|
|
196
168
|
DEBUG: 'napi:*'
|
|
197
169
|
RUSTUP_IO_THREADS: 1
|
|
@@ -202,9 +174,9 @@ jobs:
|
|
|
202
174
|
cpu_count: 3
|
|
203
175
|
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
|
|
204
176
|
shell: bash
|
|
205
|
-
|
|
177
|
+
run: |
|
|
206
178
|
sudo pkg install -y -f curl node libnghttp2 npm
|
|
207
|
-
sudo npm install -g
|
|
179
|
+
sudo npm install -g ${packageManager} --ignore-scripts
|
|
208
180
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
209
181
|
sh rustup.sh -y --profile minimal --default-toolchain stable
|
|
210
182
|
source "$HOME/.cargo/env"
|
|
@@ -219,15 +191,15 @@ jobs:
|
|
|
219
191
|
whoami
|
|
220
192
|
env
|
|
221
193
|
freebsd-version
|
|
222
|
-
|
|
223
|
-
|
|
194
|
+
${packageManager} install
|
|
195
|
+
${packageManager} build
|
|
224
196
|
strip -x *.node
|
|
225
197
|
yarn test
|
|
226
198
|
rm -rf node_modules
|
|
227
199
|
rm -rf target
|
|
228
200
|
rm -rf .yarn/cache
|
|
229
201
|
- name: Upload artifact
|
|
230
|
-
uses: actions/upload-artifact@
|
|
202
|
+
uses: actions/upload-artifact@v4
|
|
231
203
|
with:
|
|
232
204
|
name: bindings-freebsd
|
|
233
205
|
path: "*.node"
|
|
@@ -255,13 +227,13 @@ jobs:
|
|
|
255
227
|
uses: actions/setup-node@v4
|
|
256
228
|
with:
|
|
257
229
|
node-version: \${{ matrix.node }}
|
|
258
|
-
cache: '
|
|
230
|
+
cache: '${packageManager}'
|
|
259
231
|
|
|
260
232
|
- name: 'Install dependencies'
|
|
261
|
-
run:
|
|
233
|
+
run: ${packageManager} install
|
|
262
234
|
|
|
263
235
|
- name: Download artifacts
|
|
264
|
-
uses: actions/download-artifact@
|
|
236
|
+
uses: actions/download-artifact@v4
|
|
265
237
|
with:
|
|
266
238
|
name: bindings-\${{ matrix.settings.target }}
|
|
267
239
|
path: .
|
|
@@ -271,7 +243,7 @@ jobs:
|
|
|
271
243
|
shell: bash
|
|
272
244
|
|
|
273
245
|
- name: Test bindings
|
|
274
|
-
run:
|
|
246
|
+
run: ${packageManager} test
|
|
275
247
|
|
|
276
248
|
test-linux-x64-gnu-binding:
|
|
277
249
|
name: Test bindings on Linux-x64-gnu - node@\${{ matrix.node }}
|
|
@@ -290,13 +262,13 @@ jobs:
|
|
|
290
262
|
uses: actions/setup-node@v4
|
|
291
263
|
with:
|
|
292
264
|
node-version: \${{ matrix.node }}
|
|
293
|
-
cache: '
|
|
265
|
+
cache: '${packageManager}'
|
|
294
266
|
|
|
295
267
|
- name: 'Install dependencies'
|
|
296
|
-
run:
|
|
268
|
+
run: ${packageManager} install
|
|
297
269
|
|
|
298
270
|
- name: Download artifacts
|
|
299
|
-
uses: actions/download-artifact@
|
|
271
|
+
uses: actions/download-artifact@v4
|
|
300
272
|
with:
|
|
301
273
|
name: bindings-x86_64-unknown-linux-gnu
|
|
302
274
|
path: .
|
|
@@ -330,10 +302,10 @@ jobs:
|
|
|
330
302
|
- name: 'Install dependencies'
|
|
331
303
|
run: |
|
|
332
304
|
yarn config set supportedArchitectures.libc "musl"
|
|
333
|
-
|
|
305
|
+
${packageManager} install
|
|
334
306
|
|
|
335
307
|
- name: Download artifacts
|
|
336
|
-
uses: actions/download-artifact@
|
|
308
|
+
uses: actions/download-artifact@v4
|
|
337
309
|
with:
|
|
338
310
|
name: bindings-x86_64-unknown-linux-musl
|
|
339
311
|
path: .
|
|
@@ -352,14 +324,14 @@ jobs:
|
|
|
352
324
|
strategy:
|
|
353
325
|
fail-fast: false
|
|
354
326
|
matrix:
|
|
355
|
-
node: ['
|
|
327
|
+
node: ['20']
|
|
356
328
|
runs-on: ubuntu-latest
|
|
357
329
|
|
|
358
330
|
steps:
|
|
359
331
|
- uses: actions/checkout@v4
|
|
360
332
|
|
|
361
333
|
- name: Download artifacts
|
|
362
|
-
uses: actions/download-artifact@
|
|
334
|
+
uses: actions/download-artifact@v4
|
|
363
335
|
with:
|
|
364
336
|
name: bindings-aarch64-unknown-linux-gnu
|
|
365
337
|
path: .
|
|
@@ -372,7 +344,7 @@ jobs:
|
|
|
372
344
|
run: |
|
|
373
345
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
374
346
|
yarn config set supportedArchitectures.libc "glibc"
|
|
375
|
-
|
|
347
|
+
${packageManager} install
|
|
376
348
|
|
|
377
349
|
- name: Set up QEMU
|
|
378
350
|
uses: docker/setup-qemu-action@v3
|
|
@@ -385,10 +357,7 @@ jobs:
|
|
|
385
357
|
with:
|
|
386
358
|
image: node:\${{ matrix.node }}-slim
|
|
387
359
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
388
|
-
run:
|
|
389
|
-
set -e
|
|
390
|
-
yarn test
|
|
391
|
-
ls -la
|
|
360
|
+
run: yarn test
|
|
392
361
|
|
|
393
362
|
test-linux-aarch64-musl-binding:
|
|
394
363
|
name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
@@ -405,7 +374,7 @@ jobs:
|
|
|
405
374
|
- uses: actions/checkout@v4
|
|
406
375
|
|
|
407
376
|
- name: Download artifacts
|
|
408
|
-
uses: actions/download-artifact@
|
|
377
|
+
uses: actions/download-artifact@v4
|
|
409
378
|
with:
|
|
410
379
|
name: bindings-aarch64-unknown-linux-musl
|
|
411
380
|
path: .
|
|
@@ -418,7 +387,7 @@ jobs:
|
|
|
418
387
|
run: |
|
|
419
388
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
420
389
|
yarn config set supportedArchitectures.libc "musl"
|
|
421
|
-
|
|
390
|
+
${packageManager} install
|
|
422
391
|
|
|
423
392
|
- name: Set up QEMU
|
|
424
393
|
uses: docker/setup-qemu-action@v3
|
|
@@ -431,9 +400,7 @@ jobs:
|
|
|
431
400
|
with:
|
|
432
401
|
image: node:\${{ matrix.node }}-alpine
|
|
433
402
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
434
|
-
run:
|
|
435
|
-
set -e
|
|
436
|
-
yarn test
|
|
403
|
+
run: yarn test
|
|
437
404
|
|
|
438
405
|
test-linux-arm-gnueabihf-binding:
|
|
439
406
|
name: Test bindings on armv7-unknown-linux-gnueabihf - node@\${{ matrix.node }}
|
|
@@ -449,7 +416,7 @@ jobs:
|
|
|
449
416
|
- uses: actions/checkout@v4
|
|
450
417
|
|
|
451
418
|
- name: Download artifacts
|
|
452
|
-
uses: actions/download-artifact@
|
|
419
|
+
uses: actions/download-artifact@v4
|
|
453
420
|
with:
|
|
454
421
|
name: bindings-armv7-unknown-linux-gnueabihf
|
|
455
422
|
path: .
|
|
@@ -461,7 +428,7 @@ jobs:
|
|
|
461
428
|
- name: Install dependencies
|
|
462
429
|
run: |
|
|
463
430
|
yarn config set supportedArchitectures.cpu "arm"
|
|
464
|
-
|
|
431
|
+
${packageManager} install
|
|
465
432
|
|
|
466
433
|
- name: Set up QEMU
|
|
467
434
|
uses: docker/setup-qemu-action@v3
|
|
@@ -474,10 +441,7 @@ jobs:
|
|
|
474
441
|
with:
|
|
475
442
|
image: node:\${{ matrix.node }}-bullseye-slim
|
|
476
443
|
options: --platform linux/arm/v7 -v \${{ github.workspace }}:/build -w /build
|
|
477
|
-
run:
|
|
478
|
-
set -e
|
|
479
|
-
yarn test
|
|
480
|
-
ls -la
|
|
444
|
+
run: ${packageManager} test
|
|
481
445
|
|
|
482
446
|
universal-macOS:
|
|
483
447
|
name: Build universal macOS binary
|
|
@@ -491,33 +455,62 @@ jobs:
|
|
|
491
455
|
- name: Setup node
|
|
492
456
|
uses: actions/setup-node@v4
|
|
493
457
|
with:
|
|
494
|
-
node-version:
|
|
495
|
-
cache:
|
|
458
|
+
node-version: 20
|
|
459
|
+
cache: ${packageManager}
|
|
496
460
|
|
|
497
461
|
- name: 'Install dependencies'
|
|
498
|
-
run:
|
|
462
|
+
run: ${packageManager} install
|
|
499
463
|
|
|
500
464
|
- name: Download macOS x64 artifact
|
|
501
|
-
uses: actions/download-artifact@
|
|
465
|
+
uses: actions/download-artifact@v4
|
|
502
466
|
with:
|
|
503
467
|
name: bindings-x86_64-apple-darwin
|
|
504
468
|
path: .
|
|
505
469
|
- name: Download macOS arm64 artifact
|
|
506
|
-
uses: actions/download-artifact@
|
|
470
|
+
uses: actions/download-artifact@v4
|
|
507
471
|
with:
|
|
508
472
|
name: bindings-aarch64-apple-darwin
|
|
509
473
|
path: .
|
|
510
474
|
|
|
511
475
|
- name: Combine binaries
|
|
512
|
-
run:
|
|
476
|
+
run: ${packageManager} napi universalize
|
|
513
477
|
|
|
514
478
|
- name: Upload artifact
|
|
515
|
-
uses: actions/upload-artifact@
|
|
479
|
+
uses: actions/upload-artifact@v4
|
|
516
480
|
with:
|
|
517
481
|
name: bindings-universal-apple-darwin
|
|
518
482
|
path: "*.node"
|
|
519
483
|
if-no-files-found: error
|
|
520
484
|
|
|
485
|
+
test-wasi-nodejs:
|
|
486
|
+
name: Test bindings on wasi - node@\${{ matrix.node }}
|
|
487
|
+
needs:
|
|
488
|
+
- build
|
|
489
|
+
strategy:
|
|
490
|
+
fail-fast: false
|
|
491
|
+
matrix:
|
|
492
|
+
node: ['18', '20']
|
|
493
|
+
runs-on: ubuntu-latest
|
|
494
|
+
steps:
|
|
495
|
+
- uses: actions/checkout@v4
|
|
496
|
+
- name: Download artifacts
|
|
497
|
+
uses: actions/download-artifact@v4
|
|
498
|
+
with:
|
|
499
|
+
name: bindings-wasm32-wasi-preview1-threads
|
|
500
|
+
path: .
|
|
501
|
+
- name: List packages
|
|
502
|
+
run: ls -R .
|
|
503
|
+
- uses: actions/setup-node@v4
|
|
504
|
+
with:
|
|
505
|
+
node-version: \${{ matrix.node }}
|
|
506
|
+
cache: ${packageManager}
|
|
507
|
+
- name: 'Install dependencies'
|
|
508
|
+
run: ${packageManager} install
|
|
509
|
+
- name: Test
|
|
510
|
+
run: ${packageManager} test
|
|
511
|
+
env:
|
|
512
|
+
NAPI_RS_FORCE_WASI: true
|
|
513
|
+
|
|
521
514
|
publish:
|
|
522
515
|
name: Publish
|
|
523
516
|
runs-on: ubuntu-latest
|
|
@@ -528,6 +521,7 @@ jobs:
|
|
|
528
521
|
- test-linux-arm-gnueabihf-binding
|
|
529
522
|
- test-macOS-windows-binding
|
|
530
523
|
- test-linux-aarch64-musl-binding
|
|
524
|
+
- test-wasi-nodejs
|
|
531
525
|
- build-freebsd
|
|
532
526
|
|
|
533
527
|
steps:
|
|
@@ -536,15 +530,15 @@ jobs:
|
|
|
536
530
|
- name: Setup node
|
|
537
531
|
uses: actions/setup-node@v4
|
|
538
532
|
with:
|
|
539
|
-
node-version:
|
|
540
|
-
cache: '
|
|
533
|
+
node-version: 20
|
|
534
|
+
cache: '${packageManager}'
|
|
541
535
|
registry-url: 'https://registry.npmjs.org'
|
|
542
536
|
|
|
543
537
|
- name: 'Install dependencies'
|
|
544
|
-
run:
|
|
538
|
+
run: ${packageManager} install
|
|
545
539
|
|
|
546
540
|
- name: Download all artifacts
|
|
547
|
-
uses: actions/download-artifact@
|
|
541
|
+
uses: actions/download-artifact@v4
|
|
548
542
|
with:
|
|
549
543
|
path: artifacts
|
|
550
544
|
|
|
@@ -2,6 +2,7 @@ import { load, dump } from 'js-yaml'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
NodeArchToCpu,
|
|
5
|
+
type SupportedPackageManager,
|
|
5
6
|
UniArchsByPlatform,
|
|
6
7
|
parseTriple,
|
|
7
8
|
} from '../../utils/index.js'
|
|
@@ -15,9 +16,13 @@ const TEST_LINUX_X64_MUSL = 'test-linux-x64-musl-binding'
|
|
|
15
16
|
const TEST_LINUX_AARCH64_GNU = 'test-linux-aarch64-gnu-binding'
|
|
16
17
|
const TEST_LINUX_AARCH64_MUSL = 'test-linux-aarch64-musl-binding'
|
|
17
18
|
const TEST_LINUX_ARM_GNUEABIHF = 'test-linux-arm-gnueabihf-binding'
|
|
19
|
+
const TEST_WASI = 'test-wasi-nodejs'
|
|
18
20
|
const UNIVERSAL_MACOS = 'universal-macOS'
|
|
19
21
|
|
|
20
|
-
export const createGithubActionsCIYml = (
|
|
22
|
+
export const createGithubActionsCIYml = (
|
|
23
|
+
targets: string[],
|
|
24
|
+
packageManager: SupportedPackageManager,
|
|
25
|
+
) => {
|
|
21
26
|
const allTargets = new Set(
|
|
22
27
|
targets.flatMap((t) => {
|
|
23
28
|
const platform = parseTriple(t)
|
|
@@ -31,7 +36,7 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
31
36
|
}),
|
|
32
37
|
)
|
|
33
38
|
|
|
34
|
-
const fullTemplate = load(YAML()) as any
|
|
39
|
+
const fullTemplate = load(YAML(packageManager)) as any
|
|
35
40
|
|
|
36
41
|
const requiredSteps = []
|
|
37
42
|
const enableWindowsX86 = allTargets.has('x86_64-pc-windows-msvc')
|
|
@@ -43,6 +48,7 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
43
48
|
const enableLinuxArm7 = allTargets.has('armv7-unknown-linux-gnueabihf')
|
|
44
49
|
const enableFreeBSD = allTargets.has('x86_64-unknown-freebsd')
|
|
45
50
|
const enableMacOSUni = allTargets.has('universal-apple-darwin')
|
|
51
|
+
const enableWasi = allTargets.has('wasm32-wasi-preview1-threads')
|
|
46
52
|
fullTemplate.jobs.build.strategy.matrix.settings =
|
|
47
53
|
fullTemplate.jobs.build.strategy.matrix.settings.filter(
|
|
48
54
|
({ target }: { target: string }) => allTargets.has(target),
|
|
@@ -111,6 +117,12 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
111
117
|
requiredSteps.push(UNIVERSAL_MACOS)
|
|
112
118
|
}
|
|
113
119
|
|
|
120
|
+
if (!enableWasi) {
|
|
121
|
+
delete fullTemplate.jobs[TEST_WASI]
|
|
122
|
+
} else {
|
|
123
|
+
requiredSteps.push(TEST_WASI)
|
|
124
|
+
}
|
|
125
|
+
|
|
114
126
|
fullTemplate.jobs.publish.needs = requiredSteps
|
|
115
127
|
|
|
116
128
|
return dump(fullTemplate, {
|
|
@@ -311,6 +311,21 @@ switch (platform) {
|
|
|
311
311
|
throw new Error(\`Unsupported OS: \${platform}, architecture: \${arch}\`)
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
315
|
+
try {
|
|
316
|
+
localFileExisted = existsSync(
|
|
317
|
+
join(__dirname, '${localName}.wasm32-wasi.wasm')
|
|
318
|
+
) && existsSync(join(__dirname, '${localName}.wasi.cjs'))
|
|
319
|
+
if (localFileExisted) {
|
|
320
|
+
nativeBinding = require('./${localName}.wasi.cjs')
|
|
321
|
+
} else {
|
|
322
|
+
nativeBinding = require('${pkgName}-wasm32-wasi')
|
|
323
|
+
}
|
|
324
|
+
} catch {
|
|
325
|
+
// ignore
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
314
329
|
if (!nativeBinding) {
|
|
315
330
|
if (loadError) {
|
|
316
331
|
throw loadError
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
CommonPackageJsonFields,
|
|
3
|
+
SupportedTestFramework,
|
|
4
|
+
} from '../../utils/config.js'
|
|
5
|
+
import { UNIVERSAL_TARGETS } from '../../utils/target.js'
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
interface PackageMeta {
|
|
8
|
+
'dist-tags': { [index: string]: string }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const createPackageJson = async ({
|
|
4
12
|
name,
|
|
5
13
|
binaryName,
|
|
6
14
|
targets,
|
|
7
15
|
license,
|
|
8
16
|
engineRequirement,
|
|
9
17
|
cliVersion,
|
|
18
|
+
testFramework,
|
|
10
19
|
}: {
|
|
11
20
|
name: string
|
|
12
21
|
binaryName: string
|
|
@@ -14,10 +23,24 @@ export const createPackageJson = ({
|
|
|
14
23
|
license: string
|
|
15
24
|
engineRequirement: string
|
|
16
25
|
cliVersion: string
|
|
26
|
+
testFramework: SupportedTestFramework
|
|
17
27
|
}) => {
|
|
28
|
+
const hasWasmTarget = targets.some((t) => t.includes('wasm'))
|
|
29
|
+
const universalTargets = targets.filter(
|
|
30
|
+
(t) => t in UNIVERSAL_TARGETS,
|
|
31
|
+
) as (keyof typeof UNIVERSAL_TARGETS)[]
|
|
32
|
+
const unifiedtargets = universalTargets.length
|
|
33
|
+
? targets.filter(
|
|
34
|
+
(target) =>
|
|
35
|
+
!universalTargets.some((t) => {
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
return UNIVERSAL_TARGETS[t].includes(target)
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
: targets
|
|
18
41
|
const content: CommonPackageJsonFields = {
|
|
19
42
|
name,
|
|
20
|
-
version: '
|
|
43
|
+
version: '0.0.0',
|
|
21
44
|
license,
|
|
22
45
|
engines: {
|
|
23
46
|
node: engineRequirement,
|
|
@@ -29,10 +52,10 @@ export const createPackageJson = ({
|
|
|
29
52
|
exports: undefined,
|
|
30
53
|
napi: {
|
|
31
54
|
binaryName,
|
|
32
|
-
targets,
|
|
55
|
+
targets: unifiedtargets,
|
|
33
56
|
},
|
|
34
57
|
scripts: {
|
|
35
|
-
test:
|
|
58
|
+
test: testFramework,
|
|
36
59
|
build: 'napi build --release --platform --strip',
|
|
37
60
|
'build:debug': 'napi build',
|
|
38
61
|
prepublishOnly: 'napi prepublish -t npm',
|
|
@@ -44,5 +67,28 @@ export const createPackageJson = ({
|
|
|
44
67
|
},
|
|
45
68
|
}
|
|
46
69
|
|
|
70
|
+
if (testFramework === 'ava') {
|
|
71
|
+
const avaMeta = await fetch(`https://registry.npmjs.org/ava`).then(
|
|
72
|
+
(res) => res.json() as Promise<PackageMeta>,
|
|
73
|
+
)
|
|
74
|
+
content.devDependencies!['ava'] = `^${avaMeta['dist-tags'].latest}`
|
|
75
|
+
content.ava = {
|
|
76
|
+
timeout: '1m',
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (hasWasmTarget) {
|
|
81
|
+
const emnapiCoreMeta = await fetch(
|
|
82
|
+
`https://registry.npmjs.org/@emnapi/core`,
|
|
83
|
+
).then((res) => res.json() as Promise<PackageMeta>)
|
|
84
|
+
const latest = emnapiCoreMeta['dist-tags'].latest
|
|
85
|
+
content.devDependencies!['@emnapi/core'] = `^${latest}`
|
|
86
|
+
const emnapiRuntimeMeta = await fetch(
|
|
87
|
+
`https://registry.npmjs.org/@emnapi/runtime`,
|
|
88
|
+
).then((res) => res.json() as Promise<PackageMeta>)
|
|
89
|
+
const runtimeLatest = emnapiRuntimeMeta['dist-tags'].latest
|
|
90
|
+
content.devDependencies!['@emnapi/runtime'] = `^${runtimeLatest}`
|
|
91
|
+
}
|
|
92
|
+
|
|
47
93
|
return JSON.stringify(content, null, 2)
|
|
48
94
|
}
|
package/src/api/universalize.ts
CHANGED
package/src/api/version.ts
CHANGED
package/src/commands/build.ts
CHANGED