ts-pantry 0.9.19 → 0.9.21
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 +7 -7
- package/dist/chunk-2dk28v6k.js +2 -0
- package/dist/chunk-2nfjspwd.js +1 -0
- package/dist/{chunk-85nbpqdk.js → chunk-9f0255fc.js} +1 -1
- package/dist/chunk-b0zr0ad6.js +1 -0
- package/dist/{chunk-tj5t6gft.js → chunk-bmr9qds3.js} +1 -1
- package/dist/chunk-cdzdw53j.js +42 -0
- package/dist/chunk-f2c8kapq.js +2 -0
- package/dist/chunk-h8phykmh.js +1 -0
- package/dist/chunk-jym7xrra.js +2 -0
- package/dist/chunk-k4yefwkp.js +142 -0
- package/dist/chunk-nqztmdqz.js +275 -0
- package/dist/{chunk-r54nadvd.js → chunk-p9e5z92g.js} +1 -1
- package/dist/{chunk-5y0crbzc.js → chunk-q7s2k65w.js} +2 -2
- package/dist/{chunk-8f13z8n1.js → chunk-t8296krc.js} +1 -1
- package/dist/{chunk-2kx0m76s.js → chunk-xkm30wah.js} +2 -2
- package/dist/chunk-y5rfbg9v.js +11 -0
- package/dist/{chunk-c1hyjq5h.js → chunk-yjz3e391.js} +1 -1
- package/dist/consts.d.ts +1 -1
- package/dist/desktop-apps.d.ts +1 -0
- package/dist/installer.d.ts +5 -0
- package/dist/packages/alacrittyorg.d.ts +1 -1
- package/dist/packages/aliases.d.ts +7 -7
- package/dist/packages/alttabapp.d.ts +1 -1
- package/dist/packages/ansiblecom.d.ts +1 -1
- package/dist/packages/apktoolorg.d.ts +1 -1
- package/dist/packages/arkadedev.d.ts +1 -1
- package/dist/packages/atlasgoio.d.ts +1 -1
- package/dist/packages/augeasnet.d.ts +1 -1
- package/dist/packages/babashkaorg.d.ts +1 -1
- package/dist/packages/borepub.d.ts +1 -1
- package/dist/packages/bufbuild.d.ts +1 -1
- package/dist/packages/bytebasecom.d.ts +1 -1
- package/dist/packages/casdoororg.d.ts +1 -1
- package/dist/packages/ccachedev.d.ts +1 -1
- package/dist/packages/certbotefforg.d.ts +1 -1
- package/dist/packages/chezmoiio.d.ts +1 -1
- package/dist/packages/circlecicom.d.ts +1 -1
- package/dist/packages/cligithubcom.d.ts +1 -1
- package/dist/packages/cmakeorg.d.ts +1 -1
- package/dist/packages/cnqueryio.d.ts +1 -1
- package/dist/packages/codercom.d.ts +1 -1
- package/dist/packages/codevisualstudiocom.d.ts +1 -1
- package/dist/packages/cointopsh.d.ts +1 -1
- package/dist/packages/conftestdev.d.ts +1 -1
- package/dist/packages/consulio.d.ts +1 -1
- package/dist/packages/convcogithubio.d.ts +1 -1
- package/dist/packages/cuelangorg.d.ts +1 -1
- package/dist/packages/cythonorg.d.ts +1 -1
- package/dist/packages/daggerio.d.ts +1 -1
- package/dist/packages/daytonaio.d.ts +1 -1
- package/dist/packages/dblabdanvergaracom.d.ts +1 -1
- package/dist/packages/denoland.d.ts +1 -1
- package/dist/packages/depotdev.d.ts +1 -1
- package/dist/packages/dgraphio.d.ts +1 -1
- package/dist/packages/direnvnet.d.ts +1 -1
- package/dist/packages/dotnetmicrosoftcom.d.ts +1 -1
- package/dist/packages/dozzledev.d.ts +1 -1
- package/dist/packages/dprintdev.d.ts +1 -1
- package/dist/packages/duckdborg.d.ts +1 -1
- package/dist/packages/eksctlio.d.ts +1 -1
- package/dist/packages/elementsprojectorg.d.ts +1 -1
- package/dist/packages/encoredev.d.ts +1 -1
- package/dist/packages/etcdio.d.ts +1 -1
- package/dist/packages/fastlanetools.d.ts +1 -1
- package/dist/packages/fishshellcom.d.ts +1 -1
- package/dist/packages/flyio.d.ts +1 -1
- package/dist/packages/freetdsorg.d.ts +1 -1
- package/dist/packages/getcomposerorg.d.ts +1 -1
- package/dist/packages/getsynthcom.d.ts +1 -1
- package/dist/packages/getzolaorg.d.ts +1 -1
- package/dist/packages/gflagsgithubio.d.ts +1 -1
- package/dist/packages/ghostscriptcom.d.ts +1 -1
- package/dist/packages/gleamrun.d.ts +1 -1
- package/dist/packages/gohugoio.d.ts +1 -1
- package/dist/packages/goreleasercom.d.ts +1 -1
- package/dist/packages/gourceio.d.ts +1 -1
- package/dist/packages/granteddev.d.ts +1 -1
- package/dist/packages/graphitesilorg.d.ts +1 -1
- package/dist/packages/groongaorg.d.ts +1 -1
- package/dist/packages/grpcio.d.ts +1 -1
- package/dist/packages/harfbuzzorg.d.ts +1 -1
- package/dist/packages/hasuraio.d.ts +1 -1
- package/dist/packages/helmsh.d.ts +1 -1
- package/dist/packages/htopdev.d.ts +1 -1
- package/dist/packages/httpieio.d.ts +1 -1
- package/dist/packages/huggingfaceco.d.ts +1 -1
- package/dist/packages/imagemagickorg.d.ts +1 -1
- package/dist/packages/index.d.ts +1653 -1653
- package/dist/packages/infracostio.d.ts +1 -1
- package/dist/packages/ipythonorg.d.ts +1 -1
- package/dist/packages/irohcomputer.d.ts +1 -1
- package/dist/packages/istioio.d.ts +1 -1
- package/dist/packages/jbangdev.d.ts +1 -1
- package/dist/packages/jemallocnet.d.ts +1 -1
- package/dist/packages/jujuis.d.ts +1 -1
- package/dist/packages/julialangorg.d.ts +1 -1
- package/dist/packages/jumppaddev.d.ts +1 -1
- package/dist/packages/k3dio.d.ts +1 -1
- package/dist/packages/k6io.d.ts +1 -1
- package/dist/packages/kagglecom.d.ts +1 -1
- package/dist/packages/kubectxdev.d.ts +1 -1
- package/dist/packages/kubesharkco.d.ts +1 -1
- package/dist/packages/laravelcom.d.ts +1 -1
- package/dist/packages/lavinmqcom.d.ts +1 -1
- package/dist/packages/libcxxllvmorg.d.ts +1 -1
- package/dist/packages/libeventorg.d.ts +1 -1
- package/dist/packages/libexifgithubio.d.ts +1 -1
- package/dist/packages/libgdgithubio.d.ts +1 -1
- package/dist/packages/libssh2org.d.ts +1 -1
- package/dist/packages/libusbinfo.d.ts +1 -1
- package/dist/packages/libuvorg.d.ts +1 -1
- package/dist/packages/libvipsorg.d.ts +1 -1
- package/dist/packages/libziporg.d.ts +1 -1
- package/dist/packages/liteclicom.d.ts +1 -1
- package/dist/packages/littlecmscom.d.ts +1 -1
- package/dist/packages/llmdatasetteio.d.ts +1 -1
- package/dist/packages/llvmorg.d.ts +1 -1
- package/dist/packages/localaiio.d.ts +1 -1
- package/dist/packages/luarocksorg.d.ts +1 -1
- package/dist/packages/lxmlde.d.ts +1 -1
- package/dist/packages/macfusegithubio.d.ts +1 -1
- package/dist/packages/macvimorg.d.ts +1 -1
- package/dist/packages/mailpitaxllentorg.d.ts +1 -1
- package/dist/packages/maturinrs.d.ts +1 -1
- package/dist/packages/mavenapacheorg.d.ts +1 -1
- package/dist/packages/meilisearchcom.d.ts +1 -1
- package/dist/packages/mercurerocks.d.ts +1 -1
- package/dist/packages/mesonbuildcom.d.ts +1 -1
- package/dist/packages/misejdxdev.d.ts +1 -1
- package/dist/packages/mitmproxyorg.d.ts +1 -1
- package/dist/packages/mkcertdev.d.ts +1 -1
- package/dist/packages/moshorg.d.ts +1 -1
- package/dist/packages/msgpackorg.d.ts +1 -1
- package/dist/packages/neovimio.d.ts +1 -1
- package/dist/packages/networkxorg.d.ts +1 -1
- package/dist/packages/nginxorg.d.ts +1 -1
- package/dist/packages/nodejsorg.d.ts +1 -1
- package/dist/packages/nomadprojectio.d.ts +1 -1
- package/dist/packages/npmjscom.d.ts +1 -1
- package/dist/packages/numpyorg.d.ts +1 -1
- package/dist/packages/nushellsh.d.ts +1 -1
- package/dist/packages/odigosio.d.ts +1 -1
- package/dist/packages/ohmyposhdev.d.ts +1 -1
- package/dist/packages/ollamaai.d.ts +1 -1
- package/dist/packages/onefetchdev.d.ts +1 -1
- package/dist/packages/openblasnet.d.ts +1 -1
- package/dist/packages/opencodeai.d.ts +1 -1
- package/dist/packages/openexrcom.d.ts +1 -1
- package/dist/packages/openjpegorg.d.ts +1 -1
- package/dist/packages/openmpllvmorg.d.ts +1 -1
- package/dist/packages/openpolicyagentorg.d.ts +1 -1
- package/dist/packages/opensearchorg.d.ts +1 -1
- package/dist/packages/opentofuorg.d.ts +1 -1
- package/dist/packages/orasland.d.ts +1 -1
- package/dist/packages/packerio.d.ts +1 -1
- package/dist/packages/phpnet.d.ts +1 -1
- package/dist/packages/pinnipeddev.d.ts +1 -1
- package/dist/packages/pipenvpypaio.d.ts +1 -1
- package/dist/packages/pkgxsh.d.ts +1 -1
- package/dist/packages/planetscalecom.d.ts +1 -1
- package/dist/packages/pocketbaseio.d.ts +1 -1
- package/dist/packages/podmanio.d.ts +1 -1
- package/dist/packages/postgrestorg.d.ts +1 -1
- package/dist/packages/prefixdev.d.ts +1 -1
- package/dist/packages/projenio.d.ts +1 -1
- package/dist/packages/projorg.d.ts +1 -1
- package/dist/packages/pulumiio.d.ts +1 -1
- package/dist/packages/pygmentsorg.d.ts +1 -1
- package/dist/packages/railwayapp.d.ts +1 -1
- package/dist/packages/rapidjsonorg.d.ts +1 -1
- package/dist/packages/rcloneorg.d.ts +1 -1
- package/dist/packages/re2corg.d.ts +1 -1
- package/dist/packages/rectangleapp.d.ts +1 -1
- package/dist/packages/rendercom.d.ts +1 -1
- package/dist/packages/replibytecom.d.ts +1 -1
- package/dist/packages/rhashsourceforgenet.d.ts +1 -1
- package/dist/packages/riotermcom.d.ts +1 -1
- package/dist/packages/rubocoporg.d.ts +1 -1
- package/dist/packages/rubygemsorg.d.ts +1 -1
- package/dist/packages/runatlantisio.d.ts +1 -1
- package/dist/packages/s3toolsorg.d.ts +1 -1
- package/dist/packages/scalewaycom.d.ts +1 -1
- package/dist/packages/sdkmanio.d.ts +1 -1
- package/dist/packages/seaweedfscom.d.ts +1 -1
- package/dist/packages/sentryio.d.ts +1 -1
- package/dist/packages/shellchecknet.d.ts +1 -1
- package/dist/packages/skaffolddev.d.ts +1 -1
- package/dist/packages/sniffnetnet.d.ts +1 -1
- package/dist/packages/soldeerxyz.d.ts +1 -1
- package/dist/packages/soliditylangorg.d.ts +1 -1
- package/dist/packages/sqlcdev.d.ts +1 -1
- package/dist/packages/sqlfluffcom.d.ts +1 -1
- package/dist/packages/squawkhqcom.d.ts +1 -1
- package/dist/packages/starshiprs.d.ts +1 -1
- package/dist/packages/statsapp.d.ts +1 -1
- package/dist/packages/steampipeio.d.ts +1 -1
- package/dist/packages/straceio.d.ts +1 -1
- package/dist/packages/streamlinkgithubio.d.ts +1 -1
- package/dist/packages/stripecom.d.ts +1 -1
- package/dist/packages/surrealdbcom.d.ts +1 -1
- package/dist/packages/swiftorg.d.ts +1 -1
- package/dist/packages/symfonycom.d.ts +1 -1
- package/dist/packages/sympyorg.d.ts +1 -1
- package/dist/packages/syncthingnet.d.ts +1 -1
- package/dist/packages/tailscalecom.d.ts +1 -1
- package/dist/packages/tailwindcsscom.d.ts +1 -1
- package/dist/packages/tartrun.d.ts +1 -1
- package/dist/packages/taskfiledev.d.ts +1 -1
- package/dist/packages/teaxyz.d.ts +1 -1
- package/dist/packages/terraformio.d.ts +1 -1
- package/dist/packages/terragruntgruntworkio.d.ts +1 -1
- package/dist/packages/terratagio.d.ts +1 -1
- package/dist/packages/tiltdev.d.ts +1 -1
- package/dist/packages/tinygoorg.d.ts +1 -1
- package/dist/packages/tldrsh.d.ts +1 -1
- package/dist/packages/toxwiki.d.ts +1 -1
- package/dist/packages/traefikio.d.ts +1 -1
- package/dist/packages/tursotech.d.ts +1 -1
- package/dist/packages/typescriptlangorg.d.ts +1 -1
- package/dist/packages/uriparsergithubio.d.ts +1 -1
- package/dist/packages/vapoursynthcom.d.ts +1 -1
- package/dist/packages/vaultprojectio.d.ts +1 -1
- package/dist/packages/vclustercom.d.ts +1 -1
- package/dist/packages/wailsio.d.ts +1 -1
- package/dist/packages/wasmerio.d.ts +1 -1
- package/dist/packages/watchexecgithubio.d.ts +1 -1
- package/dist/packages/wavpackcom.d.ts +1 -1
- package/dist/packages/werfio.d.ts +1 -1
- package/dist/packages/xcfiledev.d.ts +1 -1
- package/dist/packages/xkbcommonorg.d.ts +1 -1
- package/dist/packages/xtlsgithubio.d.ts +1 -1
- package/dist/packages/zarfdev.d.ts +1 -1
- package/dist/packages/zeddev.d.ts +1 -1
- package/dist/packages/zeromqorg.d.ts +1 -1
- package/dist/packages/ziglangorg.d.ts +3 -3
- package/dist/packages/zotregistrydev.d.ts +1 -1
- package/dist/packages/zrokio.d.ts +1 -1
- package/dist/pantry-api.d.ts +1 -0
- package/dist/src/index.js +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/package.json +3 -4
- package/dist/chunk-b4krz2vb.js +0 -2
- package/dist/chunk-d7470145.js +0 -2
- package/dist/chunk-ehawm227.js +0 -275
- package/dist/chunk-f0qhrqsj.js +0 -2
- package/dist/chunk-fejavkhf.js +0 -1
- package/dist/chunk-fptwe9k9.js +0 -11
- package/dist/chunk-g3ex932z.js +0 -1
- package/dist/chunk-pjsw4rfb.js +0 -1
- package/dist/chunk-q0dw6bcf.js +0 -142
- package/dist/chunk-y15ydasq.js +0 -42
- package/scripts/pantry-cli.ts +0 -319
package/dist/chunk-ehawm227.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import{db as k,fb as Zw}from"./chunk-fptwe9k9.js";import{Ab as Uw,pb as dw,qb as gw,tb as mw,ub as Kw,wb as lw,yb as cw,zb as pw}from"./chunk-b4krz2vb.js";import{Fb as Q6}from"./chunk-f0qhrqsj.js";import{Gb as t,Hb as zQ}from"./chunk-5y0crbzc.js";import{Kb as tw}from"./chunk-r54nadvd.js";import{Ob as c}from"./chunk-c1hyjq5h.js";import KQ from"node:process";zQ();import hw from"node:process";function vw(w){return w in t}function JQ(w){return w.includes(".")}function X6(w){return vw(w)||JQ(w)}function Z6(w){return["darwin","linux","windows"].includes(w)}function q6(w){return["x86_64","aarch64","armv7l","i686"].includes(w)}function fw(){return Object.keys(t)}function H6(){return Object.values(t)}function Y6(w){if(vw(w))return{originalName:w,resolvedDomain:t[w],isAlias:!0};return{originalName:w,resolvedDomain:w,isAlias:!1}}function W6(w){let Q=w.lastIndexOf("@");if(Q===-1)return{name:w};let $=w.slice(0,Q),R=w.slice(Q+1);return{name:$,version:R,versionSpec:R}}function z6(w,Q){return Q?`${w}@${Q}`:w}function e(){let w=hw.platform,Q=hw.arch,$,R,X=!0;switch(w){case"darwin":$="darwin";break;case"linux":$="linux";break;case"win32":$="windows";break;default:$="linux",X=!1}switch(Q){case"x64":R="x86_64";break;case"arm64":R="aarch64";break;case"arm":R="armv7l";break;case"ia32":R="i686";break;default:R="x86_64",X=!1}return{platform:$,architecture:R,isSupported:X}}function J6(w,Q="latest",$){let R=$||e(),X;switch(R.platform){case"darwin":X="tar.xz";break;case"linux":X="tar.xz";break;case"windows":X="zip";break;default:X="tar.xz"}return{packageName:w,version:Q,platform:R.platform,architecture:R.architecture,format:X}}var K6={LATEST:"latest",ANY:"*"},kw={RUNTIME:["nodejs.org","python.org","go.dev","rust-lang.org"],BUILD_TOOLS:["cmake.org","ninja-build.org","gradle.org","maven.apache.org"],DATABASES:["postgresql.org","mysql.com","redis.io","mongodb.com"],EDITORS:["neovim.io","vim.org","code.visualstudio.com"],CLI_TOOLS:["cli.github.com","curl.se","wget.gnu.org","jq.dev"]};function U6(w){return kw[w]}function G6(w,Q){return kw[Q].includes(w)}function _6(w){return w}function B6(w,Q){return[w,Q]}function O6(w){return w}async function M6(w){try{let Q=await Kw(w);if(!Q)return{success:!1,error:`Package '${w}' not found. Use 'search' to find available packages.`};return{success:!0,data:Q}}catch(Q){return{success:!1,error:`Failed to get package info: ${Q}`}}}async function C6(w){try{if(!w||w.trim().length===0)return{success:!1,error:"Search term cannot be empty"};return{success:!0,data:await lw(w.trim())}}catch(Q){return{success:!1,error:`Search failed: ${Q}`}}}async function I6(w=20){try{return{success:!0,data:(await cw(5)).slice(0,w)}}catch(Q){return{success:!1,error:`Failed to list popular packages: ${Q}`}}}async function S6(w=20){try{return{success:!0,data:await pw(w)}}catch(Q){return{success:!1,error:`Failed to list active packages: ${Q}`}}}function F6(){try{return{success:!0,data:fw()}}catch(w){return{success:!1,error:`Failed to list aliases: ${w}`}}}async function b6(w){try{let Q=await Uw(w);if(!Q.isValid)return{success:!1,error:Q.error};return{success:!0,data:{packageName:Q.packageName,version:Q.version,isValid:!0}}}catch(Q){return{success:!1,error:`Validation failed: ${Q}`}}}async function A6(w){try{let Q=await Uw(w);if(!Q.isValid)return{success:!1,error:Q.error};let $=Q.packageName,R=Q.version||"latest",X=await mw($,R);if(!X)return{success:!1,error:`Could not resolve version '${R}' for package '${$}'`};let H=await Kw($);if(!H)return{success:!1,error:`Package '${$}' not found`};let q=e(),Z={packageName:$,resolvedVersion:X,platform:q.platform,architecture:q.architecture,dependencies:H.dependencies,companions:H.companions,installCommand:`pkgx install ${$}@${X}`},Y=[];if(!q.isSupported)Y.push(`Platform ${q.platform}/${q.architecture} may not be fully supported`);if(H.dependencies.length>0)Y.push(`This package has ${H.dependencies.length} dependencies that will also be installed`);return{success:!0,data:Z,warnings:Y.length>0?Y:void 0}}catch(Q){return{success:!1,error:`Failed to create install plan: ${Q}`}}}async function x6(w){try{let Q=await dw(w);if(!Q)return{success:!1,error:`Package '${w}' not found`};let $=await gw(w);return{success:!0,data:{latest:Q,total:$.length,versions:$}}}catch(Q){return{success:!1,error:`Failed to get version info: ${Q}`}}}function V6(w){let Q=[`Package: ${w.name}`,`Domain: ${w.domain}`,`Description: ${w.description}`,`Latest Version: ${w.latestVersion}`,`Total Versions: ${w.totalVersions}`];if(w.programs.length>0)Q.push(`Programs: ${w.programs.join(", ")}`);if(w.dependencies.length>0)Q.push(`Dependencies: ${w.dependencies.join(", ")}`);if(w.companions.length>0)Q.push(`Companions: ${w.companions.join(", ")}`);return Q.join(`
|
|
2
|
-
`)}function y6(w){if(w.length===0)return"No packages found matching your search.";let Q=[`Found ${w.length} package(s):
|
|
3
|
-
`];for(let $ of w)Q.push(`${$.name} (${$.domain})`),Q.push(` ${$.description}`),Q.push(` Latest: ${$.latestVersion} (${$.totalVersions} versions available)`),Q.push("");return Q.join(`
|
|
4
|
-
`)}function N6(w){let Q=[`Installation Plan for ${w.packageName}@${w.resolvedVersion}`,`Platform: ${w.platform}/${w.architecture}`,`Command: ${w.installCommand}`];if(w.dependencies.length>0)Q.push(`Dependencies: ${w.dependencies.join(", ")}`);if(w.companions.length>0)Q.push(`Companions: ${w.companions.join(", ")}`);return Q.join(`
|
|
5
|
-
`)}function u6(){try{let w=e();return{success:!0,data:{platform:w.platform,architecture:w.architecture,isSupported:w.isSupported,nodeVersion:KQ.version}}}catch(w){return{success:!1,error:`Failed to get system info: ${w}`}}}import m from"node:fs";import Qw from"node:path";function $w(w){if(!m.existsSync(w))throw Error(`Dependency file not found: ${w}`);let Q=m.readFileSync(w,"utf-8"),$=[],R=Q.split(`
|
|
6
|
-
`),X=!1,H=!1,q=0;for(let Z of R){let Y=Z.trim();if(!Y||Y.startsWith("#"))continue;if(Z.match(/^(dependencies|deps):\s*$/)){X=!0,H=!1,q=Z.search(/\S/);continue}if(Z.match(/^global:\s*true\s*$/)||Z.match(/^global:\s*$/)&&!X){H=!0;continue}if(Z.match(/^\w+:/)&&!Z.includes(" ")&&X&&q===0){X=!1;continue}if(X||H){if(Z.match(/^\s+(dependencies|deps):\s*$/))continue;let J=Z.indexOf(":");if(J>0){let z=Z.substring(0,J).trim(),j=Z.substring(J+1).trim();if(z&&j){let T=z,O=j.replace(/^['"]|['"]$/g,"");if(T==="global"||T==="dependencies"||T==="deps")continue;let W=O,G=O;if(O.startsWith("^"))W=O.substring(1),G=O;else if(O.startsWith("~"))W=O.substring(1),G=O;else if(O.startsWith(">=")||O.startsWith("<=")||O.startsWith(">")||O.startsWith("<")){let _=/^([><=]+)/.exec(O);if(_){let K=_[1];W=O.substring(K.length).trim(),G=O}}else if(O==="*"||O==="latest")W="latest",G="*";else W=O,G=`@${O}`;$.push({name:T,version:W,constraint:G,isOsSpecific:!1})}}}}return $}function UQ(w){if(!m.existsSync(w))throw Error(`Dependency file not found: ${w}`);let Q=m.readFileSync(w,"utf-8"),$=$w(w),R;try{let X=typeof Bun<"u"&&Bun.YAML?Bun.YAML.parse(Q):GQ(Q);if(X?.services){let H=Array.isArray(X.services.autoStart)?X.services.autoStart.map((q)=>String(q)):[];if(H.length>0)R={enabled:X.services.enabled===!0,autoStart:H}}}catch{}return{dependencies:$,services:R}}function GQ(w){let Q={},$=w.split(`
|
|
7
|
-
`),R=!1,X=!1,H=[],q=!1;for(let Z of $){let Y=Z.trim();if(!Y||Y.startsWith("#"))continue;if(Z.match(/^services:\s*$/)){R=!0,X=!1;continue}if(R&&!Z.startsWith(" ")&&!Z.startsWith("\t")&&!Y.startsWith("-")){if(Y!=="services:"){R=!1,X=!1;continue}}if(R){if(Y.startsWith("enabled:")){q=Y.includes("true");continue}if(Y.match(/^autoStart:\s*$/)){X=!0;continue}if(X&&Y.startsWith("- ")){let J=Y.slice(2).trim();if(J)H.push(J)}}}if(H.length>0)Q.services={enabled:q,autoStart:H};return Q}async function v6(w,Q="src/packages"){try{let $;if(w.includes("/"))$=Qw.join(Q,`${w}.ts`);else{let z=`${w.replace(/\./g,"")}.ts`;$=Qw.join(Q,z)}if(!m.existsSync($))return[];let R=m.readFileSync($,"utf-8"),X=R.indexOf("versions:");if(X===-1)return[];let H=R.substring(X),q=H.indexOf("["),Z=H.indexOf("] as const");if(q===-1||Z===-1)return[];let J=H.substring(q+1,Z).match(/'([^']+)'/g);if(!J)return[];return J.map((z)=>z.replace(/'/g,""))}catch{return[]}}async function _Q(w){try{let{packages:Q}=await import("./chunk-fejavkhf.js").catch(()=>import("./src/index.js")),$=w.replace(/[^a-z0-9]/gi,"").toLowerCase(),R=Q[$];if(!R)R=Object.values(Q).find((H)=>H.domain===w);if(!R)R=Object.values(Q).find((H)=>Array.isArray(H.aliases)&&H.aliases.includes(w));if(R&&R.versions&&Array.isArray(R.versions))return R.versions;return[]}catch{return[]}}async function ow(w,Q){let $=await _Q(w);if($.length===0)return Q.split("#")[0].trim().replace(/^[@^~>=<]+/,"")||"latest";let R=Q.split("#")[0].trim();if(R==="*"||R==="latest")return $[0];if(R.startsWith("@")){let H=R.slice(1);return $.includes(H)?H:$[0]}return BQ($,R)||$[0]}function BQ(w,Q){if(Q.startsWith("^")){let $=Q.slice(1),[R]=l($);return w.filter((H)=>{let[q]=l(H);return q===R&&g(H,$)>=0})[0]||null}if(Q.startsWith("~")){let $=Q.slice(1),[R,X]=l($);return w.filter((q)=>{let[Z,Y]=l(q);return Z===R&&Y===X&&g(q,$)>=0})[0]||null}if(Q.startsWith(">=")){let $=Q.slice(2).trim();return w.filter((X)=>g(X,$)>=0)[0]||null}if(Q.startsWith(">")){let $=Q.slice(1).trim();return w.filter((X)=>g(X,$)>0)[0]||null}if(Q.startsWith("<=")){let $=Q.slice(2).trim();return w.filter((X)=>g(X,$)<=0)[0]||null}if(Q.startsWith("<")){let $=Q.slice(1).trim();return w.filter((X)=>g(X,$)<0)[0]||null}if(Q.startsWith("=")){let $=Q.slice(1).trim();return w.includes($)?$:null}return w.includes(Q)?Q:null}function l(w){let Q=w.split(".").map(($)=>{let R=$.match(/^\d+/);return R?Number.parseInt(R[0],10):0});return[Q[0]||0,Q[1]||0,Q[2]||0]}function g(w,Q){if(w==="latest"&&Q!=="latest")return 1;if(Q==="latest"&&w!=="latest")return-1;if(w==="latest"&&Q==="latest")return 0;let $=w.split("#")[0].trim(),R=Q.split("#")[0].trim(),[X,H,q]=l($),[Z,Y,J]=l(R);if(X>Z)return 1;if(X<Z)return-1;if(H>Y)return 1;if(H<Y)return-1;if(q>J)return 1;if(q<J)return-1;return 0}var ww=null;async function OQ(){if(ww)return ww;return ww=(await import("./chunk-fejavkhf.js").catch(()=>import("./src/index.js"))).packages,ww}async function jQ(w){try{let Q=await OQ(),$=Q[w];if($)return{dependencies:$.dependencies||[],companions:$.companions||[]};let R=w.replace(/[^a-z0-9]/gi,"").toLowerCase(),X=Q[R];if(X)return{dependencies:X.dependencies||[],companions:X.companions||[]};let q=Object.values(Q).find((Z)=>Z.domain===w);if(q)return{dependencies:q.dependencies||[],companions:q.companions||[]};return null}catch(Q){return console.warn(`Failed to load package data for ${w}: ${Q}`),null}}async function Rw(w,Q={},$=new Set,R=0){let{maxDepth:X=10,verbose:H=!1,targetOs:q,includeOsSpecific:Z=!0}=Q;if(R>X||$.has(w))return[];if($.add(w),H)console.log(`${" ".repeat(R)}Resolving dependencies for: ${w}`);let Y=[];try{let z=function(W){let G=W.match(/^(linux|darwin|windows):(.+)$/),_=!!G,K=G?G[2]:W,S=G?G[1]:void 0;if(_&&(!Z||q&&S!==q))return null;let B=K,L="latest",U="*",M=K.match(/^([^@^~>=<]+)([@^~>=<].+)?$/);if(M){if(B=M[1],M[2]){let I=M[2];if(I.startsWith("@"))L=I.substring(1),U=I;else U=I,L=I.replace(/^\D*/,"")}}return{dep:{name:B,version:L,constraint:U,isOsSpecific:_,os:S},pkgName:B}},J=await jQ(w),T=[...J?.dependencies||[],...J?.companions||[]].map(z).filter((W)=>W!==null);for(let{dep:W}of T)Y.push(W);let O=await Promise.all(T.map(({pkgName:W})=>Rw(W,Q,$,R+1)));for(let W of O)Y.push(...W)}catch(J){if(H)console.warn(`${" ".repeat(R)}Warning: Could not resolve dependencies for ${w}: ${J}`)}return Y}async function Gw(w,Q={}){let $=new Map,R=[],X={linux:[],darwin:[],windows:[]};for(let Z of w){if(!$.has(Z.name))$.set(Z.name,[]);if($.get(Z.name).push(Z),Z.isOsSpecific&&Z.os)X[Z.os].push(Z)}let H=[],q=[];for(let[Z,Y]of $)if(Y.length===1){let J=await ow(Z,Y[0].constraint),z={...Y[0],version:J};H.push(z),q.push(Z)}else{let J=Y.map((W)=>W.version),z=[...new Set(J)];if(z.length>1)R.push({package:Z,versions:z});let j=await Promise.all(Y.map(async(W)=>({...W,resolvedVersion:await ow(Z,W.constraint)}))),T=j[0];for(let W of j.slice(1))if(T.constraint==="*"&&W.constraint!=="*")T=W;else if(T.constraint!=="*"&&W.constraint==="*");else if(g(W.resolvedVersion,T.resolvedVersion)>0)T=W;let O={...T,version:T.resolvedVersion};delete O.resolvedVersion,H.push(O),q.push(Z)}return{allDependencies:H,uniquePackages:q,conflicts:R,osSpecificDeps:X}}async function sw(w,Q={}){let{verbose:$=!1}=Q;if($)console.log(`Parsing dependency file: ${w}`);let R=$w(w);if($)console.log(`Found ${R.length} direct dependencies`);let X=[...R],H=await Promise.all(R.map(async(Y)=>{if($)console.log(`Resolving transitive dependencies for: ${Y.name}`);return Rw(Y.name,Q)}));for(let Y of H)X.push(...Y);if($)console.log(`Total dependencies found (before deduplication): ${X.length}`);let q=await Gw(X,Q);if($){if(console.log(`Unique packages after deduplication: ${q.uniquePackages.length}`),q.conflicts.length>0)console.log(`Version conflicts found: ${q.conflicts.length}`)}let Z=Qw.extname(w);if(Z===".yaml"||Z===".yml"){let Y=UQ(w);if(Y.services)q.services=Y.services}return q}function f6(w){let Q=["deps.yaml","deps.yml","dependencies.yaml","dependencies.yml","pkgx.yaml","pkgx.yml",".deps.yaml",".deps.yml"],$=[];for(let R of Q){let X=Qw.join(w,R);if(m.existsSync(X))$.push(X)}return $}import b from"node:fs";import E from"node:path";import N from"node:process";var _w=E.join(N.cwd(),"src","packages"),Bw=E.join(N.cwd(),"docs");var o={};async function Ew(w){try{let Q=w||E.join(N.cwd(),"src","packages"),$=E.join(Q,"index.ts");if(b.existsSync($)){console.log("Using generated index file for package mapping...");let H=await import(E.resolve($)),q=H.pantry||H.packages;if(q)return console.log(`Successfully loaded ${Object.keys(q).length} packages from index`),q}console.log("Index file not found, falling back to direct file reading...");let R={};if(!b.existsSync(Q))return console.log(`Packages directory does not exist: ${Q}`),R;let X=[];try{let H=function(q,Z=""){let Y=[],J=b.readdirSync(q,{withFileTypes:!0});for(let z of J)if(z.isFile()&&z.name.endsWith(".ts")&&z.name!=="index.ts"&&z.name!=="aliases.ts")Y.push(E.join(q,z.name));else if(z.isDirectory()&&!z.name.startsWith(".")){let j=E.join(q,z.name),T=Z?`${Z}/${z.name}`:z.name;Y.push(...H(j,T))}return Y};X=H(Q),console.log(`Found ${X.length} package files`)}catch(H){console.error(`Error reading packages directory ${Q}:`,H),X=[]}console.log(`Reading package data from ${X.length} files...`);for(let H of X)try{let q=E.isAbsolute(H)?H:E.join(Q,H),Z=b.readFileSync(q,"utf-8"),Y=E.basename(H,".ts"),J=Z.match(/domain:\s*['"]([^'"]*)['"]\s*as const/),z=J?J[1]:Zw(Y),j=k(z),T=TQ(Z,z);if(T)R[j]=T,console.log(`Loaded package data for ${z} -> ${j}`)}catch(q){console.error(`Error processing file ${H}:`,q)}return console.log(`Successfully loaded ${Object.keys(R).length} packages`),R}catch(Q){return console.error("Error importing pantry:",Q),{}}}function TQ(w,Q){try{let $=w.match(/domain:\s*['"]([^'"]*)['"]\s*as const/),R=$?$[1]:Q;if(!w.match(/export const \w+Package = \{([\s\S]*?)\}/))return console.warn(`Could not find package object in file for ${R}`),null;let H=(U)=>{let M=new RegExp(`${U}:\\s*\\[(.*?)\\]\\s*as const`,"s"),I=w.match(M);if(!I)return[];let C=I[1],F=C.match(/'([^']*)'/g);if(F)return F.map((x)=>x.replace(/'/g,""));if(F=C.match(/"([^"]*)"/g),F)return F.map((x)=>x.replace(/"/g,""));return[]},q=(U)=>{let I=new RegExp(`${U}:\\s*'([^']*)'\\s*as const`),C=w.match(I);if(C)return C[1].replace(/\\'/g,"'").replace(/\\\\/g,"\\");if(I=new RegExp(`${U}:\\s*'([^']*)'`),C=w.match(I),C)return C[1].replace(/\\'/g,"'").replace(/\\\\/g,"\\");return""},Z=q("name")||R,Y=q("description")||`A package from ${R}`,J=q("packageYmlUrl")||"",z=q("homepageUrl")||"",j=q("githubUrl")||"",T=q("installCommand")||"",O=q("pkgxInstallCommand")||`sh <(curl https://pkgx.sh) +${R} -- $SHELL -i`,W=q("pantryInstallCommand")||`pantry install ${R}`,G=q("fullPath")||R,_=H("programs"),K=H("companions"),S=H("dependencies"),B=H("versions"),L=H("aliases");return{name:Z,domain:R,description:Y,packageYmlUrl:J,homepageUrl:z,githubUrl:j,installCommand:T,pkgxInstallCommand:O,pantryInstallCommand:W,programs:_,companions:K,dependencies:S,versions:B,fullPath:G,aliases:L}}catch($){return console.error(`Error extracting package data for ${Q}:`,$),null}}function LQ(w,Q){let $=["cli","app","tool","server","client","api","lib","core","sdk","dev","bin"];if($.includes(w.toLowerCase()))return!1;if(w===Q)return!1;let R=Q.replace(/\./g,"");if(w===R)return!1;if(w.includes("--")||w.includes("$SHELL")||w.includes("curl")||w.includes("sh <("))return!1;if(w.includes(" -- ")||w.includes(" -i")||w.includes("+")&&w.includes(" "))return!1;if(Q.includes("/")){let H=Q.split("/"),q=H[H.length-1];if($.includes(q.toLowerCase())&&w===q)return!1}let X=["go","js","py","rb","sh","vi","cc","gc","jq","awk","sed","mc","gh"];if(w.length<3&&!X.includes(w.toLowerCase()))return!1;if(/^[\d.]+$/.test(w)&&/^\d/.test(w))return!1;if(!/[a-z]/i.test(w))return!1;if(w.includes("{{")||w.includes("}}"))return!1;if(w.includes("version.major")||w.includes("version.minor")||w.includes("version"))return!1;return!0}function rw(){return{"Programming Languages":["node","python","go","rust","ruby","julia","lua","luajit","php","crystal","nim","kotlin","scala","swift","zig","v","dart","ghc","ocaml","clojure","erl","elixir","R","perl","tcl","dmd","tinygo"],"Artificial Intelligence":["ollama","huggingface","openai","f2py","kaggle","jupyter","llm","stable-diffusion-webui","open-interpreter","interpreter","GPT Engineer","gPTEngineer","auto-gpt","autogpt","metagpt","MetaGPT","elizaOS","eliza","openplayground","chatblade","aichat"],Databases:["psql","mysql","mongod","mongos","mongosh","redis","sqlite3","duckdb","surreal","etcd","turso","mariadb","influx","clickhouse","neo4j","cassandra","couchdb","elasticsearch","opensearch","memcached","valkey","postgrest","litecli","edgedb","dgraph"],"Web Development":["vite","next","astro","vitepress","laravel","symfony","django","flask","fastapi","rails","spring","express","tailwindcss","svelte","ng","react","vue","nx","nuxt"],DevOps:["docker","compose","podman","kubectl","minikube","kustomize","helm","terraform","terragrunt","jenkins-lts","vault","consul","nomad","packer","ansible","ansible-lint","argocd","flux","lima","k3d","kind","tofu","atlantis","terratag","tflint","tfupdate","cfn-lint","infracost"],"Container & Kubernetes Tools":["docker","podman","kubectl","minikube","kustomize","helm","helmfile","stern","hubble","cilium","kube-linter","kubeshark","kubectl-cnpg","k9s","kubectx","kubecm","kubectl-krew","skaffold","tilt","linkerd","vcluster","istioctl","velero","kubeconform","kubebuilder","operator-sdk"],"Monitoring & Observability":["prometheus","grafana","datadog","newrelic","kibana","jaeger","zipkin","sentry","steampipe","logdy","loki","tempo","allure"],"Build Tools & Automation":["cmake","ninja","meson","scons","make","bazel","gradle","mvn","ant","task","just","autoconf","automake","pkg-config","vcpkg","buildctl","buildkit","earthly","buildifier","pants","scie-pants"],"Package Managers":["npm","npx","yarn","pnpm","bun","pip","pipenv","poetry","conda","bundler","cargo","composer","pod","nuget","brew","port","pkgx","mise","asdf","nixpacks","corepack","luarocks","rye","pdm"],"Editors & IDEs":["nvim","vim","emacs","code","vscode cli","micro","nano","alacritty","wezterm","helix"],"CLI Tools & Utilities":["ripgrep","rg","tree-sitter","fzf","bat","lsd","exa","eza","fd","fd-find","sed","awk","grep","find","jq","yq","tree","watch","htop","btop","bottom","tmux","screen","starship","oh-my-posh","fish","zsh","bash","curl","wget","ripgrep-all","rga","hyperfine","dust","du-dust","duf","ncdu","tokei","loc","delta","git-delta","difftastic","diff-so-fancy","gdu","procs","bandwhich","grex","choose","sd","dog","drill","xh","httpie","curlie"],Networking:["nginx","httpd","caddy","traefik","curl","wget","httpie","cloudflared","openssh","rsync","mosh"],"Security & Cryptography":["OpenSSL","gpg","gpg-tui","vault","bw","op","1Password CLI","1password_cli","mkcert","certbot","age","yubikey-agent","snyk","trivy","tfsec","checkov","git-crypt"],Multimedia:["ffmpeg","vips","mpv","yt-dlp","streamlink","gifsicle","exiftool","optipng","imagemagick"],"Graphics Libraries":["libsdlorg","libsdlorgsdl_image","openglorg","vulkanlunarcom","mesa3dorg","freeglutfileio","glewsourceforge","glmgtrucnet","cairographicsorg","opencvorg","vtkorg","ogre3dorg","irrlichtorg"],"Gaming & Game Development":["unitycom","unrealenginecom","godotengineorg","libsdlorg","love2dorg","rayliborg","allegro5org","defoldcom","constructnet","gamemakerio","cocos2dxorg","lutrisnet","steampipecom","epicgamescom"],"Cloud Platforms":["awsamazoncom","cloudgooglecom","azuremicrosoftcom","digitaloceancom","linodecom","vultrcom","hetznercom","cloudflarecom","netlifycom","vercelcom","herokucom","railwayapp","rendercom","flyio","planetscalecom","supabasecomcli","firebasecom","localstackcloudcli"],"Mobile Development":["reactnativedev","flutterdev","xamarincom","ionicio","cordovaapacheorg","capacitorjscom","nativescriptorg","expodev","fastlanetools","appiumio","androidcomcmdlinetools","gradleorg"],Testing:["jestjsio","mochajsorg","cypressio","seleniumdev","playwrightdev","puppeteerdev","testcafeio","pytestorg","unittestpythonorg","rspecinfo","junitorg","testngorg","webdriverio","vitestdev","avajs","jasminegjscom","karmatestrunnerorg"],Cryptocurrency:["bitcoinorg","ethereumorg","solanacom","getfoundrysh","racoonorg","elementsprojectorg","githubcom10gicvanitygenplusplus","ghostscriptcom","polkadotnetwork","avalanchenetwork","chainlinkcom","cardanoorg"],"Financial Tools":["raccoinorg","gnucashorg","ledgercliorg","beancountgooglecodecom","plaintextaccountingorg","quickencom","mintcom","ynabcom"],"Documentation & Text Processing":["pandocorg","texliveorg","latexprojectorg","asciidocorg","asciidoctororg","sphinxdocorg","mkdocsorg","gitbookcom","githubiohugohugorg","jekyllrb","docsifyjs","rustlangorgmdbook","typstapp","tectonic_typesettinggithubio","maaslalanicomslides"],"System Administration":["systemdio","crongnuorg","rsyncsambaorg","opensshcom","sudows","tmuxgithubcom","gnuorgscreen","htopdev","iostat","psmisc","procpsng","straceio","ltraceorg","lsofio","tcpdumporg","logrotateorg","monitoringpluginsorg"],"Scientific Computing":["numpyorg","scipyorg","pandasdataorg","matplotliborg","seabornpydataorg","plotlycom","jupyterorg","anacondacom","rorg","rstudiocom","octaveorg","matlabcom","mathematicawolframcom","sagemath","maxima","gnuplotorg","paravieworg","vtk"],"Embedded & IoT":["arduino","platformio","espressifcom","raspberrypiorg","mbed","freedosorg","qemuorg","openocdorg","stlink","jlinkorg","modbus","zigbeeorg","gpiozeropythonorg"],"Version Control":["git","gh","gitlab"],"Other Utilities":[]}}function iw(w){if(o[w])return o[w];return w.replace(/\W/g,"_")}function aw(w){return w.toLowerCase()}function Xw(w,Q,$){try{let R=Q||_w,X=$||E.join(R,`${w}.ts`),H=b.readFileSync(X,"utf-8"),q=H.match(/export const (\w+) = \{/),Z=q?q[1]:`${w.replace(/\W/g,"")}Package`,Y=H.match(/export type (\w+) = typeof/),J=Y?Y[1]:`${Z.charAt(0).toUpperCase()}${Z.slice(1)}`;return{packageVarName:Z,typeName:J}}catch(R){console.warn(`Could not read package file ${$||`${w}.ts`}, using fallback naming:`,R);let X=MQ(w),H=EQ(w);return{packageVarName:X,typeName:H}}}function EQ(w){if(o[w]){let R=o[w];return`${R.charAt(0).toUpperCase()}${R.slice(1)}Package`}let $=aw(w).replace(/\W/g,"");return`${$.charAt(0).toUpperCase()}${$.slice(1)}Package`}function MQ(w){if(o[w])return`${o[w]}Package`;return`${aw(w).replace(/\W/g,"")}Package`}function CQ(w,Q){let{typeName:$}=Xw(w,Q);return $}function IQ(w,Q){let{packageVarName:$}=Xw(w,Q);return $}async function Ow(w){try{console.log("\uD83D\uDD27 Generating package index..."),console.log(`DEBUG generateIndex START: packagesDir=${w}`),console.log(`DEBUG generateIndex START: process.cwd()=${N.cwd()}`);let Q=w||_w,$=E.resolve(Q,"index.ts");if(console.log(`DEBUG generateIndex: packagesDir=${w}`),console.log(`DEBUG generateIndex: PACKAGES_DIR=${_w}`),console.log(`DEBUG generateIndex: targetPackagesDir=${Q}`),console.log(`DEBUG generateIndex: targetIndexFile=${$}`),console.log(`DEBUG generateIndex: path.isAbsolute(targetIndexFile)=${E.isAbsolute($)}`),!b.existsSync(Q))console.log(`Creating packages directory: ${Q}`),b.mkdirSync(Q,{recursive:!0});if(!b.existsSync(Q))return console.error(`Failed to create packages directory: ${Q}`),null;let R=[];try{let H=function(q,Z=""){let Y=[],J=b.readdirSync(q,{withFileTypes:!0});for(let z of J)if(z.isFile()&&z.name.endsWith(".ts")&&z.name!=="index.ts"&&z.name!=="aliases.ts")Y.push(E.join(q,z.name));else if(z.isDirectory()&&!z.name.startsWith(".")){let j=E.join(q,z.name),T=Z?`${Z}/${z.name}`:z.name;Y.push(...H(j,T))}return Y};R=H(Q),console.log(`Found ${R.length} package files`)}catch(H){console.error(`Error reading packages directory ${Q}:`,H),R=[]}let X=`// Auto-generated package index
|
|
8
|
-
// Do not edit this file directly
|
|
9
|
-
|
|
10
|
-
export interface Pantry {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type Packages = Pantry
|
|
14
|
-
|
|
15
|
-
export const pantry: Pantry = {
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const packages: Packages = pantry
|
|
19
|
-
`;if(R.length>0){console.log(`Processing ${R.length} package files...`);let H=`// Auto-generated package index
|
|
20
|
-
// Do not edit this file directly
|
|
21
|
-
|
|
22
|
-
`,q=`export interface Pantry {
|
|
23
|
-
`,Z=`export const pantry: Pantry = {
|
|
24
|
-
`,Y=new Set,J=new Set,z=R.sort();for(let G of z)try{let _=E.basename(G,".ts"),K=iw(_),B=E.relative(Q,G).replace(/\.ts$/,"").replace(/\\/g,"/"),{packageVarName:L}=Xw(_,Q,G),U=L,M=1;while(J.has(U))U=`${L}${M}`,M++;if(J.add(U),U===L)H+=`import { ${L} } from './${B}'
|
|
25
|
-
`;else H+=`import { ${L} as ${U} } from './${B}'
|
|
26
|
-
`;let I=K,C=1;while(Y.has(I))I=`${K}${C}`,C++;Y.add(I);let F=/^\d/.test(I)||!/^[a-z_$][\w$]*$/i.test(I)?`'${I}'`:I;q+=` ${F}: typeof ${U}
|
|
27
|
-
`,Z+=` ${F}: ${U},
|
|
28
|
-
`;let V=b.readFileSync(G,"utf-8").match(/domain:\s*['"]([^'"]*)['"]\s*as const/),v=V?V[1]:"";if(v){let P=k(v);if(P!==I){let D=P,u=1;while(Y.has(D))D=`${P}${u}`,u++;Y.add(D);let f=/^\d/.test(D)||!/^[a-z_$][\w$]*$/i.test(D)?`'${D}'`:D;q+=` ${f}: typeof ${U}
|
|
29
|
-
`,Z+=` ${f}: ${U},
|
|
30
|
-
`}}}catch(_){console.error(`Error processing file ${G}:`,_)}let j=await qw(Q),T=new Map;for(let G of z)try{let K=b.readFileSync(G,"utf-8").match(/domain:\s*['"]([^'"]*)['"]\s*as const/),S=K?K[1]:"";if(S){let B=E.basename(G,".ts"),{packageVarName:L}=Xw(B,Q,G),U=L,M=1;while(J.has(U)&&U!==L)U=`${L}${M}`,M++;T.set(S,U)}}catch(_){console.error(`Error processing file for alias mapping ${G}:`,_)}for(let[G,_]of Object.entries(j)){let K=T.get(_);if(K){let S=/^\d/.test(G)||!/^[a-z_$][\w$]*$/i.test(G)?`'${G}'`:G;if(Y.has(G)){let B=S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`^\\s*${B}:\\s*typeof\\s+\\w+\\s*$`,"gm"),U=new RegExp(`^\\s*${B}:\\s*\\w+,\\s*$`,"gm");q=q.replace(L,""),Z=Z.replace(U,"")}q+=` ${S}: typeof ${K}
|
|
31
|
-
`,Z+=` ${S}: ${K},
|
|
32
|
-
`,Y.add(G)}}q+=`}
|
|
33
|
-
|
|
34
|
-
`,Z+=`}
|
|
35
|
-
|
|
36
|
-
`,X=`${H}
|
|
37
|
-
${q}export type Packages = Pantry
|
|
38
|
-
|
|
39
|
-
${Z}export const packages: Packages = pantry
|
|
40
|
-
|
|
41
|
-
export * from './aliases'
|
|
42
|
-
`}try{b.writeFileSync($,X),console.log(`Successfully generated ${$}`)}catch(H){return console.error(`Error writing index file ${$}:`,H),null}if(!b.existsSync($))return console.error(`Index file was not created: ${$}`),null;return console.log(`DEBUG generateIndex: returning ${$}`),console.log(`DEBUG generateIndex: return value isAbsolute=${E.isAbsolute($)}`),console.log(`DEBUG generateIndex: return value type=${typeof $}`),$}catch(Q){return console.error("Error generating index file:",Q),null}}async function qw(w){let Q={};console.log("Generating aliases from package files (avoiding circular dependency)");let $=w||E.join(N.cwd(),"src","packages");if(!b.existsSync($))return console.log(`Packages directory does not exist: ${$}`),Q;function R(q,Z=""){let Y=[],J=b.readdirSync(q,{withFileTypes:!0});for(let z of J)if(z.isFile()&&z.name.endsWith(".ts")&&z.name!=="index.ts"&&z.name!=="aliases.ts")Y.push(E.join(q,z.name));else if(z.isDirectory()&&!z.name.startsWith(".")){let j=E.join(q,z.name),T=Z?`${Z}/${z.name}`:z.name;Y.push(...R(j,T))}return Y}let X=R($);console.log(`Found ${X.length} package files`);for(let q of X)try{let Z=q,Y=b.readFileSync(Z,"utf-8"),J=E.basename(q,".ts"),z=Y.match(/domain:\s*['"]([^'"]*)['"]\s*as const/),j=z?z[1]:Zw(J),T=Y.match(/name:\s*['"]([^'"]*)['"]\s*as const/),O=T?T[1]:"";if(O&&O!==j&&LQ(O,j))if(!Q[O])Q[O]=j,console.log(`Auto-generated alias: ${O} -> ${j}`);else console.log(`Skipped auto-generated alias ${O} -> ${j} (already exists as ${Q[O]})`);let W=Y.match(/aliases:\s*\[([\s\S]*?)\]/);if(W&&W[1]){let G=W[1].match(/["']([^"']*)["']/g);if(G)for(let _ of G){let K=_.replace(/["']/g,"");if(!(!K||K.includes("--")||K.includes("$SHELL")||K.includes("curl")||K.includes("sh <(")||K.includes(" -- ")||K.includes(" -i")||K.includes("+")&&K.includes(" ")||K.includes("{{")||K.includes("}}")||K.includes("version.major")||K.includes("version.minor")||K===j))if(!Q[K])Q[K]=j,console.log(`Found explicit alias ${K} -> ${j}`);else console.log(`Skipped explicit alias ${K} -> ${j} (already exists as ${Q[K]})`);else console.log(`Filtered out invalid alias: ${K} for ${j}`)}}if(j==="aws.amazon.com/cli"){if(!Q.aws)Q.aws=j,console.log(`Added AWS CLI alias: aws -> ${j}`);if(!Q["aws/cli"])Q["aws/cli"]=j,console.log(`Added AWS CLI path alias: aws/cli -> ${j}`)}if(j==="aws.amazon.com/cdk"){if(!Q["aws/cdk"])Q["aws/cdk"]=j,console.log(`Added AWS CDK path alias: aws/cdk -> ${j}`)}}catch(Z){console.error(`Error extracting aliases from ${q}:`,Z)}let H=tw();for(let[q,Z]of Object.entries(H))if(!Q[q])Q[q]=Z,console.log(`Added alias override: ${q} -> ${Z}`);else{let Y=Q[q];Q[q]=Z,console.log(`Overrode alias ${q}: ${Y} -> ${Z}`)}return Q}async function jw(w){try{console.log(`DEBUG generateAliases START: packagesDir=${w}`),console.log(`DEBUG generateAliases START: process.cwd()=${N.cwd()}`);let Q=await qw(w),$=w?E.resolve(w):E.resolve(N.cwd(),"src","packages"),R=E.resolve($,"aliases.ts");console.log(`DEBUG generateAliases: targetPackagesDir=${$}`),console.log(`DEBUG generateAliases: aliasesFile=${R}`),console.log(`DEBUG generateAliases: path.isAbsolute(aliasesFile)=${E.isAbsolute(R)}`);let X=E.dirname(R);if(!b.existsSync(X))b.mkdirSync(X,{recursive:!0});let H=Q,q=`/**
|
|
43
|
-
* Auto-generated aliases for pkgx packages
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
`;q+=`export const aliases: Record<string, string> = {
|
|
47
|
-
`;let Z=Object.entries(H).sort((Y,J)=>Y[0].localeCompare(J[0]));for(let[Y,J]of Z)q+=` '${Y}': '${J}',
|
|
48
|
-
`;return q+=`}
|
|
49
|
-
`,b.writeFileSync(R,q),console.log(`Successfully generated ${R} with ${Z.length} aliases`),console.log(`DEBUG generateAliases: returning ${R}`),console.log(`DEBUG generateAliases: return value isAbsolute=${E.isAbsolute(R)}`),console.log(`DEBUG generateAliases: return value type=${typeof R}`),R}catch(Q){return console.error("Error generating aliases file:",Q),""}}function SQ(w){let Q=w.split(`
|
|
50
|
-
`).map(($)=>$.trimEnd()).join(`
|
|
51
|
-
`);return Q=FQ(Q),Q=Q.replace(/\n{3,}/g,`
|
|
52
|
-
|
|
53
|
-
`),Q=`${Q.trimEnd()}
|
|
54
|
-
`,Q}function Mw(w){return SQ(w)}function FQ(w){let Q=w.split(`
|
|
55
|
-
`),$=!1;return Q.map((R)=>{if(R.trimStart().startsWith("```"))return $=!$,R;if($)return R;return R.replace(/(?<!\]\()(?<!\()(?<!<)(https?:\/\/[^\s)>\]]+)/g,(X,H,q)=>{if(q>0&&R[q-1]==="<")return X;let Z=R.slice(0,q);if(/\]\($/.test(Z))return X;if((Z.match(/`/g)||[]).length%2===1)return X;return`<${X}>`})}).join(`
|
|
56
|
-
`)}function bQ(w){if(["undefined","null","true","false","var","let","const","function","class","if","else","for","while","do","switch","case","default","break","continue","return","try","catch","finally","throw","new","this","super","import","export","from","as","typeof","instanceof","in","of","delete","void","async","await","yield","static","extends","implements","interface","type","enum","namespace","module","declare","abstract","public","private","protected","readonly","get","set"].includes(w.toLowerCase()))return!1;let $=["go","rust","zig","nim","dart","julia","scala","kotlin","swift","node","bun"];if(!w.includes(".")&&!$.includes(w.toLowerCase()))return!1;if(!w||w.trim().length===0)return!1;if(!/^[\w.\-/]+$/.test(w))return!1;return!0}function AQ(w){if(/^[A-Z][A-Z0-9_]*(?:\^|$)/.test(w))return!0;return[/^linux$/,/^darwin$/,/^ompi_.*flags/i,/^perl5lib/i,/^gsettings-desktop-schemas$/,/^curl\.se\/ca-certs$/,/^openssh\.com$/].some(($)=>$.test(w))}function p(w){if(!bQ(w.domain))return!0;if(!w.description)return!0;return["Go home.","Crafters of fine Open Source products","Package information for","pkgx package","Loading...","Please wait...","Package information available on pkgx.dev"].some(($)=>w.description.includes($))}function ew(w){let Q=(R)=>{if(!w.versions||w.versions.length===0)return R.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}");let X=w.versions[0],H=X.split("."),q=H[0]||"",Z=H[1]||"",Y=H[2]||"",J=Z?`${q}.${Z}`:q;return R.replace(/\{\{\s*version\.marketing\s*\}\}/g,J).replace(/\{\{\s*version\.major\s*\}\}/g,q).replace(/\{\{\s*version\.minor\s*\}\}/g,Z).replace(/\{\{\s*version\.patch\s*\}\}/g,Y).replace(/\{\{\s*version\.raw\s*\}\}/g,X).replace(/\{\{\s*version\s*\}\}/g,X).replace(/\{\{(?![^}]*\}\})/g,"{{")};if(w.pantryInstallCommand){let R=w.pantryInstallCommand.match(/pantry install (.+)/);if(R){let X=R[1];if(w.aliases&&w.aliases.length>0){let H=[...w.aliases].sort((Z,Y)=>Z.length-Y.length);return`pantry install ${Q(H[0])}`}if(w.aliases&&w.aliases.some((H)=>H.toLowerCase()===X.toLowerCase()))return`pantry install ${Q(X.toLowerCase())}`;return Q(w.pantryInstallCommand)}}if(w.installCommand)return Q(w.installCommand);let $=w.domain;if(w.aliases&&w.aliases.length>0)$=[...w.aliases].sort((X,H)=>X.length-H.length)[0];return $=Q($),`pantry install ${$}`}async function xQ(w,Q){let $=await Ew(Q),R=await qw(Q),X=rw(),H=E.resolve(w,"package-catalog.md"),q={},Z=0;for(let[W,G]of Object.entries($))if(!p(G))q[W]=G;else Z++,console.log(`Excluding package ${G.domain||W} (placeholder data)`);console.log(`Filtered out ${Z} packages with placeholder data`);let Y=new Set,J=new Map;for(let[W,G]of Object.entries(q)){let _=G.domain;if(!Y.has(_))J.set(_,G),Y.add(_)}let z=new Set;Object.values(X).forEach((W)=>{W.forEach((G)=>z.add(G))});let j=[];if(J.forEach((W,G)=>{if(!z.has(G))j.push(G)}),j.length>0)X["Other Utilities"]=j;let T=`# Package Catalog
|
|
57
|
-
|
|
58
|
-
This comprehensive catalog lists all ${J.size}+ packages available in ts-pantry, organized by category.
|
|
59
|
-
|
|
60
|
-
Each package can be accessed using \`getPackage(name)\` or directly via \`pantry.domain\`.
|
|
61
|
-
|
|
62
|
-
## Quick Stats
|
|
63
|
-
|
|
64
|
-
- **Total Packages**: ${J.size}
|
|
65
|
-
- **Categories**: ${Object.keys(X).length}
|
|
66
|
-
- **Last Updated**: ${new Date().toISOString()}
|
|
67
|
-
|
|
68
|
-
## Table of Contents
|
|
69
|
-
|
|
70
|
-
`,O=(W)=>{if($[W])return{domainVarName:W,pkg:$[W]};let G=R[W];if(G){let _=k(G);if($[_])return{domainVarName:_,pkg:$[_]}}return null};Object.keys(X).forEach((W)=>{let G=W.toLowerCase().replace(/[^a-z0-9]+/g,"-"),_=X[W],K=new Map;_.forEach((B)=>{let L=O(B);if(L&&!p(L.pkg)){let U=L.pkg.domain||L.pkg.fullPath||"unknown";if(!K.has(U))K.set(U,L);else{let M=K.get(U);if(L.domainVarName.length<M.domainVarName.length||L.domainVarName.length===M.domainVarName.length&&L.domainVarName<M.domainVarName)K.set(U,L)}}});let S=K.size;if(S>0)T+=`- [${W}](#${G}) (${S} packages)
|
|
71
|
-
`}),T+=`
|
|
72
|
-
`;for(let[W,G]of Object.entries(X)){let _=new Map;G.forEach((S)=>{let B=O(S);if(B&&!p(B.pkg)){let L=B.pkg.domain||B.pkg.fullPath||"unknown";if(!_.has(L))_.set(L,B);else{let U=_.get(L);if(B.domainVarName.length<U.domainVarName.length||B.domainVarName.length===U.domainVarName.length&&B.domainVarName<U.domainVarName)_.set(L,B)}}});let K=Array.from(_.values()).sort((S,B)=>(S.pkg.domain||S.domainVarName).localeCompare(B.pkg.domain||B.domainVarName));if(K.length===0)continue;T+=`## ${W}
|
|
73
|
-
|
|
74
|
-
`,T+=`${K.length} packages in this category
|
|
75
|
-
|
|
76
|
-
`,T+=`| Package | Description | Programs | Versions | Install |
|
|
77
|
-
`,T+=`|---------|-------------|----------|----------|----------|
|
|
78
|
-
`;for(let{domainVarName:S,pkg:B}of K)try{let L=B.domain||B.fullPath||"unknown",U=B.aliases?` (${B.aliases.map((u)=>u.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}")).join(", ")})`:"",M=B.programs.slice(0,3).map((u)=>u.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}")).join(", ");if(B.programs.length>3)M+=`, ... (+${B.programs.length-3})`;if(B.programs.length===0)M="-";let I=B.versions?.length||0,C=B.versions?.[0]||"latest",F=I>0?`${C} (+${I-1})`:"latest",x=B.description.replace(/\s+/g," ").replace(/\{\{/g,"{{").replace(/\}\}/g,"}}").replace(/\x27/g,"'").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|");if(x.length>100)x=`${x.substring(0,97)}...`;let V=B.name||L;if(B.aliases&&B.aliases.length>0)V=[...B.aliases].sort((f,h)=>f.length-h.length)[0];V=V.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}");let v=`\`pkgx ${V}\``,P;if(L.includes("."))if(L.startsWith("github.com/")&&L.includes("/")){let f=L.replace("github.com/","").split("/");if(f.length>=2){let h=f[0],WQ=f.slice(1).join("-");P=`./packages/github.com/${h}/${WQ}.md`}else{let h=S.toLowerCase();if(/^\d/.test(h))h=`pkg-${h}`;h=h.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),P=`./packages/${h}.md`}}else P=`./packages/${L}/index.md`;else{let u=S.toLowerCase();if(/^\d/.test(u))u=`pkg-${u}`;u=u.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),P=`./packages/${u}.md`}let D=`| **[${L}](${P})**${U} | ${x} | ${M} | ${F} | ${v} |`.replace(/\r?\n/g," ").replace(/\s+/g," ");T+=`${D}
|
|
79
|
-
`}catch(L){let U=B.domain||B.fullPath||"unknown";console.error(`Error processing ${U}:`,L),T+=`| **${U}** | Error retrieving package information | - | - | - |
|
|
80
|
-
`}T+=`
|
|
81
|
-
`}return T+=`## Usage Examples
|
|
82
|
-
|
|
83
|
-
### Basic Usage
|
|
84
|
-
|
|
85
|
-
\`\`\`typescript
|
|
86
|
-
import { getPackage, pantry } from 'ts-pkgx'
|
|
87
|
-
|
|
88
|
-
// Get a package by domain
|
|
89
|
-
const nodePackage = pantry.nodejsorg
|
|
90
|
-
|
|
91
|
-
// Get a package by alias
|
|
92
|
-
const nodeByAlias = getPackage('node')
|
|
93
|
-
|
|
94
|
-
// Access package properties
|
|
95
|
-
console.log(\`Package: \${nodePackage.name} - \${nodePackage.description}\`)
|
|
96
|
-
console.log(\`Install: \${nodePackage.installCommand}\`)
|
|
97
|
-
console.log(\`Programs: \${nodePackage.programs.join(', ')}\`)
|
|
98
|
-
\`\`\`
|
|
99
|
-
|
|
100
|
-
### Advanced Usage
|
|
101
|
-
|
|
102
|
-
\`\`\`typescript
|
|
103
|
-
// Find packages by category
|
|
104
|
-
const databases = [
|
|
105
|
-
pantry.postgresqlorg,
|
|
106
|
-
pantry.mysqlcom,
|
|
107
|
-
pantry.redisio,
|
|
108
|
-
pantry.mongodbcom
|
|
109
|
-
]
|
|
110
|
-
|
|
111
|
-
// Get all available versions
|
|
112
|
-
const nodeVersions = pantry.nodejsorg.versions
|
|
113
|
-
console.log(\`Node.js versions: \${nodeVersions.slice(0, 5).join(', ')}...\`)
|
|
114
|
-
|
|
115
|
-
// Check dependencies
|
|
116
|
-
const nodeDeps = pantry.nodejsorg.dependencies
|
|
117
|
-
console.log(\`Node.js dependencies: \${nodeDeps.join(', ')}\`)
|
|
118
|
-
\`\`\`
|
|
119
|
-
|
|
120
|
-
### Installation Examples
|
|
121
|
-
|
|
122
|
-
\`\`\`bash
|
|
123
|
-
# Install using pkgx
|
|
124
|
-
pkgx node
|
|
125
|
-
pkgx python
|
|
126
|
-
pkgx rust
|
|
127
|
-
|
|
128
|
-
# Install specific versions
|
|
129
|
-
pkgx node@20
|
|
130
|
-
pkgx python@3.11
|
|
131
|
-
|
|
132
|
-
# Install multiple packages
|
|
133
|
-
pkgx node python rust
|
|
134
|
-
\`\`\`
|
|
135
|
-
|
|
136
|
-
## Package Information
|
|
137
|
-
|
|
138
|
-
Each package includes:
|
|
139
|
-
|
|
140
|
-
- **Name**: Short identifier for the package
|
|
141
|
-
- **Domain**: Full domain identifier
|
|
142
|
-
- **Description**: What the package does
|
|
143
|
-
- **Programs**: Executable programs provided
|
|
144
|
-
- **Versions**: Available versions
|
|
145
|
-
- **Dependencies**: Required dependencies
|
|
146
|
-
- **Companions**: Related packages
|
|
147
|
-
- **Install Command**: How to install with pkgx
|
|
148
|
-
|
|
149
|
-
## Contributing
|
|
150
|
-
|
|
151
|
-
To add or update packages, see the pkgx [contribution guide](https://docs.pkgx.sh/appendix/packaging/pantry).
|
|
152
|
-
`,await b.promises.writeFile(H,Mw(T)),H}function nw(w,Q,$){if(w.includes("."))if(w.startsWith("github.com/")){let X=w.replace("github.com/","").split("/");if(X.length>=2){let H=X[0],q=X.slice(1).join("-");return E.join($,"github.com",H,`${q}.md`)}else{let H=X[0];return E.join($,"github.com",H,"index.md")}}else return E.join($,w,"index.md");else{let R=Q.toLowerCase();if(/^\d/.test(R))R=`pkg-${R}`;return R=R.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),E.join($,`${R}.md`)}}async function VQ(w,Q){let $=await Ew(Q),R=E.join(w,"packages");if(!b.existsSync(R))b.mkdirSync(R,{recursive:!0});let X=[],H=new Map;for(let[q,Z]of Object.entries($)){if(p(Z)){console.log(`Skipping package page for ${Z.domain||q} (placeholder data)`);continue}let Y=Z.domain;if(!H.has(Y))H.set(Y,{domainVarName:q,pkg:Z});else{let J=H.get(Y);if(q.length<J.domainVarName.length||q.length===J.domainVarName.length&&q<J.domainVarName)H.set(Y,{domainVarName:q,pkg:Z}),console.log(`Replaced ${J.domainVarName} with ${q} for domain ${Y}`)}}for(let{domainVarName:q,pkg:Z}of H.values())try{let Y=Z.domain||Z.fullPath||q,J;if(Y.includes("."))if(Y.startsWith("github.com/")){let M=Y.replace("github.com/","").split("/");if(M.length>=2){let I=M[0],C=M.slice(1).join("-"),F=E.join(R,"github.com",I);if(!b.existsSync(F))b.mkdirSync(F,{recursive:!0});J=E.join(F,`${C}.md`)}else{let I=M[0],C=E.join(R,"github.com",I);if(!b.existsSync(C))b.mkdirSync(C,{recursive:!0});J=E.join(C,"index.md")}}else{let U=E.join(R,Y);if(!b.existsSync(U))b.mkdirSync(U,{recursive:!0});J=E.join(U,"index.md")}else{let U=q.toLowerCase();if(/^\d/.test(U))U=`pkg-${U}`;U=U.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),J=E.join(R,`${U}.md`)}let z=Z.description||"",j=(U)=>{if(!Z.versions||Z.versions.length===0)return U.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}");let M=Z.versions[0],I=M.split("."),C=I[0]||"",F=I[1]||"",x=I[2]||"",V=F?`${C}.${F}`:C;return U.replace(/\{\{\s*version\.marketing\s*\}\}/g,V).replace(/\{\{\s*version\.major\s*\}\}/g,C).replace(/\{\{\s*version\.minor\s*\}\}/g,F).replace(/\{\{\s*version\.patch\s*\}\}/g,x).replace(/\{\{\s*version\.raw\s*\}\}/g,M).replace(/\{\{\s*version\s*\}\}/g,M).replace(/\{\{(?![^}]*\}\})/g,"{{")},T=j(Z.name||Y),O=j(z).replace(/\s+/g," "),W=`# ${T}
|
|
153
|
-
|
|
154
|
-
${O?`> ${O}`:""}
|
|
155
|
-
|
|
156
|
-
## Package Information
|
|
157
|
-
|
|
158
|
-
- **Domain**: \`${Y}\`
|
|
159
|
-
- **Name**: \`${T}\`
|
|
160
|
-
- **Homepage**: ${Z.homepageUrl||"Not specified"}
|
|
161
|
-
- **Source**: [View on GitHub](${Z.packageYmlUrl||`https://github.com/pkgxdev/pantry/tree/main/projects/${Y}/package.yml`})
|
|
162
|
-
|
|
163
|
-
## Installation
|
|
164
|
-
|
|
165
|
-
\`\`\`bash
|
|
166
|
-
# Install with pantry
|
|
167
|
-
${ew(Z)}
|
|
168
|
-
\`\`\`
|
|
169
|
-
|
|
170
|
-
## Programs
|
|
171
|
-
|
|
172
|
-
This package provides the following executable programs:
|
|
173
|
-
|
|
174
|
-
`;if(Z.programs&&Z.programs.length>0)Z.programs.forEach((U)=>{let M=j(U);W+=`- \`${M}\`
|
|
175
|
-
`});else W+=`No programs specified.
|
|
176
|
-
`;if(Z.aliases&&Z.aliases.length>0)W+=`
|
|
177
|
-
## Aliases
|
|
178
|
-
|
|
179
|
-
This package can also be accessed using these aliases:
|
|
180
|
-
|
|
181
|
-
`,Z.aliases.forEach((U)=>{let M=j(U);W+=`- \`${M}\`
|
|
182
|
-
`});if(Z.versions&&Z.versions.length>0){W+=`
|
|
183
|
-
## Available Versions
|
|
184
|
-
|
|
185
|
-
<details>
|
|
186
|
-
<summary>Show all ${Z.versions.length} versions</summary>
|
|
187
|
-
|
|
188
|
-
`;let U=new Map,M=[];Z.versions.forEach((I)=>{let C=I.split("."),F=C.length>=2?`${C[0]}.${C[1]}`:C[0];if(!U.has(F))U.set(F,[]),M.push(F);U.get(F).push(I)}),M.forEach((I)=>{let C=U.get(I);W+=`- ${C.map((F)=>`\`${F}\``).join(", ")}
|
|
189
|
-
`}),W+=`
|
|
190
|
-
</details>
|
|
191
|
-
|
|
192
|
-
**Latest Version**: \`${Z.versions[0]}\`
|
|
193
|
-
|
|
194
|
-
### Install Specific Version
|
|
195
|
-
|
|
196
|
-
\`\`\`bash
|
|
197
|
-
# Install specific version
|
|
198
|
-
${Z.pkgxInstallCommand?j(Z.pkgxInstallCommand.replace(`+${Y}`,`+${Y}@${Z.versions[0]}`)):`sh <(curl https://pkgx.sh) +${Y}@${Z.versions[0]} -- $SHELL -i`}
|
|
199
|
-
\`\`\`
|
|
200
|
-
`}if(Z.dependencies&&Z.dependencies.length>0)W+=`
|
|
201
|
-
## Dependencies
|
|
202
|
-
|
|
203
|
-
This package depends on:
|
|
204
|
-
|
|
205
|
-
`,Z.dependencies.forEach((U)=>{W+=`- \`${U}\`
|
|
206
|
-
`});if(Z.companions&&Z.companions.length>0){let U=Z.companions.filter((M)=>!AQ(M));if(U.length>0)W+=`
|
|
207
|
-
## Related Packages
|
|
208
|
-
|
|
209
|
-
These packages work well with ${Z.name||Y}:
|
|
210
|
-
|
|
211
|
-
`,U.forEach((M)=>{let I=k(M),C=$[I];if(C&&!p(C)){let F=nw(M,I,R),x=E.relative(E.dirname(J),F).replace(/\\/g,"/"),V=C.description?.trim();if(V)W+=`- [\`${M}\`](${x}) - ${V}
|
|
212
|
-
`;else W+=`- [\`${M}\`](${x})
|
|
213
|
-
`}else{let F=nw(M,I,R),x=E.relative(E.dirname(J),F).replace(/\\/g,"/"),V=C?.description?.trim()||"Package not available";if(V&&V!=="Package not available")W+=`- [\`${M}\`](${x}) - ${V}
|
|
214
|
-
`;else W+=`- [\`${M}\`](${x})
|
|
215
|
-
`}})}let G=E.dirname(R),K=`${E.relative(E.dirname(J),G)}/package-catalog.md`.replace(/\\/g,"/"),S=Z.aliases&&Z.aliases.length>0?Z.aliases[0]:Z.name||k(Y),L=/[^\w$]/.test(S)||/^\d/.test(S)?`pantry['${S}']`:`pantry.${S}`;W+=`
|
|
216
|
-
## Usage Examples
|
|
217
|
-
|
|
218
|
-
\`\`\`typescript
|
|
219
|
-
import { pantry } from 'ts-pkgx'
|
|
220
|
-
|
|
221
|
-
// Access this package
|
|
222
|
-
const pkg = ${L}
|
|
223
|
-
|
|
224
|
-
console.log(\`Package: \${pkg.name}\`)
|
|
225
|
-
console.log(\`Description: \${pkg.description}\`)
|
|
226
|
-
console.log(\`Programs: \${pkg.programs.join(', ')}\`)
|
|
227
|
-
\`\`\`
|
|
228
|
-
|
|
229
|
-
## Links
|
|
230
|
-
|
|
231
|
-
- [Package Source](${Z.packageYmlUrl||`https://github.com/pkgxdev/pantry/tree/main/projects/${Y}/package.yml`})
|
|
232
|
-
- [Homepage](${Z.homepageUrl||"#"})
|
|
233
|
-
- [Back to Package Catalog](${K})
|
|
234
|
-
|
|
235
|
-
---
|
|
236
|
-
|
|
237
|
-
> Auto-generated from package data.
|
|
238
|
-
`,await b.promises.writeFile(J,Mw(W)),X.push(J)}catch(Y){console.error(`Error generating page for ${q}:`,Y)}return X}async function yQ(w,Q){let $=await Ew(Q),R=await qw(Q),X=rw(),H=E.join(w,"categories");if(!b.existsSync(H))b.mkdirSync(H,{recursive:!0});let q=[],Z=(Y)=>{if($[Y])return{domainVarName:Y,pkg:$[Y]};if(R[Y]){let J=R[Y],z=k(J);if($[z])return{domainVarName:z,pkg:$[z]}}return null};for(let[Y,J]of Object.entries(X)){let z=new Map;J.forEach((G)=>{let _=Z(G);if(_&&!p(_.pkg)){let K=_.pkg.domain||_.pkg.fullPath||"unknown";if(!z.has(K))z.set(K,_);else{let S=z.get(K);if(_.domainVarName.length<S.domainVarName.length||_.domainVarName.length===S.domainVarName.length&&_.domainVarName<S.domainVarName)z.set(K,_)}}});let j=Array.from(z.values()).sort((G,_)=>(G.pkg.domain||G.domainVarName).localeCompare(_.pkg.domain||_.domainVarName));if(j.length===0)continue;let T=`${Y.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.md`,O=E.join(H,T),W=`# ${Y}
|
|
239
|
-
|
|
240
|
-
${j.length} packages in this category
|
|
241
|
-
|
|
242
|
-
${Y==="Programming Languages"?"Popular programming languages and their runtimes available through pkgx.":Y==="Databases"?"Database systems and data storage solutions.":Y==="Development Tools"?"Development environments, editors, and programming tools.":Y==="Build Tools"?"Build systems, compilers, and development infrastructure.":Y==="DevOps"?"Tools for deployment, orchestration, and infrastructure management.":Y==="Multimedia"?"Audio, video, and image processing tools.":Y==="Security"?"Security tools, encryption, and authentication systems.":Y==="Networking"?"Network tools, protocols, and communication software.":Y==="CLI Tools & Utilities"?"Command-line utilities and system tools.":`Packages related to ${Y.toLowerCase()}.`}
|
|
243
|
-
|
|
244
|
-
## Packages
|
|
245
|
-
|
|
246
|
-
`;j.forEach(({domainVarName:G,pkg:_})=>{let K=_.domain||_.fullPath||"unknown",S=(C)=>{if(!_.versions||_.versions.length===0)return C.replace(/\{\{/g,"{{").replace(/\}\}/g,"}}");let F=_.versions[0],x=F.split("."),V=x[0]||"",v=x[1]||"",P=x[2]||"",D=v?`${V}.${v}`:V;return C.replace(/\{\{\s*version\.marketing\s*\}\}/g,D).replace(/\{\{\s*version\.major\s*\}\}/g,V).replace(/\{\{\s*version\.minor\s*\}\}/g,v).replace(/\{\{\s*version\.patch\s*\}\}/g,P).replace(/\{\{\s*version\.raw\s*\}\}/g,F).replace(/\{\{\s*version\s*\}\}/g,F).replace(/\{\{(?![^}]*\}\})/g,"{{")},B=[];if(_.name&&_.name!==K)B.push(_.name);if(_.aliases&&_.aliases.length>0)B.push(..._.aliases);let L=B.length>0?` (${B.join(", ")})`:"",U=_.description||"",M=S(U).replace(/\s+/g," "),I;if(K.includes("."))if(K.startsWith("github.com/")&&K.includes("/")){let F=K.replace("github.com/","").split("/");if(F.length>=2){let x=F[0],V=F.slice(1).join("-");I=`../packages/github.com/${x}/${V}.md`}else{let x=G.toLowerCase();if(/^\d/.test(x))x=`pkg-${x}`;x=x.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),I=`../packages/${x}.md`}}else I=`../packages/${K}/index.md`;else{let C=G.toLowerCase();if(/^\d/.test(C))C=`pkg-${C}`;C=C.replace(/[^\w-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,""),I=`../packages/${C}.md`}W+=`### [${K}](${I})${L}
|
|
247
|
-
|
|
248
|
-
${M?`${M}`:""}
|
|
249
|
-
|
|
250
|
-
**Programs**: ${_.programs&&_.programs.length>0?_.programs.map((C)=>S(C)).join(", "):"None specified"}
|
|
251
|
-
|
|
252
|
-
**Install**: \`${ew(_)}\`
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
`}),W+=`[← Back to Package Catalog](../package-catalog.md)
|
|
257
|
-
`,await b.promises.writeFile(O,Mw(W)),q.push(O)}return q}async function Tw(w=Bw,Q){console.log("\uD83D\uDE80 Generating comprehensive package documentation...");try{if(!b.existsSync(w))b.mkdirSync(w,{recursive:!0});console.log("\uD83D\uDCDA Generating package catalog...");let $=await xQ(w,Q);console.log(`✅ Generated: ${$}`),console.log("\uD83D\uDCC4 Generating individual package pages...");let R=await VQ(w,Q);console.log(`✅ Generated ${R.length} package pages`),console.log("\uD83D\uDCC2 Generating category pages...");let X=await yQ(w,Q);console.log(`✅ Generated ${X.length} category pages`),console.log(`
|
|
258
|
-
\uD83C\uDF89 Documentation generation complete!`),console.log(`\uD83D\uDCCD Output directory: ${w}`),console.log(`\uD83D\uDCCA Total files generated: ${1+R.length+X.length}`),console.log(`
|
|
259
|
-
Files generated:`),console.log(`- Package catalog: ${$}`),console.log(`- Package pages: ${R.length} files in docs/packages/`),console.log(`- Category pages: ${X.length} files in docs/categories/`)}catch($){throw console.error("❌ Error generating documentation:",$),$}}async function Lw(){try{console.log("\uD83C\uDFAF Updating Dependencies type timestamp...");let w=E.join(N.cwd(),"src","dependencies.ts");if(!b.existsSync(w)){console.log("dependencies.ts not found, skipping update");return}let Q=b.readFileSync(w,"utf-8"),$=new Date().toISOString(),R=Q.replace(/\/\/ Auto-generated precise dependency types/,`// Auto-generated precise dependency types
|
|
260
|
-
// Last updated: ${$}`);b.writeFileSync(w,R),console.log("✅ Updated dependencies.ts timestamp")}catch(w){console.error("Error updating dependencies.ts:",w)}}async function NQ(){try{let w=N.argv.slice(2);switch(w[0]||"index"){case"index":{if(console.log("\uD83D\uDD27 Generating package index..."),!await Ow())console.error("❌ Failed to generate index"),N.exit(1);if(console.log("\uD83C\uDFF7️ Generating aliases..."),!await jw())console.error("❌ Failed to generate aliases"),N.exit(1);console.log("\uD83C\uDFAF Updating PackageVersionMap..."),await Lw(),console.log("✨ Index and aliases generation completed successfully!");break}case"docs":{let $=w[1]||Bw;console.log(`\uD83D\uDCDA Generating documentation to ${$}...`),await Tw($),console.log("✨ Documentation generation completed successfully!");break}case"all":{if(console.log("\uD83D\uDE80 Generating everything..."),console.log("\uD83D\uDD27 Generating package index..."),!await Ow())console.error("❌ Failed to generate index"),N.exit(1);if(console.log("\uD83C\uDFF7️ Generating aliases..."),!await jw())console.error("❌ Failed to generate aliases"),N.exit(1);console.log("\uD83C\uDFAF Updating PackageVersionMap..."),await Lw();let X=w[1]||Bw;console.log(`\uD83D\uDCDA Generating documentation to ${X}...`),await Tw(X),console.log("✨ All generation completed successfully!");break}default:console.log(`
|
|
261
|
-
Usage: bun run src/generate.ts [command] [options]
|
|
262
|
-
|
|
263
|
-
Commands:
|
|
264
|
-
index Generate package index and aliases (default)
|
|
265
|
-
docs [output-dir] Generate documentation (default: ./docs)
|
|
266
|
-
all [output-dir] Generate everything (index, aliases, and docs)
|
|
267
|
-
|
|
268
|
-
Examples:
|
|
269
|
-
bun run src/generate.ts
|
|
270
|
-
bun run src/generate.ts index
|
|
271
|
-
bun run src/generate.ts docs
|
|
272
|
-
bun run src/generate.ts docs ./custom-docs
|
|
273
|
-
bun run src/generate.ts all
|
|
274
|
-
bun run src/generate.ts all ./custom-docs
|
|
275
|
-
`);break}}catch(w){console.error("\uD83D\uDCA5 Error during generation:",w),N.exit(1)}}var uQ=import.meta.url===`file://${N.argv[1]}`||import.meta.url===`file:///${N.argv[1]}`;if(uQ)NQ();import s from"node:fs";import r from"node:path";import i from"node:process";async function PQ(w,Q={}){let{targetOs:$=i.platform==="darwin"?"darwin":i.platform==="win32"?"windows":"linux",includeOsSpecific:R=!0,maxDepth:X=10,verbose:H=!1}=Q,q=await sw(w,{targetOs:$,includeOsSpecific:R,maxDepth:X,verbose:H}),Z=$w(w),Y=q.allDependencies.map((O)=>({name:O.name,version:O.version,constraint:O.constraint,isOsSpecific:O.isOsSpecific,os:O.os})),J=Z.map((O)=>O.name),z=`pkgx install ${J.join(" ")}`,j=`pantry install ${J.join(" ")}`,T=q.conflicts.map((O)=>{let W=Y.find((G)=>G.name===O.package);return{package:O.package,versions:O.versions,resolved:W?.version||"latest"}});return{packages:Y,directCount:Z.length,totalCount:Y.length,conflicts:T,pkgxCommand:z,pantryCommand:j}}async function i6(w,Q={}){let $=r.join(i.cwd(),`.temp-deps-${Date.now()}.yaml`);try{return s.writeFileSync($,w,"utf-8"),await PQ($,Q)}finally{if(s.existsSync($))s.unlinkSync($)}}async function a6(w,Q={}){let{targetOs:$=i.platform==="darwin"?"darwin":i.platform==="win32"?"windows":"linux",includeOsSpecific:R=!0,maxDepth:X=10}=Q,H=await Rw(w,{targetOs:$,includeOsSpecific:R,maxDepth:X});return H.unshift({name:w,version:"latest",constraint:"*",isOsSpecific:!1}),(await Gw(H,{targetOs:$,includeOsSpecific:R,maxDepth:X})).allDependencies.map((Z)=>({name:Z.name,version:Z.version,constraint:Z.constraint,isOsSpecific:Z.isOsSpecific,os:Z.os}))}function e6(w,Q="pantry"){if(Q==="pkgx")return`pkgx install ${w.join(" ")}`;return`pantry install ${w.join(" ")}`}function w$(w){let Q=[],$=r.join(w,"pantry");try{let H=s.readdirSync($,{withFileTypes:!0});for(let q of H){if(!q.isDirectory())continue;if(q.name.startsWith("@")){let Z=r.join($,q.name);try{let Y=s.readdirSync(Z,{withFileTypes:!0});for(let J of Y){if(!J.isDirectory())continue;let z=`${q.name}/${J.name}`,j=r.join(Z,J.name,"package.json"),T=wQ(j);Q.push({name:z,version:T,isWorkspace:z.startsWith("@stacksjs/"),isScoped:!0})}}catch{}}else{let Z=r.join($,q.name,"package.json"),Y=wQ(Z);Q.push({name:q.name,version:Y,isWorkspace:!1,isScoped:!1})}}}catch{}Q.sort((H,q)=>H.name.localeCompare(q.name));let R=Q.filter((H)=>H.isWorkspace).length,X=Q.length-R;return{packages:Q,thirdPartyCount:X,workspaceCount:R,totalCount:Q.length}}function wQ(w){try{let Q=s.readFileSync(w,"utf-8");return JSON.parse(Q).version||"0.0.0"}catch{return"0.0.0"}}Q6();function $$(w){return w}function R$(w){return w}var X$={baseUrl:"https://dist.pkgx.dev"};function Z$(w){return w}import{execSync as Cw}from"node:child_process";var a=new Set,QQ=!1;function DQ(){if(QQ)return;QQ=!0;let w=()=>{for(let Q of a)try{Cw(`pantry stop ${Q}`,{stdio:"ignore",timeout:1e4})}catch{}a.clear()};process.on("exit",w),process.on("SIGINT",()=>{w(),process.exit(130)}),process.on("SIGTERM",()=>{w(),process.exit(143)})}function Hw(w,Q=!1){let $={encoding:"utf-8",timeout:30000,stdio:Q?"pipe":["pipe","pipe","pipe"]};return Cw(`pantry ${w}`,$)}function hQ(w){let Q=w.match(/Name:\s+(\S+)/)?.[1]??"",$=/Status:\s+running/i.test(w),R=w.match(/Port:\s+(\d+)/),X=w.match(/PID:\s+(\d+)/),H=w.match(/Data Dir:\s+(.+)/);return{name:Q,running:$,port:R?Number.parseInt(R[1],10):null,pid:X?Number.parseInt(X[1],10):null,dataDir:H?H[1].trim():null}}class d{config;_startedByUs=!1;constructor(w){this.config={name:w.name,port:w.port??0,readyTimeoutMs:w.readyTimeoutMs??15000,pollIntervalMs:w.pollIntervalMs??200,quiet:w.quiet??!0}}static isAvailable(){try{return Cw("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let w=Hw(`inspect ${this.config.name}`,!0);return hQ(w)}catch{return{name:this.config.name,running:!1,port:null,pid:null,dataDir:null}}}isRunning(){return this.status().running}getPort(){return this.status().port}async start(){if(DQ(),this.isRunning())return this.status();return Hw(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,a.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{Hw(`stop ${this.config.name}`,this.config.quiet)}catch{}a.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{Hw(`stop ${this.config.name}`,this.config.quiet)}catch{}a.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let w=Date.now()+this.config.readyTimeoutMs;while(Date.now()<w){if(this.isRunning())return;await new Promise((Q)=>setTimeout(Q,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var $Q=new d({name:"postgres"});async function Iw(w){let Q=await $Q.ensureRunning();return{port:w?.port??Q.port??5432,host:w?.host??"localhost",database:w?.database??"postgres",username:w?.username??process.env.USER??"postgres"}}async function Sw(){await $Q.stop()}function vQ(w){let Q=null;return{get connection(){if(!Q)throw Error("Postgres not started. Ensure beforeAll has run.");return Q},beforeAll:async()=>{Q=await Iw(w)},afterAll:async()=>{await Sw(),Q=null}}}async function fQ(w,Q){let $=await Iw(Q);try{return await w($)}finally{if(Q?.stopAfter!==!1)await Sw()}}var RQ=new d({name:"redis"});async function Fw(w){let Q=await RQ.ensureRunning(),$=w?.port??Q.port??6379,R=w?.host??"localhost";return{port:$,host:R,url:`redis://${R}:${$}`}}async function bw(){await RQ.stop()}function kQ(w){let Q=null;return{get connection(){if(!Q)throw Error("Redis not started. Ensure beforeAll has run.");return Q},beforeAll:async()=>{Q=await Fw(w)},afterAll:async()=>{await bw(),Q=null}}}async function dQ(w,Q){let $=await Fw(Q);try{return await w($)}finally{if(Q?.stopAfter!==!1)await bw()}}var XQ=new d({name:"mysql"});async function Aw(w){let Q=await XQ.ensureRunning();return{port:w?.port??Q.port??3306,host:w?.host??"localhost",database:w?.database??"test",username:w?.username??"root"}}async function xw(){await XQ.stop()}function gQ(w){let Q=null;return{get connection(){if(!Q)throw Error("MySQL not started. Ensure beforeAll has run.");return Q},beforeAll:async()=>{Q=await Aw(w)},afterAll:async()=>{await xw(),Q=null}}}async function mQ(w,Q){let $=await Aw(Q);try{return await w($)}finally{if(Q?.stopAfter!==!1)await xw()}}import{existsSync as Vw,mkdirSync as qQ,mkdtempSync as lQ,rmSync as HQ,writeFileSync as cQ}from"node:fs";import{tmpdir as pQ}from"node:os";import{join as yw}from"node:path";var Yw=new Set,ZQ=!1;function oQ(){if(ZQ)return;ZQ=!0;let w=()=>{for(let Q of Yw)try{if(Vw(Q))HQ(Q,{recursive:!0,force:!0})}catch{}Yw.clear()};process.on("exit",w),process.on("SIGINT",()=>{w(),process.exit(130)}),process.on("SIGTERM",()=>{w(),process.exit(143)})}function Nw(w="pantry-test-"){oQ();let Q=lQ(yw(pQ(),w));return Yw.add(Q),Q}function uw(w){Yw.delete(w);try{if(Vw(w))HQ(w,{recursive:!0,force:!0})}catch{}}async function sQ(w,Q){let $=Nw(w);try{return await Q($)}finally{uw($)}}function nQ(w,Q){let $=Nw(w);try{return Q($)}finally{uw($)}}function tQ(w,Q,$){let R=yw(w,Q),X=R.substring(0,R.lastIndexOf("/"));if(X&&!Vw(X))qQ(X,{recursive:!0});return cQ(R,$),R}function rQ(w,Q){let $=yw(w,Q);return qQ($,{recursive:!0}),$}import*as A from"node:fs";import*as y from"node:path";import*as n from"node:os";import*as Pw from"node:https";import*as Dw from"node:http";import{execSync as Ww}from"node:child_process";function iQ(){let w=n.platform(),Q=n.arch();return{os:w==="darwin"?"darwin":w==="win32"?"windows":"linux",arch:Q==="arm64"?"aarch64":"x86_64"}}var Jw={"ziglang.org":{getDownloadUrl(w,Q){let $={x86_64:"x86_64",aarch64:"aarch64"},R={darwin:"macos",linux:"linux",windows:"windows"},X=$[Q.arch],H=R[Q.os],q=Q.os==="windows"?"zip":"tar.xz";if(w.includes("-dev"))return`https://ziglang.org/builds/zig-${X}-${H}-${w}.${q}`;return`https://ziglang.org/download/${w}/zig-${X}-${H}-${w}.${q}`},getArchiveFormat(w){return w.os==="windows"?"zip":"tar.xz"},getBinaries(w){return w.os==="windows"?["zig.exe"]:["zig"]},getArchivePrefix(w,Q){let $={x86_64:"x86_64",aarch64:"aarch64"},R={darwin:"macos",linux:"linux",windows:"windows"};return`zig-${$[Q.arch]}-${R[Q.os]}-${w}`}},"bun.sh":{getDownloadUrl(w,Q){let $={"darwin-aarch64":"darwin-aarch64","darwin-x86_64":"darwin-x64","linux-aarch64":"linux-aarch64","linux-x86_64":"linux-x64","windows-x86_64":"windows-x64"},R=`${Q.os}-${Q.arch}`,X=$[R]||"linux-x64";return`https://github.com/oven-sh/bun/releases/download/bun-v${w}/bun-${X}.zip`},getArchiveFormat(){return"zip"},getBinaries(w){return w.os==="windows"?["bun.exe"]:["bun","bunx"]},getArchivePrefix(w,Q){return{"darwin-aarch64":"bun-darwin-aarch64","darwin-x86_64":"bun-darwin-x64","linux-aarch64":"bun-linux-aarch64","linux-x86_64":"bun-linux-x64","windows-x86_64":"bun-windows-x64"}[`${Q.os}-${Q.arch}`]||"bun-linux-x64"}},"nodejs.org":{getDownloadUrl(w,Q){let $={darwin:"darwin",linux:"linux",windows:"win"},R={x86_64:"x64",aarch64:"arm64"},X=Q.os==="windows"?"zip":"tar.xz";return`https://nodejs.org/dist/v${w}/node-v${w}-${$[Q.os]}-${R[Q.arch]}.${X}`},getArchiveFormat(w){return w.os==="windows"?"zip":"tar.xz"},getBinaries(w){return w.os==="windows"?["node.exe","npm.cmd","npx.cmd"]:["node","npm","npx"]},getArchivePrefix(w,Q){let $={darwin:"darwin",linux:"linux",windows:"win"},R={x86_64:"x64",aarch64:"arm64"};return`node-v${w}-${$[Q.os]}-${R[Q.arch]}`}}};async function aQ(w,Q,$={}){let R=iQ(),X=Jw[w];if(!X)throw Error(`Unknown package: ${w}. Supported: ${Object.keys(Jw).join(", ")}`);let H=$.installDir||y.join(process.cwd(),"pantry"),q=y.join(H,".bin"),Z=y.join(H,w.replace(/\./g,"-"),Q),Y=X.getBinaries(R),J=y.join(Z,Y[0]);if(A.existsSync(J)){if(!$.quiet)console.log(` ✓ ${w}@${Q} (cached)`);return{name:w,version:Q,installPath:Z,binaries:Y}}let z=X.getDownloadUrl(Q,R),j=X.getArchiveFormat(R);if(!$.quiet)console.log(` → ${w}@${Q} from ${new URL(z).hostname}`);let T=A.mkdtempSync(y.join(n.tmpdir(),"pantry-")),O=y.join(T,`archive.${j}`);try{await YQ(z,O);let W=y.join(T,"extracted");A.mkdirSync(W,{recursive:!0}),await eQ(O,W,j);let G=W,_=X.getArchivePrefix?.(Q,R);if(_){let K=y.join(W,_);if(A.existsSync(K))G=K;else{let B=A.readdirSync(W).find((L)=>A.statSync(y.join(W,L)).isDirectory());if(B)G=y.join(W,B)}}if(A.mkdirSync(Z,{recursive:!0}),w6(G,Z),R.os!=="windows")for(let K of Y){let S=y.join(Z,K);if(A.existsSync(S))A.chmodSync(S,493);let B=y.join(Z,"bin",K);if(A.existsSync(B))A.chmodSync(B,493)}if($.createBinLinks!==!1){A.mkdirSync(q,{recursive:!0});let K=null;for(let S of Y){let B=y.join(Z,S);if(!A.existsSync(B))B=y.join(Z,"bin",S);if(!A.existsSync(B)){if(K){let U=y.join(q,S);try{A.unlinkSync(U)}catch{}if(R.os==="windows")A.copyFileSync(K,U);else A.symlinkSync(K,U)}continue}if(!K)K=B;let L=y.join(q,S);try{A.unlinkSync(L)}catch{}if(R.os==="windows")A.copyFileSync(B,L);else A.symlinkSync(B,L)}}if(!$.quiet)console.log(` ✓ ${w}@${Q}`);return{name:w,version:Q,installPath:Z,binaries:Y}}finally{try{A.rmSync(T,{recursive:!0,force:!0})}catch{}}}async function F$(w,Q={}){return Promise.all(w.map(($)=>aQ($.domain,$.version,Q)))}async function b$(w){if(w==="bun.sh")return((await zw("https://api.github.com/repos/oven-sh/bun/releases/latest").catch(()=>null))?.tag_name||"").replace(/^bun-v/,"");if(w==="ziglang.org")return(await zw("https://ziglang.org/download/index.json")).master?.version||"";if(w==="nodejs.org"){let $=await zw("https://nodejs.org/dist/index.json");return($.find((X)=>X.lts)?.version||$[0]?.version||"").replace(/^v/,"")}throw Error(`Cannot resolve latest version for ${w}`)}function YQ(w,Q){return new Promise(($,R)=>{let X=A.createWriteStream(Q);(w.startsWith("https")?Pw.get:Dw.get)(w,(q)=>{if(q.statusCode&&q.statusCode>=300&&q.statusCode<400&&q.headers.location)return X.close(),A.unlinkSync(Q),YQ(q.headers.location,Q).then($,R);if(q.statusCode&&q.statusCode>=400)return X.close(),R(Error(`HTTP ${q.statusCode} downloading ${w}`));q.pipe(X),X.on("finish",()=>{X.close(),$()}),X.on("error",R)}).on("error",(q)=>{X.close(),R(q)})})}async function eQ(w,Q,$){if($==="zip")if(process.platform==="win32")Ww(`powershell -NoProfile -Command "Expand-Archive -Path '${w}' -DestinationPath '${Q}' -Force"`,{stdio:"pipe"});else Ww(`unzip -o -q "${w}" -d "${Q}"`,{stdio:"pipe"});else if($==="tar.xz")Ww(`tar xf "${w}" -C "${Q}"`,{stdio:"pipe"});else if($==="tar.gz")Ww(`tar xzf "${w}" -C "${Q}"`,{stdio:"pipe"});else throw Error(`Unsupported archive format: ${$}`)}function w6(w,Q){A.cpSync(w,Q,{recursive:!0})}function zw(w){return new Promise((Q,$)=>{(w.startsWith("https")?Pw.get:Dw.get)(w,{headers:{"User-Agent":"pantry-installer"}},(X)=>{if(X.statusCode&&X.statusCode>=300&&X.statusCode<400&&X.headers.location)return zw(X.headers.location).then(Q,$);let H="";X.on("data",(q)=>H+=q),X.on("end",()=>{try{Q(JSON.parse(H))}catch(q){$(q)}})}).on("error",$)})}function A$(w){return w in Jw}function x$(){return Object.keys(Jw)}export{vw as a,JQ as b,X6 as c,Z6 as d,q6 as e,fw as f,H6 as g,Y6 as h,W6 as i,z6 as j,e as k,J6 as l,K6 as m,kw as n,U6 as o,G6 as p,_6 as q,B6 as r,O6 as s,M6 as t,C6 as u,I6 as v,S6 as w,F6 as x,b6 as y,A6 as z,x6 as A,V6 as B,y6 as C,N6 as D,u6 as E,$w as F,UQ as G,v6 as H,ow as I,g as J,Rw as K,Gw as L,sw as M,f6 as N,iw as O,CQ as P,IQ as Q,Ow as R,jw as S,Tw as T,Lw as U,PQ as V,i6 as W,a6 as X,e6 as Y,w$ as Z,$$ as _,R$ as $,X$ as aa,Z$ as ba,d as ca,Iw as da,Sw as ea,vQ as fa,fQ as ga,Fw as ha,bw as ia,kQ as ja,dQ as ka,Aw as la,xw as ma,gQ as na,mQ as oa,Nw as pa,uw as qa,sQ as ra,nQ as sa,tQ as ta,rQ as ua,aQ as va,F$ as wa,b$ as xa,A$ as ya,x$ as za};
|