@twin.org/cli-core 0.0.1-next.3 → 0.0.1-next.30
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/dist/cjs/index.cjs +23 -5
- package/dist/esm/index.mjs +23 -5
- package/dist/types/cliUtils.d.ts +9 -1
- package/dist/types/models/ICliOptions.d.ts +4 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/CLIBase.md +15 -5
- package/docs/reference/classes/CLIDisplay.md +51 -17
- package/docs/reference/classes/CLIOptions.md +19 -7
- package/docs/reference/classes/CLIParam.md +117 -39
- package/docs/reference/classes/CLIUtils.md +89 -19
- package/docs/reference/functions/addGlobalOptions.md +9 -3
- package/docs/reference/functions/initGlobalOptions.md +3 -1
- package/docs/reference/interfaces/ICliOptions.md +8 -0
- package/package.json +8 -36
package/dist/cjs/index.cjs
CHANGED
|
@@ -298,6 +298,17 @@ class CLIUtils {
|
|
|
298
298
|
});
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Run a shell command.
|
|
303
|
+
* @param command The app to run in the shell.
|
|
304
|
+
* @param args The args for the app.
|
|
305
|
+
* @param cwd The working directory to execute the command in.
|
|
306
|
+
* @returns Promise to wait for command execution to complete.
|
|
307
|
+
*/
|
|
308
|
+
static async runShellCmd(command, args, cwd) {
|
|
309
|
+
const osCommand = process.platform.startsWith("win") ? `${command}.cmd` : command;
|
|
310
|
+
return CLIUtils.runShellApp(osCommand, args, cwd);
|
|
311
|
+
}
|
|
301
312
|
/**
|
|
302
313
|
* Run a shell app.
|
|
303
314
|
* @param app The app to run in the shell.
|
|
@@ -305,10 +316,9 @@ class CLIUtils {
|
|
|
305
316
|
* @param cwd The working directory to execute the command in.
|
|
306
317
|
* @returns Promise to wait for command execution to complete.
|
|
307
318
|
*/
|
|
308
|
-
static async
|
|
319
|
+
static async runShellApp(app, args, cwd) {
|
|
309
320
|
return new Promise((resolve, reject) => {
|
|
310
|
-
const
|
|
311
|
-
const sp = node_child_process.spawn(osCommand, args, {
|
|
321
|
+
const sp = node_child_process.spawn(app, args, {
|
|
312
322
|
shell: true,
|
|
313
323
|
cwd
|
|
314
324
|
});
|
|
@@ -346,7 +356,7 @@ class CLIUtils {
|
|
|
346
356
|
CLIDisplay.task(core.I18n.formatMessage("cli.progress.writingJsonFile"), filename);
|
|
347
357
|
CLIDisplay.break();
|
|
348
358
|
await promises.mkdir(path.dirname(filename), { recursive: true });
|
|
349
|
-
await promises.writeFile(filename, JSON.stringify(core.ObjectHelper.merge(currentJson, data), undefined, "\t"));
|
|
359
|
+
await promises.writeFile(filename, `${JSON.stringify(core.ObjectHelper.merge(currentJson, data), undefined, "\t")}\n`);
|
|
350
360
|
}
|
|
351
361
|
}
|
|
352
362
|
/**
|
|
@@ -377,7 +387,7 @@ class CLIUtils {
|
|
|
377
387
|
for (const line of data) {
|
|
378
388
|
const parts = line.split("=");
|
|
379
389
|
const currentIndex = outputKeys.indexOf(parts[0]);
|
|
380
|
-
if (currentIndex
|
|
390
|
+
if (currentIndex !== -1) {
|
|
381
391
|
outputKeys.splice(currentIndex, 1);
|
|
382
392
|
}
|
|
383
393
|
outputKeys.push(parts[0]);
|
|
@@ -472,6 +482,12 @@ class CLIBase {
|
|
|
472
482
|
CLIDisplay.header(options.title, options.version, options.icon);
|
|
473
483
|
}
|
|
474
484
|
const program = new commander.Command();
|
|
485
|
+
let outputWidth = options.overrideOutputWidth;
|
|
486
|
+
let outputErrWidth = options.overrideOutputWidth;
|
|
487
|
+
if (core.Is.undefined(outputWidth) && process.stdout.isTTY) {
|
|
488
|
+
outputWidth = process.stdout.columns;
|
|
489
|
+
outputErrWidth = process.stderr.columns;
|
|
490
|
+
}
|
|
475
491
|
program
|
|
476
492
|
.name(options.appName)
|
|
477
493
|
.version(options.version)
|
|
@@ -480,6 +496,8 @@ class CLIBase {
|
|
|
480
496
|
.configureOutput({
|
|
481
497
|
writeOut: str => CLIDisplay.write(str),
|
|
482
498
|
writeErr: str => CLIDisplay.writeError(str),
|
|
499
|
+
getOutHelpWidth: () => outputWidth,
|
|
500
|
+
getErrHelpWidth: () => outputErrWidth,
|
|
483
501
|
outputError: (str, write) => CLIDisplay.error(str.replace(/^error: /, ""), false)
|
|
484
502
|
})
|
|
485
503
|
.exitOverride(err => {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -277,6 +277,17 @@ class CLIUtils {
|
|
|
277
277
|
});
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Run a shell command.
|
|
282
|
+
* @param command The app to run in the shell.
|
|
283
|
+
* @param args The args for the app.
|
|
284
|
+
* @param cwd The working directory to execute the command in.
|
|
285
|
+
* @returns Promise to wait for command execution to complete.
|
|
286
|
+
*/
|
|
287
|
+
static async runShellCmd(command, args, cwd) {
|
|
288
|
+
const osCommand = process.platform.startsWith("win") ? `${command}.cmd` : command;
|
|
289
|
+
return CLIUtils.runShellApp(osCommand, args, cwd);
|
|
290
|
+
}
|
|
280
291
|
/**
|
|
281
292
|
* Run a shell app.
|
|
282
293
|
* @param app The app to run in the shell.
|
|
@@ -284,10 +295,9 @@ class CLIUtils {
|
|
|
284
295
|
* @param cwd The working directory to execute the command in.
|
|
285
296
|
* @returns Promise to wait for command execution to complete.
|
|
286
297
|
*/
|
|
287
|
-
static async
|
|
298
|
+
static async runShellApp(app, args, cwd) {
|
|
288
299
|
return new Promise((resolve, reject) => {
|
|
289
|
-
const
|
|
290
|
-
const sp = spawn(osCommand, args, {
|
|
300
|
+
const sp = spawn(app, args, {
|
|
291
301
|
shell: true,
|
|
292
302
|
cwd
|
|
293
303
|
});
|
|
@@ -325,7 +335,7 @@ class CLIUtils {
|
|
|
325
335
|
CLIDisplay.task(I18n.formatMessage("cli.progress.writingJsonFile"), filename);
|
|
326
336
|
CLIDisplay.break();
|
|
327
337
|
await mkdir(path.dirname(filename), { recursive: true });
|
|
328
|
-
await writeFile(filename, JSON.stringify(ObjectHelper.merge(currentJson, data), undefined, "\t"));
|
|
338
|
+
await writeFile(filename, `${JSON.stringify(ObjectHelper.merge(currentJson, data), undefined, "\t")}\n`);
|
|
329
339
|
}
|
|
330
340
|
}
|
|
331
341
|
/**
|
|
@@ -356,7 +366,7 @@ class CLIUtils {
|
|
|
356
366
|
for (const line of data) {
|
|
357
367
|
const parts = line.split("=");
|
|
358
368
|
const currentIndex = outputKeys.indexOf(parts[0]);
|
|
359
|
-
if (currentIndex
|
|
369
|
+
if (currentIndex !== -1) {
|
|
360
370
|
outputKeys.splice(currentIndex, 1);
|
|
361
371
|
}
|
|
362
372
|
outputKeys.push(parts[0]);
|
|
@@ -451,6 +461,12 @@ class CLIBase {
|
|
|
451
461
|
CLIDisplay.header(options.title, options.version, options.icon);
|
|
452
462
|
}
|
|
453
463
|
const program = new Command();
|
|
464
|
+
let outputWidth = options.overrideOutputWidth;
|
|
465
|
+
let outputErrWidth = options.overrideOutputWidth;
|
|
466
|
+
if (Is.undefined(outputWidth) && process.stdout.isTTY) {
|
|
467
|
+
outputWidth = process.stdout.columns;
|
|
468
|
+
outputErrWidth = process.stderr.columns;
|
|
469
|
+
}
|
|
454
470
|
program
|
|
455
471
|
.name(options.appName)
|
|
456
472
|
.version(options.version)
|
|
@@ -459,6 +475,8 @@ class CLIBase {
|
|
|
459
475
|
.configureOutput({
|
|
460
476
|
writeOut: str => CLIDisplay.write(str),
|
|
461
477
|
writeErr: str => CLIDisplay.writeError(str),
|
|
478
|
+
getOutHelpWidth: () => outputWidth,
|
|
479
|
+
getErrHelpWidth: () => outputErrWidth,
|
|
462
480
|
outputError: (str, write) => CLIDisplay.error(str.replace(/^error: /, ""), false)
|
|
463
481
|
})
|
|
464
482
|
.exitOverride(err => {
|
package/dist/types/cliUtils.d.ts
CHANGED
|
@@ -56,6 +56,14 @@ export declare class CLIUtils {
|
|
|
56
56
|
* @returns The root path.
|
|
57
57
|
*/
|
|
58
58
|
static findNpmRoot(rootFolder: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Run a shell command.
|
|
61
|
+
* @param command The app to run in the shell.
|
|
62
|
+
* @param args The args for the app.
|
|
63
|
+
* @param cwd The working directory to execute the command in.
|
|
64
|
+
* @returns Promise to wait for command execution to complete.
|
|
65
|
+
*/
|
|
66
|
+
static runShellCmd(command: string, args: string[], cwd: string): Promise<void>;
|
|
59
67
|
/**
|
|
60
68
|
* Run a shell app.
|
|
61
69
|
* @param app The app to run in the shell.
|
|
@@ -63,7 +71,7 @@ export declare class CLIUtils {
|
|
|
63
71
|
* @param cwd The working directory to execute the command in.
|
|
64
72
|
* @returns Promise to wait for command execution to complete.
|
|
65
73
|
*/
|
|
66
|
-
static
|
|
74
|
+
static runShellApp(app: string, args: string[], cwd: string): Promise<void>;
|
|
67
75
|
/**
|
|
68
76
|
* Write a JSON file.
|
|
69
77
|
* @param jsonFilename The filename to write.
|
package/docs/changelog.md
CHANGED
|
@@ -22,15 +22,21 @@ Execute the command line processing.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### options
|
|
26
|
+
|
|
27
|
+
[`ICliOptions`](../interfaces/ICliOptions.md)
|
|
26
28
|
|
|
27
29
|
The options for the CLI.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### localesDirectory
|
|
32
|
+
|
|
33
|
+
`string`
|
|
30
34
|
|
|
31
35
|
The path to load the locales from.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### argv
|
|
38
|
+
|
|
39
|
+
`string`[]
|
|
34
40
|
|
|
35
41
|
The process arguments.
|
|
36
42
|
|
|
@@ -50,7 +56,9 @@ Configure any options or actions at the root program level.
|
|
|
50
56
|
|
|
51
57
|
#### Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### program
|
|
60
|
+
|
|
61
|
+
`Command`
|
|
54
62
|
|
|
55
63
|
The root program command.
|
|
56
64
|
|
|
@@ -68,7 +76,9 @@ Get the commands for the CLI, override in derived class to supply your own.
|
|
|
68
76
|
|
|
69
77
|
#### Parameters
|
|
70
78
|
|
|
71
|
-
|
|
79
|
+
##### program
|
|
80
|
+
|
|
81
|
+
`Command`
|
|
72
82
|
|
|
73
83
|
The main program that the commands will be added to.
|
|
74
84
|
|
|
@@ -22,10 +22,12 @@ The default output method for writing standard messages.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### buffer
|
|
26
26
|
|
|
27
27
|
The message to output.
|
|
28
28
|
|
|
29
|
+
`string` | `Uint8Array`
|
|
30
|
+
|
|
29
31
|
#### Returns
|
|
30
32
|
|
|
31
33
|
`void`
|
|
@@ -40,10 +42,12 @@ The default output method for writing error messages.
|
|
|
40
42
|
|
|
41
43
|
#### Parameters
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
##### buffer
|
|
44
46
|
|
|
45
47
|
The message to output.
|
|
46
48
|
|
|
49
|
+
`string` | `Uint8Array`
|
|
50
|
+
|
|
47
51
|
#### Returns
|
|
48
52
|
|
|
49
53
|
`void`
|
|
@@ -70,15 +74,21 @@ Display the header for the CLI.
|
|
|
70
74
|
|
|
71
75
|
#### Parameters
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
##### title
|
|
78
|
+
|
|
79
|
+
`string`
|
|
74
80
|
|
|
75
81
|
The title of the CLI.
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
##### version
|
|
84
|
+
|
|
85
|
+
`string`
|
|
78
86
|
|
|
79
87
|
The version of the CLI.
|
|
80
88
|
|
|
81
|
-
|
|
89
|
+
##### icon
|
|
90
|
+
|
|
91
|
+
`string`
|
|
82
92
|
|
|
83
93
|
The icon for the CLI.
|
|
84
94
|
|
|
@@ -96,11 +106,15 @@ Display an error message.
|
|
|
96
106
|
|
|
97
107
|
#### Parameters
|
|
98
108
|
|
|
99
|
-
|
|
109
|
+
##### error
|
|
110
|
+
|
|
111
|
+
`unknown`
|
|
100
112
|
|
|
101
113
|
The error to display.
|
|
102
114
|
|
|
103
|
-
|
|
115
|
+
##### lineBreaks
|
|
116
|
+
|
|
117
|
+
`boolean` = `true`
|
|
104
118
|
|
|
105
119
|
Whether to add a line break after the error.
|
|
106
120
|
|
|
@@ -118,7 +132,9 @@ Display a section.
|
|
|
118
132
|
|
|
119
133
|
#### Parameters
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
##### label
|
|
136
|
+
|
|
137
|
+
`string`
|
|
122
138
|
|
|
123
139
|
The label for the section.
|
|
124
140
|
|
|
@@ -136,15 +152,21 @@ Display a value with a label.
|
|
|
136
152
|
|
|
137
153
|
#### Parameters
|
|
138
154
|
|
|
139
|
-
|
|
155
|
+
##### label
|
|
156
|
+
|
|
157
|
+
`string`
|
|
140
158
|
|
|
141
159
|
The label for the value.
|
|
142
160
|
|
|
143
|
-
|
|
161
|
+
##### value
|
|
162
|
+
|
|
163
|
+
`unknown`
|
|
144
164
|
|
|
145
165
|
The value to display.
|
|
146
166
|
|
|
147
|
-
|
|
167
|
+
##### indentLevel
|
|
168
|
+
|
|
169
|
+
`number` = `0`
|
|
148
170
|
|
|
149
171
|
The level of indentation.
|
|
150
172
|
|
|
@@ -162,11 +184,15 @@ Display a task with a label.
|
|
|
162
184
|
|
|
163
185
|
#### Parameters
|
|
164
186
|
|
|
165
|
-
|
|
187
|
+
##### label
|
|
188
|
+
|
|
189
|
+
`string`
|
|
166
190
|
|
|
167
191
|
The label for the value.
|
|
168
192
|
|
|
169
|
-
|
|
193
|
+
##### task?
|
|
194
|
+
|
|
195
|
+
`string`
|
|
170
196
|
|
|
171
197
|
The task to display.
|
|
172
198
|
|
|
@@ -196,7 +222,9 @@ Display formatted and colorized JSON.
|
|
|
196
222
|
|
|
197
223
|
#### Parameters
|
|
198
224
|
|
|
199
|
-
|
|
225
|
+
##### obj
|
|
226
|
+
|
|
227
|
+
`unknown`
|
|
200
228
|
|
|
201
229
|
The object to display.
|
|
202
230
|
|
|
@@ -226,15 +254,21 @@ Start the spinner.
|
|
|
226
254
|
|
|
227
255
|
#### Parameters
|
|
228
256
|
|
|
229
|
-
|
|
257
|
+
##### i18nMessage
|
|
258
|
+
|
|
259
|
+
`string` = `"cli.progress.pleaseWait"`
|
|
230
260
|
|
|
231
261
|
The message to display with the spinner.
|
|
232
262
|
|
|
233
|
-
|
|
263
|
+
##### spinnerCharacters
|
|
264
|
+
|
|
265
|
+
`string`[] = `...`
|
|
234
266
|
|
|
235
267
|
The characters to use in the spinner.
|
|
236
268
|
|
|
237
|
-
|
|
269
|
+
##### interval
|
|
270
|
+
|
|
271
|
+
`number` = `100`
|
|
238
272
|
|
|
239
273
|
The interval for the spinner.
|
|
240
274
|
|
|
@@ -22,31 +22,43 @@ Get the options for output.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### command
|
|
26
|
+
|
|
27
|
+
`Command`
|
|
26
28
|
|
|
27
29
|
The command to add the options to.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### opts
|
|
30
32
|
|
|
31
33
|
The options of what to include.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
###### noConsole
|
|
36
|
+
|
|
37
|
+
`boolean`
|
|
34
38
|
|
|
35
39
|
Do not output to the console.
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
###### json
|
|
42
|
+
|
|
43
|
+
`boolean`
|
|
38
44
|
|
|
39
45
|
Output to a JSON file.
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
###### env
|
|
48
|
+
|
|
49
|
+
`boolean`
|
|
42
50
|
|
|
43
51
|
Output to an environment file.
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
###### mergeJson
|
|
54
|
+
|
|
55
|
+
`boolean`
|
|
46
56
|
|
|
47
57
|
Merge existing JSON file.
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
###### mergeEnv
|
|
60
|
+
|
|
61
|
+
`boolean`
|
|
50
62
|
|
|
51
63
|
Merge existing environment file.
|
|
52
64
|
|
|
@@ -22,15 +22,21 @@ Check the option to see if it exists.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### optionName
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The name of the option.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### optionValue
|
|
30
32
|
|
|
31
33
|
The option value.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
`undefined` | `string`
|
|
36
|
+
|
|
37
|
+
##### allowEnvVar
|
|
38
|
+
|
|
39
|
+
`boolean`
|
|
34
40
|
|
|
35
41
|
Allow the option to be read from an env var.
|
|
36
42
|
|
|
@@ -54,15 +60,21 @@ Check the option to see if it exists.
|
|
|
54
60
|
|
|
55
61
|
#### Parameters
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
##### optionName
|
|
64
|
+
|
|
65
|
+
`string`
|
|
58
66
|
|
|
59
67
|
The name of the option.
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
##### optionValue
|
|
62
70
|
|
|
63
71
|
The option value.
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
`undefined` | `string`
|
|
74
|
+
|
|
75
|
+
##### allowEnvVar
|
|
76
|
+
|
|
77
|
+
`boolean` = `true`
|
|
66
78
|
|
|
67
79
|
Allow the option to be read from an env var.
|
|
68
80
|
|
|
@@ -86,15 +98,21 @@ Check the option to see if it a url.
|
|
|
86
98
|
|
|
87
99
|
#### Parameters
|
|
88
100
|
|
|
89
|
-
|
|
101
|
+
##### optionName
|
|
102
|
+
|
|
103
|
+
`string`
|
|
90
104
|
|
|
91
105
|
The name of the option.
|
|
92
106
|
|
|
93
|
-
|
|
107
|
+
##### optionValue
|
|
94
108
|
|
|
95
109
|
The option value.
|
|
96
110
|
|
|
97
|
-
|
|
111
|
+
`undefined` | `string`
|
|
112
|
+
|
|
113
|
+
##### allowEnvVar
|
|
114
|
+
|
|
115
|
+
`boolean` = `true`
|
|
98
116
|
|
|
99
117
|
Allow the option to be read from an env var.
|
|
100
118
|
|
|
@@ -118,23 +136,33 @@ Check the option to see if it exists and is a number.
|
|
|
118
136
|
|
|
119
137
|
#### Parameters
|
|
120
138
|
|
|
121
|
-
|
|
139
|
+
##### optionName
|
|
140
|
+
|
|
141
|
+
`string`
|
|
122
142
|
|
|
123
143
|
The name of the option.
|
|
124
144
|
|
|
125
|
-
|
|
145
|
+
##### optionValue
|
|
126
146
|
|
|
127
147
|
The option value.
|
|
128
148
|
|
|
129
|
-
|
|
149
|
+
`undefined` | `string`
|
|
150
|
+
|
|
151
|
+
##### allowEnvVar
|
|
152
|
+
|
|
153
|
+
`boolean` = `true`
|
|
130
154
|
|
|
131
155
|
Allow the option to be read from an env var.
|
|
132
156
|
|
|
133
|
-
|
|
157
|
+
##### minValue
|
|
158
|
+
|
|
159
|
+
`number` = `0`
|
|
134
160
|
|
|
135
161
|
The minimum value.
|
|
136
162
|
|
|
137
|
-
|
|
163
|
+
##### maxValue?
|
|
164
|
+
|
|
165
|
+
`number`
|
|
138
166
|
|
|
139
167
|
The maximum value.
|
|
140
168
|
|
|
@@ -158,23 +186,33 @@ Check the option to see if it exists and is an integer.
|
|
|
158
186
|
|
|
159
187
|
#### Parameters
|
|
160
188
|
|
|
161
|
-
|
|
189
|
+
##### optionName
|
|
190
|
+
|
|
191
|
+
`string`
|
|
162
192
|
|
|
163
193
|
The name of the option.
|
|
164
194
|
|
|
165
|
-
|
|
195
|
+
##### optionValue
|
|
166
196
|
|
|
167
197
|
The option value.
|
|
168
198
|
|
|
169
|
-
|
|
199
|
+
`undefined` | `string`
|
|
200
|
+
|
|
201
|
+
##### allowEnvVar
|
|
202
|
+
|
|
203
|
+
`boolean` = `true`
|
|
170
204
|
|
|
171
205
|
Allow the option to be read from an env var.
|
|
172
206
|
|
|
173
|
-
|
|
207
|
+
##### minValue
|
|
208
|
+
|
|
209
|
+
`number` = `0`
|
|
174
210
|
|
|
175
211
|
The minimum value.
|
|
176
212
|
|
|
177
|
-
|
|
213
|
+
##### maxValue?
|
|
214
|
+
|
|
215
|
+
`number`
|
|
178
216
|
|
|
179
217
|
The maximum value.
|
|
180
218
|
|
|
@@ -198,23 +236,33 @@ Check the option to see if it exists and is a big number.
|
|
|
198
236
|
|
|
199
237
|
#### Parameters
|
|
200
238
|
|
|
201
|
-
|
|
239
|
+
##### optionName
|
|
240
|
+
|
|
241
|
+
`string`
|
|
202
242
|
|
|
203
243
|
The name of the option.
|
|
204
244
|
|
|
205
|
-
|
|
245
|
+
##### optionValue
|
|
206
246
|
|
|
207
247
|
The option value.
|
|
208
248
|
|
|
209
|
-
|
|
249
|
+
`undefined` | `string`
|
|
250
|
+
|
|
251
|
+
##### allowEnvVar
|
|
252
|
+
|
|
253
|
+
`boolean` = `true`
|
|
210
254
|
|
|
211
255
|
Allow the option to be read from an env var.
|
|
212
256
|
|
|
213
|
-
|
|
257
|
+
##### minValue
|
|
258
|
+
|
|
259
|
+
`bigint` = `0n`
|
|
214
260
|
|
|
215
261
|
The minimum value.
|
|
216
262
|
|
|
217
|
-
|
|
263
|
+
##### maxValue?
|
|
264
|
+
|
|
265
|
+
`bigint`
|
|
218
266
|
|
|
219
267
|
The maximum value.
|
|
220
268
|
|
|
@@ -238,15 +286,21 @@ Check the option to see if it exists and is a boolean.
|
|
|
238
286
|
|
|
239
287
|
#### Parameters
|
|
240
288
|
|
|
241
|
-
|
|
289
|
+
##### optionName
|
|
290
|
+
|
|
291
|
+
`string`
|
|
242
292
|
|
|
243
293
|
The name of the option.
|
|
244
294
|
|
|
245
|
-
|
|
295
|
+
##### optionValue
|
|
246
296
|
|
|
247
297
|
The option value.
|
|
248
298
|
|
|
249
|
-
|
|
299
|
+
`undefined` | `string`
|
|
300
|
+
|
|
301
|
+
##### allowEnvVar
|
|
302
|
+
|
|
303
|
+
`boolean` = `true`
|
|
250
304
|
|
|
251
305
|
Allow the option to be read from an env var.
|
|
252
306
|
|
|
@@ -270,15 +324,21 @@ Check the option to see if it exists and is hex.
|
|
|
270
324
|
|
|
271
325
|
#### Parameters
|
|
272
326
|
|
|
273
|
-
|
|
327
|
+
##### optionName
|
|
328
|
+
|
|
329
|
+
`string`
|
|
274
330
|
|
|
275
331
|
The name of the option.
|
|
276
332
|
|
|
277
|
-
|
|
333
|
+
##### optionValue
|
|
278
334
|
|
|
279
335
|
The option value.
|
|
280
336
|
|
|
281
|
-
|
|
337
|
+
`undefined` | `string`
|
|
338
|
+
|
|
339
|
+
##### allowEnvVar
|
|
340
|
+
|
|
341
|
+
`boolean` = `true`
|
|
282
342
|
|
|
283
343
|
Allow the option to be read from an env var.
|
|
284
344
|
|
|
@@ -302,15 +362,21 @@ Check the option to see if it exists and is base64.
|
|
|
302
362
|
|
|
303
363
|
#### Parameters
|
|
304
364
|
|
|
305
|
-
|
|
365
|
+
##### optionName
|
|
366
|
+
|
|
367
|
+
`string`
|
|
306
368
|
|
|
307
369
|
The name of the option.
|
|
308
370
|
|
|
309
|
-
|
|
371
|
+
##### optionValue
|
|
310
372
|
|
|
311
373
|
The option value.
|
|
312
374
|
|
|
313
|
-
|
|
375
|
+
`undefined` | `string`
|
|
376
|
+
|
|
377
|
+
##### allowEnvVar
|
|
378
|
+
|
|
379
|
+
`boolean` = `true`
|
|
314
380
|
|
|
315
381
|
Allow the option to be read from an env var.
|
|
316
382
|
|
|
@@ -334,15 +400,21 @@ Check the option to see if it exists and is hex or base64.
|
|
|
334
400
|
|
|
335
401
|
#### Parameters
|
|
336
402
|
|
|
337
|
-
|
|
403
|
+
##### optionName
|
|
404
|
+
|
|
405
|
+
`string`
|
|
338
406
|
|
|
339
407
|
The name of the option.
|
|
340
408
|
|
|
341
|
-
|
|
409
|
+
##### optionValue
|
|
342
410
|
|
|
343
411
|
The option value.
|
|
344
412
|
|
|
345
|
-
|
|
413
|
+
`undefined` | `string`
|
|
414
|
+
|
|
415
|
+
##### allowEnvVar
|
|
416
|
+
|
|
417
|
+
`boolean` = `true`
|
|
346
418
|
|
|
347
419
|
Allow the option to be read from an env var.
|
|
348
420
|
|
|
@@ -366,15 +438,21 @@ Check the option to see if it exists and is bech32.
|
|
|
366
438
|
|
|
367
439
|
#### Parameters
|
|
368
440
|
|
|
369
|
-
|
|
441
|
+
##### optionName
|
|
442
|
+
|
|
443
|
+
`string`
|
|
370
444
|
|
|
371
445
|
The name of the option.
|
|
372
446
|
|
|
373
|
-
|
|
447
|
+
##### optionValue
|
|
374
448
|
|
|
375
449
|
The option value.
|
|
376
450
|
|
|
377
|
-
|
|
451
|
+
`undefined` | `string`
|
|
452
|
+
|
|
453
|
+
##### allowEnvVar
|
|
454
|
+
|
|
455
|
+
`boolean` = `true`
|
|
378
456
|
|
|
379
457
|
Allow the option to be read from an env var.
|
|
380
458
|
|
|
@@ -22,7 +22,9 @@ Does the specified file exist.
|
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### filename
|
|
26
|
+
|
|
27
|
+
`string`
|
|
26
28
|
|
|
27
29
|
The filename to check for existence.
|
|
28
30
|
|
|
@@ -42,7 +44,9 @@ Does the specified file exist, synchronously.
|
|
|
42
44
|
|
|
43
45
|
#### Parameters
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
##### filename
|
|
48
|
+
|
|
49
|
+
`string`
|
|
46
50
|
|
|
47
51
|
The filename to check for existence.
|
|
48
52
|
|
|
@@ -62,7 +66,9 @@ Check if the dir exists.
|
|
|
62
66
|
|
|
63
67
|
#### Parameters
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
##### dir
|
|
70
|
+
|
|
71
|
+
`string`
|
|
66
72
|
|
|
67
73
|
The directory to check.
|
|
68
74
|
|
|
@@ -82,7 +88,9 @@ Check if the dir exists, synchronously.
|
|
|
82
88
|
|
|
83
89
|
#### Parameters
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
##### dir
|
|
92
|
+
|
|
93
|
+
`string`
|
|
86
94
|
|
|
87
95
|
The directory to check.
|
|
88
96
|
|
|
@@ -106,7 +114,9 @@ Read a JSON file and parse it.
|
|
|
106
114
|
|
|
107
115
|
#### Parameters
|
|
108
116
|
|
|
109
|
-
|
|
117
|
+
##### filename
|
|
118
|
+
|
|
119
|
+
`string`
|
|
110
120
|
|
|
111
121
|
The filename to read.
|
|
112
122
|
|
|
@@ -130,7 +140,9 @@ Read a JSON file and parse it, synchronously.
|
|
|
130
140
|
|
|
131
141
|
#### Parameters
|
|
132
142
|
|
|
133
|
-
|
|
143
|
+
##### filename
|
|
144
|
+
|
|
145
|
+
`string`
|
|
134
146
|
|
|
135
147
|
The filename to read.
|
|
136
148
|
|
|
@@ -150,7 +162,9 @@ Read a file as lines.
|
|
|
150
162
|
|
|
151
163
|
#### Parameters
|
|
152
164
|
|
|
153
|
-
|
|
165
|
+
##### filename
|
|
166
|
+
|
|
167
|
+
`string`
|
|
154
168
|
|
|
155
169
|
The filename to read.
|
|
156
170
|
|
|
@@ -170,7 +184,9 @@ Read a file as lines, synchronously.
|
|
|
170
184
|
|
|
171
185
|
#### Parameters
|
|
172
186
|
|
|
173
|
-
|
|
187
|
+
##### filename
|
|
188
|
+
|
|
189
|
+
`string`
|
|
174
190
|
|
|
175
191
|
The filename to read.
|
|
176
192
|
|
|
@@ -190,7 +206,9 @@ Find the NPM root based on a package.json path.
|
|
|
190
206
|
|
|
191
207
|
#### Parameters
|
|
192
208
|
|
|
193
|
-
|
|
209
|
+
##### rootFolder
|
|
210
|
+
|
|
211
|
+
`string`
|
|
194
212
|
|
|
195
213
|
The path to the package.json.
|
|
196
214
|
|
|
@@ -204,21 +222,61 @@ The root path.
|
|
|
204
222
|
|
|
205
223
|
### runShellCmd()
|
|
206
224
|
|
|
207
|
-
> `static` **runShellCmd**(`
|
|
225
|
+
> `static` **runShellCmd**(`command`, `args`, `cwd`): `Promise`\<`void`\>
|
|
226
|
+
|
|
227
|
+
Run a shell command.
|
|
228
|
+
|
|
229
|
+
#### Parameters
|
|
230
|
+
|
|
231
|
+
##### command
|
|
232
|
+
|
|
233
|
+
`string`
|
|
234
|
+
|
|
235
|
+
The app to run in the shell.
|
|
236
|
+
|
|
237
|
+
##### args
|
|
238
|
+
|
|
239
|
+
`string`[]
|
|
240
|
+
|
|
241
|
+
The args for the app.
|
|
242
|
+
|
|
243
|
+
##### cwd
|
|
244
|
+
|
|
245
|
+
`string`
|
|
246
|
+
|
|
247
|
+
The working directory to execute the command in.
|
|
248
|
+
|
|
249
|
+
#### Returns
|
|
250
|
+
|
|
251
|
+
`Promise`\<`void`\>
|
|
252
|
+
|
|
253
|
+
Promise to wait for command execution to complete.
|
|
254
|
+
|
|
255
|
+
***
|
|
256
|
+
|
|
257
|
+
### runShellApp()
|
|
258
|
+
|
|
259
|
+
> `static` **runShellApp**(`app`, `args`, `cwd`): `Promise`\<`void`\>
|
|
208
260
|
|
|
209
261
|
Run a shell app.
|
|
210
262
|
|
|
211
263
|
#### Parameters
|
|
212
264
|
|
|
213
|
-
|
|
265
|
+
##### app
|
|
266
|
+
|
|
267
|
+
`string`
|
|
214
268
|
|
|
215
269
|
The app to run in the shell.
|
|
216
270
|
|
|
217
|
-
|
|
271
|
+
##### args
|
|
272
|
+
|
|
273
|
+
`string`[]
|
|
218
274
|
|
|
219
275
|
The args for the app.
|
|
220
276
|
|
|
221
|
-
|
|
277
|
+
##### cwd
|
|
278
|
+
|
|
279
|
+
`string`
|
|
222
280
|
|
|
223
281
|
The working directory to execute the command in.
|
|
224
282
|
|
|
@@ -242,15 +300,21 @@ Write a JSON file.
|
|
|
242
300
|
|
|
243
301
|
#### Parameters
|
|
244
302
|
|
|
245
|
-
|
|
303
|
+
##### jsonFilename
|
|
246
304
|
|
|
247
305
|
The filename to write.
|
|
248
306
|
|
|
249
|
-
|
|
307
|
+
`undefined` | `string`
|
|
308
|
+
|
|
309
|
+
##### data
|
|
310
|
+
|
|
311
|
+
`T`
|
|
250
312
|
|
|
251
313
|
The data to write.
|
|
252
314
|
|
|
253
|
-
|
|
315
|
+
##### append
|
|
316
|
+
|
|
317
|
+
`boolean`
|
|
254
318
|
|
|
255
319
|
Append to the file.
|
|
256
320
|
|
|
@@ -268,15 +332,21 @@ Write an env file.
|
|
|
268
332
|
|
|
269
333
|
#### Parameters
|
|
270
334
|
|
|
271
|
-
|
|
335
|
+
##### envFilename
|
|
272
336
|
|
|
273
337
|
The filename to write.
|
|
274
338
|
|
|
275
|
-
|
|
339
|
+
`undefined` | `string`
|
|
340
|
+
|
|
341
|
+
##### data
|
|
342
|
+
|
|
343
|
+
`string`[]
|
|
276
344
|
|
|
277
345
|
The data to write.
|
|
278
346
|
|
|
279
|
-
|
|
347
|
+
##### append
|
|
348
|
+
|
|
349
|
+
`boolean`
|
|
280
350
|
|
|
281
351
|
Append to the file.
|
|
282
352
|
|
|
@@ -6,15 +6,21 @@ Add the global options.
|
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### program
|
|
10
|
+
|
|
11
|
+
`Command`
|
|
10
12
|
|
|
11
13
|
The program to add the options to.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
### supportsLang
|
|
16
|
+
|
|
17
|
+
`boolean`
|
|
14
18
|
|
|
15
19
|
Whether the CLI supports different languages.
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
### supportsEnvFiles
|
|
22
|
+
|
|
23
|
+
`boolean`
|
|
18
24
|
|
|
19
25
|
Whether the CLI supports loading env files
|
|
20
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/cli-core",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.30",
|
|
4
4
|
"description": "Core classes for building a CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,50 +13,22 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"merge-locales": "copyfiles locales/en.json dist",
|
|
20
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
22
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
23
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
24
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
25
|
-
"docs:clean": "rimraf docs/reference",
|
|
26
|
-
"docs:generate": "typedoc",
|
|
27
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
28
|
-
"dist": "npm run clean && npm run build && npm run merge-locales && npm run test && npm run bundle && npm run docs"
|
|
29
|
-
},
|
|
30
16
|
"dependencies": {
|
|
31
|
-
"@twin.org/core": "0.0.1-next.
|
|
32
|
-
"@twin.org/crypto": "0.0.1-next.
|
|
17
|
+
"@twin.org/core": "0.0.1-next.30",
|
|
18
|
+
"@twin.org/crypto": "0.0.1-next.30",
|
|
33
19
|
"@twin.org/nameof": "next",
|
|
34
|
-
"chalk": "5.
|
|
35
|
-
"commander": "
|
|
36
|
-
"dotenv": "16.4.
|
|
37
|
-
},
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@twin.org/nameof-transformer": "next",
|
|
40
|
-
"@types/node": "22.5.5",
|
|
41
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
42
|
-
"copyfiles": "2.4.1",
|
|
43
|
-
"rimraf": "6.0.1",
|
|
44
|
-
"rollup": "4.21.3",
|
|
45
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
46
|
-
"ts-patch": "3.2.1",
|
|
47
|
-
"typedoc": "0.26.7",
|
|
48
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
49
|
-
"typescript": "5.6.2",
|
|
50
|
-
"vitest": "2.1.1"
|
|
20
|
+
"chalk": "5.4.1",
|
|
21
|
+
"commander": "13.1.0",
|
|
22
|
+
"dotenv": "16.4.7"
|
|
51
23
|
},
|
|
52
24
|
"main": "./dist/cjs/index.cjs",
|
|
53
25
|
"module": "./dist/esm/index.mjs",
|
|
54
26
|
"types": "./dist/types/index.d.ts",
|
|
55
27
|
"exports": {
|
|
56
28
|
".": {
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
57
30
|
"require": "./dist/cjs/index.cjs",
|
|
58
|
-
"import": "./dist/esm/index.mjs"
|
|
59
|
-
"types": "./dist/types/index.d.ts"
|
|
31
|
+
"import": "./dist/esm/index.mjs"
|
|
60
32
|
}
|
|
61
33
|
},
|
|
62
34
|
"files": [
|