@turbo/codemod 1.10.12 → 1.10.13-canary.0
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/dist/cli.js +267 -4
- package/dist/transforms/add-package-manager.js +264 -1
- package/dist/transforms/create-turbo-config.js +1 -1
- package/dist/transforms/migrate-env-var-dependencies.js +36 -36
- package/dist/transforms/set-default-outputs.js +36 -36
- package/dist/transforms/stabilize-env-mode.js +35 -35
- package/dist/transforms/transform-env-literals-to-wildcards.js +36 -36
- package/package.json +4 -3
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var x=Object.create;var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var D=(e,r)=>{for(var t in r)g(e,t,{get:r[t],enumerable:!0})},j=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of v(r))!J.call(e,o)&&o!==t&&g(e,o,{get:()=>r[o],enumerable:!(s=S(r,o))||s.enumerable});return e};var l=(e,r,t)=>(t=e!=null?x(I(e)):{},j(r||!e||!e.__esModule?g(t,"default",{value:e,enumerable:!0}):t,e)),U=e=>j(g({},"__esModule",{value:!0}),e);var K={};D(K,{default:()=>G,transformer:()=>O});module.exports=U(K);var p=l(require("fs-extra")),F=l(require("path"));var m=l(require("chalk"));var u=l(require("chalk")),y=require("diff"),h=l(require("fs-extra")),w=l(require("os")),b=l(require("path")),d=class{constructor(r){this.changes=[];if(this.filePath=r.filePath,this.rootPath=r.rootPath,this.after=r.after,this.error=r.error,r.before===void 0)try{b.default.extname(r.filePath)===".json"?this.before=h.default.readJsonSync(r.filePath):this.before=h.default.readFileSync(r.filePath)}catch{this.before=""}else r.before===null?this.before="":this.before=r.before;r.after?typeof this.before=="object"||typeof r.after=="object"?this.changes=(0,y.diffJson)(this.before,r.after):this.changes=(0,y.diffLines)(this.before,r.after):this.changes=[]}fileName(){return b.default.relative(this.rootPath,this.filePath)}write(){this.after&&(typeof this.after=="object"?h.default.writeJsonSync(this.filePath,this.after,{spaces:2}):h.default.writeFileSync(this.filePath,this.after))}additions(){return this.changes.filter(r=>r.added).length}deletions(){return this.changes.filter(r=>r.removed).length}hasChanges(){return this.additions()>0||this.deletions()>0}log(r){r.diff?(this.changes.forEach(t=>{t.added?process.stdout.write(u.default.green(t.value)):t.removed?process.stdout.write(u.default.red(t.value)):process.stdout.write(u.default.dim(t.value))}),console.log(w.default.EOL)):console.log(this.after)}};var n=l(require("chalk")),c=class{constructor(r){this.transform=r.transformer,this.dry=r.dry}modified(...r){console.log(n.default.green(" MODIFIED "),...r,this.dry?n.default.dim("(dry run)"):"")}unchanged(...r){console.log(n.default.gray(" UNCHANGED "),...r,this.dry?n.default.dim("(dry run)"):"")}skipped(...r){console.log(n.default.yellow(" SKIPPED "),...r,this.dry?n.default.dim("(dry run)"):"")}error(...r){console.log(n.default.red(" ERROR "),...r,this.dry?n.default.dim("(dry run)"):"")}info(...r){console.log(n.default.bold(" INFO "),...r,this.dry?n.default.dim("(dry run)"):"")}};var P=class{constructor(r){this.modifications={};this.transform=r.transformer,this.rootPath=r.rootPath,this.dry=r.dry,this.print=r.print,this.logger=new c(r)}abortTransform(r){return this.logger.error(r.reason),{fatalError:new Error(r.reason),changes:r.changes||{}}}modifyFile(r){this.modifications[r.filePath]=new d({rootPath:this.rootPath,...r})}finish(){let r={changes:{}};return Object.keys(this.modifications).forEach(s=>{let o=this.modifications[s],i={action:"unchanged",additions:o.additions(),deletions:o.deletions()};if(o.hasChanges()){if(this.dry)i.action="skipped",this.logger.skipped(m.default.dim(o.fileName()));else try{o.write(),i.action="modified",this.logger.modified(m.default.bold(o.fileName()))}catch(a){let f="Unknown error";a instanceof Error&&(f=a.message),i.error=new Error(f),i.action="error",this.logger.error(o.fileName(),f)}this.print&&o.log({diff:!0})}else this.logger.unchanged(m.default.dim(o.fileName()));r.changes[o.fileName()]=i}),Object.keys(r.changes).some(s=>r.changes[s].action==="error")?this.abortTransform({reason:"Encountered an error while transforming files",changes:r.changes}):r}static logResults(r){let t=Object.keys(r.changes);if(console.log(),t.length>0){console.log(m.default.bold("Results:"));let s={};t.forEach(o=>{var a;let i=r.changes[o];s[o]={action:i.action,additions:i.additions,deletions:i.deletions,error:((a=i.error)==null?void 0:a.message)||"None"}}),console.table(s),console.log()}}},T=P;function R({transformer:e,rootPath:r,options:t}){let s={transformer:e,rootPath:r,...t},o=new c(s),i=new T(s);return{log:o,runner:i}}var N="create-turbo-config",L='Create the `turbo.json` file from an existing "turbo" key in `package.json`',M="1.1.0";function O({root:e,options:r}){let{log:t,runner:s}=R({transformer:N,rootPath:e,options:r});t.info('Migrating "package.json" "turbo" key to "turbo.json" file...');let o=F.default.join(e,"turbo.json"),i=F.default.join(e,"package.json");if(!p.default.existsSync(i))return s.abortTransform({reason:`No package.json found at ${e}. Is the path correct?`});let a=p.default.readJsonSync(i),f=null;try{f=p.default.readJSONSync(o)}catch{f=null}let k=a,A=f;if(!f&&a.turbo){let{turbo:E,...C}=a;A=E,k=C}return s.modifyFile({filePath:o,after:A}),s.modifyFile({filePath:i,after:k}),s.finish()}var H={name:N,description:L,introducedIn:M,transformer:O},G=H;0&&(module.exports={transformer});
|