@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,307 +0,0 @@
|
|
|
1
|
-
const _excluded = ["name", "version"];
|
|
2
|
-
|
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
-
|
|
5
|
-
/* eslint-disable camelcase */
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { readJSON, writeJSON, outputFile } from 'fs-extra';
|
|
8
|
-
import shell from 'shelljs';
|
|
9
|
-
import chalk from 'chalk';
|
|
10
|
-
import { command } from 'execa';
|
|
11
|
-
import { cra, cra_typescript } from './configs';
|
|
12
|
-
import storybookVersions from '../versions';
|
|
13
|
-
const logger = console;
|
|
14
|
-
export const exec = async (command, options = {}, {
|
|
15
|
-
startMessage,
|
|
16
|
-
errorMessage,
|
|
17
|
-
dryRun
|
|
18
|
-
} = {}) => {
|
|
19
|
-
if (startMessage) logger.info(startMessage);
|
|
20
|
-
|
|
21
|
-
if (dryRun) {
|
|
22
|
-
logger.info(`\n> ${command}\n`);
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
logger.debug(command);
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
const defaultOptions = {
|
|
29
|
-
silent: false
|
|
30
|
-
};
|
|
31
|
-
const child = shell.exec(command, Object.assign({}, defaultOptions, options, {
|
|
32
|
-
async: true,
|
|
33
|
-
silent: false
|
|
34
|
-
}));
|
|
35
|
-
child.stderr.pipe(process.stderr);
|
|
36
|
-
child.on('exit', code => {
|
|
37
|
-
if (code === 0) {
|
|
38
|
-
resolve(undefined);
|
|
39
|
-
} else {
|
|
40
|
-
logger.error(chalk.red(`An error occurred while executing: \`${command}\``));
|
|
41
|
-
logger.log(errorMessage);
|
|
42
|
-
reject(new Error(`command exited with code: ${code}: `));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const addPackageResolutions = async ({
|
|
49
|
-
cwd
|
|
50
|
-
}) => {
|
|
51
|
-
logger.info(`🔢 Adding package resolutions:`);
|
|
52
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
53
|
-
const packageJson = await readJSON(packageJsonPath);
|
|
54
|
-
packageJson.resolutions = storybookVersions;
|
|
55
|
-
await writeJSON(packageJsonPath, packageJson, {
|
|
56
|
-
spaces: 2
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const addLocalPackageResolutions = async ({
|
|
61
|
-
cwd
|
|
62
|
-
}) => {
|
|
63
|
-
logger.info(`🔢 Adding package resolutions:`);
|
|
64
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
65
|
-
const packageJson = await readJSON(packageJsonPath);
|
|
66
|
-
const workspaceDir = path.join(__dirname, '..', '..', '..', '..', '..');
|
|
67
|
-
const {
|
|
68
|
-
stdout
|
|
69
|
-
} = await command('yarn workspaces list --json', {
|
|
70
|
-
cwd: workspaceDir
|
|
71
|
-
});
|
|
72
|
-
console.log({
|
|
73
|
-
stdout,
|
|
74
|
-
workspaceDir
|
|
75
|
-
});
|
|
76
|
-
const workspaces = JSON.parse(`[${stdout.split('\n').join(',')}]`);
|
|
77
|
-
console.log({
|
|
78
|
-
workspaces
|
|
79
|
-
});
|
|
80
|
-
packageJson.resolutions = Object.keys(storybookVersions).reduce((acc, key) => {
|
|
81
|
-
return Object.assign({}, acc, {
|
|
82
|
-
[key]: path.join(workspaceDir, workspaces.find(item => item.name === key).location)
|
|
83
|
-
});
|
|
84
|
-
}, {});
|
|
85
|
-
await writeJSON(packageJsonPath, packageJson, {
|
|
86
|
-
spaces: 2
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const installYarn2 = async ({
|
|
91
|
-
cwd,
|
|
92
|
-
pnp,
|
|
93
|
-
name
|
|
94
|
-
}) => {
|
|
95
|
-
const command = [`yarn set version berry`, `yarn config set enableGlobalCache true`, `yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`]; // FIXME: Some dependencies used by CRA aren't listed in its package.json
|
|
96
|
-
// Next line is a hack to remove as soon as CRA will have added these missing deps
|
|
97
|
-
// for details see https://github.com/facebook/create-react-app/pull/11751
|
|
98
|
-
|
|
99
|
-
if ([cra.name, cra_typescript.name].includes(name)) {
|
|
100
|
-
command.push(`yarn config set packageExtensions --json '{ "babel-preset-react-app@10.0.x": { "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.16.0" } } }'`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
await exec(command.join(' && '), {
|
|
104
|
-
cwd
|
|
105
|
-
}, {
|
|
106
|
-
startMessage: `🧶 Installing Yarn 2`,
|
|
107
|
-
errorMessage: `🚨 Installing Yarn 2 failed`
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const configureYarn2ForE2E = async ({
|
|
112
|
-
cwd
|
|
113
|
-
}) => {
|
|
114
|
-
const command = [// ⚠️ Need to set registry because Yarn 2 is not using the conf of Yarn 1 (URL is hardcoded in CircleCI config.yml)
|
|
115
|
-
`yarn config set npmScopes --json '{ "storybook": { "npmRegistryServer": "http://localhost:6001/" } }'`, // Some required magic to be able to fetch deps from local registry
|
|
116
|
-
`yarn config set unsafeHttpWhitelist --json '["localhost"]'`, // Disable fallback mode to make sure everything is required correctly
|
|
117
|
-
`yarn config set pnpFallbackMode none`, // We need to be able to update lockfile when bootstrapping the examples
|
|
118
|
-
`yarn config set enableImmutableInstalls false`, // Discard all YN0013 - FETCH_NOT_CACHED messages
|
|
119
|
-
`yarn config set logFilters --json '[ { "code": "YN0013", "level": "discard" } ]'`].join(' && ');
|
|
120
|
-
await exec(command, {
|
|
121
|
-
cwd
|
|
122
|
-
}, {
|
|
123
|
-
startMessage: `🎛 Configuring Yarn 2`,
|
|
124
|
-
errorMessage: `🚨 Configuring Yarn 2 failed`
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const generate = async ({
|
|
129
|
-
cwd,
|
|
130
|
-
name,
|
|
131
|
-
appName,
|
|
132
|
-
version,
|
|
133
|
-
generator
|
|
134
|
-
}) => {
|
|
135
|
-
const command = generator.replace(/{{appName}}/g, appName).replace(/{{version}}/g, version);
|
|
136
|
-
await exec(command, {
|
|
137
|
-
cwd
|
|
138
|
-
}, {
|
|
139
|
-
startMessage: `🏗 Bootstrapping ${name} project (this might take a few minutes)`,
|
|
140
|
-
errorMessage: `🚨 Bootstrapping ${name} failed`
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const addAdditionalFiles = async ({
|
|
145
|
-
additionalFiles,
|
|
146
|
-
cwd
|
|
147
|
-
}) => {
|
|
148
|
-
logger.info(`⤵️ Adding required files`);
|
|
149
|
-
await Promise.all(additionalFiles.map(async file => {
|
|
150
|
-
await outputFile(path.resolve(cwd, file.path), file.contents, {
|
|
151
|
-
encoding: 'UTF-8'
|
|
152
|
-
});
|
|
153
|
-
}));
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const initStorybook = async ({
|
|
157
|
-
cwd,
|
|
158
|
-
autoDetect = true,
|
|
159
|
-
name,
|
|
160
|
-
e2e,
|
|
161
|
-
pnp
|
|
162
|
-
}) => {
|
|
163
|
-
const flags = ['--yes'];
|
|
164
|
-
|
|
165
|
-
if (!autoDetect) {
|
|
166
|
-
flags.push(`--type ${name}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (e2e) {
|
|
170
|
-
flags.push('--linkable');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (pnp) {
|
|
174
|
-
flags.push('--use-pnp');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const sbCLICommand = `node ${path.join(__dirname, '../../cjs/generate')}`;
|
|
178
|
-
const command = `${sbCLICommand} init ${flags.join(' ')}`;
|
|
179
|
-
await exec(command, {
|
|
180
|
-
cwd
|
|
181
|
-
}, {
|
|
182
|
-
startMessage: `🎨 Initializing Storybook with @storybook/cli`,
|
|
183
|
-
errorMessage: `🚨 Storybook initialization failed`
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const addRequiredDeps = async ({
|
|
188
|
-
cwd,
|
|
189
|
-
additionalDeps
|
|
190
|
-
}) => {
|
|
191
|
-
// Remove any lockfile generated without Yarn 2
|
|
192
|
-
shell.rm('-f', path.join(cwd, 'package-lock.json'), path.join(cwd, 'yarn.lock'));
|
|
193
|
-
const command = additionalDeps && additionalDeps.length > 0 ? `yarn add -D ${additionalDeps.join(' ')}` : `yarn install`;
|
|
194
|
-
await exec(command, {
|
|
195
|
-
cwd
|
|
196
|
-
}, {
|
|
197
|
-
startMessage: `🌍 Adding needed deps & installing all deps`,
|
|
198
|
-
errorMessage: `🚨 Dependencies installation failed`
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const addTypescript = async ({
|
|
203
|
-
cwd
|
|
204
|
-
}) => {
|
|
205
|
-
logger.info(`👮 Adding typescript and tsconfig.json`);
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
await exec(`yarn add -D typescript@latest`, {
|
|
209
|
-
cwd
|
|
210
|
-
});
|
|
211
|
-
const tsConfig = {
|
|
212
|
-
compilerOptions: {
|
|
213
|
-
baseUrl: '.',
|
|
214
|
-
esModuleInterop: true,
|
|
215
|
-
jsx: 'preserve',
|
|
216
|
-
skipLibCheck: true,
|
|
217
|
-
strict: true
|
|
218
|
-
},
|
|
219
|
-
include: ['src/*']
|
|
220
|
-
};
|
|
221
|
-
const tsConfigJsonPath = path.resolve(cwd, 'tsconfig.json');
|
|
222
|
-
await writeJSON(tsConfigJsonPath, tsConfig, {
|
|
223
|
-
encoding: 'utf8',
|
|
224
|
-
spaces: 2
|
|
225
|
-
});
|
|
226
|
-
} catch (e) {
|
|
227
|
-
logger.error(`🚨 Creating tsconfig.json failed`);
|
|
228
|
-
throw e;
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
const doTask = async (task, options, condition = true) => {
|
|
233
|
-
if (condition) {
|
|
234
|
-
await task(options);
|
|
235
|
-
logger.log();
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const registryUrlNPM = url => {
|
|
240
|
-
const args = ['config', 'set', 'registry', url];
|
|
241
|
-
return exec(`npm ${args.join(' ')}`, {
|
|
242
|
-
cwd: path.join(process.cwd(), '..')
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const registryUrlYarn = url => {
|
|
247
|
-
const args = ['config', 'set', 'npmRegistryServer', url];
|
|
248
|
-
return exec(`yarn ${args.join(' ')}`, {
|
|
249
|
-
cwd: path.join(__dirname, '..')
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export const createAndInit = async (cwd, _ref, {
|
|
254
|
-
e2e,
|
|
255
|
-
pnp,
|
|
256
|
-
local,
|
|
257
|
-
registry
|
|
258
|
-
}) => {
|
|
259
|
-
let {
|
|
260
|
-
name,
|
|
261
|
-
version
|
|
262
|
-
} = _ref,
|
|
263
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
264
|
-
|
|
265
|
-
const options = Object.assign({
|
|
266
|
-
name,
|
|
267
|
-
version,
|
|
268
|
-
appName: path.basename(cwd),
|
|
269
|
-
creationPath: path.join(cwd, '..'),
|
|
270
|
-
cwd,
|
|
271
|
-
e2e,
|
|
272
|
-
pnp
|
|
273
|
-
}, rest);
|
|
274
|
-
logger.log();
|
|
275
|
-
logger.info(`🏃 Starting for ${name} ${version}`);
|
|
276
|
-
logger.log();
|
|
277
|
-
await doTask(generate, Object.assign({}, options, {
|
|
278
|
-
cwd: options.creationPath
|
|
279
|
-
}));
|
|
280
|
-
await doTask(addAdditionalFiles, Object.assign({}, options, {
|
|
281
|
-
cwd
|
|
282
|
-
}), !!options.additionalFiles);
|
|
283
|
-
|
|
284
|
-
if (e2e) {
|
|
285
|
-
await doTask(addPackageResolutions, options);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (local) {
|
|
289
|
-
await doTask(addLocalPackageResolutions, options);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
await doTask(installYarn2, options);
|
|
293
|
-
|
|
294
|
-
if (e2e) {
|
|
295
|
-
await doTask(configureYarn2ForE2E, options, e2e);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
await doTask(addTypescript, options, !!options.typescript);
|
|
299
|
-
await doTask(addRequiredDeps, options);
|
|
300
|
-
|
|
301
|
-
if (registry) {
|
|
302
|
-
await registryUrlNPM(registry);
|
|
303
|
-
await registryUrlYarn(registry);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
await doTask(initStorybook, options);
|
|
307
|
-
};
|
package/dist/esm/repro-next.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import boxen from 'boxen';
|
|
5
|
-
import { dedent } from 'ts-dedent';
|
|
6
|
-
import degit from 'degit';
|
|
7
|
-
import { existsSync } from 'fs-extra';
|
|
8
|
-
import TEMPLATES from './repro-templates';
|
|
9
|
-
const logger = console;
|
|
10
|
-
|
|
11
|
-
const toChoices = c => ({
|
|
12
|
-
title: TEMPLATES[c].name,
|
|
13
|
-
value: c
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const reproNext = async ({
|
|
17
|
-
output: outputDirectory,
|
|
18
|
-
filterValue,
|
|
19
|
-
branch,
|
|
20
|
-
init
|
|
21
|
-
}) => {
|
|
22
|
-
const keys = Object.keys(TEMPLATES); // get value from template and reduce through TEMPLATES to filter out the correct template
|
|
23
|
-
|
|
24
|
-
const choices = keys.reduce((acc, group) => {
|
|
25
|
-
const current = TEMPLATES[group];
|
|
26
|
-
const filterRegex = new RegExp(filterValue, 'i');
|
|
27
|
-
|
|
28
|
-
if (!filterValue) {
|
|
29
|
-
acc.push(group);
|
|
30
|
-
return acc;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (current.name.match(filterRegex) || group.match(filterRegex) || current.expected.builder.match(filterRegex) || current.expected.framework.match(filterRegex) || current.expected.renderer.match(filterRegex)) {
|
|
34
|
-
acc.push(group);
|
|
35
|
-
return acc;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return acc;
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
if (choices.length === 0) {
|
|
42
|
-
logger.info(boxen(dedent`
|
|
43
|
-
🔎 You filtered out all templates. 🔍
|
|
44
|
-
|
|
45
|
-
After filtering all the templates with "${chalk.yellow(filterValue)}", we found no results. Please try again with a different filter.
|
|
46
|
-
|
|
47
|
-
Available templates:
|
|
48
|
-
${keys.map(key => chalk.blue`- ${key}`).join('\n')}
|
|
49
|
-
`.trim(), {
|
|
50
|
-
borderStyle: 'round',
|
|
51
|
-
padding: 1,
|
|
52
|
-
borderColor: '#F1618C'
|
|
53
|
-
}));
|
|
54
|
-
process.exit(1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let selectedTemplate = null;
|
|
58
|
-
|
|
59
|
-
if (choices.length === 1) {
|
|
60
|
-
[selectedTemplate] = choices;
|
|
61
|
-
} else {
|
|
62
|
-
logger.info(boxen(dedent`
|
|
63
|
-
🤗 Welcome to ${chalk.yellow('sb repro NEXT')}! 🤗
|
|
64
|
-
|
|
65
|
-
Create a ${chalk.green('new project')} to minimally reproduce Storybook issues.
|
|
66
|
-
|
|
67
|
-
1. select an environment that most closely matches your project setup.
|
|
68
|
-
2. select a location for the reproduction, outside of your project.
|
|
69
|
-
|
|
70
|
-
After the reproduction is ready, we'll guide you through the next steps.
|
|
71
|
-
`.trim(), {
|
|
72
|
-
borderStyle: 'round',
|
|
73
|
-
padding: 1,
|
|
74
|
-
borderColor: '#F1618C'
|
|
75
|
-
}));
|
|
76
|
-
selectedTemplate = await promptSelectedTemplate(choices);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const hasSelectedTemplate = !!(selectedTemplate ?? null);
|
|
80
|
-
|
|
81
|
-
if (!hasSelectedTemplate) {
|
|
82
|
-
logger.error('Somehow we got no templates. Please rerun this command!');
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const selectedConfig = TEMPLATES[selectedTemplate];
|
|
87
|
-
|
|
88
|
-
if (!selectedConfig) {
|
|
89
|
-
throw new Error('🚨 Repro: please specify a valid template type');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let selectedDirectory = outputDirectory;
|
|
93
|
-
const outputDirectoryName = outputDirectory || selectedTemplate;
|
|
94
|
-
|
|
95
|
-
if (selectedDirectory && existsSync(`${selectedDirectory}`)) {
|
|
96
|
-
logger.info(`⚠️ ${selectedDirectory} already exists! Overwriting...`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!selectedDirectory) {
|
|
100
|
-
const {
|
|
101
|
-
directory
|
|
102
|
-
} = await prompts({
|
|
103
|
-
type: 'text',
|
|
104
|
-
message: 'Enter the output directory',
|
|
105
|
-
name: 'directory',
|
|
106
|
-
initial: outputDirectoryName,
|
|
107
|
-
validate: async directoryName => existsSync(directoryName) ? `${directoryName} already exists. Please choose another name.` : true
|
|
108
|
-
});
|
|
109
|
-
selectedDirectory = directory;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const templateDestination = path.isAbsolute(selectedDirectory) ? selectedDirectory : path.join(process.cwd(), selectedDirectory);
|
|
114
|
-
logger.info(`🏃 Adding ${selectedConfig.name} into ${templateDestination}`);
|
|
115
|
-
logger.log('📦 Downloading repro template...');
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const templateType = init ? 'after-storybook' : 'before-storybook'; // Download the repro based on subfolder "after-storybook" and selected branch
|
|
119
|
-
|
|
120
|
-
await degit(`storybookjs/repro-templates-temp/${selectedTemplate}/${templateType}#${branch}`, {
|
|
121
|
-
force: true
|
|
122
|
-
}).clone(templateDestination);
|
|
123
|
-
} catch (err) {
|
|
124
|
-
logger.error(`🚨 Failed to download repro template: ${err.message}`);
|
|
125
|
-
throw err;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const initMessage = init ? chalk.yellow(`yarn storybook`) : `Recreate your setup, then ${chalk.yellow(`run npx storybook init`)}`;
|
|
129
|
-
logger.info(boxen(dedent`
|
|
130
|
-
🎉 Your Storybook reproduction project is ready to use! 🎉
|
|
131
|
-
|
|
132
|
-
${chalk.yellow(`cd ${selectedDirectory}`)}
|
|
133
|
-
${initMessage}
|
|
134
|
-
|
|
135
|
-
Once you've recreated the problem you're experiencing, please:
|
|
136
|
-
|
|
137
|
-
1. Document any additional steps in ${chalk.cyan('README.md')}
|
|
138
|
-
2. Publish the repository to github
|
|
139
|
-
3. Link to the repro repository in your issue
|
|
140
|
-
|
|
141
|
-
Having a clean repro helps us solve your issue faster! 🙏
|
|
142
|
-
`.trim(), {
|
|
143
|
-
borderStyle: 'round',
|
|
144
|
-
padding: 1,
|
|
145
|
-
borderColor: '#F1618C'
|
|
146
|
-
}));
|
|
147
|
-
} catch (error) {
|
|
148
|
-
logger.error('🚨 Failed to create repro');
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
async function promptSelectedTemplate(choices) {
|
|
154
|
-
const {
|
|
155
|
-
template
|
|
156
|
-
} = await prompts({
|
|
157
|
-
type: 'select',
|
|
158
|
-
message: '🌈 Select the template',
|
|
159
|
-
name: 'template',
|
|
160
|
-
choices: choices.map(toChoices)
|
|
161
|
-
});
|
|
162
|
-
return template || null;
|
|
163
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const craTemplates = {
|
|
2
|
-
'cra/default-js': {
|
|
3
|
-
name: 'Create React App (Javascript)',
|
|
4
|
-
script: 'npx create-react-app .',
|
|
5
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
6
|
-
expected: {
|
|
7
|
-
framework: '@storybook/cra',
|
|
8
|
-
renderer: '@storybook/react',
|
|
9
|
-
builder: '@storybook/builder-webpack5'
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
'cra/default-ts': {
|
|
13
|
-
name: 'Create React App (Typescript)',
|
|
14
|
-
script: 'npx create-react-app . --template typescript',
|
|
15
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
16
|
-
expected: {
|
|
17
|
-
framework: '@storybook/cra',
|
|
18
|
-
renderer: '@storybook/react',
|
|
19
|
-
builder: '@storybook/builder-webpack5'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const reactViteTemplates = {
|
|
24
|
-
'react-vite/default-js': {
|
|
25
|
-
name: 'React Vite (JS)',
|
|
26
|
-
script: 'yarn create vite . --template react',
|
|
27
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
28
|
-
expected: {
|
|
29
|
-
framework: '@storybook/react-vite',
|
|
30
|
-
renderer: '@storybook/react',
|
|
31
|
-
builder: '@storybook/builder-vite'
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
'react-vite/default-ts': {
|
|
35
|
-
name: 'React Vite (TS)',
|
|
36
|
-
script: 'yarn create vite . --template react-ts',
|
|
37
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
38
|
-
expected: {
|
|
39
|
-
framework: '@storybook/react-vite',
|
|
40
|
-
renderer: '@storybook/react',
|
|
41
|
-
builder: '@storybook/builder-vite'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const vue3ViteTemplates = {
|
|
46
|
-
'vue3-vite/default-js': {
|
|
47
|
-
name: 'Vue3 Vite (JS)',
|
|
48
|
-
script: 'yarn create vite . --template vue',
|
|
49
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
50
|
-
expected: {
|
|
51
|
-
framework: '@storybook/vue3-vite',
|
|
52
|
-
renderer: '@storybook/vue3',
|
|
53
|
-
builder: '@storybook/builder-vite'
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
'vue3-vite/default-ts': {
|
|
57
|
-
name: 'Vue3 Vite (TS)',
|
|
58
|
-
script: 'yarn create vite . --template vue-ts',
|
|
59
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
60
|
-
expected: {
|
|
61
|
-
framework: '@storybook/vue3-vite',
|
|
62
|
-
renderer: '@storybook/vue3',
|
|
63
|
-
builder: '@storybook/builder-vite'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const svelteViteTemplates = {
|
|
68
|
-
'svelte-vite/default-js': {
|
|
69
|
-
name: 'Svelte Vite (JS)',
|
|
70
|
-
script: 'yarn create vite . --template svelte',
|
|
71
|
-
cadence: ['ci', 'daily', 'weekly'],
|
|
72
|
-
expected: {
|
|
73
|
-
framework: '@storybook/svelte-vite',
|
|
74
|
-
renderer: '@storybook/svelte',
|
|
75
|
-
builder: '@storybook/builder-vite'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/*
|
|
79
|
-
* I disabled this, because it was flaky
|
|
80
|
-
* TODO: we should fixd the instability and re-enable it
|
|
81
|
-
*/
|
|
82
|
-
// 'svelte-vite/default-ts': {
|
|
83
|
-
// name: 'Svelte Vite (TS)',
|
|
84
|
-
// script: 'yarn create vite . --template svelte-ts',
|
|
85
|
-
// cadence: ['ci', 'daily', 'weekly'],
|
|
86
|
-
// expected: {
|
|
87
|
-
// framework: '@storybook/svelte-vite',
|
|
88
|
-
// renderer: '@storybook/svelte',
|
|
89
|
-
// builder: '@storybook/builder-vite'
|
|
90
|
-
// }
|
|
91
|
-
// }
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
export default Object.assign({}, craTemplates, reactViteTemplates, vue3ViteTemplates, svelteViteTemplates);
|