@turbo/codemod 2.0.0-canary.3 → 2.0.0-canary.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cli.js +3 -3
- package/dist/transforms/add-package-manager.js +1 -1
- package/dist/transforms/add-package-names.js +1 -1
- package/dist/transforms/clean-globs.js +1 -1
- package/dist/transforms/create-turbo-config.js +1 -1
- package/dist/transforms/migrate-dot-env.js +1 -1
- package/dist/transforms/migrate-env-var-dependencies.js +1 -1
- package/dist/transforms/rename-output-mode.js +1 -1
- package/dist/transforms/rename-pipeline.js +1 -1
- package/dist/transforms/set-default-outputs.js +1 -1
- package/dist/transforms/stabilize-env-mode.js +1 -1
- package/dist/transforms/stabilize-ui.js +1 -1
- package/dist/transforms/transform-env-literals-to-wildcards.js +1 -1
- package/package.json +5 -5
@@ -36,7 +36,7 @@ ${i.message}`:y,R=[x,e,t].filter(Boolean).join(`
|
|
36
36
|
`+t.slice(n,s),n=s+1),o=a;return l+=`
|
37
37
|
`,t.length-n>e&&o>n?l+=t.slice(n,o)+`
|
38
38
|
`+t.slice(o+1):l+=t.slice(n),l.slice(1)}function Jb(t){for(var e="",r=0,i,n=0;n<t.length;r>=65536?n+=2:n++)r=bi(t,n),i=pe[r],!i&&Ri(r)?(e+=t[n],r>=65536&&(e+=t[n+1])):e+=i||jb(r);return e}function e0(t,e,r){var i="",n=t.tag,s,o,a;for(s=0,o=r.length;s<o;s+=1)a=r[s],t.replacer&&(a=t.replacer.call(r,String(s),a)),(pt(t,e,a,!1,!1)||typeof a=="undefined"&&pt(t,e,null,!1,!1))&&(i!==""&&(i+=","+(t.condenseFlow?"":" ")),i+=t.dump);t.tag=n,t.dump="["+i+"]"}function th(t,e,r,i){var n="",s=t.tag,o,a,l;for(o=0,a=r.length;o<a;o+=1)l=r[o],t.replacer&&(l=t.replacer.call(r,String(o),l)),(pt(t,e+1,l,!0,!0,!1,!0)||typeof l=="undefined"&&pt(t,e+1,null,!0,!0,!1,!0))&&((!i||n!=="")&&(n+=Io(t,e)),t.dump&&xi===t.dump.charCodeAt(0)?n+="-":n+="- ",n+=t.dump);t.tag=s,t.dump=n||"[]"}function t0(t,e,r){var i="",n=t.tag,s=Object.keys(r),o,a,l,c,u;for(o=0,a=s.length;o<a;o+=1)u="",i!==""&&(u+=", "),t.condenseFlow&&(u+='"'),l=s[o],c=r[l],t.replacer&&(c=t.replacer.call(r,l,c)),pt(t,e,l,!1,!1)&&(t.dump.length>1024&&(u+="? "),u+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),pt(t,e,c,!1,!1)&&(u+=t.dump,i+=u));t.tag=n,t.dump="{"+i+"}"}function r0(t,e,r,i){var n="",s=t.tag,o=Object.keys(r),a,l,c,u,h,f;if(t.sortKeys===!0)o.sort();else if(typeof t.sortKeys=="function")o.sort(t.sortKeys);else if(t.sortKeys)throw new xe("sortKeys must be a boolean or a function");for(a=0,l=o.length;a<l;a+=1)f="",(!i||n!=="")&&(f+=Io(t,e)),c=o[a],u=r[c],t.replacer&&(u=t.replacer.call(r,c,u)),pt(t,e+1,c,!0,!0,!0)&&(h=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,h&&(t.dump&&xi===t.dump.charCodeAt(0)?f+="?":f+="? "),f+=t.dump,h&&(f+=Io(t,e)),pt(t,e+1,u,!0,h)&&(t.dump&&xi===t.dump.charCodeAt(0)?f+=":":f+=": ",f+=t.dump,n+=f));t.tag=s,t.dump=n||"{}"}function rh(t,e,r){var i,n,s,o,a,l;for(n=r?t.explicitTypes:t.implicitTypes,s=0,o=n.length;s<o;s+=1)if(a=n[s],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof e=="object"&&e instanceof a.instanceOf)&&(!a.predicate||a.predicate(e))){if(r?a.multi&&a.representName?t.tag=a.representName(e):t.tag=a.tag:t.tag="?",a.represent){if(l=t.styleMap[a.tag]||a.defaultStyle,kh.call(a.represent)==="[object Function]")i=a.represent(e,l);else if(Nh.call(a.represent,l))i=a.represent[l](e,l);else throw new xe("!<"+a.tag+'> tag resolver accepts not "'+l+'" style');t.dump=i}return!0}return!1}function pt(t,e,r,i,n,s,o){t.tag=null,t.dump=r,rh(t,r,!1)||rh(t,r,!0);var a=kh.call(t.dump),l=i,c;i&&(i=t.flowLevel<0||t.flowLevel>e);var u=a==="[object Object]"||a==="[object Array]",h,f;if(u&&(h=t.duplicates.indexOf(r),f=h!==-1),(t.tag!==null&&t.tag!=="?"||f||t.indent!==2&&e>0)&&(n=!1),f&&t.usedDuplicates[h])t.dump="*ref_"+h;else{if(u&&f&&!t.usedDuplicates[h]&&(t.usedDuplicates[h]=!0),a==="[object Object]")i&&Object.keys(t.dump).length!==0?(r0(t,e,t.dump,n),f&&(t.dump="&ref_"+h+t.dump)):(t0(t,e,t.dump),f&&(t.dump="&ref_"+h+" "+t.dump));else if(a==="[object Array]")i&&t.dump.length!==0?(t.noArrayIndent&&!o&&e>0?th(t,e-1,t.dump,n):th(t,e,t.dump,n),f&&(t.dump="&ref_"+h+t.dump)):(e0(t,e,t.dump),f&&(t.dump="&ref_"+h+" "+t.dump));else if(a==="[object String]")t.tag!=="?"&&Zb(t,t.dump,e,s,l);else{if(a==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new xe("unacceptable kind of an object to dump "+a)}t.tag!==null&&t.tag!=="?"&&(c=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",t.dump=c+" "+t.dump)}return!0}function i0(t,e){var r=[],i=[],n,s;for(No(t,r,i),n=0,s=i.length;n<s;n+=1)e.duplicates.push(r[i[n]]);e.usedDuplicates=new Array(s)}function No(t,e,r){var i,n,s;if(t!==null&&typeof t=="object")if(n=e.indexOf(t),n!==-1)r.indexOf(n)===-1&&r.push(n);else if(e.push(t),Array.isArray(t))for(n=0,s=t.length;n<s;n+=1)No(t[n],e,r);else for(i=Object.keys(t),n=0,s=i.length;n<s;n+=1)No(t[i[n]],e,r)}function n0(t,e){e=e||{};var r=new Yb(e);r.noRefs||i0(t,r);var i=t;return r.replacer&&(i=r.replacer.call({"":i},"",i)),pt(r,0,i,!0,!0)?r.dump+`
|
39
|
-
`:""}var s0=n0,o0={dump:s0};function Ho(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var a0=fe,l0=sh,c0=ch,u0=dh,h0=mh,f0=Fo,p0=Ih.load,d0=Ih.loadAll,m0=o0.dump,g0=xe,y0={binary:Sh,float:ph,map:lh,null:uh,pairs:wh,set:xh,timestamp:_h,bool:hh,int:fh,merge:Eh,omap:bh,seq:ah,str:oh},_0=Ho("safeLoad","load"),E0=Ho("safeLoadAll","loadAll"),S0=Ho("safeDump","dump"),b0={Type:a0,Schema:l0,FAILSAFE_SCHEMA:c0,JSON_SCHEMA:u0,CORE_SCHEMA:h0,DEFAULT_SCHEMA:f0,load:p0,loadAll:d0,dump:m0,YAMLException:g0,types:y0,safeLoad:_0,safeLoadAll:E0,safeDump:S0},jh=b0;var $d=U(Id()),Ud=U(require("json5"));var He={};Iu(He,{bold:()=>TR,dimmed:()=>CR,error:()=>Hd,grey:()=>LR,info:()=>AR,item:()=>PR,log:()=>qt,turboBlue:()=>qr,turboGradient:()=>RR,turboLoader:()=>qd,turboRed:()=>Md,underline:()=>OR,warn:()=>wl,yellow:()=>Bd});var Bt=U(require("chalk")),kd=U(require("ora")),Nd=U(require("gradient-string")),Dd="#0099F7",Fd="#F11712",vR="#FFFF00",RR=(0,Nd.default)(Dd,Fd),qr=Bt.default.hex(Dd),Md=Bt.default.hex(Fd),Bd=Bt.default.hex(vR),qd=t=>(0,kd.default)({text:t,spinner:{frames:[" ",qr("> "),qr(">> "),qr(">>>")]}}),AR=(...t)=>{qt(qr.bold(">>>"),...t)},TR=(...t)=>{qt(Bt.default.bold(...t))},OR=(...t)=>{qt(Bt.default.underline(...t))},CR=(...t)=>{qt(Bt.default.dim(...t))},LR=(...t)=>{qt(Bt.default.grey(...t))},PR=(...t)=>{qt(qr.bold(" \u2022"),...t)},qt=(...t)=>{console.log(...t)},wl=(...t)=>{console.error(Bd.bold(">>>"),...t)},Hd=(...t)=>{console.error(Md.bold(">>>"),...t)};var IR="turbo.json";var xl={};function kR(t){try{if(Li.default.existsSync(lr.default.join(t,"pnpm-workspace.yaml")))return jh.load(Li.default.readFileSync(lr.default.join(t,"pnpm-workspace.yaml"),"utf8")).packages||[];let e=JSON.parse(Li.default.readFileSync(lr.default.join(t,"package.json"),"utf8"));if(e.workspaces){if("packages"in e.workspaces)return e.workspaces.packages||[];if(Array.isArray(e.workspaces))return e.workspaces}return[]}catch{return[]}}function vl(t,e){var s;let r=Ao(t,e),i=[],n=(s=e==null?void 0:e.cache)!=null?s:!0;if(n&&t&&t in xl)return xl[t];if(r){let a=kR(r).map(c=>`${c}/turbo.json`);(0,$d.sync)([IR,...a],{cwd:r,onlyFiles:!0,followSymbolicLinks:!1,suppressErrors:!0}).map(c=>lr.default.join(r,c)).forEach(c=>{try{let u=Li.default.readFileSync(c,"utf8"),h=Ud.default.parse(u),f=lr.default.dirname(c)===r;if(f){if("extends"in h)return}else if(!("extends"in h))return;i.push({config:h,turboConfigPath:c,workspacePath:lr.default.dirname(c),isRootConfig:f})}catch(u){wl(u)}})}return n&&t&&(xl[t]=i),i}var TT=U(require("os")),OT=U(Rg());var CT=U(require("fs-extra"));var LT=U(require("path")),PT=U(require("fs-extra")),IT=U(require("chalk"));var vE=require("stream"),RE=require("util"),d1=require("path"),m1=require("os"),AE=require("fs"),g1=U(xE());var wk=(0,RE.promisify)(vE.Stream.pipeline);var TE=require("fs-extra");var A1=U(require("path")),T1=U(NE()),O1=U(require("chalk")),Cu=require("fs-extra");var uo=U(require("chalk"));var Ve=U(require("chalk")),yi=class{constructor(e){this.transform=e.transformer,this.dry=e.
|
39
|
+
`:""}var s0=n0,o0={dump:s0};function Ho(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var a0=fe,l0=sh,c0=ch,u0=dh,h0=mh,f0=Fo,p0=Ih.load,d0=Ih.loadAll,m0=o0.dump,g0=xe,y0={binary:Sh,float:ph,map:lh,null:uh,pairs:wh,set:xh,timestamp:_h,bool:hh,int:fh,merge:Eh,omap:bh,seq:ah,str:oh},_0=Ho("safeLoad","load"),E0=Ho("safeLoadAll","loadAll"),S0=Ho("safeDump","dump"),b0={Type:a0,Schema:l0,FAILSAFE_SCHEMA:c0,JSON_SCHEMA:u0,CORE_SCHEMA:h0,DEFAULT_SCHEMA:f0,load:p0,loadAll:d0,dump:m0,YAMLException:g0,types:y0,safeLoad:_0,safeLoadAll:E0,safeDump:S0},jh=b0;var $d=U(Id()),Ud=U(require("json5"));var He={};Iu(He,{bold:()=>TR,dimmed:()=>CR,error:()=>Hd,grey:()=>LR,info:()=>AR,item:()=>PR,log:()=>qt,turboBlue:()=>qr,turboGradient:()=>RR,turboLoader:()=>qd,turboRed:()=>Md,underline:()=>OR,warn:()=>wl,yellow:()=>Bd});var Bt=U(require("chalk")),kd=U(require("ora")),Nd=U(require("gradient-string")),Dd="#0099F7",Fd="#F11712",vR="#FFFF00",RR=(0,Nd.default)(Dd,Fd),qr=Bt.default.hex(Dd),Md=Bt.default.hex(Fd),Bd=Bt.default.hex(vR),qd=t=>(0,kd.default)({text:t,spinner:{frames:[" ",qr("> "),qr(">> "),qr(">>>")]}}),AR=(...t)=>{qt(qr.bold(">>>"),...t)},TR=(...t)=>{qt(Bt.default.bold(...t))},OR=(...t)=>{qt(Bt.default.underline(...t))},CR=(...t)=>{qt(Bt.default.dim(...t))},LR=(...t)=>{qt(Bt.default.grey(...t))},PR=(...t)=>{qt(qr.bold(" \u2022"),...t)},qt=(...t)=>{console.log(...t)},wl=(...t)=>{console.error(Bd.bold(">>>"),...t)},Hd=(...t)=>{console.error(Md.bold(">>>"),...t)};var IR="turbo.json";var xl={};function kR(t){try{if(Li.default.existsSync(lr.default.join(t,"pnpm-workspace.yaml")))return jh.load(Li.default.readFileSync(lr.default.join(t,"pnpm-workspace.yaml"),"utf8")).packages||[];let e=JSON.parse(Li.default.readFileSync(lr.default.join(t,"package.json"),"utf8"));if(e.workspaces){if("packages"in e.workspaces)return e.workspaces.packages||[];if(Array.isArray(e.workspaces))return e.workspaces}return[]}catch{return[]}}function vl(t,e){var s;let r=Ao(t,e),i=[],n=(s=e==null?void 0:e.cache)!=null?s:!0;if(n&&t&&t in xl)return xl[t];if(r){let a=kR(r).map(c=>`${c}/turbo.json`);(0,$d.sync)([IR,...a],{cwd:r,onlyFiles:!0,followSymbolicLinks:!1,suppressErrors:!0}).map(c=>lr.default.join(r,c)).forEach(c=>{try{let u=Li.default.readFileSync(c,"utf8"),h=Ud.default.parse(u),f=lr.default.dirname(c)===r;if(f){if("extends"in h)return}else if(!("extends"in h))return;i.push({config:h,turboConfigPath:c,workspacePath:lr.default.dirname(c),isRootConfig:f})}catch(u){wl(u)}})}return n&&t&&(xl[t]=i),i}var TT=U(require("os")),OT=U(Rg());var CT=U(require("fs-extra"));var LT=U(require("path")),PT=U(require("fs-extra")),IT=U(require("chalk"));var vE=require("stream"),RE=require("util"),d1=require("path"),m1=require("os"),AE=require("fs"),g1=U(xE());var wk=(0,RE.promisify)(vE.Stream.pipeline);var TE=require("fs-extra");var A1=U(require("path")),T1=U(NE()),O1=U(require("chalk")),Cu=require("fs-extra");var uo=U(require("chalk"));var Ve=U(require("chalk")),yi=class{constructor(e){this.transform=e.transformer,this.dry=e.dryRun}_log(...e){console.log(...e)}modified(...e){this._log(Ve.default.green(" MODIFIED "),...e,this.dry?Ve.default.dim("(dry run)"):"")}unchanged(...e){this._log(Ve.default.gray(" UNCHANGED "),...e,this.dry?Ve.default.dim("(dry run)"):"")}skipped(...e){this._log(Ve.default.yellow(" SKIPPED "),...e,this.dry?Ve.default.dim("(dry run)"):"")}error(...e){this._log(Ve.default.red(" ERROR "),...e,this.dry?Ve.default.dim("(dry run)"):"")}info(...e){this._log(Ve.default.bold(" INFO "),...e,this.dry?Ve.default.dim("(dry run)"):"")}};var DE=U(require("os")),Lu=U(require("path"));var ao=U(require("chalk")),co=require("diff"),Jt=require("fs-extra"),lo=class{constructor(e){this.changes=[];if(this.filePath=e.filePath,this.rootPath=e.rootPath,this.after=e.after,this.error=e.error,e.before===void 0)try{Lu.default.extname(e.filePath)===".json"?this.before=(0,Jt.readJsonSync)(e.filePath):this.before=(0,Jt.readFileSync)(e.filePath)}catch{this.before=""}else e.before===null?this.before="":this.before=e.before;e.after?typeof this.before=="object"||typeof e.after=="object"?this.changes=(0,co.diffJson)(this.before,e.after):this.changes=(0,co.diffLines)(this.before,e.after):this.changes=[]}fileName(){return Lu.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,Jt.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,Jt.writeFileSync)(this.filePath,this.after))}additions(){return this.changes.filter(e=>e.added).length}deletions(){return this.changes.filter(e=>e.removed).length}hasChanges(){return this.additions()>0||this.deletions()>0}log(e){e.diff?(this.changes.forEach(r=>{r.added?process.stdout.write(ao.default.green(r.value)):r.removed?process.stdout.write(ao.default.red(r.value)):process.stdout.write(ao.default.dim(r.value))}),He.log(DE.default.EOL)):He.log(this.after)}};var rn=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dryRun,this.print=e.print,this.logger=new yi(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new lo({rootPath:this.rootPath,...e})}finish(){let e={changes:{}};return Object.keys(this.modifications).forEach(i=>{let n=this.modifications[i],s={action:"unchanged",additions:n.additions(),deletions:n.deletions()};if(n.hasChanges()){if(this.dry)s.action="skipped",this.logger.skipped(uo.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(uo.default.bold(n.fileName()))}catch(o){let a="Unknown error";o instanceof Error&&(a=o.message),s.error=new Error(a),s.action="error",this.logger.error(n.fileName(),a)}this.print&&n.log({diff:!0})}else this.logger.unchanged(uo.default.dim(n.fileName()));e.changes[n.fileName()]=s}),Object.keys(e.changes).some(i=>e.changes[i].action==="error")?this.abortTransform({reason:"Encountered an error while transforming files",changes:e.changes}):e}static logResults(e){let r=Object.keys(e.changes);if(He.log(),r.length>0){He.bold("Results:");let i={};r.forEach(n=>{var o;let s=e.changes[n];i[n]={action:s.action,additions:s.additions,deletions:s.deletions,error:((o=s.error)==null?void 0:o.message)||"None"}}),console.table(i),He.log()}}};function FE({transformer:t,rootPath:e,options:r}){let i={transformer:t,rootPath:e,...r},n=new yi(i),s=new rn(i);return{log:n,runner:s}}var ME=require("fs-extra"),BE=require("json5");function qE(t){let e=(0,ME.readFileSync)(t,"utf8");return(0,BE.parse)(e)}var HE="transform-env-literals-to-wildcards",C1="Rewrite env fields to distinguish wildcards from literals",L1="1.10.0";function ho(t){let e=t;return t.startsWith("!")&&(e=`\\${e}`),e=e.replace(/\*/g,"\\*"),e}function P1(t){let{globalEnv:e,globalPassThroughEnv:r}=t;return Array.isArray(e)&&(t.globalEnv=e.map(ho)),Array.isArray(r)&&(t.globalPassThroughEnv=r.map(ho)),$E(t)}function $E(t){for(let[e,r]of Object.entries(t.pipeline)){let{env:i,passThroughEnv:n}=r;Array.isArray(i)&&(r.env=i.map(ho)),Array.isArray(n)&&(r.passThroughEnv=n.map(ho))}return t}function UE({root:t,options:e}){let{log:r,runner:i}=FE({transformer:HE,rootPath:t,options:e}),n=Pu.default.join(t,"package.json"),s={};try{s=(0,fo.readJsonSync)(n)}catch{}if("turbo"in s)return i.abortTransform({reason:'"turbo" key detected in package.json. Run `npx @turbo/codemod transform create-turbo-config` first'});r.info("Rewriting env vars to support wildcards");let o=Pu.default.join(t,"turbo.json");if(!(0,fo.existsSync)(o))return i.abortTransform({reason:`No turbo.json found at ${t}. Is the path correct?`});let a=qE(o);return i.modifyFile({filePath:o,after:P1(a)}),vl(t).forEach(c=>{let{config:u,turboConfigPath:h,isRootConfig:f}=c;!f&&"pipeline"in u&&i.modifyFile({filePath:h,after:$E(u)})}),i.finish()}var I1={name:HE,description:C1,introducedIn:L1,transformer:UE},k1=I1;0&&(module.exports={transformer});
|
40
40
|
/*! Bundled license information:
|
41
41
|
|
42
42
|
@babel/runtime/helpers/regeneratorRuntime.js:
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@turbo/codemod",
|
3
|
-
"version": "2.0.0-canary.
|
3
|
+
"version": "2.0.0-canary.4",
|
4
4
|
"description": "Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",
|
5
5
|
"homepage": "https://turbo.build/repo",
|
6
6
|
"license": "MIT",
|
@@ -47,12 +47,12 @@
|
|
47
47
|
"tsup": "^6.7.0",
|
48
48
|
"typescript": "5.3.3",
|
49
49
|
"@turbo/eslint-config": "0.0.0",
|
50
|
-
"@turbo/gen": "2.0.0-canary.
|
51
|
-
"@turbo/tsconfig": "0.0.0",
|
52
|
-
"@turbo/types": "2.0.0-canary.3",
|
50
|
+
"@turbo/gen": "2.0.0-canary.4",
|
53
51
|
"@turbo/utils": "0.0.0",
|
54
52
|
"@turbo/test-utils": "0.0.0",
|
55
|
-
"@turbo/
|
53
|
+
"@turbo/tsconfig": "0.0.0",
|
54
|
+
"@turbo/types": "2.0.0-canary.4",
|
55
|
+
"@turbo/workspaces": "2.0.0-canary.4"
|
56
56
|
},
|
57
57
|
"files": [
|
58
58
|
"dist"
|