@storybook/cli 7.0.0-alpha.0 → 7.0.0-alpha.11
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/dist/cjs/automigrate/fixes/angular12.js +2 -2
- package/dist/cjs/automigrate/fixes/builder-vite.js +2 -2
- package/dist/cjs/automigrate/fixes/cra5.js +2 -2
- package/dist/cjs/automigrate/fixes/eslint-plugin.js +3 -3
- package/dist/cjs/automigrate/fixes/index.js +3 -1
- package/dist/cjs/automigrate/fixes/mainjsFramework.js +3 -3
- package/dist/cjs/automigrate/fixes/npm7.js +59 -0
- package/dist/cjs/automigrate/fixes/vue3.js +2 -2
- package/dist/cjs/automigrate/fixes/webpack5.js +5 -5
- package/dist/cjs/automigrate/index.js +9 -3
- package/dist/cjs/babel-config.js +5 -4
- package/dist/cjs/dev.js +3 -5
- package/dist/cjs/frameworks/angular/Button.stories.ts +6 -4
- package/dist/cjs/frameworks/angular/Header.stories.ts +2 -2
- package/dist/cjs/frameworks/angular/Page.stories.ts +3 -3
- package/dist/cjs/frameworks/html/ts/Button.stories.ts +3 -3
- package/dist/cjs/frameworks/html/ts/Button.ts +6 -2
- package/dist/cjs/frameworks/html/ts/Header.stories.ts +3 -3
- package/dist/cjs/frameworks/html/ts/Page.stories.ts +2 -2
- package/dist/cjs/frameworks/html/ts/Page.ts +4 -4
- package/dist/cjs/frameworks/react/ts/Button.stories.tsx +2 -2
- package/dist/cjs/frameworks/react/ts/Header.stories.tsx +2 -2
- package/dist/cjs/frameworks/react/ts/Page.stories.tsx +2 -2
- package/dist/cjs/frameworks/web-components/ts/Button.stories.ts +2 -2
- package/dist/cjs/frameworks/web-components/ts/Header.stories.ts +2 -2
- package/dist/cjs/frameworks/web-components/ts/Page.stories.ts +2 -2
- package/dist/cjs/generate.js +1 -1
- package/dist/cjs/generators/ANGULAR/index.js +24 -1
- package/dist/cjs/generators/REACT_SCRIPTS/index.js +4 -4
- package/dist/cjs/generators/SVELTE/index.js +8 -14
- package/dist/cjs/generators/baseGenerator.js +42 -41
- package/dist/cjs/generators/configure.js +19 -21
- package/dist/cjs/generators/types.js +5 -0
- package/dist/cjs/helpers.js +10 -12
- package/dist/cjs/initiate.js +2 -1
- package/dist/cjs/js-package-manager/JsPackageManager.js +3 -3
- package/dist/cjs/js-package-manager/NPMProxy.js +18 -2
- package/dist/cjs/repro-generators/configs.js +22 -24
- package/dist/cjs/repro-generators/scripts.js +23 -13
- package/dist/cjs/repro.js +3 -3
- package/dist/cjs/versions.js +75 -71
- package/dist/esm/automigrate/fixes/angular12.js +2 -2
- package/dist/esm/automigrate/fixes/builder-vite.js +2 -2
- package/dist/esm/automigrate/fixes/cra5.js +2 -2
- package/dist/esm/automigrate/fixes/eslint-plugin.js +3 -3
- package/dist/esm/automigrate/fixes/index.js +3 -1
- package/dist/esm/automigrate/fixes/mainjsFramework.js +3 -3
- package/dist/esm/automigrate/fixes/npm7.js +59 -0
- package/dist/esm/automigrate/fixes/vue3.js +2 -2
- package/dist/esm/automigrate/fixes/webpack5.js +5 -5
- package/dist/esm/automigrate/index.js +9 -3
- package/dist/esm/babel-config.js +5 -4
- package/dist/esm/dev.js +3 -5
- package/dist/esm/frameworks/angular/Button.stories.ts +6 -4
- package/dist/esm/frameworks/angular/Header.stories.ts +2 -2
- package/dist/esm/frameworks/angular/Page.stories.ts +3 -3
- package/dist/esm/frameworks/html/ts/Button.stories.ts +3 -3
- package/dist/esm/frameworks/html/ts/Button.ts +6 -2
- package/dist/esm/frameworks/html/ts/Header.stories.ts +3 -3
- package/dist/esm/frameworks/html/ts/Page.stories.ts +2 -2
- package/dist/esm/frameworks/html/ts/Page.ts +4 -4
- package/dist/esm/frameworks/react/ts/Button.stories.tsx +2 -2
- package/dist/esm/frameworks/react/ts/Header.stories.tsx +2 -2
- package/dist/esm/frameworks/react/ts/Page.stories.tsx +2 -2
- package/dist/esm/frameworks/web-components/ts/Button.stories.ts +2 -2
- package/dist/esm/frameworks/web-components/ts/Header.stories.ts +2 -2
- package/dist/esm/frameworks/web-components/ts/Page.stories.ts +2 -2
- package/dist/esm/generate.js +1 -1
- package/dist/esm/generators/ANGULAR/index.js +24 -1
- package/dist/esm/generators/REACT_SCRIPTS/index.js +4 -4
- package/dist/esm/generators/SVELTE/index.js +8 -14
- package/dist/esm/generators/baseGenerator.js +42 -41
- package/dist/esm/generators/configure.js +19 -21
- package/dist/esm/generators/types.js +5 -0
- package/dist/esm/helpers.js +10 -12
- package/dist/esm/initiate.js +2 -1
- package/dist/esm/js-package-manager/JsPackageManager.js +3 -3
- package/dist/esm/js-package-manager/NPMProxy.js +18 -2
- package/dist/esm/repro-generators/configs.js +22 -24
- package/dist/esm/repro-generators/scripts.js +23 -13
- package/dist/esm/repro.js +3 -3
- package/dist/esm/versions.js +75 -71
- package/dist/types/automigrate/fixes/npm7.d.ts +9 -0
- package/dist/types/generators/ANGULAR/index.d.ts +1 -1
- package/dist/types/generators/AURELIA/index.d.ts +1 -1
- package/dist/types/generators/EMBER/index.d.ts +1 -1
- package/dist/types/generators/HTML/index.d.ts +1 -1
- package/dist/types/generators/MARIONETTE/index.d.ts +1 -1
- package/dist/types/generators/MARKO/index.d.ts +1 -1
- package/dist/types/generators/MITHRIL/index.d.ts +1 -1
- package/dist/types/generators/PREACT/index.d.ts +1 -1
- package/dist/types/generators/RAX/index.d.ts +1 -1
- package/dist/types/generators/REACT/index.d.ts +1 -1
- package/dist/types/generators/REACT_SCRIPTS/index.d.ts +1 -1
- package/dist/types/generators/RIOT/index.d.ts +1 -1
- package/dist/types/generators/SERVER/index.d.ts +1 -1
- package/dist/types/generators/SFC_VUE/index.d.ts +1 -1
- package/dist/types/generators/SVELTE/index.d.ts +1 -1
- package/dist/types/generators/VUE/index.d.ts +1 -1
- package/dist/types/generators/VUE3/index.d.ts +1 -1
- package/dist/types/generators/WEB-COMPONENTS/index.d.ts +1 -1
- package/dist/types/generators/WEBPACK_REACT/index.d.ts +1 -1
- package/dist/types/generators/baseGenerator.d.ts +3 -20
- package/dist/types/generators/configure.d.ts +2 -1
- package/dist/types/generators/types.d.ts +37 -0
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/initiate.d.ts +1 -15
- package/dist/types/js-package-manager/NPMProxy.d.ts +4 -0
- package/dist/types/repro-generators/configs.d.ts +1 -4
- package/dist/types/repro-generators/scripts.d.ts +1 -1
- package/dist/types/versions.d.ts +5 -1
- package/package.json +11 -9
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _semver = _interopRequireDefault(require("@storybook/semver"));
|
|
15
15
|
|
|
@@ -54,7 +54,7 @@ const angular12 = {
|
|
|
54
54
|
}) {
|
|
55
55
|
const angularFormatted = _chalk.default.cyan(`Angular ${angularVersion}`);
|
|
56
56
|
|
|
57
|
-
return (0, _tsDedent.
|
|
57
|
+
return (0, _tsDedent.dedent)`
|
|
58
58
|
We've detected you are running ${angularFormatted} which is powered by webpack5.
|
|
59
59
|
Your Storybook's main.js files specifies webpack4, which is incompatible.
|
|
60
60
|
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _csfTools = require("@storybook/csf-tools");
|
|
15
15
|
|
|
@@ -66,7 +66,7 @@ const builderVite = {
|
|
|
66
66
|
}) {
|
|
67
67
|
const builderFormatted = _chalk.default.cyan(JSON.stringify(builder, null, 2));
|
|
68
68
|
|
|
69
|
-
return (0, _tsDedent.
|
|
69
|
+
return (0, _tsDedent.dedent)`
|
|
70
70
|
We've detected you're using the community vite builder: ${builderFormatted}
|
|
71
71
|
|
|
72
72
|
'storybook-builder-vite' is deprecated and now located at ${_chalk.default.cyan('@storybook/builder-vite')}.
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _semver = _interopRequireDefault(require("@storybook/semver"));
|
|
15
15
|
|
|
@@ -62,7 +62,7 @@ const cra5 = {
|
|
|
62
62
|
const craFormatted = _chalk.default.cyan(`Create React App (CRA) ${craVersion}`);
|
|
63
63
|
|
|
64
64
|
console.log(Object.assign({}, rest));
|
|
65
|
-
return (0, _tsDedent.
|
|
65
|
+
return (0, _tsDedent.dedent)`
|
|
66
66
|
We've detected you are running ${craFormatted} which is powered by webpack5.
|
|
67
67
|
Your Storybook's main.js files specifies webpack4, which is incompatible.
|
|
68
68
|
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _csfTools = require("@storybook/csf-tools");
|
|
15
15
|
|
|
@@ -79,7 +79,7 @@ const eslintPlugin = {
|
|
|
79
79
|
},
|
|
80
80
|
|
|
81
81
|
prompt() {
|
|
82
|
-
return (0, _tsDedent.
|
|
82
|
+
return (0, _tsDedent.dedent)`
|
|
83
83
|
We've detected you are not using our eslint-plugin.
|
|
84
84
|
|
|
85
85
|
In order to have the best experience with Storybook and follow best practices, we advise you to install eslint-plugin-storybook.
|
|
@@ -103,7 +103,7 @@ const eslintPlugin = {
|
|
|
103
103
|
}, deps);
|
|
104
104
|
|
|
105
105
|
if (!dryRun && unsupportedExtension) {
|
|
106
|
-
throw new Error((0, _tsDedent.
|
|
106
|
+
throw new Error((0, _tsDedent.dedent)`
|
|
107
107
|
⚠️ The plugin was successfuly installed but failed to configure.
|
|
108
108
|
|
|
109
109
|
Found an .eslintrc config file with an unsupported automigration format: ${unsupportedExtension}.
|
|
@@ -22,6 +22,8 @@ var _eslintPlugin = require("./eslint-plugin");
|
|
|
22
22
|
|
|
23
23
|
var _builderVite = require("./builder-vite");
|
|
24
24
|
|
|
25
|
+
var _npm = require("./npm7");
|
|
26
|
+
|
|
25
27
|
var _types = require("../types");
|
|
26
28
|
|
|
27
29
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -35,5 +37,5 @@ Object.keys(_types).forEach(function (key) {
|
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
});
|
|
38
|
-
const fixes = [_cra.cra5, _webpack.webpack5, _angular.angular12, _vue.vue3, _mainjsFramework.mainjsFramework, _eslintPlugin.eslintPlugin, _builderVite.builderVite];
|
|
40
|
+
const fixes = [_cra.cra5, _webpack.webpack5, _angular.angular12, _vue.vue3, _mainjsFramework.mainjsFramework, _eslintPlugin.eslintPlugin, _builderVite.builderVite, _npm.npm7];
|
|
39
41
|
exports.fixes = fixes;
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _semver = _interopRequireDefault(require("@storybook/semver"));
|
|
15
15
|
|
|
@@ -43,7 +43,7 @@ const mainjsFramework = {
|
|
|
43
43
|
const storybookCoerced = storybookVersion && ((_semver$coerce = _semver.default.coerce(storybookVersion)) === null || _semver$coerce === void 0 ? void 0 : _semver$coerce.version);
|
|
44
44
|
|
|
45
45
|
if (!storybookCoerced) {
|
|
46
|
-
logger.warn((0, _tsDedent.
|
|
46
|
+
logger.warn((0, _tsDedent.dedent)`
|
|
47
47
|
❌ Unable to determine storybook version, skipping ${_chalk.default.cyan('mainjsFramework')} fix.
|
|
48
48
|
🤔 Are you running automigrate from your project directory?
|
|
49
49
|
`);
|
|
@@ -65,7 +65,7 @@ const mainjsFramework = {
|
|
|
65
65
|
}) {
|
|
66
66
|
const frameworkFormatted = _chalk.default.cyan(`framework: '${framework}'`);
|
|
67
67
|
|
|
68
|
-
return (0, _tsDedent.
|
|
68
|
+
return (0, _tsDedent.dedent)`
|
|
69
69
|
We've detected that your main.js configuration file does not specify the
|
|
70
70
|
'framework' field, which is a requirement in SB7.0 and above. We can add one
|
|
71
71
|
for you automatically:
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.npm7 = void 0;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/es.promise.js");
|
|
9
|
+
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Is the user using npm7+? If so create a .npmrc with legacy-peer-deps=true
|
|
18
|
+
*/
|
|
19
|
+
const npm7 = {
|
|
20
|
+
id: 'npm7',
|
|
21
|
+
|
|
22
|
+
async check({
|
|
23
|
+
packageManager
|
|
24
|
+
}) {
|
|
25
|
+
if (packageManager.type !== 'npm') return null;
|
|
26
|
+
const npmVersion = packageManager.getNpmVersion();
|
|
27
|
+
|
|
28
|
+
if (packageManager.needsLegacyPeerDeps(npmVersion)) {
|
|
29
|
+
return {
|
|
30
|
+
npmVersion
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
prompt({
|
|
38
|
+
npmVersion
|
|
39
|
+
}) {
|
|
40
|
+
const npmFormatted = _chalk.default.cyan(`npm ${npmVersion}`);
|
|
41
|
+
|
|
42
|
+
return (0, _tsDedent.dedent)`
|
|
43
|
+
We've detected you are running ${npmFormatted} which has peer dependency semantics which Storybook is incompatible with.
|
|
44
|
+
|
|
45
|
+
In order to work with Storybook's package structure, you'll need to run \`npm\` with the
|
|
46
|
+
\`--legacy-peer-deps=true\` flag. We can generate an \`.npmrc\` which will do that automatically.
|
|
47
|
+
|
|
48
|
+
More info: ${_chalk.default.yellow('https://github.com/storybookjs/storybook/issues/18298')}
|
|
49
|
+
`;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
async run({
|
|
53
|
+
packageManager
|
|
54
|
+
}) {
|
|
55
|
+
packageManager.setLegacyPeerDeps();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
};
|
|
59
|
+
exports.npm7 = npm7;
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _semver = _interopRequireDefault(require("@storybook/semver"));
|
|
15
15
|
|
|
@@ -57,7 +57,7 @@ const vue3 = {
|
|
|
57
57
|
|
|
58
58
|
const sbFormatted = _chalk.default.cyan(`Storybook ${storybookVersion}`);
|
|
59
59
|
|
|
60
|
-
return (0, _tsDedent.
|
|
60
|
+
return (0, _tsDedent.dedent)`
|
|
61
61
|
We've detected you are running ${vueFormatted} with Storybook.
|
|
62
62
|
${sbFormatted} runs webpack4 by default, which is incompatible.
|
|
63
63
|
|
|
@@ -9,7 +9,7 @@ require("core-js/modules/es.promise.js");
|
|
|
9
9
|
|
|
10
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
11
|
|
|
12
|
-
var _tsDedent =
|
|
12
|
+
var _tsDedent = require("ts-dedent");
|
|
13
13
|
|
|
14
14
|
var _semver = _interopRequireDefault(require("@storybook/semver"));
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ const webpack5 = {
|
|
|
44
44
|
const storybookCoerced = storybookVersion && ((_semver$coerce = _semver.default.coerce(storybookVersion)) === null || _semver$coerce === void 0 ? void 0 : _semver$coerce.version);
|
|
45
45
|
|
|
46
46
|
if (!storybookCoerced) {
|
|
47
|
-
logger.warn((0, _tsDedent.
|
|
47
|
+
logger.warn((0, _tsDedent.dedent)`
|
|
48
48
|
❌ Unable to determine storybook version, skipping ${_chalk.default.cyan('webpack5')} fix.
|
|
49
49
|
🤔 Are you running automigrate from your project directory?
|
|
50
50
|
`);
|
|
@@ -52,7 +52,7 @@ const webpack5 = {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (_semver.default.lt(storybookCoerced, '6.3.0')) {
|
|
55
|
-
logger.warn((0, _tsDedent.
|
|
55
|
+
logger.warn((0, _tsDedent.dedent)`
|
|
56
56
|
Detected SB 6.3 or below, please upgrade storybook to use webpack5.
|
|
57
57
|
|
|
58
58
|
To upgrade to the latest stable release, run this from your project directory:
|
|
@@ -111,7 +111,7 @@ const webpack5 = {
|
|
|
111
111
|
}) {
|
|
112
112
|
const webpackFormatted = _chalk.default.cyan(`webpack ${webpackVersion}`);
|
|
113
113
|
|
|
114
|
-
return (0, _tsDedent.
|
|
114
|
+
return (0, _tsDedent.dedent)`
|
|
115
115
|
We've detected you're running ${webpackFormatted}.
|
|
116
116
|
Your Storybook's main.js files specifies webpack4, which is incompatible.
|
|
117
117
|
|
|
@@ -130,7 +130,7 @@ const webpack5 = {
|
|
|
130
130
|
packageManager,
|
|
131
131
|
dryRun
|
|
132
132
|
}) {
|
|
133
|
-
const deps = [`@storybook/
|
|
133
|
+
const deps = [`@storybook/builder-webpack5@${storybookVersion}`]; // this also gets called by 'cra5' fix so we need to add
|
|
134
134
|
// webpack5 at the project root so that it gets hoisted
|
|
135
135
|
|
|
136
136
|
if (!webpackVersion) {
|
|
@@ -34,9 +34,15 @@ const automigrate = async ({
|
|
|
34
34
|
|
|
35
35
|
for (let i = 0; i < filtered.length; i += 1) {
|
|
36
36
|
const f = _fixes.fixes[i];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
let result;
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
result = await f.check({
|
|
41
|
+
packageManager
|
|
42
|
+
});
|
|
43
|
+
} catch (e) {
|
|
44
|
+
logger.info(`failed to check fix: ${f.id}`);
|
|
45
|
+
}
|
|
40
46
|
|
|
41
47
|
if (result) {
|
|
42
48
|
logger.info(`🔎 found a '${_chalk.default.cyan(f.id)}' migration:`);
|
package/dist/cjs/babel-config.js
CHANGED
|
@@ -11,8 +11,6 @@ var _fsExtra = require("fs-extra");
|
|
|
11
11
|
|
|
12
12
|
var _nodeLogger = require("@storybook/node-logger");
|
|
13
13
|
|
|
14
|
-
var _coreCommon = require("@storybook/core-common");
|
|
15
|
-
|
|
16
14
|
var _path = _interopRequireDefault(require("path"));
|
|
17
15
|
|
|
18
16
|
var _prompts = _interopRequireDefault(require("prompts"));
|
|
@@ -33,8 +31,11 @@ const generateStorybookBabelConfig = async ({
|
|
|
33
31
|
}) => {
|
|
34
32
|
_nodeLogger.logger.info(`Generating the storybook default babel config at ${target}`);
|
|
35
33
|
|
|
36
|
-
const
|
|
37
|
-
|
|
34
|
+
const contents = JSON.stringify({
|
|
35
|
+
sourceType: 'unambiguous',
|
|
36
|
+
presets: [],
|
|
37
|
+
plugins: []
|
|
38
|
+
}, null, 2);
|
|
38
39
|
const fileName = '.babelrc.json';
|
|
39
40
|
|
|
40
41
|
const location = _path.default.join(target, fileName);
|
package/dist/cjs/dev.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.dev = void 0;
|
|
|
7
7
|
|
|
8
8
|
require("core-js/modules/es.promise.js");
|
|
9
9
|
|
|
10
|
-
var _tsDedent =
|
|
10
|
+
var _tsDedent = require("ts-dedent");
|
|
11
11
|
|
|
12
12
|
var _readPkgUp = require("read-pkg-up");
|
|
13
13
|
|
|
@@ -17,8 +17,6 @@ var _coreServer = require("@storybook/core-server");
|
|
|
17
17
|
|
|
18
18
|
var _coreCommon = require("@storybook/core-common");
|
|
19
19
|
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
20
|
const dev = async cliOptions => {
|
|
23
21
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
24
22
|
|
|
@@ -53,10 +51,10 @@ const dev = async cliOptions => {
|
|
|
53
51
|
|
|
54
52
|
_nodeLogger.logger.line();
|
|
55
53
|
|
|
56
|
-
_nodeLogger.logger.warn(error.close ? (0, _tsDedent.
|
|
54
|
+
_nodeLogger.logger.warn(error.close ? (0, _tsDedent.dedent)`
|
|
57
55
|
FATAL broken build!, will close the process,
|
|
58
56
|
Fix the error below and restart storybook.
|
|
59
|
-
` : (0, _tsDedent.
|
|
57
|
+
` : (0, _tsDedent.dedent)`
|
|
60
58
|
Broken build, fix the error above.
|
|
61
59
|
You may need to refresh the browser.
|
|
62
60
|
`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// also exported from '@storybook/angular' if you can deal with breaking changes in 6.1
|
|
2
|
-
import {
|
|
2
|
+
import type { Meta, StoryFn } from '@storybook/angular';
|
|
3
3
|
import Button from './button.component';
|
|
4
4
|
|
|
5
5
|
// More on default export: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export
|
|
@@ -13,9 +13,11 @@ export default {
|
|
|
13
13
|
} as Meta;
|
|
14
14
|
|
|
15
15
|
// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
|
|
16
|
-
const Template:
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
const Template: StoryFn<Button> = (args: Button) => {
|
|
17
|
+
return {
|
|
18
|
+
props: { backgroundColor: null, ...args },
|
|
19
|
+
};
|
|
20
|
+
};
|
|
19
21
|
|
|
20
22
|
export const Primary = Template.bind({});
|
|
21
23
|
// More on args: https://storybook.js.org/docs/angular/writing-stories/args
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { moduleMetadata } from '@storybook/angular';
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Meta, StoryFn } from '@storybook/angular';
|
|
4
4
|
|
|
5
5
|
import Button from './button.component';
|
|
6
6
|
import Header from './header.component';
|
|
@@ -20,7 +20,7 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
} as Meta;
|
|
22
22
|
|
|
23
|
-
const Template:
|
|
23
|
+
const Template: StoryFn<Header> = (args: Header) => ({
|
|
24
24
|
props: args,
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { moduleMetadata,
|
|
1
|
+
import { moduleMetadata, StoryFn, Meta } from '@storybook/angular';
|
|
2
2
|
import { within, userEvent } from '@storybook/testing-library';
|
|
3
3
|
import { CommonModule } from '@angular/common';
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
title: 'Example/Page',
|
|
11
11
|
component: Page,
|
|
12
12
|
parameters: {
|
|
13
|
-
// More on
|
|
13
|
+
// More on StoryFn layout: https://storybook.js.org/docs/angular/configure/story-layout
|
|
14
14
|
layout: 'fullscreen',
|
|
15
15
|
},
|
|
16
16
|
decorators: [
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
],
|
|
22
22
|
} as Meta;
|
|
23
23
|
|
|
24
|
-
const Template:
|
|
24
|
+
const Template: StoryFn<Page> = (args: Page) => ({
|
|
25
25
|
props: args,
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/html';
|
|
2
2
|
import { createButton, ButtonProps } from './Button';
|
|
3
3
|
|
|
4
4
|
// More on default export: https://storybook.js.org/docs/html/writing-stories/introduction#default-export
|
|
@@ -15,10 +15,10 @@ export default {
|
|
|
15
15
|
options: ['small', 'medium', 'large'],
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
|
-
} as Meta
|
|
18
|
+
} as Meta<ButtonProps>;
|
|
19
19
|
|
|
20
20
|
// More on component templates: https://storybook.js.org/docs/html/writing-stories/introduction#using-args
|
|
21
|
-
const Template:
|
|
21
|
+
const Template: StoryFn<ButtonProps> = (args) => {
|
|
22
22
|
// You can either use a function to create DOM elements or use a plain html string!
|
|
23
23
|
// return `<div>${label}</div>`;
|
|
24
24
|
return createButton(args);
|
|
@@ -36,12 +36,16 @@ export const createButton = ({
|
|
|
36
36
|
const btn = document.createElement('button');
|
|
37
37
|
btn.type = 'button';
|
|
38
38
|
btn.innerText = label;
|
|
39
|
-
|
|
39
|
+
if (onClick) {
|
|
40
|
+
btn.addEventListener('click', onClick);
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
42
44
|
btn.className = ['storybook-button', `storybook-button--${size}`, mode].join(' ');
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
if (backgroundColor) {
|
|
47
|
+
btn.style.backgroundColor = backgroundColor;
|
|
48
|
+
}
|
|
45
49
|
|
|
46
50
|
return btn;
|
|
47
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/html';
|
|
2
2
|
import { createHeader, HeaderProps } from './Header';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
@@ -13,9 +13,9 @@ export default {
|
|
|
13
13
|
onLogout: { action: 'onLogout' },
|
|
14
14
|
onCreateAccount: { action: 'onCreateAccount' },
|
|
15
15
|
},
|
|
16
|
-
} as Meta
|
|
16
|
+
} as Meta<HeaderProps>;
|
|
17
17
|
|
|
18
|
-
const Template:
|
|
18
|
+
const Template: StoryFn<HeaderProps> = (args) => createHeader(args);
|
|
19
19
|
|
|
20
20
|
export const LoggedIn = Template.bind({});
|
|
21
21
|
LoggedIn.args = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { within, userEvent } from '@storybook/testing-library';
|
|
2
|
-
import {
|
|
2
|
+
import type { Meta, StoryFn } from '@storybook/html';
|
|
3
3
|
import { createPage } from './Page';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
@@ -10,7 +10,7 @@ export default {
|
|
|
10
10
|
},
|
|
11
11
|
} as Meta;
|
|
12
12
|
|
|
13
|
-
const Template:
|
|
13
|
+
const Template: StoryFn = () => createPage();
|
|
14
14
|
|
|
15
15
|
export const LoggedOut = Template.bind({});
|
|
16
16
|
|
|
@@ -7,12 +7,12 @@ type User = {
|
|
|
7
7
|
|
|
8
8
|
export const createPage = () => {
|
|
9
9
|
const article = document.createElement('article');
|
|
10
|
-
let user: User
|
|
11
|
-
let header = null;
|
|
10
|
+
let user: User | undefined;
|
|
11
|
+
let header: HTMLElement | null = null;
|
|
12
12
|
|
|
13
13
|
const rerenderHeader = () => {
|
|
14
14
|
const wrapper = document.getElementsByTagName('article')[0];
|
|
15
|
-
wrapper.replaceChild(createHeaderElement(), wrapper.firstChild);
|
|
15
|
+
wrapper.replaceChild(createHeaderElement(), wrapper.firstChild as HTMLElement);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const onLogin = () => {
|
|
@@ -21,7 +21,7 @@ export const createPage = () => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const onLogout = () => {
|
|
24
|
-
user =
|
|
24
|
+
user = undefined;
|
|
25
25
|
rerenderHeader();
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react';
|
|
3
3
|
|
|
4
4
|
import { Button } from './Button';
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
} as ComponentMeta<typeof Button>;
|
|
15
15
|
|
|
16
16
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
17
|
-
const Template:
|
|
17
|
+
const Template: ComponentStoryFn<typeof Button> = (args) => <Button {...args} />;
|
|
18
18
|
|
|
19
19
|
export const Primary = Template.bind({});
|
|
20
20
|
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react';
|
|
3
3
|
|
|
4
4
|
import { Header } from './Header';
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
},
|
|
13
13
|
} as ComponentMeta<typeof Header>;
|
|
14
14
|
|
|
15
|
-
const Template:
|
|
15
|
+
const Template: ComponentStoryFn<typeof Header> = (args) => <Header {...args} />;
|
|
16
16
|
|
|
17
17
|
export const LoggedIn = Template.bind({});
|
|
18
18
|
LoggedIn.args = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ComponentStoryFn, ComponentMeta } from '@storybook/react';
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { Page } from './Page';
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
},
|
|
13
13
|
} as ComponentMeta<typeof Page>;
|
|
14
14
|
|
|
15
|
-
const Template:
|
|
15
|
+
const Template: ComponentStoryFn<typeof Page> = (args) => <Page {...args} />;
|
|
16
16
|
|
|
17
17
|
export const LoggedOut = Template.bind({});
|
|
18
18
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/web-components';
|
|
2
2
|
import { Button, ButtonProps } from './Button';
|
|
3
3
|
|
|
4
4
|
// More on default export: https://storybook.js.org/docs/web-components/writing-stories/introduction#default-export
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
} as Meta;
|
|
17
17
|
|
|
18
18
|
// More on component templates: https://storybook.js.org/docs/web-components/writing-stories/introduction#using-args
|
|
19
|
-
const Template:
|
|
19
|
+
const Template: StoryFn<ButtonProps> = (args) => Button(args);
|
|
20
20
|
|
|
21
21
|
export const Primary = Template.bind({});
|
|
22
22
|
// More on args: https://storybook.js.org/docs/web-components/writing-stories/args
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/web-components';
|
|
2
2
|
import { Header, HeaderProps } from './Header';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
title: 'Example/Header',
|
|
6
6
|
} as Meta;
|
|
7
7
|
|
|
8
|
-
const Template:
|
|
8
|
+
const Template: StoryFn<HeaderProps> = (args) => Header(args);
|
|
9
9
|
|
|
10
10
|
export const LoggedIn = Template.bind({});
|
|
11
11
|
LoggedIn.args = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Meta, StoryFn } from '@storybook/web-components';
|
|
2
2
|
import { Page, PageProps } from './Page';
|
|
3
3
|
import * as HeaderStories from './Header.stories';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
title: 'Example/Page',
|
|
7
7
|
} as Meta;
|
|
8
8
|
|
|
9
|
-
const Template:
|
|
9
|
+
const Template: StoryFn<PageProps> = (args) => Page(args);
|
|
10
10
|
|
|
11
11
|
export const LoggedIn = Template.bind({});
|
|
12
12
|
LoggedIn.args = {
|
package/dist/cjs/generate.js
CHANGED
|
@@ -52,7 +52,7 @@ process.env.STORYBOOK_DISABLE_TELEMETRY && process.env.STORYBOOK_DISABLE_TELEMET
|
|
|
52
52
|
|
|
53
53
|
_commander.default.option('--enable-crash-reports', 'enable sending crash reports to telemetry data');
|
|
54
54
|
|
|
55
|
-
_commander.default.command('init').description('Initialize Storybook into your project.').option('-f --force', 'Force add Storybook').option('-s --skip-install', 'Skip installing deps').option('-N --use-npm', 'Use npm to install deps').option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser').option('-t --type <type>', 'Add Storybook for a specific project type').option('-y --yes', 'Answer yes to all prompts').option('-b --builder <builder>', 'Builder library').option('-l --linkable', 'Prepare installation for link (contributor helper)').action(options => (0, _initiate.initiate)(options, pkg));
|
|
55
|
+
_commander.default.command('init').description('Initialize Storybook into your project.').option('-f --force', 'Force add Storybook').option('-s --skip-install', 'Skip installing deps').option('-N --use-npm', 'Use npm to install deps').option('--use-pnp', 'Enable pnp mode').option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser').option('-t --type <type>', 'Add Storybook for a specific project type').option('-y --yes', 'Answer yes to all prompts').option('-b --builder <builder>', 'Builder library').option('-l --linkable', 'Prepare installation for link (contributor helper)').action(options => (0, _initiate.initiate)(options, pkg));
|
|
56
56
|
|
|
57
57
|
_commander.default.command('add <addon>').description('Add an addon to your Storybook').option('-N --use-npm', 'Use NPM to build the Storybook server').option('-s --skip-postinstall', 'Skip package specific postinstall config modifications').action((addonName, options) => (0, _add.add)(addonName, options));
|
|
58
58
|
|
|
@@ -57,7 +57,30 @@ const generator = async (packageManager, npmOptions, options) => {
|
|
|
57
57
|
addScripts: false
|
|
58
58
|
});
|
|
59
59
|
(0, _helpers.copyTemplate)(__dirname);
|
|
60
|
-
editAngularAppTsConfig();
|
|
60
|
+
editAngularAppTsConfig(); // TODO: we need to add the following:
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
"storybook": {
|
|
64
|
+
"builder": "@storybook/angular:start-storybook",
|
|
65
|
+
"options": {
|
|
66
|
+
"browserTarget": "angular-cli:build",
|
|
67
|
+
"port": 4400
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"build-storybook": {
|
|
71
|
+
"builder": "@storybook/angular:build-storybook",
|
|
72
|
+
"options": {
|
|
73
|
+
"browserTarget": "angular-cli:build"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
*/
|
|
77
|
+
// to the user's angular.json file. see: https://github.com/storybookjs/storybook/blob/next/examples/angular-cli/angular.json#L78
|
|
78
|
+
// then we want to add these scripts to package.json
|
|
79
|
+
// packageManager.addScripts({
|
|
80
|
+
// storybook: 'ng storybook',
|
|
81
|
+
// 'build-storybook': 'ng build-storybook',
|
|
82
|
+
// });
|
|
83
|
+
|
|
61
84
|
(0, _angularHelpers.editStorybookTsConfig)(_path.default.resolve('./.storybook/tsconfig.json')); // edit scripts to generate docs
|
|
62
85
|
|
|
63
86
|
const tsConfigFile = await (0, _angularHelpers.getBaseTsConfigName)();
|
|
@@ -30,10 +30,10 @@ const generator = async (packageManager, npmOptions, options) => {
|
|
|
30
30
|
config.resolve.plugins.forEach((p) => {
|
|
31
31
|
if (Array.isArray(p.appSrcs)) {
|
|
32
32
|
p.appSrcs.push('${monorepoRootPath}');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return config;
|
|
36
|
+
}
|
|
37
37
|
%%`
|
|
38
38
|
} : {};
|
|
39
39
|
const craVersion = (_semver$coerce = _semver.default.coerce(packageManager.retrievePackageJson().dependencies['react-scripts'])) === null || _semver$coerce === void 0 ? void 0 : _semver$coerce.version;
|