ts-pantry 0.11.52 → 0.11.55
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 +1 -1
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ Received ${r}, cleaning up...`),e)try{await e()}catch(c){console.error("Error du
|
|
|
28
28
|
✗ Command "${e}" not found.
|
|
29
29
|
`)),this.enableDidYouMean){let n=[];for(let c of this.commands){if(c.displayName)n.push(c.displayName);if(c.aliasNames)n.push(...c.aliasNames)}let r=Te(e,n);if(r.length>0)console.log(oe.yellow("Did you mean one of these?")),r.forEach((c)=>console.log(` ${oe.dim("•")} ${this.name} ${c}`)),console.log("")}console.log(oe.dim("Run"),`${this.name} --help`,oe.dim("to see all available commands")),se.exit(1)}async parse(e=Ce,n={}){let{run:r=!0,exitOnError:c=!1}=n;if(c)try{return await this.parse(e,{run:r})}catch(p){throw this.handleUsageError(p),p}if(this.rawArgs=e,!this.name)this.name=e[1]?qe(e[1]):"cli";let u=!0,d=e.slice(2),y=d[0];if(y&&!y.startsWith("-")){for(let p of this.commands)if(p.isMatched(y)){let v=this.mri(d,p);u=!1;let A={...v,args:v.args.slice(1)};this.setParsedInfo(A,p,y),this.emit(`command:${y}`,p);break}}if(u){for(let p of this.commands)if(p.name===""){u=!1;let v=this.mri(d,p);this.setParsedInfo(v,p),this.emit("command:!",p);break}}if(u){let p=this.mri(e.slice(2));this.setParsedInfo(p)}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(),r=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),r=!1,this.unsetMatchedCommand();let w={args:this.args,options:this.options};if(r)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return w}mri(e,n){let r=[...this.globalCommand.options,...n?n.options:[]],c=ze(r),u=[],d=e.indexOf("--");if(d>-1)u=e.slice(d+1),e=e.slice(0,d);let y=Ve(e,c),w={_:y._};for(let C of Object.keys(y))if(C!=="_")w[Ee(C)]=y[C];let p=w._,v={"--":u},A=n&&n.config.ignoreOptionDefaultValue?n.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,N=Object.create(null);for(let C of r){if(!A&&C.config.default!==void 0)for(let _ of C.names)v[_]=C.config.default;if(Array.isArray(C.config.type)){if(N[C.name]===void 0)N[C.name]={shouldTransform:!0,transformFunction:C.config.type[0]}}}for(let C of Object.keys(w))if(C!=="_"){let _=C.split(".");Ue(v,_,w[C]),Ge(v,N)}return{args:p,options:v}}async run(e=Ce){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!(!!e&&typeof e==="object"&&e.name==="ClappError"&&e.isUsageError!==!1))return;let c=e,u=c.message??"command-line error",d=this.name?`${this.name}: `:"",y=/--help/.test(u)?"":`
|
|
30
30
|
Run \`${this.name??"cli"} --help\` for usage.`;se.stderr.write(`${d}${u}${y}
|
|
31
|
-
`),se.exit(c.exitCode??2)}async runMatchedCommand(){let{args:e,options:n,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let c=[];r.args.forEach((w,p)=>{if(w.variadic)c.push(e.slice(p));else c.push(e[p])}),c.push(n);let u={command:r,args:c,options:n};for(let w of r.beforeHooks)await w(u);let d,y=async()=>{let w=r.commandAction.apply(this,c);if(w instanceof Promise)d=await w;else d=w;return d};if(r.middleware.length>0){let w=0,p=async()=>{if(w<r.middleware.length){let v=r.middleware[w++];await v({...u,next:p})}else await y()};await p()}else await y();for(let w of r.afterHooks)await w(u);return d}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return se.removeAllListeners("SIGINT"),se.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 _e{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 n=this.cache.get(e);if(!n){this.misses++;return}if(Date.now()-n.timestamp>n.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,n.value}set(e,n,r=5000){if(!this.enabled)return;this.cache.set(e,{value:n,timestamp:Date.now(),ttl:r})}has(e){if(!this.enabled)return!1;let n=this.cache.get(e);if(!n)return!1;if(Date.now()-n.timestamp>n.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[n,r]of this.cache.entries())if(e-r.timestamp>r.ttl)this.cache.delete(n)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var Qt=new _e;function et(){if("FORCE_COLOR"in ae.env)return ae.env.FORCE_COLOR!=="0";if("NO_COLOR"in ae.env||ae.env.TERM==="dumb")return!1;if(ae.platform==="win32")return!0;return Ie.isatty(1)&&Ie.isatty(2)}var Pe=et();function K(e,n){if(!Pe)return(r)=>r;return(r)=>e+r+n}var tt=K("\x1B[0m","\x1B[0m"),st=K("\x1B[31m","\x1B[39m"),nt=K("\x1B[32m","\x1B[39m"),it=K("\x1B[33m","\x1B[39m"),rt=K("\x1B[34m","\x1B[39m"),ot=K("\x1B[35m","\x1B[39m"),at=K("\x1B[36m","\x1B[39m"),lt=K("\x1B[37m","\x1B[39m"),ct=K("\x1B[90m","\x1B[39m"),ut=K("\x1B[1m","\x1B[22m"),ht=K("\x1B[3m","\x1B[23m"),dt=K("\x1B[4m","\x1B[24m"),pt=K("\x1B[2m","\x1B[22m"),ft=K("\x1B[7m","\x1B[27m"),mt=K("\x1B[8m","\x1B[28m"),gt=K("\x1B[9m","\x1B[29m"),yt=K("\x1B[41m","\x1B[49m"),$t=K("\x1B[42m","\x1B[49m"),bt=K("\x1B[43m","\x1B[49m"),wt=K("\x1B[44m","\x1B[49m"),vt=K("\x1B[45m","\x1B[49m"),xt=K("\x1B[46m","\x1B[49m"),St=K("\x1B[47m","\x1B[49m"),kt=Pe,Ct={reset:tt,red:st,green:nt,yellow:it,blue:rt,magenta:ot,cyan:at,white:lt,gray:ct,bold:ut,italic:ht,underline:dt,dim:pt,inverse:ft,hidden:mt,strikethrough:gt,bgRed:yt,bgGreen:$t,bgYellow:bt,bgBlue:wt,bgMagenta:vt,bgCyan:xt,bgWhite:St,isColorSupported:kt},It=Ct,Et=["up","down","left","right","space","enter","cancel"],rs={actions:new Set(Et),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var os=Ot.platform.startsWith("win"),as=Symbol("clapp:cancel");var Tt=He();var W=(e,n)=>Tt?e:n,ls=W("◆","*"),cs=W("■","x"),us=W("▲","x"),hs=W("◇","o"),ds=W("┌","T"),At=W("│","|"),ps=W("└","—"),fs=W("●",">"),ms=W("○"," "),gs=W("◻","[•]"),ys=W("◼","[+]"),$s=W("◻","[ ]"),bs=W("▪","•"),ws=W("─","-"),vs=W("╮","+"),xs=W("├","+"),Ss=W("╯","+"),ks=W("●","•"),Cs=W("◆","*"),Is=W("▲","!"),Os=W("■","x");var Es={light:W("─","-"),heavy:W("━","="),block:W("█","#")};function _t(){return`${It.gray(At)} `}var Ts=_t();var je="0.11.
|
|
31
|
+
`),se.exit(c.exitCode??2)}async runMatchedCommand(){let{args:e,options:n,matchedCommand:r}=this;if(!r||!r.commandAction)return;r.checkUnknownOptions(),r.checkOptionValue(),r.checkRequiredArgs();let c=[];r.args.forEach((w,p)=>{if(w.variadic)c.push(e.slice(p));else c.push(e[p])}),c.push(n);let u={command:r,args:c,options:n};for(let w of r.beforeHooks)await w(u);let d,y=async()=>{let w=r.commandAction.apply(this,c);if(w instanceof Promise)d=await w;else d=w;return d};if(r.middleware.length>0){let w=0,p=async()=>{if(w<r.middleware.length){let v=r.middleware[w++];await v({...u,next:p})}else await y()};await p()}else await y();for(let w of r.afterHooks)await w(u);return d}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return se.removeAllListeners("SIGINT"),se.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 _e{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 n=this.cache.get(e);if(!n){this.misses++;return}if(Date.now()-n.timestamp>n.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,n.value}set(e,n,r=5000){if(!this.enabled)return;this.cache.set(e,{value:n,timestamp:Date.now(),ttl:r})}has(e){if(!this.enabled)return!1;let n=this.cache.get(e);if(!n)return!1;if(Date.now()-n.timestamp>n.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[n,r]of this.cache.entries())if(e-r.timestamp>r.ttl)this.cache.delete(n)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var Qt=new _e;function et(){if("FORCE_COLOR"in ae.env)return ae.env.FORCE_COLOR!=="0";if("NO_COLOR"in ae.env||ae.env.TERM==="dumb")return!1;if(ae.platform==="win32")return!0;return Ie.isatty(1)&&Ie.isatty(2)}var Pe=et();function K(e,n){if(!Pe)return(r)=>r;return(r)=>e+r+n}var tt=K("\x1B[0m","\x1B[0m"),st=K("\x1B[31m","\x1B[39m"),nt=K("\x1B[32m","\x1B[39m"),it=K("\x1B[33m","\x1B[39m"),rt=K("\x1B[34m","\x1B[39m"),ot=K("\x1B[35m","\x1B[39m"),at=K("\x1B[36m","\x1B[39m"),lt=K("\x1B[37m","\x1B[39m"),ct=K("\x1B[90m","\x1B[39m"),ut=K("\x1B[1m","\x1B[22m"),ht=K("\x1B[3m","\x1B[23m"),dt=K("\x1B[4m","\x1B[24m"),pt=K("\x1B[2m","\x1B[22m"),ft=K("\x1B[7m","\x1B[27m"),mt=K("\x1B[8m","\x1B[28m"),gt=K("\x1B[9m","\x1B[29m"),yt=K("\x1B[41m","\x1B[49m"),$t=K("\x1B[42m","\x1B[49m"),bt=K("\x1B[43m","\x1B[49m"),wt=K("\x1B[44m","\x1B[49m"),vt=K("\x1B[45m","\x1B[49m"),xt=K("\x1B[46m","\x1B[49m"),St=K("\x1B[47m","\x1B[49m"),kt=Pe,Ct={reset:tt,red:st,green:nt,yellow:it,blue:rt,magenta:ot,cyan:at,white:lt,gray:ct,bold:ut,italic:ht,underline:dt,dim:pt,inverse:ft,hidden:mt,strikethrough:gt,bgRed:yt,bgGreen:$t,bgYellow:bt,bgBlue:wt,bgMagenta:vt,bgCyan:xt,bgWhite:St,isColorSupported:kt},It=Ct,Et=["up","down","left","right","space","enter","cancel"],rs={actions:new Set(Et),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var os=Ot.platform.startsWith("win"),as=Symbol("clapp:cancel");var Tt=He();var W=(e,n)=>Tt?e:n,ls=W("◆","*"),cs=W("■","x"),us=W("▲","x"),hs=W("◇","o"),ds=W("┌","T"),At=W("│","|"),ps=W("└","—"),fs=W("●",">"),ms=W("○"," "),gs=W("◻","[•]"),ys=W("◼","[+]"),$s=W("◻","[ ]"),bs=W("▪","•"),ws=W("─","-"),vs=W("╮","+"),xs=W("├","+"),Ss=W("╯","+"),ks=W("●","•"),Cs=W("◆","*"),Is=W("▲","!"),Os=W("■","x");var Es={light:W("─","-"),heavy:W("━","="),block:W("█","#")};function _t(){return`${It.gray(At)} `}var Ts=_t();var je="0.11.55";h();async function jt(e="src/pantry"){if(!T.existsSync(e))throw Error(`Pantry directory not found: ${e}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let n=[];function r(c,u=""){let d=T.readdirSync(c,{withFileTypes:!0}),y=M.join(c,"package.yml");if(u&&T.existsSync(y))n.push(u);for(let w of d)if(w.isDirectory()&&!w.name.startsWith(".")){let p=u?`${u}/${w.name}`:w.name,v=M.join(c,w.name);r(v,p)}}return r(e),console.log(`\uD83D\uDCE6 Found ${n.length} packages in local pantry`),n.sort()}async function Dt(e=!1){async function n(y){let w=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(w.searchParams.set("list-type","2"),w.searchParams.set("prefix",""),w.searchParams.set("max-keys","1000"),y)w.searchParams.set("continuation-token",y);let p=await fetch(w.toString());if(!p.ok)throw Error(`Failed to fetch S3 listing: ${p.status}`);let v=await p.text(),A=[],N=v.match(/<Key>([^<]+)<\/Key>/g);if(N)for(let J of N){let Y=J.replace(/<Key>([^<]+)<\/Key>/,"$1");A.push({Key:Y})}let C=v.includes("<IsTruncated>true</IsTruncated>"),_=v.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),B=_?_[1]:void 0;return{IsTruncated:C,NextContinuationToken:B,Contents:A}}console.log("Scraping packages from S3 registry...");let r=new Set,c;do{let y=await n(c);for(let w of y.Contents){let p=w.Key,v=p.split("/");if(v.length===0)continue;if(v[0].startsWith(".")||v[0].includes(" ")||p.match(/\.(md|txt|yml|yaml|json)$/i))continue;let A=["darwin","linux","windows"],N=-1;for(let C=1;C<v.length;C++)if(A.includes(v[C])){N=C;break}if(N>0){let C=v.slice(0,N).join("/");if(C.includes("."))r.add(C)}else if(v.length>=2&&v[0].includes(".")&&!v[1].startsWith("v")&&!v[1].match(/^\d/)){let C=`${v[0]}/${v[1]}`;r.add(C)}else if(v.length>=1&&v[0].includes("."))r.add(v[0])}c=y.NextContinuationToken,console.log(`Found ${r.size} packages so far...`)}while(c);let u=Array.from(r).sort(),d=[];for(let y of u){if(!y.includes(".")||y.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(y.endsWith("/README.rst")||y.endsWith("/README")||y.includes("/docs/"))continue;if(y.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(y))continue;d.push(y)}return console.log(`\uD83D\uDCE6 Found ${d.length} valid packages in registry`),d}async function Bt(e,n){let c=`/**
|
|
32
32
|
* Constants used throughout the ts-pantry package
|
|
33
33
|
* This file is auto-generated from ${n}. Do not edit manually.
|
|
34
34
|
* Generated on ${new Date().toISOString()}
|
package/package.json
CHANGED