@napi-rs/cli 2.15.1 → 3.0.0-alpha.0
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/README.md +17 -78
- package/cli.mjs +12 -0
- package/dist/api/artifacts.d.ts +2 -0
- package/dist/api/artifacts.js +50 -0
- package/dist/api/build.d.ts +14 -0
- package/dist/api/build.js +404 -0
- package/dist/api/create-npm-dirs.d.ts +2 -0
- package/dist/api/create-npm-dirs.js +63 -0
- package/dist/api/new.d.ts +4 -0
- package/dist/api/new.js +154 -0
- package/dist/api/pre-publish.d.ts +2 -0
- package/dist/api/pre-publish.js +157 -0
- package/dist/api/rename.d.ts +2 -0
- package/dist/api/rename.js +28 -0
- package/dist/api/templates/.gitignore.d.ts +1 -0
- package/dist/api/templates/.gitignore.js +198 -0
- package/dist/api/templates/.npmignore.d.ts +1 -0
- package/dist/api/templates/.npmignore.js +14 -0
- package/dist/api/templates/build.rs.d.ts +1 -0
- package/dist/api/templates/build.rs.js +4 -0
- package/dist/api/templates/cargo.toml.d.ts +6 -0
- package/dist/api/templates/cargo.toml.js +25 -0
- package/dist/api/templates/ci-template.d.ts +1 -0
- package/dist/api/templates/ci-template.js +566 -0
- package/dist/api/templates/ci.yml.d.ts +1 -0
- package/dist/api/templates/ci.yml.js +92 -0
- package/dist/api/templates/index.d.ts +8 -0
- package/dist/api/templates/index.js +8 -0
- package/dist/api/templates/js-binding.d.ts +1 -0
- package/dist/api/templates/js-binding.js +124 -0
- package/dist/api/templates/lib.rs.d.ts +1 -0
- package/dist/api/templates/lib.rs.js +10 -0
- package/dist/api/templates/package.json.d.ts +8 -0
- package/dist/api/templates/package.json.js +30 -0
- package/dist/api/universalize.d.ts +2 -0
- package/dist/api/universalize.js +38 -0
- package/dist/api/version.d.ts +2 -0
- package/dist/api/version.js +16 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/commands/artifacts.d.ts +6 -0
- package/dist/commands/artifacts.js +19 -0
- package/dist/commands/build.d.ts +6 -0
- package/dist/commands/build.js +34 -0
- package/dist/commands/create-npm-dirs.d.ts +4 -0
- package/dist/commands/create-npm-dirs.js +7 -0
- package/dist/commands/help.d.ts +10 -0
- package/dist/commands/help.js +12 -0
- package/dist/commands/new.d.ts +12 -0
- package/dist/commands/new.js +112 -0
- package/dist/commands/pre-publish.d.ts +4 -0
- package/dist/commands/pre-publish.js +8 -0
- package/dist/commands/rename.d.ts +4 -0
- package/dist/commands/rename.js +7 -0
- package/dist/commands/universalize.d.ts +4 -0
- package/dist/commands/universalize.js +7 -0
- package/dist/commands/version.d.ts +4 -0
- package/dist/commands/version.js +7 -0
- package/dist/def/artifacts.d.ts +50 -0
- package/dist/def/artifacts.js +38 -0
- package/dist/def/build.d.ts +150 -0
- package/dist/def/build.js +105 -0
- package/dist/def/commands/artifacts.d.ts +15 -0
- package/dist/def/commands/artifacts.js +29 -0
- package/dist/def/commands/build.d.ts +53 -0
- package/dist/def/commands/build.js +105 -0
- package/dist/def/commands/create-npm-dirs.d.ts +15 -0
- package/dist/def/commands/create-npm-dirs.js +29 -0
- package/dist/def/commands/new.d.ts +27 -0
- package/dist/def/commands/new.js +53 -0
- package/dist/def/commands/pre-publish.d.ts +23 -0
- package/dist/def/commands/pre-publish.js +45 -0
- package/dist/def/commands/rename.d.ts +25 -0
- package/dist/def/commands/rename.js +49 -0
- package/dist/def/commands/universalize.d.ts +13 -0
- package/dist/def/commands/universalize.js +25 -0
- package/dist/def/commands/version.d.ts +13 -0
- package/dist/def/commands/version.js +25 -0
- package/dist/def/create-npm-dirs.d.ts +50 -0
- package/dist/def/create-npm-dirs.js +38 -0
- package/dist/def/new.d.ts +106 -0
- package/dist/def/new.js +66 -0
- package/dist/def/options/artifacts.d.ts +35 -0
- package/dist/def/options/artifacts.js +11 -0
- package/dist/def/options/build.d.ts +97 -0
- package/dist/def/options/build.js +3 -0
- package/dist/def/options/create-npm-dirs.d.ts +35 -0
- package/dist/def/options/create-npm-dirs.js +11 -0
- package/dist/def/options/new.d.ts +79 -0
- package/dist/def/options/new.js +15 -0
- package/dist/def/options/pre-publish.d.ts +65 -0
- package/dist/def/options/pre-publish.js +13 -0
- package/dist/def/options/rename.d.ts +75 -0
- package/dist/def/options/rename.js +11 -0
- package/dist/def/options/universalize.d.ts +28 -0
- package/dist/def/options/universalize.js +10 -0
- package/dist/def/options/version.d.ts +28 -0
- package/dist/def/options/version.js +10 -0
- package/dist/def/pre-publish.d.ts +88 -0
- package/dist/def/pre-publish.js +56 -0
- package/dist/def/rename.d.ts +100 -0
- package/dist/def/rename.js +58 -0
- package/dist/def/universalize.d.ts +41 -0
- package/dist/def/universalize.js +33 -0
- package/dist/def/version.d.ts +41 -0
- package/dist/def/version.js +33 -0
- package/dist/index.cjs +20641 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/utils/__tests__/target.spec.d.ts +1 -0
- package/dist/utils/__tests__/target.spec.js +10 -0
- package/dist/utils/__tests__/typegen.spec.d.ts +1 -0
- package/dist/utils/__tests__/typegen.spec.js +37 -0
- package/dist/utils/__tests__/version.spec.d.ts +1 -0
- package/dist/utils/__tests__/version.spec.js +5 -0
- package/dist/utils/cargo.d.ts +1 -0
- package/dist/utils/cargo.js +33 -0
- package/dist/utils/ci.d.ts +11 -0
- package/dist/utils/ci.js +86 -0
- package/dist/utils/config.d.ts +65 -0
- package/dist/utils/config.js +42 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/log.d.ts +10 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/metadata.d.ts +24 -0
- package/dist/utils/metadata.js +19 -0
- package/dist/utils/misc.d.ts +13 -0
- package/dist/utils/misc.js +35 -0
- package/dist/utils/target.d.ts +30 -0
- package/dist/utils/target.js +109 -0
- package/dist/utils/typegen.d.ts +3 -0
- package/dist/utils/typegen.js +158 -0
- package/dist/utils/version.d.ts +11 -0
- package/dist/utils/version.js +59 -0
- package/package.json +63 -27
- package/src/api/artifacts.ts +93 -0
- package/src/api/build.ts +549 -0
- package/src/api/create-npm-dirs.ts +105 -0
- package/src/api/new.ts +206 -0
- package/src/api/pre-publish.ts +216 -0
- package/src/api/rename.ts +51 -0
- package/src/api/templates/.gitignore.ts +198 -0
- package/src/api/templates/.npmignore.ts +14 -0
- package/src/api/templates/build.rs.ts +4 -0
- package/src/api/templates/cargo.toml.ts +35 -0
- package/src/api/templates/ci-template.ts +566 -0
- package/src/api/templates/ci.yml.ts +116 -0
- package/src/api/templates/index.ts +8 -0
- package/src/api/templates/js-binding.ts +130 -0
- package/src/api/templates/lib.rs.ts +10 -0
- package/src/api/templates/package.json.ts +44 -0
- package/src/api/universalize.ts +76 -0
- package/src/api/version.ts +26 -0
- package/src/cli.ts +29 -0
- package/src/commands/artifacts.ts +23 -0
- package/src/commands/build.ts +42 -0
- package/src/commands/create-npm-dirs.ts +8 -0
- package/src/commands/help.ts +13 -0
- package/src/commands/new.ts +138 -0
- package/src/commands/pre-publish.ts +9 -0
- package/src/commands/rename.ts +8 -0
- package/src/commands/universalize.ts +8 -0
- package/src/commands/version.ts +8 -0
- package/src/def/artifacts.ts +79 -0
- package/src/def/build.ts +242 -0
- package/src/def/create-npm-dirs.ts +79 -0
- package/src/def/new.ts +144 -0
- package/src/def/pre-publish.ts +120 -0
- package/src/def/rename.ts +122 -0
- package/src/def/universalize.ts +66 -0
- package/src/def/version.ts +65 -0
- package/src/index.ts +31 -0
- package/src/utils/__tests__/__fixtures__/napi_type_def +201 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +110 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +618 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +20 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
- package/src/utils/__tests__/target.spec.ts +19 -0
- package/src/utils/__tests__/typegen.spec.ts +49 -0
- package/src/utils/__tests__/version.spec.ts +13 -0
- package/src/utils/cargo.ts +35 -0
- package/src/utils/ci.ts +102 -0
- package/src/utils/config.ts +123 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/log.ts +34 -0
- package/src/utils/metadata.ts +59 -0
- package/src/utils/misc.ts +45 -0
- package/src/utils/target.ts +145 -0
- package/src/utils/typegen.ts +193 -0
- package/src/utils/version.ts +76 -0
- package/scripts/index.js +0 -153779
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
export const YAML = () => `
|
|
2
|
+
name: CI
|
|
3
|
+
|
|
4
|
+
env:
|
|
5
|
+
DEBUG: 'napi:*'
|
|
6
|
+
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
tags-ignore:
|
|
13
|
+
- '**'
|
|
14
|
+
paths-ignore:
|
|
15
|
+
- '**/*.md'
|
|
16
|
+
- 'LICENSE'
|
|
17
|
+
- '**/*.gitignore'
|
|
18
|
+
- '.editorconfig'
|
|
19
|
+
- 'docs/**'
|
|
20
|
+
pull_request:
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
build:
|
|
24
|
+
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
settings:
|
|
29
|
+
- host: macos-latest
|
|
30
|
+
target: 'x86_64-apple-darwin'
|
|
31
|
+
build: |
|
|
32
|
+
yarn build --platform
|
|
33
|
+
strip -x *.node
|
|
34
|
+
- host: windows-latest
|
|
35
|
+
build: yarn build --platform
|
|
36
|
+
target: 'x86_64-pc-windows-msvc'
|
|
37
|
+
- host: windows-latest
|
|
38
|
+
build: |
|
|
39
|
+
yarn build --platform --target i686-pc-windows-msvc
|
|
40
|
+
yarn test
|
|
41
|
+
target: 'i686-pc-windows-msvc'
|
|
42
|
+
- host: ubuntu-latest
|
|
43
|
+
target: 'x86_64-unknown-linux-gnu'
|
|
44
|
+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
|
|
45
|
+
build: >-
|
|
46
|
+
set -e &&\n
|
|
47
|
+
yarn build --platform --target x86_64-unknown-linux-gnu &&\n
|
|
48
|
+
strip *.node
|
|
49
|
+
- host: ubuntu-latest
|
|
50
|
+
target: 'x86_64-unknown-linux-musl'
|
|
51
|
+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
|
52
|
+
build: >-
|
|
53
|
+
set -e &&
|
|
54
|
+
yarn build --platform &&
|
|
55
|
+
strip *.node
|
|
56
|
+
- host: macos-latest
|
|
57
|
+
target: 'aarch64-apple-darwin'
|
|
58
|
+
build: |
|
|
59
|
+
yarn build --platform --target aarch64-apple-darwin
|
|
60
|
+
strip -x *.node
|
|
61
|
+
- host: ubuntu-latest
|
|
62
|
+
target: 'aarch64-unknown-linux-gnu'
|
|
63
|
+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
|
|
64
|
+
build: >-
|
|
65
|
+
set -e &&\n
|
|
66
|
+
yarn build --platform --target aarch64-unknown-linux-gnu &&\n
|
|
67
|
+
aarch64-unknown-linux-gnu-strip *.node
|
|
68
|
+
- host: ubuntu-latest
|
|
69
|
+
target: 'armv7-unknown-linux-gnueabihf'
|
|
70
|
+
setup: |
|
|
71
|
+
sudo apt-get update
|
|
72
|
+
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
73
|
+
build: |
|
|
74
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
75
|
+
arm-linux-gnueabihf-strip *.node
|
|
76
|
+
- host: ubuntu-latest
|
|
77
|
+
target: 'aarch64-linux-android'
|
|
78
|
+
build: |
|
|
79
|
+
yarn build --platform --target aarch64-linux-android
|
|
80
|
+
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
81
|
+
- host: ubuntu-latest
|
|
82
|
+
target: 'armv7-linux-androideabi'
|
|
83
|
+
build: |
|
|
84
|
+
yarn build --platform --target armv7-linux-androideabi
|
|
85
|
+
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
86
|
+
- host: ubuntu-latest
|
|
87
|
+
target: 'aarch64-unknown-linux-musl'
|
|
88
|
+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
|
89
|
+
build: >-
|
|
90
|
+
set -e &&\n
|
|
91
|
+
rustup target add aarch64-unknown-linux-musl &&\n
|
|
92
|
+
yarn build --platform --target aarch64-unknown-linux-musl &&\n
|
|
93
|
+
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
|
|
94
|
+
- host: windows-latest
|
|
95
|
+
target: 'aarch64-pc-windows-msvc'
|
|
96
|
+
build: yarn build --platform --target aarch64-pc-windows-msvc
|
|
97
|
+
|
|
98
|
+
name: stable - \${{ matrix.settings.target }} - node@18
|
|
99
|
+
runs-on: \${{ matrix.settings.host }}
|
|
100
|
+
|
|
101
|
+
steps:
|
|
102
|
+
- uses: actions/checkout@v3
|
|
103
|
+
|
|
104
|
+
- name: Setup node
|
|
105
|
+
uses: actions/setup-node@v3
|
|
106
|
+
if: \${{ !matrix.settings.docker }}
|
|
107
|
+
with:
|
|
108
|
+
node-version: 18
|
|
109
|
+
check-latest: true
|
|
110
|
+
cache: yarn
|
|
111
|
+
|
|
112
|
+
- name: Install
|
|
113
|
+
uses: dtolnay/rust-toolchain@stable
|
|
114
|
+
if: \${{ !matrix.settings.docker }}
|
|
115
|
+
with:
|
|
116
|
+
toolchain: stable
|
|
117
|
+
targets: \${{ matrix.settings.target }}
|
|
118
|
+
|
|
119
|
+
- name: Cache cargo
|
|
120
|
+
uses: actions/cache@v3
|
|
121
|
+
with:
|
|
122
|
+
path: |
|
|
123
|
+
~/.cargo/registry/index/
|
|
124
|
+
~/.cargo/registry/cache/
|
|
125
|
+
~/.cargo/git/db/
|
|
126
|
+
.cargo-cache
|
|
127
|
+
target/
|
|
128
|
+
key: \${{ matrix.settings.target }}-cargo-\${{ matrix.settings.host }}
|
|
129
|
+
|
|
130
|
+
- uses: goto-bus-stop/setup-zig@v2
|
|
131
|
+
if: \${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
|
|
132
|
+
with:
|
|
133
|
+
version: 0.10.1
|
|
134
|
+
|
|
135
|
+
- name: Setup toolchain
|
|
136
|
+
run: \${{ matrix.settings.setup }}
|
|
137
|
+
if: \${{ matrix.settings.setup }}
|
|
138
|
+
shell: bash
|
|
139
|
+
|
|
140
|
+
- name: Setup node x86
|
|
141
|
+
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
142
|
+
run: yarn config set supportedArchitectures.cpu "ia32"
|
|
143
|
+
shell: bash
|
|
144
|
+
|
|
145
|
+
- name: 'Install dependencies'
|
|
146
|
+
run: yarn install
|
|
147
|
+
|
|
148
|
+
- name: Setup node x86
|
|
149
|
+
uses: actions/setup-node@v3
|
|
150
|
+
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
151
|
+
with:
|
|
152
|
+
node-version: 18
|
|
153
|
+
check-latest: true
|
|
154
|
+
cache: yarn
|
|
155
|
+
architecture: x86
|
|
156
|
+
|
|
157
|
+
- name: Build in docker
|
|
158
|
+
uses: addnab/docker-run-action@v3
|
|
159
|
+
if: \${{ matrix.settings.docker }}
|
|
160
|
+
with:
|
|
161
|
+
image: \${{ matrix.settings.docker }}
|
|
162
|
+
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
|
|
163
|
+
run: \${{ matrix.settings.build }}
|
|
164
|
+
|
|
165
|
+
- name: 'Build'
|
|
166
|
+
run: \${{ matrix.settings.build }}
|
|
167
|
+
if: \${{ !matrix.settings.docker }}
|
|
168
|
+
shell: bash
|
|
169
|
+
|
|
170
|
+
- name: Upload artifact
|
|
171
|
+
uses: actions/upload-artifact@v3
|
|
172
|
+
with:
|
|
173
|
+
name: bindings-\${{ matrix.settings.target }}
|
|
174
|
+
path: "*.node"
|
|
175
|
+
if-no-files-found: error
|
|
176
|
+
|
|
177
|
+
build-freebsd:
|
|
178
|
+
runs-on: macos-12
|
|
179
|
+
name: Build FreeBSD
|
|
180
|
+
steps:
|
|
181
|
+
- uses: actions/checkout@v3
|
|
182
|
+
- name: Build
|
|
183
|
+
id: build
|
|
184
|
+
uses: vmactions/freebsd-vm@v0
|
|
185
|
+
env:
|
|
186
|
+
DEBUG: 'napi:*'
|
|
187
|
+
RUSTUP_HOME: /usr/local/rustup
|
|
188
|
+
CARGO_HOME: /usr/local/cargo
|
|
189
|
+
RUSTUP_IO_THREADS: 1
|
|
190
|
+
with:
|
|
191
|
+
envs: 'DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS'
|
|
192
|
+
usesh: true
|
|
193
|
+
mem: 3000
|
|
194
|
+
prepare: |
|
|
195
|
+
pkg install -y -f curl node libnghttp2
|
|
196
|
+
curl -qL https://www.npmjs.com/install.sh | sh
|
|
197
|
+
npm install --location=global --ignore-scripts yarn
|
|
198
|
+
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
199
|
+
sh rustup.sh -y --profile minimal --default-toolchain beta
|
|
200
|
+
export PATH="/usr/local/cargo/bin:$PATH"
|
|
201
|
+
echo "~~~~ rustc --version ~~~~"
|
|
202
|
+
rustc --version
|
|
203
|
+
echo "~~~~ node -v ~~~~"
|
|
204
|
+
node -v
|
|
205
|
+
echo "~~~~ yarn --version ~~~~"
|
|
206
|
+
yarn --version
|
|
207
|
+
run: |
|
|
208
|
+
export PATH="/usr/local/cargo/bin:$PATH"
|
|
209
|
+
pwd
|
|
210
|
+
ls -lah
|
|
211
|
+
whoami
|
|
212
|
+
env
|
|
213
|
+
freebsd-version
|
|
214
|
+
yarn install
|
|
215
|
+
yarn build
|
|
216
|
+
strip -x *.node
|
|
217
|
+
yarn test
|
|
218
|
+
rm -rf node_modules
|
|
219
|
+
rm -rf target
|
|
220
|
+
rm -rf .yarn/cache
|
|
221
|
+
- name: Upload artifact
|
|
222
|
+
uses: actions/upload-artifact@v3
|
|
223
|
+
with:
|
|
224
|
+
name: bindings-freebsd
|
|
225
|
+
path: "*.node"
|
|
226
|
+
if-no-files-found: error
|
|
227
|
+
|
|
228
|
+
test-macOS-windows-binding:
|
|
229
|
+
name: Test bindings on \${{ matrix.settings.target }} - node@\${{ matrix.node }}
|
|
230
|
+
needs:
|
|
231
|
+
- build
|
|
232
|
+
strategy:
|
|
233
|
+
fail-fast: false
|
|
234
|
+
matrix:
|
|
235
|
+
settings:
|
|
236
|
+
- host: macos-latest
|
|
237
|
+
target: 'x86_64-apple-darwin'
|
|
238
|
+
- host: windows-latest
|
|
239
|
+
target: 'x86_64-pc-windows-msvc'
|
|
240
|
+
node: ['14', '16', '18']
|
|
241
|
+
runs-on: \${{ matrix.settings.host }}
|
|
242
|
+
|
|
243
|
+
steps:
|
|
244
|
+
- uses: actions/checkout@v3
|
|
245
|
+
|
|
246
|
+
- name: Setup node
|
|
247
|
+
uses: actions/setup-node@v3
|
|
248
|
+
with:
|
|
249
|
+
node-version: \${{ matrix.node }}
|
|
250
|
+
check-latest: true
|
|
251
|
+
cache: 'yarn'
|
|
252
|
+
|
|
253
|
+
- name: 'Install dependencies'
|
|
254
|
+
run: yarn install
|
|
255
|
+
|
|
256
|
+
- name: Download artifacts
|
|
257
|
+
uses: actions/download-artifact@v3
|
|
258
|
+
with:
|
|
259
|
+
name: bindings-\${{ matrix.settings.target }}
|
|
260
|
+
path: .
|
|
261
|
+
|
|
262
|
+
- name: List packages
|
|
263
|
+
run: ls -R .
|
|
264
|
+
shell: bash
|
|
265
|
+
|
|
266
|
+
- name: Test bindings
|
|
267
|
+
run: yarn test
|
|
268
|
+
|
|
269
|
+
test-linux-x64-gnu-binding:
|
|
270
|
+
name: Test bindings on Linux-x64-gnu - node@\${{ matrix.node }}
|
|
271
|
+
needs:
|
|
272
|
+
- build
|
|
273
|
+
strategy:
|
|
274
|
+
fail-fast: false
|
|
275
|
+
matrix:
|
|
276
|
+
node: ['14', '16', '18']
|
|
277
|
+
runs-on: ubuntu-latest
|
|
278
|
+
|
|
279
|
+
steps:
|
|
280
|
+
- uses: actions/checkout@v3
|
|
281
|
+
|
|
282
|
+
- name: Setup node
|
|
283
|
+
uses: actions/setup-node@v3
|
|
284
|
+
with:
|
|
285
|
+
node-version: \${{ matrix.node }}
|
|
286
|
+
check-latest: true
|
|
287
|
+
cache: 'yarn'
|
|
288
|
+
|
|
289
|
+
- name: 'Install dependencies'
|
|
290
|
+
run: yarn install
|
|
291
|
+
|
|
292
|
+
- name: Download artifacts
|
|
293
|
+
uses: actions/download-artifact@v3
|
|
294
|
+
with:
|
|
295
|
+
name: bindings-x86_64-unknown-linux-gnu
|
|
296
|
+
path: .
|
|
297
|
+
|
|
298
|
+
- name: List packages
|
|
299
|
+
run: ls -R .
|
|
300
|
+
shell: bash
|
|
301
|
+
|
|
302
|
+
- name: Test bindings
|
|
303
|
+
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-slim yarn test
|
|
304
|
+
|
|
305
|
+
test-linux-x64-musl-binding:
|
|
306
|
+
name: Test bindings on x86_64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
307
|
+
needs:
|
|
308
|
+
- build
|
|
309
|
+
strategy:
|
|
310
|
+
fail-fast: false
|
|
311
|
+
matrix:
|
|
312
|
+
node: ['14', '16', '18']
|
|
313
|
+
runs-on: ubuntu-latest
|
|
314
|
+
|
|
315
|
+
steps:
|
|
316
|
+
- uses: actions/checkout@v3
|
|
317
|
+
|
|
318
|
+
- name: Setup node
|
|
319
|
+
uses: actions/setup-node@v3
|
|
320
|
+
with:
|
|
321
|
+
node-version: \${{ matrix.node }}
|
|
322
|
+
check-latest: true
|
|
323
|
+
cache: 'yarn'
|
|
324
|
+
|
|
325
|
+
- name: 'Install dependencies'
|
|
326
|
+
run: |
|
|
327
|
+
yarn config set supportedArchitectures.libc "musl"
|
|
328
|
+
yarn install
|
|
329
|
+
|
|
330
|
+
- name: Download artifacts
|
|
331
|
+
uses: actions/download-artifact@v3
|
|
332
|
+
with:
|
|
333
|
+
name: bindings-x86_64-unknown-linux-musl
|
|
334
|
+
path: .
|
|
335
|
+
|
|
336
|
+
- name: List packages
|
|
337
|
+
run: ls -R .
|
|
338
|
+
shell: bash
|
|
339
|
+
|
|
340
|
+
- name: Test bindings
|
|
341
|
+
run: docker run --rm -v $(pwd):/build -w /build node:\${{ matrix.node }}-alpine yarn test
|
|
342
|
+
|
|
343
|
+
test-linux-aarch64-gnu-binding:
|
|
344
|
+
name: Test bindings on aarch64-unknown-linux-gnu - node@\${{ matrix.node }}
|
|
345
|
+
needs:
|
|
346
|
+
- build
|
|
347
|
+
strategy:
|
|
348
|
+
fail-fast: false
|
|
349
|
+
matrix:
|
|
350
|
+
node: ['14', '16', '18']
|
|
351
|
+
runs-on: ubuntu-latest
|
|
352
|
+
|
|
353
|
+
steps:
|
|
354
|
+
- uses: actions/checkout@v3
|
|
355
|
+
|
|
356
|
+
- name: Download artifacts
|
|
357
|
+
uses: actions/download-artifact@v3
|
|
358
|
+
with:
|
|
359
|
+
name: bindings-aarch64-unknown-linux-gnu
|
|
360
|
+
path: .
|
|
361
|
+
|
|
362
|
+
- name: List packages
|
|
363
|
+
run: ls -R .
|
|
364
|
+
shell: bash
|
|
365
|
+
|
|
366
|
+
- name: Install dependencies
|
|
367
|
+
run: |
|
|
368
|
+
yarn config set supportedArchitectures.cpu "arm64"
|
|
369
|
+
yarn config set supportedArchitectures.libc "glibc"
|
|
370
|
+
yarn install
|
|
371
|
+
|
|
372
|
+
- name: Set up QEMU
|
|
373
|
+
uses: docker/setup-qemu-action@v2
|
|
374
|
+
with:
|
|
375
|
+
platforms: arm64
|
|
376
|
+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
377
|
+
|
|
378
|
+
- name: Setup and run tests
|
|
379
|
+
uses: addnab/docker-run-action@v3
|
|
380
|
+
with:
|
|
381
|
+
image: node:\${{ matrix.node }}-slim
|
|
382
|
+
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
383
|
+
run: |
|
|
384
|
+
set -e
|
|
385
|
+
yarn test
|
|
386
|
+
ls -la
|
|
387
|
+
|
|
388
|
+
test-linux-aarch64-musl-binding:
|
|
389
|
+
name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
390
|
+
needs:
|
|
391
|
+
- build
|
|
392
|
+
|
|
393
|
+
runs-on: ubuntu-latest
|
|
394
|
+
|
|
395
|
+
steps:
|
|
396
|
+
- uses: actions/checkout@v3
|
|
397
|
+
|
|
398
|
+
- name: Download artifacts
|
|
399
|
+
uses: actions/download-artifact@v3
|
|
400
|
+
with:
|
|
401
|
+
name: bindings-aarch64-unknown-linux-musl
|
|
402
|
+
path: .
|
|
403
|
+
|
|
404
|
+
- name: List packages
|
|
405
|
+
run: ls -R .
|
|
406
|
+
shell: bash
|
|
407
|
+
|
|
408
|
+
- name: Install dependencies
|
|
409
|
+
run: |
|
|
410
|
+
yarn config set supportedArchitectures.cpu "arm64"
|
|
411
|
+
yarn config set supportedArchitectures.libc "musl"
|
|
412
|
+
yarn install
|
|
413
|
+
|
|
414
|
+
- name: Set up QEMU
|
|
415
|
+
uses: docker/setup-qemu-action@v2
|
|
416
|
+
with:
|
|
417
|
+
platforms: arm64
|
|
418
|
+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
419
|
+
|
|
420
|
+
- name: Setup and run tests
|
|
421
|
+
uses: addnab/docker-run-action@v3
|
|
422
|
+
with:
|
|
423
|
+
image: node:lts-alpine
|
|
424
|
+
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
425
|
+
run: |
|
|
426
|
+
set -e
|
|
427
|
+
yarn test
|
|
428
|
+
|
|
429
|
+
test-linux-arm-gnueabihf-binding:
|
|
430
|
+
name: Test bindings on armv7-unknown-linux-gnueabihf - node@\${{ matrix.node }}
|
|
431
|
+
needs:
|
|
432
|
+
- build
|
|
433
|
+
strategy:
|
|
434
|
+
fail-fast: false
|
|
435
|
+
matrix:
|
|
436
|
+
node: ['14', '16', '18']
|
|
437
|
+
runs-on: ubuntu-latest
|
|
438
|
+
|
|
439
|
+
steps:
|
|
440
|
+
- uses: actions/checkout@v3
|
|
441
|
+
|
|
442
|
+
- name: Download artifacts
|
|
443
|
+
uses: actions/download-artifact@v3
|
|
444
|
+
with:
|
|
445
|
+
name: bindings-armv7-unknown-linux-gnueabihf
|
|
446
|
+
path: .
|
|
447
|
+
|
|
448
|
+
- name: List packages
|
|
449
|
+
run: ls -R .
|
|
450
|
+
shell: bash
|
|
451
|
+
|
|
452
|
+
- name: Install dependencies
|
|
453
|
+
run: |
|
|
454
|
+
yarn config set supportedArchitectures.cpu "arm"
|
|
455
|
+
yarn install
|
|
456
|
+
|
|
457
|
+
- name: Set up QEMU
|
|
458
|
+
uses: docker/setup-qemu-action@v2
|
|
459
|
+
with:
|
|
460
|
+
platforms: arm
|
|
461
|
+
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
462
|
+
|
|
463
|
+
- name: Setup and run tests
|
|
464
|
+
uses: addnab/docker-run-action@v3
|
|
465
|
+
with:
|
|
466
|
+
image: node:\${{ matrix.node }}-bullseye-slim
|
|
467
|
+
options: --platform linux/arm/v7 -v \${{ github.workspace }}:/build -w /build
|
|
468
|
+
run: |
|
|
469
|
+
set -e
|
|
470
|
+
yarn test
|
|
471
|
+
ls -la
|
|
472
|
+
|
|
473
|
+
universal-macOS:
|
|
474
|
+
name: Build universal macOS binary
|
|
475
|
+
needs:
|
|
476
|
+
- build
|
|
477
|
+
runs-on: macos-latest
|
|
478
|
+
|
|
479
|
+
steps:
|
|
480
|
+
- uses: actions/checkout@v3
|
|
481
|
+
|
|
482
|
+
- name: Setup node
|
|
483
|
+
uses: actions/setup-node@v3
|
|
484
|
+
with:
|
|
485
|
+
node-version: 18
|
|
486
|
+
check-latest: true
|
|
487
|
+
cache: yarn
|
|
488
|
+
|
|
489
|
+
- name: 'Install dependencies'
|
|
490
|
+
run: yarn install
|
|
491
|
+
|
|
492
|
+
- name: Download macOS x64 artifact
|
|
493
|
+
uses: actions/download-artifact@v3
|
|
494
|
+
with:
|
|
495
|
+
name: bindings-x86_64-apple-darwin
|
|
496
|
+
path: artifacts
|
|
497
|
+
- name: Download macOS arm64 artifact
|
|
498
|
+
uses: actions/download-artifact@v3
|
|
499
|
+
with:
|
|
500
|
+
name: bindings-aarch64-apple-darwin
|
|
501
|
+
path: artifacts
|
|
502
|
+
|
|
503
|
+
- name: Combine binaries
|
|
504
|
+
run: yarn universal
|
|
505
|
+
|
|
506
|
+
- name: Upload artifact
|
|
507
|
+
uses: actions/upload-artifact@v3
|
|
508
|
+
with:
|
|
509
|
+
name: bindings-universal-apple-darwin
|
|
510
|
+
path: "*.node"
|
|
511
|
+
if-no-files-found: error
|
|
512
|
+
|
|
513
|
+
publish:
|
|
514
|
+
name: Publish
|
|
515
|
+
runs-on: ubuntu-latest
|
|
516
|
+
needs:
|
|
517
|
+
- test-linux-x64-gnu-binding
|
|
518
|
+
- test-linux-x64-musl-binding
|
|
519
|
+
- test-linux-aarch64-gnu-binding
|
|
520
|
+
- test-linux-arm-gnueabihf-binding
|
|
521
|
+
- test-macOS-windows-binding
|
|
522
|
+
- test-linux-aarch64-musl-binding
|
|
523
|
+
- build-freebsd
|
|
524
|
+
|
|
525
|
+
steps:
|
|
526
|
+
- uses: actions/checkout@v3
|
|
527
|
+
|
|
528
|
+
- name: Setup node
|
|
529
|
+
uses: actions/setup-node@v3
|
|
530
|
+
with:
|
|
531
|
+
node-version: 18
|
|
532
|
+
check-latest: true
|
|
533
|
+
cache: 'yarn'
|
|
534
|
+
|
|
535
|
+
- name: 'Install dependencies'
|
|
536
|
+
run: yarn install
|
|
537
|
+
|
|
538
|
+
- name: Download all artifacts
|
|
539
|
+
uses: actions/download-artifact@v3
|
|
540
|
+
with:
|
|
541
|
+
path: artifacts
|
|
542
|
+
|
|
543
|
+
- name: Move artifacts
|
|
544
|
+
run: yarn artifacts
|
|
545
|
+
|
|
546
|
+
- name: List packages
|
|
547
|
+
run: ls -R ./npm
|
|
548
|
+
shell: bash
|
|
549
|
+
|
|
550
|
+
- name: Publish
|
|
551
|
+
run: |
|
|
552
|
+
if git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$";
|
|
553
|
+
then
|
|
554
|
+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
|
555
|
+
npm publish --access public
|
|
556
|
+
elif git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+";
|
|
557
|
+
then
|
|
558
|
+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
|
559
|
+
npm publish --tag next --access public
|
|
560
|
+
else
|
|
561
|
+
echo "Not a release, skipping publish"
|
|
562
|
+
fi
|
|
563
|
+
env:
|
|
564
|
+
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
565
|
+
NPM_TOKEN: \${{ secrets.NPM_TOKEN }}
|
|
566
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createGithubActionsCIYml: (binaryName: string, targets: string[]) => string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { load, dump } from 'js-yaml';
|
|
2
|
+
import { NodeArchToCpu, UniArchsByPlatform, parseTriple, } from '../../utils/index.js';
|
|
3
|
+
import { YAML } from './ci-template.js';
|
|
4
|
+
const BUILD_FREEBSD = 'build-freebsd';
|
|
5
|
+
const TEST_MACOS_WINDOWS = 'test-macOS-windows-binding';
|
|
6
|
+
const TEST_LINUX_X64_GNU = 'test-linux-x64-gnu-binding';
|
|
7
|
+
const TEST_LINUX_X64_MUSL = 'test-linux-x64-musl-binding';
|
|
8
|
+
const TEST_LINUX_AARCH64_GNU = 'test-linux-aarch64-gnu-binding';
|
|
9
|
+
const TEST_LINUX_AARCH64_MUSL = 'test-linux-aarch64-musl-binding';
|
|
10
|
+
const TEST_LINUX_ARM_GNUEABIHF = 'test-linux-arm-gnueabihf-binding';
|
|
11
|
+
const UNIVERSAL_MACOS = 'universal-macOS';
|
|
12
|
+
export const createGithubActionsCIYml = (binaryName, targets) => {
|
|
13
|
+
const allTargets = new Set(targets.flatMap((t) => {
|
|
14
|
+
const platform = parseTriple(t);
|
|
15
|
+
if (platform.arch === 'universal') {
|
|
16
|
+
const srcTriples = UniArchsByPlatform[platform.platform]?.map((arch) => t.replace('universal', NodeArchToCpu[arch]));
|
|
17
|
+
return [t, ...(srcTriples ?? [])];
|
|
18
|
+
}
|
|
19
|
+
return [t];
|
|
20
|
+
}));
|
|
21
|
+
const fullTemplate = load(YAML());
|
|
22
|
+
const requiredSteps = [];
|
|
23
|
+
const enableWindowsX86 = allTargets.has('x86_64-pc-windows-msvc');
|
|
24
|
+
const enableMacOSX86 = allTargets.has('x86_64-apple-darwin');
|
|
25
|
+
const enableLinuxX86Gnu = allTargets.has('x86_64-unknown-linux-gnu');
|
|
26
|
+
const enableLinuxX86Musl = allTargets.has('x86_64-unknown-linux-musl');
|
|
27
|
+
const enableLinuxArm8Gnu = allTargets.has('aarch64-unknown-linux-gnu');
|
|
28
|
+
const enableLinuxArm8Musl = allTargets.has('aarch64-unknown-linux-musl');
|
|
29
|
+
const enableLinuxArm7 = allTargets.has('armv7-unknown-linux-gnueabihf');
|
|
30
|
+
const enableFreeBSD = allTargets.has('x86_64-unknown-freebsd');
|
|
31
|
+
const enableMacOSUni = allTargets.has('universal-apple-darwin');
|
|
32
|
+
fullTemplate.jobs.build.strategy.matrix.settings =
|
|
33
|
+
fullTemplate.jobs.build.strategy.matrix.settings.filter(({ target }) => allTargets.has(target));
|
|
34
|
+
if (!fullTemplate.jobs.build.strategy.matrix.settings.length) {
|
|
35
|
+
delete fullTemplate.jobs.build.strategy.matrix;
|
|
36
|
+
}
|
|
37
|
+
if (!enableFreeBSD) {
|
|
38
|
+
delete fullTemplate.jobs[BUILD_FREEBSD];
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
requiredSteps.push(BUILD_FREEBSD);
|
|
42
|
+
}
|
|
43
|
+
if (!enableWindowsX86 && !enableMacOSX86) {
|
|
44
|
+
delete fullTemplate.jobs[TEST_MACOS_WINDOWS];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const filterTarget = enableWindowsX86 ? 'macos-latest' : 'windows-latest';
|
|
48
|
+
fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings =
|
|
49
|
+
fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings.filter(({ host }) => host !== filterTarget);
|
|
50
|
+
requiredSteps.push(TEST_MACOS_WINDOWS);
|
|
51
|
+
}
|
|
52
|
+
if (!enableLinuxX86Gnu) {
|
|
53
|
+
delete fullTemplate.jobs[TEST_LINUX_X64_GNU];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
requiredSteps.push(TEST_LINUX_X64_GNU);
|
|
57
|
+
}
|
|
58
|
+
if (!enableLinuxX86Musl) {
|
|
59
|
+
delete fullTemplate.jobs[TEST_LINUX_X64_MUSL];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
requiredSteps.push(TEST_LINUX_X64_MUSL);
|
|
63
|
+
}
|
|
64
|
+
if (!enableLinuxArm8Gnu) {
|
|
65
|
+
delete fullTemplate.jobs[TEST_LINUX_AARCH64_GNU];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
requiredSteps.push(TEST_LINUX_AARCH64_GNU);
|
|
69
|
+
}
|
|
70
|
+
if (!enableLinuxArm8Musl) {
|
|
71
|
+
delete fullTemplate.jobs[TEST_LINUX_AARCH64_MUSL];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
requiredSteps.push(TEST_LINUX_AARCH64_MUSL);
|
|
75
|
+
}
|
|
76
|
+
if (!enableLinuxArm7) {
|
|
77
|
+
delete fullTemplate.jobs[TEST_LINUX_ARM_GNUEABIHF];
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
requiredSteps.push(TEST_LINUX_ARM_GNUEABIHF);
|
|
81
|
+
}
|
|
82
|
+
if (!enableMacOSUni) {
|
|
83
|
+
delete fullTemplate.jobs[UNIVERSAL_MACOS];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
requiredSteps.push(UNIVERSAL_MACOS);
|
|
87
|
+
}
|
|
88
|
+
fullTemplate.jobs.publish.needs = requiredSteps;
|
|
89
|
+
return dump(fullTemplate, {
|
|
90
|
+
lineWidth: 1000,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './.gitignore.js';
|
|
2
|
+
export * from './.npmignore.js';
|
|
3
|
+
export * from './build.rs.js';
|
|
4
|
+
export * from './cargo.toml.js';
|
|
5
|
+
export * from './ci.yml.js';
|
|
6
|
+
export * from './lib.rs.js';
|
|
7
|
+
export * from './package.json.js';
|
|
8
|
+
export * from './js-binding.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './.gitignore.js';
|
|
2
|
+
export * from './.npmignore.js';
|
|
3
|
+
export * from './build.rs.js';
|
|
4
|
+
export * from './cargo.toml.js';
|
|
5
|
+
export * from './ci.yml.js';
|
|
6
|
+
export * from './lib.rs.js';
|
|
7
|
+
export * from './package.json.js';
|
|
8
|
+
export * from './js-binding.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createJsBinding(localName: string, pkgName: string): string;
|