ts-pantry 0.11.145 → 0.11.146

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 (79) hide show
  1. package/dist/bin/cli.js +18 -18
  2. package/dist/bin/desktop.js +2 -2
  3. package/dist/{chunk-0dr09n6t.js → chunk-7j5va6d3.js} +9 -9
  4. package/dist/{chunk-63zdvbqd.js → chunk-8teqa39h.js} +2 -2
  5. package/dist/{chunk-76wpkhh6.js → chunk-9he46t5k.js} +2 -2
  6. package/dist/chunk-fzw9a127.js +1 -0
  7. package/dist/{chunk-hnykqejt.js → chunk-ghf9cbt0.js} +2 -2
  8. package/dist/{chunk-r9tnx251.js → chunk-jbjnzfb1.js} +13 -13
  9. package/dist/{chunk-je6hvsr6.js → chunk-kyakwzhh.js} +2 -2
  10. package/dist/chunk-mbx2zph4.js +1 -0
  11. package/dist/{chunk-fyr7re9j.js → chunk-mgdech8n.js} +1 -1
  12. package/dist/chunk-mjdrz996.js +1 -0
  13. package/dist/chunk-mqey1vaa.js +531 -0
  14. package/dist/chunk-nav50bc7.js +1 -0
  15. package/dist/chunk-rh42r3ms.js +1 -0
  16. package/dist/chunk-ws0j0x55.js +1 -0
  17. package/dist/chunk-xdjnqx1y.js +1 -0
  18. package/dist/generated-package-names.d.ts +45 -45
  19. package/dist/src/catalog/client.js +1 -1
  20. package/dist/src/desktop/service.js +1 -1
  21. package/dist/src/index.js +1 -1
  22. package/dist/src/installer.d.ts +38 -1
  23. package/dist/src/native/index.js +6 -6
  24. package/dist/src/native/release.js +1 -1
  25. package/dist/src/packages/apps/bitwardencom.d.ts +3 -3
  26. package/dist/src/packages/apps/codexopenaicom.d.ts +1 -1
  27. package/dist/src/packages/apps/diabrowsercom.d.ts +1 -1
  28. package/dist/src/packages/apps/libreofficeorg.d.ts +2 -2
  29. package/dist/src/packages/apps/lmstudioai.d.ts +2 -2
  30. package/dist/src/packages/apps/slackcom.d.ts +2 -2
  31. package/dist/src/packages/certbotefforg.d.ts +3 -3
  32. package/dist/src/packages/coder.com/code-server.d.ts +3 -3
  33. package/dist/src/packages/craft-native.org.d.ts +3 -3
  34. package/dist/src/packages/depotdev.d.ts +3 -3
  35. package/dist/src/packages/flutterdev.d.ts +3 -3
  36. package/dist/src/packages/flyio.d.ts +3 -3
  37. package/dist/src/packages/getcomposerorg.d.ts +3 -3
  38. package/dist/src/packages/getfoundrysh.d.ts +2 -2
  39. package/dist/src/packages/github.com/ggerganov/llama.cpp.d.ts +3 -3
  40. package/dist/src/packages/github.com/tw93/mole.d.ts +3 -3
  41. package/dist/src/packages/google.com/chrome.d.ts +3 -3
  42. package/dist/src/packages/groongaorg.d.ts +3 -3
  43. package/dist/src/packages/huggingfaceco.d.ts +3 -3
  44. package/dist/src/packages/insomniarest.d.ts +2 -2
  45. package/dist/src/packages/jupyterorg.d.ts +3 -3
  46. package/dist/src/packages/lavinmqcom.d.ts +3 -3
  47. package/dist/src/packages/macfusegithubio.d.ts +3 -3
  48. package/dist/src/packages/materializecom.d.ts +3 -3
  49. package/dist/src/packages/maturinrs.d.ts +3 -3
  50. package/dist/src/packages/misejdxdev.d.ts +3 -3
  51. package/dist/src/packages/mongodb.com/shell.d.ts +3 -3
  52. package/dist/src/packages/moonrepo.dev/moon.d.ts +3 -3
  53. package/dist/src/packages/mupdfcom.d.ts +3 -3
  54. package/dist/src/packages/nomadprojectio.d.ts +3 -3
  55. package/dist/src/packages/ollamaai.d.ts +3 -3
  56. package/dist/src/packages/openai.com/codex.d.ts +3 -3
  57. package/dist/src/packages/opencodeai.d.ts +3 -3
  58. package/dist/src/packages/openexrcom.d.ts +3 -3
  59. package/dist/src/packages/openpolicyagentorg.d.ts +3 -3
  60. package/dist/src/packages/openshiftcom.d.ts +3 -3
  61. package/dist/src/packages/opentofuorg.d.ts +2 -2
  62. package/dist/src/packages/projenio.d.ts +3 -3
  63. package/dist/src/packages/rubocoporg.d.ts +3 -3
  64. package/dist/src/packages/squawkhqcom.d.ts +3 -3
  65. package/dist/src/packages/streamlinkgithubio.d.ts +3 -3
  66. package/dist/src/packages/terratagio.d.ts +3 -3
  67. package/dist/src/packages/vclustercom.d.ts +3 -3
  68. package/dist/src/packages/xtlsgithubio.d.ts +3 -3
  69. package/dist/src/packages/zarfdev.d.ts +3 -3
  70. package/dist/src/testing/index.js +1 -1
  71. package/package.json +1 -1
  72. package/dist/chunk-0y2671yw.js +0 -528
  73. package/dist/chunk-1e62ct8j.js +0 -1
  74. package/dist/chunk-359r0aep.js +0 -1
  75. package/dist/chunk-6nmn1zbg.js +0 -1
  76. package/dist/chunk-9bfnpnzd.js +0 -1
  77. package/dist/chunk-fzr830kg.js +0 -1
  78. package/dist/chunk-m0gz72mn.js +0 -1
  79. package/dist/chunk-z9wb2cyn.js +0 -1
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{_,B}from"../chunk-0dr09n6t.js";import{a,U,r,h,f,C,J,ye,b,q,D,R,X,ke,ve,n,Z,A,d,ae,I,z,L,O,l,te,Ce,je,Se,ua,ha}from"../chunk-0y2671yw.js";import"../chunk-fyr7re9j.js";import"../chunk-63zdvbqd.js";import{ja}from"../chunk-76wpkhh6.js";import g from"node:fs";import x from"node:path";import s from"node:process";U();async function se(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,c=""){let u=g.readdirSync(i,{withFileTypes:!0}),p=x.join(i,"package.yml");if(c&&g.existsSync(p))e.push(c);for(let w of u)if(w.isDirectory()&&!w.name.startsWith(".")){let k=c?`${c}/${w.name}`:w.name,S=x.join(i,w.name);o(S,k)}}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 w=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(w.searchParams.set("list-type","2"),w.searchParams.set("prefix",""),w.searchParams.set("max-keys","1000"),p)w.searchParams.set("continuation-token",p);let k=await fetch(w.toString());if(!k.ok)throw Error(`Failed to fetch S3 listing: ${k.status}`);let S=await k.text(),M=[],G=S.match(/<Key>([^<]+)<\/Key>/g);if(G)for(let H of G){let N=H.replace(/<Key>([^<]+)<\/Key>/,"$1");M.push({Key:N})}let y=S.includes("<IsTruncated>true</IsTruncated>"),j=S.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),m=j?j[1]:void 0;return{IsTruncated:y,NextContinuationToken:m,Contents:M}}console.log("Scraping packages from S3 registry...");let o=new Set,i;do{let p=await e(i);for(let w of p.Contents){let k=w.Key,S=k.split("/");if(S.length===0)continue;if(S[0].startsWith(".")||S[0].includes(" ")||k.match(/\.(md|txt|yml|yaml|json)$/i))continue;let M=["darwin","linux","windows"],G=-1;for(let y=1;y<S.length;y++)if(M.includes(S[y])){G=y;break}if(G>0){let y=S.slice(0,G).join("/");if(y.includes("."))o.add(y)}else if(S.length>=2&&S[0].includes(".")&&!S[1].startsWith("v")&&!S[1].match(/^\d/)){let y=`${S[0]}/${S[1]}`;o.add(y)}else if(S.length>=1&&S[0].includes("."))o.add(S[0])}i=p.NextContinuationToken,console.log(`Found ${o.size} packages so far...`)}while(i);let c=Array.from(o).sort(),u=[];for(let p of c){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;u.push(p)}return console.log(`\uD83D\uDCE6 Found ${u.length} valid packages in registry`),u}async function le(t,e){let i=`/**
2
+ import{T,B}from"../chunk-7j5va6d3.js";import{a,j,r,h,f,S,J,ye,y,q,A,R,X,ke,ve,n,Z,I,d,ae,z,E,L,O,l,te,Ce,je,Se,ha,fa}from"../chunk-mqey1vaa.js";import"../chunk-mgdech8n.js";import"../chunk-8teqa39h.js";import{Sa}from"../chunk-9he46t5k.js";import g from"node:fs";import v from"node:path";import s from"node:process";j();async function se(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,c=""){let u=g.readdirSync(i,{withFileTypes:!0}),p=v.join(i,"package.yml");if(c&&g.existsSync(p))e.push(c);for(let x of u)if(x.isDirectory()&&!x.name.startsWith(".")){let w=c?`${c}/${x.name}`:x.name,b=v.join(i,x.name);o(b,w)}}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 x=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(x.searchParams.set("list-type","2"),x.searchParams.set("prefix",""),x.searchParams.set("max-keys","1000"),p)x.searchParams.set("continuation-token",p);let w=await fetch(x.toString());if(!w.ok)throw Error(`Failed to fetch S3 listing: ${w.status}`);let b=await w.text(),U=[],G=b.match(/<Key>([^<]+)<\/Key>/g);if(G)for(let H of G){let _=H.replace(/<Key>([^<]+)<\/Key>/,"$1");U.push({Key:_})}let k=b.includes("<IsTruncated>true</IsTruncated>"),N=b.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),m=N?N[1]:void 0;return{IsTruncated:k,NextContinuationToken:m,Contents:U}}console.log("Scraping packages from S3 registry...");let o=new Set,i;do{let p=await e(i);for(let x of p.Contents){let w=x.Key,b=w.split("/");if(b.length===0)continue;if(b[0].startsWith(".")||b[0].includes(" ")||w.match(/\.(md|txt|yml|yaml|json)$/i))continue;let U=["darwin","linux","windows"],G=-1;for(let k=1;k<b.length;k++)if(U.includes(b[k])){G=k;break}if(G>0){let k=b.slice(0,G).join("/");if(k.includes("."))o.add(k)}else if(b.length>=2&&b[0].includes(".")&&!b[1].startsWith("v")&&!b[1].match(/^\d/)){let k=`${b[0]}/${b[1]}`;o.add(k)}else if(b.length>=1&&b[0].includes("."))o.add(b[0])}i=p.NextContinuationToken,console.log(`Found ${o.size} packages so far...`)}while(i);let c=Array.from(o).sort(),u=[];for(let p of c){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;u.push(p)}return console.log(`\uD83D\uDCE6 Found ${u.length} valid packages in registry`),u}async function le(t,e){let i=`/**
3
3
  * Constants used throughout the ts-pantry package
4
4
  * This file is auto-generated from ${e}. Do not edit manually.
5
5
  * Generated on ${new Date().toISOString()}
@@ -51,30 +51,30 @@ export const ALL_KNOWN_PACKAGES: readonly string[] = [
51
51
  ${t.map((c)=>` '${c}',`).join(`
52
52
  `)}
53
53
  ] as const
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],c=o?.[2],u=i==="macos"||i==="darwin"?"darwin":i==="linux"?"linux":i==="windows"||i==="win32"?"windows":void 0,p=c==="x64"||c==="x86-64"||c==="amd64"?"x86_64":c==="arm64"||c==="aarch64"?"aarch64":void 0;if(!u||!p)throw Error(`Invalid platform "${t}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:u,arch:p}}var E=new _("ts-pantry"),de=1500000,Q=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),s.exit(1)},de);s.on("exit",()=>{clearTimeout(Q)});async function ie(t){console.log(`
55
- Received ${t} signal. Cleaning up resources...`),clearTimeout(Q);try{await d(),console.log("Resources cleaned up. Exiting.")}catch(e){console.error("Error during cleanup:",e)}setTimeout(()=>{console.log("Forcing process exit..."),s.exit(0)},1000)}s.on("SIGINT",()=>ie("SIGINT"));s.on("SIGTERM",()=>ie("SIGTERM"));function ne(t){let e={};for(let[o,i]of Object.entries(a))if(typeof i==="string")e[i]=o;return e[t]||t}function oe(t){let e=t.map(ne),o=t.map((i)=>{let c=ne(i);return c===i?i:c});return{friendlyNames:e,mixedNames:o}}E.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:r}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:h}).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:f}).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:c=r,cache:u=!0,cacheExpiration:p=h,limit:w,timeout:k=f,json:S=!1,debug:M=!1,verbose:G=!1,concurrency:y=8,pkg:j,outputJson:m=!1}=e,H=x.resolve(s.cwd(),i);if(!g.existsSync(H))g.mkdirSync(H,{recursive:!0});let N=x.resolve(s.cwd(),c);if(u){if(!g.existsSync(N))g.mkdirSync(N,{recursive:!0})}try{let v=[],F=[];if(o){if(!m)console.log("Fetching all packages...");let P={outputDir:i,cacheDir:c,cache:u,cacheExpirationMinutes:p,timeout:Number.parseInt(String(k),10),debug:M,limit:w?Number.parseInt(String(w),10):void 0,concurrency:Math.min(Number.parseInt(String(y),10),12),outputJson:m};v=await ae(P),F=[...v]}else if(j){let P=j.split(",").map((T)=>T.trim());if(!m)console.log(`Fetching ${P.length} packages: ${P.join(", ")}`);for(let T of P)try{let K=x.join(c,`${T.replace(/\//g,"-")}.json`),W=!1;if(u&&g.existsSync(K)){let V=g.statSync(K),Y=(Date.now()-V.mtime.getTime())/60000;if(Y<p){if(!m)console.log(`Using cached data for ${T} (age: ${Math.round(Y)} minutes)`);try{let ee=JSON.parse(g.readFileSync(K,"utf-8"));delete ee.fetchedAt;let re=n(i,T,ee);if(G&&!m)console.log(`Using cached data for ${T} (saved to ${re})`);v.push(T),W=!0;continue}catch{console.warn(`Cache file corrupted for ${T}, will refetch`)}}}if(!W){let V=await I(T,{timeout:Number.parseInt(String(k),10),debug:M,outputJson:m,cacheDir:c,cache:u,cacheExpirationMinutes:p});if(V){let{outputPath:Y}=A(T,V.packageInfo,{cacheDir:c,outputDir:i,cache:u});if(v.push(T),F.push(T),G&&!m)console.log(`Successfully saved ${T} to ${Y}`)}}}catch(K){console.error(`Error processing ${T}:`,K)}}else if(t){if(!m)console.log(`Fetching package: ${t}`);try{let P=x.join(N,`${t.replace(/\//g,"-")}.json`),T=!1;if(u&&g.existsSync(P)){let K=g.statSync(P),W=(Date.now()-K.mtime.getTime())/60000;if(W<p){if(!m)console.log(`Using cached data for ${t} (age: ${Math.round(W)} minutes)`);try{let V=JSON.parse(g.readFileSync(P,"utf-8"));delete V.fetchedAt;let Y=n(H,t,V);if(G&&!m)console.log(`Using cached data for ${t} (saved to ${Y})`);v.push(t),T=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!T){let K=await I(t,{timeout:Number.parseInt(String(k),10),debug:M,outputJson:m,cacheDir:c,cache:u,cacheExpirationMinutes:p});if(K){let{outputPath:W}=A(t,K.packageInfo,{cacheDir:c,outputDir:i,cache:u});if(v.push(t),F.push(t),G&&!m)console.log(`Successfully saved ${t} to ${W}`)}}}catch(P){console.error(`Error processing ${t}:`,P)}}else{if(!m)console.error("Error: Please specify a package name, use --pkg, or use --all");s.exit(1)}if(!S&&v.length>0){let P=await z();if(!m)console.log(`Successfully generated ${P}`)}if(o&&v.length>0){let P=Z(H,v);if(P.length>0&&!m)console.log(`Cleaned up ${P.length} stale generated file(s)`)}if(m){let{friendlyNames:P,mixedNames:T}=oe(F),{friendlyNames:K,mixedNames:W}=oe(v),V={success:!0,updatedPackages:F,updatedPackagesFriendly:P,updatedPackagesMixed:T,allProcessedPackages:v,allProcessedFriendly:K,allProcessedMixed:W,totalUpdated:F.length,totalProcessed:v.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(V))}else console.log(`Processed ${v.length} packages.`);clearTimeout(Q),await d(),setTimeout(()=>s.exit(0),1000)}catch(v){if(m){let F={success:!1,error:String(v),timestamp:new Date().toISOString()};console.log(JSON.stringify(F))}else console.error("Error:",v);await d(),setTimeout(()=>s.exit(1),1000)}});E.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=x.resolve(s.cwd(),e);if(!g.existsSync(o))console.error(`Error: Directory ${o} does not exist`),s.exit(1);try{let i=await z();console.log(`Successfully generated ${i}`),setTimeout(()=>s.exit(0),500)}catch(i){console.error("Error generating index:",i),s.exit(1)}});E.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:r}).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!`),s.exit(1);if(!g.existsSync(o))g.mkdirSync(o,{recursive:!0});let i=g.readdirSync(e).filter((u)=>u.endsWith(".json"));console.log(`Found ${i.length} JSON files in cache directory`);let c=0;for(let u of i)try{let p=g.readFileSync(x.join(e,u),"utf-8"),w=JSON.parse(p);delete w.fetchedAt;let k=u.replace(/\.json$/,""),S=n(o,w.fullPath||w.domain||k,w);console.log(`Generated ${S}`),c++}catch(p){console.error(`Error processing ${u}:`,p)}console.log(`Successfully generated ${c} TypeScript files from JSON cache`)}catch(e){console.error("Error generating TypeScript files:",e),s.exit(1)}});E.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let t=await L();console.log(`Successfully generated ${t}`),setTimeout(()=>s.exit(0),500)}catch(t){console.error("Error generating aliases:",t),s.exit(1)}});E.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 O(e),setTimeout(()=>s.exit(0),500)}catch(e){console.error("Error generating documentation:",e),s.exit(1)}});E.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=x.resolve(s.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 c=await i.arrayBuffer(),u=x.join(s.cwd(),"pantry.tgz");g.writeFileSync(u,new Uint8Array(c)),console.log(`Downloaded ${c.byteLength} bytes`),g.mkdirSync(o,{recursive:!0});let p=x.join(s.cwd(),"temp-pantry"),{spawn:w}=await import("node:child_process");if(g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});g.mkdirSync(p,{recursive:!0});let k=w("tar",["-xzf",u,"-C",p,"--strip-components=1"],{stdio:"inherit"});await new Promise((y,j)=>{k.on("close",(m)=>{if(m===0)y(m);else j(Error(`tar extraction failed with code ${m}`))}),k.on("error",j)});let S=x.join(p,"projects");if(g.existsSync(S)){let y=g.readdirSync(S),j=0,m=0,H=(N,v)=>{if(!g.existsSync(v))g.mkdirSync(v,{recursive:!0});for(let F of g.readdirSync(N,{withFileTypes:!0})){let P=x.join(N,F.name),T=x.join(v,F.name);if(F.isDirectory())H(P,T);else if(F.name==="package.yml")if(g.existsSync(T))m++;else g.renameSync(P,T),j++;else if(!g.existsSync(T))g.renameSync(P,T)}};console.log(`Merging ${y.length} projects from upstream...`);for(let N of y){let v=x.join(S,N),F=x.join(o,N);if(g.statSync(v).isDirectory())H(v,F)}console.log(`Merged upstream pantry: ${j} new packages added, ${m} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(g.unlinkSync(u),g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});console.log(`
56
- Downloading props files from pkgx/pantry GitHub repo...`);let G=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(G.ok){let y=await G.arrayBuffer(),j=x.join(s.cwd(),"pantry-gh.tar.gz"),m=x.join(s.cwd(),"temp-pantry-gh");if(g.writeFileSync(j,new Uint8Array(y)),console.log(`Downloaded GitHub archive: ${(y.byteLength/1024/1024).toFixed(1)} MB`),g.existsSync(m))g.rmSync(m,{recursive:!0,force:!0});g.mkdirSync(m,{recursive:!0});let H=w("tar",["-xzf",j,"-C",m,"--strip-components=1"],{stdio:"inherit"});await new Promise((v,F)=>{H.on("close",(P)=>P===0?v(P):F(Error(`tar failed: ${P}`))),H.on("error",F)});let N=x.join(m,"projects");if(g.existsSync(N)){let v=0,F=0,P=(T,K)=>{if(!g.existsSync(T))return;for(let W of g.readdirSync(T,{withFileTypes:!0})){let V=x.join(T,W.name),Y=x.join(K,W.name);if(W.isDirectory())P(V,Y);else if(W.name!=="package.yml")if(g.mkdirSync(K,{recursive:!0}),g.copyFileSync(V,Y),g.existsSync(Y))F++;else v++}};P(N,o),console.log(`Props files: ${v+F} synced (${v} new, ${F} updated)`)}if(g.unlinkSync(j),g.existsSync(m))g.rmSync(m,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${G.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),g.existsSync(o)){let y=g.readdirSync(o).filter((j)=>{let m=x.join(o,j);return g.statSync(m).isDirectory()&&!j.startsWith(".")});console.log(`Final result: ${y.length} projects in ${o}`)}s.exit(0)}catch(e){console.error("Error updating pantry:",e),s.exit(1)}});E.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 c=[];if(e==="pantry")c=await se(o);else if(e==="registry")c=await ce(i);else console.error('Invalid source. Use "pantry" or "registry"'),s.exit(1);await le(c,e),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${c.length}`);let u=new Date().toISOString(),p=`Generated from ${e} at ${u}
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],c=o?.[2],u=i==="macos"||i==="darwin"?"darwin":i==="linux"?"linux":i==="windows"||i==="win32"?"windows":void 0,p=c==="x64"||c==="x86-64"||c==="amd64"?"x86_64":c==="arm64"||c==="aarch64"?"aarch64":void 0;if(!u||!p)throw Error(`Invalid platform "${t}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:u,arch:p}}var F=new T("ts-pantry"),de=1500000,Q=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),s.exit(1)},de);s.on("exit",()=>{clearTimeout(Q)});async function ie(t){console.log(`
55
+ Received ${t} signal. Cleaning up resources...`),clearTimeout(Q);try{await d(),console.log("Resources cleaned up. Exiting.")}catch(e){console.error("Error during cleanup:",e)}setTimeout(()=>{console.log("Forcing process exit..."),s.exit(0)},1000)}s.on("SIGINT",()=>ie("SIGINT"));s.on("SIGTERM",()=>ie("SIGTERM"));function ne(t){let e={};for(let[o,i]of Object.entries(a))if(typeof i==="string")e[i]=o;return e[t]||t}function oe(t){let e=t.map(ne),o=t.map((i)=>{let c=ne(i);return c===i?i:c});return{friendlyNames:e,mixedNames:o}}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:r}).option("-n, --no-cache","Disable caching").option("-e, --cache-expiration <minutes>","Cache expiration time in minutes",{default:h}).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:f}).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:c=r,cache:u=!0,cacheExpiration:p=h,limit:x,timeout:w=f,json:b=!1,debug:U=!1,verbose:G=!1,concurrency:k=8,pkg:N,outputJson:m=!1}=e,H=v.resolve(s.cwd(),i);if(!g.existsSync(H))g.mkdirSync(H,{recursive:!0});let _=v.resolve(s.cwd(),c);if(u){if(!g.existsSync(_))g.mkdirSync(_,{recursive:!0})}try{let P=[],M=[];if(o){if(!m)console.log("Fetching all packages...");let D={outputDir:i,cacheDir:c,cache:u,cacheExpirationMinutes:p,timeout:Number.parseInt(String(w),10),debug:U,limit:x?Number.parseInt(String(x),10):void 0,concurrency:Math.min(Number.parseInt(String(k),10),12),outputJson:m};P=await ae(D),M=[...P]}else if(N){let D=N.split(",").map((C)=>C.trim());if(!m)console.log(`Fetching ${D.length} packages: ${D.join(", ")}`);for(let C of D)try{let K=v.join(c,`${C.replace(/\//g,"-")}.json`),W=!1;if(u&&g.existsSync(K)){let V=g.statSync(K),Y=(Date.now()-V.mtime.getTime())/60000;if(Y<p){if(!m)console.log(`Using cached data for ${C} (age: ${Math.round(Y)} minutes)`);try{let ee=JSON.parse(g.readFileSync(K,"utf-8"));delete ee.fetchedAt;let re=n(i,C,ee);if(G&&!m)console.log(`Using cached data for ${C} (saved to ${re})`);P.push(C),W=!0;continue}catch{console.warn(`Cache file corrupted for ${C}, will refetch`)}}}if(!W){let V=await z(C,{timeout:Number.parseInt(String(w),10),debug:U,outputJson:m,cacheDir:c,cache:u,cacheExpirationMinutes:p});if(V){let{outputPath:Y}=I(C,V.packageInfo,{cacheDir:c,outputDir:i,cache:u});if(P.push(C),M.push(C),G&&!m)console.log(`Successfully saved ${C} to ${Y}`)}}}catch(K){console.error(`Error processing ${C}:`,K)}}else if(t){if(!m)console.log(`Fetching package: ${t}`);try{let D=v.join(_,`${t.replace(/\//g,"-")}.json`),C=!1;if(u&&g.existsSync(D)){let K=g.statSync(D),W=(Date.now()-K.mtime.getTime())/60000;if(W<p){if(!m)console.log(`Using cached data for ${t} (age: ${Math.round(W)} minutes)`);try{let V=JSON.parse(g.readFileSync(D,"utf-8"));delete V.fetchedAt;let Y=n(H,t,V);if(G&&!m)console.log(`Using cached data for ${t} (saved to ${Y})`);P.push(t),C=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!C){let K=await z(t,{timeout:Number.parseInt(String(w),10),debug:U,outputJson:m,cacheDir:c,cache:u,cacheExpirationMinutes:p});if(K){let{outputPath:W}=I(t,K.packageInfo,{cacheDir:c,outputDir:i,cache:u});if(P.push(t),M.push(t),G&&!m)console.log(`Successfully saved ${t} to ${W}`)}}}catch(D){console.error(`Error processing ${t}:`,D)}}else{if(!m)console.error("Error: Please specify a package name, use --pkg, or use --all");s.exit(1)}if(!b&&P.length>0){let D=await E();if(!m)console.log(`Successfully generated ${D}`)}if(o&&P.length>0){let D=Z(H,P);if(D.length>0&&!m)console.log(`Cleaned up ${D.length} stale generated file(s)`)}if(m){let{friendlyNames:D,mixedNames:C}=oe(M),{friendlyNames:K,mixedNames:W}=oe(P),V={success:!0,updatedPackages:M,updatedPackagesFriendly:D,updatedPackagesMixed:C,allProcessedPackages:P,allProcessedFriendly:K,allProcessedMixed:W,totalUpdated:M.length,totalProcessed:P.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(V))}else console.log(`Processed ${P.length} packages.`);clearTimeout(Q),await d(),setTimeout(()=>s.exit(0),1000)}catch(P){if(m){let M={success:!1,error:String(P),timestamp:new Date().toISOString()};console.log(JSON.stringify(M))}else console.error("Error:",P);await d(),setTimeout(()=>s.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(t)=>{let{outputDir:e="src/packages"}=t,o=v.resolve(s.cwd(),e);if(!g.existsSync(o))console.error(`Error: Directory ${o} does not exist`),s.exit(1);try{let i=await E();console.log(`Successfully generated ${i}`),setTimeout(()=>s.exit(0),500)}catch(i){console.error("Error generating index:",i),s.exit(1)}});F.command("generate-ts","Generate TypeScript files from cached JSON files").option("--cache-dir <dir>","Directory with cached JSON files",{default:r}).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!`),s.exit(1);if(!g.existsSync(o))g.mkdirSync(o,{recursive:!0});let i=g.readdirSync(e).filter((u)=>u.endsWith(".json"));console.log(`Found ${i.length} JSON files in cache directory`);let c=0;for(let u of i)try{let p=g.readFileSync(v.join(e,u),"utf-8"),x=JSON.parse(p);delete x.fetchedAt;let w=u.replace(/\.json$/,""),b=n(o,x.fullPath||x.domain||w,x);console.log(`Generated ${b}`),c++}catch(p){console.error(`Error processing ${u}:`,p)}console.log(`Successfully generated ${c} TypeScript files from JSON cache`)}catch(e){console.error("Error generating TypeScript files:",e),s.exit(1)}});F.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let t=await L();console.log(`Successfully generated ${t}`),setTimeout(()=>s.exit(0),500)}catch(t){console.error("Error generating aliases:",t),s.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(t)=>{try{let{outputDir:e="docs"}=t;await O(e),setTimeout(()=>s.exit(0),500)}catch(e){console.error("Error generating documentation:",e),s.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(t)=>{try{let{pantryDir:e="src/pantry"}=t,o=v.resolve(s.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 c=await i.arrayBuffer(),u=v.join(s.cwd(),"pantry.tgz");g.writeFileSync(u,new Uint8Array(c)),console.log(`Downloaded ${c.byteLength} bytes`),g.mkdirSync(o,{recursive:!0});let p=v.join(s.cwd(),"temp-pantry"),{spawn:x}=await import("node:child_process");if(g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});g.mkdirSync(p,{recursive:!0});let w=x("tar",["-xzf",u,"-C",p,"--strip-components=1"],{stdio:"inherit"});await new Promise((k,N)=>{w.on("close",(m)=>{if(m===0)k(m);else N(Error(`tar extraction failed with code ${m}`))}),w.on("error",N)});let b=v.join(p,"projects");if(g.existsSync(b)){let k=g.readdirSync(b),N=0,m=0,H=(_,P)=>{if(!g.existsSync(P))g.mkdirSync(P,{recursive:!0});for(let M of g.readdirSync(_,{withFileTypes:!0})){let D=v.join(_,M.name),C=v.join(P,M.name);if(M.isDirectory())H(D,C);else if(M.name==="package.yml")if(g.existsSync(C))m++;else g.renameSync(D,C),N++;else if(!g.existsSync(C))g.renameSync(D,C)}};console.log(`Merging ${k.length} projects from upstream...`);for(let _ of k){let P=v.join(b,_),M=v.join(o,_);if(g.statSync(P).isDirectory())H(P,M)}console.log(`Merged upstream pantry: ${N} new packages added, ${m} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(g.unlinkSync(u),g.existsSync(p))g.rmSync(p,{recursive:!0,force:!0});console.log(`
56
+ Downloading props files from pkgx/pantry GitHub repo...`);let G=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(G.ok){let k=await G.arrayBuffer(),N=v.join(s.cwd(),"pantry-gh.tar.gz"),m=v.join(s.cwd(),"temp-pantry-gh");if(g.writeFileSync(N,new Uint8Array(k)),console.log(`Downloaded GitHub archive: ${(k.byteLength/1024/1024).toFixed(1)} MB`),g.existsSync(m))g.rmSync(m,{recursive:!0,force:!0});g.mkdirSync(m,{recursive:!0});let H=x("tar",["-xzf",N,"-C",m,"--strip-components=1"],{stdio:"inherit"});await new Promise((P,M)=>{H.on("close",(D)=>D===0?P(D):M(Error(`tar failed: ${D}`))),H.on("error",M)});let _=v.join(m,"projects");if(g.existsSync(_)){let P=0,M=0,D=(C,K)=>{if(!g.existsSync(C))return;for(let W of g.readdirSync(C,{withFileTypes:!0})){let V=v.join(C,W.name),Y=v.join(K,W.name);if(W.isDirectory())D(V,Y);else if(W.name!=="package.yml")if(g.mkdirSync(K,{recursive:!0}),g.copyFileSync(V,Y),g.existsSync(Y))M++;else P++}};D(_,o),console.log(`Props files: ${P+M} synced (${P} new, ${M} updated)`)}if(g.unlinkSync(N),g.existsSync(m))g.rmSync(m,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${G.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),g.existsSync(o)){let k=g.readdirSync(o).filter((N)=>{let m=v.join(o,N);return g.statSync(m).isDirectory()&&!N.startsWith(".")});console.log(`Final result: ${k.length} projects in ${o}`)}s.exit(0)}catch(e){console.error("Error updating pantry:",e),s.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(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 c=[];if(e==="pantry")c=await se(o);else if(e==="registry")c=await ce(i);else console.error('Invalid source. Use "pantry" or "registry"'),s.exit(1);await le(c,e),console.log("✅ Successfully updated consts.ts"),console.log(`\uD83D\uDCCA Total packages: ${c.length}`);let u=new Date().toISOString(),p=`Generated from ${e} at ${u}
57
57
  Total packages: ${c.length}
58
58
 
59
59
  ${c.join(`
60
- `)}`;g.writeFileSync(`${e}-packages-summary.txt`,p),console.log(`\uD83D\uDCC4 Created ${e}-packages-summary.txt for reference`),s.exit(0)}catch(e){console.error("Error generating consts file:",e),s.exit(1)}});E.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:c,includeOsDeps:u=!1,maxDepth:p=10,verbose:w=!1,json:k=!1,installCommand:S=!1}=e,M=t||e.file;if(!M){let j=ye(o);if(j.length===0)console.error(`No dependency files found in ${o}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),s.exit(1);else if(j.length>1)console.error(`Multiple dependency files found in ${o}:`),j.forEach((m)=>console.error(` ${m}`)),console.error("Please specify which file to use with --file or [file] argument"),s.exit(1);else if(M=j[0],!k)console.log(`Found dependency file: ${M}`)}if(!g.existsSync(M))console.error(`Dependency file not found: ${M}`),s.exit(1);let G={packagesDir:i,includeOsSpecific:u,targetOs:c,maxDepth:Number.parseInt(String(p),10),verbose:w&&!k};if(!k)console.log("\uD83D\uDD0D Resolving dependencies...");let y=await J(M,G);if(k){let j={success:!0,file:M,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(j,null,2))}else{if(console.log(`
61
- ✅ 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(`
62
- Conflicts found:`),y.conflicts.forEach((m)=>{console.log(` ${m.package}: ${m.versions.join(", ")}`)});if(console.log(`
63
- \uD83D\uDCCB All unique packages to install:`),y.uniquePackages.forEach((m,H)=>{let N=y.allDependencies.find((F)=>F.name===m),v=N&&N.version&&N.version!=="latest"?` (${N.version})`:"";console.log(` ${H+1}. ${m}${v}`)}),S)console.log(`
64
- \uD83D\uDE80 Install command:`),console.log(`pantry install ${y.uniquePackages.join(" ")}`);if(Object.values(y.osSpecificDeps).reduce((m,H)=>m+H.length,0)>0)console.log(`
65
- \uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(y.osSpecificDeps).forEach(([m,H])=>{if(H.length>0)console.log(` ${m}: ${H.map((N)=>N.name).join(", ")}`)})}s.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);s.exit(1)}});E.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-1e62ct8j.js"),o={};if(t.branches)o.supportedBranches=t.branches.split(",").map((c)=>c.trim());if(t.fallback)o.fallbackVersions=t.fallback.split(",").map((c)=>c.trim());let i=e(o);switch(t.format.toLowerCase()){case"yaml":console.log(`php_versions:
60
+ `)}`;g.writeFileSync(`${e}-packages-summary.txt`,p),console.log(`\uD83D\uDCC4 Created ${e}-packages-summary.txt for reference`),s.exit(0)}catch(e){console.error("Error generating consts file:",e),s.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(t,e)=>{try{let{dir:o=".",packagesDir:i="src/packages",targetOs:c,includeOsDeps:u=!1,maxDepth:p=10,verbose:x=!1,json:w=!1,installCommand:b=!1}=e,U=t||e.file;if(!U){let N=ye(o);if(N.length===0)console.error(`No dependency files found in ${o}`),console.error("Supported filenames: deps.yaml, dependencies.yaml, pkgx.yaml (and .yml variants)"),s.exit(1);else if(N.length>1)console.error(`Multiple dependency files found in ${o}:`),N.forEach((m)=>console.error(` ${m}`)),console.error("Please specify which file to use with --file or [file] argument"),s.exit(1);else if(U=N[0],!w)console.log(`Found dependency file: ${U}`)}if(!g.existsSync(U))console.error(`Dependency file not found: ${U}`),s.exit(1);let G={packagesDir:i,includeOsSpecific:u,targetOs:c,maxDepth:Number.parseInt(String(p),10),verbose:x&&!w};if(!w)console.log("\uD83D\uDD0D Resolving dependencies...");let k=await J(U,G);if(w){let N={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(N,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((m)=>{console.log(` ${m.package}: ${m.versions.join(", ")}`)});if(console.log(`
63
+ \uD83D\uDCCB All unique packages to install:`),k.uniquePackages.forEach((m,H)=>{let _=k.allDependencies.find((M)=>M.name===m),P=_&&_.version&&_.version!=="latest"?` (${_.version})`:"";console.log(` ${H+1}. ${m}${P}`)}),b)console.log(`
64
+ \uD83D\uDE80 Install command:`),console.log(`pantry install ${k.uniquePackages.join(" ")}`);if(Object.values(k.osSpecificDeps).reduce((m,H)=>m+H.length,0)>0)console.log(`
65
+ \uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(k.osSpecificDeps).forEach(([m,H])=>{if(H.length>0)console.log(` ${m}: ${H.map((_)=>_.name).join(", ")}`)})}s.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);s.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(t)=>{try{let{getPhpVersionsForWorkflow:e}=await import("../chunk-nav50bc7.js"),o={};if(t.branches)o.supportedBranches=t.branches.split(",").map((c)=>c.trim());if(t.fallback)o.fallbackVersions=t.fallback.split(",").map((c)=>c.trim());let i=e(o);switch(t.format.toLowerCase()){case"yaml":console.log(`php_versions:
66
66
  ${i.map((c)=>` - "${c}"`).join(`
67
- `)}`);break;case"csv":console.log(i.join(","));break;case"json":default:console.log(JSON.stringify(i));break}s.exit(0)}catch(e){console.error("Error getting PHP versions:",e),s.exit(1)}});E.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-m0gz72mn.js"),{packagesDir:i="src/packages",output:c="packages.zig",aliases:u=!1,aliasesOutput:p="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await e(i,c),u)console.log(`
67
+ `)}`);break;case"csv":console.log(i.join(","));break;case"json":default:console.log(JSON.stringify(i));break}s.exit(0)}catch(e){console.error("Error getting PHP versions:",e),s.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(t)=>{try{let{generateZigDefinitions:e,generateZigAliases:o}=await import("../chunk-fzw9a127.js"),{packagesDir:i="src/packages",output:c="packages.zig",aliases:u=!1,aliasesOutput:p="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await e(i,c),u)console.log(`
68
68
  \uD83D\uDE80 Generating Zig package aliases...`),await o(i,p);console.log(`
69
- ✅ Zig code generation complete!`),s.exit(0)}catch(e){console.error("Error generating Zig definitions:",e),s.exit(1)}});E.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)`),s.exit(1);let{runRelease:i}=await import("../chunk-cwa30yjr.js"),c=await i({type:o,yes:e.yes,dryRun:e.dryRun,noChangelog:e.changelog===!1,noPush:e.push===!1,noPublish:e.publish===!1});s.exit(c.exitCode)});E.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-359r0aep.js"),o=e();if(t.json)console.log(JSON.stringify({success:!0,apps:o,total:o.length}));else{console.log(`
69
+ ✅ Zig code generation complete!`),s.exit(0)}catch(e){console.error("Error generating Zig definitions:",e),s.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(t,e)=>{let o=(t??"patch").toLowerCase();if(!["patch","minor","major"].includes(o))console.error(`error: invalid release type "${o}" (expected: patch | minor | major)`),s.exit(1);let{runRelease:i}=await import("../chunk-cwa30yjr.js"),c=await i({type:o,yes:e.yes,dryRun:e.dryRun,noChangelog:e.changelog===!1,noPush:e.push===!1,noPublish:e.publish===!1});s.exit(c.exitCode)});F.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-mjdrz996.js"),o=e();if(t.json)console.log(JSON.stringify({success:!0,apps:o,total:o.length}));else{console.log(`
70
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}`)}s.exit(0)}catch(e){console.error("Error listing apps:",e),s.exit(1)}});E.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(t)=>{try{let{checkAppUpdates:e}=await import("../chunk-359r0aep.js");if(!t.json)console.log("Checking desktop apps for updates...");let o=await e(),i=o.filter((c)=>c.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(`
71
+ `),console.log("Application".padEnd(40)+"Version"),console.log("-".repeat(60));for(let i of o)console.log(`${i.name.padEnd(40)}${i.version}`)}s.exit(0)}catch(e){console.error("Error listing apps:",e),s.exit(1)}});F.command("apps-outdated","Check for outdated desktop applications").option("-j, --json","Output as JSON").action(async(t)=>{try{let{checkAppUpdates:e}=await import("../chunk-mjdrz996.js");if(!t.json)console.log("Checking desktop apps for updates...");let o=await e(),i=o.filter((c)=>c.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
72
  Outdated Apps (${i.length}):
73
73
  `),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let u of i)console.log(`${u.name.padEnd(30)}${u.currentVersion.padEnd(16)}${(u.latestVersion||"?").padEnd(16)}${u.source}`)}else console.log(`
74
74
  All desktop apps are up to date!`);let c=o.filter((u)=>!u.updateAvailable&&u.source!=="system"&&u.source!=="unknown");if(c.length>0)console.log(`
75
- ${c.length} app(s) up to date, ${o.filter((u)=>u.source==="unknown").length} unchecked`)}s.exit(0)}catch(e){console.error("Error checking app updates:",e),s.exit(1)}});E.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(t)=>{try{let{updateApp:e}=await import("../chunk-359r0aep.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}`),s.exit(1);s.exit(0)}catch(e){console.error("Error updating app:",e),s.exit(1)}});E.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,c=i?t.slice(0,o):t,u=i?t.slice(o+1):"latest";try{let p=await q(c,u,{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: ${x.dirname(p.globalLinks[0])}`),!s.env.PATH?.split(x.delimiter).includes(x.dirname(p.globalLinks[0])))console.log(`
77
- ⚠ ${x.dirname(p.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}s.exit(0)}catch(p){console.error(`Error installing ${t}:`,p instanceof Error?p.message:p),s.exit(1)}});function ue(t){let e=ye(t);if(e.length===0)return[];try{return C(e[0]).map((o)=>o.version&&o.version!=="latest"?`${o.name}@${String(o.version).replace(/^[\^~>=<]+/,"")}`:o.name)}catch{return[]}}E.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=x.resolve(t.dir??s.cwd()),o=ue(e);if(t.install&&o.length>0)for(let u of o){let p=u.lastIndexOf("@"),w=p>0;await q(w?u.slice(0,p):u,w?u.slice(p+1):"latest",{globalBin:!0,quiet:!0}).catch((k)=>{console.error(`# could not install ${u}: ${k instanceof Error?k.message:k}`)})}let i=b(),c=[x.join(e,".bin"),i].filter((u)=>g.existsSync(u));if(t.json)console.log(JSON.stringify({path:c,PATH:[...c,s.env.PATH??""].filter(Boolean).join(x.delimiter),dependencies:o,globalBin:i},null,2)),s.exit(0);console.log(`export PATH="${[...c,"$PATH"].join(x.delimiter)}"`),s.exit(0)});E.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??D();try{if(t.uninstall){let i=ve({shell:e});console.log(i.changed?`✓ Removed pantry shell-init from ${i.rcFile}`:`Nothing to remove (no pantry shell-init block in ${i.rcFile})`),s.exit(0)}if(t.install){let i=ke({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}`);s.exit(0)}let o=R(e);if(s.stdout.isTTY){if(console.log(`# Detected shell: ${e}`),console.log(`# Global bin dir: ${b()}`),o)console.log(`# Append this to: ${o}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}s.stdout.write(X({shell:e})),s.exit(0)}catch(o){console.error("Error:",o instanceof Error?o.message:o),s.exit(1)}});E.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 u of[].concat(e.buildArg??[])){let p=u.indexOf("=");if(p!==-1)i[u.slice(0,p)]=u.slice(p+1)}let c=await je({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(`
75
+ ${c.length} app(s) up to date, ${o.filter((u)=>u.source==="unknown").length} unchecked`)}s.exit(0)}catch(e){console.error("Error checking app updates:",e),s.exit(1)}});F.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(t)=>{try{let{updateApp:e}=await import("../chunk-mjdrz996.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}`),s.exit(1);s.exit(0)}catch(e){console.error("Error updating app:",e),s.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(t,e)=>{let o=t.lastIndexOf("@"),i=o>0,c=i?t.slice(0,o):t,u=i?t.slice(o+1):"latest";try{let p=await q(c,u,{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: ${v.dirname(p.globalLinks[0])}`),!s.env.PATH?.split(v.delimiter).includes(v.dirname(p.globalLinks[0])))console.log(`
77
+ ⚠ ${v.dirname(p.globalLinks[0])} is not on your PATH yet.`),console.log(" Run `ts-pantry shell-init --install` once to fix that.")}}s.exit(0)}catch(p){console.error(`Error installing ${t}:`,p instanceof Error?p.message:p),s.exit(1)}});function ue(t){let e=ye(t);if(e.length===0)return[];try{return S(e[0]).map((o)=>o.version&&o.version!=="latest"?`${o.name}@${String(o.version).replace(/^[\^~>=<]+/,"")}`:o.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(t)=>{let e=v.resolve(t.dir??s.cwd()),o=ue(e);if(t.install&&o.length>0)for(let u of o){let p=u.lastIndexOf("@"),x=p>0;await q(x?u.slice(0,p):u,x?u.slice(p+1):"latest",{globalBin:!0,quiet:!0}).catch((w)=>{console.error(`# could not install ${u}: ${w instanceof Error?w.message:w}`)})}let i=y(),c=[v.join(e,".bin"),i].filter((u)=>g.existsSync(u));if(t.json)console.log(JSON.stringify({path:c,PATH:[...c,s.env.PATH??""].filter(Boolean).join(v.delimiter),dependencies:o,globalBin:i},null,2)),s.exit(0);console.log(`export PATH="${[...c,"$PATH"].join(v.delimiter)}"`),s.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(t)=>{let e=t.shell??A();try{if(t.uninstall){let i=ve({shell:e});console.log(i.changed?`✓ Removed pantry shell-init from ${i.rcFile}`:`Nothing to remove (no pantry shell-init block in ${i.rcFile})`),s.exit(0)}if(t.install){let i=ke({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}`);s.exit(0)}let o=R(e);if(s.stdout.isTTY){if(console.log(`# Detected shell: ${e}`),console.log(`# Global bin dir: ${y()}`),o)console.log(`# Append this to: ${o}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}s.stdout.write(X({shell:e})),s.exit(0)}catch(o){console.error("Error:",o instanceof Error?o.message:o),s.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(t,e)=>{try{let o=[].concat(e.tag??[]),i={};for(let u of[].concat(e.buildArg??[])){let p=u.indexOf("=");if(p!==-1)i[u.slice(0,p)]=u.slice(p+1)}let c=await je({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
78
  ✓ Built ${c.imageId}`),o.length)console.log(` tags: ${o.join(", ")}`);console.log(` archive: ${c.archivePath}`),console.log(` oci layout: ${c.ociLayoutPath}`)}if(e.push){let u=te(o[0]||"app:latest");if(!e.quiet)console.log(`
79
- Pushing ${u.repository}:${u.tag} → ${l} ...`);let p=await Ce({repository:u.repository,tag:u.tag,registry:u.implicitRegistry?void 0:`https://${u.registry}`,configBytes:Buffer.from(c.configBytes),configDigest:c.configDigest,layers:c.layers.map((w)=>({digest:w.digest,path:w.path,size:w.size})),manifestBytes:Buffer.from(c.manifestBytes),manifestMediaType:c.manifestMediaType,quiet:e.quiet});console.log(`✓ Pushed ${p.ref} (${p.digest})`)}s.exit(0)}catch(o){console.error("Build failed:",o instanceof Error?o.message:o),s.exit(1)}});E.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=Se({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}`),s.exit(0)}catch(o){console.error("Generate failed:",o instanceof Error?o.message:o),s.exit(1)}});E.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(s.cwd(),{bump:t.bump||"patch",dryRun:t.dryRun})});E.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(s.cwd(),"check"),null,2))});E.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(s.cwd(),"release"),null,2))});E.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=ua({outputDirectory:t.output??".pantry/apple",commonName:t.name});console.log(JSON.stringify({requests:e},null,2)),s.exit(0)}catch(e){console.error("Apple CSR generation failed:",e instanceof Error?e.message:e),s.exit(1)}});E.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=(k)=>{if(!k)return;return g.readFileSync(x.resolve(k),"utf8")},o=x.resolve(t.output??".pantry/apple");g.mkdirSync(o,{recursive:!0});let i=await ja({identifier:t.bundleId,name:t.name,capabilities:t.capabilities?.split(",").map((k)=>k.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 k of i.certificates){if(!k.certificateContent)continue;let S=k.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",M=x.join(o,`${S}.cer`);g.writeFileSync(M,Buffer.from(k.certificateContent,"base64"),{mode:384});let G=k.type==="MAC_APP_DISTRIBUTION"?t.appCertificateCsr:t.installerCertificateCsr;if(t.p12Password&&G)ha({certificatePath:M,privateKeyPath:x.resolve(G.replace(/\.csr$/i,".key")),outputPath:x.join(o,`${S}.p12`),password:t.p12Password,name:`${t.name} ${k.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(i.profile.profileContent)g.writeFileSync(x.join(o,"mac-app-store.provisionprofile"),Buffer.from(i.profile.profileContent,"base64"),{mode:384});let c=i.certificates.map((k)=>{let S={...k};return delete S.certificateContent,S}),u={...i.profile};delete u.profileContent;let p={...i,certificates:c,profile:u},w=x.join(o,"provisioning-plan.json");g.writeFileSync(w,`${JSON.stringify(p,null,2)}
80
- `,{mode:384}),console.log(JSON.stringify({reportPath:w,...p},null,2)),s.exit(0)}catch(e){console.error("App Store provisioning failed:",e instanceof Error?e.message:e),s.exit(1)}});E.help();E.version(B);var Ee=E.parse();if(s.argv.length<=2||s.argv.includes("--help")||s.argv.includes("-h"))s.exit(0);
79
+ Pushing ${u.repository}:${u.tag} → ${l} ...`);let p=await Ce({repository:u.repository,tag:u.tag,registry:u.implicitRegistry?void 0:`https://${u.registry}`,configBytes:Buffer.from(c.configBytes),configDigest:c.configDigest,layers:c.layers.map((x)=>({digest:x.digest,path:x.path,size:x.size})),manifestBytes:Buffer.from(c.manifestBytes),manifestMediaType:c.manifestMediaType,quiet:e.quiet});console.log(`✓ Pushed ${p.ref} (${p.digest})`)}s.exit(0)}catch(o){console.error("Build failed:",o instanceof Error?o.message:o),s.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(t,e)=>{try{let o=Se({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}`),s.exit(0)}catch(o){console.error("Generate failed:",o instanceof Error?o.message:o),s.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(t)=>{let{releaseNativeApp:e}=await import("../src/native/release.js");await e(s.cwd(),{bump:t.bump||"patch",dryRun:t.dryRun})});F.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(s.cwd(),"check"),null,2))});F.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(s.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((t)=>{try{if(!t.name)throw Error("--name is required");let e=ha({outputDirectory:t.output??".pantry/apple",commonName:t.name});console.log(JSON.stringify({requests:e},null,2)),s.exit(0)}catch(e){console.error("Apple CSR generation failed:",e instanceof Error?e.message:e),s.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(t)=>{try{if(!t.bundleId||!t.name)throw Error("--bundle-id and --name are required");let e=(w)=>{if(!w)return;return g.readFileSync(v.resolve(w),"utf8")},o=v.resolve(t.output??".pantry/apple");g.mkdirSync(o,{recursive:!0});let i=await Sa({identifier:t.bundleId,name:t.name,capabilities:t.capabilities?.split(",").map((w)=>w.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 w of i.certificates){if(!w.certificateContent)continue;let b=w.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",U=v.join(o,`${b}.cer`);g.writeFileSync(U,Buffer.from(w.certificateContent,"base64"),{mode:384});let G=w.type==="MAC_APP_DISTRIBUTION"?t.appCertificateCsr:t.installerCertificateCsr;if(t.p12Password&&G)fa({certificatePath:U,privateKeyPath:v.resolve(G.replace(/\.csr$/i,".key")),outputPath:v.join(o,`${b}.p12`),password:t.p12Password,name:`${t.name} ${w.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(i.profile.profileContent)g.writeFileSync(v.join(o,"mac-app-store.provisionprofile"),Buffer.from(i.profile.profileContent,"base64"),{mode:384});let c=i.certificates.map((w)=>{let b={...w};return delete b.certificateContent,b}),u={...i.profile};delete u.profileContent;let p={...i,certificates:c,profile:u},x=v.join(o,"provisioning-plan.json");g.writeFileSync(x,`${JSON.stringify(p,null,2)}
80
+ `,{mode:384}),console.log(JSON.stringify({reportPath:x,...p},null,2)),s.exit(0)}catch(e){console.error("App Store provisioning failed:",e instanceof Error?e.message:e),s.exit(1)}});F.help();F.version(B);var Ee=F.parse();if(s.argv.length<=2||s.argv.includes("--help")||s.argv.includes("-h"))s.exit(0);
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import{_,B}from"../chunk-0dr09n6t.js";import"../chunk-63zdvbqd.js";import"../chunk-je6hvsr6.js";import{F,Y,ue,Re}from"../chunk-hnykqejt.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"?>
2
+ import{T,B}from"../chunk-7j5va6d3.js";import"../chunk-8teqa39h.js";import"../chunk-kyakwzhh.js";import{F,Y,ue,Re}from"../chunk-ghf9cbt0.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
3
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4
4
  <plist version="1.0"><dict>
5
5
  <key>Label</key><string>dev.pantry.desktop</string>
@@ -9,6 +9,6 @@ import{_,B}from"../chunk-0dr09n6t.js";import"../chunk-63zdvbqd.js";import"../chu
9
9
  <key>StandardOutPath</key><string>${a(s(r,"service.log"))}</string>
10
10
  <key>StandardErrorPath</key><string>${a(s(r,"service.log"))}</string>
11
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=F();D(r);let i=s(r,"runtime");m(i,{recursive:!0,mode:448});let n=s(i,`pantry-desktop-${B}`),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){Y(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 _("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=Re({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=ue();console.log(t.json?JSON.stringify({code:e,expiresInSeconds:300}):`Pantry pairing code: ${e}
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=F();D(r);let i=s(r,"runtime");m(i,{recursive:!0,mode:448});let n=s(i,`pantry-desktop-${B}`),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){Y(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 T("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=Re({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=ue();console.log(t.json?JSON.stringify({code:e,expiresInSeconds:300}):`Pantry pairing code: ${e}
13
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: ${ue()}
14
14
  Enter it in your desktop app within five minutes.`)});p.help();await p.parse();
@@ -1,31 +1,31 @@
1
- import{existsSync as X}from"node:fs";import V from"node:fs/promises";import P from"node:os";import A from"node:path";import y from"node:process";import{EventEmitter as Z}from"node:events";import v from"node:process";import z from"node:process";import R from"node:process";import T from"node:process";import S from"node:process";import U from"node:tty";import Pe,{stdin as ht,stdout as mt}from"node:process";class K{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=P.homedir(),t=A.join(e,".config","clapp");this.configPath=A.join(t,"telemetry.json")}async isEnabled(){if(y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true")return!1;if(y.env.NO_TELEMETRY==="1"||y.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let i={event:e,...t,timestamp:Date.now(),platform:P.platform(),nodeVersion:y.version};if(this.events.push(i),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(X(this.configPath)){let e=await V.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=A.dirname(this.configPath);await V.mkdir(t,{recursive:!0}),await V.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var Xe=new K;function N(e){return e.replace(/[<[].+/,"").trim()}function ee(e){let t=/<([^>]+)>/g,s=/\[([^\]]+)\]/g,i=[],o=(c)=>{let n=!1,r=c[1];if(r.startsWith("..."))r=r.slice(3),n=!0;return{required:c[0].startsWith("<"),value:r,variadic:n}},a;while(a=t.exec(e))i.push(o(a));let h;while(h=s.exec(e))i.push(o(h));return i}function te(e){let t={alias:{},boolean:[]};for(let[s,i]of e.entries()){if(i.names.length>1)t.alias[i.names[0]]=i.names.slice(1);if(i.isBoolean)if(i.negated){if(!e.some((a,h)=>h!==s&&a.names.some((c)=>i.names.includes(c))&&typeof a.required==="boolean"))t.boolean.push(i.names[0])}else t.boolean.push(i.names[0])}return t}function F(e){return e.reduce((t,s)=>t.length>=s.length?t:s,"")}function M(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function E(e){return e.replace(/([a-z])-([a-z])/g,(t,s,i)=>s+i.toUpperCase())}function se(e,t,s){let i=0,o=t.length,a=e,h;for(;i<o;++i)h=a[t[i]],a=a[t[i]]=i===o-1?s:h!=null?h:!!~t[i+1].indexOf(".")||!(+t[i+1]>-1)?{}:[]}function ie(e,t){for(let s of Object.keys(t)){let i=t[s];if(i.shouldTransform){if(e[s]=Array.prototype.concat.call([],e[s]),typeof i.transformFunction==="function")e[s]=e[s].map(i.transformFunction)}}}function ne(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function I(e){return e.split(".").map((t,s)=>s===0?E(t):t).join(".")}class O extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,t){super(e);if(this.name=this.constructor.name,t!==void 0)this.usage=t;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}
1
+ import{existsSync as X}from"node:fs";import V from"node:fs/promises";import P from"node:os";import A from"node:path";import y from"node:process";import{EventEmitter as Z}from"node:events";import v from"node:process";import z from"node:process";import R from"node:process";import E from"node:process";import S from"node:process";import U from"node:tty";import Pe,{stdin as ht,stdout as mt}from"node:process";class K{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=P.homedir(),t=A.join(e,".config","clapp");this.configPath=A.join(t,"telemetry.json")}async isEnabled(){if(y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true")return!1;if(y.env.NO_TELEMETRY==="1"||y.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let i={event:e,...t,timestamp:Date.now(),platform:P.platform(),nodeVersion:y.version};if(this.events.push(i),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:y.env.DO_NOT_TRACK==="1"||y.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(X(this.configPath)){let e=await V.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=A.dirname(this.configPath);await V.mkdir(t,{recursive:!0}),await V.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var Xe=new K;function N(e){return e.replace(/[<[].+/,"").trim()}function ee(e){let t=/<([^>]+)>/g,s=/\[([^\]]+)\]/g,i=[],o=(c)=>{let n=!1,r=c[1];if(r.startsWith("..."))r=r.slice(3),n=!0;return{required:c[0].startsWith("<"),value:r,variadic:n}},a;while(a=t.exec(e))i.push(o(a));let h;while(h=s.exec(e))i.push(o(h));return i}function te(e){let t={alias:{},boolean:[]};for(let[s,i]of e.entries()){if(i.names.length>1)t.alias[i.names[0]]=i.names.slice(1);if(i.isBoolean)if(i.negated){if(!e.some((a,h)=>h!==s&&a.names.some((c)=>i.names.includes(c))&&typeof a.required==="boolean"))t.boolean.push(i.names[0])}else t.boolean.push(i.names[0])}return t}function F(e){return e.reduce((t,s)=>t.length>=s.length?t:s,"")}function M(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function k(e){return e.replace(/([a-z])-([a-z])/g,(t,s,i)=>s+i.toUpperCase())}function se(e,t,s){let i=0,o=t.length,a=e,h;for(;i<o;++i)h=a[t[i]],a=a[t[i]]=i===o-1?s:h!=null?h:!!~t[i+1].indexOf(".")||!(+t[i+1]>-1)?{}:[]}function ie(e,t){for(let s of Object.keys(t)){let i=t[s];if(i.shouldTransform){if(e[s]=Array.prototype.concat.call([],e[s]),typeof i.transformFunction==="function")e[s]=e[s].map(i.transformFunction)}}}function ne(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function I(e){return e.split(".").map((t,s)=>s===0?k(t):t).join(".")}class _ extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,t){super(e);if(this.name=this.constructor.name,t!==void 0)this.usage=t;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}
2
2
 
3
3
  Stack trace:
4
- ${this.stack}`;return this.message}}function re(e){if(e instanceof O)return!0;return!!e&&typeof e==="object"&&e.name==="ClappError"&&typeof e.message==="string"}function oe(){let{env:e}=z,{TERM:t,TERM_PROGRAM:s}=e;if(z.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||s==="Terminus-Sublime"||s==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var j="\x1B",g=`${j}[`;var H={to(e,t){if(!t)return`${g}${e+1}G`;return`${g}${t+1};${e+1}H`},move(e,t){let s="";if(e<0)s+=`${g}${-e}D`;else if(e>0)s+=`${g}${e}C`;if(t<0)s+=`${g}${-t}A`;else if(t>0)s+=`${g}${t}B`;return s},up:(e=1)=>`${g}${e}A`,down:(e=1)=>`${g}${e}B`,forward:(e=1)=>`${g}${e}C`,backward:(e=1)=>`${g}${e}D`,nextLine:(e=1)=>`${g}E`.repeat(e),prevLine:(e=1)=>`${g}F`.repeat(e),left:`${g}G`,hide:`${g}?25l`,show:`${g}?25h`,save:`${j}7`,restore:`${j}8`};var st={screen:`${g}2J`,up:(e=1)=>`${g}1J`.repeat(e),down:(e=1)=>`${g}J`.repeat(e),line:`${g}2K`,lineEnd:`${g}K`,lineStart:`${g}1K`,lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?H.up():"");if(e)t+=H.left;return t}},it={screen:`${j}c`};function ae(e,t){let s=[];for(let i=0;i<=t.length;i++)s[i]=[i];for(let i=0;i<=e.length;i++)s[0][i]=i;for(let i=1;i<=t.length;i++)for(let o=1;o<=e.length;o++)if(t.charAt(i-1)===e.charAt(o-1))s[i][o]=s[i-1][o-1];else s[i][o]=Math.min(s[i-1][o-1]+1,s[i][o-1]+1,s[i-1][o]+1);return s[t.length][e.length]}function q(e,t,s=2,i=3){return t.map((o)=>({cmd:o,distance:ae(e,o)})).filter(({distance:o})=>o<=s).sort((o,a)=>o.distance-a.distance).slice(0,i).map(({cmd:o})=>o)}function le(e,t={}){let s={_:[]},i=t.alias||{},o=new Set(t.boolean||[]),a={};for(let n of Object.keys(i))for(let r of i[n])a[r]=n;for(let n of o)if(i[n])for(let r of i[n])o.add(r);function h(n,r){if(n===void 0)return r;if(typeof r==="boolean")return r;return Array.isArray(n)?[...n,r]:[n,r]}function c(n,r){let u=a[n]||n,m=h(s[u],r);if(s[u]=m,i[u])for(let l of i[u])s[l]=m;if(a[n]&&i[a[n]])for(let l of i[a[n]])s[l]=m;s[n]=m}for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){s._.push(...e.slice(n+1));break}if(r.startsWith("--")){let u=r.indexOf("=");if(u!==-1){let m=E(r.slice(2,u)),l=r.slice(u+1);c(m,l)}else{let m=r.slice(2);if(m.startsWith("no-")){let d=E(m.slice(3));c(d,!1);continue}let l=E(m),b=a[l]||l;if(o.has(b)||o.has(l))c(l,!0);else{let d=e[n+1];if(d!==void 0&&!d.startsWith("-"))c(l,d),n++;else c(l,!0)}}}else if(r.startsWith("-")&&r.length>1){let u=r.slice(1);for(let m=0;m<u.length;m++){let l=u[m],b=a[l]||l;if(m===u.length-1&&!o.has(b)&&!o.has(l)){let d=e[n+1];if(d!==void 0&&!d.startsWith("-"))c(l,d),n++;else c(l,!0)}else c(l,!0)}}else s._.push(r)}return s}class Y{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,s){if(this.rawName=e,this.description=t,this.config=Object.assign({},s),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=N(e).split(",").map((i)=>{let o=i.trim().replace(/^-{1,2}/,"");if(o.startsWith("no-"))this.negated=!0,o=o.replace(/^no-/,"");return I(o)}).sort((i,o)=>i.length>o.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 rt=R.argv,ue=`${R.platform}-${R.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,G=T.argv,ce=`${T.platform}-${T.arch} node-${T.version}`;class L{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,s,i){this.rawName=e,this.description=t,this.config=s,this.cli=i,this.options=[],this.aliasNames=[],this.name=N(e);let o=N(e),a=o.indexOf(":");if(a>0)this.namespace=o.substring(0,a),this.name=o.substring(a+1);if(this.args=ee(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!s)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,s){let i=new Y(e,t,s);return this.options.push(i),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 D}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){let t=I(e.split(".")[0]);return!!this.options.find((s)=>s.names.some((i)=>I(i)===t))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:s,options:i,helpCallback:o}=this.cli.globalCommand,a=[{body:`${e}${s?`/${s}`:""}`}];if(a.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let r=F(t.map((d)=>d.rawName)),u=new Map,m=[];for(let d of t)if(d.namespace){if(!u.has(d.namespace))u.set(d.namespace,[]);u.get(d.namespace).push(d)}else m.push(d);let l="";if(m.sort((d,k)=>d.rawName<k.rawName?-1:d.rawName>k.rawName?1:0),m.length>0)l+=m.map((d)=>` ${M(d.rawName,r.length)} ${d.description}`).join(`
5
- `);let b=Array.from(u.keys()).sort();for(let d of b){let k=u.get(d);if(l.length>0)l+=`
4
+ ${this.stack}`;return this.message}}function re(e){if(e instanceof _)return!0;return!!e&&typeof e==="object"&&e.name==="ClappError"&&typeof e.message==="string"}function oe(){let{env:e}=z,{TERM:t,TERM_PROGRAM:s}=e;if(z.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||s==="Terminus-Sublime"||s==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var j="\x1B",g=`${j}[`;var H={to(e,t){if(!t)return`${g}${e+1}G`;return`${g}${t+1};${e+1}H`},move(e,t){let s="";if(e<0)s+=`${g}${-e}D`;else if(e>0)s+=`${g}${e}C`;if(t<0)s+=`${g}${-t}A`;else if(t>0)s+=`${g}${t}B`;return s},up:(e=1)=>`${g}${e}A`,down:(e=1)=>`${g}${e}B`,forward:(e=1)=>`${g}${e}C`,backward:(e=1)=>`${g}${e}D`,nextLine:(e=1)=>`${g}E`.repeat(e),prevLine:(e=1)=>`${g}F`.repeat(e),left:`${g}G`,hide:`${g}?25l`,show:`${g}?25h`,save:`${j}7`,restore:`${j}8`};var st={screen:`${g}2J`,up:(e=1)=>`${g}1J`.repeat(e),down:(e=1)=>`${g}J`.repeat(e),line:`${g}2K`,lineEnd:`${g}K`,lineStart:`${g}1K`,lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?H.up():"");if(e)t+=H.left;return t}},it={screen:`${j}c`};function ae(e,t){let s=[];for(let i=0;i<=t.length;i++)s[i]=[i];for(let i=0;i<=e.length;i++)s[0][i]=i;for(let i=1;i<=t.length;i++)for(let o=1;o<=e.length;o++)if(t.charAt(i-1)===e.charAt(o-1))s[i][o]=s[i-1][o-1];else s[i][o]=Math.min(s[i-1][o-1]+1,s[i][o-1]+1,s[i-1][o]+1);return s[t.length][e.length]}function q(e,t,s=2,i=3){return t.map((o)=>({cmd:o,distance:ae(e,o)})).filter(({distance:o})=>o<=s).sort((o,a)=>o.distance-a.distance).slice(0,i).map(({cmd:o})=>o)}function le(e,t={}){let s={_:[]},i=t.alias||{},o=new Set(t.boolean||[]),a={};for(let n of Object.keys(i))for(let r of i[n])a[r]=n;for(let n of o)if(i[n])for(let r of i[n])o.add(r);function h(n,r){if(n===void 0)return r;if(typeof r==="boolean")return r;return Array.isArray(n)?[...n,r]:[n,r]}function c(n,r){let u=a[n]||n,m=h(s[u],r);if(s[u]=m,i[u])for(let l of i[u])s[l]=m;if(a[n]&&i[a[n]])for(let l of i[a[n]])s[l]=m;s[n]=m}for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){s._.push(...e.slice(n+1));break}if(r.startsWith("--")){let u=r.indexOf("=");if(u!==-1){let m=k(r.slice(2,u)),l=r.slice(u+1);c(m,l)}else{let m=r.slice(2);if(m.startsWith("no-")){let d=k(m.slice(3));c(d,!1);continue}let l=k(m),b=a[l]||l;if(o.has(b)||o.has(l))c(l,!0);else{let d=e[n+1];if(d!==void 0&&!d.startsWith("-"))c(l,d),n++;else c(l,!0)}}}else if(r.startsWith("-")&&r.length>1){let u=r.slice(1);for(let m=0;m<u.length;m++){let l=u[m],b=a[l]||l;if(m===u.length-1&&!o.has(b)&&!o.has(l)){let d=e[n+1];if(d!==void 0&&!d.startsWith("-"))c(l,d),n++;else c(l,!0)}else c(l,!0)}}else s._.push(r)}return s}class Y{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,s){if(this.rawName=e,this.description=t,this.config=Object.assign({},s),e=e.replace(/\.\*/g,""),this.negated=!1,this.names=N(e).split(",").map((i)=>{let o=i.trim().replace(/^-{1,2}/,"");if(o.startsWith("no-"))this.negated=!0,o=o.replace(/^no-/,"");return I(o)}).sort((i,o)=>i.length>o.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 rt=R.argv,ue=`${R.platform}-${R.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,G=E.argv,ce=`${E.platform}-${E.arch} node-${E.version}`;class L{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,s,i){this.rawName=e,this.description=t,this.config=s,this.cli=i,this.options=[],this.aliasNames=[],this.name=N(e);let o=N(e),a=o.indexOf(":");if(a>0)this.namespace=o.substring(0,a),this.name=o.substring(a+1);if(this.args=ee(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!s)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,s){let i=new Y(e,t,s);return this.options.push(i),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 D}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){let t=I(e.split(".")[0]);return!!this.options.find((s)=>s.names.some((i)=>I(i)===t))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:s,options:i,helpCallback:o}=this.cli.globalCommand,a=[{body:`${e}${s?`/${s}`:""}`}];if(a.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let r=F(t.map((d)=>d.rawName)),u=new Map,m=[];for(let d of t)if(d.namespace){if(!u.has(d.namespace))u.set(d.namespace,[]);u.get(d.namespace).push(d)}else m.push(d);let l="";if(m.sort((d,O)=>d.rawName<O.rawName?-1:d.rawName>O.rawName?1:0),m.length>0)l+=m.map((d)=>` ${M(d.rawName,r.length)} ${d.description}`).join(`
5
+ `);let b=Array.from(u.keys()).sort();for(let d of b){let O=u.get(d);if(l.length>0)l+=`
6
6
 
7
7
  `;l+=` ${d}:
8
- `,l+=k.map((W)=>` ${M(W.rawName,r.length-2)} ${W.description}`).join(`
8
+ `,l+=O.map((W)=>` ${M(W.rawName,r.length-2)} ${W.description}`).join(`
9
9
  `)}a.push({title:"Commands",body:l}),a.push({body:`Run \`${e} <command> --help\` for command details.`})}let c=new Set(this.options.flatMap((r)=>r.names)),n=this.isGlobalCommand?i:[...this.options,...(i||[]).filter((r)=>!r.names.some((u)=>c.has(u)))];if(!this.isGlobalCommand&&!this.isDefaultCommand)n=n.filter((r)=>r.name!=="version");if(n.length>0){let r=F(n.map((u)=>u.rawName));a.push({title:"Options",body:n.map((u)=>` ${M(u.rawName,r.length)} ${u.description} ${u.config.default===void 0?"":`(default: ${u.config.default})`}`).join(`
10
10
  `)})}if(this.examples.length>0)a.push({title:"Examples",body:this.examples.map((r)=>{if(typeof r==="function")return r(e);return r}).join(`
11
11
  `)});if(o)a=o(a)||a;console.log(a.map((r)=>r.title?`${r.title}:
12
12
  ${r.body}`:r.body).join(`
13
13
 
14
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.log(`${e}/${t} ${typeof Bun<"u"?ue:ce}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e){let s=this.args.filter((o)=>o.required).slice(this.cli.args.length),i=s.map((o)=>`<${o.value}>`).join(" ");throw new O(`Missing required argument${s.length>1?"s":""}: ${i}
14
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.log(`${e}/${t} ${typeof Bun<"u"?ue:ce}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e){let s=this.args.filter((o)=>o.required).slice(this.cli.args.length),i=s.map((o)=>`<${o.value}>`).join(" ");throw new _(`Missing required argument${s.length>1?"s":""}: ${i}
15
15
 
16
16
  Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let s of Object.keys(e))if(s!=="--"&&!this.hasOption(s)&&!t.hasOption(s)){let o=[...t.options,...this.options].flatMap((r)=>r.names),a=I(s.split(".")[0]),h=s.length>1?`--${s}`:`-${s}`,c=q(a,o),n=`Unknown option \`${h}\``;if(c.length>0)n+=`
17
17
 
18
18
  Did you mean one of these?`,c.forEach((r)=>{let u=r.length>1?`--${r}`:`-${r}`;n+=`
19
19
  • ${u}`});throw n+=`
20
20
 
21
- Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new O(n,this.usageLine)}}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,s=[...t.options,...this.options];for(let i of s){let o=e[i.name.split(".")[0]];if(i.required){let a=s.some((h)=>h.negated&&h.names.includes(i.name));if(o===!0||o===!1&&!a)throw new O(`Option \`${i.rawName}\` requires a value.
21
+ Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new _(n,this.usageLine)}}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,s=[...t.options,...this.options];for(let i of s){let o=e[i.name.split(".")[0]];if(i.required){let a=s.some((h)=>h.negated&&h.names.includes(i.name));if(o===!0||o===!1&&!a)throw new _(`Option \`${i.rawName}\` requires a value.
22
22
 
23
- Example: ${this.cli.name} ${this.rawName} ${i.rawName} <value>`,this.usageLine)}}}}class D extends L{constructor(e){super("@@global@@","",{},e)}}var he=L,w={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 x={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function me(){return!0}function de(){let e={};e.supportsColor=me();function t(i,o=[]){let a=i===""?[]:[...o,i],h=function(n){if(!e.supportsColor)return n;let r="",u="";for(let m of a)if(m in x&&x[m]in w){let l=x[m];r+=w[l][0],u=w[l][1]+u}else if(m in w)r+=w[m][0],u=w[m][1]+u;return r+n+u},c=[...Object.keys(w),...Object.keys(x)];for(let n of c)if(!(n in h))Object.defineProperty(h,n,{get(){return t(n,a)}});return h}let s=[...Object.keys(w),...Object.keys(x)];for(let i of s)if(!(i in e))Object.defineProperty(e,i,{get(){return t(i)}});return e}var C=de();class _ extends Z{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 D(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let t=async(s)=>{if(console.log(`
23
+ Example: ${this.cli.name} ${this.rawName} ${i.rawName} <value>`,this.usageLine)}}}}class D extends L{constructor(e){super("@@global@@","",{},e)}}var he=L,w={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 x={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function me(){return!0}function de(){let e={};e.supportsColor=me();function t(i,o=[]){let a=i===""?[]:[...o,i],h=function(n){if(!e.supportsColor)return n;let r="",u="";for(let m of a)if(m in x&&x[m]in w){let l=x[m];r+=w[l][0],u=w[l][1]+u}else if(m in w)r+=w[m][0],u=w[m][1]+u;return r+n+u},c=[...Object.keys(w),...Object.keys(x)];for(let n of c)if(!(n in h))Object.defineProperty(h,n,{get(){return t(n,a)}});return h}let s=[...Object.keys(w),...Object.keys(x)];for(let i of s)if(!(i in e))Object.defineProperty(e,i,{get(){return t(i)}});return e}var C=de();class T extends Z{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 D(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let t=async(s)=>{if(console.log(`
24
24
 
25
25
  Received ${s}, cleaning up...`),e)try{await e()}catch(i){console.error("Error during cleanup:",i)}v.exit(0)};return v.on("SIGINT",()=>t("SIGINT")),v.on("SIGTERM",()=>t("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(e=!0){return this.enableDidYouMean=e,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(e){return this.globalCommand.usage(e),this}command(e,t,s){if(!s)s={};let i=new he(e,t||"",s,this);return i.globalCommand=this.globalCommand,this.commands.push(i),i}option(e,t,s){return this.globalCommand.option(e,t,s),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},s,i){if(this.args=e,this.options=t,s)this.matchedCommand=s;if(i)this.matchedCommandName=i;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(e){if(console.log(C.red(`
26
26
  ✗ Command "${e}" not found.
27
27
  `)),this.enableDidYouMean){let t=[];for(let i of this.commands){if(i.displayName)t.push(i.displayName);if(i.aliasNames)t.push(...i.aliasNames)}let s=q(e,t);if(s.length>0)console.log(C.yellow("Did you mean one of these?")),s.forEach((i)=>console.log(` ${C.dim("•")} ${this.name} ${i}`)),console.log("")}console.log(C.dim("Run"),`${this.name} --help`,C.dim("to see all available commands")),v.exit(1)}async parse(e=G,t={}){let{run:s=!0,exitOnError:i=!1}=t;if(i)try{return await this.parse(e,{run:s})}catch(n){throw this.handleUsageError(n),n}if(this.rawArgs=e,!this.name)this.name=e[1]?ne(e[1]):"cli";let o=!0,a=e.slice(2),h=a[0];if(h&&!h.startsWith("-")){for(let n of this.commands)if(n.isMatched(h)){let r=this.mri(a,n);o=!1;let u={...r,args:r.args.slice(1)};this.setParsedInfo(u,n,h),this.emit(`command:${h}`,n);break}if(o){let n=a[1];if(n&&!n.startsWith("-")){let r=`${h}:${n}`;for(let u of this.commands)if(u.isMatched(r)){let m=this.mri(a,u);o=!1;let l={...m,args:m.args.slice(2)};this.setParsedInfo(l,u,r),this.emit(`command:${r}`,u);break}}}}if(o){for(let n of this.commands)if(n.name===""){o=!1;let r=this.mri(a,n);this.setParsedInfo(r,n),this.emit("command:!",n);break}}if(o){let n=this.mri(e.slice(2));this.setParsedInfo(n)}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(),s=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),s=!1,this.unsetMatchedCommand();let c={args:this.args,options:this.options};if(s)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return c}mri(e,t){let s=[...this.globalCommand.options,...t?t.options:[]],i=te(s),o=[],a=e.indexOf("--");if(a>-1)o=e.slice(a+1),e=e.slice(0,a);let h=le(e,i),c={_:h._};for(let l of Object.keys(h))if(l!=="_")c[I(l)]=h[l];let n=c._,r={"--":o},u=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,m=Object.create(null);for(let l of s){if(!u&&l.config.default!==void 0)for(let b of l.names)r[b]=l.config.default;if(Array.isArray(l.config.type)){if(m[l.name]===void 0)m[l.name]={shouldTransform:!0,transformFunction:l.config.type[0]}}}for(let l of Object.keys(c))if(l!=="_"){let b=l.split(".");se(r,b,c[l]),ie(r,m)}return{args:n,options:r}}async run(e=G){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!re(e)||e.isUsageError===!1)return;let t=e.message||"command-line error",s=this.name?`${this.name}: `:"",i=/--help/.test(t)?"":e.usage?`
28
28
  Usage: ${e.usage}`:`
29
29
  Run \`${this.name??"cli"} --help\` for usage.`;v.stderr.write(`${s}${t}${i}
30
- `),v.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let i=[];s.args.forEach((c,n)=>{if(c.variadic)i.push(e.slice(n));else i.push(e[n])}),i.push(t);let o={command:s,args:i,options:t};for(let c of s.beforeHooks)await c(o);let a,h=async()=>{let c=s.commandAction.apply(this,i);if(c instanceof Promise)a=await c;else a=c;return a};if(s.middleware.length>0){let c=0,n=async()=>{if(c<s.middleware.length){let r=s.middleware[c++];await r({...o,next:n})}else await h()};await n()}else await h();for(let c of s.afterHooks)await c(o);return a}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return v.removeAllListeners("SIGINT"),v.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 J{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var at=new J;function fe(){if("FORCE_COLOR"in S.env)return S.env.FORCE_COLOR!=="0";if("NO_COLOR"in S.env||S.env.TERM==="dumb")return!1;if(S.platform==="win32")return!0;return U.isatty(1)&&U.isatty(2)}var Q=fe();function p(e,t){if(!Q)return(s)=>s;return(s)=>e+s+t}var pe=p("\x1B[0m","\x1B[0m"),ge=p("\x1B[31m","\x1B[39m"),$e=p("\x1B[32m","\x1B[39m"),be=p("\x1B[33m","\x1B[39m"),ve=p("\x1B[34m","\x1B[39m"),we=p("\x1B[35m","\x1B[39m"),ye=p("\x1B[36m","\x1B[39m"),xe=p("\x1B[37m","\x1B[39m"),Ce=p("\x1B[90m","\x1B[39m"),Se=p("\x1B[1m","\x1B[22m"),Ie=p("\x1B[3m","\x1B[23m"),_e=p("\x1B[4m","\x1B[24m"),Oe=p("\x1B[2m","\x1B[22m"),ke=p("\x1B[7m","\x1B[27m"),Ee=p("\x1B[8m","\x1B[28m"),Be=p("\x1B[9m","\x1B[29m"),Te=p("\x1B[41m","\x1B[49m"),je=p("\x1B[42m","\x1B[49m"),Ve=p("\x1B[43m","\x1B[49m"),Ae=p("\x1B[44m","\x1B[49m"),Me=p("\x1B[45m","\x1B[49m"),Ne=p("\x1B[46m","\x1B[49m"),Re=p("\x1B[47m","\x1B[49m"),Le=Q,De={reset:pe,red:ge,green:$e,yellow:be,blue:ve,magenta:we,cyan:ye,white:xe,gray:Ce,bold:Se,italic:Ie,underline:_e,dim:Oe,inverse:ke,hidden:Ee,strikethrough:Be,bgRed:Te,bgGreen:je,bgYellow:Ve,bgBlue:Ae,bgMagenta:Me,bgCyan:Ne,bgWhite:Re,isColorSupported:Le},We=De,ze=["up","down","left","right","space","enter","cancel"],dt={actions:new Set(ze),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var ft=Pe.platform.startsWith("win"),pt=Symbol("clapp:cancel");var Fe=oe();var f=(e,t)=>Fe?e:t,gt=f("◆","*"),$t=f("■","x"),bt=f("▲","x"),vt=f("◇","o"),wt=f("┌","T"),He=f("│","|"),yt=f("└","—"),xt=f("●",">"),Ct=f("○"," "),St=f("◻","[•]"),It=f("◼","[+]"),_t=f("◻","[ ]"),Ot=f("▪","•"),kt=f("─","-"),Et=f("╮","+"),Bt=f("├","+"),Tt=f("╯","+"),jt=f("●","•"),Vt=f("◆","*"),At=f("▲","!"),Mt=f("■","x");var Nt={light:f("─","-"),heavy:f("━","="),block:f("█","#")};function Ge(){return`${We.gray(He)} `}var Rt=Ge();var B="0.11.145";
31
- export{_,B};
30
+ `),v.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let i=[];s.args.forEach((c,n)=>{if(c.variadic)i.push(e.slice(n));else i.push(e[n])}),i.push(t);let o={command:s,args:i,options:t};for(let c of s.beforeHooks)await c(o);let a,h=async()=>{let c=s.commandAction.apply(this,i);if(c instanceof Promise)a=await c;else a=c;return a};if(s.middleware.length>0){let c=0,n=async()=>{if(c<s.middleware.length){let r=s.middleware[c++];await r({...o,next:n})}else await h()};await n()}else await h();for(let c of s.afterHooks)await c(o);return a}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return v.removeAllListeners("SIGINT"),v.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 J{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var at=new J;function fe(){if("FORCE_COLOR"in S.env)return S.env.FORCE_COLOR!=="0";if("NO_COLOR"in S.env||S.env.TERM==="dumb")return!1;if(S.platform==="win32")return!0;return U.isatty(1)&&U.isatty(2)}var Q=fe();function p(e,t){if(!Q)return(s)=>s;return(s)=>e+s+t}var pe=p("\x1B[0m","\x1B[0m"),ge=p("\x1B[31m","\x1B[39m"),$e=p("\x1B[32m","\x1B[39m"),be=p("\x1B[33m","\x1B[39m"),ve=p("\x1B[34m","\x1B[39m"),we=p("\x1B[35m","\x1B[39m"),ye=p("\x1B[36m","\x1B[39m"),xe=p("\x1B[37m","\x1B[39m"),Ce=p("\x1B[90m","\x1B[39m"),Se=p("\x1B[1m","\x1B[22m"),Ie=p("\x1B[3m","\x1B[23m"),_e=p("\x1B[4m","\x1B[24m"),Oe=p("\x1B[2m","\x1B[22m"),ke=p("\x1B[7m","\x1B[27m"),Ee=p("\x1B[8m","\x1B[28m"),Be=p("\x1B[9m","\x1B[29m"),Te=p("\x1B[41m","\x1B[49m"),je=p("\x1B[42m","\x1B[49m"),Ve=p("\x1B[43m","\x1B[49m"),Ae=p("\x1B[44m","\x1B[49m"),Me=p("\x1B[45m","\x1B[49m"),Ne=p("\x1B[46m","\x1B[49m"),Re=p("\x1B[47m","\x1B[49m"),Le=Q,De={reset:pe,red:ge,green:$e,yellow:be,blue:ve,magenta:we,cyan:ye,white:xe,gray:Ce,bold:Se,italic:Ie,underline:_e,dim:Oe,inverse:ke,hidden:Ee,strikethrough:Be,bgRed:Te,bgGreen:je,bgYellow:Ve,bgBlue:Ae,bgMagenta:Me,bgCyan:Ne,bgWhite:Re,isColorSupported:Le},We=De,ze=["up","down","left","right","space","enter","cancel"],dt={actions:new Set(ze),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var ft=Pe.platform.startsWith("win"),pt=Symbol("clapp:cancel");var Fe=oe();var f=(e,t)=>Fe?e:t,gt=f("◆","*"),$t=f("■","x"),bt=f("▲","x"),vt=f("◇","o"),wt=f("┌","T"),He=f("│","|"),yt=f("└","—"),xt=f("●",">"),Ct=f("○"," "),St=f("◻","[•]"),It=f("◼","[+]"),_t=f("◻","[ ]"),Ot=f("▪","•"),kt=f("─","-"),Et=f("╮","+"),Bt=f("├","+"),Tt=f("╯","+"),jt=f("●","•"),Vt=f("◆","*"),At=f("▲","!"),Mt=f("■","x");var Nt={light:f("─","-"),heavy:f("━","="),block:f("█","#")};function Ge(){return`${We.gray(He)} `}var Rt=Ge();var B="0.11.146";
31
+ export{T,B};
@@ -1,3 +1,3 @@
1
- import{execFileSync as C,execSync as m}from"node:child_process";import p from"node:fs";import B from"node:os";import u from"node:path";var b=process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev",R={"Logi Options+":"logitech.com/options-plus",logioptionsplus:"logitech.com/options-plus","Logi Options Plus":"logitech.com/options-plus",logioptionsplus_installer:"logitech.com/options-plus"},ht=new Set(["Safari","Numbers","Pages","Keynote","GarageBand","iMovie","Color Picker","Simulator","Simulator (Watch)","Preview","TextEdit","Automator","Font Book","Migration Assistant","Photo Booth","System Preferences","System Settings","Disk Utility","Terminal","Activity Monitor","Console","Grapher","Script Editor","Time Machine","Photos","Mail","Calendar","Contacts","Reminders","Notes","Maps","Messages","FaceTime","Books","News","Stocks","Weather","Home","Podcasts","Music","TV","Voice Memos","Freeform","Shortcuts","Chess","Dictionary","Stickies","Image Capture","Xcode"]),ft=new Set(["Xcode","Numbers","Pages","Keynote","GarageBand","iMovie","Things3","Grammarly for Safari","AdBlock","HP Smart","Audible","Mini Motorways","Snake.io+","WhatsApp Messenger","Honey","Wappalyzer"]);function bt(r,s){if(!r||!s||r===s)return!1;if(s==="?")return!!r;let i=(n)=>n.replace(/[,+].*/g,"").replace(/-.*$/,"").split(".").map((o)=>Number.parseInt(o,10)||0),e=i(r),t=i(s);for(let n=0;n<Math.max(e.length,t.length);n++){let o=e[n]||0,a=t[n]||0;if(o>a)return!0;if(o<a)return!1}return!1}function A(r){return r.toLowerCase().replace(/[^a-z0-9]/g,"")}function ge(r="/Applications"){if(process.platform!=="darwin")return[];let s=[];if(!p.existsSync(r))return s;let i=p.readdirSync(r).filter((e)=>e.endsWith(".app"));for(let e of i){let t=e.replace(/\.app$/,""),n=`${r}/${e}`,o="?",a;try{let l=`${n}/Contents/Info.plist`;if(p.existsSync(l)){let c=C("/usr/libexec/PlistBuddy",["-c","Print :CFBundleShortVersionString",l],{timeout:5000,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(c)o=c;try{a=C("/usr/libexec/PlistBuddy",["-c","Print :CFBundleIdentifier",l],{timeout:5000,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{}}}catch{}s.push({name:t,version:o,path:n,bundleId:a})}return s}async function Ia(){try{let r=await fetch(`${b}/desktop-apps`);if(!r.ok)return[];let s=await r.json();return(s.apps??s??[]).filter((e)=>e&&e.domain).map((e)=>({domain:e.domain,label:e.label??e.name??e.domain,version:e.version??null,platforms:e.platforms}))}catch{return[]}}function E(r,s){let i=R[r];if(i){let t=s.find((n)=>n.domain===i);if(t)return t}let e=A(r);return s.find((t)=>A(t.label)===e||A(t.domain.replace(/\.(com|app|io|net|dev|org|ai|so|rest|fr)$/,""))===e)??null}async function oo(r){let s=r||ge(),i=await Ia(),e=[];for(let t of s){let n="unknown",o=null,a=!1,l=null;if(ht.has(t.name))n="system";else{let c=E(t.name,i);if(c)n="pantry",l=c.domain,o=c.version,a=!!o&&bt(o,t.version);else if(ft.has(t.name))n="mas"}e.push({name:t.name,currentVersion:t.version,latestVersion:o,updateAvailable:a,source:n,domain:l})}return e.sort((t,n)=>{if(t.updateAvailable&&!n.updateAvailable)return-1;if(!t.updateAvailable&&n.updateAvailable)return 1;return t.name.localeCompare(n.name)}),e}async function so(r){if(process.platform!=="darwin")return{success:!1,error:"Desktop app updates are macOS-only"};try{let s=await Ia(),i=E(r,s);if(!i)return{success:!1,error:`"${r}" is not a pantry-published desktop app`};let e=i.domain,t=await fetch(`${b}/binaries/${encodeURI(e)}/metadata.json`);if(!t.ok)return{success:!1,error:`no registry metadata for ${e}`};let n=await t.json(),o=n.latestVersion,a=B.arch()==="arm64"?"darwin-arm64":"darwin-x86-64",l=n.versions?.[o]?.platforms??{},c=l[a]??l["darwin-arm64"]??l["darwin-x86-64"];if(!c?.tarball)return{success:!1,error:`no ${a} build published for ${e}@${o}`};let v=`${b}/${String(c.tarball).replace(/^\/?/,"")}`,f=p.mkdtempSync(u.join(B.tmpdir(),"pantry-app-"));try{let w=u.join(f,"pkg.tar.gz"),d=await fetch(v);if(!d.ok)return{success:!1,error:`failed to download ${v} (${d.status})`};p.writeFileSync(w,Buffer.from(await d.arrayBuffer()));let g=u.join(f,"x");p.mkdirSync(g,{recursive:!0}),m(`tar -xzf "${w}" -C "${g}"`,{timeout:120000});let k=(x,P)=>{for(let S of p.readdirSync(x,{withFileTypes:!0})){if(!S.isDirectory())continue;let I=u.join(x,S.name);if(S.name.endsWith(".app"))return I;if(P>0){let M=k(I,P-1);if(M)return M}}return null},y=k(g,3);if(!y)return{success:!1,error:`tarball for ${e} contained no .app bundle`};let h=`/Applications/${u.basename(y)}`;return m(`rm -rf "${h}"`,{timeout:30000}),m(`ditto "${y}" "${h}"`,{timeout:120000}),m(`xattr -dr com.apple.quarantine "${h}" 2>/dev/null || true`,{timeout:30000}),{success:!0,version:o}}finally{try{p.rmSync(f,{recursive:!0,force:!0})}catch{}}}catch(s){return{success:!1,error:(s?.message||"Update failed").toString().trim().split(`
1
+ import{execFileSync as C,execSync as m}from"node:child_process";import p from"node:fs";import B from"node:os";import u from"node:path";var b=process.env.PANTRY_REGISTRY_URL||"https://registry.pantry.dev",R={"Logi Options+":"logitech.com/options-plus",logioptionsplus:"logitech.com/options-plus","Logi Options Plus":"logitech.com/options-plus",logioptionsplus_installer:"logitech.com/options-plus"},bt=new Set(["Safari","Numbers","Pages","Keynote","GarageBand","iMovie","Color Picker","Simulator","Simulator (Watch)","Preview","TextEdit","Automator","Font Book","Migration Assistant","Photo Booth","System Preferences","System Settings","Disk Utility","Terminal","Activity Monitor","Console","Grapher","Script Editor","Time Machine","Photos","Mail","Calendar","Contacts","Reminders","Notes","Maps","Messages","FaceTime","Books","News","Stocks","Weather","Home","Podcasts","Music","TV","Voice Memos","Freeform","Shortcuts","Chess","Dictionary","Stickies","Image Capture","Xcode"]),yt=new Set(["Xcode","Numbers","Pages","Keynote","GarageBand","iMovie","Things3","Grammarly for Safari","AdBlock","HP Smart","Audible","Mini Motorways","Snake.io+","WhatsApp Messenger","Honey","Wappalyzer"]);function kt(r,s){if(!r||!s||r===s)return!1;if(s==="?")return!!r;let i=(n)=>n.replace(/[,+].*/g,"").replace(/-.*$/,"").split(".").map((o)=>Number.parseInt(o,10)||0),e=i(r),t=i(s);for(let n=0;n<Math.max(e.length,t.length);n++){let o=e[n]||0,a=t[n]||0;if(o>a)return!0;if(o<a)return!1}return!1}function A(r){return r.toLowerCase().replace(/[^a-z0-9]/g,"")}function ge(r="/Applications"){if(process.platform!=="darwin")return[];let s=[];if(!p.existsSync(r))return s;let i=p.readdirSync(r).filter((e)=>e.endsWith(".app"));for(let e of i){let t=e.replace(/\.app$/,""),n=`${r}/${e}`,o="?",a;try{let l=`${n}/Contents/Info.plist`;if(p.existsSync(l)){let c=C("/usr/libexec/PlistBuddy",["-c","Print :CFBundleShortVersionString",l],{timeout:5000,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();if(c)o=c;try{a=C("/usr/libexec/PlistBuddy",["-c","Print :CFBundleIdentifier",l],{timeout:5000,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{}}}catch{}s.push({name:t,version:o,path:n,bundleId:a})}return s}async function za(){try{let r=await fetch(`${b}/desktop-apps`);if(!r.ok)return[];let s=await r.json();return(s.apps??s??[]).filter((e)=>e&&e.domain).map((e)=>({domain:e.domain,label:e.label??e.name??e.domain,version:e.version??null,platforms:e.platforms}))}catch{return[]}}function E(r,s){let i=R[r];if(i){let t=s.find((n)=>n.domain===i);if(t)return t}let e=A(r);return s.find((t)=>A(t.label)===e||A(t.domain.replace(/\.(com|app|io|net|dev|org|ai|so|rest|fr)$/,""))===e)??null}async function co(r){let s=r||ge(),i=await za(),e=[];for(let t of s){let n="unknown",o=null,a=!1,l=null;if(bt.has(t.name))n="system";else{let c=E(t.name,i);if(c)n="pantry",l=c.domain,o=c.version,a=!!o&&kt(o,t.version);else if(yt.has(t.name))n="mas"}e.push({name:t.name,currentVersion:t.version,latestVersion:o,updateAvailable:a,source:n,domain:l})}return e.sort((t,n)=>{if(t.updateAvailable&&!n.updateAvailable)return-1;if(!t.updateAvailable&&n.updateAvailable)return 1;return t.name.localeCompare(n.name)}),e}async function lo(r){if(process.platform!=="darwin")return{success:!1,error:"Desktop app updates are macOS-only"};try{let s=await za(),i=E(r,s);if(!i)return{success:!1,error:`"${r}" is not a pantry-published desktop app`};let e=i.domain,t=await fetch(`${b}/binaries/${encodeURI(e)}/metadata.json`);if(!t.ok)return{success:!1,error:`no registry metadata for ${e}`};let n=await t.json(),o=n.latestVersion,a=B.arch()==="arm64"?"darwin-arm64":"darwin-x86-64",l=n.versions?.[o]?.platforms??{},c=l[a]??l["darwin-arm64"]??l["darwin-x86-64"];if(!c?.tarball)return{success:!1,error:`no ${a} build published for ${e}@${o}`};let v=`${b}/${String(c.tarball).replace(/^\/?/,"")}`,f=p.mkdtempSync(u.join(B.tmpdir(),"pantry-app-"));try{let w=u.join(f,"pkg.tar.gz"),d=await fetch(v);if(!d.ok)return{success:!1,error:`failed to download ${v} (${d.status})`};p.writeFileSync(w,Buffer.from(await d.arrayBuffer()));let g=u.join(f,"x");p.mkdirSync(g,{recursive:!0}),m(`tar -xzf "${w}" -C "${g}"`,{timeout:120000});let k=(x,P)=>{for(let S of p.readdirSync(x,{withFileTypes:!0})){if(!S.isDirectory())continue;let I=u.join(x,S.name);if(S.name.endsWith(".app"))return I;if(P>0){let M=k(I,P-1);if(M)return M}}return null},y=k(g,3);if(!y)return{success:!1,error:`tarball for ${e} contained no .app bundle`};let h=`/Applications/${u.basename(y)}`;return m(`rm -rf "${h}"`,{timeout:30000}),m(`ditto "${y}" "${h}"`,{timeout:120000}),m(`xattr -dr com.apple.quarantine "${h}" 2>/dev/null || true`,{timeout:30000}),{success:!0,version:o}}finally{try{p.rmSync(f,{recursive:!0,force:!0})}catch{}}}catch(s){return{success:!1,error:(s?.message||"Update failed").toString().trim().split(`
2
2
  `).pop()}}}
3
- export{ht,ft,bt,ge,Ia,oo,so};
3
+ export{bt,yt,kt,ge,za,co,lo};