@storybook/cli 7.0.0-alpha.1 → 7.0.0-alpha.10
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/index.js +3 -1
- package/dist/cjs/automigrate/fixes/npm7.js +59 -0
- package/dist/cjs/automigrate/index.js +9 -3
- package/dist/cjs/babel-config.js +5 -4
- 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 +39 -37
- package/dist/cjs/generators/configure.js +16 -18
- 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 +2 -2
- 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/versions.js +75 -73
- package/dist/esm/automigrate/fixes/index.js +3 -1
- package/dist/esm/automigrate/fixes/npm7.js +59 -0
- package/dist/esm/automigrate/index.js +9 -3
- package/dist/esm/babel-config.js +5 -4
- 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 +39 -37
- package/dist/esm/generators/configure.js +16 -18
- 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 +2 -2
- 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/versions.js +75 -73
- 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 +2 -0
- package/package.json +9 -9
|
@@ -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;
|
|
@@ -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 = _interopRequireDefault(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.default)`
|
|
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;
|
|
@@ -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);
|
|
@@ -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;
|
|
@@ -16,25 +16,21 @@ var _baseGenerator = require("../baseGenerator");
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
18
|
const generator = async (packageManager, npmOptions, options) => {
|
|
19
|
-
let
|
|
19
|
+
let svelteOptions;
|
|
20
20
|
let commonJs = false; // svelte.config.js ?
|
|
21
21
|
|
|
22
22
|
if (_fsExtra.default.existsSync('./svelte.config.js')) {
|
|
23
23
|
_nodeLogger.logger.info("Configuring preprocessor from 'svelte.config.js'");
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
preprocess: '%%require("../svelte.config.js").preprocess%%'
|
|
28
|
-
}
|
|
25
|
+
svelteOptions = {
|
|
26
|
+
preprocess: '%%require("../svelte.config.js").preprocess%%'
|
|
29
27
|
};
|
|
30
28
|
} else if (_fsExtra.default.existsSync('./svelte.config.cjs')) {
|
|
31
29
|
_nodeLogger.logger.info("Configuring preprocessor from 'svelte.config.cjs'");
|
|
32
30
|
|
|
33
31
|
commonJs = true;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
preprocess: '%%require("../svelte.config.cjs").preprocess%%'
|
|
37
|
-
}
|
|
32
|
+
svelteOptions = {
|
|
33
|
+
preprocess: '%%require("../svelte.config.cjs").preprocess%%'
|
|
38
34
|
};
|
|
39
35
|
} else {
|
|
40
36
|
// svelte-preprocess dependencies ?
|
|
@@ -43,10 +39,8 @@ const generator = async (packageManager, npmOptions, options) => {
|
|
|
43
39
|
if (packageJson.devDependencies && packageJson.devDependencies['svelte-preprocess']) {
|
|
44
40
|
_nodeLogger.logger.info("Configuring preprocessor with 'svelte-preprocess'");
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
preprocess: '%%require("svelte-preprocess")()%%'
|
|
49
|
-
}
|
|
42
|
+
svelteOptions = {
|
|
43
|
+
preprocess: '%%require("svelte-preprocess")()%%'
|
|
50
44
|
};
|
|
51
45
|
}
|
|
52
46
|
}
|
|
@@ -54,7 +48,7 @@ const generator = async (packageManager, npmOptions, options) => {
|
|
|
54
48
|
await (0, _baseGenerator.baseGenerator)(packageManager, npmOptions, options, 'svelte', {
|
|
55
49
|
extraPackages: ['svelte', 'svelte-loader'],
|
|
56
50
|
extensions: ['js', 'jsx', 'ts', 'tsx', 'svelte'],
|
|
57
|
-
|
|
51
|
+
framework: svelteOptions,
|
|
58
52
|
commonJs
|
|
59
53
|
});
|
|
60
54
|
};
|
|
@@ -34,6 +34,7 @@ const defaultOptions = {
|
|
|
34
34
|
addBabel: true,
|
|
35
35
|
addESLint: false,
|
|
36
36
|
extraMain: undefined,
|
|
37
|
+
framework: undefined,
|
|
37
38
|
extensions: undefined,
|
|
38
39
|
commonJs: false
|
|
39
40
|
};
|
|
@@ -54,33 +55,39 @@ const getBuilderDetails = builder => {
|
|
|
54
55
|
return builder;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
const
|
|
58
|
+
const wrapForPnp = packageName => `%%path.dirname(require.resolve(path.join('${packageName}', 'package.json')))%%`;
|
|
59
|
+
|
|
60
|
+
const getFrameworkDetails = (renderer, builder, pnp) => {
|
|
58
61
|
const frameworkPackage = `@storybook/${renderer}-${builder}`;
|
|
62
|
+
const frameworkPackagePath = pnp ? wrapForPnp(frameworkPackage) : frameworkPackage;
|
|
59
63
|
const rendererPackage = `@storybook/${renderer}`;
|
|
64
|
+
const rendererPackagePath = pnp ? wrapForPnp(rendererPackage) : rendererPackage;
|
|
65
|
+
const builderPackage = getBuilderDetails(builder);
|
|
66
|
+
const builderPackagePath = pnp ? wrapForPnp(builderPackage) : builderPackage;
|
|
60
67
|
const isKnownFramework = !!_versions.default[frameworkPackage];
|
|
61
68
|
const isKnownRenderer = !!_versions.default[rendererPackage];
|
|
62
|
-
const builderPackage = getBuilderDetails(builder);
|
|
63
69
|
|
|
64
70
|
if (renderer === 'angular') {
|
|
65
71
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
packages: [rendererPackage],
|
|
73
|
+
framework: rendererPackagePath,
|
|
68
74
|
type: 'framework'
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
if (isKnownFramework) {
|
|
73
79
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
packages: [frameworkPackage],
|
|
81
|
+
framework: frameworkPackagePath,
|
|
76
82
|
type: 'framework'
|
|
77
83
|
};
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
if (isKnownRenderer) {
|
|
81
87
|
return {
|
|
82
|
-
|
|
83
|
-
builder:
|
|
88
|
+
packages: [rendererPackage, builderPackage],
|
|
89
|
+
builder: builderPackagePath,
|
|
90
|
+
renderer: rendererPackagePath,
|
|
84
91
|
type: 'renderer'
|
|
85
92
|
};
|
|
86
93
|
}
|
|
@@ -94,7 +101,8 @@ const hasInteractiveStories = framework => ['react', 'angular', 'preact', 'svelt
|
|
|
94
101
|
|
|
95
102
|
async function baseGenerator(packageManager, npmOptions, {
|
|
96
103
|
language,
|
|
97
|
-
builder = _project_types.CoreBuilder.Webpack5
|
|
104
|
+
builder = _project_types.CoreBuilder.Webpack5,
|
|
105
|
+
pnp
|
|
98
106
|
}, renderer, options = defaultOptions) {
|
|
99
107
|
const {
|
|
100
108
|
extraAddons: extraAddonPackages,
|
|
@@ -109,9 +117,9 @@ async function baseGenerator(packageManager, npmOptions, {
|
|
|
109
117
|
} = Object.assign({}, defaultOptions, options); // added to main.js
|
|
110
118
|
// make sure to update `canUsePrebuiltManager` in dev-server.js and build-manager-config/main.js when this list changes
|
|
111
119
|
|
|
112
|
-
const addons = ['@storybook/addon-links', '@storybook/addon-essentials']; // added to package.json
|
|
120
|
+
const addons = ['@storybook/addon-links', '@storybook/addon-essentials', ...stripVersions(extraAddonPackages)]; // added to package.json
|
|
113
121
|
|
|
114
|
-
const addonPackages = [
|
|
122
|
+
const addonPackages = ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-actions', ...extraAddonPackages];
|
|
115
123
|
|
|
116
124
|
if (hasInteractiveStories(renderer)) {
|
|
117
125
|
addons.push('@storybook/addon-interactions');
|
|
@@ -123,20 +131,16 @@ async function baseGenerator(packageManager, npmOptions, {
|
|
|
123
131
|
const packageJson = packageManager.retrievePackageJson();
|
|
124
132
|
const installedDependencies = new Set(Object.keys(Object.assign({}, packageJson.dependencies, packageJson.devDependencies)));
|
|
125
133
|
const {
|
|
126
|
-
|
|
134
|
+
packages: frameworkPackages,
|
|
127
135
|
type,
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
renderer: rendererInclude,
|
|
138
|
+
// deepscan-disable-line UNUSED_DECL
|
|
139
|
+
framework: frameworkInclude,
|
|
140
|
+
builder: builderInclude
|
|
141
|
+
} = getFrameworkDetails(renderer, builder, pnp); // TODO: We need to start supporting this at some point
|
|
130
142
|
|
|
131
143
|
if (type === 'renderer') {
|
|
132
|
-
console.log({
|
|
133
|
-
language,
|
|
134
|
-
builder,
|
|
135
|
-
renderer,
|
|
136
|
-
builderPackage,
|
|
137
|
-
frameworkPackage,
|
|
138
|
-
type
|
|
139
|
-
});
|
|
140
144
|
throw new Error((0, _tsDedent.default)`
|
|
141
145
|
Sorry, for now, you can not do this, please use a framework such as @storybook/react-webpack5
|
|
142
146
|
|
|
@@ -144,32 +148,30 @@ async function baseGenerator(packageManager, npmOptions, {
|
|
|
144
148
|
`);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
const packages = ['
|
|
151
|
+
const packages = ['storybook', ...frameworkPackages, ...addonPackages, ...extraPackages, ...yarn2ExtraPackages].filter(Boolean).filter(packageToInstall => !installedDependencies.has((0, _jsPackageManager.getPackageDetails)(packageToInstall)[0]));
|
|
148
152
|
const versionedPackages = await packageManager.getVersionedPackages(packages);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
const mainOptions = type !== 'framework' ? Object.assign({
|
|
153
|
-
core: {
|
|
154
|
-
builder: builderPackage
|
|
155
|
-
}
|
|
156
|
-
}, extraMain) : extraMain;
|
|
157
|
-
(0, _configure.configure)(renderer, Object.assign({
|
|
153
|
+
await _fsExtra.default.ensureDir('./.storybook');
|
|
154
|
+
await (0, _configure.configureMain)(Object.assign({
|
|
158
155
|
framework: {
|
|
159
|
-
name:
|
|
160
|
-
options: {}
|
|
156
|
+
name: frameworkInclude,
|
|
157
|
+
options: options.framework || {}
|
|
161
158
|
},
|
|
162
|
-
addons:
|
|
159
|
+
addons: pnp ? addons.map(wrapForPnp) : addons,
|
|
163
160
|
extensions,
|
|
164
161
|
commonJs: options.commonJs
|
|
165
|
-
},
|
|
162
|
+
}, extraMain, type !== 'framework' ? {
|
|
163
|
+
core: {
|
|
164
|
+
builder: builderInclude
|
|
165
|
+
}
|
|
166
|
+
} : {}));
|
|
167
|
+
await (0, _configure.configurePreview)(renderer, options.commonJs);
|
|
166
168
|
|
|
167
169
|
if (addComponents) {
|
|
168
170
|
(0, _helpers.copyComponents)(renderer, language);
|
|
169
171
|
} // FIXME: temporary workaround for https://github.com/storybookjs/storybook/issues/17516
|
|
170
172
|
|
|
171
173
|
|
|
172
|
-
if (
|
|
174
|
+
if (frameworkPackages.includes('@storybook/builder-vite')) {
|
|
173
175
|
const previewHead = (0, _tsDedent.default)`
|
|
174
176
|
<script>
|
|
175
177
|
window.global = window;
|