@napi-rs/cli 3.0.0-alpha.1 → 3.0.0-alpha.3
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 +21 -5
- package/dist/api/templates/ci-template.js +9 -9
- package/dist/api/templates/package.json.js +2 -3
- package/dist/index.cjs +20 -18
- package/dist/utils/misc.js +6 -1
- package/dist/utils/target.js +0 -2
- package/package.json +2 -2
- package/src/api/build.ts +27 -7
- package/src/api/templates/ci-template.ts +9 -9
- package/src/api/templates/package.json.ts +2 -3
- package/src/utils/misc.ts +6 -1
- package/src/utils/target.ts +0 -2
package/dist/api/build.js
CHANGED
|
@@ -207,6 +207,10 @@ class Builder {
|
|
|
207
207
|
setEnvs() {
|
|
208
208
|
// type definition intermediate file
|
|
209
209
|
this.envs.TYPE_DEF_TMP_PATH = this.getIntermediateTypeFile();
|
|
210
|
+
// WASI register intermediate file
|
|
211
|
+
this.envs.WASI_REGISTER_TMP_PATH = this.getIntermediateWasiRegisterFile();
|
|
212
|
+
// TODO:
|
|
213
|
+
// remove after napi-derive@v3 release
|
|
210
214
|
this.envs.CARGO_CFG_NAPI_RS_CLI_VERSION = CLI_VERSION;
|
|
211
215
|
// RUSTFLAGS
|
|
212
216
|
let rustflags = process.env.RUSTFLAGS ?? process.env.CARGO_BUILD_RUSTFLAGS ?? '';
|
|
@@ -222,11 +226,16 @@ class Builder {
|
|
|
222
226
|
}
|
|
223
227
|
// END RUSTFLAGS
|
|
224
228
|
// LINKER
|
|
225
|
-
const linker =
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
const linker = this.options.crossCompile
|
|
230
|
+
? void 0
|
|
231
|
+
: getTargetLinker(this.target.triple);
|
|
232
|
+
// TODO:
|
|
233
|
+
// directly set CARGO_TARGET_<target>_LINKER will cover .cargo/config.toml
|
|
234
|
+
// will detect by cargo config when it becomes stable
|
|
235
|
+
// see: https://github.com/rust-lang/cargo/issues/9301
|
|
236
|
+
const linkerEnv = `CARGO_TARGET_${targetToEnvVar(this.target.triple)}_LINKER`;
|
|
237
|
+
if (linker && !process.env[linkerEnv]) {
|
|
238
|
+
this.envs[linkerEnv] = linker;
|
|
230
239
|
}
|
|
231
240
|
if (this.target.platform === 'android') {
|
|
232
241
|
const { ANDROID_NDK_LATEST_HOME } = process.env;
|
|
@@ -290,6 +299,13 @@ class Builder {
|
|
|
290
299
|
.digest('hex')
|
|
291
300
|
.substring(0, 8)}.napi_type_def.tmp`);
|
|
292
301
|
}
|
|
302
|
+
getIntermediateWasiRegisterFile() {
|
|
303
|
+
return join(tmpdir(), `${this.crate.name}-${createHash('sha256')
|
|
304
|
+
.update(this.crate.manifest_path)
|
|
305
|
+
.update(CLI_VERSION)
|
|
306
|
+
.digest('hex')
|
|
307
|
+
.substring(0, 8)}.napi_wasi_register.tmp`);
|
|
308
|
+
}
|
|
293
309
|
async postBuild() {
|
|
294
310
|
try {
|
|
295
311
|
debug(`Try to create output directory:`);
|
|
@@ -71,7 +71,7 @@ jobs:
|
|
|
71
71
|
sudo apt-get update
|
|
72
72
|
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
73
73
|
build: |
|
|
74
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
74
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
75
75
|
arm-linux-gnueabihf-strip *.node
|
|
76
76
|
- host: ubuntu-latest
|
|
77
77
|
target: 'aarch64-linux-android'
|
|
@@ -237,7 +237,7 @@ jobs:
|
|
|
237
237
|
target: 'x86_64-apple-darwin'
|
|
238
238
|
- host: windows-latest
|
|
239
239
|
target: 'x86_64-pc-windows-msvc'
|
|
240
|
-
node: ['
|
|
240
|
+
node: ['16', '18']
|
|
241
241
|
runs-on: \${{ matrix.settings.host }}
|
|
242
242
|
|
|
243
243
|
steps:
|
|
@@ -273,7 +273,7 @@ jobs:
|
|
|
273
273
|
strategy:
|
|
274
274
|
fail-fast: false
|
|
275
275
|
matrix:
|
|
276
|
-
node: ['
|
|
276
|
+
node: ['16', '18']
|
|
277
277
|
runs-on: ubuntu-latest
|
|
278
278
|
|
|
279
279
|
steps:
|
|
@@ -309,7 +309,7 @@ jobs:
|
|
|
309
309
|
strategy:
|
|
310
310
|
fail-fast: false
|
|
311
311
|
matrix:
|
|
312
|
-
node: ['
|
|
312
|
+
node: ['16', '18']
|
|
313
313
|
runs-on: ubuntu-latest
|
|
314
314
|
|
|
315
315
|
steps:
|
|
@@ -347,7 +347,7 @@ jobs:
|
|
|
347
347
|
strategy:
|
|
348
348
|
fail-fast: false
|
|
349
349
|
matrix:
|
|
350
|
-
node: ['
|
|
350
|
+
node: ['16', '18']
|
|
351
351
|
runs-on: ubuntu-latest
|
|
352
352
|
|
|
353
353
|
steps:
|
|
@@ -433,7 +433,7 @@ jobs:
|
|
|
433
433
|
strategy:
|
|
434
434
|
fail-fast: false
|
|
435
435
|
matrix:
|
|
436
|
-
node: ['
|
|
436
|
+
node: ['16', '18']
|
|
437
437
|
runs-on: ubuntu-latest
|
|
438
438
|
|
|
439
439
|
steps:
|
|
@@ -493,15 +493,15 @@ jobs:
|
|
|
493
493
|
uses: actions/download-artifact@v3
|
|
494
494
|
with:
|
|
495
495
|
name: bindings-x86_64-apple-darwin
|
|
496
|
-
path:
|
|
496
|
+
path: .
|
|
497
497
|
- name: Download macOS arm64 artifact
|
|
498
498
|
uses: actions/download-artifact@v3
|
|
499
499
|
with:
|
|
500
500
|
name: bindings-aarch64-apple-darwin
|
|
501
|
-
path:
|
|
501
|
+
path: .
|
|
502
502
|
|
|
503
503
|
- name: Combine binaries
|
|
504
|
-
run: yarn
|
|
504
|
+
run: yarn napi universalize
|
|
505
505
|
|
|
506
506
|
- name: Upload artifact
|
|
507
507
|
uses: actions/upload-artifact@v3
|
|
@@ -9,18 +9,17 @@ export const createPackageJson = ({ name, binaryName, targets, license, engineRe
|
|
|
9
9
|
"node": "${engineRequirement}"
|
|
10
10
|
},
|
|
11
11
|
"napi": {
|
|
12
|
-
"
|
|
12
|
+
"binaryName": "${binaryName}",
|
|
13
13
|
"targets": [
|
|
14
14
|
${targets.map((t) => `"${t}"`).join(',\n ')}
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "node -e \\"assert(require('.').sum(1, 2) === 3)\\"",
|
|
19
19
|
"build": "napi build --release --platform --strip",
|
|
20
20
|
"build:debug": "napi build",
|
|
21
21
|
"prepublishOnly": "napi prepublish -t npm",
|
|
22
22
|
"artifacts": "napi artifacts",
|
|
23
|
-
"universal": "napi universal",
|
|
24
23
|
"version": "napi version"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
package/dist/index.cjs
CHANGED
|
@@ -12997,7 +12997,7 @@ var import_fs = require("fs");
|
|
|
12997
12997
|
var import_module = require("module");
|
|
12998
12998
|
var import_util = require("util");
|
|
12999
12999
|
var require2 = (0, import_module.createRequire)(__filename);
|
|
13000
|
-
var pkgJson = require2("
|
|
13000
|
+
var pkgJson = require2("@napi-rs/cli/package.json");
|
|
13001
13001
|
var readFileAsync = (0, import_util.promisify)(import_fs.readFile);
|
|
13002
13002
|
var writeFileAsync = (0, import_util.promisify)(import_fs.writeFile);
|
|
13003
13003
|
var unlinkAsync = (0, import_util.promisify)(import_fs.unlink);
|
|
@@ -13050,8 +13050,6 @@ var DEFAULT_TARGETS = [
|
|
|
13050
13050
|
"x86_64-unknown-linux-gnu"
|
|
13051
13051
|
];
|
|
13052
13052
|
var TARGET_LINKER = {
|
|
13053
|
-
"aarch64-unknown-linux-gnu": "aarch64-linux-gnu-gcc",
|
|
13054
|
-
"armv7-unknown-linux-gnueabihf": "arm-linux-gnueabihf-gcc",
|
|
13055
13053
|
"aarch64-unknown-linux-musl": "aarch64-linux-musl-gcc"
|
|
13056
13054
|
};
|
|
13057
13055
|
var CpuToNodeArch = {
|
|
@@ -18809,7 +18807,7 @@ jobs:
|
|
|
18809
18807
|
sudo apt-get update
|
|
18810
18808
|
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
18811
18809
|
build: |
|
|
18812
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
18810
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
18813
18811
|
arm-linux-gnueabihf-strip *.node
|
|
18814
18812
|
- host: ubuntu-latest
|
|
18815
18813
|
target: 'aarch64-linux-android'
|
|
@@ -18978,7 +18976,7 @@ jobs:
|
|
|
18978
18976
|
target: 'x86_64-apple-darwin'
|
|
18979
18977
|
- host: windows-latest
|
|
18980
18978
|
target: 'x86_64-pc-windows-msvc'
|
|
18981
|
-
node: ['
|
|
18979
|
+
node: ['16', '18']
|
|
18982
18980
|
runs-on: \${{ matrix.settings.host }}
|
|
18983
18981
|
|
|
18984
18982
|
steps:
|
|
@@ -19014,7 +19012,7 @@ jobs:
|
|
|
19014
19012
|
strategy:
|
|
19015
19013
|
fail-fast: false
|
|
19016
19014
|
matrix:
|
|
19017
|
-
node: ['
|
|
19015
|
+
node: ['16', '18']
|
|
19018
19016
|
runs-on: ubuntu-latest
|
|
19019
19017
|
|
|
19020
19018
|
steps:
|
|
@@ -19050,7 +19048,7 @@ jobs:
|
|
|
19050
19048
|
strategy:
|
|
19051
19049
|
fail-fast: false
|
|
19052
19050
|
matrix:
|
|
19053
|
-
node: ['
|
|
19051
|
+
node: ['16', '18']
|
|
19054
19052
|
runs-on: ubuntu-latest
|
|
19055
19053
|
|
|
19056
19054
|
steps:
|
|
@@ -19088,7 +19086,7 @@ jobs:
|
|
|
19088
19086
|
strategy:
|
|
19089
19087
|
fail-fast: false
|
|
19090
19088
|
matrix:
|
|
19091
|
-
node: ['
|
|
19089
|
+
node: ['16', '18']
|
|
19092
19090
|
runs-on: ubuntu-latest
|
|
19093
19091
|
|
|
19094
19092
|
steps:
|
|
@@ -19174,7 +19172,7 @@ jobs:
|
|
|
19174
19172
|
strategy:
|
|
19175
19173
|
fail-fast: false
|
|
19176
19174
|
matrix:
|
|
19177
|
-
node: ['
|
|
19175
|
+
node: ['16', '18']
|
|
19178
19176
|
runs-on: ubuntu-latest
|
|
19179
19177
|
|
|
19180
19178
|
steps:
|
|
@@ -19234,15 +19232,15 @@ jobs:
|
|
|
19234
19232
|
uses: actions/download-artifact@v3
|
|
19235
19233
|
with:
|
|
19236
19234
|
name: bindings-x86_64-apple-darwin
|
|
19237
|
-
path:
|
|
19235
|
+
path: .
|
|
19238
19236
|
- name: Download macOS arm64 artifact
|
|
19239
19237
|
uses: actions/download-artifact@v3
|
|
19240
19238
|
with:
|
|
19241
19239
|
name: bindings-aarch64-apple-darwin
|
|
19242
|
-
path:
|
|
19240
|
+
path: .
|
|
19243
19241
|
|
|
19244
19242
|
- name: Combine binaries
|
|
19245
|
-
run: yarn
|
|
19243
|
+
run: yarn napi universalize
|
|
19246
19244
|
|
|
19247
19245
|
- name: Upload artifact
|
|
19248
19246
|
uses: actions/upload-artifact@v3
|
|
@@ -19411,18 +19409,17 @@ var createPackageJson = ({ name, binaryName, targets, license, engineRequirement
|
|
|
19411
19409
|
"node": "${engineRequirement}"
|
|
19412
19410
|
},
|
|
19413
19411
|
"napi": {
|
|
19414
|
-
"
|
|
19412
|
+
"binaryName": "${binaryName}",
|
|
19415
19413
|
"targets": [
|
|
19416
19414
|
${targets.map((t) => `"${t}"`).join(",\n ")}
|
|
19417
19415
|
]
|
|
19418
19416
|
},
|
|
19419
19417
|
"scripts": {
|
|
19420
|
-
"test": "
|
|
19418
|
+
"test": "node -e \\"assert(require('.').sum(1, 2) === 3)\\"",
|
|
19421
19419
|
"build": "napi build --release --platform --strip",
|
|
19422
19420
|
"build:debug": "napi build",
|
|
19423
19421
|
"prepublishOnly": "napi prepublish -t npm",
|
|
19424
19422
|
"artifacts": "napi artifacts",
|
|
19425
|
-
"universal": "napi universal",
|
|
19426
19423
|
"version": "napi version"
|
|
19427
19424
|
},
|
|
19428
19425
|
"devDependencies": {
|
|
@@ -19713,6 +19710,7 @@ var Builder = class {
|
|
|
19713
19710
|
}
|
|
19714
19711
|
setEnvs() {
|
|
19715
19712
|
this.envs.TYPE_DEF_TMP_PATH = this.getIntermediateTypeFile();
|
|
19713
|
+
this.envs.WASI_REGISTER_TMP_PATH = this.getIntermediateWasiRegisterFile();
|
|
19716
19714
|
this.envs.CARGO_CFG_NAPI_RS_CLI_VERSION = CLI_VERSION;
|
|
19717
19715
|
let rustflags = process.env.RUSTFLAGS ?? process.env.CARGO_BUILD_RUSTFLAGS ?? "";
|
|
19718
19716
|
if (this.target.abi?.includes("musl") && !rustflags.includes("target-feature=-crt-static")) {
|
|
@@ -19724,9 +19722,10 @@ var Builder = class {
|
|
|
19724
19722
|
if (rustflags.length) {
|
|
19725
19723
|
this.envs.RUSTFLAGS = rustflags;
|
|
19726
19724
|
}
|
|
19727
|
-
const linker = getTargetLinker(this.target.triple);
|
|
19728
|
-
|
|
19729
|
-
|
|
19725
|
+
const linker = this.options.crossCompile ? void 0 : getTargetLinker(this.target.triple);
|
|
19726
|
+
const linkerEnv = `CARGO_TARGET_${targetToEnvVar(this.target.triple)}_LINKER`;
|
|
19727
|
+
if (linker && !process.env[linkerEnv]) {
|
|
19728
|
+
this.envs[linkerEnv] = linker;
|
|
19730
19729
|
}
|
|
19731
19730
|
if (this.target.platform === "android") {
|
|
19732
19731
|
const { ANDROID_NDK_LATEST_HOME } = process.env;
|
|
@@ -19783,6 +19782,9 @@ var Builder = class {
|
|
|
19783
19782
|
getIntermediateTypeFile() {
|
|
19784
19783
|
return (0, import_path2.join)((0, import_os.tmpdir)(), `${this.crate.name}-${(0, import_crypto.createHash)("sha256").update(this.crate.manifest_path).update(CLI_VERSION).digest("hex").substring(0, 8)}.napi_type_def.tmp`);
|
|
19785
19784
|
}
|
|
19785
|
+
getIntermediateWasiRegisterFile() {
|
|
19786
|
+
return (0, import_path2.join)((0, import_os.tmpdir)(), `${this.crate.name}-${(0, import_crypto.createHash)("sha256").update(this.crate.manifest_path).update(CLI_VERSION).digest("hex").substring(0, 8)}.napi_wasi_register.tmp`);
|
|
19787
|
+
}
|
|
19786
19788
|
async postBuild() {
|
|
19787
19789
|
try {
|
|
19788
19790
|
debug3(`Try to create output directory:`);
|
package/dist/utils/misc.js
CHANGED
|
@@ -3,7 +3,12 @@ import { createRequire } from 'module';
|
|
|
3
3
|
import { promisify } from 'util';
|
|
4
4
|
import { debug } from './log.js';
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
|
-
|
|
6
|
+
// NOTE:
|
|
7
|
+
// import pkgJson from '@napi-rs/cli/package.json' assert { type: 'json' }
|
|
8
|
+
// is experimental feature now, avoid using it.
|
|
9
|
+
// see: https://nodejs.org/api/esm.html#import-assertions
|
|
10
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
11
|
+
const pkgJson = require('@napi-rs/cli/package.json');
|
|
7
12
|
export const readFileAsync = promisify(readFile);
|
|
8
13
|
export const writeFileAsync = promisify(writeFile);
|
|
9
14
|
export const unlinkAsync = promisify(unlink);
|
package/dist/utils/target.js
CHANGED
|
@@ -21,8 +21,6 @@ export const DEFAULT_TARGETS = [
|
|
|
21
21
|
'x86_64-unknown-linux-gnu',
|
|
22
22
|
];
|
|
23
23
|
export const TARGET_LINKER = {
|
|
24
|
-
'aarch64-unknown-linux-gnu': 'aarch64-linux-gnu-gcc',
|
|
25
|
-
'armv7-unknown-linux-gnueabihf': 'arm-linux-gnueabihf-gcc',
|
|
26
24
|
'aarch64-unknown-linux-musl': 'aarch64-linux-musl-gcc',
|
|
27
25
|
};
|
|
28
26
|
const CpuToNodeArch = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "Cli tools for napi-rs",
|
|
5
5
|
"author": "LongYinan <lynweklm@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/napi-rs/napi-rs",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"build:cjs": "node ./esbuild.mjs",
|
|
97
97
|
"test": "ava"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "b5c3c0575559f9c99d7747f3163476afe7e89a6c"
|
|
100
100
|
}
|
package/src/api/build.ts
CHANGED
|
@@ -297,6 +297,10 @@ class Builder {
|
|
|
297
297
|
private setEnvs() {
|
|
298
298
|
// type definition intermediate file
|
|
299
299
|
this.envs.TYPE_DEF_TMP_PATH = this.getIntermediateTypeFile()
|
|
300
|
+
// WASI register intermediate file
|
|
301
|
+
this.envs.WASI_REGISTER_TMP_PATH = this.getIntermediateWasiRegisterFile()
|
|
302
|
+
// TODO:
|
|
303
|
+
// remove after napi-derive@v3 release
|
|
300
304
|
this.envs.CARGO_CFG_NAPI_RS_CLI_VERSION = CLI_VERSION
|
|
301
305
|
|
|
302
306
|
// RUSTFLAGS
|
|
@@ -320,13 +324,18 @@ class Builder {
|
|
|
320
324
|
// END RUSTFLAGS
|
|
321
325
|
|
|
322
326
|
// LINKER
|
|
323
|
-
const linker =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
const linker = this.options.crossCompile
|
|
328
|
+
? void 0
|
|
329
|
+
: getTargetLinker(this.target.triple)
|
|
330
|
+
// TODO:
|
|
331
|
+
// directly set CARGO_TARGET_<target>_LINKER will cover .cargo/config.toml
|
|
332
|
+
// will detect by cargo config when it becomes stable
|
|
333
|
+
// see: https://github.com/rust-lang/cargo/issues/9301
|
|
334
|
+
const linkerEnv = `CARGO_TARGET_${targetToEnvVar(
|
|
335
|
+
this.target.triple,
|
|
336
|
+
)}_LINKER`
|
|
337
|
+
if (linker && !process.env[linkerEnv]) {
|
|
338
|
+
this.envs[linkerEnv] = linker
|
|
330
339
|
}
|
|
331
340
|
|
|
332
341
|
if (this.target.platform === 'android') {
|
|
@@ -410,6 +419,17 @@ class Builder {
|
|
|
410
419
|
)
|
|
411
420
|
}
|
|
412
421
|
|
|
422
|
+
private getIntermediateWasiRegisterFile() {
|
|
423
|
+
return join(
|
|
424
|
+
tmpdir(),
|
|
425
|
+
`${this.crate.name}-${createHash('sha256')
|
|
426
|
+
.update(this.crate.manifest_path)
|
|
427
|
+
.update(CLI_VERSION)
|
|
428
|
+
.digest('hex')
|
|
429
|
+
.substring(0, 8)}.napi_wasi_register.tmp`,
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
413
433
|
private async postBuild() {
|
|
414
434
|
try {
|
|
415
435
|
debug(`Try to create output directory:`)
|
|
@@ -71,7 +71,7 @@ jobs:
|
|
|
71
71
|
sudo apt-get update
|
|
72
72
|
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
73
73
|
build: |
|
|
74
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
74
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
75
75
|
arm-linux-gnueabihf-strip *.node
|
|
76
76
|
- host: ubuntu-latest
|
|
77
77
|
target: 'aarch64-linux-android'
|
|
@@ -237,7 +237,7 @@ jobs:
|
|
|
237
237
|
target: 'x86_64-apple-darwin'
|
|
238
238
|
- host: windows-latest
|
|
239
239
|
target: 'x86_64-pc-windows-msvc'
|
|
240
|
-
node: ['
|
|
240
|
+
node: ['16', '18']
|
|
241
241
|
runs-on: \${{ matrix.settings.host }}
|
|
242
242
|
|
|
243
243
|
steps:
|
|
@@ -273,7 +273,7 @@ jobs:
|
|
|
273
273
|
strategy:
|
|
274
274
|
fail-fast: false
|
|
275
275
|
matrix:
|
|
276
|
-
node: ['
|
|
276
|
+
node: ['16', '18']
|
|
277
277
|
runs-on: ubuntu-latest
|
|
278
278
|
|
|
279
279
|
steps:
|
|
@@ -309,7 +309,7 @@ jobs:
|
|
|
309
309
|
strategy:
|
|
310
310
|
fail-fast: false
|
|
311
311
|
matrix:
|
|
312
|
-
node: ['
|
|
312
|
+
node: ['16', '18']
|
|
313
313
|
runs-on: ubuntu-latest
|
|
314
314
|
|
|
315
315
|
steps:
|
|
@@ -347,7 +347,7 @@ jobs:
|
|
|
347
347
|
strategy:
|
|
348
348
|
fail-fast: false
|
|
349
349
|
matrix:
|
|
350
|
-
node: ['
|
|
350
|
+
node: ['16', '18']
|
|
351
351
|
runs-on: ubuntu-latest
|
|
352
352
|
|
|
353
353
|
steps:
|
|
@@ -433,7 +433,7 @@ jobs:
|
|
|
433
433
|
strategy:
|
|
434
434
|
fail-fast: false
|
|
435
435
|
matrix:
|
|
436
|
-
node: ['
|
|
436
|
+
node: ['16', '18']
|
|
437
437
|
runs-on: ubuntu-latest
|
|
438
438
|
|
|
439
439
|
steps:
|
|
@@ -493,15 +493,15 @@ jobs:
|
|
|
493
493
|
uses: actions/download-artifact@v3
|
|
494
494
|
with:
|
|
495
495
|
name: bindings-x86_64-apple-darwin
|
|
496
|
-
path:
|
|
496
|
+
path: .
|
|
497
497
|
- name: Download macOS arm64 artifact
|
|
498
498
|
uses: actions/download-artifact@v3
|
|
499
499
|
with:
|
|
500
500
|
name: bindings-aarch64-apple-darwin
|
|
501
|
-
path:
|
|
501
|
+
path: .
|
|
502
502
|
|
|
503
503
|
- name: Combine binaries
|
|
504
|
-
run: yarn
|
|
504
|
+
run: yarn napi universalize
|
|
505
505
|
|
|
506
506
|
- name: Upload artifact
|
|
507
507
|
uses: actions/upload-artifact@v3
|
|
@@ -23,18 +23,17 @@ export const createPackageJson = ({
|
|
|
23
23
|
"node": "${engineRequirement}"
|
|
24
24
|
},
|
|
25
25
|
"napi": {
|
|
26
|
-
"
|
|
26
|
+
"binaryName": "${binaryName}",
|
|
27
27
|
"targets": [
|
|
28
28
|
${targets.map((t) => `"${t}"`).join(',\n ')}
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "
|
|
32
|
+
"test": "node -e \\"assert(require('.').sum(1, 2) === 3)\\"",
|
|
33
33
|
"build": "napi build --release --platform --strip",
|
|
34
34
|
"build:debug": "napi build",
|
|
35
35
|
"prepublishOnly": "napi prepublish -t npm",
|
|
36
36
|
"artifacts": "napi artifacts",
|
|
37
|
-
"universal": "napi universal",
|
|
38
37
|
"version": "napi version"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
package/src/utils/misc.ts
CHANGED
|
@@ -5,7 +5,12 @@ import { promisify } from 'util'
|
|
|
5
5
|
import { debug } from './log.js'
|
|
6
6
|
|
|
7
7
|
const require = createRequire(import.meta.url)
|
|
8
|
-
|
|
8
|
+
// NOTE:
|
|
9
|
+
// import pkgJson from '@napi-rs/cli/package.json' assert { type: 'json' }
|
|
10
|
+
// is experimental feature now, avoid using it.
|
|
11
|
+
// see: https://nodejs.org/api/esm.html#import-assertions
|
|
12
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
+
const pkgJson = require('@napi-rs/cli/package.json')
|
|
9
14
|
|
|
10
15
|
export const readFileAsync = promisify(readFile)
|
|
11
16
|
export const writeFileAsync = promisify(writeFile)
|
package/src/utils/target.ts
CHANGED
|
@@ -26,8 +26,6 @@ export const DEFAULT_TARGETS = [
|
|
|
26
26
|
] as const
|
|
27
27
|
|
|
28
28
|
export const TARGET_LINKER: Record<string, string> = {
|
|
29
|
-
'aarch64-unknown-linux-gnu': 'aarch64-linux-gnu-gcc',
|
|
30
|
-
'armv7-unknown-linux-gnueabihf': 'arm-linux-gnueabihf-gcc',
|
|
31
29
|
'aarch64-unknown-linux-musl': 'aarch64-linux-musl-gcc',
|
|
32
30
|
}
|
|
33
31
|
|