@napi-rs/cli 3.1.1 → 3.1.3

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.
Files changed (57) hide show
  1. package/dist/cli.js +519 -321
  2. package/dist/index.cjs +615 -6991
  3. package/dist/index.d.cts +537 -0
  4. package/dist/index.d.ts +527 -19
  5. package/dist/index.js +474 -287
  6. package/package.json +9 -19
  7. package/src/api/build.ts +36 -55
  8. package/src/api/rename.ts +9 -3
  9. package/src/api/templates/js-binding.ts +1 -1
  10. package/src/utils/config.ts +2 -2
  11. package/src/utils/typegen.ts +14 -2
  12. package/dist/api/__tests__/create-npm-dirs.spec.d.ts +0 -1
  13. package/dist/api/__tests__/new.spec.d.ts +0 -1
  14. package/dist/api/artifacts.d.ts +0 -2
  15. package/dist/api/build.d.ts +0 -14
  16. package/dist/api/create-npm-dirs.d.ts +0 -7
  17. package/dist/api/new.d.ts +0 -4
  18. package/dist/api/pre-publish.d.ts +0 -2
  19. package/dist/api/rename.d.ts +0 -2
  20. package/dist/api/templates/index.d.ts +0 -1
  21. package/dist/api/templates/js-binding.d.ts +0 -2
  22. package/dist/api/templates/load-wasi-template.d.ts +0 -2
  23. package/dist/api/templates/wasi-worker-template.d.ts +0 -2
  24. package/dist/api/universalize.d.ts +0 -2
  25. package/dist/api/version.d.ts +0 -2
  26. package/dist/cli.d.ts +0 -2
  27. package/dist/commands/artifacts.d.ts +0 -6
  28. package/dist/commands/build.d.ts +0 -6
  29. package/dist/commands/create-npm-dirs.d.ts +0 -4
  30. package/dist/commands/help.d.ts +0 -10
  31. package/dist/commands/new.d.ts +0 -12
  32. package/dist/commands/pre-publish.d.ts +0 -4
  33. package/dist/commands/rename.d.ts +0 -4
  34. package/dist/commands/universalize.d.ts +0 -4
  35. package/dist/commands/version.d.ts +0 -4
  36. package/dist/def/artifacts.d.ts +0 -70
  37. package/dist/def/build.d.ts +0 -313
  38. package/dist/def/create-npm-dirs.d.ts +0 -60
  39. package/dist/def/new.d.ts +0 -124
  40. package/dist/def/pre-publish.d.ts +0 -107
  41. package/dist/def/rename.d.ts +0 -110
  42. package/dist/def/universalize.d.ts +0 -51
  43. package/dist/def/version.d.ts +0 -51
  44. package/dist/utils/__tests__/config.spec.d.ts +0 -1
  45. package/dist/utils/__tests__/target.spec.d.ts +0 -1
  46. package/dist/utils/__tests__/typegen.spec.d.ts +0 -1
  47. package/dist/utils/__tests__/version.spec.d.ts +0 -1
  48. package/dist/utils/cargo.d.ts +0 -1
  49. package/dist/utils/config.d.ts +0 -129
  50. package/dist/utils/index.d.ts +0 -9
  51. package/dist/utils/log.d.ts +0 -10
  52. package/dist/utils/metadata.d.ts +0 -36
  53. package/dist/utils/misc.d.ts +0 -13
  54. package/dist/utils/read-config.d.ts +0 -7
  55. package/dist/utils/target.d.ts +0 -33
  56. package/dist/utils/typegen.d.ts +0 -6
  57. package/dist/utils/version.d.ts +0 -12
@@ -1,313 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseBuildCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- target?: string;
6
- cwd?: string;
7
- manifestPath?: string;
8
- configPath?: string;
9
- packageJsonPath?: string;
10
- targetDir?: string;
11
- outputDir?: string;
12
- platform?: boolean;
13
- jsPackageName?: string;
14
- constEnum?: boolean;
15
- jsBinding?: string;
16
- noJsBinding?: boolean;
17
- dts?: string;
18
- dtsHeader?: string;
19
- noDtsHeader?: boolean;
20
- dtsCache: boolean;
21
- esm?: boolean;
22
- strip?: boolean;
23
- release?: boolean;
24
- verbose?: boolean;
25
- bin?: string;
26
- package?: string;
27
- profile?: string;
28
- crossCompile?: boolean;
29
- useCross?: boolean;
30
- useNapiCross?: boolean;
31
- watch?: boolean;
32
- features?: string[];
33
- allFeatures?: boolean;
34
- noDefaultFeatures?: boolean;
35
- getOptions(): {
36
- target: string | undefined;
37
- cwd: string | undefined;
38
- manifestPath: string | undefined;
39
- configPath: string | undefined;
40
- packageJsonPath: string | undefined;
41
- targetDir: string | undefined;
42
- outputDir: string | undefined;
43
- platform: boolean | undefined;
44
- jsPackageName: string | undefined;
45
- constEnum: boolean | undefined;
46
- jsBinding: string | undefined;
47
- noJsBinding: boolean | undefined;
48
- dts: string | undefined;
49
- dtsHeader: string | undefined;
50
- noDtsHeader: boolean | undefined;
51
- dtsCache: boolean;
52
- esm: boolean | undefined;
53
- strip: boolean | undefined;
54
- release: boolean | undefined;
55
- verbose: boolean | undefined;
56
- bin: string | undefined;
57
- package: string | undefined;
58
- profile: string | undefined;
59
- crossCompile: boolean | undefined;
60
- useCross: boolean | undefined;
61
- useNapiCross: boolean | undefined;
62
- watch: boolean | undefined;
63
- features: string[] | undefined;
64
- allFeatures: boolean | undefined;
65
- noDefaultFeatures: boolean | undefined;
66
- };
67
- }
68
- /**
69
- * Build the NAPI-RS project
70
- */
71
- export interface BuildOptions {
72
- /**
73
- * Build for the target triple, bypassed to `cargo build --target`
74
- */
75
- target?: string;
76
- /**
77
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
78
- */
79
- cwd?: string;
80
- /**
81
- * Path to `Cargo.toml`
82
- */
83
- manifestPath?: string;
84
- /**
85
- * Path to `napi` config json file
86
- */
87
- configPath?: string;
88
- /**
89
- * Path to `package.json`
90
- */
91
- packageJsonPath?: string;
92
- /**
93
- * Directory for all crate generated artifacts, see `cargo build --target-dir`
94
- */
95
- targetDir?: string;
96
- /**
97
- * Path to where all the built files would be put. Default to the crate folder
98
- */
99
- outputDir?: string;
100
- /**
101
- * Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node`
102
- */
103
- platform?: boolean;
104
- /**
105
- * Package name in generated js binding file. Only works with `--platform` flag
106
- */
107
- jsPackageName?: string;
108
- /**
109
- * Whether generate const enum for typescript bindings
110
- */
111
- constEnum?: boolean;
112
- /**
113
- * Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output-dir`.
114
- */
115
- jsBinding?: string;
116
- /**
117
- * Whether to disable the generation JS binding file. Only works with `--platform` flag.
118
- */
119
- noJsBinding?: boolean;
120
- /**
121
- * Path and filename of generated type def file. Relative to `--output-dir`
122
- */
123
- dts?: string;
124
- /**
125
- * Custom file header for generated type def file. Only works when `typedef` feature enabled.
126
- */
127
- dtsHeader?: string;
128
- /**
129
- * Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.
130
- */
131
- noDtsHeader?: boolean;
132
- /**
133
- * Whether to enable the dts cache, default to true
134
- *
135
- * @default true
136
- */
137
- dtsCache?: boolean;
138
- /**
139
- * Whether to emit an ESM JS binding file instead of CJS format. Only works with `--platform` flag.
140
- */
141
- esm?: boolean;
142
- /**
143
- * Whether strip the library to achieve the minimum file size
144
- */
145
- strip?: boolean;
146
- /**
147
- * Build in release mode
148
- */
149
- release?: boolean;
150
- /**
151
- * Verbosely log build command trace
152
- */
153
- verbose?: boolean;
154
- /**
155
- * Build only the specified binary
156
- */
157
- bin?: string;
158
- /**
159
- * Build the specified library or the one at cwd
160
- */
161
- package?: string;
162
- /**
163
- * Build artifacts with the specified profile
164
- */
165
- profile?: string;
166
- /**
167
- * [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
168
- */
169
- crossCompile?: boolean;
170
- /**
171
- * [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
172
- */
173
- useCross?: boolean;
174
- /**
175
- * [experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.
176
- */
177
- useNapiCross?: boolean;
178
- /**
179
- * watch the crate changes and build continuously with `cargo-watch` crates
180
- */
181
- watch?: boolean;
182
- /**
183
- * Space-separated list of features to activate
184
- */
185
- features?: string[];
186
- /**
187
- * Activate all available features
188
- */
189
- allFeatures?: boolean;
190
- /**
191
- * Do not activate the `default` feature
192
- */
193
- noDefaultFeatures?: boolean;
194
- }
195
- export declare function applyDefaultBuildOptions(options: BuildOptions): {
196
- /**
197
- * Build for the target triple, bypassed to `cargo build --target`
198
- */
199
- target?: string;
200
- /**
201
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
202
- */
203
- cwd?: string;
204
- /**
205
- * Path to `Cargo.toml`
206
- */
207
- manifestPath?: string;
208
- /**
209
- * Path to `napi` config json file
210
- */
211
- configPath?: string;
212
- /**
213
- * Path to `package.json`
214
- */
215
- packageJsonPath?: string;
216
- /**
217
- * Directory for all crate generated artifacts, see `cargo build --target-dir`
218
- */
219
- targetDir?: string;
220
- /**
221
- * Path to where all the built files would be put. Default to the crate folder
222
- */
223
- outputDir?: string;
224
- /**
225
- * Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node`
226
- */
227
- platform?: boolean;
228
- /**
229
- * Package name in generated js binding file. Only works with `--platform` flag
230
- */
231
- jsPackageName?: string;
232
- /**
233
- * Whether generate const enum for typescript bindings
234
- */
235
- constEnum?: boolean;
236
- /**
237
- * Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output-dir`.
238
- */
239
- jsBinding?: string;
240
- /**
241
- * Whether to disable the generation JS binding file. Only works with `--platform` flag.
242
- */
243
- noJsBinding?: boolean;
244
- /**
245
- * Path and filename of generated type def file. Relative to `--output-dir`
246
- */
247
- dts?: string;
248
- /**
249
- * Custom file header for generated type def file. Only works when `typedef` feature enabled.
250
- */
251
- dtsHeader?: string;
252
- /**
253
- * Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.
254
- */
255
- noDtsHeader?: boolean;
256
- dtsCache: boolean;
257
- /**
258
- * Whether to emit an ESM JS binding file instead of CJS format. Only works with `--platform` flag.
259
- */
260
- esm?: boolean;
261
- /**
262
- * Whether strip the library to achieve the minimum file size
263
- */
264
- strip?: boolean;
265
- /**
266
- * Build in release mode
267
- */
268
- release?: boolean;
269
- /**
270
- * Verbosely log build command trace
271
- */
272
- verbose?: boolean;
273
- /**
274
- * Build only the specified binary
275
- */
276
- bin?: string;
277
- /**
278
- * Build the specified library or the one at cwd
279
- */
280
- package?: string;
281
- /**
282
- * Build artifacts with the specified profile
283
- */
284
- profile?: string;
285
- /**
286
- * [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
287
- */
288
- crossCompile?: boolean;
289
- /**
290
- * [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
291
- */
292
- useCross?: boolean;
293
- /**
294
- * [experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.
295
- */
296
- useNapiCross?: boolean;
297
- /**
298
- * watch the crate changes and build continuously with `cargo-watch` crates
299
- */
300
- watch?: boolean;
301
- /**
302
- * Space-separated list of features to activate
303
- */
304
- features?: string[];
305
- /**
306
- * Activate all available features
307
- */
308
- allFeatures?: boolean;
309
- /**
310
- * Do not activate the `default` feature
311
- */
312
- noDefaultFeatures?: boolean;
313
- };
@@ -1,60 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseCreateNpmDirsCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- cwd: string;
6
- configPath?: string;
7
- packageJsonPath: string;
8
- npmDir: string;
9
- dryRun: boolean;
10
- getOptions(): {
11
- cwd: string;
12
- configPath: string | undefined;
13
- packageJsonPath: string;
14
- npmDir: string;
15
- dryRun: boolean;
16
- };
17
- }
18
- /**
19
- * Create npm package dirs for different platforms
20
- */
21
- export interface CreateNpmDirsOptions {
22
- /**
23
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
24
- *
25
- * @default process.cwd()
26
- */
27
- cwd?: string;
28
- /**
29
- * Path to `napi` config json file
30
- */
31
- configPath?: string;
32
- /**
33
- * Path to `package.json`
34
- *
35
- * @default 'package.json'
36
- */
37
- packageJsonPath?: string;
38
- /**
39
- * Path to the folder where the npm packages put
40
- *
41
- * @default 'npm'
42
- */
43
- npmDir?: string;
44
- /**
45
- * Dry run without touching file system
46
- *
47
- * @default false
48
- */
49
- dryRun?: boolean;
50
- }
51
- export declare function applyDefaultCreateNpmDirsOptions(options: CreateNpmDirsOptions): {
52
- cwd: string;
53
- /**
54
- * Path to `napi` config json file
55
- */
56
- configPath?: string;
57
- packageJsonPath: string;
58
- npmDir: string;
59
- dryRun: boolean;
60
- };
package/dist/def/new.d.ts DELETED
@@ -1,124 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseNewCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- $$path: string | undefined;
6
- $$name?: string;
7
- minNodeApiVersion: number;
8
- packageManager: string;
9
- license: string;
10
- targets: string[];
11
- enableDefaultTargets: boolean;
12
- enableAllTargets: boolean;
13
- enableTypeDef: boolean;
14
- enableGithubActions: boolean;
15
- testFramework: string;
16
- dryRun: boolean;
17
- getOptions(): {
18
- path: string | undefined;
19
- name: string | undefined;
20
- minNodeApiVersion: number;
21
- packageManager: string;
22
- license: string;
23
- targets: string[];
24
- enableDefaultTargets: boolean;
25
- enableAllTargets: boolean;
26
- enableTypeDef: boolean;
27
- enableGithubActions: boolean;
28
- testFramework: string;
29
- dryRun: boolean;
30
- };
31
- }
32
- /**
33
- * Create a new project with pre-configured boilerplate
34
- */
35
- export interface NewOptions {
36
- /**
37
- * The path where the NAPI-RS project will be created.
38
- */
39
- path?: string;
40
- /**
41
- * The name of the project, default to the name of the directory if not provided
42
- */
43
- name?: string;
44
- /**
45
- * The minimum Node-API version to support
46
- *
47
- * @default 4
48
- */
49
- minNodeApiVersion?: number;
50
- /**
51
- * The package manager to use. Only support yarn 4.x for now.
52
- *
53
- * @default 'yarn'
54
- */
55
- packageManager?: string;
56
- /**
57
- * License for open-sourced project
58
- *
59
- * @default 'MIT'
60
- */
61
- license?: string;
62
- /**
63
- * All targets the crate will be compiled for.
64
- *
65
- * @default []
66
- */
67
- targets?: string[];
68
- /**
69
- * Whether enable default targets
70
- *
71
- * @default true
72
- */
73
- enableDefaultTargets?: boolean;
74
- /**
75
- * Whether enable all targets
76
- *
77
- * @default false
78
- */
79
- enableAllTargets?: boolean;
80
- /**
81
- * Whether enable the `type-def` feature for typescript definitions auto-generation
82
- *
83
- * @default true
84
- */
85
- enableTypeDef?: boolean;
86
- /**
87
- * Whether generate preconfigured GitHub Actions workflow
88
- *
89
- * @default true
90
- */
91
- enableGithubActions?: boolean;
92
- /**
93
- * The JavaScript test framework to use, only support `ava` for now
94
- *
95
- * @default 'ava'
96
- */
97
- testFramework?: string;
98
- /**
99
- * Whether to run the command in dry-run mode
100
- *
101
- * @default false
102
- */
103
- dryRun?: boolean;
104
- }
105
- export declare function applyDefaultNewOptions(options: NewOptions): {
106
- /**
107
- * The path where the NAPI-RS project will be created.
108
- */
109
- path?: string;
110
- /**
111
- * The name of the project, default to the name of the directory if not provided
112
- */
113
- name?: string;
114
- minNodeApiVersion: number;
115
- packageManager: string;
116
- license: string;
117
- targets: string[];
118
- enableDefaultTargets: boolean;
119
- enableAllTargets: boolean;
120
- enableTypeDef: boolean;
121
- enableGithubActions: boolean;
122
- testFramework: string;
123
- dryRun: boolean;
124
- };
@@ -1,107 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BasePrePublishCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- cwd: string;
6
- configPath?: string;
7
- packageJsonPath: string;
8
- npmDir: string;
9
- tagStyle: string;
10
- ghRelease: boolean;
11
- ghReleaseName?: string;
12
- ghReleaseId?: string;
13
- skipOptionalPublish: boolean;
14
- dryRun: boolean;
15
- getOptions(): {
16
- cwd: string;
17
- configPath: string | undefined;
18
- packageJsonPath: string;
19
- npmDir: string;
20
- tagStyle: string;
21
- ghRelease: boolean;
22
- ghReleaseName: string | undefined;
23
- ghReleaseId: string | undefined;
24
- skipOptionalPublish: boolean;
25
- dryRun: boolean;
26
- };
27
- }
28
- /**
29
- * Update package.json and copy addons into per platform packages
30
- */
31
- export interface PrePublishOptions {
32
- /**
33
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
34
- *
35
- * @default process.cwd()
36
- */
37
- cwd?: string;
38
- /**
39
- * Path to `napi` config json file
40
- */
41
- configPath?: string;
42
- /**
43
- * Path to `package.json`
44
- *
45
- * @default 'package.json'
46
- */
47
- packageJsonPath?: string;
48
- /**
49
- * Path to the folder where the npm packages put
50
- *
51
- * @default 'npm'
52
- */
53
- npmDir?: string;
54
- /**
55
- * git tag style, `npm` or `lerna`
56
- *
57
- * @default 'lerna'
58
- */
59
- tagStyle?: 'npm' | 'lerna';
60
- /**
61
- * Whether create GitHub release
62
- *
63
- * @default true
64
- */
65
- ghRelease?: boolean;
66
- /**
67
- * GitHub release name
68
- */
69
- ghReleaseName?: string;
70
- /**
71
- * Existing GitHub release id
72
- */
73
- ghReleaseId?: string;
74
- /**
75
- * Whether skip optionalDependencies packages publish
76
- *
77
- * @default false
78
- */
79
- skipOptionalPublish?: boolean;
80
- /**
81
- * Dry run without touching file system
82
- *
83
- * @default false
84
- */
85
- dryRun?: boolean;
86
- }
87
- export declare function applyDefaultPrePublishOptions(options: PrePublishOptions): {
88
- cwd: string;
89
- /**
90
- * Path to `napi` config json file
91
- */
92
- configPath?: string;
93
- packageJsonPath: string;
94
- npmDir: string;
95
- tagStyle: string;
96
- ghRelease: boolean;
97
- /**
98
- * GitHub release name
99
- */
100
- ghReleaseName?: string;
101
- /**
102
- * Existing GitHub release id
103
- */
104
- ghReleaseId?: string;
105
- skipOptionalPublish: boolean;
106
- dryRun: boolean;
107
- };
@@ -1,110 +0,0 @@
1
- import { Command } from 'clipanion';
2
- export declare abstract class BaseRenameCommand extends Command {
3
- static paths: string[][];
4
- static usage: import("clipanion").Usage;
5
- cwd: string;
6
- configPath?: string;
7
- packageJsonPath: string;
8
- npmDir: string;
9
- $$name?: string;
10
- binaryName?: string;
11
- packageName?: string;
12
- manifestPath: string;
13
- repository?: string;
14
- description?: string;
15
- getOptions(): {
16
- cwd: string;
17
- configPath: string | undefined;
18
- packageJsonPath: string;
19
- npmDir: string;
20
- name: string | undefined;
21
- binaryName: string | undefined;
22
- packageName: string | undefined;
23
- manifestPath: string;
24
- repository: string | undefined;
25
- description: string | undefined;
26
- };
27
- }
28
- /**
29
- * Rename the NAPI-RS project
30
- */
31
- export interface RenameOptions {
32
- /**
33
- * The working directory of where napi command will be executed in, all other paths options are relative to this path
34
- *
35
- * @default process.cwd()
36
- */
37
- cwd?: string;
38
- /**
39
- * Path to `napi` config json file
40
- */
41
- configPath?: string;
42
- /**
43
- * Path to `package.json`
44
- *
45
- * @default 'package.json'
46
- */
47
- packageJsonPath?: string;
48
- /**
49
- * Path to the folder where the npm packages put
50
- *
51
- * @default 'npm'
52
- */
53
- npmDir?: string;
54
- /**
55
- * The new name of the project
56
- */
57
- name?: string;
58
- /**
59
- * The new binary name *.node files
60
- */
61
- binaryName?: string;
62
- /**
63
- * The new package name of the project
64
- */
65
- packageName?: string;
66
- /**
67
- * Path to `Cargo.toml`
68
- *
69
- * @default 'Cargo.toml'
70
- */
71
- manifestPath?: string;
72
- /**
73
- * The new repository of the project
74
- */
75
- repository?: string;
76
- /**
77
- * The new description of the project
78
- */
79
- description?: string;
80
- }
81
- export declare function applyDefaultRenameOptions(options: RenameOptions): {
82
- cwd: string;
83
- /**
84
- * Path to `napi` config json file
85
- */
86
- configPath?: string;
87
- packageJsonPath: string;
88
- npmDir: string;
89
- /**
90
- * The new name of the project
91
- */
92
- name?: string;
93
- /**
94
- * The new binary name *.node files
95
- */
96
- binaryName?: string;
97
- /**
98
- * The new package name of the project
99
- */
100
- packageName?: string;
101
- manifestPath: string;
102
- /**
103
- * The new repository of the project
104
- */
105
- repository?: string;
106
- /**
107
- * The new description of the project
108
- */
109
- description?: string;
110
- };