@seed-design/codemod 0.0.15 → 0.0.17
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/bin/index.cjs +66 -0
- package/bin/transforms/migrate-icons/index.js +36 -0
- package/bin/transforms/replace-color-design-token/index.js +17 -0
- package/bin/transforms/replace-color-prop/index.js +17 -0
- package/bin/transforms/replace-css-color-variable/index.js +50 -0
- package/bin/transforms/replace-css-typography-variable/index.js +50 -0
- package/bin/transforms/replace-tailwind-color/index.js +17 -0
- package/bin/transforms/replace-tailwind-typography/index.js +17 -0
- package/bin/transforms/replace-text-component/index.js +17 -0
- package/bin/transforms/replace-typography-design-token/index.js +17 -0
- package/package.json +4 -4
- package/bin/index.mjs +0 -73
- package/bin/transforms/migrate-icons/index.mjs +0 -158
- package/bin/transforms/replace-color-design-token/index.mjs +0 -17
- package/bin/transforms/replace-color-prop/index.mjs +0 -17
- package/bin/transforms/replace-css-color-variable/index.mjs +0 -50
- package/bin/transforms/replace-css-typography-variable/index.mjs +0 -50
- package/bin/transforms/replace-tailwind-color/index.mjs +0 -17
- package/bin/transforms/replace-tailwind-typography/index.mjs +0 -17
- package/bin/transforms/replace-text-component/index.mjs +0 -17
- package/bin/transforms/replace-typography-design-token/index.mjs +0 -17
@@ -0,0 +1,17 @@
|
|
1
|
+
var E=Object.create;var v=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var r in e)v(t,r,{get:e[r],enumerable:!0})},C=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of D(e))!j.call(t,l)&&l!==r&&v(t,l,{get:()=>e[l],enumerable:!(a=_(e,l))||a.enumerable});return t};var L=(t,e,r)=>(r=t!=null?E(M(t)):{},C(e||!t||!t.__esModule?v(r,"default",{value:t,enumerable:!0}):r,t)),I=t=>C(v({},"__esModule",{value:!0}),t);var Q={};A(Q,{default:()=>K});module.exports=I(Q);var k=[{previous:"$semantic.typography.h1",next:[],description:"Deprecated"},{previous:"$semantic.typography.h2",next:[],description:"Deprecated"},{previous:"$semantic.typography.h3",next:[],description:"Deprecated"},{previous:"$semantic.typography.h4",next:["t10Bold","screenTitle"],description:"\uC904\uAC04\uACA9 -0.1px"},{previous:"$semantic.typography.title1Bold",next:["t9Bold"],description:"\uC904\uAC04\uACA9 -0.4px"},{previous:"$semantic.typography.title1Regular",next:[],description:"Deprecated"},{previous:"$semantic.typography.title2Bold",next:["t7Bold"]},{previous:"$semantic.typography.title2Regular",next:["t7Regular"]},{previous:"$semantic.typography.title3Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.title3Regular",next:["t6Regular"]},{previous:"$semantic.typography.subtitle1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.subtitle2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyL1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL1Regular",next:["articleBody"]},{previous:"$semantic.typography.bodyL2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL2Regular",next:[],alternative:["t4Regular"],description:"Deprecated"},{previous:"$semantic.typography.bodyM1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyM2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.caption1Bold",next:["t3Bold"],description:"\uC904\uAC04\uACA9 -1.5px"},{previous:"$semantic.typography.caption1Regular",next:[],alternative:["t3Regular"],description:"Deprecated"},{previous:"$semantic.typography.caption2Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.caption2Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label1Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.label1Regular",next:["t6Regular"]},{previous:"$semantic.typography.label2Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label2Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label3Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label3Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label4Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label4Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label5Bold",next:["t1Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label5Regular",next:["t1Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label6Bold",next:[],alternative:["t1Bold"],description:"Deprecated"},{previous:"$semantic.typography.label6Regular",next:[],alternative:["t1Regular"],description:"Deprecated"}];var f=L(require("fs"),1),g=L(require("path"),1),R=class{timestamp;fileMigrations=[];currentFile=null;reportDir=g.join(process.cwd(),".report");transformName;constructor(e){this.transformName=e,this.timestamp=this.generateTimestamp()}generateTimestamp(){return new Date(new Date().getTime()+324e5).toISOString()}getReportPath(){return g.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(e){if(!e)return"unknown";try{let r=g.resolve(e);return g.relative(this.reportDir,r)}catch{return"unknown"}}startNewFile(e){this.currentFile={filePath:this.getRelativePath(e),results:[]}}addResult(e){this.currentFile&&this.currentFile.results.push(e)}finishFile(){this.currentFile&&this.currentFile.results.length>0&&this.fileMigrations.push(this.currentFile),this.currentFile=null}hasResults(){return this.fileMigrations.length>0}writeReport(){if(!this.hasResults())return;f.existsSync(this.reportDir)||f.mkdirSync(this.reportDir,{recursive:!0});let e=this.getReportPath(),r=f.existsSync(e)?f.readFileSync(e,"utf8"):"",a=this.fileMigrations.map(i=>{let c=g.basename(i.filePath),s=i.results.map(n=>{let o=n.line?` (line: ${n.line})`:"",u=n.status==="success"?"\u2705 success":n.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",p=n.failureReason?`
|
2
|
+
- reason: ${n.failureReason}`:"";return` - ${u} ${o}
|
3
|
+
- as-is: \`${n.previousToken}\`
|
4
|
+
- to-be: ${n.nextToken?`\`${n.nextToken}\``:"undefined"}${p}`}).join(`
|
5
|
+
`);return`### [${c}](${i.filePath})
|
6
|
+
- timestamp: ${this.timestamp}
|
7
|
+
- summary:
|
8
|
+
- total: ${i.results.length}
|
9
|
+
- success: ${i.results.filter(n=>n.status==="success").length}
|
10
|
+
- warning: ${i.results.filter(n=>n.status==="warning").length}
|
11
|
+
- failure: ${i.results.filter(n=>n.status==="failure").length}
|
12
|
+
- lines
|
13
|
+
${s}`}).join(`
|
14
|
+
|
15
|
+
`);f.writeFileSync(e,r+(r?`
|
16
|
+
|
17
|
+
`:"")+a)}};var N=new RegExp("([\\p{Ll}\\d])(\\p{Lu})","gu"),U=new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])","gu"),O=new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d","u"),X=/[^\p{L}\d]+/giu,F="$1\0$2",P="";function S(t){let e=t.trim();e=e.replace(N,F).replace(U,F),e=e.replace(X,"\0");let r=0,a=e.length;for(;e.charAt(r)==="\0";)r++;if(r===a)return[];for(;e.charAt(a-1)==="\0";)a--;return e.slice(r,a).split(/\0/g)}function z(t){let e=S(t);for(let r=0;r<e.length;r++){let a=e[r],l=O.exec(a);if(l){let i=l.index+(l[1]??l[2]).length;e.splice(r,1,a.slice(0,i),a.slice(i))}}return e}function J(t,e){let[r,a,l]=q(t,e);return r+a.map(W(e==null?void 0:e.locale)).join((e==null?void 0:e.delimiter)??" ")+l}function T(t,e){return J(t,{delimiter:"-",...e})}function W(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function q(t,e={}){let r=e.split??(e.separateNumbers?z:S),a=e.prefixCharacters??P,l=e.suffixCharacters??P,i=0,c=t.length;for(;i<t.length;){let s=t.charAt(i);if(!a.includes(s))break;i++}for(;c>i;){let s=c-1,n=t.charAt(s);if(!l.includes(n))break;c=s}return[t.slice(0,i),r(t.slice(i,c)),t.slice(c)]}function b(t){let e=k.find(r=>{let a=r.previous.split(".");return a[a.length-1]===t});if(e){if(e.next&&e.next.length>0)return T(e.next[0]);if((!e.next||e.next.length===0)&&e.alternative&&e.alternative.length>0)return T(e.alternative[0])}return t}function G(t){if(t.startsWith("[")&&t.includes("]:")){let e=t.indexOf("]:"),r=t.substring(0,e+2),a=t.substring(e+2),l=b(a);return r+l}return t}function H(t){if(t.startsWith("[")&&t.includes("]:"))return G(t);if(t.includes(":")){let e=t.split(":"),r=e.pop(),a=b(r);return e.concat(a).join(":")}return b(t)}function h(t){return t.split(" ").map(a=>H(a)).join(" ")}var V=(t,e,r)=>{let a=r,{reporter:l}=a,i=e.jscodeshift,c=i(t.source),s=null;return l&&(s=new R("replace-tailwind-typography"),s.startNewFile(t.path)),c.find(i.StringLiteral).forEach(n=>{var p;let o=n.node.value,u=h(o);o!==u&&(s&&s.addResult({previousToken:o,nextToken:u,status:"success",line:(p=n.node.loc)==null?void 0:p.start.line}),n.node.value=u)}),c.find(i.TemplateLiteral).forEach(n=>{n.node.quasis.forEach(o=>{var x;let u=o.value.raw,p=h(u);u!==p&&(s&&s.addResult({previousToken:u,nextToken:p,status:"success",line:(x=o.loc)==null?void 0:x.start.line}),o.value.raw=p,o.value.cooked=p)})}),c.find(i.JSXAttribute,{name:{name:"className"}}).forEach(n=>{var o,u,p,x,w;if(((o=n.node.value)==null?void 0:o.type)==="StringLiteral"){let m=n.node.value.value,d=h(m);m!==d&&(s&&s.addResult({previousToken:m,nextToken:d,status:"success",line:(u=n.node.loc)==null?void 0:u.start.line}),n.node.value.value=d)}else if(((p=n.node.value)==null?void 0:p.type)==="JSXExpressionContainer"&&n.node.value.expression.type==="StringLiteral"){let m=n.node.value.expression.value,d=h(m);m!==d&&(s&&s.addResult({previousToken:m,nextToken:d,status:"success",line:(x=n.node.loc)==null?void 0:x.start.line}),n.node.value.expression.value=d)}else((w=n.node.value)==null?void 0:w.type)==="JSXExpressionContainer"&&n.node.value.expression.type==="TemplateLiteral"&&n.node.value.expression.quasis.forEach(d=>{var B;let $=d.value.raw,y=h($);$!==y&&(s&&s.addResult({previousToken:$,nextToken:y,status:"success",line:(B=d.loc)==null?void 0:B.start.line}),d.value.raw=y,d.value.cooked=y)})}),s&&(s.finishFile(),s.writeReport()),c.toSource()},K=V;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var w=Object.create;var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},D=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of E(t))!C.call(e,o)&&o!==r&&h(e,o,{get:()=>t[o],enumerable:!(s=j(t,o))||s.enumerable});return e};var F=(e,t,r)=>(r=e!=null?w(I(e)):{},D(t||!e||!e.__esModule?h(r,"default",{value:e,enumerable:!0}):r,e)),P=e=>D(h({},"__esModule",{value:!0}),e);var X={};L(X,{default:()=>J});module.exports=P(X);var M=[{previous:"$semantic.typography.h1",next:[],description:"Deprecated"},{previous:"$semantic.typography.h2",next:[],description:"Deprecated"},{previous:"$semantic.typography.h3",next:[],description:"Deprecated"},{previous:"$semantic.typography.h4",next:["t10Bold","screenTitle"],description:"\uC904\uAC04\uACA9 -0.1px"},{previous:"$semantic.typography.title1Bold",next:["t9Bold"],description:"\uC904\uAC04\uACA9 -0.4px"},{previous:"$semantic.typography.title1Regular",next:[],description:"Deprecated"},{previous:"$semantic.typography.title2Bold",next:["t7Bold"]},{previous:"$semantic.typography.title2Regular",next:["t7Regular"]},{previous:"$semantic.typography.title3Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.title3Regular",next:["t6Regular"]},{previous:"$semantic.typography.subtitle1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.subtitle2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyL1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL1Regular",next:["articleBody"]},{previous:"$semantic.typography.bodyL2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL2Regular",next:[],alternative:["t4Regular"],description:"Deprecated"},{previous:"$semantic.typography.bodyM1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyM2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.caption1Bold",next:["t3Bold"],description:"\uC904\uAC04\uACA9 -1.5px"},{previous:"$semantic.typography.caption1Regular",next:[],alternative:["t3Regular"],description:"Deprecated"},{previous:"$semantic.typography.caption2Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.caption2Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label1Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.label1Regular",next:["t6Regular"]},{previous:"$semantic.typography.label2Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label2Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label3Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label3Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label4Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label4Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label5Bold",next:["t1Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label5Regular",next:["t1Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label6Bold",next:[],alternative:["t1Bold"],description:"Deprecated"},{previous:"$semantic.typography.label6Regular",next:[],alternative:["t1Regular"],description:"Deprecated"}];var u=F(require("fs"),1),c=F(require("path"),1),x=class{timestamp;fileMigrations=[];currentFile=null;reportDir=c.join(process.cwd(),".report");transformName;constructor(t){this.transformName=t,this.timestamp=this.generateTimestamp()}generateTimestamp(){return new Date(new Date().getTime()+324e5).toISOString()}getReportPath(){return c.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(t){if(!t)return"unknown";try{let r=c.resolve(t);return c.relative(this.reportDir,r)}catch{return"unknown"}}startNewFile(t){this.currentFile={filePath:this.getRelativePath(t),results:[]}}addResult(t){this.currentFile&&this.currentFile.results.push(t)}finishFile(){this.currentFile&&this.currentFile.results.length>0&&this.fileMigrations.push(this.currentFile),this.currentFile=null}hasResults(){return this.fileMigrations.length>0}writeReport(){if(!this.hasResults())return;u.existsSync(this.reportDir)||u.mkdirSync(this.reportDir,{recursive:!0});let t=this.getReportPath(),r=u.existsSync(t)?u.readFileSync(t,"utf8"):"",s=this.fileMigrations.map(i=>{let m=c.basename(i.filePath),p=i.results.map(n=>{let $=n.line?` (line: ${n.line})`:"",f=n.status==="success"?"\u2705 success":n.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",a=n.failureReason?`
|
2
|
+
- reason: ${n.failureReason}`:"";return` - ${f} ${$}
|
3
|
+
- as-is: \`${n.previousToken}\`
|
4
|
+
- to-be: ${n.nextToken?`\`${n.nextToken}\``:"undefined"}${a}`}).join(`
|
5
|
+
`);return`### [${m}](${i.filePath})
|
6
|
+
- timestamp: ${this.timestamp}
|
7
|
+
- summary:
|
8
|
+
- total: ${i.results.length}
|
9
|
+
- success: ${i.results.filter(n=>n.status==="success").length}
|
10
|
+
- warning: ${i.results.filter(n=>n.status==="warning").length}
|
11
|
+
- failure: ${i.results.filter(n=>n.status==="failure").length}
|
12
|
+
- lines
|
13
|
+
${p}`}).join(`
|
14
|
+
|
15
|
+
`);u.writeFileSync(t,r+(r?`
|
16
|
+
|
17
|
+
`:"")+s)}};function v(e){let t=M.find(r=>{let s=r.previous.split(".");return s[s.length-1]===e});return t?t.next&&t.next.length>0?t.next[0]:(!t.next||t.next.length===0)&&t.alternative&&t.alternative.length>0?t.alternative[0]:null:null}function A(e,t,r){if(!r)return;let s=t.find(e.ImportDeclaration,{source:{value:"components/Base/Text"}});if(s.length===0)return;let o=t.get().node.comments||[];s.forEach(i=>{let m=i.node.comments||[];i.node.specifiers.find(n=>n.type==="ImportDefaultSpecifier")&&(i.node.source.value="@seed-design/react",i.node.specifiers=[e.importSpecifier(e.identifier("Text"))]),i.node.comments=m}),o.length>0&&(t.get().node.comments=o)}function R(e,t){if(t.consequent.type==="StringLiteral"){let r=t.consequent.value,s=v(r);s&&(t.consequent.value=s)}if(t.alternate.type==="StringLiteral"){let r=t.alternate.value,s=v(r);s&&(t.alternate.value=s)}return t.consequent.type==="ConditionalExpression"&&R(e,t.consequent),t.alternate.type==="ConditionalExpression"&&R(e,t.alternate),t}var V=(e,t,r)=>{let s=r,{reporter:o}=s,i=t.jscodeshift,m=i(e.source),p=null;o&&(p=new x("replace-text-component"),p.startNewFile(e.path));let n=!1;m.find(i.JSXElement).filter(f=>{let a=f.node.openingElement.name;return a.type==="JSXIdentifier"&&a.name==="Text"}).forEach(f=>{var b,B,S,T;let a=f.node.openingElement,g=a.attributes.find(l=>l.type==="JSXAttribute"&&l.name.name==="variant");if(g&&g.type==="JSXAttribute"){if(((b=g.value)==null?void 0:b.type)==="StringLiteral"){let l=g.value.value,y=v(l);y&&(a.attributes=a.attributes.filter(d=>!(d.type==="JSXAttribute"&&d.name.name==="variant")),a.attributes.push(i.jsxAttribute(i.jsxIdentifier("textStyle"),i.stringLiteral(y))),n=!0,p&&p.addResult({previousToken:`variant="${l}"`,nextToken:`textStyle="${y}"`,status:"success",line:(B=g.loc)==null?void 0:B.start.line}))}else if(((S=g.value)==null?void 0:S.type)==="JSXExpressionContainer"){let l=g.value.expression;if(l.type==="StringLiteral"){let y=l.value,d=v(y);d&&(a.attributes=a.attributes.filter(k=>!(k.type==="JSXAttribute"&&k.name.name==="variant")),a.attributes.push(i.jsxAttribute(i.jsxIdentifier("textStyle"),i.stringLiteral(d))),n=!0)}else if(l.type==="ConditionalExpression"){let y=R(i,l);a.attributes=a.attributes.filter(d=>!(d.type==="JSXAttribute"&&d.name.name==="variant")),a.attributes.push(i.jsxAttribute(i.jsxIdentifier("textStyle"),i.jsxExpressionContainer(y))),n=!0,p&&p.addResult({previousToken:"variant={\uC870\uAC74\uBD80 \uD45C\uD604\uC2DD}",nextToken:"textStyle={\uC870\uAC74\uBD80 \uD45C\uD604\uC2DD}",status:"success",line:(T=g.loc)==null?void 0:T.start.line})}}}}),A(i,m,n),p&&(p.finishFile(),p.writeReport());let $={quote:"double",objectCurlySpacing:!0};return m.toSource($)},J=V;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var w=Object.create;var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var N=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},B=(t,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!I.call(t,a)&&a!==n&&g(t,a,{get:()=>e[a],enumerable:!(l=S(e,a))||l.enumerable});return t};var T=(t,e,n)=>(n=t!=null?w(E(t)):{},B(e||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),C=t=>B(g({},"__esModule",{value:!0}),t);var q={};N(q,{default:()=>z});module.exports=C(q);var k=[{previous:"$semantic.typography.h1",next:[],description:"Deprecated"},{previous:"$semantic.typography.h2",next:[],description:"Deprecated"},{previous:"$semantic.typography.h3",next:[],description:"Deprecated"},{previous:"$semantic.typography.h4",next:["t10Bold","screenTitle"],description:"\uC904\uAC04\uACA9 -0.1px"},{previous:"$semantic.typography.title1Bold",next:["t9Bold"],description:"\uC904\uAC04\uACA9 -0.4px"},{previous:"$semantic.typography.title1Regular",next:[],description:"Deprecated"},{previous:"$semantic.typography.title2Bold",next:["t7Bold"]},{previous:"$semantic.typography.title2Regular",next:["t7Regular"]},{previous:"$semantic.typography.title3Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.title3Regular",next:["t6Regular"]},{previous:"$semantic.typography.subtitle1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.subtitle2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.subtitle2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyL1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL1Regular",next:["articleBody"]},{previous:"$semantic.typography.bodyL2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 -2px"},{previous:"$semantic.typography.bodyL2Regular",next:[],alternative:["t4Regular"],description:"Deprecated"},{previous:"$semantic.typography.bodyM1Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM1Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.bodyM2Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.bodyM2Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.caption1Bold",next:["t3Bold"],description:"\uC904\uAC04\uACA9 -1.5px"},{previous:"$semantic.typography.caption1Regular",next:[],alternative:["t3Regular"],description:"Deprecated"},{previous:"$semantic.typography.caption2Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.caption2Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label1Bold",next:["t6Bold"],description:"\uC904\uAC04\uACA9 -0.3px"},{previous:"$semantic.typography.label1Regular",next:["t6Regular"]},{previous:"$semantic.typography.label2Bold",next:["t5Bold"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label2Regular",next:["t5Regular"],description:"\uC904\uAC04\uACA9 +0.4px"},{previous:"$semantic.typography.label3Bold",next:["t4Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label3Regular",next:["t4Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label4Bold",next:["t2Bold"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label4Regular",next:["t2Regular"],description:"\uC904\uAC04\uACA9 -0.2px"},{previous:"$semantic.typography.label5Bold",next:["t1Bold"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label5Regular",next:["t1Regular"],description:"\uC904\uAC04\uACA9 +0.1px"},{previous:"$semantic.typography.label6Bold",next:[],alternative:["t1Bold"],description:"Deprecated"},{previous:"$semantic.typography.label6Regular",next:[],alternative:["t1Regular"],description:"Deprecated"}];var u=T(require("fs"),1),m=T(require("path"),1),y=class{timestamp;fileMigrations=[];currentFile=null;reportDir=m.join(process.cwd(),".report");transformName;constructor(e){this.transformName=e,this.timestamp=this.generateTimestamp()}generateTimestamp(){return new Date(new Date().getTime()+324e5).toISOString()}getReportPath(){return m.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(e){if(!e)return"unknown";try{let n=m.resolve(e);return m.relative(this.reportDir,n)}catch{return"unknown"}}startNewFile(e){this.currentFile={filePath:this.getRelativePath(e),results:[]}}addResult(e){this.currentFile&&this.currentFile.results.push(e)}finishFile(){this.currentFile&&this.currentFile.results.length>0&&this.fileMigrations.push(this.currentFile),this.currentFile=null}hasResults(){return this.fileMigrations.length>0}writeReport(){if(!this.hasResults())return;u.existsSync(this.reportDir)||u.mkdirSync(this.reportDir,{recursive:!0});let e=this.getReportPath(),n=u.existsSync(e)?u.readFileSync(e,"utf8"):"",l=this.fileMigrations.map(r=>{let o=m.basename(r.filePath),p=r.results.map(i=>{let f=i.line?` (line: ${i.line})`:"",c=i.status==="success"?"\u2705 success":i.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",h=i.failureReason?`
|
2
|
+
- reason: ${i.failureReason}`:"";return` - ${c} ${f}
|
3
|
+
- as-is: \`${i.previousToken}\`
|
4
|
+
- to-be: ${i.nextToken?`\`${i.nextToken}\``:"undefined"}${h}`}).join(`
|
5
|
+
`);return`### [${o}](${r.filePath})
|
6
|
+
- timestamp: ${this.timestamp}
|
7
|
+
- summary:
|
8
|
+
- total: ${r.results.length}
|
9
|
+
- success: ${r.results.filter(i=>i.status==="success").length}
|
10
|
+
- warning: ${r.results.filter(i=>i.status==="warning").length}
|
11
|
+
- failure: ${r.results.filter(i=>i.status==="failure").length}
|
12
|
+
- lines
|
13
|
+
${p}`}).join(`
|
14
|
+
|
15
|
+
`);u.writeFileSync(e,n+(n?`
|
16
|
+
|
17
|
+
`:"")+l)}};function M(t){let e=[],n=t.node;for(;n.type==="MemberExpression";)n.property.type==="Identifier"&&e.unshift(n.property.name),n=n.object;return n.type==="Identifier"&&e.unshift(n.name),e.join(".")}function P(t){let e=k.find(n=>n.previous===t);return e?e.next&&e.next.length>0?e.next[0]:(!e.next||e.next.length===0)&&e.alternative&&e.alternative.length>0?e.alternative[0]:null:null}function j(t,e,n){if(!n)return;let l=e.find(t.ImportDeclaration,{source:{value:"@seed-design/design-token"}});if(l.length===0)return;let a=e.get().node.comments||[];l.forEach(r=>{let o=r.node.comments||[];r.node.specifiers.find(i=>i.type==="ImportSpecifier"&&i.imported.name==="classNames")&&(r.node.source.value="@seed-design/css/recipes/text",r.node.specifiers=[t.importSpecifier(t.identifier("text"))]),r.node.comments=o}),a.length>0&&(e.get().node.comments=a)}function O(t,e){if(e.find(t.CallExpression,{callee:{type:"Identifier",name:"text"}}).length===0){let l=e.get().node.comments||[],a=e.find(t.ImportDeclaration,{source:{value:"@seed-design/css/recipes/text"}}),r=[];if(a.forEach(o=>{o.node.comments&&o.node.comments.length>0&&(r=[...r,...o.node.comments])}),a.remove(),r.length>0){let o=e.find(t.ImportDeclaration).at(0);o.size()>0?o.get().node.comments=[...o.get().node.comments||[],...r]:e.get().node.comments=[...l,...r]}}}function L(t,e){return t(`${e}`).find(t.ExpressionStatement).get().node.expression}var W=(t,e,n)=>{let l=n,{reporter:a}=l,r=e.jscodeshift,o=r(t.source),p=null;a&&(p=new y("replace-typography-design-token"),p.startNewFile(t.path));let i=!1;o.find(r.MemberExpression).filter(c=>M(c).startsWith("classNames.$semantic.typography.")).forEach(c=>{var $,R;let x=M(c).replace("classNames.",""),v=P(x);if(v){let b=`text({ textStyle: "${v}" })`,d=L(r,b),s=c.parent;if(s.node.type==="JSXExpressionContainer"){let D=r.jsxExpressionContainer(d);r(s).replaceWith(D)}else s.node.type==="Property"||s.node.type==="ObjectProperty"?s.node.value=d:s.node.type==="ConditionalExpression"?s.node.consequent===c.node?s.node.consequent=d:s.node.alternate===c.node&&(s.node.alternate=d):s.node.type==="ReturnStatement"?s.node.argument=d:s.node.type==="ArrowFunctionExpression"&&s.node.body===c.node?s.node.body=d:s.node.type==="VariableDeclarator"?s.node.init=d:r(s).replaceWith(d);i=!0,p&&p.addResult({previousToken:x,nextToken:b,status:"success",line:($=c.node.loc)==null?void 0:$.start.line})}else p&&p.addResult({previousToken:x,nextToken:"\uB9E4\uD551 \uC5C6\uC74C - \uC218\uB3D9 \uBCC0\uACBD \uD544\uC694",status:"failure",line:(R=c.node.loc)==null?void 0:R.start.line})}),j(r,o,i),O(r,o),p&&(p.finishFile(),p.writeReport());let f={quote:"double",trailingComma:!1,wrapColumn:1e3,tabWidth:2,reuseWhitespace:!0};return o.toSource(f)},z=W;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@seed-design/codemod",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.17",
|
4
4
|
"type": "module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"directory": "packages/codemod"
|
9
9
|
},
|
10
10
|
"license": "MIT",
|
11
|
-
"bin": "./bin/index.
|
11
|
+
"bin": "./bin/index.cjs",
|
12
12
|
"files": [
|
13
13
|
"bin"
|
14
14
|
],
|
@@ -19,8 +19,9 @@
|
|
19
19
|
"lint:publish": "bun publint"
|
20
20
|
},
|
21
21
|
"dependencies": {
|
22
|
-
"@seed-design/migration-index": "0.0.3",
|
22
|
+
"@seed-design/migration-index": "^0.0.3",
|
23
23
|
"cac": "^6.7.14",
|
24
|
+
"change-case": "^5.4.4",
|
24
25
|
"es-toolkit": "^1.25.2",
|
25
26
|
"execa": "^9.4.1",
|
26
27
|
"glob": "^11.0.1",
|
@@ -29,7 +30,6 @@
|
|
29
30
|
"postcss": "^8.5.3",
|
30
31
|
"semver": "^7.6.3",
|
31
32
|
"simple-git": "^3.27.0",
|
32
|
-
"change-case": "^5.4.4",
|
33
33
|
"winston": "^3.15.0",
|
34
34
|
"zod": "^3.23.8"
|
35
35
|
},
|