ts-pantry 0.10.36 → 0.10.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Da as c6,Ea as n6,Ga as l6,Ja as p6,L as C6,La as r6,M as S6,N as v6,P as y6,V as k6,W as h6,X as _6,Y as g6,Z as f6,ba as G6,ca as u6,da as i6}from"../chunk-
|
|
2
|
+
import{Da as c6,Ea as n6,Ga as l6,Ja as p6,L as C6,La as r6,M as S6,N as v6,P as y6,V as k6,W as h6,X as _6,Y as g6,Z as f6,ba as G6,ca as u6,da as i6}from"../chunk-rt8p2q09.js";import"../chunk-g61kvyjq.js";import"../chunk-45tts066.js";import"../chunk-bhf1p3a4.js";import{Ab as U6,nb as p,ob as m6,qb as X6,rb as r,wb as d6}from"../chunk-t3pfbk3v.js";import"../chunk-vxknhv2t.js";import"../chunk-mwn9pf2y.js";import{Sb as l,Tb as q6,Ub as J6}from"../chunk-pjs4pxq8.js";import"../chunk-gvacxb4c.js";import"../chunk-g1j4y6h5.js";import{mc as P6,nc as Q4}from"../chunk-99dpbye7.js";import{rc as h}from"../chunk-2f67zesz.js";import V from"node:fs";import B from"node:path";import H from"node:process";import{existsSync as t6}from"node:fs";import a from"node:fs/promises";import K6 from"node:os";import s from"node:path";import k from"node:process";import{EventEmitter as o6}from"node:events";import v from"node:process";import V6 from"node:process";import z6 from"node:process";import u from"node:process";import f from"node:process";import L6 from"node:tty";import fz,{stdin as E4,stdout as x4}from"node:process";import M6,{stdin as uz,stdout as iz}from"node:process";import cz from"node:readline";class B6{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let z=K6.homedir(),$=s.join(z,".config","clapp");this.configPath=s.join($,"telemetry.json")}async isEnabled(){if(k.env.DO_NOT_TRACK==="1"||k.env.DO_NOT_TRACK==="true")return!1;if(k.env.NO_TELEMETRY==="1"||k.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let z=await this.loadConfig();if(z.enabled=!0,!z.userId)z.userId=this.generateUserId();await this.saveConfig(z)}async disable(){let z=await this.loadConfig();z.enabled=!1,await this.saveConfig(z)}async track(z,$){if(!await this.isEnabled())return;let Z={event:z,...$,timestamp:Date.now(),platform:K6.platform(),nodeVersion:k.version};if(this.events.push(Z),this.events.length>=10)await this.send()}async trackCommand(z,$){await this.track("command",{command:z,duration:$})}async trackError(z,$){await this.track("error",{error:z,command:$})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let $=await this.loadConfig();return $.lastSent=Date.now(),await this.saveConfig($),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let $=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep($),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(z){return new Promise(($)=>setTimeout($,z))}async status(){let z=await this.loadConfig();return{enabled:z.enabled,doNotTrack:k.env.DO_NOT_TRACK==="1"||k.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(t6(this.configPath)){let z=await a.readFile(this.configPath,"utf-8");return this.config=JSON.parse(z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(z){this.config=z;try{let $=s.dirname(this.configPath);await a.mkdir($,{recursive:!0}),await a.writeFile(this.configPath,JSON.stringify(z,null,2),"utf-8")}catch{}}generateUserId(){let z=Math.random().toString(36).substring(2,15),$=Date.now().toString(36);return`${z}-${$}`}}var V4=new B6;function e6(z,$={}){let Q={_:[]},Z=$.alias||{},Y=new Set($.boolean||[]),q={};for(let U of Object.keys(Z))for(let X of Z[U])q[X]=U;for(let U of Y)if(Z[U])for(let X of Z[U])Y.add(X);function J(U,X){let G=q[U]||U;if(Q[G]=X,Z[G])for(let K of Z[G])Q[K]=X;if(q[U]&&Z[q[U]])for(let K of Z[q[U]])Q[K]=X;Q[U]=X}for(let U=0;U<z.length;U++){let X=z[U];if(X==="--"){Q._.push(...z.slice(U+1));break}if(X.startsWith("--")){let G=X.indexOf("=");if(G!==-1){let K=X.slice(2,G),W=X.slice(G+1);J(K,W)}else{let K=X.slice(2);if(K.startsWith("no-")){let j=K.slice(3);J(j,!1);continue}let W=q[K]||K;if(Y.has(W)||Y.has(K))J(K,!0);else{let j=z[U+1];if(j!==void 0&&!j.startsWith("-"))J(K,j),U++;else J(K,!0)}}}else if(X.startsWith("-")&&X.length>1){let G=X.slice(1);for(let K=0;K<G.length;K++){let W=G[K],j=q[W]||W;if(K===G.length-1&&!Y.has(j)&&!Y.has(W)){let F=z[U+1];if(F!==void 0&&!F.startsWith("-"))J(W,F),U++;else J(W,!0)}else J(W,!0)}}else Q._.push(X)}return Q}function e(z){return z.replace(/[<[].+/,"").trim()}function zz(z){let $=/<([^>]+)>/g,Q=/\[([^\]]+)\]/g,Z=[],Y=(U)=>{let X=!1,G=U[1];if(G.startsWith("..."))G=G.slice(3),X=!0;return{required:U[0].startsWith("<"),value:G,variadic:X}},q;while(q=$.exec(z))Z.push(Y(q));let J;while(J=Q.exec(z))Z.push(Y(J));return Z}function $z(z){let $={alias:{},boolean:[]};for(let[Q,Z]of z.entries()){if(Z.names.length>1)$.alias[Z.names[0]]=Z.names.slice(1);if(Z.isBoolean)if(Z.negated){if(!z.some((q,J)=>{return J!==Q&&q.names.some((U)=>Z.names.includes(U))&&typeof q.required==="boolean"}))$.boolean.push(Z.names[0])}else $.boolean.push(Z.names[0])}return $}function F6(z){return z.reduce(($,Q)=>$.length>=Q.length?$:Q,"")}function t(z,$){return z.length>=$?z:`${z}${" ".repeat($-z.length)}`}function Qz(z){return z.replace(/([a-z])-([a-z])/g,($,Q,Z)=>{return Q+Z.toUpperCase()})}function Zz(z,$,Q){let Z=0,Y=$.length,q=z,J;for(;Z<Y;++Z)J=q[$[Z]],q=q[$[Z]]=Z===Y-1?Q:J!=null?J:!!~$[Z+1].indexOf(".")||!(+$[Z+1]>-1)?{}:[]}function Yz(z,$){for(let Q of Object.keys($)){let Z=$[Q];if(Z.shouldTransform){if(z[Q]=Array.prototype.concat.call([],z[Q]),typeof Z.transformFunction==="function")z[Q]=z[Q].map(Z.transformFunction)}}}function qz(z){let $=/([^\\/]+)$/.exec(z);return $?$[1]:""}function N6(z){return z.split(".").map(($,Q)=>{return Q===0?Qz($):$}).join(".")}class d extends Error{exitCode=2;isUsageError=!0;constructor(z){super(z);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(z).stack}format(z=!1){if(z&&this.stack)return`${this.message}
|
|
3
3
|
|
|
4
4
|
Stack trace:
|
|
5
5
|
${this.stack}`;return this.message}}function Jz(){let{env:z}=V6,{TERM:$,TERM_PROGRAM:Q}=z;if(V6.platform!=="win32")return $!=="linux";return Boolean(z.WT_SESSION)||Boolean(z.TERMINUS_SUBLIME)||z.ConEmuTask==="{cmd::Cmder}"||Q==="Terminus-Sublime"||Q==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var n="\x1B",x=`${n}[`;var S={to(z,$){if(!$)return`${x}${z+1}G`;return`${x}${$+1};${z+1}H`},move(z,$){let Q="";if(z<0)Q+=`${x}${-z}D`;else if(z>0)Q+=`${x}${z}C`;if($<0)Q+=`${x}${-$}A`;else if($>0)Q+=`${x}${$}B`;return Q},up:(z=1)=>`${x}${z}A`,down:(z=1)=>`${x}${z}B`,forward:(z=1)=>`${x}${z}C`,backward:(z=1)=>`${x}${z}D`,nextLine:(z=1)=>`${x}E`.repeat(z),prevLine:(z=1)=>`${x}F`.repeat(z),left:`${x}G`,hide:`${x}?25l`,show:`${x}?25h`,save:`${n}7`,restore:`${n}8`};var o={screen:`${x}2J`,up:(z=1)=>`${x}1J`.repeat(z),down:(z=1)=>`${x}J`.repeat(z),line:`${x}2K`,lineEnd:`${x}K`,lineStart:`${x}1K`,lines(z){let $="";for(let Q=0;Q<z;Q++)$+=this.line+(Q<z-1?S.up():"");if(z)$+=S.left;return $}},w4={screen:`${n}c`};function Xz(z,$){let Q=[];for(let Z=0;Z<=$.length;Z++)Q[Z]=[Z];for(let Z=0;Z<=z.length;Z++)Q[0][Z]=Z;for(let Z=1;Z<=$.length;Z++)for(let Y=1;Y<=z.length;Y++)if($.charAt(Z-1)===z.charAt(Y-1))Q[Z][Y]=Q[Z-1][Y-1];else Q[Z][Y]=Math.min(Q[Z-1][Y-1]+1,Q[Z][Y-1]+1,Q[Z-1][Y]+1);return Q[$.length][z.length]}function b6(z,$,Q=2,Z=3){return $.map((Y)=>({cmd:Y,distance:Xz(z,Y)})).filter(({distance:Y})=>Y<=Q).sort((Y,q)=>Y.distance-q.distance).slice(0,Z).map(({cmd:Y})=>Y)}class D6{rawName;description;name;names;isBoolean;required;config;negated;constructor(z,$,Q){if(this.rawName=z,this.description=$,this.config=Object.assign({},Q),z=z.replace(/\.\*/g,""),this.negated=!1,this.names=e(z).split(",").map((Z)=>{let Y=Z.trim().replace(/^-{1,2}/,"");if(Y.startsWith("no-"))this.negated=!0,Y=Y.replace(/^no-/,"");return N6(Y)}).sort((Z,Y)=>Z.length>Y.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(z.includes("<"))this.required=!0;else if(z.includes("["))this.required=!1;else this.isBoolean=!0}}var O4=z6.argv,Uz=`${z6.platform}-${z6.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,W6=u.argv,Gz=`${u.platform}-${u.arch} node-${u.version}`;class $6{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(z,$,Q,Z){this.rawName=z,this.description=$,this.config=Q,this.cli=Z,this.options=[],this.aliasNames=[],this.name=e(z);let Y=e(z),q=Y.indexOf(":");if(q>0)this.namespace=Y.substring(0,q),this.name=Y.substring(q+1);if(this.args=zz(z),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!Q)this.config={}}usage(z){return this.usageText=z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(z,$="-v, --version"){return this.versionNumber=z,this.option($,"Display version number"),this}example(z){return this.examples.push(z),this}option(z,$,Q){let Z=new D6(z,$,Q);return this.options.push(Z),this}alias(z){return this.aliasNames.push(z),this}action(z){return this.commandAction=z,this}before(z){return this.beforeHooks.push(z),this}after(z){return this.afterHooks.push(z),this}use(z){return this.middleware.push(z),this}isMatched(z){if(this.aliasNames.includes(z))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===z;return this.name===z}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof Q6}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(z){return z=z.split(".")[0],!!this.options.find(($)=>{return $.names.includes(z)})}outputHelp(){let{name:z,commands:$}=this.cli,{versionNumber:Q,options:Z,helpCallback:Y}=this.cli.globalCommand,q=[{body:`${z}${Q?`/${Q}`:""}`}];if(q.push({title:"Usage",body:` $ ${z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&$.length>0){let X=F6($.map((F)=>F.rawName)),G=new Map,K=[];for(let F of $)if(F.namespace){if(!G.has(F.namespace))G.set(F.namespace,[]);G.get(F.namespace).push(F)}else K.push(F);let W="";if(K.length>0)W+=K.map((F)=>{return` ${t(F.rawName,X.length)} ${F.description}`}).join(`
|
|
@@ -37,7 +37,7 @@ Run \`${this.name??"cli"} --help\` for usage.`;v.stderr.write(`${q}${Y}${J}
|
|
|
37
37
|
`).length-1;this.output.write(S.move(-999,z*-1))}render(){let z=O6(this._render(this)??"",M6.stdout.columns,{hard:!0,trim:!1});if(z===this._prevFrame)return;if(this.state==="initial")this.output.write(S.hide);else{let $=dz(this._prevFrame,z);if(this.restoreCursor(),$&&$?.length===1){let Q=$[0];this.output.write(S.move(0,Q)),this.output.write(o.lines(1));let Z=z.split(`
|
|
38
38
|
`);this.output.write(Z[Q]),this._prevFrame=z,this.output.write(S.move(0,Z.length-Q-1));return}if($&&$?.length>1){let Q=$[0];this.output.write(S.move(0,Q)),this.output.write(o.down());let Y=z.split(`
|
|
39
39
|
`).slice(Q);this.output.write(Y.join(`
|
|
40
|
-
`)),this._prevFrame=z;return}this.output.write(o.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function pz(z,$){if(z===void 0)return 0;if($.length===0)return 0;let Z=$.findIndex((Y)=>Y.value===z);return Z!==-1?Z:0}function rz(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function az(z,$){if(!$)return;if(z)return $;return $[0]}class sz extends Y6{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#Q="";#Z;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return i.inverse(i.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let z=this.userInput.slice(0,this._cursor),[$,...Q]=this.userInput.slice(this._cursor);return`${z}${i.inverse($)}${Q.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(z){super(z);this.#$=z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=z.multiple===!0,this.#Z=z.filter??rz;let Q;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)Q=z.initialValue;else Q=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)Q=[this.options[0].value];if(Q)for(let Z of Q){let Y=$.findIndex((q)=>q.value===Z);if(Y!==-1)this.toggleSelected(Z),this.#z=Y}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Z,Y)=>this.#Y(Z,Y)),this.on("userInput",(Z)=>this.#q(Z))}_isActionKey(z,$){return z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&z!==void 0&&z!==""}#Y(z,$){let Q=$.name==="up",Z=$.name==="down",Y=$.name==="return";if(Q||Z){if(this.#z=Math.max(0,Math.min(this.#z+(Q?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Y)this.value=az(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter(($)=>$!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#q(z){if(z!==this.#Q){this.#Q=z;let $=this.options;if(z)this.filteredOptions=$.filter((Q)=>this.#Z(z,Q));else this.filteredOptions=[...$];if(this.#z=pz(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class tz extends Y6{options;cursor=0;#z;getGroupItems(z){return this.options.filter(($)=>$.group===z)}isGroupSelected(z){let $=this.getGroupItems(z),Q=this.value;if(Q===void 0)return!1;return $.every((Z)=>Q.includes(Z.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let $=String(z.value),Q=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Z)=>Q.findIndex((Y)=>Y.value===Z)===-1);else this.value=[...this.value,...Q.map((Z)=>Z.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(z.value);this.value=$?this.value.filter((Q)=>Q!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:$}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([Q,Z])=>[{value:Q,group:!0,label:Q},...Z.map((Y)=>({...Y,group:Q}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===z.cursorAt),this.#z?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var oz=Jz();var b=(z,$)=>oz?z:$,P4=b("◆","*"),C4=b("■","x"),S4=b("▲","x"),v4=b("◇","o"),y4=b("┌","T"),ez=b("│","|"),k4=b("└","—"),h4=b("●",">"),_4=b("○"," "),g4=b("◻","[•]"),f4=b("◼","[+]"),m4=b("◻","[ ]"),d4=b("▪","•"),u4=b("─","-"),i4=b("╮","+"),c4=b("├","+"),n4=b("╯","+"),l4=b("●","•"),p4=b("◆","*"),r4=b("▲","!"),a4=b("■","x");var s4={light:b("─","-"),heavy:b("━","="),block:b("█","#")};function z4(){return`${i.gray(ez)} `}var t4=z4();var I6="0.10.
|
|
40
|
+
`)),this._prevFrame=z;return}this.output.write(o.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function pz(z,$){if(z===void 0)return 0;if($.length===0)return 0;let Z=$.findIndex((Y)=>Y.value===z);return Z!==-1?Z:0}function rz(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function az(z,$){if(!$)return;if(z)return $;return $[0]}class sz extends Y6{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#Q="";#Z;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return i.inverse(i.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let z=this.userInput.slice(0,this._cursor),[$,...Q]=this.userInput.slice(this._cursor);return`${z}${i.inverse($)}${Q.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(z){super(z);this.#$=z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=z.multiple===!0,this.#Z=z.filter??rz;let Q;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)Q=z.initialValue;else Q=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)Q=[this.options[0].value];if(Q)for(let Z of Q){let Y=$.findIndex((q)=>q.value===Z);if(Y!==-1)this.toggleSelected(Z),this.#z=Y}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Z,Y)=>this.#Y(Z,Y)),this.on("userInput",(Z)=>this.#q(Z))}_isActionKey(z,$){return z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&z!==void 0&&z!==""}#Y(z,$){let Q=$.name==="up",Z=$.name==="down",Y=$.name==="return";if(Q||Z){if(this.#z=Math.max(0,Math.min(this.#z+(Q?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Y)this.value=az(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter(($)=>$!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#q(z){if(z!==this.#Q){this.#Q=z;let $=this.options;if(z)this.filteredOptions=$.filter((Q)=>this.#Z(z,Q));else this.filteredOptions=[...$];if(this.#z=pz(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class tz extends Y6{options;cursor=0;#z;getGroupItems(z){return this.options.filter(($)=>$.group===z)}isGroupSelected(z){let $=this.getGroupItems(z),Q=this.value;if(Q===void 0)return!1;return $.every((Z)=>Q.includes(Z.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let $=String(z.value),Q=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Z)=>Q.findIndex((Y)=>Y.value===Z)===-1);else this.value=[...this.value,...Q.map((Z)=>Z.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(z.value);this.value=$?this.value.filter((Q)=>Q!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:$}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([Q,Z])=>[{value:Q,group:!0,label:Q},...Z.map((Y)=>({...Y,group:Q}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===z.cursorAt),this.#z?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;if(!this.#z&&Z)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var oz=Jz();var b=(z,$)=>oz?z:$,P4=b("◆","*"),C4=b("■","x"),S4=b("▲","x"),v4=b("◇","o"),y4=b("┌","T"),ez=b("│","|"),k4=b("└","—"),h4=b("●",">"),_4=b("○"," "),g4=b("◻","[•]"),f4=b("◼","[+]"),m4=b("◻","[ ]"),d4=b("▪","•"),u4=b("─","-"),i4=b("╮","+"),c4=b("├","+"),n4=b("╯","+"),l4=b("●","•"),p4=b("◆","*"),r4=b("▲","!"),a4=b("■","x");var s4={light:b("─","-"),heavy:b("━","="),block:b("█","#")};function z4(){return`${i.gray(ez)} `}var t4=z4();var I6="0.10.40";Q4();async function Z4(z="src/pantry"){if(!V.existsSync(z))throw Error(`Pantry directory not found: ${z}. Please run 'bun ./bin/cli.ts update-pantry' first.`);let $=[];function Q(Z,Y=""){let q=V.readdirSync(Z,{withFileTypes:!0}),J=B.join(Z,"package.yml");if(Y&&V.existsSync(J))$.push(Y);for(let U of q)if(U.isDirectory()&&!U.name.startsWith(".")){let X=Y?`${Y}/${U.name}`:U.name,G=B.join(Z,U.name);Q(G,X)}}return Q(z),console.log(`\uD83D\uDCE6 Found ${$.length} packages in local pantry`),$.sort()}async function Y4(z=!1){async function $(J){let U=new URL("https://s3.amazonaws.com/dist.tea.xyz/");if(U.searchParams.set("list-type","2"),U.searchParams.set("prefix",""),U.searchParams.set("max-keys","1000"),J)U.searchParams.set("continuation-token",J);let X=await fetch(U.toString());if(!X.ok)throw Error(`Failed to fetch S3 listing: ${X.status}`);let G=await X.text(),K=[],W=G.match(/<Key>([^<]+)<\/Key>/g);if(W)for(let T of W){let E=T.replace(/<Key>([^<]+)<\/Key>/,"$1");K.push({Key:E})}let j=G.includes("<IsTruncated>true</IsTruncated>"),F=G.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),L=F?F[1]:void 0;return{IsTruncated:j,NextContinuationToken:L,Contents:K}}console.log("Scraping packages from S3 registry...");let Q=new Set,Z;do{let J=await $(Z);for(let U of J.Contents){let X=U.Key,G=X.split("/");if(G.length===0)continue;if(G[0].startsWith(".")||G[0].includes(" ")||X.match(/\.(md|txt|yml|yaml|json)$/i))continue;let K=["darwin","linux","windows"],W=-1;for(let j=1;j<G.length;j++)if(K.includes(G[j])){W=j;break}if(W>0){let j=G.slice(0,W).join("/");if(j.includes("."))Q.add(j)}else if(G.length>=2&&G[0].includes(".")&&!G[1].startsWith("v")&&!G[1].match(/^\d/)){let j=`${G[0]}/${G[1]}`;Q.add(j)}else if(G.length>=1&&G[0].includes("."))Q.add(G[0])}Z=J.NextContinuationToken,console.log(`Found ${Q.size} packages so far...`)}while(Z);let Y=Array.from(Q).sort(),q=[];for(let J of Y){if(!J.includes(".")||J.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(J.endsWith("/README.rst")||J.endsWith("/README")||J.includes("/docs/"))continue;if(J.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(J))continue;q.push(J)}return console.log(`\uD83D\uDCE6 Found ${q.length} valid packages in registry`),q}async function q4(z,$){let Z=`/**
|
|
41
41
|
* Constants used throughout the ts-pantry package
|
|
42
42
|
* This file is auto-generated from ${$}. Do not edit manually.
|
|
43
43
|
* Generated on ${new Date().toISOString()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{s as Wa,o as Xa,i as Ya,p as Za,y as _a,c as $a,g as ab,m as bb,f as cb,T as db,l as eb,C as fb,P as gb,q as hb,M as ib,R as jb,h as kb,w as lb,x as mb};
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as Va,A as P,Aa as ub,B as Q,Ba as vb,C as R,Ca as wb,D as S,Da as xb,E as Y,Ea as yb,F as Z,Fa as zb,G as _,Ga as Ab,H as $,Ha as Bb,I as aa,Ia as Cb,J as ba,Ja as Db,K as ca,Ka as Eb,L as da,La as Fb,M as ea,N as fa,O as ga,P as ha,Q as ia,R as ja,S as ka,T as la,U as ma,V as na,W as oa,X as pa,Y as qa,Z as ra,_ as Ua,a as b,aa as Wa,b as c,ba as Xa,c as d,ca as Ya,d as e,da as Za,e as f,ea as _a,f as g,fa as $a,g as h,ga as ab,h as i,ha as bb,i as j,ia as cb,j as k,ja as db,k as l,ka as eb,l as m,la as fb,m as n,ma as gb,n as o,na as hb,o as p,oa as ib,p as q,pa as jb,q as r,qa as kb,r as s,ra as lb,s as H,sa as mb,t as I,ta as nb,u as J,ua as ob,v as K,va as pb,w as L,wa as qb,x as M,xa as rb,y as N,ya as sb,z as O,za as tb}from"../chunk-
|
|
1
|
+
import{$ as Va,A as P,Aa as ub,B as Q,Ba as vb,C as R,Ca as wb,D as S,Da as xb,E as Y,Ea as yb,F as Z,Fa as zb,G as _,Ga as Ab,H as $,Ha as Bb,I as aa,Ia as Cb,J as ba,Ja as Db,K as ca,Ka as Eb,L as da,La as Fb,M as ea,N as fa,O as ga,P as ha,Q as ia,R as ja,S as ka,T as la,U as ma,V as na,W as oa,X as pa,Y as qa,Z as ra,_ as Ua,a as b,aa as Wa,b as c,ba as Xa,c as d,ca as Ya,d as e,da as Za,e as f,ea as _a,f as g,fa as $a,g as h,ga as ab,h as i,ha as bb,i as j,ia as cb,j as k,ja as db,k as l,ka as eb,l as m,la as fb,m as n,ma as gb,n as o,na as hb,o as p,oa as ib,p as q,pa as jb,q as r,qa as kb,r as s,ra as lb,s as H,sa as mb,t as I,ta as nb,u as J,ua as ob,v as K,va as pb,w as L,wa as qb,x as M,xa as rb,y as N,ya as sb,z as O,za as tb}from"../chunk-rt8p2q09.js";import"../chunk-g61kvyjq.js";import{Pa as Zb,Qa as _b,Ra as $b,Sa as ac,Ta as bc,Ua as cc,Va as dc}from"../chunk-45tts066.js";import{$a as Lb,Wa as Gb,Xa as Hb,Ya as Ib,Za as Jb,_a as Kb,ab as Mb,bb as Nb,cb as Ob,db as Pb,eb as Qb,fb as Rb,gb as Sb,hb as Tb,ib as Ub,jb as Vb,kb as Wb,lb as Xb,mb as Yb}from"../chunk-bhf1p3a4.js";import{Ab as Ta,nb as Ga,ob as Ha,pb as Ia,qb as Ja,rb as Ka,sb as La,tb as Ma,ub as Na,vb as Oa,wb as Pa,xb as Qa,yb as Ra,zb as Sa}from"../chunk-t3pfbk3v.js";import"../chunk-vxknhv2t.js";import{Eb as sa,Fb as ta,Gb as ua,Hb as va,Ib as wa,Jb as xa,Kb as ya,Lb as za,Mb as Aa,Nb as Ba,Ob as Ca,Pb as Da,Qb as Ea,Rb as Fa}from"../chunk-mwn9pf2y.js";import{Sb as T,Tb as U,Ub as V,Vb as W,Wb as X}from"../chunk-pjs4pxq8.js";import{$b as z,Xb as v,Yb as w,Zb as x,_b as y,ac as A,cc as B,dc as C,ec as D,fc as E,gc as F,hc as G}from"../chunk-gvacxb4c.js";import{ic as t,jc as u}from"../chunk-g1j4y6h5.js";import{mc as a}from"../chunk-99dpbye7.js";import"../chunk-2f67zesz.js";export{vb as writeOciLayout,wb as writeDockerArchive,Wb as withTempDirSync,Vb as withTempDir,Mb as withRedis,Ib as withPostgres,Qb as withMysql,Bb as verifyBlob,F as validatePackageSpec,M as validatePackage,q as v,Lb as useRedis,Hb as usePostgres,Pb as useMysql,_a as updatePackageVersionMap,dc as updateApp,ra as uninstallShellInit,Va as toTypeName,Ua as toSafeVarName,Wa as toPackageVarName,la as supportedPackages,Ob as stopRedis,Kb as stopPostgres,Sb as stopMysql,Nb as startRedis,Jb as startPostgres,Oa as startPeriodicCleanup,Rb as startMysql,H as showPackageInfo,ta as shouldProceedWithGitHubRequest,Na as setupCleanupHandlers,tb as serializeConfig,I as searchPackagesCommand,B as searchPackages,Ra as scanPantryPackages,ac as scanInstalledApps,Ja as saveToCacheAndOutput,sa as saveRateLimitInfo,Ga as savePackageAsTypeScript,va as saveGitHubPackageCache,G as resolveVersionFromMetadata,$ as resolveVersionConstraint,z as resolveVersion,ba as resolveTransitiveDependencies,i as resolvePackageName,Ca as resolvePackageDomain,bb as resolvePackageDependencies,ja as resolveLatestVersion,da as resolveDependencyFile,ab as resolveDependenciesFromYaml,$a as resolveDependencies,lb as resolveBuildStages,pa as renderShellSnippet,Eb as renderDockerfile,Ub as removeTempDir,db as readProjectDependencies,Sa as readPantryPackageInfo,oa as rcFileFor,Ab as pushImage,zb as pullImage,r as pkg,j as parsePackageSpec,yb as parseImageRef,mb as parseFreezer,kb as parseExecForm,jb as parseDockerfile,Z as parseDepsYamlConfig,Y as parseDependencyFile,t as pantry,u as packages,xa as logPkgxProjects,ob as loadFreezer,J as listPopularPackages,L as listAliases,K as listActivePackages,y as isVersionAvailable,d as isValidPackageName,e as isSupportedPlatform,f as isSupportedArchitecture,ka as isSupported,p as isPackageInCategory,c as isPackageDomain,b as isPackageAlias,$b as isNewerVersion,Ea as isKnownAlias,qa as installShellInit,ia as installPackages,ha as installPackage,Ba as guessOriginalDomain,fa as globalBinDir,O as getVersionInfo,Ia as getValidCachedPackage,S as getSystemInfo,ma as getPrimaryBinary,D as getPopularPackages,x as getPhpVersionsForWorkflow,C as getPackagesByPattern,o as getPackagesByCategory,A as getPackageInfo,Da as getPackageAliases,v as getLatestVersion,cb as getInstallCommand,ua as getGitHubPackageCache,Fa as getCanonicalDomain,_ as getAvailableVersionsForPackage,w as getAvailableVersions,h as getAllPackageDomains,g as getAllPackageAliases,E as getActivePackages,Xa as generateIndex,Za as generateDocs,Fb as generateContainerFiles,Ya as generateAliases,Q as formatSearchResults,k as formatPackageSpec,P as formatPackageInfo,ya as formatObjectWithoutQuotedKeys,R as formatInstallPlan,ea as findDependencyFiles,La as fetchPkgxProjects,Ta as fetchPantryPackageWithMetadata,Ma as fetchPantryPackage,wa as fetchPackageListFromGitHub,bc as fetchDesktopCatalogue,Qa as fetchAndSavePackage,Pa as fetchAndSaveAllPackages,Cb as extractLayer,rb as digestHex,qb as digest,na as detectShell,ga as detectPlatform,s as dependencies,hb as definePantryConfig,fb as definePackageList,eb as defineDependencies,ca as deduplicateDependencies,Xb as createTestFile,Yb as createTestDir,Tb as createTempDir,nb as createMatcher,l as createInstallationContext,N as createInstallPlan,za as convertDomainToVarName,Aa as convertDomainToFileName,aa as compareVersions,ib as collectBuildContext,Ka as cleanupBrowserResources,Ha as cleanStaleOutputFiles,cc as checkAppUpdates,ub as buildManifest,sb as buildLayerFromRootfs,Db as buildImage,a as aliases,m as VERSION_SPECS,Zb as SYSTEM_APPS,Gb as PantryService,xb as PANTRY_REGISTRY,n as PACKAGE_CATEGORIES,W as PACKAGE_ALIASES,pb as MEDIA_TYPE,_b as MAS_APPS,gb as DISTRIBUTION_CONFIG,V as DEFAULT_TIMEOUT_MS,U as DEFAULT_CACHE_EXPIRATION_MINUTES,T as DEFAULT_CACHE_DIR,X as ALL_KNOWN_PACKAGES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$a as f,Wa as a,Xa as b,Ya as c,Za as d,_a as e,ab as g,bb as h,cb as i,db as j,eb as k,fb as l,gb as m,hb as n,ib as o,jb as p,kb as q,lb as r,mb as s}from"../../chunk-
|
|
1
|
+
import{$a as f,Wa as a,Xa as b,Ya as c,Za as d,_a as e,ab as g,bb as h,cb as i,db as j,eb as k,fb as l,gb as m,hb as n,ib as o,jb as p,kb as q,lb as r,mb as s}from"../../chunk-bhf1p3a4.js";import"../../chunk-2f67zesz.js";export{q as withTempDirSync,p as withTempDir,g as withRedis,c as withPostgres,k as withMysql,f as useRedis,b as usePostgres,j as useMysql,i as stopRedis,e as stopPostgres,m as stopMysql,h as startRedis,d as startPostgres,l as startMysql,o as removeTempDir,r as createTestFile,s as createTestDir,n as createTempDir,a as PantryService};
|
package/package.json
CHANGED
package/dist/chunk-jrhm2n4b.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{execSync as C}from"node:child_process";var y=new Set,L=!1;function H(){if(L)return;L=!0;let s=()=>{for(let o of y)try{C(`pantry stop ${o}`,{stdio:"ignore",timeout:1e4})}catch{}y.clear()};process.on("exit",s),process.on("SIGINT",()=>{s(),process.exit(130)}),process.on("SIGTERM",()=>{s(),process.exit(143)})}function l(s,o=!1){let t={encoding:"utf-8",timeout:30000,stdio:o?"pipe":["pipe","pipe","pipe"]};return C(`pantry ${s}`,t)}function J(s){let o=s.match(/Name:\s+(\S+)/)?.[1]??"",t=/Status:\s+running/i.test(s),n=s.match(/Port:\s+(\d+)/),r=s.match(/PID:\s+(\d+)/),$=s.match(/Data Dir:\s+(.+)/);return{name:o,running:t,port:n?Number.parseInt(n[1],10):null,pid:r?Number.parseInt(r[1],10):null,dataDir:$?$[1].trim():null}}class e{config;_startedByUs=!1;constructor(s){this.config={name:s.name,port:s.port??0,readyTimeoutMs:s.readyTimeoutMs??15000,pollIntervalMs:s.pollIntervalMs??200,quiet:s.quiet??!0}}static isAvailable(){try{return C("pantry --version",{stdio:"ignore",timeout:5000}),!0}catch{return!1}}status(){try{let s=l(`inspect ${this.config.name}`,!0);return J(s)}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(H(),this.isRunning())return this.status();return l(`start ${this.config.name}`,this.config.quiet),this._startedByUs=!0,y.add(this.config.name),await this.waitReady(),this.status()}async stop(){if(!this._startedByUs)return;try{l(`stop ${this.config.name}`,this.config.quiet)}catch{}y.delete(this.config.name),this._startedByUs=!1}async forceStop(){try{l(`stop ${this.config.name}`,this.config.quiet)}catch{}y.delete(this.config.name),this._startedByUs=!1}async ensureRunning(){if(this.isRunning())return this.status();return this.start()}async waitReady(){let s=Date.now()+this.config.readyTimeoutMs;while(Date.now()<s){if(this.isRunning())return;await new Promise((o)=>setTimeout(o,this.config.pollIntervalMs))}throw Error(`Service '${this.config.name}' did not become ready within ${this.config.readyTimeoutMs}ms`)}}var u=new e({name:"postgres"});async function R(s){let o=await u.ensureRunning();return{port:s?.port??o.port??5432,host:s?.host??"localhost",database:s?.database??"postgres",username:s?.username??process.env.USER??"postgres"}}async function q(){await u.stop()}function K(s){let o=null;return{get connection(){if(!o)throw Error("Postgres not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await R(s)},afterAll:async()=>{await q(),o=null}}}async function N(s,o){let t=await R(o);try{return await s(t)}finally{if(o?.stopAfter!==!1)await q()}}var x=new e({name:"redis"});async function m(s){let o=await x.ensureRunning(),t=s?.port??o.port??6379,n=s?.host??"localhost";return{port:t,host:n,url:`redis://${n}:${t}`}}async function M(){await x.stop()}function O(s){let o=null;return{get connection(){if(!o)throw Error("Redis not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await m(s)},afterAll:async()=>{await M(),o=null}}}async function U(s,o){let t=await m(o);try{return await s(t)}finally{if(o?.stopAfter!==!1)await M()}}var z=new e({name:"mysql"});async function i(s){let o=await z.ensureRunning();return{port:s?.port??o.port??3306,host:s?.host??"localhost",database:s?.database??"test",username:s?.username??"root"}}async function A(){await z.stop()}function V(s){let o=null;return{get connection(){if(!o)throw Error("MySQL not started. Ensure beforeAll has run.");return o},beforeAll:async()=>{o=await i(s)},afterAll:async()=>{await A(),o=null}}}async function X(s,o){let t=await i(o);try{return await s(t)}finally{if(o?.stopAfter!==!1)await A()}}import{existsSync as T,mkdirSync as F,mkdtempSync as Y,rmSync as G,writeFileSync as Z}from"node:fs";import{tmpdir as a}from"node:os";import{join as b}from"node:path";var w=new Set,B=!1;function I(){if(B)return;B=!0;let s=()=>{for(let o of w)try{if(T(o))G(o,{recursive:!0,force:!0})}catch{}w.clear()};process.on("exit",s),process.on("SIGINT",()=>{s(),process.exit(130)}),process.on("SIGTERM",()=>{s(),process.exit(143)})}function P(s="pantry-test-"){I();let o=Y(b(a(),s));return w.add(o),o}function Q(s){w.delete(s);try{if(T(s))G(s,{recursive:!0,force:!0})}catch{}}async function W(s,o){let t=P(s);try{return await o(t)}finally{Q(t)}}function _(s,o){let t=P(s);try{return o(t)}finally{Q(t)}}function h(s,o,t){let n=b(s,o),r=n.substring(0,n.lastIndexOf("/"));if(r&&!T(r))F(r,{recursive:!0});return Z(n,t),n}function p(s,o){let t=b(s,o);return F(t,{recursive:!0}),t}export{e as Wa,R as Xa,q as Ya,K as Za,N as _a,m as $a,M as ab,O as bb,U as cb,i as db,A as eb,V as fb,X as gb,P as hb,Q as ib,W as jb,_ as kb,h as lb,p as mb};
|
|
File without changes
|