ts-pantry 0.11.167 → 0.11.169

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{q}from"../chunk-7q8as4h2.js";import{r,f,b,D,H,ye,k,R,I,L,W,ke,ve,n,X,z,u,Z,E,_,O,M,l,ee,Ce,je,Se,ha,fa}from"../chunk-nr2yvehm.js";import{a,C}from"../chunk-365xgy2v.js";import"../chunk-frrv46sd.js";import"../chunk-3sc39cqf.js";import{Sa}from"../chunk-0e4jg545.js";import{d}from"../chunk-egf4sf0n.js";import m from"node:fs";import v from"node:path";import s from"node:process";C();async function ae(t="src/pantry"){if(!m.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 g=m.readdirSync(i,{withFileTypes:!0}),p=v.join(i,"package.yml");if(c&&m.existsSync(p))e.push(c);for(let S of g)if(S.isDirectory()&&!S.name.startsWith(".")){let w=c?`${c}/${S.name}`:S.name,x=v.join(i,S.name);o(x,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 S=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(S.searchParams.set("list-type","2"),S.searchParams.set("prefix",""),S.searchParams.set("max-keys","1000"),p)S.searchParams.set("continuation-token",p);let w=await fetch(S.toString());if(!w.ok)throw Error(`Failed to fetch S3 listing: ${w.status}`);let x=await w.text(),B=[],J=x.match(/<Key>([^<]+)<\/Key>/g);if(J)for(let G of J){let U=G.replace(/<Key>([^<]+)<\/Key>/,"$1");B.push({Key:U})}let y=x.includes("<IsTruncated>true</IsTruncated>"),F=x.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),h=F?F[1]:void 0;return{IsTruncated:y,NextContinuationToken:h,Contents:B}}console.log("Scraping packages from S3 registry...");let o=new Set,i;do{let p=await e(i);for(let S of p.Contents){let w=S.Key,x=w.split("/");if(x.length===0)continue;if(x[0].startsWith(".")||x[0].includes(" ")||w.match(/\.(md|txt|yml|yaml|json)$/i))continue;let B=["darwin","linux","windows"],J=-1;for(let y=1;y<x.length;y++)if(B.includes(x[y])){J=y;break}if(J>0){let y=x.slice(0,J).join("/");if(y.includes("."))o.add(y)}else if(x.length>=2&&x[0].includes(".")&&!x[1].startsWith("v")&&!x[1].match(/^\d/)){let y=`${x[0]}/${x[1]}`;o.add(y)}else if(x.length>=1&&x[0].includes("."))o.add(x[0])}i=p.NextContinuationToken,console.log(`Found ${o.size} packages so far...`)}while(i);let c=Array.from(o).sort(),g=[];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;g.push(p)}return console.log(`\uD83D\uDCE6 Found ${g.length} valid packages in registry`),g}async function le(t,e){let i=`/**
2
+ import{q}from"../chunk-7q8as4h2.js";import{r,f,b,D,H,ye,k,R,I,O,W,ke,ve,n,X,z,u,Z,E,_,L,M,l,ee,Ce,je,Se,ha,fa}from"../chunk-kq4jkyn1.js";import{a,C}from"../chunk-365xgy2v.js";import"../chunk-frrv46sd.js";import"../chunk-3sc39cqf.js";import{Sa}from"../chunk-0e4jg545.js";import{d}from"../chunk-xq8dke4k.js";import m from"node:fs";import v from"node:path";import s from"node:process";C();async function ae(t="src/pantry"){if(!m.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 g=m.readdirSync(i,{withFileTypes:!0}),p=v.join(i,"package.yml");if(c&&m.existsSync(p))e.push(c);for(let S of g)if(S.isDirectory()&&!S.name.startsWith(".")){let w=c?`${c}/${S.name}`:S.name,x=v.join(i,S.name);o(x,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 S=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(S.searchParams.set("list-type","2"),S.searchParams.set("prefix",""),S.searchParams.set("max-keys","1000"),p)S.searchParams.set("continuation-token",p);let w=await fetch(S.toString());if(!w.ok)throw Error(`Failed to fetch S3 listing: ${w.status}`);let x=await w.text(),B=[],J=x.match(/<Key>([^<]+)<\/Key>/g);if(J)for(let G of J){let U=G.replace(/<Key>([^<]+)<\/Key>/,"$1");B.push({Key:U})}let y=x.includes("<IsTruncated>true</IsTruncated>"),F=x.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),h=F?F[1]:void 0;return{IsTruncated:y,NextContinuationToken:h,Contents:B}}console.log("Scraping packages from S3 registry...");let o=new Set,i;do{let p=await e(i);for(let S of p.Contents){let w=S.Key,x=w.split("/");if(x.length===0)continue;if(x[0].startsWith(".")||x[0].includes(" ")||w.match(/\.(md|txt|yml|yaml|json)$/i))continue;let B=["darwin","linux","windows"],J=-1;for(let y=1;y<x.length;y++)if(B.includes(x[y])){J=y;break}if(J>0){let y=x.slice(0,J).join("/");if(y.includes("."))o.add(y)}else if(x.length>=2&&x[0].includes(".")&&!x[1].startsWith("v")&&!x[1].match(/^\d/)){let y=`${x[0]}/${x[1]}`;o.add(y)}else if(x.length>=1&&x[0].includes("."))o.add(x[0])}i=p.NextContinuationToken,console.log(`Found ${o.size} packages so far...`)}while(i);let c=Array.from(o).sort(),g=[];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;g.push(p)}return console.log(`\uD83D\uDCE6 Found ${g.length} valid packages in registry`),g}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()}
@@ -52,7 +52,7 @@ ${t.map((c)=>` '${c}',`).join(`
52
52
  `)}
53
53
  ] as const
54
54
  `;m.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],g=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(!g||!p)throw Error(`Invalid platform "${t}". Use linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, or windows-x86_64.`);return{os:g,arch:p}}var j=new q("ts-pantry"),de=1500000,te=setTimeout(()=>{console.error("Force exiting after timeout - process may have hung"),s.exit(1)},de);s.on("exit",()=>{clearTimeout(te)});async function re(t){console.log(`
55
- Received ${t} signal. Cleaning up resources...`),clearTimeout(te);try{await u(),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",()=>re("SIGINT"));s.on("SIGTERM",()=>re("SIGTERM"));function oe(t){let e={};for(let[o,i]of Object.entries(a))if(typeof i==="string")e[i]=o;return e[t]||t}function ie(t){let e=t.map(oe),o=t.map((i)=>{let c=oe(i);return c===i?i:c});return{friendlyNames:e,mixedNames:o}}j.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:f}).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:b}).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:g=!0,cacheExpiration:p=f,limit:S,timeout:w=b,json:x=!1,debug:B=!1,verbose:J=!1,concurrency:y=8,pkg:F,outputJson:h=!1}=e,G=v.resolve(s.cwd(),i);if(!m.existsSync(G))m.mkdirSync(G,{recursive:!0});let U=v.resolve(s.cwd(),c);if(g){if(!m.existsSync(U))m.mkdirSync(U,{recursive:!0})}try{let P=[],N=[];if(o){if(!h)console.log("Fetching all packages...");let A={outputDir:i,cacheDir:c,cache:g,cacheExpirationMinutes:p,timeout:Number.parseInt(String(w),10),debug:B,limit:S?Number.parseInt(String(S),10):void 0,concurrency:Math.min(Number.parseInt(String(y),10),12),outputJson:h};P=await Z(A),N=[...P]}else if(F){let A=F.split(",").map((T)=>T.trim());if(!h)console.log(`Fetching ${A.length} packages: ${A.join(", ")}`);for(let T of A)try{let K=v.join(c,`${T.replace(/\//g,"-")}.json`),V=!1;if(g&&m.existsSync(K)){let Y=m.statSync(K),Q=(Date.now()-Y.mtime.getTime())/60000;if(Q<p){if(!h)console.log(`Using cached data for ${T} (age: ${Math.round(Q)} minutes)`);try{let ne=JSON.parse(m.readFileSync(K,"utf-8"));delete ne.fetchedAt;let se=n(i,T,ne);if(J&&!h)console.log(`Using cached data for ${T} (saved to ${se})`);P.push(T),V=!0;continue}catch{console.warn(`Cache file corrupted for ${T}, will refetch`)}}}if(!V){let Y=await E(T,{timeout:Number.parseInt(String(w),10),debug:B,outputJson:h,cacheDir:c,cache:g,cacheExpirationMinutes:p});if(Y){let{outputPath:Q}=z(T,Y.packageInfo,{cacheDir:c,outputDir:i,cache:g});if(P.push(T),N.push(T),J&&!h)console.log(`Successfully saved ${T} to ${Q}`)}}}catch(K){console.error(`Error processing ${T}:`,K)}}else if(t){if(!h)console.log(`Fetching package: ${t}`);try{let A=v.join(U,`${t.replace(/\//g,"-")}.json`),T=!1;if(g&&m.existsSync(A)){let K=m.statSync(A),V=(Date.now()-K.mtime.getTime())/60000;if(V<p){if(!h)console.log(`Using cached data for ${t} (age: ${Math.round(V)} minutes)`);try{let Y=JSON.parse(m.readFileSync(A,"utf-8"));delete Y.fetchedAt;let Q=n(G,t,Y);if(J&&!h)console.log(`Using cached data for ${t} (saved to ${Q})`);P.push(t),T=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!T){let K=await E(t,{timeout:Number.parseInt(String(w),10),debug:B,outputJson:h,cacheDir:c,cache:g,cacheExpirationMinutes:p});if(K){let{outputPath:V}=z(t,K.packageInfo,{cacheDir:c,outputDir:i,cache:g});if(P.push(t),N.push(t),J&&!h)console.log(`Successfully saved ${t} to ${V}`)}}}catch(A){console.error(`Error processing ${t}:`,A)}}else{if(!h)console.error("Error: Please specify a package name, use --pkg, or use --all");s.exit(1)}if(!x&&P.length>0){let A=await _();if(!h)console.log(`Successfully generated ${A}`)}if(o&&P.length>0){let A=X(G,P);if(A.length>0&&!h)console.log(`Cleaned up ${A.length} stale generated file(s)`)}if(h){let{friendlyNames:A,mixedNames:T}=ie(N),{friendlyNames:K,mixedNames:V}=ie(P),Y={success:!0,updatedPackages:N,updatedPackagesFriendly:A,updatedPackagesMixed:T,allProcessedPackages:P,allProcessedFriendly:K,allProcessedMixed:V,totalUpdated:N.length,totalProcessed:P.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(Y))}else console.log(`Processed ${P.length} packages.`);clearTimeout(te),await u(),setTimeout(()=>s.exit(0),1000)}catch(P){if(h){let N={success:!1,error:String(P),timestamp:new Date().toISOString()};console.log(JSON.stringify(N))}else console.error("Error:",P);await u(),setTimeout(()=>s.exit(1),1000)}});j.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(!m.existsSync(o))console.error(`Error: Directory ${o} does not exist`),s.exit(1);try{let i=await _();console.log(`Successfully generated ${i}`),setTimeout(()=>s.exit(0),500)}catch(i){console.error("Error generating index:",i),s.exit(1)}});j.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(!m.existsSync(e))console.error(`Cache directory ${e} does not exist!`),s.exit(1);if(!m.existsSync(o))m.mkdirSync(o,{recursive:!0});let i=m.readdirSync(e).filter((g)=>g.endsWith(".json"));console.log(`Found ${i.length} JSON files in cache directory`);let c=0;for(let g of i)try{let p=m.readFileSync(v.join(e,g),"utf-8"),S=JSON.parse(p);delete S.fetchedAt;let w=g.replace(/\.json$/,""),x=n(o,S.fullPath||S.domain||w,S);console.log(`Generated ${x}`),c++}catch(p){console.error(`Error processing ${g}:`,p)}console.log(`Successfully generated ${c} TypeScript files from JSON cache`)}catch(e){console.error("Error generating TypeScript files:",e),s.exit(1)}});j.command("generate-aliases","Generate TypeScript aliases file for packages").action(async()=>{try{let t=await O();console.log(`Successfully generated ${t}`),setTimeout(()=>s.exit(0),500)}catch(t){console.error("Error generating aliases:",t),s.exit(1)}});j.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 M(e),setTimeout(()=>s.exit(0),500)}catch(e){console.error("Error generating documentation:",e),s.exit(1)}});j.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(),g=v.join(s.cwd(),"pantry.tgz");m.writeFileSync(g,new Uint8Array(c)),console.log(`Downloaded ${c.byteLength} bytes`),m.mkdirSync(o,{recursive:!0});let p=v.join(s.cwd(),"temp-pantry"),{spawn:S}=await import("node:child_process");if(m.existsSync(p))m.rmSync(p,{recursive:!0,force:!0});m.mkdirSync(p,{recursive:!0});let w=S("tar",["-xzf",g,"-C",p,"--strip-components=1"],{stdio:"inherit"});await new Promise((y,F)=>{w.on("close",(h)=>{if(h===0)y(h);else F(Error(`tar extraction failed with code ${h}`))}),w.on("error",F)});let x=v.join(p,"projects");if(m.existsSync(x)){let y=m.readdirSync(x),F=0,h=0,G=(U,P)=>{if(!m.existsSync(P))m.mkdirSync(P,{recursive:!0});for(let N of m.readdirSync(U,{withFileTypes:!0})){let A=v.join(U,N.name),T=v.join(P,N.name);if(N.isDirectory())G(A,T);else if(N.name==="package.yml")if(m.existsSync(T))h++;else m.renameSync(A,T),F++;else if(!m.existsSync(T))m.renameSync(A,T)}};console.log(`Merging ${y.length} projects from upstream...`);for(let U of y){let P=v.join(x,U),N=v.join(o,U);if(m.statSync(P).isDirectory())G(P,N)}console.log(`Merged upstream pantry: ${F} new packages added, ${h} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(m.unlinkSync(g),m.existsSync(p))m.rmSync(p,{recursive:!0,force:!0});console.log(`
55
+ Received ${t} signal. Cleaning up resources...`),clearTimeout(te);try{await u(),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",()=>re("SIGINT"));s.on("SIGTERM",()=>re("SIGTERM"));function oe(t){let e={};for(let[o,i]of Object.entries(a))if(typeof i==="string")e[i]=o;return e[t]||t}function ie(t){let e=t.map(oe),o=t.map((i)=>{let c=oe(i);return c===i?i:c});return{friendlyNames:e,mixedNames:o}}j.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:f}).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:b}).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:g=!0,cacheExpiration:p=f,limit:S,timeout:w=b,json:x=!1,debug:B=!1,verbose:J=!1,concurrency:y=8,pkg:F,outputJson:h=!1}=e,G=v.resolve(s.cwd(),i);if(!m.existsSync(G))m.mkdirSync(G,{recursive:!0});let U=v.resolve(s.cwd(),c);if(g){if(!m.existsSync(U))m.mkdirSync(U,{recursive:!0})}try{let P=[],N=[];if(o){if(!h)console.log("Fetching all packages...");let A={outputDir:i,cacheDir:c,cache:g,cacheExpirationMinutes:p,timeout:Number.parseInt(String(w),10),debug:B,limit:S?Number.parseInt(String(S),10):void 0,concurrency:Math.min(Number.parseInt(String(y),10),12),outputJson:h};P=await Z(A),N=[...P]}else if(F){let A=F.split(",").map((T)=>T.trim());if(!h)console.log(`Fetching ${A.length} packages: ${A.join(", ")}`);for(let T of A)try{let K=v.join(c,`${T.replace(/\//g,"-")}.json`),V=!1;if(g&&m.existsSync(K)){let Y=m.statSync(K),Q=(Date.now()-Y.mtime.getTime())/60000;if(Q<p){if(!h)console.log(`Using cached data for ${T} (age: ${Math.round(Q)} minutes)`);try{let ne=JSON.parse(m.readFileSync(K,"utf-8"));delete ne.fetchedAt;let se=n(i,T,ne);if(J&&!h)console.log(`Using cached data for ${T} (saved to ${se})`);P.push(T),V=!0;continue}catch{console.warn(`Cache file corrupted for ${T}, will refetch`)}}}if(!V){let Y=await E(T,{timeout:Number.parseInt(String(w),10),debug:B,outputJson:h,cacheDir:c,cache:g,cacheExpirationMinutes:p});if(Y){let{outputPath:Q}=z(T,Y.packageInfo,{cacheDir:c,outputDir:i,cache:g});if(P.push(T),N.push(T),J&&!h)console.log(`Successfully saved ${T} to ${Q}`)}}}catch(K){console.error(`Error processing ${T}:`,K)}}else if(t){if(!h)console.log(`Fetching package: ${t}`);try{let A=v.join(U,`${t.replace(/\//g,"-")}.json`),T=!1;if(g&&m.existsSync(A)){let K=m.statSync(A),V=(Date.now()-K.mtime.getTime())/60000;if(V<p){if(!h)console.log(`Using cached data for ${t} (age: ${Math.round(V)} minutes)`);try{let Y=JSON.parse(m.readFileSync(A,"utf-8"));delete Y.fetchedAt;let Q=n(G,t,Y);if(J&&!h)console.log(`Using cached data for ${t} (saved to ${Q})`);P.push(t),T=!0}catch{console.warn(`Cache file corrupted for ${t}, will refetch`)}}}if(!T){let K=await E(t,{timeout:Number.parseInt(String(w),10),debug:B,outputJson:h,cacheDir:c,cache:g,cacheExpirationMinutes:p});if(K){let{outputPath:V}=z(t,K.packageInfo,{cacheDir:c,outputDir:i,cache:g});if(P.push(t),N.push(t),J&&!h)console.log(`Successfully saved ${t} to ${V}`)}}}catch(A){console.error(`Error processing ${t}:`,A)}}else{if(!h)console.error("Error: Please specify a package name, use --pkg, or use --all");s.exit(1)}if(!x&&P.length>0){let A=await _();if(!h)console.log(`Successfully generated ${A}`)}if(o&&P.length>0){let A=X(G,P);if(A.length>0&&!h)console.log(`Cleaned up ${A.length} stale generated file(s)`)}if(h){let{friendlyNames:A,mixedNames:T}=ie(N),{friendlyNames:K,mixedNames:V}=ie(P),Y={success:!0,updatedPackages:N,updatedPackagesFriendly:A,updatedPackagesMixed:T,allProcessedPackages:P,allProcessedFriendly:K,allProcessedMixed:V,totalUpdated:N.length,totalProcessed:P.length,timestamp:new Date().toISOString()};console.log(JSON.stringify(Y))}else console.log(`Processed ${P.length} packages.`);clearTimeout(te),await u(),setTimeout(()=>s.exit(0),1000)}catch(P){if(h){let N={success:!1,error:String(P),timestamp:new Date().toISOString()};console.log(JSON.stringify(N))}else console.error("Error:",P);await u(),setTimeout(()=>s.exit(1),1000)}});j.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(!m.existsSync(o))console.error(`Error: Directory ${o} does not exist`),s.exit(1);try{let i=await _();console.log(`Successfully generated ${i}`),setTimeout(()=>s.exit(0),500)}catch(i){console.error("Error generating index:",i),s.exit(1)}});j.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(!m.existsSync(e))console.error(`Cache directory ${e} does not exist!`),s.exit(1);if(!m.existsSync(o))m.mkdirSync(o,{recursive:!0});let i=m.readdirSync(e).filter((g)=>g.endsWith(".json"));console.log(`Found ${i.length} JSON files in cache directory`);let c=0;for(let g of i)try{let p=m.readFileSync(v.join(e,g),"utf-8"),S=JSON.parse(p);delete S.fetchedAt;let w=g.replace(/\.json$/,""),x=n(o,S.fullPath||S.domain||w,S);console.log(`Generated ${x}`),c++}catch(p){console.error(`Error processing ${g}:`,p)}console.log(`Successfully generated ${c} TypeScript files from JSON cache`)}catch(e){console.error("Error generating TypeScript files:",e),s.exit(1)}});j.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)}});j.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 M(e),setTimeout(()=>s.exit(0),500)}catch(e){console.error("Error generating documentation:",e),s.exit(1)}});j.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(),g=v.join(s.cwd(),"pantry.tgz");m.writeFileSync(g,new Uint8Array(c)),console.log(`Downloaded ${c.byteLength} bytes`),m.mkdirSync(o,{recursive:!0});let p=v.join(s.cwd(),"temp-pantry"),{spawn:S}=await import("node:child_process");if(m.existsSync(p))m.rmSync(p,{recursive:!0,force:!0});m.mkdirSync(p,{recursive:!0});let w=S("tar",["-xzf",g,"-C",p,"--strip-components=1"],{stdio:"inherit"});await new Promise((y,F)=>{w.on("close",(h)=>{if(h===0)y(h);else F(Error(`tar extraction failed with code ${h}`))}),w.on("error",F)});let x=v.join(p,"projects");if(m.existsSync(x)){let y=m.readdirSync(x),F=0,h=0,G=(U,P)=>{if(!m.existsSync(P))m.mkdirSync(P,{recursive:!0});for(let N of m.readdirSync(U,{withFileTypes:!0})){let A=v.join(U,N.name),T=v.join(P,N.name);if(N.isDirectory())G(A,T);else if(N.name==="package.yml")if(m.existsSync(T))h++;else m.renameSync(A,T),F++;else if(!m.existsSync(T))m.renameSync(A,T)}};console.log(`Merging ${y.length} projects from upstream...`);for(let U of y){let P=v.join(x,U),N=v.join(o,U);if(m.statSync(P).isDirectory())G(P,N)}console.log(`Merged upstream pantry: ${F} new packages added, ${h} existing preserved`)}else console.log("Warning: No projects directory found in extracted pantry");if(m.unlinkSync(g),m.existsSync(p))m.rmSync(p,{recursive:!0,force:!0});console.log(`
56
56
  Downloading props files from pkgx/pantry GitHub repo...`);let J=await fetch("https://github.com/pkgxdev/pantry/archive/refs/heads/main.tar.gz");if(J.ok){let y=await J.arrayBuffer(),F=v.join(s.cwd(),"pantry-gh.tar.gz"),h=v.join(s.cwd(),"temp-pantry-gh");if(m.writeFileSync(F,new Uint8Array(y)),console.log(`Downloaded GitHub archive: ${(y.byteLength/1024/1024).toFixed(1)} MB`),m.existsSync(h))m.rmSync(h,{recursive:!0,force:!0});m.mkdirSync(h,{recursive:!0});let G=S("tar",["-xzf",F,"-C",h,"--strip-components=1"],{stdio:"inherit"});await new Promise((P,N)=>{G.on("close",(A)=>A===0?P(A):N(Error(`tar failed: ${A}`))),G.on("error",N)});let U=v.join(h,"projects");if(m.existsSync(U)){let P=0,N=0,A=(T,K)=>{if(!m.existsSync(T))return;for(let V of m.readdirSync(T,{withFileTypes:!0})){let Y=v.join(T,V.name),Q=v.join(K,V.name);if(V.isDirectory())A(Y,Q);else if(V.name!=="package.yml")if(m.mkdirSync(K,{recursive:!0}),m.copyFileSync(Y,Q),m.existsSync(Q))N++;else P++}};A(U,o),console.log(`Props files: ${P+N} synced (${P} new, ${N} updated)`)}if(m.unlinkSync(F),m.existsSync(h))m.rmSync(h,{recursive:!0,force:!0})}else console.log(`Warning: Could not download GitHub archive (${J.status}), props files will be missing`);if(console.log("Cleaned up temporary files"),m.existsSync(o)){let y=m.readdirSync(o).filter((F)=>{let h=v.join(o,F);return m.statSync(h).isDirectory()&&!F.startsWith(".")});console.log(`Final result: ${y.length} projects in ${o}`)}s.exit(0)}catch(e){console.error("Error updating pantry:",e),s.exit(1)}});j.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 ae(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 g=new Date().toISOString(),p=`Generated from ${e} at ${g}
57
57
  Total packages: ${c.length}
58
58
 
@@ -64,7 +64,7 @@ Conflicts found:`),y.conflicts.forEach((h)=>{console.log(` ${h.package}: ${h.ve
64
64
  \uD83D\uDE80 Install command:`),console.log(`pantry install ${y.uniquePackages.join(" ")}`);if(Object.values(y.osSpecificDeps).reduce((h,G)=>h+G.length,0)>0)console.log(`
65
65
  \uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(y.osSpecificDeps).forEach(([h,G])=>{if(G.length>0)console.log(` ${h}: ${G.map((U)=>U.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)}});j.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-e20vgg36.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)}});j.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-wgpsgdr0.js"),{packagesDir:i="src/packages",output:c="packages.zig",aliases:g=!1,aliasesOutput:p="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await e(i,c),g)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)}});j.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-gk0495tp.js"),{packagesDir:i="src/packages",output:c="packages.zig",aliases:g=!1,aliasesOutput:p="aliases.zig"}=t;if(console.log("\uD83D\uDE80 Generating Zig package definitions..."),await e(i,c),g)console.log(`
68
68
  \uD83D\uDE80 Generating Zig package aliases...`),await o(i,p);console.log(`
69
69
  ✅ Zig code generation complete!`),s.exit(0)}catch(e){console.error("Error generating Zig definitions:",e),s.exit(1)}});j.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)});j.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-cv2tknjc.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}):
@@ -74,7 +74,7 @@ Outdated Apps (${i.length}):
74
74
  All desktop apps are up to date!`);let c=o.filter((g)=>!g.updateAvailable&&g.source!=="system"&&g.source!=="unknown");if(c.length>0)console.log(`
75
75
  ${c.length} app(s) up to date, ${o.filter((g)=>g.source==="unknown").length} unchecked`)}s.exit(0)}catch(e){console.error("Error checking app updates:",e),s.exit(1)}});j.command("apps-update <name>","Update a desktop application from the pantry registry").action(async(t)=>{try{let{updateApp:e}=await import("../chunk-cv2tknjc.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)}});j.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,g=i?t.slice(o+1):"latest";try{let p=await R(c,g,{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
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 D(e[0]).map((o)=>o.version&&o.version!=="latest"?`${o.name}@${String(o.version).replace(/^[\^~>=<]+/,"")}`:o.name)}catch{return[]}}j.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 g of o){let p=g.lastIndexOf("@"),S=p>0;await R(S?g.slice(0,p):g,S?g.slice(p+1):"latest",{globalBin:!0,quiet:!0}).catch((w)=>{console.error(`# could not install ${g}: ${w instanceof Error?w.message:w}`)})}let i=k(),c=[v.join(e,".bin"),i].filter((g)=>m.existsSync(g));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)});j.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??I();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=L(e);if(s.stdout.isTTY){if(console.log(`# Detected shell: ${e}`),console.log(`# Global bin dir: ${k()}`),o)console.log(`# Append this to: ${o}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}s.stdout.write(W({shell:e})),s.exit(0)}catch(o){console.error("Error:",o instanceof Error?o.message:o),s.exit(1)}});j.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 g of[].concat(e.buildArg??[])){let p=g.indexOf("=");if(p!==-1)i[g.slice(0,p)]=g.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(`
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 D(e[0]).map((o)=>o.version&&o.version!=="latest"?`${o.name}@${String(o.version).replace(/^[\^~>=<]+/,"")}`:o.name)}catch{return[]}}j.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 g of o){let p=g.lastIndexOf("@"),S=p>0;await R(S?g.slice(0,p):g,S?g.slice(p+1):"latest",{globalBin:!0,quiet:!0}).catch((w)=>{console.error(`# could not install ${g}: ${w instanceof Error?w.message:w}`)})}let i=k(),c=[v.join(e,".bin"),i].filter((g)=>m.existsSync(g));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)});j.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??I();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=O(e);if(s.stdout.isTTY){if(console.log(`# Detected shell: ${e}`),console.log(`# Global bin dir: ${k()}`),o)console.log(`# Append this to: ${o}`);console.log("# Or run: ts-pantry shell-init --install"),console.log()}s.stdout.write(W({shell:e})),s.exit(0)}catch(o){console.error("Error:",o instanceof Error?o.message:o),s.exit(1)}});j.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 g of[].concat(e.buildArg??[])){let p=g.indexOf("=");if(p!==-1)i[g.slice(0,p)]=g.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 g=ee(o[0]||"app:latest");if(!e.quiet)console.log(`
79
79
  Pushing ${g.repository}:${g.tag} → ${l} ...`);let p=await Ce({repository:g.repository,tag:g.tag,registry:g.implicitRegistry?void 0:`https://${g.registry}`,configBytes:Buffer.from(c.configBytes),configDigest:c.configDigest,layers:c.layers.map((S)=>({digest:S.digest,path:S.path,size:S.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)}});j.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)}});j.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})});j.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))});j.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))});j.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)}});j.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 m.readFileSync(v.resolve(w),"utf8")},o=v.resolve(t.output??".pantry/apple");m.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 x=w.type==="MAC_APP_DISTRIBUTION"?"mac-app-distribution":"mac-installer-distribution",B=v.join(o,`${x}.cer`);m.writeFileSync(B,Buffer.from(w.certificateContent,"base64"),{mode:384});let J=w.type==="MAC_APP_DISTRIBUTION"?t.appCertificateCsr:t.installerCertificateCsr;if(t.p12Password&&J)fa({certificatePath:B,privateKeyPath:v.resolve(J.replace(/\.csr$/i,".key")),outputPath:v.join(o,`${x}.p12`),password:t.p12Password,name:`${t.name} ${w.type==="MAC_APP_DISTRIBUTION"?"Mac App Distribution":"Mac Installer Distribution"}`})}if(i.profile.profileContent)m.writeFileSync(v.join(o,"mac-app-store.provisionprofile"),Buffer.from(i.profile.profileContent,"base64"),{mode:384});let c=i.certificates.map((w)=>{let x={...w};return delete x.certificateContent,x}),g={...i.profile};delete g.profileContent;let p={...i,certificates:c,profile:g},S=v.join(o,"provisioning-plan.json");m.writeFileSync(S,`${JSON.stringify(p,null,2)}
80
80
  `,{mode:384}),console.log(JSON.stringify({reportPath:S,...p},null,2)),s.exit(0)}catch(e){console.error("App Store provisioning failed:",e instanceof Error?e.message:e),s.exit(1)}});j.help();j.version(d);var Ee=j.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{q}from"../chunk-7q8as4h2.js";import"../chunk-3sc39cqf.js";import"../chunk-mvzv8skb.js";import{G,K,fe,Ye}from"../chunk-2x8yyzhm.js";import{d}from"../chunk-egf4sf0n.js";import{chmodSync as k,mkdirSync as h,renameSync as P,rmSync as b,writeFileSync as f}from"node:fs";import{homedir as S}from"node:os";import{isAbsolute as x,join as s}from"node:path";var a=(t)=>t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;");function D(t,e,r){return`<?xml version="1.0" encoding="UTF-8"?>
2
+ import{q}from"../chunk-7q8as4h2.js";import"../chunk-3sc39cqf.js";import"../chunk-mvzv8skb.js";import{G,K,fe,Ye}from"../chunk-2x8yyzhm.js";import{d}from"../chunk-xq8dke4k.js";import{chmodSync as k,mkdirSync as h,renameSync as P,rmSync as b,writeFileSync as f}from"node:fs";import{homedir as S}from"node:os";import{isAbsolute as x,join as s}from"node:path";var a=(t)=>t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;");function D(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>
@@ -1 +1 @@
1
- import{xe,we,Xe,Pe,ot,st,Ue,i,nt,rt,J,Qe,it,ct,lt}from"./chunk-nr2yvehm.js";export{rt as convertDomainToFileName,i as convertDomainToVarName,ot as fetchPackageListFromGitHub,Ue as formatObjectWithoutQuotedKeys,lt as getCanonicalDomain,Xe as getGitHubPackageCache,it as getPackageAliases,J as guessOriginalDomain,ct as isKnownAlias,st as logPkgxProjects,Qe as resolvePackageDomain,Pe as saveGitHubPackageCache,xe as saveRateLimitInfo,we as shouldProceedWithGitHubRequest,nt as toPropertyKey};
1
+ import{xe,we,Xe,Pe,ot,st,Ue,i,nt,rt,J,Qe,it,ct,lt}from"./chunk-kq4jkyn1.js";export{rt as convertDomainToFileName,i as convertDomainToVarName,ot as fetchPackageListFromGitHub,Ue as formatObjectWithoutQuotedKeys,lt as getCanonicalDomain,Xe as getGitHubPackageCache,it as getPackageAliases,J as guessOriginalDomain,ct as isKnownAlias,st as logPkgxProjects,Qe as resolvePackageDomain,Pe as saveGitHubPackageCache,xe as saveRateLimitInfo,we as shouldProceedWithGitHubRequest,nt as toPropertyKey};
@@ -1 +1 @@
1
- import{r,f,b,Et,_t}from"./chunk-nr2yvehm.js";export{_t as ALL_KNOWN_PACKAGES,r as DEFAULT_CACHE_DIR,f as DEFAULT_CACHE_EXPIRATION_MINUTES,b as DEFAULT_TIMEOUT_MS,Et as PACKAGE_ALIASES};
1
+ import{r,f,b,Et,_t}from"./chunk-kq4jkyn1.js";export{_t as ALL_KNOWN_PACKAGES,r as DEFAULT_CACHE_DIR,f as DEFAULT_CACHE_EXPIRATION_MINUTES,b as DEFAULT_TIMEOUT_MS,Et as PACKAGE_ALIASES};
@@ -0,0 +1 @@
1
+ import{y,Qo,Zo}from"./chunk-kq4jkyn1.js";export{y as compareVersions,Zo as generateZigAliases,Qo as generateZigDefinitions};
@@ -1 +1 @@
1
- import{n,X,Ze,z,u,pt,Q,gt,mt,Z,ea,aa,ta,E}from"./chunk-nr2yvehm.js";export{X as cleanStaleOutputFiles,u as cleanupBrowserResources,Z as fetchAndSaveAllPackages,ea as fetchAndSavePackage,Q as fetchPantryPackage,E as fetchPantryPackageWithMetadata,pt as fetchPkgxProjects,Ze as getValidCachedPackage,ta as readPantryPackageInfo,n as savePackageAsTypeScript,z as saveToCacheAndOutput,aa as scanPantryPackages,gt as setupCleanupHandlers,mt as startPeriodicCleanup};
1
+ import{n,X,Ze,z,u,pt,Q,gt,mt,Z,ea,aa,ta,E}from"./chunk-kq4jkyn1.js";export{X as cleanStaleOutputFiles,u as cleanupBrowserResources,Z as fetchAndSaveAllPackages,ea as fetchAndSavePackage,Q as fetchPantryPackage,E as fetchPantryPackageWithMetadata,pt as fetchPkgxProjects,Ze as getValidCachedPackage,ta as readPantryPackageInfo,n as savePackageAsTypeScript,z as saveToCacheAndOutput,aa as scanPantryPackages,gt as setupCleanupHandlers,mt as startPeriodicCleanup};