@optique/inquirer 1.0.0-dev.1616 → 1.0.0-dev.1658
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/index.cjs +28 -2
- package/dist/index.js +28 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -316,6 +316,16 @@ function prompt(parser, config) {
|
|
|
316
316
|
}],
|
|
317
317
|
leadingNames: parser.leadingNames,
|
|
318
318
|
acceptingAnyToken: parser.acceptingAnyToken,
|
|
319
|
+
getSuggestRuntimeNodes(state, path) {
|
|
320
|
+
const innerState = isPromptBindState(state) ? state.cliState === void 0 ? parser.initialState : state.cliState : state;
|
|
321
|
+
const innerNodes = parser.getSuggestRuntimeNodes?.(innerState, path) ?? [];
|
|
322
|
+
if (promptedParser.dependencyMetadata?.source != null) return [{
|
|
323
|
+
path,
|
|
324
|
+
parser: promptedParser,
|
|
325
|
+
state
|
|
326
|
+
}, ...innerNodes];
|
|
327
|
+
return innerNodes;
|
|
328
|
+
},
|
|
319
329
|
get initialState() {
|
|
320
330
|
return new PromptBindInitialStateClass();
|
|
321
331
|
},
|
|
@@ -326,6 +336,7 @@ function prompt(parser, config) {
|
|
|
326
336
|
...context,
|
|
327
337
|
state: innerState
|
|
328
338
|
} : context;
|
|
339
|
+
const effectiveInnerState = annotations != null && innerState == null && Reflect.get(parser, inheritParentAnnotationsKey) === true ? (0, __optique_core_annotations.injectAnnotations)(innerState, annotations) : innerState;
|
|
329
340
|
const processResult = (result$1) => {
|
|
330
341
|
if (result$1.success) {
|
|
331
342
|
const cliConsumed = result$1.consumed.length > 0;
|
|
@@ -359,7 +370,7 @@ function prompt(parser, config) {
|
|
|
359
370
|
consumed: []
|
|
360
371
|
};
|
|
361
372
|
};
|
|
362
|
-
const result = withAnnotatedInnerState(context.state,
|
|
373
|
+
const result = withAnnotatedInnerState(context.state, effectiveInnerState, (annotatedInnerState) => {
|
|
363
374
|
const innerContext = annotatedInnerState !== context.state ? {
|
|
364
375
|
...context,
|
|
365
376
|
state: annotatedInnerState
|
|
@@ -448,7 +459,7 @@ function prompt(parser, config) {
|
|
|
448
459
|
return executePrompt();
|
|
449
460
|
},
|
|
450
461
|
suggest: (context, prefix) => {
|
|
451
|
-
const innerState = isPromptBindState(context.state) ? context.state.
|
|
462
|
+
const innerState = isPromptBindState(context.state) ? context.state.cliState === void 0 ? parser.initialState : context.state.cliState : context.state;
|
|
452
463
|
const innerContext = innerState !== context.state ? {
|
|
453
464
|
...context,
|
|
454
465
|
state: innerState
|
|
@@ -480,6 +491,21 @@ function prompt(parser, config) {
|
|
|
480
491
|
configurable: true,
|
|
481
492
|
enumerable: false
|
|
482
493
|
});
|
|
494
|
+
const dependencyMetadata = parser.dependencyMetadata;
|
|
495
|
+
if (dependencyMetadata != null) Object.defineProperty(promptedParser, "dependencyMetadata", {
|
|
496
|
+
value: dependencyMetadata.source == null ? dependencyMetadata : {
|
|
497
|
+
...dependencyMetadata,
|
|
498
|
+
source: {
|
|
499
|
+
...dependencyMetadata.source,
|
|
500
|
+
extractSourceValue: (state) => {
|
|
501
|
+
if (!isPromptBindState(state)) return dependencyMetadata.source?.extractSourceValue(state);
|
|
502
|
+
return dependencyMetadata.source?.extractSourceValue(state.cliState ?? state);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
configurable: true,
|
|
507
|
+
enumerable: false
|
|
508
|
+
});
|
|
483
509
|
return promptedParser;
|
|
484
510
|
}
|
|
485
511
|
/** Normalize choices to the format Inquirer.js expects. */
|
package/dist/index.js
CHANGED
|
@@ -293,6 +293,16 @@ function prompt(parser, config) {
|
|
|
293
293
|
}],
|
|
294
294
|
leadingNames: parser.leadingNames,
|
|
295
295
|
acceptingAnyToken: parser.acceptingAnyToken,
|
|
296
|
+
getSuggestRuntimeNodes(state, path) {
|
|
297
|
+
const innerState = isPromptBindState(state) ? state.cliState === void 0 ? parser.initialState : state.cliState : state;
|
|
298
|
+
const innerNodes = parser.getSuggestRuntimeNodes?.(innerState, path) ?? [];
|
|
299
|
+
if (promptedParser.dependencyMetadata?.source != null) return [{
|
|
300
|
+
path,
|
|
301
|
+
parser: promptedParser,
|
|
302
|
+
state
|
|
303
|
+
}, ...innerNodes];
|
|
304
|
+
return innerNodes;
|
|
305
|
+
},
|
|
296
306
|
get initialState() {
|
|
297
307
|
return new PromptBindInitialStateClass();
|
|
298
308
|
},
|
|
@@ -303,6 +313,7 @@ function prompt(parser, config) {
|
|
|
303
313
|
...context,
|
|
304
314
|
state: innerState
|
|
305
315
|
} : context;
|
|
316
|
+
const effectiveInnerState = annotations != null && innerState == null && Reflect.get(parser, inheritParentAnnotationsKey) === true ? injectAnnotations(innerState, annotations) : innerState;
|
|
306
317
|
const processResult = (result$1) => {
|
|
307
318
|
if (result$1.success) {
|
|
308
319
|
const cliConsumed = result$1.consumed.length > 0;
|
|
@@ -336,7 +347,7 @@ function prompt(parser, config) {
|
|
|
336
347
|
consumed: []
|
|
337
348
|
};
|
|
338
349
|
};
|
|
339
|
-
const result = withAnnotatedInnerState(context.state,
|
|
350
|
+
const result = withAnnotatedInnerState(context.state, effectiveInnerState, (annotatedInnerState) => {
|
|
340
351
|
const innerContext = annotatedInnerState !== context.state ? {
|
|
341
352
|
...context,
|
|
342
353
|
state: annotatedInnerState
|
|
@@ -425,7 +436,7 @@ function prompt(parser, config) {
|
|
|
425
436
|
return executePrompt();
|
|
426
437
|
},
|
|
427
438
|
suggest: (context, prefix) => {
|
|
428
|
-
const innerState = isPromptBindState(context.state) ? context.state.
|
|
439
|
+
const innerState = isPromptBindState(context.state) ? context.state.cliState === void 0 ? parser.initialState : context.state.cliState : context.state;
|
|
429
440
|
const innerContext = innerState !== context.state ? {
|
|
430
441
|
...context,
|
|
431
442
|
state: innerState
|
|
@@ -457,6 +468,21 @@ function prompt(parser, config) {
|
|
|
457
468
|
configurable: true,
|
|
458
469
|
enumerable: false
|
|
459
470
|
});
|
|
471
|
+
const dependencyMetadata = parser.dependencyMetadata;
|
|
472
|
+
if (dependencyMetadata != null) Object.defineProperty(promptedParser, "dependencyMetadata", {
|
|
473
|
+
value: dependencyMetadata.source == null ? dependencyMetadata : {
|
|
474
|
+
...dependencyMetadata,
|
|
475
|
+
source: {
|
|
476
|
+
...dependencyMetadata.source,
|
|
477
|
+
extractSourceValue: (state) => {
|
|
478
|
+
if (!isPromptBindState(state)) return dependencyMetadata.source?.extractSourceValue(state);
|
|
479
|
+
return dependencyMetadata.source?.extractSourceValue(state.cliState ?? state);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
configurable: true,
|
|
484
|
+
enumerable: false
|
|
485
|
+
});
|
|
460
486
|
return promptedParser;
|
|
461
487
|
}
|
|
462
488
|
/** Normalize choices to the format Inquirer.js expects. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/inquirer",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.1658+b57e115b",
|
|
4
4
|
"description": "Interactive prompt support for Optique via Inquirer.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@inquirer/prompts": "^8.3.0",
|
|
59
|
-
"@optique/core": "1.0.0-dev.
|
|
59
|
+
"@optique/core": "1.0.0-dev.1658+b57e115b"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^20.19.9",
|
|
63
63
|
"tsdown": "^0.13.0",
|
|
64
64
|
"typescript": "^5.8.3",
|
|
65
|
-
"@optique/env": "1.0.0-dev.
|
|
65
|
+
"@optique/env": "1.0.0-dev.1658+b57e115b"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsdown",
|