@storybook/codemod 0.0.0-pr-23609-sha-f47ef339
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/README.md +262 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/transforms/add-component-parameters.d.ts +22 -0
- package/dist/transforms/add-component-parameters.js +1 -0
- package/dist/transforms/csf-2-to-3.d.ts +8 -0
- package/dist/transforms/csf-2-to-3.js +3 -0
- package/dist/transforms/csf-hoist-story-annotations.d.ts +26 -0
- package/dist/transforms/csf-hoist-story-annotations.js +1 -0
- package/dist/transforms/mdx-to-csf.d.ts +7 -0
- package/dist/transforms/mdx-to-csf.js +61 -0
- package/dist/transforms/move-builtin-addons.d.ts +3 -0
- package/dist/transforms/move-builtin-addons.js +1 -0
- package/dist/transforms/storiesof-to-csf.d.ts +24 -0
- package/dist/transforms/storiesof-to-csf.js +1 -0
- package/dist/transforms/update-addon-info.d.ts +27 -0
- package/dist/transforms/update-addon-info.js +1 -0
- package/dist/transforms/update-organisation-name.d.ts +25 -0
- package/dist/transforms/update-organisation-name.js +1 -0
- package/dist/transforms/upgrade-deprecated-types.d.ts +10 -0
- package/dist/transforms/upgrade-deprecated-types.js +2 -0
- package/dist/transforms/upgrade-hierarchy-separators.d.ts +3 -0
- package/dist/transforms/upgrade-hierarchy-separators.js +1 -0
- package/jest.config.js +9 -0
- package/package.json +102 -0
- package/project.json +6 -0
- package/src/index.ts +103 -0
- package/src/lib/utils.test.js +9 -0
- package/src/lib/utils.ts +29 -0
- package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.input.js +44 -0
- package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.output.snapshot +68 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.input.js +25 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.output.snapshot +27 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.input.js +25 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.output.snapshot +28 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.input.js +13 -0
- package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.output.snapshot +17 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/basic.input.mdx +18 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/basic.output.snapshot +40 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/component-id.input.mdx +6 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/component-id.output.snapshot +17 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/decorators.input.mdx +8 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/decorators.output.snapshot +18 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.input.mdx +19 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.output.snapshot +39 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/parameters.input.mdx +14 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/parameters.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.input.mdx +3 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.output.snapshot +11 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-function.input.mdx +10 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-function.output.snapshot +18 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.input.mdx +18 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.output.snapshot +32 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.input.mdx +22 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.output.snapshot +34 -0
- package/src/transforms/__testfixtures__/move-builtin-addons/default.input.js +2 -0
- package/src/transforms/__testfixtures__/move-builtin-addons/default.output.snapshot +8 -0
- package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.input.js +3 -0
- package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.output.snapshot +7 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/basic.input.js +18 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/basic.output.snapshot +45 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/collision.input.js +11 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/collision.output.snapshot +38 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/const.input.js +1 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/const.output.snapshot +13 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.input.js +9 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.output.snapshot +18 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/default.input.js +7 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/default.output.snapshot +17 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/digit.input.js +1 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.js +5 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.snapshot +9 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.input.js +11 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.input.js +12 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.input.js +14 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.output.snapshot +26 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/exports.input.js +2 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/exports.output.snapshot +16 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/module.input.js +12 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/module.output.snapshot +16 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/multi.input.js +14 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/multi.output.snapshot +39 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.input.js +8 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.output.snapshot +20 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.input.js +10 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.input.js +11 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.input.js +11 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.output.snapshot +29 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.input.js +14 -0
- package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.output.snapshot +32 -0
- package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.input.js +184 -0
- package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.output.snapshot +184 -0
- package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js +19 -0
- package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.output.snapshot +23 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.input.js +3 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.output.snapshot +7 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.input.js +5 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.output.snapshot +9 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.input.js +8 -0
- package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot +12 -0
- package/src/transforms/__tests__/csf-2-to-3.test.ts +439 -0
- package/src/transforms/__tests__/mdx-to-csf.test.ts +628 -0
- package/src/transforms/__tests__/transforms.tests.js +32 -0
- package/src/transforms/__tests__/upgrade-deprecated-types.test.ts +170 -0
- package/src/transforms/add-component-parameters.js +62 -0
- package/src/transforms/csf-2-to-3.ts +336 -0
- package/src/transforms/csf-hoist-story-annotations.js +97 -0
- package/src/transforms/mdx-to-csf.ts +340 -0
- package/src/transforms/move-builtin-addons.js +32 -0
- package/src/transforms/storiesof-to-csf.js +277 -0
- package/src/transforms/update-addon-info.js +114 -0
- package/src/transforms/update-organisation-name.js +71 -0
- package/src/transforms/upgrade-deprecated-types.ts +142 -0
- package/src/transforms/upgrade-hierarchy-separators.js +39 -0
- package/tsconfig.json +10 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`update-addon-info transforms correctly using "update-addon-info.input.js" data 1`] = `
|
4
|
+
"/* eslint-disable */
|
5
|
+
import React from 'react';
|
6
|
+
import Button from './Button';
|
7
|
+
|
8
|
+
import { storiesOf } from '@storybook/react';
|
9
|
+
import { action } from '@storybook/addon-actions';
|
10
|
+
|
11
|
+
import { withInfo } from \\"@storybook/addon-info\\";
|
12
|
+
|
13
|
+
storiesOf('Button').add('simple usage', withInfo(
|
14
|
+
'This is the basic usage with the button with providing a label to show the text.'
|
15
|
+
)(() => (
|
16
|
+
<div>
|
17
|
+
<Button label=\\"The Button\\" onClick={action('onClick')} />
|
18
|
+
<br />
|
19
|
+
<p>Click the \\"?\\" mark at top-right to view the info.</p>
|
20
|
+
</div>
|
21
|
+
)));
|
22
|
+
|
23
|
+
storiesOf('Button').add('simple usage (inline info)', withInfo({
|
24
|
+
text: \`
|
25
|
+
This is the basic usage with the button with providing a label to show the text.
|
26
|
+
\`,
|
27
|
+
|
28
|
+
inline: true
|
29
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
30
|
+
|
31
|
+
storiesOf('Button').add('simple usage (disable source)', withInfo({
|
32
|
+
text: \`
|
33
|
+
This is the basic usage with the button with providing a label to show the text.
|
34
|
+
\`,
|
35
|
+
|
36
|
+
source: false,
|
37
|
+
inline: true
|
38
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
39
|
+
|
40
|
+
storiesOf('Button').add('simple usage (no header)', withInfo({
|
41
|
+
text: \`
|
42
|
+
This is the basic usage with the button with providing a label to show the text.
|
43
|
+
\`,
|
44
|
+
|
45
|
+
header: false,
|
46
|
+
inline: true
|
47
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
48
|
+
|
49
|
+
storiesOf('Button').add('simple usage (no prop tables)', withInfo({
|
50
|
+
text: \`
|
51
|
+
This is the basic usage with the button with providing a label to show the text.
|
52
|
+
\`,
|
53
|
+
|
54
|
+
propTables: false,
|
55
|
+
inline: true
|
56
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
57
|
+
|
58
|
+
storiesOf('Button').add('simple usage (custom propTables)', withInfo({
|
59
|
+
text: \`
|
60
|
+
This is the basic usage with the button with providing a label to show the text.
|
61
|
+
Since, the story source code is wrapped inside a div, info addon can't figure out propTypes on it's own.
|
62
|
+
So, we need to give relevant React component classes manually using \\\\\`propTypes\\\\\` option as shown below:
|
63
|
+
~~~js
|
64
|
+
storiesOf('Button')
|
65
|
+
.addWithInfo(
|
66
|
+
'simple usage (custom propTables)',
|
67
|
+
<info>,
|
68
|
+
<storyFn>,
|
69
|
+
{ inline: true, propTables: [Button]}
|
70
|
+
);
|
71
|
+
~~~
|
72
|
+
\`,
|
73
|
+
|
74
|
+
inline: true,
|
75
|
+
propTables: [Button]
|
76
|
+
})(() => (
|
77
|
+
<div>
|
78
|
+
<Button label=\\"The Button\\" onClick={action('onClick')} />
|
79
|
+
<br />
|
80
|
+
</div>
|
81
|
+
)));
|
82
|
+
|
83
|
+
storiesOf('Button').add('simple usage (JSX description)', withInfo(<div>
|
84
|
+
<h2>This is a JSX info section</h2>
|
85
|
+
<p>
|
86
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ornare massa rutrum metus
|
87
|
+
commodo, a mattis velit dignissim. Fusce vestibulum turpis sed massa egestas pharetra. Sed at
|
88
|
+
libero nulla.
|
89
|
+
</p>
|
90
|
+
<p>
|
91
|
+
<a href=\\"https://github.com/storybookjs/react-storybook-addon-info\\">This is a link</a>
|
92
|
+
</p>
|
93
|
+
<p>
|
94
|
+
<img src=\\"https://storybook.js.org/images/placeholders/350x150.png\\" />
|
95
|
+
</p>
|
96
|
+
</div>)(() => (
|
97
|
+
<div>
|
98
|
+
<Button label=\\"The Button\\" onClick={action('onClick')} />
|
99
|
+
<br />
|
100
|
+
<p>Click the \\"?\\" mark at top-right to view the info.</p>
|
101
|
+
</div>
|
102
|
+
)));
|
103
|
+
|
104
|
+
storiesOf('Button').add('simple usage (inline JSX description)', withInfo({
|
105
|
+
text: <div>
|
106
|
+
<h2>This is a JSX info section</h2>
|
107
|
+
<p>
|
108
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ornare massa rutrum metus
|
109
|
+
commodo, a mattis velit dignissim. Fusce vestibulum turpis sed massa egestas pharetra. Sed at
|
110
|
+
libero nulla.
|
111
|
+
</p>
|
112
|
+
<p>
|
113
|
+
<a href=\\"https://github.com/storybookjs/react-storybook-addon-info\\">This is a link</a>
|
114
|
+
</p>
|
115
|
+
<p>
|
116
|
+
<img src=\\"https://storybook.js.org/images/placeholders/350x150.png\\" />
|
117
|
+
</p>
|
118
|
+
</div>,
|
119
|
+
|
120
|
+
inline: true
|
121
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
122
|
+
|
123
|
+
storiesOf('Button').add('simple usage (maxPropsInLine === 1)', withInfo({
|
124
|
+
text: \`
|
125
|
+
This is the basic usage with the button with providing a label to show the text.
|
126
|
+
\`,
|
127
|
+
|
128
|
+
inline: true,
|
129
|
+
maxPropsIntoLine: 1
|
130
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
131
|
+
|
132
|
+
storiesOf('Button').add('simple usage (maxPropObjectKeys === 5)', withInfo({
|
133
|
+
text: \`
|
134
|
+
This is the basic usage with the button with providing a label to show the text.
|
135
|
+
\`,
|
136
|
+
|
137
|
+
inline: true,
|
138
|
+
maxPropObjectKeys: 5
|
139
|
+
})(
|
140
|
+
() => <Button label=\\"The Button\\" object={{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }} />
|
141
|
+
));
|
142
|
+
|
143
|
+
storiesOf('Button').add('simple usage (maxPropArrayLength === 8)', withInfo({
|
144
|
+
text: \`
|
145
|
+
This is the basic usage with the button with providing a label to show the text.
|
146
|
+
\`,
|
147
|
+
|
148
|
+
inline: true,
|
149
|
+
maxPropArrayLength: 8
|
150
|
+
})(
|
151
|
+
() => <Button label=\\"The Button\\" array={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]} />
|
152
|
+
));
|
153
|
+
|
154
|
+
storiesOf('Button').add('simple usage (maxPropStringLength === 10)', withInfo({
|
155
|
+
text: \`
|
156
|
+
This is the basic usage with the button with providing a label to show the text.
|
157
|
+
\`,
|
158
|
+
|
159
|
+
inline: true,
|
160
|
+
maxPropStringLength: 5
|
161
|
+
})(() => <Button label=\\"The Button\\" string=\\"1 2 3 4 5 6 7 8\\" />));
|
162
|
+
|
163
|
+
storiesOf('Button').add('with custom styles', withInfo({
|
164
|
+
text: \`
|
165
|
+
This is an example of how to customize the styles of the info components.
|
166
|
+
For the full styles available, see \\\\\`./src/components/Story.js\\\\\`
|
167
|
+
\`,
|
168
|
+
|
169
|
+
inline: true,
|
170
|
+
|
171
|
+
styles: (stylesheet) => {
|
172
|
+
stylesheet.infoPage = {
|
173
|
+
backgroundColor: '#ccc',
|
174
|
+
};
|
175
|
+
return stylesheet;
|
176
|
+
}
|
177
|
+
})(() => <Button label=\\"The Button\\" onClick={action('onClick')} />));
|
178
|
+
|
179
|
+
storiesOf('shared/ProgressBar', module)
|
180
|
+
.addDecorator(withKnobs)
|
181
|
+
.add('default style', withInfo('default style')(() => (
|
182
|
+
<ProgressBar progress={number('progress', 25)} delay={number('delay', 500)} />
|
183
|
+
)));"
|
184
|
+
`;
|
package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
/* eslint-disable */
|
2
|
+
import '@kadira/storybook-addons';
|
3
|
+
import '@kadira/storybook-addon-comments';
|
4
|
+
import '@kadira/react-storybook-decorator-centered';
|
5
|
+
import '@kadira/storybook-addon-graphql';
|
6
|
+
import '@kadira/storybook-addon-info';
|
7
|
+
import '@kadira/storybook-addon-knobs';
|
8
|
+
import '@kadira/storybook-addon-links';
|
9
|
+
import '@kadira/storybook-addon-notes';
|
10
|
+
import '@kadira/storybook-addon-options';
|
11
|
+
import 'storyshots';
|
12
|
+
import '@kadira/storybook-channels';
|
13
|
+
import '@kadira/storybook-channel-postmsg';
|
14
|
+
import '@kadira/storybook-channel-websocket';
|
15
|
+
import '@kadira/getstorybook';
|
16
|
+
import '@kadira/react-storybook';
|
17
|
+
import '@kadira/react-native-storybook';
|
18
|
+
import '@kadira/storybook-ui';
|
19
|
+
import { storiesOf } from '@kadira/react-storybook';
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`update-organisation-name transforms correctly using "update-organisation-name.input.js" data 1`] = `
|
4
|
+
"/* eslint-disable */
|
5
|
+
import '@storybook/preview-api';
|
6
|
+
import '@storybook/addon-comments';
|
7
|
+
import '@storybook/addon-centered';
|
8
|
+
import '@storybook/addon-graphql';
|
9
|
+
import '@storybook/addon-info';
|
10
|
+
import '@storybook/addon-knobs';
|
11
|
+
import '@storybook/addon-links';
|
12
|
+
import '@storybook/addon-notes';
|
13
|
+
import '@storybook/addon-options';
|
14
|
+
import '@storybook/addon-storyshots';
|
15
|
+
import '@storybook/channels';
|
16
|
+
import '@storybook/channel-postmessage';
|
17
|
+
import '@storybook/channel-websocket';
|
18
|
+
import '@storybook/cli';
|
19
|
+
import '@storybook/react';
|
20
|
+
import '@storybook/react-native';
|
21
|
+
import '@storybook/manager';
|
22
|
+
import { storiesOf } from '@storybook/react';"
|
23
|
+
`;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`upgrade-hierarchy-separators transforms correctly using "dynamic-storiesof.input.js" data 1`] = `
|
4
|
+
"import { storiesOf } from '@storybook/react';
|
5
|
+
|
6
|
+
const foo = 'some|generated/path';
|
7
|
+
|
8
|
+
storiesOf(foo, module).add('foobar', () => <>hmm</>);"
|
9
|
+
`;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { storiesOf } from '@storybook/react';
|
2
|
+
|
3
|
+
storiesOf('A/B/C', module).add('abc', () => <div>hello</div>);
|
4
|
+
storiesOf('D|E/f', module).add('def', () => <div>hello</div>);
|
5
|
+
|
6
|
+
storiesOf('G|h/i.jkl', module)
|
7
|
+
.add('hijkl', () => <div>hello</div>)
|
8
|
+
.add('whatever', () => <div>goodbye!</div>);
|
package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`upgrade-hierarchy-separators transforms correctly using "storiesof.input.js" data 1`] = `
|
4
|
+
"import { storiesOf } from '@storybook/react';
|
5
|
+
|
6
|
+
storiesOf('A/B/C', module).add('abc', () => <div>hello</div>);
|
7
|
+
storiesOf('D/E/f', module).add('def', () => <div>hello</div>);
|
8
|
+
|
9
|
+
storiesOf('G/h/i/jkl', module)
|
10
|
+
.add('hijkl', () => <div>hello</div>)
|
11
|
+
.add('whatever', () => <div>goodbye!</div>);"
|
12
|
+
`;
|