@seed-design/codemod 0.0.15 → 0.0.16
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 +24 -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 +2 -2
- 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
@@ -1,17 +0,0 @@
|
|
1
|
-
var v=[{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"}];import*as d from"fs";import*as f from"path";var x=class{timestamp;fileMigrations=[];currentFile=null;reportDir=f.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 f.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(e){if(!e)return"unknown";try{let n=f.resolve(e);return f.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;d.existsSync(this.reportDir)||d.mkdirSync(this.reportDir,{recursive:!0});let e=this.getReportPath(),n=d.existsSync(e)?d.readFileSync(e,"utf8"):"",i=this.fileMigrations.map(s=>{let c=f.basename(s.filePath),a=s.results.map(r=>{let l=r.line?` (line: ${r.line})`:"",o=r.status==="success"?"\u2705 success":r.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",u=r.failureReason?`
|
2
|
-
- reason: ${r.failureReason}`:"";return` - ${o} ${l}
|
3
|
-
- as-is: \`${r.previousToken}\`
|
4
|
-
- to-be: ${r.nextToken?`\`${r.nextToken}\``:"undefined"}${u}`}).join(`
|
5
|
-
`);return`### [${c}](${s.filePath})
|
6
|
-
- timestamp: ${this.timestamp}
|
7
|
-
- summary:
|
8
|
-
- total: ${s.results.length}
|
9
|
-
- success: ${s.results.filter(r=>r.status==="success").length}
|
10
|
-
- warning: ${s.results.filter(r=>r.status==="warning").length}
|
11
|
-
- failure: ${s.results.filter(r=>r.status==="failure").length}
|
12
|
-
- lines
|
13
|
-
${a}`}).join(`
|
14
|
-
|
15
|
-
`);d.writeFileSync(e,n+(n?`
|
16
|
-
|
17
|
-
`:"")+i)}};var b=/([\p{Ll}\d])(\p{Lu})/gu,w=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,B=/(\d)\p{Ll}|(\p{L})\d/u,C=/[^\p{L}\d]+/giu,R="$1\0$2",$="";function T(t){let e=t.trim();e=e.replace(b,R).replace(w,R),e=e.replace(C,"\0");let n=0,i=e.length;for(;e.charAt(n)==="\0";)n++;if(n===i)return[];for(;e.charAt(i-1)==="\0";)i--;return e.slice(n,i).split(/\0/g)}function L(t){let e=T(t);for(let n=0;n<e.length;n++){let i=e[n],p=B.exec(i);if(p){let s=p.index+(p[1]??p[2]).length;e.splice(n,1,i.slice(0,s),i.slice(s))}}return e}function k(t,e){let[n,i,p]=P(t,e);return n+i.map(F(e?.locale)).join(e?.delimiter??" ")+p}function h(t,e){return k(t,{delimiter:"-",...e})}function F(t){return t===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t)}function P(t,e={}){let n=e.split??(e.separateNumbers?L:T),i=e.prefixCharacters??$,p=e.suffixCharacters??$,s=0,c=t.length;for(;s<t.length;){let a=t.charAt(s);if(!i.includes(a))break;s++}for(;c>s;){let a=c-1,r=t.charAt(a);if(!p.includes(r))break;c=a}return[t.slice(0,s),n(t.slice(s,c)),t.slice(c)]}function y(t){let e=v.find(n=>{let i=n.previous.split(".");return i[i.length-1]===t});if(e){if(e.next&&e.next.length>0)return h(e.next[0]);if((!e.next||e.next.length===0)&&e.alternative&&e.alternative.length>0)return h(e.alternative[0])}return t}function S(t){if(t.startsWith("[")&&t.includes("]:")){let e=t.indexOf("]:"),n=t.substring(0,e+2),i=t.substring(e+2),p=y(i);return n+p}return t}function E(t){if(t.startsWith("[")&&t.includes("]:"))return S(t);if(t.includes(":")){let e=t.split(":"),n=e.pop(),i=y(n);return e.concat(i).join(":")}return y(t)}function g(t){return t.split(" ").map(i=>E(i)).join(" ")}var _=(t,e,n)=>{let i=n,{reporter:p}=i,s=e.jscodeshift,c=s(t.source),a=null;return p&&(a=new x("replace-tailwind-typography"),a.startNewFile(t.path)),c.find(s.StringLiteral).forEach(r=>{let l=r.node.value,o=g(l);l!==o&&(a&&a.addResult({previousToken:l,nextToken:o,status:"success",line:r.node.loc?.start.line}),r.node.value=o)}),c.find(s.TemplateLiteral).forEach(r=>{r.node.quasis.forEach(l=>{let o=l.value.raw,u=g(o);o!==u&&(a&&a.addResult({previousToken:o,nextToken:u,status:"success",line:l.loc?.start.line}),l.value.raw=u,l.value.cooked=u)})}),c.find(s.JSXAttribute,{name:{name:"className"}}).forEach(r=>{if(r.node.value?.type==="StringLiteral"){let l=r.node.value.value,o=g(l);l!==o&&(a&&a.addResult({previousToken:l,nextToken:o,status:"success",line:r.node.loc?.start.line}),r.node.value.value=o)}else if(r.node.value?.type==="JSXExpressionContainer"&&r.node.value.expression.type==="StringLiteral"){let l=r.node.value.expression.value,o=g(l);l!==o&&(a&&a.addResult({previousToken:l,nextToken:o,status:"success",line:r.node.loc?.start.line}),r.node.value.expression.value=o)}else r.node.value?.type==="JSXExpressionContainer"&&r.node.value.expression.type==="TemplateLiteral"&&r.node.value.expression.quasis.forEach(o=>{let u=o.value.raw,m=g(u);u!==m&&(a&&a.addResult({previousToken:u,nextToken:m,status:"success",line:o.loc?.start.line}),o.value.raw=m,o.value.cooked=m)})}),a&&(a.finishFile(),a.writeReport()),c.toSource()},U=_;export{U as default};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
var b=[{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"}];import*as l from"fs";import*as u from"path";var h=class{timestamp;fileMigrations=[];currentFile=null;reportDir=u.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 u.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(t){if(!t)return"unknown";try{let s=u.resolve(t);return u.relative(this.reportDir,s)}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;l.existsSync(this.reportDir)||l.mkdirSync(this.reportDir,{recursive:!0});let t=this.getReportPath(),s=l.existsSync(t)?l.readFileSync(t,"utf8"):"",r=this.fileMigrations.map(e=>{let d=u.basename(e.filePath),o=e.results.map(i=>{let v=i.line?` (line: ${i.line})`:"",f=i.status==="success"?"\u2705 success":i.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",n=i.failureReason?`
|
2
|
-
- reason: ${i.failureReason}`:"";return` - ${f} ${v}
|
3
|
-
- as-is: \`${i.previousToken}\`
|
4
|
-
- to-be: ${i.nextToken?`\`${i.nextToken}\``:"undefined"}${n}`}).join(`
|
5
|
-
`);return`### [${d}](${e.filePath})
|
6
|
-
- timestamp: ${this.timestamp}
|
7
|
-
- summary:
|
8
|
-
- total: ${e.results.length}
|
9
|
-
- success: ${e.results.filter(i=>i.status==="success").length}
|
10
|
-
- warning: ${e.results.filter(i=>i.status==="warning").length}
|
11
|
-
- failure: ${e.results.filter(i=>i.status==="failure").length}
|
12
|
-
- lines
|
13
|
-
${o}`}).join(`
|
14
|
-
|
15
|
-
`);l.writeFileSync(t,s+(s?`
|
16
|
-
|
17
|
-
`:"")+r)}};function x(a){let t=b.find(s=>{let r=s.previous.split(".");return r[r.length-1]===a});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 B(a,t,s){if(!s)return;let r=t.find(a.ImportDeclaration,{source:{value:"components/Base/Text"}});if(r.length===0)return;let y=t.get().node.comments||[];r.forEach(e=>{let d=e.node.comments||[];e.node.specifiers.find(i=>i.type==="ImportDefaultSpecifier")&&(e.node.source.value="@seed-design/react",e.node.specifiers=[a.importSpecifier(a.identifier("Text"))]),e.node.comments=d}),y.length>0&&(t.get().node.comments=y)}function $(a,t){if(t.consequent.type==="StringLiteral"){let s=t.consequent.value,r=x(s);r&&(t.consequent.value=r)}if(t.alternate.type==="StringLiteral"){let s=t.alternate.value,r=x(s);r&&(t.alternate.value=r)}return t.consequent.type==="ConditionalExpression"&&$(a,t.consequent),t.alternate.type==="ConditionalExpression"&&$(a,t.alternate),t}var S=(a,t,s)=>{let r=s,{reporter:y}=r,e=t.jscodeshift,d=e(a.source),o=null;y&&(o=new h("replace-text-component"),o.startNewFile(a.path));let i=!1;d.find(e.JSXElement).filter(f=>{let n=f.node.openingElement.name;return n.type==="JSXIdentifier"&&n.name==="Text"}).forEach(f=>{let n=f.node.openingElement,c=n.attributes.find(p=>p.type==="JSXAttribute"&&p.name.name==="variant");if(c&&c.type==="JSXAttribute"){if(c.value?.type==="StringLiteral"){let p=c.value.value,m=x(p);m&&(n.attributes=n.attributes.filter(g=>!(g.type==="JSXAttribute"&&g.name.name==="variant")),n.attributes.push(e.jsxAttribute(e.jsxIdentifier("textStyle"),e.stringLiteral(m))),i=!0,o&&o.addResult({previousToken:`variant="${p}"`,nextToken:`textStyle="${m}"`,status:"success",line:c.loc?.start.line}))}else if(c.value?.type==="JSXExpressionContainer"){let p=c.value.expression;if(p.type==="StringLiteral"){let m=p.value,g=x(m);g&&(n.attributes=n.attributes.filter(R=>!(R.type==="JSXAttribute"&&R.name.name==="variant")),n.attributes.push(e.jsxAttribute(e.jsxIdentifier("textStyle"),e.stringLiteral(g))),i=!0)}else if(p.type==="ConditionalExpression"){let m=$(e,p);n.attributes=n.attributes.filter(g=>!(g.type==="JSXAttribute"&&g.name.name==="variant")),n.attributes.push(e.jsxAttribute(e.jsxIdentifier("textStyle"),e.jsxExpressionContainer(m))),i=!0,o&&o.addResult({previousToken:"variant={\uC870\uAC74\uBD80 \uD45C\uD604\uC2DD}",nextToken:"textStyle={\uC870\uAC74\uBD80 \uD45C\uD604\uC2DD}",status:"success",line:c.loc?.start.line})}}}}),B(e,d,i),o&&(o.finishFile(),o.writeReport());let v={quote:"double",objectCurlySpacing:!0};return d.toSource(v)},M=S;export{M as default};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
var $=[{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"}];import*as l from"fs";import*as c from"path";var g=class{timestamp;fileMigrations=[];currentFile=null;reportDir=c.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 c.join(this.reportDir,`${this.transformName}.md`)}getRelativePath(e){if(!e)return"unknown";try{let r=c.resolve(e);return c.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;l.existsSync(this.reportDir)||l.mkdirSync(this.reportDir,{recursive:!0});let e=this.getReportPath(),r=l.existsSync(e)?l.readFileSync(e,"utf8"):"",u=this.fileMigrations.map(t=>{let o=c.basename(t.filePath),a=t.results.map(n=>{let y=n.line?` (line: ${n.line})`:"",p=n.status==="success"?"\u2705 success":n.status==="warning"?"\u26A0\uFE0F warning":"\u274C failure",f=n.failureReason?`
|
2
|
-
- reason: ${n.failureReason}`:"";return` - ${p} ${y}
|
3
|
-
- as-is: \`${n.previousToken}\`
|
4
|
-
- to-be: ${n.nextToken?`\`${n.nextToken}\``:"undefined"}${f}`}).join(`
|
5
|
-
`);return`### [${o}](${t.filePath})
|
6
|
-
- timestamp: ${this.timestamp}
|
7
|
-
- summary:
|
8
|
-
- total: ${t.results.length}
|
9
|
-
- success: ${t.results.filter(n=>n.status==="success").length}
|
10
|
-
- warning: ${t.results.filter(n=>n.status==="warning").length}
|
11
|
-
- failure: ${t.results.filter(n=>n.status==="failure").length}
|
12
|
-
- lines
|
13
|
-
${a}`}).join(`
|
14
|
-
|
15
|
-
`);l.writeFileSync(e,r+(r?`
|
16
|
-
|
17
|
-
`:"")+u)}};function R(i){let e=[],r=i.node;for(;r.type==="MemberExpression";)r.property.type==="Identifier"&&e.unshift(r.property.name),r=r.object;return r.type==="Identifier"&&e.unshift(r.name),e.join(".")}function B(i){let e=$.find(r=>r.previous===i);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 T(i,e,r){if(!r)return;let u=e.find(i.ImportDeclaration,{source:{value:"@seed-design/design-token"}});if(u.length===0)return;let m=e.get().node.comments||[];u.forEach(t=>{let o=t.node.comments||[];t.node.specifiers.find(n=>n.type==="ImportSpecifier"&&n.imported.name==="classNames")&&(t.node.source.value="@seed-design/css/recipes/text",t.node.specifiers=[i.importSpecifier(i.identifier("text"))]),t.node.comments=o}),m.length>0&&(e.get().node.comments=m)}function k(i,e){if(e.find(i.CallExpression,{callee:{type:"Identifier",name:"text"}}).length===0){let u=e.get().node.comments||[],m=e.find(i.ImportDeclaration,{source:{value:"@seed-design/css/recipes/text"}}),t=[];if(m.forEach(o=>{o.node.comments&&o.node.comments.length>0&&(t=[...t,...o.node.comments])}),m.remove(),t.length>0){let o=e.find(i.ImportDeclaration).at(0);o.size()>0?o.get().node.comments=[...o.get().node.comments||[],...t]:e.get().node.comments=[...u,...t]}}}function M(i,e){return i(`${e}`).find(i.ExpressionStatement).get().node.expression}var D=(i,e,r)=>{let u=r,{reporter:m}=u,t=e.jscodeshift,o=t(i.source),a=null;m&&(a=new g("replace-typography-design-token"),a.startNewFile(i.path));let n=!1;o.find(t.MemberExpression).filter(p=>R(p).startsWith("classNames.$semantic.typography.")).forEach(p=>{let h=R(p).replace("classNames.",""),x=B(h);if(x){let v=`text({ textStyle: "${x}" })`,d=M(t,v),s=p.parent;if(s.node.type==="JSXExpressionContainer"){let b=t.jsxExpressionContainer(d);t(s).replaceWith(b)}else s.node.type==="Property"||s.node.type==="ObjectProperty"?s.node.value=d:s.node.type==="ConditionalExpression"?s.node.consequent===p.node?s.node.consequent=d:s.node.alternate===p.node&&(s.node.alternate=d):s.node.type==="ReturnStatement"?s.node.argument=d:s.node.type==="ArrowFunctionExpression"&&s.node.body===p.node?s.node.body=d:s.node.type==="VariableDeclarator"?s.node.init=d:t(s).replaceWith(d);n=!0,a&&a.addResult({previousToken:h,nextToken:v,status:"success",line:p.node.loc?.start.line})}else a&&a.addResult({previousToken:h,nextToken:"\uB9E4\uD551 \uC5C6\uC74C - \uC218\uB3D9 \uBCC0\uACBD \uD544\uC694",status:"failure",line:p.node.loc?.start.line})}),T(t,o,n),k(t,o),a&&(a.finishFile(),a.writeReport());let y={quote:"double",trailingComma:!1,wrapColumn:1e3,tabWidth:2,reuseWhitespace:!0};return o.toSource(y)},I=D;export{I as default};
|