@pristine-ts/cli 2.0.17 → 2.0.18
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/lib/cjs/cli.configuration-keys.js +6 -0
- package/dist/lib/cjs/cli.configuration-keys.js.map +1 -1
- package/dist/lib/cjs/cli.module.js +13 -0
- package/dist/lib/cjs/cli.module.js.map +1 -1
- package/dist/lib/cjs/errors/cli-error-code.enum.js +10 -0
- package/dist/lib/cjs/errors/cli-error-code.enum.js.map +1 -1
- package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js +3 -0
- package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js +3 -0
- package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js +3 -0
- package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
- package/dist/lib/cjs/interfaces/interfaces.js +3 -0
- package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
- package/dist/lib/cjs/reporters/cli-error.reporter.js +11 -3
- package/dist/lib/cjs/reporters/cli-error.reporter.js.map +1 -1
- package/dist/lib/cjs/services/command-argument-error-formatter.js +146 -0
- package/dist/lib/cjs/services/command-argument-error-formatter.js.map +1 -0
- package/dist/lib/cjs/services/command-argument-resolver.js +1 -1
- package/dist/lib/cjs/services/command-argument-resolver.js.map +1 -1
- package/dist/lib/cjs/services/command-options-resolver.js +30 -37
- package/dist/lib/cjs/services/command-options-resolver.js.map +1 -1
- package/dist/lib/cjs/services/command-parameter-prompter.js +118 -38
- package/dist/lib/cjs/services/command-parameter-prompter.js.map +1 -1
- package/dist/lib/cjs/services/command-usage-renderer.js +81 -0
- package/dist/lib/cjs/services/command-usage-renderer.js.map +1 -0
- package/dist/lib/cjs/services/program-name-resolver.js +98 -0
- package/dist/lib/cjs/services/program-name-resolver.js.map +1 -0
- package/dist/lib/cjs/services/services.js +3 -0
- package/dist/lib/cjs/services/services.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/types/command-parameter-choices-list.type.js +3 -0
- package/dist/lib/cjs/types/command-parameter-choices-list.type.js.map +1 -0
- package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js +3 -0
- package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js.map +1 -0
- package/dist/lib/cjs/types/command-parameter-choices.type.js +3 -0
- package/dist/lib/cjs/types/command-parameter-choices.type.js.map +1 -0
- package/dist/lib/cjs/types/types.js +3 -0
- package/dist/lib/cjs/types/types.js.map +1 -1
- package/dist/lib/esm/cli.configuration-keys.js +6 -0
- package/dist/lib/esm/cli.configuration-keys.js.map +1 -1
- package/dist/lib/esm/cli.module.js +13 -0
- package/dist/lib/esm/cli.module.js.map +1 -1
- package/dist/lib/esm/errors/cli-error-code.enum.js +10 -0
- package/dist/lib/esm/errors/cli-error-code.enum.js.map +1 -1
- package/dist/lib/esm/interfaces/command-parameter-choice.interface.js +2 -0
- package/dist/lib/esm/interfaces/command-parameter-choice.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js +2 -0
- package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js +2 -0
- package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
- package/dist/lib/esm/interfaces/interfaces.js +3 -0
- package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
- package/dist/lib/esm/reporters/cli-error.reporter.js +11 -3
- package/dist/lib/esm/reporters/cli-error.reporter.js.map +1 -1
- package/dist/lib/esm/services/command-argument-error-formatter.js +143 -0
- package/dist/lib/esm/services/command-argument-error-formatter.js.map +1 -0
- package/dist/lib/esm/services/command-argument-resolver.js +1 -1
- package/dist/lib/esm/services/command-argument-resolver.js.map +1 -1
- package/dist/lib/esm/services/command-options-resolver.js +31 -38
- package/dist/lib/esm/services/command-options-resolver.js.map +1 -1
- package/dist/lib/esm/services/command-parameter-prompter.js +120 -40
- package/dist/lib/esm/services/command-parameter-prompter.js.map +1 -1
- package/dist/lib/esm/services/command-usage-renderer.js +78 -0
- package/dist/lib/esm/services/command-usage-renderer.js.map +1 -0
- package/dist/lib/esm/services/program-name-resolver.js +62 -0
- package/dist/lib/esm/services/program-name-resolver.js.map +1 -0
- package/dist/lib/esm/services/services.js +3 -0
- package/dist/lib/esm/services/services.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/types/command-parameter-choices-list.type.js +2 -0
- package/dist/lib/esm/types/command-parameter-choices-list.type.js.map +1 -0
- package/dist/lib/esm/types/command-parameter-choices-resolver.type.js +2 -0
- package/dist/lib/esm/types/command-parameter-choices-resolver.type.js.map +1 -0
- package/dist/lib/esm/types/command-parameter-choices.type.js +2 -0
- package/dist/lib/esm/types/command-parameter-choices.type.js.map +1 -0
- package/dist/lib/esm/types/types.js +3 -0
- package/dist/lib/esm/types/types.js.map +1 -1
- package/dist/types/cli.configuration-keys.d.ts +7 -0
- package/dist/types/errors/cli-error-code.enum.d.ts +10 -0
- package/dist/types/interfaces/command-parameter-choice.interface.d.ts +14 -0
- package/dist/types/interfaces/command-parameter-choices-context.interface.d.ts +17 -0
- package/dist/types/interfaces/command-parameter-choices-provider.interface.d.ts +20 -0
- package/dist/types/interfaces/interfaces.d.ts +3 -0
- package/dist/types/options/command-parameter.options.d.ts +30 -0
- package/dist/types/services/command-argument-error-formatter.d.ts +64 -0
- package/dist/types/services/command-options-resolver.d.ts +23 -13
- package/dist/types/services/command-parameter-prompter.d.ts +60 -31
- package/dist/types/services/command-usage-renderer.d.ts +35 -0
- package/dist/types/services/program-name-resolver.d.ts +21 -0
- package/dist/types/services/services.d.ts +3 -0
- package/dist/types/types/command-parameter-choices-list.type.d.ts +6 -0
- package/dist/types/types/command-parameter-choices-resolver.type.d.ts +9 -0
- package/dist/types/types/command-parameter-choices.type.d.ts +19 -0
- package/dist/types/types/types.d.ts +3 -0
- package/package.json +12 -12
|
@@ -37,34 +37,36 @@ const cli_decorator_metadata_keyname_enum_1 = require("../enums/cli-decorator-me
|
|
|
37
37
|
const cli_error_code_enum_1 = require("../errors/cli-error-code.enum");
|
|
38
38
|
const boolean_answer_parser_1 = require("../utils/boolean-answer-parser");
|
|
39
39
|
/**
|
|
40
|
-
* Applies a command's `@commandParameter` metadata to its raw, parsed arguments before they
|
|
41
|
-
*
|
|
40
|
+
* Applies a command's `@commandParameter` metadata to its raw, parsed arguments before they are
|
|
41
|
+
* mapped onto the options instance and validated. Two things happen here:
|
|
42
42
|
*
|
|
43
|
-
* 1. **Flag binding** — a parameter whose `flag` differs from its property name is copied
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* 2. **Interactive fill** — a parameter that is absent and declares a `question` is asked
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* validated through the same mapper/validator the command
|
|
50
|
-
* invalid answer. Gated by the `InteractiveParameters`
|
|
51
|
-
* an interactive terminal; otherwise the absent value is
|
|
43
|
+
* 1. **Flag binding** — a parameter whose `flag` differs from its property name is copied from
|
|
44
|
+
* the flag key onto the property key, so the by-property-name data mapper picks it up. Two
|
|
45
|
+
* parameters resolving to the same flag is a programming error and throws.
|
|
46
|
+
* 2. **Interactive fill** — a parameter that is absent and declares a `question` is asked for
|
|
47
|
+
* interactively. Values constrained to a set — an explicit `choices`, or an `@IsIn` /
|
|
48
|
+
* `@IsEnum` — are picked from an arrow-key menu; booleans answer `(y/n)`; everything else is
|
|
49
|
+
* a free-text answer coerced + validated through the same mapper/validator the command
|
|
50
|
+
* pipeline uses, re-asking on an invalid answer. Gated by the `InteractiveParameters`
|
|
51
|
+
* configuration and only run against an interactive terminal; otherwise the absent value is
|
|
52
|
+
* left for validation to report.
|
|
52
53
|
*
|
|
53
|
-
* Parameters without a `@commandParameter` decorator are untouched, so commands that don't
|
|
54
|
-
*
|
|
54
|
+
* Parameters without a `@commandParameter` decorator are untouched, so commands that don't use
|
|
55
|
+
* it pay nothing.
|
|
55
56
|
*/
|
|
56
57
|
let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParameterPrompter {
|
|
57
|
-
constructor(cliPrompt, cliOutput, validator, dataMapper, interactiveParametersEnabled) {
|
|
58
|
+
constructor(cliPrompt, cliOutput, validator, dataMapper, interactiveParametersEnabled, container) {
|
|
58
59
|
this.cliPrompt = cliPrompt;
|
|
59
60
|
this.cliOutput = cliOutput;
|
|
60
61
|
this.validator = validator;
|
|
61
62
|
this.dataMapper = dataMapper;
|
|
62
63
|
this.interactiveParametersEnabled = interactiveParametersEnabled;
|
|
64
|
+
this.container = container;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* Returns a copy of `rawArgs` with aliased flags bound to their property and any missing,
|
|
66
|
-
* question-carrying parameters filled in interactively. The input object is never mutated
|
|
67
|
-
*
|
|
68
|
+
* question-carrying parameters filled in interactively. The input object is never mutated —
|
|
69
|
+
* the original command event payload stays intact.
|
|
68
70
|
*/
|
|
69
71
|
fillMissingParameters(optionsType, rawArgs) {
|
|
70
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -88,7 +90,7 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
88
90
|
if (this.interactiveParametersEnabled !== true || this.isInputInteractive() === false) {
|
|
89
91
|
continue;
|
|
90
92
|
}
|
|
91
|
-
const value = yield this.promptForValue(optionsType, propertyKey, options);
|
|
93
|
+
const value = yield this.promptForValue(optionsType, propertyKey, flag, options, args);
|
|
92
94
|
if (value !== undefined) {
|
|
93
95
|
args[propertyKey] = value;
|
|
94
96
|
}
|
|
@@ -97,8 +99,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
/**
|
|
100
|
-
* Reads every `@commandParameter` off `optionsType`, resolving each to its effective flag
|
|
101
|
-
*
|
|
102
|
+
* Reads every `@commandParameter` off `optionsType`, resolving each to its effective flag and
|
|
103
|
+
* detecting two parameters that would claim the same flag (a programming error).
|
|
102
104
|
* @private
|
|
103
105
|
*/
|
|
104
106
|
collectParameters(optionsType) {
|
|
@@ -125,35 +127,43 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
125
127
|
return parameters;
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
|
-
* Asks for a single parameter's value, rendering and validating it according to the
|
|
129
|
-
*
|
|
130
|
+
* Asks for a single parameter's value, rendering and validating it according to the property's
|
|
131
|
+
* declared type:
|
|
130
132
|
*
|
|
131
133
|
* - sensitive values are read with the input masked and never trimmed;
|
|
134
|
+
* - a constrained value (explicit `choices`, or `@IsIn` / `@IsEnum`) is picked from an
|
|
135
|
+
* arrow-key menu, then coerced + validated like any typed value;
|
|
132
136
|
* - booleans render as `(y/n)` and accept y/yes/true/1 & n/no/false/0;
|
|
133
|
-
* - enum-constrained values (`@IsIn` / `@IsEnum`) list their choices;
|
|
134
137
|
* - every other answer is coerced (via the data mapper) and validated (via the validator)
|
|
135
138
|
* exactly as a typed flag would be, re-asking with the real constraint message when it
|
|
136
139
|
* doesn't pass.
|
|
137
140
|
*
|
|
138
|
-
* Returns the coerced value, or `undefined` when the user enters nothing or the attempt
|
|
139
|
-
*
|
|
141
|
+
* Returns the coerced value, or `undefined` when the user enters nothing or the attempt budget
|
|
142
|
+
* is exhausted — in which case the absent value falls through to validation.
|
|
140
143
|
* @private
|
|
141
144
|
*/
|
|
142
|
-
promptForValue(optionsType, propertyKey, options) {
|
|
145
|
+
promptForValue(optionsType, propertyKey, flag, options, args) {
|
|
143
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
147
|
var _a, _b;
|
|
145
148
|
const sensitive = options.sensitive === true;
|
|
146
149
|
const isBoolean = sensitive === false && Reflect.getMetadata("design:type", optionsType.prototype, propertyKey) === Boolean;
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
// A constrained value is selected from an arrow-key menu, then coerced + validated the same
|
|
151
|
+
// way a typed flag would be. Secrets and booleans are never menus.
|
|
152
|
+
const menu = (sensitive || isBoolean) ? undefined : yield this.resolveChoices(optionsType, propertyKey, flag, options, args);
|
|
153
|
+
if (menu !== undefined) {
|
|
154
|
+
const selected = yield this.cliPrompt.select(this.menuMessage(options.question, flag), menu);
|
|
155
|
+
const outcome = yield this.coerceAndValidate(optionsType, propertyKey, selected);
|
|
156
|
+
return outcome.valid ? outcome.value : selected;
|
|
157
|
+
}
|
|
158
|
+
const prompt = this.formatQuestion(this.decorateQuestion((_a = options.question) !== null && _a !== void 0 ? _a : "", isBoolean, undefined));
|
|
149
159
|
for (let attempt = 0; attempt < CommandParameterPrompter_1.MaxAttempts; attempt++) {
|
|
150
160
|
// Secrets go through the masked reader and are never trimmed (a password may legitimately
|
|
151
161
|
// contain surrounding whitespace); ordinary answers are trimmed.
|
|
152
162
|
const raw = sensitive
|
|
153
163
|
? yield this.cliPrompt.readSecret(prompt)
|
|
154
164
|
: (yield this.cliPrompt.readLine(prompt)).trim();
|
|
155
|
-
// Nothing entered → leave the value unset so validation reports it (and a required
|
|
156
|
-
//
|
|
165
|
+
// Nothing entered → leave the value unset so validation reports it (and a required field
|
|
166
|
+
// surfaces the same way it would have without a prompt).
|
|
157
167
|
if (raw.length === 0) {
|
|
158
168
|
return undefined;
|
|
159
169
|
}
|
|
@@ -177,6 +187,76 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
177
187
|
return undefined;
|
|
178
188
|
});
|
|
179
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Resolves this parameter's selectable choices to a `{name, value}[]` menu, or `undefined`
|
|
192
|
+
* when it has none (free-text). Sources, in order: an explicit `@commandParameter({choices})`
|
|
193
|
+
* — a static list, a resolver function, or a DI provider class — else the `@IsIn` / `@IsEnum`
|
|
194
|
+
* set. An empty result is treated as "no menu".
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
resolveChoices(optionsType, propertyKey, flag, options, args) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
const list = yield this.resolveChoicesList(optionsType, propertyKey, flag, options, args);
|
|
200
|
+
if (list === undefined || list.length === 0) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
return list.map((choice) => typeof choice === "string" ? { name: choice, value: choice } : { name: choice.name, value: choice.value });
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The raw choices list from the declared `choices` (static array / resolver function / DI
|
|
208
|
+
* provider class), falling back to the enum/`@IsIn` set when none is declared. Dynamic
|
|
209
|
+
* resolution failures degrade to free-text rather than crashing the prompt.
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
resolveChoicesList(optionsType, propertyKey, flag, options, args) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const declared = options.choices;
|
|
215
|
+
// No explicit choices → the enum/`@IsIn` set (back-compat), which now drives a menu rather
|
|
216
|
+
// than a `(a/b/c)` text hint.
|
|
217
|
+
if (declared === undefined) {
|
|
218
|
+
return this.getChoices(optionsType, propertyKey);
|
|
219
|
+
}
|
|
220
|
+
if (Array.isArray(declared)) {
|
|
221
|
+
return declared;
|
|
222
|
+
}
|
|
223
|
+
const context = { args, propertyKey, flag };
|
|
224
|
+
try {
|
|
225
|
+
// A class constructor (DI provider) is distinguishable from a plain resolver function by
|
|
226
|
+
// its prototype carrying `getChoices`.
|
|
227
|
+
if (this.isChoicesProviderClass(declared)) {
|
|
228
|
+
// ── container.resolve, justified ───────────────────────────────────────────────────
|
|
229
|
+
// The provider class is named on the `@commandParameter` decorator at definition time;
|
|
230
|
+
// only at prompt time can we turn it into an instance (so it can inject a FileManager,
|
|
231
|
+
// HttpClient, …). Mirrors HelpCommand's late command resolution — the child container is
|
|
232
|
+
// constructor-injected, only the instantiation is deferred.
|
|
233
|
+
const provider = this.container.resolve(declared);
|
|
234
|
+
return yield provider.getChoices(context);
|
|
235
|
+
}
|
|
236
|
+
return yield declared(context);
|
|
237
|
+
}
|
|
238
|
+
catch (_a) {
|
|
239
|
+
this.cliOutput.writeLine(`Could not load choices for '${flag}'; enter the value directly.`);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Whether `candidate` is a provider *class* (vs a plain resolver function): a class carries a
|
|
246
|
+
* prototype with a `getChoices` method; an arrow/plain resolver does not.
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
249
|
+
isChoicesProviderClass(candidate) {
|
|
250
|
+
return typeof candidate === "function" && candidate.prototype != null && typeof candidate.prototype.getChoices === "function";
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The menu heading: the parameter's `question` when set, else a neutral `Select <flag>`.
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
menuMessage(question, flag) {
|
|
257
|
+
const text = (question !== null && question !== void 0 ? question : "").trim();
|
|
258
|
+
return text.length > 0 ? text : `Select ${flag}`;
|
|
259
|
+
}
|
|
180
260
|
/**
|
|
181
261
|
* Maps a single raw answer onto a probe instance of `optionsType` and validates just that
|
|
182
262
|
* property, returning the coerced value when it passes or the constraint messages when it
|
|
@@ -202,10 +282,9 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
202
282
|
});
|
|
203
283
|
}
|
|
204
284
|
/**
|
|
205
|
-
* Flattens `class-validator`'s per-property constraint objects into plain, user-facing
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* `[object Object]`.
|
|
285
|
+
* Flattens `class-validator`'s per-property constraint objects into plain, user-facing lines.
|
|
286
|
+
* `@pristine-ts/class-validator` stores each constraint as `{keyname, message}` rather than a
|
|
287
|
+
* bare string, so prefer `.message`, falling back so we never print `[object Object]`.
|
|
209
288
|
* @private
|
|
210
289
|
*/
|
|
211
290
|
describeErrors(errors) {
|
|
@@ -226,8 +305,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
226
305
|
/**
|
|
227
306
|
* The allowed values declared by an `@IsIn([...])` or `@IsEnum(Enum)` on the property, for
|
|
228
307
|
* display in the prompt. Reads `@pristine-ts/class-validator`'s stored validator instances
|
|
229
|
-
* defensively — any shape mismatch just yields no menu (validation still rejects bad input
|
|
230
|
-
*
|
|
308
|
+
* defensively — any shape mismatch just yields no menu (validation still rejects bad input and
|
|
309
|
+
* re-asks). Returns undefined when the property isn't enum-constrained.
|
|
231
310
|
* @private
|
|
232
311
|
*/
|
|
233
312
|
getChoices(optionsType, propertyKey) {
|
|
@@ -278,8 +357,8 @@ let CommandParameterPrompter = CommandParameterPrompter_1 = class CommandParamet
|
|
|
278
357
|
return process.stdin.isTTY === true;
|
|
279
358
|
}
|
|
280
359
|
/**
|
|
281
|
-
* Ensures the rendered question ends with a trailing space so the typed answer doesn't butt
|
|
282
|
-
*
|
|
360
|
+
* Ensures the rendered question ends with a trailing space so the typed answer doesn't butt up
|
|
361
|
+
* against the prompt text.
|
|
283
362
|
* @private
|
|
284
363
|
*/
|
|
285
364
|
formatQuestion(question) {
|
|
@@ -303,9 +382,10 @@ exports.CommandParameterPrompter = CommandParameterPrompter = CommandParameterPr
|
|
|
303
382
|
(0, tsyringe_1.injectable)(),
|
|
304
383
|
(0, common_1.moduleScoped)(cli_module_keyname_1.CliModuleKeyname),
|
|
305
384
|
__param(4, (0, common_1.injectConfig)(cli_configuration_keys_1.CliConfigurationKeys.InteractiveParameters)),
|
|
385
|
+
__param(5, (0, tsyringe_1.inject)(common_1.ServiceDefinitionTagEnum.CurrentChildContainer)),
|
|
306
386
|
__metadata("design:paramtypes", [cli_prompt_manager_1.CliPrompt,
|
|
307
387
|
cli_output_manager_1.CliOutput,
|
|
308
388
|
class_validator_1.Validator,
|
|
309
|
-
data_mapping_1.DataMapper, Boolean])
|
|
389
|
+
data_mapping_1.DataMapper, Boolean, Object])
|
|
310
390
|
], CommandParameterPrompter);
|
|
311
391
|
//# sourceMappingURL=command-parameter-prompter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-parameter-prompter.js","sourceRoot":"","sources":["../../../../src/services/command-parameter-prompter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"command-parameter-prompter.js","sourceRoot":"","sources":["../../../../src/services/command-parameter-prompter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,uCAAiE;AAEjE,gDAAqG;AACrG,oDAAsE;AACtE,kEAAuD;AACvD,4DAAoF;AACpF,8DAAuD;AACvD,sEAA+D;AAC/D,uEAAyD;AACzD,uEAAyD;AACzD,sGAA6F;AAE7F,uEAA2D;AAC3D,0EAAmE;AAMnE;;;;;;;;;;;;;;;;;GAiBG;AAGI,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAenC,YACmB,SAAoB,EACpB,SAAoB,EACpB,SAAoB,EACpB,UAAsB,EACoC,4BAAqC,EAIvC,SAA8B;QARtF,cAAS,GAAT,SAAS,CAAW;QACpB,cAAS,GAAT,SAAS,CAAW;QACpB,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAY;QACoC,iCAA4B,GAA5B,4BAA4B,CAAS;QAIvC,cAAS,GAAT,SAAS,CAAqB;IAEzG,CAAC;IAED;;;;OAIG;IACG,qBAAqB,CAAC,WAAkC,EAAE,OAA4B;;YAC1F,MAAM,IAAI,qBAA4B,OAAO,CAAC,CAAC;YAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACvD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;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I,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,QAAgB;QACrC,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IAC5D,CAAC;;AApWU,4DAAwB;AACnC;;;;GAIG;AACqB,kDAAyB,GAAG,8BAA8B,AAAjC,CAAkC;AAEnF;;;;GAIG;AACqB,oCAAW,GAAG,CAAC,AAAJ,CAAK;mCAb7B,wBAAwB;IAFpC,IAAA,qBAAU,GAAE;IACZ,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAqB1B,WAAA,IAAA,qBAAY,EAAC,6CAAoB,CAAC,qBAAqB,CAAC,CAAA;IAIxD,WAAA,IAAA,iBAAM,EAAC,iCAAwB,CAAC,qBAAqB,CAAC,CAAA;qCAR3B,8BAAS;QACT,8BAAS;QACT,2BAAS;QACR,yBAAU;GAnB9B,wBAAwB,CAqWpC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var CommandUsageRenderer_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CommandUsageRenderer = void 0;
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const tsyringe_1 = require("tsyringe");
|
|
13
|
+
const common_1 = require("@pristine-ts/common");
|
|
14
|
+
const metadata_1 = require("@pristine-ts/metadata");
|
|
15
|
+
const cli_module_keyname_1 = require("../cli.module.keyname");
|
|
16
|
+
const cli_decorator_metadata_keyname_enum_1 = require("../enums/cli-decorator-metadata-keyname.enum");
|
|
17
|
+
/**
|
|
18
|
+
* Builds the one-line `Usage:` synopsis for a command from its options class, e.g.
|
|
19
|
+
*
|
|
20
|
+
* Usage: myapp key:add --name=<name> [--pubkey=<key-or-file>] [--rotate]
|
|
21
|
+
*
|
|
22
|
+
* Every declared option property becomes a token: required values render as `--flag=<hint>`,
|
|
23
|
+
* optional values as `[--flag=<hint>]`, and booleans as `[--flag]` (presence flags take no
|
|
24
|
+
* value). The placeholder defaults to the property name and can be overridden per parameter
|
|
25
|
+
* with `@commandParameter({valueHint})`; the flag honors `@commandParameter({flag})`.
|
|
26
|
+
*
|
|
27
|
+
* "Required" means the absence of an `@IsOptional()` condition on the property — the same
|
|
28
|
+
* signal the validator uses to decide whether a missing value is an error.
|
|
29
|
+
*/
|
|
30
|
+
let CommandUsageRenderer = CommandUsageRenderer_1 = class CommandUsageRenderer {
|
|
31
|
+
/**
|
|
32
|
+
* Renders `Usage: <bin> <command> <tokens…>`. `binName` is the resolved program name (see
|
|
33
|
+
* `ProgramNameResolver`); `commandName` is the command's `name`.
|
|
34
|
+
*/
|
|
35
|
+
render(optionsType, commandName, binName) {
|
|
36
|
+
const tokens = this.collectTokens(optionsType);
|
|
37
|
+
const synopsis = [binName, commandName, ...tokens].filter((part) => part.length > 0).join(" ");
|
|
38
|
+
return `Usage: ${synopsis}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One synopsis token per declared option property, in declaration order.
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
collectTokens(optionsType) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const properties = metadata_1.ClassMetadata.getInformation(optionsType).properties;
|
|
47
|
+
const tokens = [];
|
|
48
|
+
for (const propertyKey of properties) {
|
|
49
|
+
const options = metadata_1.PropertyMetadata.getMetadata(optionsType.prototype, propertyKey, cli_decorator_metadata_keyname_enum_1.CliDecoratorMetadataKeynameEnum.CommandParameter);
|
|
50
|
+
const flag = (_a = options === null || options === void 0 ? void 0 : options.flag) !== null && _a !== void 0 ? _a : propertyKey;
|
|
51
|
+
// Booleans are presence flags — they never take a value.
|
|
52
|
+
if (Reflect.getMetadata("design:type", optionsType.prototype, propertyKey) === Boolean) {
|
|
53
|
+
tokens.push(`[--${flag}]`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const body = `--${flag}=<${(_b = options === null || options === void 0 ? void 0 : options.valueHint) !== null && _b !== void 0 ? _b : propertyKey}>`;
|
|
57
|
+
tokens.push(this.isRequired(optionsType, propertyKey) ? body : `[${body}]`);
|
|
58
|
+
}
|
|
59
|
+
return tokens;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A property is required unless it carries an `@IsOptional()` condition. Read defensively: an
|
|
63
|
+
* unexpected metadata shape is treated as required (the safer default for a usage hint).
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
isRequired(optionsType, propertyKey) {
|
|
67
|
+
const conditions = metadata_1.PropertyMetadata.getMetadata(optionsType.prototype, propertyKey, CommandUsageRenderer_1.ConditionMetadataKey);
|
|
68
|
+
if (Array.isArray(conditions) === false) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
return conditions.some((condition) => { var _a; return ((_a = condition === null || condition === void 0 ? void 0 : condition.constructor) === null || _a === void 0 ? void 0 : _a.name) === "IsOptionalCondition"; }) === false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.CommandUsageRenderer = CommandUsageRenderer;
|
|
75
|
+
/** `@pristine-ts/class-validator` stores each `@IsOptional()` as a condition here. */
|
|
76
|
+
CommandUsageRenderer.ConditionMetadataKey = "pristine-validator:condition";
|
|
77
|
+
exports.CommandUsageRenderer = CommandUsageRenderer = CommandUsageRenderer_1 = __decorate([
|
|
78
|
+
(0, tsyringe_1.injectable)(),
|
|
79
|
+
(0, common_1.moduleScoped)(cli_module_keyname_1.CliModuleKeyname)
|
|
80
|
+
], CommandUsageRenderer);
|
|
81
|
+
//# sourceMappingURL=command-usage-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-usage-renderer.js","sourceRoot":"","sources":["../../../../src/services/command-usage-renderer.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,4BAA0B;AAC1B,uCAAoC;AAEpC,gDAAiD;AACjD,oDAAsE;AACtE,8DAAuD;AACvD,sGAA6F;AAG7F;;;;;;;;;;;;GAYG;AAGI,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAI/B;;;OAGG;IACH,MAAM,CAAC,WAAkC,EAAE,WAAmB,EAAE,OAAe;QAC7E,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/F,OAAO,UAAU,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,WAAkC;;QACtD,MAAM,UAAU,GAAG,wBAAa,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC;QACxE,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE,CAAC;YACrC,MAAM,OAAO,GAAwC,2BAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,qEAA+B,CAAC,gBAAgB,CAAC,CAAC;YACxK,MAAM,IAAI,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mC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@@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var ProgramNameResolver_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.ProgramNameResolver = void 0;
|
|
50
|
+
const tsyringe_1 = require("tsyringe");
|
|
51
|
+
const common_1 = require("@pristine-ts/common");
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const cli_module_keyname_1 = require("../cli.module.keyname");
|
|
54
|
+
const cli_configuration_keys_1 = require("../cli.configuration-keys");
|
|
55
|
+
/**
|
|
56
|
+
* Resolves the program name shown in generated `Usage:` lines — the name the user actually
|
|
57
|
+
* typed, e.g. `myapp`, not the framework's `pristine`. Resolution is a hybrid, in priority
|
|
58
|
+
* order:
|
|
59
|
+
*
|
|
60
|
+
* 1. the `pristine.cli.binName` configuration, when set (an explicit override for odd launch
|
|
61
|
+
* shapes like `node dist/bin/cli.cjs`, where argv carries a file name);
|
|
62
|
+
* 2. otherwise `basename(argv[1])` with any `.cjs`/`.js`/`.mjs` extension stripped — the bin
|
|
63
|
+
* the user invoked, robust across global installs, `npx`, and local `.bin` shims;
|
|
64
|
+
* 3. otherwise the framework default `pristine`.
|
|
65
|
+
*/
|
|
66
|
+
let ProgramNameResolver = ProgramNameResolver_1 = class ProgramNameResolver {
|
|
67
|
+
constructor(configuredBinName) {
|
|
68
|
+
this.configuredBinName = configuredBinName;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the resolved program name. `argv` defaults to `process.argv`; it is a parameter so
|
|
72
|
+
* the REPL (and tests) can resolve a name from a synthetic argv.
|
|
73
|
+
*/
|
|
74
|
+
resolve(argv = process.argv) {
|
|
75
|
+
var _a;
|
|
76
|
+
const configured = (_a = this.configuredBinName) === null || _a === void 0 ? void 0 : _a.trim();
|
|
77
|
+
if (configured) {
|
|
78
|
+
return configured;
|
|
79
|
+
}
|
|
80
|
+
const scriptPath = argv[1];
|
|
81
|
+
if (typeof scriptPath === "string" && scriptPath.length > 0) {
|
|
82
|
+
const base = path.basename(scriptPath, path.extname(scriptPath));
|
|
83
|
+
if (base.length > 0) {
|
|
84
|
+
return base;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return ProgramNameResolver_1.Fallback;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.ProgramNameResolver = ProgramNameResolver;
|
|
91
|
+
ProgramNameResolver.Fallback = "pristine";
|
|
92
|
+
exports.ProgramNameResolver = ProgramNameResolver = ProgramNameResolver_1 = __decorate([
|
|
93
|
+
(0, tsyringe_1.injectable)(),
|
|
94
|
+
(0, common_1.moduleScoped)(cli_module_keyname_1.CliModuleKeyname),
|
|
95
|
+
__param(0, (0, common_1.injectConfig)(cli_configuration_keys_1.CliConfigurationKeys.BinName)),
|
|
96
|
+
__metadata("design:paramtypes", [String])
|
|
97
|
+
], ProgramNameResolver);
|
|
98
|
+
//# sourceMappingURL=program-name-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-name-resolver.js","sourceRoot":"","sources":["../../../../src/services/program-name-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,gDAA+D;AAC/D,2CAA6B;AAC7B,8DAAuD;AACvD,sEAA+D;AAE/D;;;;;;;;;;GAUG;AAGI,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAG9B,YAC+D,iBAAyB;QAAzB,sBAAiB,GAAjB,iBAAiB,CAAQ;IAExF,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,OAA0B,OAAO,CAAC,IAAI;;QAC5C,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,iBAAiB,0CAAE,IAAI,EAAE,CAAC;QAClD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YACjE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,qBAAmB,CAAC,QAAQ,CAAC;IACtC,CAAC;;AA3BU,kDAAmB;AACN,4BAAQ,GAAG,UAAU,AAAb,CAAc;8BADnC,mBAAmB;IAF/B,IAAA,qBAAU,GAAE;IACZ,IAAA,qBAAY,EAAC,qCAAgB,CAAC;IAK1B,WAAA,IAAA,qBAAY,EAAC,6CAAoB,CAAC,OAAO,CAAC,CAAA;;GAJlC,mBAAmB,CA4B/B"}
|
|
@@ -14,7 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./command-argument-error-formatter"), exports);
|
|
17
18
|
__exportStar(require("./command-argument-resolver"), exports);
|
|
18
19
|
__exportStar(require("./command-options-resolver"), exports);
|
|
19
20
|
__exportStar(require("./command-parameter-prompter"), exports);
|
|
21
|
+
__exportStar(require("./command-usage-renderer"), exports);
|
|
22
|
+
__exportStar(require("./program-name-resolver"), exports);
|
|
20
23
|
//# sourceMappingURL=services.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,6DAA2C;AAC3C,+DAA6C"}
|
|
1
|
+
{"version":3,"file":"services.js","sourceRoot":"","sources":["../../../../src/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAmD;AACnD,8DAA4C;AAC5C,6DAA2C;AAC3C,+DAA6C;AAC7C,2DAAyC;AACzC,0DAAwC"}
|