Skip to content

Commit

Permalink
remove prompt from babelrc command
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed May 12, 2023
1 parent 31344f8 commit 4eb0401
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
11 changes: 5 additions & 6 deletions code/lib/cli/src/automigrate/fixes/missing-babelrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,19 @@ export const missingBabelRc: Fix<MissingBabelRcOptions> = {
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() {
Expand Down
33 changes: 5 additions & 28 deletions code/lib/cli/src/babel-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { writeFile, pathExists } from 'fs-extra';
import { logger } from '@storybook/node-logger';
import path from 'path';
import prompts from 'prompts';
import chalk from 'chalk';
import { JsPackageManagerFactory } from './js-package-manager';

export const generateStorybookBabelConfigInCWD = async () => {
Expand Down Expand Up @@ -59,7 +58,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);
Expand All @@ -80,12 +79,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',
Expand All @@ -106,24 +99,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);
};

0 comments on commit 4eb0401

Please sign in to comment.