@napi-rs/cli 3.0.0-alpha.8 → 3.0.0-alpha.80
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/cli.mjs +1 -1
- package/dist/api/artifacts.js +28 -7
- package/dist/api/artifacts.js.map +1 -1
- package/dist/api/build.js +309 -64
- package/dist/api/build.js.map +1 -1
- package/dist/api/create-npm-dirs.js +46 -9
- package/dist/api/create-npm-dirs.js.map +1 -1
- package/dist/api/new.js +57 -20
- package/dist/api/new.js.map +1 -1
- package/dist/api/pre-publish.js +9 -7
- package/dist/api/pre-publish.js.map +1 -1
- package/dist/api/rename.js +9 -1
- package/dist/api/rename.js.map +1 -1
- package/dist/api/templates/cargo.toml.js +1 -0
- package/dist/api/templates/cargo.toml.js.map +1 -1
- package/dist/api/templates/ci-template.d.ts +3 -1
- package/dist/api/templates/ci-template.js +140 -125
- package/dist/api/templates/ci-template.js.map +1 -1
- package/dist/api/templates/ci.yml.d.ts +3 -1
- package/dist/api/templates/ci.yml.js +21 -5
- package/dist/api/templates/ci.yml.js.map +1 -1
- package/dist/api/templates/js-binding.d.ts +1 -0
- package/dist/api/templates/js-binding.js +141 -222
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/api/templates/lib.rs.js +1 -4
- package/dist/api/templates/lib.rs.js.map +1 -1
- package/dist/api/templates/load-wasi-template.d.ts +2 -0
- package/dist/api/templates/load-wasi-template.js +168 -0
- package/dist/api/templates/load-wasi-template.js.map +1 -0
- package/dist/api/templates/package.json.d.ts +9 -2
- package/dist/api/templates/package.json.js +26 -4
- package/dist/api/templates/package.json.js.map +1 -1
- package/dist/api/templates/wasi-worker-template.d.ts +2 -0
- package/dist/api/templates/wasi-worker-template.js +122 -0
- package/dist/api/templates/wasi-worker-template.js.map +1 -0
- package/dist/api/universalize.js +5 -5
- package/dist/api/universalize.js.map +1 -1
- package/dist/api/version.js +2 -2
- package/dist/api/version.js.map +1 -1
- package/dist/commands/artifacts.js +2 -2
- package/dist/commands/artifacts.js.map +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/new.js +34 -34
- package/dist/commands/new.js.map +1 -1
- package/dist/def/artifacts.d.ts +21 -1
- package/dist/def/artifacts.js +10 -2
- package/dist/def/artifacts.js.map +1 -1
- package/dist/def/build.d.ts +155 -4
- package/dist/def/build.js +30 -4
- package/dist/def/build.js.map +1 -1
- package/dist/def/create-npm-dirs.d.ts +10 -0
- package/dist/def/create-npm-dirs.js +4 -0
- package/dist/def/create-npm-dirs.js.map +1 -1
- package/dist/def/new.d.ts +25 -7
- package/dist/def/new.js +11 -1
- package/dist/def/new.js.map +1 -1
- package/dist/def/pre-publish.d.ts +12 -2
- package/dist/def/pre-publish.js +7 -3
- package/dist/def/pre-publish.js.map +1 -1
- package/dist/def/rename.d.ts +16 -6
- package/dist/def/rename.js +5 -1
- package/dist/def/rename.js.map +1 -1
- package/dist/def/universalize.d.ts +10 -0
- package/dist/def/universalize.js +4 -0
- package/dist/def/universalize.js.map +1 -1
- package/dist/def/version.d.ts +10 -0
- package/dist/def/version.js +4 -0
- package/dist/def/version.js.map +1 -1
- package/dist/index.cjs +8706 -14649
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/__tests__/config.spec.d.ts +1 -0
- package/dist/utils/__tests__/config.spec.js +63 -0
- package/dist/utils/__tests__/config.spec.js.map +1 -0
- package/dist/utils/__tests__/typegen.spec.js +8 -4
- package/dist/utils/__tests__/typegen.spec.js.map +1 -1
- package/dist/utils/cargo.js +2 -2
- package/dist/utils/cargo.js.map +1 -1
- package/dist/utils/config.d.ts +52 -4
- package/dist/utils/config.js +37 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/metadata.d.ts +12 -0
- package/dist/utils/metadata.js +21 -10
- package/dist/utils/metadata.js.map +1 -1
- package/dist/utils/misc.d.ts +1 -2
- package/dist/utils/misc.js +3 -3
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/target.d.ts +7 -5
- package/dist/utils/target.js +17 -3
- package/dist/utils/target.js.map +1 -1
- package/dist/utils/typegen.d.ts +1 -1
- package/dist/utils/typegen.js +55 -20
- package/dist/utils/typegen.js.map +1 -1
- package/dist/utils/version.d.ts +2 -1
- package/dist/utils/version.js +10 -8
- package/dist/utils/version.js.map +1 -1
- package/package.json +27 -26
- package/src/api/artifacts.ts +81 -9
- package/src/api/build.ts +467 -87
- package/src/api/create-npm-dirs.ts +57 -9
- package/src/api/new.ts +89 -31
- package/src/api/pre-publish.ts +13 -7
- package/src/api/rename.ts +10 -1
- package/src/api/templates/cargo.toml.ts +1 -0
- package/src/api/templates/ci-template.ts +150 -125
- package/src/api/templates/ci.yml.ts +27 -6
- package/src/api/templates/js-binding.ts +147 -220
- package/src/api/templates/lib.rs.ts +1 -4
- package/src/api/templates/load-wasi-template.ts +182 -0
- package/src/api/templates/package.json.ts +47 -5
- package/src/api/templates/wasi-worker-template.ts +122 -0
- package/src/api/universalize.ts +13 -8
- package/src/api/version.ts +5 -2
- package/src/commands/artifacts.ts +2 -2
- package/src/commands/build.ts +1 -1
- package/src/commands/new.ts +46 -45
- package/src/def/artifacts.ts +22 -3
- package/src/def/build.ts +64 -8
- package/src/def/create-npm-dirs.ts +9 -0
- package/src/def/new.ts +28 -3
- package/src/def/pre-publish.ts +12 -3
- package/src/def/rename.ts +11 -2
- package/src/def/universalize.ts +9 -0
- package/src/def/version.ts +9 -0
- package/src/index.ts +2 -0
- package/src/utils/__tests__/__fixtures__/napi_type_def +130 -130
- package/src/utils/__tests__/__snapshots__/config.spec.ts.md +97 -0
- package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +28 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +711 -158
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +8 -7
- package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
- package/src/utils/__tests__/config.spec.ts +81 -0
- package/src/utils/__tests__/typegen.spec.ts +18 -3
- package/src/utils/cargo.ts +2 -2
- package/src/utils/config.ts +116 -10
- package/src/utils/index.ts +0 -1
- package/src/utils/metadata.ts +38 -13
- package/src/utils/misc.ts +11 -3
- package/src/utils/target.ts +22 -4
- package/src/utils/typegen.ts +98 -49
- package/src/utils/version.ts +10 -8
- package/dist/api/load-wasi-template.d.ts +0 -1
- package/dist/api/load-wasi-template.js +0 -64
- package/dist/api/load-wasi-template.js.map +0 -1
- package/dist/api/wasi-worker-template.d.ts +0 -1
- package/dist/api/wasi-worker-template.js +0 -53
- package/dist/api/wasi-worker-template.js.map +0 -1
- package/dist/utils/ci.d.ts +0 -11
- package/dist/utils/ci.js +0 -96
- package/dist/utils/ci.js.map +0 -1
- package/src/api/load-wasi-template.ts +0 -66
- package/src/api/wasi-worker-template.ts +0 -52
- package/src/utils/ci.ts +0 -111
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import type { SupportedPackageManager } from '../../utils/config.js'
|
|
2
|
+
|
|
3
|
+
export type WasiTargetName =
|
|
4
|
+
| 'wasm32-wasi-preview1-threads'
|
|
5
|
+
| 'wasm32-wasip1-threads'
|
|
6
|
+
| 'wasm32-wasip2'
|
|
7
|
+
|
|
8
|
+
export const YAML = (
|
|
9
|
+
packageManager: SupportedPackageManager,
|
|
10
|
+
wasiTargetName: WasiTargetName,
|
|
11
|
+
) => `
|
|
2
12
|
name: CI
|
|
3
13
|
|
|
4
14
|
env:
|
|
@@ -32,82 +42,68 @@ jobs:
|
|
|
32
42
|
settings:
|
|
33
43
|
- host: macos-latest
|
|
34
44
|
target: 'x86_64-apple-darwin'
|
|
35
|
-
build:
|
|
36
|
-
yarn build --platform
|
|
37
|
-
strip -x *.node
|
|
45
|
+
build: ${packageManager} build --platform --target x86_64-apple-darwin
|
|
38
46
|
- host: windows-latest
|
|
39
|
-
build:
|
|
47
|
+
build: ${packageManager} build --platform
|
|
40
48
|
target: 'x86_64-pc-windows-msvc'
|
|
41
49
|
- host: windows-latest
|
|
42
50
|
build: |
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
${packageManager} build --platform --target i686-pc-windows-msvc
|
|
52
|
+
${packageManager} test
|
|
45
53
|
target: 'i686-pc-windows-msvc'
|
|
46
54
|
- host: ubuntu-latest
|
|
47
55
|
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
|
|
56
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-gnu --use-napi-cross
|
|
53
57
|
- host: ubuntu-latest
|
|
54
58
|
target: 'x86_64-unknown-linux-musl'
|
|
55
|
-
|
|
56
|
-
build: >-
|
|
57
|
-
set -e &&
|
|
58
|
-
yarn build --platform &&
|
|
59
|
-
strip *.node
|
|
59
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-musl -x
|
|
60
60
|
- host: macos-latest
|
|
61
61
|
target: 'aarch64-apple-darwin'
|
|
62
|
-
build:
|
|
63
|
-
yarn build --platform --target aarch64-apple-darwin
|
|
64
|
-
strip -x *.node
|
|
62
|
+
build: ${packageManager} build --platform --target aarch64-apple-darwin
|
|
65
63
|
- host: ubuntu-latest
|
|
66
64
|
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
|
|
65
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-gnu --use-napi-cross
|
|
72
66
|
- host: ubuntu-latest
|
|
73
67
|
target: 'armv7-unknown-linux-gnueabihf'
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
build:
|
|
78
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
79
|
-
arm-linux-gnueabihf-strip *.node
|
|
68
|
+
build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross
|
|
69
|
+
- host: ubuntu-latest
|
|
70
|
+
target: 'armv7-unknown-linux-musleabihf'
|
|
71
|
+
build: ${packageManager} build --platform --target armv7-unknown-linux-musleabihf -x
|
|
80
72
|
- host: ubuntu-latest
|
|
81
73
|
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
|
|
74
|
+
build: ${packageManager} build --platform --target aarch64-linux-android
|
|
85
75
|
- host: ubuntu-latest
|
|
86
76
|
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
|
|
77
|
+
build: ${packageManager} build --platform --target armv7-linux-androideabi
|
|
90
78
|
- host: ubuntu-latest
|
|
91
79
|
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
|
|
80
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-musl -x
|
|
98
81
|
- host: windows-latest
|
|
99
82
|
target: 'aarch64-pc-windows-msvc'
|
|
100
|
-
build:
|
|
83
|
+
build: ${packageManager} build --platform --target aarch64-pc-windows-msvc
|
|
101
84
|
- host: ubuntu-latest
|
|
102
85
|
target: 'riscv64gc-unknown-linux-gnu'
|
|
103
86
|
setup: |
|
|
104
87
|
sudo apt-get update
|
|
105
88
|
sudo apt-get install gcc-riscv64-linux-gnu -y
|
|
106
|
-
build:
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
build: ${packageManager} build --platform --target riscv64gc-unknown-linux-gnu
|
|
90
|
+
- host: ubuntu-latest
|
|
91
|
+
target: 'powerpc64le-unknown-linux-gnu'
|
|
92
|
+
setup: |
|
|
93
|
+
sudo apt-get update
|
|
94
|
+
sudo apt-get install gcc-powerpc64le-linux-gnu -y
|
|
95
|
+
build: ${packageManager} build --platform --target powerpc64le-unknown-linux-gnu
|
|
96
|
+
- host: ubuntu-latest
|
|
97
|
+
target: 's390x-unknown-linux-gnu'
|
|
98
|
+
setup: |
|
|
99
|
+
sudo apt-get update
|
|
100
|
+
sudo apt-get install gcc-s390x-linux-gnu -y
|
|
101
|
+
build: ${packageManager} build --platform --target s390x-unknown-linux-gnu
|
|
102
|
+
- host: ubuntu-latest
|
|
103
|
+
target: '${wasiTargetName}'
|
|
104
|
+
build: ${packageManager} build --platform --target ${wasiTargetName}
|
|
109
105
|
|
|
110
|
-
name: stable - \${{ matrix.settings.target }} - node@
|
|
106
|
+
name: stable - \${{ matrix.settings.target }} - node@20
|
|
111
107
|
runs-on: \${{ matrix.settings.host }}
|
|
112
108
|
|
|
113
109
|
steps:
|
|
@@ -115,33 +111,40 @@ jobs:
|
|
|
115
111
|
|
|
116
112
|
- name: Setup node
|
|
117
113
|
uses: actions/setup-node@v4
|
|
118
|
-
if: \${{ !matrix.settings.docker }}
|
|
119
114
|
with:
|
|
120
|
-
node-version:
|
|
121
|
-
cache:
|
|
115
|
+
node-version: 20
|
|
116
|
+
cache: ${packageManager}
|
|
122
117
|
|
|
123
118
|
- name: Install
|
|
124
119
|
uses: dtolnay/rust-toolchain@stable
|
|
125
|
-
if: \${{ !matrix.settings.docker }}
|
|
126
120
|
with:
|
|
127
121
|
toolchain: stable
|
|
128
122
|
targets: \${{ matrix.settings.target }}
|
|
129
123
|
|
|
130
124
|
- name: Cache cargo
|
|
131
|
-
uses: actions/cache@
|
|
125
|
+
uses: actions/cache@v4
|
|
132
126
|
with:
|
|
133
127
|
path: |
|
|
134
128
|
~/.cargo/registry/index/
|
|
135
129
|
~/.cargo/registry/cache/
|
|
136
130
|
~/.cargo/git/db/
|
|
131
|
+
~/.napi-rs
|
|
137
132
|
.cargo-cache
|
|
138
133
|
target/
|
|
139
134
|
key: \${{ matrix.settings.target }}-cargo-\${{ matrix.settings.host }}
|
|
140
135
|
|
|
141
136
|
- uses: goto-bus-stop/setup-zig@v2
|
|
142
|
-
if: \${{ matrix.settings.target
|
|
137
|
+
if: \${{ contains(matrix.settings.target, 'musl') }}
|
|
138
|
+
with:
|
|
139
|
+
version: 0.13.0
|
|
140
|
+
|
|
141
|
+
- name: Install cargo-zigbuild
|
|
142
|
+
uses: taiki-e/install-action@v2
|
|
143
|
+
if: \${{ contains(matrix.settings.target, 'musl') }}
|
|
144
|
+
env:
|
|
145
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
143
146
|
with:
|
|
144
|
-
|
|
147
|
+
tool: cargo-zigbuild
|
|
145
148
|
|
|
146
149
|
- name: Setup toolchain
|
|
147
150
|
run: \${{ matrix.settings.setup }}
|
|
@@ -154,57 +157,56 @@ jobs:
|
|
|
154
157
|
shell: bash
|
|
155
158
|
|
|
156
159
|
- name: 'Install dependencies'
|
|
157
|
-
run:
|
|
160
|
+
run: ${packageManager} install
|
|
158
161
|
|
|
159
162
|
- name: Setup node x86
|
|
160
163
|
uses: actions/setup-node@v4
|
|
161
164
|
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
162
165
|
with:
|
|
163
|
-
node-version:
|
|
164
|
-
cache: yarn
|
|
166
|
+
node-version: 20
|
|
165
167
|
architecture: x86
|
|
166
168
|
|
|
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
169
|
- name: 'Build'
|
|
176
170
|
run: \${{ matrix.settings.build }}
|
|
177
|
-
if: \${{ !matrix.settings.docker }}
|
|
178
171
|
shell: bash
|
|
179
172
|
|
|
180
173
|
- name: Upload artifact
|
|
181
|
-
uses: actions/upload-artifact@
|
|
174
|
+
uses: actions/upload-artifact@v4
|
|
175
|
+
if: matrix.settings.target != '${wasiTargetName}'
|
|
182
176
|
with:
|
|
183
177
|
name: bindings-\${{ matrix.settings.target }}
|
|
184
178
|
path: "*.node"
|
|
185
179
|
if-no-files-found: error
|
|
186
180
|
|
|
181
|
+
- name: Upload artifact
|
|
182
|
+
uses: actions/upload-artifact@v4
|
|
183
|
+
if: matrix.settings.target == '${wasiTargetName}'
|
|
184
|
+
with:
|
|
185
|
+
name: bindings-\${{ matrix.settings.target }}
|
|
186
|
+
path: "*.wasm"
|
|
187
|
+
if-no-files-found: error
|
|
188
|
+
|
|
187
189
|
build-freebsd:
|
|
188
|
-
runs-on:
|
|
190
|
+
runs-on: ubuntu-latest
|
|
189
191
|
name: Build FreeBSD
|
|
190
192
|
steps:
|
|
191
193
|
- uses: actions/checkout@v4
|
|
192
194
|
- name: Build
|
|
193
195
|
id: build
|
|
194
|
-
uses: cross-platform-actions/action@v0.
|
|
196
|
+
uses: cross-platform-actions/action@v0.25.0
|
|
195
197
|
env:
|
|
196
198
|
DEBUG: 'napi:*'
|
|
197
199
|
RUSTUP_IO_THREADS: 1
|
|
198
200
|
with:
|
|
199
201
|
operating_system: freebsd
|
|
200
|
-
version: '
|
|
201
|
-
memory:
|
|
202
|
+
version: '14.1'
|
|
203
|
+
memory: 8G
|
|
202
204
|
cpu_count: 3
|
|
203
205
|
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
|
|
204
206
|
shell: bash
|
|
205
|
-
|
|
207
|
+
run: |
|
|
206
208
|
sudo pkg install -y -f curl node libnghttp2 npm
|
|
207
|
-
sudo npm install -g
|
|
209
|
+
sudo npm install -g ${packageManager} --ignore-scripts
|
|
208
210
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
209
211
|
sh rustup.sh -y --profile minimal --default-toolchain stable
|
|
210
212
|
source "$HOME/.cargo/env"
|
|
@@ -219,15 +221,15 @@ jobs:
|
|
|
219
221
|
whoami
|
|
220
222
|
env
|
|
221
223
|
freebsd-version
|
|
222
|
-
|
|
223
|
-
|
|
224
|
+
${packageManager} install
|
|
225
|
+
${packageManager} build
|
|
224
226
|
strip -x *.node
|
|
225
227
|
yarn test
|
|
226
228
|
rm -rf node_modules
|
|
227
229
|
rm -rf target
|
|
228
230
|
rm -rf .yarn/cache
|
|
229
231
|
- name: Upload artifact
|
|
230
|
-
uses: actions/upload-artifact@
|
|
232
|
+
uses: actions/upload-artifact@v4
|
|
231
233
|
with:
|
|
232
234
|
name: bindings-freebsd
|
|
233
235
|
path: "*.node"
|
|
@@ -243,9 +245,13 @@ jobs:
|
|
|
243
245
|
settings:
|
|
244
246
|
- host: macos-latest
|
|
245
247
|
target: 'x86_64-apple-darwin'
|
|
248
|
+
architecture: x64
|
|
249
|
+
- host: macos-latest
|
|
250
|
+
target: 'aarch64-apple-darwin'
|
|
251
|
+
architecture: arm64
|
|
246
252
|
- host: windows-latest
|
|
247
253
|
target: 'x86_64-pc-windows-msvc'
|
|
248
|
-
|
|
254
|
+
architecture: x64
|
|
249
255
|
node: ['18', '20']
|
|
250
256
|
runs-on: \${{ matrix.settings.host }}
|
|
251
257
|
|
|
@@ -256,13 +262,14 @@ jobs:
|
|
|
256
262
|
uses: actions/setup-node@v4
|
|
257
263
|
with:
|
|
258
264
|
node-version: \${{ matrix.node }}
|
|
259
|
-
cache: '
|
|
265
|
+
cache: '${packageManager}'
|
|
266
|
+
architecture: \${{ matrix.settings.architecture }}
|
|
260
267
|
|
|
261
268
|
- name: 'Install dependencies'
|
|
262
|
-
run:
|
|
269
|
+
run: ${packageManager} install
|
|
263
270
|
|
|
264
271
|
- name: Download artifacts
|
|
265
|
-
uses: actions/download-artifact@
|
|
272
|
+
uses: actions/download-artifact@v4
|
|
266
273
|
with:
|
|
267
274
|
name: bindings-\${{ matrix.settings.target }}
|
|
268
275
|
path: .
|
|
@@ -272,7 +279,7 @@ jobs:
|
|
|
272
279
|
shell: bash
|
|
273
280
|
|
|
274
281
|
- name: Test bindings
|
|
275
|
-
run:
|
|
282
|
+
run: ${packageManager} run test
|
|
276
283
|
|
|
277
284
|
test-linux-x64-gnu-binding:
|
|
278
285
|
name: Test bindings on Linux-x64-gnu - node@\${{ matrix.node }}
|
|
@@ -281,7 +288,6 @@ jobs:
|
|
|
281
288
|
strategy:
|
|
282
289
|
fail-fast: false
|
|
283
290
|
matrix:
|
|
284
|
-
node: ['16', '18']
|
|
285
291
|
node: ['18', '20']
|
|
286
292
|
runs-on: ubuntu-latest
|
|
287
293
|
|
|
@@ -292,13 +298,13 @@ jobs:
|
|
|
292
298
|
uses: actions/setup-node@v4
|
|
293
299
|
with:
|
|
294
300
|
node-version: \${{ matrix.node }}
|
|
295
|
-
cache: '
|
|
301
|
+
cache: '${packageManager}'
|
|
296
302
|
|
|
297
303
|
- name: 'Install dependencies'
|
|
298
|
-
run:
|
|
304
|
+
run: ${packageManager} install
|
|
299
305
|
|
|
300
306
|
- name: Download artifacts
|
|
301
|
-
uses: actions/download-artifact@
|
|
307
|
+
uses: actions/download-artifact@v4
|
|
302
308
|
with:
|
|
303
309
|
name: bindings-x86_64-unknown-linux-gnu
|
|
304
310
|
path: .
|
|
@@ -308,7 +314,7 @@ jobs:
|
|
|
308
314
|
shell: bash
|
|
309
315
|
|
|
310
316
|
- name: Test bindings
|
|
311
|
-
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-slim
|
|
317
|
+
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-slim ${packageManager} run test
|
|
312
318
|
|
|
313
319
|
test-linux-x64-musl-binding:
|
|
314
320
|
name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
@@ -317,7 +323,6 @@ jobs:
|
|
|
317
323
|
strategy:
|
|
318
324
|
fail-fast: false
|
|
319
325
|
matrix:
|
|
320
|
-
node: ['16', '18']
|
|
321
326
|
node: ['18', '20']
|
|
322
327
|
runs-on: ubuntu-latest
|
|
323
328
|
|
|
@@ -328,15 +333,15 @@ jobs:
|
|
|
328
333
|
uses: actions/setup-node@v4
|
|
329
334
|
with:
|
|
330
335
|
node-version: \${{ matrix.node }}
|
|
331
|
-
cache: '
|
|
336
|
+
cache: '${packageManager}'
|
|
332
337
|
|
|
333
338
|
- name: 'Install dependencies'
|
|
334
339
|
run: |
|
|
335
340
|
yarn config set supportedArchitectures.libc "musl"
|
|
336
|
-
|
|
341
|
+
${packageManager} install
|
|
337
342
|
|
|
338
343
|
- name: Download artifacts
|
|
339
|
-
uses: actions/download-artifact@
|
|
344
|
+
uses: actions/download-artifact@v4
|
|
340
345
|
with:
|
|
341
346
|
name: bindings-x86_64-unknown-linux-musl
|
|
342
347
|
path: .
|
|
@@ -346,7 +351,7 @@ jobs:
|
|
|
346
351
|
shell: bash
|
|
347
352
|
|
|
348
353
|
- name: Test bindings
|
|
349
|
-
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-alpine
|
|
354
|
+
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-alpine ${packageManager} run test
|
|
350
355
|
|
|
351
356
|
test-linux-aarch64-gnu-binding:
|
|
352
357
|
name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }}
|
|
@@ -355,15 +360,14 @@ jobs:
|
|
|
355
360
|
strategy:
|
|
356
361
|
fail-fast: false
|
|
357
362
|
matrix:
|
|
358
|
-
node: ['
|
|
359
|
-
node: ['18', '20']
|
|
363
|
+
node: ['20']
|
|
360
364
|
runs-on: ubuntu-latest
|
|
361
365
|
|
|
362
366
|
steps:
|
|
363
367
|
- uses: actions/checkout@v4
|
|
364
368
|
|
|
365
369
|
- name: Download artifacts
|
|
366
|
-
uses: actions/download-artifact@
|
|
370
|
+
uses: actions/download-artifact@v4
|
|
367
371
|
with:
|
|
368
372
|
name: bindings-aarch64-unknown-linux-gnu
|
|
369
373
|
path: .
|
|
@@ -376,7 +380,7 @@ jobs:
|
|
|
376
380
|
run: |
|
|
377
381
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
378
382
|
yarn config set supportedArchitectures.libc "glibc"
|
|
379
|
-
|
|
383
|
+
${packageManager} install
|
|
380
384
|
|
|
381
385
|
- name: Set up QEMU
|
|
382
386
|
uses: docker/setup-qemu-action@v3
|
|
@@ -389,10 +393,7 @@ jobs:
|
|
|
389
393
|
with:
|
|
390
394
|
image: node:\${{ matrix.node }}-slim
|
|
391
395
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
392
|
-
run:
|
|
393
|
-
set -e
|
|
394
|
-
yarn test
|
|
395
|
-
ls -la
|
|
396
|
+
run: ${packageManager} run test
|
|
396
397
|
|
|
397
398
|
test-linux-aarch64-musl-binding:
|
|
398
399
|
name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
@@ -401,7 +402,7 @@ jobs:
|
|
|
401
402
|
strategy:
|
|
402
403
|
fail-fast: false
|
|
403
404
|
matrix:
|
|
404
|
-
node: ['
|
|
405
|
+
node: ['18', '20']
|
|
405
406
|
|
|
406
407
|
runs-on: ubuntu-latest
|
|
407
408
|
|
|
@@ -409,7 +410,7 @@ jobs:
|
|
|
409
410
|
- uses: actions/checkout@v4
|
|
410
411
|
|
|
411
412
|
- name: Download artifacts
|
|
412
|
-
uses: actions/download-artifact@
|
|
413
|
+
uses: actions/download-artifact@v4
|
|
413
414
|
with:
|
|
414
415
|
name: bindings-aarch64-unknown-linux-musl
|
|
415
416
|
path: .
|
|
@@ -422,7 +423,7 @@ jobs:
|
|
|
422
423
|
run: |
|
|
423
424
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
424
425
|
yarn config set supportedArchitectures.libc "musl"
|
|
425
|
-
|
|
426
|
+
${packageManager} install
|
|
426
427
|
|
|
427
428
|
- name: Set up QEMU
|
|
428
429
|
uses: docker/setup-qemu-action@v3
|
|
@@ -435,9 +436,7 @@ jobs:
|
|
|
435
436
|
with:
|
|
436
437
|
image: node:\${{ matrix.node }}-alpine
|
|
437
438
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
438
|
-
run:
|
|
439
|
-
set -e
|
|
440
|
-
yarn test
|
|
439
|
+
run: ${packageManager} run test
|
|
441
440
|
|
|
442
441
|
test-linux-arm-gnueabihf-binding:
|
|
443
442
|
name: Test bindings on armv7-unknown-linux-gnueabihf - node@\${{ matrix.node }}
|
|
@@ -446,7 +445,6 @@ jobs:
|
|
|
446
445
|
strategy:
|
|
447
446
|
fail-fast: false
|
|
448
447
|
matrix:
|
|
449
|
-
node: ['16', '18']
|
|
450
448
|
node: ['18', '20']
|
|
451
449
|
runs-on: ubuntu-latest
|
|
452
450
|
|
|
@@ -454,7 +452,7 @@ jobs:
|
|
|
454
452
|
- uses: actions/checkout@v4
|
|
455
453
|
|
|
456
454
|
- name: Download artifacts
|
|
457
|
-
uses: actions/download-artifact@
|
|
455
|
+
uses: actions/download-artifact@v4
|
|
458
456
|
with:
|
|
459
457
|
name: bindings-armv7-unknown-linux-gnueabihf
|
|
460
458
|
path: .
|
|
@@ -466,7 +464,7 @@ jobs:
|
|
|
466
464
|
- name: Install dependencies
|
|
467
465
|
run: |
|
|
468
466
|
yarn config set supportedArchitectures.cpu "arm"
|
|
469
|
-
|
|
467
|
+
${packageManager} install
|
|
470
468
|
|
|
471
469
|
- name: Set up QEMU
|
|
472
470
|
uses: docker/setup-qemu-action@v3
|
|
@@ -479,10 +477,7 @@ jobs:
|
|
|
479
477
|
with:
|
|
480
478
|
image: node:\${{ matrix.node }}-bullseye-slim
|
|
481
479
|
options: --platform linux/arm/v7 -v \${{ github.workspace }}:/build -w /build
|
|
482
|
-
run:
|
|
483
|
-
set -e
|
|
484
|
-
yarn test
|
|
485
|
-
ls -la
|
|
480
|
+
run: ${packageManager} test
|
|
486
481
|
|
|
487
482
|
universal-macOS:
|
|
488
483
|
name: Build universal macOS binary
|
|
@@ -496,33 +491,62 @@ jobs:
|
|
|
496
491
|
- name: Setup node
|
|
497
492
|
uses: actions/setup-node@v4
|
|
498
493
|
with:
|
|
499
|
-
node-version:
|
|
500
|
-
cache:
|
|
494
|
+
node-version: 20
|
|
495
|
+
cache: ${packageManager}
|
|
501
496
|
|
|
502
497
|
- name: 'Install dependencies'
|
|
503
|
-
run:
|
|
498
|
+
run: ${packageManager} install
|
|
504
499
|
|
|
505
500
|
- name: Download macOS x64 artifact
|
|
506
|
-
uses: actions/download-artifact@
|
|
501
|
+
uses: actions/download-artifact@v4
|
|
507
502
|
with:
|
|
508
503
|
name: bindings-x86_64-apple-darwin
|
|
509
504
|
path: .
|
|
510
505
|
- name: Download macOS arm64 artifact
|
|
511
|
-
uses: actions/download-artifact@
|
|
506
|
+
uses: actions/download-artifact@v4
|
|
512
507
|
with:
|
|
513
508
|
name: bindings-aarch64-apple-darwin
|
|
514
509
|
path: .
|
|
515
510
|
|
|
516
511
|
- name: Combine binaries
|
|
517
|
-
run:
|
|
512
|
+
run: ${packageManager} napi universalize
|
|
518
513
|
|
|
519
514
|
- name: Upload artifact
|
|
520
|
-
uses: actions/upload-artifact@
|
|
515
|
+
uses: actions/upload-artifact@v4
|
|
521
516
|
with:
|
|
522
517
|
name: bindings-universal-apple-darwin
|
|
523
518
|
path: "*.node"
|
|
524
519
|
if-no-files-found: error
|
|
525
520
|
|
|
521
|
+
test-wasi-nodejs:
|
|
522
|
+
name: Test bindings on wasi - node@\${{ matrix.node }}
|
|
523
|
+
needs:
|
|
524
|
+
- build
|
|
525
|
+
strategy:
|
|
526
|
+
fail-fast: false
|
|
527
|
+
matrix:
|
|
528
|
+
node: ['18', '20']
|
|
529
|
+
runs-on: ubuntu-latest
|
|
530
|
+
steps:
|
|
531
|
+
- uses: actions/checkout@v4
|
|
532
|
+
- name: Download artifacts
|
|
533
|
+
uses: actions/download-artifact@v4
|
|
534
|
+
with:
|
|
535
|
+
name: bindings-${wasiTargetName}
|
|
536
|
+
path: .
|
|
537
|
+
- name: List packages
|
|
538
|
+
run: ls -R .
|
|
539
|
+
- uses: actions/setup-node@v4
|
|
540
|
+
with:
|
|
541
|
+
node-version: \${{ matrix.node }}
|
|
542
|
+
cache: ${packageManager}
|
|
543
|
+
- name: 'Install dependencies'
|
|
544
|
+
run: ${packageManager} install
|
|
545
|
+
- name: Test
|
|
546
|
+
run: ${packageManager} test
|
|
547
|
+
env:
|
|
548
|
+
NAPI_RS_FORCE_WASI: true
|
|
549
|
+
|
|
526
550
|
publish:
|
|
527
551
|
name: Publish
|
|
528
552
|
runs-on: ubuntu-latest
|
|
@@ -533,6 +557,7 @@ jobs:
|
|
|
533
557
|
- test-linux-arm-gnueabihf-binding
|
|
534
558
|
- test-macOS-windows-binding
|
|
535
559
|
- test-linux-aarch64-musl-binding
|
|
560
|
+
- test-wasi-nodejs
|
|
536
561
|
- build-freebsd
|
|
537
562
|
|
|
538
563
|
steps:
|
|
@@ -541,20 +566,20 @@ jobs:
|
|
|
541
566
|
- name: Setup node
|
|
542
567
|
uses: actions/setup-node@v4
|
|
543
568
|
with:
|
|
544
|
-
node-version:
|
|
545
|
-
cache: '
|
|
569
|
+
node-version: 20
|
|
570
|
+
cache: '${packageManager}'
|
|
546
571
|
registry-url: 'https://registry.npmjs.org'
|
|
547
572
|
|
|
548
573
|
- name: 'Install dependencies'
|
|
549
|
-
run:
|
|
574
|
+
run: ${packageManager} install
|
|
550
575
|
|
|
551
576
|
- name: Download all artifacts
|
|
552
|
-
uses: actions/download-artifact@
|
|
577
|
+
uses: actions/download-artifact@v4
|
|
553
578
|
with:
|
|
554
579
|
path: artifacts
|
|
555
580
|
|
|
556
581
|
- name: Move artifacts
|
|
557
|
-
run:
|
|
582
|
+
run: ${packageManager} artifacts
|
|
558
583
|
|
|
559
584
|
- name: List packages
|
|
560
585
|
run: ls -R ./npm
|
|
@@ -2,11 +2,12 @@ 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'
|
|
8
9
|
|
|
9
|
-
import { YAML } from './ci-template.js'
|
|
10
|
+
import { type WasiTargetName, YAML } from './ci-template.js'
|
|
10
11
|
|
|
11
12
|
const BUILD_FREEBSD = 'build-freebsd'
|
|
12
13
|
const TEST_MACOS_WINDOWS = 'test-macOS-windows-binding'
|
|
@@ -15,9 +16,14 @@ 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
|
+
wasiTargetName: WasiTargetName,
|
|
26
|
+
) => {
|
|
21
27
|
const allTargets = new Set(
|
|
22
28
|
targets.flatMap((t) => {
|
|
23
29
|
const platform = parseTriple(t)
|
|
@@ -31,7 +37,7 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
31
37
|
}),
|
|
32
38
|
)
|
|
33
39
|
|
|
34
|
-
const fullTemplate = load(YAML()) as any
|
|
40
|
+
const fullTemplate = load(YAML(packageManager, wasiTargetName)) as any
|
|
35
41
|
|
|
36
42
|
const requiredSteps = []
|
|
37
43
|
const enableWindowsX86 = allTargets.has('x86_64-pc-windows-msvc')
|
|
@@ -43,6 +49,10 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
43
49
|
const enableLinuxArm7 = allTargets.has('armv7-unknown-linux-gnueabihf')
|
|
44
50
|
const enableFreeBSD = allTargets.has('x86_64-unknown-freebsd')
|
|
45
51
|
const enableMacOSUni = allTargets.has('universal-apple-darwin')
|
|
52
|
+
const enableWasi =
|
|
53
|
+
allTargets.has('wasm32-wasi-preview1-threads') ||
|
|
54
|
+
allTargets.has('wasm32-wasip1-threads') ||
|
|
55
|
+
allTargets.has('wasm32-wasip2')
|
|
46
56
|
fullTemplate.jobs.build.strategy.matrix.settings =
|
|
47
57
|
fullTemplate.jobs.build.strategy.matrix.settings.filter(
|
|
48
58
|
({ target }: { target: string }) => allTargets.has(target),
|
|
@@ -111,9 +121,20 @@ export const createGithubActionsCIYml = (targets: string[]) => {
|
|
|
111
121
|
requiredSteps.push(UNIVERSAL_MACOS)
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
if (!enableWasi) {
|
|
125
|
+
delete fullTemplate.jobs[TEST_WASI]
|
|
126
|
+
} else {
|
|
127
|
+
requiredSteps.push(TEST_WASI)
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
fullTemplate.jobs.publish.needs = requiredSteps
|
|
115
131
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
try {
|
|
133
|
+
return dump(fullTemplate, {
|
|
134
|
+
lineWidth: 1000,
|
|
135
|
+
})
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.info(fullTemplate)
|
|
138
|
+
throw err
|
|
139
|
+
}
|
|
119
140
|
}
|