@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.
Files changed (176) hide show
  1. package/cli.mjs +1 -1
  2. package/dist/api/__tests__/create-npm-dirs.spec.d.ts +1 -0
  3. package/dist/api/__tests__/new.spec.d.ts +1 -0
  4. package/dist/api/build.d.ts +2 -2
  5. package/dist/api/create-npm-dirs.d.ts +5 -0
  6. package/dist/api/templates/index.d.ts +0 -7
  7. package/dist/api/templates/js-binding.d.ts +2 -1
  8. package/dist/api/templates/load-wasi-template.d.ts +2 -0
  9. package/dist/api/templates/wasi-worker-template.d.ts +2 -0
  10. package/dist/cli.js +3961 -14
  11. package/dist/def/artifacts.d.ts +21 -1
  12. package/dist/def/build.d.ts +167 -4
  13. package/dist/def/create-npm-dirs.d.ts +10 -0
  14. package/dist/def/new.d.ts +25 -7
  15. package/dist/def/pre-publish.d.ts +21 -2
  16. package/dist/def/rename.d.ts +16 -6
  17. package/dist/def/universalize.d.ts +10 -0
  18. package/dist/def/version.d.ts +10 -0
  19. package/dist/index.cjs +10142 -20524
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +3711 -29
  22. package/dist/utils/__tests__/config.spec.d.ts +1 -0
  23. package/dist/utils/config.d.ts +70 -6
  24. package/dist/utils/index.d.ts +1 -1
  25. package/dist/utils/metadata.d.ts +13 -1
  26. package/dist/utils/misc.d.ts +3 -3
  27. package/dist/utils/read-config.d.ts +7 -0
  28. package/dist/utils/target.d.ts +9 -6
  29. package/dist/utils/typegen.d.ts +4 -1
  30. package/dist/utils/version.d.ts +2 -1
  31. package/package.json +60 -24
  32. package/src/api/__tests__/create-npm-dirs.spec.ts +210 -0
  33. package/src/api/__tests__/new.spec.ts +429 -0
  34. package/src/api/artifacts.ts +83 -8
  35. package/src/api/build.ts +682 -134
  36. package/src/api/create-npm-dirs.ts +64 -13
  37. package/src/api/new.ts +389 -125
  38. package/src/api/pre-publish.ts +27 -16
  39. package/src/api/rename.ts +103 -17
  40. package/src/api/templates/index.ts +0 -7
  41. package/src/api/templates/js-binding.ts +212 -107
  42. package/src/api/templates/load-wasi-template.ts +216 -0
  43. package/src/api/templates/wasi-worker-template.ts +122 -0
  44. package/src/api/universalize.ts +13 -8
  45. package/src/api/version.ts +5 -2
  46. package/src/commands/artifacts.ts +2 -2
  47. package/src/commands/build.ts +1 -1
  48. package/src/commands/new.ts +46 -49
  49. package/src/def/artifacts.ts +22 -3
  50. package/src/def/build.ts +83 -8
  51. package/src/def/create-npm-dirs.ts +9 -0
  52. package/src/def/new.ts +28 -3
  53. package/src/def/pre-publish.ts +24 -3
  54. package/src/def/rename.ts +11 -2
  55. package/src/def/universalize.ts +9 -0
  56. package/src/def/version.ts +9 -0
  57. package/src/index.ts +2 -0
  58. package/src/utils/__tests__/__fixtures__/napi_type_def +130 -130
  59. package/src/utils/__tests__/__snapshots__/config.spec.ts.md +97 -0
  60. package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
  61. package/src/utils/__tests__/__snapshots__/target.spec.ts.md +56 -0
  62. package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
  63. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +703 -164
  64. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
  65. package/src/utils/__tests__/__snapshots__/version.spec.ts.md +9 -8
  66. package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
  67. package/src/utils/__tests__/config.spec.ts +81 -0
  68. package/src/utils/__tests__/typegen.spec.ts +19 -4
  69. package/src/utils/cargo.ts +2 -2
  70. package/src/utils/config.ts +147 -13
  71. package/src/utils/index.ts +1 -1
  72. package/src/utils/log.ts +1 -1
  73. package/src/utils/metadata.ts +52 -14
  74. package/src/utils/misc.ts +21 -7
  75. package/src/utils/read-config.ts +20 -0
  76. package/src/utils/target.ts +53 -9
  77. package/src/utils/typegen.ts +100 -40
  78. package/src/utils/version.ts +11 -9
  79. package/dist/api/artifacts.js +0 -50
  80. package/dist/api/build.js +0 -404
  81. package/dist/api/create-npm-dirs.js +0 -63
  82. package/dist/api/new.js +0 -154
  83. package/dist/api/pre-publish.js +0 -157
  84. package/dist/api/rename.js +0 -28
  85. package/dist/api/templates/.gitignore.d.ts +0 -1
  86. package/dist/api/templates/.gitignore.js +0 -198
  87. package/dist/api/templates/.npmignore.d.ts +0 -1
  88. package/dist/api/templates/.npmignore.js +0 -14
  89. package/dist/api/templates/build.rs.d.ts +0 -1
  90. package/dist/api/templates/build.rs.js +0 -4
  91. package/dist/api/templates/cargo.toml.d.ts +0 -6
  92. package/dist/api/templates/cargo.toml.js +0 -25
  93. package/dist/api/templates/ci-template.d.ts +0 -1
  94. package/dist/api/templates/ci-template.js +0 -566
  95. package/dist/api/templates/ci.yml.d.ts +0 -1
  96. package/dist/api/templates/ci.yml.js +0 -92
  97. package/dist/api/templates/index.js +0 -8
  98. package/dist/api/templates/js-binding.js +0 -124
  99. package/dist/api/templates/lib.rs.d.ts +0 -1
  100. package/dist/api/templates/lib.rs.js +0 -10
  101. package/dist/api/templates/package.json.d.ts +0 -8
  102. package/dist/api/templates/package.json.js +0 -30
  103. package/dist/api/universalize.js +0 -38
  104. package/dist/api/version.js +0 -16
  105. package/dist/commands/artifacts.js +0 -19
  106. package/dist/commands/build.js +0 -34
  107. package/dist/commands/create-npm-dirs.js +0 -7
  108. package/dist/commands/help.js +0 -12
  109. package/dist/commands/new.js +0 -112
  110. package/dist/commands/pre-publish.js +0 -8
  111. package/dist/commands/rename.js +0 -7
  112. package/dist/commands/universalize.js +0 -7
  113. package/dist/commands/version.js +0 -7
  114. package/dist/def/artifacts.js +0 -38
  115. package/dist/def/build.js +0 -105
  116. package/dist/def/commands/artifacts.d.ts +0 -15
  117. package/dist/def/commands/artifacts.js +0 -29
  118. package/dist/def/commands/build.d.ts +0 -53
  119. package/dist/def/commands/build.js +0 -105
  120. package/dist/def/commands/create-npm-dirs.d.ts +0 -15
  121. package/dist/def/commands/create-npm-dirs.js +0 -29
  122. package/dist/def/commands/new.d.ts +0 -27
  123. package/dist/def/commands/new.js +0 -53
  124. package/dist/def/commands/pre-publish.d.ts +0 -23
  125. package/dist/def/commands/pre-publish.js +0 -45
  126. package/dist/def/commands/rename.d.ts +0 -25
  127. package/dist/def/commands/rename.js +0 -49
  128. package/dist/def/commands/universalize.d.ts +0 -13
  129. package/dist/def/commands/universalize.js +0 -25
  130. package/dist/def/commands/version.d.ts +0 -13
  131. package/dist/def/commands/version.js +0 -25
  132. package/dist/def/create-npm-dirs.js +0 -38
  133. package/dist/def/new.js +0 -66
  134. package/dist/def/options/artifacts.d.ts +0 -35
  135. package/dist/def/options/artifacts.js +0 -11
  136. package/dist/def/options/build.d.ts +0 -97
  137. package/dist/def/options/build.js +0 -3
  138. package/dist/def/options/create-npm-dirs.d.ts +0 -35
  139. package/dist/def/options/create-npm-dirs.js +0 -11
  140. package/dist/def/options/new.d.ts +0 -79
  141. package/dist/def/options/new.js +0 -15
  142. package/dist/def/options/pre-publish.d.ts +0 -65
  143. package/dist/def/options/pre-publish.js +0 -13
  144. package/dist/def/options/rename.d.ts +0 -75
  145. package/dist/def/options/rename.js +0 -11
  146. package/dist/def/options/universalize.d.ts +0 -28
  147. package/dist/def/options/universalize.js +0 -10
  148. package/dist/def/options/version.d.ts +0 -28
  149. package/dist/def/options/version.js +0 -10
  150. package/dist/def/pre-publish.js +0 -56
  151. package/dist/def/rename.js +0 -58
  152. package/dist/def/universalize.js +0 -33
  153. package/dist/def/version.js +0 -33
  154. package/dist/utils/__tests__/target.spec.js +0 -10
  155. package/dist/utils/__tests__/typegen.spec.js +0 -37
  156. package/dist/utils/__tests__/version.spec.js +0 -5
  157. package/dist/utils/cargo.js +0 -33
  158. package/dist/utils/ci.d.ts +0 -11
  159. package/dist/utils/ci.js +0 -86
  160. package/dist/utils/config.js +0 -42
  161. package/dist/utils/index.js +0 -9
  162. package/dist/utils/log.js +0 -14
  163. package/dist/utils/metadata.js +0 -19
  164. package/dist/utils/misc.js +0 -35
  165. package/dist/utils/target.js +0 -109
  166. package/dist/utils/typegen.js +0 -158
  167. package/dist/utils/version.js +0 -59
  168. package/src/api/templates/.gitignore.ts +0 -198
  169. package/src/api/templates/.npmignore.ts +0 -14
  170. package/src/api/templates/build.rs.ts +0 -4
  171. package/src/api/templates/cargo.toml.ts +0 -35
  172. package/src/api/templates/ci-template.ts +0 -566
  173. package/src/api/templates/ci.yml.ts +0 -116
  174. package/src/api/templates/lib.rs.ts +0 -10
  175. package/src/api/templates/package.json.ts +0 -44
  176. 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 napi-rs project',
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 `--output_dir`.',
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 `--output_dir`',
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 continiously with `cargo-watch` crates',
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 napi-rs project
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
- * Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.
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 `--output_dir`
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
- * watch the crate changes and build continiously with `cargo-watch` crates
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: true })
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 napi-rs project will be created.
86
+ * The path where the NAPI-RS project will be created.
76
87
  */
77
- path: string
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
  }
@@ -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 napi-rs project',
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 napi-rs project
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
  *
@@ -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
  *
@@ -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
  *
package/src/index.ts CHANGED
@@ -29,3 +29,5 @@ export class NapiCli {
29
29
  universalize = universalizeBinaries
30
30
  version = version
31
31
  }
32
+
33
+ export { parseTriple } from './utils/target.js'