ts-pantry 0.11.47 → 0.11.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/bin/cli.js CHANGED
@@ -28,7 +28,7 @@ Received ${s}, cleaning up...`),e)try{await e()}catch(n){console.error("Error du
28
28
  ✗ Command "${e}" not found.
29
29
  `)),this.enableDidYouMean){let t=[];for(let n of this.commands){if(n.displayName)t.push(n.displayName);if(n.aliasNames)t.push(...n.aliasNames)}let s=$e(e,t);if(s.length>0)console.log(R.yellow("Did you mean one of these?")),s.forEach((n)=>console.log(` ${R.dim("•")} ${this.name} ${n}`)),console.log("")}console.log(R.dim("Run"),`${this.name} --help`,R.dim("to see all available commands")),j.exit(1)}async parse(e=fe,t={}){let{run:s=!0,exitOnError:n=!1}=t;if(n)try{return await this.parse(e,{run:s})}catch(o){throw this.handleUsageError(o),o}if(this.rawArgs=e,!this.name)this.name=e[1]?tt(e[1]):"cli";let i=!0,r=e.slice(2),a=r[0];if(a&&!a.startsWith("-")){for(let o of this.commands)if(o.isMatched(a)){let c=this.mri(r,o);i=!1;let p={...c,args:c.args.slice(1)};this.setParsedInfo(p,o,a),this.emit(`command:${a}`,o);break}}if(i){for(let o of this.commands)if(o.name===""){i=!1;let c=this.mri(r,o);this.setParsedInfo(c,o),this.emit("command:!",o);break}}if(i){let o=this.mri(e.slice(2));this.setParsedInfo(o)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji!==void 0)this.useEmoji=!this.options.noEmoji;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache!==void 0)this.isNoCache=Boolean(this.options.noCache);if(this.options.help&&this.showHelpOnExit)this.outputHelp(),s=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),s=!1,this.unsetMatchedCommand();let l={args:this.args,options:this.options};if(s)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return l}mri(e,t){let s=[...this.globalCommand.options,...t?t.options:[]],n=Ze(s),i=[],r=e.indexOf("--");if(r>-1)i=e.slice(r+1),e=e.slice(0,r);let a=Je(e,n),l={_:a._};for(let h of Object.keys(a))if(h!=="_")l[ye(h)]=a[h];let o=l._,c={"--":i},p=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,g=Object.create(null);for(let h of s){if(!p&&h.config.default!==void 0)for(let f of h.names)c[f]=h.config.default;if(Array.isArray(h.config.type)){if(g[h.name]===void 0)g[h.name]={shouldTransform:!0,transformFunction:h.config.type[0]}}}for(let h of Object.keys(l))if(h!=="_"){let f=h.split(".");Qe(c,f,l[h]),et(c,g)}return{args:o,options:c}}async run(e=fe){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!(!!e&&typeof e==="object"&&e.name==="ClappError"&&e.isUsageError!==!1))return;let n=e,i=n.message??"command-line error",r=this.name?`${this.name}: `:"",a=/--help/.test(i)?"":`
30
30
  Run \`${this.name??"cli"} --help\` for usage.`;j.stderr.write(`${r}${i}${a}
31
- `),j.exit(n.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];s.args.forEach((l,o)=>{if(l.variadic)n.push(e.slice(o));else n.push(e[o])}),n.push(t);let i={command:s,args:n,options:t};for(let l of s.beforeHooks)await l(i);let r,a=async()=>{let l=s.commandAction.apply(this,n);if(l instanceof Promise)r=await l;else r=l;return r};if(s.middleware.length>0){let l=0,o=async()=>{if(l<s.middleware.length){let c=s.middleware[l++];await c({...i,next:o})}else await a()};await o()}else await a();for(let l of s.afterHooks)await l(i);return r}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return j.removeAllListeners("SIGINT"),j.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class we{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var cs=new we;function ct(){if("FORCE_COLOR"in L.env)return L.env.FORCE_COLOR!=="0";if("NO_COLOR"in L.env||L.env.TERM==="dumb")return!1;if(L.platform==="win32")return!0;return me.isatty(1)&&me.isatty(2)}var ve=ct();function C(e,t){if(!ve)return(s)=>s;return(s)=>e+s+t}var ut=C("\x1B[0m","\x1B[0m"),ht=C("\x1B[31m","\x1B[39m"),dt=C("\x1B[32m","\x1B[39m"),pt=C("\x1B[33m","\x1B[39m"),ft=C("\x1B[34m","\x1B[39m"),mt=C("\x1B[35m","\x1B[39m"),gt=C("\x1B[36m","\x1B[39m"),yt=C("\x1B[37m","\x1B[39m"),$t=C("\x1B[90m","\x1B[39m"),bt=C("\x1B[1m","\x1B[22m"),wt=C("\x1B[3m","\x1B[23m"),vt=C("\x1B[4m","\x1B[24m"),xt=C("\x1B[2m","\x1B[22m"),St=C("\x1B[7m","\x1B[27m"),kt=C("\x1B[8m","\x1B[28m"),Ct=C("\x1B[9m","\x1B[29m"),It=C("\x1B[41m","\x1B[49m"),Ot=C("\x1B[42m","\x1B[49m"),Et=C("\x1B[43m","\x1B[49m"),Tt=C("\x1B[44m","\x1B[49m"),At=C("\x1B[45m","\x1B[49m"),_t=C("\x1B[46m","\x1B[49m"),Pt=C("\x1B[47m","\x1B[49m"),jt=ve,Dt={reset:ut,red:ht,green:dt,yellow:pt,blue:ft,magenta:mt,cyan:gt,white:yt,gray:$t,bold:bt,italic:wt,underline:vt,dim:xt,inverse:St,hidden:kt,strikethrough:Ct,bgRed:It,bgGreen:Ot,bgYellow:Et,bgBlue:Tt,bgMagenta:At,bgCyan:_t,bgWhite:Pt,isColorSupported:jt},Bt=Dt,Mt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Mt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Nt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Rt=st();var S=(e,t)=>Rt?e:t,$s=S("◆","*"),bs=S("■","x"),ws=S("▲","x"),vs=S("◇","o"),xs=S("┌","T"),Lt=S("│","|"),Ss=S("└","—"),ks=S("●",">"),Cs=S("○"," "),Is=S("◻","[•]"),Os=S("◼","[+]"),Es=S("◻","[ ]"),Ts=S("▪","•"),As=S("─","-"),_s=S("╮","+"),Ps=S("├","+"),js=S("╯","+"),Ds=S("●","•"),Bs=S("◆","*"),Ns=S("▲","!"),Ms=S("■","x");var Rs={light:S("─","-"),heavy:S("━","="),block:S("█","#")};function Vt(){return`${Bt.gray(Lt)} `}var Ls=Vt();var xe="0.11.47";zt();async function Wt(e="src/pantry"){if(!d.existsSync(e))throw Error(`Pantry directory not found: ${e}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let t=[];function s(n,i=""){let r=d.readdirSync(n,{withFileTypes:!0}),a=y.join(n,"package.yml");if(i&&d.existsSync(a))t.push(i);for(let l of r)if(l.isDirectory()&&!l.name.startsWith(".")){let o=i?`${i}/${l.name}`:l.name,c=y.join(n,l.name);s(c,o)}}return s(e),console.log(`\uD83D\uDCE6 Found ${t.length} packages in local pantry`),t.sort()}async function Ut(e=!1){async function t(a){let l=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(l.searchParams.set("list-type","2"),l.searchParams.set("prefix",""),l.searchParams.set("max-keys","1000"),a)l.searchParams.set("continuation-token",a);let o=await fetch(l.toString());if(!o.ok)throw Error(`Failed to fetch S3 listing: ${o.status}`);let c=await o.text(),p=[],g=c.match(/<Key>([^<]+)<\/Key>/g);if(g)for(let I of g){let O=I.replace(/<Key>([^<]+)<\/Key>/,"$1");p.push({Key:O})}let h=c.includes("<IsTruncated>true</IsTruncated>"),f=c.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),m=f?f[1]:void 0;return{IsTruncated:h,NextContinuationToken:m,Contents:p}}console.log("Scraping packages from S3 registry...");let s=new Set,n;do{let a=await t(n);for(let l of a.Contents){let o=l.Key,c=o.split("/");if(c.length===0)continue;if(c[0].startsWith(".")||c[0].includes(" ")||o.match(/\.(md|txt|yml|yaml|json)$/i))continue;let p=["darwin","linux","windows"],g=-1;for(let h=1;h<c.length;h++)if(p.includes(c[h])){g=h;break}if(g>0){let h=c.slice(0,g).join("/");if(h.includes("."))s.add(h)}else if(c.length>=2&&c[0].includes(".")&&!c[1].startsWith("v")&&!c[1].match(/^\d/)){let h=`${c[0]}/${c[1]}`;s.add(h)}else if(c.length>=1&&c[0].includes("."))s.add(c[0])}n=a.NextContinuationToken,console.log(`Found ${s.size} packages so far...`)}while(n);let i=Array.from(s).sort(),r=[];for(let a of i){if(!a.includes(".")||a.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(a.endsWith("/README.rst")||a.endsWith("/README")||a.includes("/docs/"))continue;if(a.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(a))continue;r.push(a)}return console.log(`\uD83D\uDCE6 Found ${r.length} valid packages in registry`),r}async function Gt(e,t){let n=`/**
31
+ `),j.exit(n.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:s}=this;if(!s||!s.commandAction)return;s.checkUnknownOptions(),s.checkOptionValue(),s.checkRequiredArgs();let n=[];s.args.forEach((l,o)=>{if(l.variadic)n.push(e.slice(o));else n.push(e[o])}),n.push(t);let i={command:s,args:n,options:t};for(let l of s.beforeHooks)await l(i);let r,a=async()=>{let l=s.commandAction.apply(this,n);if(l instanceof Promise)r=await l;else r=l;return r};if(s.middleware.length>0){let l=0,o=async()=>{if(l<s.middleware.length){let c=s.middleware[l++];await c({...i,next:o})}else await a()};await o()}else await a();for(let l of s.afterHooks)await l(i);return r}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return j.removeAllListeners("SIGINT"),j.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class we{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,s=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:s})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,s]of this.cache.entries())if(e-s.timestamp>s.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var cs=new we;function ct(){if("FORCE_COLOR"in L.env)return L.env.FORCE_COLOR!=="0";if("NO_COLOR"in L.env||L.env.TERM==="dumb")return!1;if(L.platform==="win32")return!0;return me.isatty(1)&&me.isatty(2)}var ve=ct();function C(e,t){if(!ve)return(s)=>s;return(s)=>e+s+t}var ut=C("\x1B[0m","\x1B[0m"),ht=C("\x1B[31m","\x1B[39m"),dt=C("\x1B[32m","\x1B[39m"),pt=C("\x1B[33m","\x1B[39m"),ft=C("\x1B[34m","\x1B[39m"),mt=C("\x1B[35m","\x1B[39m"),gt=C("\x1B[36m","\x1B[39m"),yt=C("\x1B[37m","\x1B[39m"),$t=C("\x1B[90m","\x1B[39m"),bt=C("\x1B[1m","\x1B[22m"),wt=C("\x1B[3m","\x1B[23m"),vt=C("\x1B[4m","\x1B[24m"),xt=C("\x1B[2m","\x1B[22m"),St=C("\x1B[7m","\x1B[27m"),kt=C("\x1B[8m","\x1B[28m"),Ct=C("\x1B[9m","\x1B[29m"),It=C("\x1B[41m","\x1B[49m"),Ot=C("\x1B[42m","\x1B[49m"),Et=C("\x1B[43m","\x1B[49m"),Tt=C("\x1B[44m","\x1B[49m"),At=C("\x1B[45m","\x1B[49m"),_t=C("\x1B[46m","\x1B[49m"),Pt=C("\x1B[47m","\x1B[49m"),jt=ve,Dt={reset:ut,red:ht,green:dt,yellow:pt,blue:ft,magenta:mt,cyan:gt,white:yt,gray:$t,bold:bt,italic:wt,underline:vt,dim:xt,inverse:St,hidden:kt,strikethrough:Ct,bgRed:It,bgGreen:Ot,bgYellow:Et,bgBlue:Tt,bgMagenta:At,bgCyan:_t,bgWhite:Pt,isColorSupported:jt},Bt=Dt,Mt=["up","down","left","right","space","enter","cancel"],ms={actions:new Set(Mt),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var gs=Nt.platform.startsWith("win"),ys=Symbol("clapp:cancel");var Rt=st();var S=(e,t)=>Rt?e:t,$s=S("◆","*"),bs=S("■","x"),ws=S("▲","x"),vs=S("◇","o"),xs=S("┌","T"),Lt=S("│","|"),Ss=S("└","—"),ks=S("●",">"),Cs=S("○"," "),Is=S("◻","[•]"),Os=S("◼","[+]"),Es=S("◻","[ ]"),Ts=S("▪","•"),As=S("─","-"),_s=S("╮","+"),Ps=S("├","+"),js=S("╯","+"),Ds=S("●","•"),Bs=S("◆","*"),Ns=S("▲","!"),Ms=S("■","x");var Rs={light:S("─","-"),heavy:S("━","="),block:S("█","#")};function Vt(){return`${Bt.gray(Lt)} `}var Ls=Vt();var xe="0.11.50";zt();async function Wt(e="src/pantry"){if(!d.existsSync(e))throw Error(`Pantry directory not found: ${e}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let t=[];function s(n,i=""){let r=d.readdirSync(n,{withFileTypes:!0}),a=y.join(n,"package.yml");if(i&&d.existsSync(a))t.push(i);for(let l of r)if(l.isDirectory()&&!l.name.startsWith(".")){let o=i?`${i}/${l.name}`:l.name,c=y.join(n,l.name);s(c,o)}}return s(e),console.log(`\uD83D\uDCE6 Found ${t.length} packages in local pantry`),t.sort()}async function Ut(e=!1){async function t(a){let l=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(l.searchParams.set("list-type","2"),l.searchParams.set("prefix",""),l.searchParams.set("max-keys","1000"),a)l.searchParams.set("continuation-token",a);let o=await fetch(l.toString());if(!o.ok)throw Error(`Failed to fetch S3 listing: ${o.status}`);let c=await o.text(),p=[],g=c.match(/<Key>([^<]+)<\/Key>/g);if(g)for(let I of g){let O=I.replace(/<Key>([^<]+)<\/Key>/,"$1");p.push({Key:O})}let h=c.includes("<IsTruncated>true</IsTruncated>"),f=c.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),m=f?f[1]:void 0;return{IsTruncated:h,NextContinuationToken:m,Contents:p}}console.log("Scraping packages from S3 registry...");let s=new Set,n;do{let a=await t(n);for(let l of a.Contents){let o=l.Key,c=o.split("/");if(c.length===0)continue;if(c[0].startsWith(".")||c[0].includes(" ")||o.match(/\.(md|txt|yml|yaml|json)$/i))continue;let p=["darwin","linux","windows"],g=-1;for(let h=1;h<c.length;h++)if(p.includes(c[h])){g=h;break}if(g>0){let h=c.slice(0,g).join("/");if(h.includes("."))s.add(h)}else if(c.length>=2&&c[0].includes(".")&&!c[1].startsWith("v")&&!c[1].match(/^\d/)){let h=`${c[0]}/${c[1]}`;s.add(h)}else if(c.length>=1&&c[0].includes("."))s.add(c[0])}n=a.NextContinuationToken,console.log(`Found ${s.size} packages so far...`)}while(n);let i=Array.from(s).sort(),r=[];for(let a of i){if(!a.includes(".")||a.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(a.endsWith("/README.rst")||a.endsWith("/README")||a.includes("/docs/"))continue;if(a.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(a))continue;r.push(a)}return console.log(`\uD83D\uDCE6 Found ${r.length} valid packages in registry`),r}async function Gt(e,t){let n=`/**
32
32
  * Constants used throughout the ts-pantry package
33
33
  * This file is auto-generated from ${t}. Do not edit manually.
34
34
  * Generated on ${new Date().toISOString()}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ts-pantry",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.11.47",
5
+ "version": "0.11.50",
6
6
  "description": "A library & CLI for managing packages",
7
7
  "author": "Chris Breuer <chris@stacksjs.com>",
8
8
  "license": "MIT",