@decaf-ts/utils 1.5.5 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e,t;e=this,t=function(e,t,o,s,n,a,r,i,c,l,d,g,u,h,f,p,m,y,S,b,w){"use strict";function v(e){var t=Object.create(null);return e&&Object.keys(e).forEach(o=>{if("default"!==o){var s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}),t.default=e,Object.freeze(t)}var T=v(y);class C{static{this.logger=s.Logging.for(C)}constructor(e){this.type="text",this.name=e}setType(e){return C.logger.verbose("Setting type to: "+e),this.type=e,this}setMessage(e){return C.logger.verbose("Setting message to: "+e),this.message=e,this}setInitial(e){return C.logger.verbose("Setting initial value to: "+e),this.initial=e,this}setStyle(e){return C.logger.verbose("Setting style to: "+e),this.style=e,this}setFormat(e){return C.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return C.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return C.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return C.logger.verbose("Setting min value to: "+e),this.min=e,this}setMax(e){return C.logger.verbose("Setting max value to: "+e),this.max=e,this}setFloat(e){return C.logger.verbose("Setting float to: "+e),this.float=e,this}setRound(e){return C.logger.verbose("Setting round to: "+e),this.round=e,this}setInstructions(e){return C.logger.verbose("Setting instructions to: "+e),this.instructions=e,this}setIncrement(e){return C.logger.verbose("Setting increment to: "+e),this.increment=e,this}setSeparator(e){return C.logger.verbose("Setting separator to: "+e),this.separator=e,this}setActive(e){return C.logger.verbose("Setting active style to: "+e),this.active=e,this}setInactive(e){return C.logger.verbose("Setting inactive style to: "+e),this.inactive=e,this}setChoices(e){return C.logger.verbose("Setting choices: "+JSON.stringify(e)),this.choices=e,this}setHint(e){return C.logger.verbose("Setting hint to: "+e),this.hint=e,this}setWarn(e){return C.logger.verbose("Setting warn to: "+e),this.warn=e,this}setSuggest(e){return C.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return C.logger.verbose("Setting limit to: "+e),this.limit=e,this}setMask(e){return C.logger.verbose("Setting mask to: "+e),this.mask=e,this}setStdout(e){return C.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await C.ask(this))[this.name]}static async ask(e){const o=C.logger.for(this.ask);let s;Array.isArray(e)||(e=[e]);try{o.verbose("Asking questions: "+e.map(e=>e.name).join(", ")),s=await t(e),o.verbose("Received answers: "+JSON.stringify(s,null,2))}catch(e){throw Error("Error while getting input: "+e)}return s}static async askNumber(e,t,o,s,n){C.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${s}, initial: ${n}`);const a=new C(e).setMessage(t).setType("number");return"number"==typeof o&&a.setMin(o),"number"==typeof s&&a.setMax(s),"number"==typeof n&&a.setInitial(n),(await this.ask(a))[e]}static async askText(e,t,o=void 0,s){C.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${s}`);const n=new C(e).setMessage(t);return o&&n.setMask(o),"string"==typeof s&&n.setInitial(s),(await this.ask(n))[e]}static async askConfirmation(e,t,o){C.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const s=new C(e).setMessage(t).setType("confirm");return void 0!==o&&s.setInitial(o),(await this.ask(s))[e]}static async insist(e,t,o,s=1){const n=C.logger.for(this.insist);let a;n.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${s}`);let r,i=0;try{do{a=(await C.ask(e))[e.name],t(a)?(r=await C.askConfirmation(e.name+"-confirm",`Is the ${e.type} correct?`,o),r||(a=void 0)):a=void 0}while(void 0===a&&s>1&&i++<s)}catch(e){throw n.error("Error while insisting: "+e),e}return void 0===a&&n.info("no selection..."),a}static async insistForText(e,t,o,s=void 0,n,a=!1,r=-1){C.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${s}, initial: ${n}, defaultConfirmation: ${a}, limit: ${r}`);const i=new C(e).setMessage(t);return s&&i.setMask(s),"string"==typeof n&&i.setInitial(n),await this.insist(i,o,a,r)}static async insistForNumber(e,t,o,s,n,a,r=!1,i=-1){C.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${s}, max: ${n}, initial: ${a}, defaultConfirmation: ${r}, limit: ${i}`);const c=new C(e).setMessage(t).setType("number");return"number"==typeof s&&c.setMin(s),"number"==typeof n&&c.setMax(n),"number"==typeof a&&c.setInitial(a),await this.insist(c,o,r,i)}static parseArgs(e){const t=C.logger.for(this.parseArgs),s={args:process.argv.slice(2),options:e};t.debug("Parsing arguments: "+JSON.stringify(s,null,2));try{return o.parseArgs(s)}catch(o){throw t.debug(`Error while parsing arguments:\n${JSON.stringify(s,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${o}`),Error("Error while parsing arguments: "+o)}}}const k={verbose:{type:"boolean",short:"V",default:void 0},version:{type:"boolean",short:"v",default:void 0},help:{type:"boolean",short:"h",default:!1},logLevel:{type:"string",default:"info"},logStyle:{type:"boolean",default:!0},timestamp:{type:"boolean",default:!0},banner:{type:"boolean",default:!0}},D=Object.keys(k).reduce((e,t)=>(e[t]=k[t].default,e),{}),$="utf-8",E=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z])))/g;var x;e.SemVersion=void 0,(x=e.SemVersion||(e.SemVersion={})).PATCH="patch",x.MINOR="minor",x.MAJOR="major";const N="-no-ci";var F;e.Tokens=void 0,(F=e.Tokens||(e.Tokens={})).GIT=".token",F.NPM=".npmtoken",F.DOCKER=".dockertoken",F.CONFLUENCE=".confluence-token";const I="Aborted";class A{constructor(e,t,...o){this.cmd=e,this.lock=t,this.logger=s.Logging.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString($):t;const o="stderr"===e?c.style(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",e+"")}error(e){this.log("stderr",e+"")}errors(e){this.log("stderr","Error executing command exited : "+e)}exit(e,t){this.log("stdout","command exited code : "+(0===e?c.style(e.toString()).green.text:c.style(null===e?"null":e.toString()).red.text)),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){if(Array.isArray(e))return this.cmd=e.join(" "),[e[0],e.slice(1)];const t=l.parse(e).filter(e=>"string"==typeof e).map(String);return this.cmd=t.join(" "),[t[0],t.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${c.style(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=Error("number"==typeof e?"Exit code "+e:e)),this.log("stderr",`${this.cmd} failed to execute: ${c.style(e.message).red}`),this.lock.reject(e)}}function R(e,...t){let o,s;if(e instanceof AbortSignal?(s=new AbortController,o=[e,...t]):(s=e,o=t),s.signal.aborted)return s;const n=()=>s.abort();for(const e of o){if(e.aborted){s.abort();break}e.addEventListener("abort",n,{once:!0,signal:s.signal})}return s}function M(e,t,o,s,n){function a(t,s){const[a,r]=e.parseCommand(t);n.info("Running command: "+a),n.debug("with args: "+r.join(" "));const c=i.spawn(a,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:s.signal});return n.verbose("pid : "+c.pid),c}const r=t.match(/[<>$#]/g);if(r)throw Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],n=Array(e.length);n[0]=s;for(let t=0;t<e.length;t++)0!==t&&(n[t]=R(n[t-1].signal)),o.push(a(e[t],n[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return a(t,s)}function j(e,t={},o=A,...n){const a=s.Logging.for(j),r=new AbortController,i={abort:r,command:e,logs:[],errs:[]},c=new Promise((s,c)=>{let l;try{l=new o(e,{resolve:s,reject:c},...n),i.cmd=M(l,e,t,r,a)}catch(t){return c(Error(`Error running command ${e}: ${t}`))}i.cmd.stdout.setEncoding("utf8"),i.cmd.stdout.on("data",e=>{e=e.toString(),i.logs.push(e),l.data(e)}),i.cmd.stderr.on("data",e=>{e=e.toString(),i.errs.push(e),l.error(e)}),i.cmd.once("error",e=>{l.exit(e.message,i.errs)}),i.cmd.once("exit",(e=0)=>{r.signal.aborted&&null===e&&(e=I),l.exit(e,0===e?i.logs:i.errs)})});return Object.assign(i,{promise:c,pipe:async t=>{const o=a.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const s=await c;return o.verbose(`Piping output to ${t.name}: ${s}`),t(s)}catch(e){throw o.error("Error piping command output: "+e),e}}}),i}const O=s.Logging.for("fs"),P=r.createRequire(process.cwd()+"/package.json");function B(e,t,o){const a=O.for(B);if(!n.existsSync(e))throw Error(`File not found at path "${e}".`);let r=L(e);a.verbose(`Patching file "${e}"...`),a.debug("with value: "+JSON.stringify(t));try{r=((e,t,o="g",n)=>(Object.entries(t).forEach(([t,a])=>{const r=RegExp(s.escapeRegExp(t),o);e=e.replace(r,e=>(!n||n(e),a))}),e))(r,t,"g",o)}catch(e){throw Error("Error patching file: "+e)}U(e,r)}function L(e){const t=O.for(L);try{return t.verbose(`Reading file "${e}"...`),n.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),Error(`Error reading file "${e}": ${o}`)}}function U(e,t){const o=O.for(U);try{o.verbose(`Writing file "${e} with ${t.length} bytes...`),n.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),Error(`Error writing file "${e}": ${t}`)}}function _(e,t){const o=O.for(_),s=[];try{return o.verbose(`Retrieving all files from "${e}"...`),n.readdirSync(e).forEach(t=>{const o=a.join(e,t),r=n.statSync(o);r.isFile()?s.push(o):r.isDirectory()&&s.push(..._(o))}),t?s.filter(t):s}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),Error(`Error retrieving files from "${e}": ${t}`)}}function V(e,t){const o=O.for(V);let s,a;try{s=n.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),Error(`Source path "${e}" does not exist: ${t}`)}try{a=n.statSync(t)}catch(e){s.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),n.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${s.isFile()?"file":"directory"} "${e}" to "${t}...`),n.cpSync(e,t,{recursive:!0})}catch(n){throw o.verbose(`Error copying ${s.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`),Error(`Error copying ${s.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`)}}function H(e){const t=O.for(H);try{const o=n.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),n.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&n.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),Error(`Error Deleting "${e}": ${o}`)}}function W(e=process.cwd(),t){let o;try{o=JSON.parse(L(a.join(e,"package.json")))}catch(e){throw Error('Failed to retrieve package information" '+e)}if(t){if(!(t in o))throw Error(`Property "${t}" not found in package.json`);return o[t]}return o}function q(e=process.cwd()){return W(e,"version")}async function J(e=process.cwd()){const t=a.join(e,"package.json"),o=a.join(e,"package-lock.json");let s,r;try{s=JSON.parse(L(t))}catch(e){throw Error(`Could not read package.json at ${t}: ${e}`)}if(n.existsSync(o))try{r=JSON.parse(L(o))}catch(e){O.warn(`Unable to parse package-lock.json at ${o}: ${e}`)}const i=(e={})=>Object.entries(e).map(([e,t])=>({name:e,version:K(r,e,t)}));return{prod:i(s.dependencies),dev:i(s.devDependencies),peer:i(s.peerDependencies)}}function K(e,t,o){if(e){const s=e.packages||{},n="node_modules/"+t;if(s[n]&&s[n].version)return s[n].version;if(e.dependencies&&e.dependencies[t])return e.dependencies[t].version||o}return o}async function G(e){const t=O.for(G),o=e.prod||[],s=e.dev||[],n=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await j("npm install "+o.join(" "),{cwd:process.cwd()}).promise),s.length&&(t.info(`Installing devDependencies ${s.join(", ")}...`),await j("npm install --save-dev "+s.join(" "),{cwd:process.cwd()}).promise),n.length&&(t.info(`Installing peerDependencies ${n.join(", ")}...`),await j("npm install --save-peer "+n.join(" "),{cwd:process.cwd()}).promise)}async function z(e){const t=O.for(z);try{const o=n.readdirSync(e).map(t=>a.join(e,t)).filter(e=>{try{return n.statSync(e).isFile()&&(e.endsWith(".js")||e.endsWith(".cjs")||e.endsWith(".mjs"))}catch{return!1}});if(0===o.length)throw Error("No JS files found in directory "+e);let s=o[0],r=n.statSync(s).size;for(const e of o.slice(1)){const t=n.statSync(e).size;r>t&&(s=e,r=t)}t.verbose(`Selected smallest bundle: ${s} (${r} bytes)`);const i=n.readFileSync(s),c=d.gzipSync(i),l=Number((c.length/1024).toFixed(1));return t.verbose(`Gzipped size: ${c.length} bytes (${l} KB)`),l}catch(o){throw t.verbose(`Failed to compute gzipped size for ${e}: ${o}`),o}}function X(e=a.join(process.cwd(),"node_modules")){const t=O.for(X);try{if(!n.existsSync(e))return[];const o=n.readdirSync(e,{withFileTypes:!0}),s=[];for(const r of o)try{if(!r.isDirectory())continue;if(r.name.startsWith("."))continue;if(r.name.startsWith("@")){const o=a.join(e,r.name);try{const e=n.readdirSync(o,{withFileTypes:!0});for(const t of e)t.isDirectory()&&!t.name.startsWith(".")&&s.push(`${r.name}/${t.name}`)}catch(e){t.verbose(`Failed to read scope ${o}: ${e}`)}}else s.push(r.name)}catch(e){t.verbose(`Skipping entry ${r.name} due to error: ${e}`)}return s}catch(o){return t.verbose(`Failed to list node_modules packages at ${e}: ${o}`),[]}}const Y=[{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That's Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"Decaf-TS: Where smart contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No CRUD, no problem \u2014 Decaf your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS: Your frontend already understands your smart contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye CRUD, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From smart contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No CRUD. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],Z=["\x1b[38;5;215m","\x1b[38;5;209m","\x1b[38;5;205m","\x1b[38;5;210m","\x1b[38;5;217m","\x1b[38;5;216m","\x1b[38;5;224m","\x1b[38;5;230m","\x1b[38;5;230m"];function Q(e){const t=ee(),o="# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# ( ( \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# ) ) \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# [=======] \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# `-----\xb4 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n#".split("\n"),s=o.reduce((e,t)=>Math.max(e,t.length),0);o.push("# "+t.padStart(s-3)),o.forEach((t,o)=>{(e?e.info.bind(e):(()=>{}).bind())(c.style(t||"").raw(Z[o]).text)})}function ee(e){try{return e=void 0===e?Math.floor(Math.random()*Y.length):e,Y[e].Slogan}catch(e){throw Error("Failed to retrieve slogans: "+e)}}class te extends s.LoggedClass{constructor(e,t={},o=[]){super(),this.name=e,this.inputs=t,this.requirements=o,te.log||Object.defineProperty(te,"log",{writable:!1,value:s.Logging.for(te.name)}),this.inputs=Object.assign({},k,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await J(),s=[],n=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)n.includes(e)||s.push(e);s.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=C.parseArgs(this.inputs),t=s.LoggedEnvironment.accumulate(D).accumulate(e.values),{version:o,help:n,banner:a}=t;if(o)return q();if(n)return this.help(e);let r;a&&Q(this.log.for(Q,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{r=await this.run(t)}catch(e){throw e}return r}}class oe{static{this.log=s.Logging.for(oe)}static async downloadFile(e){return new Promise((t,o)=>{!function e(s){s=encodeURI(s),g.get(s,n=>{if(301===n.statusCode||307===n.statusCode)return e(n.headers.location);if(200!==n.statusCode)return oe.log.error(`Failed to fetch ${s} (status: ${n.statusCode})`),o(Error("Failed to fetch "+s));let a="";n.on("data",e=>{a+=e}),n.on("error",e=>{o(e)}),n.on("end",()=>{t(a)})})}(e)})}}const se={width:1200,height:260,padding:32,backgroundColor:"#0f172a",headerFont:"bold 18px 'Segoe UI', sans-serif",rowFont:"14px 'Segoe UI', sans-serif",headerColor:"#f8fafc",rowColor:"#cbd5f5"},ne=e=>new Promise(t=>setTimeout(t,e)),ae=(process.env.PERF_VERBOSE,(...e)=>{});function re(e){return e?Array.isArray(e)?e.map(e=>(""+e).trim()).filter(Boolean):(""+e).split(",").map(e=>e.trim()).filter(Boolean):[]}function ie(e){return e.replace(/^@/,"").split(/[/\-_.]+/).filter(Boolean).map((e,t)=>0===t?e.replace(/[^a-zA-Z0-9]/g,""):`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join("")}function ce(){let e;try{e=W(process.cwd())}catch{e=void 0}try{if(!e||!(Object.keys(e.dependencies||{}).length>0||Object.keys(e.devDependencies||{}).length>0||Object.keys(e.peerDependencies||{}).length>0)){const t=a.resolve(__dirname,"../../..");try{e=W(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),s=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...s]))}const le="##VERSION##",de="##COMMIT##",ge="##FULL_VERSION##",ue="##PACKAGE##",he="##PACKAGE_SIZE##";var fe,pe,me;(e=>{e.CJS="commonjs",e.ESM="es2022"})(fe||(fe={})),(e=>{e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"})(pe||(pe={})),(e=>{e.ESM="esm",e.CJS_CHECK="cjs-check",e.TYPES="types",e.NODE_NEXT_VALIDATE="nodenext-validate",e.BUNDLE="bundle"})(me||(me={}));const ye={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:pe.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},entry:{type:"string",default:"./src/index.ts"},banner:{type:"boolean",default:!1},validateNodeNext:{type:"boolean",default:!1}},Se=(e=".cjs")=>{const t=be.log.for(Se),o=new Map;return s=>r=>{const i=a.dirname(r.fileName);function c(s){const r=JSON.stringify([i,s]),c=o.get(r);if(null!=c)return c;let l,d=s;try{d=a.resolve(i,d+".ts")}catch(e){throw Error(`Failed to resolve path ${s}: ${e}`)}try{l=n.statSync(d)}catch(e){try{t.verbose(`Testing existence of path ${d} as a folder defaulting to index file`),l=n.statSync(d.replace(/\.ts$/gm,""))}catch(t){throw Error(`Failed to resolve path ${s}: ${e}, ${t}`)}}if(l.isDirectory()&&(d=d.replace(/\.ts$/gm,"/index.ts")),a.isAbsolute(d)){const t=(/\.tsx?$/.exec(a.basename(d))||[])[0]||void 0;d="./"+a.relative(i,a.resolve(a.dirname(d),a.basename(d,t)+e))}return o.set(r,d),d}function l(e){return!(!e.startsWith("./")&&!e.startsWith("../"))&&""===a.extname(e)}return T.visitNode(r,function e(t){if((e=>!(!T.isImportDeclaration(e)&&!T.isExportDeclaration(e))&&void 0!==e.moduleSpecifier&&!!T.isStringLiteral(e.moduleSpecifier)&&l(e.moduleSpecifier.text))(t)){if(T.isImportDeclaration(t)){const e=c(t.moduleSpecifier.text),o=s.factory.createStringLiteral(e);return s.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(T.isExportDeclaration(t)){const e=c(t.moduleSpecifier.text),o=s.factory.createStringLiteral(e);return s.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}else if(T.isCallExpression(t)){const e=(e=>(e=>e.expression.kind===T.SyntaxKind.ImportKeyword)(e)&&e.arguments.length>0&&T.isStringLiteral(e.arguments[0])||T.isIdentifier(e.expression)&&"require"===e.expression.text&&e.arguments.length>0&&T.isStringLiteral(e.arguments[0])?e.arguments[0]:void 0)(t);if(e&&l(e.text)){const o=c(e.text),n=s.factory.createStringLiteral(o),a=t.arguments.map((e,t)=>0===t?n:e);return s.factory.updateCallExpression(t,t.expression,t.typeArguments,s.factory.createNodeArray(a))}}return T.visitEachChild(t,e,s)})}};class be extends te{constructor(){super("BuildScripts",Object.assign({},k,ye)),this.replacements={};const e=W(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o;try{this.commitHash=i.execSync("git rev-parse --short HEAD",{encoding:"utf8"}).trim()}catch{this.commitHash="unknown"}this.fullVersion=`${this.pkgVersion}-${this.commitHash}`,this.replacements[le]=this.pkgVersion,this.replacements[de]=this.commitHash,this.replacements[ge]=this.fullVersion,this.replacements[ue]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:s}=W();t.info(`Patching ${o} ${s} module in ${e}...`);const r=n.statSync(e),i=e=>{let t=e;return t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t};r.isDirectory()&&n.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>{const t=a.join(e.parentPath,e.name),o=n.readFileSync(t,"utf8"),s=i(o);s!==o&&n.writeFileSync(t,s,"utf8"),B(t,Object.entries(this.replacements).reduce((e,[t,o])=>([le,de,ge,ue].includes(t)||(e[t]=o),e),{}))}),t.verbose(`Module ${o} ${s} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);try{this.log[t](o)}catch(e){throw e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:s}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${s+1})`}return t+=": "+T.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=n.readFileSync(e).toString(),o=T.parseConfigFileTextToJson(e,t),r=o.config;r||this.reportDiagnostics([o.error],s.LogLevel.error);const i=T.parseJsonConfigFileContent(r,T.sys,a.dirname(e));return i.errors.length>0&&this.reportDiagnostics(i.errors,s.LogLevel.error),i}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===T.DiagnosticCategory.Error),o=e.filter(e=>e.category===T.DiagnosticCategory.Warning),n=e.filter(e=>e.category===T.DiagnosticCategory.Suggestion),a=e.filter(e=>e.category===T.DiagnosticCategory.Message);if(o.length&&this.reportDiagnostics(o,s.LogLevel.warn),t.length)throw this.reportDiagnostics(e,s.LogLevel.error),Error(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`);n.length&&this.reportDiagnostics(n,s.LogLevel.info),a.length&&this.reportDiagnostics(a,s.LogLevel.info)}}preCheckDiagnostics(e){const t=T.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const s=this.log.for(this.checkTsDiagnostics);let n;try{n=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(n.options,o?me.BUNDLE:t===fe.ESM?me.ESM:me.CJS_CHECK,e);const a=T.createProgram(n.fileNames,n.options);this.preCheckDiagnostics(a),s.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let s;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{s=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(s.options,o?me.BUNDLE:t===fe.ESM?me.ESM:me.CJS_CHECK,e);const n=T.createProgram(s.fileNames,s.options),a={};t===fe.ESM&&(a.before=[Se(".js")]);const r=n.emit(void 0,void 0,void 0,void 0,a),i=T.getPreEmitDiagnostics(n).concat(r.diagnostics);this.evalDiagnostics(i)}async build(e,t,o=!1){const s=this.log.for(this.build);await this.buildTs(e,t,o),s.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t!==fe.CJS||o||await this.buildCjsFromEsm(e)}rewriteRelativeJsSpecifiersToCjs(e){return e.replace(/(["'])(\.{1,2}\/[^"']+?)(\1)/g,(e,t,o,s)=>`${t}${(e=>e.startsWith("./")||e.startsWith("../")||e.startsWith("/")?e.endsWith(".cjs")?e:e.endsWith(".js")?e.replace(/\.js$/,".cjs"):e:e)(o)}${s}`)}async buildCjsFromEsm(e){this.log.for(this.buildCjsFromEsm).info(`Building ${this.pkgName} ${this.pkgVersion} module (${fe.CJS}) from ESM output in ${e?"dev":"prod"} mode...`);const t=a.resolve("lib/esm"),o=a.resolve("lib/cjs");n.mkdirSync(o,{recursive:!0});const s=_(t,e=>e.endsWith(".js")&&!e.endsWith(".d.js"));for(const r of s){const s=a.relative(t,r),i=a.join(o,s).replace(/\.js$/gm,".cjs");n.mkdirSync(a.dirname(i),{recursive:!0});const c=n.readFileSync(r,"utf8"),l=T.transpileModule(c,{compilerOptions:{module:y.ModuleKind.CommonJS,target:T.ScriptTarget.ES2022,sourceMap:!e,inlineSourceMap:e,inlineSources:e,esModuleInterop:!0},fileName:a.basename(r),reportDiagnostics:!0});l.diagnostics?.length&&this.evalDiagnostics(l.diagnostics);const d=this.rewriteRelativeJsSpecifiersToCjs(l.outputText);n.writeFileSync(i,d,"utf8"),l.sourceMapText&&n.writeFileSync(i+".map",l.sourceMapText,"utf8")}}applyTsConfigProfile(e,t,o){switch(e.declaration=!1,e.emitDeclarationOnly=!1,e.noEmit=!1,e.outFile=void 0,e.moduleResolution=y.ModuleResolutionKind.Bundler,t){case me.ESM:e.module=y.ModuleKind.ESNext,e.outDir="lib/esm";break;case me.CJS_CHECK:e.module=y.ModuleKind.Preserve??y.ModuleKind.ESNext,e.moduleResolution=y.ModuleResolutionKind.Bundler,e.noEmit=!0,e.outDir=void 0;break;case me.TYPES:e.module=y.ModuleKind.ESNext,e.outDir="lib/types",e.declaration=!0,e.emitDeclarationOnly=!0;break;case me.NODE_NEXT_VALIDATE:e.module=y.ModuleKind.NodeNext,e.moduleResolution=y.ModuleResolutionKind.NodeNext,e.noEmit=!0;break;case me.BUNDLE:e.module=y.ModuleKind.ESNext,e.moduleResolution=y.ModuleResolutionKind.Bundler,e.outDir="dist",e.isolatedModules=!1,e.outFile=void 0}if(t===me.NODE_NEXT_VALIDATE)return e.inlineSourceMap=!1,e.inlineSources=!1,void(e.sourceMap=!1);o?(e.inlineSourceMap=!0,e.inlineSources=!0,e.sourceMap=!1):(e.inlineSourceMap=!1,e.inlineSources=!1,e.sourceMap=!0)}async checkNodeNextCompatibility(){const e=this.log.for(this.checkNodeNextCompatibility);let t;try{t=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(t.options,me.NODE_NEXT_VALIDATE,!1);const o=T.createProgram(t.fileNames,t.options);this.preCheckDiagnostics(o),e.verbose("TypeScript NodeNext compatibility check passed.")}async buildTypes(e){let t;this.log.for(this.buildTypes).info(`Building ${this.pkgName} ${this.pkgVersion} declaration files...`);try{t=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(t.options,me.TYPES,e);const o=T.createProgram(t.fileNames,t.options),s=o.emit(),n=T.getPreEmitDiagnostics(o).concat(s.diagnostics);this.evalDiagnostics(n),this.emitDualDeclarationFiles(),this.removeLegacyDeclarationFiles(),this.updatePackageJsonDualTypeExports()}rewriteRelativeDeclarationSpecifiers(e,t,o){const s=a.dirname(o),r=e=>{if(!e.startsWith("./")&&!e.startsWith("../")&&!e.startsWith("/"))return e;if(/\.(d\.(mts|cts)|mts|cts|ts|json)$/i.test(e))return e;const o=a.resolve(s,e);try{if(n.existsSync(o)&&n.statSync(o).isDirectory())return`${e}/index${t}`}catch{}return`${e}${t}`};let i=e.replace(/(\b(?:import|export)\b[\s\S]*?\bfrom\s*["'])([^"']+)(["'])/gm,(e,t,o,s)=>`${t}${r(o)}${s}`);return i=i.replace(/(\bimport\s*\(\s*["'])([^"']+)(["']\s*\))/gm,(e,t,o,s)=>`${t}${r(o)}${s}`),i=i.replace(/(\brequire\s*\(\s*["'])([^"']+)(["']\s*\))/gm,(e,t,o,s)=>`${t}${r(o)}${s}`),i}emitDualDeclarationFiles(){const e=this.log.for(this.emitDualDeclarationFiles),t=a.resolve("lib/types");if(!n.existsSync(t))return;const o=_(t,e=>e.endsWith(".d.ts"));for(const e of o){const t=n.readFileSync(e,"utf8"),o=e.replace(/\.d\.ts$/i,".d.mts"),s=e.replace(/\.d\.ts$/i,".d.cts");n.writeFileSync(o,this.rewriteRelativeDeclarationSpecifiers(t,".d.mts",e),"utf8"),n.writeFileSync(s,this.rewriteRelativeDeclarationSpecifiers(t,".d.cts",e),"utf8")}e.verbose(`Generated ${2*o.length} dual declaration files.`)}removeLegacyDeclarationFiles(){const e=this.log.for(this.removeLegacyDeclarationFiles),t=a.resolve("lib/types");if(!n.existsSync(t))return;const o=_(t,e=>e.endsWith(".d.ts")||e.endsWith(".d.ts.map"));for(const e of o)try{n.unlinkSync(e)}catch{}e.verbose(`Removed ${o.length} legacy declaration files.`)}updatePackageJsonDualTypeExports(){const e=this.log.for(this.updatePackageJsonDualTypeExports),t=a.resolve("package.json");if(!n.existsSync(t))return;const o=JSON.parse(n.readFileSync(t,"utf8")),s=o?.exports;if(!s||"object"!=typeof s)return;const r=(e,t)=>e.replace(/\.d\.(ts|mts|cts)$/i,t),i=e=>{if(e)return e.includes("/lib/esm/")?e.replace("/lib/esm/","/lib/cjs/").replace(/\.js$/i,".cjs"):e},c=(e,t=".d.mts")=>{if(e)return e.includes("/lib/esm/")?e.replace("/lib/esm/","/lib/types/").replace(/\.js$/i,t):void 0},l=e=>"string"==typeof e?e:e&&"object"==typeof e&&"string"==typeof e.default?e.default:void 0,d=e=>{if(e&&"object"==typeof e&&"string"==typeof e.types)return e.types},g={};for(const[e,t]of Object.entries(s)){if(!t||"object"!=typeof t||Array.isArray(t)){g[e]=t;continue}const o=t,s=l(o.import),n=l(o.require),a=n&&n.includes("/lib/esm/")?i(n):n||i(s),u=l(o.default),h=("string"==typeof o.types?o.types:void 0)||d(o.import),f=h&&/\.d\.(ts|mts|cts)$/i.test(h)?r(h,".d.mts"):d(o.import)||c(s,".d.mts"),p=h&&/\.d\.(ts|mts|cts)$/i.test(h)?r(h,".d.cts"):d(o.require)||c(s,".d.cts");g[e]={...s?{import:{...f?{types:f}:{},default:s}}:{},...a?{require:{...p?{types:p}:{},default:a}}:{},...u||s?{default:u||s}:{}}}o.exports=g,"string"==typeof o.types&&/\.d\.(ts|mts|cts)$/i.test(o.types)&&(o.types=o.types.replace(/\.d\.(ts|mts|cts)$/i,".d.mts")),n.writeFileSync(t,JSON.stringify(o,null,2)+"\n","utf8"),e.verbose("Updated package.json exports with import/require type conditions.")}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=n.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&V("./src/assets",`./${e===fe.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,s="./src/index.ts",n=this.pkgName,i,c=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const l=e===fe.ESM,d=this.pkgName,g=this.log,u=Array.from(new Set([...re(c)]));let y=re(i);if(0===y.length){try{y=X(a.join(process.cwd(),"node_modules"))}catch{}y&&0!==y.length||(y=ce())}const S=Array.from(new Set([...(()=>{try{return Array.isArray(r.builtinModules)?r.builtinModules:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}})(),...y])),b=!t||"inline",w=[h({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist",sourceMap:!t,inlineSourceMap:!!t,inlineSources:!!t},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),m()];o&&w.push(f({include:[],exclude:y}),p.nodeResolve({resolveOnly:u}));try{const k=await import("@rollup/plugin-terser"),D=k&&k.terser||k.default||k,$={parse:{ecma:2020},compress:!1,mangle:!1,format:{comments:!1,beautify:!0}},E={parse:{ecma:2020},compress:{ecma:2020,passes:5,drop_console:!0,drop_debugger:!0,toplevel:!0,module:l,unsafe:!0,unsafe_arrows:!0,unsafe_comps:!0,collapse_vars:!0,reduce_funcs:!0,reduce_vars:!0},mangle:{toplevel:!0},format:{comments:!1,ascii_only:!0},toplevel:!0};w.push(D(t?$:E))}catch{}const v={input:s,plugins:w,external:S,onwarn:void 0,treeshake:!t},T={};S.forEach(e=>{T[e]=ie(e)});const C=[{dir:o?"bin":"dist",entryFileNames:`${n||".bundle."+(t?"":"min")}${l?".js":".cjs"}`,format:o?"cjs":l?"esm":"umd",name:d,esModule:l,sourcemap:b,globals:T,exports:"auto"}];try{const{rollup:x}=await import("rollup"),N=await x(v);async function F(e){for(const t of C)await e.write(t)}g.verbose(N.watchFiles);try{await F(N)}finally{await N.close()}}catch(I){throw Error("Failed to bundle: "+I)}}async buildByEnv(e="./src/index.ts",t,o=pe.ALL,s=!1,a,r){s&&await this.checkNodeNextCompatibility();try{H("lib")}catch(e){}try{H("dist")}catch(e){}[pe.ALL,pe.BUILD].includes(o)&&(n.mkdirSync("lib",{recursive:!0}),await this.build(t,fe.ESM),await this.build(t,fe.CJS),await this.buildTypes(t),this.patchFiles("lib")),[pe.ALL,pe.BUNDLE].includes(o)&&(n.mkdirSync("dist"),await this.bundle(fe.ESM,t,!1,e||"./src/index.ts",this.pkgName,r,a),await this.bundle(fe.CJS,t,!1,e||"./src/index.ts",this.pkgName,r,a),this.patchFiles("dist")),this.copyAssets(fe.CJS),this.copyAssets(fe.ESM)}async buildDev(e="./src/index.ts",t=pe.ALL,o=!1,s,n){return this.buildByEnv(e,!0,t,o,s,n)}async buildProd(e="./src/index.ts",t=pe.ALL,o=!1,s,n){return this.buildByEnv(e,!1,t,o,s,n)}async buildDocs(){await j("npm install better-docs taffydb").promise,await j("npx markdown-include ./workdocs/readme-md.json").promise,await j("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await j("npm remove better-docs taffydb").promise,[{src:"workdocs/assets",dest:"./docs/workdocs/assets"},{src:"workdocs/reports/coverage",dest:"./docs/workdocs/reports/coverage"},{src:"workdocs/reports/html",dest:"./docs/workdocs/reports/html"},{src:"workdocs/resources",dest:"./docs/workdocs/resources"},{src:"LICENSE.md",dest:"./docs/LICENSE.md"}].forEach(e=>{const{src:t,dest:o}=e;V(t,o)});try{const e=await z(a.resolve(a.join(process.cwd(),"dist")));this.replacements[he]=e+" KB"}catch{this.replacements[he]="unknown"}try{B("./README.md",this.replacements)}catch(e){this.log.for(this.buildDocs).verbose("Failed to patch README.md: "+e)}}async run(e){const{dev:t,prod:o,docs:s,buildMode:n,includes:a,externals:r,entry:i,validateNodeNext:c}=e;return t?await this.buildDev(i||"./src/index.ts",n,!!c,a,r):o?await this.buildProd(i||"./src/index.ts",n,!!c,a,r):s?await this.buildDocs():void 0}}function we(e,t,o,s,n,a=[],r=[]){e.info(""+t),e.info(o),e.info("Usage: "+s),e.info("Options:");for(const t of n){const o=t.defaultValue?` (default: ${t.defaultValue})`:"";e.info(` ${t.flag} ${t.description}${o}`)}if(a.length>0){e.info("Notes:");for(const t of a)e.info(" "+t)}if(r.length>0){e.info("Examples:");for(const t of r)e.info(" "+t)}}const ve={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}},Te=s.Logging.for("ReleaseChainRunner");class Ce{constructor(e){this.options=e,this.workspace=e.workspace??process.cwd(),this.clonesRoot=a.join(this.workspace,".release-chain"),this.token=e.token||process.env.RELEASE_CHAIN_TOKEN||process.env.GITHUB_TOKEN||process.env.GH_TOKEN,this.metaRepoSlug=Ee(e.metaRepoUrl)||Ie("Unable to normalize META repo URL"),this.currentRepo=Ee(e.currentRepo)||Fe()}async run(){const e=await this.loadSubmodules();if(!e.length)return void Te.warn("No modules detected in provided .gitmodules file");const t=this.currentRepo?e.findIndex(e=>e.slug===this.currentRepo):-1,o=0>t?e:e.slice(t+1);Te.info(`Evaluating ${o.length} repositories for ${this.options.packageName}`);for(const e of o)await this.evaluateModule(e)}async evaluateModule(e){if(!e.slug)return void Te.verbose(`Skipping ${e.name}: unsupported repository URL`);Te.info("\n[release-chain] "+e.slug);const t=a.join(this.clonesRoot,e.slug.replace(/\//g,"__"));n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(t,{recursive:!0}),this.cloneRepository(e.url,t),await this.checkoutTargetBranch(t);const o=a.join(t,"package.json");if(!n.existsSync(o))return void Te.debug("No package.json detected for "+e.slug);if(s=JSON.parse(n.readFileSync(o,"utf8")),r=this.options.packageName,!["dependencies","devDependencies","peerDependencies","optionalDependencies"].some(e=>!!s?.[e]?.[r]))return void Te.debug(`${e.slug} does not depend on ${this.options.packageName}`);var s,r,i;if((e=>{try{S.execSync("git config user.name",{cwd:e,stdio:"pipe"}),S.execSync("git config user.email",{cwd:e,stdio:"pipe"})}catch{S.execSync("git config user.name 'release-chain'",{cwd:e}),S.execSync("git config user.email 'release-chain@users.noreply.github.com'",{cwd:e})}})(t),this.runCommand("npm install --ignore-scripts",t),this.runCommand("npm update "+this.options.packageName,t),this.runCommand("npm run build --if-present",t),this.runCommand("npm run test --if-present",t),i=t,!S.execSync("git status --porcelain",{cwd:i,encoding:"utf8"}).trim())return void Te.info("No changes detected for "+e.slug);this.runCommand("git add -A",t),this.runCommand(`git commit -m "chore: release chain update for ${this.options.packageName}"`,t),this.runCommand(`git push origin ${this.options.branch} --force-with-lease`,t);const c=await this.findExistingPr(e.slug);if(c)return Te.info(`Existing PR #${c.number} detected for ${e.slug}, attempting merge`),void await this.acceptPullRequest(e.slug,c.number,c.head.sha);const l=this.options.targetBaseBranch||await this.getDefaultBranch(e.slug);await this.createPullRequest(e.slug,l)}cloneRepository(e,t){const o=((e,t)=>{const o=xe(e);if(!t)return o;const s=new URL(o);return s.username="x-access-token",s.password=t,s.toString()})(e,this.token);this.runCommand(`git clone --no-tags --depth 1 ${o} ${t}`)}async checkoutTargetBranch(e){try{return this.runCommand(`git fetch origin ${this.options.branch}:${this.options.branch}`,e),this.runCommand("git checkout "+this.options.branch,e),void this.runCommand("git reset --hard origin/"+this.options.branch,e)}catch(e){Te.verbose(`Branch ${this.options.branch} not found remotely; creating from default`)}const t=(e=>{try{return S.execSync("git symbolic-ref --short refs/remotes/origin/HEAD",{cwd:e,encoding:"utf8"}).trim().split("/").pop()||"main"}catch{return"main"}})(e);this.runCommand(`git checkout -b ${this.options.branch} origin/${t}`,e)}async loadSubmodules(){if(this.options.submodulePath&&n.existsSync(this.options.submodulePath))return $e(n.readFileSync(this.options.submodulePath,"utf8"));const e=[this.options.submoduleFile,".gitsubmodule",".gitmodules"].filter(Boolean);for(const t of e)try{const e=await Ne(this.metaRepoSlug,this.options.branch,t,this.token);if(e)return $e(e)}catch(o){if(t===e[e.length-1])throw o}return[]}runCommand(e,t=this.workspace){Te.debug(`[${t}] ${e}`),S.execSync(e,{cwd:t,stdio:"inherit",env:Object.assign({},process.env,{RELEASE_CHAIN_TOKEN:this.token})})}async githubRequest(e,t){const o={"User-Agent":"decaf-release-chain",Accept:"application/vnd.github+json"};this.token&&(o.Authorization="Bearer "+this.token);const s=await fetch("https://api.github.com"+e,{method:t?.method||"GET",headers:Object.assign({},o,t?.headers),body:t?.body});if(!s.ok){const e=await s.text();throw Error(`GitHub API ${s.status}: ${e}`)}if(204!==s.status)return await s.json()}async findExistingPr(e){const[t]=e.split("/"),o=await this.githubRequest(`/repos/${e}/pulls?head=${t}%3A${encodeURIComponent(this.options.branch)}&state=open&per_page=1`);return o?.[0]}async acceptPullRequest(e,t,o){await this.githubRequest(`/repos/${e}/pulls/${t}/merge`,{method:"PUT",body:JSON.stringify({merge_method:"squash",commit_title:"chore: accept release chain for "+this.options.packageName,sha:o})})}async createPullRequest(e,t){await this.githubRequest(`/repos/${e}/pulls`,{method:"POST",body:JSON.stringify({title:this.options.branch+"-release-chain",head:this.options.branch,base:t,body:`Automated dependency update for ${this.options.packageName}.`})})}async getDefaultBranch(e){const t=await this.githubRequest("/repos/"+e);return t?.default_branch||"main"}}async function ke(e){const t=new Ce(e);await t.run()}async function De(e){const t=e.token||process.env.RELEASE_CHAIN_TRIGGER_TOKEN||process.env.RELEASE_CHAIN_TOKEN||process.env.GITHUB_TOKEN||process.env.GH_TOKEN,o=e.repoSlug||Fe()||Ie("Unable to determine repository slug for dispatch"),s=e.workflowFile||"release-chain.yaml",n=e.ref||e.branch,a=Ee(e.currentRepo)||o;Te.info(`Dispatching ${s} on ${o} for ${e.branch} (current repo ${a})`);const r={"User-Agent":"decaf-release-chain-dispatch",Accept:"application/vnd.github+json","Content-Type":"application/json"};t&&(r.Authorization="Bearer "+t);const i=await fetch(`https://api.github.com/repos/${o}/actions/workflows/${s}/dispatches`,{method:"POST",headers:r,body:JSON.stringify({ref:n,inputs:{meta_repo_url:e.metaRepoUrl,branch:e.branch,current_repo:a,target_branch:e.targetBaseBranch||""}})});if(!i.ok){const e=await i.text();throw Error(`Workflow dispatch failed: ${i.status} ${e}`)}}function $e(e){return e.split("[submodule").slice(1).map(e=>{const t=e.match(/"(.+?)"\]/),o=e.match(/path\s*=\s*(.+)/),s=e.match(/url\s*=\s*(.+)/),n=s?.[1]?.trim()||"";return{name:t?.[1]?.trim()||"",path:o?.[1]?.trim()||"",url:n,slug:Ee(n)}}).filter(e=>e.url)}function Ee(e){if(e){if(e.includes("github.com")){const t=xe(e);return new URL(t).pathname.replace(/^\//,"").replace(/\.git$/,"")}return e.replace(/^\//,"")}}function xe(e){return e.startsWith("git@github.com:")?"https://github.com/"+e.replace("git@github.com:",""):e.startsWith("ssh://git@github.com/")?"https://github.com/"+e.replace("ssh://git@github.com/",""):e.replace(/\.git$/,"")}async function Ne(e,t,o,s){const n=`https://raw.githubusercontent.com/${e}/${t}/${o}`,a={"User-Agent":"decaf-release-chain"};s&&(a.Authorization="Bearer "+s);const r=await fetch(n,{headers:a});if(404===r.status)return null;if(!r.ok){const e=await r.text();throw Error(`Failed to download ${o}: ${r.status} ${e}`)}return r.text()}function Fe(){if(process.env.GITHUB_REPOSITORY)return process.env.GITHUB_REPOSITORY;try{return Ee(S.execSync("git config --get remote.origin.url",{encoding:"utf8"}).trim().replace(/\s+/g,""))}catch{return}}function Ie(e){throw Error(e)}const Ae={meta:{type:"string",default:process.env.RELEASE_CHAIN_META_REPO_URL||""},branch:{type:"string",default:process.env.RELEASE_CHAIN_BRANCH||process.env.GITHUB_REF_NAME||"main"},current:{type:"string",default:process.env.RELEASE_CHAIN_CURRENT||process.env.GITHUB_REPOSITORY||""},package:{type:"string",default:""},token:{type:"string",default:process.env.RELEASE_CHAIN_TOKEN||""},submoduleFile:{type:"string",default:process.env.RELEASE_CHAIN_FILE||""},submodulePath:{type:"string",default:process.env.RELEASE_CHAIN_FILE_PATH||""},workflow:{type:"string",default:process.env.RELEASE_CHAIN_WORKFLOW||"release-chain.yaml"},repo:{type:"string",default:process.env.RELEASE_CHAIN_REPO||""},ref:{type:"string",default:process.env.RELEASE_CHAIN_REF||""},targetBase:{type:"string",default:process.env.RELEASE_CHAIN_TARGET||""}};function Re(){try{return S.execSync("git config --get remote.origin.url",{encoding:"utf8"}).trim()}catch{return}}function Me(){try{return S.execSync("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}catch{return"main"}}function je(e=process.cwd()){const t=w.join(e,".gitmodules");return b.readFileSync(t,"utf8").toString().match(/(?<=").*?(?="])/g)||[]}function Oe(e=process.cwd(),t=2){const o=new Set,s=new Set,n=(e,t,a="")=>{const r=w.resolve(e);if(s.has(r))return;s.add(r);let i=[];try{i=je(e)}catch{return}for(const s of i){const r=a?w.join(a,s):s;if(o.add(r),0>=t)continue;const i=w.join(e,s),c=w.join(i,".gitmodules");b.existsSync(c)&&n(i,t-1,r)}};return n(e,t),Array.from(o)}const Pe={basePath:{type:"string",default:process.cwd()}},Be={maxTraversal:{type:"string",default:"2"},excludes:{type:"string",multiple:!0,default:["@decaf-ts/utils","@decaf-ts/logging"]},include:{type:"string",multiple:!0,default:[]},packages:{type:"string",multiple:!0,default:[]},mainPackagePath:{type:"string",default:""},operation:{type:"string",default:"link"}};function Le(e){return e.split("/")[1]||e}function Ue(e){return[...Object.keys(e.dependencies||{}),...Object.keys(e.devDependencies||{}),...Object.keys(e.peerDependencies||{})]}function _e(e){return Array.isArray(e)?e.map(e=>(""+e).trim()).filter(Boolean):"string"==typeof e&&e.length>0?e.split(",").map(e=>e.trim()).filter(Boolean):[]}function Ve(e,t){if(t.includes("*")){const o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");return RegExp(`^${o}$`).test(e)}return e===t||w.basename(e)===t||e.endsWith("/"+t)}const He={maxTraversal:{type:"string",default:"2"},tokenFiles:{type:"string",multiple:!0,default:[".token",".npmtoken"]}},We={basePath:{type:"string",default:process.cwd()},command:{type:"string",default:void 0}},qe={public:{type:"boolean",default:!1},private:{type:"boolean",default:!1},gitToken:{type:"string",default:".token"},npmToken:{type:"string",default:".npmtoken"},gitUser:{type:"string",default:void 0},allowFromBranch:{type:"boolean",default:!1},tag:{type:"string",default:void 0},message:{type:"string",default:void 0}};e.AbortCode=I,e.BuildScripts=be,e.COMMIT="2067dda",e.Command=te,e.DefaultCommandOptions=k,e.DefaultCommandValues=D,e.Encoding=$,e.FULL_VERSION="1.5.4-2067dda",e.HttpClient=oe,e.ModulesCommand=class extends te{constructor(){super("ModulesCommand",Pe)}help(){we(this.log,"modules","List modules discovered from .gitmodules.","modules [options]",[{flag:"--base-path <path>",description:"Directory to read .gitmodules from",defaultValue:"current working directory"},{flag:"-h, --help",description:"Show this help text and exit"}],["Each discovered module path is printed on its own line."],["modules","modules --base-path ../repo"])}async run(e){je(e.basePath).forEach(e=>this.log.info(e))}},e.NoCIFLag=N,e.NpmLinkCommand=class extends te{constructor(){super("NpmLinkCommand",Be)}help(){we(this.log,"npm-link","Link or unlink decaf-ts package outputs across linked modules.","npm-link [options]",[{flag:"--max-traversal <depth>",description:"How many nested .gitmodules levels to traverse",defaultValue:"2"},{flag:"--excludes <items...>",description:"Dependency names or patterns to ignore",defaultValue:"@decaf-ts/utils,@decaf-ts/logging"},{flag:"--include <items...>",description:"Module names or paths to target explicitly"},{flag:"--packages <items...>",description:"Additional non-decaf packages to link or unlink"},{flag:"--main-package-path <path>",description:"Path to the package tree that provides the original decaf packages"},{flag:"--operation <name>",description:"Operation to run in each module",defaultValue:"link"},{flag:"-h, --help",description:"Show this help text and exit"}],["link creates symlinks for decaf-ts dependencies","link can also include extra non-decaf packages passed via --packages","when --packages is set, --main-package-path is required and is used as the source root","unlink removes those links and reinstalls dependencies","any other operation is passed through to npm in each selected module"],["npm-link --operation link","npm-link --operation unlink","npm-link --operation install --include packages/app","npm-link --packages @scope/* --main-package-path ../packages --include packages/app"])}async run(e){const t=Number.parseInt(""+(e.maxTraversal||"2"),10),o=_e(e.include),s=_e(e.excludes),n=_e(e.packages),a=(""+(e.mainPackagePath||"")).trim(),r=["@decaf-ts/utils","@decaf-ts/logging"],i=(""+(e.operation||"link")).trim()||"link",c=a?w.resolve(a):process.cwd();if(n.length>0&&!a)return void process.exit(1);const l=JSON.parse(b.readFileSync(w.join(c,"package.json"),"utf8")).name.split("/")[0]||"",d=Oe(process.cwd(),Number.isFinite(t)?t:2).filter(e=>0>=o.length||o.some(t=>Ve(e,t))),g=e=>(s.length>0?s:r).some(t=>Ve(e,t));for(const e of d){const t=w.join(process.cwd(),e);let o;try{o=JSON.parse(b.readFileSync(w.join(t,"package.json"),"utf8"))}catch{continue}const s=Ue(o).filter(e=>{return(t=e).startsWith(l)||n.some(e=>Ve(t,e));var t});if("link"!==i)if("unlink"!==i)try{S.execSync("npm "+i,{cwd:t,env:process.env,stdio:"inherit"})}catch{process.exit(1)}else{for(const e of s)if(!g(e))try{b.rmSync(w.join(t,"node_modules",e),{force:!0,recursive:!0})}catch{process.exit(1)}try{S.execSync("npm run do-install",{cwd:t,env:process.env,stdio:"inherit"})}catch{process.exit(1)}}else for(const e of s){if(g(e))continue;const o=e.endsWith("styles")?"dist":"lib",s=Le(e);try{const n=w.join(t,"node_modules",e),a=w.join(t,"node_modules",e),r=w.join(c,s,o),i=w.join(n,o);if(!b.existsSync(r))continue;b.rmSync(a,{force:!0,recursive:!0}),b.mkdirSync(n,{recursive:!0}),b.rmSync(i,{force:!0,recursive:!0}),b.symlinkSync(w.relative(n,r),i,"dir")}catch(e){process.exit(1)}}}}},e.NpmTokenCommand=class extends te{constructor(){super("NpmTokenCommand",He)}help(){we(this.log,"npm-token","Link token files into every module discovered in .gitmodules.","npm-token [options]",[{flag:"--max-traversal <depth>",description:"How many nested .gitmodules levels to traverse",defaultValue:"2"},{flag:"--token-files <files...>",description:"Token files to link into each selected module",defaultValue:".token,.npmtoken"},{flag:"-h, --help",description:"Show this help text and exit"}],["The command creates symlinks from each selected module back to the token files in the repository root."],["npm-token","npm-token --token-files .token .npmtoken secrets/npm.token"])}async run(e){const t=Number.parseInt(""+(e.maxTraversal||"2"),10),o=(s=e.tokenFiles,Array.isArray(s)?s.map(e=>(""+e).trim()).filter(Boolean):"string"==typeof s&&s.length>0?s.split(",").map(e=>e.trim()).filter(Boolean):[]);var s;const n=o.length>0?o:[".token",".npmtoken"],a=Oe(process.cwd(),Number.isFinite(t)?t:2);for(const e of a){const t=w.join(process.cwd(),e);try{for(const e of n)b.rmSync(w.join(t,e),{force:!0,recursive:!0}),b.symlinkSync(w.join("..",e),w.join(t,e))}catch{process.exit(1)}}}},e.PACKAGE_NAME="@decaf-ts/utils",e.PerformanceRunner=class{constructor(e){this.scenario=e}async run(){this.scenario.initialize&&await this.scenario.initialize();let e=0;const t=this.scenario.phases.map(t=>({phase:t,phaseNumber:++e})),o=[];for(;t.length;){const s=t.shift(),n=s.phase,a=this.mergeContext(n),r=await this.runPhase(n,a);if(o.push(r),n.generator){const a=[...o],i={phaseNumber:s.phaseNumber,phaseName:n.name,iterationCount:n.config.iterations,burstSegments:r.segmentCount,segmentCount:r.segmentCount,mode:n.config.mode,history:a},c=await n.generator({result:r,history:a,metadata:i});if(c){const o="config"in c?{name:c.name??n.name+" \u2192 gen",config:c.config,generator:n.generator}:{name:n.name+" \u2192 gen",config:c,generator:n.generator};t.push({phase:o,phaseNumber:++e})}}}if(await this.logSummary(o),!1!==this.scenario.failOnError){const e=o.reduce((e,t)=>e+t.aggregated.failureCount,0);if(e>0)throw Error(`Scenario "${this.scenario.name}" recorded ${e} failures across ${o.length} phases`)}return o}async runPhase(e,t){await this.runWarmup(e,t);const o=this.buildSegmentIndices(e.config.iterations,e.config.burst),s=[],n=Date.now();for(let n=0;n<o.length;n+=1){const a=o[n];if(!a.length)continue;ae((e.name,o.length,a[0],a[a.length-1]));const r=await this.executeSegment(this.scenario.handler,e.config,t,a);s.push(...r);const i=e.config.burst?.intervalMs;i&&n<o.length-1&&await ne(i)}const a=Date.now()-n,r=[...s].sort((e,t)=>e.iteration-t.iteration),i=this.aggregateMetrics(r);return e.config.pauseAfterMs&&await ne(e.config.pauseAfterMs),{phase:e,config:e.config,iterationMetrics:r,aggregated:i,context:t,segmentCount:o.length,wallClockMs:a}}async runWarmup(e,t){const o=e.config.warmup;if(!o?.iterations)return;const s=o.handler??this.scenario.handler;for(let n=0;n<o.iterations;n+=1)await s({iteration:n,config:e.config,loadFactor:this.computeLoadFactor(e.config,n),context:t}),o.delayBetweenIterationsMs&&n<o.iterations-1&&await ne(o.delayBetweenIterationsMs)}computeLoadFactor(e,t){return((e.loadStart??1)+(e.loadStep??0)*t)*(e.loadMultiplier??1)}buildSegmentIndices(e,t){const o=Math.max(0,e);if(0===o)return[];const s=t?.size&&t.size>0?Math.min(t.size,o):o,n=[];for(let e=0;o>e;e+=s){const t=Math.min(o,e+s);n.push(Array.from({length:t-e},(t,o)=>e+o))}return n}mergeContext(e){const t=this.scenario.baseContext??{},o=e.config.context??{};return this.mergeContexts(t,o)}mergeContexts(e,t){return Object.assign({},e,t)}async executeSegment(e,t,o,s){return s.length?"concurrent"===t.mode?this.collectConcurrent(e,t,o,s):this.collectSequential(e,t,o,s):[]}async collectSequential(e,t,o,s){const n=[],a=t.delayBetweenIterationsMs;for(let r=0;r<s.length;r+=1)n.push(await this.runIteration(e,t,o,s[r])),a&&r<s.length-1&&await ne(a);return n}async collectConcurrent(e,t,o,s){const n=Math.max(1,Math.min(t.concurrency??s.length,s.length)),a=[];let r=0;const i=async()=>{for(;r<s.length;){const n=s[r];r+=1,a.push(await this.runIteration(e,t,o,n))}};return await Promise.all(Array.from({length:n},()=>i())),a}async runIteration(e,t,o,n){const a=this.computeLoadFactor(t,n),r=new s.StopWatch(!0);let i,c=!0;t.metadata,a.toFixed(2);try{const s=await e({iteration:n,config:t,loadFactor:a,context:o});"boolean"==typeof s?.success&&(c=s.success),i=s?.meta}catch(e){c=!1,i={error:e instanceof Error?e.message:e+""}}const l=r.stop();return l.toFixed(2),{iteration:n,durationMs:l,success:c,meta:i,loadFactor:a}}aggregateMetrics(e){if(0===e.length)return{totalDurationMs:0,minMs:0,maxMs:0,averageMs:0,successCount:0,failureCount:0,loadStart:0,loadEnd:0};const t=e.reduce((e,t)=>e+t.durationMs,0),o=Math.min(...e.map(e=>e.durationMs)),s=Math.max(...e.map(e=>e.durationMs)),n=t/e.length,a=e.filter(e=>e.success).length,r=e.length-a,i=e[0]?.loadFactor??0;return{totalDurationMs:t,minMs:o,maxMs:s,averageMs:n,successCount:a,failureCount:r,loadStart:i,loadEnd:e[e.length-1]?.loadFactor??i}}logPhaseTable(e){e.config.iterations,e.wallClockMs,e.phase.name,e.config.mode,e.config.iterations.toString(),e.wallClockMs.toFixed(0),e.aggregated.averageMs.toFixed(2),e.aggregated.minMs.toFixed(2),e.aggregated.maxMs.toFixed(2),e.aggregated.successCount.toString(),e.aggregated.failureCount.toString(),e.aggregated.loadStart.toFixed(2),e.aggregated.loadEnd.toFixed(2)}async logSummary(e){if(!e.length)return;const t=["Phase","Mode","Iterations","Wall ms","RPS","Avg ms","Min ms","Max ms","Success","Failures","Load range"],o=e.map(e=>{const t=(e.config.iterations/(e.wallClockMs/1e3)).toFixed(1);return[e.phase.name,e.config.mode,e.config.iterations.toString(),e.wallClockMs.toFixed(0),t,e.aggregated.averageMs.toFixed(2),e.aggregated.minMs.toFixed(2),e.aggregated.maxMs.toFixed(2),e.aggregated.successCount.toString(),e.aggregated.failureCount.toString(),`${e.aggregated.loadStart.toFixed(2)} \u2192 ${e.aggregated.loadEnd.toFixed(2)}`]});if(this.shouldRenderCanvas()){const e=this.scenario.canvasOutputPath??a.join(process.cwd(),"workdocs","reports","performance-runner.png");await(async(e,t,o,s)=>{const n={...se,...o};let r;try{r=(await import("canvas")).createCanvas}catch(e){return}const i=r(n.width,n.height),c=i.getContext("2d");c.fillStyle=n.backgroundColor,c.fillRect(0,0,n.width,n.height),c.font=n.headerFont,c.fillStyle=n.headerColor;const l=(n.width-2*n.padding)/e.length,d=n.padding+24;e.forEach((e,t)=>{c.fillText(e,n.padding+l*t,d)}),c.font=n.rowFont,c.fillStyle=n.rowColor,t.forEach((e,t)=>{const o=d+12+24*(t+1);e.forEach((e,t)=>{c.fillText(e,n.padding+l*t,o)})}),await(async e=>{await u.mkdir(a.dirname(e),{recursive:!0})})(s),await u.writeFile(s,i.toBuffer("image/png"))})(t,o,this.scenario.canvasOptions??se,e)}}shouldRenderCanvas(){return this.scenario.enableCanvas??!!this.scenario.canvasOptions}},e.RegexpOutputWriter=class extends A{constructor(e,t,o,s="g"){super(e,t);try{this.regexp="string"==typeof o?RegExp(o,s):o}catch(e){throw Error("Invalid regular expression: "+e)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(e){return}return t}testAndResolve(e){const t=this.test(e);t&&this.resolve(t[0])}testAndReject(e){const t=this.test(e);t&&this.reject(t[0])}data(e){super.data(e),this.testAndResolve(e+"")}error(e){super.error(e),this.testAndReject(e+"")}},e.ReleaseChainCommand=class extends te{constructor(){super("ReleaseChain",Object.assign({},k,Ae))}help(){we(this.log,"release-chain","Run the release-chain workflow locally across repositories.","release-chain [options]",[{flag:"--meta <url>",description:"Meta repository URL"},{flag:"--branch <name>",description:"Branch to update downstream repositories",defaultValue:"main or detected branch"},{flag:"--current <owner/repo>",description:"Current repository slug to resume after in the chain"},{flag:"--package <name>",description:"Override detected package name"},{flag:"--token <token>",description:"GitHub token for cloning and pushing"},{flag:"--submodule-file <file>",description:"Override submodule file name"},{flag:"--submodule-path <path>",description:"Use a local submodule file instead of downloading"},{flag:"--target-base <branch>",description:"Base branch for downstream pull requests"},{flag:"-h, --help",description:"Show this help text and exit"}],["Missing meta or branch values are detected from git and environment variables when possible."])}async run(e){const t=e,o=t.package||W(process.cwd())?.name;if(!o)throw Error("Unable to determine package name");const s=t.meta||Re();if(!s)throw Error("A meta repository URL is required");const n=t.branch||Me();await ke({metaRepoUrl:s,branch:n,currentRepo:t.current,packageName:o,token:t.token,submoduleFile:t.submoduleFile||void 0,submodulePath:t.submodulePath||void 0,targetBaseBranch:t.targetBase||void 0})}},e.ReleaseChainDispatchCommand=class extends te{constructor(){super("ReleaseChainDispatch",Object.assign({},k,Ae))}help(){we(this.log,"release-chain-dispatch","Dispatch the release-chain GitHub Actions workflow.","release-chain-dispatch [options]",[{flag:"--meta <url>",description:"Meta repository URL"},{flag:"--branch <name>",description:"Branch to evaluate in downstream repositories",defaultValue:"main or detected branch"},{flag:"--current <owner/repo>",description:"Repository slug that triggered the release chain"},{flag:"--workflow <file>",description:"Workflow file name",defaultValue:"release-chain.yaml"},{flag:"--repo <owner/repo>",description:"Target repository slug where the workflow lives"},{flag:"--token <token>",description:"GitHub token for dispatching workflows"},{flag:"--ref <ref>",description:"Git ref to dispatch the workflow on"},{flag:"--target-base <branch>",description:"Base branch for downstream pull requests"},{flag:"-h, --help",description:"Show this help text and exit"}],["Missing meta or branch values are detected from git and environment variables when possible."])}async run(e){const t=e,o=t.meta||Re();if(!o)throw Error("A meta repository URL is required");const s=t.branch||Me();await De({metaRepoUrl:o,branch:s,workflowFile:t.workflow||"release-chain.yaml",repoSlug:t.repo,currentRepo:t.current,token:t.token,ref:t.ref||s,targetBaseBranch:t.targetBase||void 0})}},e.ReleaseChainRunner=Ce,e.ReleaseScript=class extends te{constructor(){super("ReleaseScript",ve)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release version provided. Prompting for one:"),t.info("Listing latest git tags:"),await j("git tag --sort=-taggerdate | head -n 5").promise,await C.insistForText("tag","Enter the new tag number (accepts v*.*.*[-...])",e=>!!e.toString().match(/^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9a-zA-Z-]+)?$/)))}testVersion(t){const o=this.log.for(this.testVersion);switch(t=t.trim().toLowerCase()){case e.SemVersion.PATCH:case e.SemVersion.MINOR:case e.SemVersion.MAJOR:return o.verbose("Using provided SemVer update: "+t,1),t;default:return o.verbose("Testing provided version for SemVer compatibility: "+t,1),RegExp(E).test(t)?(o.verbose("version approved: "+t,1),t):void o.debug("Invalid version number: "+t)}}async prepareMessage(e){const t=this.log.for(this.prepareMessage);return e||(t.verbose("No release message provided. Prompting for one"),await C.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}help(){we(this.log,"tag-release","Prepare, tag, and publish a release from the current repository.","tag-release [options]",[{flag:"--tag <version>",description:"Release tag to use"},{flag:"--message <text>",description:"Release message or ticket reference"},{flag:"--ci <true|false>",description:"Whether to treat the run as CI",defaultValue:"true"},{flag:"--version",description:"Print the package version and exit"},{flag:"-h, --help",description:"Show this help text and exit"}],["If tag or message are omitted, the command prompts interactively.","A successful run updates the package version, creates a git tag, pushes tags, and optionally publishes to npm."],['tag-release --tag v1.2.3 --message "Release 1.2.3"','tag-release --tag patch --message "Fix release"'])}async run(e){let t;const{ci:o}=e;let{tag:s,message:n}=e;s=await this.prepareVersion(s),n=await this.prepareMessage(n),t=await j(`npm run prepare-release -- ${s} ${n}`,{cwd:process.cwd()}).promise,t=await j("git status --porcelain").promise,await t,t.logs.length&&await C.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await j("git add .").promise,await j(`git commit -m "${s} - ${n} - after release preparation${o?"":N}"`).promise),await j(`npm version "${s}" -m "${n}${o?"":N}"`).promise,await j("git push --follow-tags").promise,o||await j("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}},e.RunAllCommand=class extends te{constructor(){super("RunAllCommand",We)}help(){we(this.log,"run-all","Run a shell command in every module listed in .gitmodules.","run-all [options] --command <cmd>",[{flag:"--base-path <path>",description:"Directory to read .gitmodules from",defaultValue:"current working directory"},{flag:"--command <cmd>",description:"Shell command to execute in each module"},{flag:"-h, --help",description:"Show this help text and exit"}],["The command fails fast if any module invocation fails."],["run-all --command npm test","run-all --base-path ../repo --command npm run lint"])}async run(e){const t="string"==typeof e.basePath&&e.basePath.trim().length>0?e.basePath.trim():process.cwd(),o="string"==typeof e.command?e.command.trim():"";if(0===o.length)throw Error("run-all requires a command to execute");const s=je(t);for(const e of s){const s=w.join(t,e);if(b.existsSync(s))try{S.execSync(o,{cwd:s,env:process.env,stdio:"inherit"})}catch{process.exit(1)}}}},e.SemVersionRegex=E,e.SetupScriptKey="postinstall",e.StandardOutputWriter=A,e.TagReleaseCommand=class extends te{constructor(){super("TagReleaseCommand",qe)}async ensureReleaseBranch(e=!1){if(e)return;const t=S.execSync("git rev-parse --abbrev-ref HEAD",{cwd:process.cwd(),encoding:"utf8"}).trim();if("master"!==t&&"main"!==t)throw Error("release must be run from 'master' or 'main' branch. Current branch: "+t)}async prepareTag(e){return(e=(""+(e||"")).trim()).length>0?e:(S.execSync("git tag --sort=-taggerdate | head -n 5",{cwd:process.cwd(),stdio:"inherit"}),C.insistForText("tag","What should be the new tag? (accepts v*.*.*[-...])",e=>!!e.toString().match(/^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9a-zA-Z-]+)?$/)))}async prepareMessage(e){return(e=(""+(e||"")).trim()).length>0?e:C.insistForText("message","Tag Message",e=>!!e&&e.toString().length>0)}hasToken(e){try{return b.statSync(w.join(process.cwd(),e)).size>0}catch{return!1}}readToken(e){return b.readFileSync(w.join(process.cwd(),e),"utf8").trim()}help(){we(this.log,"tag-release","Prepare a release, create a git tag, push, and optionally publish to npm.","tag-release [options] [tag] [message]",[{flag:"--public",description:"Publish to the public npm registry",defaultValue:"false"},{flag:"--private",description:"Publish to the restricted npm registry",defaultValue:"false"},{flag:"--git-token <file>",description:"File containing the token used for authenticated git pushes",defaultValue:".token"},{flag:"--npm-token <file>",description:"File containing the token used for npm publish",defaultValue:".npmtoken"},{flag:"--git-user <name>",description:"Git user name embedded in authenticated pushes"},{flag:"--allow-from-branch",description:"Skip the master/main branch guard",defaultValue:"false"},{flag:"--tag <version>",description:"Release tag to create"},{flag:"--message <text>",description:"Release message to use"},{flag:"-h, --help",description:"Show this help text and exit"}],["If tag or message are omitted, the command prompts interactively.","The command uses .token for git pushes and .npmtoken for npm publish unless overridden."],['tag-release --public --tag v1.2.3 --message "Release 1.2.3"',"tag-release --private --allow-from-branch --tag v1.2.3"])}async run(e){await this.ensureReleaseBranch(!0===e.allowFromBranch);const t=!0===e.private?"private":"public",o=await this.prepareTag(e.tag),s=await this.prepareMessage(e.message),n=""+(e.gitToken||".token"),a=""+(e.npmToken||".npmtoken"),r="string"==typeof e.gitUser&&e.gitUser.trim().length>0?e.gitUser.trim():S.execSync("git config user.name",{cwd:process.cwd(),encoding:"utf8"}).trim();S.execSync("npm run prepare-release",{cwd:process.cwd(),stdio:"inherit"}),S.execSync("git status --porcelain",{cwd:process.cwd(),encoding:"utf8"}).trim().length>0&&(S.execSync("git add .",{cwd:process.cwd(),stdio:"inherit"}),S.execSync(`git commit -m "${o} - ${s} - after release preparation"`,{cwd:process.cwd(),stdio:"inherit"})),S.execSync(`npm version "${o}" -m "${s}"`,{cwd:process.cwd(),stdio:"inherit"});const i=S.execSync("git remote get-url origin",{cwd:process.cwd(),encoding:"utf8"}).trim();if(this.hasToken(n)){const e=S.execSync("git rev-parse --abbrev-ref HEAD",{cwd:process.cwd(),encoding:"utf8"});let t="";try{t=S.execSync("git rev-parse --abbrev-ref --symbolic-full-name '@{u}'",{cwd:process.cwd(),encoding:"utf8"})}catch{t=""}const o=this.readToken(n);if(S.execSync(`git push "https://${r}:${o}@${i.replace(/^https:\/\//,"")}" --follow-tags`,{cwd:process.cwd(),stdio:"inherit"}),t.trim().length>0)try{S.execSync(`git branch --set-upstream-to="${t.trim()}" "${e.trim()}"`,{cwd:process.cwd(),stdio:"inherit"})}catch{}}else S.execSync("git push --follow-tags",{cwd:process.cwd(),stdio:"inherit"});const c="public"===t?"public":"restricted";if(s.endsWith(N)&&this.hasToken(a)){const e=this.readToken(a);S.execSync(`NPM_TOKEN="${e}" npm publish --access "${c}"`,{cwd:process.cwd(),stdio:"inherit"})}}},e.UserInput=C,e.VERSION="1.5.4",e.chainAbortController=R,e.copyFile=V,e.defaultCanvasOptions=se,e.deletePath=H,e.dispatchReleaseChainWorkflow=De,e.getAllFiles=_,e.getDependencies=J,e.getFileSizeZipped=z,e.getPackage=W,e.getPackageDependencies=ce,e.getPackageVersion=q,e.getSlogan=ee,e.installDependencies=G,e.installIfNotAvailable=async(e,t)=>{e="string"==typeof e?[e]:e;const o={prod:t?.prod?[...t.prod]:[],dev:t?.dev?[...t.dev]:[],peer:t?.peer?[...t.peer]:[]},s=new Set([...o.prod??[],...o.dev??[],...o.peer??[]]),n=[];for(const t of e)if(!s.has(t))try{P.resolve(t),s.add(t)}catch{n.push(t)}if(n.length){"test"===process.env.NODE_ENV||void 0!==process.env.JEST_WORKER_ID?O.verbose("Skipping dependency install in test environment for: "+n.join(", ")):await G({dev:n});const e=new Set(o.dev??[]);n.forEach(t=>e.add(t)),o.dev=Array.from(e)}return o},e.listFolder=function e(t=process.cwd(),o){const s=O.for(e);try{return n.existsSync(t)?n.readdirSync(t,{withFileTypes:!0}).filter(e=>!o||o(e.name,e)).map(e=>e.name):[]}catch(e){return s.verbose(`Failed to list folder ${t}: ${e}`),[]}},e.listNodeModulesPackages=X,e.lockify=e=>{let t=Promise.resolve();return(...o)=>{const s=t.then(()=>e(...o));return t=s.catch(()=>{}),s}},e.normalizeImport=async e=>e.then(e=>e.default||e),e.packageToGlobal=ie,e.parseList=re,e.patchFile=B,e.printBanner=Q,e.pushToGit=async function e(){const t=O.for(e),o=await j("git config user.name").promise,s=await j("git config user.email").promise;t.verbose(`cached git id: ${o}/${s}. changing to automation`),await j('git config user.email "automation@decaf.ts"').promise,await j('git config user.name "decaf"').promise,t.info("Pushing changes to git..."),await j("git add .").promise,await j('git commit -m "refs #1 - after repo setup"').promise,await j("git push").promise,await j(`git config user.email "${s}"`).promise,await j(`git config user.name "${o}"`).promise,t.verbose(`reverted to git id: ${o}/${s}`)},e.readFile=L,e.readGitModules=je,e.readGitModulesDeep=Oe,e.renameFile=async function e(t,o){const s=O.for(e);let a,r;try{a=n.statSync(t)}catch(e){throw s.verbose(`Source path "${t}" does not exist: ${e}`),Error(`Source path "${t}" does not exist: ${e}`)}try{r=n.statSync(o)}catch(e){}if(r)throw s.verbose(`Destination path "${o}" already exists`),Error(`Destination path "${o}" already exists`);try{s.verbose(`Renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}...`),n.renameSync(t,o),s.verbose(`Successfully renamed to "${o}"`)}catch(e){throw s.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}": ${e}`),Error(`Error renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}": ${e}`)}},e.runCommand=j,e.runReleaseChain=ke,e.setPackageAttribute=(e,t,o=process.cwd())=>{const s=W(o);s[e]=t,U(a.join(o,"package.json"),JSON.stringify(s,null,2))},e.spawnCommand=M,e.updateDependencies=async function e(){const t=O.for(e);t.info("checking for updates..."),await j("npx npm-check-updates -u").promise,t.info("updating..."),await j("npx npm run do-install").promise},e.writeFile=U},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prompts"),require("util"),require("@decaf-ts/logging"),require("fs"),require("path"),require("module"),require("child_process"),require("styled-string-builder"),require("shell-quote"),require("zlib"),require("https"),require("fs/promises"),require("@rollup/plugin-typescript"),require("@rollup/plugin-commonjs"),require("@rollup/plugin-node-resolve"),require("@rollup/plugin-json"),require("typescript"),require("node:child_process"),require("node:fs"),require("node:path")):"function"==typeof define&&define.amd?define(["exports","prompts","util","@decaf-ts/logging","fs","path","module","child_process","styled-string-builder","shell-quote","zlib","https","fs/promises","@rollup/plugin-typescript","@rollup/plugin-commonjs","@rollup/plugin-node-resolve","@rollup/plugin-json","typescript","node:child_process","node:fs","node:path"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).utils={},e.prompts,e.util,e.decafTsLogging,e.fs,e.path,e.module,e.childProcess,e.styledStringBuilder,e.shellQuote,e.zlib,e.https,e.fsPromises,e.rollupPluginTypescript,e.rollupPluginCommonjs,e.rollupPluginNodeResolve,e.rollupPluginJson,e.typescript,e.node_child_process,e.fs$1,e.path$1);
1
+ var e,t;e=this,t=function(e,t,o,s,n,a,r,i,c,l,d,g,u,h,f,p,m,y,S,b,w){"use strict";function v(e){var t=Object.create(null);return e&&Object.keys(e).forEach(o=>{if("default"!==o){var s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}),t.default=e,Object.freeze(t)}var T=v(y);class C{static{this.logger=s.Logging.for(C)}constructor(e){this.type="text",this.name=e}setType(e){return C.logger.verbose("Setting type to: "+e),this.type=e,this}setMessage(e){return C.logger.verbose("Setting message to: "+e),this.message=e,this}setInitial(e){return C.logger.verbose("Setting initial value to: "+e),this.initial=e,this}setStyle(e){return C.logger.verbose("Setting style to: "+e),this.style=e,this}setFormat(e){return C.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return C.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return C.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return C.logger.verbose("Setting min value to: "+e),this.min=e,this}setMax(e){return C.logger.verbose("Setting max value to: "+e),this.max=e,this}setFloat(e){return C.logger.verbose("Setting float to: "+e),this.float=e,this}setRound(e){return C.logger.verbose("Setting round to: "+e),this.round=e,this}setInstructions(e){return C.logger.verbose("Setting instructions to: "+e),this.instructions=e,this}setIncrement(e){return C.logger.verbose("Setting increment to: "+e),this.increment=e,this}setSeparator(e){return C.logger.verbose("Setting separator to: "+e),this.separator=e,this}setActive(e){return C.logger.verbose("Setting active style to: "+e),this.active=e,this}setInactive(e){return C.logger.verbose("Setting inactive style to: "+e),this.inactive=e,this}setChoices(e){return C.logger.verbose("Setting choices: "+JSON.stringify(e)),this.choices=e,this}setHint(e){return C.logger.verbose("Setting hint to: "+e),this.hint=e,this}setWarn(e){return C.logger.verbose("Setting warn to: "+e),this.warn=e,this}setSuggest(e){return C.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return C.logger.verbose("Setting limit to: "+e),this.limit=e,this}setMask(e){return C.logger.verbose("Setting mask to: "+e),this.mask=e,this}setStdout(e){return C.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await C.ask(this))[this.name]}static async ask(e){const o=C.logger.for(this.ask);let s;Array.isArray(e)||(e=[e]);try{o.verbose("Asking questions: "+e.map(e=>e.name).join(", ")),s=await t(e),o.verbose("Received answers: "+JSON.stringify(s,null,2))}catch(e){throw Error("Error while getting input: "+e)}return s}static async askNumber(e,t,o,s,n){C.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${s}, initial: ${n}`);const a=new C(e).setMessage(t).setType("number");return"number"==typeof o&&a.setMin(o),"number"==typeof s&&a.setMax(s),"number"==typeof n&&a.setInitial(n),(await this.ask(a))[e]}static async askText(e,t,o=void 0,s){C.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${s}`);const n=new C(e).setMessage(t);return o&&n.setMask(o),"string"==typeof s&&n.setInitial(s),(await this.ask(n))[e]}static async askConfirmation(e,t,o){C.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const s=new C(e).setMessage(t).setType("confirm");return void 0!==o&&s.setInitial(o),(await this.ask(s))[e]}static async insist(e,t,o,s=1){const n=C.logger.for(this.insist);let a;n.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${s}`);let r,i=0;try{do{a=(await C.ask(e))[e.name],t(a)?(r=await C.askConfirmation(e.name+"-confirm",`Is the ${e.type} correct?`,o),r||(a=void 0)):a=void 0}while(void 0===a&&s>1&&i++<s)}catch(e){throw n.error("Error while insisting: "+e),e}return void 0===a&&n.info("no selection..."),a}static async insistForText(e,t,o,s=void 0,n,a=!1,r=-1){C.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${s}, initial: ${n}, defaultConfirmation: ${a}, limit: ${r}`);const i=new C(e).setMessage(t);return s&&i.setMask(s),"string"==typeof n&&i.setInitial(n),await this.insist(i,o,a,r)}static async insistForNumber(e,t,o,s,n,a,r=!1,i=-1){C.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${s}, max: ${n}, initial: ${a}, defaultConfirmation: ${r}, limit: ${i}`);const c=new C(e).setMessage(t).setType("number");return"number"==typeof s&&c.setMin(s),"number"==typeof n&&c.setMax(n),"number"==typeof a&&c.setInitial(a),await this.insist(c,o,r,i)}static parseArgs(e){const t=C.logger.for(this.parseArgs),s={args:process.argv.slice(2),options:e};t.debug("Parsing arguments: "+JSON.stringify(s,null,2));try{return o.parseArgs(s)}catch(o){throw t.debug(`Error while parsing arguments:\n${JSON.stringify(s,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${o}`),Error("Error while parsing arguments: "+o)}}}const k={verbose:{type:"boolean",short:"V",default:void 0},version:{type:"boolean",short:"v",default:void 0},help:{type:"boolean",short:"h",default:!1},logLevel:{type:"string",default:"info"},logStyle:{type:"boolean",default:!0},timestamp:{type:"boolean",default:!0},banner:{type:"boolean",default:!0}},D=Object.keys(k).reduce((e,t)=>(e[t]=k[t].default,e),{}),$="utf-8",E=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z])))/g;var x;e.SemVersion=void 0,(x=e.SemVersion||(e.SemVersion={})).PATCH="patch",x.MINOR="minor",x.MAJOR="major";const N="-no-ci";var F;e.Tokens=void 0,(F=e.Tokens||(e.Tokens={})).GIT=".token",F.NPM=".npmtoken",F.DOCKER=".dockertoken",F.CONFLUENCE=".confluence-token";const I="Aborted";class A{constructor(e,t,...o){this.cmd=e,this.lock=t,this.logger=s.Logging.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString($):t;const o="stderr"===e?c.style(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",e+"")}error(e){this.log("stderr",e+"")}errors(e){this.log("stderr","Error executing command exited : "+e)}exit(e,t){this.log("stdout","command exited code : "+(0===e?c.style(e.toString()).green.text:c.style(null===e?"null":e.toString()).red.text)),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){if(Array.isArray(e))return this.cmd=e.join(" "),[e[0],e.slice(1)];const t=l.parse(e).filter(e=>"string"==typeof e).map(String);return this.cmd=t.join(" "),[t[0],t.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${c.style(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=Error("number"==typeof e?"Exit code "+e:e)),this.log("stderr",`${this.cmd} failed to execute: ${c.style(e.message).red}`),this.lock.reject(e)}}function R(e,...t){let o,s;if(e instanceof AbortSignal?(s=new AbortController,o=[e,...t]):(s=e,o=t),s.signal.aborted)return s;const n=()=>s.abort();for(const e of o){if(e.aborted){s.abort();break}e.addEventListener("abort",n,{once:!0,signal:s.signal})}return s}function M(e,t,o,s,n){function a(t,s){const[a,r]=e.parseCommand(t);n.info("Running command: "+a),n.debug("with args: "+r.join(" "));const c=i.spawn(a,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:s.signal});return n.verbose("pid : "+c.pid),c}const r=t.match(/[<>$#]/g);if(r)throw Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],n=Array(e.length);n[0]=s;for(let t=0;t<e.length;t++)0!==t&&(n[t]=R(n[t-1].signal)),o.push(a(e[t],n[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return a(t,s)}function j(e,t={},o=A,...n){const a=s.Logging.for(j),r=new AbortController,i={abort:r,command:e,logs:[],errs:[]},c=new Promise((s,c)=>{let l;try{l=new o(e,{resolve:s,reject:c},...n),i.cmd=M(l,e,t,r,a)}catch(t){return c(Error(`Error running command ${e}: ${t}`))}i.cmd.stdout.setEncoding("utf8"),i.cmd.stdout.on("data",e=>{e=e.toString(),i.logs.push(e),l.data(e)}),i.cmd.stderr.on("data",e=>{e=e.toString(),i.errs.push(e),l.error(e)}),i.cmd.once("error",e=>{l.exit(e.message,i.errs)}),i.cmd.once("exit",(e=0)=>{r.signal.aborted&&null===e&&(e=I),l.exit(e,0===e?i.logs:i.errs)})});return Object.assign(i,{promise:c,pipe:async t=>{const o=a.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const s=await c;return o.verbose(`Piping output to ${t.name}: ${s}`),t(s)}catch(e){throw o.error("Error piping command output: "+e),e}}}),i}const O=s.Logging.for("fs"),P=r.createRequire(process.cwd()+"/package.json");function B(e,t,o){const a=O.for(B);if(!n.existsSync(e))throw Error(`File not found at path "${e}".`);let r=L(e);a.verbose(`Patching file "${e}"...`),a.debug("with value: "+JSON.stringify(t));try{r=((e,t,o="g",n)=>(Object.entries(t).forEach(([t,a])=>{const r=RegExp(s.escapeRegExp(t),o);e=e.replace(r,e=>(!n||n(e),a))}),e))(r,t,"g",o)}catch(e){throw Error("Error patching file: "+e)}U(e,r)}function L(e){const t=O.for(L);try{return t.verbose(`Reading file "${e}"...`),n.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),Error(`Error reading file "${e}": ${o}`)}}function U(e,t){const o=O.for(U);try{o.verbose(`Writing file "${e} with ${t.length} bytes...`),n.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),Error(`Error writing file "${e}": ${t}`)}}function _(e,t){const o=O.for(_),s=[];try{return o.verbose(`Retrieving all files from "${e}"...`),n.readdirSync(e).forEach(t=>{const o=a.join(e,t),r=n.statSync(o);r.isFile()?s.push(o):r.isDirectory()&&s.push(..._(o))}),t?s.filter(t):s}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),Error(`Error retrieving files from "${e}": ${t}`)}}function V(e,t){const o=O.for(V);let s,a;try{s=n.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),Error(`Source path "${e}" does not exist: ${t}`)}try{a=n.statSync(t)}catch(e){s.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),n.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${s.isFile()?"file":"directory"} "${e}" to "${t}...`),n.cpSync(e,t,{recursive:!0})}catch(n){throw o.verbose(`Error copying ${s.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`),Error(`Error copying ${s.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`)}}function H(e){const t=O.for(H);try{const o=n.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),n.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&n.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),Error(`Error Deleting "${e}": ${o}`)}}function W(e=process.cwd(),t){let o;try{o=JSON.parse(L(a.join(e,"package.json")))}catch(e){throw Error('Failed to retrieve package information" '+e)}if(t){if(!(t in o))throw Error(`Property "${t}" not found in package.json`);return o[t]}return o}function q(e=process.cwd()){return W(e,"version")}async function J(e=process.cwd()){const t=a.join(e,"package.json"),o=a.join(e,"package-lock.json");let s,r;try{s=JSON.parse(L(t))}catch(e){throw Error(`Could not read package.json at ${t}: ${e}`)}if(n.existsSync(o))try{r=JSON.parse(L(o))}catch(e){O.warn(`Unable to parse package-lock.json at ${o}: ${e}`)}const i=(e={})=>Object.entries(e).map(([e,t])=>({name:e,version:K(r,e,t)}));return{prod:i(s.dependencies),dev:i(s.devDependencies),peer:i(s.peerDependencies)}}function K(e,t,o){if(e){const s=e.packages||{},n="node_modules/"+t;if(s[n]&&s[n].version)return s[n].version;if(e.dependencies&&e.dependencies[t])return e.dependencies[t].version||o}return o}async function G(e){const t=O.for(G),o=e.prod||[],s=e.dev||[],n=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await j("npm install "+o.join(" "),{cwd:process.cwd()}).promise),s.length&&(t.info(`Installing devDependencies ${s.join(", ")}...`),await j("npm install --save-dev "+s.join(" "),{cwd:process.cwd()}).promise),n.length&&(t.info(`Installing peerDependencies ${n.join(", ")}...`),await j("npm install --save-peer "+n.join(" "),{cwd:process.cwd()}).promise)}async function z(e){const t=O.for(z);try{const o=n.readdirSync(e).map(t=>a.join(e,t)).filter(e=>{try{return n.statSync(e).isFile()&&(e.endsWith(".js")||e.endsWith(".cjs")||e.endsWith(".mjs"))}catch{return!1}});if(0===o.length)throw Error("No JS files found in directory "+e);let s=o[0],r=n.statSync(s).size;for(const e of o.slice(1)){const t=n.statSync(e).size;r>t&&(s=e,r=t)}t.verbose(`Selected smallest bundle: ${s} (${r} bytes)`);const i=n.readFileSync(s),c=d.gzipSync(i),l=Number((c.length/1024).toFixed(1));return t.verbose(`Gzipped size: ${c.length} bytes (${l} KB)`),l}catch(o){throw t.verbose(`Failed to compute gzipped size for ${e}: ${o}`),o}}function X(e=a.join(process.cwd(),"node_modules")){const t=O.for(X);try{if(!n.existsSync(e))return[];const o=n.readdirSync(e,{withFileTypes:!0}),s=[];for(const r of o)try{if(!r.isDirectory())continue;if(r.name.startsWith("."))continue;if(r.name.startsWith("@")){const o=a.join(e,r.name);try{const e=n.readdirSync(o,{withFileTypes:!0});for(const t of e)t.isDirectory()&&!t.name.startsWith(".")&&s.push(`${r.name}/${t.name}`)}catch(e){t.verbose(`Failed to read scope ${o}: ${e}`)}}else s.push(r.name)}catch(e){t.verbose(`Skipping entry ${r.name} due to error: ${e}`)}return s}catch(o){return t.verbose(`Failed to list node_modules packages at ${e}: ${o}`),[]}}const Y=[{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That's Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"No caffeine, no chaos. Just clean code.",Tags:"Coffee-themed, Calm, Tech"},{Slogan:"Full flavor, no jitters. That\u2019s Decaf-TS.",Tags:"Coffee-themed, Cheerful"},{Slogan:"Chill fullstack. Powered by Decaf.",Tags:"Coffee-themed, Fun, Tech"},{Slogan:"Decaf-TS: Brewed for calm code.",Tags:"Coffee-themed, Branding"},{Slogan:"Smooth as your morning Decaf.",Tags:"Coffee-themed, Chill"},{Slogan:"All the kick, none of the crash.",Tags:"Coffee-themed, Energetic"},{Slogan:"Sip back and ship faster.",Tags:"Coffee-themed, Fun"},{Slogan:"Keep calm and code Decaf.",Tags:"Coffee-themed, Playful"},{Slogan:"Code without the caffeine shakes.",Tags:"Coffee-themed, Humorous"},{Slogan:"Your fullstack, decaffeinated.",Tags:"Coffee-themed, Technical"},{Slogan:"Decaf-TS: Where smart contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No CRUD, no problem \u2014 Decaf your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS: Your frontend already understands your smart contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye CRUD, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From smart contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No CRUD. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"},{Slogan:"Decaf-TS-TS: Where blockchain contracts meet smart interfaces.",Tags:"Blockchain, Smart Contracts, Tech"},{Slogan:"Ship dApps without the stress.",Tags:"Blockchain, Cheerful, Developer"},{Slogan:"No boilerplate, no problem \u2014 Decaf-TS your data.",Tags:"Data, No-CRUD, Chill"},{Slogan:"From DID to UI, without breaking a sweat.",Tags:"DID, SSI, UI, Calm"},{Slogan:"Decaf-TS-TS: Your frontend already understands your blockchain contract.",Tags:"Smart Contracts, DX, Magic"},{Slogan:"Self-sovereign by design. Productive by default.",Tags:"SSI, Developer, Calm"},{Slogan:"Build once. Deploy everywhere. Decentralized and delightful.",Tags:"Blockchain, Multi-platform, Happy"},{Slogan:"Data that defines its own destiny.",Tags:"SSI, Data-driven, Empowerment"},{Slogan:"Goodbye boilerplate, hello intent-based interfaces.",Tags:"No-CRUD, UI, Technical"},{Slogan:"The smoothest path from DID to done.",Tags:"DID, Workflow, Chill"},{Slogan:"Because your dApp deserves more than boilerplate.",Tags:"Blockchain, DevX, Efficiency"},{Slogan:"Own your data. Own your flow.",Tags:"SSI, Control, Ownership"},{Slogan:"Write logic like it belongs with the data \u2014 because it does.",Tags:"Data Logic, Developer, Smart"},{Slogan:"From blockchain contracts to smarter frontends.",Tags:"Smart Contracts, UI, DX"},{Slogan:"No caffeine. No boilerplate. Just the future.",Tags:"No-CRUD, Coffee-themed, Futuristic"},{Slogan:"The future of web3 UX is Decaf-TS.",Tags:"Blockchain, UX, Vision"},{Slogan:"Code with confidence. Govern with clarity.",Tags:"Blockchain, Governance, Calm"},{Slogan:"Interfaces that obey the data, not the other way around.",Tags:"UI, Data Logic, Self-aware"},{Slogan:"Brew business logic right into your bytes.",Tags:"Data Logic, Coffee-themed, Fun"},{Slogan:"DIDs done differently \u2014 and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],Z=["\x1b[38;5;215m","\x1b[38;5;209m","\x1b[38;5;205m","\x1b[38;5;210m","\x1b[38;5;217m","\x1b[38;5;216m","\x1b[38;5;224m","\x1b[38;5;230m","\x1b[38;5;230m"];function Q(e){const t=ee(),o="# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# ( ( \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# ) ) \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# [=======] \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n# `-----\xb4 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \n# \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591\u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2593\u2592\u2591 \u2591\u2592\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2591 \n#".split("\n"),s=o.reduce((e,t)=>Math.max(e,t.length),0);o.push("# "+t.padStart(s-3)),o.forEach((t,o)=>{(e?e.info.bind(e):(()=>{}).bind())(c.style(t||"").raw(Z[o]).text)})}function ee(e){try{return e=void 0===e?Math.floor(Math.random()*Y.length):e,Y[e].Slogan}catch(e){throw Error("Failed to retrieve slogans: "+e)}}class te extends s.LoggedClass{constructor(e,t={},o=[]){super(),this.name=e,this.inputs=t,this.requirements=o,te.log||Object.defineProperty(te,"log",{writable:!1,value:s.Logging.for(te.name)}),this.inputs=Object.assign({},k,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await J(),s=[],n=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)n.includes(e)||s.push(e);s.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=C.parseArgs(this.inputs),t=s.LoggedEnvironment.accumulate(D).accumulate(e.values),{version:o,help:n,banner:a}=t;if(o)return q();if(n)return this.help(e);let r;a&&Q(this.log.for(Q,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{r=await this.run(t)}catch(e){throw e}return r}}class oe{static{this.log=s.Logging.for(oe)}static async downloadFile(e){return new Promise((t,o)=>{!function e(s){s=encodeURI(s),g.get(s,n=>{if(301===n.statusCode||307===n.statusCode)return e(n.headers.location);if(200!==n.statusCode)return oe.log.error(`Failed to fetch ${s} (status: ${n.statusCode})`),o(Error("Failed to fetch "+s));let a="";n.on("data",e=>{a+=e}),n.on("error",e=>{o(e)}),n.on("end",()=>{t(a)})})}(e)})}}const se={width:1200,height:260,padding:32,backgroundColor:"#0f172a",headerFont:"bold 18px 'Segoe UI', sans-serif",rowFont:"14px 'Segoe UI', sans-serif",headerColor:"#f8fafc",rowColor:"#cbd5f5"},ne=e=>new Promise(t=>setTimeout(t,e)),ae=(process.env.PERF_VERBOSE,(...e)=>{});function re(e){return e?Array.isArray(e)?e.map(e=>(""+e).trim()).filter(Boolean):(""+e).split(",").map(e=>e.trim()).filter(Boolean):[]}function ie(e){return e.replace(/^@/,"").split(/[/\-_.]+/).filter(Boolean).map((e,t)=>0===t?e.replace(/[^a-zA-Z0-9]/g,""):`${e.charAt(0).toUpperCase()}${e.slice(1)}`).join("")}function ce(){let e;try{e=W(process.cwd())}catch{e=void 0}try{if(!e||!(Object.keys(e.dependencies||{}).length>0||Object.keys(e.devDependencies||{}).length>0||Object.keys(e.peerDependencies||{}).length>0)){const t=a.resolve(__dirname,"../../..");try{e=W(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),s=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...s]))}const le="##VERSION##",de="##COMMIT##",ge="##FULL_VERSION##",ue="##PACKAGE##",he="##PACKAGE_SIZE##";var fe,pe,me;(e=>{e.CJS="commonjs",e.ESM="es2022"})(fe||(fe={})),(e=>{e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"})(pe||(pe={})),(e=>{e.ESM="esm",e.CJS_CHECK="cjs-check",e.TYPES="types",e.NODE_NEXT_VALIDATE="nodenext-validate",e.BUNDLE="bundle"})(me||(me={}));const ye={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:pe.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},entry:{type:"string",default:"./src/index.ts"},banner:{type:"boolean",default:!1},validateNodeNext:{type:"boolean",default:!1}},Se=(e=".cjs")=>{const t=be.log.for(Se),o=new Map;return s=>r=>{const i=a.dirname(r.fileName);function c(s){const r=JSON.stringify([i,s]),c=o.get(r);if(null!=c)return c;let l,d=s;try{d=a.resolve(i,d+".ts")}catch(e){throw Error(`Failed to resolve path ${s}: ${e}`)}try{l=n.statSync(d)}catch(e){try{t.verbose(`Testing existence of path ${d} as a folder defaulting to index file`),l=n.statSync(d.replace(/\.ts$/gm,""))}catch(t){throw Error(`Failed to resolve path ${s}: ${e}, ${t}`)}}if(l.isDirectory()&&(d=d.replace(/\.ts$/gm,"/index.ts")),a.isAbsolute(d)){const t=(/\.tsx?$/.exec(a.basename(d))||[])[0]||void 0;d="./"+a.relative(i,a.resolve(a.dirname(d),a.basename(d,t)+e))}return o.set(r,d),d}function l(e){return!(!e.startsWith("./")&&!e.startsWith("../"))&&""===a.extname(e)}return T.visitNode(r,function e(t){if((e=>!(!T.isImportDeclaration(e)&&!T.isExportDeclaration(e))&&void 0!==e.moduleSpecifier&&!!T.isStringLiteral(e.moduleSpecifier)&&l(e.moduleSpecifier.text))(t)){if(T.isImportDeclaration(t)){const e=c(t.moduleSpecifier.text),o=s.factory.createStringLiteral(e);return s.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(T.isExportDeclaration(t)){const e=c(t.moduleSpecifier.text),o=s.factory.createStringLiteral(e);return s.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}else if(T.isCallExpression(t)){const e=(e=>(e=>e.expression.kind===T.SyntaxKind.ImportKeyword)(e)&&e.arguments.length>0&&T.isStringLiteral(e.arguments[0])||T.isIdentifier(e.expression)&&"require"===e.expression.text&&e.arguments.length>0&&T.isStringLiteral(e.arguments[0])?e.arguments[0]:void 0)(t);if(e&&l(e.text)){const o=c(e.text),n=s.factory.createStringLiteral(o),a=t.arguments.map((e,t)=>0===t?n:e);return s.factory.updateCallExpression(t,t.expression,t.typeArguments,s.factory.createNodeArray(a))}}return T.visitEachChild(t,e,s)})}};class be extends te{constructor(){super("BuildScripts",Object.assign({},k,ye)),this.replacements={};const e=W(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o;try{this.commitHash=i.execSync("git rev-parse --short HEAD",{encoding:"utf8"}).trim()}catch{this.commitHash="unknown"}this.fullVersion=`${this.pkgVersion}-${this.commitHash}`,this.replacements[le]=this.pkgVersion,this.replacements[de]=this.commitHash,this.replacements[ge]=this.fullVersion,this.replacements[ue]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:s}=W();t.info(`Patching ${o} ${s} module in ${e}...`);const r=n.statSync(e),i=e=>{let t=e;return t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.VERSION\s*=\s*["'])##VERSION##(["'])/gm,`$1${s}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.COMMIT\s*=\s*["'])##COMMIT##(["'])/gm,`$1${this.commitHash}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.FULL_VERSION\s*=\s*["'])##FULL_VERSION##(["'])/gm,`$1${this.fullVersion}$2`),t=t.replace(/((?:^|[\s;,(])(?:const|let|var)\s+PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t=t.replace(/((?:^|[\s;,(])(?:exports|module\.exports)\.PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t=t.replace(/((?:^|[\s;,(])\w+\.PACKAGE_NAME\s*=\s*["'])##PACKAGE##(["'])/gm,`$1${o}$2`),t};r.isDirectory()&&n.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>{const t=a.join(e.parentPath,e.name),o=n.readFileSync(t,"utf8"),s=i(o);s!==o&&n.writeFileSync(t,s,"utf8"),B(t,Object.entries(this.replacements).reduce((e,[t,o])=>([le,de,ge,ue].includes(t)||(e[t]=o),e),{}))}),t.verbose(`Module ${o} ${s} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);try{this.log[t](o)}catch(e){throw e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:s}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${s+1})`}return t+=": "+T.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=n.readFileSync(e).toString(),o=T.parseConfigFileTextToJson(e,t),r=o.config;r||this.reportDiagnostics([o.error],s.LogLevel.error);const i=T.parseJsonConfigFileContent(r,T.sys,a.dirname(e));return i.errors.length>0&&this.reportDiagnostics(i.errors,s.LogLevel.error),i}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===T.DiagnosticCategory.Error),o=e.filter(e=>e.category===T.DiagnosticCategory.Warning),n=e.filter(e=>e.category===T.DiagnosticCategory.Suggestion),a=e.filter(e=>e.category===T.DiagnosticCategory.Message);if(o.length&&this.reportDiagnostics(o,s.LogLevel.warn),t.length)throw this.reportDiagnostics(e,s.LogLevel.error),Error(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`);n.length&&this.reportDiagnostics(n,s.LogLevel.info),a.length&&this.reportDiagnostics(a,s.LogLevel.info)}}preCheckDiagnostics(e){const t=T.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const s=this.log.for(this.checkTsDiagnostics);let n;try{n=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(n.options,o?me.BUNDLE:t===fe.ESM?me.ESM:me.CJS_CHECK,e);const a=T.createProgram(n.fileNames,n.options);this.preCheckDiagnostics(a),s.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let s;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{s=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(s.options,o?me.BUNDLE:t===fe.ESM?me.ESM:me.CJS_CHECK,e);const n=T.createProgram(s.fileNames,s.options),a={};t===fe.ESM&&(a.before=[Se(".js")]);const r=n.emit(void 0,void 0,void 0,void 0,a),i=T.getPreEmitDiagnostics(n).concat(r.diagnostics);this.evalDiagnostics(i)}async build(e,t,o=!1){const s=this.log.for(this.build);await this.buildTs(e,t,o),s.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t!==fe.CJS||o||await this.buildCjsFromEsm(e)}rewriteRelativeJsSpecifiersToCjs(e){return e.replace(/(["'])(\.{1,2}\/[^"']+?)(\1)/g,(e,t,o,s)=>`${t}${(e=>e.startsWith("./")||e.startsWith("../")||e.startsWith("/")?e.endsWith(".cjs")?e:e.endsWith(".js")?e.replace(/\.js$/,".cjs"):e:e)(o)}${s}`)}async buildCjsFromEsm(e){this.log.for(this.buildCjsFromEsm).info(`Building ${this.pkgName} ${this.pkgVersion} module (${fe.CJS}) from ESM output in ${e?"dev":"prod"} mode...`);const t=a.resolve("lib/esm"),o=a.resolve("lib/cjs");n.mkdirSync(o,{recursive:!0});const s=_(t,e=>e.endsWith(".js")&&!e.endsWith(".d.js"));for(const r of s){const s=a.relative(t,r),i=a.join(o,s).replace(/\.js$/gm,".cjs");n.mkdirSync(a.dirname(i),{recursive:!0});const c=n.readFileSync(r,"utf8"),l=T.transpileModule(c,{compilerOptions:{module:y.ModuleKind.CommonJS,target:T.ScriptTarget.ES2022,sourceMap:!e,inlineSourceMap:e,inlineSources:e,esModuleInterop:!0},fileName:a.basename(r),reportDiagnostics:!0});l.diagnostics?.length&&this.evalDiagnostics(l.diagnostics);const d=this.rewriteRelativeJsSpecifiersToCjs(l.outputText);n.writeFileSync(i,d,"utf8"),l.sourceMapText&&n.writeFileSync(i+".map",l.sourceMapText,"utf8")}}applyTsConfigProfile(e,t,o){switch(e.declaration=!1,e.emitDeclarationOnly=!1,e.noEmit=!1,e.outFile=void 0,e.moduleResolution=y.ModuleResolutionKind.Bundler,t){case me.ESM:e.module=y.ModuleKind.ESNext,e.outDir="lib/esm";break;case me.CJS_CHECK:e.module=y.ModuleKind.Preserve??y.ModuleKind.ESNext,e.moduleResolution=y.ModuleResolutionKind.Bundler,e.noEmit=!0,e.outDir=void 0;break;case me.TYPES:e.module=y.ModuleKind.ESNext,e.outDir="lib/types",e.declaration=!0,e.emitDeclarationOnly=!0;break;case me.NODE_NEXT_VALIDATE:e.module=y.ModuleKind.NodeNext,e.moduleResolution=y.ModuleResolutionKind.NodeNext,e.noEmit=!0;break;case me.BUNDLE:e.module=y.ModuleKind.ESNext,e.moduleResolution=y.ModuleResolutionKind.Bundler,e.outDir="dist",e.isolatedModules=!1,e.outFile=void 0}if(t===me.NODE_NEXT_VALIDATE)return e.inlineSourceMap=!1,e.inlineSources=!1,void(e.sourceMap=!1);o?(e.inlineSourceMap=!0,e.inlineSources=!0,e.sourceMap=!1):(e.inlineSourceMap=!1,e.inlineSources=!1,e.sourceMap=!0)}async checkNodeNextCompatibility(){const e=this.log.for(this.checkNodeNextCompatibility);let t;try{t=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(t.options,me.NODE_NEXT_VALIDATE,!1);const o=T.createProgram(t.fileNames,t.options);this.preCheckDiagnostics(o),e.verbose("TypeScript NodeNext compatibility check passed.")}async buildTypes(e){let t;this.log.for(this.buildTypes).info(`Building ${this.pkgName} ${this.pkgVersion} declaration files...`);try{t=this.readConfigFile("./tsconfig.json")}catch(e){throw Error("Failed to parse tsconfig.json: "+e)}this.applyTsConfigProfile(t.options,me.TYPES,e);const o=T.createProgram(t.fileNames,t.options),s=o.emit(),n=T.getPreEmitDiagnostics(o).concat(s.diagnostics);this.evalDiagnostics(n),this.emitDualDeclarationFiles(),this.removeLegacyDeclarationFiles(),this.updatePackageJsonDualTypeExports()}rewriteRelativeDeclarationSpecifiers(e,t,o){const s=a.dirname(o),r=e=>{if(!e.startsWith("./")&&!e.startsWith("../")&&!e.startsWith("/"))return e;if(/\.(d\.(mts|cts)|mts|cts|ts|json)$/i.test(e))return e;const o=a.resolve(s,e);try{if(n.existsSync(o)&&n.statSync(o).isDirectory())return`${e}/index${t}`}catch{}return`${e}${t}`};let i=e.replace(/(\b(?:import|export)\b[\s\S]*?\bfrom\s*["'])([^"']+)(["'])/gm,(e,t,o,s)=>`${t}${r(o)}${s}`);return i=i.replace(/(\bimport\s*\(\s*["'])([^"']+)(["']\s*\))/gm,(e,t,o,s)=>`${t}${r(o)}${s}`),i=i.replace(/(\brequire\s*\(\s*["'])([^"']+)(["']\s*\))/gm,(e,t,o,s)=>`${t}${r(o)}${s}`),i}emitDualDeclarationFiles(){const e=this.log.for(this.emitDualDeclarationFiles),t=a.resolve("lib/types");if(!n.existsSync(t))return;const o=_(t,e=>e.endsWith(".d.ts"));for(const e of o){const t=n.readFileSync(e,"utf8"),o=e.replace(/\.d\.ts$/i,".d.mts"),s=e.replace(/\.d\.ts$/i,".d.cts");n.writeFileSync(o,this.rewriteRelativeDeclarationSpecifiers(t,".d.mts",e),"utf8"),n.writeFileSync(s,this.rewriteRelativeDeclarationSpecifiers(t,".d.cts",e),"utf8")}e.verbose(`Generated ${2*o.length} dual declaration files.`)}removeLegacyDeclarationFiles(){const e=this.log.for(this.removeLegacyDeclarationFiles),t=a.resolve("lib/types");if(!n.existsSync(t))return;const o=_(t,e=>e.endsWith(".d.ts")||e.endsWith(".d.ts.map"));for(const e of o)try{n.unlinkSync(e)}catch{}e.verbose(`Removed ${o.length} legacy declaration files.`)}updatePackageJsonDualTypeExports(){const e=this.log.for(this.updatePackageJsonDualTypeExports),t=a.resolve("package.json");if(!n.existsSync(t))return;const o=JSON.parse(n.readFileSync(t,"utf8")),s=o?.exports;if(!s||"object"!=typeof s)return;const r=(e,t)=>e.replace(/\.d\.(ts|mts|cts)$/i,t),i=e=>{if(e)return e.includes("/lib/esm/")?e.replace("/lib/esm/","/lib/cjs/").replace(/\.js$/i,".cjs"):e},c=(e,t=".d.mts")=>{if(e)return e.includes("/lib/esm/")?e.replace("/lib/esm/","/lib/types/").replace(/\.js$/i,t):void 0},l=e=>"string"==typeof e?e:e&&"object"==typeof e&&"string"==typeof e.default?e.default:void 0,d=e=>{if(e&&"object"==typeof e&&"string"==typeof e.types)return e.types},g={};for(const[e,t]of Object.entries(s)){if(!t||"object"!=typeof t||Array.isArray(t)){g[e]=t;continue}const o=t,s=l(o.import),n=l(o.require),a=n&&n.includes("/lib/esm/")?i(n):n||i(s),u=l(o.default),h=("string"==typeof o.types?o.types:void 0)||d(o.import),f=h&&/\.d\.(ts|mts|cts)$/i.test(h)?r(h,".d.mts"):d(o.import)||c(s,".d.mts"),p=h&&/\.d\.(ts|mts|cts)$/i.test(h)?r(h,".d.cts"):d(o.require)||c(s,".d.cts");g[e]={...s?{import:{...f?{types:f}:{},default:s}}:{},...a?{require:{...p?{types:p}:{},default:a}}:{},...u||s?{default:u||s}:{}}}o.exports=g,"string"==typeof o.types&&/\.d\.(ts|mts|cts)$/i.test(o.types)&&(o.types=o.types.replace(/\.d\.(ts|mts|cts)$/i,".d.mts")),n.writeFileSync(t,JSON.stringify(o,null,2)+"\n","utf8"),e.verbose("Updated package.json exports with import/require type conditions.")}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=n.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&V("./src/assets",`./${e===fe.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,s="./src/index.ts",n=this.pkgName,i,c=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const l=e===fe.ESM,d=this.pkgName,g=this.log,u=Array.from(new Set([...re(c)]));let y=re(i);if(0===y.length){try{y=X(a.join(process.cwd(),"node_modules"))}catch{}y&&0!==y.length||(y=ce())}const S=Array.from(new Set([...(()=>{try{return Array.isArray(r.builtinModules)?r.builtinModules:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}})(),...y])),b=!t||"inline",w=[h({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist",sourceMap:!t,inlineSourceMap:!!t,inlineSources:!!t},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),m()];o&&w.push(f({include:[],exclude:y}),p.nodeResolve({resolveOnly:u}));try{const k=await import("@rollup/plugin-terser"),D=k&&k.terser||k.default||k,$={parse:{ecma:2020},compress:!1,mangle:!1,format:{comments:!1,beautify:!0}},E={parse:{ecma:2020},compress:{ecma:2020,passes:5,drop_console:!0,drop_debugger:!0,toplevel:!0,module:l,unsafe:!0,unsafe_arrows:!0,unsafe_comps:!0,collapse_vars:!0,reduce_funcs:!0,reduce_vars:!0},mangle:{toplevel:!0},format:{comments:!1,ascii_only:!0},toplevel:!0};w.push(D(t?$:E))}catch{}const v={input:s,plugins:w,external:S,onwarn:void 0,treeshake:!t},T={};S.forEach(e=>{T[e]=ie(e)});const C=[{dir:o?"bin":"dist",entryFileNames:`${n||".bundle."+(t?"":"min")}${l?".js":".cjs"}`,format:o?"cjs":l?"esm":"umd",name:d,esModule:l,sourcemap:b,globals:T,exports:"auto"}];try{const{rollup:x}=await import("rollup"),N=await x(v);async function F(e){for(const t of C)await e.write(t)}g.verbose(N.watchFiles);try{await F(N)}finally{await N.close()}}catch(I){throw Error("Failed to bundle: "+I)}}async buildByEnv(e="./src/index.ts",t,o=pe.ALL,s=!1,a,r){s&&await this.checkNodeNextCompatibility();try{H("lib")}catch(e){}try{H("dist")}catch(e){}[pe.ALL,pe.BUILD].includes(o)&&(n.mkdirSync("lib",{recursive:!0}),await this.build(t,fe.ESM),await this.build(t,fe.CJS),await this.buildTypes(t),this.patchFiles("lib")),[pe.ALL,pe.BUNDLE].includes(o)&&(n.mkdirSync("dist"),await this.bundle(fe.ESM,t,!1,e||"./src/index.ts",this.pkgName,r,a),await this.bundle(fe.CJS,t,!1,e||"./src/index.ts",this.pkgName,r,a),this.patchFiles("dist")),this.copyAssets(fe.CJS),this.copyAssets(fe.ESM)}async buildDev(e="./src/index.ts",t=pe.ALL,o=!1,s,n){return this.buildByEnv(e,!0,t,o,s,n)}async buildProd(e="./src/index.ts",t=pe.ALL,o=!1,s,n){return this.buildByEnv(e,!1,t,o,s,n)}async buildDocs(){await j("npm install better-docs taffydb").promise,await j("npx markdown-include ./workdocs/readme-md.json").promise,await j("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await j("npm remove better-docs taffydb").promise,[{src:"workdocs/assets",dest:"./docs/workdocs/assets"},{src:"workdocs/reports/coverage",dest:"./docs/workdocs/reports/coverage"},{src:"workdocs/reports/html",dest:"./docs/workdocs/reports/html"},{src:"workdocs/resources",dest:"./docs/workdocs/resources"},{src:"LICENSE.md",dest:"./docs/LICENSE.md"}].forEach(e=>{const{src:t,dest:o}=e;V(t,o)});try{const e=await z(a.resolve(a.join(process.cwd(),"dist")));this.replacements[he]=e+" KB"}catch{this.replacements[he]="unknown"}try{B("./README.md",this.replacements)}catch(e){this.log.for(this.buildDocs).verbose("Failed to patch README.md: "+e)}}async run(e){const{dev:t,prod:o,docs:s,buildMode:n,includes:a,externals:r,entry:i,validateNodeNext:c}=e;return t?await this.buildDev(i||"./src/index.ts",n,!!c,a,r):o?await this.buildProd(i||"./src/index.ts",n,!!c,a,r):s?await this.buildDocs():void 0}}function we(e,t,o,s,n,a=[],r=[]){e.info(""+t),e.info(o),e.info("Usage: "+s),e.info("Options:");for(const t of n){const o=t.defaultValue?` (default: ${t.defaultValue})`:"";e.info(` ${t.flag} ${t.description}${o}`)}if(a.length>0){e.info("Notes:");for(const t of a)e.info(" "+t)}if(r.length>0){e.info("Examples:");for(const t of r)e.info(" "+t)}}const ve={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}},Te=s.Logging.for("ReleaseChainRunner");class Ce{constructor(e){this.options=e,this.workspace=e.workspace??process.cwd(),this.clonesRoot=a.join(this.workspace,".release-chain"),this.token=e.token||process.env.RELEASE_CHAIN_TOKEN||process.env.GITHUB_TOKEN||process.env.GH_TOKEN,this.metaRepoSlug=Ee(e.metaRepoUrl)||Ie("Unable to normalize META repo URL"),this.currentRepo=Ee(e.currentRepo)||Fe()}async run(){const e=await this.loadSubmodules();if(!e.length)return void Te.warn("No modules detected in provided .gitmodules file");const t=this.currentRepo?e.findIndex(e=>e.slug===this.currentRepo):-1,o=0>t?e:e.slice(t+1);Te.info(`Evaluating ${o.length} repositories for ${this.options.packageName}`);for(const e of o)await this.evaluateModule(e)}async evaluateModule(e){if(!e.slug)return void Te.verbose(`Skipping ${e.name}: unsupported repository URL`);Te.info("\n[release-chain] "+e.slug);const t=a.join(this.clonesRoot,e.slug.replace(/\//g,"__"));n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(t,{recursive:!0}),this.cloneRepository(e.url,t),await this.checkoutTargetBranch(t);const o=a.join(t,"package.json");if(!n.existsSync(o))return void Te.debug("No package.json detected for "+e.slug);if(s=JSON.parse(n.readFileSync(o,"utf8")),r=this.options.packageName,!["dependencies","devDependencies","peerDependencies","optionalDependencies"].some(e=>!!s?.[e]?.[r]))return void Te.debug(`${e.slug} does not depend on ${this.options.packageName}`);var s,r,i;if((e=>{try{S.execSync("git config user.name",{cwd:e,stdio:"pipe"}),S.execSync("git config user.email",{cwd:e,stdio:"pipe"})}catch{S.execSync("git config user.name 'release-chain'",{cwd:e}),S.execSync("git config user.email 'release-chain@users.noreply.github.com'",{cwd:e})}})(t),this.runCommand("npm install --ignore-scripts",t),this.runCommand("npm update "+this.options.packageName,t),this.runCommand("npm run build --if-present",t),this.runCommand("npm run test --if-present",t),i=t,!S.execSync("git status --porcelain",{cwd:i,encoding:"utf8"}).trim())return void Te.info("No changes detected for "+e.slug);this.runCommand("git add -A",t),this.runCommand(`git commit -m "chore: release chain update for ${this.options.packageName}"`,t),this.runCommand(`git push origin ${this.options.branch} --force-with-lease`,t);const c=await this.findExistingPr(e.slug);if(c)return Te.info(`Existing PR #${c.number} detected for ${e.slug}, attempting merge`),void await this.acceptPullRequest(e.slug,c.number,c.head.sha);const l=this.options.targetBaseBranch||await this.getDefaultBranch(e.slug);await this.createPullRequest(e.slug,l)}cloneRepository(e,t){const o=((e,t)=>{const o=xe(e);if(!t)return o;const s=new URL(o);return s.username="x-access-token",s.password=t,s.toString()})(e,this.token);this.runCommand(`git clone --no-tags --depth 1 ${o} ${t}`)}async checkoutTargetBranch(e){try{return this.runCommand(`git fetch origin ${this.options.branch}:${this.options.branch}`,e),this.runCommand("git checkout "+this.options.branch,e),void this.runCommand("git reset --hard origin/"+this.options.branch,e)}catch(e){Te.verbose(`Branch ${this.options.branch} not found remotely; creating from default`)}const t=(e=>{try{return S.execSync("git symbolic-ref --short refs/remotes/origin/HEAD",{cwd:e,encoding:"utf8"}).trim().split("/").pop()||"main"}catch{return"main"}})(e);this.runCommand(`git checkout -b ${this.options.branch} origin/${t}`,e)}async loadSubmodules(){if(this.options.submodulePath&&n.existsSync(this.options.submodulePath))return $e(n.readFileSync(this.options.submodulePath,"utf8"));const e=[this.options.submoduleFile,".gitsubmodule",".gitmodules"].filter(Boolean);for(const t of e)try{const e=await Ne(this.metaRepoSlug,this.options.branch,t,this.token);if(e)return $e(e)}catch(o){if(t===e[e.length-1])throw o}return[]}runCommand(e,t=this.workspace){Te.debug(`[${t}] ${e}`),S.execSync(e,{cwd:t,stdio:"inherit",env:Object.assign({},process.env,{RELEASE_CHAIN_TOKEN:this.token})})}async githubRequest(e,t){const o={"User-Agent":"decaf-release-chain",Accept:"application/vnd.github+json"};this.token&&(o.Authorization="Bearer "+this.token);const s=await fetch("https://api.github.com"+e,{method:t?.method||"GET",headers:Object.assign({},o,t?.headers),body:t?.body});if(!s.ok){const e=await s.text();throw Error(`GitHub API ${s.status}: ${e}`)}if(204!==s.status)return await s.json()}async findExistingPr(e){const[t]=e.split("/"),o=await this.githubRequest(`/repos/${e}/pulls?head=${t}%3A${encodeURIComponent(this.options.branch)}&state=open&per_page=1`);return o?.[0]}async acceptPullRequest(e,t,o){await this.githubRequest(`/repos/${e}/pulls/${t}/merge`,{method:"PUT",body:JSON.stringify({merge_method:"squash",commit_title:"chore: accept release chain for "+this.options.packageName,sha:o})})}async createPullRequest(e,t){await this.githubRequest(`/repos/${e}/pulls`,{method:"POST",body:JSON.stringify({title:this.options.branch+"-release-chain",head:this.options.branch,base:t,body:`Automated dependency update for ${this.options.packageName}.`})})}async getDefaultBranch(e){const t=await this.githubRequest("/repos/"+e);return t?.default_branch||"main"}}async function ke(e){const t=new Ce(e);await t.run()}async function De(e){const t=e.token||process.env.RELEASE_CHAIN_TRIGGER_TOKEN||process.env.RELEASE_CHAIN_TOKEN||process.env.GITHUB_TOKEN||process.env.GH_TOKEN,o=e.repoSlug||Fe()||Ie("Unable to determine repository slug for dispatch"),s=e.workflowFile||"release-chain.yaml",n=e.ref||e.branch,a=Ee(e.currentRepo)||o;Te.info(`Dispatching ${s} on ${o} for ${e.branch} (current repo ${a})`);const r={"User-Agent":"decaf-release-chain-dispatch",Accept:"application/vnd.github+json","Content-Type":"application/json"};t&&(r.Authorization="Bearer "+t);const i=await fetch(`https://api.github.com/repos/${o}/actions/workflows/${s}/dispatches`,{method:"POST",headers:r,body:JSON.stringify({ref:n,inputs:{meta_repo_url:e.metaRepoUrl,branch:e.branch,current_repo:a,target_branch:e.targetBaseBranch||""}})});if(!i.ok){const e=await i.text();throw Error(`Workflow dispatch failed: ${i.status} ${e}`)}}function $e(e){return e.split("[submodule").slice(1).map(e=>{const t=e.match(/"(.+?)"\]/),o=e.match(/path\s*=\s*(.+)/),s=e.match(/url\s*=\s*(.+)/),n=s?.[1]?.trim()||"";return{name:t?.[1]?.trim()||"",path:o?.[1]?.trim()||"",url:n,slug:Ee(n)}}).filter(e=>e.url)}function Ee(e){if(e){if(e.includes("github.com")){const t=xe(e);return new URL(t).pathname.replace(/^\//,"").replace(/\.git$/,"")}return e.replace(/^\//,"")}}function xe(e){return e.startsWith("git@github.com:")?"https://github.com/"+e.replace("git@github.com:",""):e.startsWith("ssh://git@github.com/")?"https://github.com/"+e.replace("ssh://git@github.com/",""):e.replace(/\.git$/,"")}async function Ne(e,t,o,s){const n=`https://raw.githubusercontent.com/${e}/${t}/${o}`,a={"User-Agent":"decaf-release-chain"};s&&(a.Authorization="Bearer "+s);const r=await fetch(n,{headers:a});if(404===r.status)return null;if(!r.ok){const e=await r.text();throw Error(`Failed to download ${o}: ${r.status} ${e}`)}return r.text()}function Fe(){if(process.env.GITHUB_REPOSITORY)return process.env.GITHUB_REPOSITORY;try{return Ee(S.execSync("git config --get remote.origin.url",{encoding:"utf8"}).trim().replace(/\s+/g,""))}catch{return}}function Ie(e){throw Error(e)}const Ae={meta:{type:"string",default:process.env.RELEASE_CHAIN_META_REPO_URL||""},branch:{type:"string",default:process.env.RELEASE_CHAIN_BRANCH||process.env.GITHUB_REF_NAME||"main"},current:{type:"string",default:process.env.RELEASE_CHAIN_CURRENT||process.env.GITHUB_REPOSITORY||""},package:{type:"string",default:""},token:{type:"string",default:process.env.RELEASE_CHAIN_TOKEN||""},submoduleFile:{type:"string",default:process.env.RELEASE_CHAIN_FILE||""},submodulePath:{type:"string",default:process.env.RELEASE_CHAIN_FILE_PATH||""},workflow:{type:"string",default:process.env.RELEASE_CHAIN_WORKFLOW||"release-chain.yaml"},repo:{type:"string",default:process.env.RELEASE_CHAIN_REPO||""},ref:{type:"string",default:process.env.RELEASE_CHAIN_REF||""},targetBase:{type:"string",default:process.env.RELEASE_CHAIN_TARGET||""}};function Re(){try{return S.execSync("git config --get remote.origin.url",{encoding:"utf8"}).trim()}catch{return}}function Me(){try{return S.execSync("git rev-parse --abbrev-ref HEAD",{encoding:"utf8"}).trim()}catch{return"main"}}function je(e=process.cwd()){const t=w.join(e,".gitmodules");return b.readFileSync(t,"utf8").toString().match(/(?<=").*?(?="])/g)||[]}function Oe(e=process.cwd(),t=2){const o=new Set,s=new Set,n=(e,t,a="")=>{const r=w.resolve(e);if(s.has(r))return;s.add(r);let i=[];try{i=je(e)}catch{return}for(const s of i){const r=a?w.join(a,s):s;if(o.add(r),0>=t)continue;const i=w.join(e,s),c=w.join(i,".gitmodules");b.existsSync(c)&&n(i,t-1,r)}};return n(e,t),Array.from(o)}const Pe={basePath:{type:"string",default:process.cwd()}},Be={maxTraversal:{type:"string",default:"2"},excludes:{type:"string",multiple:!0,default:["@decaf-ts/utils","@decaf-ts/logging"]},include:{type:"string",multiple:!0,default:[]},packages:{type:"string",multiple:!0,default:[]},mainPackagePath:{type:"string",default:""},operation:{type:"string",default:"link"}};function Le(e){return e.split("/")[1]||e}function Ue(e){return[...Object.keys(e.dependencies||{}),...Object.keys(e.devDependencies||{}),...Object.keys(e.peerDependencies||{})]}function _e(e){return Array.isArray(e)?e.map(e=>(""+e).trim()).filter(Boolean):"string"==typeof e&&e.length>0?e.split(",").map(e=>e.trim()).filter(Boolean):[]}function Ve(e,t){if(t.includes("*")){const o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*");return RegExp(`^${o}$`).test(e)}return e===t||w.basename(e)===t||e.endsWith("/"+t)}const He={maxTraversal:{type:"string",default:"2"},tokenFiles:{type:"string",multiple:!0,default:[".token",".npmtoken"]}},We={basePath:{type:"string",default:process.cwd()},command:{type:"string",default:void 0}},qe={public:{type:"boolean",default:!1},private:{type:"boolean",default:!1},gitToken:{type:"string",default:".token"},npmToken:{type:"string",default:".npmtoken"},gitUser:{type:"string",default:void 0},allowFromBranch:{type:"boolean",default:!1},tag:{type:"string",default:void 0},message:{type:"string",default:void 0}};e.AbortCode=I,e.BuildScripts=be,e.COMMIT="78eb3e8",e.Command=te,e.DefaultCommandOptions=k,e.DefaultCommandValues=D,e.Encoding=$,e.FULL_VERSION="1.5.6-78eb3e8",e.HttpClient=oe,e.ModulesCommand=class extends te{constructor(){super("ModulesCommand",Pe)}help(){we(this.log,"modules","List modules discovered from .gitmodules.","modules [options]",[{flag:"--base-path <path>",description:"Directory to read .gitmodules from",defaultValue:"current working directory"},{flag:"-h, --help",description:"Show this help text and exit"}],["Each discovered module path is printed on its own line."],["modules","modules --base-path ../repo"])}async run(e){je(e.basePath).forEach(e=>this.log.info(e))}},e.NoCIFLag=N,e.NpmLinkCommand=class extends te{constructor(){super("NpmLinkCommand",Be)}help(){we(this.log,"npm-link","Link or unlink decaf-ts package outputs across linked modules.","npm-link [options]",[{flag:"--max-traversal <depth>",description:"How many nested .gitmodules levels to traverse",defaultValue:"2"},{flag:"--excludes <items...>",description:"Dependency names or patterns to ignore",defaultValue:"@decaf-ts/utils,@decaf-ts/logging"},{flag:"--include <items...>",description:"Module names or paths to target explicitly"},{flag:"--packages <items...>",description:"Additional non-decaf packages to link or unlink"},{flag:"--main-package-path <path>",description:"Path to the package tree that provides the original decaf packages"},{flag:"--operation <name>",description:"Operation to run in each module",defaultValue:"link"},{flag:"-h, --help",description:"Show this help text and exit"}],["link creates symlinks for decaf-ts dependencies","link can also include extra non-decaf packages passed via --packages","when --packages is set, --main-package-path is required and is used as the source root","unlink removes those links and reinstalls dependencies","any other operation is passed through to npm in each selected module"],["npm-link --operation link","npm-link --operation unlink","npm-link --operation install --include packages/app","npm-link --packages @scope/* --main-package-path ../packages --include packages/app"])}async run(e){const t=Number.parseInt(""+(e.maxTraversal||"2"),10),o=_e(e.include),s=_e(e.excludes),n=_e(e.packages),a=(""+(e.mainPackagePath||"")).trim(),r=["@decaf-ts/utils","@decaf-ts/logging"],i=(""+(e.operation||"link")).trim()||"link",c=a?w.resolve(a):process.cwd();if(n.length>0&&!a)return void process.exit(1);const l=JSON.parse(b.readFileSync(w.join(c,"package.json"),"utf8")).name.split("/")[0]||"",d=Oe(process.cwd(),Number.isFinite(t)?t:2).filter(e=>0>=o.length||o.some(t=>Ve(e,t))),g=e=>(s.length>0?s:r).some(t=>Ve(e,t));for(const e of d){const t=w.join(process.cwd(),e);let o;try{o=JSON.parse(b.readFileSync(w.join(t,"package.json"),"utf8"))}catch{continue}const s=Ue(o).filter(e=>{return(t=e).startsWith(l)||n.some(e=>Ve(t,e));var t});if("link"!==i)if("unlink"!==i)try{S.execSync("npm "+i,{cwd:t,env:process.env,stdio:"inherit"})}catch{process.exit(1)}else{for(const e of s)if(!g(e))try{b.rmSync(w.join(t,"node_modules",e),{force:!0,recursive:!0})}catch{process.exit(1)}try{S.execSync("npm run do-install",{cwd:t,env:process.env,stdio:"inherit"})}catch{process.exit(1)}}else for(const e of s){if(g(e))continue;const o=e.endsWith("styles")?"dist":"lib",s=Le(e);try{const n=w.join(t,"node_modules",e),a=w.join(t,"node_modules",e),r=w.join(c,s,o),i=w.join(n,o);if(!b.existsSync(r))continue;b.rmSync(a,{force:!0,recursive:!0}),b.mkdirSync(n,{recursive:!0}),b.rmSync(i,{force:!0,recursive:!0}),b.symlinkSync(w.relative(n,r),i,"dir")}catch(e){process.exit(1)}}}}},e.NpmTokenCommand=class extends te{constructor(){super("NpmTokenCommand",He)}help(){we(this.log,"npm-token","Link token files into every module discovered in .gitmodules.","npm-token [options]",[{flag:"--max-traversal <depth>",description:"How many nested .gitmodules levels to traverse",defaultValue:"2"},{flag:"--token-files <files...>",description:"Token files to link into each selected module",defaultValue:".token,.npmtoken"},{flag:"-h, --help",description:"Show this help text and exit"}],["The command creates symlinks from each selected module back to the token files in the repository root."],["npm-token","npm-token --token-files .token .npmtoken secrets/npm.token"])}async run(e){const t=Number.parseInt(""+(e.maxTraversal||"2"),10),o=(s=e.tokenFiles,Array.isArray(s)?s.map(e=>(""+e).trim()).filter(Boolean):"string"==typeof s&&s.length>0?s.split(",").map(e=>e.trim()).filter(Boolean):[]);var s;const n=o.length>0?o:[".token",".npmtoken"],a=Oe(process.cwd(),Number.isFinite(t)?t:2);for(const e of a){const t=w.join(process.cwd(),e);try{for(const e of n)b.rmSync(w.join(t,e),{force:!0,recursive:!0}),b.symlinkSync(w.join("..",e),w.join(t,e))}catch{process.exit(1)}}}},e.PACKAGE_NAME="@decaf-ts/utils",e.PerformanceRunner=class{constructor(e){this.scenario=e}async run(){this.scenario.initialize&&await this.scenario.initialize();let e=0;const t=this.scenario.phases.map(t=>({phase:t,phaseNumber:++e})),o=[];for(;t.length;){const s=t.shift(),n=s.phase,a=this.mergeContext(n),r=await this.runPhase(n,a);if(o.push(r),n.generator){const a=[...o],i={phaseNumber:s.phaseNumber,phaseName:n.name,iterationCount:n.config.iterations,burstSegments:r.segmentCount,segmentCount:r.segmentCount,mode:n.config.mode,history:a},c=await n.generator({result:r,history:a,metadata:i});if(c){const o="config"in c?{name:c.name??n.name+" \u2192 gen",config:c.config,generator:n.generator}:{name:n.name+" \u2192 gen",config:c,generator:n.generator};t.push({phase:o,phaseNumber:++e})}}}if(await this.logSummary(o),!1!==this.scenario.failOnError){const e=o.reduce((e,t)=>e+t.aggregated.failureCount,0);if(e>0)throw Error(`Scenario "${this.scenario.name}" recorded ${e} failures across ${o.length} phases`)}return o}async runPhase(e,t){await this.runWarmup(e,t);const o=this.buildSegmentIndices(e.config.iterations,e.config.burst),s=[],n=Date.now();for(let n=0;n<o.length;n+=1){const a=o[n];if(!a.length)continue;ae((e.name,o.length,a[0],a[a.length-1]));const r=await this.executeSegment(this.scenario.handler,e.config,t,a);s.push(...r);const i=e.config.burst?.intervalMs;i&&n<o.length-1&&await ne(i)}const a=Date.now()-n,r=[...s].sort((e,t)=>e.iteration-t.iteration),i=this.aggregateMetrics(r);return e.config.pauseAfterMs&&await ne(e.config.pauseAfterMs),{phase:e,config:e.config,iterationMetrics:r,aggregated:i,context:t,segmentCount:o.length,wallClockMs:a}}async runWarmup(e,t){const o=e.config.warmup;if(!o?.iterations)return;const s=o.handler??this.scenario.handler;for(let n=0;n<o.iterations;n+=1)await s({iteration:n,config:e.config,loadFactor:this.computeLoadFactor(e.config,n),context:t}),o.delayBetweenIterationsMs&&n<o.iterations-1&&await ne(o.delayBetweenIterationsMs)}computeLoadFactor(e,t){return((e.loadStart??1)+(e.loadStep??0)*t)*(e.loadMultiplier??1)}buildSegmentIndices(e,t){const o=Math.max(0,e);if(0===o)return[];const s=t?.size&&t.size>0?Math.min(t.size,o):o,n=[];for(let e=0;o>e;e+=s){const t=Math.min(o,e+s);n.push(Array.from({length:t-e},(t,o)=>e+o))}return n}mergeContext(e){const t=this.scenario.baseContext??{},o=e.config.context??{};return this.mergeContexts(t,o)}mergeContexts(e,t){return Object.assign({},e,t)}async executeSegment(e,t,o,s){return s.length?"concurrent"===t.mode?this.collectConcurrent(e,t,o,s):this.collectSequential(e,t,o,s):[]}async collectSequential(e,t,o,s){const n=[],a=t.delayBetweenIterationsMs;for(let r=0;r<s.length;r+=1)n.push(await this.runIteration(e,t,o,s[r])),a&&r<s.length-1&&await ne(a);return n}async collectConcurrent(e,t,o,s){const n=Math.max(1,Math.min(t.concurrency??s.length,s.length)),a=[];let r=0;const i=async()=>{for(;r<s.length;){const n=s[r];r+=1,a.push(await this.runIteration(e,t,o,n))}};return await Promise.all(Array.from({length:n},()=>i())),a}async runIteration(e,t,o,n){const a=this.computeLoadFactor(t,n),r=new s.StopWatch(!0);let i,c=!0;t.metadata,a.toFixed(2);try{const s=await e({iteration:n,config:t,loadFactor:a,context:o});"boolean"==typeof s?.success&&(c=s.success),i=s?.meta}catch(e){c=!1,i={error:e instanceof Error?e.message:e+""}}const l=r.stop();return l.toFixed(2),{iteration:n,durationMs:l,success:c,meta:i,loadFactor:a}}aggregateMetrics(e){if(0===e.length)return{totalDurationMs:0,minMs:0,maxMs:0,averageMs:0,successCount:0,failureCount:0,loadStart:0,loadEnd:0};const t=e.reduce((e,t)=>e+t.durationMs,0),o=Math.min(...e.map(e=>e.durationMs)),s=Math.max(...e.map(e=>e.durationMs)),n=t/e.length,a=e.filter(e=>e.success).length,r=e.length-a,i=e[0]?.loadFactor??0;return{totalDurationMs:t,minMs:o,maxMs:s,averageMs:n,successCount:a,failureCount:r,loadStart:i,loadEnd:e[e.length-1]?.loadFactor??i}}logPhaseTable(e){e.config.iterations,e.wallClockMs,e.phase.name,e.config.mode,e.config.iterations.toString(),e.wallClockMs.toFixed(0),e.aggregated.averageMs.toFixed(2),e.aggregated.minMs.toFixed(2),e.aggregated.maxMs.toFixed(2),e.aggregated.successCount.toString(),e.aggregated.failureCount.toString(),e.aggregated.loadStart.toFixed(2),e.aggregated.loadEnd.toFixed(2)}async logSummary(e){if(!e.length)return;const t=["Phase","Mode","Iterations","Wall ms","RPS","Avg ms","Min ms","Max ms","Success","Failures","Load range"],o=e.map(e=>{const t=(e.config.iterations/(e.wallClockMs/1e3)).toFixed(1);return[e.phase.name,e.config.mode,e.config.iterations.toString(),e.wallClockMs.toFixed(0),t,e.aggregated.averageMs.toFixed(2),e.aggregated.minMs.toFixed(2),e.aggregated.maxMs.toFixed(2),e.aggregated.successCount.toString(),e.aggregated.failureCount.toString(),`${e.aggregated.loadStart.toFixed(2)} \u2192 ${e.aggregated.loadEnd.toFixed(2)}`]});if(this.shouldRenderCanvas()){const e=this.scenario.canvasOutputPath??a.join(process.cwd(),"workdocs","reports","performance-runner.png");await(async(e,t,o,s)=>{const n={...se,...o};let r;try{r=(await import("canvas")).createCanvas}catch(e){return}const i=r(n.width,n.height),c=i.getContext("2d");c.fillStyle=n.backgroundColor,c.fillRect(0,0,n.width,n.height),c.font=n.headerFont,c.fillStyle=n.headerColor;const l=(n.width-2*n.padding)/e.length,d=n.padding+24;e.forEach((e,t)=>{c.fillText(e,n.padding+l*t,d)}),c.font=n.rowFont,c.fillStyle=n.rowColor,t.forEach((e,t)=>{const o=d+12+24*(t+1);e.forEach((e,t)=>{c.fillText(e,n.padding+l*t,o)})}),await(async e=>{await u.mkdir(a.dirname(e),{recursive:!0})})(s),await u.writeFile(s,i.toBuffer("image/png"))})(t,o,this.scenario.canvasOptions??se,e)}}shouldRenderCanvas(){return this.scenario.enableCanvas??!!this.scenario.canvasOptions}},e.RegexpOutputWriter=class extends A{constructor(e,t,o,s="g"){super(e,t);try{this.regexp="string"==typeof o?RegExp(o,s):o}catch(e){throw Error("Invalid regular expression: "+e)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(e){return}return t}testAndResolve(e){const t=this.test(e);t&&this.resolve(t[0])}testAndReject(e){const t=this.test(e);t&&this.reject(t[0])}data(e){super.data(e),this.testAndResolve(e+"")}error(e){super.error(e),this.testAndReject(e+"")}},e.ReleaseChainCommand=class extends te{constructor(){super("ReleaseChain",Object.assign({},k,Ae))}help(){we(this.log,"release-chain","Run the release-chain workflow locally across repositories.","release-chain [options]",[{flag:"--meta <url>",description:"Meta repository URL"},{flag:"--branch <name>",description:"Branch to update downstream repositories",defaultValue:"main or detected branch"},{flag:"--current <owner/repo>",description:"Current repository slug to resume after in the chain"},{flag:"--package <name>",description:"Override detected package name"},{flag:"--token <token>",description:"GitHub token for cloning and pushing"},{flag:"--submodule-file <file>",description:"Override submodule file name"},{flag:"--submodule-path <path>",description:"Use a local submodule file instead of downloading"},{flag:"--target-base <branch>",description:"Base branch for downstream pull requests"},{flag:"-h, --help",description:"Show this help text and exit"}],["Missing meta or branch values are detected from git and environment variables when possible."])}async run(e){const t=e,o=t.package||W(process.cwd())?.name;if(!o)throw Error("Unable to determine package name");const s=t.meta||Re();if(!s)throw Error("A meta repository URL is required");const n=t.branch||Me();await ke({metaRepoUrl:s,branch:n,currentRepo:t.current,packageName:o,token:t.token,submoduleFile:t.submoduleFile||void 0,submodulePath:t.submodulePath||void 0,targetBaseBranch:t.targetBase||void 0})}},e.ReleaseChainDispatchCommand=class extends te{constructor(){super("ReleaseChainDispatch",Object.assign({},k,Ae))}help(){we(this.log,"release-chain-dispatch","Dispatch the release-chain GitHub Actions workflow.","release-chain-dispatch [options]",[{flag:"--meta <url>",description:"Meta repository URL"},{flag:"--branch <name>",description:"Branch to evaluate in downstream repositories",defaultValue:"main or detected branch"},{flag:"--current <owner/repo>",description:"Repository slug that triggered the release chain"},{flag:"--workflow <file>",description:"Workflow file name",defaultValue:"release-chain.yaml"},{flag:"--repo <owner/repo>",description:"Target repository slug where the workflow lives"},{flag:"--token <token>",description:"GitHub token for dispatching workflows"},{flag:"--ref <ref>",description:"Git ref to dispatch the workflow on"},{flag:"--target-base <branch>",description:"Base branch for downstream pull requests"},{flag:"-h, --help",description:"Show this help text and exit"}],["Missing meta or branch values are detected from git and environment variables when possible."])}async run(e){const t=e,o=t.meta||Re();if(!o)throw Error("A meta repository URL is required");const s=t.branch||Me();await De({metaRepoUrl:o,branch:s,workflowFile:t.workflow||"release-chain.yaml",repoSlug:t.repo,currentRepo:t.current,token:t.token,ref:t.ref||s,targetBaseBranch:t.targetBase||void 0})}},e.ReleaseChainRunner=Ce,e.ReleaseScript=class extends te{constructor(){super("ReleaseScript",ve)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release version provided. Prompting for one:"),t.info("Listing latest git tags:"),await j("git tag --sort=-taggerdate | head -n 5").promise,await C.insistForText("tag","Enter the new tag number (accepts v*.*.*[-...])",e=>!!e.toString().match(/^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9a-zA-Z-]+)?$/)))}testVersion(t){const o=this.log.for(this.testVersion);switch(t=t.trim().toLowerCase()){case e.SemVersion.PATCH:case e.SemVersion.MINOR:case e.SemVersion.MAJOR:return o.verbose("Using provided SemVer update: "+t,1),t;default:return o.verbose("Testing provided version for SemVer compatibility: "+t,1),RegExp(E).test(t)?(o.verbose("version approved: "+t,1),t):void o.debug("Invalid version number: "+t)}}async prepareMessage(e){const t=this.log.for(this.prepareMessage);return e||(t.verbose("No release message provided. Prompting for one"),await C.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}help(){we(this.log,"tag-release","Prepare, tag, and publish a release from the current repository.","tag-release [options]",[{flag:"--tag <version>",description:"Release tag to use"},{flag:"--message <text>",description:"Release message or ticket reference"},{flag:"--ci <true|false>",description:"Whether to treat the run as CI",defaultValue:"true"},{flag:"--version",description:"Print the package version and exit"},{flag:"-h, --help",description:"Show this help text and exit"}],["If tag or message are omitted, the command prompts interactively.","A successful run updates the package version, creates a git tag, pushes tags, and optionally publishes to npm."],['tag-release --tag v1.2.3 --message "Release 1.2.3"','tag-release --tag patch --message "Fix release"'])}async run(e){let t;const{ci:o}=e;let{tag:s,message:n}=e;s=await this.prepareVersion(s),n=await this.prepareMessage(n),t=await j(`npm run prepare-release -- ${s} ${n}`,{cwd:process.cwd()}).promise,t=await j("git status --porcelain").promise,await t,t.logs.length&&await C.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await j("git add .").promise,await j(`git commit -m "${s} - ${n} - after release preparation${o?"":N}"`).promise),await j(`npm version "${s}" -m "${n}${o?"":N}"`).promise,await j("git push --follow-tags").promise,o||await j("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}},e.RunAllCommand=class extends te{constructor(){super("RunAllCommand",We)}help(){we(this.log,"run-all","Run a shell command in every module listed in .gitmodules.","run-all [options] --command <cmd>",[{flag:"--base-path <path>",description:"Directory to read .gitmodules from",defaultValue:"current working directory"},{flag:"--command <cmd>",description:"Shell command to execute in each module"},{flag:"-h, --help",description:"Show this help text and exit"}],["The command fails fast if any module invocation fails."],["run-all --command npm test","run-all --base-path ../repo --command npm run lint"])}async run(e){const t="string"==typeof e.basePath&&e.basePath.trim().length>0?e.basePath.trim():process.cwd(),o="string"==typeof e.command?e.command.trim():"";if(0===o.length)throw Error("run-all requires a command to execute");const s=je(t);for(const e of s){const s=w.join(t,e);if(b.existsSync(s))try{S.execSync(o,{cwd:s,env:process.env,stdio:"inherit"})}catch{process.exit(1)}}}},e.SemVersionRegex=E,e.SetupScriptKey="postinstall",e.StandardOutputWriter=A,e.TagReleaseCommand=class extends te{constructor(){super("TagReleaseCommand",qe)}async ensureReleaseBranch(e=!1){if(e)return;const t=S.execSync("git rev-parse --abbrev-ref HEAD",{cwd:process.cwd(),encoding:"utf8"}).trim();if("master"!==t&&"main"!==t)throw Error("release must be run from 'master' or 'main' branch. Current branch: "+t)}async prepareTag(e){return(e=(""+(e||"")).trim()).length>0?e:(S.execSync("git tag --sort=-taggerdate | head -n 5",{cwd:process.cwd(),stdio:"inherit"}),C.insistForText("tag","What should be the new tag? (accepts v*.*.*[-...])",e=>!!e.toString().match(/^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9a-zA-Z-]+)?$/)))}async prepareMessage(e){return(e=(""+(e||"")).trim()).length>0?e:C.insistForText("message","Tag Message",e=>!!e&&e.toString().length>0)}hasToken(e){try{return b.statSync(w.join(process.cwd(),e)).size>0}catch{return!1}}readToken(e){return b.readFileSync(w.join(process.cwd(),e),"utf8").trim()}help(){we(this.log,"tag-release","Prepare a release, create a git tag, push, and optionally publish to npm.","tag-release [options] [tag] [message]",[{flag:"--public",description:"Publish to the public npm registry",defaultValue:"false"},{flag:"--private",description:"Publish to the restricted npm registry",defaultValue:"false"},{flag:"--git-token <file>",description:"File containing the token used for authenticated git pushes",defaultValue:".token"},{flag:"--npm-token <file>",description:"File containing the token used for npm publish",defaultValue:".npmtoken"},{flag:"--git-user <name>",description:"Git user name embedded in authenticated pushes"},{flag:"--allow-from-branch",description:"Skip the master/main branch guard",defaultValue:"false"},{flag:"--tag <version>",description:"Release tag to create"},{flag:"--message <text>",description:"Release message to use"},{flag:"-h, --help",description:"Show this help text and exit"}],["If tag or message are omitted, the command prompts interactively.","The command uses .token for git pushes and .npmtoken for npm publish unless overridden."],['tag-release --public --tag v1.2.3 --message "Release 1.2.3"',"tag-release --private --allow-from-branch --tag v1.2.3"])}async run(e){await this.ensureReleaseBranch(!0===e.allowFromBranch);const t=!0===e.private?"private":"public",o=await this.prepareTag(e.tag),s=await this.prepareMessage(e.message),n=""+(e.gitToken||".token"),a=""+(e.npmToken||".npmtoken"),r="string"==typeof e.gitUser&&e.gitUser.trim().length>0?e.gitUser.trim():S.execSync("git config user.name",{cwd:process.cwd(),encoding:"utf8"}).trim();S.execSync("npm run prepare-release",{cwd:process.cwd(),stdio:"inherit"}),S.execSync("git status --porcelain",{cwd:process.cwd(),encoding:"utf8"}).trim().length>0&&(S.execSync("git add .",{cwd:process.cwd(),stdio:"inherit"}),S.execSync(`git commit -m "${o} - ${s} - after release preparation"`,{cwd:process.cwd(),stdio:"inherit"})),S.execSync(`npm version "${o}" -m "${s}"`,{cwd:process.cwd(),stdio:"inherit"});const i=S.execSync("git remote get-url origin",{cwd:process.cwd(),encoding:"utf8"}).trim();if(this.hasToken(n)){const e=S.execSync("git rev-parse --abbrev-ref HEAD",{cwd:process.cwd(),encoding:"utf8"});let t="";try{t=S.execSync("git rev-parse --abbrev-ref --symbolic-full-name '@{u}'",{cwd:process.cwd(),encoding:"utf8"})}catch{t=""}const o=this.readToken(n);if(S.execSync(`git push "https://${r}:${o}@${i.replace(/^https:\/\//,"")}" --follow-tags`,{cwd:process.cwd(),stdio:"inherit"}),t.trim().length>0)try{S.execSync(`git branch --set-upstream-to="${t.trim()}" "${e.trim()}"`,{cwd:process.cwd(),stdio:"inherit"})}catch{}}else S.execSync("git push --follow-tags",{cwd:process.cwd(),stdio:"inherit"});const c="public"===t?"public":"restricted";if(s.endsWith(N)&&this.hasToken(a)){const e=this.readToken(a);S.execSync(`NPM_TOKEN="${e}" npm publish --access "${c}"`,{cwd:process.cwd(),stdio:"inherit"})}}},e.UserInput=C,e.VERSION="1.5.6",e.chainAbortController=R,e.copyFile=V,e.defaultCanvasOptions=se,e.deletePath=H,e.dispatchReleaseChainWorkflow=De,e.getAllFiles=_,e.getDependencies=J,e.getFileSizeZipped=z,e.getPackage=W,e.getPackageDependencies=ce,e.getPackageVersion=q,e.getSlogan=ee,e.installDependencies=G,e.installIfNotAvailable=async(e,t)=>{e="string"==typeof e?[e]:e;const o={prod:t?.prod?[...t.prod]:[],dev:t?.dev?[...t.dev]:[],peer:t?.peer?[...t.peer]:[]},s=new Set([...o.prod??[],...o.dev??[],...o.peer??[]]),n=[];for(const t of e)if(!s.has(t))try{P.resolve(t),s.add(t)}catch{n.push(t)}if(n.length){"test"===process.env.NODE_ENV||void 0!==process.env.JEST_WORKER_ID?O.verbose("Skipping dependency install in test environment for: "+n.join(", ")):await G({dev:n});const e=new Set(o.dev??[]);n.forEach(t=>e.add(t)),o.dev=Array.from(e)}return o},e.listFolder=function e(t=process.cwd(),o){const s=O.for(e);try{return n.existsSync(t)?n.readdirSync(t,{withFileTypes:!0}).filter(e=>!o||o(e.name,e)).map(e=>e.name):[]}catch(e){return s.verbose(`Failed to list folder ${t}: ${e}`),[]}},e.listNodeModulesPackages=X,e.lockify=e=>{let t=Promise.resolve();return(...o)=>{const s=t.then(()=>e(...o));return t=s.catch(()=>{}),s}},e.normalizeImport=async e=>e.then(e=>e.default||e),e.packageToGlobal=ie,e.parseList=re,e.patchFile=B,e.printBanner=Q,e.pushToGit=async function e(){const t=O.for(e),o=await j("git config user.name").promise,s=await j("git config user.email").promise;t.verbose(`cached git id: ${o}/${s}. changing to automation`),await j('git config user.email "automation@decaf.ts"').promise,await j('git config user.name "decaf"').promise,t.info("Pushing changes to git..."),await j("git add .").promise,await j('git commit -m "refs #1 - after repo setup"').promise,await j("git push").promise,await j(`git config user.email "${s}"`).promise,await j(`git config user.name "${o}"`).promise,t.verbose(`reverted to git id: ${o}/${s}`)},e.readFile=L,e.readGitModules=je,e.readGitModulesDeep=Oe,e.renameFile=async function e(t,o){const s=O.for(e);let a,r;try{a=n.statSync(t)}catch(e){throw s.verbose(`Source path "${t}" does not exist: ${e}`),Error(`Source path "${t}" does not exist: ${e}`)}try{r=n.statSync(o)}catch(e){}if(r)throw s.verbose(`Destination path "${o}" already exists`),Error(`Destination path "${o}" already exists`);try{s.verbose(`Renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}...`),n.renameSync(t,o),s.verbose(`Successfully renamed to "${o}"`)}catch(e){throw s.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}": ${e}`),Error(`Error renaming ${a.isFile()?"file":"directory"} "${t}" to "${o}": ${e}`)}},e.runCommand=j,e.runReleaseChain=ke,e.setPackageAttribute=(e,t,o=process.cwd())=>{const s=W(o);s[e]=t,U(a.join(o,"package.json"),JSON.stringify(s,null,2))},e.spawnCommand=M,e.updateDependencies=async function e(){const t=O.for(e);t.info("checking for updates..."),await j("npx npm-check-updates -u").promise,t.info("updating..."),await j("npx npm run do-install").promise},e.writeFile=U},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prompts"),require("util"),require("@decaf-ts/logging"),require("fs"),require("path"),require("module"),require("child_process"),require("styled-string-builder"),require("shell-quote"),require("zlib"),require("https"),require("fs/promises"),require("@rollup/plugin-typescript"),require("@rollup/plugin-commonjs"),require("@rollup/plugin-node-resolve"),require("@rollup/plugin-json"),require("typescript"),require("node:child_process"),require("node:fs"),require("node:path")):"function"==typeof define&&define.amd?define(["exports","prompts","util","@decaf-ts/logging","fs","path","module","child_process","styled-string-builder","shell-quote","zlib","https","fs/promises","@rollup/plugin-typescript","@rollup/plugin-commonjs","@rollup/plugin-node-resolve","@rollup/plugin-json","typescript","node:child_process","node:fs","node:path"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).utils={},e.prompts,e.util,e.decafTsLogging,e.fs,e.path,e.module,e.childProcess,e.styledStringBuilder,e.shellQuote,e.zlib,e.https,e.fsPromises,e.rollupPluginTypescript,e.rollupPluginCommonjs,e.rollupPluginNodeResolve,e.rollupPluginJson,e.typescript,e.node_child_process,e.fs$1,e.path$1);
2
2
  //# sourceMappingURL=utils.cjs.map
package/lib/cjs/index.cjs CHANGED
@@ -44,7 +44,7 @@ __exportStar(require("./release-chain/index.cjs"), exports);
44
44
  * @const VERSION
45
45
  * @memberOf module:utils
46
46
  */
47
- exports.VERSION = "1.5.4";
47
+ exports.VERSION = "1.5.6";
48
48
  /**
49
49
  * @description Represents the current commit hash of the module build.
50
50
  * @summary Stores the current git commit hash for the @decaf-ts/utils package.
@@ -52,7 +52,7 @@ exports.VERSION = "1.5.4";
52
52
  * @const COMMIT
53
53
  * @memberOf module:utils
54
54
  */
55
- exports.COMMIT = "2067dda";
55
+ exports.COMMIT = "78eb3e8";
56
56
  /**
57
57
  * @description Represents the full version string of the module.
58
58
  * @summary Stores the semver version and commit hash for the @decaf-ts/utils package.
@@ -60,7 +60,7 @@ exports.COMMIT = "2067dda";
60
60
  * @const FULL_VERSION
61
61
  * @memberOf module:utils
62
62
  */
63
- exports.FULL_VERSION = "1.5.4-2067dda";
63
+ exports.FULL_VERSION = "1.5.6-78eb3e8";
64
64
  /**
65
65
  * @description Represents the current version of the module.
66
66
  * @summary Stores the package name for the @decaf-ts/utils package. The build replaces
package/lib/esm/index.js CHANGED
@@ -27,7 +27,7 @@ export * from "./release-chain/index.js";
27
27
  * @const VERSION
28
28
  * @memberOf module:utils
29
29
  */
30
- export const VERSION = "1.5.4";
30
+ export const VERSION = "1.5.6";
31
31
  /**
32
32
  * @description Represents the current commit hash of the module build.
33
33
  * @summary Stores the current git commit hash for the @decaf-ts/utils package.
@@ -35,7 +35,7 @@ export const VERSION = "1.5.4";
35
35
  * @const COMMIT
36
36
  * @memberOf module:utils
37
37
  */
38
- export const COMMIT = "2067dda";
38
+ export const COMMIT = "78eb3e8";
39
39
  /**
40
40
  * @description Represents the full version string of the module.
41
41
  * @summary Stores the semver version and commit hash for the @decaf-ts/utils package.
@@ -43,7 +43,7 @@ export const COMMIT = "2067dda";
43
43
  * @const FULL_VERSION
44
44
  * @memberOf module:utils
45
45
  */
46
- export const FULL_VERSION = "1.5.4-2067dda";
46
+ export const FULL_VERSION = "1.5.6-78eb3e8";
47
47
  /**
48
48
  * @description Represents the current version of the module.
49
49
  * @summary Stores the package name for the @decaf-ts/utils package. The build replaces
@@ -27,7 +27,7 @@ export * from "./release-chain/index.d.cts";
27
27
  * @const VERSION
28
28
  * @memberOf module:utils
29
29
  */
30
- export declare const VERSION = "1.5.4";
30
+ export declare const VERSION = "1.5.6";
31
31
  /**
32
32
  * @description Represents the current commit hash of the module build.
33
33
  * @summary Stores the current git commit hash for the @decaf-ts/utils package.
@@ -35,7 +35,7 @@ export declare const VERSION = "1.5.4";
35
35
  * @const COMMIT
36
36
  * @memberOf module:utils
37
37
  */
38
- export declare const COMMIT = "2067dda";
38
+ export declare const COMMIT = "78eb3e8";
39
39
  /**
40
40
  * @description Represents the full version string of the module.
41
41
  * @summary Stores the semver version and commit hash for the @decaf-ts/utils package.
@@ -43,7 +43,7 @@ export declare const COMMIT = "2067dda";
43
43
  * @const FULL_VERSION
44
44
  * @memberOf module:utils
45
45
  */
46
- export declare const FULL_VERSION = "1.5.4-2067dda";
46
+ export declare const FULL_VERSION = "1.5.6-78eb3e8";
47
47
  /**
48
48
  * @description Represents the current version of the module.
49
49
  * @summary Stores the package name for the @decaf-ts/utils package. The build replaces
@@ -27,7 +27,7 @@ export * from "./release-chain/index.d.mts";
27
27
  * @const VERSION
28
28
  * @memberOf module:utils
29
29
  */
30
- export declare const VERSION = "1.5.4";
30
+ export declare const VERSION = "1.5.6";
31
31
  /**
32
32
  * @description Represents the current commit hash of the module build.
33
33
  * @summary Stores the current git commit hash for the @decaf-ts/utils package.
@@ -35,7 +35,7 @@ export declare const VERSION = "1.5.4";
35
35
  * @const COMMIT
36
36
  * @memberOf module:utils
37
37
  */
38
- export declare const COMMIT = "2067dda";
38
+ export declare const COMMIT = "78eb3e8";
39
39
  /**
40
40
  * @description Represents the full version string of the module.
41
41
  * @summary Stores the semver version and commit hash for the @decaf-ts/utils package.
@@ -43,7 +43,7 @@ export declare const COMMIT = "2067dda";
43
43
  * @const FULL_VERSION
44
44
  * @memberOf module:utils
45
45
  */
46
- export declare const FULL_VERSION = "1.5.4-2067dda";
46
+ export declare const FULL_VERSION = "1.5.6-78eb3e8";
47
47
  /**
48
48
  * @description Represents the current version of the module.
49
49
  * @summary Stores the package name for the @decaf-ts/utils package. The build replaces
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@decaf-ts/utils",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
+ "packageManager": "npm@11.13.0",
4
5
  "description": "module management utils for decaf-ts",
5
6
  "type": "module",
6
7
  "exports": {
@@ -126,7 +127,7 @@
126
127
  "@rollup/plugin-terser": "^1.0.0",
127
128
  "@rollup/plugin-typescript": "^12.3.0",
128
129
  "@stylistic/eslint-plugin": "^4.2.0",
129
- "@types/jest": "^30.0.0",
130
+ "@types/jest": "30.0.0",
130
131
  "@types/prompts": "^2.4.9",
131
132
  "@types/shell-quote": "^1.7.5",
132
133
  "clean-publish": "^5.1.0",
@@ -135,9 +136,9 @@
135
136
  "eslint-config-prettier": "^10.1.2",
136
137
  "eslint-plugin-prettier": "^5.2.6",
137
138
  "globals": "^16.0.0",
138
- "jest": "^30.4.2",
139
- "jest-html-reporters": "^3.1.7",
140
- "jest-junit": "^17.0.0",
139
+ "jest": "30.4.2",
140
+ "jest-html-reporters": "3.1.7",
141
+ "jest-junit": "17.0.0",
141
142
  "jsdoc": "^4.0.4",
142
143
  "jsdoc-mermaid": "^1.0.0",
143
144
  "markdown-include": "^0.4.3",
@@ -149,7 +150,7 @@
149
150
  "rimraf": "^6.0.1",
150
151
  "rollup": "^4.59.0",
151
152
  "shell-quote": "^1.8.3",
152
- "ts-jest": "^29.4.6",
153
+ "ts-jest": "29.4.9",
153
154
  "ts-loader": "^9.5.2",
154
155
  "ts-node": "^10.9.2",
155
156
  "tsx": "^4.20.6",