@hot-updater/cli-tools 0.35.7 → 0.35.9
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.d.mts +865 -38
- package/dist/index.mjs +2377 -1501
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -296,6 +296,20 @@ declare const createHotUpdaterConfigScaffoldFromBuilder: (builder: ConfigBuilder
|
|
|
296
296
|
}?: CreateHotUpdaterConfigScaffoldFromBuilderOptions) => HotUpdaterConfigScaffold;
|
|
297
297
|
declare const writeHotUpdaterConfig: (scaffold: HotUpdaterConfigScaffold, filePath?: string) => Promise<WriteHotUpdaterConfigResult>;
|
|
298
298
|
//#endregion
|
|
299
|
+
//#region src/hotUpdaterEnv.d.ts
|
|
300
|
+
type HotUpdaterInitEnv = {
|
|
301
|
+
readonly env: Readonly<Record<string, string>>;
|
|
302
|
+
readonly inputEnv?: Readonly<Record<string, string>>;
|
|
303
|
+
readonly managedEnv: Readonly<Record<string, string>>;
|
|
304
|
+
};
|
|
305
|
+
declare const getHotUpdaterInitInputEnv: ({
|
|
306
|
+
env,
|
|
307
|
+
managedEnv
|
|
308
|
+
}: HotUpdaterInitEnv, nonInteractive: boolean) => Readonly<Record<string, string>>;
|
|
309
|
+
declare const readHotUpdaterInitEnv: (cwd: string, envFile?: string) => Promise<HotUpdaterInitEnv>;
|
|
310
|
+
declare const readHotUpdaterEnv: (cwd: string) => Promise<Readonly<Record<string, string>>>;
|
|
311
|
+
declare const getHotUpdaterEnvValue: (env: Readonly<Record<string, string>>, key: string) => string | undefined;
|
|
312
|
+
//#endregion
|
|
299
313
|
//#region src/HotUpdateDirUtil.d.ts
|
|
300
314
|
declare const HotUpdateDirUtil: {
|
|
301
315
|
readonly dirName: ".hot-updater";
|
|
@@ -320,6 +334,113 @@ declare const HotUpdateDirUtil: {
|
|
|
320
334
|
}) => string;
|
|
321
335
|
};
|
|
322
336
|
//#endregion
|
|
337
|
+
//#region src/initProvider.d.ts
|
|
338
|
+
type InitProviderInputPersistence = "always" | "with-consent";
|
|
339
|
+
type InitProviderInputDefinition = {
|
|
340
|
+
readonly envKey: string;
|
|
341
|
+
readonly help: string;
|
|
342
|
+
readonly optional?: boolean;
|
|
343
|
+
readonly persistence?: InitProviderInputPersistence;
|
|
344
|
+
readonly preflight?: boolean;
|
|
345
|
+
readonly prompt?: {
|
|
346
|
+
readonly defaultValue?: string;
|
|
347
|
+
readonly message: string;
|
|
348
|
+
readonly placeholder?: string;
|
|
349
|
+
readonly type: "confirm" | "password" | "select" | "text";
|
|
350
|
+
};
|
|
351
|
+
readonly requiredWhen?: (inputs: Readonly<Record<string, string | undefined>>) => boolean;
|
|
352
|
+
readonly requirementHint?: string;
|
|
353
|
+
readonly validate?: (value: string | undefined) => boolean;
|
|
354
|
+
};
|
|
355
|
+
type InitProviderTextPromptDefinition = {
|
|
356
|
+
readonly defaultValue?: string;
|
|
357
|
+
readonly message: string;
|
|
358
|
+
readonly placeholder?: string;
|
|
359
|
+
readonly type: "text";
|
|
360
|
+
};
|
|
361
|
+
type InitProviderInputsDefinition = Readonly<Record<string, InitProviderInputDefinition>>;
|
|
362
|
+
type InitProviderDefinition<TInputs extends InitProviderInputsDefinition = InitProviderInputsDefinition> = {
|
|
363
|
+
readonly inputs: TInputs;
|
|
364
|
+
readonly label: string;
|
|
365
|
+
};
|
|
366
|
+
declare const defineInitProvider: <const TInputs extends InitProviderInputsDefinition>(provider: InitProviderDefinition<TInputs>) => InitProviderDefinition<TInputs>;
|
|
367
|
+
declare const shouldAutoSelectOnlyInitResource: ({
|
|
368
|
+
availableResourceCount,
|
|
369
|
+
savedIdentifier
|
|
370
|
+
}: {
|
|
371
|
+
readonly availableResourceCount: number;
|
|
372
|
+
readonly savedIdentifier?: string;
|
|
373
|
+
}) => boolean;
|
|
374
|
+
declare const getInitProviderTextPromptValues: (prompt: InitProviderTextPromptDefinition, savedValue?: string) => {
|
|
375
|
+
initialValue: string | undefined;
|
|
376
|
+
placeholder: string | undefined;
|
|
377
|
+
};
|
|
378
|
+
declare const resolveInitProviderInput: (env: Readonly<Record<string, string>>, input: InitProviderInputDefinition) => string | undefined;
|
|
379
|
+
declare const resolveInitProviderInputs: (env: Readonly<Record<string, string>>, provider: InitProviderDefinition) => Readonly<Record<string, string | undefined>>;
|
|
380
|
+
declare const getMissingInitProviderInputs: ({
|
|
381
|
+
inputs,
|
|
382
|
+
preflightOnly,
|
|
383
|
+
provider
|
|
384
|
+
}: {
|
|
385
|
+
readonly inputs: Readonly<Record<string, string | undefined>>;
|
|
386
|
+
readonly preflightOnly?: boolean;
|
|
387
|
+
readonly provider: InitProviderDefinition;
|
|
388
|
+
}) => readonly string[];
|
|
389
|
+
declare const assertInitProviderInputs: <TInputs extends InitProviderInputsDefinition>({
|
|
390
|
+
inputs,
|
|
391
|
+
provider,
|
|
392
|
+
strict
|
|
393
|
+
}: {
|
|
394
|
+
readonly inputs: Readonly<Record<string, string | undefined>>;
|
|
395
|
+
readonly provider: InitProviderDefinition<TInputs>;
|
|
396
|
+
readonly strict?: boolean;
|
|
397
|
+
}) => void;
|
|
398
|
+
declare const confirmInitInputPersistence: <TInputs extends InitProviderInputsDefinition>({
|
|
399
|
+
existingEnv,
|
|
400
|
+
inputs,
|
|
401
|
+
nonInteractive,
|
|
402
|
+
provider
|
|
403
|
+
}: {
|
|
404
|
+
readonly existingEnv: Readonly<Record<string, string>>;
|
|
405
|
+
readonly inputs: Readonly<Record<string, string | undefined>>;
|
|
406
|
+
readonly nonInteractive: boolean;
|
|
407
|
+
readonly provider: InitProviderDefinition<TInputs>;
|
|
408
|
+
}) => Promise<boolean>;
|
|
409
|
+
declare const getInitProviderEnvVars: <TInputs extends InitProviderInputsDefinition>({
|
|
410
|
+
includeConsentInputs,
|
|
411
|
+
inputs,
|
|
412
|
+
provider
|
|
413
|
+
}: {
|
|
414
|
+
readonly includeConsentInputs: boolean;
|
|
415
|
+
readonly inputs: Readonly<Record<string, string | undefined>>;
|
|
416
|
+
readonly provider: InitProviderDefinition<TInputs>;
|
|
417
|
+
}) => Record<string, string>;
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/initOptions.d.ts
|
|
420
|
+
type RunInitOptions = {
|
|
421
|
+
readonly build: BuildType;
|
|
422
|
+
readonly envFile?: string;
|
|
423
|
+
};
|
|
424
|
+
declare class InitError extends Error {
|
|
425
|
+
readonly name: string;
|
|
426
|
+
}
|
|
427
|
+
declare class MissingInitInputsError extends InitError {
|
|
428
|
+
readonly missingInputs: readonly string[];
|
|
429
|
+
readonly name = "MissingInitInputsError";
|
|
430
|
+
constructor(missingInputs: readonly string[]);
|
|
431
|
+
}
|
|
432
|
+
declare class InitEnvFileError extends InitError {
|
|
433
|
+
readonly name = "InitEnvFileError";
|
|
434
|
+
}
|
|
435
|
+
declare const assertInitInputs: ({
|
|
436
|
+
inputs,
|
|
437
|
+
strict
|
|
438
|
+
}: {
|
|
439
|
+
readonly inputs: Readonly<Record<string, string | undefined>>;
|
|
440
|
+
readonly strict?: boolean;
|
|
441
|
+
}) => void;
|
|
442
|
+
declare const getMissingInitInputs: (inputs: Readonly<Record<string, string | undefined>>) => readonly string[];
|
|
443
|
+
//#endregion
|
|
323
444
|
//#region src/LogWriter.d.ts
|
|
324
445
|
type HotUpdaterLogWriter = {
|
|
325
446
|
logFilePath: string | null;
|
|
@@ -360,7 +481,8 @@ type EnvVarValue = string | {
|
|
|
360
481
|
value: string;
|
|
361
482
|
};
|
|
362
483
|
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string, options?: {
|
|
363
|
-
preserveKeys?: string[];
|
|
484
|
+
readonly preserveKeys?: readonly string[];
|
|
485
|
+
readonly removeKeys?: readonly string[];
|
|
364
486
|
}) => Promise<string>;
|
|
365
487
|
//#endregion
|
|
366
488
|
//#region src/promoteBundle.d.ts
|
|
@@ -422,7 +544,7 @@ declare function promoteBundle({
|
|
|
422
544
|
targetChannel
|
|
423
545
|
}: PromoteBundleInput, deps: PromoteBundleDependencies): Promise<Bundle>;
|
|
424
546
|
//#endregion
|
|
425
|
-
//#region ../../node_modules/.pnpm/@clack+core@1.
|
|
547
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.d.mts
|
|
426
548
|
declare const actions: readonly ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
427
549
|
type Action = (typeof actions)[number];
|
|
428
550
|
/** Global settings for Clack programs, stored in memory */
|
|
@@ -434,6 +556,16 @@ interface InternalClackSettings {
|
|
|
434
556
|
error: string;
|
|
435
557
|
};
|
|
436
558
|
withGuide: boolean;
|
|
559
|
+
date: {
|
|
560
|
+
monthNames: string[];
|
|
561
|
+
messages: {
|
|
562
|
+
invalidMonth: string;
|
|
563
|
+
required: string;
|
|
564
|
+
invalidDay: (days: number, month: string) => string;
|
|
565
|
+
afterMin: (min: Date) => string;
|
|
566
|
+
beforeMax: (max: Date) => string;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
437
569
|
}
|
|
438
570
|
declare const settings: InternalClackSettings;
|
|
439
571
|
interface ClackSettings {
|
|
@@ -461,6 +593,19 @@ interface ClackSettings {
|
|
|
461
593
|
error?: string;
|
|
462
594
|
};
|
|
463
595
|
withGuide?: boolean;
|
|
596
|
+
/**
|
|
597
|
+
* Date prompt localization
|
|
598
|
+
*/
|
|
599
|
+
date?: {
|
|
600
|
+
/** Month names for validation messages (January, February, ...) */monthNames?: string[];
|
|
601
|
+
messages?: {
|
|
602
|
+
/** Shown when date is missing */required?: string; /** Shown when month > 12 */
|
|
603
|
+
invalidMonth?: string; /** (days, monthName) => message for invalid day */
|
|
604
|
+
invalidDay?: (days: number, month: string) => string; /** (min) => message when date is before minDate */
|
|
605
|
+
afterMin?: (min: Date) => string; /** (max) => message when date is after maxDate */
|
|
606
|
+
beforeMax?: (max: Date) => string;
|
|
607
|
+
};
|
|
608
|
+
};
|
|
464
609
|
}
|
|
465
610
|
declare function updateSettings(updates: ClackSettings): void;
|
|
466
611
|
/**
|
|
@@ -484,14 +629,116 @@ interface ClackEvents<TValue> {
|
|
|
484
629
|
finalize: () => void;
|
|
485
630
|
beforePrompt: () => void;
|
|
486
631
|
}
|
|
632
|
+
/** The Standard Schema interface. */
|
|
633
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
634
|
+
/** The Standard Schema properties. */
|
|
635
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
636
|
+
}
|
|
637
|
+
declare namespace StandardSchemaV1 {
|
|
638
|
+
/** The Standard Schema properties interface. */
|
|
639
|
+
interface Props<Input = unknown, Output = Input> {
|
|
640
|
+
/** The version number of the standard. */
|
|
641
|
+
readonly version: 1;
|
|
642
|
+
/** The vendor name of the schema library. */
|
|
643
|
+
readonly vendor: string;
|
|
644
|
+
/** Validates unknown input values. */
|
|
645
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
646
|
+
/** Inferred types associated with the schema. */
|
|
647
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
648
|
+
}
|
|
649
|
+
/** The result interface of the validate function. */
|
|
650
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
651
|
+
/** The result interface if validation succeeds. */
|
|
652
|
+
interface SuccessResult<Output> {
|
|
653
|
+
/** The typed output value. */
|
|
654
|
+
readonly value: Output;
|
|
655
|
+
/** A falsy value for `issues` indicates success. */
|
|
656
|
+
readonly issues?: undefined;
|
|
657
|
+
}
|
|
658
|
+
interface Options {
|
|
659
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
660
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
661
|
+
}
|
|
662
|
+
/** The result interface if validation fails. */
|
|
663
|
+
interface FailureResult {
|
|
664
|
+
/** The issues of failed validation. */
|
|
665
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
666
|
+
}
|
|
667
|
+
/** The issue interface of the failure output. */
|
|
668
|
+
interface Issue {
|
|
669
|
+
/** The error message of the issue. */
|
|
670
|
+
readonly message: string;
|
|
671
|
+
/** The path of the issue, if any. */
|
|
672
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
673
|
+
}
|
|
674
|
+
/** The path segment interface of the issue. */
|
|
675
|
+
interface PathSegment {
|
|
676
|
+
/** The key representing a path segment. */
|
|
677
|
+
readonly key: PropertyKey;
|
|
678
|
+
}
|
|
679
|
+
/** The Standard Schema types interface. */
|
|
680
|
+
interface Types<Input = unknown, Output = Input> {
|
|
681
|
+
/** The input type of the schema. */
|
|
682
|
+
readonly input: Input;
|
|
683
|
+
/** The output type of the schema. */
|
|
684
|
+
readonly output: Output;
|
|
685
|
+
}
|
|
686
|
+
/** Infers the input type of a Standard Schema. */
|
|
687
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
688
|
+
/** Infers the output type of a Standard Schema. */
|
|
689
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* A function or [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
693
|
+
* that validates user input. If a custom function is given, you should return a
|
|
694
|
+
* `string` or `Error` to show as a validation error, or `undefined` to accept the result.
|
|
695
|
+
*
|
|
696
|
+
* @example Using arktype
|
|
697
|
+
* ```ts
|
|
698
|
+
* import { text } from '@clack/prompts';
|
|
699
|
+
* import { type } from 'arktype';
|
|
700
|
+
*
|
|
701
|
+
* const name = await text({
|
|
702
|
+
* message: 'Enter your name (letters only)',
|
|
703
|
+
* validate: type('string.alpha').describe('Name can only contain letters'),
|
|
704
|
+
* });
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @example Custom validator
|
|
708
|
+
* ```ts
|
|
709
|
+
* import { text } from '@clack/prompts';
|
|
710
|
+
*
|
|
711
|
+
* const age = await text({
|
|
712
|
+
* message: 'Enter your age:',
|
|
713
|
+
* validate(value) {
|
|
714
|
+
* if (!value) return 'Please enter a value';
|
|
715
|
+
* const num = parseInt(value);
|
|
716
|
+
* if (isNaN(num)) return 'Please enter a valid number';
|
|
717
|
+
* if (num < 0 || num > 120) return 'Age must be between 0 and 120';
|
|
718
|
+
* return undefined;
|
|
719
|
+
* },
|
|
720
|
+
* });
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
type Validate<TValue> = ((value: TValue | undefined) => string | Error | undefined) | StandardSchemaV1<TValue | undefined, unknown>;
|
|
724
|
+
/**
|
|
725
|
+
* Runs the `validate()` option and normalizes the result
|
|
726
|
+
* @param validate - The validate option
|
|
727
|
+
* @param value - The user input
|
|
728
|
+
* @returns the validation result
|
|
729
|
+
*/
|
|
487
730
|
interface PromptOptions<TValue, Self extends Prompt<TValue>> {
|
|
488
731
|
render(this: Omit<Self, 'prompt'>): string | undefined;
|
|
489
732
|
initialValue?: any;
|
|
490
733
|
initialUserInput?: string;
|
|
491
|
-
|
|
734
|
+
/**
|
|
735
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
736
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
737
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
738
|
+
*/
|
|
739
|
+
validate?: Validate<TValue> | undefined;
|
|
492
740
|
input?: Readable$1;
|
|
493
741
|
output?: Writable;
|
|
494
|
-
debug?: boolean;
|
|
495
742
|
signal?: AbortSignal;
|
|
496
743
|
}
|
|
497
744
|
declare class Prompt<TValue> {
|
|
@@ -539,6 +786,7 @@ declare class Prompt<TValue> {
|
|
|
539
786
|
emit<T extends keyof ClackEvents<TValue>>(event: T, ...data: Parameters<ClackEvents<TValue>[T]>): void;
|
|
540
787
|
prompt(): Promise<symbol | TValue | undefined>;
|
|
541
788
|
protected _isActionKey(char: string | undefined, _key: Key$1): boolean;
|
|
789
|
+
protected _shouldSubmit(_char: string | undefined, _key: Key$1): boolean;
|
|
542
790
|
protected _setValue(value: TValue | undefined): void;
|
|
543
791
|
protected _setUserInput(value: string | undefined, write?: boolean): void;
|
|
544
792
|
protected _clearUserInput(): void;
|
|
@@ -557,6 +805,13 @@ interface AutocompleteOptions$1<T extends OptionLike$1> extends PromptOptions<T[
|
|
|
557
805
|
options: T[] | ((this: AutocompletePrompt<T>) => T[]);
|
|
558
806
|
filter?: FilterFunction<T>;
|
|
559
807
|
multiple?: boolean;
|
|
808
|
+
/**
|
|
809
|
+
* When set (non-empty), pressing Tab with no input fills the field with this value
|
|
810
|
+
* and runs the normal filter/selection logic so the user can confirm with Enter.
|
|
811
|
+
* Tab only fills the input when the placeholder matches at least one option under
|
|
812
|
+
* the prompt's filter (so the value remains selectable).
|
|
813
|
+
*/
|
|
814
|
+
placeholder?: string;
|
|
560
815
|
}
|
|
561
816
|
declare class AutocompletePrompt<T extends OptionLike$1> extends Prompt<T['value'] | T['value'][]> {
|
|
562
817
|
#private;
|
|
@@ -573,9 +828,10 @@ declare class AutocompletePrompt<T extends OptionLike$1> extends Prompt<T['value
|
|
|
573
828
|
deselectAll(): void;
|
|
574
829
|
toggleSelected(value: T['value']): void;
|
|
575
830
|
}
|
|
831
|
+
type DateFormat = 'YMD' | 'MDY' | 'DMY';
|
|
576
832
|
declare function isCancel(value: unknown): value is symbol;
|
|
577
833
|
declare namespace index_d_exports {
|
|
578
|
-
export { AutocompleteMultiSelectOptions, AutocompleteOptions, BoxAlignment, BoxOptions, ClackSettings, CommonOptions, ConfirmOptions, GroupMultiSelectOptions, LimitOptionsParams, LogMessageOptions, MultiSelectOptions, NoteOptions, Option, PasswordOptions, PathOptions, ProgressOptions, ProgressResult, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, S_BAR, S_BAR_END, S_BAR_END_RIGHT, S_BAR_H, S_BAR_START, S_BAR_START_RIGHT, S_CHECKBOX_ACTIVE, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, S_CONNECT_LEFT, S_CORNER_BOTTOM_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_TOP_LEFT, S_CORNER_TOP_RIGHT, S_ERROR, S_INFO, S_PASSWORD_MASK, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_SUCCESS, S_WARN, SelectKeyOptions, SelectOptions, SpinnerOptions, SpinnerResult, Task, TaskLogCompletionOptions, TaskLogMessageOptions, TaskLogOptions, TextOptions, autocomplete, autocompleteMultiselect, box, cancel, confirm, group, groupMultiselect, intro, isCI, isCancel, isTTY, limitOptions, log$1 as log, multiselect, note, outro, password, path, progress, select, selectKey, settings, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr, updateSettings };
|
|
834
|
+
export { AutocompleteMultiSelectOptions, AutocompleteOptions, BoxAlignment, BoxOptions, ClackSettings, CommonOptions, ConfirmOptions, DateFormat, DateOptions, GroupMultiSelectOptions, LimitOptionsParams, LogMessageOptions, MULTISELECT_INSTRUCTIONS, MultiLineOptions, MultiSelectOptions, NoteOptions, Option, PasswordOptions, PathOptions, ProgressOptions, ProgressResult, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SELECT_INSTRUCTIONS, S_BAR, S_BAR_END, S_BAR_END_RIGHT, S_BAR_H, S_BAR_START, S_BAR_START_RIGHT, S_CHECKBOX_ACTIVE, S_CHECKBOX_INACTIVE, S_CHECKBOX_SELECTED, S_CONNECT_LEFT, S_CORNER_BOTTOM_LEFT, S_CORNER_BOTTOM_RIGHT, S_CORNER_TOP_LEFT, S_CORNER_TOP_RIGHT, S_ERROR, S_INFO, S_PASSWORD_MASK, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_SUCCESS, S_WARN, SelectKeyOptions, SelectOptions, SpinnerOptions, SpinnerResult, Task, TaskLogCompletionOptions, TaskLogMessageOptions, TaskLogOptions, TextOptions, autocomplete, autocompleteMultiselect, box, cancel, confirm, date, formatInstructionFooter, group, groupMultiselect, intro, isCI, isCancel, isTTY, limitOptions, log$1 as log, multiline, multiselect, note, outro, password, path, progress, select, selectKey, settings, spinner, stream, symbol, symbolBar, taskLog, tasks, text, unicode, unicodeOr, updateSettings };
|
|
579
835
|
}
|
|
580
836
|
declare const unicode: boolean;
|
|
581
837
|
declare const isCI: () => boolean;
|
|
@@ -614,6 +870,8 @@ interface CommonOptions {
|
|
|
614
870
|
signal?: AbortSignal;
|
|
615
871
|
withGuide?: boolean;
|
|
616
872
|
}
|
|
873
|
+
declare function formatInstructionFooter(instructions: string[], hasGuide: boolean): string[];
|
|
874
|
+
declare const SELECT_INSTRUCTIONS: string[];
|
|
617
875
|
type Primitive = Readonly<string | boolean | number>;
|
|
618
876
|
type Option<Value> = Value extends Primitive ? {
|
|
619
877
|
/**
|
|
@@ -669,117 +927,487 @@ interface SelectOptions<Value> extends CommonOptions {
|
|
|
669
927
|
options: Option<Value>[];
|
|
670
928
|
initialValue?: Value;
|
|
671
929
|
maxItems?: number;
|
|
930
|
+
/**
|
|
931
|
+
* Show keyboard instructions below the option list.
|
|
932
|
+
* @default true
|
|
933
|
+
*/
|
|
934
|
+
showInstructions?: boolean;
|
|
672
935
|
}
|
|
673
936
|
declare const select: <Value>(opts: SelectOptions<Value>) => Promise<Value | symbol>;
|
|
937
|
+
/**
|
|
938
|
+
* Options for the {@link autocomplete} prompt.
|
|
939
|
+
*/
|
|
674
940
|
interface AutocompleteSharedOptions<Value> extends CommonOptions {
|
|
675
941
|
/**
|
|
676
|
-
* The message
|
|
942
|
+
* The message or question shown to the user above the input.
|
|
677
943
|
*/
|
|
678
944
|
message: string;
|
|
679
945
|
/**
|
|
680
|
-
*
|
|
946
|
+
* The options to present, or a function that returns the options to present
|
|
947
|
+
* allowing for custom search/filtering.
|
|
948
|
+
*
|
|
949
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#dynamic-options-getter
|
|
681
950
|
*/
|
|
682
951
|
options: Option<Value>[] | ((this: AutocompletePrompt<Option<Value>>) => Option<Value>[]);
|
|
683
952
|
/**
|
|
684
|
-
*
|
|
953
|
+
* The maximum number of items/options to display in the autocomplete list at once.
|
|
685
954
|
*/
|
|
686
955
|
maxItems?: number;
|
|
687
956
|
/**
|
|
688
|
-
* Placeholder text
|
|
957
|
+
* Placeholder text displayed when the search field is empty. When set, pressing
|
|
958
|
+
* tab copies the placeholder into the input.
|
|
689
959
|
*/
|
|
690
960
|
placeholder?: string;
|
|
691
961
|
/**
|
|
692
|
-
*
|
|
962
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
963
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
964
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
693
965
|
*/
|
|
694
|
-
validate?:
|
|
966
|
+
validate?: Validate<Value | Value[]>;
|
|
695
967
|
/**
|
|
696
|
-
* Custom filter function to match options against search input.
|
|
697
|
-
* If not provided, a default filter that matches label, hint, and value is used.
|
|
968
|
+
* Custom filter function to match options against the search input.
|
|
698
969
|
*/
|
|
699
970
|
filter?: (search: string, option: Option<Value>) => boolean;
|
|
700
971
|
}
|
|
701
972
|
interface AutocompleteOptions<Value> extends AutocompleteSharedOptions<Value> {
|
|
702
973
|
/**
|
|
703
|
-
* The
|
|
974
|
+
* The initially selected option from the list.
|
|
704
975
|
*/
|
|
705
976
|
initialValue?: Value;
|
|
706
977
|
/**
|
|
707
|
-
* The
|
|
978
|
+
* The starting value shown in the users input box.
|
|
708
979
|
*/
|
|
709
980
|
initialUserInput?: string;
|
|
710
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* The `autocomplete` prompt combines a text input with a searchable list of options.
|
|
984
|
+
* It's perfect for when you have a large list of options and want to help users
|
|
985
|
+
* find what they're looking for quickly.
|
|
986
|
+
*
|
|
987
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#autocomplete
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* ```ts
|
|
991
|
+
* import { autocomplete } from '@clack/prompts';
|
|
992
|
+
*
|
|
993
|
+
* const framework = await autocomplete({
|
|
994
|
+
* message: 'Search for a framework',
|
|
995
|
+
* options: [
|
|
996
|
+
* { value: 'next', label: 'Next.js', hint: 'React framework' },
|
|
997
|
+
* { value: 'astro', label: 'Astro', hint: 'Content-focused' },
|
|
998
|
+
* { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },
|
|
999
|
+
* { value: 'remix', label: 'Remix', hint: 'Full stack framework' },
|
|
1000
|
+
* { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },
|
|
1001
|
+
* ],
|
|
1002
|
+
* placeholder: 'Type to search...',
|
|
1003
|
+
* maxItems: 5,
|
|
1004
|
+
* });
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
711
1007
|
declare const autocomplete: <Value>(opts: AutocompleteOptions<Value>) => Promise<Value | symbol>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Options for the {@link autocompleteMultiselect} prompt
|
|
1010
|
+
*/
|
|
712
1011
|
interface AutocompleteMultiSelectOptions<Value> extends AutocompleteSharedOptions<Value> {
|
|
713
1012
|
/**
|
|
714
|
-
* The
|
|
1013
|
+
* The initially selected option(s) from the list.
|
|
715
1014
|
*/
|
|
716
1015
|
initialValues?: Value[];
|
|
717
1016
|
/**
|
|
718
|
-
*
|
|
1017
|
+
* When `true` at least one option must be selected.
|
|
1018
|
+
* @default false
|
|
719
1019
|
*/
|
|
720
1020
|
required?: boolean;
|
|
721
1021
|
}
|
|
722
1022
|
/**
|
|
723
|
-
*
|
|
1023
|
+
* The `autocompleteMultiselect` prompt combines the search functionality of autocomplete
|
|
1024
|
+
* with the ability to select multiple options.
|
|
1025
|
+
*
|
|
1026
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#autocomplete-multiselect
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* ```ts
|
|
1030
|
+
* import { autocompleteMultiselect } from '@clack/prompts';
|
|
1031
|
+
*
|
|
1032
|
+
* const frameworks = await autocompleteMultiselect({
|
|
1033
|
+
* message: 'Select frameworks',
|
|
1034
|
+
* options: [
|
|
1035
|
+
* { value: 'next', label: 'Next.js', hint: 'React framework' },
|
|
1036
|
+
* { value: 'astro', label: 'Astro', hint: 'Content-focused' },
|
|
1037
|
+
* { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' },
|
|
1038
|
+
* { value: 'remix', label: 'Remix', hint: 'Full stack framework' },
|
|
1039
|
+
* { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' },
|
|
1040
|
+
* ],
|
|
1041
|
+
* placeholder: 'Type to search...',
|
|
1042
|
+
* maxItems: 5,
|
|
1043
|
+
* });
|
|
1044
|
+
* ```
|
|
724
1045
|
*/
|
|
725
1046
|
declare const autocompleteMultiselect: <Value>(opts: AutocompleteMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Alignment for content or titles within the box.
|
|
1049
|
+
*/
|
|
726
1050
|
type BoxAlignment = 'left' | 'center' | 'right';
|
|
1051
|
+
/**
|
|
1052
|
+
* Options for the {@link box} prompt.
|
|
1053
|
+
*/
|
|
727
1054
|
interface BoxOptions extends CommonOptions {
|
|
1055
|
+
/**
|
|
1056
|
+
* Alignment of the content (`'left'`, `'center'`, or `'right'`).
|
|
1057
|
+
* @default 'left'
|
|
1058
|
+
*/
|
|
728
1059
|
contentAlign?: BoxAlignment;
|
|
1060
|
+
/**
|
|
1061
|
+
* Alignment of the title (`'left'`, `'center'`, or `'right'`).
|
|
1062
|
+
* @default 'left'
|
|
1063
|
+
*/
|
|
729
1064
|
titleAlign?: BoxAlignment;
|
|
1065
|
+
/**
|
|
1066
|
+
* The width of the box, either `'auto'` to fit the content or a number for a fixed width.
|
|
1067
|
+
* @default 'auto'
|
|
1068
|
+
*/
|
|
730
1069
|
width?: number | 'auto';
|
|
1070
|
+
/**
|
|
1071
|
+
* Padding around the title.
|
|
1072
|
+
* @default 1
|
|
1073
|
+
*/
|
|
731
1074
|
titlePadding?: number;
|
|
1075
|
+
/**
|
|
1076
|
+
* Padding around the content.
|
|
1077
|
+
* @default 2
|
|
1078
|
+
*/
|
|
732
1079
|
contentPadding?: number;
|
|
1080
|
+
/**
|
|
1081
|
+
* Use rounded corners when `true`, square corners when `false`.
|
|
1082
|
+
* @default true
|
|
1083
|
+
*/
|
|
733
1084
|
rounded?: boolean;
|
|
1085
|
+
/**
|
|
1086
|
+
* Custom function to style the border characters.
|
|
1087
|
+
*/
|
|
734
1088
|
formatBorder?: (text: string) => string;
|
|
735
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Renders a customizable box around text content. It's similar to {@link note} but offers
|
|
1092
|
+
* more styling options.
|
|
1093
|
+
*
|
|
1094
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#box
|
|
1095
|
+
*
|
|
1096
|
+
* @param message - The content to display inside the box.
|
|
1097
|
+
* @param title - The title to display in the top border of the box.
|
|
1098
|
+
* @param opts - Optional configuration for the box styling and behavior.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* import { box } from '@clack/prompts';
|
|
1103
|
+
*
|
|
1104
|
+
* box('This is the content of the box', 'Box Title', {
|
|
1105
|
+
* contentAlign: 'center',
|
|
1106
|
+
* titleAlign: 'center',
|
|
1107
|
+
* width: 'auto',
|
|
1108
|
+
* rounded: true,
|
|
1109
|
+
* });
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
736
1112
|
declare const box: (message?: string, title?: string, opts?: BoxOptions) => void;
|
|
1113
|
+
/**
|
|
1114
|
+
* Options for the {@link confirm} prompt.
|
|
1115
|
+
*/
|
|
737
1116
|
interface ConfirmOptions extends CommonOptions {
|
|
1117
|
+
/**
|
|
1118
|
+
* The message or question shown to the user above the input.
|
|
1119
|
+
*/
|
|
738
1120
|
message: string;
|
|
1121
|
+
/**
|
|
1122
|
+
* The label to use for the active (true) option.
|
|
1123
|
+
* @default 'Yes'
|
|
1124
|
+
*/
|
|
739
1125
|
active?: string;
|
|
1126
|
+
/**
|
|
1127
|
+
* The label to use for the inactive (false) option.
|
|
1128
|
+
* @default 'No'
|
|
1129
|
+
*/
|
|
740
1130
|
inactive?: string;
|
|
1131
|
+
/**
|
|
1132
|
+
* The initial selected value (true or false).
|
|
1133
|
+
* @default true
|
|
1134
|
+
*/
|
|
741
1135
|
initialValue?: boolean;
|
|
1136
|
+
/**
|
|
1137
|
+
* Whether to render the options vertically instead of horizontally.
|
|
1138
|
+
* @default false
|
|
1139
|
+
*/
|
|
742
1140
|
vertical?: boolean;
|
|
743
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* The `confirm` prompt accepts a yes or no choice, returning a boolean value
|
|
1144
|
+
* corresponding to the user's selection.
|
|
1145
|
+
*
|
|
1146
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#confirmation
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* import { confirm } from '@clack/prompts';
|
|
1151
|
+
*
|
|
1152
|
+
* const shouldProceed = await confirm({
|
|
1153
|
+
* message: 'Do you want to continue?',
|
|
1154
|
+
* });
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
744
1157
|
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Options for the {@link date} prompt.
|
|
1160
|
+
*/
|
|
1161
|
+
interface DateOptions extends CommonOptions {
|
|
1162
|
+
/**
|
|
1163
|
+
* The message or question shown to the user above the input.
|
|
1164
|
+
*/
|
|
1165
|
+
message: string;
|
|
1166
|
+
/**
|
|
1167
|
+
* The date format for the input segments.
|
|
1168
|
+
* @deafult based on locale
|
|
1169
|
+
*/
|
|
1170
|
+
format?: DateFormat;
|
|
1171
|
+
/**
|
|
1172
|
+
* The BCP 47 language tag to use for formatting
|
|
1173
|
+
* @see https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag
|
|
1174
|
+
* @example "en-GB"
|
|
1175
|
+
*/
|
|
1176
|
+
locale?: string;
|
|
1177
|
+
/**
|
|
1178
|
+
* The default value returned when the user doesn't select a date.
|
|
1179
|
+
*/
|
|
1180
|
+
defaultValue?: Date;
|
|
1181
|
+
/**
|
|
1182
|
+
* The starting date shown when the prompt first renders.
|
|
1183
|
+
* Users can edit this value before submitting.
|
|
1184
|
+
*/
|
|
1185
|
+
initialValue?: Date;
|
|
1186
|
+
/**
|
|
1187
|
+
* The minimum allowed date for validation.
|
|
1188
|
+
*/
|
|
1189
|
+
minDate?: Date;
|
|
1190
|
+
/**
|
|
1191
|
+
* The maximum allowed date for validation.
|
|
1192
|
+
*/
|
|
1193
|
+
maxDate?: Date;
|
|
1194
|
+
/**
|
|
1195
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
1196
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
1197
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
1198
|
+
*/
|
|
1199
|
+
validate?: Validate<Date>;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* The `date` prompt provides an interactive date picker, allowing users
|
|
1203
|
+
* to navigate between year, month, and day segments and
|
|
1204
|
+
* increment/decrement values using keyboard controls.
|
|
1205
|
+
*
|
|
1206
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#date-input
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* import { date } from '@clack/prompts';
|
|
1211
|
+
*
|
|
1212
|
+
* const birthday = await date({
|
|
1213
|
+
* message: 'Pick your birthday',
|
|
1214
|
+
* minDate: new Date('1900-01-01'),
|
|
1215
|
+
* initialValue: new Date(),
|
|
1216
|
+
* maxDate: new Date(),
|
|
1217
|
+
* });
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
declare const date: (opts: DateOptions) => Promise<Date | symbol>;
|
|
745
1221
|
type Prettify<T> = { [P in keyof T]: T[P] } & {};
|
|
1222
|
+
/**
|
|
1223
|
+
* The return type of a {@link PromptGroup}.
|
|
1224
|
+
* Resolves all prompt results, excluding the cancel symbol.
|
|
1225
|
+
*/
|
|
746
1226
|
type PromptGroupAwaitedReturn<T> = { [P in keyof T]: Exclude<Awaited<T[P]>, symbol> };
|
|
1227
|
+
/**
|
|
1228
|
+
* Options for the {@link group} utility.
|
|
1229
|
+
*/
|
|
747
1230
|
interface PromptGroupOptions<T> {
|
|
748
1231
|
/**
|
|
749
|
-
*
|
|
750
|
-
* if one of the prompts is canceled.
|
|
1232
|
+
* Called when any one of the prompts is canceled.
|
|
751
1233
|
*/
|
|
752
1234
|
onCancel?: (opts: {
|
|
753
1235
|
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
|
754
1236
|
}) => void;
|
|
755
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* A group of prompts to be displayed sequentially, with each prompt receiving
|
|
1240
|
+
* the results of all previous prompts in the group.
|
|
1241
|
+
*/
|
|
756
1242
|
type PromptGroup<T> = { [P in keyof T]: (opts: {
|
|
757
1243
|
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
|
758
1244
|
}) => undefined | Promise<T[P] | undefined> };
|
|
759
1245
|
/**
|
|
760
|
-
*
|
|
761
|
-
*
|
|
1246
|
+
* The `group` utility provides a consistent way to combine a series of prompts,
|
|
1247
|
+
* combining each answer into one object. Each prompt receives the results of
|
|
1248
|
+
* all previously completed prompts, and are displayed sequentially.
|
|
1249
|
+
*
|
|
1250
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#group
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```ts
|
|
1254
|
+
* import { group, text, password } from '@clack/prompts';
|
|
1255
|
+
*
|
|
1256
|
+
* const account = await group({
|
|
1257
|
+
* email: () => text({
|
|
1258
|
+
* message: 'What is your email address?',
|
|
1259
|
+
* }),
|
|
1260
|
+
* username: ({ results }) => text({
|
|
1261
|
+
* message: 'What is your username?',
|
|
1262
|
+
* placeholder: results.email?.replace(/@.+$/, '').toLowerCase() ?? '',
|
|
1263
|
+
* }),
|
|
1264
|
+
* password: () => password({
|
|
1265
|
+
* message: 'Define your password',
|
|
1266
|
+
* }),
|
|
1267
|
+
* });
|
|
1268
|
+
* ```
|
|
762
1269
|
*/
|
|
763
1270
|
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T>) => Promise<Prettify<PromptGroupAwaitedReturn<T>>>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Options for the {@link groupMultiselect} prompt.
|
|
1273
|
+
*/
|
|
764
1274
|
interface GroupMultiSelectOptions<Value> extends CommonOptions {
|
|
1275
|
+
/**
|
|
1276
|
+
* The message or question shown to the user above the input.
|
|
1277
|
+
*/
|
|
765
1278
|
message: string;
|
|
1279
|
+
/**
|
|
1280
|
+
* Grouped options to display. Each key is a group label, and each value is an array of options.
|
|
1281
|
+
*/
|
|
766
1282
|
options: Record<string, Option<Value>[]>;
|
|
1283
|
+
/**
|
|
1284
|
+
* The initially selected option(s).
|
|
1285
|
+
*/
|
|
767
1286
|
initialValues?: Value[];
|
|
1287
|
+
/**
|
|
1288
|
+
* The maximum number of items/options to display at once.
|
|
1289
|
+
*/
|
|
1290
|
+
maxItems?: number;
|
|
1291
|
+
/**
|
|
1292
|
+
* When `true` at least one option must be selected.
|
|
1293
|
+
* @default true
|
|
1294
|
+
*/
|
|
768
1295
|
required?: boolean;
|
|
1296
|
+
/**
|
|
1297
|
+
* The value the cursor should be positioned at initially.
|
|
1298
|
+
*/
|
|
769
1299
|
cursorAt?: Value;
|
|
1300
|
+
/**
|
|
1301
|
+
* Whether entire groups can be selected at once.
|
|
1302
|
+
* @default true
|
|
1303
|
+
*/
|
|
770
1304
|
selectableGroups?: boolean;
|
|
1305
|
+
/**
|
|
1306
|
+
* Number of blank lines between groups.
|
|
1307
|
+
* @default 0
|
|
1308
|
+
*/
|
|
771
1309
|
groupSpacing?: number;
|
|
1310
|
+
/**
|
|
1311
|
+
* Show keyboard instructions below the option list.
|
|
1312
|
+
* @default true
|
|
1313
|
+
*/
|
|
1314
|
+
showInstructions?: boolean;
|
|
772
1315
|
}
|
|
1316
|
+
/**
|
|
1317
|
+
* The `groupMultiselect` prompt extends the {@link multiselect} prompt to allow
|
|
1318
|
+
* arranging distinct Multi-Selects, whilst keeping all of them interactive.
|
|
1319
|
+
*
|
|
1320
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#group-multiselect
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
* ```ts
|
|
1324
|
+
* import { groupMultiselect } from '@clack/prompts';
|
|
1325
|
+
*
|
|
1326
|
+
* const result = await groupMultiselect({
|
|
1327
|
+
* message: 'Define your project',
|
|
1328
|
+
* options: {
|
|
1329
|
+
* 'Testing': [
|
|
1330
|
+
* { value: 'Jest', hint: 'JavaScript testing framework' },
|
|
1331
|
+
* { value: 'Playwright', hint: 'End-to-end testing' },
|
|
1332
|
+
* ],
|
|
1333
|
+
* 'Language': [
|
|
1334
|
+
* { value: 'js', label: 'JavaScript', hint: 'Dynamic typing' },
|
|
1335
|
+
* { value: 'ts', label: 'TypeScript', hint: 'Static typing' },
|
|
1336
|
+
* ],
|
|
1337
|
+
* },
|
|
1338
|
+
* });
|
|
1339
|
+
* ```
|
|
1340
|
+
*
|
|
1341
|
+
* @param opts The options for the group multiselect prompt
|
|
1342
|
+
*/
|
|
773
1343
|
declare const groupMultiselect: <Value>(opts: GroupMultiSelectOptions<Value>) => Promise<Value[] | symbol>;
|
|
1344
|
+
/**
|
|
1345
|
+
* Options for the {@link limitOptions} function.
|
|
1346
|
+
*/
|
|
774
1347
|
interface LimitOptionsParams<TOption> extends CommonOptions {
|
|
1348
|
+
/**
|
|
1349
|
+
* The list of options to display.
|
|
1350
|
+
*/
|
|
775
1351
|
options: TOption[];
|
|
776
|
-
|
|
1352
|
+
/**
|
|
1353
|
+
* The index of the currently active/selected option.
|
|
1354
|
+
*/
|
|
777
1355
|
cursor: number;
|
|
1356
|
+
/**
|
|
1357
|
+
* A function that styles the given option string.
|
|
1358
|
+
*
|
|
1359
|
+
* @param option - The option string to style.
|
|
1360
|
+
* @param active - Whether the option is currently selected.
|
|
1361
|
+
*/
|
|
778
1362
|
style: (option: TOption, active: boolean) => string;
|
|
1363
|
+
/**
|
|
1364
|
+
* Maximum number of options to display at once.
|
|
1365
|
+
* @default Infinity
|
|
1366
|
+
*/
|
|
1367
|
+
maxItems?: number;
|
|
1368
|
+
/**
|
|
1369
|
+
* Number of columns to reserve for padding.
|
|
1370
|
+
* @default 0
|
|
1371
|
+
*/
|
|
779
1372
|
columnPadding?: number;
|
|
1373
|
+
/**
|
|
1374
|
+
* Number of rows to reserve for padding.
|
|
1375
|
+
* @default 4
|
|
1376
|
+
*/
|
|
780
1377
|
rowPadding?: number;
|
|
781
1378
|
}
|
|
782
|
-
|
|
1379
|
+
/**
|
|
1380
|
+
* Trims an option list to what fits the terminal, while keeping the active
|
|
1381
|
+
* option (cursor) visible using a Clack style sliding window.
|
|
1382
|
+
*
|
|
1383
|
+
* @returns The lines to render.
|
|
1384
|
+
*
|
|
1385
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#limitoptions
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```ts
|
|
1389
|
+
* import { limitOptions } from '@clack/prompts';
|
|
1390
|
+
* import { styleText } from 'node:util';
|
|
1391
|
+
*
|
|
1392
|
+
* const options = ['apple', 'banana', 'cherry', 'date'];
|
|
1393
|
+
* const lines = limitOptions({
|
|
1394
|
+
* options,
|
|
1395
|
+
* cursor: 2,
|
|
1396
|
+
* maxItems: 8,
|
|
1397
|
+
* style: (opt, active) =>
|
|
1398
|
+
* active ? styleText('cyan', opt) : styleText('dim', opt),
|
|
1399
|
+
* });
|
|
1400
|
+
* ```
|
|
1401
|
+
*/
|
|
1402
|
+
declare const limitOptions: <TOption>({
|
|
1403
|
+
cursor,
|
|
1404
|
+
options,
|
|
1405
|
+
style,
|
|
1406
|
+
output,
|
|
1407
|
+
maxItems,
|
|
1408
|
+
columnPadding,
|
|
1409
|
+
rowPadding
|
|
1410
|
+
}: LimitOptionsParams<TOption>) => string[];
|
|
783
1411
|
interface LogMessageOptions extends CommonOptions {
|
|
784
1412
|
symbol?: string;
|
|
785
1413
|
spacing?: number;
|
|
@@ -800,9 +1428,136 @@ declare const log$1: {
|
|
|
800
1428
|
warning: (message: string, opts?: LogMessageOptions) => void;
|
|
801
1429
|
error: (message: string, opts?: LogMessageOptions) => void;
|
|
802
1430
|
};
|
|
1431
|
+
/**
|
|
1432
|
+
* The `cancel` function defines an interruption of an interaction
|
|
1433
|
+
* and therefore its end.
|
|
1434
|
+
*
|
|
1435
|
+
* @param title Optional closing message to be displayed.
|
|
1436
|
+
* @param opts Additional configuration options.
|
|
1437
|
+
*
|
|
1438
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#cancel
|
|
1439
|
+
*
|
|
1440
|
+
* @example
|
|
1441
|
+
* ```ts
|
|
1442
|
+
* import { cancel } from '@clack/prompts';
|
|
1443
|
+
* import process from 'node:process';
|
|
1444
|
+
*
|
|
1445
|
+
* cancel('Installation canceled');
|
|
1446
|
+
* process.exit(1);
|
|
1447
|
+
* ```
|
|
1448
|
+
*/
|
|
803
1449
|
declare const cancel: (message?: string, opts?: CommonOptions) => void;
|
|
1450
|
+
/**
|
|
1451
|
+
* The `intro` function defines the beginning of an interaction.
|
|
1452
|
+
*
|
|
1453
|
+
* @param title Optional title to be displayed.
|
|
1454
|
+
* @param opts Additional configuration options.
|
|
1455
|
+
*
|
|
1456
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#intro
|
|
1457
|
+
*
|
|
1458
|
+
* @example
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* import { intro } from '@clack/prompts';
|
|
1461
|
+
*
|
|
1462
|
+
* intro('Welcome to clack');
|
|
1463
|
+
* ```
|
|
1464
|
+
*/
|
|
804
1465
|
declare const intro: (title?: string, opts?: CommonOptions) => void;
|
|
1466
|
+
/**
|
|
1467
|
+
* The `outro` function defines the end of an interaction.
|
|
1468
|
+
*
|
|
1469
|
+
* @param title Optional closing message to be displayed.
|
|
1470
|
+
* @param opts Additional configuration options.
|
|
1471
|
+
*
|
|
1472
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#outro
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```ts
|
|
1476
|
+
* import { outro } from '@clack/prompts';
|
|
1477
|
+
*
|
|
1478
|
+
* outro('All operations are finished');
|
|
1479
|
+
* ```
|
|
1480
|
+
*/
|
|
805
1481
|
declare const outro: (message?: string, opts?: CommonOptions) => void;
|
|
1482
|
+
/**
|
|
1483
|
+
* Options for the {@link text} prompt
|
|
1484
|
+
*/
|
|
1485
|
+
interface TextOptions extends CommonOptions {
|
|
1486
|
+
/**
|
|
1487
|
+
* The prompt message or question shown to the user above the input.
|
|
1488
|
+
*/
|
|
1489
|
+
message: string;
|
|
1490
|
+
/**
|
|
1491
|
+
* A visual hint shown when the field has no content.
|
|
1492
|
+
*/
|
|
1493
|
+
placeholder?: string;
|
|
1494
|
+
/**
|
|
1495
|
+
* A fallback value returned when the user provides nothing (empty input).
|
|
1496
|
+
*/
|
|
1497
|
+
defaultValue?: string;
|
|
1498
|
+
/**
|
|
1499
|
+
* The starting value shown when the prompt first renders.
|
|
1500
|
+
* Users can edit this value before submitting.
|
|
1501
|
+
*/
|
|
1502
|
+
initialValue?: string;
|
|
1503
|
+
/**
|
|
1504
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
1505
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
1506
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
1507
|
+
*/
|
|
1508
|
+
validate?: Validate<string>;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* The text prompt accepts a single line of text.
|
|
1512
|
+
*
|
|
1513
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#text-input
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* import { text } from '@clack/prompts';
|
|
1518
|
+
*
|
|
1519
|
+
* const name = await text({
|
|
1520
|
+
* message: 'What is your name?',
|
|
1521
|
+
* placeholder: 'John Doe',
|
|
1522
|
+
* validate: (value) => {
|
|
1523
|
+
* if (!value || value.length < 2) return 'Name must be at least 2 characters';
|
|
1524
|
+
* return undefined;
|
|
1525
|
+
* },
|
|
1526
|
+
* });
|
|
1527
|
+
* ```
|
|
1528
|
+
*/
|
|
1529
|
+
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Options for the {@link multiline} prompt
|
|
1532
|
+
*/
|
|
1533
|
+
interface MultiLineOptions extends TextOptions {
|
|
1534
|
+
/**
|
|
1535
|
+
* When enabled it shows a `[ submit ]` button that can be focused with tab.
|
|
1536
|
+
* By default, pressing `Enter` twice submits the input
|
|
1537
|
+
*
|
|
1538
|
+
* @default false
|
|
1539
|
+
*/
|
|
1540
|
+
showSubmit?: boolean;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* The multi-line prompt accepts multiple lines of text input.
|
|
1544
|
+
* By default, pressing `Enter` twice submits the input.
|
|
1545
|
+
*
|
|
1546
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#multi-line-text
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```ts
|
|
1550
|
+
* import { multiline } from '@clack/prompts';
|
|
1551
|
+
*
|
|
1552
|
+
* const bio = await multiline({
|
|
1553
|
+
* message: 'Enter your bio',
|
|
1554
|
+
* placeholder: 'Tell us about yourself...',
|
|
1555
|
+
* showSubmit: true,
|
|
1556
|
+
* });
|
|
1557
|
+
* ```
|
|
1558
|
+
*/
|
|
1559
|
+
declare const multiline: (opts: MultiLineOptions) => Promise<string | symbol>;
|
|
1560
|
+
declare const MULTISELECT_INSTRUCTIONS: string[];
|
|
806
1561
|
interface MultiSelectOptions<Value> extends CommonOptions {
|
|
807
1562
|
message: string;
|
|
808
1563
|
options: Option<Value>[];
|
|
@@ -810,6 +1565,11 @@ interface MultiSelectOptions<Value> extends CommonOptions {
|
|
|
810
1565
|
maxItems?: number;
|
|
811
1566
|
required?: boolean;
|
|
812
1567
|
cursorAt?: Value;
|
|
1568
|
+
/**
|
|
1569
|
+
* Show keyboard instructions below the option list.
|
|
1570
|
+
* @default true
|
|
1571
|
+
*/
|
|
1572
|
+
showInstructions?: boolean;
|
|
813
1573
|
}
|
|
814
1574
|
declare const multiselect: <Value>(opts: MultiSelectOptions<Value>) => Promise<Value[] | symbol>;
|
|
815
1575
|
type FormatFn = (line: string) => string;
|
|
@@ -817,20 +1577,94 @@ interface NoteOptions extends CommonOptions {
|
|
|
817
1577
|
format?: FormatFn;
|
|
818
1578
|
}
|
|
819
1579
|
declare const note: (message?: string, title?: string, opts?: NoteOptions) => void;
|
|
1580
|
+
/**
|
|
1581
|
+
* Options for the {@link password} prompt
|
|
1582
|
+
*/
|
|
820
1583
|
interface PasswordOptions extends CommonOptions {
|
|
1584
|
+
/**
|
|
1585
|
+
* The prompt message or question shown to the user above the input.
|
|
1586
|
+
*/
|
|
821
1587
|
message: string;
|
|
1588
|
+
/**
|
|
1589
|
+
* Character to use for masking input.
|
|
1590
|
+
* @default ▪/•
|
|
1591
|
+
*/
|
|
822
1592
|
mask?: string;
|
|
823
|
-
|
|
1593
|
+
/**
|
|
1594
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
1595
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
1596
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
1597
|
+
*/
|
|
1598
|
+
validate?: Validate<string>;
|
|
1599
|
+
/**
|
|
1600
|
+
* When enabled it causes the input to be cleared if/when validation fails.
|
|
1601
|
+
* @default false
|
|
1602
|
+
*/
|
|
824
1603
|
clearOnError?: boolean;
|
|
825
1604
|
}
|
|
1605
|
+
/**
|
|
1606
|
+
* The password prompt behaves like the {@link text} prompt, but the input is masked.
|
|
1607
|
+
*
|
|
1608
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#password-input
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```ts
|
|
1612
|
+
* import { password } from '@clack/prompts';
|
|
1613
|
+
*
|
|
1614
|
+
* const result = await password({
|
|
1615
|
+
* message: 'Enter your password',
|
|
1616
|
+
* });
|
|
1617
|
+
* ```
|
|
1618
|
+
*/
|
|
826
1619
|
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Options for the {@link path} prompt.
|
|
1622
|
+
*/
|
|
827
1623
|
interface PathOptions extends CommonOptions {
|
|
1624
|
+
/**
|
|
1625
|
+
* The message or question shown to the user above the input.
|
|
1626
|
+
*/
|
|
1627
|
+
message: string;
|
|
1628
|
+
/**
|
|
1629
|
+
* The starting directory for path suggestions (defaults to current working directory).
|
|
1630
|
+
*/
|
|
828
1631
|
root?: string;
|
|
1632
|
+
/**
|
|
1633
|
+
* When `true` only **directories** appear in suggestions while you navigate.
|
|
1634
|
+
*/
|
|
829
1635
|
directory?: boolean;
|
|
1636
|
+
/**
|
|
1637
|
+
* The starting path shown when the prompt first renders, which users can edit
|
|
1638
|
+
* before submitting. If not provided it will fall back to the given `root`,
|
|
1639
|
+
* or the current working directory.
|
|
1640
|
+
*
|
|
1641
|
+
* In `directory` mode, if the initial value points to a directory that exists,
|
|
1642
|
+
* pressing enter will submit the input instead of jumping to the first child.
|
|
1643
|
+
*/
|
|
830
1644
|
initialValue?: string;
|
|
831
|
-
|
|
832
|
-
|
|
1645
|
+
/**
|
|
1646
|
+
* A function or a [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
1647
|
+
* that validates user input. If a custom function is given, you should return a `string` or `Error`
|
|
1648
|
+
* to show as a validation error, or `undefined` to accept the result.
|
|
1649
|
+
*/
|
|
1650
|
+
validate?: Validate<string>;
|
|
833
1651
|
}
|
|
1652
|
+
/**
|
|
1653
|
+
* The `path` prompt extends `autocomplete` to provide file and directory suggestions.
|
|
1654
|
+
*
|
|
1655
|
+
* @see https://bomb.sh/docs/clack/packages/prompts/#path-selection
|
|
1656
|
+
*
|
|
1657
|
+
* @example
|
|
1658
|
+
* ```ts
|
|
1659
|
+
* import { path } from '@clack/prompts';
|
|
1660
|
+
*
|
|
1661
|
+
* const result = await path({
|
|
1662
|
+
* message: 'Select a file:',
|
|
1663
|
+
* root: process.cwd(),
|
|
1664
|
+
* directory: false,
|
|
1665
|
+
* });
|
|
1666
|
+
* ```
|
|
1667
|
+
*/
|
|
834
1668
|
declare const path: (opts: PathOptions) => Promise<string | symbol>;
|
|
835
1669
|
interface SpinnerOptions extends CommonOptions {
|
|
836
1670
|
indicator?: 'dots' | 'timer';
|
|
@@ -936,18 +1770,11 @@ declare const taskLog: (opts: TaskLogOptions) => {
|
|
|
936
1770
|
error(message: string, opts?: TaskLogCompletionOptions): void;
|
|
937
1771
|
success(message: string, opts?: TaskLogCompletionOptions): void;
|
|
938
1772
|
};
|
|
939
|
-
interface TextOptions extends CommonOptions {
|
|
940
|
-
message: string;
|
|
941
|
-
placeholder?: string;
|
|
942
|
-
defaultValue?: string;
|
|
943
|
-
initialValue?: string;
|
|
944
|
-
validate?: (value: string | undefined) => string | Error | undefined;
|
|
945
|
-
}
|
|
946
|
-
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
|
947
1773
|
//#endregion
|
|
948
1774
|
//#region src/prompts.d.ts
|
|
949
|
-
|
|
950
|
-
type
|
|
1775
|
+
declare const p: typeof index_d_exports;
|
|
1776
|
+
type PromptProgress = ReturnType<typeof p.progress>;
|
|
1777
|
+
type PromptSpinner = ReturnType<typeof p.spinner>;
|
|
951
1778
|
//#endregion
|
|
952
1779
|
//#region src/readPackageUp.d.ts
|
|
953
1780
|
interface ReadPackageUpResult<T = unknown> {
|
|
@@ -982,4 +1809,4 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
|
|
|
982
1809
|
*/
|
|
983
1810
|
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
984
1811
|
//#endregion
|
|
985
|
-
export { BuildLogger, BuildLoggerConfig, BuildType, ConfigBuilder, ConfigBuilderScaffold, ConfigResponse, CreateHotUpdaterConfigScaffoldFromBuilderOptions, CreateHotUpdaterConfigScaffoldOptions, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, HotUpdaterConfigOptions, HotUpdaterConfigScaffold, HotUpdaterLogWriter, IConfigBuilder, ImportInfo, LEGACY_BUNDLE_ERROR, ManagedHelperStatement, ManagedHelperStrategy, PromoteBundleDependencies, PromoteBundleInput, PromptProgress, PromptSpinner, ProviderConfig, ReactNativeMetadata, ReadPackageUpResult, WriteHotUpdaterConfigResult, banner, typedColors as colors, copyDirToTmp, createCopiedBundleArchive, createHotUpdaterConfigScaffold, createHotUpdaterConfigScaffoldFromBuilder, createLogWriter, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, ensureInstallPackages, getAndroidSdkPath, getCwd, getPackageManager, getReactNativeMetadatas, link, loadConfig, log, makeEnv,
|
|
1812
|
+
export { BuildLogger, BuildLoggerConfig, BuildType, ConfigBuilder, ConfigBuilderScaffold, ConfigResponse, CreateHotUpdaterConfigScaffoldFromBuilderOptions, CreateHotUpdaterConfigScaffoldOptions, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, HotUpdaterConfigOptions, HotUpdaterConfigScaffold, HotUpdaterInitEnv, HotUpdaterLogWriter, IConfigBuilder, ImportInfo, InitEnvFileError, InitError, InitProviderDefinition, InitProviderInputDefinition, InitProviderInputPersistence, LEGACY_BUNDLE_ERROR, ManagedHelperStatement, ManagedHelperStrategy, MissingInitInputsError, PromoteBundleDependencies, PromoteBundleInput, PromptProgress, PromptSpinner, ProviderConfig, ReactNativeMetadata, ReadPackageUpResult, RunInitOptions, WriteHotUpdaterConfigResult, assertInitInputs, assertInitProviderInputs, banner, typedColors as colors, confirmInitInputPersistence, copyDirToTmp, createCopiedBundleArchive, createHotUpdaterConfigScaffold, createHotUpdaterConfigScaffoldFromBuilder, createLogWriter, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, defineInitProvider, encryptJson, ensureInstallPackages, getAndroidSdkPath, getCwd, getHotUpdaterEnvValue, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, getMissingInitInputs, getMissingInitProviderInputs, getPackageManager, getReactNativeMetadatas, link, loadConfig, log, makeEnv, p, printBanner, promoteBundle, readHotUpdaterEnv, readHotUpdaterInitEnv, readPackageUp, renderImportStatements, resolveHotUpdaterServerVersion, resolveInitProviderInput, resolveInitProviderInputs, resolvePackageVersion, shouldAutoSelectOnlyInitResource, stripAnsi, transformEnv, transformTemplate, writeHotUpdaterConfig };
|