@turbo/codemod 2.0.0-canary.0 → 2.0.0-canary.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cli.js +15 -15
- package/dist/transforms/add-package-names.js +1 -1
- package/dist/transforms/clean-globs.js +16 -16
- package/dist/transforms/migrate-dot-env.js +106 -0
- package/dist/transforms/migrate-env-var-dependencies.js +13 -13
- package/dist/transforms/rename-output-mode.js +1 -1
- package/dist/transforms/rename-pipeline.js +106 -0
- package/dist/transforms/set-default-outputs.js +6 -6
- package/dist/transforms/stabilize-env-mode.js +1 -1
- package/dist/transforms/stabilize-ui.js +93 -0
- package/dist/transforms/transform-env-literals-to-wildcards.js +23 -23
- package/package.json +6 -6
@@ -49,7 +49,7 @@ ${i.message}`:d,w=[y,e,t].filter(Boolean).join(`
|
|
49
49
|
`+t.slice(n,s),n=s+1),o=u;return a+=`
|
50
50
|
`,t.length-n>e&&o>n?a+=t.slice(n,o)+`
|
51
51
|
`+t.slice(o+1):a+=t.slice(n),a.slice(1)}function N_(t){for(var e="",r=0,i,n=0;n<t.length;r>=65536?n+=2:n++)r=qi(t,n),i=_e[r],!i&&ji(r)?(e+=t[n],r>=65536&&(e+=t[n+1])):e+=i||x_(r);return e}function k_(t,e,r){var i="",n=t.tag,s,o,u;for(s=0,o=r.length;s<o;s+=1)u=r[s],t.replacer&&(u=t.replacer.call(r,String(s),u)),(Ft(t,e,u,!1,!1)||typeof u=="undefined"&&Ft(t,e,null,!1,!1))&&(i!==""&&(i+=","+(t.condenseFlow?"":" ")),i+=t.dump);t.tag=n,t.dump="["+i+"]"}function Of(t,e,r,i){var n="",s=t.tag,o,u,a;for(o=0,u=r.length;o<u;o+=1)a=r[o],t.replacer&&(a=t.replacer.call(r,String(o),a)),(Ft(t,e+1,a,!0,!0,!1,!0)||typeof a=="undefined"&&Ft(t,e+1,null,!0,!0,!1,!0))&&((!i||n!=="")&&(n+=su(t,e)),t.dump&&$i===t.dump.charCodeAt(0)?n+="-":n+="- ",n+=t.dump);t.tag=s,t.dump=n||"[]"}function M_(t,e,r){var i="",n=t.tag,s=Object.keys(r),o,u,a,c,l;for(o=0,u=s.length;o<u;o+=1)l="",i!==""&&(l+=", "),t.condenseFlow&&(l+='"'),a=s[o],c=r[a],t.replacer&&(c=t.replacer.call(r,a,c)),Ft(t,e,a,!1,!1)&&(t.dump.length>1024&&(l+="? "),l+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ft(t,e,c,!1,!1)&&(l+=t.dump,i+=l));t.tag=n,t.dump="{"+i+"}"}function q_(t,e,r,i){var n="",s=t.tag,o=Object.keys(r),u,a,c,l,f,h;if(t.sortKeys===!0)o.sort();else if(typeof t.sortKeys=="function")o.sort(t.sortKeys);else if(t.sortKeys)throw new Be("sortKeys must be a boolean or a function");for(u=0,a=o.length;u<a;u+=1)h="",(!i||n!=="")&&(h+=su(t,e)),c=o[u],l=r[c],t.replacer&&(l=t.replacer.call(r,c,l)),Ft(t,e+1,c,!0,!0,!0)&&(f=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,f&&(t.dump&&$i===t.dump.charCodeAt(0)?h+="?":h+="? "),h+=t.dump,f&&(h+=su(t,e)),Ft(t,e+1,l,!0,f)&&(t.dump&&$i===t.dump.charCodeAt(0)?h+=":":h+=": ",h+=t.dump,n+=h));t.tag=s,t.dump=n||"{}"}function Bf(t,e,r){var i,n,s,o,u,a;for(n=r?t.explicitTypes:t.implicitTypes,s=0,o=n.length;s<o;s+=1)if(u=n[s],(u.instanceOf||u.predicate)&&(!u.instanceOf||typeof e=="object"&&e instanceof u.instanceOf)&&(!u.predicate||u.predicate(e))){if(r?u.multi&&u.representName?t.tag=u.representName(e):t.tag=u.tag:t.tag="?",u.represent){if(a=t.styleMap[u.tag]||u.defaultStyle,ch.call(u.represent)==="[object Function]")i=u.represent(e,a);else if(lh.call(u.represent,a))i=u.represent[a](e,a);else throw new Be("!<"+u.tag+'> tag resolver accepts not "'+a+'" style');t.dump=i}return!0}return!1}function Ft(t,e,r,i,n,s,o){t.tag=null,t.dump=r,Bf(t,r,!1)||Bf(t,r,!0);var u=ch.call(t.dump),a=i,c;i&&(i=t.flowLevel<0||t.flowLevel>e);var l=u==="[object Object]"||u==="[object Array]",f,h;if(l&&(f=t.duplicates.indexOf(r),h=f!==-1),(t.tag!==null&&t.tag!=="?"||h||t.indent!==2&&e>0)&&(n=!1),h&&t.usedDuplicates[f])t.dump="*ref_"+f;else{if(l&&h&&!t.usedDuplicates[f]&&(t.usedDuplicates[f]=!0),u==="[object Object]")i&&Object.keys(t.dump).length!==0?(q_(t,e,t.dump,n),h&&(t.dump="&ref_"+f+t.dump)):(M_(t,e,t.dump),h&&(t.dump="&ref_"+f+" "+t.dump));else if(u==="[object Array]")i&&t.dump.length!==0?(t.noArrayIndent&&!o&&e>0?Of(t,e-1,t.dump,n):Of(t,e,t.dump,n),h&&(t.dump="&ref_"+f+t.dump)):(k_(t,e,t.dump),h&&(t.dump="&ref_"+f+" "+t.dump));else if(u==="[object String]")t.tag!=="?"&&L_(t,t.dump,e,s,a);else{if(u==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new Be("unacceptable kind of an object to dump "+u)}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 H_(t,e){var r=[],i=[],n,s;for(uu(t,r,i),n=0,s=i.length;n<s;n+=1)e.duplicates.push(r[i[n]]);e.usedDuplicates=new Array(s)}function uu(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)uu(t[n],e,r);else for(i=Object.keys(t),n=0,s=i.length;n<s;n+=1)uu(t[i[n]],e,r)}function $_(t,e){e=e||{};var r=new R_(e);r.noRefs||H_(t,r);var i=t;return r.replacer&&(i=r.replacer.call({"":i},"",i)),Ft(r,0,i,!0,!0)?r.dump+`
|
52
|
-
`:""}var U_=$_,j_={dump:U_};function pu(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 G_=Ae,W_=If,z_=qf,Y_=Gf,K_=Wf,V_=cu,X_=ah.load,Z_=ah.loadAll,J_=j_.dump,Q_=Be,eS={binary:Xf,float:jf,map:Mf,null:Hf,pairs:Jf,set:Qf,timestamp:Kf,bool:$f,int:Uf,merge:Vf,omap:Zf,seq:kf,str:Nf},tS=pu("safeLoad","load"),rS=pu("safeLoadAll","loadAll"),iS=pu("safeDump","dump"),nS={Type:G_,Schema:W_,FAILSAFE_SCHEMA:z_,JSON_SCHEMA:Y_,CORE_SCHEMA:K_,DEFAULT_SCHEMA:V_,load:X_,loadAll:Z_,dump:J_,YAMLException:Q_,types:eS,safeLoad:tS,safeLoadAll:rS,safeDump:iS},Ah=nS;var gm=K(um());var Ve={};of(Ve,{bold:()=>lw,dimmed:()=>hw,error:()=>mm,grey:()=>pw,info:()=>cw,item:()=>dw,log:()=>Qt,turboBlue:()=>ti,turboGradient:()=>aw,turboLoader:()=>dm,turboRed:()=>hm,underline:()=>fw,warn:()=>Va,yellow:()=>pm});var Jt=K(require("chalk")),am=K(require("ora")),cm=K(require("gradient-string")),lm="#0099F7",fm="#F11712",uw="#FFFF00",aw=(0,cm.default)(lm,fm),ti=Jt.default.hex(lm),hm=Jt.default.hex(fm),pm=Jt.default.hex(uw),dm=t=>(0,am.default)({text:t,spinner:{frames:[" ",ti("> "),ti(">> "),ti(">>>")]}}),cw=(...t)=>{Qt(ti.bold(">>>"),...t)},lw=(...t)=>{Qt(Jt.default.bold(...t))},fw=(...t)=>{Qt(Jt.default.underline(...t))},hw=(...t)=>{Qt(Jt.default.dim(...t))},pw=(...t)=>{Qt(Jt.default.grey(...t))},dw=(...t)=>{Qt(ti.bold(" \u2022"),...t)},Qt=(...t)=>{console.log(...t)},Va=(...t)=>{console.error(pm.bold(">>>"),...t)},mm=(...t)=>{console.error(hm.bold(">>>"),...t)};var mw="turbo.json";var Xa={};function gw(t){try{if(Ki.default.existsSync(br.default.join(t,"pnpm-workspace.yaml")))return Ah.load(Ki.default.readFileSync(br.default.join(t,"pnpm-workspace.yaml"),"utf8")).packages||[];let e=JSON.parse(Ki.default.readFileSync(br.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 Za(t,e){var s;let r=Qo(t,e),i=[],n=(s=e==null?void 0:e.cache)!=null?s:!0;if(n&&t&&t in Xa)return Xa[t];if(r){let u=gw(r).map(c=>`${c}/turbo.json`);(0,gm.sync)([mw,...u],{cwd:r,onlyFiles:!0,followSymbolicLinks:!1,suppressErrors:!0}).map(c=>br.default.join(r,c)).forEach(c=>{try{let l=Ki.default.readFileSync(c,"utf8"),f=On.parse(l),h=br.default.dirname(c)===r;if(h){if("extends"in f)return}else if(!("extends"in f))return;i.push({config:f,turboConfigPath:c,workspacePath:br.default.dirname(c),isRootConfig:h})}catch(l){Va(l)}})}return n&&t&&(Xa[t]=i),i}var lx=K(require("os")),fx=K(Q0());var hx=K(require("fs-extra"));var px=K(require("path")),dx=K(require("fs-extra")),mx=K(require("chalk"));var JD=require("stream"),QD=require("util"),ZR=require("path"),JR=require("os"),ey=require("fs"),QR=K(ZD());var uP=(0,QD.promisify)(JD.Stream.pipeline);var ty=require("fs-extra");var cT=K(require("path")),lT=K(ay()),fT=K(require("chalk")),rf=require("fs-extra");var Lo=K(require("chalk"));var st=K(require("chalk")),Pi=class{constructor(e){this.transform=e.transformer,this.dry=e.dry}_log(...e){console.log(...e)}modified(...e){this._log(st.default.green(" MODIFIED "),...e,this.dry?st.default.dim("(dry run)"):"")}unchanged(...e){this._log(st.default.gray(" UNCHANGED "),...e,this.dry?st.default.dim("(dry run)"):"")}skipped(...e){this._log(st.default.yellow(" SKIPPED "),...e,this.dry?st.default.dim("(dry run)"):"")}error(...e){this._log(st.default.red(" ERROR "),...e,this.dry?st.default.dim("(dry run)"):"")}info(...e){this._log(st.default.bold(" INFO "),...e,this.dry?st.default.dim("(dry run)"):"")}};var cy=K(require("os")),nf=K(require("path"));var Oo=K(require("chalk")),Po=require("diff"),pr=require("fs-extra"),Bo=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{nf.default.extname(e.filePath)===".json"?this.before=(0,pr.readJsonSync)(e.filePath):this.before=(0,pr.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,Po.diffJson)(this.before,e.after):this.changes=(0,Po.diffLines)(this.before,e.after):this.changes=[]}fileName(){return nf.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,pr.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,pr.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(Oo.default.green(r.value)):r.removed?process.stdout.write(Oo.default.red(r.value)):process.stdout.write(Oo.default.dim(r.value))}),Ve.log(cy.default.EOL)):Ve.log(this.after)}};var _n=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dry,this.print=e.print,this.logger=new Pi(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new Bo({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(Lo.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(Lo.default.bold(n.fileName()))}catch(o){let u="Unknown error";o instanceof Error&&(u=o.message),s.error=new Error(u),s.action="error",this.logger.error(n.fileName(),u)}this.print&&n.log({diff:!0})}else this.logger.unchanged(Lo.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(Ve.log(),r.length>0){Ve.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),Ve.log()}}};function ly({transformer:t,rootPath:e,options:r}){let i={transformer:t,rootPath:e,...r},n=new Pi(i),s=new _n(i);return{log:n,runner:s}}var hy="rename-output-mode",hT='Rename the "outputMode" key to "outputLogs" in `turbo.json`',pT="2.0.0";function fy(t){for(let[e,r]of Object.entries(t.pipeline))Object.prototype.hasOwnProperty.call(r,"outputMode")&&(r.outputLogs=r.outputMode,delete r.outputMode);return t}function py({root:t,options:e}){let{log:r,runner:i}=ly({transformer:hy,rootPath:t,options:e}),n=sf.default.join(t,"package.json"),s={};try{s=(0,Sn.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("Renaming `outputMode` key in task config to `outputLogs`");let o=sf.default.join(t,"turbo.json");if(!(0,Sn.existsSync)(o))return i.abortTransform({reason:`No turbo.json found at ${t}. Is the path correct?`});let u=(0,Sn.readJsonSync)(o);return i.modifyFile({filePath:o,after:fy(u)}),Za(t).forEach(c=>{let{config:l,turboConfigPath:f}=c;i.modifyFile({filePath:f,after:fy(l)})}),i.finish()}var dT={name:hy,description:hT,introducedIn:pT,transformer:py},mT=dT;0&&(module.exports={transformer});
|
52
|
+
`:""}var U_=$_,j_={dump:U_};function pu(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 G_=Ae,W_=If,z_=qf,Y_=Gf,K_=Wf,V_=cu,X_=ah.load,Z_=ah.loadAll,J_=j_.dump,Q_=Be,eS={binary:Xf,float:jf,map:Mf,null:Hf,pairs:Jf,set:Qf,timestamp:Kf,bool:$f,int:Uf,merge:Vf,omap:Zf,seq:kf,str:Nf},tS=pu("safeLoad","load"),rS=pu("safeLoadAll","loadAll"),iS=pu("safeDump","dump"),nS={Type:G_,Schema:W_,FAILSAFE_SCHEMA:z_,JSON_SCHEMA:Y_,CORE_SCHEMA:K_,DEFAULT_SCHEMA:V_,load:X_,loadAll:Z_,dump:J_,YAMLException:Q_,types:eS,safeLoad:tS,safeLoadAll:rS,safeDump:iS},Ah=nS;var gm=K(um());var Ve={};of(Ve,{bold:()=>lw,dimmed:()=>hw,error:()=>mm,grey:()=>pw,info:()=>cw,item:()=>dw,log:()=>Qt,turboBlue:()=>ti,turboGradient:()=>aw,turboLoader:()=>dm,turboRed:()=>hm,underline:()=>fw,warn:()=>Va,yellow:()=>pm});var Jt=K(require("chalk")),am=K(require("ora")),cm=K(require("gradient-string")),lm="#0099F7",fm="#F11712",uw="#FFFF00",aw=(0,cm.default)(lm,fm),ti=Jt.default.hex(lm),hm=Jt.default.hex(fm),pm=Jt.default.hex(uw),dm=t=>(0,am.default)({text:t,spinner:{frames:[" ",ti("> "),ti(">> "),ti(">>>")]}}),cw=(...t)=>{Qt(ti.bold(">>>"),...t)},lw=(...t)=>{Qt(Jt.default.bold(...t))},fw=(...t)=>{Qt(Jt.default.underline(...t))},hw=(...t)=>{Qt(Jt.default.dim(...t))},pw=(...t)=>{Qt(Jt.default.grey(...t))},dw=(...t)=>{Qt(ti.bold(" \u2022"),...t)},Qt=(...t)=>{console.log(...t)},Va=(...t)=>{console.error(pm.bold(">>>"),...t)},mm=(...t)=>{console.error(hm.bold(">>>"),...t)};var mw="turbo.json";var Xa={};function gw(t){try{if(Ki.default.existsSync(br.default.join(t,"pnpm-workspace.yaml")))return Ah.load(Ki.default.readFileSync(br.default.join(t,"pnpm-workspace.yaml"),"utf8")).packages||[];let e=JSON.parse(Ki.default.readFileSync(br.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 Za(t,e){var s;let r=Qo(t,e),i=[],n=(s=e==null?void 0:e.cache)!=null?s:!0;if(n&&t&&t in Xa)return Xa[t];if(r){let u=gw(r).map(c=>`${c}/turbo.json`);(0,gm.sync)([mw,...u],{cwd:r,onlyFiles:!0,followSymbolicLinks:!1,suppressErrors:!0}).map(c=>br.default.join(r,c)).forEach(c=>{try{let l=Ki.default.readFileSync(c,"utf8"),f=On.parse(l),h=br.default.dirname(c)===r;if(h){if("extends"in f)return}else if(!("extends"in f))return;i.push({config:f,turboConfigPath:c,workspacePath:br.default.dirname(c),isRootConfig:h})}catch(l){Va(l)}})}return n&&t&&(Xa[t]=i),i}var lx=K(require("os")),fx=K(Q0());var hx=K(require("fs-extra"));var px=K(require("path")),dx=K(require("fs-extra")),mx=K(require("chalk"));var JD=require("stream"),QD=require("util"),ZR=require("path"),JR=require("os"),ey=require("fs"),QR=K(ZD());var uP=(0,QD.promisify)(JD.Stream.pipeline);var ty=require("fs-extra");var cT=K(require("path")),lT=K(ay()),fT=K(require("chalk")),rf=require("fs-extra");var Lo=K(require("chalk"));var st=K(require("chalk")),Pi=class{constructor(e){this.transform=e.transformer,this.dry=e.dry}_log(...e){console.log(...e)}modified(...e){this._log(st.default.green(" MODIFIED "),...e,this.dry?st.default.dim("(dry run)"):"")}unchanged(...e){this._log(st.default.gray(" UNCHANGED "),...e,this.dry?st.default.dim("(dry run)"):"")}skipped(...e){this._log(st.default.yellow(" SKIPPED "),...e,this.dry?st.default.dim("(dry run)"):"")}error(...e){this._log(st.default.red(" ERROR "),...e,this.dry?st.default.dim("(dry run)"):"")}info(...e){this._log(st.default.bold(" INFO "),...e,this.dry?st.default.dim("(dry run)"):"")}};var cy=K(require("os")),nf=K(require("path"));var Oo=K(require("chalk")),Po=require("diff"),pr=require("fs-extra"),Bo=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{nf.default.extname(e.filePath)===".json"?this.before=(0,pr.readJsonSync)(e.filePath):this.before=(0,pr.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,Po.diffJson)(this.before,e.after):this.changes=(0,Po.diffLines)(this.before,e.after):this.changes=[]}fileName(){return nf.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?(0,pr.writeJsonSync)(this.filePath,this.after,{spaces:2}):(0,pr.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(Oo.default.green(r.value)):r.removed?process.stdout.write(Oo.default.red(r.value)):process.stdout.write(Oo.default.dim(r.value))}),Ve.log(cy.default.EOL)):Ve.log(this.after)}};var _n=class{constructor(e){this.modifications={};this.transform=e.transformer,this.rootPath=e.rootPath,this.dry=e.dry,this.print=e.print,this.logger=new Pi(e)}abortTransform(e){return this.logger.error(e.reason),{fatalError:new Error(e.reason),changes:e.changes||{}}}modifyFile(e){this.modifications[e.filePath]=new Bo({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(Lo.default.dim(n.fileName()));else try{n.write(),s.action="modified",this.logger.modified(Lo.default.bold(n.fileName()))}catch(o){let u="Unknown error";o instanceof Error&&(u=o.message),s.error=new Error(u),s.action="error",this.logger.error(n.fileName(),u)}this.print&&n.log({diff:!0})}else this.logger.unchanged(Lo.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(Ve.log(),r.length>0){Ve.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),Ve.log()}}};function ly({transformer:t,rootPath:e,options:r}){let i={transformer:t,rootPath:e,...r},n=new Pi(i),s=new _n(i);return{log:n,runner:s}}var hy="rename-output-mode",hT='Rename the "outputMode" key to "outputLogs" in `turbo.json`',pT="2.0.0-canary.0";function fy(t){for(let[e,r]of Object.entries(t.pipeline))Object.prototype.hasOwnProperty.call(r,"outputMode")&&(r.outputLogs=r.outputMode,delete r.outputMode);return t}function py({root:t,options:e}){let{log:r,runner:i}=ly({transformer:hy,rootPath:t,options:e}),n=sf.default.join(t,"package.json"),s={};try{s=(0,Sn.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("Renaming `outputMode` key in task config to `outputLogs`");let o=sf.default.join(t,"turbo.json");if(!(0,Sn.existsSync)(o))return i.abortTransform({reason:`No turbo.json found at ${t}. Is the path correct?`});let u=(0,Sn.readJsonSync)(o);return i.modifyFile({filePath:o,after:fy(u)}),Za(t).forEach(c=>{let{config:l,turboConfigPath:f}=c;"pipeline"in l&&i.modifyFile({filePath:f,after:fy(l)})}),i.finish()}var dT={name:hy,description:hT,introducedIn:pT,transformer:py},mT=dT;0&&(module.exports={transformer});
|
53
53
|
/*! Bundled license information:
|
54
54
|
|
55
55
|
@babel/runtime/helpers/regeneratorRuntime.js:
|