grimoire-wizard 0.4.0 → 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 +12 -0
- package/dist/cli.js +105 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +101 -1
- package/dist/index.js +96 -11
- package/dist/index.js.map +1 -1
- package/examples/handlers/setup-project.ts +9 -0
- package/examples/json/with-actions.json +61 -0
- package/examples/json/with-oncomplete.json +45 -0
- package/examples/yaml/with-actions.yaml +45 -0
- package/examples/yaml/with-oncomplete.yaml +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OnCompleteHandler } from '../../src/types';
|
|
2
|
+
|
|
3
|
+
const handler: OnCompleteHandler = async ({ answers, config }) => {
|
|
4
|
+
console.log(`\n Setting up project: ${String(answers['project-name'])}`);
|
|
5
|
+
console.log(` Wizard: ${config.meta.name}`);
|
|
6
|
+
console.log(` Total answers: ${Object.keys(answers).length}\n`);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default handler;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"name": "Project Scaffolder",
|
|
4
|
+
"description": "Create a new project with post-wizard actions"
|
|
5
|
+
},
|
|
6
|
+
"theme": {
|
|
7
|
+
"preset": "catppuccin"
|
|
8
|
+
},
|
|
9
|
+
"steps": [
|
|
10
|
+
{
|
|
11
|
+
"id": "project-name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"message": "Project name?",
|
|
14
|
+
"validate": [
|
|
15
|
+
{ "rule": "required" },
|
|
16
|
+
{
|
|
17
|
+
"rule": "pattern",
|
|
18
|
+
"value": "^[a-z0-9-]+$",
|
|
19
|
+
"message": "Only lowercase letters, numbers, and hyphens"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "use-git",
|
|
25
|
+
"type": "confirm",
|
|
26
|
+
"message": "Initialize git repository?",
|
|
27
|
+
"default": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "use-readme",
|
|
31
|
+
"type": "confirm",
|
|
32
|
+
"message": "Create a README?",
|
|
33
|
+
"default": true
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"actions": [
|
|
37
|
+
{
|
|
38
|
+
"name": "Create project directory",
|
|
39
|
+
"run": "mkdir -p {{project-name}}"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "Initialize git",
|
|
43
|
+
"run": "git -C {{project-name}} init",
|
|
44
|
+
"when": {
|
|
45
|
+
"field": "use-git",
|
|
46
|
+
"equals": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "Create README",
|
|
51
|
+
"run": "echo '# {{project-name}}' > {{project-name}}/README.md",
|
|
52
|
+
"when": {
|
|
53
|
+
"field": "use-readme",
|
|
54
|
+
"equals": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"output": {
|
|
59
|
+
"format": "json"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"name": "Project Setup with Handler",
|
|
4
|
+
"description": "Demonstrates onComplete handler file"
|
|
5
|
+
},
|
|
6
|
+
"theme": {
|
|
7
|
+
"preset": "dracula"
|
|
8
|
+
},
|
|
9
|
+
"onComplete": "../handlers/setup-project.ts",
|
|
10
|
+
"steps": [
|
|
11
|
+
{
|
|
12
|
+
"id": "project-name",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"message": "Project name?",
|
|
15
|
+
"validate": [
|
|
16
|
+
{ "rule": "required" }
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "language",
|
|
21
|
+
"type": "select",
|
|
22
|
+
"message": "Language?",
|
|
23
|
+
"options": [
|
|
24
|
+
{ "value": "typescript", "label": "TypeScript" },
|
|
25
|
+
{ "value": "javascript", "label": "JavaScript" },
|
|
26
|
+
{ "value": "python", "label": "Python" }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "confirm",
|
|
31
|
+
"type": "confirm",
|
|
32
|
+
"message": "Create project?",
|
|
33
|
+
"default": true
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"actions": [
|
|
37
|
+
{
|
|
38
|
+
"name": "Log completion",
|
|
39
|
+
"run": "echo 'Created {{project-name}} with {{language}}'"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"output": {
|
|
43
|
+
"format": "json"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
meta:
|
|
2
|
+
name: Project Scaffolder
|
|
3
|
+
description: Create a new project with post-wizard actions
|
|
4
|
+
|
|
5
|
+
theme:
|
|
6
|
+
preset: catppuccin
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
- id: project-name
|
|
10
|
+
type: text
|
|
11
|
+
message: Project name?
|
|
12
|
+
validate:
|
|
13
|
+
- rule: required
|
|
14
|
+
- rule: pattern
|
|
15
|
+
value: "^[a-z0-9-]+$"
|
|
16
|
+
message: Only lowercase letters, numbers, and hyphens
|
|
17
|
+
|
|
18
|
+
- id: use-git
|
|
19
|
+
type: confirm
|
|
20
|
+
message: Initialize git repository?
|
|
21
|
+
default: true
|
|
22
|
+
|
|
23
|
+
- id: use-readme
|
|
24
|
+
type: confirm
|
|
25
|
+
message: Create a README?
|
|
26
|
+
default: true
|
|
27
|
+
|
|
28
|
+
actions:
|
|
29
|
+
- name: Create project directory
|
|
30
|
+
run: "mkdir -p {{project-name}}"
|
|
31
|
+
|
|
32
|
+
- name: Initialize git
|
|
33
|
+
run: "git -C {{project-name}} init"
|
|
34
|
+
when:
|
|
35
|
+
field: use-git
|
|
36
|
+
equals: true
|
|
37
|
+
|
|
38
|
+
- name: Create README
|
|
39
|
+
run: "echo '# {{project-name}}' > {{project-name}}/README.md"
|
|
40
|
+
when:
|
|
41
|
+
field: use-readme
|
|
42
|
+
equals: true
|
|
43
|
+
|
|
44
|
+
output:
|
|
45
|
+
format: json
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
meta:
|
|
2
|
+
name: Project Setup with Handler
|
|
3
|
+
description: Demonstrates onComplete handler file
|
|
4
|
+
|
|
5
|
+
theme:
|
|
6
|
+
preset: dracula
|
|
7
|
+
|
|
8
|
+
onComplete: ../handlers/setup-project.ts
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- id: project-name
|
|
12
|
+
type: text
|
|
13
|
+
message: Project name?
|
|
14
|
+
validate:
|
|
15
|
+
- rule: required
|
|
16
|
+
|
|
17
|
+
- id: language
|
|
18
|
+
type: select
|
|
19
|
+
message: Language?
|
|
20
|
+
options:
|
|
21
|
+
- { value: typescript, label: TypeScript }
|
|
22
|
+
- { value: javascript, label: JavaScript }
|
|
23
|
+
- { value: python, label: Python }
|
|
24
|
+
|
|
25
|
+
- id: confirm
|
|
26
|
+
type: confirm
|
|
27
|
+
message: Create project?
|
|
28
|
+
default: true
|
|
29
|
+
|
|
30
|
+
actions:
|
|
31
|
+
- name: Log completion
|
|
32
|
+
run: "echo 'Created {{project-name}} with {{language}}'"
|
|
33
|
+
|
|
34
|
+
output:
|
|
35
|
+
format: json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grimoire-wizard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Config-driven CLI wizard framework. Define interactive terminal wizards in YAML/JSON with back-navigation, conditional branching, theming, and structured output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|