ts-pantry 0.11.133 → 0.11.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +6 -0
  2. package/dist/bin/cli.js +30 -59
  3. package/dist/bin/desktop.d.ts +1 -0
  4. package/dist/bin/desktop.js +14 -0
  5. package/dist/{chunk-az1ps614.js → chunk-0wagak5e.js} +7 -7
  6. package/dist/chunk-167jazj7.js +1 -0
  7. package/dist/chunk-1abg34mb.js +2 -0
  8. package/dist/chunk-1n0fctvz.js +1 -0
  9. package/dist/chunk-31y9b4za.js +1 -0
  10. package/dist/chunk-8f07ddwg.js +3 -0
  11. package/dist/chunk-995m3fba.js +2 -0
  12. package/dist/chunk-bggscee8.js +1 -0
  13. package/dist/chunk-bmcywh4v.js +1 -0
  14. package/dist/chunk-bq29tm01.js +2 -0
  15. package/dist/chunk-dc73wbey.js +1 -0
  16. package/dist/chunk-h49t8bqz.js +524 -0
  17. package/dist/chunk-hygw1tjj.js +31 -0
  18. package/dist/chunk-jztg3vmf.js +1 -0
  19. package/dist/chunk-pggwsb9g.js +1 -0
  20. package/dist/chunk-pgnj1c0k.js +17 -0
  21. package/dist/{chunk-pkjat5c6.js → chunk-w0v9wy7r.js} +54 -54
  22. package/dist/{chunk-y7anxtyk.js → chunk-xmwegwme.js} +36 -36
  23. package/dist/chunk-zjnhaw1v.js +1 -0
  24. package/dist/generated-package-names.d.ts +40 -40
  25. package/dist/src/catalog/client.d.ts +11 -0
  26. package/dist/src/catalog/client.js +1 -0
  27. package/dist/src/catalog/types.d.ts +21 -0
  28. package/dist/src/desktop/client.d.ts +28 -0
  29. package/dist/src/desktop/client.js +1 -0
  30. package/dist/src/desktop/service.d.ts +19 -0
  31. package/dist/src/desktop/service.js +1 -0
  32. package/dist/src/desktop/setup.d.ts +8 -0
  33. package/dist/src/index.js +1 -1
  34. package/dist/src/native/index.d.ts +1 -0
  35. package/dist/src/native/index.js +6 -6
  36. package/dist/src/native/pipeline.d.ts +3 -0
  37. package/dist/src/native/release.js +1 -1
  38. package/dist/src/native/store-publish.d.ts +22 -0
  39. package/dist/src/packages/anthropic.com/claude-code.d.ts +2 -2
  40. package/dist/src/packages/apps/cursorcom.d.ts +2 -2
  41. package/dist/src/packages/apps/discordcom.d.ts +2 -2
  42. package/dist/src/packages/apps/maccyapp.d.ts +2 -2
  43. package/dist/src/packages/apps/slackcom.d.ts +2 -2
  44. package/dist/src/packages/apps/tunnelblicknet.d.ts +2 -2
  45. package/dist/src/packages/cligithubcom.d.ts +3 -3
  46. package/dist/src/packages/craft-native.org.d.ts +3 -3
  47. package/dist/src/packages/depotdev.d.ts +3 -3
  48. package/dist/src/packages/digitalocean.com/doctl.d.ts +3 -3
  49. package/dist/src/packages/fastlanetools.d.ts +3 -3
  50. package/dist/src/packages/fluxcd.io/flux2.d.ts +3 -3
  51. package/dist/src/packages/flyio.d.ts +3 -3
  52. package/dist/src/packages/github.com/ggerganov/llama.cpp.d.ts +3 -3
  53. package/dist/src/packages/github.com/git-ecosystem/git-credential-manager.d.ts +3 -3
  54. package/dist/src/packages/github.com/krzysztofzablocki/Sourcery.d.ts +3 -3
  55. package/dist/src/packages/github.com/mamba-org/micro.d.ts +3 -3
  56. package/dist/src/packages/github.com/router-for-me/CLIProxyAPI.d.ts +3 -3
  57. package/dist/src/packages/grpcio.d.ts +3 -3
  58. package/dist/src/packages/harlequinsh.d.ts +3 -3
  59. package/dist/src/packages/hunspellgithubio.d.ts +3 -3
  60. package/dist/src/packages/julialangorg.d.ts +3 -3
  61. package/dist/src/packages/kernel.org/perf.d.ts +3 -3
  62. package/dist/src/packages/meilisearchcom.d.ts +1 -1
  63. package/dist/src/packages/misejdxdev.d.ts +3 -3
  64. package/dist/src/packages/odigosio.d.ts +3 -3
  65. package/dist/src/packages/openbao.org/openbao.d.ts +3 -3
  66. package/dist/src/packages/openexrcom.d.ts +2 -2
  67. package/dist/src/packages/openshiftcom.d.ts +3 -3
  68. package/dist/src/packages/pandocorg.d.ts +3 -3
  69. package/dist/src/packages/projenio.d.ts +3 -3
  70. package/dist/src/packages/pythonorg.d.ts +3 -3
  71. package/dist/src/packages/redisio.d.ts +3 -3
  72. package/dist/src/packages/stripecom.d.ts +3 -3
  73. package/dist/src/packages/talosdev.d.ts +3 -3
  74. package/dist/src/packages/templguide.d.ts +3 -3
  75. package/dist/src/packages/valkeyio.d.ts +3 -3
  76. package/dist/src/packages/vimorg.d.ts +3 -3
  77. package/dist/src/packages/wailsio.d.ts +3 -3
  78. package/dist/src/packages/ziglangorg.d.ts +3 -3
  79. package/dist/src/testing/index.js +1 -1
  80. package/dist/src/types.d.ts +1 -0
  81. package/package.json +16 -3
  82. package/dist/chunk-3682vxak.js +0 -525
  83. package/dist/chunk-9p1hjjtd.js +0 -17
  84. package/dist/chunk-ckk0227f.js +0 -1
  85. package/dist/chunk-dm6xb408.js +0 -1
  86. package/dist/chunk-gdkpyb6t.js +0 -1
  87. package/dist/chunk-hz02y4dm.js +0 -1
  88. package/dist/chunk-j15r9wnr.js +0 -1
  89. package/dist/chunk-m59dtz1w.js +0 -1
  90. package/dist/chunk-nk4tf28s.js +0 -1
  91. package/dist/chunk-p5nwkwy1.js +0 -1
  92. package/dist/chunk-xq09n371.js +0 -1
package/README.md CHANGED
@@ -240,3 +240,9 @@ publisher to commit, tag and push normally. The tag invokes the Pantry delivery
240
240
  workflow. `ts-pantry native:release --bump patch` exposes the same operation;
241
241
  `--dry-run` previews the version change after qualification without committing,
242
242
  tagging or pushing.
243
+
244
+ ### Desktop catalog and connections
245
+
246
+ `ts-pantry/catalog` provides the complete validated public package snapshot and local search. `ts-pantry/desktop` provides an authenticated transport client for the separately installed Pantry desktop service. They contain no installer and bundle for browsers. The external CLI owns installation, pairing, job persistence and activation of apps, CLIs, libraries and fonts. See [desktop bridge documentation](../../docs/features/desktop-bridge.md).
247
+
248
+ Native Stacks projects use `buddy desktop:apple:package`, `buddy desktop:apple:publish` and `buddy desktop:apple:submit` for the shared Apple delivery pipeline. The native SDK also exports `publishNativeApple` and `submitNativeApple` for other hosts.
package/dist/bin/cli.js CHANGED
@@ -1,36 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import{t,x,n,d,h,P,Y,re,f,z,j,E,L,ie,ce,s,M,U,m,V,D,S,_,T,c,G,ue,de,he,et,tt,at}from"../chunk-3682vxak.js";import"../chunk-gdkpyb6t.js";import C from"node:fs";import O from"node:path";import v from"node:process";import{existsSync as Ge}from"node:fs";import be from"node:fs/promises";import Te from"node:os";import we from"node:path";import oe from"node:process";import{EventEmitter as qe}from"node:events";import se from"node:process";import Ae from"node:process";import Se from"node:process";import ye from"node:process";import pe from"node:process";import De from"node:tty";import Mt,{stdin as ps,stdout as fs}from"node:process";class Ne{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=Te.homedir(),i=we.join(e,".config","clapp");this.configPath=we.join(i,"telemetry.json")}async isEnabled(){if(oe.env.DO_NOT_TRACK==="1"||oe.env.DO_NOT_TRACK==="true")return!1;if(oe.env.NO_TELEMETRY==="1"||oe.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,i){if(!await this.isEnabled())return;let o={event:e,...i,timestamp:Date.now(),platform:Te.platform(),nodeVersion:oe.version};if(this.events.push(o),this.events.length>=10)await this.send()}async trackCommand(e,i){await this.track("command",{command:e,duration:i})}async trackError(e,i){await this.track("error",{error:e,command:i})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let i=await this.loadConfig();return i.lastSent=Date.now(),await this.saveConfig(i),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let i=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(i),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((i)=>setTimeout(i,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:oe.env.DO_NOT_TRACK==="1"||oe.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(Ge(this.configPath)){let e=await be.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 i=we.dirname(this.configPath);await be.mkdir(i,{recursive:!0}),await be.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),i=Date.now().toString(36);return`${e}-${i}`}}var es=new Ne;function xe(e){return e.replace(/[<[].+/,"").trim()}function He(e){let i=/<([^>]+)>/g,r=/\[([^\]]+)\]/g,o=[],a=(b)=>{let u=!1,p=b[1];if(p.startsWith("..."))p=p.slice(3),u=!0;return{required:b[0].startsWith("<"),value:p,variadic:u}},l;while(l=i.exec(e))o.push(a(l));let g;while(g=r.exec(e))o.push(a(g));return o}function Ke(e){let i={alias:{},boolean:[]};for(let[r,o]of e.entries()){if(o.names.length>1)i.alias[o.names[0]]=o.names.slice(1);if(o.isBoolean)if(o.negated){if(!e.some((l,g)=>g!==r&&l.names.some((b)=>o.names.includes(b))&&typeof l.required==="boolean"))i.boolean.push(o.names[0])}else i.boolean.push(o.names[0])}return i}function _e(e){return e.reduce((i,r)=>i.length>=r.length?i:r,"")}function ve(e,i){return e.length>=i?e:`${e}${" ".repeat(i-e.length)}`}function ge(e){return e.replace(/([a-z])-([a-z])/g,(i,r,o)=>r+o.toUpperCase())}function Je(e,i,r){let o=0,a=i.length,l=e,g;for(;o<a;++o)g=l[i[o]],l=l[i[o]]=o===a-1?r:g!=null?g:!!~i[o+1].indexOf(".")||!(+i[o+1]>-1)?{}:[]}function Ye(e,i){for(let r of Object.keys(i)){let o=i[r];if(o.shouldTransform){if(e[r]=Array.prototype.concat.call([],e[r]),typeof o.transformFunction==="function")e[r]=e[r].map(o.transformFunction)}}}function Ze(e){let i=/([^\\/]+)$/.exec(e);return i?i[1]:""}function fe(e){return e.split(".").map((i,r)=>r===0?ge(i):i).join(".")}class me extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,i){super(e);if(this.name=this.constructor.name,i!==void 0)this.usage=i;if(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
-
4
- Stack trace:
5
- ${this.stack}`;return this.message}}function Xe(e){if(e instanceof me)return!0;return!!e&&typeof e==="object"&&e.name==="ClappError"&&typeof e.message==="string"}function Qe(){let{env:e}=Ae,{TERM:i,TERM_PROGRAM:r}=e;if(Ae.platform!=="win32")return i!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||i==="xterm-256color"||i==="alacritty"||i==="rxvt-unicode"||i==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var $e="\x1B",Z=`${$e}[`;var je={to(e,i){if(!i)return`${Z}${e+1}G`;return`${Z}${i+1};${e+1}H`},move(e,i){let r="";if(e<0)r+=`${Z}${-e}D`;else if(e>0)r+=`${Z}${e}C`;if(i<0)r+=`${Z}${-i}A`;else if(i>0)r+=`${Z}${i}B`;return r},up:(e=1)=>`${Z}${e}A`,down:(e=1)=>`${Z}${e}B`,forward:(e=1)=>`${Z}${e}C`,backward:(e=1)=>`${Z}${e}D`,nextLine:(e=1)=>`${Z}E`.repeat(e),prevLine:(e=1)=>`${Z}F`.repeat(e),left:`${Z}G`,hide:`${Z}?25l`,show:`${Z}?25h`,save:`${$e}7`,restore:`${$e}8`};var is={screen:`${Z}2J`,up:(e=1)=>`${Z}1J`.repeat(e),down:(e=1)=>`${Z}J`.repeat(e),line:`${Z}2K`,lineEnd:`${Z}K`,lineStart:`${Z}1K`,lines(e){let i="";for(let r=0;r<e;r++)i+=this.line+(r<e-1?je.up():"");if(e)i+=je.left;return i}},rs={screen:`${$e}c`};function st(e,i){let r=[];for(let o=0;o<=i.length;o++)r[o]=[o];for(let o=0;o<=e.length;o++)r[0][o]=o;for(let o=1;o<=i.length;o++)for(let a=1;a<=e.length;a++)if(i.charAt(o-1)===e.charAt(a-1))r[o][a]=r[o-1][a-1];else r[o][a]=Math.min(r[o-1][a-1]+1,r[o][a-1]+1,r[o-1][a]+1);return r[i.length][e.length]}function Be(e,i,r=2,o=3){return i.map((a)=>({cmd:a,distance:st(e,a)})).filter(({distance:a})=>a<=r).sort((a,l)=>a.distance-l.distance).slice(0,o).map(({cmd:a})=>a)}function nt(e,i={}){let r={_:[]},o=i.alias||{},a=new Set(i.boolean||[]),l={};for(let u of Object.keys(o))for(let p of o[u])l[p]=u;for(let u of a)if(o[u])for(let p of o[u])a.add(p);function g(u,p){if(u===void 0)return p;if(typeof p==="boolean")return p;return Array.isArray(u)?[...u,p]:[u,p]}function b(u,p){let k=l[u]||u,I=g(r[k],p);if(r[k]=I,o[k])for(let y of o[k])r[y]=I;if(l[u]&&o[l[u]])for(let y of o[l[u]])r[y]=I;r[u]=I}for(let u=0;u<e.length;u++){let p=e[u];if(p==="--"){r._.push(...e.slice(u+1));break}if(p.startsWith("--")){let k=p.indexOf("=");if(k!==-1){let I=ge(p.slice(2,k)),y=p.slice(k+1);b(I,y)}else{let I=p.slice(2);if(I.startsWith("no-")){let w=ge(I.slice(3));b(w,!1);continue}let y=ge(I),A=l[y]||y;if(a.has(A)||a.has(y))b(y,!0);else{let w=e[u+1];if(w!==void 0&&!w.startsWith("-"))b(y,w),u++;else b(y,!0)}}}else if(p.startsWith("-")&&p.length>1){let k=p.slice(1);for(let I=0;I<k.length;I++){let y=k[I],A=l[y]||y;if(I===k.length-1&&!a.has(A)&&!a.has(y)){let w=e[u+1];if(w!==void 0&&!w.startsWith("-"))b(y,w),u++;else b(y,!0)}else b(y,!0)}}else r._.push(p)}return r}class Me{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,i,r){if(this.rawName=e,this.description=i,this.config=Object.assign({},r),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=xe(e).split(",").map((o)=>{let a=o.trim().replace(/^-{1,2}/,"");if(a.startsWith("no-"))this.negated=!0,a=a.replace(/^no-/,"");return fe(a)}).sort((o,a)=>o.length>a.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=Se.argv,it=`${Se.platform}-${Se.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,Pe=ye.argv,rt=`${ye.platform}-${ye.arch} node-${ye.version}`;class ke{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,i,r,o){this.rawName=e,this.description=i,this.config=r,this.cli=o,this.options=[],this.aliasNames=[],this.name=xe(e);let a=xe(e),l=a.indexOf(":");if(l>0)this.namespace=a.substring(0,l),this.name=a.substring(l+1);if(this.args=He(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!r)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,i="-v, --version"){return this.versionNumber=e,this.option(i,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,i,r){let o=new Me(e,i,r);return this.options.push(o),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 Ce}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){let i=fe(e.split(".")[0]);return!!this.options.find((r)=>r.names.some((o)=>fe(o)===i))}outputHelp(){let{name:e,commands:i}=this.cli,{versionNumber:r,options:o,helpCallback:a}=this.cli.globalCommand,l=[{body:`${e}${r?`/${r}`:""}`}];if(l.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&i.length>0){let p=_e(i.map((w)=>w.rawName)),k=new Map,I=[];for(let w of i)if(w.namespace){if(!k.has(w.namespace))k.set(w.namespace,[]);k.get(w.namespace).push(w)}else I.push(w);let y="";if(I.sort((w,W)=>w.rawName<W.rawName?-1:w.rawName>W.rawName?1:0),I.length>0)y+=I.map((w)=>` ${ve(w.rawName,p.length)} ${w.description}`).join(`
6
- `);let A=Array.from(k.keys()).sort();for(let w of A){let W=k.get(w);if(y.length>0)y+=`
7
-
8
- `;y+=` ${w}:
9
- `,y+=W.map((q)=>` ${ve(q.rawName,p.length-2)} ${q.description}`).join(`
10
- `)}l.push({title:"Commands",body:y}),l.push({body:`Run \`${e} <command> --help\` for command details.`})}let b=new Set(this.options.flatMap((p)=>p.names)),u=this.isGlobalCommand?o:[...this.options,...(o||[]).filter((p)=>!p.names.some((k)=>b.has(k)))];if(!this.isGlobalCommand&&!this.isDefaultCommand)u=u.filter((p)=>p.name!=="version");if(u.length>0){let p=_e(u.map((k)=>k.rawName));l.push({title:"Options",body:u.map((k)=>` ${ve(k.rawName,p.length)} ${k.description} ${k.config.default===void 0?"":`(default: ${k.config.default})`}`).join(`
11
- `)})}if(this.examples.length>0)l.push({title:"Examples",body:this.examples.map((p)=>{if(typeof p==="function")return p(e);return p}).join(`
12
- `)});if(a)l=a(l)||l;console.log(l.map((p)=>p.title?`${p.title}:
13
- ${p.body}`:p.body).join(`
14
-
15
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:i}=this.cli.globalCommand;if(i)console.log(`${e}/${i} ${typeof Bun<"u"?it:rt}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let e=this.args.filter((i)=>i.required).length;if(this.cli.args.length<e){let r=this.args.filter((a)=>a.required).slice(this.cli.args.length),o=r.map((a)=>`<${a.value}>`).join(" ");throw new me(`Missing required argument${r.length>1?"s":""}: ${o}
16
-
17
- Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:e,globalCommand:i}=this.cli;if(!this.config.allowUnknownOptions){for(let r of Object.keys(e))if(r!=="--"&&!this.hasOption(r)&&!i.hasOption(r)){let a=[...i.options,...this.options].flatMap((p)=>p.names),l=fe(r.split(".")[0]),g=r.length>1?`--${r}`:`-${r}`,b=Be(l,a),u=`Unknown option \`${g}\``;if(b.length>0)u+=`
18
-
19
- Did you mean one of these?`,b.forEach((p)=>{let k=p.length>1?`--${p}`:`-${p}`;u+=`
20
- • ${k}`});throw u+=`
21
-
22
- Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new me(u,this.usageLine)}}}checkOptionValue(){let{options:e,globalCommand:i}=this.cli,r=[...i.options,...this.options];for(let o of r){let a=e[o.name.split(".")[0]];if(o.required){let l=r.some((g)=>g.negated&&g.names.includes(o.name));if(a===!0||a===!1&&!l)throw new me(`Option \`${o.rawName}\` requires a value.
23
-
24
- Example: ${this.cli.name} ${this.rawName} ${o.rawName} <value>`,this.usageLine)}}}}class Ce extends ke{constructor(e){super("@@global@@","",{},e)}}var ot=ke,ne={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 ae={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function ct(){return!0}function lt(){let e={};e.supportsColor=ct();function i(o,a=[]){let l=o===""?[]:[...a,o],g=function(u){if(!e.supportsColor)return u;let p="",k="";for(let I of l)if(I in ae&&ae[I]in ne){let y=ae[I];p+=ne[y][0],k=ne[y][1]+k}else if(I in ne)p+=ne[I][0],k=ne[I][1]+k;return p+u+k},b=[...Object.keys(ne),...Object.keys(ae)];for(let u of b)if(!(u in g))Object.defineProperty(g,u,{get(){return i(u,l)}});return g}let r=[...Object.keys(ne),...Object.keys(ae)];for(let o of r)if(!(o in e))Object.defineProperty(e,o,{get(){return i(o)}});return e}var le=lt();class Ie extends qe{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 Ce(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let i=async(r)=>{if(console.log(`
25
-
26
- Received ${r}, cleaning up...`),e)try{await e()}catch(o){console.error("Error during cleanup:",o)}se.exit(0)};return se.on("SIGINT",()=>i("SIGINT")),se.on("SIGTERM",()=>i("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,i,r){if(!r)r={};let o=new ot(e,i||"",r,this);return o.globalCommand=this.globalCommand,this.commands.push(o),o}option(e,i,r){return this.globalCommand.option(e,i,r),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,i="-v, --version"){return this.globalCommand.version(e,i),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:i},r,o){if(this.args=e,this.options=i,r)this.matchedCommand=r;if(o)this.matchedCommandName=o;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(e){if(console.log(le.red(`
27
- ✗ Command "${e}" not found.
28
- `)),this.enableDidYouMean){let i=[];for(let o of this.commands){if(o.displayName)i.push(o.displayName);if(o.aliasNames)i.push(...o.aliasNames)}let r=Be(e,i);if(r.length>0)console.log(le.yellow("Did you mean one of these?")),r.forEach((o)=>console.log(` ${le.dim("•")} ${this.name} ${o}`)),console.log("")}console.log(le.dim("Run"),`${this.name} --help`,le.dim("to see all available commands")),se.exit(1)}async parse(e=Pe,i={}){let{run:r=!0,exitOnError:o=!1}=i;if(o)try{return await this.parse(e,{run:r})}catch(u){throw this.handleUsageError(u),u}if(this.rawArgs=e,!this.name)this.name=e[1]?Ze(e[1]):"cli";let a=!0,l=e.slice(2),g=l[0];if(g&&!g.startsWith("-")){for(let u of this.commands)if(u.isMatched(g)){let p=this.mri(l,u);a=!1;let k={...p,args:p.args.slice(1)};this.setParsedInfo(k,u,g),this.emit(`command:${g}`,u);break}if(a){let u=l[1];if(u&&!u.startsWith("-")){let p=`${g}:${u}`;for(let k of this.commands)if(k.isMatched(p)){let I=this.mri(l,k);a=!1;let y={...I,args:I.args.slice(2)};this.setParsedInfo(y,k,p),this.emit(`command:${p}`,k);break}}}}if(a){for(let u of this.commands)if(u.name===""){a=!1;let p=this.mri(l,u);this.setParsedInfo(p,u),this.emit("command:!",u);break}}if(a){let u=this.mri(e.slice(2));this.setParsedInfo(u)}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.options.interaction===!1)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||this.options.emoji===!1)this.useEmoji=!1;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache||this.options.cache===!1)this.isNoCache=!0;if(this.options.help&&this.showHelpOnExit)this.outputHelp(),r=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),r=!1,this.unsetMatchedCommand();let b={args:this.args,options:this.options};if(r)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return b}mri(e,i){let r=[...this.globalCommand.options,...i?i.options:[]],o=Ke(r),a=[],l=e.indexOf("--");if(l>-1)a=e.slice(l+1),e=e.slice(0,l);let g=nt(e,o),b={_:g._};for(let y of Object.keys(g))if(y!=="_")b[fe(y)]=g[y];let u=b._,p={"--":a},k=i&&i.config.ignoreOptionDefaultValue?i.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,I=Object.create(null);for(let y of r){if(!k&&y.config.default!==void 0)for(let A of y.names)p[A]=y.config.default;if(Array.isArray(y.config.type)){if(I[y.name]===void 0)I[y.name]={shouldTransform:!0,transformFunction:y.config.type[0]}}}for(let y of Object.keys(b))if(y!=="_"){let A=y.split(".");Je(p,A,b[y]),Ye(p,I)}return{args:u,options:p}}async run(e=Pe){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!Xe(e)||e.isUsageError===!1)return;let i=e.message||"command-line error",r=this.name?`${this.name}: `:"",o=/--help/.test(i)?"":e.usage?`
29
- Usage: ${e.usage}`:`
30
- Run \`${this.name??"cli"} --help\` for usage.`;se.stderr.write(`${r}${i}${o}
31
- `),se.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:i,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let o=[];r.args.forEach((b,u)=>{if(b.variadic)o.push(e.slice(u));else o.push(e[u])}),o.push(i);let a={command:r,args:o,options:i};for(let b of r.beforeHooks)await b(a);let l,g=async()=>{let b=r.commandAction.apply(this,o);if(b instanceof Promise)l=await b;else l=b;return l};if(r.middleware.length>0){let b=0,u=async()=>{if(b<r.middleware.length){let p=r.middleware[b++];await p({...a,next:u})}else await g()};await u()}else await g();for(let b of r.afterHooks)await b(a);return l}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return se.removeAllListeners("SIGINT"),se.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 Re{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 i=this.cache.get(e);if(!i){this.misses++;return}if(Date.now()-i.timestamp>i.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,i.value}set(e,i,r=5000){if(!this.enabled)return;this.cache.set(e,{value:i,timestamp:Date.now(),ttl:r})}has(e){if(!this.enabled)return!1;let i=this.cache.get(e);if(!i)return!1;if(Date.now()-i.timestamp>i.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[i,r]of this.cache.entries())if(e-r.timestamp>r.ttl)this.cache.delete(i)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var ls=new Re;function ut(){if("FORCE_COLOR"in pe.env)return pe.env.FORCE_COLOR!=="0";if("NO_COLOR"in pe.env||pe.env.TERM==="dumb")return!1;if(pe.platform==="win32")return!0;return De.isatty(1)&&De.isatty(2)}var Le=ut();function J(e,i){if(!Le)return(r)=>r;return(r)=>e+r+i}var dt=J("\x1B[0m","\x1B[0m"),ht=J("\x1B[31m","\x1B[39m"),pt=J("\x1B[32m","\x1B[39m"),ft=J("\x1B[33m","\x1B[39m"),mt=J("\x1B[34m","\x1B[39m"),gt=J("\x1B[35m","\x1B[39m"),yt=J("\x1B[36m","\x1B[39m"),$t=J("\x1B[37m","\x1B[39m"),bt=J("\x1B[90m","\x1B[39m"),wt=J("\x1B[1m","\x1B[22m"),vt=J("\x1B[3m","\x1B[23m"),xt=J("\x1B[4m","\x1B[24m"),St=J("\x1B[2m","\x1B[22m"),kt=J("\x1B[7m","\x1B[27m"),Ct=J("\x1B[8m","\x1B[28m"),It=J("\x1B[9m","\x1B[29m"),Ot=J("\x1B[41m","\x1B[49m"),Et=J("\x1B[42m","\x1B[49m"),Tt=J("\x1B[43m","\x1B[49m"),At=J("\x1B[44m","\x1B[49m"),_t=J("\x1B[45m","\x1B[49m"),jt=J("\x1B[46m","\x1B[49m"),Pt=J("\x1B[47m","\x1B[49m"),Dt=Le,Nt={reset:dt,red:ht,green:pt,yellow:ft,blue:mt,magenta:gt,cyan:yt,white:$t,gray:bt,bold:wt,italic:vt,underline:xt,dim:St,inverse:kt,hidden:Ct,strikethrough:It,bgRed:Ot,bgGreen:Et,bgYellow:Tt,bgBlue:At,bgMagenta:_t,bgCyan:jt,bgWhite:Pt,isColorSupported:Dt},Bt=Nt,Rt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Rt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Mt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Lt=Qe();var K=(e,i)=>Lt?e:i,$s=K("◆","*"),bs=K("■","x"),ws=K("▲","x"),vs=K("◇","o"),xs=K("┌","T"),Vt=K("│","|"),Ss=K("└","—"),ks=K("●",">"),Cs=K("○"," "),Is=K("◻","[•]"),Os=K("◼","[+]"),Es=K("◻","[ ]"),Ts=K("▪","•"),As=K("─","-"),_s=K("╮","+"),js=K("├","+"),Ps=K("╯","+"),Ds=K("●","•"),Ns=K("◆","*"),Bs=K("▲","!"),Ms=K("■","x");var Rs={light:K("─","-"),heavy:K("━","="),block:K("█","#")};function Ft(){return`${Bt.gray(Vt)} `}var Ls=Ft();var Ve="0.11.133";x();async function Wt(e="src/pantry"){if(!C.existsSync(e))throw Error(`Pantry directory not found: ${e}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let i=[];function r(o,a=""){let l=C.readdirSync(o,{withFileTypes:!0}),g=O.join(o,"package.yml");if(a&&C.existsSync(g))i.push(a);for(let b of l)if(b.isDirectory()&&!b.name.startsWith(".")){let u=a?`${a}/${b.name}`:b.name,p=O.join(o,b.name);r(p,u)}}return r(e),console.log(`\uD83D\uDCE6 Found ${i.length} packages in local pantry`),i.sort()}async function Ut(e=!1){async function i(g){let b=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(b.searchParams.set("list-type","2"),b.searchParams.set("prefix",""),b.searchParams.set("max-keys","1000"),g)b.searchParams.set("continuation-token",g);let u=await fetch(b.toString());if(!u.ok)throw Error(`Failed to fetch S3 listing: ${u.status}`);let p=await u.text(),k=[],I=p.match(/<Key>([^<]+)<\/Key>/g);if(I)for(let W of I){let q=W.replace(/<Key>([^<]+)<\/Key>/,"$1");k.push({Key:q})}let y=p.includes("<IsTruncated>true</IsTruncated>"),A=p.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),w=A?A[1]:void 0;return{IsTruncated:y,NextContinuationToken:w,Contents:k}}console.log("Scraping packages from S3 registry...");let r=new Set,o;do{let g=await i(o);for(let b of g.Contents){let u=b.Key,p=u.split("/");if(p.length===0)continue;if(p[0].startsWith(".")||p[0].includes(" ")||u.match(/\.(md|txt|yml|yaml|json)$/i))continue;let k=["darwin","linux","windows"],I=-1;for(let y=1;y<p.length;y++)if(k.includes(p[y])){I=y;break}if(I>0){let y=p.slice(0,I).join("/");if(y.includes("."))r.add(y)}else if(p.length>=2&&p[0].includes(".")&&!p[1].startsWith("v")&&!p[1].match(/^\d/)){let y=`${p[0]}/${p[1]}`;r.add(y)}else if(p.length>=1&&p[0].includes("."))r.add(p[0])}o=g.NextContinuationToken,console.log(`Found ${r.size} packages so far...`)}while(o);let a=Array.from(r).sort(),l=[];for(let g of a){if(!g.includes(".")||g.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(g.endsWith("/README.rst")||g.endsWith("/README")||g.includes("/docs/"))continue;if(g.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(g))continue;l.push(g)}return console.log(`\uD83D\uDCE6 Found ${l.length} valid packages in registry`),l}async function Gt(e,i){let o=`/**
2
+ import{z,F}from"../chunk-hygw1tjj.js";import{a,w,n,u,h,P,H,he,f,T,j,V,W,fe,be,s,X,S,m,Z,D,I,q,L,c,ee,we,Pe,Ue,ma,da}from"../chunk-h49t8bqz.js";import"../chunk-zjnhaw1v.js";import"../chunk-8f07ddwg.js";import{Ua}from"../chunk-1abg34mb.js";import g from"node:fs";import A from"node:path";import r from"node:process";w();async function ae(t="src/pantry"){if(!g.existsSync(t))throw Error(`Pantry directory not found: ${t}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let e=[];function o(i,l=""){let d=g.readdirSync(i,{withFileTypes:!0}),p=A.join(i,"package.yml");if(l&&g.existsSync(p))e.push(l);for(let b of d)if(b.isDirectory()&&!b.name.startsWith(".")){let x=l?`${l}/${b.name}`:b.name,v=A.join(i,b.name);o(v,x)}}return o(t),console.log(`\uD83D\uDCE6 Found ${e.length} packages in local pantry`),e.sort()}async function ce(t=!1){async function e(p){let b=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(b.searchParams.set("list-type","2"),b.searchParams.set("prefix",""),b.searchParams.set("max-keys","1000"),p)b.searchParams.set("continuation-token",p);let x=await fetch(b.toString());if(!x.ok)throw Error(`Failed to fetch S3 listing: ${x.status}`);let v=await x.text(),U=[],B=v.match(/<Key>([^<]+)<\/Key>/g);if(B)for(let J of B){let _=J.replace(/<Key>([^<]+)<\/Key>/,"$1");U.push({Key:_})}let k=v.includes("<IsTruncated>true</IsTruncated>"),R=v.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),y=R?R[1]:void 0;return{IsTruncated:k,NextContinuationToken:y,Contents:U}}console.log("Scraping packages from S3 registry...");let o=new Set,i;do{let p=await e(i);for(let b of p.Contents){let x=b.Key,v=x.split("/");if(v.length===0)continue;if(v[0].startsWith(".")||v[0].includes(" ")||x.match(/\.(md|txt|yml|yaml|json)$/i))continue;let U=["darwin","linux","windows"],B=-1;for(let k=1;k<v.length;k++)if(U.includes(v[k])){B=k;break}if(B>0){let k=v.slice(0,B).join("/");if(k.includes("."))o.add(k)}else if(v.length>=2&&v[0].includes(".")&&!v[1].startsWith("v")&&!v[1].match(/^\d/)){let k=`${v[0]}/${v[1]}`;o.add(k)}else if(v.length>=1&&v[0].includes("."))o.add(v[0])}i=p.NextContinuationToken,console.log(`Found ${o.size} packages so far...`)}while(i);let l=Array.from(o).sort(),d=[];for(let p of l){if(!p.includes(".")||p.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(p.endsWith("/README.rst")||p.endsWith("/README")||p.includes("/docs/"))continue;if(p.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(p))continue;d.push(p)}return console.log(`\uD83D\uDCE6 Found ${d.length} valid packages in registry`),d}async function le(t,e){let i=`/**
32
3
  * Constants used throughout the ts-pantry package
33
- * This file is auto-generated from ${i}. Do not edit manually.
4
+ * This file is auto-generated from ${e}. Do not edit manually.
34
5
  * Generated on ${new Date().toISOString()}
35
6
  */
36
7
 
@@ -74,36 +45,36 @@ export const PACKAGE_ALIASES: Record<string, string> = {
74
45
  } as const
75
46
 
76
47
  /**
77
- * List of all known packages (${e.length} total)
48
+ * List of all known packages (${t.length} total)
78
49
  */
79
50
  export const ALL_KNOWN_PACKAGES: readonly string[] = [
80
- ${e.map((a)=>` '${a}',`).join(`
51
+ ${t.map((l)=>` '${l}',`).join(`
81
52
  `)}
82
53
  ] as const
83
- `;C.writeFileSync("src/consts.ts",o,"utf-8")}function qt(e){if(!e)return;let r=e.toLowerCase().replace(/_/g,"-").match(/^(darwin|macos|linux|windows|win32)-(x86-64|x64|amd64|aarch64|arm64)$/),o=r?.[1],a=r?.[2],l=o==="macos"||o==="darwin"?"darwin":o==="linux"?"linux":o==="windows"||o==="win32"?"windows":void 0,g=a==="x64"||a==="x86-64"||a==="amd64"?"x86_64":a==="arm64"||a==="aarch64"?"aarch64":void 0;if(!l||!g)throw Error(`Invalid platform "${e}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:l,arch:g}}var F=new Ie("ts-pantry"),Ht=1500000,Oe=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),v.exit(1)},Ht);v.on("exit",()=>{clearTimeout(Oe)});async function We(e){console.log(`
84
- Received ${e} signal. Cleaning up resources...`),clearTimeout(Oe);try{await m(),console.log("Resources cleaned up. Exiting.")}catch(i){console.error("Error during cleanup:",i)}setTimeout(()=>{console.log("Forcing process exit..."),v.exit(0)},1000)}v.on("SIGINT",()=>We("SIGINT"));v.on("SIGTERM",()=>We("SIGTERM"));function Fe(e){let i={};for(let[r,o]of Object.entries(t))if(typeof o==="string")i[o]=r;return i[e]||e}function ze(e){let i=e.map(Fe),r=e.map((o)=>{let a=Fe(o);return a===o?o:a});return{friendlyNames:i,mixedNames:r}}F.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:n}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:d}).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:h}).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,i)=>{let{all:r,outputDir:o="src/packages",cacheDir:a=n,cache:l=!0,cacheExpiration:g=d,limit:b,timeout:u=h,json:p=!1,debug:k=!1,verbose:I=!1,concurrency:y=8,pkg:A,outputJson:w=!1}=i,W=O.resolve(v.cwd(),o);if(!C.existsSync(W))C.mkdirSync(W,{recursive:!0});let q=O.resolve(v.cwd(),a);if(l){if(!C.existsSync(q))C.mkdirSync(q,{recursive:!0})}try{let N=[],H=[];if(r){if(!w)console.log("Fetching all packages...");let B={outputDir:o,cacheDir:a,cache:l,cacheExpirationMinutes:g,timeout:Number.parseInt(String(u),10),debug:k,limit:b?Number.parseInt(String(b),10):void 0,concurrency:Math.min(Number.parseInt(String(y),10),12),outputJson:w};N=await V(B),H=[...N]}else if(A){let B=A.split(",").map((R)=>R.trim());if(!w)console.log(`Fetching ${B.length} packages: ${B.join(", ")}`);for(let R of B)try{let X=O.join(a,`${R.replace(/\//g,"-")}.json`),Q=!1;if(l&&C.existsSync(X)){let ee=C.statSync(X),te=(Date.now()-ee.mtime.getTime())/60000;if(te<g){if(!w)console.log(`Using cached data for ${R} (age: ${Math.round(te)} minutes)`);try{let Ee=JSON.parse(C.readFileSync(X,"utf-8"));delete Ee.fetchedAt;let Ue=s(o,R,Ee);if(I&&!w)console.log(`Using cached data for ${R} (saved to ${Ue})`);N.push(R),Q=!0;continue}catch{console.warn(`Cache file corrupted for ${R}, will refetch`)}}}if(!Q){let ee=await D(R,{timeout:Number.parseInt(String(u),10),debug:k,outputJson:w,cacheDir:a,cache:l,cacheExpirationMinutes:g});if(ee){let{outputPath:te}=U(R,ee.packageInfo,{cacheDir:a,outputDir:o,cache:l});if(N.push(R),H.push(R),I&&!w)console.log(`Successfully saved ${R} to ${te}`)}}}catch(X){console.error(`Error processing ${R}:`,X)}}else if(e){if(!w)console.log(`Fetching package: ${e}`);try{let B=O.join(q,`${e.replace(/\//g,"-")}.json`),R=!1;if(l&&C.existsSync(B)){let X=C.statSync(B),Q=(Date.now()-X.mtime.getTime())/60000;if(Q<g){if(!w)console.log(`Using cached data for ${e} (age: ${Math.round(Q)} minutes)`);try{let ee=JSON.parse(C.readFileSync(B,"utf-8"));delete ee.fetchedAt;let te=s(W,e,ee);if(I&&!w)console.log(`Using cached data for ${e} (saved to ${te})`);N.push(e),R=!0}catch{console.warn(`Cache file corrupted for ${e}, will refetch`)}}}if(!R){let X=await D(e,{timeout:Number.parseInt(String(u),10),debug:k,outputJson:w,cacheDir:a,cache:l,cacheExpirationMinutes:g});if(X){let{outputPath:Q}=U(e,X.packageInfo,{cacheDir:a,outputDir:o,cache:l});if(N.push(e),H.push(e),I&&!w)console.log(`Successfully saved ${e} to ${Q}`)}}}catch(B){console.error(`Error processing ${e}:`,B)}}else{if(!w)console.error("Error: Please specify a package name, use --pkg, or use --all");v.exit(1)}if(!p&&N.length>0){let B=await S();if(!w)console.log(`Successfully generated ${B}`)}if(r&&N.length>0){let B=M(W,N);if(B.length>0&&!w)console.log(`Cleaned up ${B.length} stale generated file(s)`)}if(w){let{friendlyNames:B,mixedNames:R}=ze(H),{friendlyNames:X,mixedNames:Q}=ze(N),ee={success:!0,updatedPackages:H,updatedPackagesFriendly:B,updatedPackagesMixed:R,allProcessedPackages:N,allProcessedFriendly:X,allProcessedMixed:Q,totalUpdated:H.length,totalProcessed:N.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(ee))}else console.log(`Processed ${N.length} packages.`);clearTimeout(Oe),await m(),setTimeout(()=>v.exit(0),1000)}catch(N){if(w){let H={success:!1,error:String(N),timestamp:new Date().toISOString()};console.log(JSON.stringify(H))}else console.error("Error:",N);await m(),setTimeout(()=>v.exit(1),1000)}});F.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:i="src/packages"}=e,r=O.resolve(v.cwd(),i);if(!C.existsSync(r))console.error(`Error: Directory ${r} does not exist`),v.exit(1);try{let o=await S();console.log(`Successfully generated ${o}`),setTimeout(()=>v.exit(0),500)}catch(o){console.error("Error generating index:",o),v.exit(1)}});F.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:n}).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:i,outputDir:r}=e;if(!C.existsSync(i))console.error(`Cache directory ${i} does not exist!`),v.exit(1);if(!C.existsSync(r))C.mkdirSync(r,{recursive:!0});let o=C.readdirSync(i).filter((l)=>l.endsWith(".json"));console.log(`Found ${o.length} JSON files in cache directory`);let a=0;for(let l of o)try{let g=C.readFileSync(O.join(i,l),"utf-8"),b=JSON.parse(g);delete b.fetchedAt;let u=l.replace(/\.json$/,""),p=s(r,b.fullPath||b.domain||u,b);console.log(`Generated ${p}`),a++}catch(g){console.error(`Error processing ${l}:`,g)}console.log(`Successfully generated ${a} TypeScript files from JSON cache`)}catch(i){console.error("Error generating TypeScript files:",i),v.exit(1)}});F.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let e=await _();console.log(`Successfully generated ${e}`),setTimeout(()=>v.exit(0),500)}catch(e){console.error("Error generating aliases:",e),v.exit(1)}});F.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:i="docs"}=e;await T(i),setTimeout(()=>v.exit(0),500)}catch(i){console.error("Error generating documentation:",i),v.exit(1)}});F.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:i="src/pantry"}=e,r=O.resolve(v.cwd(),i);console.log("Downloading pantry.tgz...");let o=await fetch("https://s3.amazonaws.com/dist.tea.xyz/pantry.tgz");if(!o.ok)throw Error(`Failed to download pantry.tgz: ${o.statusText}`);let a=await o.arrayBuffer(),l=O.join(v.cwd(),"pantry.tgz");C.writeFileSync(l,new Uint8Array(a)),console.log(`Downloaded ${a.byteLength} bytes`),C.mkdirSync(r,{recursive:!0});let g=O.join(v.cwd(),"temp-pantry"),{spawn:b}=await import("node:child_process");if(C.existsSync(g))C.rmSync(g,{recursive:!0,force:!0});C.mkdirSync(g,{recursive:!0});let u=b("tar",["-xzf",l,"-C",g,"--strip-components=1"],{stdio:"inherit"});await new Promise((y,A)=>{u.on("close",(w)=>{if(w===0)y(w);else A(Error(`tar extraction failed with code ${w}`))}),u.on("error",A)});let p=O.join(g,"projects");if(C.existsSync(p)){let y=C.readdirSync(p),A=0,w=0,W=(q,N)=>{if(!C.existsSync(N))C.mkdirSync(N,{recursive:!0});for(let H of C.readdirSync(q,{withFileTypes:!0})){let B=O.join(q,H.name),R=O.join(N,H.name);if(H.isDirectory())W(B,R);else if(H.name==="package.yml")if(C.existsSync(R))w++;else C.renameSync(B,R),A++;else if(!C.existsSync(R))C.renameSync(B,R)}};console.log(`Merging ${y.length} projects from upstream...`);for(let q of y){let N=O.join(p,q),H=O.join(r,q);if(C.statSync(N).isDirectory())W(N,H)}console.log(`Merged upstream pantry: ${A} new packages added, ${w} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(C.unlinkSync(l),C.existsSync(g))C.rmSync(g,{recursive:!0,force:!0});console.log(`
85
- Downloading props files from pkgx/pantry GitHub repo...`);let I=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(I.ok){let y=await I.arrayBuffer(),A=O.join(v.cwd(),"pantry-gh.tar.gz"),w=O.join(v.cwd(),"temp-pantry-gh");if(C.writeFileSync(A,new Uint8Array(y)),console.log(`Downloaded GitHub archive: ${(y.byteLength/1024/1024).toFixed(1)} MB`),C.existsSync(w))C.rmSync(w,{recursive:!0,force:!0});C.mkdirSync(w,{recursive:!0});let W=b("tar",["-xzf",A,"-C",w,"--strip-components=1"],{stdio:"inherit"});await new Promise((N,H)=>{W.on("close",(B)=>B===0?N(B):H(Error(`tar failed: ${B}`))),W.on("error",H)});let q=O.join(w,"projects");if(C.existsSync(q)){let N=0,H=0,B=(R,X)=>{if(!C.existsSync(R))return;for(let Q of C.readdirSync(R,{withFileTypes:!0})){let ee=O.join(R,Q.name),te=O.join(X,Q.name);if(Q.isDirectory())B(ee,te);else if(Q.name!=="package.yml")if(C.mkdirSync(X,{recursive:!0}),C.copyFileSync(ee,te),C.existsSync(te))H++;else N++}};B(q,r),console.log(`Props files: ${N+H} synced (${N} new, ${H} updated)`)}if(C.unlinkSync(A),C.existsSync(w))C.rmSync(w,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${I.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),C.existsSync(r)){let y=C.readdirSync(r).filter((A)=>{let w=O.join(r,A);return C.statSync(w).isDirectory()&&!A.startsWith(".")});console.log(`Final result: ${y.length} projects in ${r}`)}v.exit(0)}catch(i){console.error("Error updating pantry:",i),v.exit(1)}});F.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:i="pantry",pantryDir:r="src/pantry",validate:o=!1}=e;console.log(`\uD83D\uDE80 Generating consts.ts file using ${i} as source...`);let a=[];if(i==="pantry")a=await Wt(r);else if(i==="registry")a=await Ut(o);else console.error('Invalid source. Use "pantry" or "registry"'),v.exit(1);await Gt(a,i),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${a.length}`);let l=new Date().toISOString(),g=`Generated from ${i} at ${l}
86
- Total packages: ${a.length}
54
+ `;g.writeFileSync("src/consts.ts",i,"utf-8")}function pe(t){if(!t)return;let o=t.toLowerCase().replace(/_/g,"-").match(/^(darwin|macos|linux|windows|win32)-(x86-64|x64|amd64|aarch64|arm64)$/),i=o?.[1],l=o?.[2],d=i==="macos"||i==="darwin"?"darwin":i==="linux"?"linux":i==="windows"||i==="win32"?"windows":void 0,p=l==="x64"||l==="x86-64"||l==="amd64"?"x86_64":l==="arm64"||l==="aarch64"?"aarch64":void 0;if(!d||!p)throw Error(`Invalid platform "${t}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:d,arch:p}}var N=new z("ts-pantry"),de=1500000,te=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),r.exit(1)},de);r.on("exit",()=>{clearTimeout(te)});async function re(t){console.log(`
55
+ Received ${t} signal. Cleaning up resources...`),clearTimeout(te);try{await m(),console.log("Resources cleaned up. Exiting.")}catch(e){console.error("Error during cleanup:",e)}setTimeout(()=>{console.log("Forcing process exit..."),r.exit(0)},1000)}r.on("SIGINT",()=>re("SIGINT"));r.on("SIGTERM",()=>re("SIGTERM"));function oe(t){let e={};for(let[o,i]of Object.entries(a))if(typeof i==="string")e[i]=o;return e[t]||t}function ie(t){let e=t.map(oe),o=t.map((i)=>{let l=oe(i);return l===i?i:l});return{friendlyNames:e,mixedNames:o}}N.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:n}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:u}).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:h}).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(t,e)=>{let{all:o,outputDir:i="src/packages",cacheDir:l=n,cache:d=!0,cacheExpiration:p=u,limit:b,timeout:x=h,json:v=!1,debug:U=!1,verbose:B=!1,concurrency:k=8,pkg:R,outputJson:y=!1}=e,J=A.resolve(r.cwd(),i);if(!g.existsSync(J))g.mkdirSync(J,{recursive:!0});let _=A.resolve(r.cwd(),l);if(d){if(!g.existsSync(_))g.mkdirSync(_,{recursive:!0})}try{let C=[],M=[];if(o){if(!y)console.log("Fetching all packages...");let E={outputDir:i,cacheDir:l,cache:d,cacheExpirationMinutes:p,timeout:Number.parseInt(String(x),10),debug:U,limit:b?Number.parseInt(String(b),10):void 0,concurrency:Math.min(Number.parseInt(String(k),10),12),outputJson:y};C=await Z(E),M=[...C]}else if(R){let E=R.split(",").map((O)=>O.trim());if(!y)console.log(`Fetching ${E.length} packages: ${E.join(", ")}`);for(let O of E)try{let G=A.join(l,`${O.replace(/\//g,"-")}.json`),K=!1;if(d&&g.existsSync(G)){let Y=g.statSync(G),Q=(Date.now()-Y.mtime.getTime())/60000;if(Q<p){if(!y)console.log(`Using cached data for ${O} (age: ${Math.round(Q)} minutes)`);try{let ne=JSON.parse(g.readFileSync(G,"utf-8"));delete ne.fetchedAt;let se=s(i,O,ne);if(B&&!y)console.log(`Using cached data for ${O} (saved to ${se})`);C.push(O),K=!0;continue}catch{console.warn(`Cache file corrupted for ${O}, will refetch`)}}}if(!K){let Y=await D(O,{timeout:Number.parseInt(String(x),10),debug:U,outputJson:y,cacheDir:l,cache:d,cacheExpirationMinutes:p});if(Y){let{outputPath:Q}=S(O,Y.packageInfo,{cacheDir:l,outputDir:i,cache:d});if(C.push(O),M.push(O),B&&!y)console.log(`Successfully saved ${O} to ${Q}`)}}}catch(G){console.error(`Error processing ${O}:`,G)}}else if(t){if(!y)console.log(`Fetching package: ${t}`);try{let E=A.join(_,`${t.replace(/\//g,"-")}.json`),O=!1;if(d&&g.existsSync(E)){let G=g.statSync(E),K=(Date.now()-G.mtime.getTime())/60000;if(K<p){if(!y)console.log(`Using cached data for ${t} (age: ${Math.round(K)} minutes)`);try{let Y=JSON.parse(g.readFileSync(E,"utf-8"));delete Y.fetchedAt;let Q=s(J,t,Y);if(B&&!y)console.log(`Using cached data for ${t} (saved to ${Q})`);C.push(t),O=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!O){let G=await D(t,{timeout:Number.parseInt(String(x),10),debug:U,outputJson:y,cacheDir:l,cache:d,cacheExpirationMinutes:p});if(G){let{outputPath:K}=S(t,G.packageInfo,{cacheDir:l,outputDir:i,cache:d});if(C.push(t),M.push(t),B&&!y)console.log(`Successfully saved ${t} to ${K}`)}}}catch(E){console.error(`Error processing ${t}:`,E)}}else{if(!y)console.error("Error: Please specify a package name, use --pkg, or use --all");r.exit(1)}if(!v&&C.length>0){let E=await I();if(!y)console.log(`Successfully generated ${E}`)}if(o&&C.length>0){let E=X(J,C);if(E.length>0&&!y)console.log(`Cleaned up ${E.length} stale generated file(s)`)}if(y){let{friendlyNames:E,mixedNames:O}=ie(M),{friendlyNames:G,mixedNames:K}=ie(C),Y={success:!0,updatedPackages:M,updatedPackagesFriendly:E,updatedPackagesMixed:O,allProcessedPackages:C,allProcessedFriendly:G,allProcessedMixed:K,totalUpdated:M.length,totalProcessed:C.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(Y))}else console.log(`Processed ${C.length} packages.`);clearTimeout(te),await m(),setTimeout(()=>r.exit(0),1000)}catch(C){if(y){let M={success:!1,error:String(C),timestamp:new Date().toISOString()};console.log(JSON.stringify(M))}else console.error("Error:",C);await m(),setTimeout(()=>r.exit(1),1000)}});N.command("generate-index","Generate TypeScript index file for packages").option("-o, --output-dir <dir>","Directory containing package files",{default:"src/packages"}).action(async(t)=>{let{outputDir:e="src/packages"}=t,o=A.resolve(r.cwd(),e);if(!g.existsSync(o))console.error(`Error: Directory ${o} does not exist`),r.exit(1);try{let i=await I();console.log(`Successfully generated ${i}`),setTimeout(()=>r.exit(0),500)}catch(i){console.error("Error generating index:",i),r.exit(1)}});N.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:n}).option("--output-dir <dir>","Output directory for TypeScript files",{default:"packages"}).action(async(t)=>{try{console.log("Generating TypeScript files from cached JSON...");let{cacheDir:e,outputDir:o}=t;if(!g.existsSync(e))console.error(`Cache directory ${e} does not exist!`),r.exit(1);if(!g.existsSync(o))g.mkdirSync(o,{recursive:!0});let i=g.readdirSync(e).filter((d)=>d.endsWith(".json"));console.log(`Found ${i.length} JSON files in cache directory`);let l=0;for(let d of i)try{let p=g.readFileSync(A.join(e,d),"utf-8"),b=JSON.parse(p);delete b.fetchedAt;let x=d.replace(/\.json$/,""),v=s(o,b.fullPath||b.domain||x,b);console.log(`Generated ${v}`),l++}catch(p){console.error(`Error processing ${d}:`,p)}console.log(`Successfully generated ${l} TypeScript files from JSON cache`)}catch(e){console.error("Error generating TypeScript files:",e),r.exit(1)}});N.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let t=await q();console.log(`Successfully generated ${t}`),setTimeout(()=>r.exit(0),500)}catch(t){console.error("Error generating aliases:",t),r.exit(1)}});N.command("generate-docs","Generate comprehensive BunPress documentation for all packages").option("-o, --output-dir <dir>","Output directory for documentation",{default:"docs"}).action(async(t)=>{try{let{outputDir:e="docs"}=t;await L(e),setTimeout(()=>r.exit(0),500)}catch(e){console.error("Error generating documentation:",e),r.exit(1)}});N.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(t)=>{try{let{pantryDir:e="src/pantry"}=t,o=A.resolve(r.cwd(),e);console.log("Downloading pantry.tgz...");let i=await fetch("https://s3.amazonaws.com/dist.tea.xyz/pantry.tgz");if(!i.ok)throw Error(`Failed to download pantry.tgz: ${i.statusText}`);let l=await i.arrayBuffer(),d=A.join(r.cwd(),"pantry.tgz");g.writeFileSync(d,new Uint8Array(l)),console.log(`Downloaded ${l.byteLength} bytes`),g.mkdirSync(o,{recursive:!0});let p=A.join(r.cwd(),"temp-pantry"),{spawn:b}=await import("node:child_process");if(g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});g.mkdirSync(p,{recursive:!0});let x=b("tar",["-xzf",d,"-C",p,"--strip-components=1"],{stdio:"inherit"});await new Promise((k,R)=>{x.on("close",(y)=>{if(y===0)k(y);else R(Error(`tar extraction failed with code ${y}`))}),x.on("error",R)});let v=A.join(p,"projects");if(g.existsSync(v)){let k=g.readdirSync(v),R=0,y=0,J=(_,C)=>{if(!g.existsSync(C))g.mkdirSync(C,{recursive:!0});for(let M of g.readdirSync(_,{withFileTypes:!0})){let E=A.join(_,M.name),O=A.join(C,M.name);if(M.isDirectory())J(E,O);else if(M.name==="package.yml")if(g.existsSync(O))y++;else g.renameSync(E,O),R++;else if(!g.existsSync(O))g.renameSync(E,O)}};console.log(`Merging ${k.length} projects from upstream...`);for(let _ of k){let C=A.join(v,_),M=A.join(o,_);if(g.statSync(C).isDirectory())J(C,M)}console.log(`Merged upstream pantry: ${R} new packages added, ${y} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(g.unlinkSync(d),g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});console.log(`
56
+ Downloading props files from pkgx/pantry GitHub repo...`);let B=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(B.ok){let k=await B.arrayBuffer(),R=A.join(r.cwd(),"pantry-gh.tar.gz"),y=A.join(r.cwd(),"temp-pantry-gh");if(g.writeFileSync(R,new Uint8Array(k)),console.log(`Downloaded GitHub archive: ${(k.byteLength/1024/1024).toFixed(1)} MB`),g.existsSync(y))g.rmSync(y,{recursive:!0,force:!0});g.mkdirSync(y,{recursive:!0});let J=b("tar",["-xzf",R,"-C",y,"--strip-components=1"],{stdio:"inherit"});await new Promise((C,M)=>{J.on("close",(E)=>E===0?C(E):M(Error(`tar failed: ${E}`))),J.on("error",M)});let _=A.join(y,"projects");if(g.existsSync(_)){let C=0,M=0,E=(O,G)=>{if(!g.existsSync(O))return;for(let K of g.readdirSync(O,{withFileTypes:!0})){let Y=A.join(O,K.name),Q=A.join(G,K.name);if(K.isDirectory())E(Y,Q);else if(K.name!=="package.yml")if(g.mkdirSync(G,{recursive:!0}),g.copyFileSync(Y,Q),g.existsSync(Q))M++;else C++}};E(_,o),console.log(`Props files: ${C+M} synced (${C} new, ${M} updated)`)}if(g.unlinkSync(R),g.existsSync(y))g.rmSync(y,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${B.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),g.existsSync(o)){let k=g.readdirSync(o).filter((R)=>{let y=A.join(o,R);return g.statSync(y).isDirectory()&&!R.startsWith(".")});console.log(`Final result: ${k.length} projects in ${o}`)}r.exit(0)}catch(e){console.error("Error updating pantry:",e),r.exit(1)}});N.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(t)=>{try{let{source:e="pantry",pantryDir:o="src/pantry",validate:i=!1}=t;console.log(`\uD83D\uDE80 Generating consts.ts file using ${e} as source...`);let l=[];if(e==="pantry")l=await ae(o);else if(e==="registry")l=await ce(i);else console.error('Invalid source. Use "pantry" or "registry"'),r.exit(1);await le(l,e),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${l.length}`);let d=new Date().toISOString(),p=`Generated from ${e} at ${d}
57
+ Total packages: ${l.length}
87
58
 
88
- ${a.join(`
89
- `)}`;C.writeFileSync(`${i}-packages-summary.txt`,g),console.log(`\uD83D\uDCC4 Created ${i}-packages-summary.txt for reference`),v.exit(0)}catch(i){console.error("Error generating consts file:",i),v.exit(1)}});F.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,i)=>{try{let{dir:r=".",packagesDir:o="src/packages",targetOs:a,includeOsDeps:l=!1,maxDepth:g=10,verbose:b=!1,json:u=!1,installCommand:p=!1}=i,k=e||i.file;if(!k){let A=re(r);if(A.length===0)console.error(`No dependency files found in ${r}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),v.exit(1);else if(A.length>1)console.error(`Multiple dependency files found in ${r}:`),A.forEach((w)=>console.error(` ${w}`)),console.error("Please specify which file to use with --file or [file] argument"),v.exit(1);else if(k=A[0],!u)console.log(`Found dependency file: ${k}`)}if(!C.existsSync(k))console.error(`Dependency file not found: ${k}`),v.exit(1);let I={packagesDir:o,includeOsSpecific:l,targetOs:a,maxDepth:Number.parseInt(String(g),10),verbose:b&&!u};if(!u)console.log("\uD83D\uDD0D Resolving dependencies...");let y=await Y(k,I);if(u){let A={success:!0,file:k,summary:{totalUnique:y.uniquePackages.length,conflicts:y.conflicts.length,osSpecific:{linux:y.osSpecificDeps.linux.length,darwin:y.osSpecificDeps.darwin.length,windows:y.osSpecificDeps.windows.length}},packages:y.uniquePackages,dependencies:y.allDependencies,conflicts:y.conflicts,osSpecificDeps:y.osSpecificDeps,timestamp:new Date().toISOString()};console.log(JSON.stringify(A,null,2))}else{if(console.log(`
90
- ✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${y.uniquePackages.length}`),y.conflicts.length>0)console.log(`⚠️ Version conflicts: ${y.conflicts.length}`),console.log(`
91
- Conflicts found:`),y.conflicts.forEach((w)=>{console.log(` ${w.package}: ${w.versions.join(", ")}`)});if(console.log(`
92
- \uD83D\uDCCB All unique packages to install:`),y.uniquePackages.forEach((w,W)=>{let q=y.allDependencies.find((H)=>H.name===w),N=q&&q.version&&q.version!=="latest"?` (${q.version})`:"";console.log(` ${W+1}. ${w}${N}`)}),p)console.log(`
93
- \uD83D\uDE80 Install command:`),console.log(`pantry install ${y.uniquePackages.join(" ")}`);if(Object.values(y.osSpecificDeps).reduce((w,W)=>w+W.length,0)>0)console.log(`
94
- \uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(y.osSpecificDeps).forEach(([w,W])=>{if(W.length>0)console.log(` ${w}: ${W.map((q)=>q.name).join(", ")}`)})}v.exit(0)}catch(r){if(i.json){let o={success:!1,error:String(r),timestamp:new Date().toISOString()};console.log(JSON.stringify(o))}else console.error("Error resolving dependencies:",r);v.exit(1)}});F.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:i}=await import("../chunk-xq09n371.js"),r={};if(e.branches)r.supportedBranches=e.branches.split(",").map((a)=>a.trim());if(e.fallback)r.fallbackVersions=e.fallback.split(",").map((a)=>a.trim());let o=i(r);switch(e.format.toLowerCase()){case"yaml":console.log(`php_versions:
95
- ${o.map((a)=>` - "${a}"`).join(`
96
- `)}`);break;case"csv":console.log(o.join(","));break;case"json":default:console.log(JSON.stringify(o));break}v.exit(0)}catch(i){console.error("Error getting PHP versions:",i),v.exit(1)}});F.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:i,generateZigAliases:r}=await import("../chunk-m59dtz1w.js"),{packagesDir:o="src/packages",output:a="packages.zig",aliases:l=!1,aliasesOutput:g="aliases.zig"}=e;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await i(o,a),l)console.log(`
97
- \uD83D\uDE80 Generating Zig package aliases...`),await r(o,g);console.log(`
98
- ✅ Zig code generation complete!`),v.exit(0)}catch(i){console.error("Error generating Zig definitions:",i),v.exit(1)}});F.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,i)=>{let r=(e??"patch").toLowerCase();if(!["patch","minor","major"].includes(r))console.error(`error: invalid release type "${r}" (expected: patch | minor | major)`),v.exit(1);let{runRelease:o}=await import("../chunk-cwa30yjr.js"),a=await o({type:r,yes:i.yes,dryRun:i.dryRun,noChangelog:i.changelog===!1,noPush:i.push===!1,noPublish:i.publish===!1});v.exit(a.exitCode)});F.command("apps","List installed desktop applications with version info").option("-j, --json","Output as JSON").action(async(e)=>{try{let{scanInstalledApps:i}=await import("../chunk-nk4tf28s.js"),r=i();if(e.json)console.log(JSON.stringify({success:!0,apps:r,total:r.length}));else{console.log(`
99
- Installed Desktop Apps (${r.length}):
100
- `),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let o of r)console.log(`${o.name.padEnd(40)}${o.version}`)}v.exit(0)}catch(i){console.error("Error listing apps:",i),v.exit(1)}});F.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(e)=>{try{let{checkAppUpdates:i}=await import("../chunk-nk4tf28s.js");if(!e.json)console.log("Checking desktop apps for updates...");let r=await i(),o=r.filter((a)=>a.updateAvailable);if(e.json)console.log(JSON.stringify({success:!0,apps:r,outdated:o.length,total:r.length,timestamp:new Date().toISOString()}));else{if(o.length>0){console.log(`
101
- Outdated Apps (${o.length}):
102
- `),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let l of o)console.log(`${l.name.padEnd(30)}${l.currentVersion.padEnd(16)}${(l.latestVersion||"?").padEnd(16)}${l.source}`)}else console.log(`
103
- All desktop apps are up to date!`);let a=r.filter((l)=>!l.updateAvailable&&l.source!=="system"&&l.source!=="unknown");if(a.length>0)console.log(`
104
- ${a.length} app(s) up to date, ${r.filter((l)=>l.source==="unknown").length} unchecked`)}v.exit(0)}catch(i){console.error("Error checking app updates:",i),v.exit(1)}});F.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(e)=>{try{let{updateApp:i}=await import("../chunk-nk4tf28s.js");console.log(`Updating ${e} from the pantry registry...`);let r=await i(e);if(r.success)console.log(`Successfully updated ${e} to ${r.version}`);else console.error(`Failed to update ${e}: ${r.error}`),v.exit(1);v.exit(0)}catch(i){console.error("Error updating app:",i),v.exit(1)}});F.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,i)=>{let r=e.lastIndexOf("@"),o=r>0,a=o?e.slice(0,r):e,l=o?e.slice(r+1):"latest";try{let g=await z(a,l,{installDir:i.installDir,platform:qt(i.platform),createBinLinks:i.binLinks!==!1,quiet:i.quiet,globalBin:i.global?!0:void 0});if(!i.quiet){if(console.log(`
105
- ✓ ${g.name}@${g.version}`),console.log(` installed to: ${g.installPath}`),g.globalLinks&&g.globalLinks.length>0){if(console.log(` linked into: ${O.dirname(g.globalLinks[0])}`),!v.env.PATH?.split(O.delimiter).includes(O.dirname(g.globalLinks[0])))console.log(`
106
- ⚠ ${O.dirname(g.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}v.exit(0)}catch(g){console.error(`Error installing ${e}:`,g instanceof Error?g.message:g),v.exit(1)}});function Kt(e){let i=re(e);if(i.length===0)return[];try{return P(i[0]).map((r)=>r.version&&r.version!=="latest"?`${r.name}@${String(r.version).replace(/^[\^~>=<]+/,"")}`:r.name)}catch{return[]}}F.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 i=O.resolve(e.dir??v.cwd()),r=Kt(i);if(e.install&&r.length>0)for(let l of r){let g=l.lastIndexOf("@"),b=g>0;await z(b?l.slice(0,g):l,b?l.slice(g+1):"latest",{globalBin:!0,quiet:!0}).catch((u)=>{console.error(`# could not install ${l}: ${u instanceof Error?u.message:u}`)})}let o=f(),a=[O.join(i,".bin"),o].filter((l)=>C.existsSync(l));if(e.json)console.log(JSON.stringify({path:a,PATH:[...a,v.env.PATH??""].filter(Boolean).join(O.delimiter),dependencies:r,globalBin:o},null,2)),v.exit(0);console.log(`export PATH="${[...a,"$PATH"].join(O.delimiter)}"`),v.exit(0)});F.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 i=e.shell??j();try{if(e.uninstall){let o=ce({shell:i});console.log(o.changed?`✓ Removed pantry shell-init from ${o.rcFile}`:`Nothing to remove (no pantry shell-init block in ${o.rcFile})`),v.exit(0)}if(e.install){let o=ie({shell:i});if(o.changed)console.log(`✓ Added pantry shell-init to ${o.rcFile}`),console.log(` Restart your shell or run: source ${o.rcFile}`);else console.log(`✓ Already integrated in ${o.rcFile}`);v.exit(0)}let r=E(i);if(v.stdout.isTTY){if(console.log(`# Detected shell: ${i}`),console.log(`# Global bin dir: ${f()}`),r)console.log(`# Append this to: ${r}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}v.stdout.write(L({shell:i})),v.exit(0)}catch(r){console.error("Error:",r instanceof Error?r.message:r),v.exit(1)}});F.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,i)=>{try{let r=[].concat(i.tag??[]),o={};for(let l of[].concat(i.buildArg??[])){let g=l.indexOf("=");if(g!==-1)o[l.slice(0,g)]=l.slice(g+1)}let a=await de({context:e??".",dockerfile:i.file,tags:r,target:i.target,buildArgs:o,platform:i.platform,outputDir:i.output,runMode:i.runMode,quiet:i.quiet});if(!i.quiet){if(console.log(`
107
- ✓ Built ${a.imageId}`),r.length)console.log(` tags: ${r.join(", ")}`);console.log(` archive: ${a.archivePath}`),console.log(` oci layout: ${a.ociLayoutPath}`)}if(i.push){let l=G(r[0]||"app:latest");if(!i.quiet)console.log(`
108
- Pushing ${l.repository}:${l.tag} → ${c} ...`);let g=await ue({repository:l.repository,tag:l.tag,registry:l.implicitRegistry?void 0:`https://${l.registry}`,configBytes:Buffer.from(a.configBytes),configDigest:a.configDigest,layers:a.layers.map((b)=>({digest:b.digest,path:b.path,size:b.size})),manifestBytes:Buffer.from(a.manifestBytes),manifestMediaType:a.manifestMediaType,quiet:i.quiet});console.log(`✓ Pushed ${g.ref} (${g.digest})`)}v.exit(0)}catch(r){console.error("Build failed:",r instanceof Error?r.message:r),v.exit(1)}});F.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,i)=>{try{let r=he({outDir:e??"storage/framework",baseImage:i.base,workdir:i.workdir,installCommand:i.install,buildCommand:i.build,startCommand:i.start?i.start.split(/\s+/):void 0,port:i.port?Number(i.port):void 0,force:i.force});console.log(`${r.wroteDockerfile?"✓ wrote":"• kept"} ${r.dockerfilePath}`),console.log(`${r.wroteFreezer?"✓ wrote":"• kept"} ${r.freezerPath}`),v.exit(0)}catch(r){console.error("Generate failed:",r instanceof Error?r.message:r),v.exit(1)}});F.command("native:release","Qualify, version, commit and push a native app release through Pantry").option("--bump <bump>","patch, minor or major (default: patch)").option("--dry-run","Validate and preview without changing the version or publishing").action(async(e)=>{let{releaseNativeApp:i}=await import("../src/native/release.js");await i(v.cwd(),{bump:e.bump||"patch",dryRun:e.dryRun})});F.command("native:check","Build and verify the native app declared in pantry.json").action(async()=>{let{prepareNativeRelease:e}=await import("../src/native/index.js");console.log(JSON.stringify(await e(v.cwd(),"check"),null,2))});F.command("native:prepare-release","Sign, verify, notarize and package configured native release targets").action(async()=>{let{prepareNativeRelease:e}=await import("../src/native/index.js");console.log(JSON.stringify(await e(v.cwd(),"release"),null,2))});F.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 i=tt({outputDirectory:e.output??".pantry/apple",commonName:e.name});console.log(JSON.stringify({requests:i},null,2)),v.exit(0)}catch(i){console.error("Apple CSR generation failed:",i instanceof Error?i.message:i),v.exit(1)}});F.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 i=(u)=>{if(!u)return;return C.readFileSync(O.resolve(u),"utf8")},r=O.resolve(e.output??".pantry/apple");C.mkdirSync(r,{recursive:!0});let o=await et({identifier:e.bundleId,name:e.name,capabilities:e.capabilities?.split(",").map((u)=>u.trim()).filter(Boolean),appCertificateCsr:i(e.appCertificateCsr),installerCertificateCsr:i(e.installerCertificateCsr),profileName:e.profileName,keyId:e.apiKeyId,issuerId:e.apiIssuerId,keyPath:e.apiKeyPath,checkOnly:!e.apply});for(let u of o.certificates){if(!u.certificateContent)continue;let p=u.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",k=O.join(r,`${p}.cer`);C.writeFileSync(k,Buffer.from(u.certificateContent,"base64"),{mode:384});let I=u.type==="MAC_APP_DISTRIBUTION"?e.appCertificateCsr:e.installerCertificateCsr;if(e.p12Password&&I)at({certificatePath:k,privateKeyPath:O.resolve(I.replace(/\.csr$/i,".key")),outputPath:O.join(r,`${p}.p12`),password:e.p12Password,name:`${e.name} ${u.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(o.profile.profileContent)C.writeFileSync(O.join(r,"mac-app-store.provisionprofile"),Buffer.from(o.profile.profileContent,"base64"),{mode:384});let a=o.certificates.map((u)=>{let p={...u};return delete p.certificateContent,p}),l={...o.profile};delete l.profileContent;let g={...o,certificates:a,profile:l},b=O.join(r,"provisioning-plan.json");C.writeFileSync(b,`${JSON.stringify(g,null,2)}
109
- `,{mode:384}),console.log(JSON.stringify({reportPath:b,...g},null,2)),v.exit(0)}catch(i){console.error("App Store provisioning failed:",i instanceof Error?i.message:i),v.exit(1)}});F.help();F.version(Ve);var tn=F.parse();if(v.argv.length<=2||v.argv.includes("--help")||v.argv.includes("-h"))v.exit(0);
59
+ ${l.join(`
60
+ `)}`;g.writeFileSync(`${e}-packages-summary.txt`,p),console.log(`\uD83D\uDCC4 Created ${e}-packages-summary.txt for reference`),r.exit(0)}catch(e){console.error("Error generating consts file:",e),r.exit(1)}});N.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(t,e)=>{try{let{dir:o=".",packagesDir:i="src/packages",targetOs:l,includeOsDeps:d=!1,maxDepth:p=10,verbose:b=!1,json:x=!1,installCommand:v=!1}=e,U=t||e.file;if(!U){let R=he(o);if(R.length===0)console.error(`No dependency files found in ${o}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),r.exit(1);else if(R.length>1)console.error(`Multiple dependency files found in ${o}:`),R.forEach((y)=>console.error(` ${y}`)),console.error("Please specify which file to use with --file or [file] argument"),r.exit(1);else if(U=R[0],!x)console.log(`Found dependency file: ${U}`)}if(!g.existsSync(U))console.error(`Dependency file not found: ${U}`),r.exit(1);let B={packagesDir:i,includeOsSpecific:d,targetOs:l,maxDepth:Number.parseInt(String(p),10),verbose:b&&!x};if(!x)console.log("\uD83D\uDD0D Resolving dependencies...");let k=await H(U,B);if(x){let R={success:!0,file:U,summary:{totalUnique:k.uniquePackages.length,conflicts:k.conflicts.length,osSpecific:{linux:k.osSpecificDeps.linux.length,darwin:k.osSpecificDeps.darwin.length,windows:k.osSpecificDeps.windows.length}},packages:k.uniquePackages,dependencies:k.allDependencies,conflicts:k.conflicts,osSpecificDeps:k.osSpecificDeps,timestamp:new Date().toISOString()};console.log(JSON.stringify(R,null,2))}else{if(console.log(`
61
+ ✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${k.uniquePackages.length}`),k.conflicts.length>0)console.log(`⚠️ Version conflicts: ${k.conflicts.length}`),console.log(`
62
+ Conflicts found:`),k.conflicts.forEach((y)=>{console.log(` ${y.package}: ${y.versions.join(", ")}`)});if(console.log(`
63
+ \uD83D\uDCCB All unique packages to install:`),k.uniquePackages.forEach((y,J)=>{let _=k.allDependencies.find((M)=>M.name===y),C=_&&_.version&&_.version!=="latest"?` (${_.version})`:"";console.log(` ${J+1}. ${y}${C}`)}),v)console.log(`
64
+ \uD83D\uDE80 Install command:`),console.log(`pantry install ${k.uniquePackages.join(" ")}`);if(Object.values(k.osSpecificDeps).reduce((y,J)=>y+J.length,0)>0)console.log(`
65
+ \uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(k.osSpecificDeps).forEach(([y,J])=>{if(J.length>0)console.log(` ${y}: ${J.map((_)=>_.name).join(", ")}`)})}r.exit(0)}catch(o){if(e.json){let i={success:!1,error:String(o),timestamp:new Date().toISOString()};console.log(JSON.stringify(i))}else console.error("Error resolving dependencies:",o);r.exit(1)}});N.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(t)=>{try{let{getPhpVersionsForWorkflow:e}=await import("../chunk-bggscee8.js"),o={};if(t.branches)o.supportedBranches=t.branches.split(",").map((l)=>l.trim());if(t.fallback)o.fallbackVersions=t.fallback.split(",").map((l)=>l.trim());let i=e(o);switch(t.format.toLowerCase()){case"yaml":console.log(`php_versions:
66
+ ${i.map((l)=>` - "${l}"`).join(`
67
+ `)}`);break;case"csv":console.log(i.join(","));break;case"json":default:console.log(JSON.stringify(i));break}r.exit(0)}catch(e){console.error("Error getting PHP versions:",e),r.exit(1)}});N.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(t)=>{try{let{generateZigDefinitions:e,generateZigAliases:o}=await import("../chunk-31y9b4za.js"),{packagesDir:i="src/packages",output:l="packages.zig",aliases:d=!1,aliasesOutput:p="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await e(i,l),d)console.log(`
68
+ \uD83D\uDE80 Generating Zig package aliases...`),await o(i,p);console.log(`
69
+ ✅ Zig code generation complete!`),r.exit(0)}catch(e){console.error("Error generating Zig definitions:",e),r.exit(1)}});N.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(t,e)=>{let o=(t??"patch").toLowerCase();if(!["patch","minor","major"].includes(o))console.error(`error: invalid release type "${o}" (expected: patch | minor | major)`),r.exit(1);let{runRelease:i}=await import("../chunk-cwa30yjr.js"),l=await i({type:o,yes:e.yes,dryRun:e.dryRun,noChangelog:e.changelog===!1,noPush:e.push===!1,noPublish:e.publish===!1});r.exit(l.exitCode)});N.command("apps","List installed desktop applications with version info").option("-j, --json","Output as JSON").action(async(t)=>{try{let{scanInstalledApps:e}=await import("../chunk-1n0fctvz.js"),o=e();if(t.json)console.log(JSON.stringify({success:!0,apps:o,total:o.length}));else{console.log(`
70
+ Installed Desktop Apps (${o.length}):
71
+ `),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let i of o)console.log(`${i.name.padEnd(40)}${i.version}`)}r.exit(0)}catch(e){console.error("Error listing apps:",e),r.exit(1)}});N.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(t)=>{try{let{checkAppUpdates:e}=await import("../chunk-1n0fctvz.js");if(!t.json)console.log("Checking desktop apps for updates...");let o=await e(),i=o.filter((l)=>l.updateAvailable);if(t.json)console.log(JSON.stringify({success:!0,apps:o,outdated:i.length,total:o.length,timestamp:new Date().toISOString()}));else{if(i.length>0){console.log(`
72
+ Outdated Apps (${i.length}):
73
+ `),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let d of i)console.log(`${d.name.padEnd(30)}${d.currentVersion.padEnd(16)}${(d.latestVersion||"?").padEnd(16)}${d.source}`)}else console.log(`
74
+ All desktop apps are up to date!`);let l=o.filter((d)=>!d.updateAvailable&&d.source!=="system"&&d.source!=="unknown");if(l.length>0)console.log(`
75
+ ${l.length} app(s) up to date, ${o.filter((d)=>d.source==="unknown").length} unchecked`)}r.exit(0)}catch(e){console.error("Error checking app updates:",e),r.exit(1)}});N.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(t)=>{try{let{updateApp:e}=await import("../chunk-1n0fctvz.js");console.log(`Updating ${t} from the pantry registry...`);let o=await e(t);if(o.success)console.log(`Successfully updated ${t} to ${o.version}`);else console.error(`Failed to update ${t}: ${o.error}`),r.exit(1);r.exit(0)}catch(e){console.error("Error updating app:",e),r.exit(1)}});N.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(t,e)=>{let o=t.lastIndexOf("@"),i=o>0,l=i?t.slice(0,o):t,d=i?t.slice(o+1):"latest";try{let p=await T(l,d,{installDir:e.installDir,platform:pe(e.platform),createBinLinks:e.binLinks!==!1,quiet:e.quiet,globalBin:e.global?!0:void 0});if(!e.quiet){if(console.log(`
76
+ ✓ ${p.name}@${p.version}`),console.log(` installed to: ${p.installPath}`),p.globalLinks&&p.globalLinks.length>0){if(console.log(` linked into: ${A.dirname(p.globalLinks[0])}`),!r.env.PATH?.split(A.delimiter).includes(A.dirname(p.globalLinks[0])))console.log(`
77
+ ⚠ ${A.dirname(p.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}r.exit(0)}catch(p){console.error(`Error installing ${t}:`,p instanceof Error?p.message:p),r.exit(1)}});function ue(t){let e=he(t);if(e.length===0)return[];try{return P(e[0]).map((o)=>o.version&&o.version!=="latest"?`${o.name}@${String(o.version).replace(/^[\^~>=<]+/,"")}`:o.name)}catch{return[]}}N.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(t)=>{let e=A.resolve(t.dir??r.cwd()),o=ue(e);if(t.install&&o.length>0)for(let d of o){let p=d.lastIndexOf("@"),b=p>0;await T(b?d.slice(0,p):d,b?d.slice(p+1):"latest",{globalBin:!0,quiet:!0}).catch((x)=>{console.error(`# could not install ${d}: ${x instanceof Error?x.message:x}`)})}let i=f(),l=[A.join(e,".bin"),i].filter((d)=>g.existsSync(d));if(t.json)console.log(JSON.stringify({path:l,PATH:[...l,r.env.PATH??""].filter(Boolean).join(A.delimiter),dependencies:o,globalBin:i},null,2)),r.exit(0);console.log(`export PATH="${[...l,"$PATH"].join(A.delimiter)}"`),r.exit(0)});N.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(t)=>{let e=t.shell??j();try{if(t.uninstall){let i=be({shell:e});console.log(i.changed?`✓ Removed pantry shell-init from ${i.rcFile}`:`Nothing to remove (no pantry shell-init block in ${i.rcFile})`),r.exit(0)}if(t.install){let i=fe({shell:e});if(i.changed)console.log(`✓ Added pantry shell-init to ${i.rcFile}`),console.log(` Restart your shell or run: source ${i.rcFile}`);else console.log(`✓ Already integrated in ${i.rcFile}`);r.exit(0)}let o=V(e);if(r.stdout.isTTY){if(console.log(`# Detected shell: ${e}`),console.log(`# Global bin dir: ${f()}`),o)console.log(`# Append this to: ${o}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}r.stdout.write(W({shell:e})),r.exit(0)}catch(o){console.error("Error:",o instanceof Error?o.message:o),r.exit(1)}});N.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(t,e)=>{try{let o=[].concat(e.tag??[]),i={};for(let d of[].concat(e.buildArg??[])){let p=d.indexOf("=");if(p!==-1)i[d.slice(0,p)]=d.slice(p+1)}let l=await Pe({context:t??".",dockerfile:e.file,tags:o,target:e.target,buildArgs:i,platform:e.platform,outputDir:e.output,runMode:e.runMode,quiet:e.quiet});if(!e.quiet){if(console.log(`
78
+ ✓ Built ${l.imageId}`),o.length)console.log(` tags: ${o.join(", ")}`);console.log(` archive: ${l.archivePath}`),console.log(` oci layout: ${l.ociLayoutPath}`)}if(e.push){let d=ee(o[0]||"app:latest");if(!e.quiet)console.log(`
79
+ Pushing ${d.repository}:${d.tag} → ${c} ...`);let p=await we({repository:d.repository,tag:d.tag,registry:d.implicitRegistry?void 0:`https://${d.registry}`,configBytes:Buffer.from(l.configBytes),configDigest:l.configDigest,layers:l.layers.map((b)=>({digest:b.digest,path:b.path,size:b.size})),manifestBytes:Buffer.from(l.manifestBytes),manifestMediaType:l.manifestMediaType,quiet:e.quiet});console.log(`✓ Pushed ${p.ref} (${p.digest})`)}r.exit(0)}catch(o){console.error("Build failed:",o instanceof Error?o.message:o),r.exit(1)}});N.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(t,e)=>{try{let o=Ue({outDir:t??"storage/framework",baseImage:e.base,workdir:e.workdir,installCommand:e.install,buildCommand:e.build,startCommand:e.start?e.start.split(/\s+/):void 0,port:e.port?Number(e.port):void 0,force:e.force});console.log(`${o.wroteDockerfile?"✓ wrote":"• kept"} ${o.dockerfilePath}`),console.log(`${o.wroteFreezer?"✓ wrote":"• kept"} ${o.freezerPath}`),r.exit(0)}catch(o){console.error("Generate failed:",o instanceof Error?o.message:o),r.exit(1)}});N.command("native:release","Qualify, version, commit and push a native app release through Pantry").option("--bump <bump>","patch, minor or major (default: patch)").option("--dry-run","Validate and preview without changing the version or publishing").action(async(t)=>{let{releaseNativeApp:e}=await import("../src/native/release.js");await e(r.cwd(),{bump:t.bump||"patch",dryRun:t.dryRun})});N.command("native:check","Build and verify the native app declared in pantry.json").action(async()=>{let{prepareNativeRelease:t}=await import("../src/native/index.js");console.log(JSON.stringify(await t(r.cwd(),"check"),null,2))});N.command("native:prepare-release","Sign, verify, notarize and package configured native release targets").action(async()=>{let{prepareNativeRelease:t}=await import("../src/native/index.js");console.log(JSON.stringify(await t(r.cwd(),"release"),null,2))});N.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((t)=>{try{if(!t.name)throw Error("--name is required");let e=ma({outputDirectory:t.output??".pantry/apple",commonName:t.name});console.log(JSON.stringify({requests:e},null,2)),r.exit(0)}catch(e){console.error("Apple CSR generation failed:",e instanceof Error?e.message:e),r.exit(1)}});N.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(t)=>{try{if(!t.bundleId||!t.name)throw Error("--bundle-id and --name are required");let e=(x)=>{if(!x)return;return g.readFileSync(A.resolve(x),"utf8")},o=A.resolve(t.output??".pantry/apple");g.mkdirSync(o,{recursive:!0});let i=await Ua({identifier:t.bundleId,name:t.name,capabilities:t.capabilities?.split(",").map((x)=>x.trim()).filter(Boolean),appCertificateCsr:e(t.appCertificateCsr),installerCertificateCsr:e(t.installerCertificateCsr),profileName:t.profileName,keyId:t.apiKeyId,issuerId:t.apiIssuerId,keyPath:t.apiKeyPath,checkOnly:!t.apply});for(let x of i.certificates){if(!x.certificateContent)continue;let v=x.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",U=A.join(o,`${v}.cer`);g.writeFileSync(U,Buffer.from(x.certificateContent,"base64"),{mode:384});let B=x.type==="MAC_APP_DISTRIBUTION"?t.appCertificateCsr:t.installerCertificateCsr;if(t.p12Password&&B)da({certificatePath:U,privateKeyPath:A.resolve(B.replace(/\.csr$/i,".key")),outputPath:A.join(o,`${v}.p12`),password:t.p12Password,name:`${t.name} ${x.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(i.profile.profileContent)g.writeFileSync(A.join(o,"mac-app-store.provisionprofile"),Buffer.from(i.profile.profileContent,"base64"),{mode:384});let l=i.certificates.map((x)=>{let v={...x};return delete v.certificateContent,v}),d={...i.profile};delete d.profileContent;let p={...i,certificates:l,profile:d},b=A.join(o,"provisioning-plan.json");g.writeFileSync(b,`${JSON.stringify(p,null,2)}
80
+ `,{mode:384}),console.log(JSON.stringify({reportPath:b,...p},null,2)),r.exit(0)}catch(e){console.error("App Store provisioning failed:",e instanceof Error?e.message:e),r.exit(1)}});N.help();N.version(F);var Ee=N.parse();if(r.argv.length<=2||r.argv.includes("--help")||r.argv.includes("-h"))r.exit(0);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bun
2
+ import{z,F}from"../chunk-hygw1tjj.js";import"../chunk-8f07ddwg.js";import"../chunk-bq29tm01.js";import{M,N,ge,Ve}from"../chunk-995m3fba.js";import{chmodSync as h,mkdirSync as m,renameSync as v,rmSync as P,writeFileSync as k}from"node:fs";import{homedir as b}from"node:os";import{isAbsolute as S,join as s}from"node:path";var a=(t)=>t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;");function x(t,e,r){return`<?xml version="1.0" encoding="UTF-8"?>
3
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4
+ <plist version="1.0"><dict>
5
+ <key>Label</key><string>dev.pantry.desktop</string>
6
+ <key>ProgramArguments</key><array><string>${a(t)}</string><string>serve</string><string>--pantry</string><string>${a(e)}</string></array>
7
+ <key>RunAtLoad</key><true/><key>KeepAlive</key><true/>
8
+ <key>WorkingDirectory</key><string>${a(r)}</string>
9
+ <key>StandardOutPath</key><string>${a(s(r,"service.log"))}</string>
10
+ <key>StandardErrorPath</key><string>${a(s(r,"service.log"))}</string>
11
+ </dict></plist>
12
+ `}async function f(t){if(process.platform!=="darwin"||!process.getuid||process.getuid()===0)throw Error("Pantry desktop service setup requires a macOS user session");let e=t.pantryExecutable??Bun.which("pantry");if(!e||!S(e))throw Error("Install the Pantry CLI before configuring its desktop service");let r=M();D(r);let i=s(r,"runtime");m(i,{recursive:!0,mode:448});let n=s(i,`pantry-desktop-${F}`),o=`${n}.${crypto.randomUUID()}.tmp`;if(await Bun.spawn([process.execPath,"build",t.entrypoint,"--compile","--minify","--no-compile-autoload-dotenv","--no-compile-autoload-bunfig","--outfile",o],{stdin:"ignore",stdout:"inherit",stderr:"inherit"}).exited!==0)throw P(o,{force:!0}),Error("Could not build the standalone Pantry desktop service");h(o,448),v(o,n);let c=s(b(),"Library/LaunchAgents");m(c,{recursive:!0});let d=s(c,"dev.pantry.desktop.plist");k(d,x(n,e,r),{mode:384});let w=`gui/${process.getuid()}`;await E(w,d);for(let u=0;u<20;u++){try{let y=await fetch("http://127.0.0.1:46473/health",{signal:AbortSignal.timeout(500)}),g=await y.json();if(y.ok&&g.service==="pantry-desktop"&&g.protocolVersion===1)return}catch{}await Bun.sleep(250)}throw Error(`Pantry Desktop did not become ready. Check ${s(r,"service.log")}`)}function D(t){N(t);let e=s(t,"service.log");k(e,"",{mode:384,flag:"a"}),h(e,384)}async function E(t,e,r={}){let i=r.run??(async(n)=>{let o=Bun.spawn(["launchctl",...n],{stdout:"ignore",stderr:"pipe"}),[l,c]=await Promise.all([o.exited,new Response(o.stderr).text()]);return{exitCode:l,stderr:c}});await i(["bootout",`${t}/dev.pantry.desktop`]);for(let n=0;n<6;n++){let o=await i(["bootstrap",t,e]);if(o.exitCode===0)return;if(n===5||!/Bootstrap failed: 5: Input\/output error/.test(o.stderr))throw Error(`macOS did not register the Pantry desktop service: ${o.stderr.trim()}`);await(r.sleep??Bun.sleep)(100*2**n)}}var p=new z("pantry-desktop");p.command("serve","Run the authenticated local Pantry desktop bridge").option("--pantry <path>","Absolute path to the installed Pantry CLI").action((t)=>{let e=Ve({pantryExecutable:t.pantry});console.log(`Pantry Desktop ready at http://127.0.0.1:${e.server.port}`);let r=()=>{e.close().then(()=>process.exit(0))};process.once("SIGTERM",r),process.once("SIGINT",r)});p.command("pair","Create a single-use code for connecting a desktop application").option("--json","Print the code as JSON for a local setup client").action((t)=>{let e=ge();console.log(t.json?JSON.stringify({code:e,expiresInSeconds:300}):`Pantry pairing code: ${e}
13
+ Enter it in your desktop app within five minutes.`)});p.command("setup","Install the per-user Pantry desktop service, then create a pairing code").option("--yes","Allow the per-user service to start now and at login").option("--pantry <path>","Absolute path to the installed Pantry CLI").action(async(t)=>{if(!t.yes)throw Error("This installs a per-user service that starts at login. Run pantry desktop setup --yes to allow it.");await f({entrypoint:import.meta.path,pantryExecutable:t.pantry}),console.log(`Pantry Desktop is installed for this user. Pairing code: ${ge()}
14
+ Enter it in your desktop app within five minutes.`)});p.help();await p.parse();