@napi-rs/cli 2.15.1 → 3.0.0-alpha.0
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/README.md +17 -78
- package/cli.mjs +12 -0
- package/dist/api/artifacts.d.ts +2 -0
- package/dist/api/artifacts.js +50 -0
- package/dist/api/build.d.ts +14 -0
- package/dist/api/build.js +404 -0
- package/dist/api/create-npm-dirs.d.ts +2 -0
- package/dist/api/create-npm-dirs.js +63 -0
- package/dist/api/new.d.ts +4 -0
- package/dist/api/new.js +154 -0
- package/dist/api/pre-publish.d.ts +2 -0
- package/dist/api/pre-publish.js +157 -0
- package/dist/api/rename.d.ts +2 -0
- package/dist/api/rename.js +28 -0
- package/dist/api/templates/.gitignore.d.ts +1 -0
- package/dist/api/templates/.gitignore.js +198 -0
- package/dist/api/templates/.npmignore.d.ts +1 -0
- package/dist/api/templates/.npmignore.js +14 -0
- package/dist/api/templates/build.rs.d.ts +1 -0
- package/dist/api/templates/build.rs.js +4 -0
- package/dist/api/templates/cargo.toml.d.ts +6 -0
- package/dist/api/templates/cargo.toml.js +25 -0
- package/dist/api/templates/ci-template.d.ts +1 -0
- package/dist/api/templates/ci-template.js +566 -0
- package/dist/api/templates/ci.yml.d.ts +1 -0
- package/dist/api/templates/ci.yml.js +92 -0
- package/dist/api/templates/index.d.ts +8 -0
- package/dist/api/templates/index.js +8 -0
- package/dist/api/templates/js-binding.d.ts +1 -0
- package/dist/api/templates/js-binding.js +124 -0
- package/dist/api/templates/lib.rs.d.ts +1 -0
- package/dist/api/templates/lib.rs.js +10 -0
- package/dist/api/templates/package.json.d.ts +8 -0
- package/dist/api/templates/package.json.js +30 -0
- package/dist/api/universalize.d.ts +2 -0
- package/dist/api/universalize.js +38 -0
- package/dist/api/version.d.ts +2 -0
- package/dist/api/version.js +16 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +25 -0
- package/dist/commands/artifacts.d.ts +6 -0
- package/dist/commands/artifacts.js +19 -0
- package/dist/commands/build.d.ts +6 -0
- package/dist/commands/build.js +34 -0
- package/dist/commands/create-npm-dirs.d.ts +4 -0
- package/dist/commands/create-npm-dirs.js +7 -0
- package/dist/commands/help.d.ts +10 -0
- package/dist/commands/help.js +12 -0
- package/dist/commands/new.d.ts +12 -0
- package/dist/commands/new.js +112 -0
- package/dist/commands/pre-publish.d.ts +4 -0
- package/dist/commands/pre-publish.js +8 -0
- package/dist/commands/rename.d.ts +4 -0
- package/dist/commands/rename.js +7 -0
- package/dist/commands/universalize.d.ts +4 -0
- package/dist/commands/universalize.js +7 -0
- package/dist/commands/version.d.ts +4 -0
- package/dist/commands/version.js +7 -0
- package/dist/def/artifacts.d.ts +50 -0
- package/dist/def/artifacts.js +38 -0
- package/dist/def/build.d.ts +150 -0
- package/dist/def/build.js +105 -0
- package/dist/def/commands/artifacts.d.ts +15 -0
- package/dist/def/commands/artifacts.js +29 -0
- package/dist/def/commands/build.d.ts +53 -0
- package/dist/def/commands/build.js +105 -0
- package/dist/def/commands/create-npm-dirs.d.ts +15 -0
- package/dist/def/commands/create-npm-dirs.js +29 -0
- package/dist/def/commands/new.d.ts +27 -0
- package/dist/def/commands/new.js +53 -0
- package/dist/def/commands/pre-publish.d.ts +23 -0
- package/dist/def/commands/pre-publish.js +45 -0
- package/dist/def/commands/rename.d.ts +25 -0
- package/dist/def/commands/rename.js +49 -0
- package/dist/def/commands/universalize.d.ts +13 -0
- package/dist/def/commands/universalize.js +25 -0
- package/dist/def/commands/version.d.ts +13 -0
- package/dist/def/commands/version.js +25 -0
- package/dist/def/create-npm-dirs.d.ts +50 -0
- package/dist/def/create-npm-dirs.js +38 -0
- package/dist/def/new.d.ts +106 -0
- package/dist/def/new.js +66 -0
- package/dist/def/options/artifacts.d.ts +35 -0
- package/dist/def/options/artifacts.js +11 -0
- package/dist/def/options/build.d.ts +97 -0
- package/dist/def/options/build.js +3 -0
- package/dist/def/options/create-npm-dirs.d.ts +35 -0
- package/dist/def/options/create-npm-dirs.js +11 -0
- package/dist/def/options/new.d.ts +79 -0
- package/dist/def/options/new.js +15 -0
- package/dist/def/options/pre-publish.d.ts +65 -0
- package/dist/def/options/pre-publish.js +13 -0
- package/dist/def/options/rename.d.ts +75 -0
- package/dist/def/options/rename.js +11 -0
- package/dist/def/options/universalize.d.ts +28 -0
- package/dist/def/options/universalize.js +10 -0
- package/dist/def/options/version.d.ts +28 -0
- package/dist/def/options/version.js +10 -0
- package/dist/def/pre-publish.d.ts +88 -0
- package/dist/def/pre-publish.js +56 -0
- package/dist/def/rename.d.ts +100 -0
- package/dist/def/rename.js +58 -0
- package/dist/def/universalize.d.ts +41 -0
- package/dist/def/universalize.js +33 -0
- package/dist/def/version.d.ts +41 -0
- package/dist/def/version.js +33 -0
- package/dist/index.cjs +20641 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/utils/__tests__/target.spec.d.ts +1 -0
- package/dist/utils/__tests__/target.spec.js +10 -0
- package/dist/utils/__tests__/typegen.spec.d.ts +1 -0
- package/dist/utils/__tests__/typegen.spec.js +37 -0
- package/dist/utils/__tests__/version.spec.d.ts +1 -0
- package/dist/utils/__tests__/version.spec.js +5 -0
- package/dist/utils/cargo.d.ts +1 -0
- package/dist/utils/cargo.js +33 -0
- package/dist/utils/ci.d.ts +11 -0
- package/dist/utils/ci.js +86 -0
- package/dist/utils/config.d.ts +65 -0
- package/dist/utils/config.js +42 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/log.d.ts +10 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/metadata.d.ts +24 -0
- package/dist/utils/metadata.js +19 -0
- package/dist/utils/misc.d.ts +13 -0
- package/dist/utils/misc.js +35 -0
- package/dist/utils/target.d.ts +30 -0
- package/dist/utils/target.js +109 -0
- package/dist/utils/typegen.d.ts +3 -0
- package/dist/utils/typegen.js +158 -0
- package/dist/utils/version.d.ts +11 -0
- package/dist/utils/version.js +59 -0
- package/package.json +63 -27
- package/src/api/artifacts.ts +93 -0
- package/src/api/build.ts +549 -0
- package/src/api/create-npm-dirs.ts +105 -0
- package/src/api/new.ts +206 -0
- package/src/api/pre-publish.ts +216 -0
- package/src/api/rename.ts +51 -0
- package/src/api/templates/.gitignore.ts +198 -0
- package/src/api/templates/.npmignore.ts +14 -0
- package/src/api/templates/build.rs.ts +4 -0
- package/src/api/templates/cargo.toml.ts +35 -0
- package/src/api/templates/ci-template.ts +566 -0
- package/src/api/templates/ci.yml.ts +116 -0
- package/src/api/templates/index.ts +8 -0
- package/src/api/templates/js-binding.ts +130 -0
- package/src/api/templates/lib.rs.ts +10 -0
- package/src/api/templates/package.json.ts +44 -0
- package/src/api/universalize.ts +76 -0
- package/src/api/version.ts +26 -0
- package/src/cli.ts +29 -0
- package/src/commands/artifacts.ts +23 -0
- package/src/commands/build.ts +42 -0
- package/src/commands/create-npm-dirs.ts +8 -0
- package/src/commands/help.ts +13 -0
- package/src/commands/new.ts +138 -0
- package/src/commands/pre-publish.ts +9 -0
- package/src/commands/rename.ts +8 -0
- package/src/commands/universalize.ts +8 -0
- package/src/commands/version.ts +8 -0
- package/src/def/artifacts.ts +79 -0
- package/src/def/build.ts +242 -0
- package/src/def/create-npm-dirs.ts +79 -0
- package/src/def/new.ts +144 -0
- package/src/def/pre-publish.ts +120 -0
- package/src/def/rename.ts +122 -0
- package/src/def/universalize.ts +66 -0
- package/src/def/version.ts +65 -0
- package/src/index.ts +31 -0
- package/src/utils/__tests__/__fixtures__/napi_type_def +201 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +110 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +618 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +20 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
- package/src/utils/__tests__/target.spec.ts +19 -0
- package/src/utils/__tests__/typegen.spec.ts +49 -0
- package/src/utils/__tests__/version.spec.ts +13 -0
- package/src/utils/cargo.ts +35 -0
- package/src/utils/ci.ts +102 -0
- package/src/utils/config.ts +123 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/log.ts +34 -0
- package/src/utils/metadata.ts +59 -0
- package/src/utils/misc.ts +45 -0
- package/src/utils/target.ts +145 -0
- package/src/utils/typegen.ts +193 -0
- package/src/utils/version.ts +76 -0
- package/scripts/index.js +0 -153779
package/src/def/build.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// This file is generated by codegen/index.ts
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
|
|
5
|
+
export abstract class BaseBuildCommand extends Command {
|
|
6
|
+
static paths = [['build']]
|
|
7
|
+
|
|
8
|
+
static usage = Command.Usage({
|
|
9
|
+
description: 'Build the napi-rs project',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
target?: string = Option.String('--target,-t', {
|
|
13
|
+
description:
|
|
14
|
+
'Build for the target triple, bypassed to `cargo build --target`',
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
cwd?: string = Option.String('--cwd', {
|
|
18
|
+
description:
|
|
19
|
+
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
manifestPath?: string = Option.String('--manifest-path', {
|
|
23
|
+
description: 'Path to `Cargo.toml`',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
packageJsonPath?: string = Option.String('--package-json-path', {
|
|
27
|
+
description: 'Path to `package.json`',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
targetDir?: string = Option.String('--target-dir', {
|
|
31
|
+
description:
|
|
32
|
+
'Directory for all crate generated artifacts, see `cargo build --target-dir`',
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
outputDir?: string = Option.String('--output-dir,-o', {
|
|
36
|
+
description:
|
|
37
|
+
'Path to where all the built files would be put. Default to the crate folder',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
platform?: boolean = Option.Boolean('--platform', {
|
|
41
|
+
description:
|
|
42
|
+
'Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node`',
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
jsPackageName?: string = Option.String('--js-package-name', {
|
|
46
|
+
description:
|
|
47
|
+
'Package name in generated js binding file. Only works with `--platform` flag',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
jsBinding?: string = Option.String('--js', {
|
|
51
|
+
description:
|
|
52
|
+
'Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.',
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
noJsBinding?: boolean = Option.Boolean('--no-js', {
|
|
56
|
+
description:
|
|
57
|
+
'Whether to disable the generation JS binding file. Only works with `--platform` flag.',
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
dts?: string = Option.String('--dts', {
|
|
61
|
+
description:
|
|
62
|
+
'Path and filename of generated type def file. Relative to `--output_dir`',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
dtsHeader?: string = Option.String('--dts-header', {
|
|
66
|
+
description:
|
|
67
|
+
'Custom file header for generated type def file. Only works when `typedef` feature enabled.',
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
noDtsHeader?: boolean = Option.Boolean('--no-dts-header', {
|
|
71
|
+
description:
|
|
72
|
+
'Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.',
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
strip?: boolean = Option.Boolean('--strip,-s', {
|
|
76
|
+
description: 'Whether strip the library to achieve the minimum file size',
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
release?: boolean = Option.Boolean('--release,-r', {
|
|
80
|
+
description: 'Build in release mode',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
verbose?: boolean = Option.Boolean('--verbose,-v', {
|
|
84
|
+
description: 'Verbosely log build command trace',
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
bin?: string = Option.String('--bin', {
|
|
88
|
+
description: 'Build only the specified binary',
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
package?: string = Option.String('--package,-p', {
|
|
92
|
+
description: 'Build the specified library or the one at cwd',
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
crossCompile?: boolean = Option.Boolean('--cross-compile,-x', {
|
|
96
|
+
description:
|
|
97
|
+
'[experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform',
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
watch?: boolean = Option.Boolean('--watch,-w', {
|
|
101
|
+
description:
|
|
102
|
+
'watch the crate changes and build continiously with `cargo-watch` crates',
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
features?: string[] = Option.Array('--features,-F', {
|
|
106
|
+
description: 'Space-separated list of features to activate',
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
allFeatures?: boolean = Option.Boolean('--all-features', {
|
|
110
|
+
description: 'Activate all available features',
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
noDefaultFeatures?: boolean = Option.Boolean('--no-default-features', {
|
|
114
|
+
description: 'Do not activate the `default` feature',
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
getOptions() {
|
|
118
|
+
return {
|
|
119
|
+
target: this.target,
|
|
120
|
+
cwd: this.cwd,
|
|
121
|
+
manifestPath: this.manifestPath,
|
|
122
|
+
packageJsonPath: this.packageJsonPath,
|
|
123
|
+
targetDir: this.targetDir,
|
|
124
|
+
outputDir: this.outputDir,
|
|
125
|
+
platform: this.platform,
|
|
126
|
+
jsPackageName: this.jsPackageName,
|
|
127
|
+
jsBinding: this.jsBinding,
|
|
128
|
+
noJsBinding: this.noJsBinding,
|
|
129
|
+
dts: this.dts,
|
|
130
|
+
dtsHeader: this.dtsHeader,
|
|
131
|
+
noDtsHeader: this.noDtsHeader,
|
|
132
|
+
strip: this.strip,
|
|
133
|
+
release: this.release,
|
|
134
|
+
verbose: this.verbose,
|
|
135
|
+
bin: this.bin,
|
|
136
|
+
package: this.package,
|
|
137
|
+
crossCompile: this.crossCompile,
|
|
138
|
+
watch: this.watch,
|
|
139
|
+
features: this.features,
|
|
140
|
+
allFeatures: this.allFeatures,
|
|
141
|
+
noDefaultFeatures: this.noDefaultFeatures,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Build the napi-rs project
|
|
148
|
+
*/
|
|
149
|
+
export interface BuildOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Build for the target triple, bypassed to `cargo build --target`
|
|
152
|
+
*/
|
|
153
|
+
target?: string
|
|
154
|
+
/**
|
|
155
|
+
* The working directory of where napi command will be executed in, all other paths options are relative to this path
|
|
156
|
+
*/
|
|
157
|
+
cwd?: string
|
|
158
|
+
/**
|
|
159
|
+
* Path to `Cargo.toml`
|
|
160
|
+
*/
|
|
161
|
+
manifestPath?: string
|
|
162
|
+
/**
|
|
163
|
+
* Path to `package.json`
|
|
164
|
+
*/
|
|
165
|
+
packageJsonPath?: string
|
|
166
|
+
/**
|
|
167
|
+
* Directory for all crate generated artifacts, see `cargo build --target-dir`
|
|
168
|
+
*/
|
|
169
|
+
targetDir?: string
|
|
170
|
+
/**
|
|
171
|
+
* Path to where all the built files would be put. Default to the crate folder
|
|
172
|
+
*/
|
|
173
|
+
outputDir?: string
|
|
174
|
+
/**
|
|
175
|
+
* Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node`
|
|
176
|
+
*/
|
|
177
|
+
platform?: boolean
|
|
178
|
+
/**
|
|
179
|
+
* Package name in generated js binding file. Only works with `--platform` flag
|
|
180
|
+
*/
|
|
181
|
+
jsPackageName?: string
|
|
182
|
+
/**
|
|
183
|
+
* Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output_dir`.
|
|
184
|
+
*/
|
|
185
|
+
jsBinding?: string
|
|
186
|
+
/**
|
|
187
|
+
* Whether to disable the generation JS binding file. Only works with `--platform` flag.
|
|
188
|
+
*/
|
|
189
|
+
noJsBinding?: boolean
|
|
190
|
+
/**
|
|
191
|
+
* Path and filename of generated type def file. Relative to `--output_dir`
|
|
192
|
+
*/
|
|
193
|
+
dts?: string
|
|
194
|
+
/**
|
|
195
|
+
* Custom file header for generated type def file. Only works when `typedef` feature enabled.
|
|
196
|
+
*/
|
|
197
|
+
dtsHeader?: string
|
|
198
|
+
/**
|
|
199
|
+
* Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled.
|
|
200
|
+
*/
|
|
201
|
+
noDtsHeader?: boolean
|
|
202
|
+
/**
|
|
203
|
+
* Whether strip the library to achieve the minimum file size
|
|
204
|
+
*/
|
|
205
|
+
strip?: boolean
|
|
206
|
+
/**
|
|
207
|
+
* Build in release mode
|
|
208
|
+
*/
|
|
209
|
+
release?: boolean
|
|
210
|
+
/**
|
|
211
|
+
* Verbosely log build command trace
|
|
212
|
+
*/
|
|
213
|
+
verbose?: boolean
|
|
214
|
+
/**
|
|
215
|
+
* Build only the specified binary
|
|
216
|
+
*/
|
|
217
|
+
bin?: string
|
|
218
|
+
/**
|
|
219
|
+
* Build the specified library or the one at cwd
|
|
220
|
+
*/
|
|
221
|
+
package?: string
|
|
222
|
+
/**
|
|
223
|
+
* [experimental] cross-compile for the specified target with `cargo-xwin` on windows and `cargo-zigbuild` on other platform
|
|
224
|
+
*/
|
|
225
|
+
crossCompile?: boolean
|
|
226
|
+
/**
|
|
227
|
+
* watch the crate changes and build continiously with `cargo-watch` crates
|
|
228
|
+
*/
|
|
229
|
+
watch?: boolean
|
|
230
|
+
/**
|
|
231
|
+
* Space-separated list of features to activate
|
|
232
|
+
*/
|
|
233
|
+
features?: string[]
|
|
234
|
+
/**
|
|
235
|
+
* Activate all available features
|
|
236
|
+
*/
|
|
237
|
+
allFeatures?: boolean
|
|
238
|
+
/**
|
|
239
|
+
* Do not activate the `default` feature
|
|
240
|
+
*/
|
|
241
|
+
noDefaultFeatures?: boolean
|
|
242
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// This file is generated by codegen/index.ts
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
|
|
5
|
+
export abstract class BaseCreateNpmDirsCommand extends Command {
|
|
6
|
+
static paths = [['create-npm-dirs']]
|
|
7
|
+
|
|
8
|
+
static usage = Command.Usage({
|
|
9
|
+
description: 'Create npm package dirs for different platforms',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
cwd = Option.String('--cwd', process.cwd(), {
|
|
13
|
+
description:
|
|
14
|
+
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
|
+
description: 'Path to `package.json`',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
npmDir = Option.String('--npm-dir', 'npm', {
|
|
22
|
+
description: 'Path to the folder where the npm packages put',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
dryRun = Option.Boolean('--dry-run', false, {
|
|
26
|
+
description: 'Dry run without touching file system',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
getOptions() {
|
|
30
|
+
return {
|
|
31
|
+
cwd: this.cwd,
|
|
32
|
+
packageJsonPath: this.packageJsonPath,
|
|
33
|
+
npmDir: this.npmDir,
|
|
34
|
+
dryRun: this.dryRun,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create npm package dirs for different platforms
|
|
41
|
+
*/
|
|
42
|
+
export interface CreateNpmDirsOptions {
|
|
43
|
+
/**
|
|
44
|
+
* The working directory of where napi command will be executed in, all other paths options are relative to this path
|
|
45
|
+
*
|
|
46
|
+
* @default process.cwd()
|
|
47
|
+
*/
|
|
48
|
+
cwd?: string
|
|
49
|
+
/**
|
|
50
|
+
* Path to `package.json`
|
|
51
|
+
*
|
|
52
|
+
* @default 'package.json'
|
|
53
|
+
*/
|
|
54
|
+
packageJsonPath?: string
|
|
55
|
+
/**
|
|
56
|
+
* Path to the folder where the npm packages put
|
|
57
|
+
*
|
|
58
|
+
* @default 'npm'
|
|
59
|
+
*/
|
|
60
|
+
npmDir?: string
|
|
61
|
+
/**
|
|
62
|
+
* Dry run without touching file system
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
dryRun?: boolean
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function applyDefaultCreateNpmDirsOptions(
|
|
70
|
+
options: CreateNpmDirsOptions,
|
|
71
|
+
) {
|
|
72
|
+
return {
|
|
73
|
+
cwd: process.cwd(),
|
|
74
|
+
packageJsonPath: 'package.json',
|
|
75
|
+
npmDir: 'npm',
|
|
76
|
+
dryRun: false,
|
|
77
|
+
...options,
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/def/new.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// This file is generated by codegen/index.ts
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
import * as typanion from 'typanion'
|
|
5
|
+
|
|
6
|
+
export abstract class BaseNewCommand extends Command {
|
|
7
|
+
static paths = [['new']]
|
|
8
|
+
|
|
9
|
+
static usage = Command.Usage({
|
|
10
|
+
description: 'Create a new project with pre-configured boilerplate',
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
$$path = Option.String({ required: true })
|
|
14
|
+
|
|
15
|
+
$$name?: string = Option.String('--name,-n', {
|
|
16
|
+
description:
|
|
17
|
+
'The name of the project, default to the name of the directory if not provided',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
minNodeApiVersion = Option.String('--min-node-api,-v', '4', {
|
|
21
|
+
validator: typanion.isNumber(),
|
|
22
|
+
description: 'The minimum Node-API version to support',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
license = Option.String('--license,-l', 'MIT', {
|
|
26
|
+
description: 'License for open-sourced project',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
targets = Option.Array('--targets,-t', [], {
|
|
30
|
+
description: 'All targets the crate will be compiled for.',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
enableDefaultTargets = Option.Boolean('--enable-default-targets', true, {
|
|
34
|
+
description: 'Whether enable default targets',
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
enableAllTargets = Option.Boolean('--enable-all-targets', false, {
|
|
38
|
+
description: 'Whether enable all targets',
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
enableTypeDef = Option.Boolean('--enable-type-def', true, {
|
|
42
|
+
description:
|
|
43
|
+
'Whether enable the `type-def` feature for typescript definitions auto-generation',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
enableGithubActions = Option.Boolean('--enable-github-actions', true, {
|
|
47
|
+
description: 'Whether generate preconfigured GitHub Actions workflow',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
dryRun = Option.Boolean('--dry-run', false, {
|
|
51
|
+
description: 'Whether to run the command in dry-run mode',
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
getOptions() {
|
|
55
|
+
return {
|
|
56
|
+
path: this.$$path,
|
|
57
|
+
name: this.$$name,
|
|
58
|
+
minNodeApiVersion: this.minNodeApiVersion,
|
|
59
|
+
license: this.license,
|
|
60
|
+
targets: this.targets,
|
|
61
|
+
enableDefaultTargets: this.enableDefaultTargets,
|
|
62
|
+
enableAllTargets: this.enableAllTargets,
|
|
63
|
+
enableTypeDef: this.enableTypeDef,
|
|
64
|
+
enableGithubActions: this.enableGithubActions,
|
|
65
|
+
dryRun: this.dryRun,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create a new project with pre-configured boilerplate
|
|
72
|
+
*/
|
|
73
|
+
export interface NewOptions {
|
|
74
|
+
/**
|
|
75
|
+
* The path where the napi-rs project will be created.
|
|
76
|
+
*/
|
|
77
|
+
path: string
|
|
78
|
+
/**
|
|
79
|
+
* The name of the project, default to the name of the directory if not provided
|
|
80
|
+
*/
|
|
81
|
+
name?: string
|
|
82
|
+
/**
|
|
83
|
+
* The minimum Node-API version to support
|
|
84
|
+
*
|
|
85
|
+
* @default 4
|
|
86
|
+
*/
|
|
87
|
+
minNodeApiVersion?: number
|
|
88
|
+
/**
|
|
89
|
+
* License for open-sourced project
|
|
90
|
+
*
|
|
91
|
+
* @default 'MIT'
|
|
92
|
+
*/
|
|
93
|
+
license?: string
|
|
94
|
+
/**
|
|
95
|
+
* All targets the crate will be compiled for.
|
|
96
|
+
*
|
|
97
|
+
* @default []
|
|
98
|
+
*/
|
|
99
|
+
targets?: string[]
|
|
100
|
+
/**
|
|
101
|
+
* Whether enable default targets
|
|
102
|
+
*
|
|
103
|
+
* @default true
|
|
104
|
+
*/
|
|
105
|
+
enableDefaultTargets?: boolean
|
|
106
|
+
/**
|
|
107
|
+
* Whether enable all targets
|
|
108
|
+
*
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
enableAllTargets?: boolean
|
|
112
|
+
/**
|
|
113
|
+
* Whether enable the `type-def` feature for typescript definitions auto-generation
|
|
114
|
+
*
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
117
|
+
enableTypeDef?: boolean
|
|
118
|
+
/**
|
|
119
|
+
* Whether generate preconfigured GitHub Actions workflow
|
|
120
|
+
*
|
|
121
|
+
* @default true
|
|
122
|
+
*/
|
|
123
|
+
enableGithubActions?: boolean
|
|
124
|
+
/**
|
|
125
|
+
* Whether to run the command in dry-run mode
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
dryRun?: boolean
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function applyDefaultNewOptions(options: NewOptions) {
|
|
133
|
+
return {
|
|
134
|
+
minNodeApiVersion: 4,
|
|
135
|
+
license: 'MIT',
|
|
136
|
+
targets: [],
|
|
137
|
+
enableDefaultTargets: true,
|
|
138
|
+
enableAllTargets: false,
|
|
139
|
+
enableTypeDef: true,
|
|
140
|
+
enableGithubActions: true,
|
|
141
|
+
dryRun: false,
|
|
142
|
+
...options,
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// This file is generated by codegen/index.ts
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
|
|
5
|
+
export abstract class BasePrePublishCommand extends Command {
|
|
6
|
+
static paths = [['pre-publish']]
|
|
7
|
+
|
|
8
|
+
static usage = Command.Usage({
|
|
9
|
+
description:
|
|
10
|
+
'Update package.json and copy addons into per platform packages',
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
cwd = Option.String('--cwd', process.cwd(), {
|
|
14
|
+
description:
|
|
15
|
+
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
19
|
+
description: 'Path to `package.json`',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
npmDir = Option.String('--npm-dir', 'npm', {
|
|
23
|
+
description: 'Path to the folder where the npm packages put',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
tagStyle = Option.String('--tag-style', 'lerna', {
|
|
27
|
+
description: 'git tag style, `npm` or `lerna`',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
ghRelease = Option.Boolean('--gh-release', true, {
|
|
31
|
+
description: 'Whether create GitHub release',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
ghReleaseName?: string = Option.String('--gh-release-name', {
|
|
35
|
+
description: 'GitHub release name',
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
ghReleaseId?: string = Option.String('--gh-release-id', {
|
|
39
|
+
description: 'Existing GitHub release id',
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
dryRun = Option.Boolean('--dry-run', false, {
|
|
43
|
+
description: 'Dry run without touching file system',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
getOptions() {
|
|
47
|
+
return {
|
|
48
|
+
cwd: this.cwd,
|
|
49
|
+
packageJsonPath: this.packageJsonPath,
|
|
50
|
+
npmDir: this.npmDir,
|
|
51
|
+
tagStyle: this.tagStyle,
|
|
52
|
+
ghRelease: this.ghRelease,
|
|
53
|
+
ghReleaseName: this.ghReleaseName,
|
|
54
|
+
ghReleaseId: this.ghReleaseId,
|
|
55
|
+
dryRun: this.dryRun,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Update package.json and copy addons into per platform packages
|
|
62
|
+
*/
|
|
63
|
+
export interface PrePublishOptions {
|
|
64
|
+
/**
|
|
65
|
+
* The working directory of where napi command will be executed in, all other paths options are relative to this path
|
|
66
|
+
*
|
|
67
|
+
* @default process.cwd()
|
|
68
|
+
*/
|
|
69
|
+
cwd?: string
|
|
70
|
+
/**
|
|
71
|
+
* Path to `package.json`
|
|
72
|
+
*
|
|
73
|
+
* @default 'package.json'
|
|
74
|
+
*/
|
|
75
|
+
packageJsonPath?: string
|
|
76
|
+
/**
|
|
77
|
+
* Path to the folder where the npm packages put
|
|
78
|
+
*
|
|
79
|
+
* @default 'npm'
|
|
80
|
+
*/
|
|
81
|
+
npmDir?: string
|
|
82
|
+
/**
|
|
83
|
+
* git tag style, `npm` or `lerna`
|
|
84
|
+
*
|
|
85
|
+
* @default 'lerna'
|
|
86
|
+
*/
|
|
87
|
+
tagStyle?: 'npm' | 'lerna'
|
|
88
|
+
/**
|
|
89
|
+
* Whether create GitHub release
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
ghRelease?: boolean
|
|
94
|
+
/**
|
|
95
|
+
* GitHub release name
|
|
96
|
+
*/
|
|
97
|
+
ghReleaseName?: string
|
|
98
|
+
/**
|
|
99
|
+
* Existing GitHub release id
|
|
100
|
+
*/
|
|
101
|
+
ghReleaseId?: string
|
|
102
|
+
/**
|
|
103
|
+
* Dry run without touching file system
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
dryRun?: boolean
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function applyDefaultPrePublishOptions(options: PrePublishOptions) {
|
|
111
|
+
return {
|
|
112
|
+
cwd: process.cwd(),
|
|
113
|
+
packageJsonPath: 'package.json',
|
|
114
|
+
npmDir: 'npm',
|
|
115
|
+
tagStyle: 'lerna',
|
|
116
|
+
ghRelease: true,
|
|
117
|
+
dryRun: false,
|
|
118
|
+
...options,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// This file is generated by codegen/index.ts
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
import { Command, Option } from 'clipanion'
|
|
4
|
+
|
|
5
|
+
export abstract class BaseRenameCommand extends Command {
|
|
6
|
+
static paths = [['rename']]
|
|
7
|
+
|
|
8
|
+
static usage = Command.Usage({
|
|
9
|
+
description: 'Rename the napi-rs project',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
cwd = Option.String('--cwd', process.cwd(), {
|
|
13
|
+
description:
|
|
14
|
+
'The working directory of where napi command will be executed in, all other paths options are relative to this path',
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
packageJsonPath = Option.String('--package-json-path', 'package.json', {
|
|
18
|
+
description: 'Path to `package.json`',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
npmDir = Option.String('--npm-dir', 'npm', {
|
|
22
|
+
description: 'Path to the folder where the npm packages put',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
$$name?: string = Option.String('--name,-n', {
|
|
26
|
+
description: 'The new name of the project',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
binaryName?: string = Option.String('--binary-name,-b', {
|
|
30
|
+
description: 'The new binary name *.node files',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
packageName?: string = Option.String('--package-name', {
|
|
34
|
+
description: 'The new package name of the project',
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
manifestPath = Option.String('--manifest-path', 'Cargo.toml', {
|
|
38
|
+
description: 'Path to `Cargo.toml`',
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
repository?: string = Option.String('--repository', {
|
|
42
|
+
description: 'The new repository of the project',
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
description?: string = Option.String('--description', {
|
|
46
|
+
description: 'The new description of the project',
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
getOptions() {
|
|
50
|
+
return {
|
|
51
|
+
cwd: this.cwd,
|
|
52
|
+
packageJsonPath: this.packageJsonPath,
|
|
53
|
+
npmDir: this.npmDir,
|
|
54
|
+
name: this.$$name,
|
|
55
|
+
binaryName: this.binaryName,
|
|
56
|
+
packageName: this.packageName,
|
|
57
|
+
manifestPath: this.manifestPath,
|
|
58
|
+
repository: this.repository,
|
|
59
|
+
description: this.description,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Rename the napi-rs project
|
|
66
|
+
*/
|
|
67
|
+
export interface RenameOptions {
|
|
68
|
+
/**
|
|
69
|
+
* The working directory of where napi command will be executed in, all other paths options are relative to this path
|
|
70
|
+
*
|
|
71
|
+
* @default process.cwd()
|
|
72
|
+
*/
|
|
73
|
+
cwd?: string
|
|
74
|
+
/**
|
|
75
|
+
* Path to `package.json`
|
|
76
|
+
*
|
|
77
|
+
* @default 'package.json'
|
|
78
|
+
*/
|
|
79
|
+
packageJsonPath?: string
|
|
80
|
+
/**
|
|
81
|
+
* Path to the folder where the npm packages put
|
|
82
|
+
*
|
|
83
|
+
* @default 'npm'
|
|
84
|
+
*/
|
|
85
|
+
npmDir?: string
|
|
86
|
+
/**
|
|
87
|
+
* The new name of the project
|
|
88
|
+
*/
|
|
89
|
+
name?: string
|
|
90
|
+
/**
|
|
91
|
+
* The new binary name *.node files
|
|
92
|
+
*/
|
|
93
|
+
binaryName?: string
|
|
94
|
+
/**
|
|
95
|
+
* The new package name of the project
|
|
96
|
+
*/
|
|
97
|
+
packageName?: string
|
|
98
|
+
/**
|
|
99
|
+
* Path to `Cargo.toml`
|
|
100
|
+
*
|
|
101
|
+
* @default 'Cargo.toml'
|
|
102
|
+
*/
|
|
103
|
+
manifestPath?: string
|
|
104
|
+
/**
|
|
105
|
+
* The new repository of the project
|
|
106
|
+
*/
|
|
107
|
+
repository?: string
|
|
108
|
+
/**
|
|
109
|
+
* The new description of the project
|
|
110
|
+
*/
|
|
111
|
+
description?: string
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function applyDefaultRenameOptions(options: RenameOptions) {
|
|
115
|
+
return {
|
|
116
|
+
cwd: process.cwd(),
|
|
117
|
+
packageJsonPath: 'package.json',
|
|
118
|
+
npmDir: 'npm',
|
|
119
|
+
manifestPath: 'Cargo.toml',
|
|
120
|
+
...options,
|
|
121
|
+
}
|
|
122
|
+
}
|