@napi-rs/cli 3.0.0-alpha.22 → 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/{load-wasi-template.js → templates/load-wasi-template.js} +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 +320 -269
- 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 +4 -2
- 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/{load-wasi-template.ts → templates/load-wasi-template.ts} +1 -1
- 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 +22 -2
- 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/{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/{wasi-worker-template.ts → templates/wasi-worker-template.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -4550,16 +4550,16 @@ var require_dist_node5 = __commonJS({
|
|
|
4550
4550
|
let headers = {};
|
|
4551
4551
|
let status;
|
|
4552
4552
|
let url;
|
|
4553
|
-
let { fetch } = globalThis;
|
|
4553
|
+
let { fetch: fetch2 } = globalThis;
|
|
4554
4554
|
if ((_b = requestOptions.request) == null ? void 0 : _b.fetch) {
|
|
4555
|
-
|
|
4555
|
+
fetch2 = requestOptions.request.fetch;
|
|
4556
4556
|
}
|
|
4557
|
-
if (!
|
|
4557
|
+
if (!fetch2) {
|
|
4558
4558
|
throw new Error(
|
|
4559
4559
|
"fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing"
|
|
4560
4560
|
);
|
|
4561
4561
|
}
|
|
4562
|
-
return
|
|
4562
|
+
return fetch2(requestOptions.url, {
|
|
4563
4563
|
method: requestOptions.method,
|
|
4564
4564
|
body: requestOptions.body,
|
|
4565
4565
|
headers: requestOptions.headers,
|
|
@@ -7815,18 +7815,18 @@ var debugFactory = (namespace) => {
|
|
|
7815
7815
|
var debug = debugFactory("utils");
|
|
7816
7816
|
|
|
7817
7817
|
// dist/utils/misc.js
|
|
7818
|
-
var
|
|
7819
|
-
var
|
|
7820
|
-
var
|
|
7821
|
-
var require2 = (0,
|
|
7818
|
+
var import_node_fs = require("node:fs");
|
|
7819
|
+
var import_node_module = require("node:module");
|
|
7820
|
+
var import_node_util = require("node:util");
|
|
7821
|
+
var require2 = (0, import_node_module.createRequire)(__filename);
|
|
7822
7822
|
var pkgJson = require2("@napi-rs/cli/package.json");
|
|
7823
|
-
var readFileAsync = (0,
|
|
7824
|
-
var writeFileAsync = (0,
|
|
7825
|
-
var unlinkAsync = (0,
|
|
7826
|
-
var copyFileAsync = (0,
|
|
7827
|
-
var mkdirAsync = (0,
|
|
7828
|
-
var statAsync = (0,
|
|
7829
|
-
var readdirAsync = (0,
|
|
7823
|
+
var readFileAsync = (0, import_node_util.promisify)(import_node_fs.readFile);
|
|
7824
|
+
var writeFileAsync = (0, import_node_util.promisify)(import_node_fs.writeFile);
|
|
7825
|
+
var unlinkAsync = (0, import_node_util.promisify)(import_node_fs.unlink);
|
|
7826
|
+
var copyFileAsync = (0, import_node_util.promisify)(import_node_fs.copyFile);
|
|
7827
|
+
var mkdirAsync = (0, import_node_util.promisify)(import_node_fs.mkdir);
|
|
7828
|
+
var statAsync = (0, import_node_util.promisify)(import_node_fs.stat);
|
|
7829
|
+
var readdirAsync = (0, import_node_util.promisify)(import_node_fs.readdir);
|
|
7830
7830
|
async function fileExists(path2) {
|
|
7831
7831
|
const exists = await statAsync(path2).then(() => true).catch(() => false);
|
|
7832
7832
|
return exists;
|
|
@@ -7850,6 +7850,9 @@ var CLI_VERSION = pkgJson.version;
|
|
|
7850
7850
|
|
|
7851
7851
|
// dist/utils/target.js
|
|
7852
7852
|
var import_node_child_process = require("node:child_process");
|
|
7853
|
+
var UNIVERSAL_TARGETS = {
|
|
7854
|
+
"universal-apple-darwin": ["aarch64-apple-darwin", "x86_64-apple-darwin"]
|
|
7855
|
+
};
|
|
7853
7856
|
var AVAILABLE_TARGETS = [
|
|
7854
7857
|
"aarch64-apple-darwin",
|
|
7855
7858
|
"aarch64-linux-android",
|
|
@@ -7865,10 +7868,12 @@ var AVAILABLE_TARGETS = [
|
|
|
7865
7868
|
"armv7-unknown-linux-gnueabihf",
|
|
7866
7869
|
"armv7-linux-androideabi",
|
|
7867
7870
|
"universal-apple-darwin",
|
|
7868
|
-
"riscv64gc-unknown-linux-gnu"
|
|
7871
|
+
"riscv64gc-unknown-linux-gnu",
|
|
7872
|
+
"wasm32-wasi-preview1-threads"
|
|
7869
7873
|
];
|
|
7870
7874
|
var DEFAULT_TARGETS = [
|
|
7871
7875
|
"x86_64-apple-darwin",
|
|
7876
|
+
"aarch64-apple-darwin",
|
|
7872
7877
|
"x86_64-pc-windows-msvc",
|
|
7873
7878
|
"x86_64-unknown-linux-gnu"
|
|
7874
7879
|
];
|
|
@@ -7903,7 +7908,7 @@ function parseTriple(rawTriple) {
|
|
|
7903
7908
|
if (rawTriple === "wasm32-wasi-preview1-threads") {
|
|
7904
7909
|
return {
|
|
7905
7910
|
triple: rawTriple,
|
|
7906
|
-
platformArchABI:
|
|
7911
|
+
platformArchABI: "wasm32-wasi",
|
|
7907
7912
|
platform: "wasi",
|
|
7908
7913
|
arch: "wasm32",
|
|
7909
7914
|
abi: "wasi"
|
|
@@ -8009,15 +8014,15 @@ function napiEngineRequirement(napiVersion) {
|
|
|
8009
8014
|
}
|
|
8010
8015
|
|
|
8011
8016
|
// dist/utils/metadata.js
|
|
8012
|
-
var
|
|
8013
|
-
var
|
|
8017
|
+
var import_node_child_process2 = require("node:child_process");
|
|
8018
|
+
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
8014
8019
|
function parseMetadata(manifestPath) {
|
|
8015
|
-
if (!
|
|
8020
|
+
if (!import_node_fs2.default.existsSync(manifestPath)) {
|
|
8016
8021
|
throw new Error(`No crate found in manifest: ${manifestPath}`);
|
|
8017
8022
|
}
|
|
8018
8023
|
const cmd = `cargo metadata --manifest-path ${manifestPath} --format-version 1 --no-deps`;
|
|
8019
8024
|
try {
|
|
8020
|
-
const output = (0,
|
|
8025
|
+
const output = (0, import_node_child_process2.execSync)(cmd, {
|
|
8021
8026
|
encoding: "utf-8"
|
|
8022
8027
|
});
|
|
8023
8028
|
return JSON.parse(output);
|
|
@@ -10435,12 +10440,12 @@ async function readNapiConfig(path2, configPath) {
|
|
|
10435
10440
|
}, omit_default(userNapiConfig, "targets"));
|
|
10436
10441
|
let targets = userNapiConfig.targets ?? [];
|
|
10437
10442
|
if (userNapiConfig?.name) {
|
|
10438
|
-
console.warn(`[DEPRECATED] napi.name is deprecated, use napi.binaryName instead.`);
|
|
10443
|
+
console.warn(yellow(`[DEPRECATED] napi.name is deprecated, use napi.binaryName instead.`));
|
|
10439
10444
|
napiConfig.binaryName = userNapiConfig.name;
|
|
10440
10445
|
}
|
|
10441
10446
|
if (!targets.length) {
|
|
10442
10447
|
let deprecatedWarned = false;
|
|
10443
|
-
const warning = `[DEPRECATED] napi.triples is deprecated, use napi.targets instead
|
|
10448
|
+
const warning = yellow(`[DEPRECATED] napi.triples is deprecated, use napi.targets instead.`);
|
|
10444
10449
|
if (userNapiConfig.triples?.defaults) {
|
|
10445
10450
|
deprecatedWarned = true;
|
|
10446
10451
|
console.warn(warning);
|
|
@@ -10458,7 +10463,7 @@ async function readNapiConfig(path2, configPath) {
|
|
|
10458
10463
|
}
|
|
10459
10464
|
|
|
10460
10465
|
// dist/utils/cargo.js
|
|
10461
|
-
var
|
|
10466
|
+
var import_node_child_process3 = require("node:child_process");
|
|
10462
10467
|
function tryInstallCargoBinary(name, bin) {
|
|
10463
10468
|
if (detectCargoBinary(bin)) {
|
|
10464
10469
|
debug("Cargo binary already installed: %s", name);
|
|
@@ -10466,7 +10471,7 @@ function tryInstallCargoBinary(name, bin) {
|
|
|
10466
10471
|
}
|
|
10467
10472
|
try {
|
|
10468
10473
|
debug("Installing cargo binary: %s", name);
|
|
10469
|
-
(0,
|
|
10474
|
+
(0, import_node_child_process3.execSync)(`cargo install ${name}`, {
|
|
10470
10475
|
stdio: "inherit"
|
|
10471
10476
|
});
|
|
10472
10477
|
} catch (e) {
|
|
@@ -10478,7 +10483,7 @@ function tryInstallCargoBinary(name, bin) {
|
|
|
10478
10483
|
function detectCargoBinary(bin) {
|
|
10479
10484
|
debug("Detecting cargo binary: %s", bin);
|
|
10480
10485
|
try {
|
|
10481
|
-
(0,
|
|
10486
|
+
(0, import_node_child_process3.execSync)(`cargo help ${bin}`, {
|
|
10482
10487
|
stdio: "ignore"
|
|
10483
10488
|
});
|
|
10484
10489
|
debug("Cargo binary detected: %s", bin);
|
|
@@ -10705,72 +10710,13 @@ async function collectNodeBinaries(root2) {
|
|
|
10705
10710
|
}
|
|
10706
10711
|
|
|
10707
10712
|
// dist/api/build.js
|
|
10708
|
-
var
|
|
10713
|
+
var import_node_child_process4 = require("node:child_process");
|
|
10709
10714
|
var import_node_crypto = require("node:crypto");
|
|
10710
|
-
var
|
|
10711
|
-
var
|
|
10715
|
+
var import_node_fs3 = require("node:fs");
|
|
10716
|
+
var import_node_module2 = require("node:module");
|
|
10712
10717
|
var import_node_os = require("node:os");
|
|
10713
10718
|
var import_node_path2 = require("node:path");
|
|
10714
10719
|
|
|
10715
|
-
// dist/api/load-wasi-template.js
|
|
10716
|
-
var createWasiBinding = (wasmFileName, wasiRegisterFunctions) => `/* eslint-disable */
|
|
10717
|
-
/* prettier-ignore */
|
|
10718
|
-
|
|
10719
|
-
/* auto-generated by NAPI-RS */
|
|
10720
|
-
|
|
10721
|
-
const __nodeFs= require('node:fs')
|
|
10722
|
-
const __nodePath = require('node:path')
|
|
10723
|
-
const { WASI: __nodeWASI } = require('node:wasi')
|
|
10724
|
-
const { Worker } = require('node:worker_threads')
|
|
10725
|
-
|
|
10726
|
-
const { instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync } = require('@emnapi/core')
|
|
10727
|
-
const { getDefaultContext: __emnapiGetDefaultContext } = require('@emnapi/runtime')
|
|
10728
|
-
|
|
10729
|
-
const __wasi = new __nodeWASI({
|
|
10730
|
-
version: 'preview1',
|
|
10731
|
-
env: process.env,
|
|
10732
|
-
preopens: {
|
|
10733
|
-
'/': __dirname,
|
|
10734
|
-
}
|
|
10735
|
-
})
|
|
10736
|
-
|
|
10737
|
-
const __emnapiContext = __emnapiGetDefaultContext()
|
|
10738
|
-
|
|
10739
|
-
const __sharedMemory = new WebAssembly.Memory({
|
|
10740
|
-
initial: 1024,
|
|
10741
|
-
maximum: 10240,
|
|
10742
|
-
shared: true,
|
|
10743
|
-
})
|
|
10744
|
-
|
|
10745
|
-
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__nodePath.join(__dirname, '${wasmFileName}.wasm')), {
|
|
10746
|
-
context: __emnapiContext,
|
|
10747
|
-
asyncWorkPoolSize: 4,
|
|
10748
|
-
wasi: __wasi,
|
|
10749
|
-
onCreateWorker() {
|
|
10750
|
-
return new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
|
10751
|
-
env: process.env,
|
|
10752
|
-
execArgv: ['--experimental-wasi-unstable-preview1'],
|
|
10753
|
-
})
|
|
10754
|
-
},
|
|
10755
|
-
overwriteImports(importObject) {
|
|
10756
|
-
importObject.env = {
|
|
10757
|
-
...importObject.env,
|
|
10758
|
-
...importObject.napi,
|
|
10759
|
-
...importObject.emnapi,
|
|
10760
|
-
memory: __sharedMemory,
|
|
10761
|
-
}
|
|
10762
|
-
return importObject
|
|
10763
|
-
},
|
|
10764
|
-
beforeInit({ instance }) {
|
|
10765
|
-
__napi_rs_initialize_modules(instance)
|
|
10766
|
-
}
|
|
10767
|
-
})
|
|
10768
|
-
|
|
10769
|
-
function __napi_rs_initialize_modules(__napiInstance) {
|
|
10770
|
-
${wasiRegisterFunctions.map((name) => ` __napiInstance.exports['${name}']?.()`).join("\n")}
|
|
10771
|
-
}
|
|
10772
|
-
`;
|
|
10773
|
-
|
|
10774
10720
|
// dist/api/templates/.gitignore.js
|
|
10775
10721
|
var gitIgnore = `# Created by https://www.toptal.com/developers/gitignore/api/node
|
|
10776
10722
|
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
|
@@ -13679,7 +13625,7 @@ var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
|
13679
13625
|
var safeDump = renamed("safeDump", "dump");
|
|
13680
13626
|
|
|
13681
13627
|
// dist/api/templates/ci-template.js
|
|
13682
|
-
var YAML = () => `
|
|
13628
|
+
var YAML = (packageManager) => `
|
|
13683
13629
|
name: CI
|
|
13684
13630
|
|
|
13685
13631
|
env:
|
|
@@ -13713,89 +13659,53 @@ jobs:
|
|
|
13713
13659
|
settings:
|
|
13714
13660
|
- host: macos-latest
|
|
13715
13661
|
target: 'x86_64-apple-darwin'
|
|
13716
|
-
build:
|
|
13717
|
-
yarn build --platform
|
|
13718
|
-
strip -x *.node
|
|
13662
|
+
build: ${packageManager} build --platform
|
|
13719
13663
|
- host: windows-latest
|
|
13720
|
-
build:
|
|
13664
|
+
build: ${packageManager} build --platform
|
|
13721
13665
|
target: 'x86_64-pc-windows-msvc'
|
|
13722
13666
|
- host: windows-latest
|
|
13723
13667
|
build: |
|
|
13724
|
-
|
|
13725
|
-
|
|
13668
|
+
${packageManager} build --platform --target i686-pc-windows-msvc
|
|
13669
|
+
${packageManager} test
|
|
13726
13670
|
target: 'i686-pc-windows-msvc'
|
|
13727
13671
|
- host: ubuntu-latest
|
|
13728
13672
|
target: 'x86_64-unknown-linux-gnu'
|
|
13729
|
-
|
|
13730
|
-
build: >-
|
|
13731
|
-
set -e &&
|
|
13732
|
-
|
|
13733
|
-
yarn build --platform --target x86_64-unknown-linux-gnu &&
|
|
13734
|
-
|
|
13735
|
-
strip *.node
|
|
13673
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-gnu --use-napi-cross
|
|
13736
13674
|
- host: ubuntu-latest
|
|
13737
13675
|
target: 'x86_64-unknown-linux-musl'
|
|
13738
|
-
|
|
13739
|
-
build: >-
|
|
13740
|
-
set -e &&
|
|
13741
|
-
yarn build --platform &&
|
|
13742
|
-
strip *.node
|
|
13676
|
+
build: ${packageManager} build --platform --target x86_64-unknown-linux-musl -x
|
|
13743
13677
|
- host: macos-latest
|
|
13744
13678
|
target: 'aarch64-apple-darwin'
|
|
13745
|
-
build:
|
|
13746
|
-
yarn build --platform --target aarch64-apple-darwin
|
|
13747
|
-
strip -x *.node
|
|
13679
|
+
build: ${packageManager} build --platform --target aarch64-apple-darwin
|
|
13748
13680
|
- host: ubuntu-latest
|
|
13749
13681
|
target: 'aarch64-unknown-linux-gnu'
|
|
13750
|
-
|
|
13751
|
-
build: >-
|
|
13752
|
-
set -e &&
|
|
13753
|
-
|
|
13754
|
-
yarn build --platform --target aarch64-unknown-linux-gnu &&
|
|
13755
|
-
|
|
13756
|
-
aarch64-unknown-linux-gnu-strip *.node
|
|
13682
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-gnu --use-napi-cross
|
|
13757
13683
|
- host: ubuntu-latest
|
|
13758
13684
|
target: 'armv7-unknown-linux-gnueabihf'
|
|
13759
|
-
|
|
13760
|
-
sudo apt-get update
|
|
13761
|
-
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
13762
|
-
build: |
|
|
13763
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
13764
|
-
arm-linux-gnueabihf-strip *.node
|
|
13685
|
+
build: ${packageManager} build --platform --target armv7-unknown-linux-gnueabihf --use-napi-cross
|
|
13765
13686
|
- host: ubuntu-latest
|
|
13766
13687
|
target: 'aarch64-linux-android'
|
|
13767
|
-
build:
|
|
13768
|
-
yarn build --platform --target aarch64-linux-android
|
|
13769
|
-
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
13688
|
+
build: ${packageManager} build --platform --target aarch64-linux-android
|
|
13770
13689
|
- host: ubuntu-latest
|
|
13771
13690
|
target: 'armv7-linux-androideabi'
|
|
13772
|
-
build:
|
|
13773
|
-
yarn build --platform --target armv7-linux-androideabi
|
|
13774
|
-
\${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip *.node
|
|
13691
|
+
build: ${packageManager} build --platform --target armv7-linux-androideabi
|
|
13775
13692
|
- host: ubuntu-latest
|
|
13776
13693
|
target: 'aarch64-unknown-linux-musl'
|
|
13777
|
-
|
|
13778
|
-
build: >-
|
|
13779
|
-
set -e &&
|
|
13780
|
-
|
|
13781
|
-
rustup target add aarch64-unknown-linux-musl &&
|
|
13782
|
-
|
|
13783
|
-
yarn build --platform --target aarch64-unknown-linux-musl &&
|
|
13784
|
-
|
|
13785
|
-
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
|
|
13694
|
+
build: ${packageManager} build --platform --target aarch64-unknown-linux-musl -x
|
|
13786
13695
|
- host: windows-latest
|
|
13787
13696
|
target: 'aarch64-pc-windows-msvc'
|
|
13788
|
-
build:
|
|
13697
|
+
build: ${packageManager} build --platform --target aarch64-pc-windows-msvc
|
|
13789
13698
|
- host: ubuntu-latest
|
|
13790
13699
|
target: 'riscv64gc-unknown-linux-gnu'
|
|
13791
13700
|
setup: |
|
|
13792
13701
|
sudo apt-get update
|
|
13793
13702
|
sudo apt-get install gcc-riscv64-linux-gnu -y
|
|
13794
|
-
build:
|
|
13795
|
-
|
|
13796
|
-
|
|
13703
|
+
build: ${packageManager} build --platform --target riscv64gc-unknown-linux-gnu
|
|
13704
|
+
- host: ubuntu-latest
|
|
13705
|
+
target: 'wasm32-wasi-preview1-threads'
|
|
13706
|
+
build: ${packageManager} build --platform --target wasm32-wasi-preview1-threads
|
|
13797
13707
|
|
|
13798
|
-
name: stable - \${{ matrix.settings.target }} - node@
|
|
13708
|
+
name: stable - \${{ matrix.settings.target }} - node@20
|
|
13799
13709
|
runs-on: \${{ matrix.settings.host }}
|
|
13800
13710
|
|
|
13801
13711
|
steps:
|
|
@@ -13803,14 +13713,12 @@ jobs:
|
|
|
13803
13713
|
|
|
13804
13714
|
- name: Setup node
|
|
13805
13715
|
uses: actions/setup-node@v4
|
|
13806
|
-
if: \${{ !matrix.settings.docker }}
|
|
13807
13716
|
with:
|
|
13808
|
-
node-version:
|
|
13809
|
-
cache:
|
|
13717
|
+
node-version: 20
|
|
13718
|
+
cache: ${packageManager}
|
|
13810
13719
|
|
|
13811
13720
|
- name: Install
|
|
13812
13721
|
uses: dtolnay/rust-toolchain@stable
|
|
13813
|
-
if: \${{ !matrix.settings.docker }}
|
|
13814
13722
|
with:
|
|
13815
13723
|
toolchain: stable
|
|
13816
13724
|
targets: \${{ matrix.settings.target }}
|
|
@@ -13822,12 +13730,13 @@ jobs:
|
|
|
13822
13730
|
~/.cargo/registry/index/
|
|
13823
13731
|
~/.cargo/registry/cache/
|
|
13824
13732
|
~/.cargo/git/db/
|
|
13733
|
+
~/.napi-rs
|
|
13825
13734
|
.cargo-cache
|
|
13826
13735
|
target/
|
|
13827
13736
|
key: \${{ matrix.settings.target }}-cargo-\${{ matrix.settings.host }}
|
|
13828
13737
|
|
|
13829
13738
|
- uses: goto-bus-stop/setup-zig@v2
|
|
13830
|
-
if: \${{ matrix.settings.target
|
|
13739
|
+
if: \${{ contains(matrix.settings.target, 'musl') }}
|
|
13831
13740
|
with:
|
|
13832
13741
|
version: 0.11.0
|
|
13833
13742
|
|
|
@@ -13842,36 +13751,35 @@ jobs:
|
|
|
13842
13751
|
shell: bash
|
|
13843
13752
|
|
|
13844
13753
|
- name: 'Install dependencies'
|
|
13845
|
-
run:
|
|
13754
|
+
run: ${packageManager} install
|
|
13846
13755
|
|
|
13847
13756
|
- name: Setup node x86
|
|
13848
13757
|
uses: actions/setup-node@v4
|
|
13849
13758
|
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
13850
13759
|
with:
|
|
13851
|
-
node-version:
|
|
13852
|
-
cache: yarn
|
|
13760
|
+
node-version: 20
|
|
13853
13761
|
architecture: x86
|
|
13854
13762
|
|
|
13855
|
-
- name: Build in docker
|
|
13856
|
-
uses: addnab/docker-run-action@v3
|
|
13857
|
-
if: \${{ matrix.settings.docker }}
|
|
13858
|
-
with:
|
|
13859
|
-
image: \${{ matrix.settings.docker }}
|
|
13860
|
-
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
|
|
13861
|
-
run: \${{ matrix.settings.build }}
|
|
13862
|
-
|
|
13863
13763
|
- name: 'Build'
|
|
13864
13764
|
run: \${{ matrix.settings.build }}
|
|
13865
|
-
if: \${{ !matrix.settings.docker }}
|
|
13866
13765
|
shell: bash
|
|
13867
13766
|
|
|
13868
13767
|
- name: Upload artifact
|
|
13869
|
-
uses: actions/upload-artifact@
|
|
13768
|
+
uses: actions/upload-artifact@v4
|
|
13769
|
+
if: matrix.settings.target != 'wasm32-wasi-preview1-threads'
|
|
13870
13770
|
with:
|
|
13871
13771
|
name: bindings-\${{ matrix.settings.target }}
|
|
13872
13772
|
path: "*.node"
|
|
13873
13773
|
if-no-files-found: error
|
|
13874
13774
|
|
|
13775
|
+
- name: Upload artifact
|
|
13776
|
+
uses: actions/upload-artifact@v4
|
|
13777
|
+
if: matrix.settings.target == 'wasm32-wasi-preview1-threads'
|
|
13778
|
+
with:
|
|
13779
|
+
name: bindings-\${{ matrix.settings.target }}
|
|
13780
|
+
path: "*.wasm"
|
|
13781
|
+
if-no-files-found: error
|
|
13782
|
+
|
|
13875
13783
|
build-freebsd:
|
|
13876
13784
|
runs-on: macos-12
|
|
13877
13785
|
name: Build FreeBSD
|
|
@@ -13879,7 +13787,8 @@ jobs:
|
|
|
13879
13787
|
- uses: actions/checkout@v4
|
|
13880
13788
|
- name: Build
|
|
13881
13789
|
id: build
|
|
13882
|
-
uses: cross-platform-actions/action@v0.21.
|
|
13790
|
+
uses: cross-platform-actions/action@v0.21.1
|
|
13791
|
+
timeout-minutes: 30
|
|
13883
13792
|
env:
|
|
13884
13793
|
DEBUG: 'napi:*'
|
|
13885
13794
|
RUSTUP_IO_THREADS: 1
|
|
@@ -13890,9 +13799,9 @@ jobs:
|
|
|
13890
13799
|
cpu_count: 3
|
|
13891
13800
|
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
|
|
13892
13801
|
shell: bash
|
|
13893
|
-
|
|
13802
|
+
run: |
|
|
13894
13803
|
sudo pkg install -y -f curl node libnghttp2 npm
|
|
13895
|
-
sudo npm install -g
|
|
13804
|
+
sudo npm install -g ${packageManager} --ignore-scripts
|
|
13896
13805
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
13897
13806
|
sh rustup.sh -y --profile minimal --default-toolchain stable
|
|
13898
13807
|
source "$HOME/.cargo/env"
|
|
@@ -13907,15 +13816,15 @@ jobs:
|
|
|
13907
13816
|
whoami
|
|
13908
13817
|
env
|
|
13909
13818
|
freebsd-version
|
|
13910
|
-
|
|
13911
|
-
|
|
13819
|
+
${packageManager} install
|
|
13820
|
+
${packageManager} build
|
|
13912
13821
|
strip -x *.node
|
|
13913
13822
|
yarn test
|
|
13914
13823
|
rm -rf node_modules
|
|
13915
13824
|
rm -rf target
|
|
13916
13825
|
rm -rf .yarn/cache
|
|
13917
13826
|
- name: Upload artifact
|
|
13918
|
-
uses: actions/upload-artifact@
|
|
13827
|
+
uses: actions/upload-artifact@v4
|
|
13919
13828
|
with:
|
|
13920
13829
|
name: bindings-freebsd
|
|
13921
13830
|
path: "*.node"
|
|
@@ -13943,13 +13852,13 @@ jobs:
|
|
|
13943
13852
|
uses: actions/setup-node@v4
|
|
13944
13853
|
with:
|
|
13945
13854
|
node-version: \${{ matrix.node }}
|
|
13946
|
-
cache: '
|
|
13855
|
+
cache: '${packageManager}'
|
|
13947
13856
|
|
|
13948
13857
|
- name: 'Install dependencies'
|
|
13949
|
-
run:
|
|
13858
|
+
run: ${packageManager} install
|
|
13950
13859
|
|
|
13951
13860
|
- name: Download artifacts
|
|
13952
|
-
uses: actions/download-artifact@
|
|
13861
|
+
uses: actions/download-artifact@v4
|
|
13953
13862
|
with:
|
|
13954
13863
|
name: bindings-\${{ matrix.settings.target }}
|
|
13955
13864
|
path: .
|
|
@@ -13959,7 +13868,7 @@ jobs:
|
|
|
13959
13868
|
shell: bash
|
|
13960
13869
|
|
|
13961
13870
|
- name: Test bindings
|
|
13962
|
-
run:
|
|
13871
|
+
run: ${packageManager} test
|
|
13963
13872
|
|
|
13964
13873
|
test-linux-x64-gnu-binding:
|
|
13965
13874
|
name: Test bindings on Linux-x64-gnu - node@\${{ matrix.node }}
|
|
@@ -13978,13 +13887,13 @@ jobs:
|
|
|
13978
13887
|
uses: actions/setup-node@v4
|
|
13979
13888
|
with:
|
|
13980
13889
|
node-version: \${{ matrix.node }}
|
|
13981
|
-
cache: '
|
|
13890
|
+
cache: '${packageManager}'
|
|
13982
13891
|
|
|
13983
13892
|
- name: 'Install dependencies'
|
|
13984
|
-
run:
|
|
13893
|
+
run: ${packageManager} install
|
|
13985
13894
|
|
|
13986
13895
|
- name: Download artifacts
|
|
13987
|
-
uses: actions/download-artifact@
|
|
13896
|
+
uses: actions/download-artifact@v4
|
|
13988
13897
|
with:
|
|
13989
13898
|
name: bindings-x86_64-unknown-linux-gnu
|
|
13990
13899
|
path: .
|
|
@@ -14018,10 +13927,10 @@ jobs:
|
|
|
14018
13927
|
- name: 'Install dependencies'
|
|
14019
13928
|
run: |
|
|
14020
13929
|
yarn config set supportedArchitectures.libc "musl"
|
|
14021
|
-
|
|
13930
|
+
${packageManager} install
|
|
14022
13931
|
|
|
14023
13932
|
- name: Download artifacts
|
|
14024
|
-
uses: actions/download-artifact@
|
|
13933
|
+
uses: actions/download-artifact@v4
|
|
14025
13934
|
with:
|
|
14026
13935
|
name: bindings-x86_64-unknown-linux-musl
|
|
14027
13936
|
path: .
|
|
@@ -14040,14 +13949,14 @@ jobs:
|
|
|
14040
13949
|
strategy:
|
|
14041
13950
|
fail-fast: false
|
|
14042
13951
|
matrix:
|
|
14043
|
-
node: ['
|
|
13952
|
+
node: ['20']
|
|
14044
13953
|
runs-on: ubuntu-latest
|
|
14045
13954
|
|
|
14046
13955
|
steps:
|
|
14047
13956
|
- uses: actions/checkout@v4
|
|
14048
13957
|
|
|
14049
13958
|
- name: Download artifacts
|
|
14050
|
-
uses: actions/download-artifact@
|
|
13959
|
+
uses: actions/download-artifact@v4
|
|
14051
13960
|
with:
|
|
14052
13961
|
name: bindings-aarch64-unknown-linux-gnu
|
|
14053
13962
|
path: .
|
|
@@ -14060,7 +13969,7 @@ jobs:
|
|
|
14060
13969
|
run: |
|
|
14061
13970
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
14062
13971
|
yarn config set supportedArchitectures.libc "glibc"
|
|
14063
|
-
|
|
13972
|
+
${packageManager} install
|
|
14064
13973
|
|
|
14065
13974
|
- name: Set up QEMU
|
|
14066
13975
|
uses: docker/setup-qemu-action@v3
|
|
@@ -14073,10 +13982,7 @@ jobs:
|
|
|
14073
13982
|
with:
|
|
14074
13983
|
image: node:\${{ matrix.node }}-slim
|
|
14075
13984
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
14076
|
-
run:
|
|
14077
|
-
set -e
|
|
14078
|
-
yarn test
|
|
14079
|
-
ls -la
|
|
13985
|
+
run: yarn test
|
|
14080
13986
|
|
|
14081
13987
|
test-linux-aarch64-musl-binding:
|
|
14082
13988
|
name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
@@ -14093,7 +13999,7 @@ jobs:
|
|
|
14093
13999
|
- uses: actions/checkout@v4
|
|
14094
14000
|
|
|
14095
14001
|
- name: Download artifacts
|
|
14096
|
-
uses: actions/download-artifact@
|
|
14002
|
+
uses: actions/download-artifact@v4
|
|
14097
14003
|
with:
|
|
14098
14004
|
name: bindings-aarch64-unknown-linux-musl
|
|
14099
14005
|
path: .
|
|
@@ -14106,7 +14012,7 @@ jobs:
|
|
|
14106
14012
|
run: |
|
|
14107
14013
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
14108
14014
|
yarn config set supportedArchitectures.libc "musl"
|
|
14109
|
-
|
|
14015
|
+
${packageManager} install
|
|
14110
14016
|
|
|
14111
14017
|
- name: Set up QEMU
|
|
14112
14018
|
uses: docker/setup-qemu-action@v3
|
|
@@ -14119,9 +14025,7 @@ jobs:
|
|
|
14119
14025
|
with:
|
|
14120
14026
|
image: node:\${{ matrix.node }}-alpine
|
|
14121
14027
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
14122
|
-
run:
|
|
14123
|
-
set -e
|
|
14124
|
-
yarn test
|
|
14028
|
+
run: yarn test
|
|
14125
14029
|
|
|
14126
14030
|
test-linux-arm-gnueabihf-binding:
|
|
14127
14031
|
name: Test bindings on armv7-unknown-linux-gnueabihf - node@\${{ matrix.node }}
|
|
@@ -14137,7 +14041,7 @@ jobs:
|
|
|
14137
14041
|
- uses: actions/checkout@v4
|
|
14138
14042
|
|
|
14139
14043
|
- name: Download artifacts
|
|
14140
|
-
uses: actions/download-artifact@
|
|
14044
|
+
uses: actions/download-artifact@v4
|
|
14141
14045
|
with:
|
|
14142
14046
|
name: bindings-armv7-unknown-linux-gnueabihf
|
|
14143
14047
|
path: .
|
|
@@ -14149,7 +14053,7 @@ jobs:
|
|
|
14149
14053
|
- name: Install dependencies
|
|
14150
14054
|
run: |
|
|
14151
14055
|
yarn config set supportedArchitectures.cpu "arm"
|
|
14152
|
-
|
|
14056
|
+
${packageManager} install
|
|
14153
14057
|
|
|
14154
14058
|
- name: Set up QEMU
|
|
14155
14059
|
uses: docker/setup-qemu-action@v3
|
|
@@ -14162,10 +14066,7 @@ jobs:
|
|
|
14162
14066
|
with:
|
|
14163
14067
|
image: node:\${{ matrix.node }}-bullseye-slim
|
|
14164
14068
|
options: --platform linux/arm/v7 -v \${{ github.workspace }}:/build -w /build
|
|
14165
|
-
run:
|
|
14166
|
-
set -e
|
|
14167
|
-
yarn test
|
|
14168
|
-
ls -la
|
|
14069
|
+
run: ${packageManager} test
|
|
14169
14070
|
|
|
14170
14071
|
universal-macOS:
|
|
14171
14072
|
name: Build universal macOS binary
|
|
@@ -14179,33 +14080,62 @@ jobs:
|
|
|
14179
14080
|
- name: Setup node
|
|
14180
14081
|
uses: actions/setup-node@v4
|
|
14181
14082
|
with:
|
|
14182
|
-
node-version:
|
|
14183
|
-
cache:
|
|
14083
|
+
node-version: 20
|
|
14084
|
+
cache: ${packageManager}
|
|
14184
14085
|
|
|
14185
14086
|
- name: 'Install dependencies'
|
|
14186
|
-
run:
|
|
14087
|
+
run: ${packageManager} install
|
|
14187
14088
|
|
|
14188
14089
|
- name: Download macOS x64 artifact
|
|
14189
|
-
uses: actions/download-artifact@
|
|
14090
|
+
uses: actions/download-artifact@v4
|
|
14190
14091
|
with:
|
|
14191
14092
|
name: bindings-x86_64-apple-darwin
|
|
14192
14093
|
path: .
|
|
14193
14094
|
- name: Download macOS arm64 artifact
|
|
14194
|
-
uses: actions/download-artifact@
|
|
14095
|
+
uses: actions/download-artifact@v4
|
|
14195
14096
|
with:
|
|
14196
14097
|
name: bindings-aarch64-apple-darwin
|
|
14197
14098
|
path: .
|
|
14198
14099
|
|
|
14199
14100
|
- name: Combine binaries
|
|
14200
|
-
run:
|
|
14101
|
+
run: ${packageManager} napi universalize
|
|
14201
14102
|
|
|
14202
14103
|
- name: Upload artifact
|
|
14203
|
-
uses: actions/upload-artifact@
|
|
14104
|
+
uses: actions/upload-artifact@v4
|
|
14204
14105
|
with:
|
|
14205
14106
|
name: bindings-universal-apple-darwin
|
|
14206
14107
|
path: "*.node"
|
|
14207
14108
|
if-no-files-found: error
|
|
14208
14109
|
|
|
14110
|
+
test-wasi-nodejs:
|
|
14111
|
+
name: Test bindings on wasi - node@\${{ matrix.node }}
|
|
14112
|
+
needs:
|
|
14113
|
+
- build
|
|
14114
|
+
strategy:
|
|
14115
|
+
fail-fast: false
|
|
14116
|
+
matrix:
|
|
14117
|
+
node: ['18', '20']
|
|
14118
|
+
runs-on: ubuntu-latest
|
|
14119
|
+
steps:
|
|
14120
|
+
- uses: actions/checkout@v4
|
|
14121
|
+
- name: Download artifacts
|
|
14122
|
+
uses: actions/download-artifact@v4
|
|
14123
|
+
with:
|
|
14124
|
+
name: bindings-wasm32-wasi-preview1-threads
|
|
14125
|
+
path: .
|
|
14126
|
+
- name: List packages
|
|
14127
|
+
run: ls -R .
|
|
14128
|
+
- uses: actions/setup-node@v4
|
|
14129
|
+
with:
|
|
14130
|
+
node-version: \${{ matrix.node }}
|
|
14131
|
+
cache: ${packageManager}
|
|
14132
|
+
- name: 'Install dependencies'
|
|
14133
|
+
run: ${packageManager} install
|
|
14134
|
+
- name: Test
|
|
14135
|
+
run: ${packageManager} test
|
|
14136
|
+
env:
|
|
14137
|
+
NAPI_RS_FORCE_WASI: true
|
|
14138
|
+
|
|
14209
14139
|
publish:
|
|
14210
14140
|
name: Publish
|
|
14211
14141
|
runs-on: ubuntu-latest
|
|
@@ -14216,6 +14146,7 @@ jobs:
|
|
|
14216
14146
|
- test-linux-arm-gnueabihf-binding
|
|
14217
14147
|
- test-macOS-windows-binding
|
|
14218
14148
|
- test-linux-aarch64-musl-binding
|
|
14149
|
+
- test-wasi-nodejs
|
|
14219
14150
|
- build-freebsd
|
|
14220
14151
|
|
|
14221
14152
|
steps:
|
|
@@ -14224,15 +14155,15 @@ jobs:
|
|
|
14224
14155
|
- name: Setup node
|
|
14225
14156
|
uses: actions/setup-node@v4
|
|
14226
14157
|
with:
|
|
14227
|
-
node-version:
|
|
14228
|
-
cache: '
|
|
14158
|
+
node-version: 20
|
|
14159
|
+
cache: '${packageManager}'
|
|
14229
14160
|
registry-url: 'https://registry.npmjs.org'
|
|
14230
14161
|
|
|
14231
14162
|
- name: 'Install dependencies'
|
|
14232
|
-
run:
|
|
14163
|
+
run: ${packageManager} install
|
|
14233
14164
|
|
|
14234
14165
|
- name: Download all artifacts
|
|
14235
|
-
uses: actions/download-artifact@
|
|
14166
|
+
uses: actions/download-artifact@v4
|
|
14236
14167
|
with:
|
|
14237
14168
|
path: artifacts
|
|
14238
14169
|
|
|
@@ -14267,8 +14198,9 @@ var TEST_LINUX_X64_MUSL = "test-linux-x64-musl-binding";
|
|
|
14267
14198
|
var TEST_LINUX_AARCH64_GNU = "test-linux-aarch64-gnu-binding";
|
|
14268
14199
|
var TEST_LINUX_AARCH64_MUSL = "test-linux-aarch64-musl-binding";
|
|
14269
14200
|
var TEST_LINUX_ARM_GNUEABIHF = "test-linux-arm-gnueabihf-binding";
|
|
14201
|
+
var TEST_WASI = "test-wasi-nodejs";
|
|
14270
14202
|
var UNIVERSAL_MACOS = "universal-macOS";
|
|
14271
|
-
var createGithubActionsCIYml = (targets) => {
|
|
14203
|
+
var createGithubActionsCIYml = (targets, packageManager) => {
|
|
14272
14204
|
const allTargets = new Set(targets.flatMap((t) => {
|
|
14273
14205
|
const platform2 = parseTriple(t);
|
|
14274
14206
|
if (platform2.arch === "universal") {
|
|
@@ -14277,7 +14209,7 @@ var createGithubActionsCIYml = (targets) => {
|
|
|
14277
14209
|
}
|
|
14278
14210
|
return [t];
|
|
14279
14211
|
}));
|
|
14280
|
-
const fullTemplate = load(YAML());
|
|
14212
|
+
const fullTemplate = load(YAML(packageManager));
|
|
14281
14213
|
const requiredSteps = [];
|
|
14282
14214
|
const enableWindowsX86 = allTargets.has("x86_64-pc-windows-msvc");
|
|
14283
14215
|
const enableMacOSX86 = allTargets.has("x86_64-apple-darwin");
|
|
@@ -14288,6 +14220,7 @@ var createGithubActionsCIYml = (targets) => {
|
|
|
14288
14220
|
const enableLinuxArm7 = allTargets.has("armv7-unknown-linux-gnueabihf");
|
|
14289
14221
|
const enableFreeBSD = allTargets.has("x86_64-unknown-freebsd");
|
|
14290
14222
|
const enableMacOSUni = allTargets.has("universal-apple-darwin");
|
|
14223
|
+
const enableWasi = allTargets.has("wasm32-wasi-preview1-threads");
|
|
14291
14224
|
fullTemplate.jobs.build.strategy.matrix.settings = fullTemplate.jobs.build.strategy.matrix.settings.filter(({ target }) => allTargets.has(target));
|
|
14292
14225
|
if (!fullTemplate.jobs.build.strategy.matrix.settings.length) {
|
|
14293
14226
|
delete fullTemplate.jobs.build.strategy.matrix;
|
|
@@ -14340,6 +14273,11 @@ var createGithubActionsCIYml = (targets) => {
|
|
|
14340
14273
|
} else {
|
|
14341
14274
|
requiredSteps.push(UNIVERSAL_MACOS);
|
|
14342
14275
|
}
|
|
14276
|
+
if (!enableWasi) {
|
|
14277
|
+
delete fullTemplate.jobs[TEST_WASI];
|
|
14278
|
+
} else {
|
|
14279
|
+
requiredSteps.push(TEST_WASI);
|
|
14280
|
+
}
|
|
14343
14281
|
fullTemplate.jobs.publish.needs = requiredSteps;
|
|
14344
14282
|
return dump(fullTemplate, {
|
|
14345
14283
|
lineWidth: 1e3
|
|
@@ -14356,10 +14294,15 @@ pub fn sum(a: i32, b: i32) -> i32 {
|
|
|
14356
14294
|
`;
|
|
14357
14295
|
|
|
14358
14296
|
// dist/api/templates/package.json.js
|
|
14359
|
-
var createPackageJson = ({ name, binaryName, targets, license, engineRequirement, cliVersion }) => {
|
|
14297
|
+
var createPackageJson = async ({ name, binaryName, targets, license, engineRequirement, cliVersion, testFramework }) => {
|
|
14298
|
+
const hasWasmTarget = targets.some((t) => t.includes("wasm"));
|
|
14299
|
+
const universalTargets = targets.filter((t) => t in UNIVERSAL_TARGETS);
|
|
14300
|
+
const unifiedtargets = universalTargets.length ? targets.filter((target) => !universalTargets.some((t) => {
|
|
14301
|
+
return UNIVERSAL_TARGETS[t].includes(target);
|
|
14302
|
+
})) : targets;
|
|
14360
14303
|
const content = {
|
|
14361
14304
|
name,
|
|
14362
|
-
version: "
|
|
14305
|
+
version: "0.0.0",
|
|
14363
14306
|
license,
|
|
14364
14307
|
engines: {
|
|
14365
14308
|
node: engineRequirement
|
|
@@ -14371,10 +14314,10 @@ var createPackageJson = ({ name, binaryName, targets, license, engineRequirement
|
|
|
14371
14314
|
exports: void 0,
|
|
14372
14315
|
napi: {
|
|
14373
14316
|
binaryName,
|
|
14374
|
-
targets
|
|
14317
|
+
targets: unifiedtargets
|
|
14375
14318
|
},
|
|
14376
14319
|
scripts: {
|
|
14377
|
-
test:
|
|
14320
|
+
test: testFramework,
|
|
14378
14321
|
build: "napi build --release --platform --strip",
|
|
14379
14322
|
"build:debug": "napi build",
|
|
14380
14323
|
prepublishOnly: "napi prepublish -t npm",
|
|
@@ -14385,6 +14328,21 @@ var createPackageJson = ({ name, binaryName, targets, license, engineRequirement
|
|
|
14385
14328
|
"@napi-rs/cli": `^${cliVersion}`
|
|
14386
14329
|
}
|
|
14387
14330
|
};
|
|
14331
|
+
if (testFramework === "ava") {
|
|
14332
|
+
const avaMeta = await fetch(`https://registry.npmjs.org/ava`).then((res) => res.json());
|
|
14333
|
+
content.devDependencies["ava"] = `^${avaMeta["dist-tags"].latest}`;
|
|
14334
|
+
content.ava = {
|
|
14335
|
+
timeout: "1m"
|
|
14336
|
+
};
|
|
14337
|
+
}
|
|
14338
|
+
if (hasWasmTarget) {
|
|
14339
|
+
const emnapiCoreMeta = await fetch(`https://registry.npmjs.org/@emnapi/core`).then((res) => res.json());
|
|
14340
|
+
const latest = emnapiCoreMeta["dist-tags"].latest;
|
|
14341
|
+
content.devDependencies["@emnapi/core"] = `^${latest}`;
|
|
14342
|
+
const emnapiRuntimeMeta = await fetch(`https://registry.npmjs.org/@emnapi/runtime`).then((res) => res.json());
|
|
14343
|
+
const runtimeLatest = emnapiRuntimeMeta["dist-tags"].latest;
|
|
14344
|
+
content.devDependencies["@emnapi/runtime"] = `^${runtimeLatest}`;
|
|
14345
|
+
}
|
|
14388
14346
|
return JSON.stringify(content, null, 2);
|
|
14389
14347
|
};
|
|
14390
14348
|
|
|
@@ -14698,6 +14656,21 @@ switch (platform) {
|
|
|
14698
14656
|
throw new Error(\`Unsupported OS: \${platform}, architecture: \${arch}\`)
|
|
14699
14657
|
}
|
|
14700
14658
|
|
|
14659
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
14660
|
+
try {
|
|
14661
|
+
localFileExisted = existsSync(
|
|
14662
|
+
join(__dirname, '${localName}.wasm32-wasi.wasm')
|
|
14663
|
+
) && existsSync(join(__dirname, '${localName}.wasi.cjs'))
|
|
14664
|
+
if (localFileExisted) {
|
|
14665
|
+
nativeBinding = require('./${localName}.wasi.cjs')
|
|
14666
|
+
} else {
|
|
14667
|
+
nativeBinding = require('${pkgName}-wasm32-wasi')
|
|
14668
|
+
}
|
|
14669
|
+
} catch {
|
|
14670
|
+
// ignore
|
|
14671
|
+
}
|
|
14672
|
+
}
|
|
14673
|
+
|
|
14701
14674
|
if (!nativeBinding) {
|
|
14702
14675
|
if (loadError) {
|
|
14703
14676
|
throw loadError
|
|
@@ -14709,7 +14682,66 @@ ${idents.map((ident) => `module.exports.${ident} = nativeBinding.${ident}`).join
|
|
|
14709
14682
|
`;
|
|
14710
14683
|
}
|
|
14711
14684
|
|
|
14712
|
-
// dist/api/wasi-
|
|
14685
|
+
// dist/api/templates/load-wasi-template.js
|
|
14686
|
+
var createWasiBinding = (wasmFileName, wasiRegisterFunctions) => `/* eslint-disable */
|
|
14687
|
+
/* prettier-ignore */
|
|
14688
|
+
|
|
14689
|
+
/* auto-generated by NAPI-RS */
|
|
14690
|
+
|
|
14691
|
+
const __nodeFs= require('node:fs')
|
|
14692
|
+
const __nodePath = require('node:path')
|
|
14693
|
+
const { WASI: __nodeWASI } = require('node:wasi')
|
|
14694
|
+
const { Worker } = require('node:worker_threads')
|
|
14695
|
+
|
|
14696
|
+
const { instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync } = require('@emnapi/core')
|
|
14697
|
+
const { getDefaultContext: __emnapiGetDefaultContext } = require('@emnapi/runtime')
|
|
14698
|
+
|
|
14699
|
+
const __wasi = new __nodeWASI({
|
|
14700
|
+
version: 'preview1',
|
|
14701
|
+
env: process.env,
|
|
14702
|
+
preopens: {
|
|
14703
|
+
'/': '/'
|
|
14704
|
+
}
|
|
14705
|
+
})
|
|
14706
|
+
|
|
14707
|
+
const __emnapiContext = __emnapiGetDefaultContext()
|
|
14708
|
+
|
|
14709
|
+
const __sharedMemory = new WebAssembly.Memory({
|
|
14710
|
+
initial: 1024,
|
|
14711
|
+
maximum: 10240,
|
|
14712
|
+
shared: true,
|
|
14713
|
+
})
|
|
14714
|
+
|
|
14715
|
+
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__nodePath.join(__dirname, '${wasmFileName}.wasm')), {
|
|
14716
|
+
context: __emnapiContext,
|
|
14717
|
+
asyncWorkPoolSize: 4,
|
|
14718
|
+
wasi: __wasi,
|
|
14719
|
+
onCreateWorker() {
|
|
14720
|
+
return new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
|
14721
|
+
env: process.env,
|
|
14722
|
+
execArgv: ['--experimental-wasi-unstable-preview1'],
|
|
14723
|
+
})
|
|
14724
|
+
},
|
|
14725
|
+
overwriteImports(importObject) {
|
|
14726
|
+
importObject.env = {
|
|
14727
|
+
...importObject.env,
|
|
14728
|
+
...importObject.napi,
|
|
14729
|
+
...importObject.emnapi,
|
|
14730
|
+
memory: __sharedMemory,
|
|
14731
|
+
}
|
|
14732
|
+
return importObject
|
|
14733
|
+
},
|
|
14734
|
+
beforeInit({ instance }) {
|
|
14735
|
+
__napi_rs_initialize_modules(instance)
|
|
14736
|
+
}
|
|
14737
|
+
})
|
|
14738
|
+
|
|
14739
|
+
function __napi_rs_initialize_modules(__napiInstance) {
|
|
14740
|
+
${wasiRegisterFunctions.map((name) => ` __napiInstance.exports['${name}']?.()`).join("\n")}
|
|
14741
|
+
}
|
|
14742
|
+
`;
|
|
14743
|
+
|
|
14744
|
+
// dist/api/templates/wasi-worker-template.js
|
|
14713
14745
|
var WASI_WORKER_TEMPLATE = `import fs from "node:fs";
|
|
14714
14746
|
import { createRequire } from "node:module";
|
|
14715
14747
|
import { parentPort, Worker } from "node:worker_threads";
|
|
@@ -14765,7 +14797,7 @@ globalThis.onmessage = function (e) {
|
|
|
14765
14797
|
|
|
14766
14798
|
// dist/api/build.js
|
|
14767
14799
|
var debug3 = debugFactory("build");
|
|
14768
|
-
var require3 = (0,
|
|
14800
|
+
var require3 = (0, import_node_module2.createRequire)(__filename);
|
|
14769
14801
|
async function buildProject(options) {
|
|
14770
14802
|
debug3("napi build command receive options: %O", options);
|
|
14771
14803
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -14839,8 +14871,8 @@ var Builder = class {
|
|
|
14839
14871
|
try {
|
|
14840
14872
|
const { version: version2, download } = require3("@napi-rs/cross-toolchain");
|
|
14841
14873
|
const toolchainPath = (0, import_node_path2.join)((0, import_node_os.homedir)(), ".napi-rs", "cross-toolchain", version2, this.target.triple);
|
|
14842
|
-
(0,
|
|
14843
|
-
if ((0,
|
|
14874
|
+
(0, import_node_fs3.mkdirSync)(toolchainPath, { recursive: true });
|
|
14875
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path2.join)(toolchainPath, "package.json"))) {
|
|
14844
14876
|
debug3(`Toolchain ${toolchainPath} exists, skip extracting`);
|
|
14845
14877
|
} else {
|
|
14846
14878
|
const tarArchive = download(process.arch, this.target.triple);
|
|
@@ -14886,7 +14918,7 @@ var Builder = class {
|
|
|
14886
14918
|
throw new Error("`--use-cross` and `--cross-compile` can not be used together");
|
|
14887
14919
|
}
|
|
14888
14920
|
const command = process.env.CARGO ?? (this.options.useCross ? "cross" : "cargo");
|
|
14889
|
-
const buildProcess = (0,
|
|
14921
|
+
const buildProcess = (0, import_node_child_process4.spawn)(command, this.args, {
|
|
14890
14922
|
env: {
|
|
14891
14923
|
...process.env,
|
|
14892
14924
|
...this.envs
|
|
@@ -15159,7 +15191,7 @@ var Builder = class {
|
|
|
15159
15191
|
destName += `.${this.target.platformArchABI}`;
|
|
15160
15192
|
}
|
|
15161
15193
|
if (srcName.endsWith(".wasm")) {
|
|
15162
|
-
destName += ".
|
|
15194
|
+
destName += ".wasm";
|
|
15163
15195
|
} else {
|
|
15164
15196
|
destName += ".node";
|
|
15165
15197
|
}
|
|
@@ -15228,7 +15260,7 @@ var Builder = class {
|
|
|
15228
15260
|
};
|
|
15229
15261
|
|
|
15230
15262
|
// dist/api/create-npm-dirs.js
|
|
15231
|
-
var
|
|
15263
|
+
var import_node_path3 = require("node:path");
|
|
15232
15264
|
|
|
15233
15265
|
// dist/def/create-npm-dirs.js
|
|
15234
15266
|
var import_clipanion2 = __toESM(require_advanced(), 1);
|
|
@@ -15293,31 +15325,33 @@ async function createNpmDirs(userOptions) {
|
|
|
15293
15325
|
}
|
|
15294
15326
|
await writeFileAsync(file, content);
|
|
15295
15327
|
}
|
|
15296
|
-
const packageJsonPath = (0,
|
|
15297
|
-
const npmPath = (0,
|
|
15328
|
+
const packageJsonPath = (0, import_node_path3.resolve)(options.cwd, options.packageJsonPath);
|
|
15329
|
+
const npmPath = (0, import_node_path3.resolve)(options.cwd, options.npmDir);
|
|
15298
15330
|
debug4(`Read content from [${options.configPath ?? packageJsonPath}]`);
|
|
15299
|
-
const { targets, binaryName, packageName, packageJson } = await readNapiConfig(packageJsonPath, options.configPath ? (0,
|
|
15331
|
+
const { targets, binaryName, packageName, packageJson } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path3.resolve)(options.cwd, options.configPath) : void 0);
|
|
15300
15332
|
for (const target of targets) {
|
|
15301
|
-
const targetDir = (0,
|
|
15333
|
+
const targetDir = (0, import_node_path3.join)(npmPath, `${target.platformArchABI}`);
|
|
15302
15334
|
await mkdirAsync2(targetDir);
|
|
15303
|
-
const binaryFileName = `${binaryName}.${target.platformArchABI}.node`;
|
|
15335
|
+
const binaryFileName = target.arch === "wasm32" ? `${binaryName}.${target.platformArchABI}.wasm` : `${binaryName}.${target.platformArchABI}.node`;
|
|
15304
15336
|
const scopedPackageJson = {
|
|
15305
15337
|
name: `${packageName}-${target.platformArchABI}`,
|
|
15306
15338
|
version: packageJson.version,
|
|
15307
|
-
os: [target.platform],
|
|
15308
15339
|
cpu: target.arch !== "universal" ? [target.arch] : void 0,
|
|
15309
15340
|
main: binaryFileName,
|
|
15310
15341
|
files: [binaryFileName],
|
|
15311
15342
|
...pick(packageJson, "description", "keywords", "author", "authors", "homepage", "license", "engines", "publishConfig", "repository", "bugs")
|
|
15312
15343
|
};
|
|
15344
|
+
if (target.arch !== "wasm32") {
|
|
15345
|
+
scopedPackageJson.os = [target.platform];
|
|
15346
|
+
}
|
|
15313
15347
|
if (target.abi === "gnu") {
|
|
15314
15348
|
scopedPackageJson.libc = ["glibc"];
|
|
15315
15349
|
} else if (target.abi === "musl") {
|
|
15316
15350
|
scopedPackageJson.libc = ["musl"];
|
|
15317
15351
|
}
|
|
15318
|
-
const targetPackageJson = (0,
|
|
15352
|
+
const targetPackageJson = (0, import_node_path3.join)(targetDir, "package.json");
|
|
15319
15353
|
await writeFileAsync2(targetPackageJson, JSON.stringify(scopedPackageJson, null, 2));
|
|
15320
|
-
const targetReadme = (0,
|
|
15354
|
+
const targetReadme = (0, import_node_path3.join)(targetDir, "README.md");
|
|
15321
15355
|
await writeFileAsync2(targetReadme, readme(packageName, target));
|
|
15322
15356
|
debug4.info(`${packageName}-${target.platformArchABI} created`);
|
|
15323
15357
|
}
|
|
@@ -15330,7 +15364,7 @@ This is the **${target.triple}** binary for \`${packageName}\`
|
|
|
15330
15364
|
}
|
|
15331
15365
|
|
|
15332
15366
|
// dist/api/new.js
|
|
15333
|
-
var
|
|
15367
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
15334
15368
|
|
|
15335
15369
|
// dist/def/new.js
|
|
15336
15370
|
var import_clipanion3 = __toESM(require_advanced(), 1);
|
|
@@ -15340,7 +15374,7 @@ var BaseNewCommand = class extends import_clipanion3.Command {
|
|
|
15340
15374
|
static usage = import_clipanion3.Command.Usage({
|
|
15341
15375
|
description: "Create a new project with pre-configured boilerplate"
|
|
15342
15376
|
});
|
|
15343
|
-
$$path = import_clipanion3.Option.String({ required:
|
|
15377
|
+
$$path = import_clipanion3.Option.String({ required: false });
|
|
15344
15378
|
$$name = import_clipanion3.Option.String("--name,-n", {
|
|
15345
15379
|
description: "The name of the project, default to the name of the directory if not provided"
|
|
15346
15380
|
});
|
|
@@ -15348,6 +15382,9 @@ var BaseNewCommand = class extends import_clipanion3.Command {
|
|
|
15348
15382
|
validator: typanion.isNumber(),
|
|
15349
15383
|
description: "The minimum Node-API version to support"
|
|
15350
15384
|
});
|
|
15385
|
+
packageManager = import_clipanion3.Option.String("--package-manager", "yarn", {
|
|
15386
|
+
description: "The package manager to use. Only support yarn 4.x for now."
|
|
15387
|
+
});
|
|
15351
15388
|
license = import_clipanion3.Option.String("--license,-l", "MIT", {
|
|
15352
15389
|
description: "License for open-sourced project"
|
|
15353
15390
|
});
|
|
@@ -15366,6 +15403,9 @@ var BaseNewCommand = class extends import_clipanion3.Command {
|
|
|
15366
15403
|
enableGithubActions = import_clipanion3.Option.Boolean("--enable-github-actions", true, {
|
|
15367
15404
|
description: "Whether generate preconfigured GitHub Actions workflow"
|
|
15368
15405
|
});
|
|
15406
|
+
testFramework = import_clipanion3.Option.String("--test-framework", "ava", {
|
|
15407
|
+
description: "The JavaScript test framework to use, only support `ava` for now"
|
|
15408
|
+
});
|
|
15369
15409
|
dryRun = import_clipanion3.Option.Boolean("--dry-run", false, {
|
|
15370
15410
|
description: "Whether to run the command in dry-run mode"
|
|
15371
15411
|
});
|
|
@@ -15374,12 +15414,14 @@ var BaseNewCommand = class extends import_clipanion3.Command {
|
|
|
15374
15414
|
path: this.$$path,
|
|
15375
15415
|
name: this.$$name,
|
|
15376
15416
|
minNodeApiVersion: this.minNodeApiVersion,
|
|
15417
|
+
packageManager: this.packageManager,
|
|
15377
15418
|
license: this.license,
|
|
15378
15419
|
targets: this.targets,
|
|
15379
15420
|
enableDefaultTargets: this.enableDefaultTargets,
|
|
15380
15421
|
enableAllTargets: this.enableAllTargets,
|
|
15381
15422
|
enableTypeDef: this.enableTypeDef,
|
|
15382
15423
|
enableGithubActions: this.enableGithubActions,
|
|
15424
|
+
testFramework: this.testFramework,
|
|
15383
15425
|
dryRun: this.dryRun
|
|
15384
15426
|
};
|
|
15385
15427
|
}
|
|
@@ -15387,12 +15429,14 @@ var BaseNewCommand = class extends import_clipanion3.Command {
|
|
|
15387
15429
|
function applyDefaultNewOptions(options) {
|
|
15388
15430
|
return {
|
|
15389
15431
|
minNodeApiVersion: 4,
|
|
15432
|
+
packageManager: "yarn",
|
|
15390
15433
|
license: "MIT",
|
|
15391
15434
|
targets: [],
|
|
15392
15435
|
enableDefaultTargets: true,
|
|
15393
15436
|
enableAllTargets: false,
|
|
15394
15437
|
enableTypeDef: true,
|
|
15395
15438
|
enableGithubActions: true,
|
|
15439
|
+
testFramework: "ava",
|
|
15396
15440
|
dryRun: false,
|
|
15397
15441
|
...options
|
|
15398
15442
|
};
|
|
@@ -15402,10 +15446,13 @@ function applyDefaultNewOptions(options) {
|
|
|
15402
15446
|
var debug5 = debugFactory("new");
|
|
15403
15447
|
function processOptions(options) {
|
|
15404
15448
|
debug5("Processing options...");
|
|
15405
|
-
|
|
15449
|
+
if (!options.path) {
|
|
15450
|
+
throw new Error("Please provide the path as the argument");
|
|
15451
|
+
}
|
|
15452
|
+
options.path = import_node_path4.default.resolve(process.cwd(), options.path);
|
|
15406
15453
|
debug5(`Resolved target path to: ${options.path}`);
|
|
15407
15454
|
if (!options.name) {
|
|
15408
|
-
options.name =
|
|
15455
|
+
options.name = import_node_path4.default.parse(options.path).base;
|
|
15409
15456
|
debug5(`No project name provided, fix it to dir name: ${options.name}`);
|
|
15410
15457
|
}
|
|
15411
15458
|
if (!options.targets?.length) {
|
|
@@ -15427,7 +15474,7 @@ async function newProject(userOptions) {
|
|
|
15427
15474
|
const options = processOptions(userOptions);
|
|
15428
15475
|
debug5("Targets to be enabled:");
|
|
15429
15476
|
debug5(options.targets);
|
|
15430
|
-
const outputs = generateFiles(options);
|
|
15477
|
+
const outputs = await generateFiles(options);
|
|
15431
15478
|
await ensurePath(options.path, options.dryRun);
|
|
15432
15479
|
await dumpOutputs(outputs, options.dryRun);
|
|
15433
15480
|
debug5(`Project created at: ${options.path}`);
|
|
@@ -15457,12 +15504,12 @@ async function ensurePath(path2, dryRun = false) {
|
|
|
15457
15504
|
}
|
|
15458
15505
|
}
|
|
15459
15506
|
}
|
|
15460
|
-
function generateFiles(options) {
|
|
15507
|
+
async function generateFiles(options) {
|
|
15508
|
+
const packageJson = await generatePackageJson(options);
|
|
15461
15509
|
return [
|
|
15462
15510
|
generateCargoToml,
|
|
15463
15511
|
generateLibRs,
|
|
15464
15512
|
generateBuildRs,
|
|
15465
|
-
generatePackageJson,
|
|
15466
15513
|
generateGithubWorkflow,
|
|
15467
15514
|
generateIgnoreFiles
|
|
15468
15515
|
].flatMap((generator) => {
|
|
@@ -15473,12 +15520,14 @@ function generateFiles(options) {
|
|
|
15473
15520
|
if (Array.isArray(output)) {
|
|
15474
15521
|
return output.map((o) => ({
|
|
15475
15522
|
...o,
|
|
15476
|
-
target:
|
|
15523
|
+
target: import_node_path4.default.join(options.path, o.target)
|
|
15477
15524
|
}));
|
|
15478
15525
|
} else {
|
|
15479
|
-
return [{ ...output, target:
|
|
15526
|
+
return [{ ...output, target: import_node_path4.default.join(options.path, output.target) }];
|
|
15480
15527
|
}
|
|
15481
|
-
})
|
|
15528
|
+
}).concat([
|
|
15529
|
+
{ ...packageJson, target: import_node_path4.default.join(options.path, packageJson.target) }
|
|
15530
|
+
]);
|
|
15482
15531
|
}
|
|
15483
15532
|
function generateCargoToml(options) {
|
|
15484
15533
|
return {
|
|
@@ -15503,16 +15552,17 @@ function generateBuildRs(_options) {
|
|
|
15503
15552
|
content: createBuildRs()
|
|
15504
15553
|
};
|
|
15505
15554
|
}
|
|
15506
|
-
function generatePackageJson(options) {
|
|
15555
|
+
async function generatePackageJson(options) {
|
|
15507
15556
|
return {
|
|
15508
15557
|
target: "./package.json",
|
|
15509
|
-
content: createPackageJson({
|
|
15558
|
+
content: await createPackageJson({
|
|
15510
15559
|
name: options.name,
|
|
15511
15560
|
binaryName: getBinaryName(options.name),
|
|
15512
15561
|
targets: options.targets,
|
|
15513
15562
|
license: options.license,
|
|
15514
15563
|
engineRequirement: napiEngineRequirement(options.minNodeApiVersion),
|
|
15515
|
-
cliVersion: CLI_VERSION
|
|
15564
|
+
cliVersion: CLI_VERSION,
|
|
15565
|
+
testFramework: options.testFramework
|
|
15516
15566
|
})
|
|
15517
15567
|
};
|
|
15518
15568
|
}
|
|
@@ -15522,7 +15572,7 @@ function generateGithubWorkflow(options) {
|
|
|
15522
15572
|
}
|
|
15523
15573
|
return {
|
|
15524
15574
|
target: "./.github/workflows/ci.yml",
|
|
15525
|
-
content: createGithubActionsCIYml(options.targets)
|
|
15575
|
+
content: createGithubActionsCIYml(options.targets, options.packageManager)
|
|
15526
15576
|
};
|
|
15527
15577
|
}
|
|
15528
15578
|
function generateIgnoreFiles(_options) {
|
|
@@ -15548,7 +15598,7 @@ async function dumpOutputs(outputs, dryRun) {
|
|
|
15548
15598
|
continue;
|
|
15549
15599
|
}
|
|
15550
15600
|
try {
|
|
15551
|
-
await mkdirAsync(
|
|
15601
|
+
await mkdirAsync(import_node_path4.default.dirname(output.target), { recursive: true });
|
|
15552
15602
|
await writeFileAsync(output.target, output.content, "utf-8");
|
|
15553
15603
|
} catch (e) {
|
|
15554
15604
|
throw new Error(`Failed to write file: ${output.target}`, { cause: e });
|
|
@@ -15560,9 +15610,9 @@ function getBinaryName(name) {
|
|
|
15560
15610
|
}
|
|
15561
15611
|
|
|
15562
15612
|
// dist/api/pre-publish.js
|
|
15563
|
-
var
|
|
15564
|
-
var
|
|
15565
|
-
var
|
|
15613
|
+
var import_node_child_process5 = require("node:child_process");
|
|
15614
|
+
var import_node_fs4 = require("node:fs");
|
|
15615
|
+
var import_node_path6 = require("node:path");
|
|
15566
15616
|
var import_rest = __toESM(require_dist_node12(), 1);
|
|
15567
15617
|
|
|
15568
15618
|
// dist/def/pre-publish.js
|
|
@@ -15626,7 +15676,7 @@ function applyDefaultPrePublishOptions(options) {
|
|
|
15626
15676
|
}
|
|
15627
15677
|
|
|
15628
15678
|
// dist/api/version.js
|
|
15629
|
-
var
|
|
15679
|
+
var import_node_path5 = require("node:path");
|
|
15630
15680
|
|
|
15631
15681
|
// dist/def/version.js
|
|
15632
15682
|
var import_clipanion5 = __toESM(require_advanced(), 1);
|
|
@@ -15669,12 +15719,12 @@ function applyDefaultVersionOptions(options) {
|
|
|
15669
15719
|
var debug6 = debugFactory("version");
|
|
15670
15720
|
async function version(userOptions) {
|
|
15671
15721
|
const options = applyDefaultVersionOptions(userOptions);
|
|
15672
|
-
const packageJsonPath = (0,
|
|
15673
|
-
const config = await readNapiConfig(packageJsonPath, options.configPath ? (0,
|
|
15722
|
+
const packageJsonPath = (0, import_node_path5.resolve)(options.cwd, options.packageJsonPath);
|
|
15723
|
+
const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path5.resolve)(options.cwd, options.configPath) : void 0);
|
|
15674
15724
|
for (const target of config.targets) {
|
|
15675
|
-
const pkgDir = (0,
|
|
15725
|
+
const pkgDir = (0, import_node_path5.resolve)(options.cwd, options.npmDir, target.platformArchABI);
|
|
15676
15726
|
debug6(`Update version to %i in [%i]`, config.packageJson.version, pkgDir);
|
|
15677
|
-
await updatePackageJson((0,
|
|
15727
|
+
await updatePackageJson((0, import_node_path5.join)(pkgDir, "package.json"), {
|
|
15678
15728
|
version: config.packageJson.version
|
|
15679
15729
|
});
|
|
15680
15730
|
}
|
|
@@ -15686,8 +15736,8 @@ async function prePublish(userOptions) {
|
|
|
15686
15736
|
debug7("Receive pre-publish options:");
|
|
15687
15737
|
debug7(" %O", userOptions);
|
|
15688
15738
|
const options = applyDefaultPrePublishOptions(userOptions);
|
|
15689
|
-
const packageJsonPath = (0,
|
|
15690
|
-
const { packageJson, targets, packageName, binaryName, npmClient } = await readNapiConfig(packageJsonPath, options.configPath ? (0,
|
|
15739
|
+
const packageJsonPath = (0, import_node_path6.resolve)(options.cwd, options.packageJsonPath);
|
|
15740
|
+
const { packageJson, targets, packageName, binaryName, npmClient } = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path6.resolve)(options.cwd, options.configPath) : void 0);
|
|
15691
15741
|
async function createGhRelease(packageName2, version2) {
|
|
15692
15742
|
if (!options.ghRelease) {
|
|
15693
15743
|
return {
|
|
@@ -15721,7 +15771,7 @@ async function prePublish(userOptions) {
|
|
|
15721
15771
|
return { owner: owner2, repo: repo2, pkgInfo: pkgInfo2, octokit: octokit2 };
|
|
15722
15772
|
}
|
|
15723
15773
|
function getRepoInfo(packageName2, version2) {
|
|
15724
|
-
const headCommit = (0,
|
|
15774
|
+
const headCommit = (0, import_node_child_process5.execSync)("git log -1 --pretty=%B", {
|
|
15725
15775
|
encoding: "utf-8"
|
|
15726
15776
|
}).trim();
|
|
15727
15777
|
const { GITHUB_REPOSITORY } = process.env;
|
|
@@ -15764,15 +15814,16 @@ async function prePublish(userOptions) {
|
|
|
15764
15814
|
}
|
|
15765
15815
|
const { owner, repo, pkgInfo, octokit } = options.ghReleaseId ? getRepoInfo(packageName, packageJson.version) : await createGhRelease(packageName, packageJson.version);
|
|
15766
15816
|
for (const target of targets) {
|
|
15767
|
-
const pkgDir = (0,
|
|
15768
|
-
const
|
|
15769
|
-
const
|
|
15817
|
+
const pkgDir = (0, import_node_path6.resolve)(options.cwd, options.npmDir, `${target.platformArchABI}`);
|
|
15818
|
+
const ext = target.platform === "wasi" || target.platform === "wasm" ? "wasm" : "node";
|
|
15819
|
+
const filename = `${binaryName}.${target.platformArchABI}.${ext}`;
|
|
15820
|
+
const dstPath = (0, import_node_path6.join)(pkgDir, filename);
|
|
15770
15821
|
if (!options.dryRun) {
|
|
15771
|
-
if (!(0,
|
|
15822
|
+
if (!(0, import_node_fs4.existsSync)(dstPath)) {
|
|
15772
15823
|
debug7.warn(`%s doesn't exist`, dstPath);
|
|
15773
15824
|
continue;
|
|
15774
15825
|
}
|
|
15775
|
-
(0,
|
|
15826
|
+
(0, import_node_child_process5.execSync)(`${npmClient} publish`, {
|
|
15776
15827
|
cwd: pkgDir,
|
|
15777
15828
|
env: process.env
|
|
15778
15829
|
});
|
|
@@ -15784,7 +15835,7 @@ async function prePublish(userOptions) {
|
|
|
15784
15835
|
owner,
|
|
15785
15836
|
tag: pkgInfo.tag
|
|
15786
15837
|
})).data.id;
|
|
15787
|
-
const dstFileStats = (0,
|
|
15838
|
+
const dstFileStats = (0, import_node_fs4.statSync)(dstPath);
|
|
15788
15839
|
const assetInfo = await octokit.repos.uploadReleaseAsset({
|
|
15789
15840
|
owner,
|
|
15790
15841
|
repo,
|
|
@@ -15819,7 +15870,7 @@ function parseTag(tag) {
|
|
|
15819
15870
|
}
|
|
15820
15871
|
|
|
15821
15872
|
// dist/api/rename.js
|
|
15822
|
-
var
|
|
15873
|
+
var import_node_path7 = require("node:path");
|
|
15823
15874
|
|
|
15824
15875
|
// dist/def/rename.js
|
|
15825
15876
|
var import_clipanion6 = __toESM(require_advanced(), 1);
|
|
@@ -15886,8 +15937,8 @@ function applyDefaultRenameOptions(options) {
|
|
|
15886
15937
|
// dist/api/rename.js
|
|
15887
15938
|
async function renameProject(userOptions) {
|
|
15888
15939
|
const options = applyDefaultRenameOptions(userOptions);
|
|
15889
|
-
const packageJsonPath = (0,
|
|
15890
|
-
const cargoTomlPath = (0,
|
|
15940
|
+
const packageJsonPath = (0, import_node_path7.resolve)(options.cwd, options.packageJsonPath);
|
|
15941
|
+
const cargoTomlPath = (0, import_node_path7.resolve)(options.cwd, options.manifestPath);
|
|
15891
15942
|
const packageJsonContent = await readFileAsync(packageJsonPath, "utf8");
|
|
15892
15943
|
const packageJsonData = JSON.parse(packageJsonContent);
|
|
15893
15944
|
merge_default(packageJsonData, omitBy_default(pick_default(options, ["name", "description", "author", "license"]), isNil_default), {
|
|
@@ -15897,7 +15948,7 @@ async function renameProject(userOptions) {
|
|
|
15897
15948
|
}, isNil_default)
|
|
15898
15949
|
});
|
|
15899
15950
|
if (options.configPath) {
|
|
15900
|
-
const configPath = (0,
|
|
15951
|
+
const configPath = (0, import_node_path7.resolve)(options.cwd, options.configPath);
|
|
15901
15952
|
const configContent = await readFileAsync(configPath, "utf8");
|
|
15902
15953
|
const configData = JSON.parse(configContent);
|
|
15903
15954
|
configData.binaryName = options.binaryName;
|
|
@@ -15917,8 +15968,8 @@ async function renameProject(userOptions) {
|
|
|
15917
15968
|
}
|
|
15918
15969
|
|
|
15919
15970
|
// dist/api/universalize.js
|
|
15920
|
-
var
|
|
15921
|
-
var
|
|
15971
|
+
var import_node_child_process6 = require("node:child_process");
|
|
15972
|
+
var import_node_path8 = require("node:path");
|
|
15922
15973
|
|
|
15923
15974
|
// dist/def/universalize.js
|
|
15924
15975
|
var import_clipanion7 = __toESM(require_advanced(), 1);
|
|
@@ -15961,15 +16012,15 @@ function applyDefaultUniversalizeOptions(options) {
|
|
|
15961
16012
|
var debug8 = debugFactory("universalize");
|
|
15962
16013
|
var universalizers = {
|
|
15963
16014
|
darwin: (inputs, output) => {
|
|
15964
|
-
(0,
|
|
16015
|
+
(0, import_node_child_process6.spawnSync)("lipo", ["-create", "-output", output, ...inputs], {
|
|
15965
16016
|
stdio: "inherit"
|
|
15966
16017
|
});
|
|
15967
16018
|
}
|
|
15968
16019
|
};
|
|
15969
16020
|
async function universalizeBinaries(userOptions) {
|
|
15970
16021
|
const options = applyDefaultUniversalizeOptions(userOptions);
|
|
15971
|
-
const packageJsonPath = (0,
|
|
15972
|
-
const config = await readNapiConfig(packageJsonPath, options.configPath ? (0,
|
|
16022
|
+
const packageJsonPath = (0, import_node_path8.join)(options.cwd, options.packageJsonPath);
|
|
16023
|
+
const config = await readNapiConfig(packageJsonPath, options.configPath ? (0, import_node_path8.resolve)(options.cwd, options.configPath) : void 0);
|
|
15973
16024
|
const target = config.targets.find((t) => t.platform === process.platform && t.arch === "universal");
|
|
15974
16025
|
if (!target) {
|
|
15975
16026
|
throw new Error(`'universal' arch for platform '${process.platform}' not found in config!`);
|
|
@@ -15980,12 +16031,12 @@ async function universalizeBinaries(userOptions) {
|
|
|
15980
16031
|
}
|
|
15981
16032
|
debug8(`Looking up source binaries to combine: `);
|
|
15982
16033
|
debug8(" %O", srcFiles);
|
|
15983
|
-
const srcFileLookup = await Promise.all(srcFiles.map((f) => fileExists((0,
|
|
16034
|
+
const srcFileLookup = await Promise.all(srcFiles.map((f) => fileExists((0, import_node_path8.resolve)(options.cwd, options.outputDir, f))));
|
|
15984
16035
|
const notFoundFiles = srcFiles.filter((_, i) => !srcFileLookup[i]);
|
|
15985
16036
|
if (notFoundFiles.length) {
|
|
15986
16037
|
throw new Error(`Some binary files were not found: ${JSON.stringify(notFoundFiles)}`);
|
|
15987
16038
|
}
|
|
15988
|
-
const output = (0,
|
|
16039
|
+
const output = (0, import_node_path8.resolve)(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-universal.node`);
|
|
15989
16040
|
universalizers[process.platform]?.(srcFiles, output);
|
|
15990
16041
|
debug8(`Produced universal binary: ${output}`);
|
|
15991
16042
|
}
|