@storybook/cli 7.0.0-alpha.31 → 7.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +35 -0
- package/bin/index.js +1 -1
- package/dist/generate.d.ts +1 -0
- package/dist/generate.js +265 -0
- package/dist/generate.mjs +265 -0
- package/package.json +18 -12
- package/rendererAssets/svelte/Button.svelte +4 -3
- package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/tsconfig.json +0 -0
- package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/typings.d.ts +0 -0
- package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/tsconfig.json +0 -0
- package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/typings.d.ts +0 -0
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/addons.js +1 -1
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/index.js +13 -6
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/rn-addons.js +1 -1
- package/templates/react-native/template-csf/storybook/stories/Button/Button.stories.js +20 -0
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Button/index.js +8 -10
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/index.js +8 -9
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/style.js +3 -3
- package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Welcome/Welcome.stories.js +2 -3
- package/templates/react-native/template-csf/storybook/stories/Welcome/index.js +57 -0
- package/templates/react-native/template-csf/storybook/stories/index.js +2 -0
- package/templates/server/template-csf/.storybook/preview.js +5 -0
- package/dist/cjs/NpmOptions.js +0 -1
- package/dist/cjs/add.js +0 -149
- package/dist/cjs/automigrate/fixes/angular12.js +0 -74
- package/dist/cjs/automigrate/fixes/builder-vite.js +0 -118
- package/dist/cjs/automigrate/fixes/cra5.js +0 -82
- package/dist/cjs/automigrate/fixes/eslint-plugin.js +0 -126
- package/dist/cjs/automigrate/fixes/index.js +0 -45
- package/dist/cjs/automigrate/fixes/mainjsFramework.js +0 -94
- package/dist/cjs/automigrate/fixes/new-frameworks.js +0 -258
- package/dist/cjs/automigrate/fixes/npm7.js +0 -57
- package/dist/cjs/automigrate/fixes/sb-scripts.js +0 -140
- package/dist/cjs/automigrate/fixes/vue3.js +0 -77
- package/dist/cjs/automigrate/fixes/webpack5.js +0 -151
- package/dist/cjs/automigrate/helpers/getEslintInfo.js +0 -28
- package/dist/cjs/automigrate/index.js +0 -98
- package/dist/cjs/automigrate/types.js +0 -5
- package/dist/cjs/babel-config.js +0 -65
- package/dist/cjs/build.js +0 -36
- package/dist/cjs/detect-nextjs.js +0 -33
- package/dist/cjs/detect-webpack.js +0 -39
- package/dist/cjs/detect.js +0 -179
- package/dist/cjs/dev.js +0 -66
- package/dist/cjs/dirs.js +0 -12
- package/dist/cjs/extract.js +0 -93
- package/dist/cjs/generate.js +0 -215
- package/dist/cjs/generators/ANGULAR/angular-helpers.js +0 -106
- package/dist/cjs/generators/ANGULAR/index.js +0 -95
- package/dist/cjs/generators/AURELIA/index.js +0 -41
- package/dist/cjs/generators/EMBER/index.js +0 -20
- package/dist/cjs/generators/HTML/index.js +0 -15
- package/dist/cjs/generators/MARIONETTE/index.js +0 -15
- package/dist/cjs/generators/MARKO/index.js +0 -15
- package/dist/cjs/generators/MITHRIL/index.js +0 -15
- package/dist/cjs/generators/PREACT/index.js +0 -15
- package/dist/cjs/generators/RAX/index.js +0 -28
- package/dist/cjs/generators/REACT/index.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/index.js +0 -55
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/addons.js +0 -7
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/index.js +0 -31
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/rn-addons.js +0 -5
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -23
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/index.js +0 -32
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/index.js +0 -31
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/style.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/Welcome.stories.js +0 -15
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -68
- package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -5
- package/dist/cjs/generators/REACT_SCRIPTS/index.js +0 -68
- package/dist/cjs/generators/RIOT/index.js +0 -17
- package/dist/cjs/generators/SERVER/index.js +0 -20
- package/dist/cjs/generators/SERVER/template-csf/.storybook/preview.js +0 -12
- package/dist/cjs/generators/SFC_VUE/index.js +0 -15
- package/dist/cjs/generators/SVELTE/index.js +0 -59
- package/dist/cjs/generators/VUE/index.js +0 -17
- package/dist/cjs/generators/VUE3/index.js +0 -17
- package/dist/cjs/generators/WEB-COMPONENTS/index.js +0 -17
- package/dist/cjs/generators/WEBPACK_REACT/index.js +0 -15
- package/dist/cjs/generators/baseGenerator.js +0 -208
- package/dist/cjs/generators/configure.js +0 -83
- package/dist/cjs/generators/types.js +0 -5
- package/dist/cjs/helpers.js +0 -258
- package/dist/cjs/initiate.js +0 -295
- package/dist/cjs/js-package-manager/JsPackageManager.js +0 -358
- package/dist/cjs/js-package-manager/JsPackageManagerFactory.js +0 -71
- package/dist/cjs/js-package-manager/NPMProxy.js +0 -112
- package/dist/cjs/js-package-manager/PackageJson.js +0 -5
- package/dist/cjs/js-package-manager/Yarn1Proxy.js +0 -72
- package/dist/cjs/js-package-manager/Yarn2Proxy.js +0 -68
- package/dist/cjs/js-package-manager/index.js +0 -44
- package/dist/cjs/link.js +0 -99
- package/dist/cjs/migrate.js +0 -33
- package/dist/cjs/project_types.js +0 -263
- package/dist/cjs/repro-generators/configs.js +0 -201
- package/dist/cjs/repro-generators/scripts.js +0 -338
- package/dist/cjs/repro-next.js +0 -182
- package/dist/cjs/repro-templates.js +0 -103
- package/dist/cjs/repro.js +0 -194
- package/dist/cjs/typings.d.ts +0 -3
- package/dist/cjs/upgrade.js +0 -170
- package/dist/cjs/utils.js +0 -22
- package/dist/cjs/versions.js +0 -89
- package/dist/cjs/warn.js +0 -32
- package/dist/cjs/window.d.js +0 -5
- package/dist/esm/NpmOptions.js +0 -0
- package/dist/esm/add.js +0 -121
- package/dist/esm/automigrate/fixes/angular12.js +0 -58
- package/dist/esm/automigrate/fixes/builder-vite.js +0 -103
- package/dist/esm/automigrate/fixes/cra5.js +0 -66
- package/dist/esm/automigrate/fixes/eslint-plugin.js +0 -111
- package/dist/esm/automigrate/fixes/index.js +0 -12
- package/dist/esm/automigrate/fixes/mainjsFramework.js +0 -76
- package/dist/esm/automigrate/fixes/new-frameworks.js +0 -234
- package/dist/esm/automigrate/fixes/npm7.js +0 -45
- package/dist/esm/automigrate/fixes/sb-scripts.js +0 -119
- package/dist/esm/automigrate/fixes/vue3.js +0 -60
- package/dist/esm/automigrate/fixes/webpack5.js +0 -131
- package/dist/esm/automigrate/helpers/getEslintInfo.js +0 -14
- package/dist/esm/automigrate/index.js +0 -80
- package/dist/esm/automigrate/types.js +0 -1
- package/dist/esm/babel-config.js +0 -42
- package/dist/esm/build.js +0 -22
- package/dist/esm/detect-nextjs.js +0 -24
- package/dist/esm/detect-webpack.js +0 -30
- package/dist/esm/detect.js +0 -152
- package/dist/esm/dev.js +0 -47
- package/dist/esm/dirs.js +0 -4
- package/dist/esm/extract.js +0 -77
- package/dist/esm/generate.js +0 -162
- package/dist/esm/generators/ANGULAR/angular-helpers.js +0 -82
- package/dist/esm/generators/ANGULAR/index.js +0 -76
- package/dist/esm/generators/ANGULAR/template-csf/.storybook/tsconfig.json +0 -10
- package/dist/esm/generators/ANGULAR/template-csf/.storybook/typings.d.ts +0 -4
- package/dist/esm/generators/AURELIA/index.js +0 -32
- package/dist/esm/generators/AURELIA/template-csf/.storybook/tsconfig.json +0 -9
- package/dist/esm/generators/AURELIA/template-csf/.storybook/typings.d.ts +0 -4
- package/dist/esm/generators/EMBER/index.js +0 -12
- package/dist/esm/generators/HTML/index.js +0 -7
- package/dist/esm/generators/MARIONETTE/index.js +0 -7
- package/dist/esm/generators/MARKO/index.js +0 -7
- package/dist/esm/generators/MITHRIL/index.js +0 -7
- package/dist/esm/generators/PREACT/index.js +0 -7
- package/dist/esm/generators/RAX/index.js +0 -20
- package/dist/esm/generators/REACT/index.js +0 -7
- package/dist/esm/generators/REACT_NATIVE/index.js +0 -42
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -12
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -54
- package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -2
- package/dist/esm/generators/REACT_SCRIPTS/index.js +0 -49
- package/dist/esm/generators/RIOT/index.js +0 -9
- package/dist/esm/generators/SERVER/index.js +0 -11
- package/dist/esm/generators/SERVER/template-csf/.storybook/preview.js +0 -5
- package/dist/esm/generators/SFC_VUE/index.js +0 -7
- package/dist/esm/generators/SVELTE/index.js +0 -44
- package/dist/esm/generators/VUE/index.js +0 -9
- package/dist/esm/generators/VUE3/index.js +0 -9
- package/dist/esm/generators/WEB-COMPONENTS/index.js +0 -9
- package/dist/esm/generators/WEBPACK_REACT/index.js +0 -7
- package/dist/esm/generators/baseGenerator.js +0 -191
- package/dist/esm/generators/configure.js +0 -69
- package/dist/esm/generators/types.js +0 -1
- package/dist/esm/helpers.js +0 -207
- package/dist/esm/initiate.js +0 -254
- package/dist/esm/js-package-manager/JsPackageManager.js +0 -334
- package/dist/esm/js-package-manager/JsPackageManagerFactory.js +0 -57
- package/dist/esm/js-package-manager/NPMProxy.js +0 -99
- package/dist/esm/js-package-manager/PackageJson.js +0 -1
- package/dist/esm/js-package-manager/Yarn1Proxy.js +0 -62
- package/dist/esm/js-package-manager/Yarn2Proxy.js +0 -58
- package/dist/esm/js-package-manager/index.js +0 -3
- package/dist/esm/link.js +0 -69
- package/dist/esm/migrate.js +0 -25
- package/dist/esm/project_types.js +0 -248
- package/dist/esm/repro-generators/configs.js +0 -174
- package/dist/esm/repro-generators/scripts.js +0 -307
- package/dist/esm/repro-next.js +0 -163
- package/dist/esm/repro-templates.js +0 -94
- package/dist/esm/repro.js +0 -170
- package/dist/esm/typings.d.ts +0 -3
- package/dist/esm/upgrade.js +0 -132
- package/dist/esm/utils.js +0 -13
- package/dist/esm/versions.js +0 -82
- package/dist/esm/warn.js +0 -16
- package/dist/esm/window.d.js +0 -1
- package/dist/types/NpmOptions.d.ts +0 -4
- package/dist/types/add.d.ts +0 -10
- package/dist/types/automigrate/fixes/angular12.d.ts +0 -15
- package/dist/types/automigrate/fixes/builder-vite.d.ts +0 -19
- package/dist/types/automigrate/fixes/cra5.d.ts +0 -15
- package/dist/types/automigrate/fixes/eslint-plugin.d.ts +0 -15
- package/dist/types/automigrate/fixes/index.d.ts +0 -3
- package/dist/types/automigrate/fixes/mainjsFramework.d.ts +0 -8
- package/dist/types/automigrate/fixes/new-frameworks.d.ts +0 -31
- package/dist/types/automigrate/fixes/npm7.d.ts +0 -9
- package/dist/types/automigrate/fixes/sb-scripts.d.ts +0 -23
- package/dist/types/automigrate/fixes/vue3.d.ts +0 -15
- package/dist/types/automigrate/fixes/webpack5.d.ts +0 -26
- package/dist/types/automigrate/helpers/getEslintInfo.d.ts +0 -2
- package/dist/types/automigrate/index.d.ts +0 -7
- package/dist/types/automigrate/types.d.ts +0 -15
- package/dist/types/babel-config.d.ts +0 -4
- package/dist/types/build.d.ts +0 -1
- package/dist/types/detect-nextjs.d.ts +0 -2
- package/dist/types/detect-webpack.d.ts +0 -2
- package/dist/types/detect.d.ts +0 -16
- package/dist/types/dev.d.ts +0 -1
- package/dist/types/dirs.d.ts +0 -1
- package/dist/types/extract.d.ts +0 -1
- package/dist/types/generate.d.ts +0 -1
- package/dist/types/generators/ANGULAR/angular-helpers.d.ts +0 -6
- package/dist/types/generators/ANGULAR/index.d.ts +0 -3
- package/dist/types/generators/AURELIA/index.d.ts +0 -3
- package/dist/types/generators/EMBER/index.d.ts +0 -3
- package/dist/types/generators/HTML/index.d.ts +0 -3
- package/dist/types/generators/MARIONETTE/index.d.ts +0 -3
- package/dist/types/generators/MARKO/index.d.ts +0 -3
- package/dist/types/generators/MITHRIL/index.d.ts +0 -3
- package/dist/types/generators/PREACT/index.d.ts +0 -3
- package/dist/types/generators/RAX/index.d.ts +0 -3
- package/dist/types/generators/REACT/index.d.ts +0 -3
- package/dist/types/generators/REACT_NATIVE/index.d.ts +0 -4
- package/dist/types/generators/REACT_SCRIPTS/index.d.ts +0 -3
- package/dist/types/generators/RIOT/index.d.ts +0 -3
- package/dist/types/generators/SERVER/index.d.ts +0 -3
- package/dist/types/generators/SFC_VUE/index.d.ts +0 -3
- package/dist/types/generators/SVELTE/index.d.ts +0 -3
- package/dist/types/generators/VUE/index.d.ts +0 -3
- package/dist/types/generators/VUE3/index.d.ts +0 -3
- package/dist/types/generators/WEB-COMPONENTS/index.d.ts +0 -3
- package/dist/types/generators/WEBPACK_REACT/index.d.ts +0 -3
- package/dist/types/generators/baseGenerator.d.ts +0 -5
- package/dist/types/generators/configure.d.ts +0 -19
- package/dist/types/generators/types.d.ts +0 -38
- package/dist/types/helpers.d.ts +0 -26
- package/dist/types/initiate.d.ts +0 -3
- package/dist/types/js-package-manager/JsPackageManager.d.ts +0 -118
- package/dist/types/js-package-manager/JsPackageManagerFactory.d.ts +0 -4
- package/dist/types/js-package-manager/NPMProxy.d.ts +0 -23
- package/dist/types/js-package-manager/PackageJson.d.ts +0 -4
- package/dist/types/js-package-manager/Yarn1Proxy.d.ts +0 -17
- package/dist/types/js-package-manager/Yarn2Proxy.d.ts +0 -17
- package/dist/types/js-package-manager/index.d.ts +0 -3
- package/dist/types/link.d.ts +0 -7
- package/dist/types/migrate.d.ts +0 -1
- package/dist/types/project_types.d.ts +0 -64
- package/dist/types/repro-generators/configs.d.ts +0 -44
- package/dist/types/repro-generators/scripts.d.ts +0 -44
- package/dist/types/repro-next.d.ts +0 -8
- package/dist/types/repro-templates.d.ts +0 -73
- package/dist/types/repro.d.ts +0 -14
- package/dist/types/upgrade.d.ts +0 -19
- package/dist/types/utils.d.ts +0 -2
- package/dist/types/versions.d.ts +0 -82
- package/dist/types/warn.d.ts +0 -5
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Is the user using npm7+? If so create a .npmrc with legacy-peer-deps=true
|
|
6
|
-
*/
|
|
7
|
-
export const npm7 = {
|
|
8
|
-
id: 'npm7',
|
|
9
|
-
|
|
10
|
-
async check({
|
|
11
|
-
packageManager
|
|
12
|
-
}) {
|
|
13
|
-
if (packageManager.type !== 'npm') return null;
|
|
14
|
-
const npmVersion = packageManager.getNpmVersion();
|
|
15
|
-
|
|
16
|
-
if (packageManager.needsLegacyPeerDeps(npmVersion)) {
|
|
17
|
-
return {
|
|
18
|
-
npmVersion
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return null;
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
prompt({
|
|
26
|
-
npmVersion
|
|
27
|
-
}) {
|
|
28
|
-
const npmFormatted = chalk.cyan(`npm ${npmVersion}`);
|
|
29
|
-
return dedent`
|
|
30
|
-
We've detected you are running ${npmFormatted} which has peer dependency semantics which Storybook is incompatible with.
|
|
31
|
-
|
|
32
|
-
In order to work with Storybook's package structure, you'll need to run \`npm\` with the
|
|
33
|
-
\`--legacy-peer-deps=true\` flag. We can generate an \`.npmrc\` which will do that automatically.
|
|
34
|
-
|
|
35
|
-
More info: ${chalk.yellow('https://github.com/storybookjs/storybook/issues/18298')}
|
|
36
|
-
`;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
async run({
|
|
40
|
-
packageManager
|
|
41
|
-
}) {
|
|
42
|
-
packageManager.setLegacyPeerDeps();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
|
-
import semver from '@storybook/semver';
|
|
4
|
-
import { getStorybookInfo } from '@storybook/core-common';
|
|
5
|
-
import { getStorybookVersionSpecifier } from '../../helpers';
|
|
6
|
-
const logger = console;
|
|
7
|
-
export const getStorybookScripts = scripts => {
|
|
8
|
-
const storybookScripts = {
|
|
9
|
-
custom: {},
|
|
10
|
-
official: {}
|
|
11
|
-
};
|
|
12
|
-
Object.keys(scripts).forEach(key => {
|
|
13
|
-
if (key === 'storybook' || key === 'build-storybook') {
|
|
14
|
-
storybookScripts.official[key] = scripts[key];
|
|
15
|
-
} else if (scripts[key].match(/start-storybook/) || scripts[key].match(/build-storybook/)) {
|
|
16
|
-
storybookScripts.custom[key] = scripts[key];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return storybookScripts;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Is the user using start-storybook
|
|
23
|
-
*
|
|
24
|
-
* If so:
|
|
25
|
-
* - Add storybook dependency
|
|
26
|
-
* - Change start-storybook and build-storybook scripts
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export const sbScripts = {
|
|
30
|
-
id: 'sb-scripts',
|
|
31
|
-
|
|
32
|
-
async check({
|
|
33
|
-
packageManager
|
|
34
|
-
}) {
|
|
35
|
-
const packageJson = packageManager.retrievePackageJson();
|
|
36
|
-
const {
|
|
37
|
-
scripts = {},
|
|
38
|
-
devDependencies,
|
|
39
|
-
dependencies
|
|
40
|
-
} = packageJson;
|
|
41
|
-
const {
|
|
42
|
-
version: storybookVersion
|
|
43
|
-
} = getStorybookInfo(packageJson);
|
|
44
|
-
const allDeps = Object.assign({}, dependencies, devDependencies);
|
|
45
|
-
const storybookCoerced = storybookVersion && semver.coerce(storybookVersion)?.version;
|
|
46
|
-
|
|
47
|
-
if (!storybookCoerced) {
|
|
48
|
-
logger.warn(dedent`
|
|
49
|
-
❌ Unable to determine storybook version, skipping ${chalk.cyan('sb-scripts')} fix.
|
|
50
|
-
🤔 Are you running automigrate from your project directory?
|
|
51
|
-
`);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (allDeps.sb || allDeps.storybook) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const storybookScripts = getStorybookScripts(scripts);
|
|
60
|
-
|
|
61
|
-
if (Object.keys(storybookScripts.official).length === 0 && Object.keys(storybookScripts.custom).length === 0) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Object.keys(storybookScripts.official).forEach(key => {
|
|
66
|
-
storybookScripts.official[key] = storybookScripts.official[key].replace('start-storybook', 'storybook dev').replace('build-storybook', 'storybook build');
|
|
67
|
-
});
|
|
68
|
-
return semver.gte(storybookCoerced, '7.0.0') ? {
|
|
69
|
-
packageJson,
|
|
70
|
-
storybookScripts,
|
|
71
|
-
storybookVersion
|
|
72
|
-
} : null;
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
prompt({
|
|
76
|
-
storybookVersion
|
|
77
|
-
}) {
|
|
78
|
-
const sbFormatted = chalk.cyan(`Storybook ${storybookVersion}`);
|
|
79
|
-
const explanationMessage = [`Starting in Storybook 7, the ${chalk.yellow('start-storybook')} and ${chalk.yellow('build-storybook')} binaries have changed to ${chalk.magenta('storybook dev')} and ${chalk.magenta('storybook build')} respectively.`, `In order to work with ${sbFormatted}, Storybook's ${chalk.magenta('storybook')} binary has to be installed and your storybook scripts have to be adjusted to use the binary. We can install the storybook binary and attempt to adjust your scripts for you.`].join('\n');
|
|
80
|
-
return [`We've detected you are using ${sbFormatted} with scripts from previous versions of Storybook.`, explanationMessage, `More info: ${chalk.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#start-storybook--build-storybook-binaries-removed')}`].filter(Boolean).join('\n\n');
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
async run({
|
|
84
|
-
result: {
|
|
85
|
-
storybookScripts,
|
|
86
|
-
packageJson
|
|
87
|
-
},
|
|
88
|
-
packageManager,
|
|
89
|
-
dryRun
|
|
90
|
-
}) {
|
|
91
|
-
logger.log();
|
|
92
|
-
logger.info(`Adding 'storybook' as dev dependency`);
|
|
93
|
-
logger.log();
|
|
94
|
-
|
|
95
|
-
if (!dryRun) {
|
|
96
|
-
const versionToInstall = getStorybookVersionSpecifier(packageJson);
|
|
97
|
-
packageManager.addDependencies({
|
|
98
|
-
installAsDevDependencies: true
|
|
99
|
-
}, [`storybook@${versionToInstall}`]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
logger.info(`Updating scripts in package.json`);
|
|
103
|
-
logger.log();
|
|
104
|
-
|
|
105
|
-
if (!dryRun && Object.keys(storybookScripts.official).length > 0) {
|
|
106
|
-
const message = [`Migrating your scripts to:`, chalk.yellow(JSON.stringify(storybookScripts.official, null, 2))].join('\n');
|
|
107
|
-
logger.log(message);
|
|
108
|
-
logger.log();
|
|
109
|
-
packageManager.addScripts(storybookScripts.official);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!dryRun && Object.keys(storybookScripts.custom).length > 0) {
|
|
113
|
-
const message = [`We detected custom scripts that we can't automigrate:`, chalk.yellow(JSON.stringify(storybookScripts.custom, null, 2)), '\n', `Please manually migrate the ones applicable and use the documentation below for reference: ${chalk.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#start-storybook--build-storybook-binaries-removed')}`].join('\n');
|
|
114
|
-
logger.log(message);
|
|
115
|
-
logger.log();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
|
-
import semver from '@storybook/semver';
|
|
4
|
-
import { webpack5 } from './webpack5';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Is the user upgrading to Vue3?
|
|
8
|
-
*
|
|
9
|
-
* If so:
|
|
10
|
-
* - Run webpack5 fix
|
|
11
|
-
*/
|
|
12
|
-
export const vue3 = {
|
|
13
|
-
id: 'vue3',
|
|
14
|
-
|
|
15
|
-
async check({
|
|
16
|
-
packageManager
|
|
17
|
-
}) {
|
|
18
|
-
const packageJson = packageManager.retrievePackageJson();
|
|
19
|
-
const {
|
|
20
|
-
dependencies,
|
|
21
|
-
devDependencies
|
|
22
|
-
} = packageJson;
|
|
23
|
-
const vueVersion = dependencies.vue || devDependencies.vue;
|
|
24
|
-
const vueCoerced = semver.coerce(vueVersion)?.version;
|
|
25
|
-
|
|
26
|
-
if (!vueCoerced || semver.lt(vueCoerced, '3.0.0')) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const builderInfo = await webpack5.checkWebpack5Builder(packageJson);
|
|
31
|
-
return builderInfo ? Object.assign({
|
|
32
|
-
vueVersion
|
|
33
|
-
}, builderInfo) : null;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
prompt({
|
|
37
|
-
vueVersion,
|
|
38
|
-
storybookVersion
|
|
39
|
-
}) {
|
|
40
|
-
const vueFormatted = chalk.cyan(`Vue ${vueVersion}`);
|
|
41
|
-
const sbFormatted = chalk.cyan(`Storybook ${storybookVersion}`);
|
|
42
|
-
return dedent`
|
|
43
|
-
We've detected you are running ${vueFormatted} with Storybook.
|
|
44
|
-
${sbFormatted} runs webpack4 by default, which is incompatible.
|
|
45
|
-
|
|
46
|
-
In order to work with your version of Vue, we need to install Storybook's ${chalk.cyan('webpack5 builder')}.
|
|
47
|
-
|
|
48
|
-
More info: ${chalk.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#vue3-upgrade')}
|
|
49
|
-
`;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
async run(options) {
|
|
53
|
-
return webpack5.run(Object.assign({}, options, {
|
|
54
|
-
result: Object.assign({
|
|
55
|
-
webpackVersion: null
|
|
56
|
-
}, options.result)
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
|
-
import semver from '@storybook/semver';
|
|
4
|
-
import { readConfig, writeConfig } from '@storybook/csf-tools';
|
|
5
|
-
import { getStorybookInfo } from '@storybook/core-common';
|
|
6
|
-
const logger = console;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Is the user using webpack5 in their project?
|
|
10
|
-
*
|
|
11
|
-
* If the user is using a version of SB >= 6.3,
|
|
12
|
-
* prompt them to upgrade to webpack5.
|
|
13
|
-
*
|
|
14
|
-
* - Add manager-webpack5 builder-webpack5 as dev dependencies
|
|
15
|
-
* - Add core.builder = 'webpack5' to main.js
|
|
16
|
-
* - Add 'webpack5' as a project dependency
|
|
17
|
-
*/
|
|
18
|
-
export const webpack5 = {
|
|
19
|
-
id: 'webpack5',
|
|
20
|
-
|
|
21
|
-
async checkWebpack5Builder(packageJson) {
|
|
22
|
-
const {
|
|
23
|
-
mainConfig,
|
|
24
|
-
version: storybookVersion
|
|
25
|
-
} = getStorybookInfo(packageJson);
|
|
26
|
-
const storybookCoerced = storybookVersion && semver.coerce(storybookVersion)?.version;
|
|
27
|
-
|
|
28
|
-
if (!storybookCoerced) {
|
|
29
|
-
logger.warn(dedent`
|
|
30
|
-
❌ Unable to determine storybook version, skipping ${chalk.cyan('webpack5')} fix.
|
|
31
|
-
🤔 Are you running automigrate from your project directory?
|
|
32
|
-
`);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (semver.lt(storybookCoerced, '6.3.0')) {
|
|
37
|
-
logger.warn(dedent`
|
|
38
|
-
Detected SB 6.3 or below, please upgrade storybook to use webpack5.
|
|
39
|
-
|
|
40
|
-
To upgrade to the latest stable release, run this from your project directory:
|
|
41
|
-
|
|
42
|
-
${chalk.cyan('npx storybook upgrade')}
|
|
43
|
-
|
|
44
|
-
Add the ${chalk.cyan('--prerelease')} flag to get the latest prerelease.
|
|
45
|
-
`.trim());
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (semver.gte(storybookCoerced, '7.0.0')) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!mainConfig) {
|
|
54
|
-
logger.warn('Unable to find storybook main.js config');
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const main = await readConfig(mainConfig);
|
|
59
|
-
const builder = main.getFieldValue(['core', 'builder']);
|
|
60
|
-
|
|
61
|
-
if (builder && builder !== 'webpack4') {
|
|
62
|
-
logger.info(`Found builder ${builder}, skipping`);
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
storybookVersion,
|
|
68
|
-
main
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
async check({
|
|
73
|
-
packageManager
|
|
74
|
-
}) {
|
|
75
|
-
const packageJson = packageManager.retrievePackageJson();
|
|
76
|
-
const {
|
|
77
|
-
dependencies,
|
|
78
|
-
devDependencies
|
|
79
|
-
} = packageJson;
|
|
80
|
-
const webpackVersion = dependencies.webpack || devDependencies.webpack;
|
|
81
|
-
const webpackCoerced = semver.coerce(webpackVersion)?.version;
|
|
82
|
-
if (!webpackCoerced || semver.lt(webpackCoerced, '5.0.0') || semver.gte(webpackCoerced, '6.0.0')) return null;
|
|
83
|
-
const builderInfo = await this.checkWebpack5Builder(packageJson);
|
|
84
|
-
return builderInfo ? Object.assign({
|
|
85
|
-
webpackVersion
|
|
86
|
-
}, builderInfo) : null;
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
prompt({
|
|
90
|
-
webpackVersion
|
|
91
|
-
}) {
|
|
92
|
-
const webpackFormatted = chalk.cyan(`webpack ${webpackVersion}`);
|
|
93
|
-
return dedent`
|
|
94
|
-
We've detected you're running ${webpackFormatted}.
|
|
95
|
-
Your Storybook's main.js files specifies webpack4, which is incompatible.
|
|
96
|
-
|
|
97
|
-
To run Storybook in webpack5-mode, we can install Storybook's ${chalk.cyan('@storybook/builder-webpack5')} for you.
|
|
98
|
-
|
|
99
|
-
More info: ${chalk.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#webpack-5-manager-build')}
|
|
100
|
-
`;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
async run({
|
|
104
|
-
result: {
|
|
105
|
-
main,
|
|
106
|
-
storybookVersion,
|
|
107
|
-
webpackVersion
|
|
108
|
-
},
|
|
109
|
-
packageManager,
|
|
110
|
-
dryRun
|
|
111
|
-
}) {
|
|
112
|
-
const deps = [`@storybook/builder-webpack5@${storybookVersion}`]; // this also gets called by 'cra5' fix so we need to add
|
|
113
|
-
// webpack5 at the project root so that it gets hoisted
|
|
114
|
-
|
|
115
|
-
if (!webpackVersion) {
|
|
116
|
-
deps.push('webpack@5');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
logger.info(`✅ Adding dependencies: ${deps}`);
|
|
120
|
-
if (!dryRun) packageManager.addDependencies({
|
|
121
|
-
installAsDevDependencies: true
|
|
122
|
-
}, deps);
|
|
123
|
-
logger.info('✅ Setting `core.builder` to `@storybook/builder-webpack5` in main.js');
|
|
124
|
-
|
|
125
|
-
if (!dryRun) {
|
|
126
|
-
main.setFieldValue(['core', 'builder'], '@storybook/builder-webpack5');
|
|
127
|
-
await writeConfig(main);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import fse from 'fs-extra';
|
|
2
|
-
export const SUPPORTED_ESLINT_EXTENSIONS = ['js', 'cjs'];
|
|
3
|
-
const UNSUPPORTED_ESLINT_EXTENSIONS = ['yaml', 'yml', 'json'];
|
|
4
|
-
export const findEslintFile = () => {
|
|
5
|
-
const filePrefix = '.eslintrc';
|
|
6
|
-
const unsupportedExtension = UNSUPPORTED_ESLINT_EXTENSIONS.find(ext => fse.existsSync(`${filePrefix}.${ext}`));
|
|
7
|
-
|
|
8
|
-
if (unsupportedExtension) {
|
|
9
|
-
throw new Error(unsupportedExtension);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const extension = SUPPORTED_ESLINT_EXTENSIONS.find(ext => fse.existsSync(`${filePrefix}.${ext}`));
|
|
13
|
-
return extension ? `${filePrefix}.${extension}` : null;
|
|
14
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-await-in-loop */
|
|
2
|
-
import prompts from 'prompts';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import boxen from 'boxen';
|
|
5
|
-
import { JsPackageManagerFactory } from '../js-package-manager';
|
|
6
|
-
import { fixes } from './fixes';
|
|
7
|
-
const logger = console;
|
|
8
|
-
export const automigrate = async ({
|
|
9
|
-
fixId,
|
|
10
|
-
dryRun,
|
|
11
|
-
yes
|
|
12
|
-
} = {}) => {
|
|
13
|
-
const packageManager = JsPackageManagerFactory.getPackageManager();
|
|
14
|
-
const filtered = fixId ? fixes.filter(f => f.id === fixId) : fixes;
|
|
15
|
-
logger.info('🔎 checking possible migrations..');
|
|
16
|
-
|
|
17
|
-
for (let i = 0; i < filtered.length; i += 1) {
|
|
18
|
-
const f = fixes[i];
|
|
19
|
-
let result;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
result = await f.check({
|
|
23
|
-
packageManager
|
|
24
|
-
});
|
|
25
|
-
} catch (e) {
|
|
26
|
-
logger.info(`failed to check fix: ${f.id}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (result) {
|
|
30
|
-
logger.info(`🔎 found a '${chalk.cyan(f.id)}' migration:`);
|
|
31
|
-
logger.info();
|
|
32
|
-
const message = f.prompt(result);
|
|
33
|
-
logger.info(boxen(message, {
|
|
34
|
-
borderStyle: 'round',
|
|
35
|
-
padding: 1,
|
|
36
|
-
borderColor: '#F1618C'
|
|
37
|
-
}));
|
|
38
|
-
let runAnswer;
|
|
39
|
-
|
|
40
|
-
if (dryRun) {
|
|
41
|
-
runAnswer = {
|
|
42
|
-
fix: false
|
|
43
|
-
};
|
|
44
|
-
} else if (yes) {
|
|
45
|
-
runAnswer = {
|
|
46
|
-
fix: true
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
runAnswer = await prompts({
|
|
50
|
-
type: 'confirm',
|
|
51
|
-
name: 'fix',
|
|
52
|
-
message: `Do you want to run the '${chalk.cyan(f.id)}' migration on your project?`
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (runAnswer.fix) {
|
|
57
|
-
try {
|
|
58
|
-
await f.run({
|
|
59
|
-
result,
|
|
60
|
-
packageManager,
|
|
61
|
-
dryRun
|
|
62
|
-
});
|
|
63
|
-
logger.info(`✅ ran ${chalk.cyan(f.id)} migration`);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
logger.info(`❌ error when running ${chalk.cyan(f.id)} migration:`);
|
|
66
|
-
logger.info(error);
|
|
67
|
-
logger.info();
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
logger.info(`Skipping the ${chalk.cyan(f.id)} migration.`);
|
|
71
|
-
logger.info();
|
|
72
|
-
logger.info(`If you change your mind, run '${chalk.cyan('npx storybook@next automigrate')}'`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
logger.info();
|
|
78
|
-
logger.info('✅ migration check successfully ran');
|
|
79
|
-
logger.info();
|
|
80
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/babel-config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { writeFile, access } from 'fs-extra';
|
|
2
|
-
import { logger } from '@storybook/node-logger';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import prompts from 'prompts';
|
|
5
|
-
export const generateStorybookBabelConfigInCWD = async () => {
|
|
6
|
-
const target = process.cwd();
|
|
7
|
-
return generateStorybookBabelConfig({
|
|
8
|
-
target
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
export const generateStorybookBabelConfig = async ({
|
|
12
|
-
target
|
|
13
|
-
}) => {
|
|
14
|
-
logger.info(`Generating the storybook default babel config at ${target}`);
|
|
15
|
-
const contents = JSON.stringify({
|
|
16
|
-
sourceType: 'unambiguous',
|
|
17
|
-
presets: [],
|
|
18
|
-
plugins: []
|
|
19
|
-
}, null, 2);
|
|
20
|
-
const fileName = '.babelrc.json';
|
|
21
|
-
const location = path.join(target, fileName);
|
|
22
|
-
const exists = await access(location).then(() => true, () => false);
|
|
23
|
-
|
|
24
|
-
if (exists) {
|
|
25
|
-
const {
|
|
26
|
-
overwrite
|
|
27
|
-
} = await prompts({
|
|
28
|
-
type: 'confirm',
|
|
29
|
-
initial: true,
|
|
30
|
-
name: 'overwrite',
|
|
31
|
-
message: `${fileName} already exists. Would you like overwrite it?`
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (overwrite === false) {
|
|
35
|
-
logger.warn(`Cancelled, babel config file was NOT written to file-system.`);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
logger.info(`Writing file to ${location}`);
|
|
41
|
-
await writeFile(location, contents);
|
|
42
|
-
};
|
package/dist/esm/build.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { sync as readUpSync } from 'read-pkg-up';
|
|
2
|
-
import { logger } from '@storybook/node-logger';
|
|
3
|
-
import { buildStaticStandalone } from '@storybook/core-server';
|
|
4
|
-
import { cache } from '@storybook/core-common';
|
|
5
|
-
export const build = async cliOptions => {
|
|
6
|
-
try {
|
|
7
|
-
await buildStaticStandalone(Object.assign({}, cliOptions, {
|
|
8
|
-
configDir: cliOptions.configDir || './.storybook',
|
|
9
|
-
outputDir: cliOptions.outputDir || './storybook-static',
|
|
10
|
-
ignorePreview: !!cliOptions.previewUrl && !cliOptions.forceBuildPreview,
|
|
11
|
-
docsMode: !!cliOptions.docs,
|
|
12
|
-
configType: 'PRODUCTION',
|
|
13
|
-
cache,
|
|
14
|
-
packageJson: readUpSync({
|
|
15
|
-
cwd: __dirname
|
|
16
|
-
}).packageJson
|
|
17
|
-
}));
|
|
18
|
-
} catch (e) {
|
|
19
|
-
logger.error(e);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const regex = /[\s"\n]next.*?(\d+).*/;
|
|
2
|
-
export const detectNextJS = packageManager => {
|
|
3
|
-
try {
|
|
4
|
-
let out = '';
|
|
5
|
-
|
|
6
|
-
if (packageManager.type === 'npm') {
|
|
7
|
-
try {
|
|
8
|
-
// npm <= v7
|
|
9
|
-
out = packageManager.executeCommand('npm', ['ls', 'next']);
|
|
10
|
-
} catch (e2) {
|
|
11
|
-
// npm >= v8
|
|
12
|
-
out = packageManager.executeCommand('npm', ['why', 'next']);
|
|
13
|
-
}
|
|
14
|
-
} else {
|
|
15
|
-
out = packageManager.executeCommand('yarn', ['why', 'next']);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const [, version] = out.match(regex);
|
|
19
|
-
return version && parseInt(version, 10) ? parseInt(version, 10) : false;
|
|
20
|
-
} catch (err) {//
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const detectWebpack = packageManager => {
|
|
2
|
-
try {
|
|
3
|
-
let out = '';
|
|
4
|
-
|
|
5
|
-
if (packageManager.type === 'npm') {
|
|
6
|
-
try {
|
|
7
|
-
// npm <= v7
|
|
8
|
-
out = packageManager.executeCommand('npm', ['ls', 'webpack']);
|
|
9
|
-
} catch (e2) {
|
|
10
|
-
// npm >= v8
|
|
11
|
-
out = packageManager.executeCommand('npm', ['why', 'webpack']);
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
out = packageManager.executeCommand('yarn', ['why', 'webpack']);
|
|
15
|
-
} // if the user has BOTH webpack 4 and 5 installed already, we'll pick the safest options (4)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (out.includes('webpack@4') || out.includes('webpack@npm:4')) {
|
|
19
|
-
return 4;
|
|
20
|
-
} // the user has webpack 4 installed, but not 5
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (out.includes('webpack@5') || out.includes('webpack@npm:5')) {
|
|
24
|
-
return 5;
|
|
25
|
-
}
|
|
26
|
-
} catch (err) {//
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return false;
|
|
30
|
-
};
|