From cf588633b95c23ff6d70ad3dc7a4f898def08405 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Tue, 11 Jul 2023 18:59:14 +0200 Subject: [PATCH] Merge pull request #23201 from storybookjs/fix/exit-on-init-unknown-project CLI: Exit when user does not want to select a storybook project type (cherry picked from commit dcb93a753419755ca1e3a918886cf09922cfad9a) --- code/lib/cli/src/initiate.ts | 13 ++++++++++--- code/lib/cli/src/project_types.ts | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/code/lib/cli/src/initiate.ts b/code/lib/cli/src/initiate.ts index 6d62f6061ca7..6b5452c3e024 100644 --- a/code/lib/cli/src/initiate.ts +++ b/code/lib/cli/src/initiate.ts @@ -210,6 +210,7 @@ const installStorybook = async ( const projectTypeInquirer = async ( options: CommandOptions & { yes?: boolean }, packageManager: JsPackageManager + // eslint-disable-next-line consistent-return ) => { const manualAnswer = options.yes ? true @@ -222,7 +223,7 @@ const projectTypeInquirer = async ( ]); if (manualAnswer !== true && manualAnswer.manual) { - const frameworkAnswer = await prompts([ + const { manualFramework } = await prompts([ { type: 'select', name: 'manualFramework', @@ -233,9 +234,15 @@ const projectTypeInquirer = async ( })), }, ]); - return installStorybook(frameworkAnswer.manualFramework, packageManager, options); + + if (manualFramework) { + return installStorybook(manualFramework, packageManager, options); + } } - return Promise.resolve(); + + logger.log(); + logger.log('For more information about installing Storybook: https://storybook.js.org/docs'); + process.exit(0); }; async function doInitiate(options: CommandOptions, pkg: PackageJson): Promise { diff --git a/code/lib/cli/src/project_types.ts b/code/lib/cli/src/project_types.ts index ed6fbc3d7959..17bc9c27a25d 100644 --- a/code/lib/cli/src/project_types.ts +++ b/code/lib/cli/src/project_types.ts @@ -63,8 +63,8 @@ export const SUPPORTED_RENDERERS: SupportedRenderers[] = [ export enum ProjectType { UNDETECTED = 'UNDETECTED', UNSUPPORTED = 'UNSUPPORTED', - REACT_SCRIPTS = 'REACT_SCRIPTS', REACT = 'REACT', + REACT_SCRIPTS = 'REACT_SCRIPTS', REACT_NATIVE = 'REACT_NATIVE', REACT_PROJECT = 'REACT_PROJECT', WEBPACK_REACT = 'WEBPACK_REACT',