@storybook/codemod 7.0.0-beta.2 → 7.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/chunk-3OPQTROG.mjs +1 -0
- package/dist/chunk-B5FMQ3BX.mjs +1 -0
- package/dist/chunk-CO6EPEMB.mjs +1 -0
- package/dist/index.d.ts +13 -261
- package/dist/index.mjs +1 -1
- package/dist/transforms/add-component-parameters.d.ts +22 -0
- package/dist/transforms/add-component-parameters.js +1 -0
- package/dist/transforms/add-component-parameters.mjs +1 -0
- package/dist/transforms/csf-2-to-3.d.ts +7 -0
- package/dist/transforms/csf-2-to-3.js +1 -0
- package/dist/transforms/csf-2-to-3.mjs +1 -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/csf-hoist-story-annotations.mjs +1 -0
- package/dist/transforms/csf-to-mdx.d.ts +29 -0
- package/dist/transforms/csf-to-mdx.js +3 -0
- package/dist/transforms/csf-to-mdx.mjs +3 -0
- package/dist/transforms/move-builtin-addons.d.ts +3 -0
- package/dist/transforms/move-builtin-addons.js +1 -0
- package/dist/transforms/move-builtin-addons.mjs +1 -0
- package/dist/transforms/storiesof-to-csf.d.ts +24 -0
- package/dist/transforms/storiesof-to-csf.js +1 -0
- package/dist/transforms/storiesof-to-csf.mjs +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-addon-info.mjs +1 -0
- package/dist/transforms/update-organisation-name.d.ts +25 -0
- package/dist/transforms/update-organisation-name.js +1 -0
- package/dist/transforms/update-organisation-name.mjs +1 -0
- package/dist/transforms/upgrade-hierarchy-separators.d.ts +3 -0
- package/dist/transforms/upgrade-hierarchy-separators.js +1 -0
- package/dist/transforms/upgrade-hierarchy-separators.mjs +1 -0
- package/package.json +24 -7
- package/src/transforms/__testfixtures__/mdx-to-csf/{basic.input.js → basic.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{component-id.input.js → component-id.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{decorators.input.js → decorators.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{exclude-stories.input.js → exclude-stories.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{parameters.input.js → parameters.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{plaintext.input.js → plaintext.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{story-function.input.js → story-function.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{story-parameters.input.js → story-parameters.input.mdx} +0 -0
- package/src/transforms/__testfixtures__/mdx-to-csf/{story-refs.input.js → story-refs.input.mdx} +0 -0
- package/tsconfig.json +4 -2
@@ -0,0 +1 @@
|
|
1
|
+
var packageNames={"@kadira/react-storybook-decorator-centered":"@storybook/addon-centered","@kadira/storybook-addons":"@storybook/preview-api","@kadira/storybook-addon-actions":"@storybook/addon-actions","@kadira/storybook-addon-comments":"@storybook/addon-comments","@kadira/storybook-addon-graphql":"@storybook/addon-graphql","@kadira/storybook-addon-info":"@storybook/addon-info","@kadira/storybook-addon-knobs":"@storybook/addon-knobs","@kadira/storybook-addon-links":"@storybook/addon-links","@kadira/storybook-addon-notes":"@storybook/addon-notes","@kadira/storybook-addon-options":"@storybook/addon-options","@kadira/storybook-channels":"@storybook/channels","@kadira/storybook-channel-postmsg":"@storybook/channel-postmessage","@kadira/storybook-channel-websocket":"@storybook/channel-websocket","@kadira/storybook-ui":"@storybook/manager","@kadira/react-native-storybook":"@storybook/react-native","@kadira/react-storybook":"@storybook/react","@kadira/getstorybook":"@storybook/cli","@kadira/storybook":"@storybook/react",storyshots:"@storybook/addon-storyshots",getstorybook:"@storybook/cli"};function transformer(file,api){let j=api.jscodeshift,packageNamesKeys=Object.keys(packageNames),getMatch=oldpart=>packageNamesKeys.find(newpart=>oldpart.match(newpart)),getNewPackageName=oldPackageName=>{let match=getMatch(oldPackageName);if(match){let replacement=packageNames[match];return oldPackageName.replace(match,replacement)}return oldPackageName},updatePackageName=declaration=>(declaration.node.source.value=getNewPackageName(declaration.node.source.value),declaration.node);return j(file.source).find(j.ImportDeclaration).replaceWith(updatePackageName).toSource({quote:"single"})}export{packageNames,transformer};
|
@@ -0,0 +1 @@
|
|
1
|
+
function transformer(file,api){let j=api.jscodeshift,root=j(file.source),getOptions=args=>args[3]===void 0?args[2]===void 0?[args[0]]:[args[1]]:[j.objectExpression([j.property("init",j.identifier("text"),args[1]),...args[3].properties])],withInfo=addWithInfoExpression=>{let{node}=addWithInfoExpression,args=node.arguments,storyComponent=args[2]?args[2]:args[1];return node.callee.property.name="add",node.arguments=[args[0],j.callExpression(j.callExpression(j.identifier("withInfo"),getOptions(args)),[storyComponent])],node},checkWithInfoImport=()=>{root.find(j.ImportDeclaration).filter(imp=>imp.node.source.value==="@storybook/addon-info").size()||root.find(j.ImportDeclaration).at(-1).insertAfter(j.importDeclaration([j.importSpecifier(j.identifier("withInfo"))],j.literal("@storybook/addon-info")))},addWithInfoExpressions=root.find(j.CallExpression,{callee:{property:{name:"addWithInfo"}}});return addWithInfoExpressions.size()&&(checkWithInfoImport(),addWithInfoExpressions.replaceWith(withInfo)),root.toSource()}export{transformer};
|
@@ -0,0 +1 @@
|
|
1
|
+
import camelCase from"lodash/camelCase";import upperFirst from"lodash/upperFirst";var sanitizeName=name=>{let key=upperFirst(camelCase(name));return/^\d/.test(key)&&(key=`_${key}`),/^\d/.test(key)&&(key=`_${key}`),key};function jscodeshiftToPrettierParser(parser){let parserMap={babylon:"babel",flow:"flow",ts:"typescript",tsx:"typescript"};return parser&&parserMap[parser]||"babel"}export{sanitizeName,jscodeshiftToPrettierParser};
|
package/dist/index.d.ts
CHANGED
@@ -1,261 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
'@kadira/storybook-addon-graphql': '@storybook/addon-graphql',
|
15
|
-
'@kadira/storybook-addon-info': '@storybook/addon-info',
|
16
|
-
'@kadira/storybook-addon-knobs': '@storybook/addon-knobs',
|
17
|
-
'@kadira/storybook-addon-links': '@storybook/addon-links',
|
18
|
-
'@kadira/storybook-addon-notes': '@storybook/addon-notes',
|
19
|
-
'@kadira/storybook-addon-options': '@storybook/addon-options',
|
20
|
-
'@kadira/storybook-channels': '@storybook/channels',
|
21
|
-
'@kadira/storybook-channel-postmsg': '@storybook/channel-postmessage',
|
22
|
-
'@kadira/storybook-channel-websocket': '@storybook/channel-websocket',
|
23
|
-
'@kadira/storybook-ui': '@storybook/manager',
|
24
|
-
'@kadira/react-native-storybook': '@storybook/react-native',
|
25
|
-
'@kadira/react-storybook': '@storybook/react',
|
26
|
-
'@kadira/getstorybook': '@storybook/cli',
|
27
|
-
'@kadira/storybook': '@storybook/react',
|
28
|
-
storyshots: '@storybook/addon-storyshots',
|
29
|
-
getstorybook: '@storybook/cli',
|
30
|
-
};
|
31
|
-
|
32
|
-
function transformer$1(file, api) {
|
33
|
-
const j = api.jscodeshift;
|
34
|
-
|
35
|
-
const packageNamesKeys = Object.keys(packageNames);
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Checks whether the node value matches a Storybook package
|
39
|
-
* @param {string} the import declaration node
|
40
|
-
* @returns {string} whether the node value matches a Storybook package
|
41
|
-
*/
|
42
|
-
const getMatch = (oldpart) => packageNamesKeys.find((newpart) => oldpart.match(newpart));
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Returns the name of the Storybook packages with the organisation name,
|
46
|
-
* replacing the old `@kadira/` prefix.
|
47
|
-
* @param {string} oldPackageName the name of the old package
|
48
|
-
* @return {string} the new package name
|
49
|
-
* @example
|
50
|
-
* // returns '@storybook/storybook'
|
51
|
-
* getNewPackageName('@kadira/storybook')
|
52
|
-
*/
|
53
|
-
const getNewPackageName = (oldPackageName) => {
|
54
|
-
const match = getMatch(oldPackageName);
|
55
|
-
|
56
|
-
if (match) {
|
57
|
-
const replacement = packageNames[match];
|
58
|
-
return oldPackageName.replace(match, replacement);
|
59
|
-
}
|
60
|
-
return oldPackageName;
|
61
|
-
};
|
62
|
-
|
63
|
-
/**
|
64
|
-
* updatePackageName - updates the source name of the Storybook packages
|
65
|
-
* @param {ImportDeclaration} declaration the import declaration
|
66
|
-
* @returns {ImportDeclaration.Node} the import declaration node
|
67
|
-
*/
|
68
|
-
const updatePackageName = (declaration) => {
|
69
|
-
// eslint-disable-next-line no-param-reassign
|
70
|
-
declaration.node.source.value = getNewPackageName(declaration.node.source.value);
|
71
|
-
|
72
|
-
return declaration.node;
|
73
|
-
};
|
74
|
-
|
75
|
-
return j(file.source)
|
76
|
-
.find(j.ImportDeclaration)
|
77
|
-
.replaceWith(updatePackageName)
|
78
|
-
.toSource({ quote: 'single' });
|
79
|
-
}
|
80
|
-
|
81
|
-
/**
|
82
|
-
* Takes the deprecated addon-info API, addWithInfo, and
|
83
|
-
* converts to the new withInfo API.
|
84
|
-
*
|
85
|
-
* Example of deprecated addWithInfo API:
|
86
|
-
*
|
87
|
-
* storiesOf('Button')
|
88
|
-
* .addWithInfo(
|
89
|
-
* 'story name',
|
90
|
-
* 'Story description.',
|
91
|
-
* () => (
|
92
|
-
* <Button label="The Button" />
|
93
|
-
* )
|
94
|
-
* )
|
95
|
-
*
|
96
|
-
* Converts to the new withInfo API:
|
97
|
-
*
|
98
|
-
* storiesOf('Button')
|
99
|
-
* .add('story name', withInfo(
|
100
|
-
* 'Story description.'
|
101
|
-
* )(() => (
|
102
|
-
* <Button label="The Button" />
|
103
|
-
* )))
|
104
|
-
*/
|
105
|
-
function transformer(file, api) {
|
106
|
-
const j = api.jscodeshift;
|
107
|
-
const root = j(file.source);
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Returns a list of parameters for the withInfo function. The contents
|
111
|
-
* of this list is either the second argument from the original
|
112
|
-
* addWithInfo function, if no additional options were used, or a
|
113
|
-
* combined object of all the options from the original function.
|
114
|
-
* @param {list} args - original addWithInfo function parameters
|
115
|
-
* @return {list} the modified list of parameters for the new function
|
116
|
-
*/
|
117
|
-
const getOptions = (args) => {
|
118
|
-
if (args[3] === undefined) {
|
119
|
-
if (args[2] === undefined) {
|
120
|
-
// when the optional description string is not supplied for addWithInfo, use story name
|
121
|
-
return [args[0]];
|
122
|
-
}
|
123
|
-
return [args[1]];
|
124
|
-
}
|
125
|
-
return [
|
126
|
-
j.objectExpression([
|
127
|
-
j.property('init', j.identifier('text'), args[1]),
|
128
|
-
...args[3].properties,
|
129
|
-
]),
|
130
|
-
];
|
131
|
-
};
|
132
|
-
|
133
|
-
/**
|
134
|
-
* Constructs the new withInfo function from the parameters of the
|
135
|
-
* original addWithInfo function.
|
136
|
-
* @param {CallExpression} addWithInfoExpression - original function
|
137
|
-
* @returns {CallExpression} the new withInfo function
|
138
|
-
*/
|
139
|
-
const withInfo = (addWithInfoExpression) => {
|
140
|
-
const { node } = addWithInfoExpression;
|
141
|
-
const args = node.arguments;
|
142
|
-
|
143
|
-
// if optional description string is not supplied, the story component becomes second arg
|
144
|
-
const storyComponent = args[2] ? args[2] : args[1];
|
145
|
-
|
146
|
-
node.callee.property.name = 'add';
|
147
|
-
node.arguments = [
|
148
|
-
args[0],
|
149
|
-
j.callExpression(j.callExpression(j.identifier('withInfo'), getOptions(args)), [
|
150
|
-
storyComponent,
|
151
|
-
]),
|
152
|
-
];
|
153
|
-
|
154
|
-
return node;
|
155
|
-
};
|
156
|
-
|
157
|
-
/**
|
158
|
-
* Checks for - import { withInfo } from "@storybook/addon-info";
|
159
|
-
* Adds the import if necessary.
|
160
|
-
*/
|
161
|
-
const checkWithInfoImport = () => {
|
162
|
-
const importExists = root
|
163
|
-
.find(j.ImportDeclaration)
|
164
|
-
.filter((imp) => imp.node.source.value === '@storybook/addon-info')
|
165
|
-
.size();
|
166
|
-
|
167
|
-
if (importExists) return;
|
168
|
-
|
169
|
-
root
|
170
|
-
.find(j.ImportDeclaration)
|
171
|
-
.at(-1)
|
172
|
-
.insertAfter(
|
173
|
-
j.importDeclaration(
|
174
|
-
[j.importSpecifier(j.identifier('withInfo'))],
|
175
|
-
j.literal('@storybook/addon-info')
|
176
|
-
)
|
177
|
-
);
|
178
|
-
};
|
179
|
-
|
180
|
-
const addWithInfoExpressions = root.find(j.CallExpression, {
|
181
|
-
callee: {
|
182
|
-
property: {
|
183
|
-
name: 'addWithInfo',
|
184
|
-
},
|
185
|
-
},
|
186
|
-
});
|
187
|
-
|
188
|
-
if (addWithInfoExpressions.size()) {
|
189
|
-
checkWithInfoImport();
|
190
|
-
addWithInfoExpressions.replaceWith(withInfo);
|
191
|
-
}
|
192
|
-
|
193
|
-
return root.toSource();
|
194
|
-
}
|
195
|
-
|
196
|
-
/* eslint import/prefer-default-export: "off" */
|
197
|
-
|
198
|
-
const TRANSFORM_DIR = `${__dirname}/transforms`;
|
199
|
-
|
200
|
-
function listCodemods() {
|
201
|
-
return fs
|
202
|
-
.readdirSync(TRANSFORM_DIR)
|
203
|
-
.filter((fname) => fname.endsWith('.js'))
|
204
|
-
.map((fname) => fname.slice(0, -3));
|
205
|
-
}
|
206
|
-
|
207
|
-
const renameAsync = promisify(fs.rename);
|
208
|
-
|
209
|
-
async function renameFile(file, from, to, { logger }) {
|
210
|
-
const newFile = file.replace(from, to);
|
211
|
-
logger.log(`Rename: ${file} ${newFile}`);
|
212
|
-
return renameAsync(file, newFile);
|
213
|
-
}
|
214
|
-
|
215
|
-
async function runCodemod(codemod, { glob, logger, dryRun, rename, parser }) {
|
216
|
-
const codemods = listCodemods();
|
217
|
-
if (!codemods.includes(codemod)) {
|
218
|
-
throw new Error(`Unknown codemod ${codemod}. Run --list for options.`);
|
219
|
-
}
|
220
|
-
|
221
|
-
let renameParts = null;
|
222
|
-
if (rename) {
|
223
|
-
renameParts = rename.split(':');
|
224
|
-
if (renameParts.length !== 2) {
|
225
|
-
throw new Error(`Codemod rename: expected format "from:to", got "${rename}"`);
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
// jscodeshift/prettier know how to handle .ts/.tsx extensions,
|
230
|
-
// so if the user uses one of those globs, we can auto-infer
|
231
|
-
let inferredParser = parser;
|
232
|
-
if (!parser) {
|
233
|
-
const extension = path.extname(glob).slice(1);
|
234
|
-
const knownParser = jscodeshiftToPrettierParser(extension);
|
235
|
-
if (knownParser !== 'babel') inferredParser = extension;
|
236
|
-
}
|
237
|
-
|
238
|
-
const files = await globby([glob, '!**/node_modules', '!**/dist']);
|
239
|
-
logger.log(`=> Applying ${codemod}: ${files.length} files`);
|
240
|
-
if (!dryRun) {
|
241
|
-
const parserArgs = inferredParser ? ['--parser', inferredParser] : [];
|
242
|
-
sync(
|
243
|
-
'npx',
|
244
|
-
['jscodeshift', '-t', `${TRANSFORM_DIR}/${codemod}.js`, ...parserArgs, ...files],
|
245
|
-
{
|
246
|
-
stdio: 'inherit',
|
247
|
-
shell: true,
|
248
|
-
}
|
249
|
-
);
|
250
|
-
}
|
251
|
-
|
252
|
-
if (renameParts) {
|
253
|
-
const [from, to] = renameParts;
|
254
|
-
logger.log(`=> Renaming ${rename}: ${files.length} files`);
|
255
|
-
await Promise.all(
|
256
|
-
files.map((file) => renameFile(file, new RegExp(`${from}$`), to, { logger }))
|
257
|
-
);
|
258
|
-
}
|
259
|
-
}
|
260
|
-
|
261
|
-
export { listCodemods, packageNames, runCodemod, transformer as updateAddonInfo, transformer$1 as updateOrganisationName };
|
1
|
+
export { default as updateAddonInfo } from './transforms/update-addon-info.js';
|
2
|
+
export { packageNames, default as updateOrganisationName } from './transforms/update-organisation-name.js';
|
3
|
+
|
4
|
+
declare function listCodemods(): string[];
|
5
|
+
declare function runCodemod(codemod: any, { glob, logger, dryRun, rename, parser }: {
|
6
|
+
glob: any;
|
7
|
+
logger: any;
|
8
|
+
dryRun: any;
|
9
|
+
rename: any;
|
10
|
+
parser: any;
|
11
|
+
}): Promise<void>;
|
12
|
+
|
13
|
+
export { listCodemods, runCodemod };
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import{packageNames,transformer}from"./chunk-3OPQTROG.mjs";import{jscodeshiftToPrettierParser}from"./chunk-CO6EPEMB.mjs";import{transformer as transformer2}from"./chunk-B5FMQ3BX.mjs";import fs from"fs";import path from"path";import{promisify}from"util";import globby from"globby";import{sync as spawnSync}from"cross-spawn";var TRANSFORM_DIR=`${__dirname}/transforms`;function listCodemods(){return fs.readdirSync(TRANSFORM_DIR).filter(fname=>fname.endsWith(".js")).map(fname=>fname.slice(0,-3))}var renameAsync=promisify(fs.rename);async function renameFile(file,from,to,{logger}){let newFile=file.replace(from,to);return logger.log(`Rename: ${file} ${newFile}`),renameAsync(file,newFile)}async function runCodemod(codemod,{glob,logger,dryRun,rename,parser}){if(!listCodemods().includes(codemod))throw new Error(`Unknown codemod ${codemod}. Run --list for options.`);let renameParts=null;if(rename&&(renameParts=rename.split(":"),renameParts.length!==2))throw new Error(`Codemod rename: expected format "from:to", got "${rename}"`);let inferredParser=parser;if(!parser){let extension=path.extname(glob).slice(1);jscodeshiftToPrettierParser(extension)!=="babel"&&(inferredParser=extension)}let files=await globby([glob,"!**/node_modules","!**/dist"]);if(logger.log(`=> Applying ${codemod}: ${files.length} files`),!dryRun){let parserArgs=inferredParser?["--parser",inferredParser]:[];spawnSync("npx",["jscodeshift","-t",`${TRANSFORM_DIR}/${codemod}.js`,...parserArgs,...files],{stdio:"inherit",shell:!0})}if(renameParts){let[from,to]=renameParts;logger.log(`=> Renaming ${rename}: ${files.length} files`),await Promise.all(files.map(file=>renameFile(file,new RegExp(`${from}$`),to,{logger})))}}export{listCodemods,packageNames,runCodemod,transformer2 as updateAddonInfo,transformer as updateOrganisationName};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Adds a `component` parameter for each storiesOf(...) call.
|
3
|
+
*
|
4
|
+
* For example:
|
5
|
+
*
|
6
|
+
* input { Button } from './Button';
|
7
|
+
* storiesOf('Button', module).add('story', () => <Button label="The Button" />);
|
8
|
+
*
|
9
|
+
* Becomes:
|
10
|
+
*
|
11
|
+
* input { Button } from './Button';
|
12
|
+
* storiesOf('Button', module)
|
13
|
+
* .addParameters({ component: Button })
|
14
|
+
* .add('story', () => <Button label="The Button" />);
|
15
|
+
*
|
16
|
+
* Heuristics:
|
17
|
+
* - The storiesOf "kind" name must be Button
|
18
|
+
* - Button must be imported in the file
|
19
|
+
*/
|
20
|
+
declare function transformer(file: any, api: any): any;
|
21
|
+
|
22
|
+
export { transformer as default };
|
@@ -0,0 +1 @@
|
|
1
|
+
var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var g=(r,n)=>{for(var e in n)s(r,e,{get:n[e],enumerable:!0})},h=(r,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of p(n))!u.call(r,a)&&a!==e&&s(r,a,{get:()=>n[a],enumerable:!(i=d(n,a))||i.enumerable});return r};var E=r=>h(s({},"__esModule",{value:!0}),r);var x={};g(x,{default:()=>f});module.exports=E(x);function f(r,n){let e=n.jscodeshift,i=e(r.source),a={};i.find(e.ImportDeclaration).forEach(t=>t.node.specifiers.forEach(o=>{a[o.local.name]=!0}));function c(t){let o=t.split(/\/|\.|\|/);return o[o.length-1]}function l(t){let{node:o}=t,m=c(o.arguments[0].value);return e.callExpression(e.memberExpression(o,e.identifier("addParameters")),[e.objectExpression([e.property("init",e.identifier("component"),e.identifier(m))])])}return i.find(e.CallExpression).filter(t=>t.node.callee.name==="storiesOf").filter(t=>t.node.arguments.length>0&&t.node.arguments[0].type==="Literal").filter(t=>{let o=c(t.node.arguments[0].value);return a[o]}).replaceWith(l),i.toSource()}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
function transformer(file,api){let j=api.jscodeshift,root=j(file.source),importMap={};root.find(j.ImportDeclaration).forEach(imp=>imp.node.specifiers.forEach(spec=>{importMap[spec.local.name]=!0}));function getLeafName(string){let parts=string.split(/\/|\.|\|/);return parts[parts.length-1]}function addComponentParameter(call){let{node}=call,leafName=getLeafName(node.arguments[0].value);return j.callExpression(j.memberExpression(node,j.identifier("addParameters")),[j.objectExpression([j.property("init",j.identifier("component"),j.identifier(leafName))])])}return root.find(j.CallExpression).filter(call=>call.node.callee.name==="storiesOf").filter(call=>call.node.arguments.length>0&&call.node.arguments[0].type==="Literal").filter(call=>{let leafName=getLeafName(call.node.arguments[0].value);return importMap[leafName]}).replaceWith(addComponentParameter),root.toSource()}export{transformer as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
var _=Object.create;var f=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var F=(e,r)=>{for(var n in r)f(e,n,{get:r[n],enumerable:!0})},h=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of w(r))!R.call(e,o)&&o!==n&&f(e,o,{get:()=>r[o],enumerable:!(s=D(r,o))||s.enumerable});return e};var d=(e,r,n)=>(n=e!=null?_(P(e)):{},h(r||!e||!e.__esModule?f(n,"default",{value:e,enumerable:!0}):n,e)),T=e=>h(f({},"__esModule",{value:!0}),e);var G={};F(G,{default:()=>z});module.exports=T(G);var x=d(require("prettier")),t=d(require("@babel/types")),u=require("@storybook/csf-tools");var k=d(require("lodash/camelCase")),N=d(require("lodash/upperFirst"));function j(e){let r={babylon:"babel",flow:"flow",ts:"typescript",tsx:"typescript"};return e&&r[e]||"babel"}var V=console,M=e=>e==="storyName"?"name":e,O=e=>t.isCallExpression(e)&&t.isMemberExpression(e.callee)&&t.isIdentifier(e.callee.object)&&t.isIdentifier(e.callee.property)&&e.callee.property.name==="bind"&&(e.arguments.length===0||e.arguments.length===1&&t.isObjectExpression(e.arguments[0])&&e.arguments[0].properties.length===0)?e.callee.object.name:null,X=(e,r)=>t.isExpressionStatement(e)&&t.isAssignmentExpression(e.expression)&&t.isMemberExpression(e.expression.left)&&t.isIdentifier(e.expression.left.object)&&r[e.expression.left.object.name],v=(e,r)=>t.isVariableDeclaration(e)&&e.declarations.length===1&&t.isIdentifier(e.declarations[0].id)&&r[e.declarations[0].id.name],J=(e,r)=>{if(t.isExportNamedDeclaration(e)&&t.isVariableDeclaration(e.declaration)&&e.declaration.declarations.length===1){let n=e.declaration.declarations[0];if(t.isVariableDeclarator(n)&&t.isIdentifier(n.id))return r[n.id.name]}return null},$=(e,r)=>{var n;if(((n=e._meta)==null?void 0:n.component)&&t.isArrowFunctionExpression(r)&&r.params.length===1&&t.isJSXElement(r.body)){let{openingElement:s}=r.body;if(s.selfClosing&&t.isJSXIdentifier(s.name)&&s.attributes.length===1){let o=s.attributes[0],l=r.params[0];if(t.isJSXSpreadAttribute(o)&&t.isIdentifier(o.argument)&&t.isIdentifier(l)&&l.name===o.argument.name&&e._meta.component===s.name.name)return!0}}return!1},B=(e,r)=>r.length===0&&t.isArrowFunctionExpression(e)&&e.params.length===0;function W({source:e},r,n){let o=(0,u.loadCsf)(e,{makeTitle:i=>i||"FIXME"});try{o.parse()}catch(i){return V.log(`Error ${i}, skipping`),e}let l={};Object.entries(o._storyExports).forEach(([i,a])=>{let p=Object.entries(o._storyAnnotations[i]).map(([c,g])=>t.objectProperty(t.identifier(M(c)),g));if(t.isVariableDeclarator(a)){let{init:c,id:g}=a,b=O(c);if(!t.isArrowFunctionExpression(c)&&!b||B(c,p))return;let m=b&&o._templates[b];m||(m=c);let y=t.identifier(i),{typeAnnotation:E}=g;E&&(y.typeAnnotation=E);let I=$(o,m)?[]:[t.objectProperty(t.identifier("render"),m)];l[i]=t.exportNamedDeclaration(t.variableDeclaration("const",[t.variableDeclarator(y,t.objectExpression([...I,...p]))]))}});let S=o._ast.program.body.reduce((i,a)=>{if(X(a,l)||v(a,o._templates))return i;let p=J(a,l);return p?(i.push(p),i):(i.push(a),i)},[]);o._ast.program.body=S;let A=(0,u.formatCsf)(o),C=x.default.resolveConfig.sync(".",{editorconfig:!0})||{printWidth:100,tabWidth:2,bracketSpacing:!0,trailingComma:"es5",singleQuote:!0};return x.default.format(A,{...C,parser:j(n==null?void 0:n.parser)})}var z=W;0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
import{jscodeshiftToPrettierParser}from"../chunk-CO6EPEMB.mjs";import prettier from"prettier";import*as t from"@babel/types";import{formatCsf,loadCsf}from"@storybook/csf-tools";var logger=console,renameAnnotation=annotation=>annotation==="storyName"?"name":annotation,getTemplateBindVariable=init=>t.isCallExpression(init)&&t.isMemberExpression(init.callee)&&t.isIdentifier(init.callee.object)&&t.isIdentifier(init.callee.property)&&init.callee.property.name==="bind"&&(init.arguments.length===0||init.arguments.length===1&&t.isObjectExpression(init.arguments[0])&&init.arguments[0].properties.length===0)?init.callee.object.name:null,isStoryAnnotation=(stmt,objectExports)=>t.isExpressionStatement(stmt)&&t.isAssignmentExpression(stmt.expression)&&t.isMemberExpression(stmt.expression.left)&&t.isIdentifier(stmt.expression.left.object)&&objectExports[stmt.expression.left.object.name],isTemplateDeclaration=(stmt,templates)=>t.isVariableDeclaration(stmt)&&stmt.declarations.length===1&&t.isIdentifier(stmt.declarations[0].id)&&templates[stmt.declarations[0].id.name],getNewExport=(stmt,objectExports)=>{if(t.isExportNamedDeclaration(stmt)&&t.isVariableDeclaration(stmt.declaration)&&stmt.declaration.declarations.length===1){let decl=stmt.declaration.declarations[0];if(t.isVariableDeclarator(decl)&&t.isIdentifier(decl.id))return objectExports[decl.id.name]}return null},isReactGlobalRenderFn=(csf,storyFn)=>{if(csf._meta?.component&&t.isArrowFunctionExpression(storyFn)&&storyFn.params.length===1&&t.isJSXElement(storyFn.body)){let{openingElement}=storyFn.body;if(openingElement.selfClosing&&t.isJSXIdentifier(openingElement.name)&&openingElement.attributes.length===1){let attr=openingElement.attributes[0],param=storyFn.params[0];if(t.isJSXSpreadAttribute(attr)&&t.isIdentifier(attr.argument)&&t.isIdentifier(param)&¶m.name===attr.argument.name&&csf._meta.component===openingElement.name.name)return!0}}return!1},isSimpleCSFStory=(init,annotations)=>annotations.length===0&&t.isArrowFunctionExpression(init)&&init.params.length===0;function transform({source},api,options){let csf=loadCsf(source,{makeTitle:userTitle=>userTitle||"FIXME"});try{csf.parse()}catch(err){return logger.log(`Error ${err}, skipping`),source}let objectExports={};Object.entries(csf._storyExports).forEach(([key,decl])=>{let annotations=Object.entries(csf._storyAnnotations[key]).map(([annotation,val])=>t.objectProperty(t.identifier(renameAnnotation(annotation)),val));if(t.isVariableDeclarator(decl)){let{init,id}=decl,template=getTemplateBindVariable(init);if(!t.isArrowFunctionExpression(init)&&!template||isSimpleCSFStory(init,annotations))return;let storyFn=template&&csf._templates[template];storyFn||(storyFn=init);let keyId=t.identifier(key),{typeAnnotation}=id;typeAnnotation&&(keyId.typeAnnotation=typeAnnotation);let renderAnnotation=isReactGlobalRenderFn(csf,storyFn)?[]:[t.objectProperty(t.identifier("render"),storyFn)];objectExports[key]=t.exportNamedDeclaration(t.variableDeclaration("const",[t.variableDeclarator(keyId,t.objectExpression([...renderAnnotation,...annotations]))]))}});let updatedBody=csf._ast.program.body.reduce((acc,stmt)=>{if(isStoryAnnotation(stmt,objectExports)||isTemplateDeclaration(stmt,csf._templates))return acc;let newExport=getNewExport(stmt,objectExports);return newExport?(acc.push(newExport),acc):(acc.push(stmt),acc)},[]);csf._ast.program.body=updatedBody;let output=formatCsf(csf),prettierConfig=prettier.resolveConfig.sync(".",{editorconfig:!0})||{printWidth:100,tabWidth:2,bracketSpacing:!0,trailingComma:"es5",singleQuote:!0};return prettier.format(output,{...prettierConfig,parser:jscodeshiftToPrettierParser(options?.parser)})}var csf_2_to_3_default=transform;export{csf_2_to_3_default as default};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* Hoist CSF .story annotations
|
3
|
+
*
|
4
|
+
* For example:
|
5
|
+
*
|
6
|
+
* ```
|
7
|
+
* export const Basic = () => <Button />
|
8
|
+
* Basic.story = {
|
9
|
+
* name: 'foo',
|
10
|
+
* parameters: { ... },
|
11
|
+
* decorators = [ ... ],
|
12
|
+
* };
|
13
|
+
* ```
|
14
|
+
*
|
15
|
+
* Becomes:
|
16
|
+
*
|
17
|
+
* ```
|
18
|
+
* export const Basic = () => <Button />
|
19
|
+
* Basic.storyName = 'foo';
|
20
|
+
* Basic.parameters = { ... };
|
21
|
+
* Basic.decorators = [ ... ];
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
declare function transformer(file: any, api: any): any;
|
25
|
+
|
26
|
+
export { transformer as default };
|
@@ -0,0 +1 @@
|
|
1
|
+
var c=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var E=(n,o)=>{for(var r in o)c(n,r,{get:o[r],enumerable:!0})},b=(n,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of l(o))!u.call(n,i)&&i!==r&&c(n,i,{get:()=>o[i],enumerable:!(s=d(o,i))||s.enumerable});return n};var g=n=>b(c({},"__esModule",{value:!0}),n);var j={};E(j,{default:()=>y});module.exports=g(j);var m=n=>n.node.type.endsWith("Statement")?n:m(n.parent);function y(n,o){let r=o.jscodeshift,s=r(n.source),i=t=>t.type==="Identifier"&&t.name==="name"?r.identifier("storyName"):t;if(s.find(r.ExportDefaultDeclaration).filter(t=>t.node.declaration.type==="ObjectExpression"&&t.node.declaration.properties.map(e=>e.key.name).includes("title")).size()===0)return s.toSource();let a=s.find(r.AssignmentExpression).filter(t=>{let{left:e,right:p}=t.node;return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.property.type==="Identifier"&&e.property.name==="story"&&p.type==="ObjectExpression"});return a.forEach(t=>{let{left:e,right:p}=t.node;p.properties.forEach(f=>{m(t).insertBefore(r.assignmentStatement("=",r.memberExpression(e.object,i(f.key)),f.value))})}),a.remove(),s.find(r.AssignmentExpression).filter(t=>{let{left:e}=t.node;return e.type==="MemberExpression"&&e.object.type==="MemberExpression"&&e.object.property.type==="Identifier"&&e.object.property.name==="story"&&e.property.type==="Identifier"}).replaceWith(t=>{let{left:e,right:p}=t.node;return r.assignmentExpression("=",r.memberExpression(e.object.object,i(e.property)),p)}),s.toSource({quote:"single"})}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
var getContainingStatement=n=>n.node.type.endsWith("Statement")?n:getContainingStatement(n.parent);function transformer(file,api){let j=api.jscodeshift,root=j(file.source),renameKey=exp=>exp.type==="Identifier"&&exp.name==="name"?j.identifier("storyName"):exp;if(root.find(j.ExportDefaultDeclaration).filter(def=>def.node.declaration.type==="ObjectExpression"&&def.node.declaration.properties.map(p=>p.key.name).includes("title")).size()===0)return root.toSource();let storyAssignments=root.find(j.AssignmentExpression).filter(exp=>{let{left,right}=exp.node;return left.type==="MemberExpression"&&left.object.type==="Identifier"&&left.property.type==="Identifier"&&left.property.name==="story"&&right.type==="ObjectExpression"});return storyAssignments.forEach(exp=>{let{left,right}=exp.node;right.properties.forEach(prop=>{getContainingStatement(exp).insertBefore(j.assignmentStatement("=",j.memberExpression(left.object,renameKey(prop.key)),prop.value))})}),storyAssignments.remove(),root.find(j.AssignmentExpression).filter(exp=>{let{left}=exp.node;return left.type==="MemberExpression"&&left.object.type==="MemberExpression"&&left.object.property.type==="Identifier"&&left.object.property.name==="story"&&left.property.type==="Identifier"}).replaceWith(exp=>{let{left,right}=exp.node;return j.assignmentExpression("=",j.memberExpression(left.object.object,renameKey(left.property)),right)}),root.toSource({quote:"single"})}export{transformer as default};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
* Convert a component's module story file into an MDX file
|
3
|
+
*
|
4
|
+
* For example:
|
5
|
+
*
|
6
|
+
* ```
|
7
|
+
* input { Button } from './Button';
|
8
|
+
* export default {
|
9
|
+
* title: 'Button'
|
10
|
+
* }
|
11
|
+
* export const story = () => <Button label="The Button" />;
|
12
|
+
* ```
|
13
|
+
*
|
14
|
+
* Becomes:
|
15
|
+
*
|
16
|
+
* ```
|
17
|
+
* import { Meta, Story } from '@storybook/addon-docs';
|
18
|
+
* input { Button } from './Button';
|
19
|
+
*
|
20
|
+
* <Meta title='Button' />
|
21
|
+
*
|
22
|
+
* <Story name='story'>
|
23
|
+
* <Button label="The Button" />
|
24
|
+
* </Story>
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
declare function transformer(file: any, api: any): any;
|
28
|
+
|
29
|
+
export { transformer as default };
|
@@ -0,0 +1,3 @@
|
|
1
|
+
var y=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var D=(s,r)=>{for(var t in r)y(s,t,{get:r[t],enumerable:!0})},M=(s,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of A(r))!C.call(s,o)&&o!==t&&y(s,o,{get:()=>r[o],enumerable:!(a=v(r,o))||a.enumerable});return s};var W=s=>M(y({},"__esModule",{value:!0}),s);var L={};D(L,{default:()=>g});module.exports=W(L);var E=require("recast"),x=require("@storybook/csf");function J(s,r){return s.__paths[0].node.program.body.map(a=>{let{code:o}=(0,E.prettyPrint)(a,r);return a.type==="JSXElement"?`${o}
|
2
|
+
`:o}).join(`
|
3
|
+
`)}function K(s){let{code:r}=(0,E.prettyPrint)(s,{});return(0,eval)(r)}function g(s,r){let t=r.jscodeshift,a=t(s.source),o={},p={};function f(n,e){return t.jsxAttribute(t.jsxIdentifier(n),e.type==="Literal"?e:t.jsxExpressionContainer(e))}function S(n){return n.type==="ArrowFunctionExpression"&&n.body.type==="JSXElement"?n.body:t.jsxExpressionContainer(n)}function b(n){let e=o[n];if(e){let i=e.properties.find(c=>c.key.name==="name");if(i&&i.value.type==="Literal")return i.value.value}return n}function I(n){let e=[],i=o[n];return i&&i.properties.forEach(c=>{let{key:l,value:d}=c;l.name!=="name"&&e.push(f(l.name,d))}),e}let u=a.find(t.ExportDefaultDeclaration).filter(n=>n.node.declaration.properties.map(e=>e.key.name).includes("title"));if(u.size()===0)return a.toSource();a.find(t.ImportDeclaration).at(-1).insertAfter(t.emptyStatement()).insertAfter(t.importDeclaration([t.importSpecifier(t.identifier("Meta")),t.importSpecifier(t.identifier("Story"))],t.literal("@storybook/addon-docs"))),a.find(t.ImportDeclaration).filter(n=>n.node.source.value==="react").remove(),u.forEach(n=>{n.node.declaration.properties.forEach(e=>{["includeStories","excludeStories"].includes(e.key.name)&&(p[e.key.name]=K(e.value))})});let j=a.find(t.ExportNamedDeclaration);j.forEach(n=>{let e=n.node.declaration.declarations[0].id.name;(0,x.isExportStory)(e,p)&&(o[e]=null)});let h=a.find(t.AssignmentExpression).filter(n=>{let{left:e}=n.node;return e.type==="MemberExpression"&&e.object.type==="Identifier"&&e.object.name in o&&e.property.type==="Identifier"&&e.property.name==="story"});return h.forEach(n=>{let{left:e,right:i}=n.node;o[e.object.name]=i}),h.remove(),u.replaceWith(n=>{let e=t.jsxIdentifier("Meta"),i=[];n.node.declaration.properties.forEach(l=>{let{key:d,value:m}=l;["includeStories","excludeStories"].includes(d.name)||i.push(f(d.name,m))});let c=t.jsxOpeningElement(e,i);return c.selfClosing=!0,t.jsxElement(c)}),j.replaceWith(n=>{let e=n.node.declaration.declarations[0].id.name;if(!(0,x.isExportStory)(e,p))return n.node;let i=t.jsxIdentifier("Story"),c=b(e),l=[f("name",t.literal(c)),...I(e)],d=t.jsxOpeningElement(i,l),m=t.jsxClosingElement(i),k=[S(n.node.declaration.declarations[0].init)];return t.jsxElement(d,m,k)}),J(a,{quote:"single",trailingComma:"true",tabWidth:2})}0&&(module.exports={});
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import{prettyPrint}from"recast";import{isExportStory}from"@storybook/csf";function exportMdx(root,options){return root.__paths[0].node.program.body.map(n=>{let{code}=prettyPrint(n,options);return n.type==="JSXElement"?`${code}
|
2
|
+
`:code}).join(`
|
3
|
+
`)}function parseIncludeExclude(prop){let{code}=prettyPrint(prop,{});return(0,eval)(code)}function transformer(file,api){let j=api.jscodeshift,root=j(file.source),storyKeyToStory={},meta={};function makeAttr(key,val){return j.jsxAttribute(j.jsxIdentifier(key),val.type==="Literal"?val:j.jsxExpressionContainer(val))}function getStoryContents(node){return node.type==="ArrowFunctionExpression"&&node.body.type==="JSXElement"?node.body:j.jsxExpressionContainer(node)}function getName(storyKey){let story=storyKeyToStory[storyKey];if(story){let name=story.properties.find(prop=>prop.key.name==="name");if(name&&name.value.type==="Literal")return name.value.value}return storyKey}function getStoryAttrs(storyKey){let attrs=[],story=storyKeyToStory[storyKey];return story&&story.properties.forEach(prop=>{let{key,value}=prop;key.name!=="name"&&attrs.push(makeAttr(key.name,value))}),attrs}let defaultExportWithTitle=root.find(j.ExportDefaultDeclaration).filter(def=>def.node.declaration.properties.map(p=>p.key.name).includes("title"));if(defaultExportWithTitle.size()===0)return root.toSource();root.find(j.ImportDeclaration).at(-1).insertAfter(j.emptyStatement()).insertAfter(j.importDeclaration([j.importSpecifier(j.identifier("Meta")),j.importSpecifier(j.identifier("Story"))],j.literal("@storybook/addon-docs"))),root.find(j.ImportDeclaration).filter(decl=>decl.node.source.value==="react").remove(),defaultExportWithTitle.forEach(exp=>{exp.node.declaration.properties.forEach(p=>{["includeStories","excludeStories"].includes(p.key.name)&&(meta[p.key.name]=parseIncludeExclude(p.value))})});let namedExports=root.find(j.ExportNamedDeclaration);namedExports.forEach(exp=>{let storyKey=exp.node.declaration.declarations[0].id.name;isExportStory(storyKey,meta)&&(storyKeyToStory[storyKey]=null)});let storyAssignments=root.find(j.AssignmentExpression).filter(exp=>{let{left}=exp.node;return left.type==="MemberExpression"&&left.object.type==="Identifier"&&left.object.name in storyKeyToStory&&left.property.type==="Identifier"&&left.property.name==="story"});return storyAssignments.forEach(exp=>{let{left,right}=exp.node;storyKeyToStory[left.object.name]=right}),storyAssignments.remove(),defaultExportWithTitle.replaceWith(exp=>{let jsxId=j.jsxIdentifier("Meta"),attrs=[];exp.node.declaration.properties.forEach(prop=>{let{key,value}=prop;["includeStories","excludeStories"].includes(key.name)||attrs.push(makeAttr(key.name,value))});let opening=j.jsxOpeningElement(jsxId,attrs);return opening.selfClosing=!0,j.jsxElement(opening)}),namedExports.replaceWith(exp=>{let storyKey=exp.node.declaration.declarations[0].id.name;if(!isExportStory(storyKey,meta))return exp.node;let jsxId=j.jsxIdentifier("Story"),name=getName(storyKey),attributes=[makeAttr("name",j.literal(name)),...getStoryAttrs(storyKey)],opening=j.jsxOpeningElement(jsxId,attributes),closing=j.jsxClosingElement(jsxId),children=[getStoryContents(exp.node.declaration.declarations[0].init)];return j.jsxElement(opening,closing,children)}),exportMdx(root,{quote:"single",trailingComma:"true",tabWidth:2})}export{transformer as default};
|
@@ -0,0 +1 @@
|
|
1
|
+
var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},v=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of d(t))!k.call(e,r)&&r!==o&&c(e,r,{get:()=>t[r],enumerable:!(i=p(t,r))||i.enumerable});return e};var y=e=>v(c({},"__esModule",{value:!0}),e);var D={};b(D,{default:()=>f});module.exports=y(D);function f(e,t){let o=t.jscodeshift,i=(n,a)=>o.importDeclaration(n.map(s=>o.importSpecifier(o.identifier(s))),o.literal(a)),r={action:[["action"],"@storybook/addon-actions"],linkTo:[["linkTo"],"@storybook/addon-links"]};return o(e.source).find(o.ImportDeclaration).filter(n=>n.value.source.value==="@storybook/react").forEach(n=>{let a=n.value;a.specifiers=a.specifiers.filter(s=>{let l=r[s.local.name];if(l){let[m,u]=l;return n.insertAfter(i(m,u)),!1}return s})}).toSource({quote:"single"})}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
function transformer(file,api){let j=api.jscodeshift,createImportDeclaration=(specifiers,source)=>j.importDeclaration(specifiers.map(s=>j.importSpecifier(j.identifier(s))),j.literal(source)),deprecates={action:[["action"],"@storybook/addon-actions"],linkTo:[["linkTo"],"@storybook/addon-links"]};return j(file.source).find(j.ImportDeclaration).filter(i=>i.value.source.value==="@storybook/react").forEach(i=>{let importStatement=i.value;importStatement.specifiers=importStatement.specifiers.filter(specifier=>{let item=deprecates[specifier.local.name];if(item){let[specifiers,moduleName]=item;return i.insertAfter(createImportDeclaration(specifiers,moduleName)),!1}return specifier})}).toSource({quote:"single"})}export{transformer as default};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Convert a legacy story API to component story format
|
3
|
+
*
|
4
|
+
* For example:
|
5
|
+
*
|
6
|
+
* ```
|
7
|
+
* input { Button } from './Button';
|
8
|
+
* storiesOf('Button', module).add('story', () => <Button label="The Button" />);
|
9
|
+
* ```
|
10
|
+
*
|
11
|
+
* Becomes:
|
12
|
+
*
|
13
|
+
* ```
|
14
|
+
* input { Button } from './Button';
|
15
|
+
* export default {
|
16
|
+
* title: 'Button'
|
17
|
+
* }
|
18
|
+
* export const story = () => <Button label="The Button" />;
|
19
|
+
*
|
20
|
+
* NOTES: only support chained storiesOf() calls
|
21
|
+
*/
|
22
|
+
declare function transformer(file: any, api: any, options: any): any;
|
23
|
+
|
24
|
+
export { transformer as default };
|
@@ -0,0 +1 @@
|
|
1
|
+
var M=Object.create;var v=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var H=(o,n)=>{for(var l in n)v(o,l,{get:n[l],enumerable:!0})},$=(o,n,l,h)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of q(n))!G.call(o,e)&&e!==l&&v(o,e,{get:()=>n[e],enumerable:!(h=V(n,e))||h.enumerable});return o};var D=(o,n,l)=>(l=o!=null?M(B(o)):{},$(n||!o||!o.__esModule?v(l,"default",{value:o,enumerable:!0}):l,o)),K=o=>$(v({},"__esModule",{value:!0}),o);var Q={};H(Q,{default:()=>F});module.exports=K(Q);var P=D(require("prettier")),S=require("@storybook/node-logger"),A=require("@storybook/csf");var w=D(require("lodash/camelCase")),I=D(require("lodash/upperFirst")),N=o=>{let n=(0,I.default)((0,w.default)(o));return/^\d/.test(n)&&(n=`_${n}`),/^\d/.test(n)&&(n=`_${n}`),n};function O(o){let n={babylon:"babel",flow:"flow",ts:"typescript",tsx:"typescript"};return o&&n[o]||"babel"}function F(o,n,l){let h=["ts","tsx"].includes(l.parser)?"StringLiteral":"Literal",e=n.jscodeshift,c=e(o.source);function L(t){if(!t)return{};if(!t.properties)return{storyParams:t};let s=t.properties.find(i=>i.key.name==="decorators");if(!s)return{storyParams:t};s=s.value;let a={...t};return a.properties=a.properties.filter(i=>i.key.name!=="decorators"),a.properties.length===0?{storyDecorators:s}:{storyParams:a,storyDecorators:s}}function T(t,s){let a=e(t),i=[],d=[],y=[];a.find(e.CallExpression).filter(r=>r.node.callee.property&&r.node.callee.property.name==="addDecorator").forEach(r=>{let p=r.node.arguments[0];y.push(p)}),y.length>0&&(y.reverse(),d.push(e.property("init",e.identifier("decorators"),e.arrayExpression(y))));let u=[];a.find(e.CallExpression).filter(r=>r.node.callee.property&&r.node.callee.property.name==="addParameters").forEach(r=>{let p=[...r.node.arguments[0].properties];p.reverse(),p.forEach(f=>u.push(f))}),u.length>0&&(u.reverse(),d.push(e.property("init",e.identifier("parameters"),e.objectExpression(u)))),s.length>0&&d.push(e.property("init",e.identifier("excludeStories"),e.arrayExpression(s.map(r=>e.literal(r))))),a.find(e.CallExpression).filter(r=>r.node.callee.name==="storiesOf").filter(r=>r.node.arguments.length>0&&r.node.arguments[0].type===h).forEach(r=>{let p=r.node.arguments[0].value;i.push(e.exportDefaultDeclaration(e.objectExpression([e.property("init",e.identifier("title"),e.literal(p)),...d])))});let m=[];a.find(e.CallExpression).filter(r=>r.node.callee.property&&r.node.callee.property.name==="add").filter(r=>r.node.arguments.length>=2&&r.node.arguments[0].type===h).forEach(r=>m.push(r)),m.reverse(),m.push(t);let E=new Set;c.find(e.Identifier).forEach(({value:r})=>E.add(r.name)),m.forEach(r=>{let p=r.node.arguments[0].value,f=N(p);for(;E.has(f);)f=`_${f}`;E.add(f),(0,A.storyNameFromExport)(f)===p&&(p=null);let R=r.node.arguments[1];i.push(e.exportDeclaration(!1,e.variableDeclaration("const",[e.variableDeclarator(e.identifier(f),R)])));let x=[];if(p&&x.push(e.property("init",e.identifier("name"),e.literal(p))),r.node.arguments.length>2){let _=r.node.arguments[2],{storyParams:k,storyDecorators:z}=L(_);k&&x.push(e.property("init",e.identifier("parameters"),k)),z&&x.push(e.property("init",e.identifier("decorators"),z))}x.length>0&&i.push(e.assignmentStatement("=",e.memberExpression(e.identifier(f),e.identifier("story")),e.objectExpression(x)))});let j=t.parent.node.type==="VariableDeclarator"?t.parent.parent:t.parent;i.reverse(),i.forEach(r=>j.insertAfter(r)),e(j).remove()}let b=c.find(e.CallExpression).filter(t=>t.node.callee.name==="storiesOf");if(c.find(e.ExportDefaultDeclaration).size()>0)return b.size()>0&&S.logger.warn(`Found ${b.size()} 'storiesOf' calls but existing default export, SKIPPING: '${o.path}'`),c.toSource();let g=[];c.find(e.ExportNamedDeclaration).forEach(t=>{let{declaration:s,specifiers:a}=t.node;if(s){let{id:i,declarations:d}=s;d?d.forEach(y=>{let{name:u,properties:m}=y.id;u?g.push(u):m&&m.forEach(E=>g.push(E.key.name))}):i&&g.push(i.name)}else a&&a.forEach(i=>g.push(i.exported.name))}),c.find(e.CallExpression).filter(t=>t.node.callee.property&&t.node.callee.property.name==="add").filter(t=>t.node.arguments.length>=2&&t.node.arguments[0].type===h).filter(t=>["ExpressionStatement","VariableDeclarator"].includes(t.parentPath.node.type)).forEach(t=>T(t,g)),c.find(e.ImportSpecifier).filter(t=>t.node.imported.name==="storiesOf"&&t.parent.node.source.value.startsWith("@storybook/")).forEach(t=>{let s=t.parent.node.specifiers.length>1?t:t.parent;e(s).remove()});let C=c.toSource({trailingComma:!0,quote:"single",tabWidth:2});if(b.size()>1)return S.logger.warn(`Found ${b.size()} 'storiesOf' calls, PLEASE FIX BY HAND: '${o.path}'`),C;let W=P.default.resolveConfig.sync(".",{editorconfig:!0})||{printWidth:100,tabWidth:2,bracketSpacing:!0,trailingComma:"es5",singleQuote:!0};return P.default.format(C,{...W,parser:O(l.parser)})}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
import{jscodeshiftToPrettierParser,sanitizeName}from"../chunk-CO6EPEMB.mjs";import prettier from"prettier";import{logger}from"@storybook/node-logger";import{storyNameFromExport}from"@storybook/csf";function transformer(file,api,options){let LITERAL=["ts","tsx"].includes(options.parser)?"StringLiteral":"Literal",j=api.jscodeshift,root=j(file.source);function extractDecorators(parameters){if(!parameters)return{};if(!parameters.properties)return{storyParams:parameters};let storyDecorators=parameters.properties.find(p=>p.key.name==="decorators");if(!storyDecorators)return{storyParams:parameters};storyDecorators=storyDecorators.value;let storyParams={...parameters};return storyParams.properties=storyParams.properties.filter(p=>p.key.name!=="decorators"),storyParams.properties.length===0?{storyDecorators}:{storyParams,storyDecorators}}function convertToModuleExports(path,originalExports2){let base=j(path),statements=[],extraExports=[],decorators=[];base.find(j.CallExpression).filter(call=>call.node.callee.property&&call.node.callee.property.name==="addDecorator").forEach(add=>{let decorator=add.node.arguments[0];decorators.push(decorator)}),decorators.length>0&&(decorators.reverse(),extraExports.push(j.property("init",j.identifier("decorators"),j.arrayExpression(decorators))));let parameters=[];base.find(j.CallExpression).filter(call=>call.node.callee.property&&call.node.callee.property.name==="addParameters").forEach(add=>{let params=[...add.node.arguments[0].properties];params.reverse(),params.forEach(prop=>parameters.push(prop))}),parameters.length>0&&(parameters.reverse(),extraExports.push(j.property("init",j.identifier("parameters"),j.objectExpression(parameters)))),originalExports2.length>0&&extraExports.push(j.property("init",j.identifier("excludeStories"),j.arrayExpression(originalExports2.map(exp=>j.literal(exp))))),base.find(j.CallExpression).filter(call=>call.node.callee.name==="storiesOf").filter(call=>call.node.arguments.length>0&&call.node.arguments[0].type===LITERAL).forEach(storiesOf=>{let title=storiesOf.node.arguments[0].value;statements.push(j.exportDefaultDeclaration(j.objectExpression([j.property("init",j.identifier("title"),j.literal(title)),...extraExports])))});let adds=[];base.find(j.CallExpression).filter(add=>add.node.callee.property&&add.node.callee.property.name==="add").filter(add=>add.node.arguments.length>=2&&add.node.arguments[0].type===LITERAL).forEach(add=>adds.push(add)),adds.reverse(),adds.push(path);let identifiers=new Set;root.find(j.Identifier).forEach(({value})=>identifiers.add(value.name)),adds.forEach(add=>{let name=add.node.arguments[0].value,key=sanitizeName(name);for(;identifiers.has(key);)key=`_${key}`;identifiers.add(key),storyNameFromExport(key)===name&&(name=null);let val=add.node.arguments[1];statements.push(j.exportDeclaration(!1,j.variableDeclaration("const",[j.variableDeclarator(j.identifier(key),val)])));let storyAnnotations=[];if(name&&storyAnnotations.push(j.property("init",j.identifier("name"),j.literal(name))),add.node.arguments.length>2){let originalStoryParams=add.node.arguments[2],{storyParams,storyDecorators}=extractDecorators(originalStoryParams);storyParams&&storyAnnotations.push(j.property("init",j.identifier("parameters"),storyParams)),storyDecorators&&storyAnnotations.push(j.property("init",j.identifier("decorators"),storyDecorators))}storyAnnotations.length>0&&statements.push(j.assignmentStatement("=",j.memberExpression(j.identifier(key),j.identifier("story")),j.objectExpression(storyAnnotations)))});let stmt=path.parent.node.type==="VariableDeclarator"?path.parent.parent:path.parent;statements.reverse(),statements.forEach(s=>stmt.insertAfter(s)),j(stmt).remove()}let initialStoriesOf=root.find(j.CallExpression).filter(call=>call.node.callee.name==="storiesOf");if(root.find(j.ExportDefaultDeclaration).size()>0)return initialStoriesOf.size()>0&&logger.warn(`Found ${initialStoriesOf.size()} 'storiesOf' calls but existing default export, SKIPPING: '${file.path}'`),root.toSource();let originalExports=[];root.find(j.ExportNamedDeclaration).forEach(exp=>{let{declaration,specifiers}=exp.node;if(declaration){let{id,declarations}=declaration;declarations?declarations.forEach(decl=>{let{name,properties}=decl.id;name?originalExports.push(name):properties&&properties.forEach(prop=>originalExports.push(prop.key.name))}):id&&originalExports.push(id.name)}else specifiers&&specifiers.forEach(spec=>originalExports.push(spec.exported.name))}),root.find(j.CallExpression).filter(add=>add.node.callee.property&&add.node.callee.property.name==="add").filter(add=>add.node.arguments.length>=2&&add.node.arguments[0].type===LITERAL).filter(add=>["ExpressionStatement","VariableDeclarator"].includes(add.parentPath.node.type)).forEach(path=>convertToModuleExports(path,originalExports)),root.find(j.ImportSpecifier).filter(spec=>spec.node.imported.name==="storiesOf"&&spec.parent.node.source.value.startsWith("@storybook/")).forEach(spec=>{let toRemove=spec.parent.node.specifiers.length>1?spec:spec.parent;j(toRemove).remove()});let source=root.toSource({trailingComma:!0,quote:"single",tabWidth:2});if(initialStoriesOf.size()>1)return logger.warn(`Found ${initialStoriesOf.size()} 'storiesOf' calls, PLEASE FIX BY HAND: '${file.path}'`),source;let prettierConfig=prettier.resolveConfig.sync(".",{editorconfig:!0})||{printWidth:100,tabWidth:2,bracketSpacing:!0,trailingComma:"es5",singleQuote:!0};return prettier.format(source,{...prettierConfig,parser:jscodeshiftToPrettierParser(options.parser)})}export{transformer as default};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* Takes the deprecated addon-info API, addWithInfo, and
|
3
|
+
* converts to the new withInfo API.
|
4
|
+
*
|
5
|
+
* Example of deprecated addWithInfo API:
|
6
|
+
*
|
7
|
+
* storiesOf('Button')
|
8
|
+
* .addWithInfo(
|
9
|
+
* 'story name',
|
10
|
+
* 'Story description.',
|
11
|
+
* () => (
|
12
|
+
* <Button label="The Button" />
|
13
|
+
* )
|
14
|
+
* )
|
15
|
+
*
|
16
|
+
* Converts to the new withInfo API:
|
17
|
+
*
|
18
|
+
* storiesOf('Button')
|
19
|
+
* .add('story name', withInfo(
|
20
|
+
* 'Story description.'
|
21
|
+
* )(() => (
|
22
|
+
* <Button label="The Button" />
|
23
|
+
* )))
|
24
|
+
*/
|
25
|
+
declare function transformer(file: any, api: any): any;
|
26
|
+
|
27
|
+
export { transformer as default };
|
@@ -0,0 +1 @@
|
|
1
|
+
var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var I=(o,e)=>{for(var t in e)f(o,t,{get:e[t],enumerable:!0})},E=(o,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of h(e))!x.call(o,r)&&r!==t&&f(o,r,{get:()=>e[r],enumerable:!(i=m(e,r))||i.enumerable});return o};var y=o=>E(f({},"__esModule",{value:!0}),o);var W={};I(W,{default:()=>d});module.exports=y(W);function d(o,e){let t=e.jscodeshift,i=t(o.source),r=n=>n[3]===void 0?n[2]===void 0?[n[0]]:[n[1]]:[t.objectExpression([t.property("init",t.identifier("text"),n[1]),...n[3].properties])],a=n=>{let{node:s}=n,c=s.arguments,u=c[2]?c[2]:c[1];return s.callee.property.name="add",s.arguments=[c[0],t.callExpression(t.callExpression(t.identifier("withInfo"),r(c)),[u])],s},l=()=>{i.find(t.ImportDeclaration).filter(s=>s.node.source.value==="@storybook/addon-info").size()||i.find(t.ImportDeclaration).at(-1).insertAfter(t.importDeclaration([t.importSpecifier(t.identifier("withInfo"))],t.literal("@storybook/addon-info")))},p=i.find(t.CallExpression,{callee:{property:{name:"addWithInfo"}}});return p.size()&&(l(),p.replaceWith(a)),i.toSource()}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
import{transformer}from"../chunk-B5FMQ3BX.mjs";export{transformer as default};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
declare function transformer(file: any, api: any): any;
|
2
|
+
declare const packageNames: {
|
3
|
+
'@kadira/react-storybook-decorator-centered': string;
|
4
|
+
'@kadira/storybook-addons': string;
|
5
|
+
'@kadira/storybook-addon-actions': string;
|
6
|
+
'@kadira/storybook-addon-comments': string;
|
7
|
+
'@kadira/storybook-addon-graphql': string;
|
8
|
+
'@kadira/storybook-addon-info': string;
|
9
|
+
'@kadira/storybook-addon-knobs': string;
|
10
|
+
'@kadira/storybook-addon-links': string;
|
11
|
+
'@kadira/storybook-addon-notes': string;
|
12
|
+
'@kadira/storybook-addon-options': string;
|
13
|
+
'@kadira/storybook-channels': string;
|
14
|
+
'@kadira/storybook-channel-postmsg': string;
|
15
|
+
'@kadira/storybook-channel-websocket': string;
|
16
|
+
'@kadira/storybook-ui': string;
|
17
|
+
'@kadira/react-native-storybook': string;
|
18
|
+
'@kadira/react-storybook': string;
|
19
|
+
'@kadira/getstorybook': string;
|
20
|
+
'@kadira/storybook': string;
|
21
|
+
storyshots: string;
|
22
|
+
getstorybook: string;
|
23
|
+
};
|
24
|
+
|
25
|
+
export { transformer as default, packageNames };
|
@@ -0,0 +1 @@
|
|
1
|
+
var k=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var u=(t,o)=>{for(var r in o)k(t,r,{get:o[r],enumerable:!0})},m=(t,o,r,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of l(o))!h.call(t,s)&&s!==r&&k(t,s,{get:()=>o[s],enumerable:!(n=p(o,s))||n.enumerable});return t};var g=t=>m(k({},"__esModule",{value:!0}),t);var f={};u(f,{default:()=>c,packageNames:()=>d});module.exports=g(f);var d={"@kadira/react-storybook-decorator-centered":"@storybook/addon-centered","@kadira/storybook-addons":"@storybook/preview-api","@kadira/storybook-addon-actions":"@storybook/addon-actions","@kadira/storybook-addon-comments":"@storybook/addon-comments","@kadira/storybook-addon-graphql":"@storybook/addon-graphql","@kadira/storybook-addon-info":"@storybook/addon-info","@kadira/storybook-addon-knobs":"@storybook/addon-knobs","@kadira/storybook-addon-links":"@storybook/addon-links","@kadira/storybook-addon-notes":"@storybook/addon-notes","@kadira/storybook-addon-options":"@storybook/addon-options","@kadira/storybook-channels":"@storybook/channels","@kadira/storybook-channel-postmsg":"@storybook/channel-postmessage","@kadira/storybook-channel-websocket":"@storybook/channel-websocket","@kadira/storybook-ui":"@storybook/manager","@kadira/react-native-storybook":"@storybook/react-native","@kadira/react-storybook":"@storybook/react","@kadira/getstorybook":"@storybook/cli","@kadira/storybook":"@storybook/react",storyshots:"@storybook/addon-storyshots",getstorybook:"@storybook/cli"};function c(t,o){let r=o.jscodeshift,n=Object.keys(d),s=a=>n.find(e=>a.match(e)),b=a=>{let e=s(a);if(e){let i=d[e];return a.replace(e,i)}return a},y=a=>(a.node.source.value=b(a.node.source.value),a.node);return r(t.source).find(r.ImportDeclaration).replaceWith(y).toSource({quote:"single"})}0&&(module.exports={packageNames});
|
@@ -0,0 +1 @@
|
|
1
|
+
import{packageNames,transformer}from"../chunk-3OPQTROG.mjs";export{transformer as default,packageNames};
|
@@ -0,0 +1 @@
|
|
1
|
+
var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var p=(r,t)=>{for(var i in t)l(r,i,{get:t[i],enumerable:!0})},g=(r,t,i,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!f.call(r,o)&&o!==i&&l(r,o,{get:()=>t[o],enumerable:!(a=c(t,o))||a.enumerable});return r};var m=r=>g(l({},"__esModule",{value:!0}),r);var v={};p(v,{default:()=>u});module.exports=m(v);function s(r){return r.replace(/[|.]/g,"/")}function u(r,t,i){let a=t.jscodeshift,o=a(r.source);return o.find(a.CallExpression).filter(e=>e.node.callee.name==="storiesOf").filter(e=>e.node.arguments.length>0&&["Literal","StringLiteral"].includes(e.node.arguments[0].type)).forEach(e=>{let n=e.node.arguments[0];n.value=s(n.value)}),o.find(a.ExportDefaultDeclaration).filter(e=>e.node.declaration.properties.map(n=>n.key.name).includes("title")).forEach(e=>{e.node.declaration&&e.node.declaration.properties&&e.node.declaration.properties.forEach(n=>{n.key.name==="title"&&(n.value.value=s(n.value.value))})}),o.toSource({quote:"single"})}0&&(module.exports={});
|
@@ -0,0 +1 @@
|
|
1
|
+
function upgradeSeparator(path){return path.replace(/[|.]/g,"/")}function transformer(file,api,options){let j=api.jscodeshift,root=j(file.source);return root.find(j.CallExpression).filter(call=>call.node.callee.name==="storiesOf").filter(call=>call.node.arguments.length>0&&["Literal","StringLiteral"].includes(call.node.arguments[0].type)).forEach(call=>{let arg0=call.node.arguments[0];arg0.value=upgradeSeparator(arg0.value)}),root.find(j.ExportDefaultDeclaration).filter(def=>def.node.declaration.properties.map(p=>p.key.name).includes("title")).forEach(def=>{def.node.declaration&&def.node.declaration.properties&&def.node.declaration.properties.forEach(p=>{p.key.name==="title"&&(p.value.value=upgradeSeparator(p.value.value))})}),root.toSource({quote:"single"})}export{transformer as default};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/codemod",
|
3
|
-
"version": "7.0.0-beta.
|
3
|
+
"version": "7.0.0-beta.4",
|
4
4
|
"description": "A collection of codemod scripts written with JSCodeshift",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -26,11 +26,19 @@
|
|
26
26
|
"import": "./dist/index.mjs",
|
27
27
|
"types": "./dist/index.d.ts"
|
28
28
|
},
|
29
|
+
"./dist/transforms/add-component-parameters.js": "./dist/transforms/add-component-parameters.js",
|
30
|
+
"./dist/transforms/csf-2-to-3.js": "./dist/transforms/csf-2-to-3.js",
|
31
|
+
"./dist/transforms/csf-hoist-story-annotations.js": "./dist/transforms/csf-hoist-story-annotations.js",
|
32
|
+
"./dist/transforms/csf-to-mdx.js": "./dist/transforms/csf-to-mdx.js",
|
33
|
+
"./dist/transforms/move-builtin-addons.js": "./dist/transforms/move-builtin-addons.js",
|
34
|
+
"./dist/transforms/storiesof-to-csf.js": "./dist/transforms/storiesof-to-csf.js",
|
35
|
+
"./dist/transforms/update-addon-info.js": "./dist/transforms/update-addon-info.js",
|
36
|
+
"./dist/transforms/update-organisation-name.js": "./dist/transforms/update-organisation-name.js",
|
37
|
+
"./dist/transforms/upgrade-hierarchy-separators.js": "./dist/transforms/upgrade-hierarchy-separators.js",
|
29
38
|
"./package.json": "./package.json"
|
30
39
|
},
|
31
40
|
"main": "dist/index.js",
|
32
41
|
"module": "dist/index.mjs",
|
33
|
-
"jsnext:main": "src/index.js",
|
34
42
|
"types": "dist/index.d.ts",
|
35
43
|
"scripts": {
|
36
44
|
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
@@ -39,9 +47,9 @@
|
|
39
47
|
"dependencies": {
|
40
48
|
"@babel/types": "^7.20.2",
|
41
49
|
"@storybook/csf": "next",
|
42
|
-
"@storybook/csf-tools": "7.0.0-beta.
|
43
|
-
"@storybook/node-logger": "7.0.0-beta.
|
44
|
-
"@storybook/types": "7.0.0-beta.
|
50
|
+
"@storybook/csf-tools": "7.0.0-beta.4",
|
51
|
+
"@storybook/node-logger": "7.0.0-beta.4",
|
52
|
+
"@storybook/types": "7.0.0-beta.4",
|
45
53
|
"cross-spawn": "^7.0.3",
|
46
54
|
"globby": "^11.0.2",
|
47
55
|
"jscodeshift": "^0.13.1",
|
@@ -61,8 +69,17 @@
|
|
61
69
|
"bundler": {
|
62
70
|
"platform": "node",
|
63
71
|
"entries": [
|
64
|
-
"./src/index.js"
|
72
|
+
"./src/index.js",
|
73
|
+
"./src/transforms/add-component-parameters.js",
|
74
|
+
"./src/transforms/csf-2-to-3.ts",
|
75
|
+
"./src/transforms/csf-hoist-story-annotations.js",
|
76
|
+
"./src/transforms/csf-to-mdx.js",
|
77
|
+
"./src/transforms/move-builtin-addons.js",
|
78
|
+
"./src/transforms/storiesof-to-csf.js",
|
79
|
+
"./src/transforms/update-addon-info.js",
|
80
|
+
"./src/transforms/update-organisation-name.js",
|
81
|
+
"./src/transforms/upgrade-hierarchy-separators.js"
|
65
82
|
]
|
66
83
|
},
|
67
|
-
"gitHead": "
|
84
|
+
"gitHead": "4d869ed6f7166e0d06f2bef5a1b872fa77a0cf2d"
|
68
85
|
}
|
File without changes
|
package/src/transforms/__testfixtures__/mdx-to-csf/{component-id.input.js → component-id.input.mdx}
RENAMED
File without changes
|
package/src/transforms/__testfixtures__/mdx-to-csf/{decorators.input.js → decorators.input.mdx}
RENAMED
File without changes
|
File without changes
|
package/src/transforms/__testfixtures__/mdx-to-csf/{parameters.input.js → parameters.input.mdx}
RENAMED
File without changes
|
package/src/transforms/__testfixtures__/mdx-to-csf/{plaintext.input.js → plaintext.input.mdx}
RENAMED
File without changes
|
File without changes
|
File without changes
|
package/src/transforms/__testfixtures__/mdx-to-csf/{story-refs.input.js → story-refs.input.mdx}
RENAMED
File without changes
|
package/tsconfig.json
CHANGED