mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 18:41:06 +08:00
Merge pull request #21166 from storybookjs/norbert/fix-21004-some-more
CLI: Fix CRA init, ensure the new version of the preset
This commit is contained in:
commit
f9e61a6656
@ -41,6 +41,7 @@
|
||||
- [SvelteKit: needs the `@storybook/sveltekit` framework](#sveltekit-needs-the-storybooksveltekit-framework)
|
||||
- [Vue3: replaced app export with setup](#vue3-replaced-app-export-with-setup)
|
||||
- [Web-components: dropped lit-html v1 support](#web-components-dropped-lit-html-v1-support)
|
||||
- [Create React App: dropped CRA4 support](#create-react-app-dropped-cra4-support)
|
||||
- [7.0 Addon authors changes](#70-addon-authors-changes)
|
||||
- [register.js removed](#registerjs-removed)
|
||||
- [No more default export from `@storybook/addons`](#no-more-default-export-from-storybookaddons)
|
||||
@ -886,6 +887,10 @@ setup((app) => {
|
||||
|
||||
In v6.x `@storybook/web-components` had a peer dependency on `lit-html` v1 or v2. In 7.0 we've dropped support for `lit-html` v1 and now uses `lit` v2 instead. Please upgrade your project's `lit-html` dependency if you're still on 1.x.
|
||||
|
||||
#### Create React App: dropped CRA4 support
|
||||
|
||||
Since v7 [drops webpack4 support](#webpack4-support-discontinued), it longer supports Create React App < 5.0. If you're using an earlier version of CRA, please upgrade or stay on Storybook 6.x.
|
||||
|
||||
### 7.0 Addon authors changes
|
||||
|
||||
#### register.js removed
|
||||
|
@ -2,9 +2,11 @@ import path from 'path';
|
||||
import fs from 'fs';
|
||||
import semver from 'semver';
|
||||
|
||||
import dedent from 'ts-dedent';
|
||||
import { baseGenerator } from '../baseGenerator';
|
||||
import type { Generator } from '../types';
|
||||
import { CoreBuilder } from '../../project_types';
|
||||
import versions from '../../versions';
|
||||
|
||||
const generator: Generator = async (packageManager, npmOptions, options) => {
|
||||
const monorepoRootPath = path.join(__dirname, '..', '..', '..', '..', '..', '..');
|
||||
@ -26,11 +28,11 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
|
||||
const craVersion = semver.coerce(
|
||||
packageManager.retrievePackageJson().dependencies['react-scripts']
|
||||
)?.version;
|
||||
const isCra5 = craVersion && 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) {
|
||||
const isCra5OrHigher = craVersion && semver.gte(craVersion, '5.0.0');
|
||||
const updatedOptions = isCra5OrHigher ? { ...options, builder: CoreBuilder.Webpack5 } : options;
|
||||
|
||||
const extraPackages = [];
|
||||
if (isCra5OrHigher) {
|
||||
extraPackages.push('webpack');
|
||||
// Miscellaneous dependency used in `babel-preset-react-app` but not listed as dep there
|
||||
extraPackages.push('babel-plugin-named-exports-order');
|
||||
@ -38,8 +40,16 @@ const generator: Generator = async (packageManager, npmOptions, options) => {
|
||||
extraPackages.push('prop-types');
|
||||
}
|
||||
|
||||
// preset v3 is compat with older versions of CRA, otherwise let version float
|
||||
const extraAddons = [`@storybook/preset-create-react-app${isCra5 ? '' : '@3'}`];
|
||||
const version = versions['@storybook/preset-create-react-app'];
|
||||
const extraAddons = [`@storybook/preset-create-react-app@${version}`];
|
||||
|
||||
if (!isCra5OrHigher) {
|
||||
throw new Error(dedent`
|
||||
Storybook 7.0+ doesn't support react-scripts@<5.0.0.
|
||||
|
||||
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#create-react-app-dropped-cra4-support
|
||||
`);
|
||||
}
|
||||
|
||||
await baseGenerator(packageManager, npmOptions, updatedOptions, 'react', {
|
||||
extraAddons,
|
||||
|
@ -19,8 +19,7 @@ export default {
|
||||
'@storybook/addon-viewport': '7.0.0-beta.51',
|
||||
'@storybook/addons': '7.0.0-beta.51',
|
||||
'@storybook/angular': '7.0.0-beta.51',
|
||||
'@storybook/manager-api': '7.0.0-beta.51',
|
||||
'@storybook/blocks': '7.0.0-beta.51',
|
||||
'@storybook/api': '7.0.0-beta.51',
|
||||
'@storybook/builder-manager': '7.0.0-beta.51',
|
||||
'@storybook/builder-vite': '7.0.0-beta.51',
|
||||
'@storybook/builder-webpack5': '7.0.0-beta.51',
|
||||
@ -31,25 +30,27 @@ export default {
|
||||
'@storybook/client-api': '7.0.0-beta.51',
|
||||
'@storybook/client-logger': '7.0.0-beta.51',
|
||||
'@storybook/codemod': '7.0.0-beta.51',
|
||||
'@storybook/components': '7.0.0-beta.51',
|
||||
'@storybook/core-client': '7.0.0-beta.51',
|
||||
'@storybook/core-common': '7.0.0-beta.51',
|
||||
'@storybook/core-events': '7.0.0-beta.51',
|
||||
'@storybook/core-server': '7.0.0-beta.51',
|
||||
'@storybook/core-webpack': '7.0.0-beta.51',
|
||||
'@storybook/csf-plugin': '7.0.0-beta.51',
|
||||
'@storybook/csf-tools': '7.0.0-beta.51',
|
||||
'@storybook/docs-tools': '7.0.0-beta.51',
|
||||
'@storybook/ember': '7.0.0-beta.51',
|
||||
'@storybook/html': '7.0.0-beta.51',
|
||||
'@storybook/html-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/html-vite': '7.0.0-beta.51',
|
||||
'@storybook/html-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/instrumenter': '7.0.0-beta.51',
|
||||
'@storybook/manager-api': '7.0.0-beta.51',
|
||||
'@storybook/nextjs': '7.0.0-beta.51',
|
||||
'@storybook/node-logger': '7.0.0-beta.51',
|
||||
'@storybook/postinstall': '7.0.0-beta.51',
|
||||
'@storybook/preact': '7.0.0-beta.51',
|
||||
'@storybook/preact-vite': '7.0.0-beta.51',
|
||||
'@storybook/preact-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/preset-create-react-app': '7.0.0-beta.51',
|
||||
'@storybook/preset-html-webpack': '7.0.0-beta.51',
|
||||
'@storybook/preset-preact-webpack': '7.0.0-beta.51',
|
||||
'@storybook/preset-react-webpack': '7.0.0-beta.51',
|
||||
@ -70,12 +71,12 @@ export default {
|
||||
'@storybook/source-loader': '7.0.0-beta.51',
|
||||
'@storybook/store': '7.0.0-beta.51',
|
||||
'@storybook/svelte': '7.0.0-beta.51',
|
||||
'@storybook/sveltekit': '7.0.0-beta.51',
|
||||
'@storybook/svelte-vite': '7.0.0-beta.51',
|
||||
'@storybook/svelte-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/sveltekit': '7.0.0-beta.51',
|
||||
'@storybook/telemetry': '7.0.0-beta.51',
|
||||
'@storybook/theming': '7.0.0-beta.51',
|
||||
'@storybook/manager': '7.0.0-beta.51',
|
||||
'@storybook/types': '7.0.0-beta.51',
|
||||
'@storybook/vue': '7.0.0-beta.51',
|
||||
'@storybook/vue-vite': '7.0.0-beta.51',
|
||||
'@storybook/vue-webpack5': '7.0.0-beta.51',
|
||||
@ -83,8 +84,8 @@ export default {
|
||||
'@storybook/vue3-vite': '7.0.0-beta.51',
|
||||
'@storybook/vue3-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/web-components': '7.0.0-beta.51',
|
||||
'@storybook/web-components-webpack5': '7.0.0-beta.51',
|
||||
'@storybook/web-components-vite': '7.0.0-beta.51',
|
||||
'@storybook/web-components-webpack5': '7.0.0-beta.51',
|
||||
sb: '7.0.0-beta.51',
|
||||
storybook: '7.0.0-beta.51',
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user