@napi-rs/cli 3.4.1 → 3.5.1
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/cli.js +97 -252
- package/dist/index.cjs +219 -382
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +2 -2
- package/dist/index.js +97 -252
- package/package.json +15 -19
- package/src/api/build.ts +1 -1
- package/src/api/templates/js-binding.ts +6 -2
- package/src/api/templates/load-wasi-template.ts +1 -1
- package/src/utils/config.ts +2 -0
- package/src/utils/log.ts +10 -8
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Cli tools for napi-rs",
|
|
5
5
|
"author": "LongYinan <lynweklm@gmail.com>",
|
|
6
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://napi.rs/",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"engines": {
|
|
@@ -60,45 +60,41 @@
|
|
|
60
60
|
"url": "https://github.com/napi-rs/napi-rs/issues"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@inquirer/prompts": "^
|
|
63
|
+
"@inquirer/prompts": "^8.0.0",
|
|
64
64
|
"@napi-rs/cross-toolchain": "^1.0.3",
|
|
65
65
|
"@napi-rs/wasm-tools": "^1.0.1",
|
|
66
|
-
"@octokit/rest": "^22.0.
|
|
66
|
+
"@octokit/rest": "^22.0.1",
|
|
67
67
|
"clipanion": "^4.0.0-rc.4",
|
|
68
68
|
"colorette": "^2.0.20",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"es-toolkit": "^1.39.10",
|
|
69
|
+
"emnapi": "^1.7.1",
|
|
70
|
+
"es-toolkit": "^1.41.0",
|
|
72
71
|
"js-yaml": "^4.1.0",
|
|
73
|
-
"
|
|
72
|
+
"obug": "^2.0.0",
|
|
73
|
+
"semver": "^7.7.3",
|
|
74
74
|
"typanion": "^3.14.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@emnapi/runtime": "^1.
|
|
78
|
-
"@oxc-node/core": "^0.0.
|
|
79
|
-
"@std/toml": "npm:@jsr/std__toml@^1.0.
|
|
80
|
-
"@types/debug": "^4.1.12",
|
|
77
|
+
"@emnapi/runtime": "^1.7.1",
|
|
78
|
+
"@oxc-node/core": "^0.0.35",
|
|
79
|
+
"@std/toml": "npm:@jsr/std__toml@^1.0.11",
|
|
81
80
|
"@types/inquirer": "^9.0.9",
|
|
82
81
|
"@types/js-yaml": "^4.0.9",
|
|
83
|
-
"@types/node": "^24.
|
|
82
|
+
"@types/node": "^24.10.0",
|
|
84
83
|
"@types/semver": "^7.7.1",
|
|
85
84
|
"ava": "^6.4.1",
|
|
86
85
|
"empathic": "^2.0.0",
|
|
87
86
|
"env-paths": "^3.0.0",
|
|
88
87
|
"prettier": "^3.6.2",
|
|
89
|
-
"tsdown": "^0.
|
|
88
|
+
"tsdown": "^0.18.0",
|
|
90
89
|
"tslib": "^2.8.1",
|
|
91
|
-
"typescript": "^5.9.
|
|
90
|
+
"typescript": "^5.9.3"
|
|
92
91
|
},
|
|
93
92
|
"peerDependencies": {
|
|
94
|
-
"@emnapi/runtime": "^1.
|
|
93
|
+
"@emnapi/runtime": "^1.7.1"
|
|
95
94
|
},
|
|
96
95
|
"peerDependenciesMeta": {
|
|
97
96
|
"@emnapi/runtime": {
|
|
98
97
|
"optional": true
|
|
99
|
-
},
|
|
100
|
-
"emnapi": {
|
|
101
|
-
"optional": true
|
|
102
98
|
}
|
|
103
99
|
},
|
|
104
100
|
"funding": {
|
package/src/api/build.ts
CHANGED
|
@@ -915,7 +915,7 @@ class Builder {
|
|
|
915
915
|
jsBinding: this.options.jsBinding,
|
|
916
916
|
esm: this.options.esm,
|
|
917
917
|
binaryName: this.config.binaryName,
|
|
918
|
-
packageName: this.config.packageName,
|
|
918
|
+
packageName: this.options.jsPackageName ?? this.config.packageName,
|
|
919
919
|
version: process.env.npm_new_version ?? this.config.packageJson.version,
|
|
920
920
|
outputDir: this.outputDir,
|
|
921
921
|
})
|
|
@@ -238,13 +238,17 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
238
238
|
wasiBindingError = err
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
if (!nativeBinding) {
|
|
241
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
242
242
|
try {
|
|
243
243
|
wasiBinding = require('${pkgName}-wasm32-wasi')
|
|
244
244
|
nativeBinding = wasiBinding
|
|
245
245
|
} catch (err) {
|
|
246
246
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
247
|
-
wasiBindingError
|
|
247
|
+
if (!wasiBindingError) {
|
|
248
|
+
wasiBindingError = err
|
|
249
|
+
} else {
|
|
250
|
+
wasiBindingError.cause = err
|
|
251
|
+
}
|
|
248
252
|
loadErrors.push(err)
|
|
249
253
|
}
|
|
250
254
|
}
|
|
@@ -145,7 +145,7 @@ if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
|
|
145
145
|
__wasmFilePath = __wasmDebugFilePath
|
|
146
146
|
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
|
147
147
|
try {
|
|
148
|
-
__wasmFilePath =
|
|
148
|
+
__wasmFilePath = require.resolve('${packageName}-wasm32-wasi/${wasmFileName}.wasm')
|
|
149
149
|
} catch {
|
|
150
150
|
throw new Error('Cannot find ${wasmFileName}.wasm file, and ${packageName}-wasm32-wasi package is not installed.')
|
|
151
151
|
}
|
package/src/utils/config.ts
CHANGED
|
@@ -198,6 +198,8 @@ export async function readNapiConfig(
|
|
|
198
198
|
`Both napi field in ${pkgJsonPath} and [NAPI-RS config](${configPathUnderline}) file are found, the NAPI-RS config file will be used.`,
|
|
199
199
|
),
|
|
200
200
|
)
|
|
201
|
+
}
|
|
202
|
+
if (separatedConfig) {
|
|
201
203
|
Object.assign(userNapiConfig, separatedConfig)
|
|
202
204
|
}
|
|
203
205
|
const napiConfig: NapiConfig = merge(
|
package/src/utils/log.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import * as colors from 'colorette'
|
|
2
|
-
import
|
|
2
|
+
import { createDebug } from 'obug'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
rawDebug.formatters.i = (v) => {
|
|
6
|
-
return colors.green(v)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module 'debug' {
|
|
4
|
+
declare module 'obug' {
|
|
10
5
|
interface Debugger {
|
|
11
6
|
info: typeof console.error
|
|
12
7
|
warn: typeof console.error
|
|
@@ -15,7 +10,14 @@ declare module 'debug' {
|
|
|
15
10
|
}
|
|
16
11
|
|
|
17
12
|
export const debugFactory = (namespace: string) => {
|
|
18
|
-
const debug =
|
|
13
|
+
const debug = createDebug(`napi:${namespace}`, {
|
|
14
|
+
formatters: {
|
|
15
|
+
// debug('%i', 'This is an info')
|
|
16
|
+
i(v) {
|
|
17
|
+
return colors.green(v)
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
})
|
|
19
21
|
|
|
20
22
|
debug.info = (...args: any[]) =>
|
|
21
23
|
console.error(colors.black(colors.bgGreen(' INFO ')), ...args)
|