Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Exit when user does not select a storybook project type #23201

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions code/lib/cli/src/initiate.ts
Expand Up @@ -204,6 +204,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 @@ -216,7 +217,7 @@ const projectTypeInquirer = async (
]);

if (manualAnswer !== true && manualAnswer.manual) {
const frameworkAnswer = await prompts([
const { manualFramework } = await prompts([
{
type: 'select',
name: 'manualFramework',
Expand All @@ -227,9 +228,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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman reminder to check this later, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this. I think it's not great for our telemetry, but hopefully it's a small corner case.

};

async function doInitiate(options: CommandOptions, pkg: PackageJson): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/project_types.ts
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the story here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a big error count regarding "Storybook does not support react-scripts < 5.0.0" and this error can also be thrown when you choose react-scripts from the list of projects to install, but you don't have react-scripts installed.

I suspect what is influencing this count so much is that people just press enter when they get a list of options, and react-scripts is the first in the list. By changing the order, people will get react instead, free of the possibility of crashing with the react-scripts issue.

REACT_NATIVE = 'REACT_NATIVE',
REACT_PROJECT = 'REACT_PROJECT',
WEBPACK_REACT = 'WEBPACK_REACT',
Expand Down