fix: clean up onboarding + channel selection types
This commit is contained in:
@@ -246,15 +246,19 @@ export async function setupChannels(
|
||||
|
||||
options?.onSelection?.(selection);
|
||||
|
||||
const selectionNotes = new Map(
|
||||
[
|
||||
...installedPlugins.map((plugin) => [plugin.id, plugin.meta]),
|
||||
...catalogEntries.map((entry) => [entry.id, entry.meta]),
|
||||
].map(([id, meta]) => [
|
||||
id,
|
||||
formatChannelSelectionLine(meta, formatDocsLink),
|
||||
]),
|
||||
);
|
||||
const selectionNotes = new Map<string, string>();
|
||||
for (const plugin of installedPlugins) {
|
||||
selectionNotes.set(
|
||||
plugin.id,
|
||||
formatChannelSelectionLine(plugin.meta, formatDocsLink),
|
||||
);
|
||||
}
|
||||
for (const entry of catalogEntries) {
|
||||
selectionNotes.set(
|
||||
entry.id,
|
||||
formatChannelSelectionLine(entry.meta, formatDocsLink),
|
||||
);
|
||||
}
|
||||
const selectedLines = selection
|
||||
.map((channel) => selectionNotes.get(channel))
|
||||
.filter((line): line is string => Boolean(line));
|
||||
|
||||
@@ -6,7 +6,9 @@ import type { WizardPrompter } from "../../../wizard/prompts.js";
|
||||
export const makeRuntime = (overrides: Partial<RuntimeEnv> = {}): RuntimeEnv => ({
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
exit: vi.fn((code: number) => {
|
||||
throw new Error(`exit:${code}`);
|
||||
}) as RuntimeEnv["exit"],
|
||||
...overrides,
|
||||
});
|
||||
|
||||
|
||||
@@ -82,24 +82,26 @@ async function promptInstallChoice(params: {
|
||||
prompter: WizardPrompter;
|
||||
}): Promise<InstallChoice> {
|
||||
const { entry, localPath, prompter } = params;
|
||||
const localOptions: Array<{ value: InstallChoice; label: string; hint?: string }> = localPath
|
||||
? [
|
||||
{
|
||||
value: "local",
|
||||
label: "Use local plugin path",
|
||||
hint: localPath,
|
||||
},
|
||||
]
|
||||
: [];
|
||||
const options: Array<{ value: InstallChoice; label: string; hint?: string }> = [
|
||||
{ value: "npm", label: `Download from npm (${entry.install.npmSpec})` },
|
||||
...(localPath
|
||||
? [
|
||||
{
|
||||
value: "local",
|
||||
label: "Use local plugin path",
|
||||
hint: localPath,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...localOptions,
|
||||
{ value: "skip", label: "Skip for now" },
|
||||
];
|
||||
return (await prompter.select({
|
||||
const initialValue: InstallChoice = localPath ? "local" : "npm";
|
||||
return await prompter.select<InstallChoice>({
|
||||
message: `Install ${entry.meta.label} plugin?`,
|
||||
options,
|
||||
initialValue: localPath ? "local" : "npm",
|
||||
})) as InstallChoice;
|
||||
initialValue,
|
||||
});
|
||||
}
|
||||
|
||||
export async function ensureOnboardingPluginInstalled(params: {
|
||||
|
||||
Reference in New Issue
Block a user