Skip to content

Commit

Permalink
Merge pull request #23201 from storybookjs/fix/exit-on-init-unknown-p…
Browse files Browse the repository at this point in the history
…roject

CLI: Exit when user does not want to select a storybook project type
(cherry picked from commit dcb93a7)
  • Loading branch information
yannbf authored and storybook-bot committed Jul 11, 2023
1 parent dd0399e commit cf58863
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const installStorybook = async <Project extends ProjectType>(
const projectTypeInquirer = async (
options: CommandOptions & { yes?: boolean },
packageManager: JsPackageManager
// eslint-disable-next-line consistent-return
) => {
const manualAnswer = options.yes
? true
Expand All @@ -222,7 +223,7 @@ const projectTypeInquirer = async (
]);

if (manualAnswer !== true && manualAnswer.manual) {
const frameworkAnswer = await prompts([
const { manualFramework } = await prompts([
{
type: 'select',
name: 'manualFramework',
Expand All @@ -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<void> {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/project_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit cf58863

Please sign in to comment.