ts-pantry 0.11.42 → 0.11.44
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-74syf5ae.js → chunk-ara8pnq5.js} +1 -1
- package/dist/{chunk-3mny7jc4.js → chunk-k4a1xwyb.js} +2 -2
- package/dist/chunk-tx72avsr.js +2 -0
- package/dist/{chunk-exh082vx.js → chunk-v4rc3n8q.js} +1 -1
- package/dist/{chunk-qpmxc7rk.js → chunk-vskrmked.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/packages/anthropic.com/claude-code.d.ts +2 -2
- package/dist/src/packages/apps/codexopenaicom.d.ts +1 -1
- package/dist/src/packages/apps/cursorcom.d.ts +2 -2
- package/dist/src/packages/apps/libreofficeorg.d.ts +2 -2
- package/dist/src/packages/apps/linearapp.d.ts +2 -2
- package/dist/src/packages/apps/rectangleapp.d.ts +2 -2
- package/dist/src/packages/apps/whatsappcom.d.ts +2 -2
- package/dist/src/packages/apps/zeddev.d.ts +2 -2
- package/dist/src/packages/argoproj.github.io/cd.d.ts +3 -3
- package/dist/src/packages/casdoororg.d.ts +3 -3
- package/dist/src/packages/circlecicom.d.ts +3 -3
- package/dist/src/packages/cmakeorg.d.ts +3 -3
- package/dist/src/packages/cnqueryio.d.ts +3 -3
- package/dist/src/packages/coder.com/code-server.d.ts +3 -3
- package/dist/src/packages/codercom.d.ts +3 -3
- package/dist/src/packages/daggerio.d.ts +3 -3
- package/dist/src/packages/encoredev.d.ts +3 -3
- package/dist/src/packages/flyio.d.ts +3 -3
- package/dist/src/packages/getcomposerorg.d.ts +3 -3
- package/dist/src/packages/getfoundrysh.d.ts +2 -2
- package/dist/src/packages/github.com/canonical/charmcraft.d.ts +3 -3
- package/dist/src/packages/github.com/router-for-me/CLIProxyAPI.d.ts +3 -3
- package/dist/src/packages/harfbuzzorg.d.ts +2 -2
- package/dist/src/packages/harlequinsh.d.ts +3 -3
- package/dist/src/packages/huggingfaceco.d.ts +3 -3
- package/dist/src/packages/insomniarest.d.ts +2 -2
- package/dist/src/packages/irohcomputer.d.ts +3 -3
- package/dist/src/packages/kindsigsk8sio.d.ts +3 -3
- package/dist/src/packages/laravelcom.d.ts +3 -3
- package/dist/src/packages/libcxxllvmorg.d.ts +3 -3
- package/dist/src/packages/libvipsorg.d.ts +3 -3
- package/dist/src/packages/llvmorg.d.ts +3 -3
- package/dist/src/packages/materializecom.d.ts +3 -3
- package/dist/src/packages/misejdxdev.d.ts +3 -3
- package/dist/src/packages/msgpackorg.d.ts +3 -3
- package/dist/src/packages/mupdfcom.d.ts +3 -3
- package/dist/src/packages/nodejsorg.d.ts +3 -3
- package/dist/src/packages/npmjscom.d.ts +3 -3
- package/dist/src/packages/ohmyposhdev.d.ts +3 -3
- package/dist/src/packages/ollamaai.d.ts +3 -3
- package/dist/src/packages/openai.com/codex.d.ts +3 -3
- package/dist/src/packages/opencodeai.d.ts +3 -3
- package/dist/src/packages/openmpllvmorg.d.ts +3 -3
- package/dist/src/packages/openshiftcom.d.ts +2 -2
- package/dist/src/packages/pcre.org/v2.d.ts +3 -3
- package/dist/src/packages/phpnet.d.ts +3 -3
- package/dist/src/packages/planetscalecom.d.ts +3 -3
- package/dist/src/packages/plantumlcom.d.ts +3 -3
- package/dist/src/packages/pnpmio.d.ts +3 -3
- package/dist/src/packages/projenio.d.ts +3 -3
- package/dist/src/packages/railwayapp.d.ts +3 -3
- package/dist/src/packages/sconsorg.d.ts +3 -3
- package/dist/src/packages/spacetimedbcom.d.ts +2 -2
- package/dist/src/packages/srtallianceorg.d.ts +3 -3
- package/dist/src/packages/stripecom.d.ts +3 -3
- package/dist/src/packages/tartrun.d.ts +3 -3
- package/dist/src/packages/terraformio.d.ts +3 -3
- package/dist/src/packages/toxwiki.d.ts +3 -3
- package/dist/src/packages/traefikio.d.ts +3 -3
- package/dist/src/packages/upxgithubio.d.ts +3 -3
- package/dist/src/packages/valesh.d.ts +3 -3
- package/dist/src/packages/ziglangorg.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunk-36c49e8x.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,Ra as Me,S as oe,Sa as Re,Ua as Le,Xa as Ve,Za as Fe,cb as ze,db as We,eb as Ue,ha as Ee,ia as Te,ja as Ae,ka as _e,la as Pe,pa as ae,qa as Be,ra as Ne}from"../chunk-
|
|
2
|
+
import{E as Ie,L as Oe,M as ie,O as re,Ra as Me,S as oe,Sa as Re,Ua as Le,Xa as Ve,Za as Fe,cb as ze,db as We,eb as Ue,ha as Ee,ia as Te,ja as Ae,ka as _e,la as Pe,pa as ae,qa as Be,ra as Ne}from"../chunk-k4a1xwyb.js";import"../chunk-db3jgr0q.js";import"../chunk-22gn39he.js";import"../chunk-tgf8012c.js";import{Jb as U,Kb as je,Mb as se,Nb as G,Sb as De,Wb as ne}from"../chunk-1xyn336h.js";import"../chunk-n7nj6jzj.js";import"../chunk-b2z6jktp.js";import{nc as W,oc as ee,pc as te}from"../chunk-bpb1md3m.js";import"../chunk-v4rc3n8q.js";import"../chunk-tx72avsr.js";import{Lc as Ce,Mc as zt}from"../chunk-84px82t5.js";import{Qc as N}from"../chunk-jzj5056d.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.44";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-vskrmked.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-cq08zej9.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 +1 @@
|
|
|
1
|
-
import{Hc as b,Ic as c,Kc as d}from"./chunk-
|
|
1
|
+
import{Hc as b,Ic as c,Kc as d}from"./chunk-tx72avsr.js";import{Lc as a}from"./chunk-84px82t5.js";import"./chunk-jzj5056d.js";d();export{a as aliases,c as packages,b as pantry};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{fb as Je}from"./chunk-db3jgr0q.js";import{Zb as lt}from"./chunk-n7nj6jzj.js";import{fc as Q,gc as er,ic as Ve}from"./chunk-b2z6jktp.js";import{Bc as Vt,Cc as jt,Dc as qe,sc as Et,tc as Nt,wc as Tt,xc as We,zc as Ot}from"./chunk-
|
|
1
|
+
import{fb as Je}from"./chunk-db3jgr0q.js";import{Zb as lt}from"./chunk-n7nj6jzj.js";import{fc as Q,gc as er,ic as Ve}from"./chunk-b2z6jktp.js";import{Bc as Vt,Cc as jt,Dc as qe,sc as Et,tc as Nt,wc as Tt,xc as We,zc as Ot}from"./chunk-v4rc3n8q.js";import{Kc as ps}from"./chunk-tx72avsr.js";import{Lc as he,Mc as Dr}from"./chunk-84px82t5.js";import{Qc as K}from"./chunk-jzj5056d.js";import Er from"node:process";Dr();import Rt from"node:process";function Ct(e){return e in he}function Ir(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 ds(e){return Ct(e)||Ir(e)}function fs(e){return["darwin","linux","windows"].includes(e)}function ms(e){return["x86_64","aarch64","armv7l","i686"].includes(e)}function Dt(){return Object.keys(he)}function hs(){return Object.values(he)}function ys(e){if(Ct(e))return{originalName:e,resolvedDomain:he[e],isAlias:!0};return{originalName:e,resolvedDomain:e,isAlias:!1}}function bs(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 ks(e,t){return t?`${e}@${t}`:e}function ke(){let e=Rt.platform,t=Rt.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 xs(e,t="latest",r){let n=r||ke(),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 Ps={LATEST:"latest",ANY:"*"},It={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 ws(e){return It[e]}function Ss(e,t){return It[t].includes(e)}function vs(e){return e}function $s(e,t){return[e,t]}function As(e){return e}async function Es(e){try{let t=await We(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 Ns(e){try{if(!e||e.trim().length===0)return{success:!1,error:"Search term cannot be empty"};return{success:!0,data:await Ot(e.trim())}}catch(t){return{success:!1,error:`Search failed: ${t}`}}}async function Ts(e=20){try{return{success:!0,data:(await Vt(e)).slice(0,e)}}catch(t){return{success:!1,error:`Failed to list popular packages: ${t}`}}}async function Os(e=20){try{return{success:!0,data:await jt(e)}}catch(t){return{success:!1,error:`Failed to list active packages: ${t}`}}}function Vs(){try{return{success:!0,data:Dt()}}catch(e){return{success:!1,error:`Failed to list aliases: ${e}`}}}async function js(e){try{let t=await qe(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 Fs(e){try{let t=await qe(e);if(!t.isValid)return{success:!1,error:t.error};let r=t.packageName,n=t.version||"latest",s=await Tt(r,n);if(!s)return{success:!1,error:`Could not resolve version '${n}' for package '${r}'`};let o=await We(r);if(!o)return{success:!1,error:`Package '${r}' not found`};let a=ke(),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 Ms(e){try{let t=await Et(e);if(!t)return{success:!1,error:`Package '${e}' not found`};let r=await Nt(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 _s(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 Bs(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 Ls(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 zs(){try{let e=ke();return{success:!0,data:{platform:e.platform,architecture:e.architecture,isSupported:e.isSupported,nodeVersion:Er.version}}}catch(e){return{success:!1,error:`Failed to get system info: ${e}`}}}import ae from"node:fs";import Pe from"node:path";function we(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,h=u.replace(/^['"]|['"]$/g,"");if(p==="global"||p==="dependencies"||p==="deps")continue;let f=h,y=h;if(h.startsWith("^"))f=h.substring(1),y=h;else if(h.startsWith("~"))f=h.substring(1),y=h;else if(h.startsWith(">=")||h.startsWith("<=")||h.startsWith(">")||h.startsWith("<")){let m=/^([><=]+)/.exec(h);if(m){let d=m[1];f=h.substring(d.length).trim(),y=h}}else if(h==="*"||h==="latest")f="latest",y="*";else f=h,y=`@${h}`;r.push({name:p,version:f,constraint:y,isOsSpecific:!1})}}}}return r}function Nr(e){if(!ae.existsSync(e))throw Error(`Dependency file not found: ${e}`);let t=ae.readFileSync(e,"utf-8"),r=we(e),n;try{let s=typeof Bun<"u"&&Bun.YAML?Bun.YAML.parse(t):Tr(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 Tr(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 Gs(e,t="src/packages"){try{let r;if(e.includes("/"))r=Pe.join(t,`${e}.ts`);else{let g=`${e.replace(/\./g,"")}.ts`;r=Pe.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 Or(e){try{let{packages:t}=await import("./chunk-74syf5ae.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 Or(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 Vr(r,n)||r[0]}function Vr(e,t){if(t.startsWith("^")){let r=t.slice(1),[n]=pe(r);return e.filter((o)=>{let[a]=pe(o);return a===n&&oe(o,r)>=0})[0]||null}if(t.startsWith("~")){let r=t.slice(1),[n,s]=pe(r);return e.filter((a)=>{let[i,c]=pe(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 pe(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]=pe(r),[i,c,l]=pe(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 xe=null;async function jr(){if(xe)return xe;return xe=(await import("./chunk-74syf5ae.js").catch(()=>import("./src/index.js"))).packages,xe}async function Fr(e){try{let t=await jr(),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 Se(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):(.+)$/),m=!!y,d=y?y[2]:f,k=y?y[1]:void 0;if(m&&(!i||a&&k!==a))return null;let w=d,x="latest",b="*",P=d.match(/^(@?[^@^~>=<]+(?:\/[^@^~>=<]+)?)([@^~>=<].+)?$/);if(P){if(w=P[1],P[2]){let S=P[2];if(S.startsWith("@"))x=S.substring(1),b=S;else b=S,x=S.replace(/^\D*/,"")}}return{dep:{name:w,version:x,constraint:b,isOsSpecific:m,os:k},pkgName:w}},l=await Fr(e),p=[...l?.dependencies||[],...l?.companions||[]].map(g).filter((f)=>f!==null);for(let{dep:f}of p)c.push(f);let h=await Promise.allSettled(p.map(({pkgName:f})=>Se(f,t,r,n+1)));for(let f of h)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 Ge(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 h={...p,version:p.resolvedVersion};delete h.resolvedVersion,o.push(h),a.push(i)}return{allDependencies:o,uniquePackages:a,conflicts:n,osSpecificDeps:s}}async function Mt(e,t={}){let{verbose:r=!1}=t;if(r)console.log(`Parsing dependency file: ${e}`);let n=we(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 Se(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 Ge(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=Pe.extname(e);if(i===".yaml"||i===".yml"){let c=Nr(e);if(c.services)a.services=c.services}return a}function Ks(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=Pe.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 Ze from"node:https";import*as Xe from"node:http";import{execFileSync as ve}from"node:child_process";import{createHash as Mr}from"node:crypto";import{Transform as _r}from"node:stream";import{pipeline as Br}from"node:stream/promises";var Qe=(process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev").replace(/\/$/,"");function Lr(e,t){if(e!=="ziglang.org")return t;return t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")}function Re(){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 Ce(){let e=X.platform(),t=X.arch();return{os:e==="darwin"?"darwin":e==="win32"?"windows":"linux",arch:t==="arm64"?"aarch64":"x86_64"}}function Ke(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 zr(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 zt(e){return e==="bun.sh"||e==="bun.com"}var ce={"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 Ke(e,t).url},getArchiveFormat(e){return Ke("0.0.0",e).format},getBinaries(e){return e.os==="windows"?["zig.exe"]:["zig"]},getArchivePrefix(e,t){return Ke(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 zr(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 _t(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 Ut(e,t,r={}){let n=r.platform||Ce(),s=ce[e];if(!s)throw Error(`Unknown package: ${e}. Supported: ${Object.keys(ce).join(", ")}`);if(/^[\^~>=<]/.test(t))t=await Zr(e,t,n);else if(t==="latest"||t==="*"||!t)t=await et(e,n);else if(e==="ziglang.org"&&t.endsWith("-dev")){let m=await Wr(t,n,{onRetry:r.onRetry});if(!m)throw Error(`Could not resolve ${t} to a published ziglang.org development build`);t=m}if(t=Lr(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(c.length===0)throw Error(`No binaries defined for ${e} on ${n.os}-${n.arch}`);let l=T.join(i,c[0]),g=T.join(i,"bin",c[0]);if(A.existsSync(l)||A.existsSync(g)){if(!r.quiet)console.log(` ✓ ${e}@${t} (cached)`);if(r.createBinLinks!==!1)_t(i,c,a,n);let m=Bt(i,c,n,r);return{name:e,version:t,installPath:i,binaries:c,globalLinks:m}}let u=e==="ziglang.org"&&t.includes("-dev.")?Gr(await Wt(e,{onRetry:r.onRetry}),t,n):null,p=u?.url??s.getDownloadUrl(t,n),h=u?.format??s.getArchiveFormat(n);if(!r.quiet)console.log(` → ${e}@${t} from ${new URL(p).hostname}`);let f=A.mkdtempSync(T.join(X.tmpdir(),"pantry-")),y=T.join(f,`archive.${h}`);try{let m;if(p.startsWith(`${Qe}/binaries/`)){let b=T.join(f,"archive.sha256");await Lt(`${p}.sha256`,b,{quiet:r.quiet,onRetry:r.onRetry});let P=A.readFileSync(b,"utf8").match(/\b([a-f0-9]{64})\b/i)?.[1];if(!P)throw Error(`Invalid SHA-256 checksum response for ${p}`);m=P.toLowerCase()}await Lt(p,y,{quiet:r.quiet,onRetry:r.onRetry,expectedSha256:m});let d=T.join(f,"extracted");A.mkdirSync(d,{recursive:!0}),await nn(y,d,h);let k=d,w=u?u.prefix:s.getArchivePrefix?.(t,n);if(w){let b=T.join(d,w);if(A.existsSync(b))k=b;else{let S=A.readdirSync(d).find((v)=>A.statSync(T.join(d,v)).isDirectory());if(S)k=T.join(d,S)}}if(A.mkdirSync(i,{recursive:!0}),sn(k,i),n.os!=="windows"){for(let b of c){let P=T.join(i,b);if(A.existsSync(P))A.chmodSync(P,493);let S=T.join(i,"bin",b);if(A.existsSync(S))A.chmodSync(S,493)}for(let b of["bin","sbin","libexec"])Yt(T.join(i,b))}if(r.createBinLinks!==!1)_t(i,c,a,n);if(!r.quiet)console.log(` ✓ ${e}@${t}`);let x=Bt(i,c,n,r);return{name:e,version:t,installPath:i,binaries:c,globalLinks:x}}finally{try{A.rmSync(f,{recursive:!0,force:!0})}catch{}}}function Bt(e,t,r,n){if(!n.globalBin)return[];let s=typeof n.globalBin==="string"?n.globalBin:Re();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 Ur(e,t={}){return Promise.all(e.map((r)=>Ut(r.domain,r.version,t)))}async function et(e,t=Ce()){if(zt(e)){let n=(await Y("https://api.github.com/repos/oven-sh/bun/releases/latest").catch(()=>null))?.tag_name?.replace(/^bun-v/,"")||"";if(n)return n;let s=await He(e);if(s)return s;throw Error("Failed to resolve latest bun.sh version (GitHub API unreachable, no bundled metadata)")}if(e==="ziglang.org"){let r=await rt(e,t);if(r.length>0)return r.sort(Je)[0];throw Error(`Failed to resolve a ziglang.org version published for ${tt(t)}`)}if(e==="nodejs.org"){let n=await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[],o=(n.find((i)=>i.lts)?.version||n[0]?.version||"").replace(/^v/,"");if(o)return o;let a=await He(e);if(a)return a;throw Error("Failed to resolve latest nodejs.org version")}if(e==="github.com/mail-os/mail"){let n=(await Y("https://api.github.com/repos/mail-os/mail/releases/latest").catch(()=>null))?.tag_name?.replace(/^v/,"")||"";if(n)return n;let o=((await Y("https://api.github.com/repos/mail-os/mail/tags?per_page=1").catch(()=>null))?.[0]?.name||"").replace(/^v/,"");if(o)return o;let a=await He(e);if(a)return a;throw Error("Failed to resolve latest github.com/mail-os/mail version")}throw Error(`Cannot resolve latest version for ${e}`)}async function He(e){try{let t=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:r}=await import("./chunk-74syf5ae.js").catch(()=>import("./src/index.js")),s=r[t]?.versions||[];return s.find((o)=>!o.includes("-"))||s[0]||""}catch{return""}}async function Wr(e,t,r={}){let s=(await rt("ziglang.org",t,r)).filter((i)=>i.startsWith(`${e}.`)).sort(Je)[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 tt(e){let t=e.arch==="aarch64"?"arm64":"x86-64";return`${e.os}-${t}`}function qr(e,t){let r=tt(t);return Object.entries(e?.versions||{}).filter(([,n])=>Object.hasOwn(n.platforms||{},r)).map(([n])=>n)}async function Wt(e,t={}){return await Y(`${Qe}/binaries/${encodeURI(e)}/metadata.json`,5,t).catch(()=>null)}async function rt(e,t,r={}){return qr(await Wt(e,r),t)}function Gr(e,t,r){if(!t.includes("-dev.")||!e)return null;let n=tt(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:`${Qe}/binaries/ziglang.org/${a}/${n}/ziglang.org-${a}.tar.gz`,format:"tar.gz",prefix:""}}function qt(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 $e(e){return e.split(/[+_-]/,1)[0].split(".").map((t)=>Number.parseInt(t,10))}function Gt(e,t){let r=$e(e),n=$e(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 Kr(e,t){let{operator:r,target:n}=t;if(e.includes("-")&&!n.includes("-"))return!1;let s=$e(e),o=$e(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=Gt(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 Hr(e,t){if(zt(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=Yr(r,t);if(n.length>0)return n;return await rt(e,t)}return[]}function Yr(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 Ye(e,t){return Gt(t,e)}function Jr(e,t){let r=qt(e);if(!r)return null;return[...new Set(t)].sort(Ye).find((n)=>Kr(n,r))||null}async function Zr(e,t,r){if(!qt(t))return et(e,r);let n;try{let i=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:c}=await import("./chunk-74syf5ae.js").catch(()=>import("./src/index.js"));n=c[i]?.versions||[]}catch{n=[]}let s=await Hr(e,r),o=e==="ziglang.org"?s.sort(Ye):[...new Set([...s,...n])].sort(Ye),a=Jr(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 Xr=4;function Ae(e){return e instanceof Error?e.message:String(e)}function Qr(e){if(typeof e==="object"&&e!==null&&"statusCode"in e){let r=Number(e.statusCode);if(Number.isFinite(r))return r}let t=Ae(e).match(/\bHTTP\s+(\d{3})\b/i);return t?Number(t[1]):void 0}function en(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 tn(e){let t=Qr(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(en(e)))return!0;return/socket hang up|connection reset|premature close|aborted|terminated|timed? ?out|temporar|stalled|incomplete download|checksum mismatch/i.test(Ae(e))}async function Kt(e,t,r={}){let n=r.maxAttempts??Xr,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,!tn(c))throw c;if(i===n)break;let l=Math.min(s*2**(i-1),1e4);r.onRetry?.(`${e} failed (${Ae(c)}); retrying in ${l}ms`),await o(l)}throw Error(`${e} failed after ${n} attempts: ${Ae(a)}`)}function Ht(e,t,r){return new Promise((n,s)=>{let a=(e.startsWith("https")?Ze.get:Xe.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 Ht(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 rn(e,t,r){let n=`${t}.part`;try{A.rmSync(n,{force:!0})}catch{}let s=await Ht(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?Mr("sha256"):void 0,u=new _r({transform(p,h,f){c+=p.length,g?.update(p);let y=Date.now();if(o&&y-l>200){l=y;let m=(c/1048576).toFixed(1);if(i>0){let d=(i/1048576).toFixed(1),k=Math.floor(c/i*100);process.stderr.write(`\r ${m}/${d} MB (${k}%)`)}else process.stderr.write(`\r ${m} MB`)}f(null,p)}});try{if(await Br(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 Lt(e,t,r={}){await Kt(`Download ${e}`,()=>rn(e,t,r),r)}async function nn(e,t,r){if(r==="zip")if(process.platform==="win32")ve("powershell",["-NoProfile","-Command","Expand-Archive","-Path",e,"-DestinationPath",t,"-Force"],{stdio:"pipe"});else ve("unzip",["-o","-q",e,"-d",t],{stdio:"pipe"});else if(r==="tar.xz")ve("tar",["xJf",e,"-C",t],{stdio:"pipe"});else if(r==="tar.gz")ve("tar",["xzf",e,"-C",t],{stdio:"pipe"});else throw Error(`Unsupported archive format: ${r}`)}function sn(e,t){A.cpSync(e,t,{recursive:!0})}function Yt(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()){Yt(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 Jt(e,t){return new Promise((r,n)=>{let s=e.startsWith("https")?Ze.get:Xe.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 Jt(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 Kt(`Fetch ${e}`,()=>Jt(e,t),r)}ce["bun.com"]=ce["bun.sh"];function on(e){return e in ce}function ei(){return Object.keys(ce)}function ti(e){let t=ce[e];if(!t)return;let r=Ce();return t.getBinaries(r)[0]}import*as L from"node:fs";import*as Ee from"node:os";import*as le from"node:path";var De="# >>> pantry shell-init >>>",Ie="# <<< pantry shell-init <<<";function Ne(){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 nt(e){let t=Ee.homedir();switch(e){case"zsh":{let r=process.env.ZDOTDIR;return le.join(r&&r.length>0?r:t,".zshrc")}case"bash":{if(Ee.platform()==="darwin"){let r=le.join(t,".bash_profile");if(L.existsSync(r))return r}return le.join(t,".bashrc")}case"fish":return le.join(t,".config","fish","config.fish");case"unknown":return null}}function Zt(e={}){let t=e.globalBin??Re();if((e.shell??Ne())==="fish")return[De,`if test -d "${t}"`,` set -gx PATH "${t}" $PATH`,"end",Ie,""].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 Gs(e,t="src/packages"){try{let r;if(e.includes("/"))r=Pe.join(t,`${e}.ts`);else{let g=`${e.replace(/\./g,"")}.ts`;r=Pe.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 Or(e){try{let{packages:t}=await import("./chunk-ara8pnq5.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 Or(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 Vr(r,n)||r[0]}function Vr(e,t){if(t.startsWith("^")){let r=t.slice(1),[n]=pe(r);return e.filter((o)=>{let[a]=pe(o);return a===n&&oe(o,r)>=0})[0]||null}if(t.startsWith("~")){let r=t.slice(1),[n,s]=pe(r);return e.filter((a)=>{let[i,c]=pe(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 pe(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]=pe(r),[i,c,l]=pe(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 xe=null;async function jr(){if(xe)return xe;return xe=(await import("./chunk-ara8pnq5.js").catch(()=>import("./src/index.js"))).packages,xe}async function Fr(e){try{let t=await jr(),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 Se(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):(.+)$/),m=!!y,d=y?y[2]:f,k=y?y[1]:void 0;if(m&&(!i||a&&k!==a))return null;let w=d,x="latest",b="*",P=d.match(/^(@?[^@^~>=<]+(?:\/[^@^~>=<]+)?)([@^~>=<].+)?$/);if(P){if(w=P[1],P[2]){let S=P[2];if(S.startsWith("@"))x=S.substring(1),b=S;else b=S,x=S.replace(/^\D*/,"")}}return{dep:{name:w,version:x,constraint:b,isOsSpecific:m,os:k},pkgName:w}},l=await Fr(e),p=[...l?.dependencies||[],...l?.companions||[]].map(g).filter((f)=>f!==null);for(let{dep:f}of p)c.push(f);let h=await Promise.allSettled(p.map(({pkgName:f})=>Se(f,t,r,n+1)));for(let f of h)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 Ge(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 h={...p,version:p.resolvedVersion};delete h.resolvedVersion,o.push(h),a.push(i)}return{allDependencies:o,uniquePackages:a,conflicts:n,osSpecificDeps:s}}async function Mt(e,t={}){let{verbose:r=!1}=t;if(r)console.log(`Parsing dependency file: ${e}`);let n=we(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 Se(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 Ge(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=Pe.extname(e);if(i===".yaml"||i===".yml"){let c=Nr(e);if(c.services)a.services=c.services}return a}function Ks(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=Pe.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 Ze from"node:https";import*as Xe from"node:http";import{execFileSync as ve}from"node:child_process";import{createHash as Mr}from"node:crypto";import{Transform as _r}from"node:stream";import{pipeline as Br}from"node:stream/promises";var Qe=(process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev").replace(/\/$/,"");function Lr(e,t){if(e!=="ziglang.org")return t;return t.replace(/(-dev\.\d+)\+([0-9A-Za-z-]+)$/,"$1_$2")}function Re(){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 Ce(){let e=X.platform(),t=X.arch();return{os:e==="darwin"?"darwin":e==="win32"?"windows":"linux",arch:t==="arm64"?"aarch64":"x86_64"}}function Ke(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 zr(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 zt(e){return e==="bun.sh"||e==="bun.com"}var ce={"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 Ke(e,t).url},getArchiveFormat(e){return Ke("0.0.0",e).format},getBinaries(e){return e.os==="windows"?["zig.exe"]:["zig"]},getArchivePrefix(e,t){return Ke(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 zr(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 _t(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 Ut(e,t,r={}){let n=r.platform||Ce(),s=ce[e];if(!s)throw Error(`Unknown package: ${e}. Supported: ${Object.keys(ce).join(", ")}`);if(/^[\^~>=<]/.test(t))t=await Zr(e,t,n);else if(t==="latest"||t==="*"||!t)t=await et(e,n);else if(e==="ziglang.org"&&t.endsWith("-dev")){let m=await Wr(t,n,{onRetry:r.onRetry});if(!m)throw Error(`Could not resolve ${t} to a published ziglang.org development build`);t=m}if(t=Lr(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(c.length===0)throw Error(`No binaries defined for ${e} on ${n.os}-${n.arch}`);let l=T.join(i,c[0]),g=T.join(i,"bin",c[0]);if(A.existsSync(l)||A.existsSync(g)){if(!r.quiet)console.log(` ✓ ${e}@${t} (cached)`);if(r.createBinLinks!==!1)_t(i,c,a,n);let m=Bt(i,c,n,r);return{name:e,version:t,installPath:i,binaries:c,globalLinks:m}}let u=e==="ziglang.org"&&t.includes("-dev.")?Gr(await Wt(e,{onRetry:r.onRetry}),t,n):null,p=u?.url??s.getDownloadUrl(t,n),h=u?.format??s.getArchiveFormat(n);if(!r.quiet)console.log(` → ${e}@${t} from ${new URL(p).hostname}`);let f=A.mkdtempSync(T.join(X.tmpdir(),"pantry-")),y=T.join(f,`archive.${h}`);try{let m;if(p.startsWith(`${Qe}/binaries/`)){let b=T.join(f,"archive.sha256");await Lt(`${p}.sha256`,b,{quiet:r.quiet,onRetry:r.onRetry});let P=A.readFileSync(b,"utf8").match(/\b([a-f0-9]{64})\b/i)?.[1];if(!P)throw Error(`Invalid SHA-256 checksum response for ${p}`);m=P.toLowerCase()}await Lt(p,y,{quiet:r.quiet,onRetry:r.onRetry,expectedSha256:m});let d=T.join(f,"extracted");A.mkdirSync(d,{recursive:!0}),await nn(y,d,h);let k=d,w=u?u.prefix:s.getArchivePrefix?.(t,n);if(w){let b=T.join(d,w);if(A.existsSync(b))k=b;else{let S=A.readdirSync(d).find((v)=>A.statSync(T.join(d,v)).isDirectory());if(S)k=T.join(d,S)}}if(A.mkdirSync(i,{recursive:!0}),sn(k,i),n.os!=="windows"){for(let b of c){let P=T.join(i,b);if(A.existsSync(P))A.chmodSync(P,493);let S=T.join(i,"bin",b);if(A.existsSync(S))A.chmodSync(S,493)}for(let b of["bin","sbin","libexec"])Yt(T.join(i,b))}if(r.createBinLinks!==!1)_t(i,c,a,n);if(!r.quiet)console.log(` ✓ ${e}@${t}`);let x=Bt(i,c,n,r);return{name:e,version:t,installPath:i,binaries:c,globalLinks:x}}finally{try{A.rmSync(f,{recursive:!0,force:!0})}catch{}}}function Bt(e,t,r,n){if(!n.globalBin)return[];let s=typeof n.globalBin==="string"?n.globalBin:Re();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 Ur(e,t={}){return Promise.all(e.map((r)=>Ut(r.domain,r.version,t)))}async function et(e,t=Ce()){if(zt(e)){let n=(await Y("https://api.github.com/repos/oven-sh/bun/releases/latest").catch(()=>null))?.tag_name?.replace(/^bun-v/,"")||"";if(n)return n;let s=await He(e);if(s)return s;throw Error("Failed to resolve latest bun.sh version (GitHub API unreachable, no bundled metadata)")}if(e==="ziglang.org"){let r=await rt(e,t);if(r.length>0)return r.sort(Je)[0];throw Error(`Failed to resolve a ziglang.org version published for ${tt(t)}`)}if(e==="nodejs.org"){let n=await Y("https://nodejs.org/dist/index.json").catch(()=>null)||[],o=(n.find((i)=>i.lts)?.version||n[0]?.version||"").replace(/^v/,"");if(o)return o;let a=await He(e);if(a)return a;throw Error("Failed to resolve latest nodejs.org version")}if(e==="github.com/mail-os/mail"){let n=(await Y("https://api.github.com/repos/mail-os/mail/releases/latest").catch(()=>null))?.tag_name?.replace(/^v/,"")||"";if(n)return n;let o=((await Y("https://api.github.com/repos/mail-os/mail/tags?per_page=1").catch(()=>null))?.[0]?.name||"").replace(/^v/,"");if(o)return o;let a=await He(e);if(a)return a;throw Error("Failed to resolve latest github.com/mail-os/mail version")}throw Error(`Cannot resolve latest version for ${e}`)}async function He(e){try{let t=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:r}=await import("./chunk-ara8pnq5.js").catch(()=>import("./src/index.js")),s=r[t]?.versions||[];return s.find((o)=>!o.includes("-"))||s[0]||""}catch{return""}}async function Wr(e,t,r={}){let s=(await rt("ziglang.org",t,r)).filter((i)=>i.startsWith(`${e}.`)).sort(Je)[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 tt(e){let t=e.arch==="aarch64"?"arm64":"x86-64";return`${e.os}-${t}`}function qr(e,t){let r=tt(t);return Object.entries(e?.versions||{}).filter(([,n])=>Object.hasOwn(n.platforms||{},r)).map(([n])=>n)}async function Wt(e,t={}){return await Y(`${Qe}/binaries/${encodeURI(e)}/metadata.json`,5,t).catch(()=>null)}async function rt(e,t,r={}){return qr(await Wt(e,r),t)}function Gr(e,t,r){if(!t.includes("-dev.")||!e)return null;let n=tt(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:`${Qe}/binaries/ziglang.org/${a}/${n}/ziglang.org-${a}.tar.gz`,format:"tar.gz",prefix:""}}function qt(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 $e(e){return e.split(/[+_-]/,1)[0].split(".").map((t)=>Number.parseInt(t,10))}function Gt(e,t){let r=$e(e),n=$e(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 Kr(e,t){let{operator:r,target:n}=t;if(e.includes("-")&&!n.includes("-"))return!1;let s=$e(e),o=$e(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=Gt(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 Hr(e,t){if(zt(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=Yr(r,t);if(n.length>0)return n;return await rt(e,t)}return[]}function Yr(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 Ye(e,t){return Gt(t,e)}function Jr(e,t){let r=qt(e);if(!r)return null;return[...new Set(t)].sort(Ye).find((n)=>Kr(n,r))||null}async function Zr(e,t,r){if(!qt(t))return et(e,r);let n;try{let i=e.replace(/[^a-z0-9]/gi,"").toLowerCase(),{packages:c}=await import("./chunk-ara8pnq5.js").catch(()=>import("./src/index.js"));n=c[i]?.versions||[]}catch{n=[]}let s=await Hr(e,r),o=e==="ziglang.org"?s.sort(Ye):[...new Set([...s,...n])].sort(Ye),a=Jr(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 Xr=4;function Ae(e){return e instanceof Error?e.message:String(e)}function Qr(e){if(typeof e==="object"&&e!==null&&"statusCode"in e){let r=Number(e.statusCode);if(Number.isFinite(r))return r}let t=Ae(e).match(/\bHTTP\s+(\d{3})\b/i);return t?Number(t[1]):void 0}function en(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 tn(e){let t=Qr(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(en(e)))return!0;return/socket hang up|connection reset|premature close|aborted|terminated|timed? ?out|temporar|stalled|incomplete download|checksum mismatch/i.test(Ae(e))}async function Kt(e,t,r={}){let n=r.maxAttempts??Xr,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,!tn(c))throw c;if(i===n)break;let l=Math.min(s*2**(i-1),1e4);r.onRetry?.(`${e} failed (${Ae(c)}); retrying in ${l}ms`),await o(l)}throw Error(`${e} failed after ${n} attempts: ${Ae(a)}`)}function Ht(e,t,r){return new Promise((n,s)=>{let a=(e.startsWith("https")?Ze.get:Xe.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 Ht(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 rn(e,t,r){let n=`${t}.part`;try{A.rmSync(n,{force:!0})}catch{}let s=await Ht(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?Mr("sha256"):void 0,u=new _r({transform(p,h,f){c+=p.length,g?.update(p);let y=Date.now();if(o&&y-l>200){l=y;let m=(c/1048576).toFixed(1);if(i>0){let d=(i/1048576).toFixed(1),k=Math.floor(c/i*100);process.stderr.write(`\r ${m}/${d} MB (${k}%)`)}else process.stderr.write(`\r ${m} MB`)}f(null,p)}});try{if(await Br(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 Lt(e,t,r={}){await Kt(`Download ${e}`,()=>rn(e,t,r),r)}async function nn(e,t,r){if(r==="zip")if(process.platform==="win32")ve("powershell",["-NoProfile","-Command","Expand-Archive","-Path",e,"-DestinationPath",t,"-Force"],{stdio:"pipe"});else ve("unzip",["-o","-q",e,"-d",t],{stdio:"pipe"});else if(r==="tar.xz")ve("tar",["xJf",e,"-C",t],{stdio:"pipe"});else if(r==="tar.gz")ve("tar",["xzf",e,"-C",t],{stdio:"pipe"});else throw Error(`Unsupported archive format: ${r}`)}function sn(e,t){A.cpSync(e,t,{recursive:!0})}function Yt(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()){Yt(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 Jt(e,t){return new Promise((r,n)=>{let s=e.startsWith("https")?Ze.get:Xe.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 Jt(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 Kt(`Fetch ${e}`,()=>Jt(e,t),r)}ce["bun.com"]=ce["bun.sh"];function on(e){return e in ce}function ei(){return Object.keys(ce)}function ti(e){let t=ce[e];if(!t)return;let r=Ce();return t.getBinaries(r)[0]}import*as L from"node:fs";import*as Ee from"node:os";import*as le from"node:path";var De="# >>> pantry shell-init >>>",Ie="# <<< pantry shell-init <<<";function Ne(){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 nt(e){let t=Ee.homedir();switch(e){case"zsh":{let r=process.env.ZDOTDIR;return le.join(r&&r.length>0?r:t,".zshrc")}case"bash":{if(Ee.platform()==="darwin"){let r=le.join(t,".bash_profile");if(L.existsSync(r))return r}return le.join(t,".bashrc")}case"fish":return le.join(t,".config","fish","config.fish");case"unknown":return null}}function Zt(e={}){let t=e.globalBin??Re();if((e.shell??Ne())==="fish")return[De,`if test -d "${t}"`,` set -gx PATH "${t}" $PATH`,"end",Ie,""].join(`
|
|
8
8
|
`);return[De,`if [ -d "${t}" ] && [[ ":$PATH:" != *":${t}:"* ]]; then`,` export PATH="${t}:$PATH"`,"fi",Ie,""].join(`
|
|
9
9
|
`)}function an(e={}){let t=e.shell??Ne(),r=nt(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=Zt({...e,shell:t}),s="";if(L.existsSync(r)){if(s=L.readFileSync(r,"utf-8"),s.includes(De))return{rcFile:r,shell:t,changed:!1}}else L.mkdirSync(le.dirname(r),{recursive:!0});let o=s.length>0&&!s.endsWith(`
|
|
10
10
|
`)?`
|