diff --git a/dist/index.js b/dist/index.js index c9f98e5..d865771 100755 --- a/dist/index.js +++ b/dist/index.js @@ -21,9 +21,9 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._life `),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ht(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=o=>{let l=o.attributeName(),a=this.getOptionValue(l),u=this.options.find(c=>c.negate&&l===c.attributeName()),h=this.options.find(c=>!c.negate&&l===c.attributeName());return u&&(u.presetArg===void 0&&a===!1||u.presetArg!==void 0&&a===u.presetArg)?u:h||o},n=o=>{let l=i(o),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(l=>l.long).map(l=>l.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=Ee(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this._args.length,i=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),t=Ee(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e} `),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this._args.map(i=>Vt(i));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=x.basename(e,x.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);V(this).reverse().forEach(s=>s.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this.emit(this._helpLongFlag),this.emit("afterHelp",i),V(this).forEach(s=>s.emit("afterAllHelp",i))}helpOption(e,t){if(typeof e=="boolean")return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;let i=kt(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,s=>{let o;typeof t=="function"?o=t({error:s.error,command:s.command}):o=t,o&&s.write(`${o} -`)}),this}};function ve(r,e){r._hasHelpOption&&e.find(i=>i===r._helpLongFlag||i===r._helpShortFlag)&&(r.outputHelp(),r._exit(0,"commander.helpDisplayed","(outputHelp)"))}function Se(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],i=s[3],n=s[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}function V(r){let e=[];for(let t=r;t;t=t.parent)e.push(t);return e}$e.Command=N});var ke=O((C,Ne)=>{var{Argument:Rt}=P(),{Command:Fe}=Te(),{CommanderError:It,InvalidArgumentError:Ve}=F(),{Help:Dt}=X(),{Option:Mt}=te();C=Ne.exports=new Fe;C.program=C;C.Argument=Rt;C.Command=Fe;C.CommanderError=It;C.Help=Dt;C.InvalidArgumentError=Ve;C.InvalidOptionArgumentError=Ve;C.Option=Mt});var Ke=O((Li,Zt)=>{Zt.exports=["|/-\\","\u2802-\u2013\u2014\u2013-","\u25D0\u25D3\u25D1\u25D2","\u25F4\u25F7\u25F6\u25F5","\u25F0\u25F3\u25F2\u25F1","\u2596\u2598\u259D\u2597","\u25A0\u25A1\u25AA\u25AB","\u258C\u2580\u2590\u2584","\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u258E\u258D\u258C\u258B\u258A\u2589","\u2581\u2583\u2584\u2585\u2586\u2587\u2588\u2587\u2586\u2585\u2584\u2583","\u2190\u2196\u2191\u2197\u2192\u2198\u2193\u2199","\u2524\u2518\u2534\u2514\u251C\u250C\u252C\u2510","\u25E2\u25E3\u25E4\u25E5",".oO\xB0Oo.",".oO@*",["\u{1F30D}","\u{1F30E}","\u{1F30F}"],"\u25E1\u25E1 \u2299\u2299 \u25E0\u25E0","\u2631\u2632\u2634","\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F","\u280B\u2819\u281A\u281E\u2816\u2826\u2834\u2832\u2833\u2813","\u2804\u2806\u2807\u280B\u2819\u2838\u2830\u2820\u2830\u2838\u2819\u280B\u2807\u2806","\u280B\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B","\u2801\u2809\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2824\u2804\u2804\u2824\u2834\u2832\u2812\u2802\u2802\u2812\u281A\u2819\u2809\u2801","\u2808\u2809\u280B\u2813\u2812\u2810\u2810\u2812\u2816\u2826\u2824\u2820\u2820\u2824\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B\u2809\u2808","\u2801\u2801\u2809\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2824\u2804\u2804\u2824\u2820\u2820\u2824\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B\u2809\u2808\u2808","\u2884\u2882\u2881\u2841\u2848\u2850\u2860","\u28B9\u28BA\u28BC\u28F8\u28C7\u2867\u2857\u284F","\u28FE\u28FD\u28FB\u28BF\u287F\u28DF\u28EF\u28F7","\u2801\u2802\u2804\u2840\u2880\u2820\u2810\u2808",["\u{1F311}","\u{1F312}","\u{1F313}","\u{1F314}","\u{1F315}","\u{1F31D}","\u{1F316}","\u{1F317}","\u{1F318}","\u{1F31A}"],["\u{1F55B}","\u{1F550}","\u{1F551}","\u{1F552}","\u{1F553}","\u{1F554}","\u{1F555}","\u{1F556}","\u{1F557}","\u{1F558}","\u{1F559}","\u{1F55A}"]]});var Ze=O(Xe=>{var Je=require("readline"),ze=0,Qe=60;function ei(r){this.clearLine(this.stream),this.stream.write(r)}var g=function(r){if(!(this instanceof g))return new g(r);typeof r=="string"?r={text:r}:r||(r={}),this.text=r.text||"",this.setSpinnerString(ze),this.setSpinnerDelay(Qe),this.onTick=r.onTick||ei,this.stream=r.stream||process.stdout};g.spinners=Ke();g.setDefaultSpinnerString=function(r){return ze=r,this};g.setDefaultSpinnerDelay=function(r){return Qe=r,this};g.prototype.start=function(){if(this.stream===process.stdout&&this.stream.isTTY!==!0)return this;var r=0,e=this,t=function(){var i=e.text.indexOf("%s")>-1?e.text.replace("%s",e.chars[r]):e.chars[r]+" "+e.text;e.onTick(i),r=++r%e.chars.length};return t(),this.id=setInterval(t,this.delay),this};g.prototype.isSpinning=function(){return this.id!==void 0};g.prototype.setSpinnerDelay=function(r){return this.delay=r,this};g.prototype.setSpinnerString=function(r){let e=ii(r,this.spinners);return this.chars=Array.isArray(e)?e:e.split(""),this};g.prototype.setSpinnerTitle=function(r){return this.text=r,this};g.prototype.stop=function(r){return this.isSpinning===!1?this:(clearInterval(this.id),this.id=void 0,r&&this.clearLine(this.stream),this)};g.prototype.clearLine=function(r){return Je.clearLine(r,0),Je.cursorTo(r,0),this};function ti(r){return typeof r=="number"&&r%1===0}function ii(r,e){if(!ti(r))return r+"";var t=g.spinners.length;return r=r>=t?0:r,r=r<0?t+r:r,g.spinners[r]}Xe.Spinner=g});var ai={};ct(ai,{ACCOUNT_PATH:()=>si,LEDGER_PATH:()=>le,LOG_PATH:()=>fe,SOLV_ROOT:()=>de,USER:()=>ni,VOTE_ACCOUNT_PATH:()=>ri,WD:()=>st,program:()=>E});module.exports=pt(ai);var me=S(Oe());var He=S(ke(),1),{program:_i,createCommand:bi,createArgument:Oi,createOption:Ci,CommanderError:Ai,InvalidArgumentError:xi,InvalidOptionArgumentError:wi,Command:Re,Argument:yi,Option:Ei,Help:vi}=He.default;var Ie="0.1.6";var se=require("child_process");var oe=async r=>{let e=[`sh -c "$(curl -sSfL https://release.solana.com/v${r}/install)"`];(0,se.spawnSync)(e.join(" && "),{shell:!0,stdio:"inherit"})},ae=async r=>{let e=[`solana-validator --ledger ${le} exit --max-delinquent-stake ${r} --monitor`];(0,se.spawnSync)(e.join(" && "),{shell:!0,stdio:"inherit"})};var De=(r=0)=>e=>`\x1B[${e+r}m`,Me=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,je=(r=0)=>(e,t,i)=>`\x1B[${38+r};2;${e};${t};${i}m`,f={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Vi=Object.keys(f.modifier),jt=Object.keys(f.color),Pt=Object.keys(f.bgColor),Ni=[...jt,...Pt];function Lt(){let r=new Map;for(let[e,t]of Object.entries(f)){for(let[i,n]of Object.entries(t))f[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[i]=f[i],r.set(n[0],n[1]);Object.defineProperty(f,e,{value:t,enumerable:!1})}return Object.defineProperty(f,"codes",{value:r,enumerable:!1}),f.color.close="\x1B[39m",f.bgColor.close="\x1B[49m",f.color.ansi=De(),f.color.ansi256=Me(),f.color.ansi16m=je(),f.bgColor.ansi=De(10),f.bgColor.ansi256=Me(10),f.bgColor.ansi16m=je(10),Object.defineProperties(f,{rgbToAnsi256:{value(e,t,i){return e===t&&t===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;i.length===3&&(i=[...i].map(s=>s+s).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>f.rgbToAnsi256(...f.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,i,n;if(e>=232)t=((e-232)*10+8)/255,i=t,n=t;else{e-=16;let l=e%36;t=Math.floor(e/36)/5,i=Math.floor(l/6)/5,n=l%6/5}let s=Math.max(t,i,n)*2;if(s===0)return 30;let o=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(t));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>f.ansi256ToAnsi(f.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>f.ansi256ToAnsi(f.hexToAnsi256(e)),enumerable:!1}}),f}var qt=Lt(),A=qt;var B=S(require("node:process"),1),Le=S(require("node:os"),1),ue=S(require("node:tty"),1);function b(r,e=globalThis.Deno?globalThis.Deno.args:B.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",i=e.indexOf(t+r),n=e.indexOf("--");return i!==-1&&(n===-1||i=2,has16m:r>=3}}function Ut(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let i=Bt();i!==void 0&&(q=i);let n=t?q:i;if(n===0)return 0;if(t){if(b("color=16m")||b("color=full")||b("color=truecolor"))return 3;if(b("color=256"))return 2}if("TF_BUILD"in m&&"AGENT_NAME"in m)return 1;if(r&&!e&&n===void 0)return 0;let s=n||0;if(m.TERM==="dumb")return s;if(B.default.platform==="win32"){let o=Le.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in m)return"GITHUB_ACTIONS"in m||"GITEA_ACTIONS"in m?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in m)||m.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor"||m.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in m){let o=Number.parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:s}function Pe(r,e={}){let t=Ut(r,{streamIsTTY:r&&r.isTTY,...e});return Wt(t)}var Gt={stdout:Pe({isTTY:ue.default.isatty(1)}),stderr:Pe({isTTY:ue.default.isatty(2)})},qe=Gt;function Be(r,e,t){let i=r.indexOf(e);if(i===-1)return r;let n=e.length,s=0,o="";do o+=r.slice(s,i)+e+t,s=i+n,i=r.indexOf(e,s);while(i!==-1);return o+=r.slice(s),o}function We(r,e,t,i){let n=0,s="";do{let o=r[i-1]==="\r";s+=r.slice(n,o?i-1:i)+e+(o?`\r +`)}),this}};function ve(r,e){r._hasHelpOption&&e.find(i=>i===r._helpLongFlag||i===r._helpShortFlag)&&(r.outputHelp(),r._exit(0,"commander.helpDisplayed","(outputHelp)"))}function Se(r){return r.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],i=s[3],n=s[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}function V(r){let e=[];for(let t=r;t;t=t.parent)e.push(t);return e}$e.Command=N});var ke=O((C,Ne)=>{var{Argument:Rt}=P(),{Command:Fe}=Te(),{CommanderError:It,InvalidArgumentError:Ve}=F(),{Help:Dt}=X(),{Option:Mt}=te();C=Ne.exports=new Fe;C.program=C;C.Argument=Rt;C.Command=Fe;C.CommanderError=It;C.Help=Dt;C.InvalidArgumentError=Ve;C.InvalidOptionArgumentError=Ve;C.Option=Mt});var Ke=O((Li,Zt)=>{Zt.exports=["|/-\\","\u2802-\u2013\u2014\u2013-","\u25D0\u25D3\u25D1\u25D2","\u25F4\u25F7\u25F6\u25F5","\u25F0\u25F3\u25F2\u25F1","\u2596\u2598\u259D\u2597","\u25A0\u25A1\u25AA\u25AB","\u258C\u2580\u2590\u2584","\u2589\u258A\u258B\u258C\u258D\u258E\u258F\u258E\u258D\u258C\u258B\u258A\u2589","\u2581\u2583\u2584\u2585\u2586\u2587\u2588\u2587\u2586\u2585\u2584\u2583","\u2190\u2196\u2191\u2197\u2192\u2198\u2193\u2199","\u2524\u2518\u2534\u2514\u251C\u250C\u252C\u2510","\u25E2\u25E3\u25E4\u25E5",".oO\xB0Oo.",".oO@*",["\u{1F30D}","\u{1F30E}","\u{1F30F}"],"\u25E1\u25E1 \u2299\u2299 \u25E0\u25E0","\u2631\u2632\u2634","\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F","\u280B\u2819\u281A\u281E\u2816\u2826\u2834\u2832\u2833\u2813","\u2804\u2806\u2807\u280B\u2819\u2838\u2830\u2820\u2830\u2838\u2819\u280B\u2807\u2806","\u280B\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B","\u2801\u2809\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2824\u2804\u2804\u2824\u2834\u2832\u2812\u2802\u2802\u2812\u281A\u2819\u2809\u2801","\u2808\u2809\u280B\u2813\u2812\u2810\u2810\u2812\u2816\u2826\u2824\u2820\u2820\u2824\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B\u2809\u2808","\u2801\u2801\u2809\u2819\u281A\u2812\u2802\u2802\u2812\u2832\u2834\u2824\u2804\u2804\u2824\u2820\u2820\u2824\u2826\u2816\u2812\u2810\u2810\u2812\u2813\u280B\u2809\u2808\u2808","\u2884\u2882\u2881\u2841\u2848\u2850\u2860","\u28B9\u28BA\u28BC\u28F8\u28C7\u2867\u2857\u284F","\u28FE\u28FD\u28FB\u28BF\u287F\u28DF\u28EF\u28F7","\u2801\u2802\u2804\u2840\u2880\u2820\u2810\u2808",["\u{1F311}","\u{1F312}","\u{1F313}","\u{1F314}","\u{1F315}","\u{1F31D}","\u{1F316}","\u{1F317}","\u{1F318}","\u{1F31A}"],["\u{1F55B}","\u{1F550}","\u{1F551}","\u{1F552}","\u{1F553}","\u{1F554}","\u{1F555}","\u{1F556}","\u{1F557}","\u{1F558}","\u{1F559}","\u{1F55A}"]]});var Ze=O(Xe=>{var Je=require("readline"),ze=0,Qe=60;function ei(r){this.clearLine(this.stream),this.stream.write(r)}var g=function(r){if(!(this instanceof g))return new g(r);typeof r=="string"?r={text:r}:r||(r={}),this.text=r.text||"",this.setSpinnerString(ze),this.setSpinnerDelay(Qe),this.onTick=r.onTick||ei,this.stream=r.stream||process.stdout};g.spinners=Ke();g.setDefaultSpinnerString=function(r){return ze=r,this};g.setDefaultSpinnerDelay=function(r){return Qe=r,this};g.prototype.start=function(){if(this.stream===process.stdout&&this.stream.isTTY!==!0)return this;var r=0,e=this,t=function(){var i=e.text.indexOf("%s")>-1?e.text.replace("%s",e.chars[r]):e.chars[r]+" "+e.text;e.onTick(i),r=++r%e.chars.length};return t(),this.id=setInterval(t,this.delay),this};g.prototype.isSpinning=function(){return this.id!==void 0};g.prototype.setSpinnerDelay=function(r){return this.delay=r,this};g.prototype.setSpinnerString=function(r){let e=ii(r,this.spinners);return this.chars=Array.isArray(e)?e:e.split(""),this};g.prototype.setSpinnerTitle=function(r){return this.text=r,this};g.prototype.stop=function(r){return this.isSpinning===!1?this:(clearInterval(this.id),this.id=void 0,r&&this.clearLine(this.stream),this)};g.prototype.clearLine=function(r){return Je.clearLine(r,0),Je.cursorTo(r,0),this};function ti(r){return typeof r=="number"&&r%1===0}function ii(r,e){if(!ti(r))return r+"";var t=g.spinners.length;return r=r>=t?0:r,r=r<0?t+r:r,g.spinners[r]}Xe.Spinner=g});var ai={};ct(ai,{ACCOUNT_PATH:()=>si,LEDGER_PATH:()=>le,LOG_PATH:()=>fe,SOLV_ROOT:()=>de,USER:()=>ni,VOTE_ACCOUNT_PATH:()=>ri,WD:()=>st,program:()=>E});module.exports=pt(ai);var me=S(Oe());var He=S(ke(),1),{program:_i,createCommand:bi,createArgument:Oi,createOption:Ci,CommanderError:Ai,InvalidArgumentError:xi,InvalidOptionArgumentError:wi,Command:Re,Argument:yi,Option:Ei,Help:vi}=He.default;var Ie="0.1.7";var se=require("child_process");var oe=async r=>{let e=[`sh -c "$(curl -sSfL https://release.solana.com/v${r}/install)"`];(0,se.spawnSync)(e.join(" && "),{shell:!0,stdio:"inherit"})},ae=async r=>{let e=[`solana-validator --ledger ${le} exit --max-delinquent-stake ${r} --monitor`];(0,se.spawnSync)(e.join(" && "),{shell:!0,stdio:"inherit"})};var De=(r=0)=>e=>`\x1B[${e+r}m`,Me=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,je=(r=0)=>(e,t,i)=>`\x1B[${38+r};2;${e};${t};${i}m`,f={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Vi=Object.keys(f.modifier),jt=Object.keys(f.color),Pt=Object.keys(f.bgColor),Ni=[...jt,...Pt];function Lt(){let r=new Map;for(let[e,t]of Object.entries(f)){for(let[i,n]of Object.entries(t))f[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[i]=f[i],r.set(n[0],n[1]);Object.defineProperty(f,e,{value:t,enumerable:!1})}return Object.defineProperty(f,"codes",{value:r,enumerable:!1}),f.color.close="\x1B[39m",f.bgColor.close="\x1B[49m",f.color.ansi=De(),f.color.ansi256=Me(),f.color.ansi16m=je(),f.bgColor.ansi=De(10),f.bgColor.ansi256=Me(10),f.bgColor.ansi16m=je(10),Object.defineProperties(f,{rgbToAnsi256:{value(e,t,i){return e===t&&t===i?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;i.length===3&&(i=[...i].map(s=>s+s).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>f.rgbToAnsi256(...f.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,i,n;if(e>=232)t=((e-232)*10+8)/255,i=t,n=t;else{e-=16;let l=e%36;t=Math.floor(e/36)/5,i=Math.floor(l/6)/5,n=l%6/5}let s=Math.max(t,i,n)*2;if(s===0)return 30;let o=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(t));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>f.ansi256ToAnsi(f.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>f.ansi256ToAnsi(f.hexToAnsi256(e)),enumerable:!1}}),f}var qt=Lt(),A=qt;var B=S(require("node:process"),1),Le=S(require("node:os"),1),ue=S(require("node:tty"),1);function b(r,e=globalThis.Deno?globalThis.Deno.args:B.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",i=e.indexOf(t+r),n=e.indexOf("--");return i!==-1&&(n===-1||i=2,has16m:r>=3}}function Ut(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let i=Bt();i!==void 0&&(q=i);let n=t?q:i;if(n===0)return 0;if(t){if(b("color=16m")||b("color=full")||b("color=truecolor"))return 3;if(b("color=256"))return 2}if("TF_BUILD"in m&&"AGENT_NAME"in m)return 1;if(r&&!e&&n===void 0)return 0;let s=n||0;if(m.TERM==="dumb")return s;if(B.default.platform==="win32"){let o=Le.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in m)return"GITHUB_ACTIONS"in m||"GITEA_ACTIONS"in m?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in m)||m.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor"||m.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in m){let o=Number.parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:s}function Pe(r,e={}){let t=Ut(r,{streamIsTTY:r&&r.isTTY,...e});return Wt(t)}var Gt={stdout:Pe({isTTY:ue.default.isatty(1)}),stderr:Pe({isTTY:ue.default.isatty(2)})},qe=Gt;function Be(r,e,t){let i=r.indexOf(e);if(i===-1)return r;let n=e.length,s=0,o="";do o+=r.slice(s,i)+e+t,s=i+n,i=r.indexOf(e,s);while(i!==-1);return o+=r.slice(s),o}function We(r,e,t,i){let n=0,s="";do{let o=r[i-1]==="\r";s+=r.slice(n,o?i-1:i)+e+(o?`\r `:` `)+t,n=i+1,i=r.indexOf(` `,n)}while(i!==-1);return s+=r.slice(n),s}var{stdout:Ue,stderr:Ge}=qe,he=Symbol("GENERATOR"),$=Symbol("STYLER"),k=Symbol("IS_EMPTY"),Ye=["ansi","ansi","ansi256","ansi16m"],T=Object.create(null),Yt=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Ue?Ue.level:0;r.level=e.level===void 0?t:e.level};var Kt=r=>{let e=(...t)=>t.join(" ");return Yt(e,r),Object.setPrototypeOf(e,H.prototype),e};function H(r){return Kt(r)}Object.setPrototypeOf(H.prototype,Function.prototype);for(let[r,e]of Object.entries(A))T[r]={get(){let t=W(this,pe(e.open,e.close,this[$]),this[k]);return Object.defineProperty(this,r,{value:t}),t}};T.visible={get(){let r=W(this,this[$],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var ce=(r,e,t,...i)=>r==="rgb"?e==="ansi16m"?A[t].ansi16m(...i):e==="ansi256"?A[t].ansi256(A.rgbToAnsi256(...i)):A[t].ansi(A.rgbToAnsi(...i)):r==="hex"?ce("rgb",e,t,...A.hexToRgb(...i)):A[t][r](...i),Jt=["rgb","hex","ansi256"];for(let r of Jt){T[r]={get(){let{level:t}=this;return function(...i){let n=pe(ce(r,Ye[t],"color",...i),A.color.close,this[$]);return W(this,n,this[k])}}};let e="bg"+r[0].toUpperCase()+r.slice(1);T[e]={get(){let{level:t}=this;return function(...i){let n=pe(ce(r,Ye[t],"bgColor",...i),A.bgColor.close,this[$]);return W(this,n,this[k])}}}}var zt=Object.defineProperties(()=>{},{...T,level:{enumerable:!0,get(){return this[he].level},set(r){this[he].level=r}}}),pe=(r,e,t)=>{let i,n;return t===void 0?(i=r,n=e):(i=t.openAll+r,n=e+t.closeAll),{open:r,close:e,openAll:i,closeAll:n,parent:t}},W=(r,e,t)=>{let i=(...n)=>Qt(i,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(i,zt),i[he]=r,i[$]=e,i[k]=t,i},Qt=(r,e)=>{if(r.level<=0||!e)return r[k]?"":e;let t=r[$];if(t===void 0)return e;let{openAll:i,closeAll:n}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Be(e,t.close,t.open),t=t.parent;let s=e.indexOf(` `);return s!==-1&&(e=We(e,n,i,s)),i+e+n};Object.defineProperties(H.prototype,T);var Xt=H(),ji=H({level:Ge?Ge.level:0});var y=Xt;var et=S(Ze()),R;(t=>(t.normal=i=>{console.log(y.white(i))},t.syncSpinner=i=>{let n=new et.Spinner(y.white(i)+` %s -`);try{return n.setSpinnerString(18),n.start(),n}catch(s){throw n.stop(!0),new Error(`syncSpinner Error: ${s}`)}}))(R||={});var tt=async()=>{let r=E.command("update").description("Update Solana Validator Node");r.command("solana").alias("s").description("Update Solana Version").argument("","Solana Version e.g. 1.16.7").action(async e=>{let t=R.syncSpinner(`\u2714\uFE0F Updating Solana to ${y.green(e)}`);await oe(e),t.stop(!0)}),r.command("monitor").alias("m").description("Monitor Update").argument("","Max Delinquent Stake e.g. 10").action(async e=>{let t=R.syncSpinner(`\u2714\uFE0F Monitoring Update with Max Delinquent Stake ${y.green(e)}`);await ae(e),t.stop(!0)}),r.command("all").alias("a").description("Update Solana Version and Monitor Update").argument("","Solana Version e.g. 1.16.7").argument("","Max Delinquent Stake e.g. 10").action(async(e,t)=>{let i=R.syncSpinner(`\u2714\uFE0F Updating Solana to ${y.green(e)} and Monitoring Update with Max Delinquent Stake ${y.green(t)}`);await oe(e),await ae(t),i.stop(!0)})};var it=require("child_process"),nt=async r=>{try{let e=`tail -f ${fe}/solana-validator.log`;r.all?e+=" | grep '(WARN|ERR)'":r.info?e+=" | grep INFO":r.warning?e+=" | grep WARN":e+=" | grep ERR",(0,it.spawnSync)(e,{shell:!0,stdio:"inherit"})}catch(e){throw new Error(`tail Error: ${e}`)}};var rt=async()=>{E.command("log").description("log commands").command("tail").alias("t").description("tail logs").option("-i, --info","Follow INFO output",!1).option("-w, --warning","Follow WARN output",!1).option("-e, --error","Follow ERR output",!1).option("-a, --all","Follow WARN and ERR output",!0).action(async e=>{await nt(e)})};me.default.config();var ni=process.env.SOLV_USER||"solv",de="/mt/solana",st=`${de}/solana-validator`,fe=`${st}/logs`,ri=`${de}/vote-account.json`,si="/mt/solana-accounts",le="/mt/ledger/validator-ledger",E=new Re;E.name("solv").description("CLI for Solana Validators").version(Ie);me.default.config();async function oi(){try{E.command("solv").description("CLI for Solana Validators").action(()=>{console.log("solv")}),await tt(),await rt(),await E.parseAsync(process.argv)}catch(r){console.log(r)}}oi();0&&(module.exports={ACCOUNT_PATH,LEDGER_PATH,LOG_PATH,SOLV_ROOT,USER,VOTE_ACCOUNT_PATH,WD,program}); +`);try{return n.setSpinnerString(18),n.start(),n}catch(s){throw n.stop(!0),new Error(`syncSpinner Error: ${s}`)}}))(R||={});var tt=async()=>{let r=E.command("update").description("Update Solana Validator Node");r.command("solana").alias("s").description("Update Solana Version").argument("","Solana Version e.g. 1.16.7").action(async e=>{let t=R.syncSpinner(`\u2714\uFE0F Updating Solana to ${y.green(e)}`);await oe(e),t.stop(!0)}),r.command("monitor").alias("m").description("Monitor Update").argument("","Max Delinquent Stake e.g. 10").action(async e=>{let t=R.syncSpinner(`\u2714\uFE0F Monitoring Update with Max Delinquent Stake ${y.green(e)}`);await ae(e),t.stop(!0)}),r.command("all").alias("a").description("Update Solana Version and Monitor Update").argument("","Solana Version e.g. 1.16.7").argument("","Max Delinquent Stake e.g. 10").action(async(e,t)=>{let i=R.syncSpinner(`\u2714\uFE0F Updating Solana to ${y.green(e)} and Monitoring Update with Max Delinquent Stake ${y.green(t)}`);await oe(e),await ae(t),i.stop(!0)})};var it=require("child_process"),nt=async r=>{try{let e=`tail -f ${fe}/solana-validator.log`;r.all?e+=" | grep '(WARN|ERR)'":r.info?e+=" | grep INFO":r.warning?e+=" | grep WARN":e+=" | grep ERR",(0,it.spawnSync)(e,{shell:!0,stdio:"inherit"})}catch(e){throw new Error(`tail Error: ${e}`)}};var rt=async()=>{E.command("log").description("log commands").command("tail").alias("t").description("tail logs").option("-i, --info","Follow INFO output",!1).option("-w, --warning","Follow WARN output",!1).option("-e, --error","Follow ERR output",!1).option("-a, --all","Follow WARN and ERR output",!0).action(async e=>{await nt(e)})};me.default.config();var ni=process.env.SOLV_USER||"solv",de="/mt/solana",st=`${de}/solana-validator`,fe=`${st}/log`,ri=`${de}/vote-account.json`,si="/mt/solana-accounts",le="/mt/ledger/validator-ledger",E=new Re;E.name("solv").description("CLI for Solana Validators").version(Ie);me.default.config();async function oi(){try{E.command("solv").description("CLI for Solana Validators").action(()=>{console.log("solv")}),await tt(),await rt(),await E.parseAsync(process.argv)}catch(r){console.log(r)}}oi();0&&(module.exports={ACCOUNT_PATH,LEDGER_PATH,LOG_PATH,SOLV_ROOT,USER,VOTE_ACCOUNT_PATH,WD,program}); diff --git a/package.json b/package.json index e5133c1..da0720a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@epics-dao/solv", - "version": "0.1.6", + "version": "0.1.7", "description": "Solana Validator CLI SOLV", "main": "dist/index.js", "repository": "https://github.com/EpicsDAO/solv", diff --git a/src/index.ts b/src/index.ts index 5d978df..b1ee603 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ dotenv.config() export const USER = process.env.SOLV_USER || 'solv' export const SOLV_ROOT = '/mt/solana' export const WD = `${SOLV_ROOT}/solana-validator` -export const LOG_PATH = `${WD}/logs` +export const LOG_PATH = `${WD}/log` export const VOTE_ACCOUNT_PATH = `${SOLV_ROOT}/vote-account.json` export const ACCOUNT_PATH = `/mt/solana-accounts` export const LEDGER_PATH = `/mt/ledger/validator-ledger` diff --git a/src/lib/version.ts b/src/lib/version.ts index 842959a..c8ab77d 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.6' \ No newline at end of file +export const VERSION = '0.1.7' \ No newline at end of file