@napi-rs/cli 3.0.0-alpha.2 → 3.0.0-alpha.20

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 (201) hide show
  1. package/dist/api/artifacts.js +5 -2
  2. package/dist/api/artifacts.js.map +1 -0
  3. package/dist/api/build.d.ts +1 -1
  4. package/dist/api/build.js +182 -32
  5. package/dist/api/build.js.map +1 -0
  6. package/dist/api/create-npm-dirs.js +3 -2
  7. package/dist/api/create-npm-dirs.js.map +1 -0
  8. package/dist/api/load-wasi-template.d.ts +1 -0
  9. package/dist/api/load-wasi-template.js +60 -0
  10. package/dist/api/load-wasi-template.js.map +1 -0
  11. package/dist/api/new.js +31 -12
  12. package/dist/api/new.js.map +1 -0
  13. package/dist/api/pre-publish.js +4 -3
  14. package/dist/api/pre-publish.js.map +1 -0
  15. package/dist/api/rename.js +9 -0
  16. package/dist/api/rename.js.map +1 -0
  17. package/dist/api/templates/.gitignore.d.ts +1 -1
  18. package/dist/api/templates/.gitignore.js +2 -0
  19. package/dist/api/templates/.gitignore.js.map +1 -0
  20. package/dist/api/templates/.npmignore.js +1 -0
  21. package/dist/api/templates/.npmignore.js.map +1 -0
  22. package/dist/api/templates/build.rs.js +1 -0
  23. package/dist/api/templates/build.rs.js.map +1 -0
  24. package/dist/api/templates/cargo.toml.js +1 -0
  25. package/dist/api/templates/cargo.toml.js.map +1 -0
  26. package/dist/api/templates/ci-template.js +64 -57
  27. package/dist/api/templates/ci-template.js.map +1 -0
  28. package/dist/api/templates/ci.yml.d.ts +1 -1
  29. package/dist/api/templates/ci.yml.js +10 -3
  30. package/dist/api/templates/ci.yml.js.map +1 -0
  31. package/dist/api/templates/index.js +1 -0
  32. package/dist/api/templates/index.js.map +1 -0
  33. package/dist/api/templates/js-binding.d.ts +1 -1
  34. package/dist/api/templates/js-binding.js +306 -108
  35. package/dist/api/templates/js-binding.js.map +1 -0
  36. package/dist/api/templates/lib.rs.js +2 -4
  37. package/dist/api/templates/lib.rs.js.map +1 -0
  38. package/dist/api/templates/package.json.js +30 -28
  39. package/dist/api/templates/package.json.js.map +1 -0
  40. package/dist/api/universalize.js +2 -1
  41. package/dist/api/universalize.js.map +1 -0
  42. package/dist/api/version.js +2 -1
  43. package/dist/api/version.js.map +1 -0
  44. package/dist/api/wasi-worker-template.d.ts +1 -0
  45. package/dist/api/wasi-worker-template.js +53 -0
  46. package/dist/api/wasi-worker-template.js.map +1 -0
  47. package/dist/cli.js +1 -0
  48. package/dist/cli.js.map +1 -0
  49. package/dist/commands/artifacts.js +1 -0
  50. package/dist/commands/artifacts.js.map +1 -0
  51. package/dist/commands/build.js +1 -0
  52. package/dist/commands/build.js.map +1 -0
  53. package/dist/commands/create-npm-dirs.js +1 -0
  54. package/dist/commands/create-npm-dirs.js.map +1 -0
  55. package/dist/commands/help.js +1 -0
  56. package/dist/commands/help.js.map +1 -0
  57. package/dist/commands/new.js +2 -4
  58. package/dist/commands/new.js.map +1 -0
  59. package/dist/commands/pre-publish.js +1 -0
  60. package/dist/commands/pre-publish.js.map +1 -0
  61. package/dist/commands/rename.js +1 -0
  62. package/dist/commands/rename.js.map +1 -0
  63. package/dist/commands/universalize.js +1 -0
  64. package/dist/commands/universalize.js.map +1 -0
  65. package/dist/commands/version.js +1 -0
  66. package/dist/commands/version.js.map +1 -0
  67. package/dist/def/artifacts.d.ts +11 -1
  68. package/dist/def/artifacts.js +7 -2
  69. package/dist/def/artifacts.js.map +1 -0
  70. package/dist/def/build.d.ts +32 -2
  71. package/dist/def/build.js +23 -2
  72. package/dist/def/build.js.map +1 -0
  73. package/dist/def/create-npm-dirs.d.ts +10 -0
  74. package/dist/def/create-npm-dirs.js +5 -0
  75. package/dist/def/create-npm-dirs.js.map +1 -0
  76. package/dist/def/new.d.ts +2 -2
  77. package/dist/def/new.js +1 -0
  78. package/dist/def/new.js.map +1 -0
  79. package/dist/def/pre-publish.d.ts +10 -0
  80. package/dist/def/pre-publish.js +7 -2
  81. package/dist/def/pre-publish.js.map +1 -0
  82. package/dist/def/rename.d.ts +11 -1
  83. package/dist/def/rename.js +6 -1
  84. package/dist/def/rename.js.map +1 -0
  85. package/dist/def/universalize.d.ts +10 -0
  86. package/dist/def/universalize.js +5 -0
  87. package/dist/def/universalize.js.map +1 -0
  88. package/dist/def/version.d.ts +10 -0
  89. package/dist/def/version.js +5 -0
  90. package/dist/def/version.js.map +1 -0
  91. package/dist/index.cjs +3424 -8044
  92. package/dist/index.d.ts +1 -0
  93. package/dist/index.js +2 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/utils/__tests__/config.spec.d.ts +1 -0
  96. package/dist/utils/__tests__/config.spec.js +63 -0
  97. package/dist/utils/__tests__/config.spec.js.map +1 -0
  98. package/dist/utils/__tests__/target.spec.js +1 -0
  99. package/dist/utils/__tests__/target.spec.js.map +1 -0
  100. package/dist/utils/__tests__/typegen.spec.js +9 -4
  101. package/dist/utils/__tests__/typegen.spec.js.map +1 -0
  102. package/dist/utils/__tests__/version.spec.js +1 -0
  103. package/dist/utils/__tests__/version.spec.js.map +1 -0
  104. package/dist/utils/cargo.js +1 -0
  105. package/dist/utils/cargo.js.map +1 -0
  106. package/dist/utils/ci.js +10 -0
  107. package/dist/utils/ci.js.map +1 -0
  108. package/dist/utils/config.d.ts +16 -5
  109. package/dist/utils/config.js +37 -6
  110. package/dist/utils/config.js.map +1 -0
  111. package/dist/utils/index.js +1 -0
  112. package/dist/utils/index.js.map +1 -0
  113. package/dist/utils/log.js +1 -0
  114. package/dist/utils/log.js.map +1 -0
  115. package/dist/utils/metadata.js +1 -0
  116. package/dist/utils/metadata.js.map +1 -0
  117. package/dist/utils/misc.js +1 -0
  118. package/dist/utils/misc.js.map +1 -0
  119. package/dist/utils/target.d.ts +6 -5
  120. package/dist/utils/target.js +15 -1
  121. package/dist/utils/target.js.map +1 -0
  122. package/dist/utils/typegen.d.ts +4 -1
  123. package/dist/utils/typegen.js +27 -6
  124. package/dist/utils/typegen.js.map +1 -0
  125. package/dist/utils/version.d.ts +2 -1
  126. package/dist/utils/version.js +13 -10
  127. package/dist/utils/version.js.map +1 -0
  128. package/package.json +48 -15
  129. package/src/api/artifacts.ts +7 -4
  130. package/src/api/build.ts +283 -39
  131. package/src/api/create-npm-dirs.ts +5 -2
  132. package/src/api/load-wasi-template.ts +62 -0
  133. package/src/api/new.ts +37 -14
  134. package/src/api/pre-publish.ts +14 -8
  135. package/src/api/rename.ts +9 -0
  136. package/src/api/templates/.gitignore.ts +1 -0
  137. package/src/api/templates/ci-template.ts +63 -57
  138. package/src/api/templates/ci.yml.ts +9 -6
  139. package/src/api/templates/js-binding.ts +299 -104
  140. package/src/api/templates/lib.rs.ts +1 -4
  141. package/src/api/templates/package.json.ts +31 -27
  142. package/src/api/universalize.ts +4 -1
  143. package/src/api/version.ts +4 -1
  144. package/src/api/wasi-worker-template.ts +52 -0
  145. package/src/commands/new.ts +1 -5
  146. package/src/def/artifacts.ts +12 -3
  147. package/src/def/build.ts +51 -4
  148. package/src/def/create-npm-dirs.ts +9 -0
  149. package/src/def/new.ts +1 -1
  150. package/src/def/pre-publish.ts +11 -2
  151. package/src/def/rename.ts +11 -2
  152. package/src/def/universalize.ts +9 -0
  153. package/src/def/version.ts +9 -0
  154. package/src/index.ts +2 -0
  155. package/src/utils/__tests__/__snapshots__/config.spec.ts.md +97 -0
  156. package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
  157. package/src/utils/__tests__/__snapshots__/target.spec.ts.md +7 -0
  158. package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
  159. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +555 -0
  160. package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
  161. package/src/utils/__tests__/__snapshots__/version.spec.ts.md +9 -8
  162. package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
  163. package/src/utils/__tests__/config.spec.ts +81 -0
  164. package/src/utils/__tests__/typegen.spec.ts +19 -4
  165. package/src/utils/ci.ts +9 -0
  166. package/src/utils/config.ts +64 -9
  167. package/src/utils/target.ts +22 -8
  168. package/src/utils/typegen.ts +30 -5
  169. package/src/utils/version.ts +11 -9
  170. package/dist/def/commands/artifacts.d.ts +0 -15
  171. package/dist/def/commands/artifacts.js +0 -29
  172. package/dist/def/commands/build.d.ts +0 -53
  173. package/dist/def/commands/build.js +0 -105
  174. package/dist/def/commands/create-npm-dirs.d.ts +0 -15
  175. package/dist/def/commands/create-npm-dirs.js +0 -29
  176. package/dist/def/commands/new.d.ts +0 -27
  177. package/dist/def/commands/new.js +0 -53
  178. package/dist/def/commands/pre-publish.d.ts +0 -23
  179. package/dist/def/commands/pre-publish.js +0 -45
  180. package/dist/def/commands/rename.d.ts +0 -25
  181. package/dist/def/commands/rename.js +0 -49
  182. package/dist/def/commands/universalize.d.ts +0 -13
  183. package/dist/def/commands/universalize.js +0 -25
  184. package/dist/def/commands/version.d.ts +0 -13
  185. package/dist/def/commands/version.js +0 -25
  186. package/dist/def/options/artifacts.d.ts +0 -35
  187. package/dist/def/options/artifacts.js +0 -11
  188. package/dist/def/options/build.d.ts +0 -97
  189. package/dist/def/options/build.js +0 -3
  190. package/dist/def/options/create-npm-dirs.d.ts +0 -35
  191. package/dist/def/options/create-npm-dirs.js +0 -11
  192. package/dist/def/options/new.d.ts +0 -79
  193. package/dist/def/options/new.js +0 -15
  194. package/dist/def/options/pre-publish.d.ts +0 -65
  195. package/dist/def/options/pre-publish.js +0 -13
  196. package/dist/def/options/rename.d.ts +0 -75
  197. package/dist/def/options/rename.js +0 -11
  198. package/dist/def/options/universalize.d.ts +0 -28
  199. package/dist/def/options/universalize.js +0 -10
  200. package/dist/def/options/version.d.ts +0 -28
  201. package/dist/def/options/version.js +0 -10
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,6 +51,10 @@ 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
60
  'Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.',
@@ -92,14 +100,28 @@ export abstract class BaseBuildCommand extends Command {
92
100
  description: 'Build the specified library or the one at cwd',
93
101
  })
94
102
 
103
+ profile?: string = Option.String('--profile', {
104
+ description: 'Build artifacts with the specified profile',
105
+ })
106
+
95
107
  crossCompile?: boolean = Option.Boolean('--cross-compile,-x', {
96
108
  description:
97
109
  '[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
98
110
  })
99
111
 
112
+ useCross?: boolean = Option.Boolean('--use-cross', {
113
+ description:
114
+ '[experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`',
115
+ })
116
+
117
+ useNapiCross?: boolean = Option.Boolean('--use-napi-cross', {
118
+ description:
119
+ '[experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.',
120
+ })
121
+
100
122
  watch?: boolean = Option.Boolean('--watch,-w', {
101
123
  description:
102
- 'watch the crate changes and build continiously with `cargo-watch` crates',
124
+ 'watch the crate changes and build continuously with `cargo-watch` crates',
103
125
  })
104
126
 
105
127
  features?: string[] = Option.Array('--features,-F', {
@@ -119,11 +141,13 @@ export abstract class BaseBuildCommand extends Command {
119
141
  target: this.target,
120
142
  cwd: this.cwd,
121
143
  manifestPath: this.manifestPath,
144
+ configPath: this.configPath,
122
145
  packageJsonPath: this.packageJsonPath,
123
146
  targetDir: this.targetDir,
124
147
  outputDir: this.outputDir,
125
148
  platform: this.platform,
126
149
  jsPackageName: this.jsPackageName,
150
+ constEnum: this.constEnum,
127
151
  jsBinding: this.jsBinding,
128
152
  noJsBinding: this.noJsBinding,
129
153
  dts: this.dts,
@@ -134,7 +158,10 @@ export abstract class BaseBuildCommand extends Command {
134
158
  verbose: this.verbose,
135
159
  bin: this.bin,
136
160
  package: this.package,
161
+ profile: this.profile,
137
162
  crossCompile: this.crossCompile,
163
+ useCross: this.useCross,
164
+ useNapiCross: this.useNapiCross,
138
165
  watch: this.watch,
139
166
  features: this.features,
140
167
  allFeatures: this.allFeatures,
@@ -144,7 +171,7 @@ export abstract class BaseBuildCommand extends Command {
144
171
  }
145
172
 
146
173
  /**
147
- * Build the napi-rs project
174
+ * Build the NAPI-RS project
148
175
  */
149
176
  export interface BuildOptions {
150
177
  /**
@@ -159,6 +186,10 @@ export interface BuildOptions {
159
186
  * Path to `Cargo.toml`
160
187
  */
161
188
  manifestPath?: string
189
+ /**
190
+ * Path to `napi` config json file
191
+ */
192
+ configPath?: string
162
193
  /**
163
194
  * Path to `package.json`
164
195
  */
@@ -179,6 +210,10 @@ export interface BuildOptions {
179
210
  * Package name in generated js binding file. Only works with `--platform` flag
180
211
  */
181
212
  jsPackageName?: string
213
+ /**
214
+ * Whether generate const enum for typescript bindings
215
+ */
216
+ constEnum?: boolean
182
217
  /**
183
218
  * Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.
184
219
  */
@@ -219,12 +254,24 @@ export interface BuildOptions {
219
254
  * Build the specified library or the one at cwd
220
255
  */
221
256
  package?: string
257
+ /**
258
+ * Build artifacts with the specified profile
259
+ */
260
+ profile?: string
222
261
  /**
223
262
  * [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
224
263
  */
225
264
  crossCompile?: boolean
226
265
  /**
227
- * watch the crate changes and build continiously with `cargo-watch` crates
266
+ * [experimental] use [cross](https://github.com/cross-rs/cross) instead of `cargo`
267
+ */
268
+ useCross?: boolean
269
+ /**
270
+ * [experimental] use @napi-rs/cross-toolchain to cross-compile Linux arm/arm64/x64 gnu targets.
271
+ */
272
+ useNapiCross?: boolean
273
+ /**
274
+ * watch the crate changes and build continuously with `cargo-watch` crates
228
275
  */
229
276
  watch?: boolean
230
277
  /**
@@ -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
@@ -72,7 +72,7 @@ export abstract class BaseNewCommand extends Command {
72
72
  */
73
73
  export interface NewOptions {
74
74
  /**
75
- * The path where the napi-rs project will be created.
75
+ * The path where the NAPI-RS project will be created.
76
76
  */
77
77
  path: string
78
78
  /**
@@ -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,6 +15,10 @@ 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
  })
@@ -23,7 +27,7 @@ export abstract class BasePrePublishCommand extends Command {
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,-t', 'lerna', {
27
31
  description: 'git tag style, `npm` or `lerna`',
28
32
  })
29
33
 
@@ -46,6 +50,7 @@ export abstract class BasePrePublishCommand extends Command {
46
50
  getOptions() {
47
51
  return {
48
52
  cwd: this.cwd,
53
+ configPath: this.configPath,
49
54
  packageJsonPath: this.packageJsonPath,
50
55
  npmDir: this.npmDir,
51
56
  tagStyle: this.tagStyle,
@@ -67,6 +72,10 @@ export interface PrePublishOptions {
67
72
  * @default process.cwd()
68
73
  */
69
74
  cwd?: string
75
+ /**
76
+ * Path to `napi` config json file
77
+ */
78
+ configPath?: string
70
79
  /**
71
80
  * Path to `package.json`
72
81
  *
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'
@@ -0,0 +1,97 @@
1
+ # Snapshot report for `src/utils/__tests__/config.spec.ts`
2
+
3
+ The actual snapshot is saved in `config.spec.ts.snap`.
4
+
5
+ Generated by [AVA](https://avajs.dev).
6
+
7
+ ## should be able to read config from package.json
8
+
9
+ > Snapshot 1
10
+
11
+ {
12
+ binaryName: 'testing',
13
+ npmClient: 'npm',
14
+ packageJson: {
15
+ name: '@napi-rs/testing',
16
+ napi: {
17
+ binaryName: 'testing',
18
+ packageName: '@napi-rs/testing',
19
+ targets: [
20
+ 'x86_64-unknown-linux-gnu',
21
+ 'x86_64-pc-windows-msvc',
22
+ 'x86_64-apple-darwin',
23
+ ],
24
+ },
25
+ version: '0.0.0',
26
+ },
27
+ packageName: '@napi-rs/testing',
28
+ targets: [
29
+ {
30
+ abi: 'gnu',
31
+ arch: 'x64',
32
+ platform: 'linux',
33
+ platformArchABI: 'linux-x64-gnu',
34
+ triple: 'x86_64-unknown-linux-gnu',
35
+ },
36
+ {
37
+ abi: 'msvc',
38
+ arch: 'x64',
39
+ platform: 'win32',
40
+ platformArchABI: 'win32-x64-msvc',
41
+ triple: 'x86_64-pc-windows-msvc',
42
+ },
43
+ {
44
+ abi: null,
45
+ arch: 'x64',
46
+ platform: 'darwin',
47
+ platformArchABI: 'darwin-x64',
48
+ triple: 'x86_64-apple-darwin',
49
+ },
50
+ ],
51
+ }
52
+
53
+ ## should be able to read config from napi.json
54
+
55
+ > Snapshot 1
56
+
57
+ {
58
+ binaryName: 'testing',
59
+ npmClient: 'npm',
60
+ packageJson: {
61
+ name: '@napi-rs/testing',
62
+ napi: {
63
+ binaryName: 'testing',
64
+ packageName: '@node-rs/testing',
65
+ targets: [
66
+ 'x86_64-unknown-linux-gnu',
67
+ 'x86_64-apple-darwin',
68
+ 'aarch64-apple-darwin',
69
+ ],
70
+ },
71
+ version: '0.0.0',
72
+ },
73
+ packageName: '@node-rs/testing',
74
+ targets: [
75
+ {
76
+ abi: 'gnu',
77
+ arch: 'x64',
78
+ platform: 'linux',
79
+ platformArchABI: 'linux-x64-gnu',
80
+ triple: 'x86_64-unknown-linux-gnu',
81
+ },
82
+ {
83
+ abi: null,
84
+ arch: 'x64',
85
+ platform: 'darwin',
86
+ platformArchABI: 'darwin-x64',
87
+ triple: 'x86_64-apple-darwin',
88
+ },
89
+ {
90
+ abi: null,
91
+ arch: 'arm64',
92
+ platform: 'darwin',
93
+ platformArchABI: 'darwin-arm64',
94
+ triple: 'aarch64-apple-darwin',
95
+ },
96
+ ],
97
+ }
@@ -107,4 +107,11 @@ Generated by [AVA](https://avajs.dev).
107
107
  platformArchABI: 'darwin-universal',
108
108
  triple: 'universal-apple-darwin',
109
109
  },
110
+ {
111
+ abi: 'gnu',
112
+ arch: 'riscv64',
113
+ platform: 'linux',
114
+ platformArchABI: 'linux-riscv64-gnu',
115
+ triple: 'riscv64gc-unknown-linux-gnu',
116
+ },
110
117
  ]