grimoire-wizard 0.5.1 → 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/dist/index.d.ts CHANGED
@@ -58,11 +58,18 @@ interface SelectOption {
58
58
  label: string;
59
59
  hint?: string;
60
60
  disabled?: boolean | string;
61
+ checked?: boolean;
61
62
  }
62
63
  interface SeparatorOption {
63
64
  separator: string;
64
65
  }
65
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
+ }
66
73
  interface BaseStepConfig {
67
74
  id: string;
68
75
  type: string;
@@ -73,6 +80,7 @@ interface BaseStepConfig {
73
80
  keepValuesOnPrevious?: boolean;
74
81
  required?: boolean;
75
82
  group?: string;
83
+ review?: StepReviewConfig;
76
84
  }
77
85
  interface TextStepConfig extends BaseStepConfig {
78
86
  type: 'text';
@@ -88,6 +96,7 @@ interface SelectStepConfig extends BaseStepConfig {
88
96
  routes?: Record<string, string>;
89
97
  pageSize?: number;
90
98
  loop?: boolean;
99
+ columns?: number;
91
100
  }
92
101
  interface MultiSelectStepConfig extends BaseStepConfig {
93
102
  type: 'multiselect';
@@ -98,6 +107,7 @@ interface MultiSelectStepConfig extends BaseStepConfig {
98
107
  max?: number;
99
108
  pageSize?: number;
100
109
  loop?: boolean;
110
+ columns?: number;
101
111
  }
102
112
  interface ConfirmStepConfig extends BaseStepConfig {
103
113
  type: 'confirm';
@@ -121,6 +131,7 @@ interface SearchStepConfig extends BaseStepConfig {
121
131
  default?: string;
122
132
  placeholder?: string;
123
133
  pageSize?: number;
134
+ columns?: number;
124
135
  loop?: boolean;
125
136
  }
126
137
  interface EditorStepConfig extends BaseStepConfig {
@@ -145,8 +156,22 @@ interface MessageStepConfig extends BaseStepConfig {
145
156
  }
146
157
  interface NoteStepConfig extends BaseStepConfig {
147
158
  type: 'note';
159
+ style?: NoteStyle;
160
+ }
161
+ interface BrowserStepConfig extends BaseStepConfig {
162
+ type: 'browser';
163
+ url: string;
164
+ fallback?: string;
148
165
  }
149
- 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';
150
175
  interface ThemeConfig {
151
176
  preset?: string;
152
177
  tokens?: {
@@ -157,6 +182,11 @@ interface ThemeConfig {
157
182
  info?: string;
158
183
  muted?: string;
159
184
  accent?: string;
185
+ highlight?: string;
186
+ highlightBg?: string;
187
+ pointer?: string;
188
+ checked?: string;
189
+ dimmed?: string;
160
190
  };
161
191
  icons?: {
162
192
  step?: string;
@@ -168,11 +198,14 @@ interface ThemeConfig {
168
198
  frames: string[];
169
199
  interval?: number;
170
200
  };
201
+ spinnerElapsed?: boolean;
202
+ progressBar?: ProgressBarConfig;
171
203
  }
172
204
  interface PreFlightCheck {
173
205
  name: string;
174
206
  run: string;
175
207
  message: string;
208
+ showOutput?: boolean;
176
209
  }
177
210
  interface ActionConfig {
178
211
  name?: string;
@@ -183,6 +216,7 @@ type OnCompleteHandler = (context: {
183
216
  answers: Record<string, unknown>;
184
217
  config: WizardConfig;
185
218
  }) => Promise<void> | void;
219
+ type ChecksStyle = 'spinner' | 'tasklist';
186
220
  interface WizardConfig {
187
221
  meta: {
188
222
  name: string;
@@ -190,6 +224,12 @@ interface WizardConfig {
190
224
  description?: string;
191
225
  review?: boolean;
192
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;
193
233
  };
194
234
  theme?: ThemeConfig;
195
235
  steps: StepConfig[];
@@ -201,6 +241,8 @@ interface WizardConfig {
201
241
  checks?: PreFlightCheck[];
202
242
  actions?: ActionConfig[];
203
243
  onComplete?: string;
244
+ /** Internal — set by loadWizardConfig to enable relative path resolution */
245
+ _configFilePath?: string;
204
246
  }
205
247
  interface WizardState {
206
248
  currentStepId: string;
@@ -263,6 +305,7 @@ type WizardEvent = {
263
305
  } | {
264
306
  type: 'checks:start';
265
307
  checks: PreFlightCheck[];
308
+ mode?: 'spinner' | 'tasklist';
266
309
  } | {
267
310
  type: 'check:pass';
268
311
  name: string;
@@ -286,6 +329,16 @@ type WizardEvent = {
286
329
  type: 'oncomplete:fail';
287
330
  error: string;
288
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
+ }
289
342
  interface ResolvedTheme {
290
343
  primary: (text: string) => string;
291
344
  success: (text: string) => string;
@@ -294,12 +347,51 @@ interface ResolvedTheme {
294
347
  info: (text: string) => string;
295
348
  muted: (text: string) => string;
296
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;
297
355
  bold: (text: string) => string;
298
356
  icons: Required<NonNullable<ThemeConfig['icons']>>;
299
357
  spinner: {
300
358
  frames: string[];
301
359
  interval: number;
302
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>;
303
395
  }
304
396
  interface WizardRenderer {
305
397
  renderText(step: TextStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
@@ -429,10 +521,10 @@ interface RunWizardOptions {
429
521
  plain?: boolean;
430
522
  mockAnswers?: Record<string, unknown>;
431
523
  templateAnswers?: Record<string, unknown>;
432
- onBeforeStep?: (stepId: string, step: StepConfig, state: WizardState) => Promise<void> | void;
433
- onAfterStep?: (stepId: string, value: unknown, state: WizardState) => Promise<void> | void;
524
+ onBeforeStep?: (stepId: string, step: StepConfig, context: HookContext) => Promise<void> | void;
525
+ onAfterStep?: (stepId: string, value: unknown, context: HookContext) => Promise<void> | void;
434
526
  onStepComplete?: (stepId: string, value: unknown, state: WizardState) => void;
435
- onCancel?: (state: WizardState) => void;
527
+ onCancel?: (state: WizardState) => Promise<void> | void;
436
528
  plugins?: GrimoirePlugin[];
437
529
  asyncValidate?: (stepId: string, value: unknown, answers: Record<string, unknown>) => Promise<string | null>;
438
530
  cache?: boolean | {
@@ -443,13 +535,14 @@ interface RunWizardOptions {
443
535
  configFilePath?: string;
444
536
  optionsProvider?: (stepId: string, answers: Record<string, unknown>) => Promise<SelectOption[] | undefined>;
445
537
  }
446
- declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme, renderer?: WizardRenderer): void;
538
+ declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme, renderer?: WizardRenderer, checksStyle?: 'spinner' | 'tasklist'): void;
447
539
  declare function runWizard(config: WizardConfig, options?: RunWizardOptions): Promise<Record<string, unknown>>;
448
540
 
449
541
  declare function defineWizard(config: WizardConfig): WizardConfig;
450
542
 
451
543
  declare class InquirerRenderer implements WizardRenderer {
452
544
  renderStepHeader(stepIndex: number, totalVisible: number, message: string, theme: ResolvedTheme, description?: string): void;
545
+ renderNote(step: NoteStepConfig, theme: ResolvedTheme): void;
453
546
  renderText(step: TextStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
454
547
  renderSelect(step: SelectStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
455
548
  renderMultiSelect(step: MultiSelectStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string[]>;
@@ -465,6 +558,12 @@ declare class InquirerRenderer implements WizardRenderer {
465
558
  renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
466
559
  clear(): void;
467
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[];
468
567
 
469
568
  /**
470
569
  * Resolve {{stepId}} placeholders in a template string.
@@ -478,14 +577,15 @@ declare function resolveTemplate(template: string, answers: Record<string, unkno
478
577
  */
479
578
  declare function resolveTemplateStrict(template: string, answers: Record<string, unknown>): string;
480
579
 
481
- /**
482
- * Render a figlet ASCII art banner for the wizard name.
483
- * Falls back to plain bold text if figlet rendering fails.
484
- */
485
- declare function renderBanner(name: string, theme: ResolvedTheme, options?: {
580
+ interface BannerOptions {
486
581
  plain?: boolean;
487
582
  icon?: string;
488
- }): string;
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;
489
589
 
490
590
  declare function slugify(name: string): string;
491
591
  declare function getCacheDir(customDir?: string): string;
@@ -518,6 +618,8 @@ declare class InkRenderer implements WizardRenderer {
518
618
  declare class ClackRenderer extends InquirerRenderer {
519
619
  private spinnerInterval;
520
620
  private spinnerFrameIndex;
621
+ private spinnerStartTime;
622
+ private checksMode;
521
623
  renderStepHeader(): void;
522
624
  renderGroupHeader(): void;
523
625
  renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
@@ -558,4 +660,4 @@ interface PipelineStep {
558
660
  }
559
661
  declare function runPipeline(steps: PipelineStep[], globalOptions?: Omit<RunWizardOptions, 'mockAnswers' | 'templateAnswers'>): Promise<Record<string, Record<string, unknown>>>;
560
662
 
561
- 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 };