ts-pantry 0.11.10 → 0.11.12
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{$ as _6,Ha as n6,Ia as i6,Ka as l6,L as C6,M as S6,N as v6,Na as p6,P as y6,Pa as r6,Ua as a6,Va as s6,Wa as t6,Z as k6,_ as h6,aa as g6,ba as f6,fa as G6,ga as u6,ha as c6}from"../chunk-
|
|
2
|
+
import{$ as _6,Ha as n6,Ia as i6,Ka as l6,L as C6,M as S6,N as v6,Na as p6,P as y6,Pa as r6,Ua as a6,Va as s6,Wa as t6,Z as k6,_ as h6,aa as g6,ba as f6,fa as G6,ga as u6,ha as c6}from"../chunk-v06v6686.js";import"../chunk-7msnsp1q.js";import"../chunk-pwytxyxw.js";import"../chunk-g0992q6d.js";import{Bb as X6,Cb as r,Hb as d6,Lb as U6,yb as p,zb as m6}from"../chunk-mjkz6cxz.js";import"../chunk-mt6r4c0m.js";import"../chunk-9xe74rn4.js";import{bc as l,cc as q6,dc as J6}from"../chunk-99e8jvg1.js";import"../chunk-btc5022y.js";import"../chunk-rg8h99fk.js";import{Ac as q4,zc as P6}from"../chunk-qzr4847k.js";import{Ec as h}from"../chunk-403r79k6.js";import K from"node:fs";import w from"node:path";import H from"node:process";import{existsSync as zz}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 $z}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 uz,{stdin as R4,stdout as A4}from"node:process";import M6,{stdin as iz,stdout as lz}from"node:process";import pz 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(zz(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 L4=new B6;function Qz(z,$={}){let Q={_:[]},Z=$.alias||{},Y=new Set($.boolean||[]),q={};for(let U of Object.keys(Z))for(let J of Z[U])q[J]=U;for(let U of Y)if(Z[U])for(let J of Z[U])Y.add(J);function X(U,J){let G=q[U]||U;if(Q[G]=J,Z[G])for(let V of Z[G])Q[V]=J;if(q[U]&&Z[q[U]])for(let V of Z[q[U]])Q[V]=J;Q[U]=J}for(let U=0;U<z.length;U++){let J=z[U];if(J==="--"){Q._.push(...z.slice(U+1));break}if(J.startsWith("--")){let G=J.indexOf("=");if(G!==-1){let V=J.slice(2,G),F=J.slice(G+1);X(V,F)}else{let V=J.slice(2);if(V.startsWith("no-")){let j=V.slice(3);X(j,!1);continue}let F=q[V]||V;if(Y.has(F)||Y.has(V))X(V,!0);else{let j=z[U+1];if(j!==void 0&&!j.startsWith("-"))X(V,j),U++;else X(V,!0)}}}else if(J.startsWith("-")&&J.length>1){let G=J.slice(1);for(let V=0;V<G.length;V++){let F=G[V],j=q[F]||F;if(V===G.length-1&&!Y.has(j)&&!Y.has(F)){let W=z[U+1];if(W!==void 0&&!W.startsWith("-"))X(F,W),U++;else X(F,!0)}else X(F,!0)}}else Q._.push(J)}return Q}function e(z){return z.replace(/[<[].+/,"").trim()}function Zz(z){let $=/<([^>]+)>/g,Q=/\[([^\]]+)\]/g,Z=[],Y=(U)=>{let J=!1,G=U[1];if(G.startsWith("..."))G=G.slice(3),J=!0;return{required:U[0].startsWith("<"),value:G,variadic:J}},q;while(q=$.exec(z))Z.push(Y(q));let X;while(X=Q.exec(z))Z.push(Y(X));return Z}function Yz(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,X)=>{return X!==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 Jz(z,$,Q){let Z=0,Y=$.length,q=z,X;for(;Z<Y;++Z)X=q[$[Z]],q=q[$[Z]]=Z===Y-1?Q:X!=null?X:!!~$[Z+1].indexOf(".")||!(+$[Z+1]>-1)?{}:[]}function Xz(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 Uz(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 Gz(){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 i="\x1B",I=`${i}[`;var S={to(z,$){if(!$)return`${I}${z+1}G`;return`${I}${$+1};${z+1}H`},move(z,$){let Q="";if(z<0)Q+=`${I}${-z}D`;else if(z>0)Q+=`${I}${z}C`;if($<0)Q+=`${I}${-$}A`;else if($>0)Q+=`${I}${$}B`;return Q},up:(z=1)=>`${I}${z}A`,down:(z=1)=>`${I}${z}B`,forward:(z=1)=>`${I}${z}C`,backward:(z=1)=>`${I}${z}D`,nextLine:(z=1)=>`${I}E`.repeat(z),prevLine:(z=1)=>`${I}F`.repeat(z),left:`${I}G`,hide:`${I}?25l`,show:`${I}?25h`,save:`${i}7`,restore:`${i}8`};var o={screen:`${I}2J`,up:(z=1)=>`${I}1J`.repeat(z),down:(z=1)=>`${I}J`.repeat(z),line:`${I}2K`,lineEnd:`${I}K`,lineStart:`${I}1K`,lines(z){let $="";for(let Q=0;Q<z;Q++)$+=this.line+(Q<z-1?S.up():"");if(z)$+=S.left;return $}},B4={screen:`${i}c`};function jz(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:jz(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 b4=z6.argv,Hz=`${z6.platform}-${z6.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,W6=u.argv,Kz=`${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 J=F6($.map((W)=>W.rawName)),G=new Map,V=[];for(let W of $)if(W.namespace){if(!G.has(W.namespace))G.set(W.namespace,[]);G.get(W.namespace).push(W)}else V.push(W);let F="";if(V.length>0)F+=V.map((W)=>{return` ${t(W.rawName,J.length)} ${W.description}`}).join(`
|
|
@@ -37,7 +37,7 @@ Run \`${this.name??"cli"} --help\` for usage.`;v.stderr.write(`${q}${Y}${X}
|
|
|
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 $=nz(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 sz(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 tz(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function oz(z,$){if(!$)return;if(z)return $;return $[0]}class ez extends Y6{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#Q="";#Z;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return c.inverse(c.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}${c.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??tz;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=oz(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=sz(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 z4 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 $4=Gz();var b=(z,$)=>$4?z:$,v4=b("◆","*"),y4=b("■","x"),k4=b("▲","x"),h4=b("◇","o"),_4=b("┌","T"),Q4=b("│","|"),g4=b("└","—"),f4=b("●",">"),m4=b("○"," "),d4=b("◻","[•]"),u4=b("◼","[+]"),c4=b("◻","[ ]"),n4=b("▪","•"),i4=b("─","-"),l4=b("╮","+"),p4=b("├","+"),r4=b("╯","+"),a4=b("●","•"),s4=b("◆","*"),t4=b("▲","!"),o4=b("■","x");var e4={light:b("─","-"),heavy:b("━","="),block:b("█","#")};function Z4(){return`${c.gray(Q4)} `}var z1=Z4();var I6="0.11.
|
|
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 sz(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 tz(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function oz(z,$){if(!$)return;if(z)return $;return $[0]}class ez extends Y6{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#Q="";#Z;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return c.inverse(c.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}${c.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??tz;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=oz(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=sz(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 z4 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 $4=Gz();var b=(z,$)=>$4?z:$,v4=b("◆","*"),y4=b("■","x"),k4=b("▲","x"),h4=b("◇","o"),_4=b("┌","T"),Q4=b("│","|"),g4=b("└","—"),f4=b("●",">"),m4=b("○"," "),d4=b("◻","[•]"),u4=b("◼","[+]"),c4=b("◻","[ ]"),n4=b("▪","•"),i4=b("─","-"),l4=b("╮","+"),p4=b("├","+"),r4=b("╯","+"),a4=b("●","•"),s4=b("◆","*"),t4=b("▲","!"),o4=b("■","x");var e4={light:b("─","-"),heavy:b("━","="),block:b("█","#")};function Z4(){return`${c.gray(Q4)} `}var z1=Z4();var I6="0.11.12";q4();async function J4(z="src/pantry"){if(!K.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=K.readdirSync(Z,{withFileTypes:!0}),X=w.join(Z,"package.yml");if(Y&&K.existsSync(X))$.push(Y);for(let U of q)if(U.isDirectory()&&!U.name.startsWith(".")){let J=Y?`${Y}/${U.name}`:U.name,G=w.join(Z,U.name);Q(G,J)}}return Q(z),console.log(`\uD83D\uDCE6 Found ${$.length} packages in local pantry`),$.sort()}async function X4(z=!1){async function $(X){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"),X)U.searchParams.set("continuation-token",X);let J=await fetch(U.toString());if(!J.ok)throw Error(`Failed to fetch S3 listing: ${J.status}`);let G=await J.text(),V=[],F=G.match(/<Key>([^<]+)<\/Key>/g);if(F)for(let E of F){let x=E.replace(/<Key>([^<]+)<\/Key>/,"$1");V.push({Key:x})}let j=G.includes("<IsTruncated>true</IsTruncated>"),W=G.match(/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/),L=W?W[1]:void 0;return{IsTruncated:j,NextContinuationToken:L,Contents:V}}console.log("Scraping packages from S3 registry...");let Q=new Set,Z;do{let X=await $(Z);for(let U of X.Contents){let J=U.Key,G=J.split("/");if(G.length===0)continue;if(G[0].startsWith(".")||G[0].includes(" ")||J.match(/\.(md|txt|yml|yaml|json)$/i))continue;let V=["darwin","linux","windows"],F=-1;for(let j=1;j<G.length;j++)if(V.includes(G[j])){F=j;break}if(F>0){let j=G.slice(0,F).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=X.NextContinuationToken,console.log(`Found ${Q.size} packages so far...`)}while(Z);let Y=Array.from(Q).sort(),q=[];for(let X of Y){if(!X.includes(".")||X.match(/^[a-z0-9.-]+\.[a-z]{2,}(\/[\w.-]+){0,20}$/i)===null)continue;if(X.endsWith("/README.rst")||X.endsWith("/README")||X.includes("/docs/"))continue;if(X.endsWith("/.pkgroot"))continue;if(["amazon.com/aws","charm.sh","code.videolan.org","crates.io"].includes(X))continue;q.push(X)}return console.log(`\uD83D\uDCE6 Found ${q.length} valid packages in registry`),q}async function U4(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
|
+
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 fb,R as gb,q as hb,K as ib,N as jb,m as kb,M as lb,O as mb,U as nb,i as ob,A as pb,V as qb,X as rb,P as sb,Q as tb,W as ub,_ as vb,h as wb,p as xb};
|
package/dist/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as va,A as R,Aa as wb,B as S,Ba as xb,C as T,Ca as yb,D as U,Da as zb,E as _,Ea as Ab,F as $,Fa as Bb,G as aa,Ga as Cb,H as ba,Ha as Db,I as ca,Ia as Eb,J as da,Ja as Fb,K as ea,Ka as Gb,L as fa,La as Hb,M as ga,Ma as Ib,N as ha,Na as Jb,O as ia,Oa as Kb,P as ja,Pa as Lb,Q as ka,Qa as kc,R as la,Ra as lc,S as ma,Sa as mc,T as na,Ta as nc,U as oa,Ua as oc,V as pa,Va as pc,W as qa,Wa as qc,X as ra,Y as sa,Z as ta,_ as ua,a as b,aa as wa,b as c,ba as xa,c as d,ca as _a,d as e,da as $a,e as f,ea as ab,f as g,fa as bb,g as h,ga as cb,h as i,ha as db,i as j,ia as eb,j as k,ja as fb,k as l,ka as gb,l as m,la as hb,m as n,ma as ib,n as o,na as jb,o as p,oa as kb,p as q,pa as lb,q as r,qa as mb,r as s,ra as nb,s as J,sa as ob,t as K,ta as pb,u as L,ua as qb,v as M,va as rb,w as N,wa as sb,x as O,xa as tb,y as P,ya as ub,z as Q,za as vb}from"../chunk-
|
|
1
|
+
import{$ as va,A as R,Aa as wb,B as S,Ba as xb,C as T,Ca as yb,D as U,Da as zb,E as _,Ea as Ab,F as $,Fa as Bb,G as aa,Ga as Cb,H as ba,Ha as Db,I as ca,Ia as Eb,J as da,Ja as Fb,K as ea,Ka as Gb,L as fa,La as Hb,M as ga,Ma as Ib,N as ha,Na as Jb,O as ia,Oa as Kb,P as ja,Pa as Lb,Q as ka,Qa as kc,R as la,Ra as lc,S as ma,Sa as mc,T as na,Ta as nc,U as oa,Ua as oc,V as pa,Va as pc,W as qa,Wa as qc,X as ra,Y as sa,Z as ta,_ as ua,a as b,aa as wa,b as c,ba as xa,c as d,ca as _a,d as e,da as $a,e as f,ea as ab,f as g,fa as bb,g as h,ga as cb,h as i,ha as db,i as j,ia as eb,j as k,ja as fb,k as l,ka as gb,l as m,la as hb,m as n,ma as ib,n as o,na as jb,o as p,oa as kb,p as q,pa as lb,q as r,qa as mb,r as s,ra as nb,s as J,sa as ob,t as K,ta as pb,u as L,ua as qb,v as M,va as rb,w as N,wa as sb,x as O,xa as tb,y as P,ya as ub,z as Q,za as vb}from"../chunk-v06v6686.js";import"../chunk-7msnsp1q.js";import{$a as ec,_a as dc,ab as fc,bb as gc,cb as hc,db as ic,eb as jc}from"../chunk-pwytxyxw.js";import{fb as Mb,gb as Nb,hb as Ob,ib as Pb,jb as Qb,kb as Rb,lb as Sb,mb as Tb,nb as Ub,ob as Vb,pb as Wb,qb as Xb,rb as Yb,sb as Zb,tb as _b,ub as $b,vb as ac,wb as bc,xb as cc}from"../chunk-g0992q6d.js";import{Ab as Oa,Bb as Pa,Cb as Qa,Db as Ra,Eb as Sa,Fb as Ta,Gb as Ua,Hb as Va,Ib as Wa,Jb as Xa,Kb as Ya,Lb as Za,yb as Ma,zb as Na}from"../chunk-mjkz6cxz.js";import"../chunk-mt6r4c0m.js";import{$b as Ka,Pb as ya,Qb as za,Rb as Aa,Sb as Ba,Tb as Ca,Ub as Da,Vb as Ea,Wb as Fa,Xb as Ga,Yb as Ha,Zb as Ia,_b as Ja,ac as La}from"../chunk-9xe74rn4.js";import{bc as V,cc as W,dc as X,ec as Y,fc as Z}from"../chunk-99e8jvg1.js";import{gc as v,hc as w,ic as x,jc as y,kc as z,lc as A,nc as B,oc as C,pc as D,qc as E,rc as F,sc as G,tc as H,uc as I}from"../chunk-btc5022y.js";import{vc as t,wc as u}from"../chunk-rg8h99fk.js";import{zc as a}from"../chunk-qzr4847k.js";import"../chunk-403r79k6.js";export{Bb as writeOciLayout,Cb as writeDockerArchive,ac as withTempDirSync,$b as withTempDir,Ub as withRedis,Qb as withPostgres,Yb as withMysql,nc as waitForAppStoreBuilds,Hb as verifyBlob,F as validatePackageSpec,O as validatePackage,q as v,Tb as useRedis,Pb as usePostgres,Xb as useMysql,eb as updatePackageVersionMap,jc as updateApp,xa as uninstallShellInit,$a as toTypeName,_a as toSafeVarName,ab as toPackageVarName,ra as supportedPackages,Sb as stopRedis,Ob as stopPostgres,Wb as stopMysql,Rb as startRedis,Nb as startPostgres,Ua as startPeriodicCleanup,Vb as startMysql,J as showPackageInfo,za as shouldProceedWithGitHubRequest,Ta as setupCleanupHandlers,zb as serializeConfig,K as searchPackagesCommand,B as searchPackages,Xa as scanPantryPackages,gc as scanInstalledApps,Pa as saveToCacheAndOutput,ya as saveRateLimitInfo,Ma as savePackageAsTypeScript,Ba as saveGitHubPackageCache,na as satisfiesInstallerConstraint,I as resolveVersionFromMetadata,ba as resolveVersionConstraint,z as resolveVersion,da as resolveTransitiveDependencies,i as resolvePackageName,Ia as resolvePackageDomain,hb as resolvePackageDependencies,la as resolveLatestVersion,pa as resolveInstallerConstraintFromCandidates,fa as resolveDependencyFile,gb as resolveDependenciesFromYaml,fb as resolveDependencies,rb as resolveBuildStages,va as renderShellSnippet,Kb as renderDockerfile,_b as removeTempDir,jb as readProjectDependencies,Ya as readPantryPackageInfo,ua as rcFileFor,Gb as pushImage,Fb as pullImage,oc as provisionMacApp,r as pkg,G as parseVersion,j as parsePackageSpec,ma as parseInstallerConstraint,Eb as parseImageRef,sb as parseFreezer,qb as parseExecForm,pb as parseDockerfile,$ as parseDepsYamlConfig,_ as parseDependencyFile,t as pantry,u as packages,Da as logPkgxProjects,ub as loadFreezer,L as listPopularPackages,N as listAliases,M as listActivePackages,y as isVersionAvailable,d as isValidPackageName,e as isSupportedPlatform,f as isSupportedArchitecture,qa as isSupported,p as isPackageInCategory,c as isPackageDomain,b as isPackageAlias,fc as isNewerVersion,Ka as isKnownAlias,wa as installShellInit,ka as installPackages,ja as installPackage,Ha as guessOriginalDomain,ha as globalBinDir,Q as getVersionInfo,Oa as getValidCachedPackage,U as getSystemInfo,sa as getPrimaryBinary,D as getPopularPackages,x as getPhpVersionsForWorkflow,C as getPackagesByPattern,o as getPackagesByCategory,A as getPackageInfo,Ja as getPackageAliases,v as getLatestVersion,ib as getInstallCommand,Aa as getGitHubPackageCache,La as getCanonicalDomain,aa as getAvailableVersionsForPackage,w as getAvailableVersions,h as getAllPackageDomains,g as getAllPackageAliases,E as getActivePackages,pc as generateMacCertificateRequests,bb as generateIndex,db as generateDocs,Lb as generateContainerFiles,cb as generateAliases,S as formatSearchResults,k as formatPackageSpec,R as formatPackageInfo,Ea as formatObjectWithoutQuotedKeys,T as formatInstallPlan,ga as findDependencyFiles,Ra as fetchPkgxProjects,Za as fetchPantryPackageWithMetadata,Sa as fetchPantryPackage,Ca as fetchPackageListFromGitHub,hc as fetchDesktopCatalogue,Wa as fetchAndSavePackage,Va as fetchAndSaveAllPackages,Ib as extractLayer,qc as exportAppleCertificateP12,mc as ensureAppStoreVersions,xb as digestHex,wb as digest,ta as detectShell,ia as detectPlatform,s as dependencies,nb as definePantryConfig,lb as definePackageList,kb as defineDependencies,ea as deduplicateDependencies,bc as createTestFile,cc as createTestDir,Zb as createTempDir,tb as createMatcher,l as createInstallationContext,P as createInstallPlan,Fa as convertDomainToVarName,Ga as convertDomainToFileName,H as compareVersionsDesc,ca as compareVersions,oa as compareInstallerVersionsDesc,ob as collectBuildContext,Qa as cleanupBrowserResources,Na as cleanStaleOutputFiles,ic as checkAppUpdates,Ab as buildManifest,yb as buildLayerFromRootfs,Jb as buildImage,kc as appStoreConnectToken,a as aliases,m as VERSION_SPECS,dc as SYSTEM_APPS,Mb as PantryService,Db as PANTRY_REGISTRY,n as PACKAGE_CATEGORIES,Y as PACKAGE_ALIASES,vb as MEDIA_TYPE,ec as MAS_APPS,mb as DISTRIBUTION_CONFIG,X as DEFAULT_TIMEOUT_MS,W as DEFAULT_CACHE_EXPIRATION_MINUTES,V as DEFAULT_CACHE_DIR,lc as AppStoreConnectClient,Z as ALL_KNOWN_PACKAGES};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fb as a,gb as b,hb as c,ib as d,jb as e,kb as f,lb as g,mb as h,nb as i,ob as j,pb as k,qb as l,rb as m,sb as n,tb as o,ub as p,vb as q,wb as r,xb as s}from"../../chunk-
|
|
1
|
+
import{fb as a,gb as b,hb as c,ib as d,jb as e,kb as f,lb as g,mb as h,nb as i,ob as j,pb as k,qb as l,rb as m,sb as n,tb as o,ub as p,vb as q,wb as r,xb as s}from"../../chunk-g0992q6d.js";import"../../chunk-403r79k6.js";export{q as withTempDirSync,p as withTempDir,i as withRedis,e as withPostgres,m as withMysql,h as useRedis,d as usePostgres,l as useMysql,g as stopRedis,c as stopPostgres,k as stopMysql,f as startRedis,b as startPostgres,j as startMysql,o as removeTempDir,r as createTestFile,s as createTestDir,n as createTempDir,a as PantryService};
|
package/package.json
CHANGED
package/dist/chunk-d3094v8w.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{s as fb,o as gb,i as hb,p as ib,y as jb,c as kb,g as lb,m as mb,f as nb,T as ob,l as pb,C as qb,P as rb,q as sb,M as tb,R as ub,h as vb,w as wb,x as xb};
|
|
File without changes
|