@storybook/cli 7.0.0-alpha.31 → 7.0.0-alpha.33

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.
Files changed (254) hide show
  1. package/.eslintrc.js +35 -0
  2. package/bin/index.js +1 -1
  3. package/dist/generate.d.ts +1 -0
  4. package/dist/generate.js +265 -0
  5. package/dist/generate.mjs +265 -0
  6. package/package.json +17 -11
  7. package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/tsconfig.json +0 -0
  8. package/{dist/cjs/generators/ANGULAR → templates/angular}/template-csf/.storybook/typings.d.ts +0 -0
  9. package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/tsconfig.json +0 -0
  10. package/{dist/cjs/generators/AURELIA → templates/aurelia}/template-csf/.storybook/typings.d.ts +0 -0
  11. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/addons.js +1 -1
  12. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/index.js +13 -6
  13. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/rn-addons.js +1 -1
  14. package/templates/react-native/template-csf/storybook/stories/Button/Button.stories.js +20 -0
  15. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Button/index.js +8 -10
  16. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/index.js +8 -9
  17. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/CenterView/style.js +3 -3
  18. package/{dist/esm/generators/REACT_NATIVE → templates/react-native}/template-csf/storybook/stories/Welcome/Welcome.stories.js +2 -3
  19. package/templates/react-native/template-csf/storybook/stories/Welcome/index.js +57 -0
  20. package/templates/react-native/template-csf/storybook/stories/index.js +2 -0
  21. package/templates/server/template-csf/.storybook/preview.js +5 -0
  22. package/dist/cjs/NpmOptions.js +0 -1
  23. package/dist/cjs/add.js +0 -149
  24. package/dist/cjs/automigrate/fixes/angular12.js +0 -74
  25. package/dist/cjs/automigrate/fixes/builder-vite.js +0 -118
  26. package/dist/cjs/automigrate/fixes/cra5.js +0 -82
  27. package/dist/cjs/automigrate/fixes/eslint-plugin.js +0 -126
  28. package/dist/cjs/automigrate/fixes/index.js +0 -45
  29. package/dist/cjs/automigrate/fixes/mainjsFramework.js +0 -94
  30. package/dist/cjs/automigrate/fixes/new-frameworks.js +0 -258
  31. package/dist/cjs/automigrate/fixes/npm7.js +0 -57
  32. package/dist/cjs/automigrate/fixes/sb-scripts.js +0 -140
  33. package/dist/cjs/automigrate/fixes/vue3.js +0 -77
  34. package/dist/cjs/automigrate/fixes/webpack5.js +0 -151
  35. package/dist/cjs/automigrate/helpers/getEslintInfo.js +0 -28
  36. package/dist/cjs/automigrate/index.js +0 -98
  37. package/dist/cjs/automigrate/types.js +0 -5
  38. package/dist/cjs/babel-config.js +0 -65
  39. package/dist/cjs/build.js +0 -36
  40. package/dist/cjs/detect-nextjs.js +0 -33
  41. package/dist/cjs/detect-webpack.js +0 -39
  42. package/dist/cjs/detect.js +0 -179
  43. package/dist/cjs/dev.js +0 -66
  44. package/dist/cjs/dirs.js +0 -12
  45. package/dist/cjs/extract.js +0 -93
  46. package/dist/cjs/generate.js +0 -215
  47. package/dist/cjs/generators/ANGULAR/angular-helpers.js +0 -106
  48. package/dist/cjs/generators/ANGULAR/index.js +0 -95
  49. package/dist/cjs/generators/AURELIA/index.js +0 -41
  50. package/dist/cjs/generators/EMBER/index.js +0 -20
  51. package/dist/cjs/generators/HTML/index.js +0 -15
  52. package/dist/cjs/generators/MARIONETTE/index.js +0 -15
  53. package/dist/cjs/generators/MARKO/index.js +0 -15
  54. package/dist/cjs/generators/MITHRIL/index.js +0 -15
  55. package/dist/cjs/generators/PREACT/index.js +0 -15
  56. package/dist/cjs/generators/RAX/index.js +0 -28
  57. package/dist/cjs/generators/REACT/index.js +0 -15
  58. package/dist/cjs/generators/REACT_NATIVE/index.js +0 -55
  59. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/addons.js +0 -7
  60. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/index.js +0 -31
  61. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/rn-addons.js +0 -5
  62. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -23
  63. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Button/index.js +0 -32
  64. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/index.js +0 -31
  65. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/CenterView/style.js +0 -15
  66. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/Welcome.stories.js +0 -15
  67. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -68
  68. package/dist/cjs/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -5
  69. package/dist/cjs/generators/REACT_SCRIPTS/index.js +0 -68
  70. package/dist/cjs/generators/RIOT/index.js +0 -17
  71. package/dist/cjs/generators/SERVER/index.js +0 -20
  72. package/dist/cjs/generators/SERVER/template-csf/.storybook/preview.js +0 -12
  73. package/dist/cjs/generators/SFC_VUE/index.js +0 -15
  74. package/dist/cjs/generators/SVELTE/index.js +0 -59
  75. package/dist/cjs/generators/VUE/index.js +0 -17
  76. package/dist/cjs/generators/VUE3/index.js +0 -17
  77. package/dist/cjs/generators/WEB-COMPONENTS/index.js +0 -17
  78. package/dist/cjs/generators/WEBPACK_REACT/index.js +0 -15
  79. package/dist/cjs/generators/baseGenerator.js +0 -208
  80. package/dist/cjs/generators/configure.js +0 -83
  81. package/dist/cjs/generators/types.js +0 -5
  82. package/dist/cjs/helpers.js +0 -258
  83. package/dist/cjs/initiate.js +0 -295
  84. package/dist/cjs/js-package-manager/JsPackageManager.js +0 -358
  85. package/dist/cjs/js-package-manager/JsPackageManagerFactory.js +0 -71
  86. package/dist/cjs/js-package-manager/NPMProxy.js +0 -112
  87. package/dist/cjs/js-package-manager/PackageJson.js +0 -5
  88. package/dist/cjs/js-package-manager/Yarn1Proxy.js +0 -72
  89. package/dist/cjs/js-package-manager/Yarn2Proxy.js +0 -68
  90. package/dist/cjs/js-package-manager/index.js +0 -44
  91. package/dist/cjs/link.js +0 -99
  92. package/dist/cjs/migrate.js +0 -33
  93. package/dist/cjs/project_types.js +0 -263
  94. package/dist/cjs/repro-generators/configs.js +0 -201
  95. package/dist/cjs/repro-generators/scripts.js +0 -338
  96. package/dist/cjs/repro-next.js +0 -182
  97. package/dist/cjs/repro-templates.js +0 -103
  98. package/dist/cjs/repro.js +0 -194
  99. package/dist/cjs/typings.d.ts +0 -3
  100. package/dist/cjs/upgrade.js +0 -170
  101. package/dist/cjs/utils.js +0 -22
  102. package/dist/cjs/versions.js +0 -89
  103. package/dist/cjs/warn.js +0 -32
  104. package/dist/cjs/window.d.js +0 -5
  105. package/dist/esm/NpmOptions.js +0 -0
  106. package/dist/esm/add.js +0 -121
  107. package/dist/esm/automigrate/fixes/angular12.js +0 -58
  108. package/dist/esm/automigrate/fixes/builder-vite.js +0 -103
  109. package/dist/esm/automigrate/fixes/cra5.js +0 -66
  110. package/dist/esm/automigrate/fixes/eslint-plugin.js +0 -111
  111. package/dist/esm/automigrate/fixes/index.js +0 -12
  112. package/dist/esm/automigrate/fixes/mainjsFramework.js +0 -76
  113. package/dist/esm/automigrate/fixes/new-frameworks.js +0 -234
  114. package/dist/esm/automigrate/fixes/npm7.js +0 -45
  115. package/dist/esm/automigrate/fixes/sb-scripts.js +0 -119
  116. package/dist/esm/automigrate/fixes/vue3.js +0 -60
  117. package/dist/esm/automigrate/fixes/webpack5.js +0 -131
  118. package/dist/esm/automigrate/helpers/getEslintInfo.js +0 -14
  119. package/dist/esm/automigrate/index.js +0 -80
  120. package/dist/esm/automigrate/types.js +0 -1
  121. package/dist/esm/babel-config.js +0 -42
  122. package/dist/esm/build.js +0 -22
  123. package/dist/esm/detect-nextjs.js +0 -24
  124. package/dist/esm/detect-webpack.js +0 -30
  125. package/dist/esm/detect.js +0 -152
  126. package/dist/esm/dev.js +0 -47
  127. package/dist/esm/dirs.js +0 -4
  128. package/dist/esm/extract.js +0 -77
  129. package/dist/esm/generate.js +0 -162
  130. package/dist/esm/generators/ANGULAR/angular-helpers.js +0 -82
  131. package/dist/esm/generators/ANGULAR/index.js +0 -76
  132. package/dist/esm/generators/ANGULAR/template-csf/.storybook/tsconfig.json +0 -10
  133. package/dist/esm/generators/ANGULAR/template-csf/.storybook/typings.d.ts +0 -4
  134. package/dist/esm/generators/AURELIA/index.js +0 -32
  135. package/dist/esm/generators/AURELIA/template-csf/.storybook/tsconfig.json +0 -9
  136. package/dist/esm/generators/AURELIA/template-csf/.storybook/typings.d.ts +0 -4
  137. package/dist/esm/generators/EMBER/index.js +0 -12
  138. package/dist/esm/generators/HTML/index.js +0 -7
  139. package/dist/esm/generators/MARIONETTE/index.js +0 -7
  140. package/dist/esm/generators/MARKO/index.js +0 -7
  141. package/dist/esm/generators/MITHRIL/index.js +0 -7
  142. package/dist/esm/generators/PREACT/index.js +0 -7
  143. package/dist/esm/generators/RAX/index.js +0 -20
  144. package/dist/esm/generators/REACT/index.js +0 -7
  145. package/dist/esm/generators/REACT_NATIVE/index.js +0 -42
  146. package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Button/Button.stories.js +0 -12
  147. package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/Welcome/index.js +0 -54
  148. package/dist/esm/generators/REACT_NATIVE/template-csf/storybook/stories/index.js +0 -2
  149. package/dist/esm/generators/REACT_SCRIPTS/index.js +0 -49
  150. package/dist/esm/generators/RIOT/index.js +0 -9
  151. package/dist/esm/generators/SERVER/index.js +0 -11
  152. package/dist/esm/generators/SERVER/template-csf/.storybook/preview.js +0 -5
  153. package/dist/esm/generators/SFC_VUE/index.js +0 -7
  154. package/dist/esm/generators/SVELTE/index.js +0 -44
  155. package/dist/esm/generators/VUE/index.js +0 -9
  156. package/dist/esm/generators/VUE3/index.js +0 -9
  157. package/dist/esm/generators/WEB-COMPONENTS/index.js +0 -9
  158. package/dist/esm/generators/WEBPACK_REACT/index.js +0 -7
  159. package/dist/esm/generators/baseGenerator.js +0 -191
  160. package/dist/esm/generators/configure.js +0 -69
  161. package/dist/esm/generators/types.js +0 -1
  162. package/dist/esm/helpers.js +0 -207
  163. package/dist/esm/initiate.js +0 -254
  164. package/dist/esm/js-package-manager/JsPackageManager.js +0 -334
  165. package/dist/esm/js-package-manager/JsPackageManagerFactory.js +0 -57
  166. package/dist/esm/js-package-manager/NPMProxy.js +0 -99
  167. package/dist/esm/js-package-manager/PackageJson.js +0 -1
  168. package/dist/esm/js-package-manager/Yarn1Proxy.js +0 -62
  169. package/dist/esm/js-package-manager/Yarn2Proxy.js +0 -58
  170. package/dist/esm/js-package-manager/index.js +0 -3
  171. package/dist/esm/link.js +0 -69
  172. package/dist/esm/migrate.js +0 -25
  173. package/dist/esm/project_types.js +0 -248
  174. package/dist/esm/repro-generators/configs.js +0 -174
  175. package/dist/esm/repro-generators/scripts.js +0 -307
  176. package/dist/esm/repro-next.js +0 -163
  177. package/dist/esm/repro-templates.js +0 -94
  178. package/dist/esm/repro.js +0 -170
  179. package/dist/esm/typings.d.ts +0 -3
  180. package/dist/esm/upgrade.js +0 -132
  181. package/dist/esm/utils.js +0 -13
  182. package/dist/esm/versions.js +0 -82
  183. package/dist/esm/warn.js +0 -16
  184. package/dist/esm/window.d.js +0 -1
  185. package/dist/types/NpmOptions.d.ts +0 -4
  186. package/dist/types/add.d.ts +0 -10
  187. package/dist/types/automigrate/fixes/angular12.d.ts +0 -15
  188. package/dist/types/automigrate/fixes/builder-vite.d.ts +0 -19
  189. package/dist/types/automigrate/fixes/cra5.d.ts +0 -15
  190. package/dist/types/automigrate/fixes/eslint-plugin.d.ts +0 -15
  191. package/dist/types/automigrate/fixes/index.d.ts +0 -3
  192. package/dist/types/automigrate/fixes/mainjsFramework.d.ts +0 -8
  193. package/dist/types/automigrate/fixes/new-frameworks.d.ts +0 -31
  194. package/dist/types/automigrate/fixes/npm7.d.ts +0 -9
  195. package/dist/types/automigrate/fixes/sb-scripts.d.ts +0 -23
  196. package/dist/types/automigrate/fixes/vue3.d.ts +0 -15
  197. package/dist/types/automigrate/fixes/webpack5.d.ts +0 -26
  198. package/dist/types/automigrate/helpers/getEslintInfo.d.ts +0 -2
  199. package/dist/types/automigrate/index.d.ts +0 -7
  200. package/dist/types/automigrate/types.d.ts +0 -15
  201. package/dist/types/babel-config.d.ts +0 -4
  202. package/dist/types/build.d.ts +0 -1
  203. package/dist/types/detect-nextjs.d.ts +0 -2
  204. package/dist/types/detect-webpack.d.ts +0 -2
  205. package/dist/types/detect.d.ts +0 -16
  206. package/dist/types/dev.d.ts +0 -1
  207. package/dist/types/dirs.d.ts +0 -1
  208. package/dist/types/extract.d.ts +0 -1
  209. package/dist/types/generate.d.ts +0 -1
  210. package/dist/types/generators/ANGULAR/angular-helpers.d.ts +0 -6
  211. package/dist/types/generators/ANGULAR/index.d.ts +0 -3
  212. package/dist/types/generators/AURELIA/index.d.ts +0 -3
  213. package/dist/types/generators/EMBER/index.d.ts +0 -3
  214. package/dist/types/generators/HTML/index.d.ts +0 -3
  215. package/dist/types/generators/MARIONETTE/index.d.ts +0 -3
  216. package/dist/types/generators/MARKO/index.d.ts +0 -3
  217. package/dist/types/generators/MITHRIL/index.d.ts +0 -3
  218. package/dist/types/generators/PREACT/index.d.ts +0 -3
  219. package/dist/types/generators/RAX/index.d.ts +0 -3
  220. package/dist/types/generators/REACT/index.d.ts +0 -3
  221. package/dist/types/generators/REACT_NATIVE/index.d.ts +0 -4
  222. package/dist/types/generators/REACT_SCRIPTS/index.d.ts +0 -3
  223. package/dist/types/generators/RIOT/index.d.ts +0 -3
  224. package/dist/types/generators/SERVER/index.d.ts +0 -3
  225. package/dist/types/generators/SFC_VUE/index.d.ts +0 -3
  226. package/dist/types/generators/SVELTE/index.d.ts +0 -3
  227. package/dist/types/generators/VUE/index.d.ts +0 -3
  228. package/dist/types/generators/VUE3/index.d.ts +0 -3
  229. package/dist/types/generators/WEB-COMPONENTS/index.d.ts +0 -3
  230. package/dist/types/generators/WEBPACK_REACT/index.d.ts +0 -3
  231. package/dist/types/generators/baseGenerator.d.ts +0 -5
  232. package/dist/types/generators/configure.d.ts +0 -19
  233. package/dist/types/generators/types.d.ts +0 -38
  234. package/dist/types/helpers.d.ts +0 -26
  235. package/dist/types/initiate.d.ts +0 -3
  236. package/dist/types/js-package-manager/JsPackageManager.d.ts +0 -118
  237. package/dist/types/js-package-manager/JsPackageManagerFactory.d.ts +0 -4
  238. package/dist/types/js-package-manager/NPMProxy.d.ts +0 -23
  239. package/dist/types/js-package-manager/PackageJson.d.ts +0 -4
  240. package/dist/types/js-package-manager/Yarn1Proxy.d.ts +0 -17
  241. package/dist/types/js-package-manager/Yarn2Proxy.d.ts +0 -17
  242. package/dist/types/js-package-manager/index.d.ts +0 -3
  243. package/dist/types/link.d.ts +0 -7
  244. package/dist/types/migrate.d.ts +0 -1
  245. package/dist/types/project_types.d.ts +0 -64
  246. package/dist/types/repro-generators/configs.d.ts +0 -44
  247. package/dist/types/repro-generators/scripts.d.ts +0 -44
  248. package/dist/types/repro-next.d.ts +0 -8
  249. package/dist/types/repro-templates.d.ts +0 -73
  250. package/dist/types/repro.d.ts +0 -14
  251. package/dist/types/upgrade.d.ts +0 -19
  252. package/dist/types/utils.d.ts +0 -2
  253. package/dist/types/versions.d.ts +0 -82
  254. 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 {};
@@ -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
- };