@pokit/prompter-clack 0.0.32 → 0.0.35
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/prompter.d.ts.map +1 -1
- package/dist/prompter.js +19 -1
- package/package.json +3 -3
- package/src/prompter.ts +23 -1
package/dist/prompter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompter.d.ts","sourceRoot":"","sources":["../src/prompter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"prompter.d.ts","sourceRoot":"","sources":["../src/prompter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,QAAQ,EAST,MAAM,aAAa,CAAC;AAqZrB;;GAEG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CA8FzC"}
|
package/dist/prompter.js
CHANGED
|
@@ -372,7 +372,25 @@ export function createPrompter() {
|
|
|
372
372
|
message: options.message,
|
|
373
373
|
placeholder: options.placeholder,
|
|
374
374
|
initialValue: options.initialValue,
|
|
375
|
-
validate: options.validate
|
|
375
|
+
validate: options.validate
|
|
376
|
+
? (value) => options.validate(value ?? '')
|
|
377
|
+
: undefined,
|
|
378
|
+
});
|
|
379
|
+
if (p.isCancel(result)) {
|
|
380
|
+
process.exit(0);
|
|
381
|
+
}
|
|
382
|
+
return result;
|
|
383
|
+
},
|
|
384
|
+
async autocomplete(options) {
|
|
385
|
+
const result = await p.autocomplete({
|
|
386
|
+
message: options.message,
|
|
387
|
+
options: options.options.map((opt) => ({
|
|
388
|
+
value: opt.value,
|
|
389
|
+
label: opt.label,
|
|
390
|
+
hint: opt.hint,
|
|
391
|
+
})),
|
|
392
|
+
placeholder: options.placeholder,
|
|
393
|
+
maxItems: options.maxItems,
|
|
376
394
|
});
|
|
377
395
|
if (p.isCancel(result)) {
|
|
378
396
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pokit/prompter-clack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "Clack-based prompter adapter for pok CLI applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@clack/prompts": "^0.
|
|
48
|
+
"@clack/prompts": "^1.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/bun": "latest"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@pokit/core": "0.0.
|
|
54
|
+
"@pokit/core": "0.0.35"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"bun": ">=1.0.0"
|
package/src/prompter.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
MultiselectOptions,
|
|
14
14
|
ConfirmOptions,
|
|
15
15
|
TextOptions,
|
|
16
|
+
AutocompleteOptions,
|
|
16
17
|
OptionsPage,
|
|
17
18
|
} from '@pokit/core';
|
|
18
19
|
import { isDynamicOptions } from '@pokit/core';
|
|
@@ -485,7 +486,9 @@ export function createPrompter(): Prompter {
|
|
|
485
486
|
message: options.message,
|
|
486
487
|
placeholder: options.placeholder,
|
|
487
488
|
initialValue: options.initialValue,
|
|
488
|
-
validate: options.validate
|
|
489
|
+
validate: options.validate
|
|
490
|
+
? (value: string | undefined) => options.validate!(value ?? '')
|
|
491
|
+
: undefined,
|
|
489
492
|
});
|
|
490
493
|
|
|
491
494
|
if (p.isCancel(result)) {
|
|
@@ -494,5 +497,24 @@ export function createPrompter(): Prompter {
|
|
|
494
497
|
|
|
495
498
|
return result;
|
|
496
499
|
},
|
|
500
|
+
|
|
501
|
+
async autocomplete<T>(options: AutocompleteOptions<T>): Promise<T> {
|
|
502
|
+
const result = await p.autocomplete({
|
|
503
|
+
message: options.message,
|
|
504
|
+
options: options.options.map((opt) => ({
|
|
505
|
+
value: opt.value,
|
|
506
|
+
label: opt.label,
|
|
507
|
+
hint: opt.hint,
|
|
508
|
+
})) as Parameters<typeof p.autocomplete>[0]['options'],
|
|
509
|
+
placeholder: options.placeholder,
|
|
510
|
+
maxItems: options.maxItems,
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
if (p.isCancel(result)) {
|
|
514
|
+
process.exit(0);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return result as T;
|
|
518
|
+
},
|
|
497
519
|
};
|
|
498
520
|
}
|