@under_koen/bsm 1.6.0 → 1.6.1

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  `&&(u+=Gt(i)))}return u};qt.exports=(t,e,n)=>String(t).normalize().replace(/\r\n/g,`
6
6
  `).split(`
7
7
  `).map(r=>ir(r,e,n)).join(`
8
- `)});var Yt=v((Bu,Qt)=>{var or=require("stream"),We=class extends or{#n=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,n){return this._dest?this._dest[e]:this._src?this._src[e]:n}#e(e,...n){var r,u;typeof((r=this._dest)==null?void 0:r[e])=="function"&&this._dest[e](...n),typeof((u=this._src)==null?void 0:u[e])=="function"&&this._src[e](...n)}get isTTY(){return this.#n!==null?this.#n:this.#t("isTTY",!1)}set isTTY(e){this.#n=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,n){return this._dest=e,super.pipe(e,n)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e&&this.replace?e=e.toString().replace(/./g,this.replace):e=null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}};Qt.exports=We});var Xt=v((xu,Xe)=>{"use strict";var E=Xe.exports;Xe.exports.default=E;var b="\x1B[",ue="\x1B]",ee="\x07",be=";",Jt=process.env.TERM_PROGRAM==="Apple_Terminal";E.cursorTo=(t,e)=>{if(typeof t!="number")throw new TypeError("The `x` argument is required");return typeof e!="number"?b+(t+1)+"G":b+(e+1)+";"+(t+1)+"H"};E.cursorMove=(t,e)=>{if(typeof t!="number")throw new TypeError("The `x` argument is required");let n="";return t<0?n+=b+-t+"D":t>0&&(n+=b+t+"C"),e<0?n+=b+-e+"A":e>0&&(n+=b+e+"B"),n};E.cursorUp=(t=1)=>b+t+"A";E.cursorDown=(t=1)=>b+t+"B";E.cursorForward=(t=1)=>b+t+"C";E.cursorBackward=(t=1)=>b+t+"D";E.cursorLeft=b+"G";E.cursorSavePosition=Jt?"\x1B7":b+"s";E.cursorRestorePosition=Jt?"\x1B8":b+"u";E.cursorGetPosition=b+"6n";E.cursorNextLine=b+"E";E.cursorPrevLine=b+"F";E.cursorHide=b+"?25l";E.cursorShow=b+"?25h";E.eraseLines=t=>{let e="";for(let n=0;n<t;n++)e+=E.eraseLine+(n<t-1?E.cursorUp():"");return t&&(e+=E.cursorLeft),e};E.eraseEndLine=b+"K";E.eraseStartLine=b+"1K";E.eraseLine=b+"2K";E.eraseDown=b+"J";E.eraseUp=b+"1J";E.eraseScreen=b+"2J";E.scrollUp=b+"S";E.scrollDown=b+"T";E.clearScreen="\x1Bc";E.clearTerminal=process.platform==="win32"?`${E.eraseScreen}${b}0f`:`${E.eraseScreen}${b}3J${b}H`;E.beep=ee;E.link=(t,e)=>[ue,"8",be,be,e,ee,t,ue,"8",be,be,ee].join("");E.image=(t,e={})=>{let n=`${ue}1337;File=inline=1`;return e.width&&(n+=`;width=${e.width}`),e.height&&(n+=`;height=${e.height}`),e.preserveAspectRatio===!1&&(n+=";preserveAspectRatio=0"),n+":"+t.toString("base64")+ee};E.iTerm={setCwd:(t=process.cwd())=>`${ue}50;CurrentDir=${t}${ee}`,annotation:(t,e={})=>{let n=`${ue}1337;`,r=typeof e.x<"u",u=typeof e.y<"u";if((r||u)&&!(r&&u&&typeof e.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return t=t.replace(/\|/g,""),n+=e.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",e.length>0?n+=(r?[t,e.length,e.x,e.y]:[e.length,t]).join("|"):n+=t,n+ee}}});var on=v((ni,ar)=>{ar.exports={name:"@under_koen/bsm",version:"1.6.0",description:"BSM (Basic Script Manager) is a useful tool that enables you to create clear and concise scripts without cluttering your `package.json` file.",license:"MIT",author:"Koen van Staveren <koen@underkoen.nl>",homepage:"https://github.com/UnderKoen/bsm#readme",repository:{type:"git",url:"https://github.com/UnderKoen/bsm.git"},bugs:{url:"https://github.com/UnderKoen/bsm/issues"},main:"dist/index.js",bin:{bsm:"./dist/index.js"},files:["dist"],scripts:{build:"bsm","build:dev":"bsm","build:prod":"bsm","build:watch":"bsm",lint:"bsm",prettier:"bsm",prepublishOnly:"bsm build.prod",test:"bsm","test:cov":"bsm test.cov"},devDependencies:{"@eslint/js":"^9.21.0","@inquirer/core":"^10.1.7","@semantic-release/changelog":"^6.0.3","@semantic-release/exec":"^7.0.3","@semantic-release/git":"^10.0.1","@semantic-release/github":"^11.0.1","@types/minimist":"^1.2.5","@types/node":"^22.13.9","@types/sinon":"^17.0.4","@typescript-eslint/eslint-plugin":"^8.26.0","@typescript-eslint/parser":"^8.26.0","@under_koen/bsm":"^1.5.0",c8:"^10.1.3","ci-info":"^4.1.0","cpy-cli":"^5.0.0",defu:"^6.1.4",esbuild:"^0.25.0",eslint:"^9.21.0","eslint-config-prettier":"^10.0.2",globals:"^16.0.0",minimist:"^1.2.8",prettier:"^3.5.3","prettier-package-json":"^2.8.0",rimraf:"^6.0.1","semantic-release":"^24.2.3",sinon:"^19.0.2",tsm:"^2.3.0",typescript:"^5.8.2","typescript-eslint":"^8.26.0",uvu:"^0.5.6"},keywords:["script","scripting"]}});var sn=v((ui,fr)=>{fr.exports=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]});var cn=v(P=>{"use strict";var Dn=sn(),w=process.env;Object.defineProperty(P,"_vendors",{value:Dn.map(function(t){return t.constant})});P.name=null;P.isPR=null;P.id=null;Dn.forEach(function(t){let n=(Array.isArray(t.env)?t.env:[t.env]).every(function(r){return ln(r)});P[t.constant]=n,n&&(P.name=t.name,P.isPR=pr(t),P.id=t.constant)});P.isCI=!!(w.CI!=="false"&&(w.BUILD_ID||w.BUILD_NUMBER||w.CI||w.CI_APP_ID||w.CI_BUILD_ID||w.CI_BUILD_NUMBER||w.CI_NAME||w.CONTINUOUS_INTEGRATION||w.RUN_ID||P.name));function ln(t){return typeof t=="string"?!!w[t]:"env"in t?w[t.env]&&w[t.env].includes(t.includes):"any"in t?t.any.some(function(e){return!!w[e]}):Object.keys(t).every(function(e){return w[e]===t[e]})}function pr(t){switch(typeof t.pr){case"string":return!!w[t.pr];case"object":return"env"in t.pr?"any"in t.pr?t.pr.any.some(function(e){return w[t.pr.env]===e}):t.pr.env in w&&w[t.pr.env]!==t.pr.ne:"any"in t.pr?t.pr.any.some(function(e){return!!w[e]}):ln(t.pr);default:return null}}});var mr={};An(mr,{main:()=>En});module.exports=wn(mr);var gn=x(st());function Se(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function xe(t,e,n=".",r){if(!Se(e))return xe(t,{},n,r);let u=Object.assign({},e);for(let i in t){if(i==="__proto__"||i==="constructor")continue;let o=t[i];o!=null&&(r&&r(u,i,o,n)||(Array.isArray(o)&&Array.isArray(u[i])?u[i]=[...o,...u[i]]:Se(o)&&Se(u[i])?u[i]=xe(o,u[i],(n?`${n}.`:"")+i.toString(),r):u[i]=o))}return u}function Re(t){return(...e)=>e.reduce((n,r)=>xe(n,r,"",t),{})}var Dt=Re(),Cr=Re((t,e,n)=>{if(t[e]!==void 0&&typeof n=="function")return t[e]=n(t[e]),!0}),Fr=Re((t,e,n)=>{if(Array.isArray(t[e])&&typeof n=="function")return t[e]=n(t[e]),!0});var Sn=Object.freeze({scripts:{},config:{defaultHelpBehavior:"help",idempotency:{location:"./node_modules/.cache/bsm/idempotency",useFileContent:!1}}}),_=class{static getSource(e){return Array.isArray(e)?e[0]:e}static async loadExtensions(e){return!Object.hasOwn(e,"extends")||!e.extends?[]:(await Promise.all([...e.extends].map(n=>this.loadFile(n,!1)))).filter(n=>n!==void 0)}static async loadFile(e,n=!0){var u,i;if(!e)return;let r=this.getSource(e);try{r=require.resolve(r,{paths:[process.cwd()]});let o=require(r);typeof o=="function"&&(o=await o(...Array.isArray(e)?e.slice(1):[]));let s=await this.loadExtensions(o);return Dt(o,...s,Sn)}catch(o){let s=o,D=(i=(u=s.requireStack)==null?void 0:u[0])==null?void 0:i.replaceAll("\\","/");if(s.code==="MODULE_NOT_FOUND"&&(D!=null&&D.includes("bsm/dist/index.js"))){if(n)return;console.error(`\x1B[31mCannot find config '${r}' to extend\x1B[0m`),process.exit(1)}else console.error(o),Array.isArray(e)&&(e=e[0]),console.error(`\x1B[31mError loading config '${e}'\x1B[0m`),process.exit(1)}}static async load(e){let n=[e.config,process.env.BSM_CONFIG,"./package.scripts.js","./package.scripts.json"].filter(r=>r!==void 0);for(let r of n){let u=await this.loadFile(r);if(u)return process.env.BSM_CONFIG=r,this._config=u,u}console.error(`\x1B[31mCannot find config ${n.map(r=>`'${r}'`).join(" or ")}\x1B[0m`),process.exit(1)}static _config;static get config(){if(this._config)return this._config;throw new Error("Config not loaded")}};var se=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e==null?void 0:e.cause}},De=class extends Error{name="CancelPromptError";message="Prompt was canceled"},le=class extends Error{name="ExitPromptError"},ce=class extends Error{name="HookError"},ae=class extends Error{name="ValidationError"};var fe=require("node:async_hooks");var lt=new fe.AsyncLocalStorage;function xn(t){return{rl:t,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function ct(t,e){let n=xn(t);return lt.run(n,()=>{function r(u){n.handleChange=()=>{n.index=0,u()},n.handleChange()}return e(r)})}function W(){let t=lt.getStore();if(!t)throw new ce("[Inquirer] Hook functions can only be called from within a prompt");return t}function Le(){return W().rl}function Ie(t){let e=(...n)=>{let r=W(),u=!1,i=r.handleChange;r.handleChange=()=>{u=!0};let o=t(...n);return u&&i(),r.handleChange=i,o};return fe.AsyncResource.bind(e)}function z(t){let e=W(),{index:n}=e,r={get(){return e.hooks[n]},set(i){e.hooks[n]=i},initialized:n in e.hooks},u=t(r);return e.index++,u}function at(){W().handleChange()}var V={queue(t){let e=W(),{index:n}=e;e.hooksEffect.push(()=>{var u,i;(i=(u=e.hooksCleanup)[n])==null||i.call(u);let r=t(Le());if(r!=null&&typeof r!="function")throw new ae("useEffect return value must be a cleanup function or nothing.");e.hooksCleanup[n]=r})},run(){let t=W();Ie(()=>{t.hooksEffect.forEach(e=>{e()}),t.hooksEffect.length=0})()},clearAll(){let t=W();t.hooksCleanup.forEach(e=>{e==null||e()}),t.hooksEffect.length=0,t.hooksCleanup.length=0}};function N(t){return z(e=>{let n=u=>{e.get()!==u&&(e.set(u),at())};if(e.initialized)return[e.get(),n];let r=typeof t=="function"?t():t;return e.set(r),[r,n]})}function pe(t,e){z(n=>{let r=n.get();(!Array.isArray(r)||e.some((i,o)=>!Object.is(i,r[o])))&&V.queue(t),n.set(e)})}var T=x(dt(),1);var U=x(require("node:process"),1);function Ln(){return U.default.platform!=="win32"?U.default.env.TERM!=="linux":!!U.default.env.WT_SESSION||!!U.default.env.TERMINUS_SUBLIME||U.default.env.ConEmuTask==="{cmd::Cmder}"||U.default.env.TERM_PROGRAM==="Terminus-Sublime"||U.default.env.TERM_PROGRAM==="vscode"||U.default.env.TERM==="xterm-256color"||U.default.env.TERM==="alacritty"||U.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var mt={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},gt={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},In={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Tn={...mt,...gt},_n={...mt,...In},Un=Ln(),On=Un?Tn:_n,_e=On,_r=Object.entries(gt);var Pn={prefix:{idle:T.default.blue("?"),done:T.default.green(_e.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(t=>T.default.yellow(t))},style:{answer:T.default.cyan,message:T.default.bold,error:t=>T.default.red(`> ${t}`),defaultAnswer:t=>T.default.dim(`(${t})`),help:T.default.dim,highlight:T.default.cyan,key:t=>T.default.cyan(T.default.bold(`<${t}>`))}};function Ue(t,e){return z(n=>{let r=n.get();if(!r||r.dependencies.length!==e.length||r.dependencies.some((u,i)=>u!==e[i])){let u=t();return n.set({value:u,dependencies:e}),u}return r.value})}function de(t){return N({current:t})[0]}function Oe(t){let e=de(t);e.current=t,pe(n=>{let r=!1,u=Ie((i,o)=>{r||e.current(o,n)});return n.input.on("keypress",u),()=>{r=!0,n.input.removeListener("keypress",u)}},[])}var Vt=x(Ct(),1),Kt=x(Wt(),1);function Ee(t,e){return t.split(`
8
+ `)});var Yt=v((Bu,Qt)=>{var or=require("stream"),We=class extends or{#n=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,n){return this._dest?this._dest[e]:this._src?this._src[e]:n}#e(e,...n){var r,u;typeof((r=this._dest)==null?void 0:r[e])=="function"&&this._dest[e](...n),typeof((u=this._src)==null?void 0:u[e])=="function"&&this._src[e](...n)}get isTTY(){return this.#n!==null?this.#n:this.#t("isTTY",!1)}set isTTY(e){this.#n=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,n){return this._dest=e,super.pipe(e,n)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e&&this.replace?e=e.toString().replace(/./g,this.replace):e=null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}};Qt.exports=We});var Xt=v((xu,Xe)=>{"use strict";var E=Xe.exports;Xe.exports.default=E;var b="\x1B[",ue="\x1B]",ee="\x07",be=";",Jt=process.env.TERM_PROGRAM==="Apple_Terminal";E.cursorTo=(t,e)=>{if(typeof t!="number")throw new TypeError("The `x` argument is required");return typeof e!="number"?b+(t+1)+"G":b+(e+1)+";"+(t+1)+"H"};E.cursorMove=(t,e)=>{if(typeof t!="number")throw new TypeError("The `x` argument is required");let n="";return t<0?n+=b+-t+"D":t>0&&(n+=b+t+"C"),e<0?n+=b+-e+"A":e>0&&(n+=b+e+"B"),n};E.cursorUp=(t=1)=>b+t+"A";E.cursorDown=(t=1)=>b+t+"B";E.cursorForward=(t=1)=>b+t+"C";E.cursorBackward=(t=1)=>b+t+"D";E.cursorLeft=b+"G";E.cursorSavePosition=Jt?"\x1B7":b+"s";E.cursorRestorePosition=Jt?"\x1B8":b+"u";E.cursorGetPosition=b+"6n";E.cursorNextLine=b+"E";E.cursorPrevLine=b+"F";E.cursorHide=b+"?25l";E.cursorShow=b+"?25h";E.eraseLines=t=>{let e="";for(let n=0;n<t;n++)e+=E.eraseLine+(n<t-1?E.cursorUp():"");return t&&(e+=E.cursorLeft),e};E.eraseEndLine=b+"K";E.eraseStartLine=b+"1K";E.eraseLine=b+"2K";E.eraseDown=b+"J";E.eraseUp=b+"1J";E.eraseScreen=b+"2J";E.scrollUp=b+"S";E.scrollDown=b+"T";E.clearScreen="\x1Bc";E.clearTerminal=process.platform==="win32"?`${E.eraseScreen}${b}0f`:`${E.eraseScreen}${b}3J${b}H`;E.beep=ee;E.link=(t,e)=>[ue,"8",be,be,e,ee,t,ue,"8",be,be,ee].join("");E.image=(t,e={})=>{let n=`${ue}1337;File=inline=1`;return e.width&&(n+=`;width=${e.width}`),e.height&&(n+=`;height=${e.height}`),e.preserveAspectRatio===!1&&(n+=";preserveAspectRatio=0"),n+":"+t.toString("base64")+ee};E.iTerm={setCwd:(t=process.cwd())=>`${ue}50;CurrentDir=${t}${ee}`,annotation:(t,e={})=>{let n=`${ue}1337;`,r=typeof e.x<"u",u=typeof e.y<"u";if((r||u)&&!(r&&u&&typeof e.length<"u"))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return t=t.replace(/\|/g,""),n+=e.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",e.length>0?n+=(r?[t,e.length,e.x,e.y]:[e.length,t]).join("|"):n+=t,n+ee}}});var on=v((ni,ar)=>{ar.exports={name:"@under_koen/bsm",version:"1.6.1",description:"BSM (Basic Script Manager) is a useful tool that enables you to create clear and concise scripts without cluttering your `package.json` file.",license:"MIT",author:"Koen van Staveren <koen@underkoen.nl>",homepage:"https://github.com/UnderKoen/bsm#readme",repository:{type:"git",url:"https://github.com/UnderKoen/bsm.git"},bugs:{url:"https://github.com/UnderKoen/bsm/issues"},main:"dist/index.js",bin:{bsm:"./dist/index.js"},files:["dist"],scripts:{build:"bsm","build:dev":"bsm","build:prod":"bsm","build:watch":"bsm",lint:"bsm",prettier:"bsm",prepublishOnly:"bsm build.prod",test:"bsm","test:cov":"bsm test.cov"},devDependencies:{"@eslint/js":"^9.21.0","@inquirer/core":"^10.1.7","@semantic-release/changelog":"^6.0.3","@semantic-release/exec":"^7.0.3","@semantic-release/git":"^10.0.1","@semantic-release/github":"^11.0.1","@types/minimist":"^1.2.5","@types/node":"^22.13.9","@types/sinon":"^17.0.4","@typescript-eslint/eslint-plugin":"^8.26.0","@typescript-eslint/parser":"^8.26.0","@under_koen/bsm":"^1.5.0",c8:"^10.1.3","ci-info":"^4.1.0","cpy-cli":"^5.0.0",defu:"^6.1.4",esbuild:"^0.25.0",eslint:"^9.21.0","eslint-config-prettier":"^10.0.2",globals:"^16.0.0",minimist:"^1.2.8",prettier:"^3.5.3","prettier-package-json":"^2.8.0",rimraf:"^6.0.1","semantic-release":"^24.2.3",sinon:"^19.0.2",tsm:"^2.3.0",typescript:"^5.8.2","typescript-eslint":"^8.26.0",uvu:"^0.5.6"},keywords:["script","scripting"]}});var sn=v((ui,fr)=>{fr.exports=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]});var cn=v(P=>{"use strict";var Dn=sn(),w=process.env;Object.defineProperty(P,"_vendors",{value:Dn.map(function(t){return t.constant})});P.name=null;P.isPR=null;P.id=null;Dn.forEach(function(t){let n=(Array.isArray(t.env)?t.env:[t.env]).every(function(r){return ln(r)});P[t.constant]=n,n&&(P.name=t.name,P.isPR=pr(t),P.id=t.constant)});P.isCI=!!(w.CI!=="false"&&(w.BUILD_ID||w.BUILD_NUMBER||w.CI||w.CI_APP_ID||w.CI_BUILD_ID||w.CI_BUILD_NUMBER||w.CI_NAME||w.CONTINUOUS_INTEGRATION||w.RUN_ID||P.name));function ln(t){return typeof t=="string"?!!w[t]:"env"in t?w[t.env]&&w[t.env].includes(t.includes):"any"in t?t.any.some(function(e){return!!w[e]}):Object.keys(t).every(function(e){return w[e]===t[e]})}function pr(t){switch(typeof t.pr){case"string":return!!w[t.pr];case"object":return"env"in t.pr?"any"in t.pr?t.pr.any.some(function(e){return w[t.pr.env]===e}):t.pr.env in w&&w[t.pr.env]!==t.pr.ne:"any"in t.pr?t.pr.any.some(function(e){return!!w[e]}):ln(t.pr);default:return null}}});var mr={};An(mr,{main:()=>En});module.exports=wn(mr);var gn=x(st());function Se(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.iterator in t?!1:Symbol.toStringTag in t?Object.prototype.toString.call(t)==="[object Module]":!0}function xe(t,e,n=".",r){if(!Se(e))return xe(t,{},n,r);let u=Object.assign({},e);for(let i in t){if(i==="__proto__"||i==="constructor")continue;let o=t[i];o!=null&&(r&&r(u,i,o,n)||(Array.isArray(o)&&Array.isArray(u[i])?u[i]=[...o,...u[i]]:Se(o)&&Se(u[i])?u[i]=xe(o,u[i],(n?`${n}.`:"")+i.toString(),r):u[i]=o))}return u}function Re(t){return(...e)=>e.reduce((n,r)=>xe(n,r,"",t),{})}var Dt=Re(),Cr=Re((t,e,n)=>{if(t[e]!==void 0&&typeof n=="function")return t[e]=n(t[e]),!0}),Fr=Re((t,e,n)=>{if(Array.isArray(t[e])&&typeof n=="function")return t[e]=n(t[e]),!0});var Sn=Object.freeze({scripts:{},config:{defaultHelpBehavior:"help",idempotency:{location:"./node_modules/.cache/bsm/idempotency",useFileContent:!1}}}),_=class{static getSource(e){return Array.isArray(e)?e[0]:e}static async loadExtensions(e){return!Object.hasOwn(e,"extends")||!e.extends?[]:(await Promise.all([...e.extends].map(n=>this.loadFile(n,!1)))).filter(n=>n!==void 0)}static async loadFile(e,n=!0){var u,i;if(!e)return;let r=this.getSource(e);try{r=require.resolve(r,{paths:[process.cwd()]});let o=require(r);typeof o=="function"&&(o=await o(...Array.isArray(e)?e.slice(1):[]));let s=await this.loadExtensions(o);return Dt(o,...s,Sn)}catch(o){let s=o,D=(i=(u=s.requireStack)==null?void 0:u[0])==null?void 0:i.replaceAll("\\","/");if(s.code==="MODULE_NOT_FOUND"&&(D!=null&&D.includes("bsm/dist/index.js"))){if(n)return;console.error(`\x1B[31mCannot find config '${r}' to extend\x1B[0m`),process.exit(1)}else console.error(o),Array.isArray(e)&&(e=e[0]),console.error(`\x1B[31mError loading config '${e}'\x1B[0m`),process.exit(1)}}static async load(e){let n=[e.config,process.env.BSM_CONFIG,"./package.scripts.js","./package.scripts.json"].filter(r=>r!==void 0);for(let r of n){let u=await this.loadFile(r);if(u)return process.env.BSM_CONFIG=r,this._config=u,u}console.error(`\x1B[31mCannot find config ${n.map(r=>`'${r}'`).join(" or ")}\x1B[0m`),process.exit(1)}static _config;static get config(){if(this._config)return this._config;throw new Error("Config not loaded")}};var se=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e==null?void 0:e.cause}},De=class extends Error{name="CancelPromptError";message="Prompt was canceled"},le=class extends Error{name="ExitPromptError"},ce=class extends Error{name="HookError"},ae=class extends Error{name="ValidationError"};var fe=require("node:async_hooks");var lt=new fe.AsyncLocalStorage;function xn(t){return{rl:t,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function ct(t,e){let n=xn(t);return lt.run(n,()=>{function r(u){n.handleChange=()=>{n.index=0,u()},n.handleChange()}return e(r)})}function W(){let t=lt.getStore();if(!t)throw new ce("[Inquirer] Hook functions can only be called from within a prompt");return t}function Le(){return W().rl}function Ie(t){let e=(...n)=>{let r=W(),u=!1,i=r.handleChange;r.handleChange=()=>{u=!0};let o=t(...n);return u&&i(),r.handleChange=i,o};return fe.AsyncResource.bind(e)}function z(t){let e=W(),{index:n}=e,r={get(){return e.hooks[n]},set(i){e.hooks[n]=i},initialized:n in e.hooks},u=t(r);return e.index++,u}function at(){W().handleChange()}var V={queue(t){let e=W(),{index:n}=e;e.hooksEffect.push(()=>{var u,i;(i=(u=e.hooksCleanup)[n])==null||i.call(u);let r=t(Le());if(r!=null&&typeof r!="function")throw new ae("useEffect return value must be a cleanup function or nothing.");e.hooksCleanup[n]=r})},run(){let t=W();Ie(()=>{t.hooksEffect.forEach(e=>{e()}),t.hooksEffect.length=0})()},clearAll(){let t=W();t.hooksCleanup.forEach(e=>{e==null||e()}),t.hooksEffect.length=0,t.hooksCleanup.length=0}};function N(t){return z(e=>{let n=u=>{e.get()!==u&&(e.set(u),at())};if(e.initialized)return[e.get(),n];let r=typeof t=="function"?t():t;return e.set(r),[r,n]})}function pe(t,e){z(n=>{let r=n.get();(!Array.isArray(r)||e.some((i,o)=>!Object.is(i,r[o])))&&V.queue(t),n.set(e)})}var T=x(dt(),1);var U=x(require("node:process"),1);function Ln(){return U.default.platform!=="win32"?U.default.env.TERM!=="linux":!!U.default.env.WT_SESSION||!!U.default.env.TERMINUS_SUBLIME||U.default.env.ConEmuTask==="{cmd::Cmder}"||U.default.env.TERM_PROGRAM==="Terminus-Sublime"||U.default.env.TERM_PROGRAM==="vscode"||U.default.env.TERM==="xterm-256color"||U.default.env.TERM==="alacritty"||U.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var mt={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},gt={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},In={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Tn={...mt,...gt},_n={...mt,...In},Un=Ln(),On=Un?Tn:_n,_e=On,_r=Object.entries(gt);var Pn={prefix:{idle:T.default.blue("?"),done:T.default.green(_e.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(t=>T.default.yellow(t))},style:{answer:T.default.cyan,message:T.default.bold,error:t=>T.default.red(`> ${t}`),defaultAnswer:t=>T.default.dim(`(${t})`),help:T.default.dim,highlight:T.default.cyan,key:t=>T.default.cyan(T.default.bold(`<${t}>`))}};function Ue(t,e){return z(n=>{let r=n.get();if(!r||r.dependencies.length!==e.length||r.dependencies.some((u,i)=>u!==e[i])){let u=t();return n.set({value:u,dependencies:e}),u}return r.value})}function de(t){return N({current:t})[0]}function Oe(t){let e=de(t);e.current=t,pe(n=>{let r=!1,u=Ie((i,o)=>{r||e.current(o,n)});return n.input.on("keypress",u),()=>{r=!0,n.input.removeListener("keypress",u)}},[])}var Vt=x(Ct(),1),Kt=x(Wt(),1);function Ee(t,e){return t.split(`
9
9
  `).flatMap(n=>(0,Kt.default)(n,e,{trim:!1,hard:!0}).split(`
10
10
  `).map(r=>r.trimEnd())).join(`
11
11
  `)}function qe(){return(0,Vt.default)({defaultWidth:80,output:Le().output})}var nn=x(require("node:readline"),1),rn=require("node:async_hooks"),un=x(Yt(),1);var K=[];K.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&K.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&K.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Ce=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Ve=Symbol.for("signal-exit emitter"),Ke=globalThis,sr=Object.defineProperty.bind(Object),Qe=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Ke[Ve])return Ke[Ve];sr(Ke,Ve,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,n){this.listeners[e].push(n)}removeListener(e,n){let r=this.listeners[e],u=r.indexOf(n);u!==-1&&(u===0&&r.length===1?r.length=0:r.splice(u,1))}emit(e,n,r){if(this.emitted[e])return!1;this.emitted[e]=!0;let u=!1;for(let i of this.listeners[e])u=i(n,r)===!0||u;return e==="exit"&&(u=this.emit("afterExit",n,r)||u),u}},Fe=class{},Dr=t=>({onExit(e,n){return t.onExit(e,n)},load(){return t.load()},unload(){return t.unload()}}),Ye=class extends Fe{onExit(){return()=>{}}load(){}unload(){}},ze=class extends Fe{#n=Je.platform==="win32"?"SIGINT":"SIGHUP";#t=new Qe;#e;#i;#o;#u={};#r=!1;constructor(e){super(),this.#e=e,this.#u={};for(let n of K)this.#u[n]=()=>{let r=this.#e.listeners(n),{count:u}=this.#t,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(u+=i.__signal_exit_emitter__.count),r.length===u){this.unload();let o=this.#t.emit("exit",null,n),s=n==="SIGHUP"?this.#n:n;o||e.kill(e.pid,s)}};this.#o=e.reallyExit,this.#i=e.emit}onExit(e,n){if(!Ce(this.#e))return()=>{};this.#r===!1&&this.load();let r=n!=null&&n.alwaysLast?"afterExit":"exit";return this.#t.on(r,e),()=>{this.#t.removeListener(r,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#r){this.#r=!0,this.#t.count+=1;for(let e of K)try{let n=this.#u[e];n&&this.#e.on(e,n)}catch{}this.#e.emit=(e,...n)=>this.#D(e,...n),this.#e.reallyExit=e=>this.#s(e)}}unload(){this.#r&&(this.#r=!1,K.forEach(e=>{let n=this.#u[e];if(!n)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,n)}catch{}}),this.#e.emit=this.#i,this.#e.reallyExit=this.#o,this.#t.count-=1)}#s(e){return Ce(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#o.call(this.#e,this.#e.exitCode)):0}#D(e,...n){let r=this.#i;if(e==="exit"&&Ce(this.#e)){typeof n[0]=="number"&&(this.#e.exitCode=n[0]);let u=r.call(this.#e,e,...n);return this.#t.emit("exit",this.#e.exitCode,null),u}else return r.call(this.#e,e,...n)}},Je=globalThis.process,{onExit:zt,load:wu,unload:vu}=Dr(Ce(Je)?new ze(Je):new Ye);var tn=require("node:util"),H=x(Xt(),1);var Zt=t=>t.split(`
@@ -16,7 +16,7 @@
16
16
  `,n+=H.default.cursorShow,this.write(n),this.rl.close()}};var Be=class extends Promise{static withResolver(){let e,n;return{promise:new Promise((u,i)=>{e=u,n=i}),resolve:e,reject:n}}};function cr(){let t=Error.prepareStackTrace;try{let e=[];return Error.prepareStackTrace=(n,r)=>{let u=r.slice(1);return e=u,u},new Error().stack,e}finally{Error.prepareStackTrace=t}}function Ze(t){var u,i;let n=(i=(u=cr()[1])==null?void 0:u.getFileName)==null?void 0:i.call(u);return(o,s={})=>{let{input:D=process.stdin,signal:l}=s,p=new Set,m=new un.default;m.pipe(s.output??process.stdout);let a=nn.createInterface({terminal:!0,input:D,output:m}),F=new ie(a),{promise:A,resolve:k,reject:L}=Be.withResolver(),S=()=>L(new De);if(l){let B=()=>L(new se({cause:l.reason}));if(l.aborted)return B(),Object.assign(A,{cancel:S});l.addEventListener("abort",B),p.add(()=>l.removeEventListener("abort",B))}p.add(zt((B,f)=>{L(new le(`User force closed the prompt with ${B} ${f}`))}));let j=()=>F.checkCursorPos();return a.input.on("keypress",j),p.add(()=>a.input.removeListener("keypress",j)),ct(a,B=>{let f=rn.AsyncResource.bind(()=>V.clearAll());return a.on("close",f),p.add(()=>a.removeListener("close",f)),B(()=>{try{let g=t(o,M=>{setImmediate(()=>k(M))});if(g===void 0)throw new Error(`Prompt functions must return a string.
17
17
  at ${n}`);let[R,C]=typeof g=="string"?[g]:g;F.render(R,C),V.run()}catch(g){L(g)}}),Object.assign(A.then(g=>(V.clearAll(),g),g=>{throw V.clearAll(),g}).finally(()=>{p.forEach(g=>g()),F.done({clearContent:!!s.clearPromptOnDone}),m.end()}).then(()=>A),{cancel:S})})}}var O=class t{static printHelp(e,n){let r=n._;if(r.length===0)console.log(`
18
18
  \x1B[1mAvailable commands:\x1B[0m`),t.printCommands(e.scripts);else for(let u of r){console.log(`
19
- \x1B[1mAvailable commands: \x1B[90m${u}\x1B[0m`);let i=u.split("."),o=[[e.scripts,[],i]];for(;o.length>0;){let s=o.shift();if(s[2].length===0)t.printCommands(s[0],s[1]);else if(s[2][0]==="*"){if(typeof s[0]=="object")if(Array.isArray(s[0]))for(let D=0;D<s[0].length;D++)o.push([s[0][D],[...s[1],D.toString()],[]]);else for(let D in s[0])Object.hasOwn(s[0],D)&&o.push([s[0][D],[...s[1],D],s[2].slice(1)])}else{let D=s[2][0];if(typeof s[0]=="object")if(Array.isArray(s[0])){let l=parseInt(D);o.push([s[0][l],[...s[1],l.toString()],s[2].slice(1)])}else o.push([s[0][D],[...s[1],D],s[2].slice(1)])}}}process.exit(0)}static printCommands(e,n=[],r=!0){if(Array.isArray(e))e.forEach((u,i)=>{t.printCommand(u,[...n,i.toString()])});else if(typeof e=="object"){r&&n.length>0&&t.printCommand(e,[...n]);for(let u in e)Object.hasOwn(e,u)&&t.printCommand(e[u],[...n,u])}else t.printCommand(e,n)}static printCommand(e,n){if(e===void 0){console.error(`\x1B[31mScript '${n.join(".")}' not found\x1B[0m`);return}let r=t.getCommandHelp(e,n);r&&console.log(r)}static getCommandHelp(e,n){if(n[n.length-1]==="$description")return;let r=`\x1B[92m${n.join(".")}\x1B[0m\x1B[90m - \x1B[0m`,u;return typeof e=="string"?u=e:typeof e=="function"?u="\x1B[90m<function>\x1B[0m":Array.isArray(e)?u=`\x1B[90m[${e.length}]\x1B[0m`:Object.hasOwn(e,"$description")?u=`\x1B[90m${e.$description}\x1B[0m`:u=`\x1B[90m{${Object.keys(e).join(", ")}}\x1B[0m`,`${r}${u}`}static printVersion(){let e=on();console.log(e.version),process.exit(0)}};var pn=x(require("node:child_process")),hn=x(cn());var dn=x(require("path")),ye=x(require("fs"));var an=require("node:crypto");var G=x(require("fs")),fn=x(require("path")),$=class{static get useFileContent(){var e,n;return((n=(e=_.config.config)==null?void 0:e.idempotency)==null?void 0:n.useFileContent)??!1}static get location(){var e,n;return((n=(e=_.config.config)==null?void 0:e.idempotency)==null?void 0:n.location)??"./node_modules/.cache/bsm/idempotency"}static updateHashForFile(e,n){try{if(this.useFileContent){let r=G.default.readFileSync(n);e.update(r)}else{let r=G.default.lstatSync(n);e.update(r.ctimeMs.toString()),e.update(r.mtimeMs.toString())}}catch{}}static updateHashForDir(e,n){G.default.readdirSync(n,{withFileTypes:!0,recursive:!0}).forEach(r=>{if(r.name==null)return;let u=fn.default.join(r.path??n,r.name).replace(/\\/g,"/");e.update(u),r.isFile()&&this.updateHashForFile(e,u)})}static calculateIdempotencyHash(e,n){var i;let r=[];if(Array.isArray(e))r.push(...e);else if(typeof e=="string")r.push(e);else for(let o of Object.values(e))Array.isArray(o)?r.push(...o):r.push(o);let u=(0,an.createHash)("sha256");for(let o of r){let s=o.split(":")[0],D=o.substring(s.length+1);switch(s){case"static":u.update(D);break;case"env":u.update(D),u.update(((i=n==null?void 0:n.env)==null?void 0:i[D])??process.env[D]??Buffer.of());break;case"file":this.updateHashForFile(u,D);break;case"dir":this.updateHashForDir(u,D);break;default:console.log(`\x1B[33m[Idempotency]\x1B[0m Unknown type: ${s}, using value as static`),u.update(o)}}return u.digest("hex")}static saveIdempotencyHash(e,n){let r=n.join("."),u=`${this.location}/${r}.hash`;G.default.mkdirSync(this.location,{recursive:!0}),G.default.writeFileSync(u,e)}static getSavedIdempotencyHash(e){let n=e.join("."),r=`${this.location}/${n}.hash`;if(G.default.existsSync(r))return G.default.readFileSync(r,"utf-8")}static checkIdempotency(e,n,r){let u=e.$idempotency,i=this.calculateIdempotencyHash(u,r);return this.getSavedIdempotencyHash(n)===i}static saveIdempotency(e,n){let r=e.$idempotency,u=this.calculateIdempotencyHash(r);this.saveIdempotencyHash(u,n)}static hasIdempotencyEnabled(e){return Object.hasOwn(e,"$idempotency")?Object.hasOwn(e,"$idempotencyEnabled")?!!e.$idempotencyEnabled:!0:!1}};var q=class extends Error{constructor(n,r){super();this.code=n;this.script=r}},te=class extends q{constructor(n,r){super(1,r);this.func=n;this.script=r}};var Q=class t{static async run(e){let n=_.config;await t.runScript(n.scripts,e.split("."),[],{})}static async runScript(e,n,r,u){typeof e=="function"?await t.executeFunction(e,n,r,u):typeof e=="string"?await t.executeString(e,n,r,u):typeof e=="object"?Array.isArray(e)?await t.executeArray(e,n,r,u):await t.executeObject(e,n,r,u):await t.notFound(r,u)}static async notFound(e,n,r){var u;if(!n.ignoreNotFound){if(r){let i=e[e.length-1],o=e.slice(0,-1);if(o.length===0?console.error(`\x1B[31mScript '${i}' does not exist\x1B[0m`):console.error(`\x1B[31mScript '${o.join(".")}' does not have a '${i}' script\x1B[0m`),((u=_.config.config)==null?void 0:u.defaultHelpBehavior)==="interactive"){let s=await Y.selectScript(_.config,{_:[e.join(".")]});await this.run(s[0]),process.exit(0)}else console.log(),Object.hasOwn(r,"$description")&&(O.printCommand(r,o),console.log()),console.log("\x1B[1mTry one of the following:\x1B[0m"),O.printCommands(r,o,!1)}else console.error(`\x1B[31mScript '${e.join(".")}' not found\x1B[0m`);process.exit(127)}}static async executeFunction(e,n,r,u){var s;console.log(`> \x1B[93mExecuting JavaScript function\x1B[0m \x1B[90m(${[...r].join(".")})\x1B[0m`);let i,o=process.env;try{process.env={...process.env,...u.env},i=await e.call(null,process.argv)}catch(D){throw D instanceof Error&&(D.stack=(s=D.stack)==null?void 0:s.split(" at executeFunction")[0]),new te(D,r.join("."))}finally{process.env=o}if(i==null){n.length>0&&await t.notFound([...r,...n],u);return}await t.runScript(i,n,r,{...u,excludeArgs:!0})}static async executeString(e,n,r,u){if(n.length>0){await t.notFound([...r,...n],u);return}!u.excludeArgs&&process.argv.length&&(e+=" "+process.argv.join(" ")),console.log(`> ${e} \x1B[90m(${r.join(".")})\x1B[0m`),process.env.BSM_LOG_FILE&&ye.default.appendFileSync(process.env.BSM_LOG_FILE,`${new Date().toISOString()} ${e} ${r.join(".")} ${process.cwd()}
19
+ \x1B[1mAvailable commands: \x1B[90m${u}\x1B[0m`);let i=u.split("."),o=[[e.scripts,[],i]];for(;o.length>0;){let s=o.shift();if(s[2].length===0)t.printCommands(s[0],s[1]);else if(s[2][0]==="*"){if(typeof s[0]=="object")if(Array.isArray(s[0]))for(let D=0;D<s[0].length;D++)o.push([s[0][D],[...s[1],D.toString()],[]]);else for(let D in s[0])Object.hasOwn(s[0],D)&&o.push([s[0][D],[...s[1],D],s[2].slice(1)])}else{let D=s[2][0];if(typeof s[0]=="object")if(Array.isArray(s[0])){let l=parseInt(D);o.push([s[0][l],[...s[1],l.toString()],s[2].slice(1)])}else o.push([s[0][D],[...s[1],D],s[2].slice(1)])}}}process.exit(0)}static printCommands(e,n=[],r=!0){if(Array.isArray(e))e.forEach((u,i)=>{t.printCommand(u,[...n,i.toString()])});else if(typeof e=="object"){r&&n.length>0&&t.printCommand(e,[...n]);for(let u in e)Object.hasOwn(e,u)&&t.printCommand(e[u],[...n,u])}else t.printCommand(e,n)}static printCommand(e,n){if(e===void 0){console.error(`\x1B[31mScript '${n.join(".")}' not found\x1B[0m`);return}let r=t.getCommandHelp(e,n);r&&console.log(r)}static getCommandHelp(e,n){if(n[n.length-1]==="$description")return;let r=`\x1B[92m${n.join(".")}\x1B[0m\x1B[90m - \x1B[0m`,u;return typeof e=="string"?u=e:typeof e=="function"?u="\x1B[90m<function>\x1B[0m":Array.isArray(e)?u=`\x1B[90m[${e.length}]\x1B[0m`:Object.hasOwn(e,"$description")?u=`\x1B[90m${e.$description}\x1B[0m`:u=`\x1B[90m{${Object.keys(e).join(", ")}}\x1B[0m`,`${r}${u}`}static printVersion(){let e=on();console.log(e.version),process.exit(0)}};var pn=x(require("node:child_process")),hn=x(cn());var dn=x(require("path")),ye=x(require("fs"));var an=require("node:crypto");var G=x(require("fs")),fn=x(require("path")),$=class{static get useFileContent(){var e,n;return((n=(e=_.config.config)==null?void 0:e.idempotency)==null?void 0:n.useFileContent)??!1}static get location(){var e,n;return((n=(e=_.config.config)==null?void 0:e.idempotency)==null?void 0:n.location)??"./node_modules/.cache/bsm/idempotency"}static updateHashForFile(e,n){try{if(this.useFileContent){let r=G.default.readFileSync(n);e.update(r)}else{let r=G.default.lstatSync(n);e.update(r.ctimeMs.toString()),e.update(r.mtimeMs.toString())}}catch{}}static updateHashForDir(e,n){try{G.default.readdirSync(n,{withFileTypes:!0,recursive:!0}).forEach(r=>{if(r.name==null)return;let u=fn.default.join(r.path??n,r.name).replace(/\\/g,"/");e.update(u),r.isFile()&&this.updateHashForFile(e,u)})}catch{}}static calculateIdempotencyHash(e,n){var i;let r=[];if(Array.isArray(e))r.push(...e);else if(typeof e=="string")r.push(e);else for(let o of Object.values(e))Array.isArray(o)?r.push(...o):r.push(o);let u=(0,an.createHash)("sha256");for(let o of r){let s=o.split(":")[0],D=o.substring(s.length+1);switch(s){case"static":u.update(D);break;case"env":u.update(D),u.update(((i=n==null?void 0:n.env)==null?void 0:i[D])??process.env[D]??Buffer.of());break;case"file":this.updateHashForFile(u,D);break;case"dir":this.updateHashForDir(u,D);break;default:console.log(`\x1B[33m[Idempotency]\x1B[0m Unknown type: ${s}, using value as static`),u.update(o)}}return u.digest("hex")}static saveIdempotencyHash(e,n){let r=n.join("."),u=`${this.location}/${r}.hash`;G.default.mkdirSync(this.location,{recursive:!0}),G.default.writeFileSync(u,e)}static getSavedIdempotencyHash(e){let n=e.join("."),r=`${this.location}/${n}.hash`;if(G.default.existsSync(r))return G.default.readFileSync(r,"utf-8")}static checkIdempotency(e,n,r){let u=e.$idempotency,i=this.calculateIdempotencyHash(u,r);return this.getSavedIdempotencyHash(n)===i}static saveIdempotency(e,n){let r=e.$idempotency,u=this.calculateIdempotencyHash(r);this.saveIdempotencyHash(u,n)}static hasIdempotencyEnabled(e){return Object.hasOwn(e,"$idempotency")?Object.hasOwn(e,"$idempotencyEnabled")?!!e.$idempotencyEnabled:!0:!1}};var q=class extends Error{constructor(n,r){super();this.code=n;this.script=r}},te=class extends q{constructor(n,r){super(1,r);this.func=n;this.script=r}};var Q=class t{static async run(e){let n=_.config;await t.runScript(n.scripts,e.split("."),[],{})}static async runScript(e,n,r,u){typeof e=="function"?await t.executeFunction(e,n,r,u):typeof e=="string"?await t.executeString(e,n,r,u):typeof e=="object"?Array.isArray(e)?await t.executeArray(e,n,r,u):await t.executeObject(e,n,r,u):await t.notFound(r,u)}static async notFound(e,n,r){var u;if(!n.ignoreNotFound){if(r){let i=e[e.length-1],o=e.slice(0,-1);if(o.length===0?console.error(`\x1B[31mScript '${i}' does not exist\x1B[0m`):console.error(`\x1B[31mScript '${o.join(".")}' does not have a '${i}' script\x1B[0m`),((u=_.config.config)==null?void 0:u.defaultHelpBehavior)==="interactive"){let s=await Y.selectScript(_.config,{_:[e.join(".")]});await this.run(s[0]),process.exit(0)}else console.log(),Object.hasOwn(r,"$description")&&(O.printCommand(r,o),console.log()),console.log("\x1B[1mTry one of the following:\x1B[0m"),O.printCommands(r,o,!1)}else console.error(`\x1B[31mScript '${e.join(".")}' not found\x1B[0m`);process.exit(127)}}static async executeFunction(e,n,r,u){var s;console.log(`> \x1B[93mExecuting JavaScript function\x1B[0m \x1B[90m(${[...r].join(".")})\x1B[0m`);let i,o=process.env;try{process.env={...process.env,...u.env},i=await e.call(null,process.argv)}catch(D){throw D instanceof Error&&(D.stack=(s=D.stack)==null?void 0:s.split(" at executeFunction")[0]),new te(D,r.join("."))}finally{process.env=o}if(i==null){n.length>0&&await t.notFound([...r,...n],u);return}await t.runScript(i,n,r,{...u,excludeArgs:!0})}static async executeString(e,n,r,u){if(n.length>0){await t.notFound([...r,...n],u);return}!u.excludeArgs&&process.argv.length&&(e+=" "+process.argv.join(" ")),console.log(`> ${e} \x1B[90m(${r.join(".")})\x1B[0m`),process.env.BSM_LOG_FILE&&ye.default.appendFileSync(process.env.BSM_LOG_FILE,`${new Date().toISOString()} ${e} ${r.join(".")} ${process.cwd()}
20
20
  `),e!==""&&(e=e.replace(/bsm ~/g,"bsm \\~"),await new Promise((i,o)=>{pn.default.spawn(e,[],{stdio:"inherit",shell:!0,env:{...process.env,...u.env,BSM_PATH:r.slice(0,-1).join("."),BSM_SCRIPT:r.join(".")}}).on("close",D=>{D===0?i():o(new q(D,r.join(".")))})}))}static async executeArray(e,n,r,u){if(n.length===0||n[0]==="*"){for(let i=0;i<e.length;i++)await t.runScript(e[i],n.slice(1),[...r,i.toString()],{...u,ignoreNotFound:n[0]==="*"?!0:u.ignoreNotFound});return}else{let i=n[0],o=e[parseInt(i)];if(o===void 0){let s=t.subscriptWithAlias(e,i);if(s){await t.runScript(s[1],n.slice(1),[...r,s[0]],u);return}else{await t.notFound([...r,i],u,e);return}}await t.runScript(o,n.slice(1),[...r,i],u)}}static shouldRun(e,n,r,u){return $.hasIdempotencyEnabled(e)&&$.checkIdempotency(e,r,u)?(console.log(`\x1B[90mNot running ${[...r,...n].join(".")} because the idempotency hash is the same\x1B[0m`),!1):!0}static async executeObject(e,n,r,u){try{if(Object.hasOwn(e,"$env")&&(u.env={...u.env,...t.getEnv(e.$env)}),!t.shouldRun(e,n,r,u))return;if(await t.executeHook(e,"_pre",r,u),n.length===0)await t.runObject(e,r,u);else if(n[0]==="*")for(let i in e)i.startsWith("_")||i.startsWith("$")||Object.hasOwn(e,i)&&await t.runScript(e[i],n.slice(1),[...r,i],{...u,ignoreNotFound:!0});else{let i=n[0];if(Object.hasOwn(e,i))await t.runScript(e[i],n.slice(1),[...r,i],u);else{let o=t.subscriptWithAlias(e,i);if(o)await t.runScript(o[1],n.slice(1),[...r,o[0]],u);else{await t.notFound([...r,i],u,e);return}}}await t.executeHook(e,"_post",r,u),$.hasIdempotencyEnabled(e)&&$.saveIdempotency(e,r)}catch(i){if(i instanceof q?process.env.BSM_ERROR=i.code.toString():process.env.BSM_ERROR="1",await t.executeHook(e,"_onError",r,u),!await t.executeHook(e,"_catch",r,u))throw i;$.hasIdempotencyEnabled(e)&&$.saveIdempotency(e,r)}finally{await t.executeHook(e,"_finally",r,u)}}static subscriptWithAlias(e,n){for(let r of Object.entries(e)){let u=r[1];if(typeof u=="object"&&!Array.isArray(u)&&Object.hasOwn(u,"$alias")){let i=u.$alias;if(typeof i=="string"){if(i===n)return r}else if(Array.isArray(i)&&i.includes(n))return r}}}static getEnv(e){if(typeof e=="string"){if(e==="")return{};if(e.startsWith("file:")){let n=dn.default.join(process.cwd(),e.slice(5));if(!ye.default.existsSync(n))return console.error(`\x1B[31mFile '${n}' does not exist\x1B[0m
21
21
  \x1B[1mRunning script without these environment variables\x1B[0m
22
22
  `),{};let u=ye.default.readFileSync(n,"utf-8").replaceAll("\r","").split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@under_koen/bsm",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "BSM (Basic Script Manager) is a useful tool that enables you to create clear and concise scripts without cluttering your `package.json` file.",
5
5
  "license": "MIT",
6
6
  "author": "Koen van Staveren <koen@underkoen.nl>",