@napi-rs/cli 3.0.0-alpha.1 → 3.0.0-alpha.100
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/__tests__/create-npm-dirs.spec.d.ts +1 -0
- package/dist/api/__tests__/new.spec.d.ts +1 -0
- package/dist/api/build.d.ts +2 -2
- package/dist/api/create-npm-dirs.d.ts +5 -0
- package/dist/api/templates/index.d.ts +0 -7
- package/dist/api/templates/js-binding.d.ts +2 -1
- package/dist/api/templates/load-wasi-template.d.ts +2 -0
- package/dist/api/templates/wasi-worker-template.d.ts +2 -0
- package/dist/cli.js +3961 -14
- package/dist/def/artifacts.d.ts +21 -1
- package/dist/def/build.d.ts +167 -4
- package/dist/def/create-npm-dirs.d.ts +10 -0
- package/dist/def/new.d.ts +25 -7
- package/dist/def/pre-publish.d.ts +21 -2
- package/dist/def/rename.d.ts +16 -6
- package/dist/def/universalize.d.ts +10 -0
- package/dist/def/version.d.ts +10 -0
- package/dist/index.cjs +10142 -20524
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3711 -29
- package/dist/utils/__tests__/config.spec.d.ts +1 -0
- package/dist/utils/config.d.ts +70 -6
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/metadata.d.ts +13 -1
- package/dist/utils/misc.d.ts +3 -3
- package/dist/utils/read-config.d.ts +7 -0
- package/dist/utils/target.d.ts +9 -6
- package/dist/utils/typegen.d.ts +4 -1
- package/dist/utils/version.d.ts +2 -1
- package/package.json +60 -24
- package/src/api/__tests__/create-npm-dirs.spec.ts +210 -0
- package/src/api/__tests__/new.spec.ts +429 -0
- package/src/api/artifacts.ts +83 -8
- package/src/api/build.ts +682 -134
- package/src/api/create-npm-dirs.ts +64 -13
- package/src/api/new.ts +389 -125
- package/src/api/pre-publish.ts +27 -16
- package/src/api/rename.ts +103 -17
- package/src/api/templates/index.ts +0 -7
- package/src/api/templates/js-binding.ts +212 -107
- package/src/api/templates/load-wasi-template.ts +216 -0
- 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 -49
- package/src/def/artifacts.ts +22 -3
- package/src/def/build.ts +83 -8
- package/src/def/create-npm-dirs.ts +9 -0
- package/src/def/new.ts +28 -3
- package/src/def/pre-publish.ts +24 -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 +56 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +703 -164
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +9 -8
- 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 +19 -4
- package/src/utils/cargo.ts +2 -2
- package/src/utils/config.ts +147 -13
- package/src/utils/index.ts +1 -1
- package/src/utils/log.ts +1 -1
- package/src/utils/metadata.ts +52 -14
- package/src/utils/misc.ts +21 -7
- package/src/utils/read-config.ts +20 -0
- package/src/utils/target.ts +53 -9
- package/src/utils/typegen.ts +100 -40
- package/src/utils/version.ts +11 -9
- package/dist/api/artifacts.js +0 -50
- package/dist/api/build.js +0 -404
- package/dist/api/create-npm-dirs.js +0 -63
- package/dist/api/new.js +0 -154
- package/dist/api/pre-publish.js +0 -157
- package/dist/api/rename.js +0 -28
- package/dist/api/templates/.gitignore.d.ts +0 -1
- package/dist/api/templates/.gitignore.js +0 -198
- package/dist/api/templates/.npmignore.d.ts +0 -1
- package/dist/api/templates/.npmignore.js +0 -14
- package/dist/api/templates/build.rs.d.ts +0 -1
- package/dist/api/templates/build.rs.js +0 -4
- package/dist/api/templates/cargo.toml.d.ts +0 -6
- package/dist/api/templates/cargo.toml.js +0 -25
- package/dist/api/templates/ci-template.d.ts +0 -1
- package/dist/api/templates/ci-template.js +0 -566
- package/dist/api/templates/ci.yml.d.ts +0 -1
- package/dist/api/templates/ci.yml.js +0 -92
- package/dist/api/templates/index.js +0 -8
- package/dist/api/templates/js-binding.js +0 -124
- package/dist/api/templates/lib.rs.d.ts +0 -1
- package/dist/api/templates/lib.rs.js +0 -10
- package/dist/api/templates/package.json.d.ts +0 -8
- package/dist/api/templates/package.json.js +0 -30
- package/dist/api/universalize.js +0 -38
- package/dist/api/version.js +0 -16
- package/dist/commands/artifacts.js +0 -19
- package/dist/commands/build.js +0 -34
- package/dist/commands/create-npm-dirs.js +0 -7
- package/dist/commands/help.js +0 -12
- package/dist/commands/new.js +0 -112
- package/dist/commands/pre-publish.js +0 -8
- package/dist/commands/rename.js +0 -7
- package/dist/commands/universalize.js +0 -7
- package/dist/commands/version.js +0 -7
- package/dist/def/artifacts.js +0 -38
- package/dist/def/build.js +0 -105
- 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/create-npm-dirs.js +0 -38
- package/dist/def/new.js +0 -66
- 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/dist/def/pre-publish.js +0 -56
- package/dist/def/rename.js +0 -58
- package/dist/def/universalize.js +0 -33
- package/dist/def/version.js +0 -33
- package/dist/utils/__tests__/target.spec.js +0 -10
- package/dist/utils/__tests__/typegen.spec.js +0 -37
- package/dist/utils/__tests__/version.spec.js +0 -5
- package/dist/utils/cargo.js +0 -33
- package/dist/utils/ci.d.ts +0 -11
- package/dist/utils/ci.js +0 -86
- package/dist/utils/config.js +0 -42
- package/dist/utils/index.js +0 -9
- package/dist/utils/log.js +0 -14
- package/dist/utils/metadata.js +0 -19
- package/dist/utils/misc.js +0 -35
- package/dist/utils/target.js +0 -109
- package/dist/utils/typegen.js +0 -158
- package/dist/utils/version.js +0 -59
- package/src/api/templates/.gitignore.ts +0 -198
- package/src/api/templates/.npmignore.ts +0 -14
- package/src/api/templates/build.rs.ts +0 -4
- package/src/api/templates/cargo.toml.ts +0 -35
- package/src/api/templates/ci-template.ts +0 -566
- package/src/api/templates/ci.yml.ts +0 -116
- package/src/api/templates/lib.rs.ts +0 -10
- package/src/api/templates/package.json.ts +0 -44
- package/src/utils/ci.ts +0 -102
package/src/def/build.ts
CHANGED
|
@@ -6,7 +6,7 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
6
6
|
static paths = [['build']]
|
|
7
7
|
|
|
8
8
|
static usage = Command.Usage({
|
|
9
|
-
description: 'Build the
|
|
9
|
+
description: 'Build the NAPI-RS project',
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
target?: string = Option.String('--target,-t', {
|
|
@@ -23,6 +23,10 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
23
23
|
description: 'Path to `Cargo.toml`',
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
27
|
+
description: 'Path to `napi` config json file',
|
|
28
|
+
})
|
|
29
|
+
|
|
26
30
|
packageJsonPath?: string = Option.String('--package-json-path', {
|
|
27
31
|
description: 'Path to `package.json`',
|
|
28
32
|
})
|
|
@@ -47,9 +51,13 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
47
51
|
'Package name in generated js binding file. Only works with `--platform` flag',
|
|
48
52
|
})
|
|
49
53
|
|
|
54
|
+
constEnum?: boolean = Option.Boolean('--const-enum', {
|
|
55
|
+
description: 'Whether generate const enum for typescript bindings',
|
|
56
|
+
})
|
|
57
|
+
|
|
50
58
|
jsBinding?: string = Option.String('--js', {
|
|
51
59
|
description:
|
|
52
|
-
'Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--
|
|
60
|
+
'Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output-dir`.',
|
|
53
61
|
})
|
|
54
62
|
|
|
55
63
|
noJsBinding?: boolean = Option.Boolean('--no-js', {
|
|
@@ -59,7 +67,7 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
59
67
|
|
|
60
68
|
dts?: string = Option.String('--dts', {
|
|
61
69
|
description:
|
|
62
|
-
'Path and filename of generated type def file. Relative to `--
|
|
70
|
+
'Path and filename of generated type def file. Relative to `--output-dir`',
|
|
63
71
|
})
|
|
64
72
|
|
|
65
73
|
dtsHeader?: string = Option.String('--dts-header', {
|
|
@@ -72,6 +80,15 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
72
80
|
'Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.',
|
|
73
81
|
})
|
|
74
82
|
|
|
83
|
+
dtsCache = Option.Boolean('--dts-cache', true, {
|
|
84
|
+
description: 'Whether to enable the dts cache, default to true',
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
esm?: boolean = Option.Boolean('--esm', {
|
|
88
|
+
description:
|
|
89
|
+
'Whether to emit an ESM JS binding file instead of CJS format. Only works with `--platform` flag.',
|
|
90
|
+
})
|
|
91
|
+
|
|
75
92
|
strip?: boolean = Option.Boolean('--strip,-s', {
|
|
76
93
|
description: 'Whether strip the library to achieve the minimum file size',
|
|
77
94
|
})
|
|
@@ -92,14 +109,28 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
92
109
|
description: 'Build the specified library or the one at cwd',
|
|
93
110
|
})
|
|
94
111
|
|
|
112
|
+
profile?: string = Option.String('--profile', {
|
|
113
|
+
description: 'Build artifacts with the specified profile',
|
|
114
|
+
})
|
|
115
|
+
|
|
95
116
|
crossCompile?: boolean = Option.Boolean('--cross-compile,-x', {
|
|
96
117
|
description:
|
|
97
118
|
'[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
|
|
98
119
|
})
|
|
99
120
|
|
|
121
|
+
useCross?: boolean = Option.Boolean('--use-cross', {
|
|
122
|
+
description:
|
|
123
|
+
'[experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`',
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
useNapiCross?: boolean = Option.Boolean('--use-napi-cross', {
|
|
127
|
+
description:
|
|
128
|
+
'[experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.',
|
|
129
|
+
})
|
|
130
|
+
|
|
100
131
|
watch?: boolean = Option.Boolean('--watch,-w', {
|
|
101
132
|
description:
|
|
102
|
-
'watch the crate changes and build
|
|
133
|
+
'watch the crate changes and build continuously with `cargo-watch` crates',
|
|
103
134
|
})
|
|
104
135
|
|
|
105
136
|
features?: string[] = Option.Array('--features,-F', {
|
|
@@ -119,22 +150,29 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
119
150
|
target: this.target,
|
|
120
151
|
cwd: this.cwd,
|
|
121
152
|
manifestPath: this.manifestPath,
|
|
153
|
+
configPath: this.configPath,
|
|
122
154
|
packageJsonPath: this.packageJsonPath,
|
|
123
155
|
targetDir: this.targetDir,
|
|
124
156
|
outputDir: this.outputDir,
|
|
125
157
|
platform: this.platform,
|
|
126
158
|
jsPackageName: this.jsPackageName,
|
|
159
|
+
constEnum: this.constEnum,
|
|
127
160
|
jsBinding: this.jsBinding,
|
|
128
161
|
noJsBinding: this.noJsBinding,
|
|
129
162
|
dts: this.dts,
|
|
130
163
|
dtsHeader: this.dtsHeader,
|
|
131
164
|
noDtsHeader: this.noDtsHeader,
|
|
165
|
+
dtsCache: this.dtsCache,
|
|
166
|
+
esm: this.esm,
|
|
132
167
|
strip: this.strip,
|
|
133
168
|
release: this.release,
|
|
134
169
|
verbose: this.verbose,
|
|
135
170
|
bin: this.bin,
|
|
136
171
|
package: this.package,
|
|
172
|
+
profile: this.profile,
|
|
137
173
|
crossCompile: this.crossCompile,
|
|
174
|
+
useCross: this.useCross,
|
|
175
|
+
useNapiCross: this.useNapiCross,
|
|
138
176
|
watch: this.watch,
|
|
139
177
|
features: this.features,
|
|
140
178
|
allFeatures: this.allFeatures,
|
|
@@ -144,7 +182,7 @@ export abstract class BaseBuildCommand extends Command {
|
|
|
144
182
|
}
|
|
145
183
|
|
|
146
184
|
/**
|
|
147
|
-
* Build the
|
|
185
|
+
* Build the NAPI-RS project
|
|
148
186
|
*/
|
|
149
187
|
export interface BuildOptions {
|
|
150
188
|
/**
|
|
@@ -159,6 +197,10 @@ export interface BuildOptions {
|
|
|
159
197
|
* Path to `Cargo.toml`
|
|
160
198
|
*/
|
|
161
199
|
manifestPath?: string
|
|
200
|
+
/**
|
|
201
|
+
* Path to `napi` config json file
|
|
202
|
+
*/
|
|
203
|
+
configPath?: string
|
|
162
204
|
/**
|
|
163
205
|
* Path to `package.json`
|
|
164
206
|
*/
|
|
@@ -180,7 +222,11 @@ export interface BuildOptions {
|
|
|
180
222
|
*/
|
|
181
223
|
jsPackageName?: string
|
|
182
224
|
/**
|
|
183
|
-
*
|
|
225
|
+
* Whether generate const enum for typescript bindings
|
|
226
|
+
*/
|
|
227
|
+
constEnum?: boolean
|
|
228
|
+
/**
|
|
229
|
+
* Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output-dir`.
|
|
184
230
|
*/
|
|
185
231
|
jsBinding?: string
|
|
186
232
|
/**
|
|
@@ -188,7 +234,7 @@ export interface BuildOptions {
|
|
|
188
234
|
*/
|
|
189
235
|
noJsBinding?: boolean
|
|
190
236
|
/**
|
|
191
|
-
* Path and filename of generated type def file. Relative to `--
|
|
237
|
+
* Path and filename of generated type def file. Relative to `--output-dir`
|
|
192
238
|
*/
|
|
193
239
|
dts?: string
|
|
194
240
|
/**
|
|
@@ -199,6 +245,16 @@ export interface BuildOptions {
|
|
|
199
245
|
* Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.
|
|
200
246
|
*/
|
|
201
247
|
noDtsHeader?: boolean
|
|
248
|
+
/**
|
|
249
|
+
* Whether to enable the dts cache, default to true
|
|
250
|
+
*
|
|
251
|
+
* @default true
|
|
252
|
+
*/
|
|
253
|
+
dtsCache?: boolean
|
|
254
|
+
/**
|
|
255
|
+
* Whether to emit an ESM JS binding file instead of CJS format. Only works with `--platform` flag.
|
|
256
|
+
*/
|
|
257
|
+
esm?: boolean
|
|
202
258
|
/**
|
|
203
259
|
* Whether strip the library to achieve the minimum file size
|
|
204
260
|
*/
|
|
@@ -219,12 +275,24 @@ export interface BuildOptions {
|
|
|
219
275
|
* Build the specified library or the one at cwd
|
|
220
276
|
*/
|
|
221
277
|
package?: string
|
|
278
|
+
/**
|
|
279
|
+
* Build artifacts with the specified profile
|
|
280
|
+
*/
|
|
281
|
+
profile?: string
|
|
222
282
|
/**
|
|
223
283
|
* [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
|
|
224
284
|
*/
|
|
225
285
|
crossCompile?: boolean
|
|
226
286
|
/**
|
|
227
|
-
*
|
|
287
|
+
* [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
|
|
288
|
+
*/
|
|
289
|
+
useCross?: boolean
|
|
290
|
+
/**
|
|
291
|
+
* [experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.
|
|
292
|
+
*/
|
|
293
|
+
useNapiCross?: boolean
|
|
294
|
+
/**
|
|
295
|
+
* watch the crate changes and build continuously with `cargo-watch` crates
|
|
228
296
|
*/
|
|
229
297
|
watch?: boolean
|
|
230
298
|
/**
|
|
@@ -240,3 +308,10 @@ export interface BuildOptions {
|
|
|
240
308
|
*/
|
|
241
309
|
noDefaultFeatures?: boolean
|
|
242
310
|
}
|
|
311
|
+
|
|
312
|
+
export function applyDefaultBuildOptions(options: BuildOptions) {
|
|
313
|
+
return {
|
|
314
|
+
dtsCache: true,
|
|
315
|
+
...options,
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -14,6 +14,10 @@ export abstract class BaseCreateNpmDirsCommand extends Command {
|
|
|
14
14
|
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
18
|
+
description: 'Path to `napi` config json file',
|
|
19
|
+
})
|
|
20
|
+
|
|
17
21
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
22
|
description: 'Path to `package.json`',
|
|
19
23
|
})
|
|
@@ -29,6 +33,7 @@ export abstract class BaseCreateNpmDirsCommand extends Command {
|
|
|
29
33
|
getOptions() {
|
|
30
34
|
return {
|
|
31
35
|
cwd: this.cwd,
|
|
36
|
+
configPath: this.configPath,
|
|
32
37
|
packageJsonPath: this.packageJsonPath,
|
|
33
38
|
npmDir: this.npmDir,
|
|
34
39
|
dryRun: this.dryRun,
|
|
@@ -46,6 +51,10 @@ export interface CreateNpmDirsOptions {
|
|
|
46
51
|
* @default process.cwd()
|
|
47
52
|
*/
|
|
48
53
|
cwd?: string
|
|
54
|
+
/**
|
|
55
|
+
* Path to `napi` config json file
|
|
56
|
+
*/
|
|
57
|
+
configPath?: string
|
|
49
58
|
/**
|
|
50
59
|
* Path to `package.json`
|
|
51
60
|
*
|
package/src/def/new.ts
CHANGED
|
@@ -10,7 +10,7 @@ export abstract class BaseNewCommand extends Command {
|
|
|
10
10
|
description: 'Create a new project with pre-configured boilerplate',
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
$$path = Option.String({ required:
|
|
13
|
+
$$path = Option.String({ required: false })
|
|
14
14
|
|
|
15
15
|
$$name?: string = Option.String('--name,-n', {
|
|
16
16
|
description:
|
|
@@ -22,6 +22,10 @@ export abstract class BaseNewCommand extends Command {
|
|
|
22
22
|
description: 'The minimum Node-API version to support',
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
packageManager = Option.String('--package-manager', 'yarn', {
|
|
26
|
+
description: 'The package manager to use. Only support yarn 4.x for now.',
|
|
27
|
+
})
|
|
28
|
+
|
|
25
29
|
license = Option.String('--license,-l', 'MIT', {
|
|
26
30
|
description: 'License for open-sourced project',
|
|
27
31
|
})
|
|
@@ -47,6 +51,11 @@ export abstract class BaseNewCommand extends Command {
|
|
|
47
51
|
description: 'Whether generate preconfigured GitHub Actions workflow',
|
|
48
52
|
})
|
|
49
53
|
|
|
54
|
+
testFramework = Option.String('--test-framework', 'ava', {
|
|
55
|
+
description:
|
|
56
|
+
'The JavaScript test framework to use, only support `ava` for now',
|
|
57
|
+
})
|
|
58
|
+
|
|
50
59
|
dryRun = Option.Boolean('--dry-run', false, {
|
|
51
60
|
description: 'Whether to run the command in dry-run mode',
|
|
52
61
|
})
|
|
@@ -56,12 +65,14 @@ export abstract class BaseNewCommand extends Command {
|
|
|
56
65
|
path: this.$$path,
|
|
57
66
|
name: this.$$name,
|
|
58
67
|
minNodeApiVersion: this.minNodeApiVersion,
|
|
68
|
+
packageManager: this.packageManager,
|
|
59
69
|
license: this.license,
|
|
60
70
|
targets: this.targets,
|
|
61
71
|
enableDefaultTargets: this.enableDefaultTargets,
|
|
62
72
|
enableAllTargets: this.enableAllTargets,
|
|
63
73
|
enableTypeDef: this.enableTypeDef,
|
|
64
74
|
enableGithubActions: this.enableGithubActions,
|
|
75
|
+
testFramework: this.testFramework,
|
|
65
76
|
dryRun: this.dryRun,
|
|
66
77
|
}
|
|
67
78
|
}
|
|
@@ -72,9 +83,9 @@ export abstract class BaseNewCommand extends Command {
|
|
|
72
83
|
*/
|
|
73
84
|
export interface NewOptions {
|
|
74
85
|
/**
|
|
75
|
-
* The path where the
|
|
86
|
+
* The path where the NAPI-RS project will be created.
|
|
76
87
|
*/
|
|
77
|
-
path
|
|
88
|
+
path?: string
|
|
78
89
|
/**
|
|
79
90
|
* The name of the project, default to the name of the directory if not provided
|
|
80
91
|
*/
|
|
@@ -85,6 +96,12 @@ export interface NewOptions {
|
|
|
85
96
|
* @default 4
|
|
86
97
|
*/
|
|
87
98
|
minNodeApiVersion?: number
|
|
99
|
+
/**
|
|
100
|
+
* The package manager to use. Only support yarn 4.x for now.
|
|
101
|
+
*
|
|
102
|
+
* @default 'yarn'
|
|
103
|
+
*/
|
|
104
|
+
packageManager?: string
|
|
88
105
|
/**
|
|
89
106
|
* License for open-sourced project
|
|
90
107
|
*
|
|
@@ -121,6 +138,12 @@ export interface NewOptions {
|
|
|
121
138
|
* @default true
|
|
122
139
|
*/
|
|
123
140
|
enableGithubActions?: boolean
|
|
141
|
+
/**
|
|
142
|
+
* The JavaScript test framework to use, only support `ava` for now
|
|
143
|
+
*
|
|
144
|
+
* @default 'ava'
|
|
145
|
+
*/
|
|
146
|
+
testFramework?: string
|
|
124
147
|
/**
|
|
125
148
|
* Whether to run the command in dry-run mode
|
|
126
149
|
*
|
|
@@ -132,12 +155,14 @@ export interface NewOptions {
|
|
|
132
155
|
export function applyDefaultNewOptions(options: NewOptions) {
|
|
133
156
|
return {
|
|
134
157
|
minNodeApiVersion: 4,
|
|
158
|
+
packageManager: 'yarn',
|
|
135
159
|
license: 'MIT',
|
|
136
160
|
targets: [],
|
|
137
161
|
enableDefaultTargets: true,
|
|
138
162
|
enableAllTargets: false,
|
|
139
163
|
enableTypeDef: true,
|
|
140
164
|
enableGithubActions: true,
|
|
165
|
+
testFramework: 'ava',
|
|
141
166
|
dryRun: false,
|
|
142
167
|
...options,
|
|
143
168
|
}
|
package/src/def/pre-publish.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Command, Option } from 'clipanion'
|
|
4
4
|
|
|
5
5
|
export abstract class BasePrePublishCommand extends Command {
|
|
6
|
-
static paths = [['pre-publish']]
|
|
6
|
+
static paths = [['pre-publish'], ['prepublish']]
|
|
7
7
|
|
|
8
8
|
static usage = Command.Usage({
|
|
9
9
|
description:
|
|
@@ -15,15 +15,19 @@ export abstract class BasePrePublishCommand extends Command {
|
|
|
15
15
|
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
19
|
+
description: 'Path to `napi` config json file',
|
|
20
|
+
})
|
|
21
|
+
|
|
18
22
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
19
23
|
description: 'Path to `package.json`',
|
|
20
24
|
})
|
|
21
25
|
|
|
22
|
-
npmDir = Option.String('--npm-dir', 'npm', {
|
|
26
|
+
npmDir = Option.String('--npm-dir,-p', 'npm', {
|
|
23
27
|
description: 'Path to the folder where the npm packages put',
|
|
24
28
|
})
|
|
25
29
|
|
|
26
|
-
tagStyle = Option.String('--tag-style', 'lerna', {
|
|
30
|
+
tagStyle = Option.String('--tag-style,--tagstyle,-t', 'lerna', {
|
|
27
31
|
description: 'git tag style, `npm` or `lerna`',
|
|
28
32
|
})
|
|
29
33
|
|
|
@@ -39,6 +43,10 @@ export abstract class BasePrePublishCommand extends Command {
|
|
|
39
43
|
description: 'Existing GitHub release id',
|
|
40
44
|
})
|
|
41
45
|
|
|
46
|
+
skipOptionalPublish = Option.Boolean('--skip-optional-publish', false, {
|
|
47
|
+
description: 'Whether skip optionalDependencies packages publish',
|
|
48
|
+
})
|
|
49
|
+
|
|
42
50
|
dryRun = Option.Boolean('--dry-run', false, {
|
|
43
51
|
description: 'Dry run without touching file system',
|
|
44
52
|
})
|
|
@@ -46,12 +54,14 @@ export abstract class BasePrePublishCommand extends Command {
|
|
|
46
54
|
getOptions() {
|
|
47
55
|
return {
|
|
48
56
|
cwd: this.cwd,
|
|
57
|
+
configPath: this.configPath,
|
|
49
58
|
packageJsonPath: this.packageJsonPath,
|
|
50
59
|
npmDir: this.npmDir,
|
|
51
60
|
tagStyle: this.tagStyle,
|
|
52
61
|
ghRelease: this.ghRelease,
|
|
53
62
|
ghReleaseName: this.ghReleaseName,
|
|
54
63
|
ghReleaseId: this.ghReleaseId,
|
|
64
|
+
skipOptionalPublish: this.skipOptionalPublish,
|
|
55
65
|
dryRun: this.dryRun,
|
|
56
66
|
}
|
|
57
67
|
}
|
|
@@ -67,6 +77,10 @@ export interface PrePublishOptions {
|
|
|
67
77
|
* @default process.cwd()
|
|
68
78
|
*/
|
|
69
79
|
cwd?: string
|
|
80
|
+
/**
|
|
81
|
+
* Path to `napi` config json file
|
|
82
|
+
*/
|
|
83
|
+
configPath?: string
|
|
70
84
|
/**
|
|
71
85
|
* Path to `package.json`
|
|
72
86
|
*
|
|
@@ -99,6 +113,12 @@ export interface PrePublishOptions {
|
|
|
99
113
|
* Existing GitHub release id
|
|
100
114
|
*/
|
|
101
115
|
ghReleaseId?: string
|
|
116
|
+
/**
|
|
117
|
+
* Whether skip optionalDependencies packages publish
|
|
118
|
+
*
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
skipOptionalPublish?: boolean
|
|
102
122
|
/**
|
|
103
123
|
* Dry run without touching file system
|
|
104
124
|
*
|
|
@@ -114,6 +134,7 @@ export function applyDefaultPrePublishOptions(options: PrePublishOptions) {
|
|
|
114
134
|
npmDir: 'npm',
|
|
115
135
|
tagStyle: 'lerna',
|
|
116
136
|
ghRelease: true,
|
|
137
|
+
skipOptionalPublish: false,
|
|
117
138
|
dryRun: false,
|
|
118
139
|
...options,
|
|
119
140
|
}
|
package/src/def/rename.ts
CHANGED
|
@@ -6,7 +6,7 @@ export abstract class BaseRenameCommand extends Command {
|
|
|
6
6
|
static paths = [['rename']]
|
|
7
7
|
|
|
8
8
|
static usage = Command.Usage({
|
|
9
|
-
description: 'Rename the
|
|
9
|
+
description: 'Rename the NAPI-RS project',
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
cwd = Option.String('--cwd', process.cwd(), {
|
|
@@ -14,6 +14,10 @@ export abstract class BaseRenameCommand extends Command {
|
|
|
14
14
|
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
18
|
+
description: 'Path to `napi` config json file',
|
|
19
|
+
})
|
|
20
|
+
|
|
17
21
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
22
|
description: 'Path to `package.json`',
|
|
19
23
|
})
|
|
@@ -49,6 +53,7 @@ export abstract class BaseRenameCommand extends Command {
|
|
|
49
53
|
getOptions() {
|
|
50
54
|
return {
|
|
51
55
|
cwd: this.cwd,
|
|
56
|
+
configPath: this.configPath,
|
|
52
57
|
packageJsonPath: this.packageJsonPath,
|
|
53
58
|
npmDir: this.npmDir,
|
|
54
59
|
name: this.$$name,
|
|
@@ -62,7 +67,7 @@ export abstract class BaseRenameCommand extends Command {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
|
-
* Rename the
|
|
70
|
+
* Rename the NAPI-RS project
|
|
66
71
|
*/
|
|
67
72
|
export interface RenameOptions {
|
|
68
73
|
/**
|
|
@@ -71,6 +76,10 @@ export interface RenameOptions {
|
|
|
71
76
|
* @default process.cwd()
|
|
72
77
|
*/
|
|
73
78
|
cwd?: string
|
|
79
|
+
/**
|
|
80
|
+
* Path to `napi` config json file
|
|
81
|
+
*/
|
|
82
|
+
configPath?: string
|
|
74
83
|
/**
|
|
75
84
|
* Path to `package.json`
|
|
76
85
|
*
|
package/src/def/universalize.ts
CHANGED
|
@@ -14,6 +14,10 @@ export abstract class BaseUniversalizeCommand extends Command {
|
|
|
14
14
|
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
18
|
+
description: 'Path to `napi` config json file',
|
|
19
|
+
})
|
|
20
|
+
|
|
17
21
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
22
|
description: 'Path to `package.json`',
|
|
19
23
|
})
|
|
@@ -26,6 +30,7 @@ export abstract class BaseUniversalizeCommand extends Command {
|
|
|
26
30
|
getOptions() {
|
|
27
31
|
return {
|
|
28
32
|
cwd: this.cwd,
|
|
33
|
+
configPath: this.configPath,
|
|
29
34
|
packageJsonPath: this.packageJsonPath,
|
|
30
35
|
outputDir: this.outputDir,
|
|
31
36
|
}
|
|
@@ -42,6 +47,10 @@ export interface UniversalizeOptions {
|
|
|
42
47
|
* @default process.cwd()
|
|
43
48
|
*/
|
|
44
49
|
cwd?: string
|
|
50
|
+
/**
|
|
51
|
+
* Path to `napi` config json file
|
|
52
|
+
*/
|
|
53
|
+
configPath?: string
|
|
45
54
|
/**
|
|
46
55
|
* Path to `package.json`
|
|
47
56
|
*
|
package/src/def/version.ts
CHANGED
|
@@ -14,6 +14,10 @@ export abstract class BaseVersionCommand extends Command {
|
|
|
14
14
|
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
+
configPath?: string = Option.String('--config-path,-c', {
|
|
18
|
+
description: 'Path to `napi` config json file',
|
|
19
|
+
})
|
|
20
|
+
|
|
17
21
|
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
22
|
description: 'Path to `package.json`',
|
|
19
23
|
})
|
|
@@ -25,6 +29,7 @@ export abstract class BaseVersionCommand extends Command {
|
|
|
25
29
|
getOptions() {
|
|
26
30
|
return {
|
|
27
31
|
cwd: this.cwd,
|
|
32
|
+
configPath: this.configPath,
|
|
28
33
|
packageJsonPath: this.packageJsonPath,
|
|
29
34
|
npmDir: this.npmDir,
|
|
30
35
|
}
|
|
@@ -41,6 +46,10 @@ export interface VersionOptions {
|
|
|
41
46
|
* @default process.cwd()
|
|
42
47
|
*/
|
|
43
48
|
cwd?: string
|
|
49
|
+
/**
|
|
50
|
+
* Path to `napi` config json file
|
|
51
|
+
*/
|
|
52
|
+
configPath?: string
|
|
44
53
|
/**
|
|
45
54
|
* Path to `package.json`
|
|
46
55
|
*
|