diff --git a/code/lib/cli/src/automigrate/fixes/missing-babelrc.ts b/code/lib/cli/src/automigrate/fixes/missing-babelrc.ts index 2e13685fd8b4..1b403a6b0d4b 100644 --- a/code/lib/cli/src/automigrate/fixes/missing-babelrc.ts +++ b/code/lib/cli/src/automigrate/fixes/missing-babelrc.ts @@ -65,20 +65,19 @@ export const missingBabelRc: Fix = { If your project does not have a babel configuration file, we can generate one that's equivalent to the 6.x defaults for you. Keep in mind that this can affect your project if it uses babel, and you may need to make additional changes based on your projects needs. + We can create a ${chalk.blue( + '.babelrc.json' + )} file with some basic configuration and add any necessary package devDependencies. + ${chalk.bold( 'Note:' - )} This automatic setup doesn't work in a monorepo, see the babel documentation for how to setup babel manually: + )} After installing the necessary presets, if it does not work in a monorepo, see the babel documentation for reference: ${chalk.yellow('https://babeljs.io/docs')} - We can create a ${chalk.blue( - '.babelrc.json' - )} file with some basic configuration and add any necessary package devDependencies. - Please see the migration guide for more information: ${chalk.yellow( 'https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#babel-mode-v7-exclusively' )} - `; }, async run() { diff --git a/code/lib/cli/src/babel-config.ts b/code/lib/cli/src/babel-config.ts index 24ea3436927b..8816042e7b9b 100644 --- a/code/lib/cli/src/babel-config.ts +++ b/code/lib/cli/src/babel-config.ts @@ -59,7 +59,7 @@ export const writeBabelConfigFile = async ({ }; export const generateStorybookBabelConfig = async ({ target }: { target: string }) => { - logger.info(`Generating the storybook default babel config at ${target}`); + logger.info(`Generating the Storybook default babel config at ${target}`); const fileName = '.babelrc.json'; const location = path.join(target, fileName); @@ -80,12 +80,6 @@ export const generateStorybookBabelConfig = async ({ target }: { target: string } } - logger.info( - `The config will contain ${chalk.yellow( - '@babel/preset-env' - )} and you will be prompted for additional presets, if you wish to add them depending on your project needs.` - ); - const { typescript, jsx } = await prompts([ { type: 'confirm', @@ -106,24 +100,8 @@ export const generateStorybookBabelConfig = async ({ target }: { target: string logger.info(`Writing file to ${location}`); await writeBabelConfigFile({ location, typescript, jsx }); - const { runInstall } = await prompts({ - type: 'confirm', - initial: true, - name: 'runInstall', - message: `Shall we install the required dependencies now? (${dependencies.join(', ')})`, - }); - - if (runInstall) { - logger.info(`Installing dependencies...`); - - const packageManager = JsPackageManagerFactory.getPackageManager(); - - await packageManager.addDependencies({ installAsDevDependencies: true }, dependencies); - } else { - logger.info( - `⚠️ Please remember to install the required dependencies yourself: (${dependencies.join( - ', ' - )})` - ); - } + const packageManager = JsPackageManagerFactory.getPackageManager(); + + logger.info(`Installing dependencies (${dependencies.join(', ')})`); + await packageManager.addDependencies({ installAsDevDependencies: true }, dependencies); };