@storybook/codemod 7.0.0-alpha.48 → 7.0.0-alpha.49
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import b from"fs";import g from"path";import{promisify as x}from"util";import w from"globby";import{sync as $}from"cross-spawn";import R from"lodash/camelCase";import A from"lodash/upperFirst";function l(t){let i={babylon:"babel",flow:"flow",ts:"typescript",tsx:"typescript"};return t&&i[t]||"babel"}var k={"@kadira/react-storybook-decorator-centered":"@storybook/addon-centered","@kadira/storybook-addons":"@storybook/addons","@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 m(t,i){let o=i.jscodeshift,d=Object.keys(k),a=e=>d.find(r=>e.match(r)),c=e=>{let r=a(e);if(r){let n=k[r];return e.replace(r,n)}return e},f=e=>(e.node.source.value=c(e.node.source.value),e.node);return o(t.source).find(o.ImportDeclaration).replaceWith(f).toSource({quote:"single"})}function y(t,i){let o=i.jscodeshift,d=o(t.source),a=r=>r[3]===void 0?r[2]===void 0?[r[0]]:[r[1]]:[o.objectExpression([o.property("init",o.identifier("text"),r[1]),...r[3].properties])],c=r=>{let{node:n}=r,s=n.arguments,p=s[2]?s[2]:s[1];return n.callee.property.name="add",n.arguments=[s[0],o.callExpression(o.callExpression(o.identifier("withInfo"),a(s)),[p])],n},f=()=>{d.find(o.ImportDeclaration).filter(n=>n.node.source.value==="@storybook/addon-info").size()||d.find(o.ImportDeclaration).at(-1).insertAfter(o.importDeclaration([o.importSpecifier(o.identifier("withInfo"))],o.literal("@storybook/addon-info")))},e=d.find(o.CallExpression,{callee:{property:{name:"addWithInfo"}}});return e.size()&&(f(),e.replaceWith(c)),d.toSource()}var u=`${__dirname}/transforms`;function I(){return b.readdirSync(u).filter(t=>t.endsWith(".js")).map(t=>t.slice(0,-3))}var j=x(b.rename);async function E(t,i,o,{logger:d}){let a=t.replace(i,o);return d.log(`Rename: ${t} ${a}`),j(t,a)}async function z(t,{glob:i,logger:o,dryRun:d,rename:a,parser:c}){if(!I().includes(t))throw new Error(`Unknown codemod ${t}. Run --list for options.`);let e=null;if(a&&(e=a.split(":"),e.length!==2))throw new Error(`Codemod rename: expected format "from:to", got "${a}"`);let r=c;if(!c){let s=g.extname(i).slice(1);l(s)!=="babel"&&(r=s)}let n=await w([i,"!**/node_modules","!**/dist"]);if(o.log(`=> Applying ${t}: ${n.length} files`),!d){let s=r?["--parser",r]:[];$("npx",["jscodeshift","-t",`${u}/${t}.js`,...s,...n],{stdio:"inherit",shell:!0})}if(e){let[s,p]=e;o.log(`=> Renaming ${a}: ${n.length} files`),await Promise.all(n.map(h=>E(h,new RegExp(`${s}$`),p,{logger:o})))}}export{I as listCodemods,k as packageNames,z as runCodemod,y as updateAddonInfo,m as updateOrganisationName};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/codemod",
|
3
|
-
"version": "7.0.0-alpha.
|
3
|
+
"version": "7.0.0-alpha.49",
|
4
4
|
"description": "A collection of codemod scripts written with JSCodeshift",
|
5
5
|
"keywords": [
|
6
6
|
"storybook"
|
@@ -39,9 +39,9 @@
|
|
39
39
|
"dependencies": {
|
40
40
|
"@babel/types": "^7.12.11",
|
41
41
|
"@storybook/csf": "next",
|
42
|
-
"@storybook/csf-tools": "7.0.0-alpha.
|
43
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
44
|
-
"@storybook/types": "7.0.0-alpha.
|
42
|
+
"@storybook/csf-tools": "7.0.0-alpha.49",
|
43
|
+
"@storybook/node-logger": "7.0.0-alpha.49",
|
44
|
+
"@storybook/types": "7.0.0-alpha.49",
|
45
45
|
"cross-spawn": "^7.0.3",
|
46
46
|
"globby": "^11.0.2",
|
47
47
|
"jscodeshift": "^0.13.1",
|
@@ -64,5 +64,5 @@
|
|
64
64
|
"./src/index.js"
|
65
65
|
]
|
66
66
|
},
|
67
|
-
"gitHead": "
|
67
|
+
"gitHead": "d7eb433300cac55d3c7256c8181eb6fd7a47b4c8"
|
68
68
|
}
|