Skip to content

Commit 5eae6f8

Browse files
committed
chore: bump to madwizard 0.14.1
this adds initial support for the profile api. no user-visible changes yet.
1 parent ea5370a commit 5eae6f8

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

package-lock.json

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/plugin-madwizard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^0.13.0"
26+
"madwizard": "^0.14.1"
2727
}
2828
}

plugins/plugin-madwizard/src/plugin.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ interface Options extends ParsedOptions {
3636
}
3737

3838
// TODO export this from madwizard
39-
type Task = "guide" | "plan"
39+
type Task = "profile" | "guide" | "plan"
4040

41-
function withFilepath(
41+
function doMadwizard(
4242
readonly: boolean,
4343
task: Task,
44-
cb: (filepath: string, tab: Tab) => Promise<true | ReactResponse["react"]>
44+
withFilepath = false,
45+
cb?: (filepath: string, tab: Tab) => Promise<true | ReactResponse["react"]>
4546
) {
4647
return async ({ tab, argvNoOptions, parsedOptions }: Arguments<Options>) => {
47-
if (!argvNoOptions[1]) {
48+
if (withFilepath && !argvNoOptions[1]) {
4849
argvNoOptions.push("ml/codeflare")
4950
}
5051

@@ -76,8 +77,12 @@ function withFilepath(
7677
const { setTabReadonly } = await import("./util")
7778
setTabReadonly({ tab })
7879
}
79-
return {
80-
react: await cb(argvNoOptions[1], tab),
80+
if (cb) {
81+
return {
82+
react: await cb(argvNoOptions[1], tab),
83+
}
84+
} else {
85+
return true
8186
}
8287
}
8388
}
@@ -89,25 +94,27 @@ export default function registerMadwizardCommands(registrar: Registrar) {
8994
alias: { quiet: ["q"], interactive: ["i"] },
9095
}
9196

97+
registrar.listen("/profile", doMadwizard(true, "profile"))
98+
9299
registrar.listen(
93100
"/guide",
94-
withFilepath(true, "guide", (filepath, tab) =>
101+
doMadwizard(true, "guide", true, (filepath, tab) =>
95102
import("./components/PlanAndGuide").then((_) => _.planAndGuide(filepath, { tab }))
96103
),
97104
{ outputOnly: true, flags }
98105
)
99106

100107
registrar.listen(
101108
"/wizard",
102-
withFilepath(false, "guide", (filepath, tab) =>
109+
doMadwizard(false, "guide", true, (filepath, tab) =>
103110
import("./components/Guide").then((_) => _.guide(filepath, { tab }))
104111
),
105112
{ flags }
106113
)
107114

108115
registrar.listen(
109116
"/plan",
110-
withFilepath(false, "plan", (filepath) => import("./components/Plan").then((_) => _.plan(filepath))),
117+
doMadwizard(false, "plan", true, (filepath) => import("./components/Plan").then((_) => _.plan(filepath))),
111118
{ flags }
112119
)
113120
}

plugins/plugin-madwizard/src/read.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
*/
1616

1717
export default async function read(filepath: string) {
18-
const { Parser, reader } = await import("madwizard")
19-
return Parser.parse(filepath, await reader(), undefined, undefined, { store: process.env.GUIDEBOOK_STORE })
18+
// TODO... use user-specified profile
19+
const profile = "default"
20+
21+
const { Choices, Parser, reader } = await import("madwizard")
22+
return Parser.parse(filepath, await reader(), Choices.newChoiceState(profile), undefined, {
23+
store: process.env.GUIDEBOOK_STORE,
24+
})
2025
}

0 commit comments

Comments
 (0)