@storybook/cli 7.0.0-alpha.18 → 7.0.0-alpha.19

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.
@@ -24,6 +24,8 @@ var _builderVite = require("./builder-vite");
24
24
 
25
25
  var _npm = require("./npm7");
26
26
 
27
+ var _sbScripts = require("./sb-scripts");
28
+
27
29
  var _types = require("../types");
28
30
 
29
31
  Object.keys(_types).forEach(function (key) {
@@ -37,5 +39,5 @@ Object.keys(_types).forEach(function (key) {
37
39
  }
38
40
  });
39
41
  });
40
- const fixes = [_cra.cra5, _webpack.webpack5, _angular.angular12, _vue.vue3, _mainjsFramework.mainjsFramework, _eslintPlugin.eslintPlugin, _builderVite.builderVite, _npm.npm7];
42
+ const fixes = [_cra.cra5, _webpack.webpack5, _angular.angular12, _vue.vue3, _mainjsFramework.mainjsFramework, _eslintPlugin.eslintPlugin, _builderVite.builderVite, _npm.npm7, _sbScripts.sbScripts];
41
43
  exports.fixes = fixes;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sbScripts = exports.getStorybookScripts = void 0;
7
+
8
+ var _chalk = _interopRequireDefault(require("chalk"));
9
+
10
+ var _tsDedent = require("ts-dedent");
11
+
12
+ var _semver = _interopRequireDefault(require("@storybook/semver"));
13
+
14
+ var _coreCommon = require("@storybook/core-common");
15
+
16
+ var _helpers = require("../../helpers");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const logger = console;
21
+
22
+ const getStorybookScripts = scripts => {
23
+ const storybookScripts = {
24
+ custom: {},
25
+ official: {}
26
+ };
27
+ Object.keys(scripts).forEach(key => {
28
+ if (key === 'storybook' || key === 'build-storybook') {
29
+ storybookScripts.official[key] = scripts[key];
30
+ } else if (scripts[key].match(/start-storybook/) || scripts[key].match(/build-storybook/)) {
31
+ storybookScripts.custom[key] = scripts[key];
32
+ }
33
+ });
34
+ return storybookScripts;
35
+ };
36
+ /**
37
+ * Is the user using start-storybook
38
+ *
39
+ * If so:
40
+ * - Add storybook dependency
41
+ * - Change start-storybook and build-storybook scripts
42
+ */
43
+
44
+
45
+ exports.getStorybookScripts = getStorybookScripts;
46
+ const sbScripts = {
47
+ id: 'sb-scripts',
48
+
49
+ async check({
50
+ packageManager
51
+ }) {
52
+ var _semver$coerce;
53
+
54
+ const packageJson = packageManager.retrievePackageJson();
55
+ const {
56
+ scripts = {},
57
+ devDependencies,
58
+ dependencies
59
+ } = packageJson;
60
+ const {
61
+ version: storybookVersion
62
+ } = (0, _coreCommon.getStorybookInfo)(packageJson);
63
+ const allDeps = Object.assign({}, dependencies, devDependencies);
64
+ const storybookCoerced = storybookVersion && ((_semver$coerce = _semver.default.coerce(storybookVersion)) === null || _semver$coerce === void 0 ? void 0 : _semver$coerce.version);
65
+
66
+ if (!storybookCoerced) {
67
+ logger.warn((0, _tsDedent.dedent)`
68
+ ❌ Unable to determine storybook version, skipping ${_chalk.default.cyan('sb-scripts')} fix.
69
+ 🤔 Are you running automigrate from your project directory?
70
+ `);
71
+ return null;
72
+ }
73
+
74
+ if (allDeps.sb || allDeps.storybook) {
75
+ return null;
76
+ }
77
+
78
+ const storybookScripts = getStorybookScripts(scripts);
79
+
80
+ if (Object.keys(storybookScripts.official).length === 0 && Object.keys(storybookScripts.custom).length === 0) {
81
+ return null;
82
+ }
83
+
84
+ Object.keys(storybookScripts.official).forEach(key => {
85
+ storybookScripts.official[key] = storybookScripts.official[key].replace('start-storybook', 'storybook dev').replace('build-storybook', 'storybook build');
86
+ });
87
+ return _semver.default.gte(storybookCoerced, '7.0.0') ? {
88
+ packageJson,
89
+ storybookScripts,
90
+ storybookVersion
91
+ } : null;
92
+ },
93
+
94
+ prompt({
95
+ storybookVersion
96
+ }) {
97
+ const sbFormatted = _chalk.default.cyan(`Storybook ${storybookVersion}`);
98
+
99
+ const explanationMessage = [`Starting in Storybook 7, the ${_chalk.default.yellow('start-storybook')} and ${_chalk.default.yellow('build-storybook')} binaries have changed to ${_chalk.default.magenta('storybook dev')} and ${_chalk.default.magenta('storybook build')} respectively.`, `In order to work with ${sbFormatted}, Storybook's ${_chalk.default.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');
100
+ return [`We've detected you are using ${sbFormatted} with scripts from previous versions of Storybook.`, explanationMessage, `More info: ${_chalk.default.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#start-storybook--build-storybook-binaries-removed')}`].filter(Boolean).join('\n\n');
101
+ },
102
+
103
+ async run({
104
+ result: {
105
+ storybookScripts,
106
+ packageJson
107
+ },
108
+ packageManager,
109
+ dryRun
110
+ }) {
111
+ logger.log();
112
+ logger.info(`Adding 'storybook' as dev dependency`);
113
+ logger.log();
114
+
115
+ if (!dryRun) {
116
+ const versionToInstall = (0, _helpers.getStorybookVersionSpecifier)(packageJson);
117
+ packageManager.addDependencies({
118
+ installAsDevDependencies: true
119
+ }, [`storybook@${versionToInstall}`]);
120
+ }
121
+
122
+ logger.info(`Updating scripts in package.json`);
123
+ logger.log();
124
+
125
+ if (!dryRun && Object.keys(storybookScripts.official).length > 0) {
126
+ const message = [`Migrating your scripts to:`, _chalk.default.yellow(JSON.stringify(storybookScripts.official, null, 2))].join('\n');
127
+ logger.log(message);
128
+ logger.log();
129
+ packageManager.addScripts(storybookScripts.official);
130
+ }
131
+
132
+ if (!dryRun && Object.keys(storybookScripts.custom).length > 0) {
133
+ const message = [`We detected custom scripts that we can't automigrate:`, _chalk.default.yellow(JSON.stringify(storybookScripts.custom, null, 2)), '\n', `Please manually migrate the ones applicable and use the documentation below for reference: ${_chalk.default.yellow('https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#start-storybook--build-storybook-binaries-removed')}`].join('\n');
134
+ logger.log(message);
135
+ logger.log();
136
+ }
137
+ }
138
+
139
+ };
140
+ exports.sbScripts = sbScripts;
@@ -128,7 +128,7 @@ _commander.default.command('repro [outputDirectory]').description('Create a repr
128
128
  process.exit(1);
129
129
  }));
130
130
 
131
- _commander.default.command('repro-next [filterValue]').description('Create a reproduction from a set of possible templates').option('-o --output <outDir>', 'Define an output directory').option('-b --branch <branch>', 'Define the branch to degit from', 'next').action((filterValue, options) => (0, _reproNext.reproNext)(Object.assign({
131
+ _commander.default.command('repro-next [filterValue]').description('Create a reproduction from a set of possible templates').option('-o --output <outDir>', 'Define an output directory').option('-b --branch <branch>', 'Define the branch to degit from', 'next').option('--no-init', 'Whether to download a template without an initialized Storybook', false).action((filterValue, options) => (0, _reproNext.reproNext)(Object.assign({
132
132
  filterValue
133
133
  }, options)).catch(e => {
134
134
  _nodeLogger.logger.error(e);
@@ -11,6 +11,7 @@ exports.copyTemplate = copyTemplate;
11
11
  exports.getBabelDependencies = getBabelDependencies;
12
12
  exports.getBowerJson = getBowerJson;
13
13
  exports.getChars = getChars;
14
+ exports.getStorybookVersionSpecifier = getStorybookVersionSpecifier;
14
15
  exports.paddedLog = paddedLog;
15
16
  exports.readFileAsJson = readFileAsJson;
16
17
  exports.writeFileAsJson = void 0;
@@ -29,6 +30,8 @@ var _stripJsonComments = _interopRequireDefault(require("strip-json-comments"));
29
30
 
30
31
  var _dirs = require("./dirs");
31
32
 
33
+ var _versions = _interopRequireDefault(require("./versions"));
34
+
32
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
36
 
34
37
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -239,4 +242,19 @@ async function copyComponents(framework, language) {
239
242
  await _fsExtra.default.copy((0, _path.join)((0, _dirs.getBaseDir)(), 'frameworks/common'), destinationPath, {
240
243
  overwrite: true
241
244
  });
245
+ } // Given a package.json, finds any official storybook package within it
246
+ // and if it exists, returns the version of that package from the specified package.json
247
+
248
+
249
+ function getStorybookVersionSpecifier(packageJson) {
250
+ const allDeps = Object.assign({}, packageJson.dependencies, packageJson.devDependencies);
251
+ const storybookPackage = Object.keys(allDeps).find(name => {
252
+ return _versions.default[name];
253
+ });
254
+
255
+ if (!storybookPackage) {
256
+ throw new Error(`Couldn't find any official storybook packages in package.json`);
257
+ }
258
+
259
+ return allDeps[storybookPackage];
242
260
  }
@@ -134,6 +134,48 @@ class JsPackageManager {
134
134
  }
135
135
  }
136
136
  }
137
+ /**
138
+ * Remove dependencies from a project using `yarn remove` or `npm uninstall`.
139
+ *
140
+ * @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages.
141
+ * @param {Array} dependencies contains a list of packages to remove.
142
+ * @example
143
+ * removeDependencies(options, [
144
+ * `@storybook/react`,
145
+ * `@storybook/addon-actions`,
146
+ * ]);
147
+ */
148
+
149
+
150
+ removeDependencies(options, dependencies) {
151
+ const {
152
+ skipInstall
153
+ } = options;
154
+
155
+ if (skipInstall) {
156
+ const {
157
+ packageJson
158
+ } = options;
159
+ dependencies.forEach(dep => {
160
+ if (packageJson.devDependencies) {
161
+ delete packageJson.devDependencies[dep];
162
+ }
163
+
164
+ if (packageJson.dependencies) {
165
+ delete packageJson.dependencies[dep];
166
+ }
167
+ });
168
+ (0, _PackageJsonHelper.writePackageJson)(packageJson);
169
+ } else {
170
+ try {
171
+ this.runRemoveDeps(dependencies);
172
+ } catch (e) {
173
+ logger.error('An error occurred while removing dependencies.');
174
+ logger.log(e.message);
175
+ process.exit(1);
176
+ }
177
+ }
178
+ }
137
179
  /**
138
180
  * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
139
181
  *
@@ -16,6 +16,7 @@ class NPMProxy extends _JsPackageManager.JsPackageManager {
16
16
  super(...args);
17
17
  this.type = 'npm';
18
18
  this.installArgs = void 0;
19
+ this.uninstallArgs = void 0;
19
20
  }
20
21
 
21
22
  initPackageJson() {
@@ -55,6 +56,14 @@ class NPMProxy extends _JsPackageManager.JsPackageManager {
55
56
  return this.installArgs;
56
57
  }
57
58
 
59
+ getUninstallArgs() {
60
+ if (!this.uninstallArgs) {
61
+ this.uninstallArgs = this.needsLegacyPeerDeps(this.getNpmVersion()) ? ['uninstall', '--legacy-peer-deps'] : ['uninstall'];
62
+ }
63
+
64
+ return this.uninstallArgs;
65
+ }
66
+
58
67
  runInstall() {
59
68
  this.executeCommand('npm', this.getInstallArgs(), 'inherit');
60
69
  }
@@ -69,6 +78,11 @@ class NPMProxy extends _JsPackageManager.JsPackageManager {
69
78
  this.executeCommand('npm', [...this.getInstallArgs(), ...args], 'inherit');
70
79
  }
71
80
 
81
+ runRemoveDeps(dependencies) {
82
+ const args = [...dependencies];
83
+ this.executeCommand('npm', [...this.getUninstallArgs(), ...args], 'inherit');
84
+ }
85
+
72
86
  runGetVersions(packageName, fetchAllVersions) {
73
87
  const args = [fetchAllVersions ? 'versions' : 'version', '--json'];
74
88
  const commandResult = this.executeCommand('npm', ['info', packageName, ...args]);
@@ -39,6 +39,11 @@ class Yarn1Proxy extends _JsPackageManager.JsPackageManager {
39
39
  this.executeCommand('yarn', ['add', ...args], 'inherit');
40
40
  }
41
41
 
42
+ runRemoveDeps(dependencies) {
43
+ const args = ['--ignore-workspace-root-check', ...dependencies];
44
+ this.executeCommand('yarn', ['remove', ...args], 'inherit');
45
+ }
46
+
42
47
  runGetVersions(packageName, fetchAllVersions) {
43
48
  const args = [fetchAllVersions ? 'versions' : 'version', '--json'];
44
49
  const commandResult = this.executeCommand('yarn', ['info', packageName, ...args]);
@@ -39,6 +39,11 @@ class Yarn2Proxy extends _JsPackageManager.JsPackageManager {
39
39
  this.executeCommand('yarn', ['add', ...args], 'inherit');
40
40
  }
41
41
 
42
+ runRemoveDeps(dependencies) {
43
+ const args = [...dependencies];
44
+ this.executeCommand('yarn', ['remove', ...args], 'inherit');
45
+ }
46
+
42
47
  runGetVersions(packageName, fetchAllVersions) {
43
48
  const field = fetchAllVersions ? 'versions' : 'version';
44
49
  const args = ['--fields', field, '--json'];
@@ -7,8 +7,6 @@ exports.reproNext = void 0;
7
7
 
8
8
  var _prompts = _interopRequireDefault(require("prompts"));
9
9
 
10
- var _fs = _interopRequireDefault(require("fs"));
11
-
12
10
  var _path = _interopRequireDefault(require("path"));
13
11
 
14
12
  var _chalk = _interopRequireDefault(require("chalk"));
@@ -19,6 +17,8 @@ var _tsDedent = require("ts-dedent");
19
17
 
20
18
  var _degit = _interopRequireDefault(require("degit"));
21
19
 
20
+ var _fsExtra = require("fs-extra");
21
+
22
22
  var _reproTemplates = _interopRequireDefault(require("./repro-templates"));
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -33,7 +33,8 @@ const toChoices = c => ({
33
33
  const reproNext = async ({
34
34
  output: outputDirectory,
35
35
  filterValue,
36
- branch
36
+ branch,
37
+ init
37
38
  }) => {
38
39
  const keys = Object.keys(_reproTemplates.default); // get value from template and reduce through TEMPLATES to filter out the correct template
39
40
 
@@ -57,7 +58,8 @@ const reproNext = async ({
57
58
  if (choices.length === 0) {
58
59
  logger.info((0, _boxen.default)((0, _tsDedent.dedent)`
59
60
  🔎 You filtered out all templates. 🔍
60
- After filtering all the templates with "${_chalk.default.yellow(filterValue)}", we found no templates.
61
+
62
+ After filtering all the templates with "${_chalk.default.yellow(filterValue)}", we found no results. Please try again with a different filter.
61
63
 
62
64
  Available templates:
63
65
  ${keys.map(key => _chalk.default.blue`- ${key}`).join('\n')}
@@ -66,7 +68,7 @@ const reproNext = async ({
66
68
  padding: 1,
67
69
  borderColor: '#F1618C'
68
70
  }));
69
- return;
71
+ process.exit(1);
70
72
  }
71
73
 
72
74
  let selectedTemplate = null;
@@ -105,6 +107,11 @@ const reproNext = async ({
105
107
  }
106
108
 
107
109
  let selectedDirectory = outputDirectory;
110
+ const outputDirectoryName = outputDirectory || selectedTemplate;
111
+
112
+ if (selectedDirectory && (0, _fsExtra.existsSync)(`${selectedDirectory}`)) {
113
+ logger.info(`⚠️ ${selectedDirectory} already exists! Overwriting...`);
114
+ }
108
115
 
109
116
  if (!selectedDirectory) {
110
117
  const {
@@ -113,32 +120,34 @@ const reproNext = async ({
113
120
  type: 'text',
114
121
  message: 'Enter the output directory',
115
122
  name: 'directory',
116
- initial: selectedTemplate,
117
- validate: directoryName => _fs.default.existsSync(directoryName) ? `${directoryName} already exists. Please choose another name.` : true
123
+ initial: outputDirectoryName,
124
+ validate: async directoryName => (0, _fsExtra.existsSync)(directoryName) ? `${directoryName} already exists. Please choose another name.` : true
118
125
  });
119
126
  selectedDirectory = directory;
120
127
  }
121
128
 
122
129
  try {
123
- const cwd = _path.default.isAbsolute(selectedDirectory) ? selectedDirectory : _path.default.join(process.cwd(), selectedDirectory);
124
- logger.info(`🏃 Adding ${selectedConfig.name} into ${cwd}`);
130
+ const templateDestination = _path.default.isAbsolute(selectedDirectory) ? selectedDirectory : _path.default.join(process.cwd(), selectedDirectory);
131
+ logger.info(`🏃 Adding ${selectedConfig.name} into ${templateDestination}`);
125
132
  logger.log('📦 Downloading repro template...');
126
133
 
127
134
  try {
128
- // Download the repro based on subfolder "after-storybook" and selected branch
129
- await (0, _degit.default)(`storybookjs/repro-templates-temp/${selectedTemplate}/after-storybook#${branch}`, {
135
+ const templateType = init ? 'after-storybook' : 'before-storybook'; // Download the repro based on subfolder "after-storybook" and selected branch
136
+
137
+ await (0, _degit.default)(`storybookjs/repro-templates-temp/${selectedTemplate}/${templateType}#${branch}`, {
130
138
  force: true
131
- }).clone(selectedTemplate.replace('/', '-'));
139
+ }).clone(templateDestination);
132
140
  } catch (err) {
133
141
  logger.error(`🚨 Failed to download repro template: ${err.message}`);
134
- return;
142
+ throw err;
135
143
  }
136
144
 
145
+ const initMessage = init ? _chalk.default.yellow(`yarn storybook`) : `Recreate your setup, then ${_chalk.default.yellow(`run npx storybook init`)}`;
137
146
  logger.info((0, _boxen.default)((0, _tsDedent.dedent)`
138
147
  🎉 Your Storybook reproduction project is ready to use! 🎉
139
148
 
140
149
  ${_chalk.default.yellow(`cd ${selectedDirectory}`)}
141
- ${_chalk.default.yellow(`yarn storybook`)}
150
+ ${initMessage}
142
151
 
143
152
  Once you've recreated the problem you're experiencing, please:
144
153
 
@@ -6,80 +6,80 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  // auto generated file, do not edit
8
8
  var _default = {
9
- '@storybook/addon-a11y': '7.0.0-alpha.18',
10
- '@storybook/addon-actions': '7.0.0-alpha.18',
11
- '@storybook/addon-backgrounds': '7.0.0-alpha.18',
12
- '@storybook/addon-controls': '7.0.0-alpha.18',
13
- '@storybook/addon-docs': '7.0.0-alpha.18',
14
- '@storybook/addon-essentials': '7.0.0-alpha.18',
15
- '@storybook/addon-highlight': '7.0.0-alpha.18',
16
- '@storybook/addon-interactions': '7.0.0-alpha.18',
17
- '@storybook/addon-jest': '7.0.0-alpha.18',
18
- '@storybook/addon-links': '7.0.0-alpha.18',
19
- '@storybook/addon-measure': '7.0.0-alpha.18',
20
- '@storybook/addon-outline': '7.0.0-alpha.18',
21
- '@storybook/addon-storyshots': '7.0.0-alpha.18',
22
- '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.18',
23
- '@storybook/addon-storysource': '7.0.0-alpha.18',
24
- '@storybook/addon-toolbars': '7.0.0-alpha.18',
25
- '@storybook/addon-viewport': '7.0.0-alpha.18',
26
- '@storybook/addons': '7.0.0-alpha.18',
27
- '@storybook/angular': '7.0.0-alpha.18',
28
- '@storybook/api': '7.0.0-alpha.18',
29
- '@storybook/blocks': '7.0.0-alpha.18',
30
- '@storybook/builder-manager': '7.0.0-alpha.18',
31
- '@storybook/builder-webpack5': '7.0.0-alpha.18',
32
- '@storybook/channel-postmessage': '7.0.0-alpha.18',
33
- '@storybook/channel-websocket': '7.0.0-alpha.18',
34
- '@storybook/channels': '7.0.0-alpha.18',
35
- '@storybook/cli': '7.0.0-alpha.18',
36
- '@storybook/client-api': '7.0.0-alpha.18',
37
- '@storybook/client-logger': '7.0.0-alpha.18',
38
- '@storybook/codemod': '7.0.0-alpha.18',
39
- '@storybook/components': '7.0.0-alpha.18',
40
- '@storybook/core-client': '7.0.0-alpha.18',
41
- '@storybook/core-common': '7.0.0-alpha.18',
42
- '@storybook/core-events': '7.0.0-alpha.18',
43
- '@storybook/core-server': '7.0.0-alpha.18',
44
- '@storybook/core-webpack': '7.0.0-alpha.18',
45
- '@storybook/csf-tools': '7.0.0-alpha.18',
46
- '@storybook/docs-tools': '7.0.0-alpha.18',
47
- '@storybook/ember': '7.0.0-alpha.18',
48
- '@storybook/html': '7.0.0-alpha.18',
49
- '@storybook/html-webpack5': '7.0.0-alpha.18',
50
- '@storybook/instrumenter': '7.0.0-alpha.18',
51
- '@storybook/node-logger': '7.0.0-alpha.18',
52
- '@storybook/postinstall': '7.0.0-alpha.18',
53
- '@storybook/preact': '7.0.0-alpha.18',
54
- '@storybook/preact-webpack5': '7.0.0-alpha.18',
55
- '@storybook/preset-html-webpack': '7.0.0-alpha.18',
56
- '@storybook/preset-preact-webpack': '7.0.0-alpha.18',
57
- '@storybook/preset-react-webpack': '7.0.0-alpha.18',
58
- '@storybook/preset-server-webpack': '7.0.0-alpha.18',
59
- '@storybook/preset-svelte-webpack': '7.0.0-alpha.18',
60
- '@storybook/preset-vue-webpack': '7.0.0-alpha.18',
61
- '@storybook/preset-vue3-webpack': '7.0.0-alpha.18',
62
- '@storybook/preset-web-components-webpack': '7.0.0-alpha.18',
63
- '@storybook/preview-web': '7.0.0-alpha.18',
64
- '@storybook/react': '7.0.0-alpha.18',
65
- '@storybook/react-webpack5': '7.0.0-alpha.18',
66
- '@storybook/router': '7.0.0-alpha.18',
67
- '@storybook/server': '7.0.0-alpha.18',
68
- '@storybook/server-webpack5': '7.0.0-alpha.18',
69
- '@storybook/source-loader': '7.0.0-alpha.18',
70
- '@storybook/store': '7.0.0-alpha.18',
71
- '@storybook/svelte': '7.0.0-alpha.18',
72
- '@storybook/svelte-webpack5': '7.0.0-alpha.18',
73
- '@storybook/telemetry': '7.0.0-alpha.18',
74
- '@storybook/theming': '7.0.0-alpha.18',
75
- '@storybook/ui': '7.0.0-alpha.18',
76
- '@storybook/vue': '7.0.0-alpha.18',
77
- '@storybook/vue-webpack5': '7.0.0-alpha.18',
78
- '@storybook/vue3': '7.0.0-alpha.18',
79
- '@storybook/vue3-webpack5': '7.0.0-alpha.18',
80
- '@storybook/web-components': '7.0.0-alpha.18',
81
- '@storybook/web-components-webpack5': '7.0.0-alpha.18',
82
- sb: '7.0.0-alpha.18',
83
- storybook: '7.0.0-alpha.18'
9
+ '@storybook/addon-a11y': '7.0.0-alpha.19',
10
+ '@storybook/addon-actions': '7.0.0-alpha.19',
11
+ '@storybook/addon-backgrounds': '7.0.0-alpha.19',
12
+ '@storybook/addon-controls': '7.0.0-alpha.19',
13
+ '@storybook/addon-docs': '7.0.0-alpha.19',
14
+ '@storybook/addon-essentials': '7.0.0-alpha.19',
15
+ '@storybook/addon-highlight': '7.0.0-alpha.19',
16
+ '@storybook/addon-interactions': '7.0.0-alpha.19',
17
+ '@storybook/addon-jest': '7.0.0-alpha.19',
18
+ '@storybook/addon-links': '7.0.0-alpha.19',
19
+ '@storybook/addon-measure': '7.0.0-alpha.19',
20
+ '@storybook/addon-outline': '7.0.0-alpha.19',
21
+ '@storybook/addon-storyshots': '7.0.0-alpha.19',
22
+ '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.19',
23
+ '@storybook/addon-storysource': '7.0.0-alpha.19',
24
+ '@storybook/addon-toolbars': '7.0.0-alpha.19',
25
+ '@storybook/addon-viewport': '7.0.0-alpha.19',
26
+ '@storybook/addons': '7.0.0-alpha.19',
27
+ '@storybook/angular': '7.0.0-alpha.19',
28
+ '@storybook/api': '7.0.0-alpha.19',
29
+ '@storybook/blocks': '7.0.0-alpha.19',
30
+ '@storybook/builder-manager': '7.0.0-alpha.19',
31
+ '@storybook/builder-webpack5': '7.0.0-alpha.19',
32
+ '@storybook/channel-postmessage': '7.0.0-alpha.19',
33
+ '@storybook/channel-websocket': '7.0.0-alpha.19',
34
+ '@storybook/channels': '7.0.0-alpha.19',
35
+ '@storybook/cli': '7.0.0-alpha.19',
36
+ '@storybook/client-api': '7.0.0-alpha.19',
37
+ '@storybook/client-logger': '7.0.0-alpha.19',
38
+ '@storybook/codemod': '7.0.0-alpha.19',
39
+ '@storybook/components': '7.0.0-alpha.19',
40
+ '@storybook/core-client': '7.0.0-alpha.19',
41
+ '@storybook/core-common': '7.0.0-alpha.19',
42
+ '@storybook/core-events': '7.0.0-alpha.19',
43
+ '@storybook/core-server': '7.0.0-alpha.19',
44
+ '@storybook/core-webpack': '7.0.0-alpha.19',
45
+ '@storybook/csf-tools': '7.0.0-alpha.19',
46
+ '@storybook/docs-tools': '7.0.0-alpha.19',
47
+ '@storybook/ember': '7.0.0-alpha.19',
48
+ '@storybook/html': '7.0.0-alpha.19',
49
+ '@storybook/html-webpack5': '7.0.0-alpha.19',
50
+ '@storybook/instrumenter': '7.0.0-alpha.19',
51
+ '@storybook/node-logger': '7.0.0-alpha.19',
52
+ '@storybook/postinstall': '7.0.0-alpha.19',
53
+ '@storybook/preact': '7.0.0-alpha.19',
54
+ '@storybook/preact-webpack5': '7.0.0-alpha.19',
55
+ '@storybook/preset-html-webpack': '7.0.0-alpha.19',
56
+ '@storybook/preset-preact-webpack': '7.0.0-alpha.19',
57
+ '@storybook/preset-react-webpack': '7.0.0-alpha.19',
58
+ '@storybook/preset-server-webpack': '7.0.0-alpha.19',
59
+ '@storybook/preset-svelte-webpack': '7.0.0-alpha.19',
60
+ '@storybook/preset-vue-webpack': '7.0.0-alpha.19',
61
+ '@storybook/preset-vue3-webpack': '7.0.0-alpha.19',
62
+ '@storybook/preset-web-components-webpack': '7.0.0-alpha.19',
63
+ '@storybook/preview-web': '7.0.0-alpha.19',
64
+ '@storybook/react': '7.0.0-alpha.19',
65
+ '@storybook/react-webpack5': '7.0.0-alpha.19',
66
+ '@storybook/router': '7.0.0-alpha.19',
67
+ '@storybook/server': '7.0.0-alpha.19',
68
+ '@storybook/server-webpack5': '7.0.0-alpha.19',
69
+ '@storybook/source-loader': '7.0.0-alpha.19',
70
+ '@storybook/store': '7.0.0-alpha.19',
71
+ '@storybook/svelte': '7.0.0-alpha.19',
72
+ '@storybook/svelte-webpack5': '7.0.0-alpha.19',
73
+ '@storybook/telemetry': '7.0.0-alpha.19',
74
+ '@storybook/theming': '7.0.0-alpha.19',
75
+ '@storybook/ui': '7.0.0-alpha.19',
76
+ '@storybook/vue': '7.0.0-alpha.19',
77
+ '@storybook/vue-webpack5': '7.0.0-alpha.19',
78
+ '@storybook/vue3': '7.0.0-alpha.19',
79
+ '@storybook/vue3-webpack5': '7.0.0-alpha.19',
80
+ '@storybook/web-components': '7.0.0-alpha.19',
81
+ '@storybook/web-components-webpack5': '7.0.0-alpha.19',
82
+ sb: '7.0.0-alpha.19',
83
+ storybook: '7.0.0-alpha.19'
84
84
  };
85
85
  exports.default = _default;
@@ -6,5 +6,6 @@ import { mainjsFramework } from './mainjsFramework';
6
6
  import { eslintPlugin } from './eslint-plugin';
7
7
  import { builderVite } from './builder-vite';
8
8
  import { npm7 } from './npm7';
9
+ import { sbScripts } from './sb-scripts';
9
10
  export * from '../types';
10
- export const fixes = [cra5, webpack5, angular12, vue3, mainjsFramework, eslintPlugin, builderVite, npm7];
11
+ export const fixes = [cra5, webpack5, angular12, vue3, mainjsFramework, eslintPlugin, builderVite, npm7, sbScripts];
@@ -0,0 +1,119 @@
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
+ };
@@ -88,7 +88,7 @@ program.command('repro [outputDirectory]').description('Create a reproduction fr
88
88
  logger.error(e);
89
89
  process.exit(1);
90
90
  }));
91
- program.command('repro-next [filterValue]').description('Create a reproduction from a set of possible templates').option('-o --output <outDir>', 'Define an output directory').option('-b --branch <branch>', 'Define the branch to degit from', 'next').action((filterValue, options) => reproNext(Object.assign({
91
+ program.command('repro-next [filterValue]').description('Create a reproduction from a set of possible templates').option('-o --output <outDir>', 'Define an output directory').option('-b --branch <branch>', 'Define the branch to degit from', 'next').option('--no-init', 'Whether to download a template without an initialized Storybook', false).action((filterValue, options) => reproNext(Object.assign({
92
92
  filterValue
93
93
  }, options)).catch(e => {
94
94
  logger.error(e);
@@ -6,6 +6,7 @@ import chalk from 'chalk';
6
6
  import { satisfies } from '@storybook/semver';
7
7
  import stripJsonComments from 'strip-json-comments';
8
8
  import { getBaseDir } from './dirs';
9
+ import storybookMonorepoPackages from './versions';
9
10
  const logger = console;
10
11
  export function getBowerJson() {
11
12
  const bowerJsonPath = path.resolve('bower.json');
@@ -190,4 +191,18 @@ export async function copyComponents(framework, language) {
190
191
  await fse.copy(join(getBaseDir(), 'frameworks/common'), destinationPath, {
191
192
  overwrite: true
192
193
  });
194
+ } // Given a package.json, finds any official storybook package within it
195
+ // and if it exists, returns the version of that package from the specified package.json
196
+
197
+ export function getStorybookVersionSpecifier(packageJson) {
198
+ const allDeps = Object.assign({}, packageJson.dependencies, packageJson.devDependencies);
199
+ const storybookPackage = Object.keys(allDeps).find(name => {
200
+ return storybookMonorepoPackages[name];
201
+ });
202
+
203
+ if (!storybookPackage) {
204
+ throw new Error(`Couldn't find any official storybook packages in package.json`);
205
+ }
206
+
207
+ return allDeps[storybookPackage];
193
208
  }
@@ -117,6 +117,48 @@ export class JsPackageManager {
117
117
  }
118
118
  }
119
119
  }
120
+ /**
121
+ * Remove dependencies from a project using `yarn remove` or `npm uninstall`.
122
+ *
123
+ * @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages.
124
+ * @param {Array} dependencies contains a list of packages to remove.
125
+ * @example
126
+ * removeDependencies(options, [
127
+ * `@storybook/react`,
128
+ * `@storybook/addon-actions`,
129
+ * ]);
130
+ */
131
+
132
+
133
+ removeDependencies(options, dependencies) {
134
+ const {
135
+ skipInstall
136
+ } = options;
137
+
138
+ if (skipInstall) {
139
+ const {
140
+ packageJson
141
+ } = options;
142
+ dependencies.forEach(dep => {
143
+ if (packageJson.devDependencies) {
144
+ delete packageJson.devDependencies[dep];
145
+ }
146
+
147
+ if (packageJson.dependencies) {
148
+ delete packageJson.dependencies[dep];
149
+ }
150
+ });
151
+ writePackageJson(packageJson);
152
+ } else {
153
+ try {
154
+ this.runRemoveDeps(dependencies);
155
+ } catch (e) {
156
+ logger.error('An error occurred while removing dependencies.');
157
+ logger.log(e.message);
158
+ process.exit(1);
159
+ }
160
+ }
161
+ }
120
162
  /**
121
163
  * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
122
164
  *
@@ -5,6 +5,7 @@ export class NPMProxy extends JsPackageManager {
5
5
  super(...args);
6
6
  this.type = 'npm';
7
7
  this.installArgs = void 0;
8
+ this.uninstallArgs = void 0;
8
9
  }
9
10
 
10
11
  initPackageJson() {
@@ -44,6 +45,14 @@ export class NPMProxy extends JsPackageManager {
44
45
  return this.installArgs;
45
46
  }
46
47
 
48
+ getUninstallArgs() {
49
+ if (!this.uninstallArgs) {
50
+ this.uninstallArgs = this.needsLegacyPeerDeps(this.getNpmVersion()) ? ['uninstall', '--legacy-peer-deps'] : ['uninstall'];
51
+ }
52
+
53
+ return this.uninstallArgs;
54
+ }
55
+
47
56
  runInstall() {
48
57
  this.executeCommand('npm', this.getInstallArgs(), 'inherit');
49
58
  }
@@ -58,6 +67,11 @@ export class NPMProxy extends JsPackageManager {
58
67
  this.executeCommand('npm', [...this.getInstallArgs(), ...args], 'inherit');
59
68
  }
60
69
 
70
+ runRemoveDeps(dependencies) {
71
+ const args = [...dependencies];
72
+ this.executeCommand('npm', [...this.getUninstallArgs(), ...args], 'inherit');
73
+ }
74
+
61
75
  runGetVersions(packageName, fetchAllVersions) {
62
76
  const args = [fetchAllVersions ? 'versions' : 'version', '--json'];
63
77
  const commandResult = this.executeCommand('npm', ['info', packageName, ...args]);
@@ -31,6 +31,11 @@ export class Yarn1Proxy extends JsPackageManager {
31
31
  this.executeCommand('yarn', ['add', ...args], 'inherit');
32
32
  }
33
33
 
34
+ runRemoveDeps(dependencies) {
35
+ const args = ['--ignore-workspace-root-check', ...dependencies];
36
+ this.executeCommand('yarn', ['remove', ...args], 'inherit');
37
+ }
38
+
34
39
  runGetVersions(packageName, fetchAllVersions) {
35
40
  const args = [fetchAllVersions ? 'versions' : 'version', '--json'];
36
41
  const commandResult = this.executeCommand('yarn', ['info', packageName, ...args]);
@@ -31,6 +31,11 @@ export class Yarn2Proxy extends JsPackageManager {
31
31
  this.executeCommand('yarn', ['add', ...args], 'inherit');
32
32
  }
33
33
 
34
+ runRemoveDeps(dependencies) {
35
+ const args = [...dependencies];
36
+ this.executeCommand('yarn', ['remove', ...args], 'inherit');
37
+ }
38
+
34
39
  runGetVersions(packageName, fetchAllVersions) {
35
40
  const field = fetchAllVersions ? 'versions' : 'version';
36
41
  const args = ['--fields', field, '--json'];
@@ -1,10 +1,10 @@
1
1
  import prompts from 'prompts';
2
- import fs from 'fs';
3
2
  import path from 'path';
4
3
  import chalk from 'chalk';
5
4
  import boxen from 'boxen';
6
5
  import { dedent } from 'ts-dedent';
7
6
  import degit from 'degit';
7
+ import { existsSync } from 'fs-extra';
8
8
  import TEMPLATES from './repro-templates';
9
9
  const logger = console;
10
10
 
@@ -16,7 +16,8 @@ const toChoices = c => ({
16
16
  export const reproNext = async ({
17
17
  output: outputDirectory,
18
18
  filterValue,
19
- branch
19
+ branch,
20
+ init
20
21
  }) => {
21
22
  const keys = Object.keys(TEMPLATES); // get value from template and reduce through TEMPLATES to filter out the correct template
22
23
 
@@ -40,7 +41,8 @@ export const reproNext = async ({
40
41
  if (choices.length === 0) {
41
42
  logger.info(boxen(dedent`
42
43
  🔎 You filtered out all templates. 🔍
43
- After filtering all the templates with "${chalk.yellow(filterValue)}", we found no templates.
44
+
45
+ After filtering all the templates with "${chalk.yellow(filterValue)}", we found no results. Please try again with a different filter.
44
46
 
45
47
  Available templates:
46
48
  ${keys.map(key => chalk.blue`- ${key}`).join('\n')}
@@ -49,7 +51,7 @@ export const reproNext = async ({
49
51
  padding: 1,
50
52
  borderColor: '#F1618C'
51
53
  }));
52
- return;
54
+ process.exit(1);
53
55
  }
54
56
 
55
57
  let selectedTemplate = null;
@@ -88,6 +90,11 @@ export const reproNext = async ({
88
90
  }
89
91
 
90
92
  let selectedDirectory = outputDirectory;
93
+ const outputDirectoryName = outputDirectory || selectedTemplate;
94
+
95
+ if (selectedDirectory && existsSync(`${selectedDirectory}`)) {
96
+ logger.info(`⚠️ ${selectedDirectory} already exists! Overwriting...`);
97
+ }
91
98
 
92
99
  if (!selectedDirectory) {
93
100
  const {
@@ -96,32 +103,34 @@ export const reproNext = async ({
96
103
  type: 'text',
97
104
  message: 'Enter the output directory',
98
105
  name: 'directory',
99
- initial: selectedTemplate,
100
- validate: directoryName => fs.existsSync(directoryName) ? `${directoryName} already exists. Please choose another name.` : true
106
+ initial: outputDirectoryName,
107
+ validate: async directoryName => existsSync(directoryName) ? `${directoryName} already exists. Please choose another name.` : true
101
108
  });
102
109
  selectedDirectory = directory;
103
110
  }
104
111
 
105
112
  try {
106
- const cwd = path.isAbsolute(selectedDirectory) ? selectedDirectory : path.join(process.cwd(), selectedDirectory);
107
- logger.info(`🏃 Adding ${selectedConfig.name} into ${cwd}`);
113
+ const templateDestination = path.isAbsolute(selectedDirectory) ? selectedDirectory : path.join(process.cwd(), selectedDirectory);
114
+ logger.info(`🏃 Adding ${selectedConfig.name} into ${templateDestination}`);
108
115
  logger.log('📦 Downloading repro template...');
109
116
 
110
117
  try {
111
- // Download the repro based on subfolder "after-storybook" and selected branch
112
- await degit(`storybookjs/repro-templates-temp/${selectedTemplate}/after-storybook#${branch}`, {
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}`, {
113
121
  force: true
114
- }).clone(selectedTemplate.replace('/', '-'));
122
+ }).clone(templateDestination);
115
123
  } catch (err) {
116
124
  logger.error(`🚨 Failed to download repro template: ${err.message}`);
117
- return;
125
+ throw err;
118
126
  }
119
127
 
128
+ const initMessage = init ? chalk.yellow(`yarn storybook`) : `Recreate your setup, then ${chalk.yellow(`run npx storybook init`)}`;
120
129
  logger.info(boxen(dedent`
121
130
  🎉 Your Storybook reproduction project is ready to use! 🎉
122
131
 
123
132
  ${chalk.yellow(`cd ${selectedDirectory}`)}
124
- ${chalk.yellow(`yarn storybook`)}
133
+ ${initMessage}
125
134
 
126
135
  Once you've recreated the problem you're experiencing, please:
127
136
 
@@ -1,78 +1,78 @@
1
1
  // auto generated file, do not edit
2
2
  export default {
3
- '@storybook/addon-a11y': '7.0.0-alpha.18',
4
- '@storybook/addon-actions': '7.0.0-alpha.18',
5
- '@storybook/addon-backgrounds': '7.0.0-alpha.18',
6
- '@storybook/addon-controls': '7.0.0-alpha.18',
7
- '@storybook/addon-docs': '7.0.0-alpha.18',
8
- '@storybook/addon-essentials': '7.0.0-alpha.18',
9
- '@storybook/addon-highlight': '7.0.0-alpha.18',
10
- '@storybook/addon-interactions': '7.0.0-alpha.18',
11
- '@storybook/addon-jest': '7.0.0-alpha.18',
12
- '@storybook/addon-links': '7.0.0-alpha.18',
13
- '@storybook/addon-measure': '7.0.0-alpha.18',
14
- '@storybook/addon-outline': '7.0.0-alpha.18',
15
- '@storybook/addon-storyshots': '7.0.0-alpha.18',
16
- '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.18',
17
- '@storybook/addon-storysource': '7.0.0-alpha.18',
18
- '@storybook/addon-toolbars': '7.0.0-alpha.18',
19
- '@storybook/addon-viewport': '7.0.0-alpha.18',
20
- '@storybook/addons': '7.0.0-alpha.18',
21
- '@storybook/angular': '7.0.0-alpha.18',
22
- '@storybook/api': '7.0.0-alpha.18',
23
- '@storybook/blocks': '7.0.0-alpha.18',
24
- '@storybook/builder-manager': '7.0.0-alpha.18',
25
- '@storybook/builder-webpack5': '7.0.0-alpha.18',
26
- '@storybook/channel-postmessage': '7.0.0-alpha.18',
27
- '@storybook/channel-websocket': '7.0.0-alpha.18',
28
- '@storybook/channels': '7.0.0-alpha.18',
29
- '@storybook/cli': '7.0.0-alpha.18',
30
- '@storybook/client-api': '7.0.0-alpha.18',
31
- '@storybook/client-logger': '7.0.0-alpha.18',
32
- '@storybook/codemod': '7.0.0-alpha.18',
33
- '@storybook/components': '7.0.0-alpha.18',
34
- '@storybook/core-client': '7.0.0-alpha.18',
35
- '@storybook/core-common': '7.0.0-alpha.18',
36
- '@storybook/core-events': '7.0.0-alpha.18',
37
- '@storybook/core-server': '7.0.0-alpha.18',
38
- '@storybook/core-webpack': '7.0.0-alpha.18',
39
- '@storybook/csf-tools': '7.0.0-alpha.18',
40
- '@storybook/docs-tools': '7.0.0-alpha.18',
41
- '@storybook/ember': '7.0.0-alpha.18',
42
- '@storybook/html': '7.0.0-alpha.18',
43
- '@storybook/html-webpack5': '7.0.0-alpha.18',
44
- '@storybook/instrumenter': '7.0.0-alpha.18',
45
- '@storybook/node-logger': '7.0.0-alpha.18',
46
- '@storybook/postinstall': '7.0.0-alpha.18',
47
- '@storybook/preact': '7.0.0-alpha.18',
48
- '@storybook/preact-webpack5': '7.0.0-alpha.18',
49
- '@storybook/preset-html-webpack': '7.0.0-alpha.18',
50
- '@storybook/preset-preact-webpack': '7.0.0-alpha.18',
51
- '@storybook/preset-react-webpack': '7.0.0-alpha.18',
52
- '@storybook/preset-server-webpack': '7.0.0-alpha.18',
53
- '@storybook/preset-svelte-webpack': '7.0.0-alpha.18',
54
- '@storybook/preset-vue-webpack': '7.0.0-alpha.18',
55
- '@storybook/preset-vue3-webpack': '7.0.0-alpha.18',
56
- '@storybook/preset-web-components-webpack': '7.0.0-alpha.18',
57
- '@storybook/preview-web': '7.0.0-alpha.18',
58
- '@storybook/react': '7.0.0-alpha.18',
59
- '@storybook/react-webpack5': '7.0.0-alpha.18',
60
- '@storybook/router': '7.0.0-alpha.18',
61
- '@storybook/server': '7.0.0-alpha.18',
62
- '@storybook/server-webpack5': '7.0.0-alpha.18',
63
- '@storybook/source-loader': '7.0.0-alpha.18',
64
- '@storybook/store': '7.0.0-alpha.18',
65
- '@storybook/svelte': '7.0.0-alpha.18',
66
- '@storybook/svelte-webpack5': '7.0.0-alpha.18',
67
- '@storybook/telemetry': '7.0.0-alpha.18',
68
- '@storybook/theming': '7.0.0-alpha.18',
69
- '@storybook/ui': '7.0.0-alpha.18',
70
- '@storybook/vue': '7.0.0-alpha.18',
71
- '@storybook/vue-webpack5': '7.0.0-alpha.18',
72
- '@storybook/vue3': '7.0.0-alpha.18',
73
- '@storybook/vue3-webpack5': '7.0.0-alpha.18',
74
- '@storybook/web-components': '7.0.0-alpha.18',
75
- '@storybook/web-components-webpack5': '7.0.0-alpha.18',
76
- sb: '7.0.0-alpha.18',
77
- storybook: '7.0.0-alpha.18'
3
+ '@storybook/addon-a11y': '7.0.0-alpha.19',
4
+ '@storybook/addon-actions': '7.0.0-alpha.19',
5
+ '@storybook/addon-backgrounds': '7.0.0-alpha.19',
6
+ '@storybook/addon-controls': '7.0.0-alpha.19',
7
+ '@storybook/addon-docs': '7.0.0-alpha.19',
8
+ '@storybook/addon-essentials': '7.0.0-alpha.19',
9
+ '@storybook/addon-highlight': '7.0.0-alpha.19',
10
+ '@storybook/addon-interactions': '7.0.0-alpha.19',
11
+ '@storybook/addon-jest': '7.0.0-alpha.19',
12
+ '@storybook/addon-links': '7.0.0-alpha.19',
13
+ '@storybook/addon-measure': '7.0.0-alpha.19',
14
+ '@storybook/addon-outline': '7.0.0-alpha.19',
15
+ '@storybook/addon-storyshots': '7.0.0-alpha.19',
16
+ '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.19',
17
+ '@storybook/addon-storysource': '7.0.0-alpha.19',
18
+ '@storybook/addon-toolbars': '7.0.0-alpha.19',
19
+ '@storybook/addon-viewport': '7.0.0-alpha.19',
20
+ '@storybook/addons': '7.0.0-alpha.19',
21
+ '@storybook/angular': '7.0.0-alpha.19',
22
+ '@storybook/api': '7.0.0-alpha.19',
23
+ '@storybook/blocks': '7.0.0-alpha.19',
24
+ '@storybook/builder-manager': '7.0.0-alpha.19',
25
+ '@storybook/builder-webpack5': '7.0.0-alpha.19',
26
+ '@storybook/channel-postmessage': '7.0.0-alpha.19',
27
+ '@storybook/channel-websocket': '7.0.0-alpha.19',
28
+ '@storybook/channels': '7.0.0-alpha.19',
29
+ '@storybook/cli': '7.0.0-alpha.19',
30
+ '@storybook/client-api': '7.0.0-alpha.19',
31
+ '@storybook/client-logger': '7.0.0-alpha.19',
32
+ '@storybook/codemod': '7.0.0-alpha.19',
33
+ '@storybook/components': '7.0.0-alpha.19',
34
+ '@storybook/core-client': '7.0.0-alpha.19',
35
+ '@storybook/core-common': '7.0.0-alpha.19',
36
+ '@storybook/core-events': '7.0.0-alpha.19',
37
+ '@storybook/core-server': '7.0.0-alpha.19',
38
+ '@storybook/core-webpack': '7.0.0-alpha.19',
39
+ '@storybook/csf-tools': '7.0.0-alpha.19',
40
+ '@storybook/docs-tools': '7.0.0-alpha.19',
41
+ '@storybook/ember': '7.0.0-alpha.19',
42
+ '@storybook/html': '7.0.0-alpha.19',
43
+ '@storybook/html-webpack5': '7.0.0-alpha.19',
44
+ '@storybook/instrumenter': '7.0.0-alpha.19',
45
+ '@storybook/node-logger': '7.0.0-alpha.19',
46
+ '@storybook/postinstall': '7.0.0-alpha.19',
47
+ '@storybook/preact': '7.0.0-alpha.19',
48
+ '@storybook/preact-webpack5': '7.0.0-alpha.19',
49
+ '@storybook/preset-html-webpack': '7.0.0-alpha.19',
50
+ '@storybook/preset-preact-webpack': '7.0.0-alpha.19',
51
+ '@storybook/preset-react-webpack': '7.0.0-alpha.19',
52
+ '@storybook/preset-server-webpack': '7.0.0-alpha.19',
53
+ '@storybook/preset-svelte-webpack': '7.0.0-alpha.19',
54
+ '@storybook/preset-vue-webpack': '7.0.0-alpha.19',
55
+ '@storybook/preset-vue3-webpack': '7.0.0-alpha.19',
56
+ '@storybook/preset-web-components-webpack': '7.0.0-alpha.19',
57
+ '@storybook/preview-web': '7.0.0-alpha.19',
58
+ '@storybook/react': '7.0.0-alpha.19',
59
+ '@storybook/react-webpack5': '7.0.0-alpha.19',
60
+ '@storybook/router': '7.0.0-alpha.19',
61
+ '@storybook/server': '7.0.0-alpha.19',
62
+ '@storybook/server-webpack5': '7.0.0-alpha.19',
63
+ '@storybook/source-loader': '7.0.0-alpha.19',
64
+ '@storybook/store': '7.0.0-alpha.19',
65
+ '@storybook/svelte': '7.0.0-alpha.19',
66
+ '@storybook/svelte-webpack5': '7.0.0-alpha.19',
67
+ '@storybook/telemetry': '7.0.0-alpha.19',
68
+ '@storybook/theming': '7.0.0-alpha.19',
69
+ '@storybook/ui': '7.0.0-alpha.19',
70
+ '@storybook/vue': '7.0.0-alpha.19',
71
+ '@storybook/vue-webpack5': '7.0.0-alpha.19',
72
+ '@storybook/vue3': '7.0.0-alpha.19',
73
+ '@storybook/vue3-webpack5': '7.0.0-alpha.19',
74
+ '@storybook/web-components': '7.0.0-alpha.19',
75
+ '@storybook/web-components-webpack5': '7.0.0-alpha.19',
76
+ sb: '7.0.0-alpha.19',
77
+ storybook: '7.0.0-alpha.19'
78
78
  };
@@ -0,0 +1,23 @@
1
+ import { Fix } from '../types';
2
+ import { PackageJsonWithDepsAndDevDeps } from '../../js-package-manager';
3
+ interface SbScriptsRunOptions {
4
+ storybookScripts: {
5
+ custom: Record<string, string>;
6
+ official: Record<string, string>;
7
+ };
8
+ storybookVersion: string;
9
+ packageJson: PackageJsonWithDepsAndDevDeps;
10
+ }
11
+ export declare const getStorybookScripts: (scripts: Record<string, string>) => {
12
+ custom: Record<string, string>;
13
+ official: Record<string, string>;
14
+ };
15
+ /**
16
+ * Is the user using start-storybook
17
+ *
18
+ * If so:
19
+ * - Add storybook dependency
20
+ * - Change start-storybook and build-storybook scripts
21
+ */
22
+ export declare const sbScripts: Fix<SbScriptsRunOptions>;
23
+ export {};
@@ -23,3 +23,4 @@ export declare function getBabelDependencies(packageManager: JsPackageManager, p
23
23
  export declare function addToDevDependenciesIfNotPresent(packageJson: PackageJson, name: string, packageVersion: string): void;
24
24
  export declare function copyTemplate(templateRoot: string): void;
25
25
  export declare function copyComponents(framework: SupportedRenderers, language: SupportedLanguage): Promise<void>;
26
+ export declare function getStorybookVersionSpecifier(packageJson: PackageJsonWithDepsAndDevDeps): string;
@@ -38,6 +38,21 @@ export declare abstract class JsPackageManager {
38
38
  installAsDevDependencies?: boolean;
39
39
  packageJson?: PackageJson;
40
40
  }, dependencies: string[]): void;
41
+ /**
42
+ * Remove dependencies from a project using `yarn remove` or `npm uninstall`.
43
+ *
44
+ * @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages.
45
+ * @param {Array} dependencies contains a list of packages to remove.
46
+ * @example
47
+ * removeDependencies(options, [
48
+ * `@storybook/react`,
49
+ * `@storybook/addon-actions`,
50
+ * ]);
51
+ */
52
+ removeDependencies(options: {
53
+ skipInstall?: boolean;
54
+ packageJson?: PackageJson;
55
+ }, dependencies: string[]): void;
41
56
  /**
42
57
  * Return an array of strings matching following format: `<package_name>@<package_latest_version>`
43
58
  *
@@ -78,6 +93,7 @@ export declare abstract class JsPackageManager {
78
93
  addScripts(scripts: Record<string, string>): void;
79
94
  protected abstract runInstall(): void;
80
95
  protected abstract runAddDeps(dependencies: string[], installAsDevDependencies: boolean): void;
96
+ protected abstract runRemoveDeps(dependencies: string[]): void;
81
97
  /**
82
98
  * Get the latest or all versions of the input package available on npmjs.com
83
99
  *
@@ -2,6 +2,7 @@ import { JsPackageManager } from './JsPackageManager';
2
2
  export declare class NPMProxy extends JsPackageManager {
3
3
  readonly type = "npm";
4
4
  installArgs: string[] | undefined;
5
+ uninstallArgs: string[] | undefined;
5
6
  initPackageJson(): string;
6
7
  getRunStorybookCommand(): string;
7
8
  getRunCommand(command: string): string;
@@ -10,7 +11,9 @@ export declare class NPMProxy extends JsPackageManager {
10
11
  setLegacyPeerDeps(): void;
11
12
  needsLegacyPeerDeps(version: string): boolean;
12
13
  getInstallArgs(): string[];
14
+ getUninstallArgs(): string[];
13
15
  protected runInstall(): void;
14
16
  protected runAddDeps(dependencies: string[], installAsDevDependencies: boolean): void;
17
+ protected runRemoveDeps(dependencies: string[]): void;
15
18
  protected runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
16
19
  }
@@ -6,5 +6,6 @@ export declare class Yarn1Proxy extends JsPackageManager {
6
6
  getRunCommand(command: string): string;
7
7
  protected runInstall(): void;
8
8
  protected runAddDeps(dependencies: string[], installAsDevDependencies: boolean): void;
9
+ protected runRemoveDeps(dependencies: string[]): void;
9
10
  protected runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
10
11
  }
@@ -6,5 +6,6 @@ export declare class Yarn2Proxy extends JsPackageManager {
6
6
  getRunCommand(command: string): string;
7
7
  protected runInstall(): void;
8
8
  protected runAddDeps(dependencies: string[], installAsDevDependencies: boolean): void;
9
+ protected runRemoveDeps(dependencies: string[]): void;
9
10
  protected runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
10
11
  }
@@ -2,6 +2,7 @@ interface ReproOptions {
2
2
  filterValue?: string;
3
3
  output?: string;
4
4
  branch?: string;
5
+ init?: boolean;
5
6
  }
6
- export declare const reproNext: ({ output: outputDirectory, filterValue, branch }: ReproOptions) => Promise<void>;
7
+ export declare const reproNext: ({ output: outputDirectory, filterValue, branch, init, }: ReproOptions) => Promise<void>;
7
8
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/cli",
3
- "version": "7.0.0-alpha.18",
3
+ "version": "7.0.0-alpha.19",
4
4
  "description": "Storybook's CLI - easiest method of adding storybook to your projects",
5
5
  "keywords": [
6
6
  "cli",
@@ -49,13 +49,13 @@
49
49
  "dependencies": {
50
50
  "@babel/core": "^7.12.10",
51
51
  "@babel/preset-env": "^7.12.11",
52
- "@storybook/codemod": "7.0.0-alpha.18",
53
- "@storybook/core-common": "7.0.0-alpha.18",
54
- "@storybook/core-server": "7.0.0-alpha.18",
55
- "@storybook/csf-tools": "7.0.0-alpha.18",
56
- "@storybook/node-logger": "7.0.0-alpha.18",
52
+ "@storybook/codemod": "7.0.0-alpha.19",
53
+ "@storybook/core-common": "7.0.0-alpha.19",
54
+ "@storybook/core-server": "7.0.0-alpha.19",
55
+ "@storybook/csf-tools": "7.0.0-alpha.19",
56
+ "@storybook/node-logger": "7.0.0-alpha.19",
57
57
  "@storybook/semver": "^7.3.2",
58
- "@storybook/telemetry": "7.0.0-alpha.18",
58
+ "@storybook/telemetry": "7.0.0-alpha.19",
59
59
  "boxen": "^5.1.2",
60
60
  "chalk": "^4.1.0",
61
61
  "commander": "^6.2.1",
@@ -82,7 +82,7 @@
82
82
  "update-notifier": "^5.0.1"
83
83
  },
84
84
  "devDependencies": {
85
- "@storybook/client-api": "7.0.0-alpha.18",
85
+ "@storybook/client-api": "7.0.0-alpha.19",
86
86
  "@types/cross-spawn": "^6.0.2",
87
87
  "@types/degit": "^2.8.3",
88
88
  "@types/prompts": "^2.0.9",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "bd59f1eef0f644175abdb0d9873ed0553f431f53"
100
+ "gitHead": "74bdb53f67dd59bae2661c668d2d5d4296113281"
101
101
  }