@decaf-ts/utils 0.4.2 → 0.4.3

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 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prompts"),require("util"),require("@decaf-ts/logging"),require("fs"),require("path"),require("child_process"),require("styled-string-builder"),require("https"),require("rollup"),require("@rollup/plugin-typescript"),require("@rollup/plugin-commonjs"),require("@rollup/plugin-node-resolve"),require("@rollup/plugin-json"),require("module"),require("typescript")):"function"==typeof define&&define.amd?define(["exports","prompts","util","@decaf-ts/logging","fs","path","child_process","styled-string-builder","https","rollup","@rollup/plugin-typescript","@rollup/plugin-commonjs","@rollup/plugin-node-resolve","@rollup/plugin-json","module","typescript"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).utils={},e.prompts,e.util,e.decafTsLogging,e.fs,e.path,e.childProcess,e.styledStringBuilder,e.https,e.rollup,e.rollupPluginTypescript,e.rollupPluginCommonjs,e.rollupPluginNodeResolve,e.rollupPluginJson,e.module,e.typescript)}(this,function(e,t,o,a,n,s,i,r,l,c,g,d,f,u,h,p){"use strict";function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function S(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}var y=m(t),w=m(n),T=m(s),b=m(l),C=m(g),v=m(d),D=m(u),k=S(p);class ${static{this.logger=a.Logging.for($)}constructor(e){this.type="text",this.name=e}setType(e){return $.logger.verbose(`Setting type to: ${e}`),this.type=e,this}setMessage(e){return $.logger.verbose(`Setting message to: ${e}`),this.message=e,this}setInitial(e){return $.logger.verbose(`Setting initial value to: ${e}`),this.initial=e,this}setStyle(e){return $.logger.verbose(`Setting style to: ${e}`),this.style=e,this}setFormat(e){return $.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return $.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return $.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return $.logger.verbose(`Setting min value to: ${e}`),this.min=e,this}setMax(e){return $.logger.verbose(`Setting max value to: ${e}`),this.max=e,this}setFloat(e){return $.logger.verbose(`Setting float to: ${e}`),this.float=e,this}setRound(e){return $.logger.verbose(`Setting round to: ${e}`),this.round=e,this}setInstructions(e){return $.logger.verbose(`Setting instructions to: ${e}`),this.instructions=e,this}setIncrement(e){return $.logger.verbose(`Setting increment to: ${e}`),this.increment=e,this}setSeparator(e){return $.logger.verbose(`Setting separator to: ${e}`),this.separator=e,this}setActive(e){return $.logger.verbose(`Setting active style to: ${e}`),this.active=e,this}setInactive(e){return $.logger.verbose(`Setting inactive style to: ${e}`),this.inactive=e,this}setChoices(e){return $.logger.verbose(`Setting choices: ${JSON.stringify(e)}`),this.choices=e,this}setHint(e){return $.logger.verbose(`Setting hint to: ${e}`),this.hint=e,this}setWarn(e){return $.logger.verbose(`Setting warn to: ${e}`),this.warn=e,this}setSuggest(e){return $.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return $.logger.verbose(`Setting limit to: ${e}`),this.limit=e,this}setMask(e){return $.logger.verbose(`Setting mask to: ${e}`),this.mask=e,this}setStdout(e){return $.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await $.ask(this))[this.name]}static async ask(e){const t=$.logger.for(this.ask);let o;Array.isArray(e)||(e=[e]);try{t.verbose(`Asking questions: ${e.map(e=>e.name).join(", ")}`),o=await y.default(e),t.verbose(`Received answers: ${JSON.stringify(o,null,2)}`)}catch(e){throw new Error(`Error while getting input: ${e}`)}return o}static async askNumber(e,t,o,a,n){$.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${a}, initial: ${n}`);const s=new $(e).setMessage(t).setType("number");return"number"==typeof o&&s.setMin(o),"number"==typeof a&&s.setMax(a),"number"==typeof n&&s.setInitial(n),(await this.ask(s))[e]}static async askText(e,t,o=void 0,a){$.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${a}`);const n=new $(e).setMessage(t);return o&&n.setMask(o),"string"==typeof a&&n.setInitial(a),(await this.ask(n))[e]}static async askConfirmation(e,t,o){$.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const a=new $(e).setMessage(t).setType("confirm");return void 0!==o&&a.setInitial(o),(await this.ask(a))[e]}static async insist(e,t,o,a=1){const n=$.logger.for(this.insist);let s;n.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${a}`);let i,r=0;try{do{s=(await $.ask(e))[e.name],t(s)?(i=await $.askConfirmation(`${e.name}-confirm`,`Is the ${e.type} correct?`,o),i||(s=void 0)):s=void 0}while(void 0===s&&a>1&&r++<a)}catch(e){throw n.error(`Error while insisting: ${e}`),e}return void 0===s&&n.info("no selection..."),s}static async insistForText(e,t,o,a=void 0,n,s=!1,i=-1){$.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${a}, initial: ${n}, defaultConfirmation: ${s}, limit: ${i}`);const r=new $(e).setMessage(t);return a&&r.setMask(a),"string"==typeof n&&r.setInitial(n),await this.insist(r,o,s,i)}static async insistForNumber(e,t,o,a,n,s,i=!1,r=-1){$.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${a}, max: ${n}, initial: ${s}, defaultConfirmation: ${i}, limit: ${r}`);const l=new $(e).setMessage(t).setType("number");return"number"==typeof a&&l.setMin(a),"number"==typeof n&&l.setMax(n),"number"==typeof s&&l.setInitial(s),await this.insist(l,o,i,r)}static parseArgs(e){const t=$.logger.for(this.parseArgs),a={args:process.argv.slice(2),options:e};t.debug(`Parsing arguments: ${JSON.stringify(a,null,2)}`);try{return o.parseArgs(a)}catch(o){throw t.debug(`Error while parsing arguments:\n${JSON.stringify(a,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${o}`),new Error(`Error while parsing arguments: ${o}`)}}}const E={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}},I=Object.keys(E).reduce((e,t)=>(e[t]=E[t].default,e),{}),F="utf-8",j=/^(\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 A="-no-ci",N="postinstall";var P;e.Tokens=void 0,(P=e.Tokens||(e.Tokens={})).GIT=".token",P.NPM=".npmtoken",P.DOCKER=".dockertoken",P.CONFLUENCE=".confluence-token";const O="Aborted";class L{constructor(e,t,...o){this.cmd=e,this.lock=t,this.logger=a.Logging.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString(F):t;const o="stderr"===e?r.style(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",String(e))}error(e){this.log("stderr",String(e))}errors(e){this.log("stderr",`Error executing command exited : ${e}`)}exit(e,t){this.log("stdout",`command exited code : ${0===e?r.style(e.toString()).green.text:r.style(null===e?"null":e.toString()).red.text}`),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(new Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){return e="string"==typeof e?e.split(" "):e,this.cmd=e.join(" "),[e[0],e.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${r.style(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=new Error("number"==typeof e?`Exit code ${e}`:e)),this.log("stderr",`${this.cmd} failed to execute: ${r.style(e.message).red}`),this.lock.reject(e)}}function B(e,...t){let o,a;if(e instanceof AbortSignal?(a=new AbortController,o=[e,...t]):(a=e,o=t),a.signal.aborted)return a;const n=()=>a.abort();for(const e of o){if(e.aborted){a.abort();break}e.addEventListener("abort",n,{once:!0,signal:a.signal})}return a}function M(e,t,o,a,n){function s(t,a){const[s,r]=e.parseCommand(t);n.info(`Running command: ${s}`),n.debug(`with args: ${r.join(" ")}`);const l=i.spawn(s,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:a.signal});return n.verbose(`pid : ${l.pid}`),l}const r=t.match(/[<>$#]/g);if(r)throw new Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],n=new Array(e.length);n[0]=a;for(let t=0;t<e.length;t++)0!==t&&(n[t]=B(n[t-1].signal)),o.push(s(e[t],n[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return s(t,a)}function U(e,t={},o=L,...n){const s=a.Logging.for(U),i=new AbortController,r={abort:i,command:e,logs:[],errs:[]},l=new Promise((a,l)=>{let c;try{c=new o(e,{resolve:a,reject:l},...n),r.cmd=M(c,e,t,i,s)}catch(t){return l(new Error(`Error running command ${e}: ${t}`))}r.cmd.stdout.setEncoding("utf8"),r.cmd.stdout.on("data",e=>{e=e.toString(),r.logs.push(e),c.data(e)}),r.cmd.stderr.on("data",e=>{e=e.toString(),r.errs.push(e),c.error(e)}),r.cmd.once("error",e=>{c.exit(e.message,r.errs)}),r.cmd.once("exit",(e=0)=>{i.signal.aborted&&null===e&&(e=O),c.exit(e,0===e?r.logs:r.errs)})});return Object.assign(r,{promise:l,pipe:async t=>{const o=s.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const a=await l;return o.verbose(`Piping output to ${t.name}: ${a}`),t(a)}catch(e){throw o.error(`Error piping command output: ${e}`),e}}}),r}const R=a.Logging.for("fs");function J(e,t){const o=R.for(J);if(!w.default.existsSync(e))throw new Error(`File not found at path "${e}".`);let n=V(e);try{o.verbose(`Patching file "${e}"...`),o.debug(`with value: ${JSON.stringify(t)}`),n=a.patchString(n,t)}catch(e){throw new Error(`Error patching file: ${e}`)}q(e,n)}function V(e){const t=R.for(V);try{return t.verbose(`Reading file "${e}"...`),w.default.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),new Error(`Error reading file "${e}": ${o}`)}}function q(e,t){const o=R.for(q);try{o.verbose(`Writing file "${e} with ${t.length} bytes...`),w.default.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),new Error(`Error writing file "${e}": ${t}`)}}function G(e,t){const o=R.for(G),a=[];try{o.verbose(`Retrieving all files from "${e}"...`);return w.default.readdirSync(e).forEach(t=>{const o=T.default.join(e,t),n=w.default.statSync(o);n.isFile()?a.push(o):n.isDirectory()&&a.push(...G(o))}),t?a.filter(t):a}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),new Error(`Error retrieving files from "${e}": ${t}`)}}async function W(e,t){const o=R.for(W);let a,n;try{a=w.default.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{n=w.default.statSync(t)}catch(e){}if(n)throw o.verbose(`Destination path "${t}" already exists`),new Error(`Destination path "${t}" already exists`);try{o.verbose(`Renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),w.default.renameSync(e,t),o.verbose(`Successfully renamed to "${t}"`)}catch(n){throw o.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${n}`),new Error(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${n}`)}}function X(e,t){const o=R.for(X);let a,n;try{a=w.default.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{n=w.default.statSync(t)}catch(e){a.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),w.default.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),w.default.cpSync(e,t,{recursive:!0})}catch(n){throw o.verbose(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`),new Error(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`)}}function _(e){const t=R.for(_);try{const o=w.default.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),w.default.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&w.default.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),new Error(`Error Deleting "${e}": ${o}`)}}function H(e=process.cwd(),t){let o;try{o=JSON.parse(V(T.default.join(e,"package.json")))}catch(e){throw new Error(`Failed to retrieve package information" ${e}`)}if(t){if(!(t in o))throw new Error(`Property "${t}" not found in package.json`);return o[t]}return o}function K(e,t,o=process.cwd()){const a=H(o);a[e]=t,q(T.default.join(o,"package.json"),JSON.stringify(a,null,2))}function z(e=process.cwd()){return H(e,"version")}async function Y(e=process.cwd()){let t;try{t=JSON.parse(await U("npm ls --json",{cwd:e}).promise)}catch(e){throw new Error(`Failed to retrieve dependencies: ${e}`)}const o=(e,t)=>({name:e[0],version:e[1].version});return{prod:Object.entries(t.dependencies||{}).map(o),dev:Object.entries(t.devDependencies||{}).map(o),peer:Object.entries(t.peerDependencies||{}).map(o)}}async function Z(e){const t=R.for(Z),o=e.prod||[],a=e.dev||[],n=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await U(`npm install ${o.join(" ")}`,{cwd:process.cwd()}).promise),a.length&&(t.info(`Installing devDependencies ${a.join(", ")}...`),await U(`npm install --save-dev ${a.join(" ")}`,{cwd:process.cwd()}).promise),n.length&&(t.info(`Installing peerDependencies ${n.join(", ")}...`),await U(`npm install --save-peer ${n.join(" ")}`,{cwd:process.cwd()}).promise)}const Q=[{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’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’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’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’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’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’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’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’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’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:"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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],ee=["","","","","","","","",""];function te(e){const t=oe(),o="# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░ ░▒▓████████▓▒░ ░▒▓████████▓▒░ ░▒▓███████▓▒░ \n# ( ( ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ) ) ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# [=======] ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ \n# `-----´ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓███████▓▒░ \n#".split("\n"),a=o.reduce((e,t)=>Math.max(e,t.length),0);o.push(`# ${t.padStart(a-3)}`),o.forEach((t,o)=>{(e?e.info.bind(e):console.log.bind(console))(r.style(t||"").raw(ee[o]).text)})}function oe(e){try{return e=void 0===e?Math.floor(Math.random()*Q.length):e,Q[e].Slogan}catch(e){throw new Error(`Failed to retrieve slogans: ${e}`)}}class ae extends a.LoggedClass{constructor(e,t={},o=[]){super(),this.name=e,this.inputs=t,this.requirements=o,ae.log||Object.defineProperty(ae,"log",{writable:!1,value:a.Logging.for(ae.name)}),this.inputs=Object.assign({},E,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await Y(),a=[],n=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)n.includes(e)||a.push(e);a.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=$.parseArgs(this.inputs),t=a.LoggedEnvironment.accumulate(I).accumulate(e.values),{version:o,help:n,banner:s}=t;if(o)return z();if(n)return this.help(e);let i;s&&te(this.log.for(te,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{i=await this.run(t)}catch(e){throw e}return i}}class ne{static{this.log=a.Logging.for(ne)}static async downloadFile(e){return new Promise((t,o)=>{!function e(a){a=encodeURI(a),b.default.get(a,n=>{if(301===n.statusCode||307===n.statusCode)return e(n.headers.location);if(200!==n.statusCode)return ne.log.error(`Failed to fetch ${a} (status: ${n.statusCode})`),o(new Error(`Failed to fetch ${a}`));let s="";n.on("data",e=>{s+=e}),n.on("error",e=>{o(e)}),n.on("end",()=>{t(s)})})}(e)})}}function se(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 re(){let e;try{e=H(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=T.default.resolve(__dirname,"../../..");try{e=H(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),a=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...a]))}var le,ce;!function(e){e.CJS="commonjs",e.ESM="es2022"}(le||(le={})),function(e){e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"}(ce||(ce={}));const ge={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:ce.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},banner:{type:"boolean",default:!1}},de=(e=".cjs")=>{const t=fe.log.for(de),o=new Map;return a=>n=>{const s=T.default.dirname(n.fileName);function i(a){const n=JSON.stringify([s,a]),i=o.get(n);if(null!=i)return i;let r,l=a;try{l=T.default.resolve(s,l+".ts")}catch(e){throw new Error(`Failed to resolve path ${a}: ${e}`)}try{r=w.default.statSync(l)}catch(e){try{t.verbose(`Testing existence of path ${l} as a folder defaulting to index file`),r=w.default.statSync(l.replace(/\.ts$/gm,""))}catch(t){throw new Error(`Failed to resolve path ${a}: ${e}, ${t}`)}}if(r.isDirectory()&&(l=l.replace(/\.ts$/gm,"/index.ts")),T.default.isAbsolute(l)){const t=(/\.tsx?$/.exec(T.default.basename(l))||[])[0]||void 0;l="./"+T.default.relative(s,T.default.resolve(T.default.dirname(l),T.default.basename(l,t)+e))}return o.set(n,l),l}return k.visitNode(n,function e(t){if(function(e){return!(!k.isImportDeclaration(e)&&!k.isExportDeclaration(e))&&(void 0!==e.moduleSpecifier&&(!!k.isStringLiteral(e.moduleSpecifier)&&(!(!e.moduleSpecifier.text.startsWith("./")&&!e.moduleSpecifier.text.startsWith("../"))&&""===T.default.extname(e.moduleSpecifier.text))))}(t)){if(k.isImportDeclaration(t)){const e=i(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(k.isExportDeclaration(t)){const e=i(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}return k.visitEachChild(t,e,a)})}};class fe extends ae{constructor(){super("BuildScripts",Object.assign({},E,ge)),this.replacements={};const e=H(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o,this.replacements["0.4.1"]=this.pkgVersion,this.replacements["@decaf-ts/utils"]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:a}=H();t.info(`Patching ${o} ${a} module in ${e}...`);w.default.statSync(e).isDirectory()&&w.default.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>J(T.default.join(e.parentPath,e.name),this.replacements)),t.verbose(`Module ${o} ${a} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);if(!Object.values(a.LogLevel).includes(t))throw new Error(`Invalid LogLevel ${t}`);try{this.log[t](o)}catch(e){throw console.warn(`Failed to get logger for ${t}`),e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:a}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${a+1})`}return t+=": "+k.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=w.default.readFileSync(e).toString(),o=k.parseConfigFileTextToJson(e,t),n=o.config;n||this.reportDiagnostics([o.error],a.LogLevel.error);const s=k.parseJsonConfigFileContent(n,k.sys,T.default.dirname(e));return s.errors.length>0&&this.reportDiagnostics(s.errors,a.LogLevel.error),s}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===k.DiagnosticCategory.Error),o=e.filter(e=>e.category===k.DiagnosticCategory.Warning),n=e.filter(e=>e.category===k.DiagnosticCategory.Suggestion),s=e.filter(e=>e.category===k.DiagnosticCategory.Message);o.length&&this.reportDiagnostics(o,a.LogLevel.info),t.length&&(this.reportDiagnostics(e,a.LogLevel.error),this.log.info(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`)),n.length&&this.reportDiagnostics(n,a.LogLevel.info),s.length&&this.reportDiagnostics(s,a.LogLevel.info)}}preCheckDiagnostics(e){const t=k.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const a=this.log.for(this.checkTsDiagnostics);let n;try{n=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(n.options.module=p.ModuleKind.AMD,n.options.outDir="dist",n.options.isolatedModules=!1,n.options.outFile=this.pkgName):(n.options.outDir="lib"+(t===le.ESM?"/esm":""),n.options.module=t===le.ESM?p.ModuleKind.ES2022:p.ModuleKind.CommonJS),e?(n.options.inlineSourceMap=!0,n.options.sourceMap=!1):n.options.sourceMap=!1;const s=k.createProgram(n.fileNames,n.options);this.preCheckDiagnostics(s),a.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let a;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{a=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(a.options.module=p.ModuleKind.AMD,a.options.outDir="dist",a.options.isolatedModules=!1,a.options.outFile=this.pkgName):(a.options.outDir="lib"+(t===le.ESM?"/esm":""),a.options.module=t===le.ESM?p.ModuleKind.ES2022:p.ModuleKind.CommonJS),e?(a.options.inlineSourceMap=!0,a.options.sourceMap=!1):a.options.sourceMap=!1;const n=k.createProgram(a.fileNames,a.options),s={};t===le.CJS?s.before=[de(".cjs")]:t===le.ESM&&(s.before=[de(".js")]);const i=n.emit(void 0,void 0,void 0,void 0,s),r=k.getPreEmitDiagnostics(n).concat(i.diagnostics);this.evalDiagnostics(r)}async build(e,t,o=!1){const a=this.log.for(this.build);if(await this.buildTs(e,t,o),a.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t===le.CJS&&!o){const e=G("lib",e=>e.endsWith(".js")&&!e.includes("/esm/"));for(const t of e){a.verbose(`Patching ${t}'s cjs imports...`);const e=t.replace(".js",".cjs");await W(t,e)}}}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=w.default.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&X("./src/assets",`./${e===le.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,a="src/index.ts",n=this.pkgName,s,i=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const r=e===le.ESM,l=this.pkgName,g=Array.from(new Set([...se(i)]));let d=se(s);0===d.length&&(d=re());const u=Array.from(new Set([...function(){try{return Array.isArray(h.builtinModules)?h.builtinModules:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}}(),...d])),p=[C.default({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist"},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),D.default()];if(!t)try{const w=await import("@rollup/plugin-terser"),T=w&&w.terser||w.default||w;p.push(T())}catch{}o&&p.push(v.default({include:[],exclude:d}),f.nodeResolve({resolveOnly:g}));const m={input:a,plugins:p,external:u},S={};u.forEach(e=>{S[e]=ie(e)});const y=[{file:`${o?"bin/":"dist/"}${n||".bundle."+(t?"":"min")}${r?".esm":""}.cjs`,format:o?"cjs":r?"esm":"umd",name:l,esModule:r,sourcemap:!!t&&"inline",globals:S,exports:"auto"}];try{const b=await c.rollup(m);async function k(e){for(const t of y)await e.write(t)}console.log(b.watchFiles),await k(b)}catch($){throw new Error(`Failed to bundle: ${$}`)}}async buildByEnv(e,t=ce.ALL,o,a){try{_("lib")}catch(e){}try{_("dist")}catch(e){}w.default.mkdirSync("lib"),w.default.mkdirSync("dist"),[ce.ALL,ce.BUILD].includes(t)&&(await this.build(e,le.ESM),await this.build(e,le.CJS),this.patchFiles("lib")),[ce.ALL,ce.BUNDLE].includes(t)&&(await this.bundle(le.ESM,e,!1,"src/index.ts",this.pkgName,a,o),await this.bundle(le.CJS,e,!1,"src/index.ts",this.pkgName,a,o),this.patchFiles("dist")),this.copyAssets(le.CJS),this.copyAssets(le.ESM)}async buildDev(e=ce.ALL,t,o){return this.buildByEnv(!0,e,t,o)}async buildProd(e=ce.ALL,t,o){return this.buildByEnv(!1,e,t,o)}async buildDocs(){await U("npm install better-docs taffydb").promise,await U("npx markdown-include ./workdocs/readme-md.json").promise,await U("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await U("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;X(t,o)})}async run(e){const{dev:t,prod:o,docs:a,buildMode:n,includes:s,externals:i}=e;return t?await this.buildDev(n,s,i):o?await this.buildProd(n,s,i):a?await this.buildDocs():void 0}}const ue={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}};const he="https://raw.githubusercontent.com/decaf-ts/ts-workspace/master",pe={templates:[".github/ISSUE_TEMPLATE/bug_report.md",".github/ISSUE_TEMPLATE/feature_request.md",".github/FUNDING.yml"],workflows:[".github/workflows/codeql-analysis.yml",".github/workflows/jest-coverage.yaml",".github/workflows/nodejs-build-prod.yaml",".github/workflows/pages.yaml",".github/workflows/publish-on-release.yaml",".github/workflows/release-on-tag.yaml",".github/workflows/snyk-analysis.yaml"],ide:[".idea/runConfigurations/All Tests.run.xml",".idea/runConfigurations/build.run.xml",".idea/runConfigurations/build_prod.run.xml",".idea/runConfigurations/coverage.run.xml",".idea/runConfigurations/docs.run.xml",".idea/runConfigurations/drawings.run.xml",".idea/runConfigurations/flash-forward.run.xml",".idea/runConfigurations/Integration_Tests.run.xml",".idea/runConfigurations/Bundling_Tests.run.xml",".idea/runConfigurations/lint-fix.run.xml",".idea/runConfigurations/release.run.xml",".idea/runConfigurations/test_circular.run.xml",".idea/runConfigurations/uml.run.xml",".idea/runConfigurations/Unit Tests.run.xml",".idea/runConfigurations/update-scripts.run.xml"],docs:["workdocs/tutorials/Contributing.md","workdocs/tutorials/Documentation.md","workdocs/tutorials/For Developers.md","workdocs/2-Badges.md","workdocs/jsdocs.json","workdocs/readme-md.json"],styles:[".prettierrc","eslint.config.js"],scripts:["bin/update-scripts.cjs","bin/tag-release.cjs","bin/build-scripts.cjs"],tests:["jest.config.ts","workdocs/reports/jest.coverage.config.ts"],typescript:["tsconfig.json"],docker:["Dockerfile"],automation:["workdocs/confluence/Continuous Integration-Deployment/GitHub.md","workdocs/confluence/Continuous Integration-Deployment/Jira.md","workdocs/confluence/Continuous Integration-Deployment/Teams.md"]},me={boot:{type:"boolean"},org:{type:"string",short:"o"},name:{type:"string",short:"n",default:void 0},author:{type:"string",short:"a",default:void 0},all:{type:"boolean"},license:{type:"string",message:"Pick the license"},scripts:{type:"boolean"},styles:{type:"boolean"},docs:{type:"boolean"},ide:{type:"boolean"},workflows:{type:"boolean"},templates:{type:"boolean"},typescript:{type:"boolean"},docker:{type:"boolean"},pkg:{type:"boolean"},dependencies:{type:"boolean"},tests:{type:"boolean"},automation:{type:"boolean"}};e.AbortCode=O,e.BuildScripts=fe,e.Command=ae,e.DefaultCommandOptions=E,e.DefaultCommandValues=I,e.Encoding=F,e.HttpClient=ne,e.NoCIFLag=A,e.PACKAGE_NAME="@decaf-ts/utils",e.RegexpOutputWriter=class extends L{constructor(e,t,o,a="g"){super(e,t);try{this.regexp="string"==typeof o?new RegExp(o,a):o}catch(e){throw new Error(`Invalid regular expression: ${e}`)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(t){return console.debug(`Failed to parse chunk: ${e}\nError: ${t} `)}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(String(e))}error(e){super.error(e),this.testAndReject(String(e))}},e.ReleaseScript=class extends ae{constructor(){super("ReleaseScript",ue)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release message provided. Prompting for one:"),t.info("Listing latest git tags:"),await U("git tag --sort=-taggerdate | head -n 5").promise,await $.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),new RegExp(j).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 $.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}async run(e){let t;const{ci:o}=e;let{tag:a,message:n}=e;a=await this.prepareVersion(a),n=await this.prepareMessage(n),t=await U(`npm run prepare-release -- ${a} ${n}`,{cwd:process.cwd()}).promise,t=await U("git status --porcelain").promise,await t,t.logs.length&&await $.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await U("git add .").promise,await U(`git commit -m "${a} - ${n} - after release preparation${o?"":A}"`).promise),await U(`npm version "${a}" -m "${n}${o?"":A}"`).promise,await U("git push --follow-tags").promise,o||await U("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}},e.SemVersionRegex=j,e.SetupScriptKey=N,e.StandardOutputWriter=L,e.TemplateSync=class extends ae{constructor(){super("TemplateSync",me),this.replacements={},this.getStyles=()=>this.downloadOption("styles"),this.getTemplates=()=>this.downloadOption("templates"),this.getWorkflows=()=>this.downloadOption("workflows"),this.getDocs=()=>this.downloadOption("docs"),this.getTypescript=()=>this.downloadOption("typescript"),this.getAutomation=()=>this.downloadOption("automation"),this.getTests=()=>this.downloadOption("tests"),this.getDocker=()=>this.downloadOption("docker")}loadValuesFromPackage(){const e=process.cwd(),t=H(e,"author");let o,a=H(e,"name");if(a.startsWith("@")){const e=a.split("/");a=e[1],o=e[0].replace("@","")}["Tiago Venceslau","TiagoVenceslau","${author}"].forEach(e=>this.replacements[e]=t),["TS-Workspace","ts-workspace","${name}"].forEach(e=>this.replacements[e]=a),["decaf-ts","${org}"].forEach(e=>this.replacements[e]=o||'""'),this.replacements["${org_or_owner}"]=o||a}async downloadOption(e){if(!(e in pe))throw new Error(`Option "${e}" not found in options`);const t=pe[e];for(const e of t){this.log.info(`Downloading ${e}`);let t=await ne.downloadFile(`${he}/${e}`);t=a.patchString(t,this.replacements),q(T.default.join(process.cwd(),e),t)}}async getLicense(e){this.log.info(`Downloading ${e} license`);const t=`${he}/workdocs/licenses/${e}.md`;let o=await ne.downloadFile(t);o=a.patchString(o,this.replacements),q(T.default.join(process.cwd(),"LICENSE.md"),o),K("license",e)}async getIde(){w.default.mkdirSync(T.default.join(process.cwd(),".idea","runConfigurations"),{recursive:!0}),await this.downloadOption("ide")}async getScripts(){await this.downloadOption("scripts"),this.log.info("please re-run the command"),process.exit(0)}async initPackage(e,t,o){try{const a=H();delete a[N],a.name=e,a.version="0.0.1",a.author=t,a.license=o,w.default.writeFileSync("package.json",JSON.stringify(a,null,2))}catch(e){throw new Error(`Error fixing package.json: ${e}`)}}async updatePackageScrips(){try{const e=JSON.parse(await ne.downloadFile(`${he}/package.json`)),{scripts:t}=e,o=H();Object.keys(o.scripts).forEach(e=>{if(e in t){const n=a.patchString(t[e],this.replacements);n!==t[e]&&(o.scripts[e]=n)}}),o.exports.require=e.exports.require,o.exports.import=e.exports.import,o.types=e.types,w.default.writeFileSync("package.json",JSON.stringify(o,null,2))}catch(e){throw new Error(`Error fixing package.json scripts: ${e}`)}}async createTokenFiles(){const t=this.log.for(this.createTokenFiles),o=await $.insistForText("token","please input your github token",e=>!!e.match(/^ghp_[0-9a-zA-Z]{36}$/g));Object.values(e.Tokens).forEach(e=>{try{let a;try{a=w.default.existsSync(e)}catch(a){return t.info(`Token file ${e} not found. Creating a new one...`),void w.default.writeFileSync(e,".token"===e?o:"")}a||w.default.writeFileSync(e,".token"===e?o:"")}catch(t){throw new Error(`Error creating token file ${e}: ${t}`)}})}async getOrg(){const e=await $.askText("Organization","Enter the organization name (will be used to scope your npm project. leave blank to create a unscoped project):");return await $.askConfirmation("Confirm organization","Is this organization correct?",!0)?e:this.getOrg()}async auditFix(){return await U("npm audit fix --force").promise}patchFiles(){const e=[...w.default.readdirSync(T.default.join(process.cwd(),"src"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>T.default.join(e.parentPath,e.name)),...w.default.readdirSync(T.default.join(process.cwd(),"workdocs"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".md")).map(e=>T.default.join(e.parentPath,e.name)),T.default.join(process.cwd(),".gitlab-ci.yml"),T.default.join(process.cwd(),"workdocs","jsdocs.json")];for(const t of e)J(t,this.replacements)}async updateDependencies(){try{const e=JSON.parse(await ne.downloadFile(`${he}/package.json`)),{devDependencies:t}=e,o=H();Object.keys(o.scripts).forEach(e=>{if(e in t){const a=t[e];a!==t[e]&&(o.devDependencies=o.devDependencies||{},o.devDependencies[e]=a)}}),w.default.writeFileSync("package.json",JSON.stringify(o,null,2)),await U("npm install").promise}catch(e){throw new Error(`Error fixing package.json dependencies: ${e}`)}}async run(e){let{license:t}=e;const{boot:o}=e;let{all:a,scripts:n,styles:s,docs:i,ide:r,workflows:l,templates:c,docker:g,typescript:d,dependencies:f,tests:u,automation:h,pkg:p}=e;if((n||s||i||r||l||c||g||d||h||f||u||p)&&(a=!1),o){const e=await this.getOrg(),o=await $.insistForText("Project name","Enter the project name:",e=>e.length>1),a=await $.insistForText("Author","Enter the author name:",e=>e.length>1),n=e?`@${e}/${o}`:o;await this.initPackage(n,a,t),await this.createTokenFiles(),await this.auditFix(),this.patchFiles()}if(a&&(n=!1,s=!0,i=!0,r=!0,l=!0,c=!0,g=!0,d=!0,p=!0,f=!0,u=!0,h=!1),void 0===n&&(n=await $.askConfirmation("scripts","Do you want to get scripts?",!0)),n&&await this.getScripts(),this.loadValuesFromPackage(),!a&&void 0===t){await $.askConfirmation("license","Do you want to set a license?",!0)&&(t=await $.insistForText("license","Enter the desired License (MIT|GPL|Apache|LGPL|AGPL):",e=>!!e&&!!e.match(/^(MIT|GPL|Apache|LGPL|AGPL)$/g)))}void 0!==t&&await this.getLicense(t),void 0===r&&(r=await $.askConfirmation("ide","Do you want to get ide configs?",!0)),r&&await this.getIde(),void 0===d&&(d=await $.askConfirmation("typescript","Do you want to get typescript configs?",!0)),d&&await this.getTypescript(),void 0===g&&(g=await $.askConfirmation("docker","Do you want to get docker configs?",!0)),g&&await this.getDocker(),void 0===h&&(h=await $.askConfirmation("automation","Do you want to get automation configs?",!0)),h&&await this.getAutomation(),void 0===s&&(s=await $.askConfirmation("styles","Do you want to get styles?",!0)),s&&await this.getStyles(),void 0===i&&(i=await $.askConfirmation("docs","Do you want to get docs?",!0)),i&&await this.getDocs(),void 0===l&&(l=await $.askConfirmation("workflows","Do you want to get workflows?",!0)),l&&await this.getWorkflows(),void 0===c&&(c=await $.askConfirmation("templates","Do you want to get templates?",!0)),c&&await this.getTemplates(),void 0===p&&(p=await $.askConfirmation("pkg","Do you want to update your package.json scripts?",!0)),p&&await this.updatePackageScrips(),void 0===u&&(u=await $.askConfirmation("pkg","Do you want to update your test configs?",!0)),u&&await this.getTests(),void 0===f&&(f=await $.askConfirmation("pkg","Do you want to update dev dependencies?",!0)),f&&await this.updateDependencies()}},e.UserInput=$,e.VERSION="0.4.1",e.chainAbortController=B,e.copyFile=X,e.deletePath=_,e.getAllFiles=G,e.getDependencies=Y,e.getPackage=H,e.getPackageDependencies=re,e.getPackageVersion=z,e.getSlogan=oe,e.installDependencies=Z,e.installIfNotAvailable=async function(e,t){if(!t){const e=await Y();t={prod:e.prod?.map(e=>e.name)||[],dev:e.dev?.map(e=>e.name)||[],peer:e.peer?.map(e=>e.name)||[]}}const{prod:o,dev:a,peer:n}=t,s=Array.from(new Set([...o||[],...a||[],...n||[]])),i=(e="string"==typeof e?[e]:e).filter(e=>!s.includes(e));return i.length&&await Z({dev:i}),t.dev=t.dev||[],t.dev.push(...i),t},e.lockify=function(e){let t=Promise.resolve();return(...o)=>{const a=t.then(()=>e(...o));return t=a.catch(()=>{}),a}},e.normalizeImport=async function(e){return e.then(e=>e.default||e)},e.packageToGlobal=ie,e.parseList=se,e.patchFile=J,e.printBanner=te,e.pushToGit=async function e(){const t=R.for(e),o=await U("git config user.name").promise,a=await U("git config user.email").promise;t.verbose(`cached git id: ${o}/${a}. changing to automation`),await U('git config user.email "automation@decaf.ts"').promise,await U('git config user.name "decaf"').promise,t.info("Pushing changes to git..."),await U("git add .").promise,await U('git commit -m "refs #1 - after repo setup"').promise,await U("git push").promise,await U(`git config user.email "${a}"`).promise,await U(`git config user.name "${o}"`).promise,t.verbose(`reverted to git id: ${o}/${a}`)},e.readFile=V,e.renameFile=W,e.runCommand=U,e.setPackageAttribute=K,e.spawnCommand=M,e.updateDependencies=async function e(){const t=R.for(e);t.info("checking for updates..."),await U("npx npm-check-updates -u").promise,t.info("updating..."),await U("npx npm run do-install").promise},e.writeFile=q});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prompts"),require("util"),require("@decaf-ts/logging"),require("fs"),require("path"),require("child_process"),require("styled-string-builder"),require("https"),require("rollup"),require("@rollup/plugin-typescript"),require("@rollup/plugin-commonjs"),require("@rollup/plugin-node-resolve"),require("@rollup/plugin-json"),require("module"),require("typescript")):"function"==typeof define&&define.amd?define(["exports","prompts","util","@decaf-ts/logging","fs","path","child_process","styled-string-builder","https","rollup","@rollup/plugin-typescript","@rollup/plugin-commonjs","@rollup/plugin-node-resolve","@rollup/plugin-json","module","typescript"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).utils={},e.prompts,e.util,e.decafTsLogging,e.fs,e.path,e.childProcess,e.styledStringBuilder,e.https,e.rollup,e.rollupPluginTypescript,e.rollupPluginCommonjs,e.rollupPluginNodeResolve,e.rollupPluginJson,e.module,e.typescript)}(this,function(e,t,o,a,n,s,i,r,l,c,g,d,f,u,h,p){"use strict";function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function S(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}var y=m(t),w=m(n),T=m(s),b=m(l),C=m(g),v=m(d),D=m(u),k=S(p);class ${static{this.logger=a.Logging.for($)}constructor(e){this.type="text",this.name=e}setType(e){return $.logger.verbose(`Setting type to: ${e}`),this.type=e,this}setMessage(e){return $.logger.verbose(`Setting message to: ${e}`),this.message=e,this}setInitial(e){return $.logger.verbose(`Setting initial value to: ${e}`),this.initial=e,this}setStyle(e){return $.logger.verbose(`Setting style to: ${e}`),this.style=e,this}setFormat(e){return $.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return $.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return $.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return $.logger.verbose(`Setting min value to: ${e}`),this.min=e,this}setMax(e){return $.logger.verbose(`Setting max value to: ${e}`),this.max=e,this}setFloat(e){return $.logger.verbose(`Setting float to: ${e}`),this.float=e,this}setRound(e){return $.logger.verbose(`Setting round to: ${e}`),this.round=e,this}setInstructions(e){return $.logger.verbose(`Setting instructions to: ${e}`),this.instructions=e,this}setIncrement(e){return $.logger.verbose(`Setting increment to: ${e}`),this.increment=e,this}setSeparator(e){return $.logger.verbose(`Setting separator to: ${e}`),this.separator=e,this}setActive(e){return $.logger.verbose(`Setting active style to: ${e}`),this.active=e,this}setInactive(e){return $.logger.verbose(`Setting inactive style to: ${e}`),this.inactive=e,this}setChoices(e){return $.logger.verbose(`Setting choices: ${JSON.stringify(e)}`),this.choices=e,this}setHint(e){return $.logger.verbose(`Setting hint to: ${e}`),this.hint=e,this}setWarn(e){return $.logger.verbose(`Setting warn to: ${e}`),this.warn=e,this}setSuggest(e){return $.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return $.logger.verbose(`Setting limit to: ${e}`),this.limit=e,this}setMask(e){return $.logger.verbose(`Setting mask to: ${e}`),this.mask=e,this}setStdout(e){return $.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await $.ask(this))[this.name]}static async ask(e){const t=$.logger.for(this.ask);let o;Array.isArray(e)||(e=[e]);try{t.verbose(`Asking questions: ${e.map(e=>e.name).join(", ")}`),o=await y.default(e),t.verbose(`Received answers: ${JSON.stringify(o,null,2)}`)}catch(e){throw new Error(`Error while getting input: ${e}`)}return o}static async askNumber(e,t,o,a,n){$.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${a}, initial: ${n}`);const s=new $(e).setMessage(t).setType("number");return"number"==typeof o&&s.setMin(o),"number"==typeof a&&s.setMax(a),"number"==typeof n&&s.setInitial(n),(await this.ask(s))[e]}static async askText(e,t,o=void 0,a){$.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${a}`);const n=new $(e).setMessage(t);return o&&n.setMask(o),"string"==typeof a&&n.setInitial(a),(await this.ask(n))[e]}static async askConfirmation(e,t,o){$.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const a=new $(e).setMessage(t).setType("confirm");return void 0!==o&&a.setInitial(o),(await this.ask(a))[e]}static async insist(e,t,o,a=1){const n=$.logger.for(this.insist);let s;n.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${a}`);let i,r=0;try{do{s=(await $.ask(e))[e.name],t(s)?(i=await $.askConfirmation(`${e.name}-confirm`,`Is the ${e.type} correct?`,o),i||(s=void 0)):s=void 0}while(void 0===s&&a>1&&r++<a)}catch(e){throw n.error(`Error while insisting: ${e}`),e}return void 0===s&&n.info("no selection..."),s}static async insistForText(e,t,o,a=void 0,n,s=!1,i=-1){$.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${a}, initial: ${n}, defaultConfirmation: ${s}, limit: ${i}`);const r=new $(e).setMessage(t);return a&&r.setMask(a),"string"==typeof n&&r.setInitial(n),await this.insist(r,o,s,i)}static async insistForNumber(e,t,o,a,n,s,i=!1,r=-1){$.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${a}, max: ${n}, initial: ${s}, defaultConfirmation: ${i}, limit: ${r}`);const l=new $(e).setMessage(t).setType("number");return"number"==typeof a&&l.setMin(a),"number"==typeof n&&l.setMax(n),"number"==typeof s&&l.setInitial(s),await this.insist(l,o,i,r)}static parseArgs(e){const t=$.logger.for(this.parseArgs),a={args:process.argv.slice(2),options:e};t.debug(`Parsing arguments: ${JSON.stringify(a,null,2)}`);try{return o.parseArgs(a)}catch(o){throw t.debug(`Error while parsing arguments:\n${JSON.stringify(a,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${o}`),new Error(`Error while parsing arguments: ${o}`)}}}const E={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}},I=Object.keys(E).reduce((e,t)=>(e[t]=E[t].default,e),{}),F="utf-8",j=/^(\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 A="-no-ci",N="postinstall";var P;e.Tokens=void 0,(P=e.Tokens||(e.Tokens={})).GIT=".token",P.NPM=".npmtoken",P.DOCKER=".dockertoken",P.CONFLUENCE=".confluence-token";const O="Aborted";class L{constructor(e,t,...o){this.cmd=e,this.lock=t,this.logger=a.Logging.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString(F):t;const o="stderr"===e?r.style(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",String(e))}error(e){this.log("stderr",String(e))}errors(e){this.log("stderr",`Error executing command exited : ${e}`)}exit(e,t){this.log("stdout",`command exited code : ${0===e?r.style(e.toString()).green.text:r.style(null===e?"null":e.toString()).red.text}`),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(new Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){return e="string"==typeof e?e.split(" "):e,this.cmd=e.join(" "),[e[0],e.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${r.style(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=new Error("number"==typeof e?`Exit code ${e}`:e)),this.log("stderr",`${this.cmd} failed to execute: ${r.style(e.message).red}`),this.lock.reject(e)}}function B(e,...t){let o,a;if(e instanceof AbortSignal?(a=new AbortController,o=[e,...t]):(a=e,o=t),a.signal.aborted)return a;const n=()=>a.abort();for(const e of o){if(e.aborted){a.abort();break}e.addEventListener("abort",n,{once:!0,signal:a.signal})}return a}function M(e,t,o,a,n){function s(t,a){const[s,r]=e.parseCommand(t);n.info(`Running command: ${s}`),n.debug(`with args: ${r.join(" ")}`);const l=i.spawn(s,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:a.signal});return n.verbose(`pid : ${l.pid}`),l}const r=t.match(/[<>$#]/g);if(r)throw new Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],n=new Array(e.length);n[0]=a;for(let t=0;t<e.length;t++)0!==t&&(n[t]=B(n[t-1].signal)),o.push(s(e[t],n[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return s(t,a)}function U(e,t={},o=L,...n){const s=a.Logging.for(U),i=new AbortController,r={abort:i,command:e,logs:[],errs:[]},l=new Promise((a,l)=>{let c;try{c=new o(e,{resolve:a,reject:l},...n),r.cmd=M(c,e,t,i,s)}catch(t){return l(new Error(`Error running command ${e}: ${t}`))}r.cmd.stdout.setEncoding("utf8"),r.cmd.stdout.on("data",e=>{e=e.toString(),r.logs.push(e),c.data(e)}),r.cmd.stderr.on("data",e=>{e=e.toString(),r.errs.push(e),c.error(e)}),r.cmd.once("error",e=>{c.exit(e.message,r.errs)}),r.cmd.once("exit",(e=0)=>{i.signal.aborted&&null===e&&(e=O),c.exit(e,0===e?r.logs:r.errs)})});return Object.assign(r,{promise:l,pipe:async t=>{const o=s.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const a=await l;return o.verbose(`Piping output to ${t.name}: ${a}`),t(a)}catch(e){throw o.error(`Error piping command output: ${e}`),e}}}),r}const R=a.Logging.for("fs");function J(e,t){const o=R.for(J);if(!w.default.existsSync(e))throw new Error(`File not found at path "${e}".`);let n=V(e);try{o.verbose(`Patching file "${e}"...`),o.debug(`with value: ${JSON.stringify(t)}`),n=a.patchString(n,t)}catch(e){throw new Error(`Error patching file: ${e}`)}q(e,n)}function V(e){const t=R.for(V);try{return t.verbose(`Reading file "${e}"...`),w.default.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),new Error(`Error reading file "${e}": ${o}`)}}function q(e,t){const o=R.for(q);try{o.verbose(`Writing file "${e} with ${t.length} bytes...`),w.default.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),new Error(`Error writing file "${e}": ${t}`)}}function G(e,t){const o=R.for(G),a=[];try{o.verbose(`Retrieving all files from "${e}"...`);return w.default.readdirSync(e).forEach(t=>{const o=T.default.join(e,t),n=w.default.statSync(o);n.isFile()?a.push(o):n.isDirectory()&&a.push(...G(o))}),t?a.filter(t):a}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),new Error(`Error retrieving files from "${e}": ${t}`)}}async function W(e,t){const o=R.for(W);let a,n;try{a=w.default.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{n=w.default.statSync(t)}catch(e){}if(n)throw o.verbose(`Destination path "${t}" already exists`),new Error(`Destination path "${t}" already exists`);try{o.verbose(`Renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),w.default.renameSync(e,t),o.verbose(`Successfully renamed to "${t}"`)}catch(n){throw o.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${n}`),new Error(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${n}`)}}function X(e,t){const o=R.for(X);let a,n;try{a=w.default.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{n=w.default.statSync(t)}catch(e){a.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),w.default.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),w.default.cpSync(e,t,{recursive:!0})}catch(n){throw o.verbose(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`),new Error(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${n}`)}}function _(e){const t=R.for(_);try{const o=w.default.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),w.default.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&w.default.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),new Error(`Error Deleting "${e}": ${o}`)}}function H(e=process.cwd(),t){let o;try{o=JSON.parse(V(T.default.join(e,"package.json")))}catch(e){throw new Error(`Failed to retrieve package information" ${e}`)}if(t){if(!(t in o))throw new Error(`Property "${t}" not found in package.json`);return o[t]}return o}function K(e,t,o=process.cwd()){const a=H(o);a[e]=t,q(T.default.join(o,"package.json"),JSON.stringify(a,null,2))}function z(e=process.cwd()){return H(e,"version")}async function Y(e=process.cwd()){let t;try{t=JSON.parse(await U("npm ls --json",{cwd:e}).promise)}catch(e){throw new Error(`Failed to retrieve dependencies: ${e}`)}const o=(e,t)=>({name:e[0],version:e[1].version});return{prod:Object.entries(t.dependencies||{}).map(o),dev:Object.entries(t.devDependencies||{}).map(o),peer:Object.entries(t.peerDependencies||{}).map(o)}}async function Z(e){const t=R.for(Z),o=e.prod||[],a=e.dev||[],n=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await U(`npm install ${o.join(" ")}`,{cwd:process.cwd()}).promise),a.length&&(t.info(`Installing devDependencies ${a.join(", ")}...`),await U(`npm install --save-dev ${a.join(" ")}`,{cwd:process.cwd()}).promise),n.length&&(t.info(`Installing peerDependencies ${n.join(", ")}...`),await U(`npm install --save-peer ${n.join(" ")}`,{cwd:process.cwd()}).promise)}const Q=[{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’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’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’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’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’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’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’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’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’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:"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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],ee=["","","","","","","","",""];function te(e){const t=oe(),o="# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░ ░▒▓████████▓▒░ ░▒▓████████▓▒░ ░▒▓███████▓▒░ \n# ( ( ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ) ) ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# [=======] ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ \n# `-----´ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓███████▓▒░ \n#".split("\n"),a=o.reduce((e,t)=>Math.max(e,t.length),0);o.push(`# ${t.padStart(a-3)}`),o.forEach((t,o)=>{(e?e.info.bind(e):console.log.bind(console))(r.style(t||"").raw(ee[o]).text)})}function oe(e){try{return e=void 0===e?Math.floor(Math.random()*Q.length):e,Q[e].Slogan}catch(e){throw new Error(`Failed to retrieve slogans: ${e}`)}}class ae extends a.LoggedClass{constructor(e,t={},o=[]){super(),this.name=e,this.inputs=t,this.requirements=o,ae.log||Object.defineProperty(ae,"log",{writable:!1,value:a.Logging.for(ae.name)}),this.inputs=Object.assign({},E,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await Y(),a=[],n=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)n.includes(e)||a.push(e);a.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=$.parseArgs(this.inputs),t=a.LoggedEnvironment.accumulate(I).accumulate(e.values),{version:o,help:n,banner:s}=t;if(o)return z();if(n)return this.help(e);let i;s&&te(this.log.for(te,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{i=await this.run(t)}catch(e){throw e}return i}}class ne{static{this.log=a.Logging.for(ne)}static async downloadFile(e){return new Promise((t,o)=>{!function e(a){a=encodeURI(a),b.default.get(a,n=>{if(301===n.statusCode||307===n.statusCode)return e(n.headers.location);if(200!==n.statusCode)return ne.log.error(`Failed to fetch ${a} (status: ${n.statusCode})`),o(new Error(`Failed to fetch ${a}`));let s="";n.on("data",e=>{s+=e}),n.on("error",e=>{o(e)}),n.on("end",()=>{t(s)})})}(e)})}}function se(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 re(){let e;try{e=H(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=T.default.resolve(__dirname,"../../..");try{e=H(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),a=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...a]))}var le,ce;!function(e){e.CJS="commonjs",e.ESM="es2022"}(le||(le={})),function(e){e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"}(ce||(ce={}));const ge={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:ce.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},banner:{type:"boolean",default:!1}},de=(e=".cjs")=>{const t=fe.log.for(de),o=new Map;return a=>n=>{const s=T.default.dirname(n.fileName);function i(a){const n=JSON.stringify([s,a]),i=o.get(n);if(null!=i)return i;let r,l=a;try{l=T.default.resolve(s,l+".ts")}catch(e){throw new Error(`Failed to resolve path ${a}: ${e}`)}try{r=w.default.statSync(l)}catch(e){try{t.verbose(`Testing existence of path ${l} as a folder defaulting to index file`),r=w.default.statSync(l.replace(/\.ts$/gm,""))}catch(t){throw new Error(`Failed to resolve path ${a}: ${e}, ${t}`)}}if(r.isDirectory()&&(l=l.replace(/\.ts$/gm,"/index.ts")),T.default.isAbsolute(l)){const t=(/\.tsx?$/.exec(T.default.basename(l))||[])[0]||void 0;l="./"+T.default.relative(s,T.default.resolve(T.default.dirname(l),T.default.basename(l,t)+e))}return o.set(n,l),l}return k.visitNode(n,function e(t){if(function(e){return!(!k.isImportDeclaration(e)&&!k.isExportDeclaration(e))&&(void 0!==e.moduleSpecifier&&(!!k.isStringLiteral(e.moduleSpecifier)&&(!(!e.moduleSpecifier.text.startsWith("./")&&!e.moduleSpecifier.text.startsWith("../"))&&""===T.default.extname(e.moduleSpecifier.text))))}(t)){if(k.isImportDeclaration(t)){const e=i(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(k.isExportDeclaration(t)){const e=i(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}return k.visitEachChild(t,e,a)})}};class fe extends ae{constructor(){super("BuildScripts",Object.assign({},E,ge)),this.replacements={};const e=H(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o,this.replacements["0.4.2"]=this.pkgVersion,this.replacements["@decaf-ts/utils"]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:a}=H();t.info(`Patching ${o} ${a} module in ${e}...`);w.default.statSync(e).isDirectory()&&w.default.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>J(T.default.join(e.parentPath,e.name),this.replacements)),t.verbose(`Module ${o} ${a} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);if(!Object.values(a.LogLevel).includes(t))throw new Error(`Invalid LogLevel ${t}`);try{this.log[t](o)}catch(e){throw console.warn(`Failed to get logger for ${t}`),e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:a}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${a+1})`}return t+=": "+k.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=w.default.readFileSync(e).toString(),o=k.parseConfigFileTextToJson(e,t),n=o.config;n||this.reportDiagnostics([o.error],a.LogLevel.error);const s=k.parseJsonConfigFileContent(n,k.sys,T.default.dirname(e));return s.errors.length>0&&this.reportDiagnostics(s.errors,a.LogLevel.error),s}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===k.DiagnosticCategory.Error),o=e.filter(e=>e.category===k.DiagnosticCategory.Warning),n=e.filter(e=>e.category===k.DiagnosticCategory.Suggestion),s=e.filter(e=>e.category===k.DiagnosticCategory.Message);o.length&&this.reportDiagnostics(o,a.LogLevel.info),t.length&&(this.reportDiagnostics(e,a.LogLevel.error),this.log.info(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`)),n.length&&this.reportDiagnostics(n,a.LogLevel.info),s.length&&this.reportDiagnostics(s,a.LogLevel.info)}}preCheckDiagnostics(e){const t=k.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const a=this.log.for(this.checkTsDiagnostics);let n;try{n=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(n.options.module=p.ModuleKind.AMD,n.options.outDir="dist",n.options.isolatedModules=!1,n.options.outFile=this.pkgName):(n.options.outDir="lib"+(t===le.ESM?"/esm":""),n.options.module=t===le.ESM?p.ModuleKind.ES2022:p.ModuleKind.CommonJS),e?(n.options.inlineSourceMap=!0,n.options.sourceMap=!1):n.options.sourceMap=!1;const s=k.createProgram(n.fileNames,n.options);this.preCheckDiagnostics(s),a.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let a;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{a=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(a.options.module=p.ModuleKind.AMD,a.options.outDir="dist",a.options.isolatedModules=!1,a.options.outFile=this.pkgName):(a.options.outDir="lib"+(t===le.ESM?"/esm":""),a.options.module=t===le.ESM?p.ModuleKind.ES2022:p.ModuleKind.CommonJS),e?(a.options.inlineSourceMap=!0,a.options.sourceMap=!1):a.options.sourceMap=!1;const n=k.createProgram(a.fileNames,a.options),s={};t===le.CJS?s.before=[de(".cjs")]:t===le.ESM&&(s.before=[de(".js")]);const i=n.emit(void 0,void 0,void 0,void 0,s),r=k.getPreEmitDiagnostics(n).concat(i.diagnostics);this.evalDiagnostics(r)}async build(e,t,o=!1){const a=this.log.for(this.build);if(await this.buildTs(e,t,o),a.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t===le.CJS&&!o){const e=G("lib",e=>e.endsWith(".js")&&!e.includes("/esm/"));for(const t of e){a.verbose(`Patching ${t}'s cjs imports...`);const e=t.replace(".js",".cjs");await W(t,e)}}}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=w.default.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&X("./src/assets",`./${e===le.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,a="src/index.ts",n=this.pkgName,s,i=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const r=e===le.ESM,l=this.pkgName,g=Array.from(new Set([...se(i)]));let d=se(s);0===d.length&&(d=re());const u=Array.from(new Set([...function(){try{return Array.isArray(h.builtinModules)?h.builtinModules:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}}(),...d])),p=[C.default({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist"},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),D.default()];if(!t)try{const w=await import("@rollup/plugin-terser"),T=w&&w.terser||w.default||w;p.push(T())}catch{}o&&p.push(v.default({include:[],exclude:d}),f.nodeResolve({resolveOnly:g}));const m={input:a,plugins:p,external:u},S={};u.forEach(e=>{S[e]=ie(e)});const y=[{file:`${o?"bin/":"dist/"}${n||".bundle."+(t?"":"min")}${r?".esm":""}.cjs`,format:o?"cjs":r?"esm":"umd",name:l,esModule:r,sourcemap:!!t&&"inline",globals:S,exports:"auto"}];try{const b=await c.rollup(m);async function k(e){for(const t of y)await e.write(t)}console.log(b.watchFiles),await k(b)}catch($){throw new Error(`Failed to bundle: ${$}`)}}async buildByEnv(e,t=ce.ALL,o,a){try{_("lib")}catch(e){}try{_("dist")}catch(e){}w.default.mkdirSync("lib"),w.default.mkdirSync("dist"),[ce.ALL,ce.BUILD].includes(t)&&(await this.build(e,le.ESM),await this.build(e,le.CJS),this.patchFiles("lib")),[ce.ALL,ce.BUNDLE].includes(t)&&(await this.bundle(le.ESM,e,!1,"src/index.ts",this.pkgName,a,o),await this.bundle(le.CJS,e,!1,"src/index.ts",this.pkgName,a,o),this.patchFiles("dist")),this.copyAssets(le.CJS),this.copyAssets(le.ESM)}async buildDev(e=ce.ALL,t,o){return this.buildByEnv(!0,e,t,o)}async buildProd(e=ce.ALL,t,o){return this.buildByEnv(!1,e,t,o)}async buildDocs(){await U("npm install better-docs taffydb").promise,await U("npx markdown-include ./workdocs/readme-md.json").promise,await U("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await U("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;X(t,o)})}async run(e){const{dev:t,prod:o,docs:a,buildMode:n,includes:s,externals:i}=e;return t?await this.buildDev(n,s,i):o?await this.buildProd(n,s,i):a?await this.buildDocs():void 0}}const ue={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}};const he="https://raw.githubusercontent.com/decaf-ts/ts-workspace/master",pe={templates:[".github/ISSUE_TEMPLATE/bug_report.md",".github/ISSUE_TEMPLATE/feature_request.md",".github/FUNDING.yml"],workflows:[".github/workflows/codeql-analysis.yml",".github/workflows/jest-coverage.yaml",".github/workflows/nodejs-build-prod.yaml",".github/workflows/pages.yaml",".github/workflows/publish-on-release.yaml",".github/workflows/release-on-tag.yaml",".github/workflows/snyk-analysis.yaml"],ide:[".idea/runConfigurations/All Tests.run.xml",".idea/runConfigurations/build.run.xml",".idea/runConfigurations/build_prod.run.xml",".idea/runConfigurations/coverage.run.xml",".idea/runConfigurations/docs.run.xml",".idea/runConfigurations/drawings.run.xml",".idea/runConfigurations/flash-forward.run.xml",".idea/runConfigurations/Integration_Tests.run.xml",".idea/runConfigurations/Bundling_Tests.run.xml",".idea/runConfigurations/lint-fix.run.xml",".idea/runConfigurations/release.run.xml",".idea/runConfigurations/test_circular.run.xml",".idea/runConfigurations/uml.run.xml",".idea/runConfigurations/Unit Tests.run.xml",".idea/runConfigurations/update-scripts.run.xml"],docs:["workdocs/tutorials/Contributing.md","workdocs/tutorials/Documentation.md","workdocs/tutorials/For Developers.md","workdocs/2-Badges.md","workdocs/jsdocs.json","workdocs/readme-md.json"],styles:[".prettierrc","eslint.config.js"],scripts:["bin/update-scripts.cjs","bin/tag-release.cjs","bin/build-scripts.cjs"],tests:["jest.config.ts","workdocs/reports/jest.coverage.config.ts"],typescript:["tsconfig.json"],docker:["Dockerfile"],automation:["workdocs/confluence/Continuous Integration-Deployment/GitHub.md","workdocs/confluence/Continuous Integration-Deployment/Jira.md","workdocs/confluence/Continuous Integration-Deployment/Teams.md"]},me={boot:{type:"boolean"},org:{type:"string",short:"o"},name:{type:"string",short:"n",default:void 0},author:{type:"string",short:"a",default:void 0},all:{type:"boolean"},license:{type:"string",message:"Pick the license"},scripts:{type:"boolean"},styles:{type:"boolean"},docs:{type:"boolean"},ide:{type:"boolean"},workflows:{type:"boolean"},templates:{type:"boolean"},typescript:{type:"boolean"},docker:{type:"boolean"},pkg:{type:"boolean"},dependencies:{type:"boolean"},tests:{type:"boolean"},automation:{type:"boolean"}};e.AbortCode=O,e.BuildScripts=fe,e.Command=ae,e.DefaultCommandOptions=E,e.DefaultCommandValues=I,e.Encoding=F,e.HttpClient=ne,e.NoCIFLag=A,e.PACKAGE_NAME="@decaf-ts/utils",e.RegexpOutputWriter=class extends L{constructor(e,t,o,a="g"){super(e,t);try{this.regexp="string"==typeof o?new RegExp(o,a):o}catch(e){throw new Error(`Invalid regular expression: ${e}`)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(t){return console.debug(`Failed to parse chunk: ${e}\nError: ${t} `)}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(String(e))}error(e){super.error(e),this.testAndReject(String(e))}},e.ReleaseScript=class extends ae{constructor(){super("ReleaseScript",ue)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release message provided. Prompting for one:"),t.info("Listing latest git tags:"),await U("git tag --sort=-taggerdate | head -n 5").promise,await $.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),new RegExp(j).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 $.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}async run(e){let t;const{ci:o}=e;let{tag:a,message:n}=e;a=await this.prepareVersion(a),n=await this.prepareMessage(n),t=await U(`npm run prepare-release -- ${a} ${n}`,{cwd:process.cwd()}).promise,t=await U("git status --porcelain").promise,await t,t.logs.length&&await $.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await U("git add .").promise,await U(`git commit -m "${a} - ${n} - after release preparation${o?"":A}"`).promise),await U(`npm version "${a}" -m "${n}${o?"":A}"`).promise,await U("git push --follow-tags").promise,o||await U("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}},e.SemVersionRegex=j,e.SetupScriptKey=N,e.StandardOutputWriter=L,e.TemplateSync=class extends ae{constructor(){super("TemplateSync",me),this.replacements={},this.getStyles=()=>this.downloadOption("styles"),this.getTemplates=()=>this.downloadOption("templates"),this.getWorkflows=()=>this.downloadOption("workflows"),this.getDocs=()=>this.downloadOption("docs"),this.getTypescript=()=>this.downloadOption("typescript"),this.getAutomation=()=>this.downloadOption("automation"),this.getTests=()=>this.downloadOption("tests"),this.getDocker=()=>this.downloadOption("docker")}loadValuesFromPackage(){const e=process.cwd(),t=H(e,"author");let o,a=H(e,"name");if(a.startsWith("@")){const e=a.split("/");a=e[1],o=e[0].replace("@","")}["Tiago Venceslau","TiagoVenceslau","${author}"].forEach(e=>this.replacements[e]=t),["TS-Workspace","ts-workspace","${name}"].forEach(e=>this.replacements[e]=a),["decaf-ts","${org}"].forEach(e=>this.replacements[e]=o||'""'),this.replacements["${org_or_owner}"]=o||a}async downloadOption(e){if(!(e in pe))throw new Error(`Option "${e}" not found in options`);const t=pe[e];for(const e of t){this.log.info(`Downloading ${e}`);let t=await ne.downloadFile(`${he}/${e}`);t=a.patchString(t,this.replacements),q(T.default.join(process.cwd(),e),t)}}async getLicense(e){this.log.info(`Downloading ${e} license`);const t=`${he}/workdocs/licenses/${e}.md`;let o=await ne.downloadFile(t);o=a.patchString(o,this.replacements),q(T.default.join(process.cwd(),"LICENSE.md"),o),K("license",e)}async getIde(){w.default.mkdirSync(T.default.join(process.cwd(),".idea","runConfigurations"),{recursive:!0}),await this.downloadOption("ide")}async getScripts(){await this.downloadOption("scripts"),this.log.info("please re-run the command"),process.exit(0)}async initPackage(e,t,o){try{const a=H();delete a[N],a.name=e,a.version="0.0.1",a.author=t,a.license=o,w.default.writeFileSync("package.json",JSON.stringify(a,null,2))}catch(e){throw new Error(`Error fixing package.json: ${e}`)}}async updatePackageScrips(){try{const e=JSON.parse(await ne.downloadFile(`${he}/package.json`)),{scripts:t}=e,o=H();Object.keys(o.scripts).forEach(e=>{if(e in t){const n=a.patchString(t[e],this.replacements);n!==t[e]&&(o.scripts[e]=n)}}),o.exports.require=e.exports.require,o.exports.import=e.exports.import,o.types=e.types,w.default.writeFileSync("package.json",JSON.stringify(o,null,2))}catch(e){throw new Error(`Error fixing package.json scripts: ${e}`)}}async createTokenFiles(){const t=this.log.for(this.createTokenFiles),o=await $.insistForText("token","please input your github token",e=>!!e.match(/^ghp_[0-9a-zA-Z]{36}$/g));Object.values(e.Tokens).forEach(e=>{try{let a;try{a=w.default.existsSync(e)}catch(a){return t.info(`Token file ${e} not found. Creating a new one...`),void w.default.writeFileSync(e,".token"===e?o:"")}a||w.default.writeFileSync(e,".token"===e?o:"")}catch(t){throw new Error(`Error creating token file ${e}: ${t}`)}})}async getOrg(){const e=await $.askText("Organization","Enter the organization name (will be used to scope your npm project. leave blank to create a unscoped project):");return await $.askConfirmation("Confirm organization","Is this organization correct?",!0)?e:this.getOrg()}async auditFix(){return await U("npm audit fix --force").promise}patchFiles(){const e=[...w.default.readdirSync(T.default.join(process.cwd(),"src"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>T.default.join(e.parentPath,e.name)),...w.default.readdirSync(T.default.join(process.cwd(),"workdocs"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".md")).map(e=>T.default.join(e.parentPath,e.name)),T.default.join(process.cwd(),".gitlab-ci.yml"),T.default.join(process.cwd(),"workdocs","jsdocs.json")];for(const t of e)J(t,this.replacements)}async updateDependencies(){try{const e=JSON.parse(await ne.downloadFile(`${he}/package.json`)),{devDependencies:t}=e,o=H();Object.keys(o.scripts).forEach(e=>{if(e in t){const a=t[e];a!==t[e]&&(o.devDependencies=o.devDependencies||{},o.devDependencies[e]=a)}}),w.default.writeFileSync("package.json",JSON.stringify(o,null,2)),await U("npm install").promise}catch(e){throw new Error(`Error fixing package.json dependencies: ${e}`)}}async run(e){let{license:t}=e;const{boot:o}=e;let{all:a,scripts:n,styles:s,docs:i,ide:r,workflows:l,templates:c,docker:g,typescript:d,dependencies:f,tests:u,automation:h,pkg:p}=e;if((n||s||i||r||l||c||g||d||h||f||u||p)&&(a=!1),o){const e=await this.getOrg(),o=await $.insistForText("Project name","Enter the project name:",e=>e.length>1),a=await $.insistForText("Author","Enter the author name:",e=>e.length>1),n=e?`@${e}/${o}`:o;await this.initPackage(n,a,t),await this.createTokenFiles(),await this.auditFix(),this.patchFiles()}if(a&&(n=!1,s=!0,i=!0,r=!0,l=!0,c=!0,g=!0,d=!0,p=!0,f=!0,u=!0,h=!1),void 0===n&&(n=await $.askConfirmation("scripts","Do you want to get scripts?",!0)),n&&await this.getScripts(),this.loadValuesFromPackage(),!a&&void 0===t){await $.askConfirmation("license","Do you want to set a license?",!0)&&(t=await $.insistForText("license","Enter the desired License (MIT|GPL|Apache|LGPL|AGPL):",e=>!!e&&!!e.match(/^(MIT|GPL|Apache|LGPL|AGPL)$/g)))}void 0!==t&&await this.getLicense(t),void 0===r&&(r=await $.askConfirmation("ide","Do you want to get ide configs?",!0)),r&&await this.getIde(),void 0===d&&(d=await $.askConfirmation("typescript","Do you want to get typescript configs?",!0)),d&&await this.getTypescript(),void 0===g&&(g=await $.askConfirmation("docker","Do you want to get docker configs?",!0)),g&&await this.getDocker(),void 0===h&&(h=await $.askConfirmation("automation","Do you want to get automation configs?",!0)),h&&await this.getAutomation(),void 0===s&&(s=await $.askConfirmation("styles","Do you want to get styles?",!0)),s&&await this.getStyles(),void 0===i&&(i=await $.askConfirmation("docs","Do you want to get docs?",!0)),i&&await this.getDocs(),void 0===l&&(l=await $.askConfirmation("workflows","Do you want to get workflows?",!0)),l&&await this.getWorkflows(),void 0===c&&(c=await $.askConfirmation("templates","Do you want to get templates?",!0)),c&&await this.getTemplates(),void 0===p&&(p=await $.askConfirmation("pkg","Do you want to update your package.json scripts?",!0)),p&&await this.updatePackageScrips(),void 0===u&&(u=await $.askConfirmation("pkg","Do you want to update your test configs?",!0)),u&&await this.getTests(),void 0===f&&(f=await $.askConfirmation("pkg","Do you want to update dev dependencies?",!0)),f&&await this.updateDependencies()}},e.UserInput=$,e.VERSION="0.4.2",e.chainAbortController=B,e.copyFile=X,e.deletePath=_,e.getAllFiles=G,e.getDependencies=Y,e.getPackage=H,e.getPackageDependencies=re,e.getPackageVersion=z,e.getSlogan=oe,e.installDependencies=Z,e.installIfNotAvailable=async function(e,t){if(!t){const e=await Y();t={prod:e.prod?.map(e=>e.name)||[],dev:e.dev?.map(e=>e.name)||[],peer:e.peer?.map(e=>e.name)||[]}}const{prod:o,dev:a,peer:n}=t,s=Array.from(new Set([...o||[],...a||[],...n||[]])),i=(e="string"==typeof e?[e]:e).filter(e=>!s.includes(e));return i.length&&await Z({dev:i}),t.dev=t.dev||[],t.dev.push(...i),t},e.lockify=function(e){let t=Promise.resolve();return(...o)=>{const a=t.then(()=>e(...o));return t=a.catch(()=>{}),a}},e.normalizeImport=async function(e){return e.then(e=>e.default||e)},e.packageToGlobal=ie,e.parseList=se,e.patchFile=J,e.printBanner=te,e.pushToGit=async function e(){const t=R.for(e),o=await U("git config user.name").promise,a=await U("git config user.email").promise;t.verbose(`cached git id: ${o}/${a}. changing to automation`),await U('git config user.email "automation@decaf.ts"').promise,await U('git config user.name "decaf"').promise,t.info("Pushing changes to git..."),await U("git add .").promise,await U('git commit -m "refs #1 - after repo setup"').promise,await U("git push").promise,await U(`git config user.email "${a}"`).promise,await U(`git config user.name "${o}"`).promise,t.verbose(`reverted to git id: ${o}/${a}`)},e.readFile=V,e.renameFile=W,e.runCommand=U,e.setPackageAttribute=K,e.spawnCommand=M,e.updateDependencies=async function e(){const t=R.for(e);t.info("checking for updates..."),await U("npx npm-check-updates -u").promise,t.info("updating..."),await U("npx npm run do-install").promise},e.writeFile=q});
@@ -1 +1 @@
1
- import e from"prompts";import{parseArgs as t}from"util";import{Logging as o,patchString as a,LoggedClass as s,LoggedEnvironment as n,LogLevel as r}from"@decaf-ts/logging";import i from"fs";import c from"path";import{spawn as l}from"child_process";import{style as g}from"styled-string-builder";import d from"https";import{rollup as f}from"rollup";import h from"@rollup/plugin-typescript";import u from"@rollup/plugin-commonjs";import{nodeResolve as p}from"@rollup/plugin-node-resolve";import m from"@rollup/plugin-json";import{builtinModules as S}from"module";import*as y from"typescript";import{ModuleKind as w}from"typescript";class T{static{this.logger=o.for(T)}constructor(e){this.type="text",this.name=e}setType(e){return T.logger.verbose(`Setting type to: ${e}`),this.type=e,this}setMessage(e){return T.logger.verbose(`Setting message to: ${e}`),this.message=e,this}setInitial(e){return T.logger.verbose(`Setting initial value to: ${e}`),this.initial=e,this}setStyle(e){return T.logger.verbose(`Setting style to: ${e}`),this.style=e,this}setFormat(e){return T.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return T.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return T.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return T.logger.verbose(`Setting min value to: ${e}`),this.min=e,this}setMax(e){return T.logger.verbose(`Setting max value to: ${e}`),this.max=e,this}setFloat(e){return T.logger.verbose(`Setting float to: ${e}`),this.float=e,this}setRound(e){return T.logger.verbose(`Setting round to: ${e}`),this.round=e,this}setInstructions(e){return T.logger.verbose(`Setting instructions to: ${e}`),this.instructions=e,this}setIncrement(e){return T.logger.verbose(`Setting increment to: ${e}`),this.increment=e,this}setSeparator(e){return T.logger.verbose(`Setting separator to: ${e}`),this.separator=e,this}setActive(e){return T.logger.verbose(`Setting active style to: ${e}`),this.active=e,this}setInactive(e){return T.logger.verbose(`Setting inactive style to: ${e}`),this.inactive=e,this}setChoices(e){return T.logger.verbose(`Setting choices: ${JSON.stringify(e)}`),this.choices=e,this}setHint(e){return T.logger.verbose(`Setting hint to: ${e}`),this.hint=e,this}setWarn(e){return T.logger.verbose(`Setting warn to: ${e}`),this.warn=e,this}setSuggest(e){return T.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return T.logger.verbose(`Setting limit to: ${e}`),this.limit=e,this}setMask(e){return T.logger.verbose(`Setting mask to: ${e}`),this.mask=e,this}setStdout(e){return T.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await T.ask(this))[this.name]}static async ask(t){const o=T.logger.for(this.ask);let a;Array.isArray(t)||(t=[t]);try{o.verbose(`Asking questions: ${t.map(e=>e.name).join(", ")}`),a=await e(t),o.verbose(`Received answers: ${JSON.stringify(a,null,2)}`)}catch(e){throw new Error(`Error while getting input: ${e}`)}return a}static async askNumber(e,t,o,a,s){T.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${a}, initial: ${s}`);const n=new T(e).setMessage(t).setType("number");return"number"==typeof o&&n.setMin(o),"number"==typeof a&&n.setMax(a),"number"==typeof s&&n.setInitial(s),(await this.ask(n))[e]}static async askText(e,t,o=void 0,a){T.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${a}`);const s=new T(e).setMessage(t);return o&&s.setMask(o),"string"==typeof a&&s.setInitial(a),(await this.ask(s))[e]}static async askConfirmation(e,t,o){T.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const a=new T(e).setMessage(t).setType("confirm");return void 0!==o&&a.setInitial(o),(await this.ask(a))[e]}static async insist(e,t,o,a=1){const s=T.logger.for(this.insist);let n;s.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${a}`);let r,i=0;try{do{n=(await T.ask(e))[e.name],t(n)?(r=await T.askConfirmation(`${e.name}-confirm`,`Is the ${e.type} correct?`,o),r||(n=void 0)):n=void 0}while(void 0===n&&a>1&&i++<a)}catch(e){throw s.error(`Error while insisting: ${e}`),e}return void 0===n&&s.info("no selection..."),n}static async insistForText(e,t,o,a=void 0,s,n=!1,r=-1){T.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${a}, initial: ${s}, defaultConfirmation: ${n}, limit: ${r}`);const i=new T(e).setMessage(t);return a&&i.setMask(a),"string"==typeof s&&i.setInitial(s),await this.insist(i,o,n,r)}static async insistForNumber(e,t,o,a,s,n,r=!1,i=-1){T.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${a}, max: ${s}, initial: ${n}, defaultConfirmation: ${r}, limit: ${i}`);const c=new T(e).setMessage(t).setType("number");return"number"==typeof a&&c.setMin(a),"number"==typeof s&&c.setMax(s),"number"==typeof n&&c.setInitial(n),await this.insist(c,o,r,i)}static parseArgs(e){const o=T.logger.for(this.parseArgs),a={args:process.argv.slice(2),options:e};o.debug(`Parsing arguments: ${JSON.stringify(a,null,2)}`);try{return t(a)}catch(t){throw o.debug(`Error while parsing arguments:\n${JSON.stringify(a,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${t}`),new Error(`Error while parsing arguments: ${t}`)}}}const b={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}},C=Object.keys(b).reduce((e,t)=>(e[t]=b[t].default,e),{}),D="utf-8",v=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z])))/g;var k;!function(e){e.PATCH="patch",e.MINOR="minor",e.MAJOR="major"}(k||(k={}));const $="-no-ci",E="postinstall";var I;!function(e){e.GIT=".token",e.NPM=".npmtoken",e.DOCKER=".dockertoken",e.CONFLUENCE=".confluence-token"}(I||(I={}));const F="Aborted";class x{constructor(e,t,...a){this.cmd=e,this.lock=t,this.logger=o.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString(D):t;const o="stderr"===e?g(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",String(e))}error(e){this.log("stderr",String(e))}errors(e){this.log("stderr",`Error executing command exited : ${e}`)}exit(e,t){this.log("stdout",`command exited code : ${0===e?g(e.toString()).green.text:g(null===e?"null":e.toString()).red.text}`),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(new Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){return e="string"==typeof e?e.split(" "):e,this.cmd=e.join(" "),[e[0],e.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${g(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=new Error("number"==typeof e?`Exit code ${e}`:e)),this.log("stderr",`${this.cmd} failed to execute: ${g(e.message).red}`),this.lock.reject(e)}}function j(e){let t=Promise.resolve();return(...o)=>{const a=t.then(()=>e(...o));return t=a.catch(()=>{}),a}}function N(e,...t){let o,a;if(e instanceof AbortSignal?(a=new AbortController,o=[e,...t]):(a=e,o=t),a.signal.aborted)return a;const s=()=>a.abort();for(const e of o){if(e.aborted){a.abort();break}e.addEventListener("abort",s,{once:!0,signal:a.signal})}return a}function A(e,t,o,a,s){function n(t,a){const[n,r]=e.parseCommand(t);s.info(`Running command: ${n}`),s.debug(`with args: ${r.join(" ")}`);const i=l(n,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:a.signal});return s.verbose(`pid : ${i.pid}`),i}const r=t.match(/[<>$#]/g);if(r)throw new Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],s=new Array(e.length);s[0]=a;for(let t=0;t<e.length;t++)0!==t&&(s[t]=N(s[t-1].signal)),o.push(n(e[t],s[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return n(t,a)}function B(e,t={},a=x,...s){const n=o.for(B),r=new AbortController,i={abort:r,command:e,logs:[],errs:[]},c=new Promise((o,c)=>{let l;try{l=new a(e,{resolve:o,reject:c},...s),i.cmd=A(l,e,t,r,n)}catch(t){return c(new 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=F),l.exit(e,0===e?i.logs:i.errs)})});return Object.assign(i,{promise:c,pipe:async t=>{const o=n.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const a=await c;return o.verbose(`Piping output to ${t.name}: ${a}`),t(a)}catch(e){throw o.error(`Error piping command output: ${e}`),e}}}),i}const O=o.for("fs");function P(e,t){const o=O.for(P);if(!i.existsSync(e))throw new Error(`File not found at path "${e}".`);let s=M(e);try{o.verbose(`Patching file "${e}"...`),o.debug(`with value: ${JSON.stringify(t)}`),s=a(s,t)}catch(e){throw new Error(`Error patching file: ${e}`)}U(e,s)}function M(e){const t=O.for(M);try{return t.verbose(`Reading file "${e}"...`),i.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),new 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...`),i.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),new Error(`Error writing file "${e}": ${t}`)}}function L(e,t){const o=O.for(L),a=[];try{o.verbose(`Retrieving all files from "${e}"...`);return i.readdirSync(e).forEach(t=>{const o=c.join(e,t),s=i.statSync(o);s.isFile()?a.push(o):s.isDirectory()&&a.push(...L(o))}),t?a.filter(t):a}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),new Error(`Error retrieving files from "${e}": ${t}`)}}async function J(e,t){const o=O.for(J);let a,s;try{a=i.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{s=i.statSync(t)}catch(e){}if(s)throw o.verbose(`Destination path "${t}" already exists`),new Error(`Destination path "${t}" already exists`);try{o.verbose(`Renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),i.renameSync(e,t),o.verbose(`Successfully renamed to "${t}"`)}catch(s){throw o.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${s}`),new Error(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${s}`)}}function R(e,t){const o=O.for(R);let a,s;try{a=i.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{s=i.statSync(t)}catch(e){a.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),i.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),i.cpSync(e,t,{recursive:!0})}catch(s){throw o.verbose(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${s}`),new Error(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${s}`)}}function W(e){const t=O.for(W);try{const o=i.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),i.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&i.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),new Error(`Error Deleting "${e}": ${o}`)}}function G(e=process.cwd(),t){let o;try{o=JSON.parse(M(c.join(e,"package.json")))}catch(e){throw new Error(`Failed to retrieve package information" ${e}`)}if(t){if(!(t in o))throw new Error(`Property "${t}" not found in package.json`);return o[t]}return o}function V(e,t,o=process.cwd()){const a=G(o);a[e]=t,U(c.join(o,"package.json"),JSON.stringify(a,null,2))}function X(e=process.cwd()){return G(e,"version")}async function H(e=process.cwd()){let t;try{t=JSON.parse(await B("npm ls --json",{cwd:e}).promise)}catch(e){throw new Error(`Failed to retrieve dependencies: ${e}`)}const o=(e,t)=>({name:e[0],version:e[1].version});return{prod:Object.entries(t.dependencies||{}).map(o),dev:Object.entries(t.devDependencies||{}).map(o),peer:Object.entries(t.peerDependencies||{}).map(o)}}async function _(){const e=O.for(_);e.info("checking for updates..."),await B("npx npm-check-updates -u").promise,e.info("updating..."),await B("npx npm run do-install").promise}async function q(e,t){if(!t){const e=await H();t={prod:e.prod?.map(e=>e.name)||[],dev:e.dev?.map(e=>e.name)||[],peer:e.peer?.map(e=>e.name)||[]}}const{prod:o,dev:a,peer:s}=t,n=Array.from(new Set([...o||[],...a||[],...s||[]])),r=(e="string"==typeof e?[e]:e).filter(e=>!n.includes(e));return r.length&&await Y({dev:r}),t.dev=t.dev||[],t.dev.push(...r),t}async function z(){const e=O.for(z),t=await B("git config user.name").promise,o=await B("git config user.email").promise;e.verbose(`cached git id: ${t}/${o}. changing to automation`),await B('git config user.email "automation@decaf.ts"').promise,await B('git config user.name "decaf"').promise,e.info("Pushing changes to git..."),await B("git add .").promise,await B('git commit -m "refs #1 - after repo setup"').promise,await B("git push").promise,await B(`git config user.email "${o}"`).promise,await B(`git config user.name "${t}"`).promise,e.verbose(`reverted to git id: ${t}/${o}`)}async function Y(e){const t=O.for(Y),o=e.prod||[],a=e.dev||[],s=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await B(`npm install ${o.join(" ")}`,{cwd:process.cwd()}).promise),a.length&&(t.info(`Installing devDependencies ${a.join(", ")}...`),await B(`npm install --save-dev ${a.join(" ")}`,{cwd:process.cwd()}).promise),s.length&&(t.info(`Installing peerDependencies ${s.join(", ")}...`),await B(`npm install --save-peer ${s.join(" ")}`,{cwd:process.cwd()}).promise)}async function K(e){return e.then(e=>e.default||e)}const Z=[{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’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’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’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’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’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’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’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’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’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:"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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],Q=["","","","","","","","",""];function ee(e){const t=te(),o="# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░ ░▒▓████████▓▒░ ░▒▓████████▓▒░ ░▒▓███████▓▒░ \n# ( ( ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ) ) ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# [=======] ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ \n# `-----´ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓███████▓▒░ \n#".split("\n"),a=o.reduce((e,t)=>Math.max(e,t.length),0);o.push(`# ${t.padStart(a-3)}`),o.forEach((t,o)=>{(e?e.info.bind(e):console.log.bind(console))(g(t||"").raw(Q[o]).text)})}function te(e){try{return e=void 0===e?Math.floor(Math.random()*Z.length):e,Z[e].Slogan}catch(e){throw new Error(`Failed to retrieve slogans: ${e}`)}}class oe extends s{constructor(e,t={},a=[]){super(),this.name=e,this.inputs=t,this.requirements=a,oe.log||Object.defineProperty(oe,"log",{writable:!1,value:o.for(oe.name)}),this.inputs=Object.assign({},b,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await H(),a=[],s=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)s.includes(e)||a.push(e);a.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=T.parseArgs(this.inputs),t=n.accumulate(C).accumulate(e.values),{version:o,help:a,banner:s}=t;if(o)return X();if(a)return this.help(e);let r;s&&ee(this.log.for(ee,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{r=await this.run(t)}catch(e){throw e}return r}}class ae{static{this.log=o.for(ae)}static async downloadFile(e){return new Promise((t,o)=>{!function e(a){a=encodeURI(a),d.get(a,s=>{if(301===s.statusCode||307===s.statusCode)return e(s.headers.location);if(200!==s.statusCode)return ae.log.error(`Failed to fetch ${a} (status: ${s.statusCode})`),o(new Error(`Failed to fetch ${a}`));let n="";s.on("data",e=>{n+=e}),s.on("error",e=>{o(e)}),s.on("end",()=>{t(n)})})}(e)})}}function se(e){return e?Array.isArray(e)?e.map(e=>`${e}`.trim()).filter(Boolean):`${e}`.split(",").map(e=>e.trim()).filter(Boolean):[]}function ne(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 re(){let e;try{e=G(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=c.resolve(__dirname,"../../..");try{e=G(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),a=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...a]))}var ie,ce;!function(e){e.CJS="commonjs",e.ESM="es2022"}(ie||(ie={})),function(e){e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"}(ce||(ce={}));const le={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:ce.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},banner:{type:"boolean",default:!1}},ge=(e=".cjs")=>{const t=de.log.for(ge),o=new Map;return a=>s=>{const n=c.dirname(s.fileName);function r(a){const s=JSON.stringify([n,a]),r=o.get(s);if(null!=r)return r;let l,g=a;try{g=c.resolve(n,g+".ts")}catch(e){throw new Error(`Failed to resolve path ${a}: ${e}`)}try{l=i.statSync(g)}catch(e){try{t.verbose(`Testing existence of path ${g} as a folder defaulting to index file`),l=i.statSync(g.replace(/\.ts$/gm,""))}catch(t){throw new Error(`Failed to resolve path ${a}: ${e}, ${t}`)}}if(l.isDirectory()&&(g=g.replace(/\.ts$/gm,"/index.ts")),c.isAbsolute(g)){const t=(/\.tsx?$/.exec(c.basename(g))||[])[0]||void 0;g="./"+c.relative(n,c.resolve(c.dirname(g),c.basename(g,t)+e))}return o.set(s,g),g}return y.visitNode(s,function e(t){if(function(e){return!(!y.isImportDeclaration(e)&&!y.isExportDeclaration(e))&&(void 0!==e.moduleSpecifier&&(!!y.isStringLiteral(e.moduleSpecifier)&&(!(!e.moduleSpecifier.text.startsWith("./")&&!e.moduleSpecifier.text.startsWith("../"))&&""===c.extname(e.moduleSpecifier.text))))}(t)){if(y.isImportDeclaration(t)){const e=r(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(y.isExportDeclaration(t)){const e=r(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}return y.visitEachChild(t,e,a)})}};class de extends oe{constructor(){super("BuildScripts",Object.assign({},b,le)),this.replacements={};const e=G(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o,this.replacements["0.4.1"]=this.pkgVersion,this.replacements["@decaf-ts/utils"]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:a}=G();t.info(`Patching ${o} ${a} module in ${e}...`);i.statSync(e).isDirectory()&&i.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>P(c.join(e.parentPath,e.name),this.replacements)),t.verbose(`Module ${o} ${a} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);if(!Object.values(r).includes(t))throw new Error(`Invalid LogLevel ${t}`);try{this.log[t](o)}catch(e){throw console.warn(`Failed to get logger for ${t}`),e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:a}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${a+1})`}return t+=": "+y.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=i.readFileSync(e).toString(),o=y.parseConfigFileTextToJson(e,t),a=o.config;a||this.reportDiagnostics([o.error],r.error);const s=y.parseJsonConfigFileContent(a,y.sys,c.dirname(e));return s.errors.length>0&&this.reportDiagnostics(s.errors,r.error),s}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===y.DiagnosticCategory.Error),o=e.filter(e=>e.category===y.DiagnosticCategory.Warning),a=e.filter(e=>e.category===y.DiagnosticCategory.Suggestion),s=e.filter(e=>e.category===y.DiagnosticCategory.Message);o.length&&this.reportDiagnostics(o,r.info),t.length&&(this.reportDiagnostics(e,r.error),this.log.info(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`)),a.length&&this.reportDiagnostics(a,r.info),s.length&&this.reportDiagnostics(s,r.info)}}preCheckDiagnostics(e){const t=y.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const a=this.log.for(this.checkTsDiagnostics);let s;try{s=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(s.options.module=w.AMD,s.options.outDir="dist",s.options.isolatedModules=!1,s.options.outFile=this.pkgName):(s.options.outDir="lib"+(t===ie.ESM?"/esm":""),s.options.module=t===ie.ESM?w.ES2022:w.CommonJS),e?(s.options.inlineSourceMap=!0,s.options.sourceMap=!1):s.options.sourceMap=!1;const n=y.createProgram(s.fileNames,s.options);this.preCheckDiagnostics(n),a.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let a;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{a=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(a.options.module=w.AMD,a.options.outDir="dist",a.options.isolatedModules=!1,a.options.outFile=this.pkgName):(a.options.outDir="lib"+(t===ie.ESM?"/esm":""),a.options.module=t===ie.ESM?w.ES2022:w.CommonJS),e?(a.options.inlineSourceMap=!0,a.options.sourceMap=!1):a.options.sourceMap=!1;const s=y.createProgram(a.fileNames,a.options),n={};t===ie.CJS?n.before=[ge(".cjs")]:t===ie.ESM&&(n.before=[ge(".js")]);const r=s.emit(void 0,void 0,void 0,void 0,n),i=y.getPreEmitDiagnostics(s).concat(r.diagnostics);this.evalDiagnostics(i)}async build(e,t,o=!1){const a=this.log.for(this.build);if(await this.buildTs(e,t,o),a.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t===ie.CJS&&!o){const e=L("lib",e=>e.endsWith(".js")&&!e.includes("/esm/"));for(const t of e){a.verbose(`Patching ${t}'s cjs imports...`);const e=t.replace(".js",".cjs");await J(t,e)}}}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=i.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&R("./src/assets",`./${e===ie.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,a="src/index.ts",s=this.pkgName,n,r=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const i=e===ie.ESM,c=this.pkgName,l=Array.from(new Set([...se(r)]));let g=se(n);0===g.length&&(g=re());const d=Array.from(new Set([...function(){try{return Array.isArray(S)?S:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}}(),...g])),y=[h({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist"},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),m()];if(!t)try{const C=await import("@rollup/plugin-terser"),D=C&&C.terser||C.default||C;y.push(D())}catch{}o&&y.push(u({include:[],exclude:g}),p({resolveOnly:l}));const w={input:a,plugins:y,external:d},T={};d.forEach(e=>{T[e]=ne(e)});const b=[{file:`${o?"bin/":"dist/"}${s||".bundle."+(t?"":"min")}${i?".esm":""}.cjs`,format:o?"cjs":i?"esm":"umd",name:c,esModule:i,sourcemap:!!t&&"inline",globals:T,exports:"auto"}];try{const v=await f(w);async function k(e){for(const t of b)await e.write(t)}console.log(v.watchFiles),await k(v)}catch($){throw new Error(`Failed to bundle: ${$}`)}}async buildByEnv(e,t=ce.ALL,o,a){try{W("lib")}catch(e){}try{W("dist")}catch(e){}i.mkdirSync("lib"),i.mkdirSync("dist"),[ce.ALL,ce.BUILD].includes(t)&&(await this.build(e,ie.ESM),await this.build(e,ie.CJS),this.patchFiles("lib")),[ce.ALL,ce.BUNDLE].includes(t)&&(await this.bundle(ie.ESM,e,!1,"src/index.ts",this.pkgName,a,o),await this.bundle(ie.CJS,e,!1,"src/index.ts",this.pkgName,a,o),this.patchFiles("dist")),this.copyAssets(ie.CJS),this.copyAssets(ie.ESM)}async buildDev(e=ce.ALL,t,o){return this.buildByEnv(!0,e,t,o)}async buildProd(e=ce.ALL,t,o){return this.buildByEnv(!1,e,t,o)}async buildDocs(){await B("npm install better-docs taffydb").promise,await B("npx markdown-include ./workdocs/readme-md.json").promise,await B("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await B("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;R(t,o)})}async run(e){const{dev:t,prod:o,docs:a,buildMode:s,includes:n,externals:r}=e;return t?await this.buildDev(s,n,r):o?await this.buildProd(s,n,r):a?await this.buildDocs():void 0}}const fe={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}};class he extends oe{constructor(){super("ReleaseScript",fe)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release message provided. Prompting for one:"),t.info("Listing latest git tags:"),await B("git tag --sort=-taggerdate | head -n 5").promise,await T.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(e){const t=this.log.for(this.testVersion);switch(e=e.trim().toLowerCase()){case k.PATCH:case k.MINOR:case k.MAJOR:return t.verbose(`Using provided SemVer update: ${e}`,1),e;default:return t.verbose(`Testing provided version for SemVer compatibility: ${e}`,1),new RegExp(v).test(e)?(t.verbose(`version approved: ${e}`,1),e):void t.debug(`Invalid version number: ${e}`)}}async prepareMessage(e){const t=this.log.for(this.prepareMessage);return e||(t.verbose("No release message provided. Prompting for one"),await T.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}async run(e){let t;const{ci:o}=e;let{tag:a,message:s}=e;a=await this.prepareVersion(a),s=await this.prepareMessage(s),t=await B(`npm run prepare-release -- ${a} ${s}`,{cwd:process.cwd()}).promise,t=await B("git status --porcelain").promise,await t,t.logs.length&&await T.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await B("git add .").promise,await B(`git commit -m "${a} - ${s} - after release preparation${o?"":$}"`).promise),await B(`npm version "${a}" -m "${s}${o?"":$}"`).promise,await B("git push --follow-tags").promise,o||await B("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}}const ue="https://raw.githubusercontent.com/decaf-ts/ts-workspace/master",pe={templates:[".github/ISSUE_TEMPLATE/bug_report.md",".github/ISSUE_TEMPLATE/feature_request.md",".github/FUNDING.yml"],workflows:[".github/workflows/codeql-analysis.yml",".github/workflows/jest-coverage.yaml",".github/workflows/nodejs-build-prod.yaml",".github/workflows/pages.yaml",".github/workflows/publish-on-release.yaml",".github/workflows/release-on-tag.yaml",".github/workflows/snyk-analysis.yaml"],ide:[".idea/runConfigurations/All Tests.run.xml",".idea/runConfigurations/build.run.xml",".idea/runConfigurations/build_prod.run.xml",".idea/runConfigurations/coverage.run.xml",".idea/runConfigurations/docs.run.xml",".idea/runConfigurations/drawings.run.xml",".idea/runConfigurations/flash-forward.run.xml",".idea/runConfigurations/Integration_Tests.run.xml",".idea/runConfigurations/Bundling_Tests.run.xml",".idea/runConfigurations/lint-fix.run.xml",".idea/runConfigurations/release.run.xml",".idea/runConfigurations/test_circular.run.xml",".idea/runConfigurations/uml.run.xml",".idea/runConfigurations/Unit Tests.run.xml",".idea/runConfigurations/update-scripts.run.xml"],docs:["workdocs/tutorials/Contributing.md","workdocs/tutorials/Documentation.md","workdocs/tutorials/For Developers.md","workdocs/2-Badges.md","workdocs/jsdocs.json","workdocs/readme-md.json"],styles:[".prettierrc","eslint.config.js"],scripts:["bin/update-scripts.cjs","bin/tag-release.cjs","bin/build-scripts.cjs"],tests:["jest.config.ts","workdocs/reports/jest.coverage.config.ts"],typescript:["tsconfig.json"],docker:["Dockerfile"],automation:["workdocs/confluence/Continuous Integration-Deployment/GitHub.md","workdocs/confluence/Continuous Integration-Deployment/Jira.md","workdocs/confluence/Continuous Integration-Deployment/Teams.md"]},me={boot:{type:"boolean"},org:{type:"string",short:"o"},name:{type:"string",short:"n",default:void 0},author:{type:"string",short:"a",default:void 0},all:{type:"boolean"},license:{type:"string",message:"Pick the license"},scripts:{type:"boolean"},styles:{type:"boolean"},docs:{type:"boolean"},ide:{type:"boolean"},workflows:{type:"boolean"},templates:{type:"boolean"},typescript:{type:"boolean"},docker:{type:"boolean"},pkg:{type:"boolean"},dependencies:{type:"boolean"},tests:{type:"boolean"},automation:{type:"boolean"}};class Se extends oe{constructor(){super("TemplateSync",me),this.replacements={},this.getStyles=()=>this.downloadOption("styles"),this.getTemplates=()=>this.downloadOption("templates"),this.getWorkflows=()=>this.downloadOption("workflows"),this.getDocs=()=>this.downloadOption("docs"),this.getTypescript=()=>this.downloadOption("typescript"),this.getAutomation=()=>this.downloadOption("automation"),this.getTests=()=>this.downloadOption("tests"),this.getDocker=()=>this.downloadOption("docker")}loadValuesFromPackage(){const e=process.cwd(),t=G(e,"author");let o,a=G(e,"name");if(a.startsWith("@")){const e=a.split("/");a=e[1],o=e[0].replace("@","")}["Tiago Venceslau","TiagoVenceslau","${author}"].forEach(e=>this.replacements[e]=t),["TS-Workspace","ts-workspace","${name}"].forEach(e=>this.replacements[e]=a),["decaf-ts","${org}"].forEach(e=>this.replacements[e]=o||'""'),this.replacements["${org_or_owner}"]=o||a}async downloadOption(e){if(!(e in pe))throw new Error(`Option "${e}" not found in options`);const t=pe[e];for(const e of t){this.log.info(`Downloading ${e}`);let t=await ae.downloadFile(`${ue}/${e}`);t=a(t,this.replacements),U(c.join(process.cwd(),e),t)}}async getLicense(e){this.log.info(`Downloading ${e} license`);const t=`${ue}/workdocs/licenses/${e}.md`;let o=await ae.downloadFile(t);o=a(o,this.replacements),U(c.join(process.cwd(),"LICENSE.md"),o),V("license",e)}async getIde(){i.mkdirSync(c.join(process.cwd(),".idea","runConfigurations"),{recursive:!0}),await this.downloadOption("ide")}async getScripts(){await this.downloadOption("scripts"),this.log.info("please re-run the command"),process.exit(0)}async initPackage(e,t,o){try{const a=G();delete a[E],a.name=e,a.version="0.0.1",a.author=t,a.license=o,i.writeFileSync("package.json",JSON.stringify(a,null,2))}catch(e){throw new Error(`Error fixing package.json: ${e}`)}}async updatePackageScrips(){try{const e=JSON.parse(await ae.downloadFile(`${ue}/package.json`)),{scripts:t}=e,o=G();Object.keys(o.scripts).forEach(e=>{if(e in t){const s=a(t[e],this.replacements);s!==t[e]&&(o.scripts[e]=s)}}),o.exports.require=e.exports.require,o.exports.import=e.exports.import,o.types=e.types,i.writeFileSync("package.json",JSON.stringify(o,null,2))}catch(e){throw new Error(`Error fixing package.json scripts: ${e}`)}}async createTokenFiles(){const e=this.log.for(this.createTokenFiles),t=await T.insistForText("token","please input your github token",e=>!!e.match(/^ghp_[0-9a-zA-Z]{36}$/g));Object.values(I).forEach(o=>{try{let a;try{a=i.existsSync(o)}catch(a){return e.info(`Token file ${o} not found. Creating a new one...`),void i.writeFileSync(o,".token"===o?t:"")}a||i.writeFileSync(o,".token"===o?t:"")}catch(e){throw new Error(`Error creating token file ${o}: ${e}`)}})}async getOrg(){const e=await T.askText("Organization","Enter the organization name (will be used to scope your npm project. leave blank to create a unscoped project):");return await T.askConfirmation("Confirm organization","Is this organization correct?",!0)?e:this.getOrg()}async auditFix(){return await B("npm audit fix --force").promise}patchFiles(){const e=[...i.readdirSync(c.join(process.cwd(),"src"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>c.join(e.parentPath,e.name)),...i.readdirSync(c.join(process.cwd(),"workdocs"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".md")).map(e=>c.join(e.parentPath,e.name)),c.join(process.cwd(),".gitlab-ci.yml"),c.join(process.cwd(),"workdocs","jsdocs.json")];for(const t of e)P(t,this.replacements)}async updateDependencies(){try{const e=JSON.parse(await ae.downloadFile(`${ue}/package.json`)),{devDependencies:t}=e,o=G();Object.keys(o.scripts).forEach(e=>{if(e in t){const a=t[e];a!==t[e]&&(o.devDependencies=o.devDependencies||{},o.devDependencies[e]=a)}}),i.writeFileSync("package.json",JSON.stringify(o,null,2)),await B("npm install").promise}catch(e){throw new Error(`Error fixing package.json dependencies: ${e}`)}}async run(e){let{license:t}=e;const{boot:o}=e;let{all:a,scripts:s,styles:n,docs:r,ide:i,workflows:c,templates:l,docker:g,typescript:d,dependencies:f,tests:h,automation:u,pkg:p}=e;if((s||n||r||i||c||l||g||d||u||f||h||p)&&(a=!1),o){const e=await this.getOrg(),o=await T.insistForText("Project name","Enter the project name:",e=>e.length>1),a=await T.insistForText("Author","Enter the author name:",e=>e.length>1),s=e?`@${e}/${o}`:o;await this.initPackage(s,a,t),await this.createTokenFiles(),await this.auditFix(),this.patchFiles()}if(a&&(s=!1,n=!0,r=!0,i=!0,c=!0,l=!0,g=!0,d=!0,p=!0,f=!0,h=!0,u=!1),void 0===s&&(s=await T.askConfirmation("scripts","Do you want to get scripts?",!0)),s&&await this.getScripts(),this.loadValuesFromPackage(),!a&&void 0===t){await T.askConfirmation("license","Do you want to set a license?",!0)&&(t=await T.insistForText("license","Enter the desired License (MIT|GPL|Apache|LGPL|AGPL):",e=>!!e&&!!e.match(/^(MIT|GPL|Apache|LGPL|AGPL)$/g)))}void 0!==t&&await this.getLicense(t),void 0===i&&(i=await T.askConfirmation("ide","Do you want to get ide configs?",!0)),i&&await this.getIde(),void 0===d&&(d=await T.askConfirmation("typescript","Do you want to get typescript configs?",!0)),d&&await this.getTypescript(),void 0===g&&(g=await T.askConfirmation("docker","Do you want to get docker configs?",!0)),g&&await this.getDocker(),void 0===u&&(u=await T.askConfirmation("automation","Do you want to get automation configs?",!0)),u&&await this.getAutomation(),void 0===n&&(n=await T.askConfirmation("styles","Do you want to get styles?",!0)),n&&await this.getStyles(),void 0===r&&(r=await T.askConfirmation("docs","Do you want to get docs?",!0)),r&&await this.getDocs(),void 0===c&&(c=await T.askConfirmation("workflows","Do you want to get workflows?",!0)),c&&await this.getWorkflows(),void 0===l&&(l=await T.askConfirmation("templates","Do you want to get templates?",!0)),l&&await this.getTemplates(),void 0===p&&(p=await T.askConfirmation("pkg","Do you want to update your package.json scripts?",!0)),p&&await this.updatePackageScrips(),void 0===h&&(h=await T.askConfirmation("pkg","Do you want to update your test configs?",!0)),h&&await this.getTests(),void 0===f&&(f=await T.askConfirmation("pkg","Do you want to update dev dependencies?",!0)),f&&await this.updateDependencies()}}class ye extends x{constructor(e,t,o,a="g"){super(e,t);try{this.regexp="string"==typeof o?new RegExp(o,a):o}catch(e){throw new Error(`Invalid regular expression: ${e}`)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(t){return console.debug(`Failed to parse chunk: ${e}\nError: ${t} `)}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(String(e))}error(e){super.error(e),this.testAndReject(String(e))}}const we="0.4.1",Te="@decaf-ts/utils";export{F as AbortCode,de as BuildScripts,oe as Command,b as DefaultCommandOptions,C as DefaultCommandValues,D as Encoding,ae as HttpClient,$ as NoCIFLag,Te as PACKAGE_NAME,ye as RegexpOutputWriter,he as ReleaseScript,k as SemVersion,v as SemVersionRegex,E as SetupScriptKey,x as StandardOutputWriter,Se as TemplateSync,I as Tokens,T as UserInput,we as VERSION,N as chainAbortController,R as copyFile,W as deletePath,L as getAllFiles,H as getDependencies,G as getPackage,re as getPackageDependencies,X as getPackageVersion,te as getSlogan,Y as installDependencies,q as installIfNotAvailable,j as lockify,K as normalizeImport,ne as packageToGlobal,se as parseList,P as patchFile,ee as printBanner,z as pushToGit,M as readFile,J as renameFile,B as runCommand,V as setPackageAttribute,A as spawnCommand,_ as updateDependencies,U as writeFile};
1
+ import e from"prompts";import{parseArgs as t}from"util";import{Logging as o,patchString as a,LoggedClass as s,LoggedEnvironment as n,LogLevel as r}from"@decaf-ts/logging";import i from"fs";import c from"path";import{spawn as l}from"child_process";import{style as g}from"styled-string-builder";import d from"https";import{rollup as f}from"rollup";import h from"@rollup/plugin-typescript";import u from"@rollup/plugin-commonjs";import{nodeResolve as p}from"@rollup/plugin-node-resolve";import m from"@rollup/plugin-json";import{builtinModules as S}from"module";import*as y from"typescript";import{ModuleKind as w}from"typescript";class T{static{this.logger=o.for(T)}constructor(e){this.type="text",this.name=e}setType(e){return T.logger.verbose(`Setting type to: ${e}`),this.type=e,this}setMessage(e){return T.logger.verbose(`Setting message to: ${e}`),this.message=e,this}setInitial(e){return T.logger.verbose(`Setting initial value to: ${e}`),this.initial=e,this}setStyle(e){return T.logger.verbose(`Setting style to: ${e}`),this.style=e,this}setFormat(e){return T.logger.verbose("Setting format function"),this.format=e,this}setValidate(e){return T.logger.verbose("Setting validate function"),this.validate=e,this}setOnState(e){return T.logger.verbose("Setting onState callback"),this.onState=e,this}setMin(e){return T.logger.verbose(`Setting min value to: ${e}`),this.min=e,this}setMax(e){return T.logger.verbose(`Setting max value to: ${e}`),this.max=e,this}setFloat(e){return T.logger.verbose(`Setting float to: ${e}`),this.float=e,this}setRound(e){return T.logger.verbose(`Setting round to: ${e}`),this.round=e,this}setInstructions(e){return T.logger.verbose(`Setting instructions to: ${e}`),this.instructions=e,this}setIncrement(e){return T.logger.verbose(`Setting increment to: ${e}`),this.increment=e,this}setSeparator(e){return T.logger.verbose(`Setting separator to: ${e}`),this.separator=e,this}setActive(e){return T.logger.verbose(`Setting active style to: ${e}`),this.active=e,this}setInactive(e){return T.logger.verbose(`Setting inactive style to: ${e}`),this.inactive=e,this}setChoices(e){return T.logger.verbose(`Setting choices: ${JSON.stringify(e)}`),this.choices=e,this}setHint(e){return T.logger.verbose(`Setting hint to: ${e}`),this.hint=e,this}setWarn(e){return T.logger.verbose(`Setting warn to: ${e}`),this.warn=e,this}setSuggest(e){return T.logger.verbose("Setting suggest function"),this.suggest=e,this}setLimit(e){return T.logger.verbose(`Setting limit to: ${e}`),this.limit=e,this}setMask(e){return T.logger.verbose(`Setting mask to: ${e}`),this.mask=e,this}setStdout(e){return T.logger.verbose("Setting stdout stream"),this.stdout=e,this}setStdin(e){return this.stdin=e,this}async ask(){return(await T.ask(this))[this.name]}static async ask(t){const o=T.logger.for(this.ask);let a;Array.isArray(t)||(t=[t]);try{o.verbose(`Asking questions: ${t.map(e=>e.name).join(", ")}`),a=await e(t),o.verbose(`Received answers: ${JSON.stringify(a,null,2)}`)}catch(e){throw new Error(`Error while getting input: ${e}`)}return a}static async askNumber(e,t,o,a,s){T.logger.for(this.askNumber).verbose(`Asking number input: undefined, question: ${t}, min: ${o}, max: ${a}, initial: ${s}`);const n=new T(e).setMessage(t).setType("number");return"number"==typeof o&&n.setMin(o),"number"==typeof a&&n.setMax(a),"number"==typeof s&&n.setInitial(s),(await this.ask(n))[e]}static async askText(e,t,o=void 0,a){T.logger.for(this.askText).verbose(`Asking text input: undefined, question: ${t}, mask: ${o}, initial: ${a}`);const s=new T(e).setMessage(t);return o&&s.setMask(o),"string"==typeof a&&s.setInitial(a),(await this.ask(s))[e]}static async askConfirmation(e,t,o){T.logger.for(this.askConfirmation).verbose(`Asking confirmation input: undefined, question: ${t}, initial: ${o}`);const a=new T(e).setMessage(t).setType("confirm");return void 0!==o&&a.setInitial(o),(await this.ask(a))[e]}static async insist(e,t,o,a=1){const s=T.logger.for(this.insist);let n;s.verbose(`Insisting on input: ${e.name}, test: ${t.toString()}, defaultConfirmation: ${o}, limit: ${a}`);let r,i=0;try{do{n=(await T.ask(e))[e.name],t(n)?(r=await T.askConfirmation(`${e.name}-confirm`,`Is the ${e.type} correct?`,o),r||(n=void 0)):n=void 0}while(void 0===n&&a>1&&i++<a)}catch(e){throw s.error(`Error while insisting: ${e}`),e}return void 0===n&&s.info("no selection..."),n}static async insistForText(e,t,o,a=void 0,s,n=!1,r=-1){T.logger.for(this.insistForText).verbose(`Insisting for text input: undefined, question: ${t}, test: ${o.toString()}, mask: ${a}, initial: ${s}, defaultConfirmation: ${n}, limit: ${r}`);const i=new T(e).setMessage(t);return a&&i.setMask(a),"string"==typeof s&&i.setInitial(s),await this.insist(i,o,n,r)}static async insistForNumber(e,t,o,a,s,n,r=!1,i=-1){T.logger.for(this.insistForNumber).verbose(`Insisting for number input: undefined, question: ${t}, test: ${o.toString()}, min: ${a}, max: ${s}, initial: ${n}, defaultConfirmation: ${r}, limit: ${i}`);const c=new T(e).setMessage(t).setType("number");return"number"==typeof a&&c.setMin(a),"number"==typeof s&&c.setMax(s),"number"==typeof n&&c.setInitial(n),await this.insist(c,o,r,i)}static parseArgs(e){const o=T.logger.for(this.parseArgs),a={args:process.argv.slice(2),options:e};o.debug(`Parsing arguments: ${JSON.stringify(a,null,2)}`);try{return t(a)}catch(t){throw o.debug(`Error while parsing arguments:\n${JSON.stringify(a,null,2)}\n | options\n${JSON.stringify(e,null,2)}\n | ${t}`),new Error(`Error while parsing arguments: ${t}`)}}}const b={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}},C=Object.keys(b).reduce((e,t)=>(e[t]=b[t].default,e),{}),D="utf-8",v=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z])))/g;var k;!function(e){e.PATCH="patch",e.MINOR="minor",e.MAJOR="major"}(k||(k={}));const $="-no-ci",E="postinstall";var I;!function(e){e.GIT=".token",e.NPM=".npmtoken",e.DOCKER=".dockertoken",e.CONFLUENCE=".confluence-token"}(I||(I={}));const F="Aborted";class x{constructor(e,t,...a){this.cmd=e,this.lock=t,this.logger=o.for(this.cmd)}log(e,t){t=Buffer.isBuffer(t)?t.toString(D):t;const o="stderr"===e?g(t).red.text:t;this.logger.info(o)}data(e){this.log("stdout",String(e))}error(e){this.log("stderr",String(e))}errors(e){this.log("stderr",`Error executing command exited : ${e}`)}exit(e,t){this.log("stdout",`command exited code : ${0===e?g(e.toString()).green.text:g(null===e?"null":e.toString()).red.text}`),0===e?this.resolve(t.map(e=>e.trim()).join("\n")):this.reject(new Error(t.length?t.join("\n"):e.toString()))}parseCommand(e){return e="string"==typeof e?e.split(" "):e,this.cmd=e.join(" "),[e[0],e.slice(1)]}resolve(e){this.log("stdout",`${this.cmd} executed successfully: ${g(e?"ran to completion":e).green}`),this.lock.resolve(e)}reject(e){e instanceof Error||(e=new Error("number"==typeof e?`Exit code ${e}`:e)),this.log("stderr",`${this.cmd} failed to execute: ${g(e.message).red}`),this.lock.reject(e)}}function j(e){let t=Promise.resolve();return(...o)=>{const a=t.then(()=>e(...o));return t=a.catch(()=>{}),a}}function N(e,...t){let o,a;if(e instanceof AbortSignal?(a=new AbortController,o=[e,...t]):(a=e,o=t),a.signal.aborted)return a;const s=()=>a.abort();for(const e of o){if(e.aborted){a.abort();break}e.addEventListener("abort",s,{once:!0,signal:a.signal})}return a}function A(e,t,o,a,s){function n(t,a){const[n,r]=e.parseCommand(t);s.info(`Running command: ${n}`),s.debug(`with args: ${r.join(" ")}`);const i=l(n,r,{...o,cwd:o.cwd||process.cwd(),env:Object.assign({},process.env,o.env,{PATH:process.env.PATH}),shell:o.shell||!1,signal:a.signal});return s.verbose(`pid : ${i.pid}`),i}const r=t.match(/[<>$#]/g);if(r)throw new Error(`Invalid command: ${t}. contains invalid characters: ${r}`);if(t.includes(" | ")){const e=t.split(" | "),o=[],s=new Array(e.length);s[0]=a;for(let t=0;t<e.length;t++)0!==t&&(s[t]=N(s[t-1].signal)),o.push(n(e[t],s[t])),0!==t&&o[t-1].stdout.pipe(o[t].stdin);return o[e.length-1]}return n(t,a)}function B(e,t={},a=x,...s){const n=o.for(B),r=new AbortController,i={abort:r,command:e,logs:[],errs:[]},c=new Promise((o,c)=>{let l;try{l=new a(e,{resolve:o,reject:c},...s),i.cmd=A(l,e,t,r,n)}catch(t){return c(new 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=F),l.exit(e,0===e?i.logs:i.errs)})});return Object.assign(i,{promise:c,pipe:async t=>{const o=n.for("pipe");try{o.verbose(`Executing pipe function ${e}...`);const a=await c;return o.verbose(`Piping output to ${t.name}: ${a}`),t(a)}catch(e){throw o.error(`Error piping command output: ${e}`),e}}}),i}const O=o.for("fs");function P(e,t){const o=O.for(P);if(!i.existsSync(e))throw new Error(`File not found at path "${e}".`);let s=M(e);try{o.verbose(`Patching file "${e}"...`),o.debug(`with value: ${JSON.stringify(t)}`),s=a(s,t)}catch(e){throw new Error(`Error patching file: ${e}`)}U(e,s)}function M(e){const t=O.for(M);try{return t.verbose(`Reading file "${e}"...`),i.readFileSync(e,"utf8")}catch(o){throw t.verbose(`Error reading file "${e}": ${o}`),new 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...`),i.writeFileSync(e,t,"utf8")}catch(t){throw o.verbose(`Error writing file "${e}": ${t}`),new Error(`Error writing file "${e}": ${t}`)}}function L(e,t){const o=O.for(L),a=[];try{o.verbose(`Retrieving all files from "${e}"...`);return i.readdirSync(e).forEach(t=>{const o=c.join(e,t),s=i.statSync(o);s.isFile()?a.push(o):s.isDirectory()&&a.push(...L(o))}),t?a.filter(t):a}catch(t){throw o.verbose(`Error retrieving files from "${e}": ${t}`),new Error(`Error retrieving files from "${e}": ${t}`)}}async function J(e,t){const o=O.for(J);let a,s;try{a=i.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{s=i.statSync(t)}catch(e){}if(s)throw o.verbose(`Destination path "${t}" already exists`),new Error(`Destination path "${t}" already exists`);try{o.verbose(`Renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),i.renameSync(e,t),o.verbose(`Successfully renamed to "${t}"`)}catch(s){throw o.verbose(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${s}`),new Error(`Error renaming ${a.isFile()?"file":"directory"} "${e}" to "${t}": ${s}`)}}function R(e,t){const o=O.for(R);let a,s;try{a=i.statSync(e)}catch(t){throw o.verbose(`Source path "${e}" does not exist: ${t}`),new Error(`Source path "${e}" does not exist: ${t}`)}try{s=i.statSync(t)}catch(e){a.isDirectory()&&(o.verbose(`Dest path "${t}" does not exist. creating`),i.mkdirSync(t,{recursive:!0}))}try{o.verbose(`Copying ${a.isFile()?"file":"directory"} "${e}" to "${t}...`),i.cpSync(e,t,{recursive:!0})}catch(s){throw o.verbose(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${s}`),new Error(`Error copying ${a.isFile()?"file":"directory"} "${e}" to "${t}: ${s}`)}}function W(e){const t=O.for(W);try{const o=i.statSync(e);o.isFile()?(t.verbose(`Deleting file "${e}...`),i.rmSync(e,{recursive:!0,force:!0})):o.isDirectory()&&i.rmSync(e,{recursive:!0,force:!0})}catch(o){throw t.verbose(`Error Deleting "${e}": ${o}`),new Error(`Error Deleting "${e}": ${o}`)}}function G(e=process.cwd(),t){let o;try{o=JSON.parse(M(c.join(e,"package.json")))}catch(e){throw new Error(`Failed to retrieve package information" ${e}`)}if(t){if(!(t in o))throw new Error(`Property "${t}" not found in package.json`);return o[t]}return o}function V(e,t,o=process.cwd()){const a=G(o);a[e]=t,U(c.join(o,"package.json"),JSON.stringify(a,null,2))}function X(e=process.cwd()){return G(e,"version")}async function H(e=process.cwd()){let t;try{t=JSON.parse(await B("npm ls --json",{cwd:e}).promise)}catch(e){throw new Error(`Failed to retrieve dependencies: ${e}`)}const o=(e,t)=>({name:e[0],version:e[1].version});return{prod:Object.entries(t.dependencies||{}).map(o),dev:Object.entries(t.devDependencies||{}).map(o),peer:Object.entries(t.peerDependencies||{}).map(o)}}async function _(){const e=O.for(_);e.info("checking for updates..."),await B("npx npm-check-updates -u").promise,e.info("updating..."),await B("npx npm run do-install").promise}async function q(e,t){if(!t){const e=await H();t={prod:e.prod?.map(e=>e.name)||[],dev:e.dev?.map(e=>e.name)||[],peer:e.peer?.map(e=>e.name)||[]}}const{prod:o,dev:a,peer:s}=t,n=Array.from(new Set([...o||[],...a||[],...s||[]])),r=(e="string"==typeof e?[e]:e).filter(e=>!n.includes(e));return r.length&&await Y({dev:r}),t.dev=t.dev||[],t.dev.push(...r),t}async function z(){const e=O.for(z),t=await B("git config user.name").promise,o=await B("git config user.email").promise;e.verbose(`cached git id: ${t}/${o}. changing to automation`),await B('git config user.email "automation@decaf.ts"').promise,await B('git config user.name "decaf"').promise,e.info("Pushing changes to git..."),await B("git add .").promise,await B('git commit -m "refs #1 - after repo setup"').promise,await B("git push").promise,await B(`git config user.email "${o}"`).promise,await B(`git config user.name "${t}"`).promise,e.verbose(`reverted to git id: ${t}/${o}`)}async function Y(e){const t=O.for(Y),o=e.prod||[],a=e.dev||[],s=e.peer||[];o.length&&(t.info(`Installing dependencies ${o.join(", ")}...`),await B(`npm install ${o.join(" ")}`,{cwd:process.cwd()}).promise),a.length&&(t.info(`Installing devDependencies ${a.join(", ")}...`),await B(`npm install --save-dev ${a.join(" ")}`,{cwd:process.cwd()}).promise),s.length&&(t.info(`Installing peerDependencies ${s.join(", ")}...`),await B(`npm install --save-peer ${s.join(" ")}`,{cwd:process.cwd()}).promise)}async function K(e){return e.then(e=>e.default||e)}const Z=[{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’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’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’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’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’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’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’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’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’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:"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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — 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 — and delightfully.",Tags:"DID, Self-Sovereign, Playful"}],Q=["","","","","","","","",""];function ee(e){const t=te(),o="# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓██████▓▒░ ░▒▓████████▓▒░ ░▒▓████████▓▒░ ░▒▓███████▓▒░ \n# ( ( ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ) ) ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# [=======] ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░ ░▒▓██████▓▒░ \n# `-----´ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ \n# ░▒▓███████▓▒░ ░▒▓████████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓███████▓▒░ \n#".split("\n"),a=o.reduce((e,t)=>Math.max(e,t.length),0);o.push(`# ${t.padStart(a-3)}`),o.forEach((t,o)=>{(e?e.info.bind(e):console.log.bind(console))(g(t||"").raw(Q[o]).text)})}function te(e){try{return e=void 0===e?Math.floor(Math.random()*Z.length):e,Z[e].Slogan}catch(e){throw new Error(`Failed to retrieve slogans: ${e}`)}}class oe extends s{constructor(e,t={},a=[]){super(),this.name=e,this.inputs=t,this.requirements=a,oe.log||Object.defineProperty(oe,"log",{writable:!1,value:o.for(oe.name)}),this.inputs=Object.assign({},b,t)}async checkRequirements(){const{prod:e,dev:t,peer:o}=await H(),a=[],s=Array.from(new Set([...e,...t,...o]).values()).map(e=>e.name);for(const e of this.requirements)s.includes(e)||a.push(e);a.length}help(e){return this.log.info("This is help. I'm no use because I should have been overridden.")}async execute(){const e=T.parseArgs(this.inputs),t=n.accumulate(C).accumulate(e.values),{version:o,help:a,banner:s}=t;if(o)return X();if(a)return this.help(e);let r;s&&ee(this.log.for(ee,{timestamp:!1,style:!1,context:!1,logLevel:!1}));try{r=await this.run(t)}catch(e){throw e}return r}}class ae{static{this.log=o.for(ae)}static async downloadFile(e){return new Promise((t,o)=>{!function e(a){a=encodeURI(a),d.get(a,s=>{if(301===s.statusCode||307===s.statusCode)return e(s.headers.location);if(200!==s.statusCode)return ae.log.error(`Failed to fetch ${a} (status: ${s.statusCode})`),o(new Error(`Failed to fetch ${a}`));let n="";s.on("data",e=>{n+=e}),s.on("error",e=>{o(e)}),s.on("end",()=>{t(n)})})}(e)})}}function se(e){return e?Array.isArray(e)?e.map(e=>`${e}`.trim()).filter(Boolean):`${e}`.split(",").map(e=>e.trim()).filter(Boolean):[]}function ne(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 re(){let e;try{e=G(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=c.resolve(__dirname,"../../..");try{e=G(t)}catch{}}}catch{}const t=Object.keys(e&&e.dependencies||{}),o=Object.keys(e&&e.peerDependencies||{}),a=Object.keys(e&&e.devDependencies||{});return Array.from(new Set([...t,...o,...a]))}var ie,ce;!function(e){e.CJS="commonjs",e.ESM="es2022"}(ie||(ie={})),function(e){e.BUILD="build",e.BUNDLE="bundle",e.ALL="all"}(ce||(ce={}));const le={prod:{type:"boolean",default:!1},dev:{type:"boolean",default:!1},buildMode:{type:"string",default:ce.ALL},includes:{type:"string",default:""},externals:{type:"string",default:""},docs:{type:"boolean",default:!1},commands:{type:"boolean",default:!1},banner:{type:"boolean",default:!1}},ge=(e=".cjs")=>{const t=de.log.for(ge),o=new Map;return a=>s=>{const n=c.dirname(s.fileName);function r(a){const s=JSON.stringify([n,a]),r=o.get(s);if(null!=r)return r;let l,g=a;try{g=c.resolve(n,g+".ts")}catch(e){throw new Error(`Failed to resolve path ${a}: ${e}`)}try{l=i.statSync(g)}catch(e){try{t.verbose(`Testing existence of path ${g} as a folder defaulting to index file`),l=i.statSync(g.replace(/\.ts$/gm,""))}catch(t){throw new Error(`Failed to resolve path ${a}: ${e}, ${t}`)}}if(l.isDirectory()&&(g=g.replace(/\.ts$/gm,"/index.ts")),c.isAbsolute(g)){const t=(/\.tsx?$/.exec(c.basename(g))||[])[0]||void 0;g="./"+c.relative(n,c.resolve(c.dirname(g),c.basename(g,t)+e))}return o.set(s,g),g}return y.visitNode(s,function e(t){if(function(e){return!(!y.isImportDeclaration(e)&&!y.isExportDeclaration(e))&&(void 0!==e.moduleSpecifier&&(!!y.isStringLiteral(e.moduleSpecifier)&&(!(!e.moduleSpecifier.text.startsWith("./")&&!e.moduleSpecifier.text.startsWith("../"))&&""===c.extname(e.moduleSpecifier.text))))}(t)){if(y.isImportDeclaration(t)){const e=r(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateImportDeclaration(t,t.modifiers,t.importClause,o,void 0)}if(y.isExportDeclaration(t)){const e=r(t.moduleSpecifier.text),o=a.factory.createStringLiteral(e);return a.factory.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,o,void 0)}}return y.visitEachChild(t,e,a)})}};class de extends oe{constructor(){super("BuildScripts",Object.assign({},b,le)),this.replacements={};const e=G(),{name:t,version:o}=e;this.pkgName=t.includes("@")?t.split("/")[1]:t,this.pkgVersion=o,this.replacements["0.4.2"]=this.pkgVersion,this.replacements["@decaf-ts/utils"]=t}patchFiles(e){const t=this.log.for(this.patchFiles),{name:o,version:a}=G();t.info(`Patching ${o} ${a} module in ${e}...`);i.statSync(e).isDirectory()&&i.readdirSync(e,{withFileTypes:!0,recursive:!0}).filter(e=>e.isFile()).forEach(e=>P(c.join(e.parentPath,e.name),this.replacements)),t.verbose(`Module ${o} ${a} patched in ${e}...`)}reportDiagnostics(e,t){const o=this.formatDiagnostics(e);if(!Object.values(r).includes(t))throw new Error(`Invalid LogLevel ${t}`);try{this.log[t](o)}catch(e){throw console.warn(`Failed to get logger for ${t}`),e}return o}formatDiagnostics(e){return e.map(e=>{let t="";if(e.file&&e.start){const{line:o,character:a}=e.file.getLineAndCharacterOfPosition(e.start);t+=`${e.file.fileName} (${o+1},${a+1})`}return t+=": "+y.flattenDiagnosticMessageText(e.messageText,"\n"),t}).join("\n")}readConfigFile(e){const t=i.readFileSync(e).toString(),o=y.parseConfigFileTextToJson(e,t),a=o.config;a||this.reportDiagnostics([o.error],r.error);const s=y.parseJsonConfigFileContent(a,y.sys,c.dirname(e));return s.errors.length>0&&this.reportDiagnostics(s.errors,r.error),s}evalDiagnostics(e){if(e&&e.length>0){const t=e.filter(e=>e.category===y.DiagnosticCategory.Error),o=e.filter(e=>e.category===y.DiagnosticCategory.Warning),a=e.filter(e=>e.category===y.DiagnosticCategory.Suggestion),s=e.filter(e=>e.category===y.DiagnosticCategory.Message);o.length&&this.reportDiagnostics(o,r.info),t.length&&(this.reportDiagnostics(e,r.error),this.log.info(`TypeScript reported ${e.length} diagnostic(s) during check; aborting.`)),a.length&&this.reportDiagnostics(a,r.info),s.length&&this.reportDiagnostics(s,r.info)}}preCheckDiagnostics(e){const t=y.getPreEmitDiagnostics(e);this.evalDiagnostics(t)}async checkTsDiagnostics(e,t,o=!1){const a=this.log.for(this.checkTsDiagnostics);let s;try{s=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(s.options.module=w.AMD,s.options.outDir="dist",s.options.isolatedModules=!1,s.options.outFile=this.pkgName):(s.options.outDir="lib"+(t===ie.ESM?"/esm":""),s.options.module=t===ie.ESM?w.ES2022:w.CommonJS),e?(s.options.inlineSourceMap=!0,s.options.sourceMap=!1):s.options.sourceMap=!1;const n=y.createProgram(s.fileNames,s.options);this.preCheckDiagnostics(n),a.verbose(`TypeScript checks passed (${o?"bundle":"normal"} mode).`)}async buildTs(e,t,o=!1){let a;this.log.for(this.buildTs).info(`Building ${this.pkgName} ${this.pkgVersion} module (${t}) in ${e?"dev":"prod"} mode...`);try{a=this.readConfigFile("./tsconfig.json")}catch(e){throw new Error(`Failed to parse tsconfig.json: ${e}`)}o?(a.options.module=w.AMD,a.options.outDir="dist",a.options.isolatedModules=!1,a.options.outFile=this.pkgName):(a.options.outDir="lib"+(t===ie.ESM?"/esm":""),a.options.module=t===ie.ESM?w.ES2022:w.CommonJS),e?(a.options.inlineSourceMap=!0,a.options.sourceMap=!1):a.options.sourceMap=!1;const s=y.createProgram(a.fileNames,a.options),n={};t===ie.CJS?n.before=[ge(".cjs")]:t===ie.ESM&&(n.before=[ge(".js")]);const r=s.emit(void 0,void 0,void 0,void 0,n),i=y.getPreEmitDiagnostics(s).concat(r.diagnostics);this.evalDiagnostics(i)}async build(e,t,o=!1){const a=this.log.for(this.build);if(await this.buildTs(e,t,o),a.verbose(`Module ${this.pkgName} ${this.pkgVersion} (${t}) built in ${e?"dev":"prod"} mode...`),t===ie.CJS&&!o){const e=L("lib",e=>e.endsWith(".js")&&!e.includes("/esm/"));for(const t of e){a.verbose(`Patching ${t}'s cjs imports...`);const e=t.replace(".js",".cjs");await J(t,e)}}}copyAssets(e){const t=this.log.for(this.copyAssets);let o=!1;try{o=i.statSync("./src/assets").isDirectory()}catch(e){return t.verbose("No assets found in ./src/assets to copy")}o&&R("./src/assets",`./${e===ie.CJS?"lib":"dist"}/assets`)}async bundle(e,t,o,a="src/index.ts",s=this.pkgName,n,r=["prompts","styled-string-builder","typed-object-accumulator","@decaf-ts/logging"]){await this.checkTsDiagnostics(t,e,!0);const i=e===ie.ESM,c=this.pkgName,l=Array.from(new Set([...se(r)]));let g=se(n);0===g.length&&(g=re());const d=Array.from(new Set([...function(){try{return Array.isArray(S)?S:[]}catch{return["fs","path","process","child_process","util","https","http","os","stream","crypto","zlib","net","tls","url","querystring","assert","events","tty","dns","querystring"]}}(),...g])),y=[h({compilerOptions:{module:"esnext",declaration:!1,outDir:o?"bin":"dist"},include:["src/**/*.ts"],exclude:["node_modules","**/*.spec.ts"],tsconfig:"./tsconfig.json"}),m()];if(!t)try{const C=await import("@rollup/plugin-terser"),D=C&&C.terser||C.default||C;y.push(D())}catch{}o&&y.push(u({include:[],exclude:g}),p({resolveOnly:l}));const w={input:a,plugins:y,external:d},T={};d.forEach(e=>{T[e]=ne(e)});const b=[{file:`${o?"bin/":"dist/"}${s||".bundle."+(t?"":"min")}${i?".esm":""}.cjs`,format:o?"cjs":i?"esm":"umd",name:c,esModule:i,sourcemap:!!t&&"inline",globals:T,exports:"auto"}];try{const v=await f(w);async function k(e){for(const t of b)await e.write(t)}console.log(v.watchFiles),await k(v)}catch($){throw new Error(`Failed to bundle: ${$}`)}}async buildByEnv(e,t=ce.ALL,o,a){try{W("lib")}catch(e){}try{W("dist")}catch(e){}i.mkdirSync("lib"),i.mkdirSync("dist"),[ce.ALL,ce.BUILD].includes(t)&&(await this.build(e,ie.ESM),await this.build(e,ie.CJS),this.patchFiles("lib")),[ce.ALL,ce.BUNDLE].includes(t)&&(await this.bundle(ie.ESM,e,!1,"src/index.ts",this.pkgName,a,o),await this.bundle(ie.CJS,e,!1,"src/index.ts",this.pkgName,a,o),this.patchFiles("dist")),this.copyAssets(ie.CJS),this.copyAssets(ie.ESM)}async buildDev(e=ce.ALL,t,o){return this.buildByEnv(!0,e,t,o)}async buildProd(e=ce.ALL,t,o){return this.buildByEnv(!1,e,t,o)}async buildDocs(){await B("npm install better-docs taffydb").promise,await B("npx markdown-include ./workdocs/readme-md.json").promise,await B("npx jsdoc -c ./workdocs/jsdocs.json -t ./node_modules/better-docs").promise,await B("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;R(t,o)})}async run(e){const{dev:t,prod:o,docs:a,buildMode:s,includes:n,externals:r}=e;return t?await this.buildDev(s,n,r):o?await this.buildProd(s,n,r):a?await this.buildDocs():void 0}}const fe={ci:{type:"boolean",default:!0},message:{type:"string",short:"m"},tag:{type:"string",short:"t",default:void 0}};class he extends oe{constructor(){super("ReleaseScript",fe)}async prepareVersion(e){const t=this.log.for(this.prepareVersion);return(e=this.testVersion(e||""))||(t.verbose("No release message provided. Prompting for one:"),t.info("Listing latest git tags:"),await B("git tag --sort=-taggerdate | head -n 5").promise,await T.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(e){const t=this.log.for(this.testVersion);switch(e=e.trim().toLowerCase()){case k.PATCH:case k.MINOR:case k.MAJOR:return t.verbose(`Using provided SemVer update: ${e}`,1),e;default:return t.verbose(`Testing provided version for SemVer compatibility: ${e}`,1),new RegExp(v).test(e)?(t.verbose(`version approved: ${e}`,1),e):void t.debug(`Invalid version number: ${e}`)}}async prepareMessage(e){const t=this.log.for(this.prepareMessage);return e||(t.verbose("No release message provided. Prompting for one"),await T.insistForText("message","What should be the release message/ticket?",e=>!!e&&e.toString().length>5))}async run(e){let t;const{ci:o}=e;let{tag:a,message:s}=e;a=await this.prepareVersion(a),s=await this.prepareMessage(s),t=await B(`npm run prepare-release -- ${a} ${s}`,{cwd:process.cwd()}).promise,t=await B("git status --porcelain").promise,await t,t.logs.length&&await T.askConfirmation("git-changes","Do you want to push the changes to the remote repository?",!0)&&(await B("git add .").promise,await B(`git commit -m "${a} - ${s} - after release preparation${o?"":$}"`).promise),await B(`npm version "${a}" -m "${s}${o?"":$}"`).promise,await B("git push --follow-tags").promise,o||await B("NPM_TOKEN=$(cat .npmtoken) npm publish --access public").promise}}const ue="https://raw.githubusercontent.com/decaf-ts/ts-workspace/master",pe={templates:[".github/ISSUE_TEMPLATE/bug_report.md",".github/ISSUE_TEMPLATE/feature_request.md",".github/FUNDING.yml"],workflows:[".github/workflows/codeql-analysis.yml",".github/workflows/jest-coverage.yaml",".github/workflows/nodejs-build-prod.yaml",".github/workflows/pages.yaml",".github/workflows/publish-on-release.yaml",".github/workflows/release-on-tag.yaml",".github/workflows/snyk-analysis.yaml"],ide:[".idea/runConfigurations/All Tests.run.xml",".idea/runConfigurations/build.run.xml",".idea/runConfigurations/build_prod.run.xml",".idea/runConfigurations/coverage.run.xml",".idea/runConfigurations/docs.run.xml",".idea/runConfigurations/drawings.run.xml",".idea/runConfigurations/flash-forward.run.xml",".idea/runConfigurations/Integration_Tests.run.xml",".idea/runConfigurations/Bundling_Tests.run.xml",".idea/runConfigurations/lint-fix.run.xml",".idea/runConfigurations/release.run.xml",".idea/runConfigurations/test_circular.run.xml",".idea/runConfigurations/uml.run.xml",".idea/runConfigurations/Unit Tests.run.xml",".idea/runConfigurations/update-scripts.run.xml"],docs:["workdocs/tutorials/Contributing.md","workdocs/tutorials/Documentation.md","workdocs/tutorials/For Developers.md","workdocs/2-Badges.md","workdocs/jsdocs.json","workdocs/readme-md.json"],styles:[".prettierrc","eslint.config.js"],scripts:["bin/update-scripts.cjs","bin/tag-release.cjs","bin/build-scripts.cjs"],tests:["jest.config.ts","workdocs/reports/jest.coverage.config.ts"],typescript:["tsconfig.json"],docker:["Dockerfile"],automation:["workdocs/confluence/Continuous Integration-Deployment/GitHub.md","workdocs/confluence/Continuous Integration-Deployment/Jira.md","workdocs/confluence/Continuous Integration-Deployment/Teams.md"]},me={boot:{type:"boolean"},org:{type:"string",short:"o"},name:{type:"string",short:"n",default:void 0},author:{type:"string",short:"a",default:void 0},all:{type:"boolean"},license:{type:"string",message:"Pick the license"},scripts:{type:"boolean"},styles:{type:"boolean"},docs:{type:"boolean"},ide:{type:"boolean"},workflows:{type:"boolean"},templates:{type:"boolean"},typescript:{type:"boolean"},docker:{type:"boolean"},pkg:{type:"boolean"},dependencies:{type:"boolean"},tests:{type:"boolean"},automation:{type:"boolean"}};class Se extends oe{constructor(){super("TemplateSync",me),this.replacements={},this.getStyles=()=>this.downloadOption("styles"),this.getTemplates=()=>this.downloadOption("templates"),this.getWorkflows=()=>this.downloadOption("workflows"),this.getDocs=()=>this.downloadOption("docs"),this.getTypescript=()=>this.downloadOption("typescript"),this.getAutomation=()=>this.downloadOption("automation"),this.getTests=()=>this.downloadOption("tests"),this.getDocker=()=>this.downloadOption("docker")}loadValuesFromPackage(){const e=process.cwd(),t=G(e,"author");let o,a=G(e,"name");if(a.startsWith("@")){const e=a.split("/");a=e[1],o=e[0].replace("@","")}["Tiago Venceslau","TiagoVenceslau","${author}"].forEach(e=>this.replacements[e]=t),["TS-Workspace","ts-workspace","${name}"].forEach(e=>this.replacements[e]=a),["decaf-ts","${org}"].forEach(e=>this.replacements[e]=o||'""'),this.replacements["${org_or_owner}"]=o||a}async downloadOption(e){if(!(e in pe))throw new Error(`Option "${e}" not found in options`);const t=pe[e];for(const e of t){this.log.info(`Downloading ${e}`);let t=await ae.downloadFile(`${ue}/${e}`);t=a(t,this.replacements),U(c.join(process.cwd(),e),t)}}async getLicense(e){this.log.info(`Downloading ${e} license`);const t=`${ue}/workdocs/licenses/${e}.md`;let o=await ae.downloadFile(t);o=a(o,this.replacements),U(c.join(process.cwd(),"LICENSE.md"),o),V("license",e)}async getIde(){i.mkdirSync(c.join(process.cwd(),".idea","runConfigurations"),{recursive:!0}),await this.downloadOption("ide")}async getScripts(){await this.downloadOption("scripts"),this.log.info("please re-run the command"),process.exit(0)}async initPackage(e,t,o){try{const a=G();delete a[E],a.name=e,a.version="0.0.1",a.author=t,a.license=o,i.writeFileSync("package.json",JSON.stringify(a,null,2))}catch(e){throw new Error(`Error fixing package.json: ${e}`)}}async updatePackageScrips(){try{const e=JSON.parse(await ae.downloadFile(`${ue}/package.json`)),{scripts:t}=e,o=G();Object.keys(o.scripts).forEach(e=>{if(e in t){const s=a(t[e],this.replacements);s!==t[e]&&(o.scripts[e]=s)}}),o.exports.require=e.exports.require,o.exports.import=e.exports.import,o.types=e.types,i.writeFileSync("package.json",JSON.stringify(o,null,2))}catch(e){throw new Error(`Error fixing package.json scripts: ${e}`)}}async createTokenFiles(){const e=this.log.for(this.createTokenFiles),t=await T.insistForText("token","please input your github token",e=>!!e.match(/^ghp_[0-9a-zA-Z]{36}$/g));Object.values(I).forEach(o=>{try{let a;try{a=i.existsSync(o)}catch(a){return e.info(`Token file ${o} not found. Creating a new one...`),void i.writeFileSync(o,".token"===o?t:"")}a||i.writeFileSync(o,".token"===o?t:"")}catch(e){throw new Error(`Error creating token file ${o}: ${e}`)}})}async getOrg(){const e=await T.askText("Organization","Enter the organization name (will be used to scope your npm project. leave blank to create a unscoped project):");return await T.askConfirmation("Confirm organization","Is this organization correct?",!0)?e:this.getOrg()}async auditFix(){return await B("npm audit fix --force").promise}patchFiles(){const e=[...i.readdirSync(c.join(process.cwd(),"src"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>c.join(e.parentPath,e.name)),...i.readdirSync(c.join(process.cwd(),"workdocs"),{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(".md")).map(e=>c.join(e.parentPath,e.name)),c.join(process.cwd(),".gitlab-ci.yml"),c.join(process.cwd(),"workdocs","jsdocs.json")];for(const t of e)P(t,this.replacements)}async updateDependencies(){try{const e=JSON.parse(await ae.downloadFile(`${ue}/package.json`)),{devDependencies:t}=e,o=G();Object.keys(o.scripts).forEach(e=>{if(e in t){const a=t[e];a!==t[e]&&(o.devDependencies=o.devDependencies||{},o.devDependencies[e]=a)}}),i.writeFileSync("package.json",JSON.stringify(o,null,2)),await B("npm install").promise}catch(e){throw new Error(`Error fixing package.json dependencies: ${e}`)}}async run(e){let{license:t}=e;const{boot:o}=e;let{all:a,scripts:s,styles:n,docs:r,ide:i,workflows:c,templates:l,docker:g,typescript:d,dependencies:f,tests:h,automation:u,pkg:p}=e;if((s||n||r||i||c||l||g||d||u||f||h||p)&&(a=!1),o){const e=await this.getOrg(),o=await T.insistForText("Project name","Enter the project name:",e=>e.length>1),a=await T.insistForText("Author","Enter the author name:",e=>e.length>1),s=e?`@${e}/${o}`:o;await this.initPackage(s,a,t),await this.createTokenFiles(),await this.auditFix(),this.patchFiles()}if(a&&(s=!1,n=!0,r=!0,i=!0,c=!0,l=!0,g=!0,d=!0,p=!0,f=!0,h=!0,u=!1),void 0===s&&(s=await T.askConfirmation("scripts","Do you want to get scripts?",!0)),s&&await this.getScripts(),this.loadValuesFromPackage(),!a&&void 0===t){await T.askConfirmation("license","Do you want to set a license?",!0)&&(t=await T.insistForText("license","Enter the desired License (MIT|GPL|Apache|LGPL|AGPL):",e=>!!e&&!!e.match(/^(MIT|GPL|Apache|LGPL|AGPL)$/g)))}void 0!==t&&await this.getLicense(t),void 0===i&&(i=await T.askConfirmation("ide","Do you want to get ide configs?",!0)),i&&await this.getIde(),void 0===d&&(d=await T.askConfirmation("typescript","Do you want to get typescript configs?",!0)),d&&await this.getTypescript(),void 0===g&&(g=await T.askConfirmation("docker","Do you want to get docker configs?",!0)),g&&await this.getDocker(),void 0===u&&(u=await T.askConfirmation("automation","Do you want to get automation configs?",!0)),u&&await this.getAutomation(),void 0===n&&(n=await T.askConfirmation("styles","Do you want to get styles?",!0)),n&&await this.getStyles(),void 0===r&&(r=await T.askConfirmation("docs","Do you want to get docs?",!0)),r&&await this.getDocs(),void 0===c&&(c=await T.askConfirmation("workflows","Do you want to get workflows?",!0)),c&&await this.getWorkflows(),void 0===l&&(l=await T.askConfirmation("templates","Do you want to get templates?",!0)),l&&await this.getTemplates(),void 0===p&&(p=await T.askConfirmation("pkg","Do you want to update your package.json scripts?",!0)),p&&await this.updatePackageScrips(),void 0===h&&(h=await T.askConfirmation("pkg","Do you want to update your test configs?",!0)),h&&await this.getTests(),void 0===f&&(f=await T.askConfirmation("pkg","Do you want to update dev dependencies?",!0)),f&&await this.updateDependencies()}}class ye extends x{constructor(e,t,o,a="g"){super(e,t);try{this.regexp="string"==typeof o?new RegExp(o,a):o}catch(e){throw new Error(`Invalid regular expression: ${e}`)}}test(e){let t;this.regexp.lastIndex=0;try{t=this.regexp.exec(e)}catch(t){return console.debug(`Failed to parse chunk: ${e}\nError: ${t} `)}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(String(e))}error(e){super.error(e),this.testAndReject(String(e))}}const we="0.4.2",Te="@decaf-ts/utils";export{F as AbortCode,de as BuildScripts,oe as Command,b as DefaultCommandOptions,C as DefaultCommandValues,D as Encoding,ae as HttpClient,$ as NoCIFLag,Te as PACKAGE_NAME,ye as RegexpOutputWriter,he as ReleaseScript,k as SemVersion,v as SemVersionRegex,E as SetupScriptKey,x as StandardOutputWriter,Se as TemplateSync,I as Tokens,T as UserInput,we as VERSION,N as chainAbortController,R as copyFile,W as deletePath,L as getAllFiles,H as getDependencies,G as getPackage,re as getPackageDependencies,X as getPackageVersion,te as getSlogan,Y as installDependencies,q as installIfNotAvailable,j as lockify,K as normalizeImport,ne as packageToGlobal,se as parseList,P as patchFile,ee as printBanner,z as pushToGit,M as readFile,J as renameFile,B as runCommand,V as setPackageAttribute,A as spawnCommand,_ as updateDependencies,U as writeFile};
@@ -107,7 +107,7 @@ function getPackageDependencies() {
107
107
  const dev = Object.keys((pkg && pkg.devDependencies) || {});
108
108
  return Array.from(new Set([...deps, ...peer, ...dev]));
109
109
  }
110
- const VERSION_STRING = "0.4.1";
110
+ const VERSION_STRING = "0.4.2";
111
111
  const PACKAGE_STRING = "@decaf-ts/utils";
112
112
  var Modes;
113
113
  (function (Modes) {
@@ -65,7 +65,7 @@ export function getPackageDependencies() {
65
65
  const dev = Object.keys((pkg && pkg.devDependencies) || {});
66
66
  return Array.from(new Set([...deps, ...peer, ...dev]));
67
67
  }
68
- const VERSION_STRING = "0.4.1";
68
+ const VERSION_STRING = "0.4.2";
69
69
  const PACKAGE_STRING = "@decaf-ts/utils";
70
70
  var Modes;
71
71
  (function (Modes) {
@@ -26,7 +26,7 @@ export * from "./writers";
26
26
  * @const VERSION
27
27
  * @memberOf module:utils
28
28
  */
29
- export declare const VERSION = "0.4.1";
29
+ export declare const VERSION = "0.4.2";
30
30
  /**
31
31
  * @description Represents the current version of the module.
32
32
  * @summary Stores the version for the @decaf-ts/utils package. The build replaces
package/lib/esm/index.js CHANGED
@@ -26,7 +26,7 @@ export * from "./writers/index.js";
26
26
  * @const VERSION
27
27
  * @memberOf module:utils
28
28
  */
29
- export const VERSION = "0.4.1";
29
+ export const VERSION = "0.4.2";
30
30
  /**
31
31
  * @description Represents the current version of the module.
32
32
  * @summary Stores the version for the @decaf-ts/utils package. The build replaces
package/lib/index.cjs CHANGED
@@ -43,7 +43,7 @@ __exportStar(require("./writers/index.cjs"), exports);
43
43
  * @const VERSION
44
44
  * @memberOf module:utils
45
45
  */
46
- exports.VERSION = "0.4.1";
46
+ exports.VERSION = "0.4.2";
47
47
  /**
48
48
  * @description Represents the current version of the module.
49
49
  * @summary Stores the version for the @decaf-ts/utils package. The build replaces
package/lib/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export * from "./writers";
26
26
  * @const VERSION
27
27
  * @memberOf module:utils
28
28
  */
29
- export declare const VERSION = "0.4.1";
29
+ export declare const VERSION = "0.4.2";
30
30
  /**
31
31
  * @description Represents the current version of the module.
32
32
  * @summary Stores the version for the @decaf-ts/utils package. The build replaces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/utils",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "module management utils for decaf-ts",
5
5
  "type": "module",
6
6
  "exports": {