CLI: Limit preset install for old versions of SB

This commit is contained in:
Michael Shilman 2021-09-30 23:43:46 +08:00
parent 2744fb78ba
commit c8ad08828c

View File

@ -27,12 +27,15 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
)?.version;
const isCra5 = semver.gte(craVersion, '5.0.0');
const updatedOptions = isCra5 ? { ...options, builder: CoreBuilder.Webpack5 } : options;
// `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
const extraPackages = ['@storybook/node-logger'];
if (isCra5) extraPackages.push('webpack');
// preset v3 is compat with older versions of CRA, otherwise let version float
const extraAddons = [`@storybook/preset-create-react-app${isCra5 ? '' : '@3'}`];
await baseGenerator(packageManager, npmOptions, updatedOptions, 'react', {
extraAddons: ['@storybook/preset-create-react-app'],
// `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
extraAddons,
extraPackages,
staticDir: fs.existsSync(path.resolve('./public')) ? 'public' : undefined,
addBabel: false,