@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.
Files changed (119) hide show
  1. package/README.md +262 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +1 -0
  4. package/dist/transforms/add-component-parameters.d.ts +22 -0
  5. package/dist/transforms/add-component-parameters.js +1 -0
  6. package/dist/transforms/csf-2-to-3.d.ts +8 -0
  7. package/dist/transforms/csf-2-to-3.js +3 -0
  8. package/dist/transforms/csf-hoist-story-annotations.d.ts +26 -0
  9. package/dist/transforms/csf-hoist-story-annotations.js +1 -0
  10. package/dist/transforms/mdx-to-csf.d.ts +7 -0
  11. package/dist/transforms/mdx-to-csf.js +61 -0
  12. package/dist/transforms/move-builtin-addons.d.ts +3 -0
  13. package/dist/transforms/move-builtin-addons.js +1 -0
  14. package/dist/transforms/storiesof-to-csf.d.ts +24 -0
  15. package/dist/transforms/storiesof-to-csf.js +1 -0
  16. package/dist/transforms/update-addon-info.d.ts +27 -0
  17. package/dist/transforms/update-addon-info.js +1 -0
  18. package/dist/transforms/update-organisation-name.d.ts +25 -0
  19. package/dist/transforms/update-organisation-name.js +1 -0
  20. package/dist/transforms/upgrade-deprecated-types.d.ts +10 -0
  21. package/dist/transforms/upgrade-deprecated-types.js +2 -0
  22. package/dist/transforms/upgrade-hierarchy-separators.d.ts +3 -0
  23. package/dist/transforms/upgrade-hierarchy-separators.js +1 -0
  24. package/jest.config.js +9 -0
  25. package/package.json +102 -0
  26. package/project.json +6 -0
  27. package/src/index.ts +103 -0
  28. package/src/lib/utils.test.js +9 -0
  29. package/src/lib/utils.ts +29 -0
  30. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.input.js +44 -0
  31. package/src/transforms/__testfixtures__/add-component-parameters/add-component-parameters.output.snapshot +68 -0
  32. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.input.js +25 -0
  33. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/basic.output.snapshot +27 -0
  34. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.input.js +25 -0
  35. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/overrides.output.snapshot +28 -0
  36. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.input.js +13 -0
  37. package/src/transforms/__testfixtures__/csf-hoist-story-annotations/variable.output.snapshot +17 -0
  38. package/src/transforms/__testfixtures__/mdx-to-csf/basic.input.mdx +18 -0
  39. package/src/transforms/__testfixtures__/mdx-to-csf/basic.output.snapshot +40 -0
  40. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.input.mdx +6 -0
  41. package/src/transforms/__testfixtures__/mdx-to-csf/component-id.output.snapshot +17 -0
  42. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.input.mdx +8 -0
  43. package/src/transforms/__testfixtures__/mdx-to-csf/decorators.output.snapshot +18 -0
  44. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.input.mdx +19 -0
  45. package/src/transforms/__testfixtures__/mdx-to-csf/exclude-stories.output.snapshot +39 -0
  46. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.input.mdx +14 -0
  47. package/src/transforms/__testfixtures__/mdx-to-csf/parameters.output.snapshot +23 -0
  48. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.input.mdx +3 -0
  49. package/src/transforms/__testfixtures__/mdx-to-csf/plaintext.output.snapshot +11 -0
  50. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.input.mdx +10 -0
  51. package/src/transforms/__testfixtures__/mdx-to-csf/story-function.output.snapshot +18 -0
  52. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.input.mdx +18 -0
  53. package/src/transforms/__testfixtures__/mdx-to-csf/story-parameters.output.snapshot +32 -0
  54. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.input.mdx +22 -0
  55. package/src/transforms/__testfixtures__/mdx-to-csf/story-refs.output.snapshot +34 -0
  56. package/src/transforms/__testfixtures__/move-builtin-addons/default.input.js +2 -0
  57. package/src/transforms/__testfixtures__/move-builtin-addons/default.output.snapshot +8 -0
  58. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.input.js +3 -0
  59. package/src/transforms/__testfixtures__/move-builtin-addons/with-no-change.output.snapshot +7 -0
  60. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.input.js +18 -0
  61. package/src/transforms/__testfixtures__/storiesof-to-csf/basic.output.snapshot +45 -0
  62. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.input.js +11 -0
  63. package/src/transforms/__testfixtures__/storiesof-to-csf/collision.output.snapshot +38 -0
  64. package/src/transforms/__testfixtures__/storiesof-to-csf/const.input.js +1 -0
  65. package/src/transforms/__testfixtures__/storiesof-to-csf/const.output.snapshot +13 -0
  66. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.input.js +9 -0
  67. package/src/transforms/__testfixtures__/storiesof-to-csf/decorators.output.snapshot +18 -0
  68. package/src/transforms/__testfixtures__/storiesof-to-csf/default.input.js +7 -0
  69. package/src/transforms/__testfixtures__/storiesof-to-csf/default.output.snapshot +17 -0
  70. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.input.js +1 -0
  71. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.js +5 -0
  72. package/src/transforms/__testfixtures__/storiesof-to-csf/digit.output.snapshot +9 -0
  73. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.input.js +11 -0
  74. package/src/transforms/__testfixtures__/storiesof-to-csf/export-destructuring.output.snapshot +23 -0
  75. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.input.js +12 -0
  76. package/src/transforms/__testfixtures__/storiesof-to-csf/export-function.output.snapshot +23 -0
  77. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.input.js +14 -0
  78. package/src/transforms/__testfixtures__/storiesof-to-csf/export-names.output.snapshot +26 -0
  79. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.input.js +2 -0
  80. package/src/transforms/__testfixtures__/storiesof-to-csf/exports.output.snapshot +16 -0
  81. package/src/transforms/__testfixtures__/storiesof-to-csf/module.input.js +12 -0
  82. package/src/transforms/__testfixtures__/storiesof-to-csf/module.output.snapshot +16 -0
  83. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.input.js +14 -0
  84. package/src/transforms/__testfixtures__/storiesof-to-csf/multi.output.snapshot +39 -0
  85. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.input.js +8 -0
  86. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters-as-var.output.snapshot +20 -0
  87. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.input.js +10 -0
  88. package/src/transforms/__testfixtures__/storiesof-to-csf/parameters.output.snapshot +23 -0
  89. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.input.js +11 -0
  90. package/src/transforms/__testfixtures__/storiesof-to-csf/storiesof-var.output.snapshot +23 -0
  91. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.input.js +11 -0
  92. package/src/transforms/__testfixtures__/storiesof-to-csf/story-decorators.output.snapshot +29 -0
  93. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.input.js +14 -0
  94. package/src/transforms/__testfixtures__/storiesof-to-csf/story-parameters.output.snapshot +32 -0
  95. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.input.js +184 -0
  96. package/src/transforms/__testfixtures__/update-addon-info/update-addon-info.output.snapshot +184 -0
  97. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.input.js +19 -0
  98. package/src/transforms/__testfixtures__/update-organisation-name/update-organisation-name.output.snapshot +23 -0
  99. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.input.js +3 -0
  100. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/csf.output.snapshot +7 -0
  101. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.input.js +5 -0
  102. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/dynamic-storiesof.output.snapshot +9 -0
  103. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.input.js +8 -0
  104. package/src/transforms/__testfixtures__/upgrade-hierarchy-separators/storiesof.output.snapshot +12 -0
  105. package/src/transforms/__tests__/csf-2-to-3.test.ts +439 -0
  106. package/src/transforms/__tests__/mdx-to-csf.test.ts +628 -0
  107. package/src/transforms/__tests__/transforms.tests.js +32 -0
  108. package/src/transforms/__tests__/upgrade-deprecated-types.test.ts +170 -0
  109. package/src/transforms/add-component-parameters.js +62 -0
  110. package/src/transforms/csf-2-to-3.ts +336 -0
  111. package/src/transforms/csf-hoist-story-annotations.js +97 -0
  112. package/src/transforms/mdx-to-csf.ts +340 -0
  113. package/src/transforms/move-builtin-addons.js +32 -0
  114. package/src/transforms/storiesof-to-csf.js +277 -0
  115. package/src/transforms/update-addon-info.js +114 -0
  116. package/src/transforms/update-organisation-name.js +71 -0
  117. package/src/transforms/upgrade-deprecated-types.ts +142 -0
  118. package/src/transforms/upgrade-hierarchy-separators.js +39 -0
  119. 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
+ `;
@@ -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,3 @@
1
+ export default {
2
+ title: 'Foo|Bar/baz.whatever',
3
+ };
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`upgrade-hierarchy-separators transforms correctly using "csf.input.js" data 1`] = `
4
+ "export default {
5
+ title: 'Foo/Bar/baz/whatever',
6
+ };"
7
+ `;
@@ -0,0 +1,5 @@
1
+ import { storiesOf } from '@storybook/react';
2
+
3
+ const foo = 'some|generated/path';
4
+
5
+ storiesOf(foo, module).add('foobar', () => <>hmm</>);
@@ -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>);
@@ -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
+ `;