grimoire-wizard 0.5.2 → 0.6.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/README.md +66 -51
- package/dist/cli.js +504 -69
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +113 -12
- package/dist/index.js +506 -70
- package/dist/index.js.map +1 -1
- package/examples/yaml/demo.yaml +54 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,12 @@ interface SeparatorOption {
|
|
|
64
64
|
separator: string;
|
|
65
65
|
}
|
|
66
66
|
type SelectChoice = SelectOption | SeparatorOption;
|
|
67
|
+
type ReviewFormat = 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
68
|
+
interface StepReviewConfig {
|
|
69
|
+
hide?: boolean;
|
|
70
|
+
label?: string;
|
|
71
|
+
format?: ReviewFormat;
|
|
72
|
+
}
|
|
67
73
|
interface BaseStepConfig {
|
|
68
74
|
id: string;
|
|
69
75
|
type: string;
|
|
@@ -74,6 +80,7 @@ interface BaseStepConfig {
|
|
|
74
80
|
keepValuesOnPrevious?: boolean;
|
|
75
81
|
required?: boolean;
|
|
76
82
|
group?: string;
|
|
83
|
+
review?: StepReviewConfig;
|
|
77
84
|
}
|
|
78
85
|
interface TextStepConfig extends BaseStepConfig {
|
|
79
86
|
type: 'text';
|
|
@@ -89,6 +96,7 @@ interface SelectStepConfig extends BaseStepConfig {
|
|
|
89
96
|
routes?: Record<string, string>;
|
|
90
97
|
pageSize?: number;
|
|
91
98
|
loop?: boolean;
|
|
99
|
+
columns?: number;
|
|
92
100
|
}
|
|
93
101
|
interface MultiSelectStepConfig extends BaseStepConfig {
|
|
94
102
|
type: 'multiselect';
|
|
@@ -99,6 +107,7 @@ interface MultiSelectStepConfig extends BaseStepConfig {
|
|
|
99
107
|
max?: number;
|
|
100
108
|
pageSize?: number;
|
|
101
109
|
loop?: boolean;
|
|
110
|
+
columns?: number;
|
|
102
111
|
}
|
|
103
112
|
interface ConfirmStepConfig extends BaseStepConfig {
|
|
104
113
|
type: 'confirm';
|
|
@@ -122,6 +131,7 @@ interface SearchStepConfig extends BaseStepConfig {
|
|
|
122
131
|
default?: string;
|
|
123
132
|
placeholder?: string;
|
|
124
133
|
pageSize?: number;
|
|
134
|
+
columns?: number;
|
|
125
135
|
loop?: boolean;
|
|
126
136
|
}
|
|
127
137
|
interface EditorStepConfig extends BaseStepConfig {
|
|
@@ -146,8 +156,22 @@ interface MessageStepConfig extends BaseStepConfig {
|
|
|
146
156
|
}
|
|
147
157
|
interface NoteStepConfig extends BaseStepConfig {
|
|
148
158
|
type: 'note';
|
|
159
|
+
style?: NoteStyle;
|
|
160
|
+
}
|
|
161
|
+
interface BrowserStepConfig extends BaseStepConfig {
|
|
162
|
+
type: 'browser';
|
|
163
|
+
url: string;
|
|
164
|
+
fallback?: string;
|
|
149
165
|
}
|
|
150
|
-
type StepConfig = TextStepConfig | SelectStepConfig | MultiSelectStepConfig | ConfirmStepConfig | PasswordStepConfig | NumberStepConfig | SearchStepConfig | EditorStepConfig | PathStepConfig | ToggleStepConfig | MessageStepConfig | NoteStepConfig;
|
|
166
|
+
type StepConfig = TextStepConfig | SelectStepConfig | MultiSelectStepConfig | ConfirmStepConfig | PasswordStepConfig | NumberStepConfig | SearchStepConfig | EditorStepConfig | PathStepConfig | ToggleStepConfig | MessageStepConfig | NoteStepConfig | BrowserStepConfig;
|
|
167
|
+
type ProgressBarStyle = 'blocks' | 'line' | 'dots' | 'arrow';
|
|
168
|
+
interface ProgressBarConfig {
|
|
169
|
+
width?: number;
|
|
170
|
+
filledColor?: string;
|
|
171
|
+
emptyColor?: string;
|
|
172
|
+
style?: ProgressBarStyle;
|
|
173
|
+
}
|
|
174
|
+
type NoteStyle = 'info' | 'warning' | 'error' | 'success' | 'code' | 'banner';
|
|
151
175
|
interface ThemeConfig {
|
|
152
176
|
preset?: string;
|
|
153
177
|
tokens?: {
|
|
@@ -158,6 +182,11 @@ interface ThemeConfig {
|
|
|
158
182
|
info?: string;
|
|
159
183
|
muted?: string;
|
|
160
184
|
accent?: string;
|
|
185
|
+
highlight?: string;
|
|
186
|
+
highlightBg?: string;
|
|
187
|
+
pointer?: string;
|
|
188
|
+
checked?: string;
|
|
189
|
+
dimmed?: string;
|
|
161
190
|
};
|
|
162
191
|
icons?: {
|
|
163
192
|
step?: string;
|
|
@@ -169,11 +198,14 @@ interface ThemeConfig {
|
|
|
169
198
|
frames: string[];
|
|
170
199
|
interval?: number;
|
|
171
200
|
};
|
|
201
|
+
spinnerElapsed?: boolean;
|
|
202
|
+
progressBar?: ProgressBarConfig;
|
|
172
203
|
}
|
|
173
204
|
interface PreFlightCheck {
|
|
174
205
|
name: string;
|
|
175
206
|
run: string;
|
|
176
207
|
message: string;
|
|
208
|
+
showOutput?: boolean;
|
|
177
209
|
}
|
|
178
210
|
interface ActionConfig {
|
|
179
211
|
name?: string;
|
|
@@ -184,6 +216,7 @@ type OnCompleteHandler = (context: {
|
|
|
184
216
|
answers: Record<string, unknown>;
|
|
185
217
|
config: WizardConfig;
|
|
186
218
|
}) => Promise<void> | void;
|
|
219
|
+
type ChecksStyle = 'spinner' | 'tasklist';
|
|
187
220
|
interface WizardConfig {
|
|
188
221
|
meta: {
|
|
189
222
|
name: string;
|
|
@@ -191,6 +224,12 @@ interface WizardConfig {
|
|
|
191
224
|
description?: string;
|
|
192
225
|
review?: boolean;
|
|
193
226
|
icon?: string;
|
|
227
|
+
iconSize?: 'small' | 'medium' | 'large' | number;
|
|
228
|
+
font?: string;
|
|
229
|
+
banner?: string | ((theme: ResolvedTheme) => string);
|
|
230
|
+
subtitle?: string;
|
|
231
|
+
clearBetweenSteps?: boolean;
|
|
232
|
+
checksStyle?: ChecksStyle;
|
|
194
233
|
};
|
|
195
234
|
theme?: ThemeConfig;
|
|
196
235
|
steps: StepConfig[];
|
|
@@ -202,6 +241,8 @@ interface WizardConfig {
|
|
|
202
241
|
checks?: PreFlightCheck[];
|
|
203
242
|
actions?: ActionConfig[];
|
|
204
243
|
onComplete?: string;
|
|
244
|
+
/** Internal — set by loadWizardConfig to enable relative path resolution */
|
|
245
|
+
_configFilePath?: string;
|
|
205
246
|
}
|
|
206
247
|
interface WizardState {
|
|
207
248
|
currentStepId: string;
|
|
@@ -264,6 +305,7 @@ type WizardEvent = {
|
|
|
264
305
|
} | {
|
|
265
306
|
type: 'checks:start';
|
|
266
307
|
checks: PreFlightCheck[];
|
|
308
|
+
mode?: 'spinner' | 'tasklist';
|
|
267
309
|
} | {
|
|
268
310
|
type: 'check:pass';
|
|
269
311
|
name: string;
|
|
@@ -287,6 +329,16 @@ type WizardEvent = {
|
|
|
287
329
|
type: 'oncomplete:fail';
|
|
288
330
|
error: string;
|
|
289
331
|
};
|
|
332
|
+
interface ResolvedProgressBar {
|
|
333
|
+
width: number;
|
|
334
|
+
filledColor: (text: string) => string;
|
|
335
|
+
emptyColor: (text: string) => string;
|
|
336
|
+
style: ProgressBarStyle;
|
|
337
|
+
chars: {
|
|
338
|
+
filled: string;
|
|
339
|
+
empty: string;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
290
342
|
interface ResolvedTheme {
|
|
291
343
|
primary: (text: string) => string;
|
|
292
344
|
success: (text: string) => string;
|
|
@@ -295,12 +347,51 @@ interface ResolvedTheme {
|
|
|
295
347
|
info: (text: string) => string;
|
|
296
348
|
muted: (text: string) => string;
|
|
297
349
|
accent: (text: string) => string;
|
|
350
|
+
highlight: (text: string) => string;
|
|
351
|
+
highlightBg: (text: string) => string;
|
|
352
|
+
pointer: (text: string) => string;
|
|
353
|
+
checked: (text: string) => string;
|
|
354
|
+
dimmed: (text: string) => string;
|
|
298
355
|
bold: (text: string) => string;
|
|
299
356
|
icons: Required<NonNullable<ThemeConfig['icons']>>;
|
|
300
357
|
spinner: {
|
|
301
358
|
frames: string[];
|
|
302
359
|
interval: number;
|
|
303
360
|
};
|
|
361
|
+
spinnerElapsed: boolean;
|
|
362
|
+
progressBar: ResolvedProgressBar;
|
|
363
|
+
}
|
|
364
|
+
type PromptConfig = {
|
|
365
|
+
type: 'select';
|
|
366
|
+
message: string;
|
|
367
|
+
options: SelectChoice[];
|
|
368
|
+
default?: string;
|
|
369
|
+
} | {
|
|
370
|
+
type: 'text' | 'password';
|
|
371
|
+
message: string;
|
|
372
|
+
default?: string;
|
|
373
|
+
} | {
|
|
374
|
+
type: 'confirm';
|
|
375
|
+
message: string;
|
|
376
|
+
default?: boolean;
|
|
377
|
+
} | {
|
|
378
|
+
type: 'number';
|
|
379
|
+
message: string;
|
|
380
|
+
default?: number;
|
|
381
|
+
};
|
|
382
|
+
interface HookContext {
|
|
383
|
+
readonly answers: Readonly<Record<string, unknown>>;
|
|
384
|
+
readonly state: Readonly<WizardState>;
|
|
385
|
+
showNote: (title: string, body: string) => void;
|
|
386
|
+
setNextStep: (stepId: string) => void;
|
|
387
|
+
}
|
|
388
|
+
interface HookContext {
|
|
389
|
+
readonly answers: Readonly<Record<string, unknown>>;
|
|
390
|
+
readonly state: Readonly<WizardState>;
|
|
391
|
+
showNote: (title: string, body: string) => void;
|
|
392
|
+
setNextStep: (stepId: string) => void;
|
|
393
|
+
openBrowser: (url: string) => Promise<void>;
|
|
394
|
+
prompt: (config: PromptConfig) => Promise<unknown>;
|
|
304
395
|
}
|
|
305
396
|
interface WizardRenderer {
|
|
306
397
|
renderText(step: TextStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
|
|
@@ -430,10 +521,10 @@ interface RunWizardOptions {
|
|
|
430
521
|
plain?: boolean;
|
|
431
522
|
mockAnswers?: Record<string, unknown>;
|
|
432
523
|
templateAnswers?: Record<string, unknown>;
|
|
433
|
-
onBeforeStep?: (stepId: string, step: StepConfig,
|
|
434
|
-
onAfterStep?: (stepId: string, value: unknown,
|
|
524
|
+
onBeforeStep?: (stepId: string, step: StepConfig, context: HookContext) => Promise<void> | void;
|
|
525
|
+
onAfterStep?: (stepId: string, value: unknown, context: HookContext) => Promise<void> | void;
|
|
435
526
|
onStepComplete?: (stepId: string, value: unknown, state: WizardState) => void;
|
|
436
|
-
onCancel?: (state: WizardState) => void;
|
|
527
|
+
onCancel?: (state: WizardState) => Promise<void> | void;
|
|
437
528
|
plugins?: GrimoirePlugin[];
|
|
438
529
|
asyncValidate?: (stepId: string, value: unknown, answers: Record<string, unknown>) => Promise<string | null>;
|
|
439
530
|
cache?: boolean | {
|
|
@@ -444,13 +535,14 @@ interface RunWizardOptions {
|
|
|
444
535
|
configFilePath?: string;
|
|
445
536
|
optionsProvider?: (stepId: string, answers: Record<string, unknown>) => Promise<SelectOption[] | undefined>;
|
|
446
537
|
}
|
|
447
|
-
declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme, renderer?: WizardRenderer): void;
|
|
538
|
+
declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme, renderer?: WizardRenderer, checksStyle?: 'spinner' | 'tasklist'): void;
|
|
448
539
|
declare function runWizard(config: WizardConfig, options?: RunWizardOptions): Promise<Record<string, unknown>>;
|
|
449
540
|
|
|
450
541
|
declare function defineWizard(config: WizardConfig): WizardConfig;
|
|
451
542
|
|
|
452
543
|
declare class InquirerRenderer implements WizardRenderer {
|
|
453
544
|
renderStepHeader(stepIndex: number, totalVisible: number, message: string, theme: ResolvedTheme, description?: string): void;
|
|
545
|
+
renderNote(step: NoteStepConfig, theme: ResolvedTheme): void;
|
|
454
546
|
renderText(step: TextStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
|
|
455
547
|
renderSelect(step: SelectStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
|
|
456
548
|
renderMultiSelect(step: MultiSelectStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string[]>;
|
|
@@ -466,6 +558,12 @@ declare class InquirerRenderer implements WizardRenderer {
|
|
|
466
558
|
renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
|
|
467
559
|
clear(): void;
|
|
468
560
|
}
|
|
561
|
+
declare function applyColumns<T extends {
|
|
562
|
+
name: string;
|
|
563
|
+
value: string;
|
|
564
|
+
description?: string;
|
|
565
|
+
disabled?: boolean | string;
|
|
566
|
+
}>(items: T[], columns: number): T[];
|
|
469
567
|
|
|
470
568
|
/**
|
|
471
569
|
* Resolve {{stepId}} placeholders in a template string.
|
|
@@ -479,14 +577,15 @@ declare function resolveTemplate(template: string, answers: Record<string, unkno
|
|
|
479
577
|
*/
|
|
480
578
|
declare function resolveTemplateStrict(template: string, answers: Record<string, unknown>): string;
|
|
481
579
|
|
|
482
|
-
|
|
483
|
-
* Render a figlet ASCII art banner for the wizard name.
|
|
484
|
-
* Falls back to plain bold text if figlet rendering fails.
|
|
485
|
-
*/
|
|
486
|
-
declare function renderBanner(name: string, theme: ResolvedTheme, options?: {
|
|
580
|
+
interface BannerOptions {
|
|
487
581
|
plain?: boolean;
|
|
488
582
|
icon?: string;
|
|
489
|
-
|
|
583
|
+
iconSize?: 'small' | 'medium' | 'large' | number;
|
|
584
|
+
font?: string;
|
|
585
|
+
banner?: string | ((theme: ResolvedTheme) => string);
|
|
586
|
+
subtitle?: string;
|
|
587
|
+
}
|
|
588
|
+
declare function renderBanner(name: string, theme: ResolvedTheme, options?: BannerOptions): string;
|
|
490
589
|
|
|
491
590
|
declare function slugify(name: string): string;
|
|
492
591
|
declare function getCacheDir(customDir?: string): string;
|
|
@@ -519,6 +618,8 @@ declare class InkRenderer implements WizardRenderer {
|
|
|
519
618
|
declare class ClackRenderer extends InquirerRenderer {
|
|
520
619
|
private spinnerInterval;
|
|
521
620
|
private spinnerFrameIndex;
|
|
621
|
+
private spinnerStartTime;
|
|
622
|
+
private checksMode;
|
|
522
623
|
renderStepHeader(): void;
|
|
523
624
|
renderGroupHeader(): void;
|
|
524
625
|
renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
|
|
@@ -559,4 +660,4 @@ interface PipelineStep {
|
|
|
559
660
|
}
|
|
560
661
|
declare function runPipeline(steps: PipelineStep[], globalOptions?: Omit<RunWizardOptions, 'mockAnswers' | 'templateAnswers'>): Promise<Record<string, Record<string, unknown>>>;
|
|
561
662
|
|
|
562
|
-
export { type ActionConfig, ClackRenderer, type Condition, type ConfirmStepConfig, DEFAULT_SPINNER, type EditorStepConfig, type GrimoirePlugin, InkRenderer, InquirerRenderer, type MessageStepConfig, type MultiSelectStepConfig, type NoteStepConfig, type NumberStepConfig, type OnCompleteHandler, type PasswordStepConfig, type PathStepConfig, type PipelineStep, type PreFlightCheck, type ResolvedTheme, type RunWizardOptions, type SavedProgress, type SearchStepConfig, type SelectChoice, type SelectOption, type SelectStepConfig, type SeparatorOption, type SpinnerConfig, type SpinnerName, type StepConfig, type StepPlugin, type TextStepConfig, type ThemeConfig, type ToggleStepConfig, type ValidationRule, type WizardConfig, type WizardEvent, type WizardRenderer, type WizardState, type WizardTransition, clearCache, clearMruData, clearPlugins, clearProgress, createWizardState, defineWizard, deleteTemplate, evaluateCondition, getCacheDir, getOrderedOptions, getPluginStep, getVisibleSteps, isStepVisible, listTemplates, loadCachedAnswers, loadProgress, loadTemplate, loadWizardConfig, parseWizardConfig, parseWizardYAML, recordSelection, registerPlugin, renderBanner, resolveEnvDefault, resolveNextStep, resolveSpinner, resolveTemplate, resolveTemplateStrict, resolveTheme, runPipeline, runPreFlightChecks, runWizard, saveCachedAnswers, saveProgress, saveTemplate, slugify, spinners, validateStepAnswer, wizardReducer };
|
|
663
|
+
export { type ActionConfig, type BrowserStepConfig, type ChecksStyle, ClackRenderer, type Condition, type ConfirmStepConfig, DEFAULT_SPINNER, type EditorStepConfig, type GrimoirePlugin, type HookContext, InkRenderer, InquirerRenderer, type MessageStepConfig, type MultiSelectStepConfig, type NoteStepConfig, type NoteStyle, type NumberStepConfig, type OnCompleteHandler, type PasswordStepConfig, type PathStepConfig, type PipelineStep, type PreFlightCheck, type ProgressBarConfig, type ProgressBarStyle, type PromptConfig, type ResolvedProgressBar, type ResolvedTheme, type ReviewFormat, type RunWizardOptions, type SavedProgress, type SearchStepConfig, type SelectChoice, type SelectOption, type SelectStepConfig, type SeparatorOption, type SpinnerConfig, type SpinnerName, type StepConfig, type StepPlugin, type StepReviewConfig, type TextStepConfig, type ThemeConfig, type ToggleStepConfig, type ValidationRule, type WizardConfig, type WizardEvent, type WizardRenderer, type WizardState, type WizardTransition, applyColumns, clearCache, clearMruData, clearPlugins, clearProgress, createWizardState, defineWizard, deleteTemplate, evaluateCondition, getCacheDir, getOrderedOptions, getPluginStep, getVisibleSteps, isStepVisible, listTemplates, loadCachedAnswers, loadProgress, loadTemplate, loadWizardConfig, parseWizardConfig, parseWizardYAML, recordSelection, registerPlugin, renderBanner, resolveEnvDefault, resolveNextStep, resolveSpinner, resolveTemplate, resolveTemplateStrict, resolveTheme, runPipeline, runPreFlightChecks, runWizard, saveCachedAnswers, saveProgress, saveTemplate, slugify, spinners, validateStepAnswer, wizardReducer };
|