diff --git a/src/bin/add-story.ts b/src/bin/add-story.ts index acf46f86..b3ed5be7 100644 --- a/src/bin/add-story.ts +++ b/src/bin/add-story.ts @@ -26,8 +26,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) console.log(chalk.cyan("Theme type:")); - const { value: themeType } = await cliSelect({ - values: [...THEME_TYPES].filter(themeType => { + const themeType = await (async () => { + const values = THEME_TYPES.filter(themeType => { switch (themeType) { case "account": return buildContext.implementedThemeTypes.account.isImplemented; @@ -35,10 +35,22 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) return buildContext.implementedThemeTypes.login.isImplemented; } assert>(false); - }) - }).catch(() => { - process.exit(-1); - }); + }); + + assert(values.length > 0, "No theme is implemented in this project"); + + if (values.length === 1) { + return values[0]; + } + + const { value } = await cliSelect({ + values + }).catch(() => { + process.exit(-1); + }); + + return value; + })(); if ( themeType === "account" && diff --git a/src/bin/eject-page.ts b/src/bin/eject-page.ts index 15d3c88e..404483ec 100644 --- a/src/bin/eject-page.ts +++ b/src/bin/eject-page.ts @@ -33,8 +33,8 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) console.log(chalk.cyan("Theme type:")); - const { value: themeType } = await cliSelect({ - values: [...THEME_TYPES].filter(themeType => { + const themeType = await (async () => { + const values = THEME_TYPES.filter(themeType => { switch (themeType) { case "account": return buildContext.implementedThemeTypes.account.isImplemented; @@ -42,10 +42,22 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) return buildContext.implementedThemeTypes.login.isImplemented; } assert>(false); - }) - }).catch(() => { - process.exit(-1); - }); + }); + + assert(values.length > 0, "No theme is implemented in this project"); + + if (values.length === 1) { + return values[0]; + } + + const { value } = await cliSelect({ + values + }).catch(() => { + process.exit(-1); + }); + + return value; + })(); if ( themeType === "account" &&