codemod 0.11.0 → 0.11.2
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/index.cjs +4 -7
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -821,7 +821,7 @@ ${Ie.join(`
|
|
|
821
821
|
`;ce.forEach(Ie=>{_e+=Ie}),e.fail(_e)}};let N={};_.conflicts=function(te,ce){Nw("<string|object> [array|string]",[te,ce],arguments.length),typeof te=="object"?Object.keys(te).forEach(_e=>{_.conflicts(_e,te[_e])}):(t.global(te),N[te]||(N[te]=[]),Array.isArray(ce)?ce.forEach(_e=>_.conflicts(te,_e)):N[te].push(ce))},_.getConflicting=()=>N,_.conflicting=function(te){Object.keys(te).forEach(ce=>{N[ce]&&N[ce].forEach(_e=>{_e&&te[ce]!==void 0&&te[_e]!==void 0&&e.fail(r("Arguments %s and %s are mutually exclusive",ce,_e))})}),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(N).forEach(ce=>{N[ce].forEach(_e=>{_e&&te[n.Parser.camelCase(ce)]!==void 0&&te[n.Parser.camelCase(_e)]!==void 0&&e.fail(r("Arguments %s and %s are mutually exclusive",ce,_e))})})},_.recommendCommands=function(te,ce){ce=ce.sort((Ue,Ke)=>Ke.length-Ue.length);let Ie=null,Se=1/0;for(let Ue=0,Ke;(Ke=ce[Ue])!==void 0;Ue++){let ft=Pwr(te,Ke);ft<=3&&ft<Se&&(Se=ft,Ie=Ke)}Ie&&e.fail(r("Did you mean %s?",Ie))},_.reset=function(te){return v=mDt(v,ce=>!te[ce]),N=mDt(N,ce=>!te[ce]),_};let L=[];return _.freeze=function(){L.push({implied:v,conflicting:N})},_.unfreeze=function(){let te=L.pop();zGe(te,void 0,n),{implied:v,conflicting:N}=te},_}var Owr,Rwr=Ma(()=>{Stn();eLt();Nwr();Ctn();Owr=["$0","--","_"]});function UGt(t,e,n,r){GGt=r;let l={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if(typeof t.extends!="string")return l;let _=/\.json|\..*rc$/.test(t.extends),v=null;if(_)v=_is(e,t.extends);else try{v=require.resolve(t.extends)}catch{return t}dis(v),hOn.push(v),l=_?JSON.parse(GGt.readFileSync(v,"utf8")):require(t.extends),delete t.extends,l=UGt(l,GGt.path.dirname(v),n,GGt)}return hOn=[],n?Mwr(l,t):Object.assign({},l,t)}function dis(t){if(hOn.indexOf(t)>-1)throw new Fte(`Circular extended configurations: '${t}'.`)}function _is(t,e){return GGt.path.resolve(t,e)}function Mwr(t,e){let n={};function r(l){return l&&typeof l=="object"&&!Array.isArray(l)}Object.assign(n,t);for(let l of Object.keys(e))r(e[l])&&r(n[l])?n[l]=Mwr(t[l],e[l]):n[l]=e[l];return n}var hOn,GGt,gOn=Ma(()=>{Y7t();hOn=[]});function nIr(t){return(e=[],n=t.process.cwd(),r)=>{let l=new kOn(e,n,r,t);return Object.defineProperty(l,"argv",{get:()=>l.parse(),enumerable:!0}),l.help(),l.version(),l}}function Swr(t){return!!t&&typeof t.getInternalMethods=="function"}var Uw,mf,_ye,MNt,VGt,rut,Snt,Dtn,gDt,FNt,ktn,iut,wtn,sut,Ixt,Ent,aut,Itn,rLt,Iwe,mN,Ptn,Ntn,Tnt,BNt,iLt,jNt,yDt,Otn,WO,WNt,GNt,UNt,NL,Ltn,Pxt,Sme,Fwr,Bwr,yOn,jwr,Wwr,Gwr,VNt,Uwr,vOn,Vwr,zwr,xOn,vDt,sLt,bOn,SOn,EOn,TOn,COn,qwr,Hwr,Jwr,Kwr,$wr,Xwr,Ywr,Qwr,Rtn,Zwr,zNt,eIr,AOn,zGt,DOn,tIr,qNt,kOn,pOn=Ma(()=>{fOn();eLt();Y7t();Cwr();Stn();Iwr();Rwr();Ctn();gOn();oOn();tLt();cOn();dOn();Uw=function(t,e,n,r,l){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!l)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!l:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?l.call(t,n):l?l.value=n:e.set(t,n),n},mf=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)};Fwr=Symbol("copyDoubleDash"),Bwr=Symbol("copyDoubleDash"),yOn=Symbol("deleteFromParserHintObject"),jwr=Symbol("emitWarning"),Wwr=Symbol("freeze"),Gwr=Symbol("getDollarZero"),VNt=Symbol("getParserConfiguration"),Uwr=Symbol("getUsageConfiguration"),vOn=Symbol("guessLocale"),Vwr=Symbol("guessVersion"),zwr=Symbol("parsePositionalNumbers"),xOn=Symbol("pkgUp"),vDt=Symbol("populateParserHintArray"),sLt=Symbol("populateParserHintSingleValueDictionary"),bOn=Symbol("populateParserHintArrayDictionary"),SOn=Symbol("populateParserHintDictionary"),EOn=Symbol("sanitizeKey"),TOn=Symbol("setKey"),COn=Symbol("unfreeze"),qwr=Symbol("validateAsync"),Hwr=Symbol("getCommandInstance"),Jwr=Symbol("getContext"),Kwr=Symbol("getHasOutput"),$wr=Symbol("getLoggerInstance"),Xwr=Symbol("getParseContext"),Ywr=Symbol("getUsageInstance"),Qwr=Symbol("getValidationInstance"),Rtn=Symbol("hasParseCallback"),Zwr=Symbol("isGlobalContext"),zNt=Symbol("postProcess"),eIr=Symbol("rebase"),AOn=Symbol("reset"),zGt=Symbol("runYargsParserAndExecuteCommands"),DOn=Symbol("runValidation"),tIr=Symbol("setHasOutput"),qNt=Symbol("kTrackManuallySetKeys"),kOn=class{constructor(e=[],n,r,l){this.customScriptName=!1,this.parsed=!1,_ye.set(this,void 0),MNt.set(this,void 0),VGt.set(this,{commands:[],fullCommands:[]}),rut.set(this,null),Snt.set(this,null),Dtn.set(this,"show-hidden"),gDt.set(this,null),FNt.set(this,!0),ktn.set(this,{}),iut.set(this,!0),wtn.set(this,[]),sut.set(this,void 0),Ixt.set(this,{}),Ent.set(this,!1),aut.set(this,null),Itn.set(this,!0),rLt.set(this,void 0),Iwe.set(this,""),mN.set(this,void 0),Ptn.set(this,void 0),Ntn.set(this,{}),Tnt.set(this,null),BNt.set(this,null),iLt.set(this,{}),jNt.set(this,{}),yDt.set(this,void 0),Otn.set(this,!1),WO.set(this,void 0),WNt.set(this,!1),GNt.set(this,!1),UNt.set(this,!1),NL.set(this,void 0),Ltn.set(this,{}),Pxt.set(this,null),Sme.set(this,void 0),Uw(this,WO,l,"f"),Uw(this,yDt,e,"f"),Uw(this,MNt,n,"f"),Uw(this,Ptn,r,"f"),Uw(this,sut,new Etn(this),"f"),this.$0=this[Gwr](),this[AOn](),Uw(this,_ye,mf(this,_ye,"f"),"f"),Uw(this,NL,mf(this,NL,"f"),"f"),Uw(this,Sme,mf(this,Sme,"f"),"f"),Uw(this,mN,mf(this,mN,"f"),"f"),mf(this,mN,"f").showHiddenOpt=mf(this,Dtn,"f"),Uw(this,rLt,this[Bwr](),"f")}addHelpOpt(e,n){let r="help";return Nw("[string|boolean] [string]",[e,n],arguments.length),mf(this,aut,"f")&&(this[yOn](mf(this,aut,"f")),Uw(this,aut,null,"f")),e===!1&&n===void 0?this:(Uw(this,aut,typeof e=="string"?e:r,"f"),this.boolean(mf(this,aut,"f")),this.describe(mf(this,aut,"f"),n||mf(this,NL,"f").deferY18nLookup("Show help")),this)}help(e,n){return this.addHelpOpt(e,n)}addShowHiddenOpt(e,n){if(Nw("[string|boolean] [string]",[e,n],arguments.length),e===!1&&n===void 0)return this;let r=typeof e=="string"?e:mf(this,Dtn,"f");return this.boolean(r),this.describe(r,n||mf(this,NL,"f").deferY18nLookup("Show hidden options")),mf(this,mN,"f").showHiddenOpt=r,this}showHidden(e,n){return this.addShowHiddenOpt(e,n)}alias(e,n){return Nw("<object|string|array> [string|array]",[e,n],arguments.length),this[bOn](this.alias.bind(this),"alias",e,n),this}array(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("array",e),this[qNt](e),this}boolean(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("boolean",e),this[qNt](e),this}check(e,n){return Nw("<function> [boolean]",[e,n],arguments.length),this.middleware((r,l)=>RNt(()=>e(r,l.getOptions()),_=>(_?(typeof _=="string"||_ instanceof Error)&&mf(this,NL,"f").fail(_.toString(),_):mf(this,NL,"f").fail(mf(this,WO,"f").y18n.__("Argument check failed: %s",e.toString())),r),_=>(mf(this,NL,"f").fail(_.message?_.message:_.toString(),_),r)),!1,n),this}choices(e,n){return Nw("<object|string|array> [string|array]",[e,n],arguments.length),this[bOn](this.choices.bind(this),"choices",e,n),this}coerce(e,n){if(Nw("<object|string|array> [function]",[e,n],arguments.length),Array.isArray(e)){if(!n)throw new Fte("coerce callback must be provided");for(let r of e)this.coerce(r,n);return this}else if(typeof e=="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!n)throw new Fte("coerce callback must be provided");return mf(this,mN,"f").key[e]=!0,mf(this,sut,"f").addCoerceMiddleware((r,l)=>{let _;return Object.prototype.hasOwnProperty.call(r,e)?RNt(()=>(_=l.getAliases(),n(r[e])),D=>{r[e]=D;let N=l.getInternalMethods().getParserConfiguration()["strip-aliased"];if(_[e]&&N!==!0)for(let L of _[e])r[L]=D;return r},D=>{throw new Fte(D.message)}):r},e),this}conflicts(e,n){return Nw("<string|object> [string|array]",[e,n],arguments.length),mf(this,Sme,"f").conflicts(e,n),this}config(e="config",n,r){return Nw("[object|string] [string|function] [function]",[e,n,r],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=UGt(e,mf(this,MNt,"f"),this[VNt]()["deep-merge-config"]||!1,mf(this,WO,"f")),mf(this,mN,"f").configObjects=(mf(this,mN,"f").configObjects||[]).concat(e),this):(typeof n=="function"&&(r=n,n=void 0),this.describe(e,n||mf(this,NL,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(l=>{mf(this,mN,"f").config[l]=r||!0}),this)}completion(e,n,r){return Nw("[string] [string|boolean|function] [function]",[e,n,r],arguments.length),typeof n=="function"&&(r=n,n=void 0),Uw(this,Snt,e||mf(this,Snt,"f")||"completion","f"),!n&&n!==!1&&(n="generate completion script"),this.command(mf(this,Snt,"f"),n),r&&mf(this,rut,"f").registerFunction(r),this}command(e,n,r,l,_,v){return Nw("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,n,r,l,_,v],arguments.length),mf(this,_ye,"f").addHandler(e,n,r,l,_,v),this}commands(e,n,r,l,_,v){return this.command(e,n,r,l,_,v)}commandDir(e,n){Nw("<string> [object]",[e,n],arguments.length);let r=mf(this,Ptn,"f")||mf(this,WO,"f").require;return mf(this,_ye,"f").addDirectory(e,r,mf(this,WO,"f").getCallerFile(),n),this}count(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("count",e),this[qNt](e),this}default(e,n,r){return Nw("<object|string|array> [*] [string]",[e,n,r],arguments.length),r&&(aOn(e,mf(this,WO,"f")),mf(this,mN,"f").defaultDescription[e]=r),typeof n=="function"&&(aOn(e,mf(this,WO,"f")),mf(this,mN,"f").defaultDescription[e]||(mf(this,mN,"f").defaultDescription[e]=mf(this,NL,"f").functionDescription(n)),n=n.call()),this[sLt](this.default.bind(this),"default",e,n),this}defaults(e,n,r){return this.default(e,n,r)}demandCommand(e=1,n,r,l){return Nw("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,n,r,l],arguments.length),typeof n!="number"&&(r=n,n=1/0),this.global("_",!1),mf(this,mN,"f").demandedCommands._={min:e,max:n,minMsg:r,maxMsg:l},this}demand(e,n,r){return Array.isArray(n)?(n.forEach(l=>{zGe(r,!0,mf(this,WO,"f")),this.demandOption(l,r)}),n=1/0):typeof n!="number"&&(r=n,n=1/0),typeof e=="number"?(zGe(r,!0,mf(this,WO,"f")),this.demandCommand(e,n,r,r)):Array.isArray(e)?e.forEach(l=>{zGe(r,!0,mf(this,WO,"f")),this.demandOption(l,r)}):typeof r=="string"?this.demandOption(e,r):(r===!0||typeof r>"u")&&this.demandOption(e),this}demandOption(e,n){return Nw("<object|string|array> [string]",[e,n],arguments.length),this[sLt](this.demandOption.bind(this),"demandedOptions",e,n),this}deprecateOption(e,n){return Nw("<string> [string|boolean]",[e,n],arguments.length),mf(this,mN,"f").deprecatedOptions[e]=n,this}describe(e,n){return Nw("<object|string|array> [string]",[e,n],arguments.length),this[TOn](e,!0),mf(this,NL,"f").describe(e,n),this}detectLocale(e){return Nw("<boolean>",[e],arguments.length),Uw(this,FNt,e,"f"),this}env(e){return Nw("[string|boolean]",[e],arguments.length),e===!1?delete mf(this,mN,"f").envPrefix:mf(this,mN,"f").envPrefix=e||"",this}epilogue(e){return Nw("<string>",[e],arguments.length),mf(this,NL,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,n){return Nw("<string|array> [string]",[e,n],arguments.length),Array.isArray(e)?e.forEach(r=>this.example(...r)):mf(this,NL,"f").example(e,n),this}exit(e,n){Uw(this,Ent,!0,"f"),Uw(this,gDt,n,"f"),mf(this,iut,"f")&&mf(this,WO,"f").process.exit(e)}exitProcess(e=!0){return Nw("[boolean]",[e],arguments.length),Uw(this,iut,e,"f"),this}fail(e){if(Nw("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new Fte("Invalid first argument. Expected function or boolean 'false'");return mf(this,NL,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,n){return Nw("<array> [function]",[e,n],arguments.length),n?mf(this,rut,"f").getCompletion(e,n):new Promise((r,l)=>{mf(this,rut,"f").getCompletion(e,(_,v)=>{_?l(_):r(v)})})}getDemandedOptions(){return Nw([],0),mf(this,mN,"f").demandedOptions}getDemandedCommands(){return Nw([],0),mf(this,mN,"f").demandedCommands}getDeprecatedOptions(){return Nw([],0),mf(this,mN,"f").deprecatedOptions}getDetectLocale(){return mf(this,FNt,"f")}getExitProcess(){return mf(this,iut,"f")}getGroups(){return Object.assign({},mf(this,Ixt,"f"),mf(this,jNt,"f"))}getHelp(){if(Uw(this,Ent,!0,"f"),!mf(this,NL,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[zGt](mf(this,yDt,"f"),void 0,void 0,0,!0);if(Cae(n))return n.then(()=>mf(this,NL,"f").help())}let e=mf(this,_ye,"f").runDefaultBuilderOn(this);if(Cae(e))return e.then(()=>mf(this,NL,"f").help())}return Promise.resolve(mf(this,NL,"f").help())}getOptions(){return mf(this,mN,"f")}getStrict(){return mf(this,WNt,"f")}getStrictCommands(){return mf(this,GNt,"f")}getStrictOptions(){return mf(this,UNt,"f")}global(e,n){return Nw("<string|array> [boolean]",[e,n],arguments.length),e=[].concat(e),n!==!1?mf(this,mN,"f").local=mf(this,mN,"f").local.filter(r=>e.indexOf(r)===-1):e.forEach(r=>{mf(this,mN,"f").local.includes(r)||mf(this,mN,"f").local.push(r)}),this}group(e,n){Nw("<string|array> <string>",[e,n],arguments.length);let r=mf(this,jNt,"f")[n]||mf(this,Ixt,"f")[n];mf(this,jNt,"f")[n]&&delete mf(this,jNt,"f")[n];let l={};return mf(this,Ixt,"f")[n]=(r||[]).concat(e).filter(_=>l[_]?!1:l[_]=!0),this}hide(e){return Nw("<string>",[e],arguments.length),mf(this,mN,"f").hiddenOptions.push(e),this}implies(e,n){return Nw("<string|object> [number|string|array]",[e,n],arguments.length),mf(this,Sme,"f").implies(e,n),this}locale(e){return Nw("[string]",[e],arguments.length),e===void 0?(this[vOn](),mf(this,WO,"f").y18n.getLocale()):(Uw(this,FNt,!1,"f"),mf(this,WO,"f").y18n.setLocale(e),this)}middleware(e,n,r){return mf(this,sut,"f").addMiddleware(e,!!n,r)}nargs(e,n){return Nw("<string|object|array> [number]",[e,n],arguments.length),this[sLt](this.nargs.bind(this),"narg",e,n),this}normalize(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("normalize",e),this}number(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("number",e),this[qNt](e),this}option(e,n){if(Nw("<string|object> [object]",[e,n],arguments.length),typeof e=="object")Object.keys(e).forEach(r=>{this.options(r,e[r])});else{typeof n!="object"&&(n={}),this[qNt](e),mf(this,Pxt,"f")&&(e==="version"||n?.alias==="version")&&this[jwr](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
822
822
|
`),void 0,"versionWarning"),mf(this,mN,"f").key[e]=!0,n.alias&&this.alias(e,n.alias);let r=n.deprecate||n.deprecated;r&&this.deprecateOption(e,r);let l=n.demand||n.required||n.require;l&&this.demand(e,l),n.demandOption&&this.demandOption(e,typeof n.demandOption=="string"?n.demandOption:void 0),n.conflicts&&this.conflicts(e,n.conflicts),"default"in n&&this.default(e,n.default),n.implies!==void 0&&this.implies(e,n.implies),n.nargs!==void 0&&this.nargs(e,n.nargs),n.config&&this.config(e,n.configParser),n.normalize&&this.normalize(e),n.choices&&this.choices(e,n.choices),n.coerce&&this.coerce(e,n.coerce),n.group&&this.group(e,n.group),(n.boolean||n.type==="boolean")&&(this.boolean(e),n.alias&&this.boolean(n.alias)),(n.array||n.type==="array")&&(this.array(e),n.alias&&this.array(n.alias)),(n.number||n.type==="number")&&(this.number(e),n.alias&&this.number(n.alias)),(n.string||n.type==="string")&&(this.string(e),n.alias&&this.string(n.alias)),(n.count||n.type==="count")&&this.count(e),typeof n.global=="boolean"&&this.global(e,n.global),n.defaultDescription&&(mf(this,mN,"f").defaultDescription[e]=n.defaultDescription),n.skipValidation&&this.skipValidation(e);let _=n.describe||n.description||n.desc,v=mf(this,NL,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(v,e)||typeof _=="string")&&this.describe(e,_),n.hidden&&this.hide(e),n.requiresArg&&this.requiresArg(e)}return this}options(e,n){return this.option(e,n)}parse(e,n,r){Nw("[string|array] [function|boolean|object] [function]",[e,n,r],arguments.length),this[Wwr](),typeof e>"u"&&(e=mf(this,yDt,"f")),typeof n=="object"&&(Uw(this,BNt,n,"f"),n=r),typeof n=="function"&&(Uw(this,Tnt,n,"f"),n=!1),n||Uw(this,yDt,e,"f"),mf(this,Tnt,"f")&&Uw(this,iut,!1,"f");let l=this[zGt](e,!!n),_=this.parsed;return mf(this,rut,"f").setParsed(this.parsed),Cae(l)?l.then(v=>(mf(this,Tnt,"f")&&mf(this,Tnt,"f").call(this,mf(this,gDt,"f"),v,mf(this,Iwe,"f")),v)).catch(v=>{throw mf(this,Tnt,"f")&&mf(this,Tnt,"f")(v,this.parsed.argv,mf(this,Iwe,"f")),v}).finally(()=>{this[COn](),this.parsed=_}):(mf(this,Tnt,"f")&&mf(this,Tnt,"f").call(this,mf(this,gDt,"f"),l,mf(this,Iwe,"f")),this[COn](),this.parsed=_,l)}parseAsync(e,n,r){let l=this.parse(e,n,r);return Cae(l)?l:Promise.resolve(l)}parseSync(e,n,r){let l=this.parse(e,n,r);if(Cae(l))throw new Fte(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return l}parserConfiguration(e){return Nw("<object>",[e],arguments.length),Uw(this,Ntn,e,"f"),this}pkgConf(e,n){Nw("<string> [string]",[e,n],arguments.length);let r=null,l=this[xOn](n||mf(this,MNt,"f"));return l[e]&&typeof l[e]=="object"&&(r=UGt(l[e],n||mf(this,MNt,"f"),this[VNt]()["deep-merge-config"]||!1,mf(this,WO,"f")),mf(this,mN,"f").configObjects=(mf(this,mN,"f").configObjects||[]).concat(r)),this}positional(e,n){Nw("<string> <object>",[e,n],arguments.length);let r=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];n=mDt(n,(v,D)=>v==="type"&&!["string","number","boolean"].includes(D)?!1:r.includes(v));let l=mf(this,VGt,"f").fullCommands[mf(this,VGt,"f").fullCommands.length-1],_=l?mf(this,_ye,"f").cmdToParseOptions(l):{array:[],alias:{},default:{},demand:{}};return Z7t(_).forEach(v=>{let D=_[v];Array.isArray(D)?D.indexOf(e)!==-1&&(n[v]=!0):D[e]&&!(v in n)&&(n[v]=D[e])}),this.group(e,mf(this,NL,"f").getPositionalGroupName()),this.option(e,n)}recommendCommands(e=!0){return Nw("[boolean]",[e],arguments.length),Uw(this,Otn,e,"f"),this}required(e,n,r){return this.demand(e,n,r)}require(e,n,r){return this.demand(e,n,r)}requiresArg(e){return Nw("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&mf(this,mN,"f").narg[e]?this:(this[sLt](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,n){return Nw("[string] [string]",[e,n],arguments.length),e=e||this.$0,mf(this,rLt,"f").log(mf(this,rut,"f").generateCompletionScript(e,n||mf(this,Snt,"f")||"completion")),this}showHelp(e){if(Nw("[string|function]",[e],arguments.length),Uw(this,Ent,!0,"f"),!mf(this,NL,"f").hasCachedHelpMessage()){if(!this.parsed){let r=this[zGt](mf(this,yDt,"f"),void 0,void 0,0,!0);if(Cae(r))return r.then(()=>{mf(this,NL,"f").showHelp(e)}),this}let n=mf(this,_ye,"f").runDefaultBuilderOn(this);if(Cae(n))return n.then(()=>{mf(this,NL,"f").showHelp(e)}),this}return mf(this,NL,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,n){return Nw("[boolean|string] [string]",[e,n],arguments.length),mf(this,NL,"f").showHelpOnFail(e,n),this}showVersion(e){return Nw("[string|function]",[e],arguments.length),mf(this,NL,"f").showVersion(e),this}skipValidation(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("skipValidation",e),this}strict(e){return Nw("[boolean]",[e],arguments.length),Uw(this,WNt,e!==!1,"f"),this}strictCommands(e){return Nw("[boolean]",[e],arguments.length),Uw(this,GNt,e!==!1,"f"),this}strictOptions(e){return Nw("[boolean]",[e],arguments.length),Uw(this,UNt,e!==!1,"f"),this}string(e){return Nw("<array|string>",[e],arguments.length),this[vDt]("string",e),this[qNt](e),this}terminalWidth(){return Nw([],0),mf(this,WO,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return Nw("<object>",[e],arguments.length),Uw(this,FNt,!1,"f"),mf(this,WO,"f").y18n.updateLocale(e),this}usage(e,n,r,l){if(Nw("<string|null|undefined> [string|boolean] [function|object] [function]",[e,n,r,l],arguments.length),n!==void 0){if(zGe(e,null,mf(this,WO,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,n,r,l);throw new Fte(".usage() description must start with $0 if being used as alias for .command()")}else return mf(this,NL,"f").usage(e),this}usageConfiguration(e){return Nw("<object>",[e],arguments.length),Uw(this,Ltn,e,"f"),this}version(e,n,r){let l="version";if(Nw("[boolean|string] [string] [string]",[e,n,r],arguments.length),mf(this,Pxt,"f")&&(this[yOn](mf(this,Pxt,"f")),mf(this,NL,"f").version(void 0),Uw(this,Pxt,null,"f")),arguments.length===0)r=this[Vwr](),e=l;else if(arguments.length===1){if(e===!1)return this;r=e,e=l}else arguments.length===2&&(r=n,n=void 0);return Uw(this,Pxt,typeof e=="string"?e:l,"f"),n=n||mf(this,NL,"f").deferY18nLookup("Show version number"),mf(this,NL,"f").version(r||void 0),this.boolean(mf(this,Pxt,"f")),this.describe(mf(this,Pxt,"f"),n),this}wrap(e){return Nw("<number|null|undefined>",[e],arguments.length),mf(this,NL,"f").wrap(e),this}[(_ye=new WeakMap,MNt=new WeakMap,VGt=new WeakMap,rut=new WeakMap,Snt=new WeakMap,Dtn=new WeakMap,gDt=new WeakMap,FNt=new WeakMap,ktn=new WeakMap,iut=new WeakMap,wtn=new WeakMap,sut=new WeakMap,Ixt=new WeakMap,Ent=new WeakMap,aut=new WeakMap,Itn=new WeakMap,rLt=new WeakMap,Iwe=new WeakMap,mN=new WeakMap,Ptn=new WeakMap,Ntn=new WeakMap,Tnt=new WeakMap,BNt=new WeakMap,iLt=new WeakMap,jNt=new WeakMap,yDt=new WeakMap,Otn=new WeakMap,WO=new WeakMap,WNt=new WeakMap,GNt=new WeakMap,UNt=new WeakMap,NL=new WeakMap,Ltn=new WeakMap,Pxt=new WeakMap,Sme=new WeakMap,Fwr)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[Bwr](){return{log:(...e)=>{this[Rtn]()||console.log(...e),Uw(this,Ent,!0,"f"),mf(this,Iwe,"f").length&&Uw(this,Iwe,mf(this,Iwe,"f")+`
|
|
823
823
|
`,"f"),Uw(this,Iwe,mf(this,Iwe,"f")+e.join(" "),"f")},error:(...e)=>{this[Rtn]()||console.error(...e),Uw(this,Ent,!0,"f"),mf(this,Iwe,"f").length&&Uw(this,Iwe,mf(this,Iwe,"f")+`
|
|
824
|
-
`,"f"),Uw(this,Iwe,mf(this,Iwe,"f")+e.join(" "),"f")}}}[yOn](e){Z7t(mf(this,mN,"f")).forEach(n=>{if((l=>l==="configObjects")(n))return;let r=mf(this,mN,"f")[n];Array.isArray(r)?r.includes(e)&&r.splice(r.indexOf(e),1):typeof r=="object"&&delete r[e]}),delete mf(this,NL,"f").getDescriptions()[e]}[jwr](e,n,r){mf(this,ktn,"f")[r]||(mf(this,WO,"f").process.emitWarning(e,n),mf(this,ktn,"f")[r]=!0)}[Wwr](){mf(this,wtn,"f").push({options:mf(this,mN,"f"),configObjects:mf(this,mN,"f").configObjects.slice(0),exitProcess:mf(this,iut,"f"),groups:mf(this,Ixt,"f"),strict:mf(this,WNt,"f"),strictCommands:mf(this,GNt,"f"),strictOptions:mf(this,UNt,"f"),completionCommand:mf(this,Snt,"f"),output:mf(this,Iwe,"f"),exitError:mf(this,gDt,"f"),hasOutput:mf(this,Ent,"f"),parsed:this.parsed,parseFn:mf(this,Tnt,"f"),parseContext:mf(this,BNt,"f")}),mf(this,NL,"f").freeze(),mf(this,Sme,"f").freeze(),mf(this,_ye,"f").freeze(),mf(this,sut,"f").freeze()}[Gwr](){let e="",n;return/\b(node|iojs|electron)(\.exe)?$/.test(mf(this,WO,"f").process.argv()[0])?n=mf(this,WO,"f").process.argv().slice(1,2):n=mf(this,WO,"f").process.argv().slice(0,1),e=n.map(r=>{let l=this[eIr](mf(this,MNt,"f"),r);return r.match(/^(\/|([a-zA-Z]:)?\\)/)&&l.length<r.length?l:r}).join(" ").trim(),mf(this,WO,"f").getEnv("_")&&mf(this,WO,"f").getProcessArgvBin()===mf(this,WO,"f").getEnv("_")&&(e=mf(this,WO,"f").getEnv("_").replace(`${mf(this,WO,"f").path.dirname(mf(this,WO,"f").process.execPath())}/`,"")),e}[VNt](){return mf(this,Ntn,"f")}[Uwr](){return mf(this,Ltn,"f")}[vOn](){if(!mf(this,FNt,"f"))return;let e=mf(this,WO,"f").getEnv("LC_ALL")||mf(this,WO,"f").getEnv("LC_MESSAGES")||mf(this,WO,"f").getEnv("LANG")||mf(this,WO,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Vwr](){return this[xOn]().version||"unknown"}[zwr](e){let n=e["--"]?e["--"]:e._;for(let r=0,l;(l=n[r])!==void 0;r++)mf(this,WO,"f").Parser.looksLikeNumber(l)&&Number.isSafeInteger(Math.floor(parseFloat(`${l}`)))&&(n[r]=Number(l));return e}[xOn](e){let n=e||"*";if(mf(this,iLt,"f")[n])return mf(this,iLt,"f")[n];let r={};try{let l=e||mf(this,WO,"f").mainFilename;!e&&mf(this,WO,"f").path.extname(l)&&(l=mf(this,WO,"f").path.dirname(l));let _=mf(this,WO,"f").findUp(l,(v,D)=>{if(D.includes("package.json"))return"package.json"});zGe(_,void 0,mf(this,WO,"f")),r=JSON.parse(mf(this,WO,"f").readFileSync(_,"utf8"))}catch{}return mf(this,iLt,"f")[n]=r||{},mf(this,iLt,"f")[n]}[vDt](e,n){n=[].concat(n),n.forEach(r=>{r=this[EOn](r),mf(this,mN,"f")[e].push(r)})}[sLt](e,n,r,l){this[SOn](e,n,r,l,(_,v,D)=>{mf(this,mN,"f")[_][v]=D})}[bOn](e,n,r,l){this[SOn](e,n,r,l,(_,v,D)=>{mf(this,mN,"f")[_][v]=(mf(this,mN,"f")[_][v]||[]).concat(D)})}[SOn](e,n,r,l,_){if(Array.isArray(r))r.forEach(v=>{e(v,l)});else if((v=>typeof v=="object")(r))for(let v of Z7t(r))e(v,r[v]);else _(n,this[EOn](r),l)}[EOn](e){return e==="__proto__"?"___proto___":e}[TOn](e,n){return this[sLt](this[TOn].bind(this),"key",e,n),this}[COn](){var e,n,r,l,_,v,D,N,L,G,te,ce;let _e=mf(this,wtn,"f").pop();zGe(_e,void 0,mf(this,WO,"f"));let Ie;e=this,n=this,r=this,l=this,_=this,v=this,D=this,N=this,L=this,G=this,te=this,ce=this,{options:{set value(Se){Uw(e,mN,Se,"f")}}.value,configObjects:Ie,exitProcess:{set value(Se){Uw(n,iut,Se,"f")}}.value,groups:{set value(Se){Uw(r,Ixt,Se,"f")}}.value,output:{set value(Se){Uw(l,Iwe,Se,"f")}}.value,exitError:{set value(Se){Uw(_,gDt,Se,"f")}}.value,hasOutput:{set value(Se){Uw(v,Ent,Se,"f")}}.value,parsed:this.parsed,strict:{set value(Se){Uw(D,WNt,Se,"f")}}.value,strictCommands:{set value(Se){Uw(N,GNt,Se,"f")}}.value,strictOptions:{set value(Se){Uw(L,UNt,Se,"f")}}.value,completionCommand:{set value(Se){Uw(G,Snt,Se,"f")}}.value,parseFn:{set value(Se){Uw(te,Tnt,Se,"f")}}.value,parseContext:{set value(Se){Uw(ce,BNt,Se,"f")}}.value}=_e,mf(this,mN,"f").configObjects=Ie,mf(this,NL,"f").unfreeze(),mf(this,Sme,"f").unfreeze(),mf(this,_ye,"f").unfreeze(),mf(this,sut,"f").unfreeze()}[qwr](e,n){return RNt(n,r=>(e(r),r))}getInternalMethods(){return{getCommandInstance:this[Hwr].bind(this),getContext:this[Jwr].bind(this),getHasOutput:this[Kwr].bind(this),getLoggerInstance:this[$wr].bind(this),getParseContext:this[Xwr].bind(this),getParserConfiguration:this[VNt].bind(this),getUsageConfiguration:this[Uwr].bind(this),getUsageInstance:this[Ywr].bind(this),getValidationInstance:this[Qwr].bind(this),hasParseCallback:this[Rtn].bind(this),isGlobalContext:this[Zwr].bind(this),postProcess:this[zNt].bind(this),reset:this[AOn].bind(this),runValidation:this[DOn].bind(this),runYargsParserAndExecuteCommands:this[zGt].bind(this),setHasOutput:this[tIr].bind(this)}}[Hwr](){return mf(this,_ye,"f")}[Jwr](){return mf(this,VGt,"f")}[Kwr](){return mf(this,Ent,"f")}[$wr](){return mf(this,rLt,"f")}[Xwr](){return mf(this,BNt,"f")||{}}[Ywr](){return mf(this,NL,"f")}[Qwr](){return mf(this,Sme,"f")}[Rtn](){return!!mf(this,Tnt,"f")}[Zwr](){return mf(this,Itn,"f")}[zNt](e,n,r,l){return r||Cae(e)||(n||(e=this[Fwr](e)),(this[VNt]()["parse-positional-numbers"]||this[VNt]()["parse-positional-numbers"]===void 0)&&(e=this[zwr](e)),l&&(e=LNt(e,this,mf(this,sut,"f").getMiddleware(),!1))),e}[AOn](e={}){Uw(this,mN,mf(this,mN,"f")||{},"f");let n={};n.local=mf(this,mN,"f").local||[],n.configObjects=mf(this,mN,"f").configObjects||[];let r={};n.local.forEach(v=>{r[v]=!0,(e[v]||[]).forEach(D=>{r[D]=!0})}),Object.assign(mf(this,jNt,"f"),Object.keys(mf(this,Ixt,"f")).reduce((v,D)=>{let N=mf(this,Ixt,"f")[D].filter(L=>!(L in r));return N.length>0&&(v[D]=N),v},{})),Uw(this,Ixt,{},"f");let l=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],_=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return l.forEach(v=>{n[v]=(mf(this,mN,"f")[v]||[]).filter(D=>!r[D])}),_.forEach(v=>{n[v]=mDt(mf(this,mN,"f")[v],D=>!r[D])}),n.envPrefix=mf(this,mN,"f").envPrefix,Uw(this,mN,n,"f"),Uw(this,NL,mf(this,NL,"f")?mf(this,NL,"f").reset(r):Twr(this,mf(this,WO,"f")),"f"),Uw(this,Sme,mf(this,Sme,"f")?mf(this,Sme,"f").reset(r):Lwr(this,mf(this,NL,"f"),mf(this,WO,"f")),"f"),Uw(this,_ye,mf(this,_ye,"f")?mf(this,_ye,"f").reset():bwr(mf(this,NL,"f"),mf(this,Sme,"f"),mf(this,sut,"f"),mf(this,WO,"f")),"f"),mf(this,rut,"f")||Uw(this,rut,wwr(this,mf(this,NL,"f"),mf(this,_ye,"f"),mf(this,WO,"f")),"f"),mf(this,sut,"f").reset(),Uw(this,Snt,null,"f"),Uw(this,Iwe,"","f"),Uw(this,gDt,null,"f"),Uw(this,Ent,!1,"f"),this.parsed=!1,this}[eIr](e,n){return mf(this,WO,"f").path.relative(e,n)}[zGt](e,n,r,l=0,_=!1){let v=!!r||_;e=e||mf(this,yDt,"f"),mf(this,mN,"f").__=mf(this,WO,"f").y18n.__,mf(this,mN,"f").configuration=this[VNt]();let D=!!mf(this,mN,"f").configuration["populate--"],N=Object.assign({},mf(this,mN,"f").configuration,{"populate--":!0}),L=mf(this,WO,"f").Parser.detailed(e,Object.assign({},mf(this,mN,"f"),{configuration:{"parse-positional-numbers":!1,...N}})),G=Object.assign(L.argv,mf(this,BNt,"f")),te,ce=L.aliases,_e=!1,Ie=!1;Object.keys(G).forEach(Se=>{Se===mf(this,aut,"f")&&G[Se]?_e=!0:Se===mf(this,Pxt,"f")&&G[Se]&&(Ie=!0)}),G.$0=this.$0,this.parsed=L,l===0&&mf(this,NL,"f").clearCachedHelpMessage();try{if(this[vOn](),n)return this[zNt](G,D,!!r,!1);mf(this,aut,"f")&&[mf(this,aut,"f")].concat(ce[mf(this,aut,"f")]||[]).filter(Tn=>Tn.length>1).includes(""+G._[G._.length-1])&&(G._.pop(),_e=!0),Uw(this,Itn,!1,"f");let Se=mf(this,_ye,"f").getCommands(),Ue=mf(this,rut,"f").completionKey in G,Ke=_e||Ue||_;if(G._.length){if(Se.length){let ft;for(let Tn=l||0,It;G._[Tn]!==void 0;Tn++)if(It=String(G._[Tn]),Se.includes(It)&&It!==mf(this,Snt,"f")){let Xn=mf(this,_ye,"f").runCommand(It,this,L,Tn+1,_,_e||Ie||_);return this[zNt](Xn,D,!!r,!1)}else if(!ft&&It!==mf(this,Snt,"f")){ft=It;break}!mf(this,_ye,"f").hasDefaultCommand()&&mf(this,Otn,"f")&&ft&&!Ke&&mf(this,Sme,"f").recommendCommands(ft,Se)}mf(this,Snt,"f")&&G._.includes(mf(this,Snt,"f"))&&!Ue&&(mf(this,iut,"f")&&hDt(!0),this.showCompletionScript(),this.exit(0))}if(mf(this,_ye,"f").hasDefaultCommand()&&!Ke){let ft=mf(this,_ye,"f").runCommand(null,this,L,0,_,_e||Ie||_);return this[zNt](ft,D,!!r,!1)}if(Ue){mf(this,iut,"f")&&hDt(!0),e=[].concat(e);let ft=e.slice(e.indexOf(`--${mf(this,rut,"f").completionKey}`)+1);return mf(this,rut,"f").getCompletion(ft,(Tn,It)=>{if(Tn)throw new Fte(Tn.message);(It||[]).forEach(Xn=>{mf(this,rLt,"f").log(Xn)}),this.exit(0)}),this[zNt](G,!D,!!r,!1)}if(mf(this,Ent,"f")||(_e?(mf(this,iut,"f")&&hDt(!0),v=!0,this.showHelp("log"),this.exit(0)):Ie&&(mf(this,iut,"f")&&hDt(!0),v=!0,mf(this,NL,"f").showVersion("log"),this.exit(0))),!v&&mf(this,mN,"f").skipValidation.length>0&&(v=Object.keys(G).some(ft=>mf(this,mN,"f").skipValidation.indexOf(ft)>=0&&G[ft]===!0)),!v){if(L.error)throw new Fte(L.error.message);if(!Ue){let ft=this[DOn](ce,{},L.error);r||(te=LNt(G,this,mf(this,sut,"f").getMiddleware(),!0)),te=this[qwr](ft,te??G),Cae(te)&&!r&&(te=te.then(()=>LNt(G,this,mf(this,sut,"f").getMiddleware(),!1)))}}}catch(Se){if(Se instanceof Fte)mf(this,NL,"f").fail(Se.message,Se);else throw Se}return this[zNt](te??G,D,!!r,!0)}[DOn](e,n,r,l){let _={...this.getDemandedOptions()};return v=>{if(r)throw new Fte(r.message);mf(this,Sme,"f").nonOptionCount(v),mf(this,Sme,"f").requiredArguments(v,_);let D=!1;mf(this,GNt,"f")&&(D=mf(this,Sme,"f").unknownCommands(v)),mf(this,WNt,"f")&&!D?mf(this,Sme,"f").unknownArguments(v,e,n,!!l):mf(this,UNt,"f")&&mf(this,Sme,"f").unknownArguments(v,e,{},!1,!1),mf(this,Sme,"f").limitedChoices(v),mf(this,Sme,"f").implications(v),mf(this,Sme,"f").conflicting(v)}}[tIr](){Uw(this,Ent,!0,"f")}[qNt](e){if(typeof e=="string")mf(this,mN,"f").key[e]=!0;else for(let n of e)mf(this,mN,"f").key[n]=!0}}});var mis,rIr,iIr=Ma(()=>{"use strict";sOn();pOn();mis=nIr(iOn),rIr=mis});var sIr=Ma(()=>{gOn();nOn();eOn();sOn()});var Mtn,aIr=Ma(()=>{Mtn="0.11.0"});var aLt,oIr,cIr,lIr,uIr,fIr,pIr,dIr,_Ir,mIr,aEt=Ma(()=>{"use strict";dDt();aLt="X-Codemod-Access-Token".toLocaleLowerCase(),oIr=async t=>(await S4e.post("https://backend.codemod.com/validateAccessToken",{},{headers:{[aLt]:t},timeout:5e3})).data,cIr=async(t,e)=>{await S4e.post("https://backend.codemod.com/publish",e,{headers:{[aLt]:t,"Content-Type":"multipart/form-data"},timeout:1e4})},lIr=async(t,e)=>{await S4e.post("https://backend.codemod.com/unpublish",{name:e},{headers:{[aLt]:t},timeout:1e4})},uIr=async t=>{await S4e.delete("https://backend.codemod.com/revokeToken",{headers:{[aLt]:t},timeout:1e4})},fIr=async(t,e)=>{let n=new URL("https://backend.codemod.com/codemods/downloadLink");t&&n.searchParams.set("name",t);let r={};return e&&(r[aLt]=e),(await S4e.get(n.toString(),{headers:r,timeout:1e4})).data},pIr=async t=>{let{accessToken:e,search:n}=t??{},r={};e&&(r[aLt]=e);let l=new URL("https://backend.codemod.com/codemods/list");return n&&l.searchParams.set("search",n),(await S4e.get(l.toString(),{headers:r,timeout:1e4})).data},dIr=async()=>(await S4e.post("https://backend.codemod.com/intents",{})).data,_Ir=async(t,e)=>(await S4e.get(`https://backend.codemod.com/intents/${t}?iv=${e}`)).data.token,mIr=async t=>(await S4e.post("https://backend.codemod.com/diffs",{before:t.beforeSnippet,after:t.afterSnippet,source:"cli"})).data});var hIr,gIr,yIr,vIr,wOn,Ftn,BMe,xIr,Btn,jtn,out=Ma(()=>{"use strict";hIr=require("node:child_process"),gIr=require("node:os"),yIr=require("node:path");Ble();vIr=Dx(r0t(),1),wOn=Dx(require("keytar"),1);aEt();Ftn=t=>{let e=process.platform==="win32"?"start":"open",n=[t];try{return(0,hIr.spawnSync)(e,n,{stdio:"ignore",shell:!1}),!0}catch(r){return console.error("Error while opening URL:",r),!1}},BMe=async()=>{let[t]=await wOn.default.findCredentials("codemod.com");if(!JKe(t))return null;let{account:e,password:n}=t,r;try{r=await oIr(n)}catch{return await wOn.default.deletePassword("codemod.com",e),null}return{user:r,token:n}},xIr=(t,e="slug")=>{let n;switch(e){case"slug":n=r=>r.slug;break;case"name":n=r=>r.name;break;case"slug-and-name":n=r=>r.name===r.slug?r.name:`${r.name} (${r.slug})`;break;default:throw new Error("Invalid type")}return t.user.organizations.map(n).filter(JKe)},Btn=t=>(0,yIr.join)(String(t)==="runOnPreCommit"?process.cwd():(0,gIr.homedir)(),".codemod"),jtn=async t=>{let{globPattern:e,source:n,errorText:r,onSuccess:l,onFail:_}=t,v=async()=>(await(0,vIr.glob)(e,{absolute:!0,ignore:["**/node_modules/**"],cwd:n,onlyFiles:!0})).at(0),D=await v();try{if(await yae("codemod build",{cwd:n}),D=await v(),D===void 0)throw new Error;l?.()}catch{throw _?.(),new Error(r)}return D}});var bIr,oLt,IOn,gis,yis,SIr,EIr=Ma(()=>{"use strict";bIr=require("node:crypto"),oLt=require("node:fs/promises"),IOn=require("node:path");out();gis=async t=>{try{let e=await(0,oLt.readFile)((0,IOn.join)(t,"session.json"),"utf-8");return JSON.parse(e).id}catch{return null}},yis=async t=>{await(0,oLt.mkdir)(t,{recursive:!0});let e=(0,bIr.randomBytes)(16).toString("hex");return await(0,oLt.writeFile)((0,IOn.join)(t,"session.json"),JSON.stringify({id:e})),e},SIr=async()=>{let t=Btn(),e=await BMe();if(e!==null)return e.user.userId;let n=await gis(t);return n!==null?n:await yis(t)}});var NOn,Nxt,cLt,TIr,vis,CIr,POn,AIr,lLt,DIr,uLt,fLt,kIr,pLt,qGt=Ma(()=>{"use strict";NOn=require("node:crypto"),Nxt=require("node:path");Ble();cLt=function(t,e,n,r){function l(_){return _ instanceof n?_:new n(function(v){v(_)})}return new(n||(n=Promise))(function(_,v){function D(G){try{L(r.next(G))}catch(te){v(te)}}function N(G){try{L(r.throw(G))}catch(te){v(te)}}function L(G){G.done?_(G.value):l(G.value).then(D,N)}L((r=r.apply(t,e||[])).next())})},TIr={tabWidth:4,useTabs:!0,semi:!0,singleQuote:!0,quoteProps:"as-needed",trailingComma:"all",bracketSpacing:!0,arrowParens:"always",endOfLine:"lf",parser:"typescript"},vis=new Map([["ts","typescript"],["tsx","typescript"],["js","babel"],["jsx","babel"],["json","json"],["json5","json5"],["jsonc","json"],["css","css"],["scss","scss"],["less","less"],["graphql","graphql"],["md","markdown"],["mdx","mdx"],["html","html"],["vue","vue"],["yaml","yaml"],["yml","yaml"]]),CIr=t=>cLt(void 0,void 0,void 0,function*(){var e;let{resolveConfig:n}=yield import("prettier"),r=yield n(t,{editorconfig:!1});(r===null||Object.keys(r).length===0)&&(r=TIr);let l=(e=vis.get((0,Nxt.extname)(t).slice(1)))!==null&&e!==void 0?e:"typescript";return Object.assign(Object.assign({},r),{parser:l})}),POn=(t,e,n)=>cLt(void 0,void 0,void 0,function*(){let r=e.replace(/\/\*\* \*\*\//gm,"");if(!n)return r;try{let{format:l}=yield import("prettier"),_=yield CIr(t);return yield l(r,_)}catch{return r}}),AIr=t=>cLt(void 0,void 0,void 0,function*(){if(t.kind==="createFile"){let e=yield POn(t.newPath,t.newData,t.formatWithPrettier);return Object.assign(Object.assign({},t),{newData:e,formatted:!0})}if(t.kind==="updateFile"){let e=yield POn(t.oldPath,t.newData,t.formatWithPrettier);return t.oldData===e?null:Object.assign(Object.assign({},t),{newData:e,formatted:!0})}return Object.assign(Object.assign({},t),{formatted:!0})}),lLt=t=>cLt(void 0,void 0,void 0,function*(){return(yield Promise.all(t.map(n=>AIr(n)))).filter(JKe)}),DIr=(t,e)=>cLt(void 0,void 0,void 0,function*(){if(e.kind==="createFile"){let n=(0,Nxt.dirname)(e.newPath);return yield t.promises.mkdir(n,{recursive:!0}),t.promises.writeFile(e.newPath,e.newData)}if(e.kind==="deleteFile")return t.promises.unlink(e.oldPath);if(e.kind==="moveFile")return yield t.promises.copyFile(e.oldPath,e.newPath),t.promises.unlink(e.oldPath);if(e.kind==="updateFile")return t.promises.writeFile(e.oldPath,e.newData);if(e.kind==="copyFile"){let n=(0,Nxt.dirname)(e.newPath);return yield t.promises.mkdir(n,{recursive:!0}),t.promises.copyFile(e.oldPath,e.newPath)}}),uLt=(t,e)=>{let n=(0,NOn.createHash)("md5").update(e.kind).update(e.newPath).update(e.newData).digest("base64url"),r=(0,Nxt.extname)(e.newPath);return(0,Nxt.join)(t,`${n}${r}`)},fLt=(t,e)=>{let n=(0,NOn.createHash)("md5").update(e.kind).update(e.oldPath).update(e.newData).digest("base64url"),r=(0,Nxt.extname)(e.oldPath);return(0,Nxt.join)(t,`${n}${r}`)},kIr=(t,e,n)=>cLt(void 0,void 0,void 0,function*(){if(n.kind==="createFile"){let r=uLt(e,n);yield t.promises.writeFile(r,n.newData)}if(n.kind==="updateFile"){let r=fLt(e,n);yield t.promises.writeFile(r,n.newData)}}),pLt=(t,e,n)=>e.dryRun===!0?kIr(t,e.outputDirectoryPath,n):DIr(t,n)});var wIr=Ma(()=>{"use strict"});var IIr,xis,bis,PIr,NIr=Ma(()=>{"use strict";IIr=require("node:fs");MGe();xis=MY([pk("jscodeshift"),pk("filemod"),pk("ts-morph"),pk("ast-grep"),pk("workflow")]),bis=oR({_:gme(vD()),source:jO(vD()),engine:jO(xis)}),PIr=t=>{var e,n;let r=Mle(bis,t);if(r._.includes("runOnPreCommit"))return{kind:"runOnPreCommit"};let l=r._.at(0);if(!l)throw new Error("Codemod to run was not specified!");return(0,IIr.existsSync)(l)||r.source?{kind:"runSourced",source:(e=r.source)!==null&&e!==void 0?e:l,engine:(n=r.engine)!==null&&n!==void 0?n:null}:{kind:"runNamed",name:l}}});var OIr,HGt,Sis,OOn,LOn,ROn,MOn,FOn,LIr,RIr,Eis,MIr,BOn=Ma(()=>{"use strict";OIr=require("node:path");ITe();MGe();HGt=["**/node_modules/**/*.*","**/*.d.ts","**/.next/**/*.*","**/dist/**/*.*","**/build/**/*.*"],Sis=process.cwd(),OOn=!0,LOn=!0,ROn=!0,MOn=!1,FOn=4,LIr=!1,RIr=!0,Eis=oR({_:gme(vD()),include:jO(gme(vD())),exclude:jO(gme(vD())),target:jO(vD()),files:jO(gme(vD())),format:jO(h4e(),OOn),cache:jO(h4e(),LOn),install:jO(h4e(),ROn),json:jO(h4e(),MOn),threads:jO(J8t([bcr(0)]),FOn)}),MIr=(t,e)=>{var n,r;let l=Mle(Eis,t),_=l._.at(1),v=l.target,D;return _&&v?(e.printConsoleMessage("info",bm.yellow("Both positional and argument target options are passed. Defaulting to the argument target option...")),D=v):D=(n=_??v)!==null&&n!==void 0?n:Sis,Object.assign(Object.assign({},l),{target:(0,OIr.resolve)(D),exclude:((r=l.exclude)!==null&&r!==void 0?r:[]).concat(HGt)})}});var FIr,BIr,Tis,jIr,WIr=Ma(()=>{"use strict";FIr=require("node:crypto"),BIr=require("node:path");MGe();Tis=MY([oR({dry:jO(pk(!1),!1)}),oR({dry:pk(!0),output:jO(vD())})]),jIr=(t,e)=>{let n=(0,FIr.randomBytes)(20);return Mle(Tis,e).dry===!1?{dryRun:!1,caseHashDigest:n}:{dryRun:!0,streamingEnabled:!0,outputDirectoryPath:(0,BIr.join)(t,".codemod","cases",n.toString("base64url")),caseHashDigest:n}}});var UIr=nn((v0o,GIr)=>{var Cis=Object.prototype.toString,jOn=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function Ais(t){return Cis.call(t).slice(8,-1)==="ArrayBuffer"}function Dis(t,e,n){e>>>=0;var r=t.byteLength-e;if(r<0)throw new RangeError("'offset' is out of bounds");if(n===void 0)n=r;else if(n>>>=0,n>r)throw new RangeError("'length' is out of bounds");return jOn?Buffer.from(t.slice(e,e+n)):new Buffer(new Uint8Array(t.slice(e,e+n)))}function kis(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');return jOn?Buffer.from(t,e):new Buffer(t,e)}function wis(t,e,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return Ais(t)?Dis(t,e,n):typeof t=="string"?kis(t,e):jOn?Buffer.from(t):new Buffer(t)}GIr.exports=wis});var $Gt=nn((JNt,VOn)=>{var Iis=FYt().SourceMapConsumer,WOn=require("path"),Oxt;try{Oxt=require("fs"),(!Oxt.existsSync||!Oxt.readFileSync)&&(Oxt=null)}catch{}var Pis=UIr();function VIr(t,e){return t.require(e)}var zIr=!1,qIr=!1,GOn=!1,JGt="auto",HNt={},KGt={},Nis=/^data:application\/json[^,]+base64,/,xDt=[],bDt=[];function zOn(){return JGt==="browser"?!0:JGt==="node"?!1:typeof window<"u"&&typeof XMLHttpRequest=="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function Ois(){return typeof process=="object"&&process!==null&&typeof process.on=="function"}function Lis(){return typeof process=="object"&&process!==null?process.version:""}function Ris(){if(typeof process=="object"&&process!==null)return process.stderr}function Mis(t){if(typeof process=="object"&&process!==null&&typeof process.exit=="function")return process.exit(t)}function Wtn(t){return function(e){for(var n=0;n<t.length;n++){var r=t[n](e);if(r)return r}return null}}var qOn=Wtn(xDt);xDt.push(function(t){if(t=t.trim(),/^file:/.test(t)&&(t=t.replace(/file:\/\/\/(\w:)?/,function(r,l){return l?"":"/"})),t in HNt)return HNt[t];var e="";try{if(Oxt)Oxt.existsSync(t)&&(e=Oxt.readFileSync(t,"utf8"));else{var n=new XMLHttpRequest;n.open("GET",t,!1),n.send(null),n.readyState===4&&n.status===200&&(e=n.responseText)}}catch{}return HNt[t]=e});function UOn(t,e){if(!t)return e;var n=WOn.dirname(t),r=/^\w+:\/\/[^\/]*/.exec(n),l=r?r[0]:"",_=n.slice(l.length);return l&&/^\/\w\:/.test(_)?(l+="/",l+WOn.resolve(n.slice(l.length),e).replace(/\\/g,"/")):l+WOn.resolve(n.slice(l.length),e)}function Fis(t){var e;if(zOn())try{var n=new XMLHttpRequest;n.open("GET",t,!1),n.send(null),e=n.readyState===4?n.responseText:null;var r=n.getResponseHeader("SourceMap")||n.getResponseHeader("X-SourceMap");if(r)return r}catch{}e=qOn(t);for(var l=/(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg,_,v;v=l.exec(e);)_=v;return _?_[1]:null}var HOn=Wtn(bDt);bDt.push(function(t){var e=Fis(t);if(!e)return null;var n;if(Nis.test(e)){var r=e.slice(e.indexOf(",")+1);n=Pis(r,"base64").toString(),e=t}else e=UOn(t,e),n=qOn(e);return n?{url:e,map:n}:null});function JOn(t){var e=KGt[t.source];if(!e){var n=HOn(t.source);n?(e=KGt[t.source]={url:n.url,map:new Iis(n.map)},e.map.sourcesContent&&e.map.sources.forEach(function(l,_){var v=e.map.sourcesContent[_];if(v){var D=UOn(e.url,l);HNt[D]=v}})):e=KGt[t.source]={url:null,map:null}}if(e&&e.map&&typeof e.map.originalPositionFor=="function"){var r=e.map.originalPositionFor(t);if(r.source!==null)return r.source=UOn(e.url,r.source),r}return t}function JIr(t){var e=/^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(t);if(e){var n=JOn({source:e[2],line:+e[3],column:e[4]-1});return"eval at "+e[1]+" ("+n.source+":"+n.line+":"+(n.column+1)+")"}return e=/^eval at ([^(]+) \((.+)\)$/.exec(t),e?"eval at "+e[1]+" ("+JIr(e[2])+")":t}function Bis(){var t,e="";if(this.isNative())e="native";else{t=this.getScriptNameOrSourceURL(),!t&&this.isEval()&&(e=this.getEvalOrigin(),e+=", "),t?e+=t:e+="<anonymous>";var n=this.getLineNumber();if(n!=null){e+=":"+n;var r=this.getColumnNumber();r&&(e+=":"+r)}}var l="",_=this.getFunctionName(),v=!0,D=this.isConstructor(),N=!(this.isToplevel()||D);if(N){var L=this.getTypeName();L==="[object Object]"&&(L="null");var G=this.getMethodName();_?(L&&_.indexOf(L)!=0&&(l+=L+"."),l+=_,G&&_.indexOf("."+G)!=_.length-G.length-1&&(l+=" [as "+G+"]")):l+=L+"."+(G||"<anonymous>")}else D?l+="new "+(_||"<anonymous>"):_?l+=_:(l+=e,v=!1);return v&&(l+=" ("+e+")"),l}function HIr(t){var e={};return Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(function(n){e[n]=/^(?:is|get)/.test(n)?function(){return t[n].call(t)}:t[n]}),e.toString=Bis,e}function KIr(t,e){if(e===void 0&&(e={nextPosition:null,curPosition:null}),t.isNative())return e.curPosition=null,t;var n=t.getFileName()||t.getScriptNameOrSourceURL();if(n){var r=t.getLineNumber(),l=t.getColumnNumber()-1,_=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/,v=_.test(Lis())?0:62;r===1&&l>v&&!zOn()&&!t.isEval()&&(l-=v);var D=JOn({source:n,line:r,column:l});e.curPosition=D,t=HIr(t);var N=t.getFunctionName;return t.getFunctionName=function(){return e.nextPosition==null?N():e.nextPosition.name||N()},t.getFileName=function(){return D.source},t.getLineNumber=function(){return D.line},t.getColumnNumber=function(){return D.column+1},t.getScriptNameOrSourceURL=function(){return D.source},t}var L=t.isEval()&&t.getEvalOrigin();return L&&(L=JIr(L),t=HIr(t),t.getEvalOrigin=function(){return L}),t}function jis(t,e){GOn&&(HNt={},KGt={});for(var n=t.name||"Error",r=t.message||"",l=n+": "+r,_={nextPosition:null,curPosition:null},v=[],D=e.length-1;D>=0;D--)v.push(`
|
|
824
|
+
`,"f"),Uw(this,Iwe,mf(this,Iwe,"f")+e.join(" "),"f")}}}[yOn](e){Z7t(mf(this,mN,"f")).forEach(n=>{if((l=>l==="configObjects")(n))return;let r=mf(this,mN,"f")[n];Array.isArray(r)?r.includes(e)&&r.splice(r.indexOf(e),1):typeof r=="object"&&delete r[e]}),delete mf(this,NL,"f").getDescriptions()[e]}[jwr](e,n,r){mf(this,ktn,"f")[r]||(mf(this,WO,"f").process.emitWarning(e,n),mf(this,ktn,"f")[r]=!0)}[Wwr](){mf(this,wtn,"f").push({options:mf(this,mN,"f"),configObjects:mf(this,mN,"f").configObjects.slice(0),exitProcess:mf(this,iut,"f"),groups:mf(this,Ixt,"f"),strict:mf(this,WNt,"f"),strictCommands:mf(this,GNt,"f"),strictOptions:mf(this,UNt,"f"),completionCommand:mf(this,Snt,"f"),output:mf(this,Iwe,"f"),exitError:mf(this,gDt,"f"),hasOutput:mf(this,Ent,"f"),parsed:this.parsed,parseFn:mf(this,Tnt,"f"),parseContext:mf(this,BNt,"f")}),mf(this,NL,"f").freeze(),mf(this,Sme,"f").freeze(),mf(this,_ye,"f").freeze(),mf(this,sut,"f").freeze()}[Gwr](){let e="",n;return/\b(node|iojs|electron)(\.exe)?$/.test(mf(this,WO,"f").process.argv()[0])?n=mf(this,WO,"f").process.argv().slice(1,2):n=mf(this,WO,"f").process.argv().slice(0,1),e=n.map(r=>{let l=this[eIr](mf(this,MNt,"f"),r);return r.match(/^(\/|([a-zA-Z]:)?\\)/)&&l.length<r.length?l:r}).join(" ").trim(),mf(this,WO,"f").getEnv("_")&&mf(this,WO,"f").getProcessArgvBin()===mf(this,WO,"f").getEnv("_")&&(e=mf(this,WO,"f").getEnv("_").replace(`${mf(this,WO,"f").path.dirname(mf(this,WO,"f").process.execPath())}/`,"")),e}[VNt](){return mf(this,Ntn,"f")}[Uwr](){return mf(this,Ltn,"f")}[vOn](){if(!mf(this,FNt,"f"))return;let e=mf(this,WO,"f").getEnv("LC_ALL")||mf(this,WO,"f").getEnv("LC_MESSAGES")||mf(this,WO,"f").getEnv("LANG")||mf(this,WO,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Vwr](){return this[xOn]().version||"unknown"}[zwr](e){let n=e["--"]?e["--"]:e._;for(let r=0,l;(l=n[r])!==void 0;r++)mf(this,WO,"f").Parser.looksLikeNumber(l)&&Number.isSafeInteger(Math.floor(parseFloat(`${l}`)))&&(n[r]=Number(l));return e}[xOn](e){let n=e||"*";if(mf(this,iLt,"f")[n])return mf(this,iLt,"f")[n];let r={};try{let l=e||mf(this,WO,"f").mainFilename;!e&&mf(this,WO,"f").path.extname(l)&&(l=mf(this,WO,"f").path.dirname(l));let _=mf(this,WO,"f").findUp(l,(v,D)=>{if(D.includes("package.json"))return"package.json"});zGe(_,void 0,mf(this,WO,"f")),r=JSON.parse(mf(this,WO,"f").readFileSync(_,"utf8"))}catch{}return mf(this,iLt,"f")[n]=r||{},mf(this,iLt,"f")[n]}[vDt](e,n){n=[].concat(n),n.forEach(r=>{r=this[EOn](r),mf(this,mN,"f")[e].push(r)})}[sLt](e,n,r,l){this[SOn](e,n,r,l,(_,v,D)=>{mf(this,mN,"f")[_][v]=D})}[bOn](e,n,r,l){this[SOn](e,n,r,l,(_,v,D)=>{mf(this,mN,"f")[_][v]=(mf(this,mN,"f")[_][v]||[]).concat(D)})}[SOn](e,n,r,l,_){if(Array.isArray(r))r.forEach(v=>{e(v,l)});else if((v=>typeof v=="object")(r))for(let v of Z7t(r))e(v,r[v]);else _(n,this[EOn](r),l)}[EOn](e){return e==="__proto__"?"___proto___":e}[TOn](e,n){return this[sLt](this[TOn].bind(this),"key",e,n),this}[COn](){var e,n,r,l,_,v,D,N,L,G,te,ce;let _e=mf(this,wtn,"f").pop();zGe(_e,void 0,mf(this,WO,"f"));let Ie;e=this,n=this,r=this,l=this,_=this,v=this,D=this,N=this,L=this,G=this,te=this,ce=this,{options:{set value(Se){Uw(e,mN,Se,"f")}}.value,configObjects:Ie,exitProcess:{set value(Se){Uw(n,iut,Se,"f")}}.value,groups:{set value(Se){Uw(r,Ixt,Se,"f")}}.value,output:{set value(Se){Uw(l,Iwe,Se,"f")}}.value,exitError:{set value(Se){Uw(_,gDt,Se,"f")}}.value,hasOutput:{set value(Se){Uw(v,Ent,Se,"f")}}.value,parsed:this.parsed,strict:{set value(Se){Uw(D,WNt,Se,"f")}}.value,strictCommands:{set value(Se){Uw(N,GNt,Se,"f")}}.value,strictOptions:{set value(Se){Uw(L,UNt,Se,"f")}}.value,completionCommand:{set value(Se){Uw(G,Snt,Se,"f")}}.value,parseFn:{set value(Se){Uw(te,Tnt,Se,"f")}}.value,parseContext:{set value(Se){Uw(ce,BNt,Se,"f")}}.value}=_e,mf(this,mN,"f").configObjects=Ie,mf(this,NL,"f").unfreeze(),mf(this,Sme,"f").unfreeze(),mf(this,_ye,"f").unfreeze(),mf(this,sut,"f").unfreeze()}[qwr](e,n){return RNt(n,r=>(e(r),r))}getInternalMethods(){return{getCommandInstance:this[Hwr].bind(this),getContext:this[Jwr].bind(this),getHasOutput:this[Kwr].bind(this),getLoggerInstance:this[$wr].bind(this),getParseContext:this[Xwr].bind(this),getParserConfiguration:this[VNt].bind(this),getUsageConfiguration:this[Uwr].bind(this),getUsageInstance:this[Ywr].bind(this),getValidationInstance:this[Qwr].bind(this),hasParseCallback:this[Rtn].bind(this),isGlobalContext:this[Zwr].bind(this),postProcess:this[zNt].bind(this),reset:this[AOn].bind(this),runValidation:this[DOn].bind(this),runYargsParserAndExecuteCommands:this[zGt].bind(this),setHasOutput:this[tIr].bind(this)}}[Hwr](){return mf(this,_ye,"f")}[Jwr](){return mf(this,VGt,"f")}[Kwr](){return mf(this,Ent,"f")}[$wr](){return mf(this,rLt,"f")}[Xwr](){return mf(this,BNt,"f")||{}}[Ywr](){return mf(this,NL,"f")}[Qwr](){return mf(this,Sme,"f")}[Rtn](){return!!mf(this,Tnt,"f")}[Zwr](){return mf(this,Itn,"f")}[zNt](e,n,r,l){return r||Cae(e)||(n||(e=this[Fwr](e)),(this[VNt]()["parse-positional-numbers"]||this[VNt]()["parse-positional-numbers"]===void 0)&&(e=this[zwr](e)),l&&(e=LNt(e,this,mf(this,sut,"f").getMiddleware(),!1))),e}[AOn](e={}){Uw(this,mN,mf(this,mN,"f")||{},"f");let n={};n.local=mf(this,mN,"f").local||[],n.configObjects=mf(this,mN,"f").configObjects||[];let r={};n.local.forEach(v=>{r[v]=!0,(e[v]||[]).forEach(D=>{r[D]=!0})}),Object.assign(mf(this,jNt,"f"),Object.keys(mf(this,Ixt,"f")).reduce((v,D)=>{let N=mf(this,Ixt,"f")[D].filter(L=>!(L in r));return N.length>0&&(v[D]=N),v},{})),Uw(this,Ixt,{},"f");let l=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],_=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return l.forEach(v=>{n[v]=(mf(this,mN,"f")[v]||[]).filter(D=>!r[D])}),_.forEach(v=>{n[v]=mDt(mf(this,mN,"f")[v],D=>!r[D])}),n.envPrefix=mf(this,mN,"f").envPrefix,Uw(this,mN,n,"f"),Uw(this,NL,mf(this,NL,"f")?mf(this,NL,"f").reset(r):Twr(this,mf(this,WO,"f")),"f"),Uw(this,Sme,mf(this,Sme,"f")?mf(this,Sme,"f").reset(r):Lwr(this,mf(this,NL,"f"),mf(this,WO,"f")),"f"),Uw(this,_ye,mf(this,_ye,"f")?mf(this,_ye,"f").reset():bwr(mf(this,NL,"f"),mf(this,Sme,"f"),mf(this,sut,"f"),mf(this,WO,"f")),"f"),mf(this,rut,"f")||Uw(this,rut,wwr(this,mf(this,NL,"f"),mf(this,_ye,"f"),mf(this,WO,"f")),"f"),mf(this,sut,"f").reset(),Uw(this,Snt,null,"f"),Uw(this,Iwe,"","f"),Uw(this,gDt,null,"f"),Uw(this,Ent,!1,"f"),this.parsed=!1,this}[eIr](e,n){return mf(this,WO,"f").path.relative(e,n)}[zGt](e,n,r,l=0,_=!1){let v=!!r||_;e=e||mf(this,yDt,"f"),mf(this,mN,"f").__=mf(this,WO,"f").y18n.__,mf(this,mN,"f").configuration=this[VNt]();let D=!!mf(this,mN,"f").configuration["populate--"],N=Object.assign({},mf(this,mN,"f").configuration,{"populate--":!0}),L=mf(this,WO,"f").Parser.detailed(e,Object.assign({},mf(this,mN,"f"),{configuration:{"parse-positional-numbers":!1,...N}})),G=Object.assign(L.argv,mf(this,BNt,"f")),te,ce=L.aliases,_e=!1,Ie=!1;Object.keys(G).forEach(Se=>{Se===mf(this,aut,"f")&&G[Se]?_e=!0:Se===mf(this,Pxt,"f")&&G[Se]&&(Ie=!0)}),G.$0=this.$0,this.parsed=L,l===0&&mf(this,NL,"f").clearCachedHelpMessage();try{if(this[vOn](),n)return this[zNt](G,D,!!r,!1);mf(this,aut,"f")&&[mf(this,aut,"f")].concat(ce[mf(this,aut,"f")]||[]).filter(Tn=>Tn.length>1).includes(""+G._[G._.length-1])&&(G._.pop(),_e=!0),Uw(this,Itn,!1,"f");let Se=mf(this,_ye,"f").getCommands(),Ue=mf(this,rut,"f").completionKey in G,Ke=_e||Ue||_;if(G._.length){if(Se.length){let ft;for(let Tn=l||0,It;G._[Tn]!==void 0;Tn++)if(It=String(G._[Tn]),Se.includes(It)&&It!==mf(this,Snt,"f")){let Xn=mf(this,_ye,"f").runCommand(It,this,L,Tn+1,_,_e||Ie||_);return this[zNt](Xn,D,!!r,!1)}else if(!ft&&It!==mf(this,Snt,"f")){ft=It;break}!mf(this,_ye,"f").hasDefaultCommand()&&mf(this,Otn,"f")&&ft&&!Ke&&mf(this,Sme,"f").recommendCommands(ft,Se)}mf(this,Snt,"f")&&G._.includes(mf(this,Snt,"f"))&&!Ue&&(mf(this,iut,"f")&&hDt(!0),this.showCompletionScript(),this.exit(0))}if(mf(this,_ye,"f").hasDefaultCommand()&&!Ke){let ft=mf(this,_ye,"f").runCommand(null,this,L,0,_,_e||Ie||_);return this[zNt](ft,D,!!r,!1)}if(Ue){mf(this,iut,"f")&&hDt(!0),e=[].concat(e);let ft=e.slice(e.indexOf(`--${mf(this,rut,"f").completionKey}`)+1);return mf(this,rut,"f").getCompletion(ft,(Tn,It)=>{if(Tn)throw new Fte(Tn.message);(It||[]).forEach(Xn=>{mf(this,rLt,"f").log(Xn)}),this.exit(0)}),this[zNt](G,!D,!!r,!1)}if(mf(this,Ent,"f")||(_e?(mf(this,iut,"f")&&hDt(!0),v=!0,this.showHelp("log"),this.exit(0)):Ie&&(mf(this,iut,"f")&&hDt(!0),v=!0,mf(this,NL,"f").showVersion("log"),this.exit(0))),!v&&mf(this,mN,"f").skipValidation.length>0&&(v=Object.keys(G).some(ft=>mf(this,mN,"f").skipValidation.indexOf(ft)>=0&&G[ft]===!0)),!v){if(L.error)throw new Fte(L.error.message);if(!Ue){let ft=this[DOn](ce,{},L.error);r||(te=LNt(G,this,mf(this,sut,"f").getMiddleware(),!0)),te=this[qwr](ft,te??G),Cae(te)&&!r&&(te=te.then(()=>LNt(G,this,mf(this,sut,"f").getMiddleware(),!1)))}}}catch(Se){if(Se instanceof Fte)mf(this,NL,"f").fail(Se.message,Se);else throw Se}return this[zNt](te??G,D,!!r,!0)}[DOn](e,n,r,l){let _={...this.getDemandedOptions()};return v=>{if(r)throw new Fte(r.message);mf(this,Sme,"f").nonOptionCount(v),mf(this,Sme,"f").requiredArguments(v,_);let D=!1;mf(this,GNt,"f")&&(D=mf(this,Sme,"f").unknownCommands(v)),mf(this,WNt,"f")&&!D?mf(this,Sme,"f").unknownArguments(v,e,n,!!l):mf(this,UNt,"f")&&mf(this,Sme,"f").unknownArguments(v,e,{},!1,!1),mf(this,Sme,"f").limitedChoices(v),mf(this,Sme,"f").implications(v),mf(this,Sme,"f").conflicting(v)}}[tIr](){Uw(this,Ent,!0,"f")}[qNt](e){if(typeof e=="string")mf(this,mN,"f").key[e]=!0;else for(let n of e)mf(this,mN,"f").key[n]=!0}}});var mis,rIr,iIr=Ma(()=>{"use strict";sOn();pOn();mis=nIr(iOn),rIr=mis});var sIr=Ma(()=>{gOn();nOn();eOn();sOn()});var Mtn,aIr=Ma(()=>{Mtn="0.11.2"});var aLt,oIr,cIr,lIr,uIr,fIr,pIr,dIr,_Ir,mIr,aEt=Ma(()=>{"use strict";dDt();aLt="X-Codemod-Access-Token".toLocaleLowerCase(),oIr=async t=>(await S4e.post("https://backend.codemod.com/validateAccessToken",{},{headers:{[aLt]:t},timeout:5e3})).data,cIr=async(t,e)=>{await S4e.post("https://backend.codemod.com/publish",e,{headers:{[aLt]:t,"Content-Type":"multipart/form-data"},timeout:1e4})},lIr=async(t,e)=>{await S4e.post("https://backend.codemod.com/unpublish",{name:e},{headers:{[aLt]:t},timeout:1e4})},uIr=async t=>{await S4e.delete("https://backend.codemod.com/revokeToken",{headers:{[aLt]:t},timeout:1e4})},fIr=async(t,e)=>{let n=new URL("https://backend.codemod.com/codemods/downloadLink");t&&n.searchParams.set("name",t);let r={};return e&&(r[aLt]=e),(await S4e.get(n.toString(),{headers:r,timeout:1e4})).data},pIr=async t=>{let{accessToken:e,search:n}=t??{},r={};e&&(r[aLt]=e);let l=new URL("https://backend.codemod.com/codemods/list");return n&&l.searchParams.set("search",n),(await S4e.get(l.toString(),{headers:r,timeout:1e4})).data},dIr=async()=>(await S4e.post("https://backend.codemod.com/intents",{})).data,_Ir=async(t,e)=>(await S4e.get(`https://backend.codemod.com/intents/${t}?iv=${e}`)).data.token,mIr=async t=>(await S4e.post("https://backend.codemod.com/diffs",{before:t.beforeSnippet,after:t.afterSnippet,source:"cli"})).data});var hIr,gIr,yIr,vIr,wOn,Ftn,BMe,xIr,Btn,jtn,out=Ma(()=>{"use strict";hIr=require("node:child_process"),gIr=require("node:os"),yIr=require("node:path");Ble();vIr=Dx(r0t(),1),wOn=Dx(require("keytar"),1);aEt();Ftn=t=>{let e=process.platform==="win32"?"start":"open",n=[t];try{return(0,hIr.spawnSync)(e,n,{stdio:"ignore",shell:!1}),!0}catch(r){return console.error("Error while opening URL:",r),!1}},BMe=async()=>{let[t]=await wOn.default.findCredentials("codemod.com");if(!JKe(t))return null;let{account:e,password:n}=t,r;try{r=await oIr(n)}catch{return await wOn.default.deletePassword("codemod.com",e),null}return{user:r,token:n}},xIr=(t,e="slug")=>{let n;switch(e){case"slug":n=r=>r.slug;break;case"name":n=r=>r.name;break;case"slug-and-name":n=r=>r.name===r.slug?r.name:`${r.name} (${r.slug})`;break;default:throw new Error("Invalid type")}return t.user.organizations.map(n).filter(JKe)},Btn=t=>(0,yIr.join)(String(t)==="runOnPreCommit"?process.cwd():(0,gIr.homedir)(),".codemod"),jtn=async t=>{let{globPattern:e,source:n,errorText:r,onSuccess:l,onFail:_}=t,v=async()=>(await(0,vIr.glob)(e,{absolute:!0,ignore:["**/node_modules/**"],cwd:n,onlyFiles:!0})).at(0),D=await v();try{if(await yae("codemod build",{cwd:n}),D=await v(),D===void 0)throw new Error;l?.()}catch{throw _?.(),new Error(r)}return D}});var bIr,oLt,IOn,gis,yis,SIr,EIr=Ma(()=>{"use strict";bIr=require("node:crypto"),oLt=require("node:fs/promises"),IOn=require("node:path");out();gis=async t=>{try{let e=await(0,oLt.readFile)((0,IOn.join)(t,"session.json"),"utf-8");return JSON.parse(e).id}catch{return null}},yis=async t=>{await(0,oLt.mkdir)(t,{recursive:!0});let e=(0,bIr.randomBytes)(16).toString("hex");return await(0,oLt.writeFile)((0,IOn.join)(t,"session.json"),JSON.stringify({id:e})),e},SIr=async()=>{let t=Btn(),e=await BMe();if(e!==null)return e.user.userId;let n=await gis(t);return n!==null?n:await yis(t)}});var NOn,Nxt,cLt,TIr,vis,CIr,POn,AIr,lLt,DIr,uLt,fLt,kIr,pLt,qGt=Ma(()=>{"use strict";NOn=require("node:crypto"),Nxt=require("node:path");Ble();cLt=function(t,e,n,r){function l(_){return _ instanceof n?_:new n(function(v){v(_)})}return new(n||(n=Promise))(function(_,v){function D(G){try{L(r.next(G))}catch(te){v(te)}}function N(G){try{L(r.throw(G))}catch(te){v(te)}}function L(G){G.done?_(G.value):l(G.value).then(D,N)}L((r=r.apply(t,e||[])).next())})},TIr={tabWidth:4,useTabs:!0,semi:!0,singleQuote:!0,quoteProps:"as-needed",trailingComma:"all",bracketSpacing:!0,arrowParens:"always",endOfLine:"lf",parser:"typescript"},vis=new Map([["ts","typescript"],["tsx","typescript"],["js","babel"],["jsx","babel"],["json","json"],["json5","json5"],["jsonc","json"],["css","css"],["scss","scss"],["less","less"],["graphql","graphql"],["md","markdown"],["mdx","mdx"],["html","html"],["vue","vue"],["yaml","yaml"],["yml","yaml"]]),CIr=t=>cLt(void 0,void 0,void 0,function*(){var e;let{resolveConfig:n}=yield import("prettier"),r=yield n(t,{editorconfig:!1});(r===null||Object.keys(r).length===0)&&(r=TIr);let l=(e=vis.get((0,Nxt.extname)(t).slice(1)))!==null&&e!==void 0?e:"typescript";return Object.assign(Object.assign({},r),{parser:l})}),POn=(t,e,n)=>cLt(void 0,void 0,void 0,function*(){let r=e.replace(/\/\*\* \*\*\//gm,"");if(!n)return r;try{let{format:l}=yield import("prettier"),_=yield CIr(t);return yield l(r,_)}catch{return r}}),AIr=t=>cLt(void 0,void 0,void 0,function*(){if(t.kind==="createFile"){let e=yield POn(t.newPath,t.newData,t.formatWithPrettier);return Object.assign(Object.assign({},t),{newData:e,formatted:!0})}if(t.kind==="updateFile"){let e=yield POn(t.oldPath,t.newData,t.formatWithPrettier);return t.oldData===e?null:Object.assign(Object.assign({},t),{newData:e,formatted:!0})}return Object.assign(Object.assign({},t),{formatted:!0})}),lLt=t=>cLt(void 0,void 0,void 0,function*(){return(yield Promise.all(t.map(n=>AIr(n)))).filter(JKe)}),DIr=(t,e)=>cLt(void 0,void 0,void 0,function*(){if(e.kind==="createFile"){let n=(0,Nxt.dirname)(e.newPath);return yield t.promises.mkdir(n,{recursive:!0}),t.promises.writeFile(e.newPath,e.newData)}if(e.kind==="deleteFile")return t.promises.unlink(e.oldPath);if(e.kind==="moveFile")return yield t.promises.copyFile(e.oldPath,e.newPath),t.promises.unlink(e.oldPath);if(e.kind==="updateFile")return t.promises.writeFile(e.oldPath,e.newData);if(e.kind==="copyFile"){let n=(0,Nxt.dirname)(e.newPath);return yield t.promises.mkdir(n,{recursive:!0}),t.promises.copyFile(e.oldPath,e.newPath)}}),uLt=(t,e)=>{let n=(0,NOn.createHash)("md5").update(e.kind).update(e.newPath).update(e.newData).digest("base64url"),r=(0,Nxt.extname)(e.newPath);return(0,Nxt.join)(t,`${n}${r}`)},fLt=(t,e)=>{let n=(0,NOn.createHash)("md5").update(e.kind).update(e.oldPath).update(e.newData).digest("base64url"),r=(0,Nxt.extname)(e.oldPath);return(0,Nxt.join)(t,`${n}${r}`)},kIr=(t,e,n)=>cLt(void 0,void 0,void 0,function*(){if(n.kind==="createFile"){let r=uLt(e,n);yield t.promises.writeFile(r,n.newData)}if(n.kind==="updateFile"){let r=fLt(e,n);yield t.promises.writeFile(r,n.newData)}}),pLt=(t,e,n)=>e.dryRun===!0?kIr(t,e.outputDirectoryPath,n):DIr(t,n)});var wIr=Ma(()=>{"use strict"});var IIr,xis,bis,PIr,NIr=Ma(()=>{"use strict";IIr=require("node:fs");MGe();xis=MY([pk("jscodeshift"),pk("filemod"),pk("ts-morph"),pk("ast-grep"),pk("workflow")]),bis=oR({_:gme(vD()),source:jO(vD()),engine:jO(xis)}),PIr=t=>{var e,n;let r=Mle(bis,t);if(r._.includes("runOnPreCommit"))return{kind:"runOnPreCommit"};let l=r._.at(0);if(!l)throw new Error("Codemod to run was not specified!");return(0,IIr.existsSync)(l)||r.source?{kind:"runSourced",source:(e=r.source)!==null&&e!==void 0?e:l,engine:(n=r.engine)!==null&&n!==void 0?n:null}:{kind:"runNamed",name:l}}});var OIr,HGt,Sis,OOn,LOn,ROn,MOn,FOn,LIr,RIr,Eis,MIr,BOn=Ma(()=>{"use strict";OIr=require("node:path");ITe();MGe();HGt=["**/node_modules/**/*.*","**/*.d.ts","**/.next/**/*.*","**/dist/**/*.*","**/build/**/*.*"],Sis=process.cwd(),OOn=!0,LOn=!0,ROn=!0,MOn=!1,FOn=4,LIr=!1,RIr=!0,Eis=oR({_:gme(vD()),include:jO(gme(vD())),exclude:jO(gme(vD())),target:jO(vD()),files:jO(gme(vD())),format:jO(h4e(),OOn),cache:jO(h4e(),LOn),install:jO(h4e(),ROn),json:jO(h4e(),MOn),threads:jO(J8t([bcr(0)]),FOn)}),MIr=(t,e)=>{var n,r;let l=Mle(Eis,t),_=l._.at(1),v=l.target,D;return _&&v?(e.printConsoleMessage("info",bm.yellow("Both positional and argument target options are passed. Defaulting to the argument target option...")),D=v):D=(n=_??v)!==null&&n!==void 0?n:Sis,Object.assign(Object.assign({},l),{target:(0,OIr.resolve)(D),exclude:((r=l.exclude)!==null&&r!==void 0?r:[]).concat(HGt)})}});var FIr,BIr,Tis,jIr,WIr=Ma(()=>{"use strict";FIr=require("node:crypto"),BIr=require("node:path");MGe();Tis=MY([oR({dry:jO(pk(!1),!1)}),oR({dry:pk(!0),output:jO(vD())})]),jIr=(t,e)=>{let n=(0,FIr.randomBytes)(20);return Mle(Tis,e).dry===!1?{dryRun:!1,caseHashDigest:n}:{dryRun:!0,streamingEnabled:!0,outputDirectoryPath:(0,BIr.join)(t,".codemod","cases",n.toString("base64url")),caseHashDigest:n}}});var UIr=nn((v0o,GIr)=>{var Cis=Object.prototype.toString,jOn=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function Ais(t){return Cis.call(t).slice(8,-1)==="ArrayBuffer"}function Dis(t,e,n){e>>>=0;var r=t.byteLength-e;if(r<0)throw new RangeError("'offset' is out of bounds");if(n===void 0)n=r;else if(n>>>=0,n>r)throw new RangeError("'length' is out of bounds");return jOn?Buffer.from(t.slice(e,e+n)):new Buffer(new Uint8Array(t.slice(e,e+n)))}function kis(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');return jOn?Buffer.from(t,e):new Buffer(t,e)}function wis(t,e,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return Ais(t)?Dis(t,e,n):typeof t=="string"?kis(t,e):jOn?Buffer.from(t):new Buffer(t)}GIr.exports=wis});var $Gt=nn((JNt,VOn)=>{var Iis=FYt().SourceMapConsumer,WOn=require("path"),Oxt;try{Oxt=require("fs"),(!Oxt.existsSync||!Oxt.readFileSync)&&(Oxt=null)}catch{}var Pis=UIr();function VIr(t,e){return t.require(e)}var zIr=!1,qIr=!1,GOn=!1,JGt="auto",HNt={},KGt={},Nis=/^data:application\/json[^,]+base64,/,xDt=[],bDt=[];function zOn(){return JGt==="browser"?!0:JGt==="node"?!1:typeof window<"u"&&typeof XMLHttpRequest=="function"&&!(window.require&&window.module&&window.process&&window.process.type==="renderer")}function Ois(){return typeof process=="object"&&process!==null&&typeof process.on=="function"}function Lis(){return typeof process=="object"&&process!==null?process.version:""}function Ris(){if(typeof process=="object"&&process!==null)return process.stderr}function Mis(t){if(typeof process=="object"&&process!==null&&typeof process.exit=="function")return process.exit(t)}function Wtn(t){return function(e){for(var n=0;n<t.length;n++){var r=t[n](e);if(r)return r}return null}}var qOn=Wtn(xDt);xDt.push(function(t){if(t=t.trim(),/^file:/.test(t)&&(t=t.replace(/file:\/\/\/(\w:)?/,function(r,l){return l?"":"/"})),t in HNt)return HNt[t];var e="";try{if(Oxt)Oxt.existsSync(t)&&(e=Oxt.readFileSync(t,"utf8"));else{var n=new XMLHttpRequest;n.open("GET",t,!1),n.send(null),n.readyState===4&&n.status===200&&(e=n.responseText)}}catch{}return HNt[t]=e});function UOn(t,e){if(!t)return e;var n=WOn.dirname(t),r=/^\w+:\/\/[^\/]*/.exec(n),l=r?r[0]:"",_=n.slice(l.length);return l&&/^\/\w\:/.test(_)?(l+="/",l+WOn.resolve(n.slice(l.length),e).replace(/\\/g,"/")):l+WOn.resolve(n.slice(l.length),e)}function Fis(t){var e;if(zOn())try{var n=new XMLHttpRequest;n.open("GET",t,!1),n.send(null),e=n.readyState===4?n.responseText:null;var r=n.getResponseHeader("SourceMap")||n.getResponseHeader("X-SourceMap");if(r)return r}catch{}e=qOn(t);for(var l=/(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg,_,v;v=l.exec(e);)_=v;return _?_[1]:null}var HOn=Wtn(bDt);bDt.push(function(t){var e=Fis(t);if(!e)return null;var n;if(Nis.test(e)){var r=e.slice(e.indexOf(",")+1);n=Pis(r,"base64").toString(),e=t}else e=UOn(t,e),n=qOn(e);return n?{url:e,map:n}:null});function JOn(t){var e=KGt[t.source];if(!e){var n=HOn(t.source);n?(e=KGt[t.source]={url:n.url,map:new Iis(n.map)},e.map.sourcesContent&&e.map.sources.forEach(function(l,_){var v=e.map.sourcesContent[_];if(v){var D=UOn(e.url,l);HNt[D]=v}})):e=KGt[t.source]={url:null,map:null}}if(e&&e.map&&typeof e.map.originalPositionFor=="function"){var r=e.map.originalPositionFor(t);if(r.source!==null)return r.source=UOn(e.url,r.source),r}return t}function JIr(t){var e=/^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(t);if(e){var n=JOn({source:e[2],line:+e[3],column:e[4]-1});return"eval at "+e[1]+" ("+n.source+":"+n.line+":"+(n.column+1)+")"}return e=/^eval at ([^(]+) \((.+)\)$/.exec(t),e?"eval at "+e[1]+" ("+JIr(e[2])+")":t}function Bis(){var t,e="";if(this.isNative())e="native";else{t=this.getScriptNameOrSourceURL(),!t&&this.isEval()&&(e=this.getEvalOrigin(),e+=", "),t?e+=t:e+="<anonymous>";var n=this.getLineNumber();if(n!=null){e+=":"+n;var r=this.getColumnNumber();r&&(e+=":"+r)}}var l="",_=this.getFunctionName(),v=!0,D=this.isConstructor(),N=!(this.isToplevel()||D);if(N){var L=this.getTypeName();L==="[object Object]"&&(L="null");var G=this.getMethodName();_?(L&&_.indexOf(L)!=0&&(l+=L+"."),l+=_,G&&_.indexOf("."+G)!=_.length-G.length-1&&(l+=" [as "+G+"]")):l+=L+"."+(G||"<anonymous>")}else D?l+="new "+(_||"<anonymous>"):_?l+=_:(l+=e,v=!1);return v&&(l+=" ("+e+")"),l}function HIr(t){var e={};return Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(function(n){e[n]=/^(?:is|get)/.test(n)?function(){return t[n].call(t)}:t[n]}),e.toString=Bis,e}function KIr(t,e){if(e===void 0&&(e={nextPosition:null,curPosition:null}),t.isNative())return e.curPosition=null,t;var n=t.getFileName()||t.getScriptNameOrSourceURL();if(n){var r=t.getLineNumber(),l=t.getColumnNumber()-1,_=/^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/,v=_.test(Lis())?0:62;r===1&&l>v&&!zOn()&&!t.isEval()&&(l-=v);var D=JOn({source:n,line:r,column:l});e.curPosition=D,t=HIr(t);var N=t.getFunctionName;return t.getFunctionName=function(){return e.nextPosition==null?N():e.nextPosition.name||N()},t.getFileName=function(){return D.source},t.getLineNumber=function(){return D.line},t.getColumnNumber=function(){return D.column+1},t.getScriptNameOrSourceURL=function(){return D.source},t}var L=t.isEval()&&t.getEvalOrigin();return L&&(L=JIr(L),t=HIr(t),t.getEvalOrigin=function(){return L}),t}function jis(t,e){GOn&&(HNt={},KGt={});for(var n=t.name||"Error",r=t.message||"",l=n+": "+r,_={nextPosition:null,curPosition:null},v=[],D=e.length-1;D>=0;D--)v.push(`
|
|
825
825
|
at `+KIr(e[D],_)),_.nextPosition=_.curPosition;return _.curPosition=_.nextPosition=null,l+v.reverse().join("")}function $Ir(t){var e=/\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(t.stack);if(e){var n=e[1],r=+e[2],l=+e[3],_=HNt[n];if(!_&&Oxt&&Oxt.existsSync(n))try{_=Oxt.readFileSync(n,"utf8")}catch{_=""}if(_){var v=_.split(/(?:\r\n|\r|\n)/)[r-1];if(v)return n+":"+r+`
|
|
826
826
|
`+v+`
|
|
827
827
|
`+new Array(l).join(" ")+"^"}}return null}function Wis(t){var e=$Ir(t),n=Ris();n&&n._handle&&n._handle.setBlocking&&n._handle.setBlocking(!0),e&&(console.error(),console.error(e)),console.error(t.stack),Mis(1)}function Gis(){var t=process.emit;process.emit=function(e){if(e==="uncaughtException"){var n=arguments[1]&&arguments[1].stack,r=this.listeners(e).length>0;if(n&&!r)return Wis(arguments[1])}return t.apply(this,arguments)}}var Uis=xDt.slice(0),Vis=bDt.slice(0);JNt.wrapCallSite=KIr;JNt.getErrorSource=$Ir;JNt.mapSourcePosition=JOn;JNt.retrieveSourceMap=HOn;JNt.install=function(t){if(t=t||{},t.environment&&(JGt=t.environment,["node","browser","auto"].indexOf(JGt)===-1))throw new Error("environment "+JGt+" was unknown. Available options are {auto, browser, node}");if(t.retrieveFile&&(t.overrideRetrieveFile&&(xDt.length=0),xDt.unshift(t.retrieveFile)),t.retrieveSourceMap&&(t.overrideRetrieveSourceMap&&(bDt.length=0),bDt.unshift(t.retrieveSourceMap)),t.hookRequire&&!zOn()){var e=VIr(VOn,"module"),n=e.prototype._compile;n.__sourceMapSupport||(e.prototype._compile=function(_,v){return HNt[v]=_,KGt[v]=void 0,n.call(this,_,v)},e.prototype._compile.__sourceMapSupport=!0)}if(GOn||(GOn="emptyCacheBetweenOperations"in t?t.emptyCacheBetweenOperations:!1),zIr||(zIr=!0,Error.prepareStackTrace=jis),!qIr){var r="handleUncaughtExceptions"in t?t.handleUncaughtExceptions:!0;try{var l=VIr(VOn,"worker_threads");l.isMainThread===!1&&(r=!1)}catch{}r&&Ois()&&(qIr=!0,Gis())}};JNt.resetRetrieveHandlers=function(){xDt.length=0,bDt.length=0,xDt=Uis.slice(0),bDt=Vis.slice(0),HOn=Wtn(bDt),qOn=Wtn(xDt)}});var rPr=nn((x0o,XGt)=>{"use strict";/*! *****************************************************************************
|
|
@@ -54787,10 +54787,7 @@ Soon, we will support other engines and hence other extensions including .md, .m
|
|
|
54787
54787
|
`))}t.printConsoleMessage("info",(0,xDi.default)(l,{headingTransform:_=>bm.bold(_.toLocaleUpperCase())}))}});var EDi=nn(C$t=>{"use strict";var oTn=C$t&&C$t.__assign||function(){return oTn=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&(t[l]=e[l])}return t},oTn.apply(this,arguments)};Object.defineProperty(C$t,"__esModule",{value:!0});var mYa={delayFirstAttempt:!1,jitter:"none",maxDelay:1/0,numOfAttempts:10,retry:function(){return!0},startingDelay:100,timeMultiple:2};function hYa(t){var e=oTn(oTn({},mYa),t);return e.numOfAttempts<1&&(e.numOfAttempts=1),e}C$t.getSanitizedOptions=hYa});var TDi=nn(Hir=>{"use strict";Object.defineProperty(Hir,"__esModule",{value:!0});function gYa(t){var e=Math.random()*t;return Math.round(e)}Hir.fullJitter=gYa});var CDi=nn(Jir=>{"use strict";Object.defineProperty(Jir,"__esModule",{value:!0});function yYa(t){return t}Jir.noJitter=yYa});var ADi=nn(Kir=>{"use strict";Object.defineProperty(Kir,"__esModule",{value:!0});var vYa=TDi(),xYa=CDi();function bYa(t){switch(t.jitter){case"full":return vYa.fullJitter;case"none":default:return xYa.noJitter}}Kir.JitterFactory=bYa});var Xir=nn($ir=>{"use strict";Object.defineProperty($ir,"__esModule",{value:!0});var SYa=ADi(),EYa=function(){function t(e){this.options=e,this.attempt=0}return t.prototype.apply=function(){var e=this;return new Promise(function(n){return setTimeout(n,e.jitteredDelay)})},t.prototype.setAttemptNumber=function(e){this.attempt=e},Object.defineProperty(t.prototype,"jitteredDelay",{get:function(){var e=SYa.JitterFactory(this.options);return e(this.delay)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"delay",{get:function(){var e=this.options.startingDelay,n=this.options.timeMultiple,r=this.numOfDelayedAttempts,l=e*Math.pow(n,r);return Math.min(l,this.options.maxDelay)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt},enumerable:!0,configurable:!0}),t}();$ir.Delay=EYa});var DDi=nn(WTt=>{"use strict";var TYa=WTt&&WTt.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,l){r.__proto__=l}||function(r,l){for(var _ in l)l.hasOwnProperty(_)&&(r[_]=l[_])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),CYa=WTt&&WTt.__awaiter||function(t,e,n,r){function l(_){return _ instanceof n?_:new n(function(v){v(_)})}return new(n||(n=Promise))(function(_,v){function D(G){try{L(r.next(G))}catch(te){v(te)}}function N(G){try{L(r.throw(G))}catch(te){v(te)}}function L(G){G.done?_(G.value):l(G.value).then(D,N)}L((r=r.apply(t,e||[])).next())})},AYa=WTt&&WTt.__generator||function(t,e){var n={label:0,sent:function(){if(_[0]&1)throw _[1];return _[1]},trys:[],ops:[]},r,l,_,v;return v={next:D(0),throw:D(1),return:D(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function D(L){return function(G){return N([L,G])}}function N(L){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,l&&(_=L[0]&2?l.return:L[0]?l.throw||((_=l.return)&&_.call(l),0):l.next)&&!(_=_.call(l,L[1])).done)return _;switch(l=0,_&&(L=[L[0]&2,_.value]),L[0]){case 0:case 1:_=L;break;case 4:return n.label++,{value:L[1],done:!1};case 5:n.label++,l=L[1],L=[0];continue;case 7:L=n.ops.pop(),n.trys.pop();continue;default:if(_=n.trys,!(_=_.length>0&&_[_.length-1])&&(L[0]===6||L[0]===2)){n=0;continue}if(L[0]===3&&(!_||L[1]>_[0]&&L[1]<_[3])){n.label=L[1];break}if(L[0]===6&&n.label<_[1]){n.label=_[1],_=L;break}if(_&&n.label<_[2]){n.label=_[2],n.ops.push(L);break}_[2]&&n.ops.pop(),n.trys.pop();continue}L=e.call(t,n)}catch(G){L=[6,G],l=0}finally{r=_=0}if(L[0]&5)throw L[1];return{value:L[0]?L[1]:void 0,done:!0}}};Object.defineProperty(WTt,"__esModule",{value:!0});var DYa=Xir(),kYa=function(t){TYa(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.apply=function(){return CYa(this,void 0,void 0,function(){return AYa(this,function(n){return[2,this.isFirstAttempt?!0:t.prototype.apply.call(this)]})})},Object.defineProperty(e.prototype,"isFirstAttempt",{get:function(){return this.attempt===0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numOfDelayedAttempts",{get:function(){return this.attempt-1},enumerable:!0,configurable:!0}),e}(DYa.Delay);WTt.SkipFirstDelay=kYa});var kDi=nn(A$t=>{"use strict";var wYa=A$t&&A$t.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,l){r.__proto__=l}||function(r,l){for(var _ in l)l.hasOwnProperty(_)&&(r[_]=l[_])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(A$t,"__esModule",{value:!0});var IYa=Xir(),PYa=function(t){wYa(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(IYa.Delay);A$t.AlwaysDelay=PYa});var wDi=nn(Yir=>{"use strict";Object.defineProperty(Yir,"__esModule",{value:!0});var NYa=DDi(),OYa=kDi();function LYa(t,e){var n=RYa(t);return n.setAttemptNumber(e),n}Yir.DelayFactory=LYa;function RYa(t){return t.delayFirstAttempt?new OYa.AlwaysDelay(t):new NYa.SkipFirstDelay(t)}});var IDi=nn(p8t=>{"use strict";var Qir=p8t&&p8t.__awaiter||function(t,e,n,r){function l(_){return _ instanceof n?_:new n(function(v){v(_)})}return new(n||(n=Promise))(function(_,v){function D(G){try{L(r.next(G))}catch(te){v(te)}}function N(G){try{L(r.throw(G))}catch(te){v(te)}}function L(G){G.done?_(G.value):l(G.value).then(D,N)}L((r=r.apply(t,e||[])).next())})},Zir=p8t&&p8t.__generator||function(t,e){var n={label:0,sent:function(){if(_[0]&1)throw _[1];return _[1]},trys:[],ops:[]},r,l,_,v;return v={next:D(0),throw:D(1),return:D(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function D(L){return function(G){return N([L,G])}}function N(L){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,l&&(_=L[0]&2?l.return:L[0]?l.throw||((_=l.return)&&_.call(l),0):l.next)&&!(_=_.call(l,L[1])).done)return _;switch(l=0,_&&(L=[L[0]&2,_.value]),L[0]){case 0:case 1:_=L;break;case 4:return n.label++,{value:L[1],done:!1};case 5:n.label++,l=L[1],L=[0];continue;case 7:L=n.ops.pop(),n.trys.pop();continue;default:if(_=n.trys,!(_=_.length>0&&_[_.length-1])&&(L[0]===6||L[0]===2)){n=0;continue}if(L[0]===3&&(!_||L[1]>_[0]&&L[1]<_[3])){n.label=L[1];break}if(L[0]===6&&n.label<_[1]){n.label=_[1],_=L;break}if(_&&n.label<_[2]){n.label=_[2],n.ops.push(L);break}_[2]&&n.ops.pop(),n.trys.pop();continue}L=e.call(t,n)}catch(G){L=[6,G],l=0}finally{r=_=0}if(L[0]&5)throw L[1];return{value:L[0]?L[1]:void 0,done:!0}}};Object.defineProperty(p8t,"__esModule",{value:!0});var MYa=EDi(),FYa=wDi();function BYa(t,e){return e===void 0&&(e={}),Qir(this,void 0,void 0,function(){var n,r;return Zir(this,function(l){switch(l.label){case 0:return n=MYa.getSanitizedOptions(e),r=new jYa(t,n),[4,r.execute()];case 1:return[2,l.sent()]}})})}p8t.backOff=BYa;var jYa=function(){function t(e,n){this.request=e,this.options=n,this.attemptNumber=0}return t.prototype.execute=function(){return Qir(this,void 0,void 0,function(){var e,n;return Zir(this,function(r){switch(r.label){case 0:if(this.attemptLimitReached)return[3,7];r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.applyDelay()];case 2:return r.sent(),[4,this.request()];case 3:return[2,r.sent()];case 4:return e=r.sent(),this.attemptNumber++,[4,this.options.retry(e,this.attemptNumber)];case 5:if(n=r.sent(),!n||this.attemptLimitReached)throw e;return[3,6];case 6:return[3,0];case 7:throw new Error("Something went wrong.")}})})},Object.defineProperty(t.prototype,"attemptLimitReached",{get:function(){return this.attemptNumber>=this.options.numOfAttempts},enumerable:!0,configurable:!0}),t.prototype.applyDelay=function(){return Qir(this,void 0,void 0,function(){var e;return Zir(this,function(n){switch(n.label){case 0:return e=FYa.DelayFactory(this.options,this.attemptNumber),[4,e.apply()];case 1:return n.sent(),[2]}})})},t}()});var PDi,NDi,WYa,GYa,ODi,LDi=Ma(()=>{"use strict";ITe();PDi=Dx(IDi(),1),NDi=Dx(require("keytar"),1);aEt();out();WYa="accessTokenRequestedByCLI",GYa=(t,e,n)=>{Ftn(`https://codemod.com?command=${WYa}&sessionId=${e}&iv=${n}`)||t.printOperationMessage({kind:"error",message:"An unexpected error occurred while redirecting to the sign-in page. Please submit a GitHub issue (github.com/codemod-com/codemod/issues/new) or report it to us (codemod.com/community)."})},ODi=async t=>{if(await BMe()!==null){t.printConsoleMessage("info",bm.bold.cyan("You're already logged in."));return}let{id:n,iv:r}=await dIr();GYa(t,n,r);let l=t.withLoaderMessage(bm.cyan("Redirecting to Codemod sign-in page"));try{let _=await(0,PDi.backOff)(()=>_Ir(n,r),{numOfAttempts:60,startingDelay:1e3,timeMultiple:1});await NDi.default.setPassword("codemod.com","user-account",_),l.succeed(),t.printConsoleMessage("info",bm.bold.cyan("You are successfully logged in."))}catch{throw l.fail(),new Error("Could not validate access token. Please try again.")}}});var RDi,MDi=Ma(()=>{"use strict";aEt();out();RDi=async t=>{let e=await BMe();if(e===null){t.printConsoleMessage("info","You are already logged out.");return}try{await uIr(e.token)}catch{}t.printConsoleMessage("info","You have been successfully logged out.")}});var rBt,bIt,FDi,BDi,jDi,WDi=Ma(()=>{"use strict";rBt=Dx(require("node:fs"),1),bIt=require("node:path");ITe();Ble();dDt();FDi=Dx(r0t(),1),BDi=Dx(yen(),1);q4t();aEt();out();Qtr();jDi=async(t,e)=>{let n=await BMe();if(n===null)throw new Error("To be able to publish to Codemod Registry, please log in first.");let{token:r}=n,l=new BDi.default,_;try{_=await rBt.promises.readFile((0,bIt.join)(e,".codemodrc.json"))}catch{let{init:G}=await qTe.prompt({type:"confirm",name:"init",message:"Could not find the .codemodrc.json file in the codemod directory. Would you like to initialize the codemod configuration now?"});if(!G)throw new Error("To publish your codemod, please configure it first by running `codemod init` in the codemod directory.");let te;if(await rBt.promises.lstat(e).then(Ie=>Ie.isFile()))e=(0,bIt.dirname)(e),te=(0,bIt.basename)(e);else{let{mainPath:Ie}=await qTe.prompt({type:"input",name:"mainPath",message:"If there is a main codemod file, please provide the relative path leading to it, e.g. `src/index.ts`.",default:"empty"});Ie!=="empty"&&(te=Ie)}let _e=await Nxn({printer:t,target:e,mainFilePath:te??"index.ts"});if(!te){t.printConsoleMessage("info","Codemod initialization has been completed, however no main file was provided. Consider adjusting the main file for the codemod to become meaningful first.");return}if(!_e)throw new Error("Unexpected error, codemod package initialization has been canceled.");e=_e;try{_=await rBt.promises.readFile((0,bIt.join)(_e,".codemodrc.json"))}catch{throw new Error("Unexpected error, codemodrc file could not be found after codemod package initialization has been completed.")}}l.append(".codemodrc.json",_);let v=_.toString("utf-8"),D=pnt(JSON.parse(v));if(D.engine==="recipe"){if(D.names.length<2)throw new Error('The "names" field in .codemodrc.json must contain at least two names for a recipe codemod.');for(let L of D.names)if(!JXt.test(L))throw new Error('Each entry in the "names" field in .codemodrc.json must only contain allowed characters (a-z, A-Z, 0-9, _, /, @ or -)')}if(!JXt.test(D.name))throw new Error('The "name" field in .codemodrc.json must only contain allowed characters (a-z, A-Z, 0-9, _, /, @ or -)');if(D.engine!=="recipe"){let L,G,te;switch(D.engine){case"ast-grep":L="**/rule.yaml",G="rule.yaml",te='Please create the main "rule.yaml" file first.';break;case"piranha":L="**/rules.toml",G="rules.toml",te='Please create the main "rules.toml" file first.';break;default:if(L="dist/index.cjs",G="index.cjs",D.build?.input&&(await(0,FDi.glob)(D.build.input,{absolute:!0,cwd:e,onlyFiles:!0})).at(0)===void 0){te=`Please create the main file under ${bm.bold(D.build.input)} first.`;break}if(D.build?.output){te=`Please make sure the output path in your .codemodrc.json under ${bm.bold(D.build.output)} flag is correct.`;break}te="Please make sure your codemod can be built correctly."}let ce=t.withLoaderMessage(bm.cyan("Rebuilding the codemod before publishing...")),_e=await jtn({globPattern:D.build?.output??L,source:e,errorText:`Could not find the main file of the codemod. ${te}`,onSuccess:()=>ce.succeed(),onFail:()=>ce.fail()}),Ie=await rBt.promises.readFile(_e);l.append(G,Ie)}try{let L=await rBt.promises.readFile((0,bIt.join)(e,"README.md"));l.append("description.md",L)}catch{}let N=t.withLoaderMessage(bm.cyan("Publishing the codemod using name from",bm.bold(".codemodrc.json"),"file:",bm.bold(hz(D.name))));try{await cIr(r,l),N.succeed()}catch(L){N.fail();let G=L instanceof pDt?L.response?.data.error:String(L),te=`${bm.bold(`Could not publish the "${D.name}" codemod`)}:
|
|
54788
54788
|
${G}`;t.printOperationMessage({kind:"error",message:te});return}t.printConsoleMessage("info",bm.bold(bm.cyan(`Codemod was successfully published to the registry under the name "${D.name}".`))),t.printConsoleMessage("info",`
|
|
54789
54789
|
Now, you can run the codemod anywhere:
|
|
54790
|
-
${bm.bold(`$ codemod ${D.name}`)}`)}});var GDi,UDi,iBt,UYa,VYa,esr,VDi=Ma(()=>{"use strict";GDi=require("node:fs"),UDi=require("node:fs/promises"),iBt=Dx(require("node:path"),1);ITe();Ble();dDt();MGe();out();UYa=async(t,e)=>{try{let n=await t.promises.readFile(e,{encoding:"utf-8"}),r=oR({engine:KXt}),{engine:l}=Mle(r,JSON.parse(n.toString()));return l}catch{return null}},VYa=async(t,e,n)=>{let r,l,_;switch(e.engine){case"ast-grep":r="**/rule.yaml",l="rule.yaml",_='Please create the main "rule.yaml" file first.';break;case"piranha":r="**/rules.toml",l="rules.toml",_='Please create the main "rules.toml" file first.';break;default:r="dist/index.cjs",l="index.cjs",_='Did you forget to run "codemod build"?'}return jtn({globPattern:e.build?.output??r,source:n,errorText:`Could not find the main file of the codemod with name ${l}. ${_}`})},esr=async(t,e,n,r)=>{if(!await t.promises.lstat(n.source).then(L=>L.isDirectory())){if(n.engine===null)throw new Error("--engine has to be defined when running local codemod");return{source:"standalone",engine:n.engine,indexPath:n.source}}let _;try{_=await(0,UDi.readFile)(iBt.default.join(n.source,".codemodrc.json"),{encoding:"utf-8"})}catch{throw new Error(`Codemod directory is of incorrect structure at ${n.source}`)}let v=pnt(JSON.parse(_)),D=await UYa(t,iBt.default.join(n.source,".codemodrc.json"));if(D==="piranha"||D===null)throw new Error(`Engine specified in .codemodrc.json at ${n.source} is not a valid codemod engine for local run.`);if(D==="recipe"){let L=v.names,G=e.withLoaderMessage(bm.cyan(`Downloading recipe (${L.length} codemods)`)),te=await Promise.all(L.map(async ce=>{let _e=(0,iBt.resolve)(n.source,ce);if((0,GDi.existsSync)(_e))return esr(t,e,{...n,source:(0,iBt.resolve)(ce)},r);try{return await r.download(ce,!0)}catch(Ie){throw G.fail(),Ie instanceof pDt&&Ie.response?.status===400&&Ie.response.data.error==="Codemod not found"?new Error(`Error locating one of the recipe codemods: ${bm.bold(hz(ce))}`):Ie}}));return G.succeed(),{source:"package",name:v.name,version:v.version,engine:"recipe",directoryPath:n.source,arguments:v.arguments,codemods:te}}let N=await VYa(e,v,n.source);return{source:"package",engine:D,name:v.name,version:v.version,indexPath:N,arguments:v.arguments,directoryPath:n.source}}});var cTn,zDi=Ma(()=>{"use strict";Ble();cTn=(t,e)=>{let n=hPn({engine:t,...e});return n.success?n.output:null}});var sBt,tsr=Ma(()=>{"use strict";dDt();sBt=class{constructor(e,n,r){this.cacheEnabled=e;this._ifs=n;this._printer=r}async download(e,n){let r="cache was disabled manually";if(this.cacheEnabled){let v=await this.__getLocalFileLastModified(n),D=await this.__getRemoteFileLastModified(e);if(v===null)r="local codemod was not found";else if(D===null)r="codemod required access permissions";else{let N=await this._ifs.promises.readFile(n);return{data:Buffer.from(N),cacheUsed:!0,cacheReason:"cache was enabled"}}}let{data:l}=await S4e.get(e,{responseType:"arraybuffer"}),_=Buffer.from(l);return await this._ifs.promises.writeFile(n,_),{data:_,cacheUsed:!1,cacheReason:r}}async __getLocalFileLastModified(e){try{return(await this._ifs.promises.stat(e)).mtime.getTime()}catch{return null}}async __getRemoteFileLastModified(e){let n;try{n=await S4e.head(e,{timeout:15e3})}catch(l){if(!HAr(l))throw l;return l.response?.status===403,null}let r=n.headers["last-modified"];return r?Date.parse(r):null}}});var qDi,D$t,d8t,HDi,aBt,JDi=Ma(()=>{"use strict";qDi=require("node:crypto"),D$t=require("node:fs/promises"),d8t=require("node:path");ITe();Ble();q4t();HDi=Dx(z8n(),1);aEt();tsr();out();aBt=class{constructor(e,n,r,l,_){this.__printer=e;this.__configurationDirectoryPath=n;this._cacheEnabled=r;this._fileDownloadService=l;this._tarService=_}async download(e,n){await(0,D$t.mkdir)(this.__configurationDirectoryPath,{recursive:!0});let r=(0,qDi.createHash)("ripemd160").update(e).digest("base64url"),l=(0,d8t.join)(this.__configurationDirectoryPath,r);await(0,D$t.mkdir)(l,{recursive:!0});let _=null;n||(_=this.__printer.withLoaderMessage(bm.cyan("Downloading the",bm.bold(hz(e)),"codemod")));let v=await BMe(),D;try{D=await fIr(e,v?.token)}catch(Ie){throw _?.fail(),new Error(
|
|
54791
|
-
${Ie}`)}let N=(0,d8t.join)(l,"codemod.tar.gz"),L;try{L=await this._fileDownloadService.download(D.link,N)}catch(Ie){throw _?.fail(),new Error(`Error downloading codemod:
|
|
54792
|
-
${Ie}`)}let{data:G,cacheUsed:te,cacheReason:ce}=L;try{await this._tarService.unpack(l,G)}catch(Ie){throw _?.fail(),new Error(`Error unpacking codemod:
|
|
54793
|
-
${Ie}`)}_?.succeed(),this.__printer.printConsoleMessage("info",bm.cyan(te?"Successfully used cache to retrieve the codemod":bm("Downloaded the codemod from the registry without using cache",`(${bm.yellow(ce)})`)));let _e;try{let Ie=await(0,D$t.readFile)((0,d8t.join)(l,".codemodrc.json"));_e=pnt(JSON.parse(Ie.toString("utf8")))}catch(Ie){throw new Error(`Error parsing config for codemod ${e}: ${Ie}`)}if(this._fileDownloadService.cacheEnabled&&HDi.default.gt(D.version,_e.version)){let{update:Ie}=await qTe.prompt({name:"update",type:"confirm",default:!1,message:bm.yellow("Newer version of",bm.cyan(e),"codemod is available.","Do you want to download the newest version?")});if(Ie)return new aBt(this.__printer,this.__configurationDirectoryPath,!1,new sBt(!1,this._fileDownloadService._ifs,this._fileDownloadService._printer),this._tarService).download(e,n)}if(_e.engine==="ast-grep")try{let Ie=(0,d8t.join)(l,"rule.yaml");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,indexPath:Ie,directoryPath:l,arguments:_e.arguments}}catch(Ie){if(!(Ie instanceof Error))throw new Error("Error while downloading ast-grep codemod");this.__printer.printOperationMessage({kind:"error",message:Ie.message})}if(_e.engine==="piranha"){let Ie=(0,d8t.join)(l,"rules.toml");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,directoryPath:l,arguments:_e.arguments}}if(_e.engine==="jscodeshift"||_e.engine==="filemod"||_e.engine==="ts-morph"||_e.engine==="workflow"){let Ie=(0,d8t.join)(l,"index.cjs");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,indexPath:Ie,directoryPath:l,arguments:_e.arguments}}if(_e.engine==="recipe"){let Ie=[],{runAll:Se}=await qTe.prompt({name:"runAll",type:"confirm",message:"The codemod you are trying to run is a recipe. Do you wish to run all of them?",default:!0});if(!Se){let{names:Ue}=await qTe.prompt({name:"names",type:"checkbox",message:"Please select the codemods you want to run (use space and arrow keys to select)",choices:_e.names,default:_e.names});_e.names=Ue}for(let Ue of _e.names){let Ke=await this.download(Ue);Ie.push(Ke)}return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,codemods:Ie,directoryPath:l,arguments:_e.arguments}}throw new Error("Unsupported engine")}}});var KDi,$Di=Ma(()=>{"use strict";AJt();KDi=(t,e)=>{if(!t.dryRun)return null;if(e.kind==="createFile"){let n=uLt(t.outputDirectoryPath,e);return{kind:"create",newFilePath:e.newPath,newContentPath:n}}if(e.kind==="deleteFile")return{kind:"delete",oldFilePath:e.oldPath};if(e.kind==="moveFile")return{kind:"move",oldFilePath:e.oldPath,newFilePath:e.newPath};if(e.kind==="updateFile"){let n=fLt(t.outputDirectoryPath,e);return{kind:"rewrite",oldPath:e.oldPath,newDataPath:n}}if(e.kind==="copyFile")return{kind:"copy",oldFilePath:e.oldPath,newFilePath:e.newPath};throw new Error("Not supported command")}});var XDi,nsr,xht,YDi,zYa,QDi,ZDi=Ma(()=>{"use strict";XDi=require("node:fs"),nsr=require("node:fs/promises"),xht=require("node:path");ITe();Ble();YDi=Dx(r0t(),1);q4t();zYa={"package-lock.json":"npm","yarn.lock":"yarn","pnpm-lock.yaml":"pnpm","bun.lockb":"bun"},QDi=async t=>{let{codemodName:e,printer:n,target:r,affectedFiles:l,deps:_}=t;try{if(_.length===0)return;let{detectedPackageManager:v,rootPath:D}=await JBt(r);D===null&&(n.printConsoleMessage("info",`Could not determine the root of the project programmatically, defaulting to ${r}...`),D=r);let N=await(0,YDi.glob)("**/package.json",{cwd:D,ignore:["**/node_modules/**"],absolute:!0});if(v===null)for(let pr of N){let ds=await(0,nsr.readFile)(pr,{encoding:"utf-8"}),_s=JSON.parse(ds);if(_s.packageManager){v=_s.packageManager.split("@").at(0);break}}let L=!1;v===null&&(L=!0,v="npm");let G=N.filter(pr=>l.some(ds=>ds.startsWith((0,xht.dirname)(pr)))),te=[],ce=[];for(let pr of _){let{libName:ds}=eOt(pr);ds?.startsWith("-")?ce.push(ds.slice(1)):te.push(pr)}let _e=(0,xht.join)(D,"package.json"),Ie=te.length?bm.green("+",te.join(`
|
|
54790
|
+
${bm.bold(`$ codemod ${D.name}`)}`)}});var GDi,UDi,iBt,UYa,VYa,esr,VDi=Ma(()=>{"use strict";GDi=require("node:fs"),UDi=require("node:fs/promises"),iBt=Dx(require("node:path"),1);ITe();Ble();dDt();MGe();out();UYa=async(t,e)=>{try{let n=await t.promises.readFile(e,{encoding:"utf-8"}),r=oR({engine:KXt}),{engine:l}=Mle(r,JSON.parse(n.toString()));return l}catch{return null}},VYa=async(t,e,n)=>{let r,l,_;switch(e.engine){case"ast-grep":r="**/rule.yaml",l="rule.yaml",_='Please create the main "rule.yaml" file first.';break;case"piranha":r="**/rules.toml",l="rules.toml",_='Please create the main "rules.toml" file first.';break;default:r="dist/index.cjs",l="index.cjs",_='Did you forget to run "codemod build"?'}return jtn({globPattern:e.build?.output??r,source:n,errorText:`Could not find the main file of the codemod with name ${l}. ${_}`})},esr=async(t,e,n,r)=>{if(!await t.promises.lstat(n.source).then(L=>L.isDirectory())){if(n.engine===null)throw new Error("--engine has to be defined when running local codemod");return{source:"standalone",engine:n.engine,indexPath:n.source}}let _;try{_=await(0,UDi.readFile)(iBt.default.join(n.source,".codemodrc.json"),{encoding:"utf-8"})}catch{throw new Error(`Codemod directory is of incorrect structure at ${n.source}`)}let v=pnt(JSON.parse(_)),D=await UYa(t,iBt.default.join(n.source,".codemodrc.json"));if(D==="piranha"||D===null)throw new Error(`Engine specified in .codemodrc.json at ${n.source} is not a valid codemod engine for local run.`);if(D==="recipe"){let L=v.names,G=e.withLoaderMessage(bm.cyan(`Downloading recipe (${L.length} codemods)`)),te=await Promise.all(L.map(async ce=>{let _e=(0,iBt.resolve)(n.source,ce);if((0,GDi.existsSync)(_e))return esr(t,e,{...n,source:(0,iBt.resolve)(ce)},r);try{return await r.download(ce,!0)}catch(Ie){throw G.fail(),Ie instanceof pDt&&Ie.response?.status===400&&Ie.response.data.error==="Codemod not found"?new Error(`Error locating one of the recipe codemods: ${bm.bold(hz(ce))}`):Ie}}));return G.succeed(),{source:"package",name:v.name,version:v.version,engine:"recipe",directoryPath:n.source,arguments:v.arguments,codemods:te}}let N=await VYa(e,v,n.source);return{source:"package",engine:D,name:v.name,version:v.version,indexPath:N,arguments:v.arguments,directoryPath:n.source}}});var cTn,zDi=Ma(()=>{"use strict";Ble();cTn=(t,e)=>{let n=hPn({engine:t,...e});return n.success?n.output:null}});var sBt,tsr=Ma(()=>{"use strict";dDt();sBt=class{constructor(e,n,r){this.cacheEnabled=e;this._ifs=n;this._printer=r}async download(e,n){let r="cache was disabled manually";if(this.cacheEnabled){let v=await this.__getLocalFileLastModified(n),D=await this.__getRemoteFileLastModified(e);if(v===null)r="local codemod was not found";else if(D===null)r="codemod required access permissions";else{let N=await this._ifs.promises.readFile(n);return{data:Buffer.from(N),cacheUsed:!0,cacheReason:"cache was enabled"}}}let{data:l}=await S4e.get(e,{responseType:"arraybuffer"}),_=Buffer.from(l);return await this._ifs.promises.writeFile(n,_),{data:_,cacheUsed:!1,cacheReason:r}}async __getLocalFileLastModified(e){try{return(await this._ifs.promises.stat(e)).mtime.getTime()}catch{return null}}async __getRemoteFileLastModified(e){let n;try{n=await S4e.head(e,{timeout:15e3})}catch(l){if(!HAr(l))throw l;return l.response?.status===403,null}let r=n.headers["last-modified"];return r?Date.parse(r):null}}});var qDi,D$t,d8t,HDi,aBt,JDi=Ma(()=>{"use strict";qDi=require("node:crypto"),D$t=require("node:fs/promises"),d8t=require("node:path");ITe();Ble();q4t();HDi=Dx(z8n(),1);aEt();tsr();out();aBt=class{constructor(e,n,r,l,_){this.__printer=e;this.__configurationDirectoryPath=n;this._cacheEnabled=r;this._fileDownloadService=l;this._tarService=_}async download(e,n){await(0,D$t.mkdir)(this.__configurationDirectoryPath,{recursive:!0});let r=(0,qDi.createHash)("ripemd160").update(e).digest("base64url"),l=(0,d8t.join)(this.__configurationDirectoryPath,r);await(0,D$t.mkdir)(l,{recursive:!0});let _=null;n||(_=this.__printer.withLoaderMessage(bm.cyan("Downloading the",bm.bold(hz(e)),"codemod")));let v=await BMe(),D;try{D=await fIr(e,v?.token)}catch(Ie){throw _?.fail(),new Error(Ie.response?.data?.error??"Error getting download link for codemod")}let N=(0,d8t.join)(l,"codemod.tar.gz"),L;try{L=await this._fileDownloadService.download(D.link,N)}catch(Ie){throw _?.fail(),new Error(Ie.response?.data?.error??"Error downloading codemod from the registry")}let{data:G,cacheUsed:te,cacheReason:ce}=L;try{await this._tarService.unpack(l,G)}catch(Ie){throw _?.fail(),new Error(Ie.message??"Error unpacking codemod")}_?.succeed(),this.__printer.printConsoleMessage("info",bm.cyan(te?"Successfully used cache to retrieve the codemod":bm("Downloaded the codemod from the registry without using cache",`(${bm.yellow(ce)})`)));let _e;try{let Ie=await(0,D$t.readFile)((0,d8t.join)(l,".codemodrc.json"));_e=pnt(JSON.parse(Ie.toString("utf8")))}catch(Ie){throw new Error(`Error parsing config for codemod ${e}: ${Ie}`)}if(this._fileDownloadService.cacheEnabled&&HDi.default.gt(D.version,_e.version)){let{update:Ie}=await qTe.prompt({name:"update",type:"confirm",default:!1,message:bm.yellow("Newer version of",bm.cyan(e),"codemod is available.","Do you want to download the newest version?")});if(Ie)return new aBt(this.__printer,this.__configurationDirectoryPath,!1,new sBt(!1,this._fileDownloadService._ifs,this._fileDownloadService._printer),this._tarService).download(e,n)}if(_e.engine==="ast-grep")try{let Ie=(0,d8t.join)(l,"rule.yaml");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,indexPath:Ie,directoryPath:l,arguments:_e.arguments}}catch(Ie){if(!(Ie instanceof Error))throw new Error("Error while downloading ast-grep codemod");this.__printer.printOperationMessage({kind:"error",message:Ie.message})}if(_e.engine==="piranha"){let Ie=(0,d8t.join)(l,"rules.toml");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,directoryPath:l,arguments:_e.arguments}}if(_e.engine==="jscodeshift"||_e.engine==="filemod"||_e.engine==="ts-morph"||_e.engine==="workflow"){let Ie=(0,d8t.join)(l,"index.cjs");return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,indexPath:Ie,directoryPath:l,arguments:_e.arguments}}if(_e.engine==="recipe"){let Ie=[],{runAll:Se}=await qTe.prompt({name:"runAll",type:"confirm",message:"The codemod you are trying to run is a recipe. Do you wish to run all of them?",default:!0});if(!Se){let{names:Ue}=await qTe.prompt({name:"names",type:"checkbox",message:"Please select the codemods you want to run (use space and arrow keys to select)",choices:_e.names,default:_e.names});_e.names=Ue}for(let Ue of _e.names){let Ke=await this.download(Ue);Ie.push(Ke)}return{source:"package",name:e,version:_e.version,engine:_e.engine,include:_e.include,codemods:Ie,directoryPath:l,arguments:_e.arguments}}throw new Error("Unsupported engine")}}});var KDi,$Di=Ma(()=>{"use strict";AJt();KDi=(t,e)=>{if(!t.dryRun)return null;if(e.kind==="createFile"){let n=uLt(t.outputDirectoryPath,e);return{kind:"create",newFilePath:e.newPath,newContentPath:n}}if(e.kind==="deleteFile")return{kind:"delete",oldFilePath:e.oldPath};if(e.kind==="moveFile")return{kind:"move",oldFilePath:e.oldPath,newFilePath:e.newPath};if(e.kind==="updateFile"){let n=fLt(t.outputDirectoryPath,e);return{kind:"rewrite",oldPath:e.oldPath,newDataPath:n}}if(e.kind==="copyFile")return{kind:"copy",oldFilePath:e.oldPath,newFilePath:e.newPath};throw new Error("Not supported command")}});var XDi,nsr,xht,YDi,zYa,QDi,ZDi=Ma(()=>{"use strict";XDi=require("node:fs"),nsr=require("node:fs/promises"),xht=require("node:path");ITe();Ble();YDi=Dx(r0t(),1);q4t();zYa={"package-lock.json":"npm","yarn.lock":"yarn","pnpm-lock.yaml":"pnpm","bun.lockb":"bun"},QDi=async t=>{let{codemodName:e,printer:n,target:r,affectedFiles:l,deps:_}=t;try{if(_.length===0)return;let{detectedPackageManager:v,rootPath:D}=await JBt(r);D===null&&(n.printConsoleMessage("info",`Could not determine the root of the project programmatically, defaulting to ${r}...`),D=r);let N=await(0,YDi.glob)("**/package.json",{cwd:D,ignore:["**/node_modules/**"],absolute:!0});if(v===null)for(let pr of N){let ds=await(0,nsr.readFile)(pr,{encoding:"utf-8"}),_s=JSON.parse(ds);if(_s.packageManager){v=_s.packageManager.split("@").at(0);break}}let L=!1;v===null&&(L=!0,v="npm");let G=N.filter(pr=>l.some(ds=>ds.startsWith((0,xht.dirname)(pr)))),te=[],ce=[];for(let pr of _){let{libName:ds}=eOt(pr);ds?.startsWith("-")?ce.push(ds.slice(1)):te.push(pr)}let _e=(0,xht.join)(D,"package.json"),Ie=te.length?bm.green("+",te.join(`
|
|
54794
54791
|
+ `)):"",Se=ce.length?bm.red("-",ce.join(`
|
|
54795
54792
|
- `)):"",Ue=bm.bold(G.map(pr=>{let ds=(0,xht.relative)(r,pr);return pr===_e?`${bm.yellow("ROOT:")} ${ds}`:ds}).join(`
|
|
54796
54793
|
`));if(G.length===0)return;let Ke=[{name:"Modify dependencies in the affected package.jsons",value:"affected"},{name:"Skip dependency installation",value:"none"}],ft="Do you want to make the dependency changes in the affected package.jsons?";(0,XDi.existsSync)(_e)&&(ft="A root package.json was detected in your project. Select how you want to proceed:",Ke.splice(1,0,{name:"Modify dependencies in the root package.json",value:"root"})),n.printConsoleMessage("info",bm.cyan(`
|
|
@@ -55223,7 +55220,7 @@ Using following arguments:
|
|
|
55223
55220
|
-`,bm.bold(Object.entries(r).map(([D,N])=>bm(`${D}:`,N,_.includes(D)?bm.grey("(default value)"):"")).join(`
|
|
55224
55221
|
- `)))),r}});var ear,b8t,tar,oIi,CTn,Qeo,nar,cIi=Ma(()=>{"use strict";ear=require("node:crypto"),b8t=Dx(require("node:fs"),1),tar=require("node:fs/promises"),oIi=require("node:os"),CTn=require("node:path");ITe();AJt();Ble();dDt();q4t();wxn();VDi();zDi();JDi();$Di();tsr();ZDi();sIi();aIi();out();Qeo=async t=>{let e=!0;try{(await yae("git status --porcelain",{cwd:t})).stdout.trim()&&(e=(await qTe.prompt({type:"confirm",name:"force",message:"Current git state contains uncommitted changes. Proceed anyway?",default:!1})).force)}catch(n){if(!(n instanceof Error))return;if("stderr"in n&&typeof n.stderr=="string"&&n.stderr.trim().startsWith("fatal: not a git repository")){e=(await qTe.prompt({type:"confirm",name:"force",message:"Target folder is not tracked by git. Codemod changes might be irreversible. Proceed anyway?",default:!1})).force;return}e=(await qTe.prompt({type:"confirm",name:"force",message:"Could not run git working tree check. Codemod changes might be irreversible. Proceed anyway?",default:!1})).force}e||process.exit(0)},nar=async(t,e,n)=>{let r=PIr(e),l=MIr(e,t),_=jIr((0,oIi.homedir)(),e);_.dryRun||await Qeo(l.target);let v=new sBt(e.cache,b8t,t),D=new rGt(b8t),N=Btn(e._),L=new aBt(t,N,e.cache,v,D),G=null;if(r.kind==="runSourced"){let Se=await esr(b8t,t,r,L),Ue=await cTn(Se.engine,e);G={kind:r.kind,codemod:{...Se,hashDigest:(0,ear.createHash)("ripemd160").update(r.source).digest(),safeArgumentRecord:await TTn(Se,e,t),engineOptions:Ue}}}else if(r.kind==="runNamed"){let Se;try{Se=await L.download(r.name)}catch(Ke){throw Ke instanceof pDt&&Ke.response?.status===400&&Ke.response.data.error==="Codemod not found"&&(t.printConsoleMessage("error",bm.red("The specified command or codemod name could not be recognized.",`
|
|
55225
55222
|
To view available commands, execute`,`${bm.yellow.bold(hz("codemod --help"))}.`,`
|
|
55226
|
-
To see a list of existing codemods, run`,`${bm.yellow.bold(hz("codemod search"))}`,"or",`${bm.yellow.bold(hz("codemod list"))}`,"with a query representing the codemod you are looking for.")),process.exit(1)),new Error(`Error while downloading codemod ${name}: ${Ke}`)}let Ue=cTn(Se.engine,e);G={kind:r.kind,codemod:{...Se,hashDigest:(0,ear.createHash)("ripemd160").update(Se.name).digest(),safeArgumentRecord:await TTn(Se,e,t),engineOptions:Ue}}}else{let{preCommitCodemods:Se}=await iIi(),Ue=[];for(let Ke of Se){if(Ke.source==="package"){let ft=await L.download(Ke.name),Tn=cTn(ft.engine,e);Ue.push({...ft,safeArgumentRecord:await TTn(ft,Ke.arguments,t),engineOptions:Tn})}G={kind:r.kind,codemods:Ue}}}if(!G)throw new Error("Codemod definition could not be resolved.");let te=G.kind==="runOnPreCommit"?G.codemods:[G.codemod],ce=new pzt(te,b8t,_,l);_.dryRun&&t.printConsoleMessage("log",nft("Click to view the live results of this run in the Codemod VSCode Extension!",`vscode://codemod.codemod-vscode-extension/cases/${_.caseHashDigest.toString("base64url")}`));let _e={};if(G.kind!=="runOnPreCommit"){let{codemod:Se}=G,Ue=null;if(Se.engine==="filemod"){let dn=await(0,tar.readFile)(Se.indexPath,{encoding:"utf8"}),pr=Se.indexPath.endsWith(".ts")?ULt(dn.toString()):dn.toString();Ue=HUt(pr)}let{include:Ke,exclude:ft,reason:Tn}=await GRt(l,Se,Ue),It="",Xn="",Si=r.kind==="runSourced";G.codemod.source!=="standalone"?(It+=`@${G.codemod.version}`,Xn=G.codemod.name):(It+=" (standalone)",Xn=G.codemod.indexPath),t.printConsoleMessage("info",U8t(bm.cyan("Codemod:",bm.bold(`${Xn}${It}`),Si?bm.bold(`
|
|
55223
|
+
To see a list of existing codemods, run`,`${bm.yellow.bold(hz("codemod search"))}`,"or",`${bm.yellow.bold(hz("codemod list"))}`,"with a query representing the codemod you are looking for.")),process.exit(1)),new Error(`Error while downloading codemod ${r.name}: ${Ke}`)}let Ue=cTn(Se.engine,e);G={kind:r.kind,codemod:{...Se,hashDigest:(0,ear.createHash)("ripemd160").update(Se.name).digest(),safeArgumentRecord:await TTn(Se,e,t),engineOptions:Ue}}}else{let{preCommitCodemods:Se}=await iIi(),Ue=[];for(let Ke of Se){if(Ke.source==="package"){let ft=await L.download(Ke.name),Tn=cTn(ft.engine,e);Ue.push({...ft,safeArgumentRecord:await TTn(ft,Ke.arguments,t),engineOptions:Tn})}G={kind:r.kind,codemods:Ue}}}if(!G)throw new Error("Codemod definition could not be resolved.");let te=G.kind==="runOnPreCommit"?G.codemods:[G.codemod],ce=new pzt(te,b8t,_,l);_.dryRun&&t.printConsoleMessage("log",nft("Click to view the live results of this run in the Codemod VSCode Extension!",`vscode://codemod.codemod-vscode-extension/cases/${_.caseHashDigest.toString("base64url")}`));let _e={};if(G.kind!=="runOnPreCommit"){let{codemod:Se}=G,Ue=null;if(Se.engine==="filemod"){let dn=await(0,tar.readFile)(Se.indexPath,{encoding:"utf8"}),pr=Se.indexPath.endsWith(".ts")?ULt(dn.toString()):dn.toString();Ue=HUt(pr)}let{include:Ke,exclude:ft,reason:Tn}=await GRt(l,Se,Ue),It="",Xn="",Si=r.kind==="runSourced";G.codemod.source!=="standalone"?(It+=`@${G.codemod.version}`,Xn=G.codemod.name):(It+=" (standalone)",Xn=G.codemod.indexPath),t.printConsoleMessage("info",U8t(bm.cyan("Codemod:",bm.bold(`${Xn}${It}`),Si?bm.bold(`
|
|
55227
55224
|
Running from local filesystem`):"",`
|
|
55228
55225
|
Target:`,bm.bold(l.target),`
|
|
55229
55226
|
`,bm.yellow(Tn?`
|
|
@@ -55246,4 +55243,4 @@ ${L}`;t.printOperationMessage({kind:"error",message:G});return}t.printConsoleMes
|
|
|
55246
55243
|
`,bm.bold(`- ${xIr(e).join(`
|
|
55247
55244
|
- `)}`)))}});var dIi={};aAt(dIi,{executeMainThread:()=>eto});var rar,Zeo,cft,eto,_Ii=Ma(()=>{"use strict";ITe();mCr();Ble();dDt();rar=Dx(z8n(),1);iIr();sIr();aIr();EIr();gli();xli();Qtr();pDi();SDi();LDi();MDi();WDi();cIi();uIi();pIi();Zeo=async()=>{try{let t=(await yae("npm view codemod version",{timeout:3e3})).stdout.trim(),e=rar.default.coerce(t)?.version;e&&rar.default.gt(e,Mtn)&&console.log(U8t(bm("Update available",bm.dim(Mtn),">",bm.green(e),`
|
|
55248
55245
|
|
|
55249
|
-
Run`,bm.bold.cyan(hz("npm i -g codemod@latest")),"to upgrade"),{padding:1,textAlignment:"center",borderColor:"yellowBright",borderStyle:"round"}))}catch{}},cft=async t=>{let e=typeof t.clientIdentifier=="string"?t.clientIdentifier:"CLI";S4e.interceptors.request.use(v=>(v.headers["X-Client-Identifier"]=e,v));let n=new HBt(t.json),r=t.telemetry?new vGt({cloudRole:e,distinctId:await SIr()}):new xGt,l=async()=>{await r.dispose(),process.exit(0)};return{printer:n,telemetryService:r,exit:l,executeCliCommand:async v=>{try{await v()}catch(D){if(!(D instanceof Error))return;n.printOperationMessage({kind:"error",message:D.message})}l()}}},eto=async()=>{await Zeo();let t=tOn(process.argv),e=hli(rIr(t).help().version(!1));if(e.scriptName("codemod").usage("Usage: <command> [options]").command("*","runs a codemod or recipe",r=>$Yn(r),async r=>{let{printer:l,telemetryService:_,executeCliCommand:v}=await cft(r);return v(()=>nar(l,r,_))}).command("runOnPreCommit [files...]","run pre-commit codemods against staged files passed positionally",r=>$Yn(r),async r=>{let{executeCliCommand:l,printer:_,telemetryService:v}=await cft(r);return l(()=>nar(_,r,v))}).command(["list","ls","search"],"lists all the codemods & recipes in the public registry. can be used to search by name and tags",r=>r,async r=>{let l=r._.length>1?String(r._.at(-1)):null;if(l&&l.length<2)throw new Error("Search term must be at least 2 characters long. Aborting...");let{executeCliCommand:_,printer:v}=await cft(r);return _(()=>bDi(v,l))}).command("learn","exports the current `git diff` in a file to before/after panels in the Codemod Studio",r=>r.option("target",{alias:"t",type:"string",description:"path to the file to be learned"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>fDi(_,r.target??null))}).command("login","logs in through authentication in the Codemod Studio",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>ODi(_))}).command("logout","logs out",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>RDi(_))}).command("whoami","prints the user data of currently logged in user",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>fIi(_))}).command("build","build the JavaScript engine codemod",r=>r.option("source",{alias:"s",type:"string",description:"path to the codemod to be built"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>vli(_,r.source??process.cwd()))}).command("publish","publish the codemod to Codemod Registry",r=>r.option("source",{type:"string",description:"path to the codemod to be published"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>jDi(_,r.source??process.cwd()))}).command("unpublish","unpublish previously published codemod from Codemod Registry",r=>r.option("force",{type:"boolean",alias:"f",boolean:!0,description:"whether to remove all versions"}),async r=>{let l=r._.length>1?String(r._.at(-1)):null,{executeCliCommand:_,printer:v,exit:D}=await cft(r);return l?_(()=>lIi(v,l,r.force)):(v.printOperationMessage({kind:"error",message:"You must provide the name of the codemod to unpublish. Aborting..."}),D())}).command("init","initialize a codemod package",r=>r.option("target",{alias:"t",type:"string",description:"Path to init codemod in",default:process.cwd()}).option("no-prompt",{alias:"y",type:"boolean",description:"skip all prompts and use default values"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>Nxn({printer:_,noPrompt:r.noPrompt,target:r.target}))}),t.length===0)return e.showHelp();let n=await e.parse();
|
|
55246
|
+
Run`,bm.bold.cyan(hz("npm i -g codemod@latest")),"to upgrade"),{padding:1,textAlignment:"center",borderColor:"yellowBright",borderStyle:"round"}))}catch{}},cft=async t=>{let e=typeof t.clientIdentifier=="string"?t.clientIdentifier:"CLI";S4e.interceptors.request.use(v=>(v.headers["X-Client-Identifier"]=e,v));let n=new HBt(t.json),r=t.telemetry?new vGt({cloudRole:e,distinctId:await SIr()}):new xGt,l=async()=>{await r.dispose(),process.exit(0)};return{printer:n,telemetryService:r,exit:l,executeCliCommand:async v=>{try{await v()}catch(D){if(!(D instanceof Error))return;n.printOperationMessage({kind:"error",message:D.message})}l()}}},eto=async()=>{await Zeo();let t=tOn(process.argv),e=hli(rIr(t).help().version(!1));if(t.includes("--version")||t.includes("-v"))return console.log(Mtn);if(e.scriptName("codemod").usage("Usage: <command> [options]").command("*","runs a codemod or recipe",r=>$Yn(r),async r=>{let{printer:l,telemetryService:_,executeCliCommand:v}=await cft(r);return v(()=>nar(l,r,_))}).command("runOnPreCommit [files...]","run pre-commit codemods against staged files passed positionally",r=>$Yn(r),async r=>{let{executeCliCommand:l,printer:_,telemetryService:v}=await cft(r);return l(()=>nar(_,r,v))}).command(["list","ls","search"],"lists all the codemods & recipes in the public registry. can be used to search by name and tags",r=>r,async r=>{let l=r._.length>1?String(r._.at(-1)):null;if(l&&l.length<2)throw new Error("Search term must be at least 2 characters long. Aborting...");let{executeCliCommand:_,printer:v}=await cft(r);return _(()=>bDi(v,l))}).command("learn","exports the current `git diff` in a file to before/after panels in the Codemod Studio",r=>r.option("target",{alias:"t",type:"string",description:"path to the file to be learned"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>fDi(_,r.target??null))}).command("login","logs in through authentication in the Codemod Studio",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>ODi(_))}).command("logout","logs out",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>RDi(_))}).command("whoami","prints the user data of currently logged in user",r=>r,async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>fIi(_))}).command("build","build the JavaScript engine codemod",r=>r.option("source",{alias:"s",type:"string",description:"path to the codemod to be built"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>vli(_,r.source??process.cwd()))}).command("publish","publish the codemod to Codemod Registry",r=>r.option("source",{type:"string",description:"path to the codemod to be published"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>jDi(_,r.source??process.cwd()))}).command("unpublish","unpublish previously published codemod from Codemod Registry",r=>r.option("force",{type:"boolean",alias:"f",boolean:!0,description:"whether to remove all versions"}),async r=>{let l=r._.length>1?String(r._.at(-1)):null,{executeCliCommand:_,printer:v,exit:D}=await cft(r);return l?_(()=>lIi(v,l,r.force)):(v.printOperationMessage({kind:"error",message:"You must provide the name of the codemod to unpublish. Aborting..."}),D())}).command("init","initialize a codemod package",r=>r.option("target",{alias:"t",type:"string",description:"Path to init codemod in",default:process.cwd()}).option("no-prompt",{alias:"y",type:"boolean",description:"skip all prompts and use default values"}),async r=>{let{executeCliCommand:l,printer:_}=await cft(r);return l(()=>Nxn({printer:_,noPrompt:r.noPrompt,target:r.target}))}),t.length===0)return e.showHelp();let n=await e.parse();{let{exit:r}=await cft(n);process.on("SIGINT",r)}}});var gIi={};aAt(gIi,{executeWorkerThread:()=>tto});var hBt,ATn,mIi,ort,hIi,tto,yIi=Ma(()=>{"use strict";hBt=require("node:worker_threads");ITe();AJt();ATn=class extends Error{constructor(n,r){super(r);this.path=n}},mIi=(t,e)=>{hBt.parentPort?.postMessage({kind:"console",consoleKind:t,message:e})},ort=null,hIi=async t=>{try{let e;try{e=nEr(t)}catch(n){throw new Error(`Failed to decode message: ${String(n)}`)}if(e.kind==="initialization"){ort=e;return}if(e.kind==="exit"){hBt.parentPort?.off("message",hIi);return}if(ort===null)throw new Error;try{let n=[];switch(ort.codemodEngine){case"jscodeshift":n=lli(ort.codemodSource,e.path,e.data,ort.enablePrettier,ort.safeArgumentRecord,ort.engineOptions,mIi);break;case"ts-morph":n=_li(ort.codemodSource,e.path,e.data,ort.enablePrettier,ort.safeArgumentRecord,mIi);break;case"ast-grep":n=await GOr(ort.codemodPath,e.path,e.data,ort.enablePrettier);break;case"workflow":throw new Error("Workflow engine is not supported in worker threads");default:throw new Error(`Unknown codemod engine: ${ort.codemodEngine}`)}let r=await lLt(n);hBt.parentPort?.postMessage({kind:"commands",commands:r,path:e.path})}catch(n){throw new ATn(e.path,n instanceof Error?n.message:String(n))}}catch(e){hBt.parentPort?.postMessage({kind:"error",message:e instanceof Error?e.message:String(e),path:e instanceof ATn?e.path:void 0})}},tto=()=>{hBt.parentPort?.on("message",hIi)}});var vIi=require("node:worker_threads");vIi.isMainThread?Promise.resolve().then(()=>(_Ii(),dIi)).then(({executeMainThread:t})=>t()).catch(t=>{t instanceof Error&&console.error(JSON.stringify({message:t.message}))}):Promise.resolve().then(()=>(yIi(),gIi)).then(({executeWorkerThread:t})=>t());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codemod",
|
|
3
3
|
"author": "Codemod, Inc.",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"description": "A codemod engine for Node.js libraries (jscodeshift, ts-morph, etc.)",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": null,
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"vitest": "^1.0.1",
|
|
56
56
|
"yargs": "^17.6.2",
|
|
57
57
|
"@codemod-com/filemod": "2.0.3",
|
|
58
|
-
"@codemod-com/runner": "1.0.1",
|
|
59
|
-
"@codemod-com/printer": "1.0.1",
|
|
60
58
|
"@codemod-com/telemetry": "1.1.0",
|
|
61
59
|
"@codemod-com/utilities": "1.1.4",
|
|
60
|
+
"@codemod-com/printer": "1.0.1",
|
|
61
|
+
"@codemod-com/runner": "1.0.1",
|
|
62
62
|
"@codemod.com/workflow": "0.0.2"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|