ts-pantry 0.11.46 → 0.11.47
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/bin/cli.js +3 -3
- package/dist/{chunk-a3hfht05.js → chunk-2cd3s91w.js} +2 -2
- package/dist/{chunk-f85jr02h.js → chunk-en908hmq.js} +1 -1
- package/dist/{chunk-vwgjwxzv.js → chunk-ggxaeaat.js} +1 -1
- package/dist/chunk-ws531zme.js +2 -0
- package/dist/{chunk-rvjeacx2.js → chunk-y1ss7e12.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/packages/apps/codexopenaicom.d.ts +1 -1
- package/dist/src/packages/dozzledev.d.ts +3 -3
- package/dist/src/packages/vclustercom.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunk-x0nv26m0.js +0 -2
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{E as Ie,L as Oe,M as ie,O as re,S as oe,Ua as Me,Va as Re,Xa as Le,_a as Ve,ab as Fe,fb as ze,gb as We,hb as Ue,ka as Ee,la as Te,ma as Ae,na as _e,oa as Pe,sa as ae,ta as Be,ua as Ne}from"../chunk-
|
|
2
|
+
import{E as Ie,L as Oe,M as ie,O as re,S as oe,Ua as Me,Va as Re,Xa as Le,_a as Ve,ab as Fe,fb as ze,gb as We,hb as Ue,ka as Ee,la as Te,ma as Ae,na as _e,oa as Pe,sa as ae,ta as Be,ua as Ne}from"../chunk-2cd3s91w.js";import"../chunk-hcjwces4.js";import"../chunk-az80mvjc.js";import"../chunk-4bmqqr46.js";import{Mb as U,Nb as je,Pb as se,Qb as G,Vb as De,Zb as ne}from"../chunk-g74212sz.js";import"../chunk-pxh9p9j7.js";import"../chunk-vfvcayrz.js";import{qc as W,rc as ee,sc as te}from"../chunk-8tmasvs9.js";import"../chunk-en908hmq.js";import"../chunk-ws531zme.js";import{Oc as Ce,Pc as zt}from"../chunk-s094ynsz.js";import{Tc as N}from"../chunk-ava4pf2j.js";import d from"node:fs";import y from"node:path";import u from"node:process";import{existsSync as He}from"node:fs";import q from"node:fs/promises";import ue from"node:os";import H from"node:path";import B from"node:process";import{EventEmitter as Ke}from"node:events";import j from"node:process";import he from"node:process";import Y from"node:process";import F from"node:process";import L from"node:process";import me from"node:tty";import Nt,{stdin as ps,stdout as fs}from"node:process";class ge{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=ue.homedir(),t=H.join(e,".config","clapp");this.configPath=H.join(t,"telemetry.json")}async isEnabled(){if(B.env.DO_NOT_TRACK==="1"||B.env.DO_NOT_TRACK==="true")return!1;if(B.env.NO_TELEMETRY==="1"||B.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let n={event:e,...t,timestamp:Date.now(),platform:ue.platform(),nodeVersion:B.version};if(this.events.push(n),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:B.env.DO_NOT_TRACK==="1"||B.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(He(this.configPath)){let e=await q.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=H.dirname(this.configPath);await q.mkdir(t,{recursive:!0}),await q.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var es=new ge;function Je(e,t={}){let s={_:[]},n=t.alias||{},i=new Set(t.boolean||[]),r={};for(let l of Object.keys(n))for(let o of n[l])r[o]=l;for(let l of i)if(n[l])for(let o of n[l])i.add(o);function a(l,o){let c=r[l]||l;if(s[c]=o,n[c])for(let p of n[c])s[p]=o;if(r[l]&&n[r[l]])for(let p of n[r[l]])s[p]=o;s[l]=o}for(let l=0;l<e.length;l++){let o=e[l];if(o==="--"){s._.push(...e.slice(l+1));break}if(o.startsWith("--")){let c=o.indexOf("=");if(c!==-1){let p=o.slice(2,c),g=o.slice(c+1);a(p,g)}else{let p=o.slice(2);if(p.startsWith("no-")){let h=p.slice(3);a(h,!1);continue}let g=r[p]||p;if(i.has(g)||i.has(p))a(p,!0);else{let h=e[l+1];if(h!==void 0&&!h.startsWith("-"))a(p,h),l++;else a(p,!0)}}}else if(o.startsWith("-")&&o.length>1){let c=o.slice(1);for(let p=0;p<c.length;p++){let g=c[p],h=r[g]||g;if(p===c.length-1&&!i.has(h)&&!i.has(g)){let f=e[l+1];if(f!==void 0&&!f.startsWith("-"))a(g,f),l++;else a(g,!0)}else a(g,!0)}}else s._.push(o)}return s}function J(e){return e.replace(/[<[].+/,"").trim()}function Ye(e){let t=/<([^>]+)>/g,s=/\[([^\]]+)\]/g,n=[],i=(l)=>{let o=!1,c=l[1];if(c.startsWith("..."))c=c.slice(3),o=!0;return{required:l[0].startsWith("<"),value:c,variadic:o}},r;while(r=t.exec(e))n.push(i(r));let a;while(a=s.exec(e))n.push(i(a));return n}function Ze(e){let t={alias:{},boolean:[]};for(let[s,n]of e.entries()){if(n.names.length>1)t.alias[n.names[0]]=n.names.slice(1);if(n.isBoolean)if(n.negated){if(!e.some((r,a)=>a!==s&&r.names.some((l)=>n.names.includes(l))&&typeof r.required==="boolean"))t.boolean.push(n.names[0])}else t.boolean.push(n.names[0])}return t}function de(e){return e.reduce((t,s)=>t.length>=s.length?t:s,"")}function K(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Xe(e){return e.replace(/([a-z])-([a-z])/g,(t,s,n)=>s+n.toUpperCase())}function Qe(e,t,s){let n=0,i=t.length,r=e,a;for(;n<i;++n)a=r[t[n]],r=r[t[n]]=n===i-1?s:a!=null?a:!!~t[n+1].indexOf(".")||!(+t[n+1]>-1)?{}:[]}function et(e,t){for(let s of Object.keys(t)){let n=t[s];if(n.shouldTransform){if(e[s]=Array.prototype.concat.call([],e[s]),typeof n.transformFunction==="function")e[s]=e[s].map(n.transformFunction)}}}function tt(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function ye(e){return e.split(".").map((t,s)=>s===0?Xe(t):t).join(".")}class V extends Error{exitCode=2;isUsageError=!0;constructor(e){super(e);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(e).stack}format(e=!1){if(e&&this.stack)return`${this.message}
|
|
3
3
|
|
|
4
4
|
Stack trace:
|
|
5
5
|
${this.stack}`;return this.message}}function st(){let{env:e}=he,{TERM:t,TERM_PROGRAM:s}=e;if(he.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||s==="Terminus-Sublime"||s==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var z="\x1B",E=`${z}[`;var pe={to(e,t){if(!t)return`${E}${e+1}G`;return`${E}${t+1};${e+1}H`},move(e,t){let s="";if(e<0)s+=`${E}${-e}D`;else if(e>0)s+=`${E}${e}C`;if(t<0)s+=`${E}${-t}A`;else if(t>0)s+=`${E}${t}B`;return s},up:(e=1)=>`${E}${e}A`,down:(e=1)=>`${E}${e}B`,forward:(e=1)=>`${E}${e}C`,backward:(e=1)=>`${E}${e}D`,nextLine:(e=1)=>`${E}E`.repeat(e),prevLine:(e=1)=>`${E}F`.repeat(e),left:`${E}G`,hide:`${E}?25l`,show:`${E}?25h`,save:`${z}7`,restore:`${z}8`};var is={screen:`${E}2J`,up:(e=1)=>`${E}1J`.repeat(e),down:(e=1)=>`${E}J`.repeat(e),line:`${E}2K`,lineEnd:`${E}K`,lineStart:`${E}1K`,lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?pe.up():"");if(e)t+=pe.left;return t}},rs={screen:`${z}c`};function nt(e,t){let s=[];for(let n=0;n<=t.length;n++)s[n]=[n];for(let n=0;n<=e.length;n++)s[0][n]=n;for(let n=1;n<=t.length;n++)for(let i=1;i<=e.length;i++)if(t.charAt(n-1)===e.charAt(i-1))s[n][i]=s[n-1][i-1];else s[n][i]=Math.min(s[n-1][i-1]+1,s[n][i-1]+1,s[n-1][i]+1);return s[t.length][e.length]}function $e(e,t,s=2,n=3){return t.map((i)=>({cmd:i,distance:nt(e,i)})).filter(({distance:i})=>i<=s).sort((i,r)=>i.distance-r.distance).slice(0,n).map(({cmd:i})=>i)}class be{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,s){if(this.rawName=e,this.description=t,this.config=Object.assign({},s),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=J(e).split(",").map((n)=>{let i=n.trim().replace(/^-{1,2}/,"");if(i.startsWith("no-"))this.negated=!0,i=i.replace(/^no-/,"");return ye(i)}).sort((n,i)=>n.length>i.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}}var as=Y.argv,it=`${Y.platform}-${Y.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,fe=F.argv,rt=`${F.platform}-${F.arch} node-${F.version}`;class Z{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,s,n){this.rawName=e,this.description=t,this.config=s,this.cli=n,this.options=[],this.aliasNames=[],this.name=J(e);let i=J(e),r=i.indexOf(":");if(r>0)this.namespace=i.substring(0,r),this.name=i.substring(r+1);if(this.args=Ye(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!s)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,s){let n=new be(e,t,s);return this.options.push(n),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}before(e){return this.beforeHooks.push(e),this}after(e){return this.afterHooks.push(e),this}use(e){return this.middleware.push(e),this}isMatched(e){if(this.aliasNames.includes(e))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===e;return this.name===e}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof X}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){return e=e.split(".")[0],!!this.options.find((t)=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:s,options:n,helpCallback:i}=this.cli.globalCommand,r=[{body:`${e}${s?`/${s}`:""}`}];if(r.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let o=de(t.map((f)=>f.rawName)),c=new Map,p=[];for(let f of t)if(f.namespace){if(!c.has(f.namespace))c.set(f.namespace,[]);c.get(f.namespace).push(f)}else p.push(f);let g="";if(p.length>0)g+=p.map((f)=>` ${K(f.rawName,o.length)} ${f.description}`).join(`
|
|
@@ -28,7 +28,7 @@ Received ${s}, cleaning up...`),e)try{await e()}catch(n){console.error("Error du
|
|
|
28
28
|
✗ Command "${e}" not found.
|
|
29
29
|
`)),this.enableDidYouMean){let t=[];for(let n of this.commands){if(n.displayName)t.push(n.displayName);if(n.aliasNames)t.push(...n.aliasNames)}let s=$e(e,t);if(s.length>0)console.log(R.yellow("Did you mean one of these?")),s.forEach((n)=>console.log(` ${R.dim("•")} ${this.name} ${n}`)),console.log("")}console.log(R.dim("Run"),`${this.name} --help`,R.dim("to see all available commands")),j.exit(1)}async parse(e=fe,t={}){let{run:s=!0,exitOnError:n=!1}=t;if(n)try{return await this.parse(e,{run:s})}catch(o){throw this.handleUsageError(o),o}if(this.rawArgs=e,!this.name)this.name=e[1]?tt(e[1]):"cli";let i=!0,r=e.slice(2),a=r[0];if(a&&!a.startsWith("-")){for(let o of this.commands)if(o.isMatched(a)){let c=this.mri(r,o);i=!1;let p={...c,args:c.args.slice(1)};this.setParsedInfo(p,o,a),this.emit(`command:${a}`,o);break}}if(i){for(let o of this.commands)if(o.name===""){i=!1;let c=this.mri(r,o);this.setParsedInfo(c,o),this.emit("command:!",o);break}}if(i){let o=this.mri(e.slice(2));this.setParsedInfo(o)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji!==void 0)this.useEmoji=!this.options.noEmoji;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache!==void 0)this.isNoCache=Boolean(this.options.noCache);if(this.options.help&&this.showHelpOnExit)this.outputHelp(),s=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),s=!1,this.unsetMatchedCommand();let l={args:this.args,options:this.options};if(s)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return l}mri(e,t){let s=[...this.globalCommand.options,...t?t.options:[]],n=Ze(s),i=[],r=e.indexOf("--");if(r>-1)i=e.slice(r+1),e=e.slice(0,r);let a=Je(e,n),l={_:a._};for(let h of Object.keys(a))if(h!=="_")l[ye(h)]=a[h];let o=l._,c={"--":i},p=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,g=Object.create(null);for(let h of s){if(!p&&h.config.default!==void 0)for(let f of h.names)c[f]=h.config.default;if(Array.isArray(h.config.type)){if(g[h.name]===void 0)g[h.name]={shouldTransform:!0,transformFunction:h.config.type[0]}}}for(let h of Object.keys(l))if(h!=="_"){let f=h.split(".");Qe(c,f,l[h]),et(c,g)}return{args:o,options:c}}async run(e=fe){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!(!!e&&typeof e==="object"&&e.name==="ClappError"&&e.isUsageError!==!1))return;let n=e,i=n.message??"command-line error",r=this.name?`${this.name}: `:"",a=/--help/.test(i)?"":`
|
|
30
30
|
Run \`${this.name??"cli"} --help\` for usage.`;j.stderr.write(`${r}${i}${a}
|
|
31
|
-
`),j.exit(n.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];s.args.forEach((l,o)=>{if(l.variadic)n.push(e.slice(o));else n.push(e[o])}),n.push(t);let i={command:s,args:n,options:t};for(let l of s.beforeHooks)await l(i);let r,a=async()=>{let l=s.commandAction.apply(this,n);if(l instanceof Promise)r=await l;else r=l;return r};if(s.middleware.length>0){let l=0,o=async()=>{if(l<s.middleware.length){let c=s.middleware[l++];await c({...i,next:o})}else await a()};await o()}else await a();for(let l of s.afterHooks)await l(i);return r}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return j.removeAllListeners("SIGINT"),j.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class we{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var cs=new we;function ct(){if("FORCE_COLOR"in L.env)return L.env.FORCE_COLOR!=="0";if("NO_COLOR"in L.env||L.env.TERM==="dumb")return!1;if(L.platform==="win32")return!0;return me.isatty(1)&&me.isatty(2)}var ve=ct();function C(e,t){if(!ve)return(s)=>s;return(s)=>e+s+t}var ut=C("\x1B[0m","\x1B[0m"),ht=C("\x1B[31m","\x1B[39m"),dt=C("\x1B[32m","\x1B[39m"),pt=C("\x1B[33m","\x1B[39m"),ft=C("\x1B[34m","\x1B[39m"),mt=C("\x1B[35m","\x1B[39m"),gt=C("\x1B[36m","\x1B[39m"),yt=C("\x1B[37m","\x1B[39m"),$t=C("\x1B[90m","\x1B[39m"),bt=C("\x1B[1m","\x1B[22m"),wt=C("\x1B[3m","\x1B[23m"),vt=C("\x1B[4m","\x1B[24m"),xt=C("\x1B[2m","\x1B[22m"),St=C("\x1B[7m","\x1B[27m"),kt=C("\x1B[8m","\x1B[28m"),Ct=C("\x1B[9m","\x1B[29m"),It=C("\x1B[41m","\x1B[49m"),Ot=C("\x1B[42m","\x1B[49m"),Et=C("\x1B[43m","\x1B[49m"),Tt=C("\x1B[44m","\x1B[49m"),At=C("\x1B[45m","\x1B[49m"),_t=C("\x1B[46m","\x1B[49m"),Pt=C("\x1B[47m","\x1B[49m"),jt=ve,Dt={reset:ut,red:ht,green:dt,yellow:pt,blue:ft,magenta:mt,cyan:gt,white:yt,gray:$t,bold:bt,italic:wt,underline:vt,dim:xt,inverse:St,hidden:kt,strikethrough:Ct,bgRed:It,bgGreen:Ot,bgYellow:Et,bgBlue:Tt,bgMagenta:At,bgCyan:_t,bgWhite:Pt,isColorSupported:jt},Bt=Dt,Mt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Mt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Nt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Rt=st();var S=(e,t)=>Rt?e:t,$s=S("◆","*"),bs=S("■","x"),ws=S("▲","x"),vs=S("◇","o"),xs=S("┌","T"),Lt=S("│","|"),Ss=S("└","—"),ks=S("●",">"),Cs=S("○"," "),Is=S("◻","[•]"),Os=S("◼","[+]"),Es=S("◻","[ ]"),Ts=S("▪","•"),As=S("─","-"),_s=S("╮","+"),Ps=S("├","+"),js=S("╯","+"),Ds=S("●","•"),Bs=S("◆","*"),Ns=S("▲","!"),Ms=S("■","x");var Rs={light:S("─","-"),heavy:S("━","="),block:S("█","#")};function Vt(){return`${Bt.gray(Lt)} `}var Ls=Vt();var xe="0.11.
|
|
31
|
+
`),j.exit(n.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];s.args.forEach((l,o)=>{if(l.variadic)n.push(e.slice(o));else n.push(e[o])}),n.push(t);let i={command:s,args:n,options:t};for(let l of s.beforeHooks)await l(i);let r,a=async()=>{let l=s.commandAction.apply(this,n);if(l instanceof Promise)r=await l;else r=l;return r};if(s.middleware.length>0){let l=0,o=async()=>{if(l<s.middleware.length){let c=s.middleware[l++];await c({...i,next:o})}else await a()};await o()}else await a();for(let l of s.afterHooks)await l(i);return r}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return j.removeAllListeners("SIGINT"),j.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class we{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var cs=new we;function ct(){if("FORCE_COLOR"in L.env)return L.env.FORCE_COLOR!=="0";if("NO_COLOR"in L.env||L.env.TERM==="dumb")return!1;if(L.platform==="win32")return!0;return me.isatty(1)&&me.isatty(2)}var ve=ct();function C(e,t){if(!ve)return(s)=>s;return(s)=>e+s+t}var ut=C("\x1B[0m","\x1B[0m"),ht=C("\x1B[31m","\x1B[39m"),dt=C("\x1B[32m","\x1B[39m"),pt=C("\x1B[33m","\x1B[39m"),ft=C("\x1B[34m","\x1B[39m"),mt=C("\x1B[35m","\x1B[39m"),gt=C("\x1B[36m","\x1B[39m"),yt=C("\x1B[37m","\x1B[39m"),$t=C("\x1B[90m","\x1B[39m"),bt=C("\x1B[1m","\x1B[22m"),wt=C("\x1B[3m","\x1B[23m"),vt=C("\x1B[4m","\x1B[24m"),xt=C("\x1B[2m","\x1B[22m"),St=C("\x1B[7m","\x1B[27m"),kt=C("\x1B[8m","\x1B[28m"),Ct=C("\x1B[9m","\x1B[29m"),It=C("\x1B[41m","\x1B[49m"),Ot=C("\x1B[42m","\x1B[49m"),Et=C("\x1B[43m","\x1B[49m"),Tt=C("\x1B[44m","\x1B[49m"),At=C("\x1B[45m","\x1B[49m"),_t=C("\x1B[46m","\x1B[49m"),Pt=C("\x1B[47m","\x1B[49m"),jt=ve,Dt={reset:ut,red:ht,green:dt,yellow:pt,blue:ft,magenta:mt,cyan:gt,white:yt,gray:$t,bold:bt,italic:wt,underline:vt,dim:xt,inverse:St,hidden:kt,strikethrough:Ct,bgRed:It,bgGreen:Ot,bgYellow:Et,bgBlue:Tt,bgMagenta:At,bgCyan:_t,bgWhite:Pt,isColorSupported:jt},Bt=Dt,Mt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Mt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Nt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Rt=st();var S=(e,t)=>Rt?e:t,$s=S("◆","*"),bs=S("■","x"),ws=S("▲","x"),vs=S("◇","o"),xs=S("┌","T"),Lt=S("│","|"),Ss=S("└","—"),ks=S("●",">"),Cs=S("○"," "),Is=S("◻","[•]"),Os=S("◼","[+]"),Es=S("◻","[ ]"),Ts=S("▪","•"),As=S("─","-"),_s=S("╮","+"),Ps=S("├","+"),js=S("╯","+"),Ds=S("●","•"),Bs=S("◆","*"),Ns=S("▲","!"),Ms=S("■","x");var Rs={light:S("─","-"),heavy:S("━","="),block:S("█","#")};function Vt(){return`${Bt.gray(Lt)} `}var Ls=Vt();var xe="0.11.47";zt();async function Wt(e="src/pantry"){if(!d.existsSync(e))throw Error(`Pantry directory not found: ${e}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let t=[];function s(n,i=""){let r=d.readdirSync(n,{withFileTypes:!0}),a=y.join(n,"package.yml");if(i&&d.existsSync(a))t.push(i);for(let l of r)if(l.isDirectory()&&!l.name.startsWith(".")){let o=i?`${i}/${l.name}`:l.name,c=y.join(n,l.name);s(c,o)}}return s(e),console.log(`\uD83D\uDCE6 Found ${t.length} packages in local pantry`),t.sort()}async function Ut(e=!1){async function t(a){let l=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(l.searchParams.set("list-type","2"),l.searchParams.set("prefix",""),l.searchParams.set("max-keys","1000"),a)l.searchParams.set("continuation-token",a);let o=await fetch(l.toString());if(!o.ok)throw Error(`Failed to fetch S3 listing: ${o.status}`);let c=await o.text(),p=[],g=c.match(/<Key>([^<]+)<\/Key>/g);if(g)for(let I of g){let O=I.replace(/<Key>([^<]+)<\/Key>/,"$1");p.push({Key:O})}let h=c.includes("<IsTruncated>true</IsTruncated>"),f=c.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),m=f?f[1]:void 0;return{IsTruncated:h,NextContinuationToken:m,Contents:p}}console.log("Scraping packages from S3 registry...");let s=new Set,n;do{let a=await t(n);for(let l of a.Contents){let o=l.Key,c=o.split("/");if(c.length===0)continue;if(c[0].startsWith(".")||c[0].includes(" ")||o.match(/\.(md|txt|yml|yaml|json)$/i))continue;let p=["darwin","linux","windows"],g=-1;for(let h=1;h<c.length;h++)if(p.includes(c[h])){g=h;break}if(g>0){let h=c.slice(0,g).join("/");if(h.includes("."))s.add(h)}else if(c.length>=2&&c[0].includes(".")&&!c[1].startsWith("v")&&!c[1].match(/^\d/)){let h=`${c[0]}/${c[1]}`;s.add(h)}else if(c.length>=1&&c[0].includes("."))s.add(c[0])}n=a.NextContinuationToken,console.log(`Found ${s.size} packages so far...`)}while(n);let i=Array.from(s).sort(),r=[];for(let a of i){if(!a.includes(".")||a.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(a.endsWith("/README.rst")||a.endsWith("/README")||a.includes("/docs/"))continue;if(a.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(a))continue;r.push(a)}return console.log(`\uD83D\uDCE6 Found ${r.length} valid packages in registry`),r}async function Gt(e,t){let n=`/**
|
|
32
32
|
* Constants used throughout the ts-pantry package
|
|
33
33
|
* This file is auto-generated from ${t}. Do not edit manually.
|
|
34
34
|
* Generated on ${new Date().toISOString()}
|
|
@@ -91,7 +91,7 @@ ${i.join(`
|
|
|
91
91
|
Conflicts found:`),h.conflicts.forEach((m)=>{console.log(` ${m.package}: ${m.versions.join(", ")}`)});if(console.log(`
|
|
92
92
|
\uD83D\uDCCB All unique packages to install:`),h.uniquePackages.forEach((m,I)=>{let O=h.allDependencies.find((x)=>x.name===m),b=O&&O.version&&O.version!=="latest"?` (${O.version})`:"";console.log(` ${I+1}. ${m}${b}`)}),c)console.log(`
|
|
93
93
|
\uD83D\uDE80 Install command:`),console.log(`pantry install ${h.uniquePackages.join(" ")}`);if(Object.values(h.osSpecificDeps).reduce((m,I)=>m+I.length,0)>0)console.log(`
|
|
94
|
-
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(h.osSpecificDeps).forEach(([m,I])=>{if(I.length>0)console.log(` ${m}: ${I.map((O)=>O.name).join(", ")}`)})}u.exit(0)}catch(s){if(t.json){let n={success:!1,error:String(s),timestamp:new Date().toISOString()};console.log(JSON.stringify(n))}else console.error("Error resolving dependencies:",s);u.exit(1)}});k.command("get-php-versions","Get PHP versions suitable for CI/CD workflows").option("--format <type>","Output format: json (default), yaml, or csv",{default:"json"}).option("--branches <branches>","Comma-separated list of PHP branches to include (e.g., 8.4,8.3,8.2)").option("--fallback <versions>","Comma-separated list of fallback versions if detection fails").action(async(e)=>{try{let{getPhpVersionsForWorkflow:t}=await import("../chunk-
|
|
94
|
+
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(h.osSpecificDeps).forEach(([m,I])=>{if(I.length>0)console.log(` ${m}: ${I.map((O)=>O.name).join(", ")}`)})}u.exit(0)}catch(s){if(t.json){let n={success:!1,error:String(s),timestamp:new Date().toISOString()};console.log(JSON.stringify(n))}else console.error("Error resolving dependencies:",s);u.exit(1)}});k.command("get-php-versions","Get PHP versions suitable for CI/CD workflows").option("--format <type>","Output format: json (default), yaml, or csv",{default:"json"}).option("--branches <branches>","Comma-separated list of PHP branches to include (e.g., 8.4,8.3,8.2)").option("--fallback <versions>","Comma-separated list of fallback versions if detection fails").action(async(e)=>{try{let{getPhpVersionsForWorkflow:t}=await import("../chunk-y1ss7e12.js"),s={};if(e.branches)s.supportedBranches=e.branches.split(",").map((i)=>i.trim());if(e.fallback)s.fallbackVersions=e.fallback.split(",").map((i)=>i.trim());let n=t(s);switch(e.format.toLowerCase()){case"yaml":console.log(`php_versions:
|
|
95
95
|
${n.map((i)=>` - "${i}"`).join(`
|
|
96
96
|
`)}`);break;case"csv":console.log(n.join(","));break;case"json":default:console.log(JSON.stringify(n));break}u.exit(0)}catch(t){console.error("Error getting PHP versions:",t),u.exit(1)}});k.command("generate-zig","Generate Zig package definitions from TypeScript packages").option("--packages-dir <dir>","Directory containing TypeScript package files",{default:"src/packages"}).option("--output <file>","Output Zig file path",{default:"packages.zig"}).option("--aliases","Also generate aliases file").option("--aliases-output <file>","Output file for Zig aliases",{default:"aliases.zig"}).action(async(e)=>{try{let{generateZigDefinitions:t,generateZigAliases:s}=await import("../chunk-42d3p49w.js"),{packagesDir:n="src/packages",output:i="packages.zig",aliases:r=!1,aliasesOutput:a="aliases.zig"}=e;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await t(n,i),r)console.log(`
|
|
97
97
|
\uD83D\uDE80 Generating Zig package aliases...`),await s(n,a);console.log(`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{ib as Ce}from"./chunk-hcjwces4.js";import{ac as pt}from"./chunk-pxh9p9j7.js";import{ic as Q,jc as rr,lc as _e}from"./chunk-vfvcayrz.js";import{Ac as He,Cc as Vt,Ec as jt,Fc as Mt,Gc as Ye,vc as Nt,wc as Tt,zc as Ot}from"./chunk-
|
|
1
|
+
import{ib as Ce}from"./chunk-hcjwces4.js";import{ac as pt}from"./chunk-pxh9p9j7.js";import{ic as Q,jc as rr,lc as _e}from"./chunk-vfvcayrz.js";import{Ac as He,Cc as Vt,Ec as jt,Fc as Mt,Gc as Ye,vc as Nt,wc as Tt,zc as Ot}from"./chunk-en908hmq.js";import{Nc as ds}from"./chunk-ws531zme.js";import{Oc as be,Pc as Er}from"./chunk-s094ynsz.js";import{Tc as K}from"./chunk-ava4pf2j.js";import Tr from"node:process";Er();import Ct from"node:process";function Dt(e){return e in be}function Nr(e){if(!e.includes(".")||e.startsWith(".")||e.endsWith("."))return!1;if(/^v?\d+(?:\.\d+){0,10}$/.test(e))return!1;return/^[a-z0-9][\w.\-/]*$/i.test(e)}function hs(e){return Dt(e)||Nr(e)}function ys(e){return["darwin","linux","windows"].includes(e)}function bs(e){return["x86_64","aarch64","armv7l","i686"].includes(e)}function It(){return Object.keys(be)}function ks(){return Object.values(be)}function xs(e){if(Dt(e))return{originalName:e,resolvedDomain:be[e],isAlias:!0};return{originalName:e,resolvedDomain:e,isAlias:!1}}function Ps(e){let t=e.lastIndexOf("@");if(t===-1)return{name:e};let r=e.slice(0,t),n=e.slice(t+1);return{name:r,version:n,versionSpec:n}}function ws(e,t){return t?`${e}@${t}`:e}function we(){let e=Ct.platform,t=Ct.arch,r,n,s=!0;switch(e){case"darwin":r="darwin";break;case"linux":r="linux";break;case"win32":r="windows";break;default:r="linux",s=!1}switch(t){case"x64":n="x86_64";break;case"arm64":n="aarch64";break;case"arm":n="armv7l";break;case"ia32":n="i686";break;default:n="x86_64",s=!1}return{platform:r,architecture:n,isSupported:s}}function Ss(e,t="latest",r){let n=r||we(),s;switch(n.platform){case"darwin":s="tar.xz";break;case"linux":s="tar.xz";break;case"windows":s="zip";break;default:s="tar.xz"}return{packageName:e,version:t,platform:n.platform,architecture:n.architecture,format:s}}var vs={LATEST:"latest",ANY:"*"},Et={RUNTIME:["nodejs.org","python.org","go.dev","rust-lang.org"],BUILD_TOOLS:["cmake.org","ninja-build.org","gradle.org","maven.apache.org"],DATABASES:["postgresql.org","mysql.com","redis.io","mongodb.com"],EDITORS:["neovim.io","vim.org","code.visualstudio.com"],CLI_TOOLS:["cli.github.com","curl.se","wget.gnu.org","jq.dev"]};function $s(e){return Et[e]}function As(e,t){return Et[t].includes(e)}function Rs(e){return e}function Cs(e,t){return[e,t]}function Ds(e){return e}async function Os(e){try{let t=await He(e);if(!t)return{success:!1,error:`Package '${e}' not found. Use 'search' to find available packages.`};return{success:!0,data:t}}catch(t){return{success:!1,error:`Failed to get package info: ${t}`}}}async function Vs(e){try{if(!e||e.trim().length===0)return{success:!1,error:"Search term cannot be empty"};return{success:!0,data:await Vt(e.trim())}}catch(t){return{success:!1,error:`Search failed: ${t}`}}}async function js(e=20){try{return{success:!0,data:(await jt(e)).slice(0,e)}}catch(t){return{success:!1,error:`Failed to list popular packages: ${t}`}}}async function Ms(e=20){try{return{success:!0,data:await Mt(e)}}catch(t){return{success:!1,error:`Failed to list active packages: ${t}`}}}function Fs(){try{return{success:!0,data:It()}}catch(e){return{success:!1,error:`Failed to list aliases: ${e}`}}}async function _s(e){try{let t=await Ye(e);if(!t.isValid)return{success:!1,error:t.error};return{success:!0,data:{packageName:t.packageName,version:t.version,isValid:!0}}}catch(t){return{success:!1,error:`Validation failed: ${t}`}}}async function Bs(e){try{let t=await Ye(e);if(!t.isValid)return{success:!1,error:t.error};let r=t.packageName,n=t.version||"latest",s=await Ot(r,n);if(!s)return{success:!1,error:`Could not resolve version '${n}' for package '${r}'`};let o=await He(r);if(!o)return{success:!1,error:`Package '${r}' not found`};let a=we(),i={packageName:r,resolvedVersion:s,platform:a.platform,architecture:a.architecture,dependencies:o.dependencies,companions:o.companions,installCommand:`pkgx install ${r}@${s}`},c=[];if(!a.isSupported)c.push(`Platform ${a.platform}/${a.architecture} may not be fully supported`);if(o.dependencies.length>0)c.push(`This package has ${o.dependencies.length} dependencies that will also be installed`);return{success:!0,data:i,warnings:c.length>0?c:void 0}}catch(t){return{success:!1,error:`Failed to create install plan: ${t}`}}}async function Ls(e){try{let t=await Nt(e);if(!t)return{success:!1,error:`Package '${e}' not found`};let r=await Tt(e);return{success:!0,data:{latest:t,total:r.length,versions:r}}}catch(t){return{success:!1,error:`Failed to get version info: ${t}`}}}function zs(e){let t=[`Package: ${e.name}`,`Domain: ${e.domain}`,`Description: ${e.description}`,`Latest Version: ${e.latestVersion}`,`Total Versions: ${e.totalVersions}`];if(e.programs.length>0)t.push(`Programs: ${e.programs.join(", ")}`);if(e.dependencies.length>0)t.push(`Dependencies: ${e.dependencies.join(", ")}`);if(e.companions.length>0)t.push(`Companions: ${e.companions.join(", ")}`);return t.join(`
|
|
2
2
|
`)}function Us(e){if(e.length===0)return"No packages found matching your search.";let t=[`Found ${e.length} package(s):
|
|
3
3
|
`];for(let r of e)t.push(`${r.name} (${r.domain})`),t.push(` ${r.description}`),t.push(` Latest: ${r.latestVersion} (${r.totalVersions} versions available)`),t.push("");return t.join(`
|
|
4
4
|
`)}function Ws(e){let t=[`Installation Plan for ${e.packageName}@${e.resolvedVersion}`,`Platform: ${e.platform}/${e.architecture}`,`Command: ${e.installCommand}`];if(e.dependencies.length>0)t.push(`Dependencies: ${e.dependencies.join(", ")}`);if(e.companions.length>0)t.push(`Companions: ${e.companions.join(", ")}`);return t.join(`
|
|
5
5
|
`)}function qs(){try{let e=we();return{success:!0,data:{platform:e.platform,architecture:e.architecture,isSupported:e.isSupported,nodeVersion:Tr.version}}}catch(e){return{success:!1,error:`Failed to get system info: ${e}`}}}import ae from"node:fs";import ve from"node:path";function $e(e){if(!ae.existsSync(e))throw Error(`Dependency file not found: ${e}`);let t=ae.readFileSync(e,"utf-8"),r=[],n=t.split(`
|
|
6
6
|
`),s=!1,o=!1,a=0;for(let i of n){let c=i.trim();if(!c||c.startsWith("#"))continue;if(i.match(/^(dependencies|deps):\s*$/)){s=!0,o=!1,a=i.search(/\S/);continue}if(i.match(/^global:\s*true\s*$/)||i.match(/^global:\s*$/)&&!s){o=!0;continue}if(i.match(/^\w+:/)&&!i.includes(" ")&&s&&a===0){s=!1;continue}if(s||o){if(i.match(/^\s+(dependencies|deps):\s*$/))continue;let l=i.indexOf(":");if(l>0){let g=i.substring(0,l).trim(),u=i.substring(l+1).trim();if(g&&u){let p=g,m=u.replace(/^['"]|['"]$/g,"");if(p==="global"||p==="dependencies"||p==="deps")continue;let f=m,y=m;if(m.startsWith("^"))f=m.substring(1),y=m;else if(m.startsWith("~"))f=m.substring(1),y=m;else if(m.startsWith(">=")||m.startsWith("<=")||m.startsWith(">")||m.startsWith("<")){let h=/^([><=]+)/.exec(m);if(h){let d=h[1];f=m.substring(d.length).trim(),y=m}}else if(m==="*"||m==="latest")f="latest",y="*";else f=m,y=`@${m}`;r.push({name:p,version:f,constraint:y,isOsSpecific:!1})}}}}return r}function Or(e){if(!ae.existsSync(e))throw Error(`Dependency file not found: ${e}`);let t=ae.readFileSync(e,"utf-8"),r=$e(e),n;try{let s=typeof Bun<"u"&&Bun.YAML?Bun.YAML.parse(t):Vr(t);if(s?.services){let o=Array.isArray(s.services.autoStart)?s.services.autoStart.map((a)=>String(a)):[];if(o.length>0)n={enabled:s.services.enabled===!0,autoStart:o}}}catch{}return{dependencies:r,services:n}}function Vr(e){let t={},r=e.split(`
|
|
7
|
-
`),n=!1,s=!1,o=[],a=!1;for(let i of r){let c=i.trim();if(!c||c.startsWith("#"))continue;if(i.match(/^services:\s*$/)){n=!0,s=!1;continue}if(n&&!i.startsWith(" ")&&!i.startsWith("\t")&&!c.startsWith("-")){if(c!=="services:"){n=!1,s=!1;continue}}if(n){if(c.startsWith("enabled:")){a=c.includes("true");continue}if(c.match(/^autoStart:\s*$/)){s=!0;continue}if(s&&c.startsWith("- ")){let l=c.slice(2).trim();if(l)o.push(l)}}}if(o.length>0)t.services={enabled:a,autoStart:o};return t}async function Ys(e,t="src/packages"){try{let r;if(e.includes("/"))r=ve.join(t,`${e}.ts`);else{let g=`${e.replace(/\./g,"")}.ts`;r=ve.join(t,g)}if(!ae.existsSync(r))return[];let n=ae.readFileSync(r,"utf-8"),s=n.indexOf("versions:");if(s===-1)return[];let o=n.substring(s),a=o.indexOf("["),i=o.indexOf("] as const");if(a===-1||i===-1)return[];let l=o.substring(a+1,i).match(/'([^']+)'/g);if(!l)return[];return l.map((g)=>g.replace(/'/g,""))}catch{return[]}}async function jr(e){try{let{packages:t}=await import("./chunk-vwgjwxzv.js").catch(()=>import("./src/index.js")),r=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),n=t[r];if(!n){let s=Object.values(t);n=s.find((o)=>o.domain===e)||s.find((o)=>Array.isArray(o.aliases)&&o.aliases.includes(e))}if(n&&n.versions&&Array.isArray(n.versions))return n.versions;return[]}catch{return[]}}async function Ft(e,t){let r=await jr(e);if(r.length===0)return t.split("#")[0].trim().replace(/^[@^~>=<]+/,"")||"latest";let n=t.split("#")[0].trim();if(n==="*"||n==="latest")return r[0];if(n.startsWith("@")){let o=n.slice(1);return r.includes(o)?o:r[0]}return Mr(r,n)||r[0]}function Mr(e,t){if(t.startsWith("^")){let r=t.slice(1),[n]=le(r);return e.filter((o)=>{let[a]=le(o);return a===n&&oe(o,r)>=0})[0]||null}if(t.startsWith("~")){let r=t.slice(1),[n,s]=le(r);return e.filter((a)=>{let[i,c]=le(a);return i===n&&c===s&&oe(a,r)>=0})[0]||null}if(t.startsWith(">=")){let r=t.slice(2).trim();return e.filter((s)=>oe(s,r)>=0)[0]||null}if(t.startsWith(">")){let r=t.slice(1).trim();return e.filter((s)=>oe(s,r)>0)[0]||null}if(t.startsWith("<=")){let r=t.slice(2).trim();return e.filter((s)=>oe(s,r)<=0)[0]||null}if(t.startsWith("<")){let r=t.slice(1).trim();return e.filter((s)=>oe(s,r)<0)[0]||null}if(t.startsWith("=")){let r=t.slice(1).trim();return e.includes(r)?r:null}return e.includes(t)?t:null}function le(e){let t=e.split(".").map((r)=>{let n=r.match(/^\d+/);return n?Number.parseInt(n[0],10):0});return[t[0]||0,t[1]||0,t[2]||0]}function oe(e,t){if(e==="latest"&&t!=="latest")return 1;if(t==="latest"&&e!=="latest")return-1;if(e==="latest"&&t==="latest")return 0;let r=e.split("#")[0].trim(),n=t.split("#")[0].trim(),[s,o,a]=le(r),[i,c,l]=le(n);if(s>i)return 1;if(s<i)return-1;if(o>c)return 1;if(o<c)return-1;if(a>l)return 1;if(a<l)return-1;return 0}var Se=null;async function Fr(){if(Se)return Se;return Se=(await import("./chunk-vwgjwxzv.js").catch(()=>import("./src/index.js"))).packages,Se}async function _r(e){try{let t=await Fr(),r=t[e];if(r)return{dependencies:r.dependencies||[],companions:r.companions||[]};let n=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),s=t[n];if(s)return{dependencies:s.dependencies||[],companions:s.companions||[]};let a=Object.values(t).find((i)=>i.domain===e);if(a)return{dependencies:a.dependencies||[],companions:a.companions||[]};return null}catch(t){return console.warn(`Failed to load package data for ${e}: ${t}`),null}}async function Ae(e,t={},r=new Set,n=0){let{maxDepth:s=10,verbose:o=!1,targetOs:a,includeOsSpecific:i=!0}=t;if(n>s){if(o)console.warn(` Warning: max dependency depth (${s}) exceeded for ${e}`);return[]}if(r.has(e))return[];if(r.add(e),o)console.log(`${" ".repeat(n)}Resolving dependencies for: ${e}`);let c=[];try{let g=function(f){let y=f.match(/^(linux|darwin|windows):(.+)$/),h=!!y,d=y?y[2]:f,b=y?y[1]:void 0;if(h&&(!i||a&&b!==a))return null;let x=d,P="latest",k="*",w=d.match(/^(@?[^@^~>=<]+(?:\/[^@^~>=<]+)?)([@^~>=<].+)?$/);if(w){if(x=w[1],w[2]){let v=w[2];if(v.startsWith("@"))P=v.substring(1),k=v;else k=v,P=v.replace(/^\D*/,"")}}return{dep:{name:x,version:P,constraint:k,isOsSpecific:h,os:b},pkgName:x}},l=await _r(e),p=[...l?.dependencies||[],...l?.companions||[]].map(g).filter((f)=>f!==null);for(let{dep:f}of p)c.push(f);let m=await Promise.allSettled(p.map(({pkgName:f})=>Ae(f,t,r,n+1)));for(let f of m)if(f.status==="fulfilled")c.push(...f.value);else if(o)console.warn(` Warning: transitive dependency resolution failed: ${f.reason}`)}catch(l){if(o)console.warn(`${" ".repeat(n)}Warning: Could not resolve dependencies for ${e}: ${l}`)}return c}async function Je(e,t={}){let r=new Map,n=[],s={linux:[],darwin:[],windows:[]};for(let i of e){if(!r.has(i.name))r.set(i.name,[]);if(r.get(i.name).push(i),i.isOsSpecific&&i.os)s[i.os].push(i)}let o=[],a=[];for(let[i,c]of r)if(c.length===1){let l=await Ft(i,c[0].constraint),g={...c[0],version:l};o.push(g),a.push(i)}else{let l=c.map((f)=>f.version),g=[...new Set(l)];if(g.length>1)n.push({package:i,versions:g});let u=await Promise.all(c.map(async(f)=>({...f,resolvedVersion:await Ft(i,f.constraint)}))),p=u[0];for(let f of u.slice(1))if(p.constraint==="*"&&f.constraint!=="*")p=f;else if(p.constraint!=="*"&&f.constraint==="*");else if(oe(f.resolvedVersion,p.resolvedVersion)>0)p=f;let m={...p,version:p.resolvedVersion};delete m.resolvedVersion,o.push(m),a.push(i)}return{allDependencies:o,uniquePackages:a,conflicts:n,osSpecificDeps:s}}async function _t(e,t={}){let{verbose:r=!1}=t;if(r)console.log(`Parsing dependency file: ${e}`);let n=$e(e);if(r)console.log(`Found ${n.length} direct dependencies`);let s=[...n],o=await Promise.all(n.map(async(c)=>{if(r)console.log(`Resolving transitive dependencies for: ${c.name}`);return Ae(c.name,t)}));for(let c of o)s.push(...c);if(r)console.log(`Total dependencies found (before deduplication): ${s.length}`);let a=await Je(s,t);if(r){if(console.log(`Unique packages after deduplication: ${a.uniquePackages.length}`),a.conflicts.length>0)console.log(`Version conflicts found: ${a.conflicts.length}`)}let i=ve.extname(e);if(i===".yaml"||i===".yml"){let c=Or(e);if(c.services)a.services=c.services}return a}function Js(e){let t=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"],r=[];for(let n of t){let s=ve.join(e,n);if(ae.existsSync(s))r.push(s)}return r}import*as A from"node:fs";import*as T from"node:path";import*as X from"node:os";import*as tt from"node:https";import*as rt from"node:http";import{execFileSync as Re}from"node:child_process";import{createHash as Br}from"node:crypto";import{Transform as Lr}from"node:stream";import{pipeline as zr}from"node:stream/promises";function Ee(){return(process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev").replace(/\/$/,"")}function Ur(e,t){if(e!=="ziglang.org")return t;return t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")}function Ne(){let e=process.env.XDG_DATA_HOME,t=e&&e.length>0?e:T.join(X.homedir(),".local","share");return T.join(t,"pantry","global","bin")}function ke(){let e=X.platform(),t=X.arch();return{os:e==="darwin"?"darwin":e==="win32"?"windows":"linux",arch:t==="arm64"?"aarch64":"x86_64"}}function Ze(e,t){let r=e.replace(/(-dev\.\d+)_([0-9A-Za-z-]+)$/,"$1+$2"),n=t.os==="darwin"?"macos":t.os,s=t.arch==="aarch64"?"aarch64":"x86_64",o=t.os==="windows"?"zip":"tar.xz",a=`zig-${s}-${n}-${r}`,i=`${a}.${o}`;return{url:r.includes("-dev.")?`https://ziglang.org/builds/${i}`:`https://ziglang.org/download/${r}/${i}`,format:o,prefix:a}}function Wr(e,t){let[r,n,s]=e.split(".").map(Number);if(r!==3||!Number.isInteger(n)||!Number.isInteger(s))throw Error(`Unsupported SQLite version: ${e}`);let o=n>=52?2026:n>=48?2025:2024,i={"darwin-aarch64":"osx-arm64","darwin-x86_64":"osx-x64","linux-x86_64":"linux-x64","windows-aarch64":"win-arm64","windows-x86_64":"win-x64"}[`${t.os}-${t.arch}`];if(!i)throw Error(`Unsupported platform for SQLite tools: ${t.os}-${t.arch}`);let c=`${r}${n}${String(s).padStart(2,"0")}00`;return`https://sqlite.org/${o}/sqlite-tools-${i}-${c}.zip`}function Ut(e){return e==="bun.sh"||e==="bun.com"}var pe={"github.com/mail-os/mail":{getDownloadUrl(e,t){if(t.os!=="linux"||t.arch!=="x86_64")throw Error("github.com/mail-os/mail currently publishes linux-x86_64 release binaries");let r={darwin:"macos",linux:"linux",windows:"windows"},n=`mail-${t.arch}-${r[t.os]}`;return`https://github.com/mail-os/mail/releases/download/v${e}/${n}.tar.gz`},getArchiveFormat(){return"tar.gz"},getBinaries(e){let t={darwin:"macos",linux:"linux",windows:"windows"};return[`mail-${e.arch}-${t[e.os]}`,"mail"]}},"ziglang.org":{getDownloadUrl(e,t){return Ze(e,t).url},getArchiveFormat(e){return Ze("0.0.0",e).format},getBinaries(e){return e.os==="windows"?["zig.exe"]:["zig"]},getArchivePrefix(e,t){return Ze(e,t).prefix}},"bun.sh":{getDownloadUrl(e,t){let r={"darwin-aarch64":"darwin-aarch64","darwin-x86_64":"darwin-x64","linux-aarch64":"linux-aarch64","linux-x86_64":"linux-x64","windows-x86_64":"windows-x64"},n=`${t.os}-${t.arch}`,s=r[n]||"linux-x64";return`https://github.com/oven-sh/bun/releases/download/bun-v${e}/bun-${s}.zip`},getArchiveFormat(){return"zip"},getBinaries(e){return e.os==="windows"?["bun.exe"]:["bun","bunx"]},getArchivePrefix(e,t){let r={"darwin-aarch64":"bun-darwin-aarch64","darwin-x86_64":"bun-darwin-x64","linux-aarch64":"bun-linux-aarch64","linux-x86_64":"bun-linux-x64","windows-x86_64":"bun-windows-x64"},n=`${t.os}-${t.arch}`,s=r[n];if(!s)throw Error(`Unsupported platform for bun: ${n}`);return s}},"sqlite.org":{getDownloadUrl(e,t){return Wr(e,t)},getArchiveFormat(){return"zip"},getBinaries(e){let t=e.os==="windows"?".exe":"";return[`sqlite3${t}`,`sqldiff${t}`,`sqlite3_analyzer${t}`,`sqlite3_rsync${t}`]}},"nodejs.org":{getDownloadUrl(e,t){let r={darwin:"darwin",linux:"linux",windows:"win"},n={x86_64:"x64",aarch64:"arm64"},s=t.os==="windows"?"zip":"tar.xz";return`https://nodejs.org/dist/v${e}/node-v${e}-${r[t.os]}-${n[t.arch]}.${s}`},getArchiveFormat(e){return e.os==="windows"?"zip":"tar.xz"},getBinaries(e){return e.os==="windows"?["node.exe","npm.cmd","npx.cmd"]:["node","npm","npx"]},getArchivePrefix(e,t){let r={darwin:"darwin",linux:"linux",windows:"win"},n={x86_64:"x64",aarch64:"arm64"};return`node-v${e}-${r[t.os]}-${n[t.arch]}`}}};function Bt(e,t,r,n){A.mkdirSync(r,{recursive:!0});let s=null;for(let o of t){let a=T.join(e,o);if(!A.existsSync(a))a=T.join(e,"bin",o);if(!A.existsSync(a)){if(s){let c=T.join(r,o);try{A.unlinkSync(c)}catch{}if(n.os==="windows")A.copyFileSync(s,c);else A.symlinkSync(s,c)}continue}if(!s)s=a;let i=T.join(r,o);try{A.unlinkSync(i)}catch{}if(n.os==="windows")A.copyFileSync(a,i);else A.symlinkSync(a,i)}}async function Wt(e,t,r={}){let n=r.platform||ke(),s=pe[e];if(/^[\^~>=<]/.test(t))t=await en(e,t,n);else if(t==="latest"||t==="*"||!t)t=await nt(e,n);else if(e==="ziglang.org"&&t.endsWith("-dev")){let b=await Gr(t,n,{onRetry:r.onRetry});if(!b)throw Error(`Could not resolve ${t} to a published ziglang.org development build`);t=b}if(t=Ur(e,t),!t)throw Error(`Could not resolve a concrete version for ${e} (got empty string from resolver)`);let o=r.installDir||T.join(process.cwd(),"pantry"),a=T.join(o,".bin"),i=T.join(o,e.replace(/\./g,"-"),t),c=s?.getBinaries(n);if(s&&(!c||c.length===0))throw Error(`No binaries defined for ${e} on ${n.os}-${n.arch}`);if(c?A.existsSync(T.join(i,c[0]))||A.existsSync(T.join(i,"bin",c[0])):Qe(i).length>0){let b=c??Qe(i);if(!r.quiet)console.log(` ✓ ${e}@${t} (cached)`);if(r.createBinLinks!==!1)Bt(i,b,a,n);let x=Lt(i,b,n,r);return{name:e,version:t,installPath:i,binaries:b,globalLinks:x}}let u=!s||e==="ziglang.org"&&t.includes("-dev.")?await qt(e,{onRetry:r.onRetry}):null,p=s?e==="ziglang.org"&&t.includes("-dev.")?Yr(u,t,n):null:Hr(u,t,n);if(!s&&!p)throw Error(`Cannot install ${e}@${t}: no built-in resolver, and the registry publishes no ${ge(n)} artifact for that version.`);let m=p?.url??s.getDownloadUrl(t,n),f=p?.format??s.getArchiveFormat(n),y=p?.sha256;if(!r.quiet)console.log(` → ${e}@${t} from ${new URL(m).hostname}`);let h=A.mkdtempSync(T.join(X.tmpdir(),"pantry-")),d=T.join(h,`archive.${f}`);try{let b=y;if(!b&&m.startsWith(`${Ee()}/binaries/`)){let S=T.join(h,"archive.sha256");await zt(`${m}.sha256`,S,{quiet:r.quiet,onRetry:r.onRetry});let C=A.readFileSync(S,"utf8").match(/\b([a-f0-9]{64})\b/i)?.[1];if(!C)throw Error(`Invalid SHA-256 checksum response for ${m}`);b=C.toLowerCase()}await zt(m,d,{quiet:r.quiet,onRetry:r.onRetry,expectedSha256:b});let x=T.join(h,"extracted");A.mkdirSync(x,{recursive:!0}),await an(d,x,f);let P=x,k=p?p.prefix:s.getArchivePrefix?.(t,n);if(k){let S=T.join(x,k);if(A.existsSync(S))P=S;else{let D=A.readdirSync(x).find((E)=>A.statSync(T.join(x,E)).isDirectory());if(D)P=T.join(x,D)}}A.mkdirSync(i,{recursive:!0}),cn(P,i);let w=c??Qe(i);if(w.length===0)throw Error(`${e}@${t} unpacked with no executables in bin/`);if(n.os!=="windows"){for(let S of w){let C=T.join(i,S);if(A.existsSync(C))A.chmodSync(C,493);let D=T.join(i,"bin",S);if(A.existsSync(D))A.chmodSync(D,493)}for(let S of["bin","sbin","libexec"])Jt(T.join(i,S))}if(r.createBinLinks!==!1)Bt(i,w,a,n);if(!r.quiet)console.log(` ✓ ${e}@${t}`);let v=Lt(i,w,n,r);return{name:e,version:t,installPath:i,binaries:w,globalLinks:v}}finally{try{A.rmSync(h,{recursive:!0,force:!0})}catch{}}}function Lt(e,t,r,n){if(!n.globalBin)return[];let s=typeof n.globalBin==="string"?n.globalBin:Ne();A.mkdirSync(s,{recursive:!0});let o=[];for(let a of t){let i=T.join(e,a);if(!A.existsSync(i))i=T.join(e,"bin",a);if(!A.existsSync(i))continue;let c=T.join(s,a);try{A.unlinkSync(c)}catch{}if(r.os==="windows")A.copyFileSync(i,c);else A.symlinkSync(i,c);o.push(c)}if(!n.quiet&&o.length>0)console.log(` → linked ${o.length} binary(ies) into ${s}`);return o}async function qr(e,t={}){return Promise.all(e.map((r)=>Wt(r.domain,r.version,t)))}async function nt(e,t=ke()){if(Ut(e)){let s=(await Y("https://api.github.com/repos/oven-sh/bun/releases/latest").catch(()=>null))?.tag_name?.replace(/^bun-v/,"")||"";if(s)return s;let o=await Xe(e);if(o)return o;throw Error("Failed to resolve latest bun.sh version (GitHub API unreachable, no bundled metadata)")}if(e==="ziglang.org"){let n=await ue(e,t);if(n.length>0)return n.sort(Ce)[0];throw Error(`Failed to resolve a ziglang.org version published for ${ge(t)}`)}if(e==="nodejs.org"){let s=await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[],a=(s.find((c)=>c.lts)?.version||s[0]?.version||"").replace(/^v/,"");if(a)return a;let i=await Xe(e);if(i)return i;throw Error("Failed to resolve latest nodejs.org version")}if(e==="github.com/mail-os/mail"){let s=(await Y("https://api.github.com/repos/mail-os/mail/releases/latest").catch(()=>null))?.tag_name?.replace(/^v/,"")||"";if(s)return s;let a=((await Y("https://api.github.com/repos/mail-os/mail/tags?per_page=1").catch(()=>null))?.[0]?.name||"").replace(/^v/,"");if(a)return a;let i=await Xe(e);if(i)return i;throw Error("Failed to resolve latest github.com/mail-os/mail version")}let r=await ue(e,t);if(r.length>0)return r.sort(Ce)[0];throw Error(`Cannot resolve latest version for ${e} (no built-in resolver, and the registry publishes nothing for ${ge(t)})`)}async function Xe(e){try{let t=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:r}=await import("./chunk-vwgjwxzv.js").catch(()=>import("./src/index.js")),s=r[t]?.versions||[];return s.find((o)=>!o.includes("-"))||s[0]||""}catch{return""}}async function Gr(e,t,r={}){let s=(await ue("ziglang.org",t,r)).filter((i)=>i.startsWith(`${e}.`)).sort(Ce)[0];if(s)return s;let a=(await Y("https://ziglang.org/download/index.json",3,r).catch(()=>null))?.master?.version||"";return a.startsWith(`${e}.`)?a:null}function ge(e){let t=e.arch==="aarch64"?"arm64":"x86-64";return`${e.os}-${t}`}function Kr(e,t){let r=ge(t);return Object.entries(e?.versions||{}).filter(([,n])=>Object.hasOwn(n.platforms||{},r)).map(([n])=>n)}async function qt(e,t={}){return await Y(`${Ee()}/binaries/${encodeURI(e)}/metadata.json`,5,t).catch(()=>null)}async function ue(e,t,r={}){return Kr(await qt(e,r),t)}function Hr(e,t,r){let n=e?.versions?.[t]?.platforms?.[ge(r)];if(!n?.tarball)return null;return{url:`${Ee()}/${n.tarball.replace(/^\/+/,"")}`,format:"tar.gz",prefix:"",sha256:n.sha256?.toLowerCase()}}function Qe(e){try{return A.readdirSync(T.join(e,"bin")).filter((t)=>!t.startsWith(".")).sort()}catch{return[]}}function Yr(e,t,r){if(!t.includes("-dev.")||!e)return null;let n=ge(r),o=[t.replace(/(-dev\.\d+)_([0-9A-Za-z-]+)$/,"$1+$2"),t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")].find((i)=>Object.hasOwn(e.versions?.[i]?.platforms||{},n));if(!o)return null;let a=encodeURIComponent(o).replace(/%2B/gi,"+");return{url:`${Ee()}/binaries/ziglang.org/${a}/${n}/ziglang.org-${a}.tar.gz`,format:"tar.gz",prefix:""}}function Gt(e){let t=e.match(/^([~^]|>=|<=|>|<|=)(\d+(?:\.\d+){0,10}(?:-[0-9A-Za-z.-]+)?(?:[+_][0-9A-Za-z.-]+)?)/);if(!t)return null;return{operator:t[1],target:t[2]}}function De(e){return e.split(/[+_-]/,1)[0].split(".").map((t)=>Number.parseInt(t,10))}function Kt(e,t){let r=De(e),n=De(t);for(let c=0;c<Math.max(r.length,n.length,3);c++){let l=(r[c]||0)-(n[c]||0);if(l)return l}let s=e.includes("-"),o=t.includes("-");if(s!==o)return s?-1:1;let a=Number.parseInt(e.match(/-dev\.(\d+)/)?.[1]||"0",10),i=Number.parseInt(t.match(/-dev\.(\d+)/)?.[1]||"0",10);return a-i}function Jr(e,t){let{operator:r,target:n}=t;if(e.includes("-")&&!n.includes("-"))return!1;let s=De(e),o=De(n);if(s.some(Number.isNaN)||o.some(Number.isNaN))return!1;let[a,i,c]=[s[0]||0,s[1]||0,s[2]||0],[l,g,u]=[o[0]||0,o[1]||0,o[2]||0],p=Kt(e,n);if(r==="^"){if(p<0)return!1;if(l===0&&g===0)return a===0&&i===0&&c===u;if(l===0)return a===0&&i===g;return a===l}if(r==="~"){if(p<0)return!1;return o.length===1?a===l:a===l&&i===g}if(r===">=")return p>=0;if(r==="<=")return p<=0;if(r===">")return p>0;if(r==="<")return p<0;if(r==="=")return p===0;return!1}async function Zr(e,t){if(Ut(e))return(await Y("https://api.github.com/repos/oven-sh/bun/releases?per_page=100").catch(()=>null)||[]).map((s)=>(s.tag_name||"").replace(/^bun-v/,"")).filter(Boolean);if(e==="nodejs.org")return(await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[]).map((s)=>(s.version||"").replace(/^v/,"")).filter(Boolean);if(e==="ziglang.org"){let r=await Y("https://ziglang.org/download/index.json").catch(()=>null),n=Xr(r,t);if(n.length>0)return n;return await ue(e,t)}return await ue(e,t)}function Xr(e,t){let r=`${t.arch}-${t.os==="darwin"?"macos":t.os}`;return Object.entries(e||{}).filter(([,n])=>Boolean(n[r])).map(([n,s])=>s.version||n).filter(Boolean)}function et(e,t){return Kt(t,e)}function Qr(e,t){let r=Gt(e);if(!r)return null;return[...new Set(t)].sort(et).find((n)=>Jr(n,r))||null}async function en(e,t,r){if(!Gt(t))return nt(e,r);let n;try{let i=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:c}=await import("./chunk-vwgjwxzv.js").catch(()=>import("./src/index.js"));n=c[i]?.versions||[]}catch{n=[]}let s=await Zr(e,r),o=e==="ziglang.org"?s.sort(et):[...new Set([...s,...n])].sort(et),a=Qr(t,o);if(a)return a;throw Error(`No version of ${e} satisfies "${t}" (checked ${o.length} version${o.length===1?"":"s"}${o.length>0?`, newest ${o[0]}`:""}).`)}var tn=4;function Ie(e){return e instanceof Error?e.message:String(e)}function rn(e){if(typeof e==="object"&&e!==null&&"statusCode"in e){let r=Number(e.statusCode);if(Number.isFinite(r))return r}let t=Ie(e).match(/\bHTTP\s+(\d{3})\b/i);return t?Number(t[1]):void 0}function nn(e){if(typeof e!=="object"||e===null)return"";let t="code"in e?String(e.code||""):"";if(t)return t;let r="cause"in e?e.cause:void 0;return typeof r==="object"&&r!==null&&"code"in r?String(r.code||""):""}function sn(e){let t=rn(e);if(t!==void 0)return t===408||t===425||t===429||t>=500;if(/^(?:ECONNRESET|ECONNREFUSED|EPIPE|ETIMEDOUT|EAI_AGAIN|ENETDOWN|ENETUNREACH|EHOSTUNREACH|UND_ERR_SOCKET)$/i.test(nn(e)))return!0;return/socket hang up|connection reset|premature close|aborted|terminated|timed? ?out|temporar|stalled|incomplete download|checksum mismatch/i.test(Ie(e))}async function Ht(e,t,r={}){let n=r.maxAttempts??tn,s=r.retryDelayMs??1000,o=r.sleep??((i)=>new Promise((c)=>setTimeout(c,i))),a;for(let i=1;i<=n;i+=1)try{return await t()}catch(c){if(a=c,!sn(c))throw c;if(i===n)break;let l=Math.min(s*2**(i-1),1e4);r.onRetry?.(`${e} failed (${Ie(c)}); retrying in ${l}ms`),await o(l)}throw Error(`${e} failed after ${n} attempts: ${Ie(a)}`)}function Yt(e,t,r){return new Promise((n,s)=>{let a=(e.startsWith("https")?tt.get:rt.get)(e,{headers:{"User-Agent":"pantry-installer"}},(i)=>{if(i.statusCode&&i.statusCode>=300&&i.statusCode<400&&i.headers.location){if(i.resume(),t<=0)return s(Error(`Too many redirects for ${e}`));let c=new URL(i.headers.location,e).href;return Yt(c,t-1,r).then(n,s)}if(!i.statusCode||i.statusCode<200||i.statusCode>=300){i.resume();let c=Object.assign(Error(`HTTP ${i.statusCode||"unknown"} downloading ${e}`),{statusCode:i.statusCode});return s(c)}i.setTimeout(r,()=>{i.destroy(Error(`Download stalled (no data for ${r/1000}s): ${e}`))}),n(i)});a.setTimeout(r,()=>{a.destroy(Error(`Download timed out after ${r/1000}s: ${e}`))}),a.once("error",s)})}async function on(e,t,r){let n=`${t}.part`;try{A.rmSync(n,{force:!0})}catch{}let s=await Yt(e,10,r.stallTimeoutMs??60000),o=!r.quiet&&process.stderr.isTTY,a=Number.parseInt(String(s.headers["content-length"]||""),10),i=Number.isFinite(a)?a:0,c=0,l=0,g=r.expectedSha256?Br("sha256"):void 0,u=new Lr({transform(p,m,f){c+=p.length,g?.update(p);let y=Date.now();if(o&&y-l>200){l=y;let h=(c/1048576).toFixed(1);if(i>0){let d=(i/1048576).toFixed(1),b=Math.floor(c/i*100);process.stderr.write(`\r ${h}/${d} MB (${b}%)`)}else process.stderr.write(`\r ${h} MB`)}f(null,p)}});try{if(await zr(s,u,A.createWriteStream(n)),!s.complete||i>0&&c!==i)throw Error(`Incomplete download for ${e}: received ${c} of ${i||"unknown"} bytes`);if(r.expectedSha256){let p=g.digest("hex");if(p!==r.expectedSha256.toLowerCase())throw Error(`Checksum mismatch for ${e}: expected ${r.expectedSha256}, got ${p}`)}A.renameSync(n,t)}catch(p){try{A.rmSync(n,{force:!0})}catch{}throw p}finally{if(o&&l>0)process.stderr.write("\r\x1B[K")}}async function zt(e,t,r={}){await Ht(`Download ${e}`,()=>on(e,t,r),r)}async function an(e,t,r){if(r==="zip")if(process.platform==="win32")Re("powershell",["-NoProfile","-Command","Expand-Archive","-Path",e,"-DestinationPath",t,"-Force"],{stdio:"pipe"});else Re("unzip",["-o","-q",e,"-d",t],{stdio:"pipe"});else if(r==="tar.xz")Re("tar",["xJf",e,"-C",t],{stdio:"pipe"});else if(r==="tar.gz")Re("tar",["xzf",e,"-C",t],{stdio:"pipe"});else throw Error(`Unsupported archive format: ${r}`)}function cn(e,t){A.cpSync(e,t,{recursive:!0})}function Jt(e){let t;try{t=A.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of t){let n=T.join(e,r.name);try{if(r.isDirectory()){Jt(n);continue}if(!r.isFile())continue;let s=A.statSync(n).mode&511,o=s|(s&292)>>2;if(o!==s)A.chmodSync(n,o)}catch{}}}function Zt(e,t){return new Promise((r,n)=>{let s=e.startsWith("https")?tt.get:rt.get,o={"User-Agent":"pantry-installer",Accept:"application/json"};if(e.includes("api.github.com")){let i=process.env.GITHUB_TOKEN||process.env.GH_TOKEN;if(i)o.Authorization=`Bearer ${i}`}let a=s(e,{headers:o,timeout:30000},(i)=>{if(i.statusCode&&i.statusCode>=300&&i.statusCode<400&&i.headers.location){if(t<=0)return n(Error(`Too many redirects for ${e}`));let l=new URL(i.headers.location,e).href;return Zt(l,t-1).then(r,n)}if(!i.statusCode||i.statusCode<200||i.statusCode>=300)return n(Object.assign(Error(`HTTP ${i.statusCode||"unknown"} fetching ${e}`),{statusCode:i.statusCode}));let c="";i.on("data",(l)=>c+=l),i.on("end",()=>{try{r(JSON.parse(c))}catch(l){n(l)}})});a.on("error",n),a.on("timeout",()=>{a.destroy(),n(Error(`Request timed out: ${e}`))})})}function Y(e,t=5,r={}){return Ht(`Fetch ${e}`,()=>Zt(e,t),r)}pe["bun.com"]=pe["bun.sh"];function Xt(e){return e in pe}async function ln(e,t=ke()){if(Xt(e))return!0;return(await ue(e,t)).length>0}function ni(){return Object.keys(pe)}function si(e){let t=pe[e];if(!t)return;let r=ke();return t.getBinaries(r)[0]}import*as L from"node:fs";import*as Ve from"node:os";import*as ce from"node:path";var Te="# >>> pantry shell-init >>>",Oe="# <<< pantry shell-init <<<";function je(){let e=process.env.SHELL??"";if(e.endsWith("/zsh")||e==="zsh")return"zsh";if(e.endsWith("/bash")||e==="bash")return"bash";if(e.endsWith("/fish")||e==="fish")return"fish";return"unknown"}function st(e){let t=Ve.homedir();switch(e){case"zsh":{let r=process.env.ZDOTDIR;return ce.join(r&&r.length>0?r:t,".zshrc")}case"bash":{if(Ve.platform()==="darwin"){let r=ce.join(t,".bash_profile");if(L.existsSync(r))return r}return ce.join(t,".bashrc")}case"fish":return ce.join(t,".config","fish","config.fish");case"unknown":return null}}function Qt(e={}){let t=e.globalBin??Ne();if((e.shell??je())==="fish")return[Te,`if test -d "${t}"`,` set -gx PATH "${t}" $PATH`,"end",Oe,""].join(`
|
|
7
|
+
`),n=!1,s=!1,o=[],a=!1;for(let i of r){let c=i.trim();if(!c||c.startsWith("#"))continue;if(i.match(/^services:\s*$/)){n=!0,s=!1;continue}if(n&&!i.startsWith(" ")&&!i.startsWith("\t")&&!c.startsWith("-")){if(c!=="services:"){n=!1,s=!1;continue}}if(n){if(c.startsWith("enabled:")){a=c.includes("true");continue}if(c.match(/^autoStart:\s*$/)){s=!0;continue}if(s&&c.startsWith("- ")){let l=c.slice(2).trim();if(l)o.push(l)}}}if(o.length>0)t.services={enabled:a,autoStart:o};return t}async function Ys(e,t="src/packages"){try{let r;if(e.includes("/"))r=ve.join(t,`${e}.ts`);else{let g=`${e.replace(/\./g,"")}.ts`;r=ve.join(t,g)}if(!ae.existsSync(r))return[];let n=ae.readFileSync(r,"utf-8"),s=n.indexOf("versions:");if(s===-1)return[];let o=n.substring(s),a=o.indexOf("["),i=o.indexOf("] as const");if(a===-1||i===-1)return[];let l=o.substring(a+1,i).match(/'([^']+)'/g);if(!l)return[];return l.map((g)=>g.replace(/'/g,""))}catch{return[]}}async function jr(e){try{let{packages:t}=await import("./chunk-ggxaeaat.js").catch(()=>import("./src/index.js")),r=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),n=t[r];if(!n){let s=Object.values(t);n=s.find((o)=>o.domain===e)||s.find((o)=>Array.isArray(o.aliases)&&o.aliases.includes(e))}if(n&&n.versions&&Array.isArray(n.versions))return n.versions;return[]}catch{return[]}}async function Ft(e,t){let r=await jr(e);if(r.length===0)return t.split("#")[0].trim().replace(/^[@^~>=<]+/,"")||"latest";let n=t.split("#")[0].trim();if(n==="*"||n==="latest")return r[0];if(n.startsWith("@")){let o=n.slice(1);return r.includes(o)?o:r[0]}return Mr(r,n)||r[0]}function Mr(e,t){if(t.startsWith("^")){let r=t.slice(1),[n]=le(r);return e.filter((o)=>{let[a]=le(o);return a===n&&oe(o,r)>=0})[0]||null}if(t.startsWith("~")){let r=t.slice(1),[n,s]=le(r);return e.filter((a)=>{let[i,c]=le(a);return i===n&&c===s&&oe(a,r)>=0})[0]||null}if(t.startsWith(">=")){let r=t.slice(2).trim();return e.filter((s)=>oe(s,r)>=0)[0]||null}if(t.startsWith(">")){let r=t.slice(1).trim();return e.filter((s)=>oe(s,r)>0)[0]||null}if(t.startsWith("<=")){let r=t.slice(2).trim();return e.filter((s)=>oe(s,r)<=0)[0]||null}if(t.startsWith("<")){let r=t.slice(1).trim();return e.filter((s)=>oe(s,r)<0)[0]||null}if(t.startsWith("=")){let r=t.slice(1).trim();return e.includes(r)?r:null}return e.includes(t)?t:null}function le(e){let t=e.split(".").map((r)=>{let n=r.match(/^\d+/);return n?Number.parseInt(n[0],10):0});return[t[0]||0,t[1]||0,t[2]||0]}function oe(e,t){if(e==="latest"&&t!=="latest")return 1;if(t==="latest"&&e!=="latest")return-1;if(e==="latest"&&t==="latest")return 0;let r=e.split("#")[0].trim(),n=t.split("#")[0].trim(),[s,o,a]=le(r),[i,c,l]=le(n);if(s>i)return 1;if(s<i)return-1;if(o>c)return 1;if(o<c)return-1;if(a>l)return 1;if(a<l)return-1;return 0}var Se=null;async function Fr(){if(Se)return Se;return Se=(await import("./chunk-ggxaeaat.js").catch(()=>import("./src/index.js"))).packages,Se}async function _r(e){try{let t=await Fr(),r=t[e];if(r)return{dependencies:r.dependencies||[],companions:r.companions||[]};let n=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),s=t[n];if(s)return{dependencies:s.dependencies||[],companions:s.companions||[]};let a=Object.values(t).find((i)=>i.domain===e);if(a)return{dependencies:a.dependencies||[],companions:a.companions||[]};return null}catch(t){return console.warn(`Failed to load package data for ${e}: ${t}`),null}}async function Ae(e,t={},r=new Set,n=0){let{maxDepth:s=10,verbose:o=!1,targetOs:a,includeOsSpecific:i=!0}=t;if(n>s){if(o)console.warn(` Warning: max dependency depth (${s}) exceeded for ${e}`);return[]}if(r.has(e))return[];if(r.add(e),o)console.log(`${" ".repeat(n)}Resolving dependencies for: ${e}`);let c=[];try{let g=function(f){let y=f.match(/^(linux|darwin|windows):(.+)$/),h=!!y,d=y?y[2]:f,b=y?y[1]:void 0;if(h&&(!i||a&&b!==a))return null;let x=d,P="latest",k="*",w=d.match(/^(@?[^@^~>=<]+(?:\/[^@^~>=<]+)?)([@^~>=<].+)?$/);if(w){if(x=w[1],w[2]){let v=w[2];if(v.startsWith("@"))P=v.substring(1),k=v;else k=v,P=v.replace(/^\D*/,"")}}return{dep:{name:x,version:P,constraint:k,isOsSpecific:h,os:b},pkgName:x}},l=await _r(e),p=[...l?.dependencies||[],...l?.companions||[]].map(g).filter((f)=>f!==null);for(let{dep:f}of p)c.push(f);let m=await Promise.allSettled(p.map(({pkgName:f})=>Ae(f,t,r,n+1)));for(let f of m)if(f.status==="fulfilled")c.push(...f.value);else if(o)console.warn(` Warning: transitive dependency resolution failed: ${f.reason}`)}catch(l){if(o)console.warn(`${" ".repeat(n)}Warning: Could not resolve dependencies for ${e}: ${l}`)}return c}async function Je(e,t={}){let r=new Map,n=[],s={linux:[],darwin:[],windows:[]};for(let i of e){if(!r.has(i.name))r.set(i.name,[]);if(r.get(i.name).push(i),i.isOsSpecific&&i.os)s[i.os].push(i)}let o=[],a=[];for(let[i,c]of r)if(c.length===1){let l=await Ft(i,c[0].constraint),g={...c[0],version:l};o.push(g),a.push(i)}else{let l=c.map((f)=>f.version),g=[...new Set(l)];if(g.length>1)n.push({package:i,versions:g});let u=await Promise.all(c.map(async(f)=>({...f,resolvedVersion:await Ft(i,f.constraint)}))),p=u[0];for(let f of u.slice(1))if(p.constraint==="*"&&f.constraint!=="*")p=f;else if(p.constraint!=="*"&&f.constraint==="*");else if(oe(f.resolvedVersion,p.resolvedVersion)>0)p=f;let m={...p,version:p.resolvedVersion};delete m.resolvedVersion,o.push(m),a.push(i)}return{allDependencies:o,uniquePackages:a,conflicts:n,osSpecificDeps:s}}async function _t(e,t={}){let{verbose:r=!1}=t;if(r)console.log(`Parsing dependency file: ${e}`);let n=$e(e);if(r)console.log(`Found ${n.length} direct dependencies`);let s=[...n],o=await Promise.all(n.map(async(c)=>{if(r)console.log(`Resolving transitive dependencies for: ${c.name}`);return Ae(c.name,t)}));for(let c of o)s.push(...c);if(r)console.log(`Total dependencies found (before deduplication): ${s.length}`);let a=await Je(s,t);if(r){if(console.log(`Unique packages after deduplication: ${a.uniquePackages.length}`),a.conflicts.length>0)console.log(`Version conflicts found: ${a.conflicts.length}`)}let i=ve.extname(e);if(i===".yaml"||i===".yml"){let c=Or(e);if(c.services)a.services=c.services}return a}function Js(e){let t=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"],r=[];for(let n of t){let s=ve.join(e,n);if(ae.existsSync(s))r.push(s)}return r}import*as A from"node:fs";import*as T from"node:path";import*as X from"node:os";import*as tt from"node:https";import*as rt from"node:http";import{execFileSync as Re}from"node:child_process";import{createHash as Br}from"node:crypto";import{Transform as Lr}from"node:stream";import{pipeline as zr}from"node:stream/promises";function Ee(){return(process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev").replace(/\/$/,"")}function Ur(e,t){if(e!=="ziglang.org")return t;return t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")}function Ne(){let e=process.env.XDG_DATA_HOME,t=e&&e.length>0?e:T.join(X.homedir(),".local","share");return T.join(t,"pantry","global","bin")}function ke(){let e=X.platform(),t=X.arch();return{os:e==="darwin"?"darwin":e==="win32"?"windows":"linux",arch:t==="arm64"?"aarch64":"x86_64"}}function Ze(e,t){let r=e.replace(/(-dev\.\d+)_([0-9A-Za-z-]+)$/,"$1+$2"),n=t.os==="darwin"?"macos":t.os,s=t.arch==="aarch64"?"aarch64":"x86_64",o=t.os==="windows"?"zip":"tar.xz",a=`zig-${s}-${n}-${r}`,i=`${a}.${o}`;return{url:r.includes("-dev.")?`https://ziglang.org/builds/${i}`:`https://ziglang.org/download/${r}/${i}`,format:o,prefix:a}}function Wr(e,t){let[r,n,s]=e.split(".").map(Number);if(r!==3||!Number.isInteger(n)||!Number.isInteger(s))throw Error(`Unsupported SQLite version: ${e}`);let o=n>=52?2026:n>=48?2025:2024,i={"darwin-aarch64":"osx-arm64","darwin-x86_64":"osx-x64","linux-x86_64":"linux-x64","windows-aarch64":"win-arm64","windows-x86_64":"win-x64"}[`${t.os}-${t.arch}`];if(!i)throw Error(`Unsupported platform for SQLite tools: ${t.os}-${t.arch}`);let c=`${r}${n}${String(s).padStart(2,"0")}00`;return`https://sqlite.org/${o}/sqlite-tools-${i}-${c}.zip`}function Ut(e){return e==="bun.sh"||e==="bun.com"}var pe={"github.com/mail-os/mail":{getDownloadUrl(e,t){if(t.os!=="linux"||t.arch!=="x86_64")throw Error("github.com/mail-os/mail currently publishes linux-x86_64 release binaries");let r={darwin:"macos",linux:"linux",windows:"windows"},n=`mail-${t.arch}-${r[t.os]}`;return`https://github.com/mail-os/mail/releases/download/v${e}/${n}.tar.gz`},getArchiveFormat(){return"tar.gz"},getBinaries(e){let t={darwin:"macos",linux:"linux",windows:"windows"};return[`mail-${e.arch}-${t[e.os]}`,"mail"]}},"ziglang.org":{getDownloadUrl(e,t){return Ze(e,t).url},getArchiveFormat(e){return Ze("0.0.0",e).format},getBinaries(e){return e.os==="windows"?["zig.exe"]:["zig"]},getArchivePrefix(e,t){return Ze(e,t).prefix}},"bun.sh":{getDownloadUrl(e,t){let r={"darwin-aarch64":"darwin-aarch64","darwin-x86_64":"darwin-x64","linux-aarch64":"linux-aarch64","linux-x86_64":"linux-x64","windows-x86_64":"windows-x64"},n=`${t.os}-${t.arch}`,s=r[n]||"linux-x64";return`https://github.com/oven-sh/bun/releases/download/bun-v${e}/bun-${s}.zip`},getArchiveFormat(){return"zip"},getBinaries(e){return e.os==="windows"?["bun.exe"]:["bun","bunx"]},getArchivePrefix(e,t){let r={"darwin-aarch64":"bun-darwin-aarch64","darwin-x86_64":"bun-darwin-x64","linux-aarch64":"bun-linux-aarch64","linux-x86_64":"bun-linux-x64","windows-x86_64":"bun-windows-x64"},n=`${t.os}-${t.arch}`,s=r[n];if(!s)throw Error(`Unsupported platform for bun: ${n}`);return s}},"sqlite.org":{getDownloadUrl(e,t){return Wr(e,t)},getArchiveFormat(){return"zip"},getBinaries(e){let t=e.os==="windows"?".exe":"";return[`sqlite3${t}`,`sqldiff${t}`,`sqlite3_analyzer${t}`,`sqlite3_rsync${t}`]}},"nodejs.org":{getDownloadUrl(e,t){let r={darwin:"darwin",linux:"linux",windows:"win"},n={x86_64:"x64",aarch64:"arm64"},s=t.os==="windows"?"zip":"tar.xz";return`https://nodejs.org/dist/v${e}/node-v${e}-${r[t.os]}-${n[t.arch]}.${s}`},getArchiveFormat(e){return e.os==="windows"?"zip":"tar.xz"},getBinaries(e){return e.os==="windows"?["node.exe","npm.cmd","npx.cmd"]:["node","npm","npx"]},getArchivePrefix(e,t){let r={darwin:"darwin",linux:"linux",windows:"win"},n={x86_64:"x64",aarch64:"arm64"};return`node-v${e}-${r[t.os]}-${n[t.arch]}`}}};function Bt(e,t,r,n){A.mkdirSync(r,{recursive:!0});let s=null;for(let o of t){let a=T.join(e,o);if(!A.existsSync(a))a=T.join(e,"bin",o);if(!A.existsSync(a)){if(s){let c=T.join(r,o);try{A.unlinkSync(c)}catch{}if(n.os==="windows")A.copyFileSync(s,c);else A.symlinkSync(s,c)}continue}if(!s)s=a;let i=T.join(r,o);try{A.unlinkSync(i)}catch{}if(n.os==="windows")A.copyFileSync(a,i);else A.symlinkSync(a,i)}}async function Wt(e,t,r={}){let n=r.platform||ke(),s=pe[e];if(/^[\^~>=<]/.test(t))t=await en(e,t,n);else if(t==="latest"||t==="*"||!t)t=await nt(e,n);else if(e==="ziglang.org"&&t.endsWith("-dev")){let b=await Gr(t,n,{onRetry:r.onRetry});if(!b)throw Error(`Could not resolve ${t} to a published ziglang.org development build`);t=b}if(t=Ur(e,t),!t)throw Error(`Could not resolve a concrete version for ${e} (got empty string from resolver)`);let o=r.installDir||T.join(process.cwd(),"pantry"),a=T.join(o,".bin"),i=T.join(o,e.replace(/\./g,"-"),t),c=s?.getBinaries(n);if(s&&(!c||c.length===0))throw Error(`No binaries defined for ${e} on ${n.os}-${n.arch}`);if(c?A.existsSync(T.join(i,c[0]))||A.existsSync(T.join(i,"bin",c[0])):Qe(i).length>0){let b=c??Qe(i);if(!r.quiet)console.log(` ✓ ${e}@${t} (cached)`);if(r.createBinLinks!==!1)Bt(i,b,a,n);let x=Lt(i,b,n,r);return{name:e,version:t,installPath:i,binaries:b,globalLinks:x}}let u=!s||e==="ziglang.org"&&t.includes("-dev.")?await qt(e,{onRetry:r.onRetry}):null,p=s?e==="ziglang.org"&&t.includes("-dev.")?Yr(u,t,n):null:Hr(u,t,n);if(!s&&!p)throw Error(`Cannot install ${e}@${t}: no built-in resolver, and the registry publishes no ${ge(n)} artifact for that version.`);let m=p?.url??s.getDownloadUrl(t,n),f=p?.format??s.getArchiveFormat(n),y=p?.sha256;if(!r.quiet)console.log(` → ${e}@${t} from ${new URL(m).hostname}`);let h=A.mkdtempSync(T.join(X.tmpdir(),"pantry-")),d=T.join(h,`archive.${f}`);try{let b=y;if(!b&&m.startsWith(`${Ee()}/binaries/`)){let S=T.join(h,"archive.sha256");await zt(`${m}.sha256`,S,{quiet:r.quiet,onRetry:r.onRetry});let C=A.readFileSync(S,"utf8").match(/\b([a-f0-9]{64})\b/i)?.[1];if(!C)throw Error(`Invalid SHA-256 checksum response for ${m}`);b=C.toLowerCase()}await zt(m,d,{quiet:r.quiet,onRetry:r.onRetry,expectedSha256:b});let x=T.join(h,"extracted");A.mkdirSync(x,{recursive:!0}),await an(d,x,f);let P=x,k=p?p.prefix:s.getArchivePrefix?.(t,n);if(k){let S=T.join(x,k);if(A.existsSync(S))P=S;else{let D=A.readdirSync(x).find((E)=>A.statSync(T.join(x,E)).isDirectory());if(D)P=T.join(x,D)}}A.mkdirSync(i,{recursive:!0}),cn(P,i);let w=c??Qe(i);if(w.length===0)throw Error(`${e}@${t} unpacked with no executables in bin/`);if(n.os!=="windows"){for(let S of w){let C=T.join(i,S);if(A.existsSync(C))A.chmodSync(C,493);let D=T.join(i,"bin",S);if(A.existsSync(D))A.chmodSync(D,493)}for(let S of["bin","sbin","libexec"])Jt(T.join(i,S))}if(r.createBinLinks!==!1)Bt(i,w,a,n);if(!r.quiet)console.log(` ✓ ${e}@${t}`);let v=Lt(i,w,n,r);return{name:e,version:t,installPath:i,binaries:w,globalLinks:v}}finally{try{A.rmSync(h,{recursive:!0,force:!0})}catch{}}}function Lt(e,t,r,n){if(!n.globalBin)return[];let s=typeof n.globalBin==="string"?n.globalBin:Ne();A.mkdirSync(s,{recursive:!0});let o=[];for(let a of t){let i=T.join(e,a);if(!A.existsSync(i))i=T.join(e,"bin",a);if(!A.existsSync(i))continue;let c=T.join(s,a);try{A.unlinkSync(c)}catch{}if(r.os==="windows")A.copyFileSync(i,c);else A.symlinkSync(i,c);o.push(c)}if(!n.quiet&&o.length>0)console.log(` → linked ${o.length} binary(ies) into ${s}`);return o}async function qr(e,t={}){return Promise.all(e.map((r)=>Wt(r.domain,r.version,t)))}async function nt(e,t=ke()){if(Ut(e)){let s=(await Y("https://api.github.com/repos/oven-sh/bun/releases/latest").catch(()=>null))?.tag_name?.replace(/^bun-v/,"")||"";if(s)return s;let o=await Xe(e);if(o)return o;throw Error("Failed to resolve latest bun.sh version (GitHub API unreachable, no bundled metadata)")}if(e==="ziglang.org"){let n=await ue(e,t);if(n.length>0)return n.sort(Ce)[0];throw Error(`Failed to resolve a ziglang.org version published for ${ge(t)}`)}if(e==="nodejs.org"){let s=await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[],a=(s.find((c)=>c.lts)?.version||s[0]?.version||"").replace(/^v/,"");if(a)return a;let i=await Xe(e);if(i)return i;throw Error("Failed to resolve latest nodejs.org version")}if(e==="github.com/mail-os/mail"){let s=(await Y("https://api.github.com/repos/mail-os/mail/releases/latest").catch(()=>null))?.tag_name?.replace(/^v/,"")||"";if(s)return s;let a=((await Y("https://api.github.com/repos/mail-os/mail/tags?per_page=1").catch(()=>null))?.[0]?.name||"").replace(/^v/,"");if(a)return a;let i=await Xe(e);if(i)return i;throw Error("Failed to resolve latest github.com/mail-os/mail version")}let r=await ue(e,t);if(r.length>0)return r.sort(Ce)[0];throw Error(`Cannot resolve latest version for ${e} (no built-in resolver, and the registry publishes nothing for ${ge(t)})`)}async function Xe(e){try{let t=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:r}=await import("./chunk-ggxaeaat.js").catch(()=>import("./src/index.js")),s=r[t]?.versions||[];return s.find((o)=>!o.includes("-"))||s[0]||""}catch{return""}}async function Gr(e,t,r={}){let s=(await ue("ziglang.org",t,r)).filter((i)=>i.startsWith(`${e}.`)).sort(Ce)[0];if(s)return s;let a=(await Y("https://ziglang.org/download/index.json",3,r).catch(()=>null))?.master?.version||"";return a.startsWith(`${e}.`)?a:null}function ge(e){let t=e.arch==="aarch64"?"arm64":"x86-64";return`${e.os}-${t}`}function Kr(e,t){let r=ge(t);return Object.entries(e?.versions||{}).filter(([,n])=>Object.hasOwn(n.platforms||{},r)).map(([n])=>n)}async function qt(e,t={}){return await Y(`${Ee()}/binaries/${encodeURI(e)}/metadata.json`,5,t).catch(()=>null)}async function ue(e,t,r={}){return Kr(await qt(e,r),t)}function Hr(e,t,r){let n=e?.versions?.[t]?.platforms?.[ge(r)];if(!n?.tarball)return null;return{url:`${Ee()}/${n.tarball.replace(/^\/+/,"")}`,format:"tar.gz",prefix:"",sha256:n.sha256?.toLowerCase()}}function Qe(e){try{return A.readdirSync(T.join(e,"bin")).filter((t)=>!t.startsWith(".")).sort()}catch{return[]}}function Yr(e,t,r){if(!t.includes("-dev.")||!e)return null;let n=ge(r),o=[t.replace(/(-dev\.\d+)_([0-9A-Za-z-]+)$/,"$1+$2"),t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")].find((i)=>Object.hasOwn(e.versions?.[i]?.platforms||{},n));if(!o)return null;let a=encodeURIComponent(o).replace(/%2B/gi,"+");return{url:`${Ee()}/binaries/ziglang.org/${a}/${n}/ziglang.org-${a}.tar.gz`,format:"tar.gz",prefix:""}}function Gt(e){let t=e.match(/^([~^]|>=|<=|>|<|=)(\d+(?:\.\d+){0,10}(?:-[0-9A-Za-z.-]+)?(?:[+_][0-9A-Za-z.-]+)?)/);if(!t)return null;return{operator:t[1],target:t[2]}}function De(e){return e.split(/[+_-]/,1)[0].split(".").map((t)=>Number.parseInt(t,10))}function Kt(e,t){let r=De(e),n=De(t);for(let c=0;c<Math.max(r.length,n.length,3);c++){let l=(r[c]||0)-(n[c]||0);if(l)return l}let s=e.includes("-"),o=t.includes("-");if(s!==o)return s?-1:1;let a=Number.parseInt(e.match(/-dev\.(\d+)/)?.[1]||"0",10),i=Number.parseInt(t.match(/-dev\.(\d+)/)?.[1]||"0",10);return a-i}function Jr(e,t){let{operator:r,target:n}=t;if(e.includes("-")&&!n.includes("-"))return!1;let s=De(e),o=De(n);if(s.some(Number.isNaN)||o.some(Number.isNaN))return!1;let[a,i,c]=[s[0]||0,s[1]||0,s[2]||0],[l,g,u]=[o[0]||0,o[1]||0,o[2]||0],p=Kt(e,n);if(r==="^"){if(p<0)return!1;if(l===0&&g===0)return a===0&&i===0&&c===u;if(l===0)return a===0&&i===g;return a===l}if(r==="~"){if(p<0)return!1;return o.length===1?a===l:a===l&&i===g}if(r===">=")return p>=0;if(r==="<=")return p<=0;if(r===">")return p>0;if(r==="<")return p<0;if(r==="=")return p===0;return!1}async function Zr(e,t){if(Ut(e))return(await Y("https://api.github.com/repos/oven-sh/bun/releases?per_page=100").catch(()=>null)||[]).map((s)=>(s.tag_name||"").replace(/^bun-v/,"")).filter(Boolean);if(e==="nodejs.org")return(await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[]).map((s)=>(s.version||"").replace(/^v/,"")).filter(Boolean);if(e==="ziglang.org"){let r=await Y("https://ziglang.org/download/index.json").catch(()=>null),n=Xr(r,t);if(n.length>0)return n;return await ue(e,t)}return await ue(e,t)}function Xr(e,t){let r=`${t.arch}-${t.os==="darwin"?"macos":t.os}`;return Object.entries(e||{}).filter(([,n])=>Boolean(n[r])).map(([n,s])=>s.version||n).filter(Boolean)}function et(e,t){return Kt(t,e)}function Qr(e,t){let r=Gt(e);if(!r)return null;return[...new Set(t)].sort(et).find((n)=>Jr(n,r))||null}async function en(e,t,r){if(!Gt(t))return nt(e,r);let n;try{let i=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:c}=await import("./chunk-ggxaeaat.js").catch(()=>import("./src/index.js"));n=c[i]?.versions||[]}catch{n=[]}let s=await Zr(e,r),o=e==="ziglang.org"?s.sort(et):[...new Set([...s,...n])].sort(et),a=Qr(t,o);if(a)return a;throw Error(`No version of ${e} satisfies "${t}" (checked ${o.length} version${o.length===1?"":"s"}${o.length>0?`, newest ${o[0]}`:""}).`)}var tn=4;function Ie(e){return e instanceof Error?e.message:String(e)}function rn(e){if(typeof e==="object"&&e!==null&&"statusCode"in e){let r=Number(e.statusCode);if(Number.isFinite(r))return r}let t=Ie(e).match(/\bHTTP\s+(\d{3})\b/i);return t?Number(t[1]):void 0}function nn(e){if(typeof e!=="object"||e===null)return"";let t="code"in e?String(e.code||""):"";if(t)return t;let r="cause"in e?e.cause:void 0;return typeof r==="object"&&r!==null&&"code"in r?String(r.code||""):""}function sn(e){let t=rn(e);if(t!==void 0)return t===408||t===425||t===429||t>=500;if(/^(?:ECONNRESET|ECONNREFUSED|EPIPE|ETIMEDOUT|EAI_AGAIN|ENETDOWN|ENETUNREACH|EHOSTUNREACH|UND_ERR_SOCKET)$/i.test(nn(e)))return!0;return/socket hang up|connection reset|premature close|aborted|terminated|timed? ?out|temporar|stalled|incomplete download|checksum mismatch/i.test(Ie(e))}async function Ht(e,t,r={}){let n=r.maxAttempts??tn,s=r.retryDelayMs??1000,o=r.sleep??((i)=>new Promise((c)=>setTimeout(c,i))),a;for(let i=1;i<=n;i+=1)try{return await t()}catch(c){if(a=c,!sn(c))throw c;if(i===n)break;let l=Math.min(s*2**(i-1),1e4);r.onRetry?.(`${e} failed (${Ie(c)}); retrying in ${l}ms`),await o(l)}throw Error(`${e} failed after ${n} attempts: ${Ie(a)}`)}function Yt(e,t,r){return new Promise((n,s)=>{let a=(e.startsWith("https")?tt.get:rt.get)(e,{headers:{"User-Agent":"pantry-installer"}},(i)=>{if(i.statusCode&&i.statusCode>=300&&i.statusCode<400&&i.headers.location){if(i.resume(),t<=0)return s(Error(`Too many redirects for ${e}`));let c=new URL(i.headers.location,e).href;return Yt(c,t-1,r).then(n,s)}if(!i.statusCode||i.statusCode<200||i.statusCode>=300){i.resume();let c=Object.assign(Error(`HTTP ${i.statusCode||"unknown"} downloading ${e}`),{statusCode:i.statusCode});return s(c)}i.setTimeout(r,()=>{i.destroy(Error(`Download stalled (no data for ${r/1000}s): ${e}`))}),n(i)});a.setTimeout(r,()=>{a.destroy(Error(`Download timed out after ${r/1000}s: ${e}`))}),a.once("error",s)})}async function on(e,t,r){let n=`${t}.part`;try{A.rmSync(n,{force:!0})}catch{}let s=await Yt(e,10,r.stallTimeoutMs??60000),o=!r.quiet&&process.stderr.isTTY,a=Number.parseInt(String(s.headers["content-length"]||""),10),i=Number.isFinite(a)?a:0,c=0,l=0,g=r.expectedSha256?Br("sha256"):void 0,u=new Lr({transform(p,m,f){c+=p.length,g?.update(p);let y=Date.now();if(o&&y-l>200){l=y;let h=(c/1048576).toFixed(1);if(i>0){let d=(i/1048576).toFixed(1),b=Math.floor(c/i*100);process.stderr.write(`\r ${h}/${d} MB (${b}%)`)}else process.stderr.write(`\r ${h} MB`)}f(null,p)}});try{if(await zr(s,u,A.createWriteStream(n)),!s.complete||i>0&&c!==i)throw Error(`Incomplete download for ${e}: received ${c} of ${i||"unknown"} bytes`);if(r.expectedSha256){let p=g.digest("hex");if(p!==r.expectedSha256.toLowerCase())throw Error(`Checksum mismatch for ${e}: expected ${r.expectedSha256}, got ${p}`)}A.renameSync(n,t)}catch(p){try{A.rmSync(n,{force:!0})}catch{}throw p}finally{if(o&&l>0)process.stderr.write("\r\x1B[K")}}async function zt(e,t,r={}){await Ht(`Download ${e}`,()=>on(e,t,r),r)}async function an(e,t,r){if(r==="zip")if(process.platform==="win32")Re("powershell",["-NoProfile","-Command","Expand-Archive","-Path",e,"-DestinationPath",t,"-Force"],{stdio:"pipe"});else Re("unzip",["-o","-q",e,"-d",t],{stdio:"pipe"});else if(r==="tar.xz")Re("tar",["xJf",e,"-C",t],{stdio:"pipe"});else if(r==="tar.gz")Re("tar",["xzf",e,"-C",t],{stdio:"pipe"});else throw Error(`Unsupported archive format: ${r}`)}function cn(e,t){A.cpSync(e,t,{recursive:!0})}function Jt(e){let t;try{t=A.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of t){let n=T.join(e,r.name);try{if(r.isDirectory()){Jt(n);continue}if(!r.isFile())continue;let s=A.statSync(n).mode&511,o=s|(s&292)>>2;if(o!==s)A.chmodSync(n,o)}catch{}}}function Zt(e,t){return new Promise((r,n)=>{let s=e.startsWith("https")?tt.get:rt.get,o={"User-Agent":"pantry-installer",Accept:"application/json"};if(e.includes("api.github.com")){let i=process.env.GITHUB_TOKEN||process.env.GH_TOKEN;if(i)o.Authorization=`Bearer ${i}`}let a=s(e,{headers:o,timeout:30000},(i)=>{if(i.statusCode&&i.statusCode>=300&&i.statusCode<400&&i.headers.location){if(t<=0)return n(Error(`Too many redirects for ${e}`));let l=new URL(i.headers.location,e).href;return Zt(l,t-1).then(r,n)}if(!i.statusCode||i.statusCode<200||i.statusCode>=300)return n(Object.assign(Error(`HTTP ${i.statusCode||"unknown"} fetching ${e}`),{statusCode:i.statusCode}));let c="";i.on("data",(l)=>c+=l),i.on("end",()=>{try{r(JSON.parse(c))}catch(l){n(l)}})});a.on("error",n),a.on("timeout",()=>{a.destroy(),n(Error(`Request timed out: ${e}`))})})}function Y(e,t=5,r={}){return Ht(`Fetch ${e}`,()=>Zt(e,t),r)}pe["bun.com"]=pe["bun.sh"];function Xt(e){return e in pe}async function ln(e,t=ke()){if(Xt(e))return!0;return(await ue(e,t)).length>0}function ni(){return Object.keys(pe)}function si(e){let t=pe[e];if(!t)return;let r=ke();return t.getBinaries(r)[0]}import*as L from"node:fs";import*as Ve from"node:os";import*as ce from"node:path";var Te="# >>> pantry shell-init >>>",Oe="# <<< pantry shell-init <<<";function je(){let e=process.env.SHELL??"";if(e.endsWith("/zsh")||e==="zsh")return"zsh";if(e.endsWith("/bash")||e==="bash")return"bash";if(e.endsWith("/fish")||e==="fish")return"fish";return"unknown"}function st(e){let t=Ve.homedir();switch(e){case"zsh":{let r=process.env.ZDOTDIR;return ce.join(r&&r.length>0?r:t,".zshrc")}case"bash":{if(Ve.platform()==="darwin"){let r=ce.join(t,".bash_profile");if(L.existsSync(r))return r}return ce.join(t,".bashrc")}case"fish":return ce.join(t,".config","fish","config.fish");case"unknown":return null}}function Qt(e={}){let t=e.globalBin??Ne();if((e.shell??je())==="fish")return[Te,`if test -d "${t}"`,` set -gx PATH "${t}" $PATH`,"end",Oe,""].join(`
|
|
8
8
|
`);return[Te,`if [ -d "${t}" ] && [[ ":$PATH:" != *":${t}:"* ]]; then`,` export PATH="${t}:$PATH"`,"fi",Oe,""].join(`
|
|
9
9
|
`)}function pn(e={}){let t=e.shell??je(),r=st(t);if(!r)throw Error(`Could not detect a supported shell (got SHELL=${process.env.SHELL??"<unset>"}). Run \`ts-pantry shell-init\` and copy the printed snippet into your rc file manually.`);let n=Qt({...e,shell:t}),s="";if(L.existsSync(r)){if(s=L.readFileSync(r,"utf-8"),s.includes(Te))return{rcFile:r,shell:t,changed:!1}}else L.mkdirSync(ce.dirname(r),{recursive:!0});let o=s.length>0&&!s.endsWith(`
|
|
10
10
|
`)?`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Mc as I,Nc as C}from"./chunk-
|
|
1
|
+
import{Mc as I,Nc as C}from"./chunk-ws531zme.js";import{Oc as h,Pc as x}from"./chunk-s094ynsz.js";import{Qc as y,Tc as j}from"./chunk-ava4pf2j.js";x();async function p(){try{let{packages:s}=await import("./chunk-ggxaeaat.js");return s}catch{return{}}}async function b(s){let r=P(s);if(!r)return null;let e=(await p())[r];if(!e||!e.versions||e.versions.length===0)return null;return e.versions[0]}async function v(s){let r=P(s);if(!r)return[];let e=(await p())[r];if(!e||!e.versions)return[];return[...e.versions]}function D(s={}){let r=["8.4.11","8.3.14","8.2.26","8.1.30"],t=s.fallbackVersions||r;try{let{pantry:e}=(C(),y(I)),n=e.phpnet||e.php;if(!n||!n.versions||n.versions.length===0)return t;let i=[...n.versions],a=s.supportedBranches||A(i),c=new Map;for(let u of i){let[f,m]=u.split(".");if(!f||!m)continue;let o=`${f}.${m}`;if(a.includes(o)&&!c.has(o))c.set(o,u)}let l=a.map((u)=>c.get(u)).filter(Boolean);return l.length>0?l:t}catch{return t}}function A(s){let r=new Map;for(let e of s){let[n,i]=e.split(".");if(!n||!i)continue;let a=`${n}.${i}`;r.set(a,(r.get(a)||0)+1)}return Array.from(r.keys()).filter((e)=>{let[n]=e.split(".");return n==="8"&&r.get(e)>3}).sort((e,n)=>{let[i,a]=e.split(".").map(Number),[c,l]=n.split(".").map(Number);if(i!==c)return c-i;return l-a}).slice(0,4)}async function B(s,r){return(await v(s)).includes(r)}async function W(s,r="latest"){if(r==="latest")return await b(s);let t=await v(s);if(t.length===0)return null;if(t.includes(r))return r;if(r.startsWith("^")){let n=r.slice(1).split(".")[0];return t.filter((a)=>a.startsWith(`${n}.`))[0]||null}if(r.startsWith("~")){let e=r.slice(1),[n,i]=e.split("."),a=`${n}.${i}.`;return t.filter((l)=>l.startsWith(a))[0]||null}if(r.startsWith(">=")){let n=r.slice(2).split(".").map(Number);return t.filter((a)=>{let c=a.split(".").map(Number);for(let l=0;l<Math.max(c.length,n.length);l++){let u=c[l]??0,f=n[l]??0;if(u>f)return!0;if(u<f)return!1}return!0})[0]||null}return await b(s)}async function k(s){let r=P(s);if(!r)return null;let e=(await p())[r];if(!e)return null;let n=await b(s);if(!n)return null;return{name:String(s),domain:r,description:e.description||"",latestVersion:n,totalVersions:e.versions?.length||0,programs:[...e.programs||[]],dependencies:[...e.dependencies||[]],companions:[...e.companions||[]],versions:[...e.versions||[]]}}function P(s){let r=String(s);if(r in h){let t=h[r];return N(t)}return N(r)}function N(s){if(s.includes("/")){let[r,...t]=s.split("/"),e=t.join("/"),n=r.replace(/\./g,""),i=e.replace(/[/\-_.]/g,"").toLowerCase();return`${n}${i}`.toLowerCase()}return s.replace(/[.\-_]/g,"").toLowerCase()}async function O(s){let r=[],t=s.toLowerCase();for(let[n,i]of Object.entries(h))if(n.toLowerCase().includes(t)){let a=await k(n);if(a)r.push(a)}let e=await p();for(let[n,i]of Object.entries(e))if(n.toLowerCase().includes(t)||i.description?.toLowerCase().includes(t)){let a=await k(n);if(a&&!r.some((c)=>c.domain===n))r.push(a)}return r}async function F(s){let r=[],t=await p();for(let e of Object.keys(t))if(s.test(e)){let n=await k(e);if(n)r.push(n)}return r}async function M(s=10){let r=[],t=await p();for(let e of Object.keys(t)){let n=await k(e);if(n&&n.totalVersions>=s)r.push(n)}return r.sort((e,n)=>n.totalVersions-e.totalVersions)}async function R(s=50){return(await M(5)).slice(0,s)}async function _(s){try{let r=s.lastIndexOf("@");if(r===-1){let a=s;if(!P(a))return{isValid:!1,error:`Unknown package: ${a}`};return{isValid:!0,packageName:a}}let t=s.slice(0,r),e=s.slice(r+1);if(!P(t))return{isValid:!1,error:`Unknown package: ${t}`};if(e==="latest")return{isValid:!0,packageName:t,version:e};if(!await B(t,e))return{isValid:!1,packageName:t,version:e,error:`Version ${e} not available for package ${t}`};return{isValid:!0,packageName:t,version:e}}catch{return{isValid:!1,error:`Invalid package specification: ${s}`}}}function d(s){let r=s.replace(/^v/,"").split("+")[0],[t,...e]=r.split("-"),[n,i,a]=t.split(".").map((c)=>{let l=Number.parseInt(c,10);return Number.isNaN(l)?0:l});return{major:n??0,minor:i??0,patch:a??0,prerelease:e.length>0?e.join("-").split("."):[]}}function w(s,r){let t=d(s),e=d(r);if(t.major!==e.major)return e.major-t.major;if(t.minor!==e.minor)return e.minor-t.minor;if(t.patch!==e.patch)return e.patch-t.patch;let n=t.prerelease.length>0,i=e.prerelease.length>0;if(n!==i)return n?1:-1;if(!n)return 0;for(let a=0;a<Math.max(t.prerelease.length,e.prerelease.length);a++){let c=t.prerelease[a],l=e.prerelease[a];if(c===void 0)return 1;if(l===void 0)return-1;let u=Number.parseInt(c,10),f=Number.parseInt(l,10),m=!Number.isNaN(u)&&String(u)===c,o=!Number.isNaN(f)&&String(f)===l;if(m&&o){if(u!==f)return f-u}else if(m!==o)return m?1:-1;else if(c!==l)return c<l?1:-1}return 0}function T(s,r){if(!r||r.length===0)return null;let t=[...r].sort(w),e=s.replace(/^[\^~]/,""),n=d(e),i=e.replace(/^v/,"").split("+")[0].split("-")[0],a=i.split(".").length>=3,c=n.prerelease.length>0,l=(o)=>{if(o.prerelease.length===0)return!0;if(!c)return!1;return o.major===n.major&&o.minor===n.minor&&o.patch===n.patch},u=(o,g)=>w(g,e)<=0||o.prerelease.length>0,f=(o)=>{for(let g of t){let V=d(g);if(!l(V))continue;if(o(V,g))return g}return null};if(s.startsWith("^"))return f((o,g)=>{if(o.major!==n.major)return!1;if(n.major===0&&o.minor!==n.minor)return!1;return u(o,g)});if(s.startsWith("~"))return f((o,g)=>{if(o.major!==n.major||o.minor!==n.minor)return!1;return!a||u(o,g)});if(t.includes(e))return e;let m=i.split(".").filter(Boolean).map((o)=>Number.parseInt(o,10));if(m.length>0&&m.every((o)=>!Number.isNaN(o))){let o=f((g)=>{if(m[0]!==void 0&&g.major!==m[0])return!1;if(m[1]!==void 0&&g.minor!==m[1])return!1;if(m[2]!==void 0&&g.patch!==m[2])return!1;return!0});if(o)return o}return f(()=>!0)??t[0]??null}
|
|
2
2
|
export{b as vc,v as wc,D as xc,B as yc,W as zc,k as Ac,P as Bc,O as Cc,F as Dc,M as Ec,R as Fc,_ as Gc,d as Hc,w as Ic,T as Jc};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Kc as b,Lc as c,Nc as d}from"./chunk-
|
|
1
|
+
import{Kc as b,Lc as c,Nc as d}from"./chunk-ws531zme.js";import{Oc as a}from"./chunk-s094ynsz.js";import"./chunk-ava4pf2j.js";d();export{a as aliases,c as packages,b as pantry};
|