From 1f2b4050462fdc35964fd056c9a684c7785344df Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Sat, 20 May 2023 09:26:28 +0200 Subject: [PATCH] Merge pull request #22651 from storybookjs/fix/sandbox-init-command CLI: Skip prompting for eslint plugin with --yes flag --- code/lib/cli/src/generators/baseGenerator.ts | 11 ++++++++--- code/lib/cli/src/generators/types.ts | 2 ++ code/lib/cli/src/initiate.ts | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/code/lib/cli/src/generators/baseGenerator.ts b/code/lib/cli/src/generators/baseGenerator.ts index 760ee4348072..999c533f0025 100644 --- a/code/lib/cli/src/generators/baseGenerator.ts +++ b/code/lib/cli/src/generators/baseGenerator.ts @@ -167,7 +167,13 @@ const hasFrameworkTemplates = (framework?: SupportedFrameworks) => export async function baseGenerator( packageManager: JsPackageManager, npmOptions: NpmOptions, - { language, builder = CoreBuilder.Webpack5, pnp, frameworkPreviewParts }: GeneratorOptions, + { + language, + builder = CoreBuilder.Webpack5, + pnp, + frameworkPreviewParts, + yes: skipPrompts, + }: GeneratorOptions, renderer: SupportedRenderers, options: FrameworkOptions = defaultOptions, framework?: SupportedFrameworks @@ -358,8 +364,7 @@ export async function baseGenerator( ); if (hasEslint && !isStorybookPluginInstalled) { - const shouldInstallESLintPlugin = await suggestESLintPlugin(); - if (shouldInstallESLintPlugin) { + if (skipPrompts || (await suggestESLintPlugin())) { depsToInstall.push('eslint-plugin-storybook'); await configureEslintPlugin(eslintConfigFile, packageManager); } diff --git a/code/lib/cli/src/generators/types.ts b/code/lib/cli/src/generators/types.ts index 6ef446c6538c..c4298cc85529 100644 --- a/code/lib/cli/src/generators/types.ts +++ b/code/lib/cli/src/generators/types.ts @@ -9,6 +9,8 @@ export type GeneratorOptions = { linkable: boolean; pnp: boolean; frameworkPreviewParts?: FrameworkPreviewParts; + // skip prompting the user + yes: boolean; }; export interface FrameworkOptions { diff --git a/code/lib/cli/src/initiate.ts b/code/lib/cli/src/initiate.ts index b49ebc6a4d9a..6d62f6061ca7 100644 --- a/code/lib/cli/src/initiate.ts +++ b/code/lib/cli/src/initiate.ts @@ -65,6 +65,7 @@ const installStorybook = async ( builder: options.builder || (await detectBuilder(packageManager, projectType)), linkable: !!options.linkable, pnp: pnp || options.usePnp, + yes: options.yes, }; const runGenerator: () => Promise = async () => {