@napi-rs/cli 3.0.0-alpha.2 → 3.0.0-alpha.4
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 +0 -0
- package/dist/api/build.js +8 -2
- package/dist/api/templates/ci-template.js +18 -17
- package/dist/api/templates/js-binding.js +242 -109
- package/dist/api/templates/package.json.js +1 -2
- package/dist/cli.js +0 -0
- package/dist/commands/artifacts.js +2 -1
- package/dist/commands/help.js +2 -1
- package/dist/def/artifacts.js +2 -1
- package/dist/def/build.d.ts +12 -0
- package/dist/def/build.js +10 -1
- package/dist/def/create-npm-dirs.js +2 -1
- package/dist/def/new.js +2 -1
- package/dist/def/pre-publish.js +2 -1
- package/dist/def/rename.js +2 -1
- package/dist/def/universalize.js +2 -1
- package/dist/def/version.js +2 -1
- package/dist/index.cjs +284 -127
- package/dist/utils/ci.js +9 -0
- package/dist/utils/target.d.ts +2 -2
- package/dist/utils/target.js +4 -0
- package/package.json +5 -5
- package/src/api/build.ts +11 -7
- package/src/api/templates/ci-template.ts +18 -17
- package/src/api/templates/js-binding.ts +231 -104
- package/src/api/templates/package.json.ts +1 -2
- package/src/def/build.ts +19 -0
- 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/ci.ts +9 -0
- package/src/utils/target.ts +5 -0
- package/dist/def/commands/artifacts.d.ts +0 -15
- package/dist/def/commands/artifacts.js +0 -29
- package/dist/def/commands/build.d.ts +0 -53
- package/dist/def/commands/build.js +0 -105
- package/dist/def/commands/create-npm-dirs.d.ts +0 -15
- package/dist/def/commands/create-npm-dirs.js +0 -29
- package/dist/def/commands/new.d.ts +0 -27
- package/dist/def/commands/new.js +0 -53
- package/dist/def/commands/pre-publish.d.ts +0 -23
- package/dist/def/commands/pre-publish.js +0 -45
- package/dist/def/commands/rename.d.ts +0 -25
- package/dist/def/commands/rename.js +0 -49
- package/dist/def/commands/universalize.d.ts +0 -13
- package/dist/def/commands/universalize.js +0 -25
- package/dist/def/commands/version.d.ts +0 -13
- package/dist/def/commands/version.js +0 -25
- package/dist/def/options/artifacts.d.ts +0 -35
- package/dist/def/options/artifacts.js +0 -11
- package/dist/def/options/build.d.ts +0 -97
- package/dist/def/options/build.js +0 -3
- package/dist/def/options/create-npm-dirs.d.ts +0 -35
- package/dist/def/options/create-npm-dirs.js +0 -11
- package/dist/def/options/new.d.ts +0 -79
- package/dist/def/options/new.js +0 -15
- package/dist/def/options/pre-publish.d.ts +0 -65
- package/dist/def/options/pre-publish.js +0 -13
- package/dist/def/options/rename.d.ts +0 -75
- package/dist/def/options/rename.js +0 -11
- package/dist/def/options/universalize.d.ts +0 -28
- package/dist/def/options/universalize.js +0 -10
- package/dist/def/options/version.d.ts +0 -28
- package/dist/def/options/version.js +0 -10
package/cli.mjs
CHANGED
|
File without changes
|
package/dist/api/build.js
CHANGED
|
@@ -90,7 +90,8 @@ class Builder {
|
|
|
90
90
|
debug(' %i', `cargo ${this.args.join(' ')}`);
|
|
91
91
|
const controller = new AbortController();
|
|
92
92
|
const buildTask = new Promise((resolve, reject) => {
|
|
93
|
-
const
|
|
93
|
+
const command = process.env.CARGO ?? (this.options.useCross ? 'cross' : 'cargo');
|
|
94
|
+
const buildProcess = spawn(command, this.args, {
|
|
94
95
|
env: {
|
|
95
96
|
...process.env,
|
|
96
97
|
...this.envs,
|
|
@@ -287,6 +288,9 @@ class Builder {
|
|
|
287
288
|
if (this.options.targetDir) {
|
|
288
289
|
this.args.push('--target-dir', this.options.targetDir);
|
|
289
290
|
}
|
|
291
|
+
if (this.options.profile) {
|
|
292
|
+
this.args.push('--profile', this.options.profile);
|
|
293
|
+
}
|
|
290
294
|
if (this.options.cargoOptions?.length) {
|
|
291
295
|
this.args.push(...this.options.cargoOptions);
|
|
292
296
|
}
|
|
@@ -331,7 +335,9 @@ class Builder {
|
|
|
331
335
|
if (!srcName || !destName) {
|
|
332
336
|
return;
|
|
333
337
|
}
|
|
334
|
-
const
|
|
338
|
+
const profile = this.options.profile ?? (this.options.release ? 'release' : 'debug');
|
|
339
|
+
const src = join(this.targetDir, this.target.triple, profile, srcName);
|
|
340
|
+
debug(`Copy artifact from: [${src}]`);
|
|
335
341
|
const dest = join(this.outputDir, destName);
|
|
336
342
|
try {
|
|
337
343
|
if (await fileExists(dest)) {
|
|
@@ -71,7 +71,7 @@ jobs:
|
|
|
71
71
|
sudo apt-get update
|
|
72
72
|
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
73
73
|
build: |
|
|
74
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
74
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
75
75
|
arm-linux-gnueabihf-strip *.node
|
|
76
76
|
- host: ubuntu-latest
|
|
77
77
|
target: 'aarch64-linux-android'
|
|
@@ -94,6 +94,14 @@ jobs:
|
|
|
94
94
|
- host: windows-latest
|
|
95
95
|
target: 'aarch64-pc-windows-msvc'
|
|
96
96
|
build: yarn build --platform --target aarch64-pc-windows-msvc
|
|
97
|
+
- host: ubuntu-latest
|
|
98
|
+
target: 'riscv64gc-unknown-linux-gnu'
|
|
99
|
+
setup: |
|
|
100
|
+
sudo apt-get update
|
|
101
|
+
sudo apt-get install gcc-riscv64-linux-gnu -y
|
|
102
|
+
build: |
|
|
103
|
+
yarn build --platform --target riscv64gc-unknown-linux-gnu
|
|
104
|
+
riscv64-linux-gnu-strip *.node
|
|
97
105
|
|
|
98
106
|
name: stable - \${{ matrix.settings.target }} - node@18
|
|
99
107
|
runs-on: \${{ matrix.settings.host }}
|
|
@@ -106,7 +114,6 @@ jobs:
|
|
|
106
114
|
if: \${{ !matrix.settings.docker }}
|
|
107
115
|
with:
|
|
108
116
|
node-version: 18
|
|
109
|
-
check-latest: true
|
|
110
117
|
cache: yarn
|
|
111
118
|
|
|
112
119
|
- name: Install
|
|
@@ -150,7 +157,6 @@ jobs:
|
|
|
150
157
|
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
151
158
|
with:
|
|
152
159
|
node-version: 18
|
|
153
|
-
check-latest: true
|
|
154
160
|
cache: yarn
|
|
155
161
|
architecture: x86
|
|
156
162
|
|
|
@@ -237,7 +243,7 @@ jobs:
|
|
|
237
243
|
target: 'x86_64-apple-darwin'
|
|
238
244
|
- host: windows-latest
|
|
239
245
|
target: 'x86_64-pc-windows-msvc'
|
|
240
|
-
node: ['
|
|
246
|
+
node: ['16', '18']
|
|
241
247
|
runs-on: \${{ matrix.settings.host }}
|
|
242
248
|
|
|
243
249
|
steps:
|
|
@@ -247,7 +253,6 @@ jobs:
|
|
|
247
253
|
uses: actions/setup-node@v3
|
|
248
254
|
with:
|
|
249
255
|
node-version: \${{ matrix.node }}
|
|
250
|
-
check-latest: true
|
|
251
256
|
cache: 'yarn'
|
|
252
257
|
|
|
253
258
|
- name: 'Install dependencies'
|
|
@@ -273,7 +278,7 @@ jobs:
|
|
|
273
278
|
strategy:
|
|
274
279
|
fail-fast: false
|
|
275
280
|
matrix:
|
|
276
|
-
node: ['
|
|
281
|
+
node: ['16', '18']
|
|
277
282
|
runs-on: ubuntu-latest
|
|
278
283
|
|
|
279
284
|
steps:
|
|
@@ -283,7 +288,6 @@ jobs:
|
|
|
283
288
|
uses: actions/setup-node@v3
|
|
284
289
|
with:
|
|
285
290
|
node-version: \${{ matrix.node }}
|
|
286
|
-
check-latest: true
|
|
287
291
|
cache: 'yarn'
|
|
288
292
|
|
|
289
293
|
- name: 'Install dependencies'
|
|
@@ -309,7 +313,7 @@ jobs:
|
|
|
309
313
|
strategy:
|
|
310
314
|
fail-fast: false
|
|
311
315
|
matrix:
|
|
312
|
-
node: ['
|
|
316
|
+
node: ['16', '18']
|
|
313
317
|
runs-on: ubuntu-latest
|
|
314
318
|
|
|
315
319
|
steps:
|
|
@@ -319,7 +323,6 @@ jobs:
|
|
|
319
323
|
uses: actions/setup-node@v3
|
|
320
324
|
with:
|
|
321
325
|
node-version: \${{ matrix.node }}
|
|
322
|
-
check-latest: true
|
|
323
326
|
cache: 'yarn'
|
|
324
327
|
|
|
325
328
|
- name: 'Install dependencies'
|
|
@@ -347,7 +350,7 @@ jobs:
|
|
|
347
350
|
strategy:
|
|
348
351
|
fail-fast: false
|
|
349
352
|
matrix:
|
|
350
|
-
node: ['
|
|
353
|
+
node: ['16', '18']
|
|
351
354
|
runs-on: ubuntu-latest
|
|
352
355
|
|
|
353
356
|
steps:
|
|
@@ -368,7 +371,7 @@ jobs:
|
|
|
368
371
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
369
372
|
yarn config set supportedArchitectures.libc "glibc"
|
|
370
373
|
yarn install
|
|
371
|
-
|
|
374
|
+
|
|
372
375
|
- name: Set up QEMU
|
|
373
376
|
uses: docker/setup-qemu-action@v2
|
|
374
377
|
with:
|
|
@@ -433,7 +436,7 @@ jobs:
|
|
|
433
436
|
strategy:
|
|
434
437
|
fail-fast: false
|
|
435
438
|
matrix:
|
|
436
|
-
node: ['
|
|
439
|
+
node: ['16', '18']
|
|
437
440
|
runs-on: ubuntu-latest
|
|
438
441
|
|
|
439
442
|
steps:
|
|
@@ -483,7 +486,6 @@ jobs:
|
|
|
483
486
|
uses: actions/setup-node@v3
|
|
484
487
|
with:
|
|
485
488
|
node-version: 18
|
|
486
|
-
check-latest: true
|
|
487
489
|
cache: yarn
|
|
488
490
|
|
|
489
491
|
- name: 'Install dependencies'
|
|
@@ -493,15 +495,15 @@ jobs:
|
|
|
493
495
|
uses: actions/download-artifact@v3
|
|
494
496
|
with:
|
|
495
497
|
name: bindings-x86_64-apple-darwin
|
|
496
|
-
path:
|
|
498
|
+
path: .
|
|
497
499
|
- name: Download macOS arm64 artifact
|
|
498
500
|
uses: actions/download-artifact@v3
|
|
499
501
|
with:
|
|
500
502
|
name: bindings-aarch64-apple-darwin
|
|
501
|
-
path:
|
|
503
|
+
path: .
|
|
502
504
|
|
|
503
505
|
- name: Combine binaries
|
|
504
|
-
run: yarn
|
|
506
|
+
run: yarn napi universalize
|
|
505
507
|
|
|
506
508
|
- name: Upload artifact
|
|
507
509
|
uses: actions/upload-artifact@v3
|
|
@@ -529,7 +531,6 @@ jobs:
|
|
|
529
531
|
uses: actions/setup-node@v3
|
|
530
532
|
with:
|
|
531
533
|
node-version: 18
|
|
532
|
-
check-latest: true
|
|
533
534
|
cache: 'yarn'
|
|
534
535
|
|
|
535
536
|
- name: 'Install dependencies'
|
|
@@ -1,124 +1,257 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
export function createJsBinding(localName, pkgName) {
|
|
2
|
+
return `// prettier-ignore
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
|
|
6
|
+
/* auto-generated by NAPI-RS */
|
|
7
|
+
|
|
8
|
+
const { existsSync, readFileSync } = require('fs')
|
|
9
|
+
const { join } = require('path')
|
|
10
|
+
|
|
11
|
+
const { platform, arch } = process
|
|
12
|
+
|
|
13
|
+
let nativeBinding = null
|
|
14
|
+
let localFileExisted = false
|
|
15
|
+
let loadError = null
|
|
16
|
+
|
|
17
|
+
function isMusl() {
|
|
18
|
+
// For Node 10
|
|
19
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
20
|
+
try {
|
|
21
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
22
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
28
|
+
return !glibcVersionRuntime
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
switch (platform) {
|
|
33
|
+
case 'android':
|
|
34
|
+
switch (arch) {
|
|
35
|
+
case 'arm64':
|
|
36
|
+
localFileExisted = existsSync(join(__dirname, '${localName}.android-arm64.node'))
|
|
37
|
+
try {
|
|
38
|
+
if (localFileExisted) {
|
|
39
|
+
nativeBinding = require('./${localName}.android-arm64.node')
|
|
40
|
+
} else {
|
|
41
|
+
nativeBinding = require('${pkgName}-android-arm64')
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
loadError = e
|
|
20
45
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
break
|
|
47
|
+
case 'arm':
|
|
48
|
+
localFileExisted = existsSync(join(__dirname, '${localName}.android-arm-eabi.node'))
|
|
49
|
+
try {
|
|
50
|
+
if (localFileExisted) {
|
|
51
|
+
nativeBinding = require('./${localName}.android-arm-eabi.node')
|
|
52
|
+
} else {
|
|
53
|
+
nativeBinding = require('${pkgName}-android-arm-eabi')
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
loadError = e
|
|
25
57
|
}
|
|
58
|
+
break
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(\`Unsupported architecture on Android \${arch}\`)
|
|
26
61
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
candidates.push('linux-x64-gnu');
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
case 'arm64':
|
|
78
|
-
if (isMusl()) {
|
|
79
|
-
candidates.push('linux-arm64-musl');
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
candidates.push('linux-arm64-gnu');
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
case 'arm':
|
|
86
|
-
candidates.push('linux-arm-gnueabihf');
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
62
|
+
break
|
|
63
|
+
case 'win32':
|
|
64
|
+
switch (arch) {
|
|
65
|
+
case 'x64':
|
|
66
|
+
localFileExisted = existsSync(
|
|
67
|
+
join(__dirname, '${localName}.win32-x64-msvc.node')
|
|
68
|
+
)
|
|
69
|
+
try {
|
|
70
|
+
if (localFileExisted) {
|
|
71
|
+
nativeBinding = require('./${localName}.win32-x64-msvc.node')
|
|
72
|
+
} else {
|
|
73
|
+
nativeBinding = require('${pkgName}-win32-x64-msvc')
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
loadError = e
|
|
77
|
+
}
|
|
78
|
+
break
|
|
79
|
+
case 'ia32':
|
|
80
|
+
localFileExisted = existsSync(
|
|
81
|
+
join(__dirname, '${localName}.win32-ia32-msvc.node')
|
|
82
|
+
)
|
|
83
|
+
try {
|
|
84
|
+
if (localFileExisted) {
|
|
85
|
+
nativeBinding = require('./${localName}.win32-ia32-msvc.node')
|
|
86
|
+
} else {
|
|
87
|
+
nativeBinding = require('${pkgName}-win32-ia32-msvc')
|
|
88
|
+
}
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadError = e
|
|
91
|
+
}
|
|
92
|
+
break
|
|
93
|
+
case 'arm64':
|
|
94
|
+
localFileExisted = existsSync(
|
|
95
|
+
join(__dirname, '${localName}.win32-arm64-msvc.node')
|
|
96
|
+
)
|
|
97
|
+
try {
|
|
98
|
+
if (localFileExisted) {
|
|
99
|
+
nativeBinding = require('./${localName}.win32-arm64-msvc.node')
|
|
100
|
+
} else {
|
|
101
|
+
nativeBinding = require('${pkgName}-win32-arm64-msvc')
|
|
102
|
+
}
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadError = e
|
|
105
|
+
}
|
|
106
|
+
break
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(\`Unsupported architecture on Windows: \${arch}\`)
|
|
90
109
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
break
|
|
111
|
+
case 'darwin':
|
|
112
|
+
localFileExisted = existsSync(join(__dirname, '${localName}.darwin-universal.node'))
|
|
113
|
+
try {
|
|
114
|
+
if (localFileExisted) {
|
|
115
|
+
nativeBinding = require('./${localName}.darwin-universal.node')
|
|
116
|
+
} else {
|
|
117
|
+
nativeBinding = require('${pkgName}-darwin-universal')
|
|
118
|
+
}
|
|
119
|
+
break
|
|
120
|
+
} catch {}
|
|
121
|
+
switch (arch) {
|
|
122
|
+
case 'x64':
|
|
123
|
+
localFileExisted = existsSync(join(__dirname, '${localName}.darwin-x64.node'))
|
|
96
124
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
if (localFileExisted) {
|
|
126
|
+
nativeBinding = require('./${localName}.darwin-x64.node')
|
|
127
|
+
} else {
|
|
128
|
+
nativeBinding = require('${pkgName}-darwin-x64')
|
|
129
|
+
}
|
|
130
|
+
} catch (e) {
|
|
131
|
+
loadError = e
|
|
132
|
+
}
|
|
133
|
+
break
|
|
134
|
+
case 'arm64':
|
|
135
|
+
localFileExisted = existsSync(
|
|
136
|
+
join(__dirname, '${localName}.darwin-arm64.node')
|
|
137
|
+
)
|
|
138
|
+
try {
|
|
139
|
+
if (localFileExisted) {
|
|
140
|
+
nativeBinding = require('./${localName}.darwin-arm64.node')
|
|
141
|
+
} else {
|
|
142
|
+
nativeBinding = require('${pkgName}-darwin-arm64')
|
|
143
|
+
}
|
|
144
|
+
} catch (e) {
|
|
145
|
+
loadError = e
|
|
146
|
+
}
|
|
147
|
+
break
|
|
148
|
+
default:
|
|
149
|
+
throw new Error(\`Unsupported architecture on macOS: \${arch}\`)
|
|
150
|
+
}
|
|
151
|
+
break
|
|
152
|
+
case 'freebsd':
|
|
153
|
+
if (arch !== 'x64') {
|
|
154
|
+
throw new Error(\`Unsupported architecture on FreeBSD: \${arch}\`)
|
|
155
|
+
}
|
|
156
|
+
localFileExisted = existsSync(join(__dirname, '${localName}.freebsd-x64.node'))
|
|
157
|
+
try {
|
|
158
|
+
if (localFileExisted) {
|
|
159
|
+
nativeBinding = require('./${localName}.freebsd-x64.node')
|
|
160
|
+
} else {
|
|
161
|
+
nativeBinding = require('${pkgName}-freebsd-x64')
|
|
162
|
+
}
|
|
163
|
+
} catch (e) {
|
|
164
|
+
loadError = e
|
|
165
|
+
}
|
|
166
|
+
break
|
|
167
|
+
case 'linux':
|
|
168
|
+
switch (arch) {
|
|
169
|
+
case 'x64':
|
|
170
|
+
if (isMusl()) {
|
|
171
|
+
localFileExisted = existsSync(
|
|
172
|
+
join(__dirname, '${localName}.linux-x64-musl.node')
|
|
173
|
+
)
|
|
174
|
+
try {
|
|
175
|
+
if (localFileExisted) {
|
|
176
|
+
nativeBinding = require('./${localName}.linux-x64-musl.node')
|
|
177
|
+
} else {
|
|
178
|
+
nativeBinding = require('${pkgName}-linux-x64-musl')
|
|
99
179
|
}
|
|
100
|
-
|
|
101
|
-
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadError = e
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
localFileExisted = existsSync(
|
|
185
|
+
join(__dirname, '${localName}.linux-x64-gnu.node')
|
|
186
|
+
)
|
|
187
|
+
try {
|
|
188
|
+
if (localFileExisted) {
|
|
189
|
+
nativeBinding = require('./${localName}.linux-x64-gnu.node')
|
|
190
|
+
} else {
|
|
191
|
+
nativeBinding = require('${pkgName}-linux-x64-gnu')
|
|
102
192
|
}
|
|
193
|
+
} catch (e) {
|
|
194
|
+
loadError = e
|
|
195
|
+
}
|
|
103
196
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
197
|
+
break
|
|
198
|
+
case 'arm64':
|
|
199
|
+
if (isMusl()) {
|
|
200
|
+
localFileExisted = existsSync(
|
|
201
|
+
join(__dirname, '${localName}.linux-arm64-musl.node')
|
|
202
|
+
)
|
|
203
|
+
try {
|
|
204
|
+
if (localFileExisted) {
|
|
205
|
+
nativeBinding = require('./${localName}.linux-arm64-musl.node')
|
|
206
|
+
} else {
|
|
207
|
+
nativeBinding = require('${pkgName}-linux-arm64-musl')
|
|
208
|
+
}
|
|
209
|
+
} catch (e) {
|
|
210
|
+
loadError = e
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
localFileExisted = existsSync(
|
|
214
|
+
join(__dirname, '${localName}.linux-arm64-gnu.node')
|
|
215
|
+
)
|
|
216
|
+
try {
|
|
217
|
+
if (localFileExisted) {
|
|
218
|
+
nativeBinding = require('./${localName}.linux-arm64-gnu.node')
|
|
219
|
+
} else {
|
|
220
|
+
nativeBinding = require('${pkgName}-linux-arm64-gnu')
|
|
221
|
+
}
|
|
222
|
+
} catch (e) {
|
|
223
|
+
loadError = e
|
|
224
|
+
}
|
|
107
225
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
226
|
+
break
|
|
227
|
+
case 'arm':
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, '${localName}.linux-arm-gnueabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./${localName}.linux-arm-gnueabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('${pkgName}-linux-arm-gnueabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
114
239
|
}
|
|
115
|
-
|
|
240
|
+
break
|
|
241
|
+
default:
|
|
242
|
+
throw new Error(\`Unsupported architecture on Linux: \${arch}\`)
|
|
116
243
|
}
|
|
117
|
-
|
|
244
|
+
break
|
|
245
|
+
default:
|
|
246
|
+
throw new Error(\`Unsupported OS: \${platform}, architecture: \${arch}\`)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!nativeBinding) {
|
|
250
|
+
if (loadError) {
|
|
251
|
+
throw loadError
|
|
252
|
+
}
|
|
253
|
+
throw new Error(\`Failed to load native binding\`)
|
|
118
254
|
}
|
|
119
|
-
export function createJsBinding(localName, pkgName) {
|
|
120
|
-
return `${loadNapiModule.toString()}
|
|
121
255
|
|
|
122
|
-
module.exports = loadNapiModule('${localName}', '${pkgName}')
|
|
123
256
|
`;
|
|
124
257
|
}
|
|
@@ -15,12 +15,11 @@ export const createPackageJson = ({ name, binaryName, targets, license, engineRe
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "node -e \\"assert(require('.').sum(1, 2) === 3)\\"",
|
|
19
19
|
"build": "napi build --release --platform --strip",
|
|
20
20
|
"build:debug": "napi build",
|
|
21
21
|
"prepublishOnly": "napi prepublish -t npm",
|
|
22
22
|
"artifacts": "napi artifacts",
|
|
23
|
-
"universal": "napi universal",
|
|
24
23
|
"version": "napi version"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'clipanion';
|
|
2
2
|
import { collectArtifacts } from '../api/artifacts.js';
|
|
3
3
|
import { BaseArtifactsCommand } from '../def/artifacts.js';
|
|
4
|
-
|
|
4
|
+
class ArtifactsCommand extends BaseArtifactsCommand {
|
|
5
5
|
static usage = Command.Usage({
|
|
6
6
|
description: 'Copy artifacts from Github Actions into specified dir',
|
|
7
7
|
examples: [
|
|
@@ -17,3 +17,4 @@ e.g: index.linux-x64-gnu.node --> ./npm/linux-x64-gnu/index.node`,
|
|
|
17
17
|
await collectArtifacts(this.getOptions());
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
export { ArtifactsCommand };
|
package/dist/commands/help.js
CHANGED
|
@@ -4,9 +4,10 @@ import { Command } from 'clipanion';
|
|
|
4
4
|
*
|
|
5
5
|
* Paths: `-h`, `--help`
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
class HelpCommand extends Command {
|
|
8
8
|
static paths = [[`-h`], [`--help`]];
|
|
9
9
|
async execute() {
|
|
10
10
|
await this.context.stdout.write(this.cli.usage());
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
export { HelpCommand };
|
package/dist/def/artifacts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is generated by codegen/index.ts
|
|
2
2
|
// Do not edit this file manually
|
|
3
3
|
import { Command, Option } from 'clipanion';
|
|
4
|
-
|
|
4
|
+
class BaseArtifactsCommand extends Command {
|
|
5
5
|
static paths = [['artifacts']];
|
|
6
6
|
static usage = Command.Usage({
|
|
7
7
|
description: 'Copy artifacts from Github Actions into npm packages and ready to publish',
|
|
@@ -27,6 +27,7 @@ export class BaseArtifactsCommand extends Command {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
export { BaseArtifactsCommand };
|
|
30
31
|
export function applyDefaultArtifactsOptions(options) {
|
|
31
32
|
return {
|
|
32
33
|
cwd: process.cwd(),
|
package/dist/def/build.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export declare abstract class BaseBuildCommand extends Command {
|
|
|
20
20
|
verbose?: boolean;
|
|
21
21
|
bin?: string;
|
|
22
22
|
package?: string;
|
|
23
|
+
profile?: string;
|
|
23
24
|
crossCompile?: boolean;
|
|
25
|
+
useCross?: boolean;
|
|
24
26
|
watch?: boolean;
|
|
25
27
|
features?: string[];
|
|
26
28
|
allFeatures?: boolean;
|
|
@@ -44,7 +46,9 @@ export declare abstract class BaseBuildCommand extends Command {
|
|
|
44
46
|
verbose: boolean | undefined;
|
|
45
47
|
bin: string | undefined;
|
|
46
48
|
package: string | undefined;
|
|
49
|
+
profile: string | undefined;
|
|
47
50
|
crossCompile: boolean | undefined;
|
|
51
|
+
useCross: boolean | undefined;
|
|
48
52
|
watch: boolean | undefined;
|
|
49
53
|
features: string[] | undefined;
|
|
50
54
|
allFeatures: boolean | undefined;
|
|
@@ -127,10 +131,18 @@ export interface BuildOptions {
|
|
|
127
131
|
* Build the specified library or the one at cwd
|
|
128
132
|
*/
|
|
129
133
|
package?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Build artifacts with the specified profile
|
|
136
|
+
*/
|
|
137
|
+
profile?: string;
|
|
130
138
|
/**
|
|
131
139
|
* [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
|
|
132
140
|
*/
|
|
133
141
|
crossCompile?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
|
|
144
|
+
*/
|
|
145
|
+
useCross?: boolean;
|
|
134
146
|
/**
|
|
135
147
|
* watch the crate changes and build continiously with `cargo-watch` crates
|
|
136
148
|
*/
|