grimoire-wizard 0.3.1 → 0.5.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 +185 -18
- package/dist/cli.js +602 -109
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +207 -3
- package/dist/index.js +921 -371
- package/dist/index.js.map +1 -1
- package/examples/handlers/setup-project.ts +9 -0
- package/examples/json/all-features.json +66 -0
- package/examples/json/appstore-screenshot-wizard.json +362 -0
- package/examples/json/appstore-upload.json +104 -0
- package/examples/json/basic.json +72 -0
- package/examples/json/batch-generate.json +186 -0
- package/examples/json/brief-builder.json +519 -0
- package/examples/json/conditional.json +155 -0
- package/examples/json/cost-analyzer.json +83 -0
- package/examples/json/demo.json +130 -0
- package/examples/json/scraper-selector.json +63 -0
- package/examples/json/themed-catppuccin.json +39 -0
- package/examples/json/themed.json +103 -0
- package/examples/json/with-actions.json +61 -0
- package/examples/json/with-checks.json +47 -0
- package/examples/json/with-oncomplete.json +45 -0
- package/examples/yaml/appstore-screenshot-wizard.yaml +321 -0
- package/examples/yaml/appstore-upload.yaml +84 -0
- package/examples/yaml/batch-generate.yaml +156 -0
- package/examples/yaml/brief-builder.yaml +429 -0
- package/examples/yaml/cost-analyzer.yaml +69 -0
- package/examples/yaml/pipeline.yaml +35 -0
- package/examples/yaml/scraper-selector.yaml +52 -0
- package/examples/yaml/themed-catppuccin.yaml +31 -0
- package/examples/yaml/with-actions.yaml +45 -0
- package/examples/yaml/with-oncomplete.yaml +35 -0
- package/package.json +1 -1
- /package/examples/{all-features.yaml → yaml/all-features.yaml} +0 -0
- /package/examples/{base.yaml → yaml/base.yaml} +0 -0
- /package/examples/{basic.yaml → yaml/basic.yaml} +0 -0
- /package/examples/{conditional.yaml → yaml/conditional.yaml} +0 -0
- /package/examples/{demo.yaml → yaml/demo.yaml} +0 -0
- /package/examples/{ebay-mcp-setup.yaml → yaml/ebay-mcp-setup.yaml} +0 -0
- /package/examples/{extended.yaml → yaml/extended.yaml} +0 -0
- /package/examples/{themed.yaml → yaml/themed.yaml} +0 -0
- /package/examples/{with-checks.yaml → yaml/with-checks.yaml} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -143,8 +143,12 @@ interface ToggleStepConfig extends BaseStepConfig {
|
|
|
143
143
|
interface MessageStepConfig extends BaseStepConfig {
|
|
144
144
|
type: 'message';
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
interface NoteStepConfig extends BaseStepConfig {
|
|
147
|
+
type: 'note';
|
|
148
|
+
}
|
|
149
|
+
type StepConfig = TextStepConfig | SelectStepConfig | MultiSelectStepConfig | ConfirmStepConfig | PasswordStepConfig | NumberStepConfig | SearchStepConfig | EditorStepConfig | PathStepConfig | ToggleStepConfig | MessageStepConfig | NoteStepConfig;
|
|
147
150
|
interface ThemeConfig {
|
|
151
|
+
preset?: string;
|
|
148
152
|
tokens?: {
|
|
149
153
|
primary?: string;
|
|
150
154
|
success?: string;
|
|
@@ -160,6 +164,10 @@ interface ThemeConfig {
|
|
|
160
164
|
stepPending?: string;
|
|
161
165
|
pointer?: string;
|
|
162
166
|
};
|
|
167
|
+
spinner?: string | {
|
|
168
|
+
frames: string[];
|
|
169
|
+
interval?: number;
|
|
170
|
+
};
|
|
163
171
|
}
|
|
164
172
|
interface PreFlightCheck {
|
|
165
173
|
name: string;
|
|
@@ -171,11 +179,16 @@ interface ActionConfig {
|
|
|
171
179
|
run: string;
|
|
172
180
|
when?: Condition;
|
|
173
181
|
}
|
|
182
|
+
type OnCompleteHandler = (context: {
|
|
183
|
+
answers: Record<string, unknown>;
|
|
184
|
+
config: WizardConfig;
|
|
185
|
+
}) => Promise<void> | void;
|
|
174
186
|
interface WizardConfig {
|
|
175
187
|
meta: {
|
|
176
188
|
name: string;
|
|
177
189
|
version?: string;
|
|
178
190
|
description?: string;
|
|
191
|
+
review?: boolean;
|
|
179
192
|
};
|
|
180
193
|
theme?: ThemeConfig;
|
|
181
194
|
steps: StepConfig[];
|
|
@@ -186,6 +199,7 @@ interface WizardConfig {
|
|
|
186
199
|
extends?: string;
|
|
187
200
|
checks?: PreFlightCheck[];
|
|
188
201
|
actions?: ActionConfig[];
|
|
202
|
+
onComplete?: string;
|
|
189
203
|
}
|
|
190
204
|
interface WizardState {
|
|
191
205
|
currentStepId: string;
|
|
@@ -205,6 +219,72 @@ type WizardTransition = {
|
|
|
205
219
|
} | {
|
|
206
220
|
type: 'CANCEL';
|
|
207
221
|
};
|
|
222
|
+
type WizardEvent = {
|
|
223
|
+
type: 'session:start';
|
|
224
|
+
wizard: string;
|
|
225
|
+
description?: string;
|
|
226
|
+
totalSteps: number;
|
|
227
|
+
} | {
|
|
228
|
+
type: 'session:end';
|
|
229
|
+
answers: Record<string, unknown>;
|
|
230
|
+
cancelled: boolean;
|
|
231
|
+
} | {
|
|
232
|
+
type: 'group:start';
|
|
233
|
+
group: string;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'step:start';
|
|
236
|
+
stepId: string;
|
|
237
|
+
stepIndex: number;
|
|
238
|
+
totalVisible: number;
|
|
239
|
+
step: StepConfig;
|
|
240
|
+
} | {
|
|
241
|
+
type: 'step:complete';
|
|
242
|
+
stepId: string;
|
|
243
|
+
value: unknown;
|
|
244
|
+
step: StepConfig;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'step:error';
|
|
247
|
+
stepId: string;
|
|
248
|
+
error: string;
|
|
249
|
+
} | {
|
|
250
|
+
type: 'step:back';
|
|
251
|
+
stepId: string;
|
|
252
|
+
} | {
|
|
253
|
+
type: 'spinner:start';
|
|
254
|
+
message: string;
|
|
255
|
+
} | {
|
|
256
|
+
type: 'spinner:stop';
|
|
257
|
+
message?: string;
|
|
258
|
+
} | {
|
|
259
|
+
type: 'note';
|
|
260
|
+
title: string;
|
|
261
|
+
body: string;
|
|
262
|
+
} | {
|
|
263
|
+
type: 'checks:start';
|
|
264
|
+
checks: PreFlightCheck[];
|
|
265
|
+
} | {
|
|
266
|
+
type: 'check:pass';
|
|
267
|
+
name: string;
|
|
268
|
+
} | {
|
|
269
|
+
type: 'check:fail';
|
|
270
|
+
name: string;
|
|
271
|
+
message: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: 'actions:start';
|
|
274
|
+
} | {
|
|
275
|
+
type: 'action:pass';
|
|
276
|
+
name: string;
|
|
277
|
+
} | {
|
|
278
|
+
type: 'action:fail';
|
|
279
|
+
name: string;
|
|
280
|
+
} | {
|
|
281
|
+
type: 'oncomplete:start';
|
|
282
|
+
} | {
|
|
283
|
+
type: 'oncomplete:pass';
|
|
284
|
+
} | {
|
|
285
|
+
type: 'oncomplete:fail';
|
|
286
|
+
error: string;
|
|
287
|
+
};
|
|
208
288
|
interface ResolvedTheme {
|
|
209
289
|
primary: (text: string) => string;
|
|
210
290
|
success: (text: string) => string;
|
|
@@ -215,6 +295,10 @@ interface ResolvedTheme {
|
|
|
215
295
|
accent: (text: string) => string;
|
|
216
296
|
bold: (text: string) => string;
|
|
217
297
|
icons: Required<NonNullable<ThemeConfig['icons']>>;
|
|
298
|
+
spinner: {
|
|
299
|
+
frames: string[];
|
|
300
|
+
interval: number;
|
|
301
|
+
};
|
|
218
302
|
}
|
|
219
303
|
interface WizardRenderer {
|
|
220
304
|
renderText(step: TextStepConfig, state: WizardState, theme: ResolvedTheme): Promise<string>;
|
|
@@ -232,6 +316,7 @@ interface WizardRenderer {
|
|
|
232
316
|
renderGroupHeader(group: string, theme: ResolvedTheme): void;
|
|
233
317
|
renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
|
|
234
318
|
clear(): void;
|
|
319
|
+
onEvent?(event: WizardEvent, theme: ResolvedTheme): void;
|
|
235
320
|
}
|
|
236
321
|
|
|
237
322
|
declare function parseWizardConfig(raw: unknown): WizardConfig;
|
|
@@ -250,6 +335,79 @@ declare function wizardReducer(state: WizardState, transition: WizardTransition,
|
|
|
250
335
|
|
|
251
336
|
declare function resolveTheme(themeConfig?: ThemeConfig): ResolvedTheme;
|
|
252
337
|
|
|
338
|
+
interface SpinnerConfig {
|
|
339
|
+
frames: string[];
|
|
340
|
+
interval: number;
|
|
341
|
+
}
|
|
342
|
+
declare const spinners: {
|
|
343
|
+
readonly dots: {
|
|
344
|
+
readonly interval: 80;
|
|
345
|
+
readonly frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
346
|
+
};
|
|
347
|
+
readonly dots2: {
|
|
348
|
+
readonly interval: 80;
|
|
349
|
+
readonly frames: ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"];
|
|
350
|
+
};
|
|
351
|
+
readonly line: {
|
|
352
|
+
readonly interval: 130;
|
|
353
|
+
readonly frames: ["-", "\\", "|", "/"];
|
|
354
|
+
};
|
|
355
|
+
readonly arc: {
|
|
356
|
+
readonly interval: 100;
|
|
357
|
+
readonly frames: ["◜", "◠", "◝", "◞", "◡", "◟"];
|
|
358
|
+
};
|
|
359
|
+
readonly circle: {
|
|
360
|
+
readonly interval: 80;
|
|
361
|
+
readonly frames: ["◒", "◐", "◓", "◑"];
|
|
362
|
+
};
|
|
363
|
+
readonly circleHalves: {
|
|
364
|
+
readonly interval: 50;
|
|
365
|
+
readonly frames: ["◐", "◓", "◑", "◒"];
|
|
366
|
+
};
|
|
367
|
+
readonly triangle: {
|
|
368
|
+
readonly interval: 50;
|
|
369
|
+
readonly frames: ["◢", "◣", "◤", "◥"];
|
|
370
|
+
};
|
|
371
|
+
readonly pipe: {
|
|
372
|
+
readonly interval: 100;
|
|
373
|
+
readonly frames: ["┤", "┘", "┴", "└", "├", "┌", "┬", "┐"];
|
|
374
|
+
};
|
|
375
|
+
readonly arrow: {
|
|
376
|
+
readonly interval: 100;
|
|
377
|
+
readonly frames: ["←", "↖", "↑", "↗", "→", "↘", "↓", "↙"];
|
|
378
|
+
};
|
|
379
|
+
readonly arrow3: {
|
|
380
|
+
readonly interval: 120;
|
|
381
|
+
readonly frames: ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"];
|
|
382
|
+
};
|
|
383
|
+
readonly bouncingBar: {
|
|
384
|
+
readonly interval: 80;
|
|
385
|
+
readonly frames: ["[ ]", "[= ]", "[== ]", "[=== ]", "[====]", "[ ===]", "[ ==]", "[ =]", "[ ]", "[ =]", "[ ==]", "[ ===]", "[====]", "[=== ]", "[== ]", "[= ]"];
|
|
386
|
+
};
|
|
387
|
+
readonly bouncingBall: {
|
|
388
|
+
readonly interval: 80;
|
|
389
|
+
readonly frames: ["( ● )", "( ● )", "( ● )", "( ● )", "( ●)", "( ● )", "( ● )", "( ● )", "( ● )", "(● )"];
|
|
390
|
+
};
|
|
391
|
+
readonly simpleDots: {
|
|
392
|
+
readonly interval: 400;
|
|
393
|
+
readonly frames: [". ", ".. ", "...", " "];
|
|
394
|
+
};
|
|
395
|
+
readonly aesthetic: {
|
|
396
|
+
readonly interval: 80;
|
|
397
|
+
readonly frames: ["▰▱▱▱▱▱▱", "▰▰▱▱▱▱▱", "▰▰▰▱▱▱▱", "▰▰▰▰▱▱▱", "▰▰▰▰▰▱▱", "▰▰▰▰▰▰▱", "▰▰▰▰▰▰▰", "▰▱▱▱▱▱▱"];
|
|
398
|
+
};
|
|
399
|
+
readonly star: {
|
|
400
|
+
readonly interval: 70;
|
|
401
|
+
readonly frames: ["✶", "✸", "✹", "✺", "✹", "✷"];
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
type SpinnerName = keyof typeof spinners;
|
|
405
|
+
declare const DEFAULT_SPINNER: SpinnerName;
|
|
406
|
+
declare function resolveSpinner(config?: string | {
|
|
407
|
+
frames: string[];
|
|
408
|
+
interval?: number;
|
|
409
|
+
}): SpinnerConfig;
|
|
410
|
+
|
|
253
411
|
declare function resolveEnvDefault(value: string | undefined): string | undefined;
|
|
254
412
|
|
|
255
413
|
interface StepPlugin {
|
|
@@ -280,8 +438,10 @@ interface RunWizardOptions {
|
|
|
280
438
|
dir?: string;
|
|
281
439
|
};
|
|
282
440
|
mru?: boolean;
|
|
441
|
+
resume?: boolean;
|
|
442
|
+
configFilePath?: string;
|
|
283
443
|
}
|
|
284
|
-
declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme): void;
|
|
444
|
+
declare function runPreFlightChecks(checks: PreFlightCheck[], theme: ResolvedTheme, renderer?: WizardRenderer): void;
|
|
285
445
|
declare function runWizard(config: WizardConfig, options?: RunWizardOptions): Promise<Record<string, unknown>>;
|
|
286
446
|
|
|
287
447
|
declare function defineWizard(config: WizardConfig): WizardConfig;
|
|
@@ -309,6 +469,12 @@ declare class InquirerRenderer implements WizardRenderer {
|
|
|
309
469
|
* Array values are joined with ", ". Unresolved placeholders remain as-is.
|
|
310
470
|
*/
|
|
311
471
|
declare function resolveTemplate(template: string, answers: Record<string, unknown>): string;
|
|
472
|
+
/**
|
|
473
|
+
* Resolve {{stepId}} placeholders strictly — throws if any placeholder
|
|
474
|
+
* references a step-id not found in the answers map.
|
|
475
|
+
* Used by actions where missing answers indicate a config error.
|
|
476
|
+
*/
|
|
477
|
+
declare function resolveTemplateStrict(template: string, answers: Record<string, unknown>): string;
|
|
312
478
|
|
|
313
479
|
/**
|
|
314
480
|
* Render a figlet ASCII art banner for the wizard name.
|
|
@@ -346,9 +512,47 @@ declare class InkRenderer implements WizardRenderer {
|
|
|
346
512
|
clear(): void;
|
|
347
513
|
}
|
|
348
514
|
|
|
515
|
+
declare class ClackRenderer extends InquirerRenderer {
|
|
516
|
+
private spinnerInterval;
|
|
517
|
+
private spinnerFrameIndex;
|
|
518
|
+
renderStepHeader(): void;
|
|
519
|
+
renderGroupHeader(): void;
|
|
520
|
+
renderSummary(answers: Record<string, unknown>, steps: StepConfig[], theme: ResolvedTheme): void;
|
|
521
|
+
onEvent(event: WizardEvent, theme: ResolvedTheme): void;
|
|
522
|
+
private handleSessionStart;
|
|
523
|
+
private handleSessionEnd;
|
|
524
|
+
private handleStepComplete;
|
|
525
|
+
private formatValue;
|
|
526
|
+
private writeNoteBox;
|
|
527
|
+
private startSpinner;
|
|
528
|
+
private stopSpinner;
|
|
529
|
+
}
|
|
530
|
+
|
|
349
531
|
declare function saveTemplate(wizardName: string, templateName: string, answers: Record<string, unknown>, excludeKeys?: string[]): void;
|
|
350
532
|
declare function loadTemplate(wizardName: string, templateName: string): Record<string, unknown> | undefined;
|
|
351
533
|
declare function listTemplates(wizardName: string): string[];
|
|
352
534
|
declare function deleteTemplate(wizardName: string, templateName: string): void;
|
|
353
535
|
|
|
354
|
-
|
|
536
|
+
interface SavedProgress {
|
|
537
|
+
currentStepId: string;
|
|
538
|
+
answers: Record<string, unknown>;
|
|
539
|
+
history: string[];
|
|
540
|
+
savedAt: string;
|
|
541
|
+
}
|
|
542
|
+
declare function saveProgress(wizardName: string, state: {
|
|
543
|
+
currentStepId: string;
|
|
544
|
+
answers: Record<string, unknown>;
|
|
545
|
+
history: string[];
|
|
546
|
+
}, customDir?: string, excludeStepIds?: string[]): void;
|
|
547
|
+
declare function loadProgress(wizardName: string, customDir?: string): SavedProgress | null;
|
|
548
|
+
declare function clearProgress(wizardName: string, customDir?: string): void;
|
|
549
|
+
|
|
550
|
+
interface PipelineStep {
|
|
551
|
+
config: WizardConfig | string;
|
|
552
|
+
when?: Condition;
|
|
553
|
+
mockAnswers?: Record<string, unknown>;
|
|
554
|
+
options?: Omit<RunWizardOptions, 'mockAnswers' | 'templateAnswers'>;
|
|
555
|
+
}
|
|
556
|
+
declare function runPipeline(steps: PipelineStep[], globalOptions?: Omit<RunWizardOptions, 'mockAnswers' | 'templateAnswers'>): Promise<Record<string, Record<string, unknown>>>;
|
|
557
|
+
|
|
558
|
+
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 };
|