ts-pantry 0.11.38 → 0.11.39
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 +50 -59
- package/dist/chunk-2vc7kdam.js +1 -0
- package/dist/chunk-3dbeqd3c.js +315 -0
- package/dist/{chunk-gqzj0edb.js → chunk-415b756j.js} +2 -2
- package/dist/chunk-5y7jxjtz.js +42 -0
- package/dist/chunk-7qhxan0b.js +1 -0
- package/dist/chunk-7tw8z583.js +1 -0
- package/dist/chunk-8rg91cqd.js +2 -0
- package/dist/chunk-92zrwkxc.js +1 -0
- package/dist/{chunk-6zb03z2q.js → chunk-a20hctx6.js} +1 -1
- package/dist/chunk-afzfbcrx.js +3 -0
- package/dist/chunk-agh1vkqm.js +11 -0
- package/dist/chunk-btrd677x.js +1 -0
- package/dist/chunk-gr5aqxxx.js +1 -0
- package/dist/{chunk-gzwcsenc.js → chunk-hxd34yh9.js} +2 -2
- package/dist/chunk-k004pgye.js +1 -0
- package/dist/chunk-nfdg722p.js +141 -0
- package/dist/chunk-p763mye8.js +2 -0
- package/dist/{chunk-cye3q2ph.js → chunk-rqny4g8r.js} +2 -2
- package/dist/chunk-tp1d7cq1.js +2 -0
- package/dist/chunk-w55vdzzf.js +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/installer.d.ts +0 -3
- package/dist/src/packages/anthropic.com/claude-code.d.ts +2 -2
- package/dist/src/packages/apps/bitwardencom.d.ts +1 -1
- 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/diabrowsercom.d.ts +1 -1
- package/dist/src/packages/apps/obsidianmd.d.ts +2 -2
- package/dist/src/packages/apps/rectangleapp.d.ts +1 -1
- package/dist/src/packages/apps/whatsappcom.d.ts +1 -1
- package/dist/src/packages/argoproj.github.io/workflows.d.ts +3 -3
- package/dist/src/packages/arkadedev.d.ts +3 -3
- package/dist/src/packages/buncom.d.ts +3 -3
- package/dist/src/packages/casdoororg.d.ts +3 -3
- package/dist/src/packages/changiedev.d.ts +1 -1
- package/dist/src/packages/circlecicom.d.ts +1 -1
- package/dist/src/packages/cligithubcom.d.ts +1 -1
- package/dist/src/packages/codercom.d.ts +1 -1
- package/dist/src/packages/craft-native.org.d.ts +1 -1
- package/dist/src/packages/cythonorg.d.ts +3 -3
- package/dist/src/packages/depotdev.d.ts +3 -3
- package/dist/src/packages/dprintdev.d.ts +3 -3
- package/dist/src/packages/flyio.d.ts +1 -1
- package/dist/src/packages/fonts/jetbrainsmononerdfont.d.ts +1 -1
- package/dist/src/packages/fonts/meslolgnerdfont.d.ts +1 -1
- package/dist/src/packages/getzolaorg.d.ts +1 -1
- package/dist/src/packages/github.com/chainguard-dev/apko.d.ts +1 -1
- package/dist/src/packages/github.com/ggerganov/llama.cpp.d.ts +3 -3
- package/dist/src/packages/github.com/mail-os/mail.d.ts +1 -1
- package/dist/src/packages/github.com/router-for-me/CLIProxyAPI.d.ts +3 -3
- package/dist/src/packages/github.com/tw93/mole.d.ts +3 -3
- package/dist/src/packages/index.d.ts +2 -0
- package/dist/src/packages/libgeosorg.d.ts +1 -1
- package/dist/src/packages/llmdatasetteio.d.ts +3 -3
- package/dist/src/packages/localaiio.d.ts +1 -1
- package/dist/src/packages/mailpitaxllentorg.d.ts +3 -3
- package/dist/src/packages/materializecom.d.ts +1 -1
- package/dist/src/packages/misejdxdev.d.ts +1 -1
- package/dist/src/packages/ollamaai.d.ts +1 -1
- package/dist/src/packages/openai.com/codex.d.ts +1 -1
- package/dist/src/packages/opencodeai.d.ts +3 -3
- package/dist/src/packages/openexrcom.d.ts +3 -3
- package/dist/src/packages/openshiftcom.d.ts +3 -3
- package/dist/src/packages/pipenvpypaio.d.ts +1 -1
- package/dist/src/packages/planetscalecom.d.ts +3 -3
- package/dist/src/packages/postgrestorg.d.ts +3 -3
- package/dist/src/packages/projenio.d.ts +3 -3
- package/dist/src/packages/protobufdev.d.ts +1 -1
- package/dist/src/packages/railwayapp.d.ts +3 -3
- package/dist/src/packages/rubygemsorg.d.ts +1 -1
- package/dist/src/packages/runatlantisio.d.ts +1 -1
- package/dist/src/packages/seaweedfscom.d.ts +3 -3
- package/dist/src/packages/stripecom.d.ts +3 -3
- package/dist/src/packages/tailscalecom.d.ts +1 -1
- package/dist/src/packages/valesh.d.ts +1 -1
- package/dist/src/packages/wasmerio.d.ts +3 -3
- package/dist/src/packages/watchexecgithubio.d.ts +3 -3
- package/dist/src/packages/zarfdev.d.ts +1 -1
- package/dist/src/packages/ziglangorg.d.ts +3 -3
- package/dist/src/testing/index.js +1 -1
- package/dist/src/utils.d.ts +11 -0
- package/package.json +2 -2
- package/dist/chunk-1d97zpdr.js +0 -141
- package/dist/chunk-2e5b7mwg.js +0 -1
- package/dist/chunk-3981va6j.js +0 -2
- package/dist/chunk-3h7dfjr4.js +0 -1
- package/dist/chunk-4dmq776q.js +0 -42
- package/dist/chunk-4pgde91f.js +0 -3
- package/dist/chunk-aa72n836.js +0 -1
- package/dist/chunk-btvyp7sq.js +0 -1
- package/dist/chunk-dg3m62qj.js +0 -313
- package/dist/chunk-fndnz9td.js +0 -1
- package/dist/chunk-g0fyaqj2.js +0 -1
- package/dist/chunk-hh0g2d6f.js +0 -11
- package/dist/chunk-k9awpjtg.js +0 -1
- package/dist/chunk-r2x07fgr.js +0 -2
- package/dist/chunk-rq61h9w2.js +0 -1
- package/dist/chunk-sdd8tnwv.js +0 -2
package/dist/bin/cli.js
CHANGED
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{E as
|
|
2
|
+
import{E as Ie,L as Oe,M as ie,O as re,Qa as Me,Ra as Re,S as oe,Ta as Le,Wa as Ve,Ya as Fe,bb as ze,cb as We,db as Ue,ga as Ee,ha as Te,ia as Ae,ja as _e,ka as Pe,oa as ae,pa as Be,qa as Ne}from"../chunk-3dbeqd3c.js";import"../chunk-nfdg722p.js";import"../chunk-afzfbcrx.js";import"../chunk-w55vdzzf.js";import{Ib as U,Jb as je,Lb as se,Mb as G,Rb as De,Vb as ne}from"../chunk-5y7jxjtz.js";import"../chunk-415b756j.js";import"../chunk-agh1vkqm.js";import{mc as W,nc as ee,oc as te}from"../chunk-rqny4g8r.js";import"../chunk-p763mye8.js";import"../chunk-8rg91cqd.js";import{Kc as Ce,Lc as zt}from"../chunk-hxd34yh9.js";import{Pc as N}from"../chunk-a20hctx6.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
|
-
${this.stack}`;return this.message}}function
|
|
6
|
-
`);let
|
|
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(`
|
|
6
|
+
`);let h=Array.from(c.keys()).sort();for(let f of h){let m=c.get(f);if(g.length>0)g+=`
|
|
7
7
|
|
|
8
|
-
`;
|
|
9
|
-
`,
|
|
10
|
-
`)}
|
|
11
|
-
`)})}let
|
|
12
|
-
`)})}if(this.examples.length>0)
|
|
13
|
-
`)});if(
|
|
14
|
-
${
|
|
8
|
+
`;g+=` ${f}:
|
|
9
|
+
`,g+=m.map((I)=>` ${K(I.rawName,o.length-2)} ${I.description}`).join(`
|
|
10
|
+
`)}r.push({title:"Commands",body:g}),r.push({title:"For more info, run any command with the `--help` flag",body:t.map((f)=>` $ ${e}${f.displayName===""?"":` ${f.displayName}`} --help`).join(`
|
|
11
|
+
`)})}let l=this.isGlobalCommand?n:[...this.options,...n||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)l=l.filter((o)=>o.name!=="version");if(l.length>0){let o=de(l.map((c)=>c.rawName));r.push({title:"Options",body:l.map((c)=>` ${K(c.rawName,o.length)} ${c.description} ${c.config.default===void 0?"":`(default: ${c.config.default})`}`).join(`
|
|
12
|
+
`)})}if(this.examples.length>0)r.push({title:"Examples",body:this.examples.map((o)=>{if(typeof o==="function")return o(e);return o}).join(`
|
|
13
|
+
`)});if(i)r=i(r)||r;console.log(r.map((o)=>o.title?`${o.title}:
|
|
14
|
+
${o.body}`:o.body).join(`
|
|
15
15
|
|
|
16
|
-
`))}outputVersion(){let{name:
|
|
16
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.log(`${e}/${t} ${typeof Bun<"u"?it:rt}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e){let s=this.args.filter((i)=>i.required).slice(this.cli.args.length),n=s.map((i)=>`<${i.value}>`).join(" ");throw new V(`Missing required argument${s.length>1?"s":""}: ${n}
|
|
17
17
|
|
|
18
|
-
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`)}}checkUnknownOptions(){let{options:
|
|
18
|
+
Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`)}}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let s of Object.keys(e))if(s!=="--"&&!this.hasOption(s)&&!t.hasOption(s)){let i=[...t.options,...this.options].flatMap((o)=>o.names),r=s.length>1?`--${s}`:`-${s}`,a=$e(s,i),l=`Unknown option \`${r}\``;if(a.length>0)l+=`
|
|
19
19
|
|
|
20
|
-
Did you mean one of these?`,
|
|
21
|
-
• ${
|
|
20
|
+
Did you mean one of these?`,a.forEach((o)=>{let c=o.length>1?`--${o}`:`-${o}`;l+=`
|
|
21
|
+
• ${c}`});throw l+=`
|
|
22
22
|
|
|
23
|
-
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new
|
|
23
|
+
Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new V(l)}}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,s=[...t.options,...this.options];for(let n of s){let i=e[n.name.split(".")[0]];if(n.required){let r=s.some((a)=>a.negated&&a.names.includes(n.name));if(i===!0||i===!1&&!r)throw new V(`Option \`${n.rawName}\` requires a value.
|
|
24
24
|
|
|
25
|
-
Example: ${this.cli.name} ${this.rawName} ${
|
|
25
|
+
Example: ${this.cli.name} ${this.rawName} ${n.rawName} <value>`)}}}}class X extends Z{constructor(e){super("@@global@@","",{},e)}}var ot=Z,D={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var M={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function at(){return!0}function lt(){let e={};e.supportsColor=at();function t(n,i=[]){let r=n===""?[]:[...i,n],a=function(o){if(!e.supportsColor)return o;let c="",p="";for(let g of r)if(g in M&&M[g]in D){let h=M[g];c+=D[h][0],p=D[h][1]+p}else if(g in D)c+=D[g][0],p=D[g][1]+p;return c+o+p},l=[...Object.keys(D),...Object.keys(M)];for(let o of l)if(!(o in a))Object.defineProperty(a,o,{get(){return t(o,r)}});return a}let s=[...Object.keys(D),...Object.keys(M)];for(let n of s)if(!(n in e))Object.defineProperty(e,n,{get(){return t(n)}});return e}var R=lt();class Q extends Ke{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(e=""){super();this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new X(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let t=async(s)=>{if(console.log(`
|
|
26
26
|
|
|
27
|
-
Received ${
|
|
28
|
-
✗ Command "${
|
|
29
|
-
`)),this.enableDidYouMean){let
|
|
30
|
-
Run \`${this.name??"cli"} --help\` for usage.`;
|
|
31
|
-
`),
|
|
32
|
-
`),Z=$.split(`
|
|
33
|
-
`),Y=[];for(let q=0;q<Math.max(Q.length,Z.length);q++)if(Q[q]!==Z[q])Y.push(q);return Y}var S4=cz.platform.startsWith("win"),B6=Symbol("clapp:cancel");function m(z,$){let Q=z;if(Q.isTTY)Q.setRawMode($)}function az(z){return z.replace(/\x1b\[[0-9;]*m/g,"")}function sz(z){return az(z).length}function b6(z,$,Q){if(!$||$<1)return z;let Z=Q?.hard??!1,Y=Q?.trim??!0,q=z.split(`
|
|
34
|
-
`),X=[];for(let U of q){if(sz(U)<=$){X.push(Y?U.trimEnd():U);continue}if(Z){let J="",G=0,V=0;while(V<U.length){let W=U.slice(V).match(/^\x1b\[[0-9;]*m/);if(W){J+=W[0],V+=W[0].length;continue}if(G>=$)X.push(Y?J.trimEnd():J),J="",G=0;J+=U[V],G++,V++}if(J)X.push(Y?J.trimEnd():J)}else X.push(Y?U.trimEnd():U)}return X.join(`
|
|
35
|
-
`)}class Y6{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;_manualLine="";state="initial";error="";value;userInput="";constructor(z,$=!0){let{input:Q=nz,output:Z=pz,render:Y,signal:q,...X}=z;this.opts=X,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=$,this._abortSignal=q,this.input=Q,this.output=Z}unsubscribe(){this._subscribers.clear()}setSubscriber(z,$){let Q=this._subscribers.get(z)??[];Q.push($),this._subscribers.set(z,Q)}on(z,$){return this.setSubscriber(z,{cb:$}),this}once(z,$){return this.setSubscriber(z,{cb:$,once:!0}),this}emit(z,...$){let Q=this._subscribers.get(z)??[],Z=[];for(let Y of Q)if(Y.cb(...$),Y.once)Z.push(()=>Q.splice(Q.indexOf(Y),1));for(let Y of Z)Y();return this}prompt(){return new Promise((z)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),z(B6);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}if(this.rl=rz.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0)this._setUserInput(this.opts.initialUserInput,!0);this.input.on("keypress",this.onKeypress),m(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(S.show),this.output.off("resize",this.render),m(this.input,!1),z(this.value)}),this.once("cancel",()=>{this.output.write(S.show),this.output.off("resize",this.render),m(this.input,!1),z(B6)})})}_isActionKey(z,$){return z==="\t"}_setValue(z){this.value=z,this.emit("value",this.value)}_setUserInput(z,$){if(this.userInput=z??"",this.emit("userInput",this.userInput),$&&this._track&&this.rl)this.rl.write(this.userInput),this._cursor=this.rl.cursor}onKeypress(z,$){if(this._track&&$.name!=="return"){if($.name&&this._isActionKey(z,$))this.rl?.write(null,{ctrl:!0,name:"h"});this._cursor=this.rl?.cursor??0;let Q=$.name==="tab"||$.name==="escape"||$.name==="backspace"||$.name==="delete"||$.name==="enter"||$.name==="return"||$.name&&["up","down","left","right"].includes($.name);if(z&&!Q&&z.length===1&&z>=" ")this._manualLine+=z;else if($.name==="backspace"&&this._manualLine.length>0)this._manualLine=this._manualLine.slice(0,-1);let Z=this._manualLine.length>=(this.rl?.line?.length||0)?this._manualLine:this.rl?.line;this._setUserInput(Z)}if(this.state==="error")this.state="active",this.error="";if($?.name){if(!this._track&&i.aliases.has($.name))this.emit("cursor",i.aliases.get($.name));if(i.actions.has($.name))this.emit("cursor",$.name)}if(z&&(z.toLowerCase()==="y"||z.toLowerCase()==="n"))this.emit("confirm",z.toLowerCase()==="y");if(this.emit("key",z?.toLowerCase(),$),$?.name==="return"){if(this.opts.validate){let Q=this.opts.validate(this.value);if(Q)this.error=Q instanceof Error?Q.message:Q,this.state="error"}if(this.state!=="error")this.state="submit"}if(A6([z,$?.name,$?.sequence],"cancel"))this.state="cancel";if(this.state==="submit"||this.state==="cancel")this.emit("finalize");if(this.render(),this.state==="submit"||this.state==="cancel")this.close()}close(){if(this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
36
|
-
`),m(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.state==="cancel")setTimeout(()=>{this.unsubscribe()},10);else this.unsubscribe()}restoreCursor(){let z=b6(this._prevFrame,N6.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
37
|
-
`).length-1;this.output.write(S.move(-999,z*-1))}render(){let z=b6(this._render(this)??"",N6.stdout.columns,{hard:!0,trim:!1});if(z===this._prevFrame)return;if(this.state==="initial")this.output.write(S.hide);else{let $=lz(this._prevFrame,z);if(this.restoreCursor(),$&&$?.length===1){let Q=$[0];this.output.write(S.move(0,Q)),this.output.write(o.lines(1));let Z=z.split(`
|
|
38
|
-
`);this.output.write(Z[Q]),this._prevFrame=z,this.output.write(S.move(0,Z.length-Q-1));return}if($&&$?.length>1){let Q=$[0];this.output.write(S.move(0,Q)),this.output.write(o.down());let Y=z.split(`
|
|
39
|
-
`).slice(Q);this.output.write(Y.join(`
|
|
40
|
-
`)),this._prevFrame=z;return}this.output.write(o.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function tz(z,$){if(z===void 0)return 0;if($.length===0)return 0;let Z=$.findIndex((Y)=>Y.value===z);return Z!==-1?Z:0}function oz(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function ez(z,$){if(!$)return;if(z)return $;return $[0]}class z4 extends Y6{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#Q="";#Z;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return c.inverse(c.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let z=this.userInput.slice(0,this._cursor),[$,...Q]=this.userInput.slice(this._cursor);return`${z}${c.inverse($)}${Q.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(z){super(z);this.#$=z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=z.multiple===!0,this.#Z=z.filter??oz;let Q;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)Q=z.initialValue;else Q=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)Q=[this.options[0].value];if(Q)for(let Z of Q){let Y=$.findIndex((q)=>q.value===Z);if(Y!==-1)this.toggleSelected(Z),this.#z=Y}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Z,Y)=>this.#Y(Z,Y)),this.on("userInput",(Z)=>this.#q(Z))}_isActionKey(z,$){return z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&z!==void 0&&z!==""}#Y(z,$){let Q=$.name==="up",Z=$.name==="down",Y=$.name==="return";if(Q||Z){if(this.#z=Math.max(0,Math.min(this.#z+(Q?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Y)this.value=ez(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter(($)=>$!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#q(z){if(z!==this.#Q){this.#Q=z;let $=this.options;if(z)this.filteredOptions=$.filter((Q)=>this.#Z(z,Q));else this.filteredOptions=[...$];if(this.#z=tz(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class $4 extends Y6{options;cursor=0;#z;getGroupItems(z){return this.options.filter(($)=>$.group===z)}isGroupSelected(z){let $=this.getGroupItems(z),Q=this.value;if(Q===void 0)return!1;return $.every((Z)=>Q.includes(Z.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let $=String(z.value),Q=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Z)=>Q.findIndex((Y)=>Y.value===Z)===-1);else this.value=[...this.value,...Q.map((Z)=>Z.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(z.value);this.value=$?this.value.filter((Q)=>Q!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:$}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([Q,Z])=>[{value:Q,group:!0,label:Q},...Z.map((Y)=>({...Y,group:Q}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===z.cursorAt),this.#z?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var Q4=jz();var b=(z,$)=>Q4?z:$,k4=b("◆","*"),h4=b("■","x"),_4=b("▲","x"),g4=b("◇","o"),f4=b("┌","T"),Z4=b("│","|"),m4=b("└","—"),d4=b("●",">"),u4=b("○"," "),c4=b("◻","[•]"),i4=b("◼","[+]"),l4=b("◻","[ ]"),n4=b("▪","•"),p4=b("─","-"),r4=b("╮","+"),a4=b("├","+"),s4=b("╯","+"),t4=b("●","•"),o4=b("◆","*"),e4=b("▲","!"),z0=b("■","x");var $0={light:b("─","-"),heavy:b("━","="),block:b("█","#")};function Y4(){return`${c.gray(Z4)} `}var Q0=Y4();var P6="0.11.38";J4();async function X4(z="src/pantry"){if(!H.existsSync(z))throw Error(`Pantry directory not found: ${z}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let $=[];function Q(Z,Y=""){let q=H.readdirSync(Z,{withFileTypes:!0}),X=w.join(Z,"package.yml");if(Y&&H.existsSync(X))$.push(Y);for(let U of q)if(U.isDirectory()&&!U.name.startsWith(".")){let J=Y?`${Y}/${U.name}`:U.name,G=w.join(Z,U.name);Q(G,J)}}return Q(z),console.log(`\uD83D\uDCE6 Found ${$.length} packages in local pantry`),$.sort()}async function U4(z=!1){async function $(X){let U=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(U.searchParams.set("list-type","2"),U.searchParams.set("prefix",""),U.searchParams.set("max-keys","1000"),X)U.searchParams.set("continuation-token",X);let J=await fetch(U.toString());if(!J.ok)throw Error(`Failed to fetch S3 listing: ${J.status}`);let G=await J.text(),V=[],W=G.match(/<Key>([^<]+)<\/Key>/g);if(W)for(let E of W){let x=E.replace(/<Key>([^<]+)<\/Key>/,"$1");V.push({Key:x})}let K=G.includes("<IsTruncated>true</IsTruncated>"),F=G.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),L=F?F[1]:void 0;return{IsTruncated:K,NextContinuationToken:L,Contents:V}}console.log("Scraping packages from S3 registry...");let Q=new Set,Z;do{let X=await $(Z);for(let U of X.Contents){let J=U.Key,G=J.split("/");if(G.length===0)continue;if(G[0].startsWith(".")||G[0].includes(" ")||J.match(/\.(md|txt|yml|yaml|json)$/i))continue;let V=["darwin","linux","windows"],W=-1;for(let K=1;K<G.length;K++)if(V.includes(G[K])){W=K;break}if(W>0){let K=G.slice(0,W).join("/");if(K.includes("."))Q.add(K)}else if(G.length>=2&&G[0].includes(".")&&!G[1].startsWith("v")&&!G[1].match(/^\d/)){let K=`${G[0]}/${G[1]}`;Q.add(K)}else if(G.length>=1&&G[0].includes("."))Q.add(G[0])}Z=X.NextContinuationToken,console.log(`Found ${Q.size} packages so far...`)}while(Z);let Y=Array.from(Q).sort(),q=[];for(let X of Y){if(!X.includes(".")||X.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(X.endsWith("/README.rst")||X.endsWith("/README")||X.includes("/docs/"))continue;if(X.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(X))continue;q.push(X)}return console.log(`\uD83D\uDCE6 Found ${q.length} valid packages in registry`),q}async function G4(z,$){let Z=`/**
|
|
27
|
+
Received ${s}, cleaning up...`),e)try{await e()}catch(n){console.error("Error during cleanup:",n)}j.exit(0)};return j.on("SIGINT",()=>t("SIGINT")),j.on("SIGTERM",()=>t("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(e=!0){return this.enableDidYouMean=e,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(e){return this.globalCommand.usage(e),this}command(e,t,s){if(!s)s={};let n=new ot(e,t||"",s,this);return n.globalCommand=this.globalCommand,this.commands.push(n),n}option(e,t,s){return this.globalCommand.option(e,t,s),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},s,n){if(this.args=e,this.options=t,s)this.matchedCommand=s;if(n)this.matchedCommandName=n;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(e){if(console.log(R.red(`
|
|
28
|
+
✗ Command "${e}" not found.
|
|
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
|
+
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.39";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=`/**
|
|
41
32
|
* Constants used throughout the ts-pantry package
|
|
42
|
-
* This file is auto-generated from ${
|
|
33
|
+
* This file is auto-generated from ${t}. Do not edit manually.
|
|
43
34
|
* Generated on ${new Date().toISOString()}
|
|
44
35
|
*/
|
|
45
36
|
|
|
@@ -83,36 +74,36 @@ export const PACKAGE_ALIASES: Record<string, string> = {
|
|
|
83
74
|
} as const
|
|
84
75
|
|
|
85
76
|
/**
|
|
86
|
-
* List of all known packages (${
|
|
77
|
+
* List of all known packages (${e.length} total)
|
|
87
78
|
*/
|
|
88
79
|
export const ALL_KNOWN_PACKAGES: readonly string[] = [
|
|
89
|
-
${
|
|
80
|
+
${e.map((i)=>` '${i}',`).join(`
|
|
90
81
|
`)}
|
|
91
82
|
] as const
|
|
92
|
-
`;
|
|
93
|
-
Received ${
|
|
94
|
-
Downloading props files from pkgx/pantry GitHub repo...`);let
|
|
95
|
-
Total packages: ${
|
|
83
|
+
`;d.writeFileSync("src/consts.ts",n,"utf-8")}function qt(e){if(!e)return;let s=e.toLowerCase().replace(/_/g,"-").match(/^(darwin|macos|linux|windows|win32)-(x86-64|x64|amd64|aarch64|arm64)$/),n=s?.[1],i=s?.[2],r=n==="macos"||n==="darwin"?"darwin":n==="linux"?"linux":n==="windows"||n==="win32"?"windows":void 0,a=i==="x64"||i==="x86-64"||i==="amd64"?"x86_64":i==="arm64"||i==="aarch64"?"aarch64":void 0;if(!r||!a)throw Error(`Invalid platform "${e}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:r,arch:a}}var k=new Q("ts-pantry"),Ht=1500000,le=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),u.exit(1)},Ht);u.on("exit",()=>{clearTimeout(le)});async function Ge(e){console.log(`
|
|
84
|
+
Received ${e} signal. Cleaning up resources...`),clearTimeout(le);try{await G(),console.log("Resources cleaned up. Exiting.")}catch(t){console.error("Error during cleanup:",t)}setTimeout(()=>{console.log("Forcing process exit..."),u.exit(0)},1000)}u.on("SIGINT",()=>Ge("SIGINT"));u.on("SIGTERM",()=>Ge("SIGTERM"));function Se(e){let t={};for(let[s,n]of Object.entries(Ce))if(typeof n==="string")t[n]=s;return t[e]||e}function ke(e){let t=e.map(Se),s=e.map((n)=>{let i=Se(n);return i===n?n:i});return{friendlyNames:t,mixedNames:s}}k.command("fetch [packageName]","Fetch package information from pkgx.dev").option("-a, --all","Fetch all packages").option("-p, --pkg <packageNames>","Comma-separated list of package names to fetch").option("-o, --output-dir <dir>","Directory to save package data",{default:"src/packages"}).option("-c, --cache-dir <dir>","Directory to cache package data",{default:W}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:ee}).option("-l, --limit <count>","Limit the number of packages to fetch (use with --all)").option("-t, --timeout <ms>","Timeout for network requests in milliseconds",{default:te}).option("-r, --max-retries <count>","Maximum number of retry attempts for failed requests",{default:3}).option("-j, --json","Save as JSON instead of TypeScript").option("-d, --debug","Enable debug mode (save screenshots)").option("-v, --verbose","Enable verbose output").option("-y, --concurrency <count>","Number of packages to fetch concurrently (default: 8)",{default:8}).option("--output-json","Output results as JSON (for CI integration)").action(async(e,t)=>{let{all:s,outputDir:n="src/packages",cacheDir:i=W,cache:r=!0,cacheExpiration:a=ee,limit:l,timeout:o=te,json:c=!1,debug:p=!1,verbose:g=!1,concurrency:h=8,pkg:f,outputJson:m=!1}=t,I=y.resolve(u.cwd(),n);if(!d.existsSync(I))d.mkdirSync(I,{recursive:!0});let O=y.resolve(u.cwd(),i);if(r){if(!d.existsSync(O))d.mkdirSync(O,{recursive:!0})}try{let b=[],x=[];if(s){if(!m)console.log("Fetching all packages...");let w={outputDir:n,cacheDir:i,cache:r,cacheExpirationMinutes:a,timeout:Number.parseInt(String(o),10),debug:p,limit:l?Number.parseInt(String(l),10):void 0,concurrency:Math.min(Number.parseInt(String(h),10),12),outputJson:m};b=await De(w),x=[...b]}else if(f){let w=f.split(",").map((v)=>v.trim());if(!m)console.log(`Fetching ${w.length} packages: ${w.join(", ")}`);for(let v of w)try{let T=y.join(i,`${v.replace(/\//g,"-")}.json`),A=!1;if(r&&d.existsSync(T)){let _=d.statSync(T),P=(Date.now()-_.mtime.getTime())/60000;if(P<a){if(!m)console.log(`Using cached data for ${v} (age: ${Math.round(P)} minutes)`);try{let ce=JSON.parse(d.readFileSync(T,"utf-8"));delete ce.fetchedAt;let qe=U(n,v,ce);if(g&&!m)console.log(`Using cached data for ${v} (saved to ${qe})`);b.push(v),A=!0;continue}catch{console.warn(`Cache file corrupted for ${v}, will refetch`)}}}if(!A){let _=await ne(v,{timeout:Number.parseInt(String(o),10),debug:p,outputJson:m,cacheDir:i,cache:r,cacheExpirationMinutes:a});if(_){let{outputPath:P}=se(v,_.packageInfo,{cacheDir:i,outputDir:n,cache:r});if(b.push(v),x.push(v),g&&!m)console.log(`Successfully saved ${v} to ${P}`)}}}catch(T){console.error(`Error processing ${v}:`,T)}}else if(e){if(!m)console.log(`Fetching package: ${e}`);try{let w=y.join(O,`${e.replace(/\//g,"-")}.json`),v=!1;if(r&&d.existsSync(w)){let T=d.statSync(w),A=(Date.now()-T.mtime.getTime())/60000;if(A<a){if(!m)console.log(`Using cached data for ${e} (age: ${Math.round(A)} minutes)`);try{let _=JSON.parse(d.readFileSync(w,"utf-8"));delete _.fetchedAt;let P=U(I,e,_);if(g&&!m)console.log(`Using cached data for ${e} (saved to ${P})`);b.push(e),v=!0}catch{console.warn(`Cache file corrupted for ${e}, will refetch`)}}}if(!v){let T=await ne(e,{timeout:Number.parseInt(String(o),10),debug:p,outputJson:m,cacheDir:i,cache:r,cacheExpirationMinutes:a});if(T){let{outputPath:A}=se(e,T.packageInfo,{cacheDir:i,outputDir:n,cache:r});if(b.push(e),x.push(e),g&&!m)console.log(`Successfully saved ${e} to ${A}`)}}}catch(w){console.error(`Error processing ${e}:`,w)}}else{if(!m)console.error("Error: Please specify a package name, use --pkg, or use --all");u.exit(1)}if(!c&&b.length>0){let w=await ae();if(!m)console.log(`Successfully generated ${w}`)}if(s&&b.length>0){let w=je(I,b);if(w.length>0&&!m)console.log(`Cleaned up ${w.length} stale generated file(s)`)}if(m){let{friendlyNames:w,mixedNames:v}=ke(x),{friendlyNames:T,mixedNames:A}=ke(b),_={success:!0,updatedPackages:x,updatedPackagesFriendly:w,updatedPackagesMixed:v,allProcessedPackages:b,allProcessedFriendly:T,allProcessedMixed:A,totalUpdated:x.length,totalProcessed:b.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(_))}else console.log(`Processed ${b.length} packages.`);clearTimeout(le),await G(),setTimeout(()=>u.exit(0),1000)}catch(b){if(m){let x={success:!1,error:String(b),timestamp:new Date().toISOString()};console.log(JSON.stringify(x))}else console.error("Error:",b);await G(),setTimeout(()=>u.exit(1),1000)}});k.command("generate-index","Generate TypeScript index file for packages").option("-o, --output-dir <dir>","Directory containing package files",{default:"src/packages"}).action(async(e)=>{let{outputDir:t="src/packages"}=e,s=y.resolve(u.cwd(),t);if(!d.existsSync(s))console.error(`Error: Directory ${s} does not exist`),u.exit(1);try{let n=await ae();console.log(`Successfully generated ${n}`),setTimeout(()=>u.exit(0),500)}catch(n){console.error("Error generating index:",n),u.exit(1)}});k.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:W}).option("--output-dir <dir>","Output directory for TypeScript files",{default:"packages"}).action(async(e)=>{try{console.log("Generating TypeScript files from cached JSON...");let{cacheDir:t,outputDir:s}=e;if(!d.existsSync(t))console.error(`Cache directory ${t} does not exist!`),u.exit(1);if(!d.existsSync(s))d.mkdirSync(s,{recursive:!0});let n=d.readdirSync(t).filter((r)=>r.endsWith(".json"));console.log(`Found ${n.length} JSON files in cache directory`);let i=0;for(let r of n)try{let a=d.readFileSync(y.join(t,r),"utf-8"),l=JSON.parse(a);delete l.fetchedAt;let o=r.replace(/\.json$/,""),c=U(s,l.fullPath||l.domain||o,l);console.log(`Generated ${c}`),i++}catch(a){console.error(`Error processing ${r}:`,a)}console.log(`Successfully generated ${i} TypeScript files from JSON cache`)}catch(t){console.error("Error generating TypeScript files:",t),u.exit(1)}});k.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let e=await Be();console.log(`Successfully generated ${e}`),setTimeout(()=>u.exit(0),500)}catch(e){console.error("Error generating aliases:",e),u.exit(1)}});k.command("generate-docs","Generate comprehensive BunPress documentation for all packages").option("-o, --output-dir <dir>","Output directory for documentation",{default:"docs"}).action(async(e)=>{try{let{outputDir:t="docs"}=e;await Ne(t),setTimeout(()=>u.exit(0),500)}catch(t){console.error("Error generating documentation:",t),u.exit(1)}});k.command("update-pantry","Download and extract the latest pantry.tgz file").option("-d, --pantry-dir <dir>","Directory to extract pantry files",{default:"src/pantry"}).action(async(e)=>{try{let{pantryDir:t="src/pantry"}=e,s=y.resolve(u.cwd(),t);console.log("Downloading pantry.tgz...");let n=await fetch("https://s3.amazonaws.com/dist.tea.xyz/pantry.tgz");if(!n.ok)throw Error(`Failed to download pantry.tgz: ${n.statusText}`);let i=await n.arrayBuffer(),r=y.join(u.cwd(),"pantry.tgz");d.writeFileSync(r,new Uint8Array(i)),console.log(`Downloaded ${i.byteLength} bytes`),d.mkdirSync(s,{recursive:!0});let a=y.join(u.cwd(),"temp-pantry"),{spawn:l}=await import("node:child_process");if(d.existsSync(a))d.rmSync(a,{recursive:!0,force:!0});d.mkdirSync(a,{recursive:!0});let o=l("tar",["-xzf",r,"-C",a,"--strip-components=1"],{stdio:"inherit"});await new Promise((h,f)=>{o.on("close",(m)=>{if(m===0)h(m);else f(Error(`tar extraction failed with code ${m}`))}),o.on("error",f)});let c=y.join(a,"projects");if(d.existsSync(c)){let h=d.readdirSync(c),f=0,m=0,I=(O,b)=>{if(!d.existsSync(b))d.mkdirSync(b,{recursive:!0});for(let x of d.readdirSync(O,{withFileTypes:!0})){let w=y.join(O,x.name),v=y.join(b,x.name);if(x.isDirectory())I(w,v);else if(x.name==="package.yml")if(d.existsSync(v))m++;else d.renameSync(w,v),f++;else if(!d.existsSync(v))d.renameSync(w,v)}};console.log(`Merging ${h.length} projects from upstream...`);for(let O of h){let b=y.join(c,O),x=y.join(s,O);if(d.statSync(b).isDirectory())I(b,x)}console.log(`Merged upstream pantry: ${f} new packages added, ${m} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(d.unlinkSync(r),d.existsSync(a))d.rmSync(a,{recursive:!0,force:!0});console.log(`
|
|
85
|
+
Downloading props files from pkgx/pantry GitHub repo...`);let g=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(g.ok){let h=await g.arrayBuffer(),f=y.join(u.cwd(),"pantry-gh.tar.gz"),m=y.join(u.cwd(),"temp-pantry-gh");if(d.writeFileSync(f,new Uint8Array(h)),console.log(`Downloaded GitHub archive: ${(h.byteLength/1024/1024).toFixed(1)} MB`),d.existsSync(m))d.rmSync(m,{recursive:!0,force:!0});d.mkdirSync(m,{recursive:!0});let I=l("tar",["-xzf",f,"-C",m,"--strip-components=1"],{stdio:"inherit"});await new Promise((b,x)=>{I.on("close",(w)=>w===0?b(w):x(Error(`tar failed: ${w}`))),I.on("error",x)});let O=y.join(m,"projects");if(d.existsSync(O)){let b=0,x=0,w=(v,T)=>{if(!d.existsSync(v))return;for(let A of d.readdirSync(v,{withFileTypes:!0})){let _=y.join(v,A.name),P=y.join(T,A.name);if(A.isDirectory())w(_,P);else if(A.name!=="package.yml")if(d.mkdirSync(T,{recursive:!0}),d.copyFileSync(_,P),d.existsSync(P))x++;else b++}};w(O,s),console.log(`Props files: ${b+x} synced (${b} new, ${x} updated)`)}if(d.unlinkSync(f),d.existsSync(m))d.rmSync(m,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${g.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),d.existsSync(s)){let h=d.readdirSync(s).filter((f)=>{let m=y.join(s,f);return d.statSync(m).isDirectory()&&!f.startsWith(".")});console.log(`Final result: ${h.length} projects in ${s}`)}u.exit(0)}catch(t){console.error("Error updating pantry:",t),u.exit(1)}});k.command("generate-consts","Generate or update the consts.ts file with all known packages").option("-s, --source <source>",'Source for packages: "pantry" (default) or "registry"',{default:"pantry"}).option("--pantry-dir <dir>","Directory containing pantry files",{default:"src/pantry"}).option("--validate","Validate a sample of packages (slower but more accurate)").action(async(e)=>{try{let{source:t="pantry",pantryDir:s="src/pantry",validate:n=!1}=e;console.log(`\uD83D\uDE80 Generating consts.ts file using ${t} as source...`);let i=[];if(t==="pantry")i=await Wt(s);else if(t==="registry")i=await Ut(n);else console.error('Invalid source. Use "pantry" or "registry"'),u.exit(1);await Gt(i,t),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${i.length}`);let r=new Date().toISOString(),a=`Generated from ${t} at ${r}
|
|
86
|
+
Total packages: ${i.length}
|
|
96
87
|
|
|
97
|
-
${
|
|
98
|
-
`)}`;
|
|
99
|
-
✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${
|
|
100
|
-
Conflicts found:`),
|
|
101
|
-
\uD83D\uDCCB All unique packages to install:`),
|
|
102
|
-
\uD83D\uDE80 Install command:`),console.log(`pantry install ${
|
|
103
|
-
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(
|
|
104
|
-
${
|
|
105
|
-
`)}`);break;case"csv":console.log(
|
|
106
|
-
\uD83D\uDE80 Generating Zig package aliases...`),await
|
|
107
|
-
✅ Zig code generation complete!`),
|
|
108
|
-
Installed Desktop Apps (${
|
|
109
|
-
`),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let
|
|
110
|
-
Outdated Apps (${
|
|
111
|
-
`),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let
|
|
112
|
-
All desktop apps are up to date!`);let
|
|
113
|
-
${
|
|
114
|
-
✓ ${
|
|
115
|
-
⚠ ${
|
|
116
|
-
✓ Built ${
|
|
117
|
-
Pushing ${
|
|
118
|
-
`,{mode:384}),console.log(JSON.stringify({reportPath:
|
|
88
|
+
${i.join(`
|
|
89
|
+
`)}`;d.writeFileSync(`${t}-packages-summary.txt`,a),console.log(`\uD83D\uDCC4 Created ${t}-packages-summary.txt for reference`),u.exit(0)}catch(t){console.error("Error generating consts file:",t),u.exit(1)}});k.command("resolve-deps [file]","Resolve all dependencies (including transitive) from a dependency file").option("-f, --file <path>","Path to dependency file (deps.yaml, dependencies.yaml, pkgx.yaml, etc.)").option("-d, --dir <directory>","Directory to search for dependency files",{default:"."}).option("--pantry-dir <dir>","Directory containing pantry files",{default:"src/pantry"}).option("--packages-dir <dir>","Directory containing generated package files",{default:"src/packages"}).option("--target-os <os>","Target OS for OS-specific dependencies (linux, darwin, windows)").option("--include-os-deps","Include OS-specific dependencies in resolution").option("--max-depth <depth>","Maximum recursion depth for dependency resolution",{default:10}).option("-v, --verbose","Enable verbose output").option("-j, --json","Output results as JSON").option("--install-command","Show install commands for resolved packages").action(async(e,t)=>{try{let{dir:s=".",packagesDir:n="src/packages",targetOs:i,includeOsDeps:r=!1,maxDepth:a=10,verbose:l=!1,json:o=!1,installCommand:c=!1}=t,p=e||t.file;if(!p){let f=ie(s);if(f.length===0)console.error(`No dependency files found in ${s}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),u.exit(1);else if(f.length>1)console.error(`Multiple dependency files found in ${s}:`),f.forEach((m)=>console.error(` ${m}`)),console.error("Please specify which file to use with --file or [file] argument"),u.exit(1);else if(p=f[0],!o)console.log(`Found dependency file: ${p}`)}if(!d.existsSync(p))console.error(`Dependency file not found: ${p}`),u.exit(1);let g={packagesDir:n,includeOsSpecific:r,targetOs:i,maxDepth:Number.parseInt(String(a),10),verbose:l&&!o};if(!o)console.log("\uD83D\uDD0D Resolving dependencies...");let h=await Oe(p,g);if(o){let f={success:!0,file:p,summary:{totalUnique:h.uniquePackages.length,conflicts:h.conflicts.length,osSpecific:{linux:h.osSpecificDeps.linux.length,darwin:h.osSpecificDeps.darwin.length,windows:h.osSpecificDeps.windows.length}},packages:h.uniquePackages,dependencies:h.allDependencies,conflicts:h.conflicts,osSpecificDeps:h.osSpecificDeps,timestamp:new Date().toISOString()};console.log(JSON.stringify(f,null,2))}else{if(console.log(`
|
|
90
|
+
✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${h.uniquePackages.length}`),h.conflicts.length>0)console.log(`⚠️ Version conflicts: ${h.conflicts.length}`),console.log(`
|
|
91
|
+
Conflicts found:`),h.conflicts.forEach((m)=>{console.log(` ${m.package}: ${m.versions.join(", ")}`)});if(console.log(`
|
|
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
|
+
\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-92zrwkxc.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
|
+
${n.map((i)=>` - "${i}"`).join(`
|
|
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-btrd677x.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
|
+
\uD83D\uDE80 Generating Zig package aliases...`),await s(n,a);console.log(`
|
|
98
|
+
✅ Zig code generation complete!`),u.exit(0)}catch(t){console.error("Error generating Zig definitions:",t),u.exit(1)}});k.command("release [type]","Release a Zig package (changelog, bump, commit, tag, push, publish)").option("-y, --yes","Non-interactive mode (skip confirmation prompts)").option("--dry-run","Preview the release without changing anything").option("--no-changelog","Skip changelog generation").option("--no-push","Skip pushing the commit and tag").option("--no-publish","Skip publishing to the pantry registry").action(async(e,t)=>{let s=(e??"patch").toLowerCase();if(!["patch","minor","major"].includes(s))console.error(`error: invalid release type "${s}" (expected: patch | minor | major)`),u.exit(1);let{runRelease:n}=await import("../chunk-tp1d7cq1.js"),i=await n({type:s,yes:t.yes,dryRun:t.dryRun,noChangelog:t.changelog===!1,noPush:t.push===!1,noPublish:t.publish===!1});u.exit(i.exitCode)});k.command("apps","List installed desktop applications with version info").option("-j, --json","Output as JSON").action(async(e)=>{try{let{scanInstalledApps:t}=await import("../chunk-gr5aqxxx.js"),s=t();if(e.json)console.log(JSON.stringify({success:!0,apps:s,total:s.length}));else{console.log(`
|
|
99
|
+
Installed Desktop Apps (${s.length}):
|
|
100
|
+
`),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let n of s)console.log(`${n.name.padEnd(40)}${n.version}`)}u.exit(0)}catch(t){console.error("Error listing apps:",t),u.exit(1)}});k.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(e)=>{try{let{checkAppUpdates:t}=await import("../chunk-gr5aqxxx.js");if(!e.json)console.log("Checking desktop apps for updates...");let s=await t(),n=s.filter((i)=>i.updateAvailable);if(e.json)console.log(JSON.stringify({success:!0,apps:s,outdated:n.length,total:s.length,timestamp:new Date().toISOString()}));else{if(n.length>0){console.log(`
|
|
101
|
+
Outdated Apps (${n.length}):
|
|
102
|
+
`),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let r of n)console.log(`${r.name.padEnd(30)}${r.currentVersion.padEnd(16)}${(r.latestVersion||"?").padEnd(16)}${r.source}`)}else console.log(`
|
|
103
|
+
All desktop apps are up to date!`);let i=s.filter((r)=>!r.updateAvailable&&r.source!=="system"&&r.source!=="unknown");if(i.length>0)console.log(`
|
|
104
|
+
${i.length} app(s) up to date, ${s.filter((r)=>r.source==="unknown").length} unchecked`)}u.exit(0)}catch(t){console.error("Error checking app updates:",t),u.exit(1)}});k.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(e)=>{try{let{updateApp:t}=await import("../chunk-gr5aqxxx.js");console.log(`Updating ${e} from the pantry registry...`);let s=await t(e);if(s.success)console.log(`Successfully updated ${e} to ${s.version}`);else console.error(`Failed to update ${e}: ${s.error}`),u.exit(1);u.exit(0)}catch(t){console.error("Error updating app:",t),u.exit(1)}});k.command("install <pkg>","Install a system package (e.g. ziglang.org@0.17.0-dev)").option("--global","Link binaries into the user-level global bin so they appear on PATH").option("--install-dir <dir>","Where to download into (default: ./pantry)").option("--platform <target>","Install for a target platform (e.g. linux-x86_64)").option("--no-bin-links","Skip creating local .bin/ symlinks").option("--quiet","Suppress progress output").action(async(e,t)=>{let s=e.lastIndexOf("@"),n=s>0,i=n?e.slice(0,s):e,r=n?e.slice(s+1):"latest";try{let a=await oe(i,r,{installDir:t.installDir,platform:qt(t.platform),createBinLinks:t.binLinks!==!1,quiet:t.quiet,globalBin:t.global?!0:void 0});if(!t.quiet){if(console.log(`
|
|
105
|
+
✓ ${a.name}@${a.version}`),console.log(` installed to: ${a.installPath}`),a.globalLinks&&a.globalLinks.length>0){if(console.log(` linked into: ${y.dirname(a.globalLinks[0])}`),!u.env.PATH?.split(y.delimiter).includes(y.dirname(a.globalLinks[0])))console.log(`
|
|
106
|
+
⚠ ${y.dirname(a.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}u.exit(0)}catch(a){console.error(`Error installing ${e}:`,a instanceof Error?a.message:a),u.exit(1)}});function Kt(e){let t=ie(e);if(t.length===0)return[];try{return Ie(t[0]).map((s)=>s.version&&s.version!=="latest"?`${s.name}@${String(s.version).replace(/^[\^~>=<]+/,"")}`:s.name)}catch{return[]}}k.command("env","Print the environment pantry-installed packages need, for a program to consume").option("--json","Print JSON instead of shell assignments").option("--dir <path>","A project directory, whose dependency file is included (default: cwd)").option("--install","Install anything the dependency file names that is missing").action(async(e)=>{let t=y.resolve(e.dir??u.cwd()),s=Kt(t);if(e.install&&s.length>0)for(let r of s){let a=r.lastIndexOf("@"),l=a>0;await oe(l?r.slice(0,a):r,l?r.slice(a+1):"latest",{globalBin:!0,quiet:!0}).catch((o)=>{console.error(`# could not install ${r}: ${o instanceof Error?o.message:o}`)})}let n=re(),i=[y.join(t,".bin"),n].filter((r)=>d.existsSync(r));if(e.json)console.log(JSON.stringify({path:i,PATH:[...i,u.env.PATH??""].filter(Boolean).join(y.delimiter),dependencies:s,globalBin:n},null,2)),u.exit(0);console.log(`export PATH="${[...i,"$PATH"].join(y.delimiter)}"`),u.exit(0)});k.command("shell-init","Print the shell snippet that puts pantry-installed packages on PATH").option("--install","Append the snippet to your shell rc file (idempotent)").option("--uninstall","Remove a previously installed snippet").option("--shell <shell>","Force a shell (zsh|bash|fish) instead of autodetect").action(async(e)=>{let t=e.shell??Ee();try{if(e.uninstall){let n=Pe({shell:t});console.log(n.changed?`✓ Removed pantry shell-init from ${n.rcFile}`:`Nothing to remove (no pantry shell-init block in ${n.rcFile})`),u.exit(0)}if(e.install){let n=_e({shell:t});if(n.changed)console.log(`✓ Added pantry shell-init to ${n.rcFile}`),console.log(` Restart your shell or run: source ${n.rcFile}`);else console.log(`✓ Already integrated in ${n.rcFile}`);u.exit(0)}let s=Te(t);if(u.stdout.isTTY){if(console.log(`# Detected shell: ${t}`),console.log(`# Global bin dir: ${re()}`),s)console.log(`# Append this to: ${s}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}u.stdout.write(Ae({shell:t})),u.exit(0)}catch(s){console.error("Error:",s instanceof Error?s.message:s),u.exit(1)}});k.command("build [context]","Build a Dockerfile into an OCI image (no Docker daemon required)").option("-f, --file <path>","Path to the Dockerfile (default: <context>/Dockerfile)").option("-t, --tag <tag>","Image tag, e.g. myapp:latest (repeatable)").option("--target <stage>","Target stage for a multi-stage build").option("--build-arg <kv>","Set a build arg KEY=VALUE (repeatable)").option("--platform <os/arch>","Target platform (default: linux/<host-arch>)").option("--output <dir>","Where to write the image archive + OCI layout (default: <context>/.pantry/images)").option("--run-mode <mode>","How to run RUN steps: auto|chroot|host|skip (default: auto)").option("--push","Push the built image to the pantry registry after building").option("--quiet","Suppress step output").action(async(e,t)=>{try{let s=[].concat(t.tag??[]),n={};for(let r of[].concat(t.buildArg??[])){let a=r.indexOf("=");if(a!==-1)n[r.slice(0,a)]=r.slice(a+1)}let i=await Ve({context:e??".",dockerfile:t.file,tags:s,target:t.target,buildArgs:n,platform:t.platform,outputDir:t.output,runMode:t.runMode,quiet:t.quiet});if(!t.quiet){if(console.log(`
|
|
107
|
+
✓ Built ${i.imageId}`),s.length)console.log(` tags: ${s.join(", ")}`);console.log(` archive: ${i.archivePath}`),console.log(` oci layout: ${i.ociLayoutPath}`)}if(t.push){let r=Re(s[0]||"app:latest");if(!t.quiet)console.log(`
|
|
108
|
+
Pushing ${r.repository}:${r.tag} → ${Me} ...`);let a=await Le({repository:r.repository,tag:r.tag,registry:r.implicitRegistry?void 0:`https://${r.registry}`,configBytes:Buffer.from(i.configBytes),configDigest:i.configDigest,layers:i.layers.map((l)=>({digest:l.digest,path:l.path,size:l.size})),manifestBytes:Buffer.from(i.manifestBytes),manifestMediaType:i.manifestMediaType,quiet:t.quiet});console.log(`✓ Pushed ${a.ref} (${a.digest})`)}u.exit(0)}catch(s){console.error("Build failed:",s instanceof Error?s.message:s),u.exit(1)}});k.command("container:generate [outDir]","Generate a Dockerfile + .freezer (default outDir: storage/framework)").alias("freeze").option("--base <image>","Base image (default: oven/bun:1.3.10)").option("--workdir <dir>","Working directory in the image (default: /app)").option("--install <cmd>","Install command (default: bun install --frozen-lockfile)").option("--build <cmd>","Optional build command run after install").option("--start <cmd>","Start command (default: bun start)").option("--port <port>","Exposed port (default: 3000)").option("--force","Overwrite existing files").action(async(e,t)=>{try{let s=Fe({outDir:e??"storage/framework",baseImage:t.base,workdir:t.workdir,installCommand:t.install,buildCommand:t.build,startCommand:t.start?t.start.split(/\s+/):void 0,port:t.port?Number(t.port):void 0,force:t.force});console.log(`${s.wroteDockerfile?"✓ wrote":"• kept"} ${s.dockerfilePath}`),console.log(`${s.wroteFreezer?"✓ wrote":"• kept"} ${s.freezerPath}`),u.exit(0)}catch(s){console.error("Generate failed:",s instanceof Error?s.message:s),u.exit(1)}});k.command("app-store:csr","Generate private keys and CSRs for Mac App Store certificates").option("--name <name>","App name used in certificate request common names").option("--output <dir>","Output directory (default: .pantry/apple)").action((e)=>{try{if(!e.name)throw Error("--name is required");let t=We({outputDirectory:e.output??".pantry/apple",commonName:e.name});console.log(JSON.stringify({requests:t},null,2)),u.exit(0)}catch(t){console.error("Apple CSR generation failed:",t instanceof Error?t.message:t),u.exit(1)}});k.command("app-store:provision","Plan or reconcile macOS App Store Connect resources").option("--bundle-id <id>","Reverse-DNS bundle identifier").option("--name <name>","Mac App Store display name").option("--api-key-id <id>","App Store Connect API key ID").option("--api-issuer-id <id>","App Store Connect API issuer ID").option("--api-key-path <path>","App Store Connect AuthKey .p8 file").option("--capabilities <types>","Comma-separated Apple capability types").option("--app-certificate-csr <path>","CSR for a missing Mac App Distribution certificate").option("--installer-certificate-csr <path>","CSR for a missing Mac Installer Distribution certificate").option("--profile-name <name>","Provisioning profile name").option("--output <dir>","Output directory (default: .pantry/apple)").option("--p12-password <password>","Export newly issued certificates as password-protected P12 files").option("--apply","Apply the plan; the default only reports missing resources").action(async(e)=>{try{if(!e.bundleId||!e.name)throw Error("--bundle-id and --name are required");let t=(o)=>{if(!o)return;return d.readFileSync(y.resolve(o),"utf8")},s=y.resolve(e.output??".pantry/apple");d.mkdirSync(s,{recursive:!0});let n=await ze({identifier:e.bundleId,name:e.name,capabilities:e.capabilities?.split(",").map((o)=>o.trim()).filter(Boolean),appCertificateCsr:t(e.appCertificateCsr),installerCertificateCsr:t(e.installerCertificateCsr),profileName:e.profileName,keyId:e.apiKeyId,issuerId:e.apiIssuerId,keyPath:e.apiKeyPath,checkOnly:!e.apply});for(let o of n.certificates){if(!o.certificateContent)continue;let c=o.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",p=y.join(s,`${c}.cer`);d.writeFileSync(p,Buffer.from(o.certificateContent,"base64"),{mode:384});let g=o.type==="MAC_APP_DISTRIBUTION"?e.appCertificateCsr:e.installerCertificateCsr;if(e.p12Password&&g)Ue({certificatePath:p,privateKeyPath:y.resolve(g.replace(/\.csr$/i,".key")),outputPath:y.join(s,`${c}.p12`),password:e.p12Password,name:`${e.name} ${o.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(n.profile.profileContent)d.writeFileSync(y.join(s,"mac-app-store.provisionprofile"),Buffer.from(n.profile.profileContent,"base64"),{mode:384});let i=n.certificates.map((o)=>{let c={...o};return delete c.certificateContent,c}),r={...n.profile};delete r.profileContent;let a={...n,certificates:i,profile:r},l=y.join(s,"provisioning-plan.json");d.writeFileSync(l,`${JSON.stringify(a,null,2)}
|
|
109
|
+
`,{mode:384}),console.log(JSON.stringify({reportPath:l,...a},null,2)),u.exit(0)}catch(t){console.error("App Store provisioning failed:",t instanceof Error?t.message:t),u.exit(1)}});k.help();k.version(xe);var tn=k.parse();if(u.argv.length<=2||u.argv.includes("--help")||u.argv.includes("-h"))u.exit(0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ib as a,Jb as b,Kb as c,Lb as d,Mb as e,Nb as f,Ob as g,Pb as h,Qb as i,Rb as j,Sb as k,Tb as l,Ub as m,Vb as n}from"./chunk-5y7jxjtz.js";import"./chunk-415b756j.js";import"./chunk-rqny4g8r.js";import"./chunk-hxd34yh9.js";import"./chunk-a20hctx6.js";export{b as cleanStaleOutputFiles,e as cleanupBrowserResources,j as fetchAndSaveAllPackages,k as fetchAndSavePackage,g as fetchPantryPackage,n as fetchPantryPackageWithMetadata,f as fetchPkgxProjects,c as getValidCachedPackage,m as readPantryPackageInfo,a as savePackageAsTypeScript,d as saveToCacheAndOutput,l as scanPantryPackages,h as setupCleanupHandlers,i as startPeriodicCleanup};
|