inquirerer 2.1.14 → 2.2.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/esm/prompt.js +17 -0
- package/package.json +2 -2
- package/prompt.d.ts +5 -0
- package/prompt.js +17 -0
- package/question/types.d.ts +1 -0
package/esm/prompt.js
CHANGED
|
@@ -346,6 +346,8 @@ export class Inquirerer {
|
|
|
346
346
|
let obj = shouldMutate ? argv : { ...argv };
|
|
347
347
|
// Resolve dynamic defaults before processing questions
|
|
348
348
|
await this.resolveDynamicDefaults(questions);
|
|
349
|
+
// Resolve dynamic options before processing questions
|
|
350
|
+
await this.resolveOptionsFrom(questions);
|
|
349
351
|
// Resolve setFrom values - these bypass prompting entirely
|
|
350
352
|
await this.resolveSetValues(questions, obj);
|
|
351
353
|
// first loop through the question, and set any overrides in case other questions use objs for validation
|
|
@@ -465,6 +467,21 @@ export class Inquirerer {
|
|
|
465
467
|
}
|
|
466
468
|
}
|
|
467
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Resolves optionsFrom values for all questions that have optionsFrom specified.
|
|
472
|
+
* Updates the question.options property with the resolved array.
|
|
473
|
+
*/
|
|
474
|
+
async resolveOptionsFrom(questions) {
|
|
475
|
+
for (const question of questions) {
|
|
476
|
+
if ('optionsFrom' in question && question.optionsFrom) {
|
|
477
|
+
const resolved = await this.resolverRegistry.resolve(question.optionsFrom);
|
|
478
|
+
if (resolved !== undefined && Array.isArray(resolved)) {
|
|
479
|
+
// Update question.options with resolved array
|
|
480
|
+
question.options = resolved;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
468
485
|
applyDefaultValues(questions, obj) {
|
|
469
486
|
questions.forEach(question => {
|
|
470
487
|
if ('default' in question) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inquirerer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "TypeScript-first library for building beautiful CLI interfaces with interactive prompts",
|
|
6
6
|
"main": "index.js",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"clean-ansi": "0.1.5",
|
|
42
42
|
"makage": "0.1.8"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "4daa10528afcb41fa99f6e94646ce40354121794"
|
|
45
45
|
}
|
package/prompt.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ export declare class Inquirerer {
|
|
|
75
75
|
* Sets the value directly in obj, bypassing the prompt entirely.
|
|
76
76
|
*/
|
|
77
77
|
private resolveSetValues;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves optionsFrom values for all questions that have optionsFrom specified.
|
|
80
|
+
* Updates the question.options property with the resolved array.
|
|
81
|
+
*/
|
|
82
|
+
private resolveOptionsFrom;
|
|
78
83
|
private applyDefaultValues;
|
|
79
84
|
private applyOverrides;
|
|
80
85
|
private handleOverrides;
|
package/prompt.js
CHANGED
|
@@ -353,6 +353,8 @@ class Inquirerer {
|
|
|
353
353
|
let obj = shouldMutate ? argv : { ...argv };
|
|
354
354
|
// Resolve dynamic defaults before processing questions
|
|
355
355
|
await this.resolveDynamicDefaults(questions);
|
|
356
|
+
// Resolve dynamic options before processing questions
|
|
357
|
+
await this.resolveOptionsFrom(questions);
|
|
356
358
|
// Resolve setFrom values - these bypass prompting entirely
|
|
357
359
|
await this.resolveSetValues(questions, obj);
|
|
358
360
|
// first loop through the question, and set any overrides in case other questions use objs for validation
|
|
@@ -472,6 +474,21 @@ class Inquirerer {
|
|
|
472
474
|
}
|
|
473
475
|
}
|
|
474
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Resolves optionsFrom values for all questions that have optionsFrom specified.
|
|
479
|
+
* Updates the question.options property with the resolved array.
|
|
480
|
+
*/
|
|
481
|
+
async resolveOptionsFrom(questions) {
|
|
482
|
+
for (const question of questions) {
|
|
483
|
+
if ('optionsFrom' in question && question.optionsFrom) {
|
|
484
|
+
const resolved = await this.resolverRegistry.resolve(question.optionsFrom);
|
|
485
|
+
if (resolved !== undefined && Array.isArray(resolved)) {
|
|
486
|
+
// Update question.options with resolved array
|
|
487
|
+
question.options = resolved;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
475
492
|
applyDefaultValues(questions, obj) {
|
|
476
493
|
questions.forEach(question => {
|
|
477
494
|
if ('default' in question) {
|