grimoire-wizard 0.3.1 → 0.4.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 +173 -18
- package/dist/cli.js +503 -97
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +107 -3
- package/dist/index.js +832 -367
- package/dist/index.js.map +1 -1
- 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-checks.json +47 -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/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/README.md
CHANGED
|
@@ -47,6 +47,12 @@ Grimoire is a config-driven CLI wizard framework for Node.js. You write a YAML o
|
|
|
47
47
|
- **`optionsFrom`** — load select/multiselect/search options from an external JSON or YAML file
|
|
48
48
|
- **Lifecycle hooks** — `onBeforeStep` and `onAfterStep` callbacks in the programmatic API
|
|
49
49
|
- **Ink renderer** — alternative renderer with box-drawing characters and progress percentages
|
|
50
|
+
- **Clack-style renderer** — connected `│` guide lines, `◇` collapsed steps, `┌`/`└` session framing, bordered note boxes
|
|
51
|
+
- **6 theme presets** — catppuccin, dracula, nord, tokyonight, monokai; set `preset` in your theme config
|
|
52
|
+
- **Note step type** — display bordered info boxes inline in the wizard flow
|
|
53
|
+
- **Progress persistence** — auto-resume from where you left off after Ctrl+C; `--no-resume` to disable
|
|
54
|
+
- **Step review screen** — review all answers before final submission; set `review: true` in meta
|
|
55
|
+
- **Wizard pipelines** — chain multiple wizard configs, forwarding answers between them
|
|
50
56
|
- **ASCII art banner** — figlet + gradient banner shown at startup; suppressed with `--plain`
|
|
51
57
|
- **`--plain` / `--no-color` flags** — disable colors and banner for plain-text environments
|
|
52
58
|
|
|
@@ -125,8 +131,9 @@ grimoire run setup.yaml --json
|
|
|
125
131
|
| `--mock <json>` | Run non-interactively with preset answers (JSON object string) |
|
|
126
132
|
| `--json` | Emit a structured JSON result envelope to stdout |
|
|
127
133
|
| `--no-cache` | Disable answer caching for this run |
|
|
134
|
+
| `--no-resume` | Disable progress resume for this run |
|
|
128
135
|
| `--template <name>` | Load a saved template as default answers |
|
|
129
|
-
| `--renderer <type>` | Renderer to use: `inquirer` (default) or `
|
|
136
|
+
| `--renderer <type>` | Renderer to use: `inquirer` (default), `ink`, or `clack` |
|
|
130
137
|
| `--plain` | Plain output mode (no colors, no banner) |
|
|
131
138
|
| `--no-color` | Disable colored output |
|
|
132
139
|
|
|
@@ -468,6 +475,19 @@ A binary toggle with custom labels for each state. Returns a boolean.
|
|
|
468
475
|
default: true
|
|
469
476
|
```
|
|
470
477
|
|
|
478
|
+
### `note`
|
|
479
|
+
|
|
480
|
+
Displays a bordered info box inline in the wizard flow. No input is collected. Useful for showing instructions, warnings, or section headers between prompts.
|
|
481
|
+
|
|
482
|
+
```yaml
|
|
483
|
+
- id: info
|
|
484
|
+
type: note
|
|
485
|
+
message: Setup Complete
|
|
486
|
+
description: "Run npm install to get started"
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The `message` becomes the box title and `description` is the body text. Note steps are skipped in `--mock` mode and excluded from the answers output.
|
|
490
|
+
|
|
471
491
|
---
|
|
472
492
|
|
|
473
493
|
## Dynamic Options (`optionsFrom`)
|
|
@@ -728,6 +748,26 @@ theme:
|
|
|
728
748
|
| `stepPending` | Upcoming step indicator |
|
|
729
749
|
| `pointer` | Selection cursor in lists |
|
|
730
750
|
|
|
751
|
+
### Theme presets
|
|
752
|
+
|
|
753
|
+
Instead of specifying individual tokens, pick a built-in preset with a single line:
|
|
754
|
+
|
|
755
|
+
```yaml
|
|
756
|
+
theme:
|
|
757
|
+
preset: catppuccin
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
| Preset | Primary color | Style |
|
|
761
|
+
|--------|--------------|-------|
|
|
762
|
+
| `default` | `#7C3AED` | Purple |
|
|
763
|
+
| `catppuccin` | `#cba6f7` | Soft lavender (Mocha) |
|
|
764
|
+
| `dracula` | `#bd93f9` | Purple on dark |
|
|
765
|
+
| `nord` | `#88c0d0` | Arctic blue |
|
|
766
|
+
| `tokyonight` | `#7aa2f7` | Night blue |
|
|
767
|
+
| `monokai` | `#a6e22e` | Vibrant green |
|
|
768
|
+
|
|
769
|
+
Any `tokens` or `icons` you set alongside `preset` override the preset's values.
|
|
770
|
+
|
|
731
771
|
---
|
|
732
772
|
|
|
733
773
|
## Environment Variables
|
|
@@ -1029,6 +1069,25 @@ Or from the CLI:
|
|
|
1029
1069
|
grimoire run setup.yaml --renderer ink
|
|
1030
1070
|
```
|
|
1031
1071
|
|
|
1072
|
+
### Clack renderer
|
|
1073
|
+
|
|
1074
|
+
The `ClackRenderer` gives your wizard a clack-style visual flow: a continuous `│` guide line connects all prompts, answered steps collapse to a single `◇ Question · answer` line, and the session opens with a `┌` header and closes with a `└` outro. Note steps render as bordered boxes. Spinners animate during async operations.
|
|
1075
|
+
|
|
1076
|
+
```bash
|
|
1077
|
+
grimoire run setup.yaml --renderer clack
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
Or programmatically:
|
|
1081
|
+
|
|
1082
|
+
```typescript
|
|
1083
|
+
import { runWizard } from 'grimoire-wizard'
|
|
1084
|
+
import { ClackRenderer } from 'grimoire-wizard'
|
|
1085
|
+
|
|
1086
|
+
const answers = await runWizard(config, {
|
|
1087
|
+
renderer: new ClackRenderer(),
|
|
1088
|
+
})
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1032
1091
|
### Exported types
|
|
1033
1092
|
|
|
1034
1093
|
```typescript
|
|
@@ -1045,6 +1104,7 @@ import type {
|
|
|
1045
1104
|
EditorStepConfig,
|
|
1046
1105
|
PathStepConfig,
|
|
1047
1106
|
ToggleStepConfig,
|
|
1107
|
+
NoteStepConfig,
|
|
1048
1108
|
SelectOption,
|
|
1049
1109
|
ValidationRule,
|
|
1050
1110
|
Condition,
|
|
@@ -1053,6 +1113,7 @@ import type {
|
|
|
1053
1113
|
WizardState,
|
|
1054
1114
|
WizardTransition,
|
|
1055
1115
|
WizardRenderer,
|
|
1116
|
+
WizardEvent,
|
|
1056
1117
|
PreFlightCheck,
|
|
1057
1118
|
RunWizardOptions,
|
|
1058
1119
|
GrimoirePlugin,
|
|
@@ -1093,6 +1154,14 @@ import {
|
|
|
1093
1154
|
deleteTemplate, // Delete a named template
|
|
1094
1155
|
// Banner
|
|
1095
1156
|
renderBanner, // Render the ASCII art banner for a wizard name
|
|
1157
|
+
// Renderers
|
|
1158
|
+
ClackRenderer, // Clack-style renderer with guide lines and collapsed steps
|
|
1159
|
+
// Pipelines
|
|
1160
|
+
runPipeline, // Chain multiple wizard configs in sequence
|
|
1161
|
+
// Progress persistence
|
|
1162
|
+
saveProgress, // Save wizard progress to disk
|
|
1163
|
+
loadProgress, // Load saved wizard progress
|
|
1164
|
+
clearProgress, // Delete saved wizard progress
|
|
1096
1165
|
} from 'grimoire-wizard'
|
|
1097
1166
|
```
|
|
1098
1167
|
|
|
@@ -1131,6 +1200,74 @@ const answers = await runWizard(config, { cache: { dir: '/tmp/my-cache' } })
|
|
|
1131
1200
|
|
|
1132
1201
|
---
|
|
1133
1202
|
|
|
1203
|
+
## Progress Persistence
|
|
1204
|
+
|
|
1205
|
+
If you press Ctrl+C mid-wizard, grimoire saves your progress automatically. The next time you run the same wizard, it resumes from where you left off, with all previous answers pre-filled.
|
|
1206
|
+
|
|
1207
|
+
Progress files are stored in `~/.config/grimoire/progress/` as JSON, one file per wizard.
|
|
1208
|
+
|
|
1209
|
+
Disable resume for a single run:
|
|
1210
|
+
|
|
1211
|
+
```bash
|
|
1212
|
+
grimoire run setup.yaml --no-resume
|
|
1213
|
+
```
|
|
1214
|
+
|
|
1215
|
+
Or programmatically:
|
|
1216
|
+
|
|
1217
|
+
```typescript
|
|
1218
|
+
const answers = await runWizard(config, { resume: false })
|
|
1219
|
+
```
|
|
1220
|
+
|
|
1221
|
+
Manage progress files directly:
|
|
1222
|
+
|
|
1223
|
+
```typescript
|
|
1224
|
+
import { saveProgress, loadProgress, clearProgress } from 'grimoire-wizard'
|
|
1225
|
+
|
|
1226
|
+
const saved = loadProgress('Project Setup')
|
|
1227
|
+
clearProgress('Project Setup')
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
---
|
|
1231
|
+
|
|
1232
|
+
## Review Screen
|
|
1233
|
+
|
|
1234
|
+
Set `review: true` in your wizard's `meta` block to show a summary of all answers before the wizard completes. The user can confirm or go back to change any answer.
|
|
1235
|
+
|
|
1236
|
+
```yaml
|
|
1237
|
+
meta:
|
|
1238
|
+
name: Deploy Wizard
|
|
1239
|
+
review: true
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
The review screen lists every answered step with its question and value. Selecting an answer jumps back to that step. Confirming submits the wizard.
|
|
1243
|
+
|
|
1244
|
+
---
|
|
1245
|
+
|
|
1246
|
+
## Wizard Pipelines
|
|
1247
|
+
|
|
1248
|
+
Pipelines let you chain multiple wizard configs in sequence. Each wizard's answers are forwarded to the next, so later wizards can reference earlier answers in their `when` conditions and `default` values.
|
|
1249
|
+
|
|
1250
|
+
```typescript
|
|
1251
|
+
import { runPipeline } from 'grimoire-wizard'
|
|
1252
|
+
|
|
1253
|
+
const results = await runPipeline([
|
|
1254
|
+
{ config: setupConfig },
|
|
1255
|
+
{ config: deployConfig, when: { field: 'name', equals: 'my-app' } },
|
|
1256
|
+
])
|
|
1257
|
+
```
|
|
1258
|
+
|
|
1259
|
+
Each entry in the array accepts:
|
|
1260
|
+
|
|
1261
|
+
| Field | Type | Description |
|
|
1262
|
+
|-------|------|-------------|
|
|
1263
|
+
| `config` | `WizardConfig` | The wizard config to run |
|
|
1264
|
+
| `mockAnswers` | `Record<string, unknown>` | Preset answers for this stage |
|
|
1265
|
+
| `when` | `Condition` | Skip this stage if the condition is not met |
|
|
1266
|
+
|
|
1267
|
+
`runPipeline` returns an array of answer objects, one per stage that ran. Stages that are skipped via `when` return `null`.
|
|
1268
|
+
|
|
1269
|
+
---
|
|
1270
|
+
|
|
1134
1271
|
## Templates
|
|
1135
1272
|
|
|
1136
1273
|
Templates are named answer presets. Save a set of answers under a name, then load them as defaults on future runs. Useful for environments like staging vs. production that share the same wizard but need different values.
|
|
@@ -1324,72 +1461,90 @@ grimoire completion fish > ~/.config/fish/completions/grimoire.fish
|
|
|
1324
1461
|
|
|
1325
1462
|
## Examples
|
|
1326
1463
|
|
|
1327
|
-
The `examples/` directory contains
|
|
1464
|
+
The `examples/` directory contains ready-to-run configs in both YAML (`examples/yaml/`) and JSON (`examples/json/`) formats. Every YAML example (except `base.yaml` and `extended.yaml`, which use `extends:`) has a JSON equivalent.
|
|
1328
1465
|
|
|
1329
|
-
### `examples/basic.yaml`
|
|
1466
|
+
### `examples/yaml/basic.yaml`
|
|
1330
1467
|
|
|
1331
1468
|
A 6-step project setup wizard covering the core input types: project name (text with validation and pattern), description (optional text), language (select with default), features (multiselect with min), license (select), and confirm. Good starting point for your own configs.
|
|
1332
1469
|
|
|
1333
1470
|
```bash
|
|
1334
|
-
grimoire run examples/basic.yaml
|
|
1471
|
+
grimoire run examples/yaml/basic.yaml
|
|
1472
|
+
grimoire run examples/json/basic.json # JSON equivalent
|
|
1335
1473
|
```
|
|
1336
1474
|
|
|
1337
|
-
### `examples/conditional.yaml`
|
|
1475
|
+
### `examples/yaml/conditional.yaml`
|
|
1338
1476
|
|
|
1339
1477
|
An 11-step wizard that branches based on project type. A `select` step with `routes` sends users down one of four paths (web, api, cli, lib), each with its own framework or feature selection step. Additional steps use `when` conditions to show or hide options based on earlier answers.
|
|
1340
1478
|
|
|
1341
1479
|
```bash
|
|
1342
|
-
grimoire run examples/conditional.yaml
|
|
1480
|
+
grimoire run examples/yaml/conditional.yaml
|
|
1343
1481
|
```
|
|
1344
1482
|
|
|
1345
|
-
### `examples/themed.yaml`
|
|
1483
|
+
### `examples/yaml/themed.yaml`
|
|
1346
1484
|
|
|
1347
1485
|
An 8-step account setup wizard styled with the Catppuccin Mocha color palette. Demonstrates all 7 color tokens and custom icon overrides. Steps cover username, email, role, experience, interests, newsletter, password, and confirm.
|
|
1348
1486
|
|
|
1349
1487
|
```bash
|
|
1350
|
-
grimoire run examples/themed.yaml
|
|
1488
|
+
grimoire run examples/yaml/themed.yaml
|
|
1351
1489
|
```
|
|
1352
1490
|
|
|
1353
|
-
### `examples/demo.yaml`
|
|
1491
|
+
### `examples/yaml/demo.yaml`
|
|
1354
1492
|
|
|
1355
1493
|
The built-in demo config used by `grimoire demo`. Exercises all 10 step types across 4 named groups: Text Inputs (text, editor, path, password), Selections (select, multiselect, search), Toggles and Numbers (toggle, number), and Confirmation (confirm).
|
|
1356
1494
|
|
|
1357
1495
|
```bash
|
|
1358
|
-
grimoire run examples/demo.yaml
|
|
1496
|
+
grimoire run examples/yaml/demo.yaml
|
|
1359
1497
|
# or
|
|
1360
1498
|
grimoire demo
|
|
1361
1499
|
```
|
|
1362
1500
|
|
|
1363
|
-
### `examples/all-features.yaml`
|
|
1501
|
+
### `examples/yaml/all-features.yaml`
|
|
1364
1502
|
|
|
1365
1503
|
A focused showcase of the newer step types: search, path, toggle, editor, and number, organized into two groups (Project Setup and Configuration).
|
|
1366
1504
|
|
|
1367
1505
|
```bash
|
|
1368
|
-
grimoire run examples/all-features.yaml
|
|
1506
|
+
grimoire run examples/yaml/all-features.yaml
|
|
1369
1507
|
```
|
|
1370
1508
|
|
|
1371
|
-
### `examples/base.yaml`
|
|
1509
|
+
### `examples/yaml/base.yaml`
|
|
1372
1510
|
|
|
1373
1511
|
A minimal base config with a name step, optional description, and confirm. Intended to be inherited via `extends`.
|
|
1374
1512
|
|
|
1375
1513
|
```bash
|
|
1376
|
-
grimoire run examples/base.yaml
|
|
1514
|
+
grimoire run examples/yaml/base.yaml
|
|
1377
1515
|
```
|
|
1378
1516
|
|
|
1379
|
-
### `examples/extended.yaml`
|
|
1517
|
+
### `examples/yaml/extended.yaml`
|
|
1380
1518
|
|
|
1381
1519
|
Extends `base.yaml` and adds a language select step. Demonstrates how `extends` merges configs and how the child's `output` and `meta` override the base.
|
|
1382
1520
|
|
|
1383
1521
|
```bash
|
|
1384
|
-
grimoire run examples/extended.yaml
|
|
1522
|
+
grimoire run examples/yaml/extended.yaml
|
|
1385
1523
|
```
|
|
1386
1524
|
|
|
1387
|
-
### `examples/with-checks.yaml`
|
|
1525
|
+
### `examples/yaml/with-checks.yaml`
|
|
1388
1526
|
|
|
1389
1527
|
A deployment wizard with two pre-flight checks (Node.js and Git). Shows how `checks` abort the wizard before any prompts if the environment isn't ready.
|
|
1390
1528
|
|
|
1391
1529
|
```bash
|
|
1392
|
-
grimoire run examples/with-checks.yaml
|
|
1530
|
+
grimoire run examples/yaml/with-checks.yaml
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
### `examples/yaml/themed-catppuccin.yaml`
|
|
1534
|
+
|
|
1535
|
+
A 3-step project setup wizard using the `catppuccin` theme preset. Shows how a single `preset` line replaces manual token configuration.
|
|
1536
|
+
|
|
1537
|
+
```bash
|
|
1538
|
+
grimoire run examples/yaml/themed-catppuccin.yaml
|
|
1539
|
+
grimoire run examples/json/themed-catppuccin.json # JSON equivalent
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
### `examples/yaml/pipeline.yaml`
|
|
1543
|
+
|
|
1544
|
+
A multi-stage wizard demonstrating the pipeline concept using `note` steps as stage dividers. Shows how to structure a wizard that covers multiple logical phases in a single config.
|
|
1545
|
+
|
|
1546
|
+
```bash
|
|
1547
|
+
grimoire run examples/yaml/pipeline.yaml
|
|
1393
1548
|
```
|
|
1394
1549
|
|
|
1395
1550
|
---
|