ts-pantry 0.11.138 → 0.11.140
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 +25 -25
- package/dist/bin/desktop.js +3 -3
- package/dist/{chunk-bq29tm01.js → chunk-128xc94w.js} +2 -2
- package/dist/chunk-1s037kz2.js +1 -0
- package/dist/chunk-359r0aep.js +1 -0
- package/dist/chunk-45bpxyc5.js +1 -0
- package/dist/chunk-4x4ejq0g.js +1 -0
- package/dist/{chunk-8f07ddwg.js → chunk-63zdvbqd.js} +2 -2
- package/dist/chunk-8jma0xxn.js +1 -0
- package/dist/{chunk-w0v9wy7r.js → chunk-b0xqpp3v.js} +22 -22
- package/dist/{chunk-zjnhaw1v.js → chunk-fyr7re9j.js} +1 -1
- package/dist/chunk-gryfzzk6.js +524 -0
- package/dist/chunk-m07wcaj5.js +1 -0
- package/dist/chunk-mfjh5x2c.js +1 -0
- package/dist/chunk-nwvn537a.js +2 -0
- package/dist/chunk-r9tnx251.js +17 -0
- package/dist/chunk-rfzpbgew.js +1 -0
- package/dist/{chunk-995m3fba.js → chunk-rj21ersa.js} +2 -2
- package/dist/{chunk-hygw1tjj.js → chunk-zt4tphan.js} +10 -10
- package/dist/generated-package-names.d.ts +12 -8
- package/dist/src/binary-publish.d.ts +84 -0
- package/dist/src/catalog/client.js +1 -1
- package/dist/src/desktop/service.js +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/src/native/apple.d.ts +1 -0
- package/dist/src/native/config.d.ts +1 -0
- package/dist/src/native/index.d.ts +1 -0
- package/dist/src/native/index.js +6 -5
- package/dist/src/native/registry.d.ts +18 -0
- package/dist/src/native/release.js +1 -1
- package/dist/src/packages/aliases.d.ts +2 -0
- package/dist/src/packages/apps/launchpad.d.ts +16 -0
- package/dist/src/packages/codercom.d.ts +3 -3
- package/dist/src/packages/craft-native.org.d.ts +3 -3
- package/dist/src/packages/github.com/ggerganov/llama.cpp.d.ts +3 -3
- package/dist/src/packages/hasuraio.d.ts +3 -3
- package/dist/src/packages/index.d.ts +4 -0
- package/dist/src/packages/pdmfmingdev.d.ts +3 -3
- package/dist/src/packages/pnpmio.d.ts +3 -3
- package/dist/src/packages/valkeyio.d.ts +2 -2
- package/dist/src/packages/ziglangorg.d.ts +3 -3
- package/dist/src/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-167jazj7.js +0 -1
- package/dist/chunk-1abg34mb.js +0 -2
- package/dist/chunk-1n0fctvz.js +0 -1
- package/dist/chunk-31y9b4za.js +0 -1
- package/dist/chunk-bggscee8.js +0 -1
- package/dist/chunk-bmcywh4v.js +0 -1
- package/dist/chunk-dc73wbey.js +0 -1
- package/dist/chunk-h49t8bqz.js +0 -524
- package/dist/chunk-jztg3vmf.js +0 -1
- package/dist/chunk-pggwsb9g.js +0 -1
- package/dist/chunk-pgnj1c0k.js +0 -17
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{_,B}from"../chunk-zt4tphan.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-gryfzzk6.js";import"../chunk-fyr7re9j.js";import"../chunk-63zdvbqd.js";import{ja}from"../chunk-nwvn537a.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=`/**
|
|
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()}
|
|
@@ -48,33 +48,33 @@ export const PACKAGE_ALIASES: Record<string, string> = {
|
|
|
48
48
|
* List of all known packages (${t.length} total)
|
|
49
49
|
*/
|
|
50
50
|
export const ALL_KNOWN_PACKAGES: readonly string[] = [
|
|
51
|
-
${t.map((
|
|
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],
|
|
55
|
-
Received ${t} signal. Cleaning up resources...`),clearTimeout(
|
|
56
|
-
Downloading props files from pkgx/pantry GitHub repo...`);let
|
|
57
|
-
Total packages: ${
|
|
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}
|
|
57
|
+
Total packages: ${c.length}
|
|
58
58
|
|
|
59
|
-
${
|
|
60
|
-
`)}`;g.writeFileSync(`${e}-packages-summary.txt`,p),console.log(`\uD83D\uDCC4 Created ${e}-packages-summary.txt for reference`),
|
|
61
|
-
✅ Dependency resolution complete!`),console.log(`\uD83D\uDCE6 Total unique packages: ${
|
|
62
|
-
Conflicts found:`),
|
|
63
|
-
\uD83D\uDCCB All unique packages to install:`),
|
|
64
|
-
\uD83D\uDE80 Install command:`),console.log(`pantry install ${
|
|
65
|
-
\uD83D\uDDA5️ OS-specific dependencies:`),Object.entries(
|
|
66
|
-
${i.map((
|
|
67
|
-
`)}`);break;case"csv":console.log(i.join(","));break;case"json":default:console.log(JSON.stringify(i));break}
|
|
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-1s037kz2.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
|
+
${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-4x4ejq0g.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!`),
|
|
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(`
|
|
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}`)}
|
|
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(`
|
|
72
72
|
Outdated Apps (${i.length}):
|
|
73
|
-
`),console.log("Application".padEnd(30)+"Current".padEnd(16)+"Latest".padEnd(16)+"Source"),console.log("-".repeat(75));for(let
|
|
74
|
-
All desktop apps are up to date!`);let
|
|
75
|
-
${
|
|
76
|
-
✓ ${p.name}@${p.version}`),console.log(` installed to: ${p.installPath}`),p.globalLinks&&p.globalLinks.length>0){if(console.log(` linked into: ${
|
|
77
|
-
⚠ ${
|
|
78
|
-
✓ Built ${
|
|
79
|
-
Pushing ${
|
|
80
|
-
`,{mode:384}),console.log(JSON.stringify({reportPath:
|
|
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
|
+
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(`
|
|
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);
|
package/dist/bin/desktop.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import{
|
|
2
|
+
import{_,B}from"../chunk-zt4tphan.js";import"../chunk-63zdvbqd.js";import"../chunk-128xc94w.js";import{F,Y,ue,Re}from"../chunk-rj21ersa.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("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'");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{z,F}from"../chunk-hygw1tjj.js";import"../chunk-8f07ddwg.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=
|
|
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: ${
|
|
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}
|
|
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();
|