@napi-rs/cli 3.0.0-alpha.7 → 3.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +1 -1
- package/dist/api/artifacts.js +28 -7
- package/dist/api/artifacts.js.map +1 -1
- package/dist/api/build.js +247 -47
- package/dist/api/build.js.map +1 -1
- package/dist/api/create-npm-dirs.js +46 -9
- package/dist/api/create-npm-dirs.js.map +1 -1
- package/dist/api/new.js +57 -20
- package/dist/api/new.js.map +1 -1
- package/dist/api/pre-publish.js +9 -7
- package/dist/api/pre-publish.js.map +1 -1
- package/dist/api/rename.js +9 -1
- package/dist/api/rename.js.map +1 -1
- package/dist/api/templates/cargo.toml.js +1 -0
- package/dist/api/templates/cargo.toml.js.map +1 -1
- package/dist/api/templates/ci-template.d.ts +3 -1
- package/dist/api/templates/ci-template.js +144 -131
- package/dist/api/templates/ci-template.js.map +1 -1
- package/dist/api/templates/ci.yml.d.ts +3 -1
- package/dist/api/templates/ci.yml.js +21 -5
- package/dist/api/templates/ci.yml.js.map +1 -1
- package/dist/api/templates/js-binding.d.ts +1 -0
- package/dist/api/templates/js-binding.js +135 -221
- package/dist/api/templates/js-binding.js.map +1 -1
- package/dist/api/templates/lib.rs.js +1 -4
- package/dist/api/templates/lib.rs.js.map +1 -1
- package/dist/api/templates/load-wasi-template.d.ts +2 -0
- package/dist/api/templates/load-wasi-template.js +166 -0
- package/dist/api/templates/load-wasi-template.js.map +1 -0
- package/dist/api/templates/package.json.d.ts +9 -2
- package/dist/api/templates/package.json.js +26 -4
- package/dist/api/templates/package.json.js.map +1 -1
- package/dist/api/templates/wasi-worker-template.d.ts +2 -0
- package/dist/api/templates/wasi-worker-template.js +122 -0
- package/dist/api/templates/wasi-worker-template.js.map +1 -0
- package/dist/api/universalize.js +5 -5
- package/dist/api/universalize.js.map +1 -1
- package/dist/api/version.js +2 -2
- package/dist/api/version.js.map +1 -1
- package/dist/commands/artifacts.js +2 -2
- package/dist/commands/artifacts.js.map +1 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/new.js +34 -34
- package/dist/commands/new.js.map +1 -1
- package/dist/def/artifacts.d.ts +21 -1
- package/dist/def/artifacts.js +10 -2
- package/dist/def/artifacts.js.map +1 -1
- package/dist/def/build.d.ts +155 -4
- package/dist/def/build.js +30 -4
- package/dist/def/build.js.map +1 -1
- package/dist/def/create-npm-dirs.d.ts +10 -0
- package/dist/def/create-npm-dirs.js +4 -0
- package/dist/def/create-npm-dirs.js.map +1 -1
- package/dist/def/new.d.ts +25 -7
- package/dist/def/new.js +11 -1
- package/dist/def/new.js.map +1 -1
- package/dist/def/pre-publish.d.ts +12 -2
- package/dist/def/pre-publish.js +7 -3
- package/dist/def/pre-publish.js.map +1 -1
- package/dist/def/rename.d.ts +16 -6
- package/dist/def/rename.js +5 -1
- package/dist/def/rename.js.map +1 -1
- package/dist/def/universalize.d.ts +10 -0
- package/dist/def/universalize.js +4 -0
- package/dist/def/universalize.js.map +1 -1
- package/dist/def/version.d.ts +10 -0
- package/dist/def/version.js +4 -0
- package/dist/def/version.js.map +1 -1
- package/dist/index.cjs +8146 -14672
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/__tests__/config.spec.d.ts +1 -0
- package/dist/utils/__tests__/config.spec.js +63 -0
- package/dist/utils/__tests__/config.spec.js.map +1 -0
- package/dist/utils/__tests__/typegen.spec.js +8 -4
- package/dist/utils/__tests__/typegen.spec.js.map +1 -1
- package/dist/utils/cargo.js +2 -2
- package/dist/utils/cargo.js.map +1 -1
- package/dist/utils/config.d.ts +48 -4
- package/dist/utils/config.js +37 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/metadata.js +2 -2
- package/dist/utils/metadata.js.map +1 -1
- package/dist/utils/misc.d.ts +1 -2
- package/dist/utils/misc.js +3 -3
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/target.d.ts +7 -5
- package/dist/utils/target.js +17 -3
- package/dist/utils/target.js.map +1 -1
- package/dist/utils/typegen.d.ts +1 -1
- package/dist/utils/typegen.js +51 -17
- package/dist/utils/typegen.js.map +1 -1
- package/dist/utils/version.d.ts +2 -1
- package/dist/utils/version.js +10 -8
- package/dist/utils/version.js.map +1 -1
- package/package.json +27 -26
- package/src/api/artifacts.ts +81 -9
- package/src/api/build.ts +403 -66
- package/src/api/create-npm-dirs.ts +57 -9
- package/src/api/new.ts +89 -31
- package/src/api/pre-publish.ts +13 -7
- package/src/api/rename.ts +10 -1
- package/src/api/templates/cargo.toml.ts +1 -0
- package/src/api/templates/ci-template.ts +154 -131
- package/src/api/templates/ci.yml.ts +27 -6
- package/src/api/templates/js-binding.ts +141 -219
- package/src/api/templates/lib.rs.ts +1 -4
- package/src/api/templates/load-wasi-template.ts +180 -0
- package/src/api/templates/package.json.ts +47 -5
- package/src/api/templates/wasi-worker-template.ts +122 -0
- package/src/api/universalize.ts +13 -8
- package/src/api/version.ts +5 -2
- package/src/commands/artifacts.ts +2 -2
- package/src/commands/build.ts +1 -1
- package/src/commands/new.ts +46 -45
- package/src/def/artifacts.ts +22 -3
- package/src/def/build.ts +64 -8
- package/src/def/create-npm-dirs.ts +9 -0
- package/src/def/new.ts +28 -3
- package/src/def/pre-publish.ts +12 -3
- package/src/def/rename.ts +11 -2
- package/src/def/universalize.ts +9 -0
- package/src/def/version.ts +9 -0
- package/src/index.ts +2 -0
- package/src/utils/__tests__/__fixtures__/napi_type_def +130 -130
- package/src/utils/__tests__/__snapshots__/config.spec.ts.md +97 -0
- package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +28 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +711 -158
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +8 -7
- package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
- package/src/utils/__tests__/config.spec.ts +81 -0
- package/src/utils/__tests__/typegen.spec.ts +18 -3
- package/src/utils/cargo.ts +2 -2
- package/src/utils/config.ts +112 -10
- package/src/utils/index.ts +0 -1
- package/src/utils/metadata.ts +2 -2
- package/src/utils/misc.ts +11 -3
- package/src/utils/target.ts +22 -4
- package/src/utils/typegen.ts +81 -36
- package/src/utils/version.ts +10 -8
- package/dist/api/load-wasi-template.d.ts +0 -1
- package/dist/api/load-wasi-template.js +0 -63
- package/dist/api/load-wasi-template.js.map +0 -1
- package/dist/api/wasi-worker-template.d.ts +0 -1
- package/dist/api/wasi-worker-template.js +0 -53
- package/dist/api/wasi-worker-template.js.map +0 -1
- package/dist/utils/ci.d.ts +0 -11
- package/dist/utils/ci.js +0 -96
- package/dist/utils/ci.js.map +0 -1
- package/src/api/load-wasi-template.ts +0 -65
- package/src/api/wasi-worker-template.ts +0 -52
- package/src/utils/ci.ts +0 -111
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { UNIVERSAL_TARGETS } from '../../utils/target.js';
|
|
2
|
+
export const createPackageJson = async ({ name, binaryName, targets, license, engineRequirement, cliVersion, testFramework, }) => {
|
|
3
|
+
const hasWasmTarget = targets.some((t) => t.includes('wasm'));
|
|
4
|
+
const universalTargets = targets.filter((t) => t in UNIVERSAL_TARGETS);
|
|
5
|
+
const unifiedtargets = universalTargets.length
|
|
6
|
+
? targets.filter((target) => !universalTargets.some((t) => {
|
|
7
|
+
// @ts-expect-error
|
|
8
|
+
return UNIVERSAL_TARGETS[t].includes(target);
|
|
9
|
+
}))
|
|
10
|
+
: targets;
|
|
2
11
|
const content = {
|
|
3
12
|
name,
|
|
4
|
-
version: '
|
|
13
|
+
version: '0.0.0',
|
|
5
14
|
license,
|
|
6
15
|
engines: {
|
|
7
16
|
node: engineRequirement,
|
|
@@ -9,14 +18,15 @@ export const createPackageJson = ({ name, binaryName, targets, license, engineRe
|
|
|
9
18
|
type: 'commonjs',
|
|
10
19
|
main: 'index.js',
|
|
11
20
|
types: 'index.d.ts',
|
|
21
|
+
browser: 'browser.js',
|
|
12
22
|
module: undefined,
|
|
13
23
|
exports: undefined,
|
|
14
24
|
napi: {
|
|
15
25
|
binaryName,
|
|
16
|
-
targets,
|
|
26
|
+
targets: unifiedtargets,
|
|
17
27
|
},
|
|
18
28
|
scripts: {
|
|
19
|
-
test:
|
|
29
|
+
test: testFramework,
|
|
20
30
|
build: 'napi build --release --platform --strip',
|
|
21
31
|
'build:debug': 'napi build',
|
|
22
32
|
prepublishOnly: 'napi prepublish -t npm',
|
|
@@ -27,6 +37,18 @@ export const createPackageJson = ({ name, binaryName, targets, license, engineRe
|
|
|
27
37
|
'@napi-rs/cli': `^${cliVersion}`,
|
|
28
38
|
},
|
|
29
39
|
};
|
|
40
|
+
if (testFramework === 'ava') {
|
|
41
|
+
const avaMeta = await fetch(`https://registry.npmjs.org/ava`).then((res) => res.json());
|
|
42
|
+
content.devDependencies['ava'] = `^${avaMeta['dist-tags'].latest}`;
|
|
43
|
+
content.ava = {
|
|
44
|
+
timeout: '1m',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (hasWasmTarget) {
|
|
48
|
+
const wasmRuntime = await fetch(`https://registry.npmjs.org/@napi-rs/wasm-runtime`).then((res) => res.json());
|
|
49
|
+
const latest = wasmRuntime['dist-tags'].latest;
|
|
50
|
+
content.devDependencies['@napi-rs/wasm-runtime'] = `^${latest}`;
|
|
51
|
+
}
|
|
30
52
|
return JSON.stringify(content, null, 2);
|
|
31
53
|
};
|
|
32
54
|
//# sourceMappingURL=package.json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sourceRoot":"","sources":["../../../src/api/templates/package.json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.js","sourceRoot":"","sources":["../../../src/api/templates/package.json.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAMzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,aAAa,GASd,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,iBAAiB,CACQ,CAAA;IACvC,MAAM,cAAc,GAAG,gBAAgB,CAAC,MAAM;QAC5C,CAAC,CAAC,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAAE,EAAE,CACT,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,mBAAmB;YACnB,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC9C,CAAC,CAAC,CACL;QACH,CAAC,CAAC,OAAO,CAAA;IACX,MAAM,OAAO,GAA4B;QACvC,IAAI;QACJ,OAAO,EAAE,OAAO;QAChB,OAAO;QACP,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;SACxB;QACD,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE;YACJ,UAAU;YACV,OAAO,EAAE,cAAc;SACxB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,yCAAyC;YAChD,aAAa,EAAE,YAAY;YAC3B,cAAc,EAAE,wBAAwB;YACxC,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE,cAAc;SACxB;QACD,eAAe,EAAE;YACf,cAAc,EAAE,IAAI,UAAU,EAAE;SACjC;KACF,CAAA;IAED,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,gCAAgC,CAAC,CAAC,IAAI,CAChE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0B,CAC5C,CAAA;QACD,OAAO,CAAC,eAAgB,CAAC,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAA;QACnE,OAAO,CAAC,GAAG,GAAG;YACZ,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,WAAW,GAAG,MAAM,KAAK,CAC7B,kDAAkD,CACnD,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAA0B,CAAC,CAAA;QACnD,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC,MAAM,CAAA;QAC9C,OAAO,CAAC,eAAgB,CAAC,uBAAuB,CAAC,GAAG,IAAI,MAAM,EAAE,CAAA;IAClE,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACzC,CAAC,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const WASI_WORKER_TEMPLATE = "import fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { parse } from \"node:path\";\nimport { WASI } from \"node:wasi\";\nimport { parentPort, Worker } from \"node:worker_threads\";\n\nconst require = createRequire(import.meta.url);\n\nconst { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require(\"@napi-rs/wasm-runtime\");\n\nif (parentPort) {\n parentPort.on(\"message\", (data) => {\n globalThis.onmessage({ data });\n });\n}\n\nObject.assign(globalThis, {\n self: globalThis,\n require,\n Worker,\n importScripts: function (f) {\n ;(0, eval)(fs.readFileSync(f, \"utf8\") + \"//# sourceURL=\" + f);\n },\n postMessage: function (msg) {\n if (parentPort) {\n parentPort.postMessage(msg);\n }\n },\n});\n\nconst emnapiContext = getDefaultContext();\n\nconst __rootDir = parse(process.cwd()).root;\n\nconst handler = new MessageHandler({\n onLoad({ wasmModule, wasmMemory }) {\n const wasi = new WASI({\n version: 'preview1',\n env: process.env,\n preopens: {\n [__rootDir]: __rootDir,\n },\n });\n\n return instantiateNapiModuleSync(wasmModule, {\n childThread: true,\n wasi,\n context: emnapiContext,\n overwriteImports(importObject) {\n importObject.env = {\n ...importObject.env,\n ...importObject.napi,\n ...importObject.emnapi,\n memory: wasmMemory\n };\n },\n });\n },\n});\n\nglobalThis.onmessage = function (e) {\n handler.handle(e);\n};\n";
|
|
2
|
+
export declare const createWasiBrowserWorkerBinding: (fs: boolean) => string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const WASI_WORKER_TEMPLATE = `import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { parse } from "node:path";
|
|
4
|
+
import { WASI } from "node:wasi";
|
|
5
|
+
import { parentPort, Worker } from "node:worker_threads";
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
|
|
10
|
+
|
|
11
|
+
if (parentPort) {
|
|
12
|
+
parentPort.on("message", (data) => {
|
|
13
|
+
globalThis.onmessage({ data });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Object.assign(globalThis, {
|
|
18
|
+
self: globalThis,
|
|
19
|
+
require,
|
|
20
|
+
Worker,
|
|
21
|
+
importScripts: function (f) {
|
|
22
|
+
;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
|
|
23
|
+
},
|
|
24
|
+
postMessage: function (msg) {
|
|
25
|
+
if (parentPort) {
|
|
26
|
+
parentPort.postMessage(msg);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const emnapiContext = getDefaultContext();
|
|
32
|
+
|
|
33
|
+
const __rootDir = parse(process.cwd()).root;
|
|
34
|
+
|
|
35
|
+
const handler = new MessageHandler({
|
|
36
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
37
|
+
const wasi = new WASI({
|
|
38
|
+
version: 'preview1',
|
|
39
|
+
env: process.env,
|
|
40
|
+
preopens: {
|
|
41
|
+
[__rootDir]: __rootDir,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return instantiateNapiModuleSync(wasmModule, {
|
|
46
|
+
childThread: true,
|
|
47
|
+
wasi,
|
|
48
|
+
context: emnapiContext,
|
|
49
|
+
overwriteImports(importObject) {
|
|
50
|
+
importObject.env = {
|
|
51
|
+
...importObject.env,
|
|
52
|
+
...importObject.napi,
|
|
53
|
+
...importObject.emnapi,
|
|
54
|
+
memory: wasmMemory
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
globalThis.onmessage = function (e) {
|
|
62
|
+
handler.handle(e);
|
|
63
|
+
};
|
|
64
|
+
`;
|
|
65
|
+
export const createWasiBrowserWorkerBinding = (fs) => {
|
|
66
|
+
const fsImport = fs
|
|
67
|
+
? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
|
|
68
|
+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
|
|
69
|
+
|
|
70
|
+
const fs = createFsProxy(__memfsExported)`
|
|
71
|
+
: `import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'`;
|
|
72
|
+
const wasiCreation = fs
|
|
73
|
+
? `const wasi = new WASI({
|
|
74
|
+
fs,
|
|
75
|
+
preopens: {
|
|
76
|
+
'/': '/',
|
|
77
|
+
},
|
|
78
|
+
print: function () {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.log.apply(console, arguments)
|
|
81
|
+
},
|
|
82
|
+
printErr: function() {
|
|
83
|
+
// eslint-disable-next-line no-console
|
|
84
|
+
console.error.apply(console, arguments)
|
|
85
|
+
},
|
|
86
|
+
})`
|
|
87
|
+
: `const wasi = new WASI({
|
|
88
|
+
print: function () {
|
|
89
|
+
// eslint-disable-next-line no-console
|
|
90
|
+
console.log.apply(console, arguments)
|
|
91
|
+
},
|
|
92
|
+
printErr: function() {
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.error.apply(console, arguments)
|
|
95
|
+
},
|
|
96
|
+
})`;
|
|
97
|
+
return `${fsImport}
|
|
98
|
+
|
|
99
|
+
const handler = new MessageHandler({
|
|
100
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
101
|
+
${wasiCreation}
|
|
102
|
+
return instantiateNapiModuleSync(wasmModule, {
|
|
103
|
+
childThread: true,
|
|
104
|
+
wasi,
|
|
105
|
+
overwriteImports(importObject) {
|
|
106
|
+
importObject.env = {
|
|
107
|
+
...importObject.env,
|
|
108
|
+
...importObject.napi,
|
|
109
|
+
...importObject.emnapi,
|
|
110
|
+
memory: wasmMemory,
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
globalThis.onmessage = function (e) {
|
|
118
|
+
handler.handle(e)
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=wasi-worker-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasi-worker-template.js","sourceRoot":"","sources":["../../../src/api/templates/wasi-worker-template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DnC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAW,EAAE,EAAE;IAC5D,MAAM,QAAQ,GAAG,EAAE;QACjB,CAAC,CAAC;;;0CAGoC;QACtC,CAAC,CAAC,yFAAyF,CAAA;IAC7F,MAAM,YAAY,GAAG,EAAE;QACrB,CAAC,CAAC;;;;;;;;;;;;;OAaC;QACH,CAAC,CAAC;;;;;;;;;OASC,CAAA;IACL,OAAO,GAAG,QAAQ;;;;MAId,YAAY;;;;;;;;;;;;;;;;;;;CAmBjB,CAAA;AACD,CAAC,CAAA"}
|
package/dist/api/universalize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { spawnSync } from 'child_process';
|
|
2
|
-
import { join, resolve } from 'path';
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
3
|
import { applyDefaultUniversalizeOptions, } from '../def/universalize.js';
|
|
4
4
|
import { readNapiConfig } from '../utils/config.js';
|
|
5
5
|
import { debugFactory } from '../utils/log.js';
|
|
@@ -16,18 +16,18 @@ const universalizers = {
|
|
|
16
16
|
export async function universalizeBinaries(userOptions) {
|
|
17
17
|
const options = applyDefaultUniversalizeOptions(userOptions);
|
|
18
18
|
const packageJsonPath = join(options.cwd, options.packageJsonPath);
|
|
19
|
-
const config = await readNapiConfig(packageJsonPath);
|
|
19
|
+
const config = await readNapiConfig(packageJsonPath, options.configPath ? resolve(options.cwd, options.configPath) : undefined);
|
|
20
20
|
const target = config.targets.find((t) => t.platform === process.platform && t.arch === 'universal');
|
|
21
21
|
if (!target) {
|
|
22
22
|
throw new Error(`'universal' arch for platform '${process.platform}' not found in config!`);
|
|
23
23
|
}
|
|
24
|
-
const srcFiles = UniArchsByPlatform[process.platform]?.map((arch) => `${config.binaryName}.${process.platform}-${arch}.node`);
|
|
24
|
+
const srcFiles = UniArchsByPlatform[process.platform]?.map((arch) => resolve(options.cwd, options.outputDir, `${config.binaryName}.${process.platform}-${arch}.node`));
|
|
25
25
|
if (!srcFiles || !universalizers[process.platform]) {
|
|
26
26
|
throw new Error(`'universal' arch for platform '${process.platform}' not supported.`);
|
|
27
27
|
}
|
|
28
28
|
debug(`Looking up source binaries to combine: `);
|
|
29
29
|
debug(' %O', srcFiles);
|
|
30
|
-
const srcFileLookup = await Promise.all(srcFiles.map((f) => fileExists(
|
|
30
|
+
const srcFileLookup = await Promise.all(srcFiles.map((f) => fileExists(f)));
|
|
31
31
|
const notFoundFiles = srcFiles.filter((_, i) => !srcFileLookup[i]);
|
|
32
32
|
if (notFoundFiles.length) {
|
|
33
33
|
throw new Error(`Some binary files were not found: ${JSON.stringify(notFoundFiles)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"universalize.js","sourceRoot":"","sources":["../../src/api/universalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"universalize.js","sourceRoot":"","sources":["../../src/api/universalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EACL,+BAA+B,GAEhC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,KAAK,GAAG,YAAY,CAAC,cAAc,CAAC,CA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CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CACb,kCAAkC,OAAO,CAAC,QAAQ,kBAAkB,CACrE,CAAA;IACH,CAAC;IAED,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAChD,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEvB,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3E,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAElE,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,qCAAqC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CACrE,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CACpB,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,SAAS,EACjB,GAAG,MAAM,CAAC,UAAU,IAAI,OAAO,CAAC,QAAQ,iBAAiB,CAC1D,CAAA;IAED,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAEpD,KAAK,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAA;AAC/C,CAAC"}
|
package/dist/api/version.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { join, resolve } from 'path';
|
|
1
|
+
import { join, resolve } from 'node:path';
|
|
2
2
|
import { applyDefaultVersionOptions } from '../def/version.js';
|
|
3
3
|
import { readNapiConfig, debugFactory, updatePackageJson, } from '../utils/index.js';
|
|
4
4
|
const debug = debugFactory('version');
|
|
5
5
|
export async function version(userOptions) {
|
|
6
6
|
const options = applyDefaultVersionOptions(userOptions);
|
|
7
7
|
const packageJsonPath = resolve(options.cwd, options.packageJsonPath);
|
|
8
|
-
const config = await readNapiConfig(packageJsonPath);
|
|
8
|
+
const config = await readNapiConfig(packageJsonPath, options.configPath ? resolve(options.cwd, options.configPath) : undefined);
|
|
9
9
|
for (const target of config.targets) {
|
|
10
10
|
const pkgDir = resolve(options.cwd, options.npmDir, target.platformArchABI);
|
|
11
11
|
debug(`Update version to %i in [%i]`, config.packageJson.version, pkgDir);
|
package/dist/api/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/api/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/api/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,0BAA0B,EAAkB,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAA;AAErC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,WAA2B;IACvD,MAAM,OAAO,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAA;IACvD,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IAErE,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC,eAAe,EACf,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAC1E,CAAA;IAED,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,CAAA;QAE3E,KAAK,CAAC,8BAA8B,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QACzE,MAAM,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE;YACpD,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO;SACpC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -6,9 +6,9 @@ export class ArtifactsCommand extends BaseArtifactsCommand {
|
|
|
6
6
|
description: 'Copy artifacts from Github Actions into specified dir',
|
|
7
7
|
examples: [
|
|
8
8
|
[
|
|
9
|
-
'$0 artifacts --dir
|
|
9
|
+
'$0 artifacts --output-dir ./artifacts --dist ./npm',
|
|
10
10
|
`Copy [binaryName].[platform].node under current dir(.) into packages under npm dir.
|
|
11
|
-
e.g: index.linux-x64-gnu.node --> ./npm/linux-x64-gnu/index.node`,
|
|
11
|
+
e.g: index.linux-x64-gnu.node --> ./npm/linux-x64-gnu/index.linux-x64-gnu.node`,
|
|
12
12
|
],
|
|
13
13
|
],
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/commands/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,MAAM,OAAO,gBAAiB,SAAQ,oBAAoB;IACxD,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,WAAW,EAAE,uDAAuD;QACpE,QAAQ,EAAE;YACR;gBACE,
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/commands/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,MAAM,OAAO,gBAAiB,SAAQ,oBAAoB;IACxD,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,WAAW,EAAE,uDAAuD;QACpE,QAAQ,EAAE;YACR;gBACE,oDAAoD;gBACpD;+EACuE;aACxE;SACF;KACF,CAAC,CAAA;IAEF,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;IAE9B,KAAK,CAAC,OAAO;QACX,MAAM,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IAC3C,CAAC"}
|
package/dist/commands/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;AAEnC,MAAM,OAAO,YAAa,SAAQ,gBAAgB;IAChD,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;QAC7B,WAAW,EACT,yFAAyF;KAC5F,CAAC,CAAA;IAEF,YAAY,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAE5B,KAAK,CAAC,OAAO;QACX,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CAAC;YAClC,GAAG,IAAI,CAAC,UAAU,EAAE;YACpB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAA;QAE1B,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,KAAK,CAAC,mCAAmC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;gBACrD,IAAI,CAAC;oBACH,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE;wBACtC,KAAK,EAAE,SAAS;wBAChB,GAAG,EAAE,IAAI,CAAC,GAAG;qBACd,CAAC,CAAA;gBACJ,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,KAAK,CAAC,KAAK,CAAC,8BAA8B,MAAM,CAAC,IAAI,aAAa,CAAC,CAAA;oBACnE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/commands/new.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { input, select, checkbox, confirm } from '@inquirer/prompts';
|
|
2
3
|
import { Option } from 'clipanion';
|
|
3
|
-
import inquirer from 'inquirer';
|
|
4
4
|
import { newProject } from '../api/new.js';
|
|
5
5
|
import { BaseNewCommand } from '../def/new.js';
|
|
6
6
|
import { AVAILABLE_TARGETS, debugFactory, DEFAULT_TARGETS, } from '../utils/index.js';
|
|
7
7
|
import { napiEngineRequirement } from '../utils/version.js';
|
|
8
8
|
const debug = debugFactory('new');
|
|
9
9
|
export class NewCommand extends BaseNewCommand {
|
|
10
|
-
interactive = Option.Boolean('--interactive,-i',
|
|
10
|
+
interactive = Option.Boolean('--interactive,-i', true, {
|
|
11
11
|
description: 'Ask project basic information interactively without just using the default.',
|
|
12
12
|
});
|
|
13
13
|
async execute() {
|
|
@@ -25,9 +25,13 @@ export class NewCommand extends BaseNewCommand {
|
|
|
25
25
|
async fetchOptions() {
|
|
26
26
|
const cmdOptions = super.getOptions();
|
|
27
27
|
if (this.interactive) {
|
|
28
|
+
const targetPath = cmdOptions.path
|
|
29
|
+
? cmdOptions.path
|
|
30
|
+
: await inquirerProjectPath();
|
|
31
|
+
cmdOptions.path = targetPath;
|
|
28
32
|
return {
|
|
29
33
|
...cmdOptions,
|
|
30
|
-
name: await this.fetchName(path.parse(
|
|
34
|
+
name: await this.fetchName(path.parse(targetPath).base),
|
|
31
35
|
minNodeApiVersion: await this.fetchNapiVersion(),
|
|
32
36
|
targets: await this.fetchTargets(),
|
|
33
37
|
license: await this.fetchLicense(),
|
|
@@ -39,72 +43,68 @@ export class NewCommand extends BaseNewCommand {
|
|
|
39
43
|
}
|
|
40
44
|
async fetchName(defaultName) {
|
|
41
45
|
return (this.$$name ??
|
|
42
|
-
(
|
|
43
|
-
.prompt({
|
|
44
|
-
type: 'input',
|
|
45
|
-
name: 'name',
|
|
46
|
+
input({
|
|
46
47
|
message: 'Package name (the name field in your package.json file)',
|
|
47
48
|
default: defaultName,
|
|
48
|
-
})
|
|
49
|
-
.then(({ name }) => name)));
|
|
49
|
+
}));
|
|
50
50
|
}
|
|
51
51
|
async fetchLicense() {
|
|
52
|
-
return
|
|
53
|
-
.prompt({
|
|
54
|
-
type: 'input',
|
|
55
|
-
name: 'license',
|
|
52
|
+
return input({
|
|
56
53
|
message: 'License for open-sourced project',
|
|
57
54
|
default: this.license,
|
|
58
|
-
})
|
|
59
|
-
.then(({ license }) => license);
|
|
55
|
+
});
|
|
60
56
|
}
|
|
61
57
|
async fetchNapiVersion() {
|
|
62
|
-
return
|
|
63
|
-
.prompt({
|
|
64
|
-
type: 'list',
|
|
65
|
-
name: 'minNodeApiVersion',
|
|
58
|
+
return select({
|
|
66
59
|
message: 'Minimum node-api version (with node version requirement)',
|
|
67
60
|
loop: false,
|
|
68
|
-
choices:
|
|
61
|
+
choices: Array.from({ length: 8 }, (_, i) => ({
|
|
69
62
|
name: `napi${i + 1} (${napiEngineRequirement(i + 1)})`,
|
|
70
63
|
value: i + 1,
|
|
71
64
|
})),
|
|
72
65
|
// choice index
|
|
73
66
|
default: this.minNodeApiVersion - 1,
|
|
74
|
-
})
|
|
75
|
-
.then(({ minNodeApiVersion }) => minNodeApiVersion);
|
|
67
|
+
});
|
|
76
68
|
}
|
|
77
69
|
async fetchTargets() {
|
|
78
70
|
if (this.enableAllTargets) {
|
|
79
71
|
return AVAILABLE_TARGETS.concat();
|
|
80
72
|
}
|
|
81
|
-
const
|
|
82
|
-
name: 'targets',
|
|
83
|
-
type: 'checkbox',
|
|
73
|
+
const targets = await checkbox({
|
|
84
74
|
loop: false,
|
|
85
75
|
message: 'Choose target(s) your crate will be compiled to',
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
choices: AVAILABLE_TARGETS.map((target) => ({
|
|
77
|
+
name: target,
|
|
78
|
+
value: target,
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
checked: DEFAULT_TARGETS.includes(target),
|
|
81
|
+
})),
|
|
88
82
|
});
|
|
89
83
|
return targets;
|
|
90
84
|
}
|
|
91
85
|
async fetchTypeDef() {
|
|
92
|
-
const
|
|
93
|
-
name: 'enableTypeDef',
|
|
94
|
-
type: 'confirm',
|
|
86
|
+
const enableTypeDef = await confirm({
|
|
95
87
|
message: 'Enable type definition auto-generation',
|
|
96
88
|
default: this.enableTypeDef,
|
|
97
89
|
});
|
|
98
90
|
return enableTypeDef;
|
|
99
91
|
}
|
|
100
92
|
async fetchGithubActions() {
|
|
101
|
-
const
|
|
102
|
-
name: 'enableGithubActions',
|
|
103
|
-
type: 'confirm',
|
|
93
|
+
const enableGithubActions = await confirm({
|
|
104
94
|
message: 'Enable Github Actions CI',
|
|
105
95
|
default: this.enableGithubActions,
|
|
106
96
|
});
|
|
107
97
|
return enableGithubActions;
|
|
108
98
|
}
|
|
109
99
|
}
|
|
100
|
+
async function inquirerProjectPath() {
|
|
101
|
+
return input({
|
|
102
|
+
message: 'Target path to create the project, relative to cwd.',
|
|
103
|
+
}).then((path) => {
|
|
104
|
+
if (!path) {
|
|
105
|
+
return inquirerProjectPath();
|
|
106
|
+
}
|
|
107
|
+
return path;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
110
|
//# sourceMappingURL=new.js.map
|
package/dist/commands/new.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,GAEhB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;AAEjC,MAAM,OAAO,UAAW,SAAQ,cAAc;IAC5C,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,EAAE;QACrD,WAA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,EAAE,wCAAwC;YACjD,OAAO,EAAE,IAAI,CAAC,aAAa;SAC5B,CAAC,CAAA;QAEF,OAAO,aAAa,CAAA;IACtB,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC9B,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC;YACxC,OAAO,EAAE,0BAA0B;YACnC,OAAO,EAAE,IAAI,CAAC,mBAAmB;SAClC,CAAC,CAAA;QAEF,OAAO,mBAAmB,CAAA;IAC5B,CAAC;CACF;AAED,KAAK,UAAU,mBAAmB;IAChC,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,qDAAqD;KAC/D,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,mBAAmB,EAAE,CAAA;QAC9B,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/def/artifacts.d.ts
CHANGED
|
@@ -3,14 +3,18 @@ export declare abstract class BaseArtifactsCommand extends Command {
|
|
|
3
3
|
static paths: string[][];
|
|
4
4
|
static usage: import("clipanion").Usage;
|
|
5
5
|
cwd: string;
|
|
6
|
+
configPath?: string;
|
|
6
7
|
packageJsonPath: string;
|
|
7
8
|
outputDir: string;
|
|
8
9
|
npmDir: string;
|
|
10
|
+
buildOutputDir?: string;
|
|
9
11
|
getOptions(): {
|
|
10
12
|
cwd: string;
|
|
13
|
+
configPath: string | undefined;
|
|
11
14
|
packageJsonPath: string;
|
|
12
15
|
outputDir: string;
|
|
13
16
|
npmDir: string;
|
|
17
|
+
buildOutputDir: string | undefined;
|
|
14
18
|
};
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
@@ -23,6 +27,10 @@ export interface ArtifactsOptions {
|
|
|
23
27
|
* @default process.cwd()
|
|
24
28
|
*/
|
|
25
29
|
cwd?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Path to `napi` config json file
|
|
32
|
+
*/
|
|
33
|
+
configPath?: string;
|
|
26
34
|
/**
|
|
27
35
|
* Path to `package.json`
|
|
28
36
|
*
|
|
@@ -32,7 +40,7 @@ export interface ArtifactsOptions {
|
|
|
32
40
|
/**
|
|
33
41
|
* Path to the folder where all built `.node` files put, same as `--output-dir` of build command
|
|
34
42
|
*
|
|
35
|
-
* @default './'
|
|
43
|
+
* @default './artifacts'
|
|
36
44
|
*/
|
|
37
45
|
outputDir?: string;
|
|
38
46
|
/**
|
|
@@ -41,10 +49,22 @@ export interface ArtifactsOptions {
|
|
|
41
49
|
* @default 'npm'
|
|
42
50
|
*/
|
|
43
51
|
npmDir?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Path to the build output dir, only needed when targets contains `wasm32-wasi-*`
|
|
54
|
+
*/
|
|
55
|
+
buildOutputDir?: string;
|
|
44
56
|
}
|
|
45
57
|
export declare function applyDefaultArtifactsOptions(options: ArtifactsOptions): {
|
|
46
58
|
cwd: string;
|
|
59
|
+
/**
|
|
60
|
+
* Path to `napi` config json file
|
|
61
|
+
*/
|
|
62
|
+
configPath?: string;
|
|
47
63
|
packageJsonPath: string;
|
|
48
64
|
outputDir: string;
|
|
49
65
|
npmDir: string;
|
|
66
|
+
/**
|
|
67
|
+
* Path to the build output dir, only needed when targets contains `wasm32-wasi-*`
|
|
68
|
+
*/
|
|
69
|
+
buildOutputDir?: string;
|
|
50
70
|
};
|
package/dist/def/artifacts.js
CHANGED
|
@@ -9,21 +9,29 @@ export class BaseArtifactsCommand extends Command {
|
|
|
9
9
|
cwd = Option.String('--cwd', process.cwd(), {
|
|
10
10
|
description: 'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
11
11
|
});
|
|
12
|
+
configPath = Option.String('--config-path,-c', {
|
|
13
|
+
description: 'Path to `napi` config json file',
|
|
14
|
+
});
|
|
12
15
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
13
16
|
description: 'Path to `package.json`',
|
|
14
17
|
});
|
|
15
|
-
outputDir = Option.String('--output-dir,-o', './', {
|
|
18
|
+
outputDir = Option.String('--output-dir,-o,-d', './artifacts', {
|
|
16
19
|
description: 'Path to the folder where all built `.node` files put, same as `--output-dir` of build command',
|
|
17
20
|
});
|
|
18
21
|
npmDir = Option.String('--npm-dir', 'npm', {
|
|
19
22
|
description: 'Path to the folder where the npm packages put',
|
|
20
23
|
});
|
|
24
|
+
buildOutputDir = Option.String('--build-output-dir', {
|
|
25
|
+
description: 'Path to the build output dir, only needed when targets contains `wasm32-wasi-*`',
|
|
26
|
+
});
|
|
21
27
|
getOptions() {
|
|
22
28
|
return {
|
|
23
29
|
cwd: this.cwd,
|
|
30
|
+
configPath: this.configPath,
|
|
24
31
|
packageJsonPath: this.packageJsonPath,
|
|
25
32
|
outputDir: this.outputDir,
|
|
26
33
|
npmDir: this.npmDir,
|
|
34
|
+
buildOutputDir: this.buildOutputDir,
|
|
27
35
|
};
|
|
28
36
|
}
|
|
29
37
|
}
|
|
@@ -31,7 +39,7 @@ export function applyDefaultArtifactsOptions(options) {
|
|
|
31
39
|
return {
|
|
32
40
|
cwd: process.cwd(),
|
|
33
41
|
packageJsonPath: 'package.json',
|
|
34
|
-
outputDir: './',
|
|
42
|
+
outputDir: './artifacts',
|
|
35
43
|
npmDir: 'npm',
|
|
36
44
|
...options,
|
|
37
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/def/artifacts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,iCAAiC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,OAAgB,oBAAqB,SAAQ,OAAO;IACxD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;IAE9B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,WAAW,EACT,2EAA2E;KAC9E,CAAC,CAAA;IAEF,GAAG,GAAG,MAAM,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