hofii 0.0.3 → 0.1.0
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/main.js +48 -54
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,61 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`)},{title:"For more info, run any command with the `--help` flag",body:
|
|
5
|
-
`)})}let
|
|
6
|
-
`)})}if(this.examples.length>0)
|
|
7
|
-
`)});if(
|
|
8
|
-
${
|
|
3
|
+
var dn=Object.create;var{getPrototypeOf:gn,defineProperty:nt,getOwnPropertyNames:vn}=Object;var $n=Object.prototype.hasOwnProperty;function bn(e){return this[e]}var kn,wn,st=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?kn??=new WeakMap:wn??=new WeakMap,u=r.get(e);if(u)return u}n=e!=null?dn(gn(e)):{};let o=t||!e||!e.__esModule?nt(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of vn(e))if(!$n.call(o,a))nt(o,a,{get:bn.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var xn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ge=xn(function(vr,Ot){var Le={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`\x1B[${-e}D`;else if(e>0)n+=`\x1B[${e}C`;if(t<0)n+=`\x1B[${-t}A`;else if(t>0)n+=`\x1B[${t}B`;return n},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},ts={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},ns={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?Le.up():"");if(e)t+=Le.left;return t}};Ot.exports={cursor:Le,scroll:ts,erase:ns,beep:"\x07"}});function Me(e){return e==null?[]:Array.isArray(e)?e:[e]}function _n(e,t,n,s){var r,u=e[t],o=~s.string.indexOf(t)?n==null||n===!0?"":String(n):typeof n==="boolean"?n:~s.boolean.indexOf(t)?n==="false"?!1:n==="true"||(e._.push((r=+n,r*0===0)?r:n),!!n):(r=+n,r*0===0)?r:n;e[t]=u==null?o:Array.isArray(u)?u.concat(o):[u,o]}function En(e,t){e=e||[],t=t||{};var n,s,r,u,o,a={_:[]},i=0,l=0,c=0,f=e.length;let h=t.alias!==void 0,g=t.unknown!==void 0,m=t.default!==void 0;if(t.alias=t.alias||{},t.string=Me(t.string),t.boolean=Me(t.boolean),h)for(n in t.alias){s=t.alias[n]=Me(t.alias[n]);for(i=0;i<s.length;i++)(t.alias[s[i]]=s.concat(n)).splice(i,1)}for(i=t.boolean.length;i-- >0;){s=t.alias[t.boolean[i]]||[];for(l=s.length;l-- >0;)t.boolean.push(s[l])}for(i=t.string.length;i-- >0;){s=t.alias[t.string[i]]||[];for(l=s.length;l-- >0;)t.string.push(s[l])}if(m){for(n in t.default)if(u=typeof t.default[n],s=t.alias[n]=t.alias[n]||[],t[u]!==void 0){t[u].push(n);for(i=0;i<s.length;i++)t[u].push(s[i])}}let y=g?Object.keys(t.alias):[];for(i=0;i<f;i++){if(r=e[i],r==="--"){a._=a._.concat(e.slice(++i));break}for(l=0;l<r.length;l++)if(r.charCodeAt(l)!==45)break;if(l===0)a._.push(r);else if(r.substring(l,l+3)==="no-"){if(u=r.substring(l+3),g&&!~y.indexOf(u))return t.unknown(r);a[u]=!1}else{for(c=l+1;c<r.length;c++)if(r.charCodeAt(c)===61)break;u=r.substring(l,c),o=r.substring(++c)||i+1===f||(""+e[i+1]).charCodeAt(0)===45||e[++i],s=l===2?[u]:u;for(c=0;c<s.length;c++){if(u=s[c],g&&!~y.indexOf(u))return t.unknown("-".repeat(l)+u);_n(a,u,c+1<s.length||o,t)}}}if(m){for(n in t.default)if(a[n]===void 0)a[n]=t.default[n]}if(h)for(n in a){s=t.alias[n]||[];while(s.length>0)a[s.shift()]=a[n]}return a}function ut(e){return e.replace(/[<[].+/,"").trim()}function In(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,s=[],r=(a)=>{let i=!1,l=a[1];if(l.startsWith("..."))l=l.slice(3),i=!0;return{required:a[0].startsWith("<"),value:l,variadic:i}},u;while(u=t.exec(e))s.push(r(u));let o;while(o=n.exec(e))s.push(r(o));return s}function Sn(e){let t={alias:{},boolean:[]};for(let[n,s]of e.entries()){if(s.names.length>1)t.alias[s.names[0]]=s.names.slice(1);if(s.isBoolean)if(s.negated){if(!e.some((r,u)=>u!==n&&r.names.some((o)=>s.names.includes(o))&&typeof r.required==="boolean"))t.boolean.push(s.names[0])}else t.boolean.push(s.names[0])}return t}function rt(e){return e.sort((t,n)=>t.length>n.length?-1:1)[0]}function it(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function Cn(e){return e.replaceAll(/([a-z])-([a-z])/g,(t,n,s)=>n+s.toUpperCase())}function An(e,t,n){let s=e;for(let r=0;r<t.length;r++){let u=t[r];if(r===t.length-1){s[u]=n;return}if(s[u]==null){let o=+t[r+1]>-1;s[u]=o?[]:{}}s=s[u]}}function On(e,t){for(let n of Object.keys(t)){let s=t[n];if(s.shouldTransform){if(e[n]=[e[n]].flat(),typeof s.transformFunction==="function")e[n]=e[n].map(s.transformFunction)}}}function Mn(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function ot(e){return e.split(".").map((t,n)=>n===0?Cn(t):t).join(".")}var ae=class extends Error{constructor(e){super(e);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(e).stack}},Dn=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(e,t,n){if(this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replaceAll(".*",""),this.negated=!1,this.names=ut(e).split(",").map((s)=>{let r=s.trim().replace(/^-{1,2}/,"");if(r.startsWith("no-"))this.negated=!0,r=r.replace(/^no-/,"");return ot(r)}).sort((s,r)=>s.length>r.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}},De,le;if(typeof process<"u"){let e;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")e="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")e="bun";else e="node";le=`${process.platform}-${process.arch} ${e}-${process.version}`,De=process.argv}else if(typeof navigator>"u")le="unknown";else le=`${navigator.platform} ${navigator.userAgent}`;var at=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(e,t,n={},s){this.rawName=e,this.description=t,this.config=n,this.cli=s,this.options=[],this.aliasNames=[],this.name=ut(e),this.args=In(e),this.examples=[]}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,n){let s=new Dn(e,t,n);return this.options.push(s),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}isMatched(e){return this.name===e||this.aliasNames.includes(e)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof lt}hasOption(e){return e=e.split(".")[0],this.options.find((t)=>t.names.includes(e))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:s,helpCallback:r}=this.cli.globalCommand,u=[{body:`${e}${n?`/${n}`:""}`}];if(u.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let a=rt(t.map((i)=>i.rawName));u.push({title:"Commands",body:t.map((i)=>` ${it(i.rawName,a.length)} ${i.description}`).join(`
|
|
4
|
+
`)},{title:"For more info, run any command with the `--help` flag",body:t.map((i)=>` $ ${e}${i.name===""?"":` ${i.name}`} --help`).join(`
|
|
5
|
+
`)})}let o=this.isGlobalCommand?s:[...this.options,...s||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)o=o.filter((a)=>a.name!=="version");if(o.length>0){let a=rt(o.map((i)=>i.rawName));u.push({title:"Options",body:o.map((i)=>` ${it(i.rawName,a.length)} ${i.description} ${i.config.default===void 0?"":`(default: ${i.config.default})`}`).join(`
|
|
6
|
+
`)})}if(this.examples.length>0)u.push({title:"Examples",body:this.examples.map((a)=>{if(typeof a==="function")return a(e);return a}).join(`
|
|
7
|
+
`)});if(r)u=r(u)||u;console.info(u.map((a)=>a.title?`${a.title}:
|
|
8
|
+
${a.body}`:a.body).join(`
|
|
9
9
|
|
|
10
|
-
`))}outputVersion(){let{name:Z}=this.cli,{versionNumber:J}=this.cli.globalCommand;if(J)console.info(`${Z}/${J} ${L0}`)}checkRequiredArgs(){let Z=this.args.filter((J)=>J.required).length;if(this.cli.args.length<Z)throw new U0(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:Z,globalCommand:J}=this.cli;if(!this.config.allowUnknownOptions){for(let Q of Object.keys(Z))if(Q!=="--"&&!this.hasOption(Q)&&!J.hasOption(Q))throw new U0(`Unknown option \`${Q.length>1?`--${Q}`:`-${Q}`}\``)}}checkOptionValue(){let{options:Z,globalCommand:J}=this.cli,Q=[...J.options,...this.options];for(let F of Q){let Y=Z[F.name.split(".")[0]];if(F.required){let H=Q.some((z)=>z.negated&&z.names.includes(F.name));if(Y===!0||Y===!1&&!H)throw new U0(`option \`${F.rawName}\` value is missing`)}}}checkUnusedArgs(){let Z=this.args.some((J)=>J.variadic)?1/0:this.args.length;if(Z<this.cli.args.length)throw new U0(`Unused args: ${this.cli.args.slice(Z).map((J)=>`\`${J}\``).join(", ")}`)}},G1=class extends M1{constructor(Z){super("@@global@@","",{},Z)}},p9=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(Z=""){super();this.name=Z,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new G1(this),this.globalCommand.usage("<command> [options]")}usage(Z){return this.globalCommand.usage(Z),this}command(Z,J,Q){let F=new M1(Z,J||"",Q,this);return F.globalCommand=this.globalCommand,this.commands.push(F),F}option(Z,J,Q){return this.globalCommand.option(Z,J,Q),this}help(Z){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=Z,this.showHelpOnExit=!0,this}version(Z,J="-v, --version"){return this.globalCommand.version(Z,J),this.showVersionOnExit=!0,this}example(Z){return this.globalCommand.example(Z),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:Z,options:J},Q,F){if(this.args=Z,this.options=J,Q)this.matchedCommand=Q;if(F)this.matchedCommandName=F;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(Z,{run:J=!0}={}){if(!Z){if(!k0)throw Error("No argv provided and runtime process argv is not available.");Z=k0}if(this.rawArgs=Z,!this.name)this.name=Z[1]?y9(Z[1]):"cli";let Q=!0;for(let Y of this.commands){let H=this.mri(Z.slice(2),Y),z=H.args[0];if(Y.isMatched(z)){Q=!1;let U={...H,args:H.args.slice(1)};this.setParsedInfo(U,Y,z),this.dispatchEvent(new CustomEvent(`command:${z}`,{detail:Y}))}}if(Q){for(let Y of this.commands)if(Y.isDefaultCommand){Q=!1;let H=this.mri(Z.slice(2),Y);this.setParsedInfo(H,Y),this.dispatchEvent(new CustomEvent("command:!",{detail:Y}))}}if(Q){let Y=this.mri(Z.slice(2));this.setParsedInfo(Y)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let F={args:this.args,options:this.options};if(J)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return F}mri(Z,J){let Q=[...this.globalCommand.options,...J?J.options:[]],F=h9(Q),Y=[],H=Z.indexOf("--");if(H!==-1)Y=Z.slice(H+1),Z=Z.slice(0,H);let z=S9(Z,F);z=Object.keys(z).reduce((X,M)=>{return{...X,[X1(M)]:z[M]}},{_:[]});let U=z._,W={"--":Y},L=J&&J.config.ignoreOptionDefaultValue?J.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,K=Object.create(null);for(let X of Q){if(!L&&X.config.default!==void 0)for(let M of X.names)W[M]=X.config.default;if(Array.isArray(X.config.type)&&K[X.name]===void 0)K[X.name]=Object.create(null),K[X.name].shouldTransform=!0,K[X.name].transformFunction=X.config.type[0]}for(let X of Object.keys(z))if(X!=="_")_9(W,X.split("."),z[X]),f9(W,K);return{args:U,options:W}}runMatchedCommand(){let{args:Z,options:J,matchedCommand:Q}=this;if(!Q||!Q.commandAction)return;Q.checkUnknownOptions(),Q.checkOptionValue(),Q.checkRequiredArgs(),Q.checkUnusedArgs();let F=[];return Q.args.forEach((Y,H)=>{if(Y.variadic)F.push(Z.slice(H));else F.push(Z[H])}),F.push(J),Q.commandAction.apply(this,F)}},j1=(Z="")=>new p9(Z);import V6 from"path";var K0,g9={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function V1(Z){if(!Z&&!K0)return g9;return{lang:Z?.lang??K0?.lang,message:Z?.message,abortEarly:Z?.abortEarly??K0?.abortEarly,abortPipeEarly:Z?.abortPipeEarly??K0?.abortPipeEarly}}var l9;function c9(Z){return l9?.get(Z)}var m9;function u9(Z){return m9?.get(Z)}var r9;function o9(Z,J){return r9?.get(Z)?.get(J)}function h0(Z){let J=typeof Z;if(J==="string")return`"${Z}"`;if(J==="number"||J==="bigint"||J==="boolean")return`${Z}`;if(J==="object"||J==="function")return(Z&&Object.getPrototypeOf(Z)?.constructor?.name)??"null";return J}function f(Z,J,Q,F,Y){let H=Y&&"input"in Y?Y.input:Q.value,z=Y?.expected??Z.expects??null,U=Y?.received??h0(H),W={kind:Z.kind,type:Z.type,input:H,expected:z,received:U,message:`Invalid ${J}: ${z?`Expected ${z} but r`:"R"}eceived ${U}`,requirement:Z.requirement,path:Y?.path,issues:Y?.issues,lang:F.lang,abortEarly:F.abortEarly,abortPipeEarly:F.abortPipeEarly},L=Z.kind==="schema",K=Y?.message??Z.message??o9(Z.reference,W.lang)??(L?u9(W.lang):null)??F.message??c9(W.lang);if(K!==void 0)W.message=typeof K==="function"?K(W):K;if(L)Q.typed=!1;if(Q.issues)Q.issues.push(W);else Q.issues=[W]}var N1=new WeakMap;function y(Z){let J=N1.get(Z);if(!J)J={version:1,vendor:"valibot",validate(Q){return Z["~run"]({value:Q},V1())}},N1.set(Z,J);return J}function B1(Z,J){let Q=[...new Set(Z)];if(Q.length>1)return`(${Q.join(` ${J} `)})`;return Q[0]??"never"}var v0=class extends Error{constructor(Z){super(Z[0].message);this.name="ValiError",this.issues=Z}};function n9(Z,J,Q){return typeof Z.fallback==="function"?Z.fallback(J,Q):Z.fallback}function q1(Z,J,Q){return typeof Z.default==="function"?Z.default(J,Q):Z.default}function $(Z,J){return{kind:"schema",type:"array",reference:$,expects:"Array",async:!1,item:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y=Q.value;if(Array.isArray(Y)){Q.typed=!0,Q.value=[];for(let H=0;H<Y.length;H++){let z=Y[H],U=this.item["~run"]({value:z},F);if(U.issues){let W={type:"array",origin:"value",input:Y,key:H,value:z};for(let L of U.issues){if(L.path)L.path.unshift(W);else L.path=[W];Q.issues?.push(L)}if(!Q.issues)Q.issues=U.issues;if(F.abortEarly){Q.typed=!1;break}}if(!U.typed)Q.typed=!1;Q.value.push(U.value)}}else f(this,"type",Q,F);return Q}}}function t(Z){return{kind:"schema",type:"boolean",reference:t,expects:"boolean",async:!1,message:Z,get "~standard"(){return y(this)},"~run"(J,Q){if(typeof J.value==="boolean")J.typed=!0;else f(this,"type",J,Q);return J}}}function _0(Z,J){return{kind:"schema",type:"literal",reference:_0,expects:h0(Z),async:!1,literal:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){if(Q.value===this.literal)Q.typed=!0;else f(this,"type",Q,F);return Q}}}function u(Z,J){return{kind:"schema",type:"object",reference:u,expects:"Object",async:!1,entries:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y=Q.value;if(Y&&typeof Y==="object"){Q.typed=!0,Q.value={};for(let H in this.entries){let z=this.entries[H];if(H in Y||(z.type==="exact_optional"||z.type==="optional"||z.type==="nullish")&&z.default!==void 0){let U=H in Y?Y[H]:q1(z),W=z["~run"]({value:U},F);if(W.issues){let L={type:"object",origin:"value",input:Y,key:H,value:U};for(let K of W.issues){if(K.path)K.path.unshift(L);else K.path=[L];Q.issues?.push(K)}if(!Q.issues)Q.issues=W.issues;if(F.abortEarly){Q.typed=!1;break}}if(!W.typed)Q.typed=!1;Q.value[H]=W.value}else if(z.fallback!==void 0)Q.value[H]=n9(z);else if(z.type!=="exact_optional"&&z.type!=="optional"&&z.type!=="nullish"){if(f(this,"key",Q,F,{input:void 0,expected:`"${H}"`,path:[{type:"object",origin:"key",input:Y,key:H,value:Y[H]}]}),F.abortEarly)break}}}else f(this,"type",Q,F);return Q}}}function Z0(Z,J){return{kind:"schema",type:"optional",reference:Z0,expects:`(${Z.expects} | undefined)`,async:!1,wrapped:Z,default:J,get "~standard"(){return y(this)},"~run"(Q,F){if(Q.value===void 0){if(this.default!==void 0)Q.value=q1(this,Q,F);if(Q.value===void 0)return Q.typed=!0,Q}return this.wrapped["~run"](Q,F)}}}function J0(Z,J){return{kind:"schema",type:"picklist",reference:J0,expects:B1(Z.map(h0),"|"),async:!1,options:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){if(this.options.includes(Q.value))Q.typed=!0;else f(this,"type",Q,F);return Q}}}function S(Z){return{kind:"schema",type:"string",reference:S,expects:"string",async:!1,message:Z,get "~standard"(){return y(this)},"~run"(J,Q){if(typeof J.value==="string")J.typed=!0;else f(this,"type",J,Q);return J}}}function w1(Z){let J;if(Z)for(let Q of Z)if(J)for(let F of Q.issues)J.push(F);else J=Q.issues;return J}function Q0(Z,J){return{kind:"schema",type:"union",reference:Q0,expects:B1(Z.map((Q)=>Q.expects),"|"),async:!1,options:Z,message:J,get "~standard"(){return y(this)},"~run"(Q,F){let Y,H,z;for(let U of this.options){let W=U["~run"]({value:Q.value},F);if(W.typed)if(W.issues)if(H)H.push(W);else H=[W];else{Y=W;break}else if(z)z.push(W);else z=[W]}if(Y)return Y;if(H){if(H.length===1)return H[0];f(this,"type",Q,F,{issues:w1(H)}),Q.typed=!0}else if(z?.length===1)return z[0];else f(this,"type",Q,F,{issues:w1(z)});return Q}}}function X0(Z,J,Q){let F=Z["~run"]({value:J},V1(Q));if(F.issues)throw new v0(F.issues);return F.value}function f0(Z,J){let Q={};for(let F in Z.entries)Q[F]=!J||J.includes(F)?Z0(Z.entries[F]):Z.entries[F];return{...Z,entries:Q,get "~standard"(){return y(this)}}}import{styleText as m0}from"util";import{stdout as n0,stdin as $1}from"process";import*as r from"readline";import L8 from"readline";var P1=(()=>{let Z=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(J)=>{let Q=0;Z.lastIndex=0;while(Z.test(J))Q+=1;return J.length-Q}})(),O1=(Z)=>{return Z===12288||Z>=65281&&Z<=65376||Z>=65504&&Z<=65510},b1=(Z)=>{return Z===8987||Z===9001||Z>=12272&&Z<=12287||Z>=12289&&Z<=12350||Z>=12441&&Z<=12543||Z>=12549&&Z<=12591||Z>=12593&&Z<=12686||Z>=12688&&Z<=12771||Z>=12783&&Z<=12830||Z>=12832&&Z<=12871||Z>=12880&&Z<=19903||Z>=65040&&Z<=65049||Z>=65072&&Z<=65106||Z>=65108&&Z<=65126||Z>=65128&&Z<=65131||Z>=127488&&Z<=127490||Z>=127504&&Z<=127547||Z>=127552&&Z<=127560||Z>=131072&&Z<=196605||Z>=196608&&Z<=262141};var i9=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,d9=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,C1=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,s9=/\t{1,1000}/y,R1=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,a9=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,e9=/\p{M}+/gu,t9={limit:1/0,ellipsis:""},A1=(Z,J={},Q={})=>{let F=J.limit??1/0,Y=J.ellipsis??"",H=J?.ellipsisWidth??(Y?A1(Y,t9,Q).width:0),z=0,U=Q.controlWidth??0,W=Q.tabWidth??8,L=Q.emojiWidth??2,K=2,X=Q.regularWidth??1,M=Q.wideWidth??2,N=[[a9,X],[i9,0],[d9,U],[s9,W],[R1,L],[C1,M]],j=0,w=0,k=Z.length,l=0,c=!1,x=k,h=Math.max(0,F-H),A=0,d=0,T=0,R=0;Z:while(!0){if(d>A||w>=k&&w>j){let m=Z.slice(A,d)||Z.slice(j,w);l=0;for(let i of m.replaceAll(e9,"")){let E=i.codePointAt(0)||0;if(O1(E))R=2;else if(b1(E))R=M;else R=X;if(T+R>h)x=Math.min(x,Math.max(A,j)+l);if(T+R>F){c=!0;break Z}l+=i.length,T+=R}A=d=0}if(w>=k)break Z;for(let m=0,i=N.length;m<i;m++){let[E,W0]=N[m];if(E.lastIndex=w,E.test(Z)){if(l=E===C1?P1(Z.slice(w,E.lastIndex)):E===R1?1:E.lastIndex-w,R=l*W0,T+R>h)x=Math.min(x,w+Math.floor((h-T)/W0));if(T+R>F){c=!0;break Z}T+=R,A=j,d=w,w=j=E.lastIndex;continue Z}}w+=1}return{width:c?h:T,index:c?x:k,truncated:c,ellipsed:c&&F>=H}},E1=A1;var Z8={limit:1/0,ellipsis:"",ellipsisWidth:0},J8=(Z,J={})=>{return E1(Z,Z8,J).width},b=J8;var G0="\x1B",S1="\x9B",Q8=39,$0="\x07",k1="[",F8="]",h1="m",p0=`${F8}8;;`,D1=new RegExp(`(?:\\${k1}(?<code>\\d+)m|\\${p0}(?<uri>.*)${$0})`,"y"),I1=(Z)=>{if(Z>=30&&Z<=37)return 39;if(Z>=90&&Z<=97)return 39;if(Z>=40&&Z<=47)return 49;if(Z>=100&&Z<=107)return 49;if(Z===1||Z===2)return 22;if(Z===3)return 23;if(Z===4)return 24;if(Z===7)return 27;if(Z===8)return 28;if(Z===9)return 29;if(Z===0)return 0;return},x1=(Z)=>`${G0}${k1}${Z}${h1}`,T1=(Z)=>`${G0}${p0}${Z}${$0}`,y0=(Z,J,Q)=>{let F=J[Symbol.iterator](),Y=!1,H=!1,z=Z.at(-1),U=z===void 0?0:b(z),W=F.next(),L=F.next(),K=0;while(!W.done){let X=W.value,M=b(X);if(U+M<=Q)Z[Z.length-1]+=X;else Z.push(X),U=0;if(X===G0||X===S1)Y=!0,H=J.startsWith(p0,K+1);if(Y){if(H){if(X===$0)Y=!1,H=!1}else if(X===h1)Y=!1}else if(U+=M,U===Q&&!L.done)Z.push(""),U=0;W=L,L=F.next(),K+=X.length}if(z=Z.at(-1),!U&&z!==void 0&&z.length&&Z.length>1)Z[Z.length-2]+=Z.pop()},Y8=(Z)=>{let J=Z.split(" "),Q=J.length;while(Q){if(b(J[Q-1]))break;Q--}if(Q===J.length)return Z;return J.slice(0,Q).join(" ")+J.slice(Q).join("")},H8=(Z,J,Q={})=>{if(Q.trim!==!1&&Z.trim()==="")return"";let F="",Y,H,z=Z.split(" "),U=[""],W=0;for(let X=0;X<z.length;X++){let M=z[X];if(Q.trim!==!1){let j=U.at(-1)??"",w=j.trimStart();if(j.length!==w.length)U[U.length-1]=w,W=b(w)}if(X!==0){if(W>=J&&(Q.wordWrap===!1||Q.trim===!1))U.push(""),W=0;if(W||Q.trim===!1)U[U.length-1]+=" ",W++}let N=b(M);if(Q.hard&&N>J){let j=J-W,w=1+Math.floor((N-j-1)/J);if(Math.floor((N-1)/J)<w)U.push("");y0(U,M,J),W=b(U.at(-1)??"");continue}if(W+N>J&&W&&N){if(Q.wordWrap===!1&&W<J){y0(U,M,J),W=b(U.at(-1)??"");continue}U.push(""),W=0}if(W+N>J&&Q.wordWrap===!1){y0(U,M,J),W=b(U.at(-1)??"");continue}U[U.length-1]+=M,W+=N}if(Q.trim!==!1)U=U.map((X)=>Y8(X));let L=U.join(`
|
|
11
|
-
`),
|
|
12
|
-
`){if(
|
|
13
|
-
`){if(
|
|
14
|
-
`)}var
|
|
15
|
-
`),
|
|
16
|
-
`),
|
|
17
|
-
`)
|
|
18
|
-
`).
|
|
19
|
-
`)
|
|
20
|
-
`)
|
|
21
|
-
`)
|
|
22
|
-
`)
|
|
23
|
-
`).
|
|
24
|
-
`)),this._prevFrame=Z;return}}this.output.write(P.erase.down())}this.output.write(Z),this.state==="initial"&&(this.state="active"),this._prevFrame=Z}}}function j8(Z,J){if(Z===void 0||J.length===0)return 0;let Q=J.findIndex((F)=>F.value===Z);return Q!==-1?Q:0}function N8(Z,J){return(J.label??String(J.value)).toLowerCase().includes(Z.toLowerCase())}function w8(Z,J){if(J)return Z?J:J[0]}var V8=class extends s{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#J=0;#Y="";#Z;#H;#z;get cursor(){return this.#J}get userInputWithCursor(){if(!this.userInput)return m0(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let J=this.userInput.slice(0,this.cursor),Q=this.userInput.slice(this.cursor,this.cursor+1),F=this.userInput.slice(this.cursor+1);return`${J}${m0("inverse",Q)}${F}`}get options(){return typeof this.#H=="function"?this.#H():this.#H}constructor(J){super(J),this.#H=J.options,this.#z=J.placeholder;let Q=this.options;this.filteredOptions=[...Q],this.multiple=J.multiple===!0,this.#Z=typeof J.options=="function"?J.filter:J.filter??N8;let F;if(J.initialValue&&Array.isArray(J.initialValue)?this.multiple?F=J.initialValue:F=J.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(F=[this.options[0]?.value]),F)for(let Y of F){let H=Q.findIndex((z)=>z.value===Y);H!==-1&&(this.toggleSelected(Y),this.#J=H)}this.focusedValue=this.options[this.#J]?.value,this.on("key",(Y,H)=>this.#Q(Y,H)),this.on("userInput",(Y)=>this.#F(Y))}_isActionKey(J,Q){return J==="\t"||this.multiple&&this.isNavigating&&Q.name==="space"&&J!==void 0&&J!==""}#Q(J,Q){let F=Q.name==="up",Y=Q.name==="down",H=Q.name==="return",z=this.userInput===""||this.userInput==="\t",U=this.#z,W=this.options,L=U!==void 0&&U!==""&&W.some((K)=>!K.disabled&&(this.#Z?this.#Z(U,K):!0));if(Q.name==="tab"&&z&&L){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(U,!0),this.isNavigating=!1;return}F||Y?(this.#J=u0(this.#J,F?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#J]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):H?this.value=w8(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(Q.name==="tab"||this.isNavigating&&Q.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(J){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(J)?this.selectedValues=this.selectedValues.filter((Q)=>Q!==J):this.selectedValues=[...this.selectedValues,J]:this.selectedValues=[J])}#F(J){if(J!==this.#Y){this.#Y=J;let Q=this.options;J&&this.#Z?this.filteredOptions=Q.filter((H)=>this.#Z?.(J,H)):this.filteredOptions=[...Q];let F=j8(this.focusedValue,this.filteredOptions);this.#J=u0(F,0,this.filteredOptions);let Y=this.filteredOptions[this.#J];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class d0 extends s{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(Z){super(Z,!1),this.value=!!Z.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(P.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var B8={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function f1(Z){return[...Z].map((J)=>B8[J])}function q8(Z){let J=new Intl.DateTimeFormat(Z,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),Q=[],F="/";for(let Y of J)Y.type==="literal"?F=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&Q.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:Q,separator:F}}function c0(Z){return Number.parseInt((Z||"0").replace(/_/g,"0"),10)||0}function w0(Z){return{year:c0(Z.year),month:c0(Z.month),day:c0(Z.day)}}function o0(Z,J){return new Date(Z||2001,J||1,0).getDate()}function m1(Z){let{year:J,month:Q,day:F}=w0(Z);if(!J||J<0||J>9999||!Q||Q<1||Q>12||!F||F<1)return;let Y=new Date(Date.UTC(J,Q-1,F));if(!(Y.getUTCFullYear()!==J||Y.getUTCMonth()!==Q-1||Y.getUTCDate()!==F))return{year:J,month:Q,day:F}}function y1(Z){let J=m1(Z);return J?new Date(Date.UTC(J.year,J.month-1,J.day)):void 0}function P8(Z,J,Q,F){let Y=Q?{year:Q.getUTCFullYear(),month:Q.getUTCMonth()+1,day:Q.getUTCDate()}:null,H=F?{year:F.getUTCFullYear(),month:F.getUTCMonth()+1,day:F.getUTCDate()}:null;return Z==="year"?{min:Y?.year??1,max:H?.year??9999}:Z==="month"?{min:Y&&J.year===Y.year?Y.month:1,max:H&&J.year===H.year?H.month:12}:{min:Y&&J.year===Y.year&&J.month===Y.month?Y.day:1,max:H&&J.year===H.year&&J.month===H.month?H.day:o0(J.year,J.month)}}class u1 extends s{#J;#Y;#Z;#H;#z;#Q={segmentIndex:0,positionInSegment:0};#F=!0;#W=null;inlineError="";get segmentCursor(){return{...this.#Q}}get segmentValues(){return{...this.#Z}}get segments(){return this.#J}get separator(){return this.#Y}get formattedValue(){return this.#X(this.#Z)}#X(Z){return this.#J.map((J)=>Z[J.type]).join(this.#Y)}#U(){this._setUserInput(this.#X(this.#Z)),this._setValue(y1(this.#Z)??void 0)}constructor(Z){let J=Z.format?{segments:f1(Z.format),separator:Z.separator??"/"}:q8(Z.locale),Q=Z.separator??J.separator,F=Z.format?f1(Z.format):J.segments,Y=Z.initialValue??Z.defaultValue,H=Y?{year:String(Y.getUTCFullYear()).padStart(4,"0"),month:String(Y.getUTCMonth()+1).padStart(2,"0"),day:String(Y.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},z=F.map((U)=>H[U.type]).join(Q);super({...Z,initialUserInput:z},!1),this.#J=F,this.#Y=Q,this.#Z=H,this.#H=Z.minDate,this.#z=Z.maxDate,this.#U(),this.on("cursor",(U)=>this.#j(U)),this.on("key",(U,W)=>this.#N(U,W)),this.on("finalize",()=>this.#w(Z))}#L(){let Z=Math.max(0,Math.min(this.#Q.segmentIndex,this.#J.length-1)),J=this.#J[Z];if(J)return this.#Q.positionInSegment=Math.max(0,Math.min(this.#Q.positionInSegment,J.len-1)),{segment:J,index:Z}}#K(Z){this.inlineError="",this.#W=null;let J=this.#L();J&&(this.#Q.segmentIndex=Math.max(0,Math.min(this.#J.length-1,J.index+Z)),this.#Q.positionInSegment=0,this.#F=!0)}#M(Z){let J=this.#L();if(!J)return;let{segment:Q}=J,F=this.#Z[Q.type],Y=!F||F.replace(/_/g,"")==="",H=Number.parseInt((F||"0").replace(/_/g,"0"),10)||0,z=P8(Q.type,w0(this.#Z),this.#H,this.#z),U;Y?U=Z===1?z.min:z.max:U=Math.max(Math.min(z.max,H+Z),z.min),this.#Z={...this.#Z,[Q.type]:U.toString().padStart(Q.len,"0")},this.#F=!0,this.#W=null,this.#U()}#j(Z){if(Z)switch(Z){case"right":return this.#K(1);case"left":return this.#K(-1);case"up":return this.#M(1);case"down":return this.#M(-1)}}#N(Z,J){if(J?.name==="backspace"||J?.sequence==="\x7F"||J?.sequence==="\b"||Z==="\x7F"||Z==="\b"){this.inlineError="";let Q=this.#L();if(!Q)return;if(!this.#Z[Q.segment.type].replace(/_/g,"")){this.#K(-1);return}this.#Z[Q.segment.type]="_".repeat(Q.segment.len),this.#F=!0,this.#Q.positionInSegment=0,this.#U();return}if(J?.name==="tab"){this.inlineError="";let Q=this.#L();if(!Q)return;let F=J.shift?-1:1,Y=Q.index+F;Y>=0&&Y<this.#J.length&&(this.#Q.segmentIndex=Y,this.#Q.positionInSegment=0,this.#F=!0);return}if(Z&&/^[0-9]$/.test(Z)){let Q=this.#L();if(!Q)return;let{segment:F}=Q,Y=!this.#Z[F.type].replace(/_/g,"");if(this.#F&&this.#W!==null&&!Y){let M=this.#W+Z,N={...this.#Z,[F.type]:M},j=this.#G(N,F);if(j){this.inlineError=j,this.#W=null,this.#F=!1;return}this.inlineError="",this.#Z[F.type]=M,this.#W=null,this.#F=!1,this.#U(),Q.index<this.#J.length-1&&(this.#Q.segmentIndex=Q.index+1,this.#Q.positionInSegment=0,this.#F=!0);return}this.#F&&!Y&&(this.#Z[F.type]="_".repeat(F.len),this.#Q.positionInSegment=0),this.#F=!1,this.#W=null;let H=this.#Z[F.type],z=H.indexOf("_"),U=z>=0?z:Math.min(this.#Q.positionInSegment,F.len-1);if(U<0||U>=F.len)return;let W=H.slice(0,U)+Z+H.slice(U+1),L=!1;if(U===0&&H==="__"&&(F.type==="month"||F.type==="day")){let M=Number.parseInt(Z,10);W=`0${Z}`,L=M<=(F.type==="month"?1:2)}if(F.type==="year"&&(W=(H.replace(/_/g,"")+Z).padStart(F.len,"_")),!W.includes("_")){let M={...this.#Z,[F.type]:W},N=this.#G(M,F);if(N){this.inlineError=N;return}}this.inlineError="",this.#Z[F.type]=W;let K=W.includes("_")?void 0:m1(this.#Z);if(K){let{year:M,month:N}=K,j=o0(M,N);this.#Z={year:String(Math.max(0,Math.min(9999,M))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,N))).padStart(2,"0"),day:String(Math.max(1,Math.min(j,K.day))).padStart(2,"0")}}this.#U();let X=W.indexOf("_");L?(this.#F=!0,this.#W=Z):X>=0?this.#Q.positionInSegment=X:z>=0&&Q.index<this.#J.length-1?(this.#Q.segmentIndex=Q.index+1,this.#Q.positionInSegment=0,this.#F=!0):this.#Q.positionInSegment=Math.min(U+1,F.len-1)}}#G(Z,J){let{month:Q,day:F}=w0(Z);if(J.type==="month"&&(Q<0||Q>12))return O.date.messages.invalidMonth;if(J.type==="day"&&(F<0||F>31))return O.date.messages.invalidDay(31,"any month")}#w(Z){let{year:J,month:Q,day:F}=w0(this.#Z);if(J&&Q&&F){let Y=o0(J,Q);this.#Z={...this.#Z,day:String(Math.min(F,Y)).padStart(2,"0")}}this.value=y1(this.#Z)??Z.defaultValue??void 0}}var O8=class extends s{options;cursor=0;#J;getGroupItems(J){return this.options.filter((Q)=>Q.group===J)}isGroupSelected(J){let Q=this.getGroupItems(J),F=this.value;return F===void 0?!1:Q.every((Y)=>F.includes(Y.value))}toggleValue(){let J=this.options[this.cursor];if(J!==void 0)if(this.value===void 0&&(this.value=[]),J.group===!0){let Q=J.value,F=this.getGroupItems(Q);this.isGroupSelected(Q)?this.value=this.value.filter((Y)=>F.findIndex((H)=>H.value===Y)===-1):this.value=[...this.value,...F.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let Q=this.value.includes(J.value);this.value=Q?this.value.filter((F)=>F!==J.value):[...this.value,J.value]}}constructor(J){super(J,!1);let{options:Q}=J;this.#J=J.selectableGroups!==!1,this.options=Object.entries(Q).flatMap(([F,Y])=>[{value:F,group:!0,label:F},...Y.map((H)=>({...H,group:F}))]),this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:F})=>F===J.cursorAt),this.#J?0:1),this.on("cursor",(F)=>{switch(F){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(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 Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},b8=new Set(["up","down","left","right"]);class r1 extends s{#J=!1;#Y;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let Z=this.userInput;if(this.cursor>=Z.length)return`${Z}\u2588`;let J=Z.slice(0,this.cursor),Q=Z.slice(this.cursor,this.cursor+1),F=Z.slice(this.cursor+1);return Q===`
|
|
25
|
-
|
|
26
|
-
${
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
${G("gray",C)}`:""}`}default:{let L=F?`${G("cyan",C)} `:"",K=F?G("cyan",a1):"";return`${U}${L}${this.value?`${G("green",o1)} ${J}`:`${G("dim",n1)} ${G("dim",J)}`}${Z.vertical?F?`
|
|
33
|
-
${G("cyan",C)} `:`
|
|
34
|
-
`:` ${G("dim","/")} `}${this.value?`${G("dim",n1)} ${G("dim",Q)}`:`${G("green",o1)} ${Q}`}
|
|
35
|
-
${K}
|
|
36
|
-
`}}}}).prompt()};var H7=[`${G("dim","\u2191/\u2193")} to navigate`,`${G("dim","Space:")} select`,`${G("dim","Enter:")} confirm`];var B={message:(Z=[],{symbol:J=G("gray",C),secondarySymbol:Q=G("gray",C),output:F=process.stdout,spacing:Y=1,withGuide:H}={})=>{let z=[],U=H??O.withGuide,W=U?Q:"",L=U?`${J} `:"",K=U?`${Q} `:"";for(let M=0;M<Y;M++)z.push(W);let X=Array.isArray(Z)?Z:Z.split(`
|
|
37
|
-
`);if(X.length>0){let[M,...N]=X;M.length>0?z.push(`${L}${M}`):z.push(U?J:"");for(let j of N)j.length>0?z.push(`${K}${j}`):z.push(U?Q:"")}F.write(`${z.join(`
|
|
10
|
+
`))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.info(`${e}/${t} ${le}`)}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e)throw new ae(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!t.hasOption(n))throw new ae(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let s of n){let r=e[s.name.split(".")[0]];if(s.required){let u=n.some((o)=>o.negated&&o.names.includes(s.name));if(r===!0||r===!1&&!u)throw new ae(`option \`${s.rawName}\` value is missing`)}}}checkUnusedArgs(){let e=this.args.some((t)=>t.variadic)?1/0:this.args.length;if(e<this.cli.args.length)throw new ae(`Unused args: ${this.cli.args.slice(e).map((t)=>`\`${t}\``).join(", ")}`)}},lt=class extends at{constructor(e){super("@@global@@","",{},e)}},Fn=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor(e=""){super();this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new lt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){let s=new at(e,t||"",n,this);return s.globalCommand=this.globalCommand,this.commands.push(s),s}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,s){if(this.args=e,this.options=t,n)this.matchedCommand=n;if(s)this.matchedCommandName=s;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e,{run:t=!0}={}){if(!e){if(!De)throw Error("No argv provided and runtime process argv is not available.");e=De}if(this.rawArgs=e,!this.name)this.name=e[1]?Mn(e[1]):"cli";let n=!0;for(let r of this.commands){let u=this.mri(e.slice(2),r),o=u.args[0];if(r.isMatched(o)){n=!1;let a={...u,args:u.args.slice(1)};this.setParsedInfo(a,r,o),this.dispatchEvent(new CustomEvent(`command:${o}`,{detail:r}))}}if(n){for(let r of this.commands)if(r.isDefaultCommand){n=!1;let u=this.mri(e.slice(2),r);this.setParsedInfo(u,r),this.dispatchEvent(new CustomEvent("command:!",{detail:r}))}}if(n){let r=this.mri(e.slice(2));this.setParsedInfo(r)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),t=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),t=!1,this.unsetMatchedCommand();let s={args:this.args,options:this.options};if(t)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return s}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],s=Sn(n),r=[],u=e.indexOf("--");if(u!==-1)r=e.slice(u+1),e=e.slice(0,u);let o=En(e,s);o=Object.keys(o).reduce((f,h)=>({...f,[ot(h)]:o[h]}),{_:[]});let a=o._,i={"--":r},l=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,c=Object.create(null);for(let f of n){if(!l&&f.config.default!==void 0)for(let h of f.names)i[h]=f.config.default;if(Array.isArray(f.config.type)&&c[f.name]===void 0)c[f.name]=Object.create(null),c[f.name].shouldTransform=!0,c[f.name].transformFunction=f.config.type[0]}for(let f of Object.keys(o))if(f!=="_")An(i,f.split("."),o[f]),On(i,c);return{args:a,options:i}}runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs(),n.checkUnusedArgs();let s=[];return n.args.forEach((r,u)=>{if(r.variadic)s.push(e.slice(u));else s.push(e[u])}),s.push(t),n.commandAction.apply(this,s)}},ct=(e="")=>new Fn(e);import nr from"path";var ce,jn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ht(e){if(!e&&!ce)return jn;return{lang:e?.lang??ce?.lang,message:e?.message,abortEarly:e?.abortEarly??ce?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ce?.abortPipeEarly}}var Tn;function Rn(e){return Tn?.get(e)}var Pn;function Nn(e){return Pn?.get(e)}var Vn;function Ln(e,t){return Vn?.get(e)?.get(t)}function Fe(e){let t=typeof e;if(t==="string")return`"${e}"`;if(t==="number"||t==="bigint"||t==="boolean")return`${e}`;if(t==="object"||t==="function")return(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null";return t}function P(e,t,n,s,r){let u=r&&"input"in r?r.input:n.value,o=r?.expected??e.expects??null,a=r?.received??Fe(u),i={kind:e.kind,type:e.type,input:u,expected:o,received:a,message:`Invalid ${t}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:r?.path,issues:r?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},l=e.kind==="schema",c=r?.message??e.message??Ln(e.reference,i.lang)??(l?Nn(i.lang):null)??s.message??Rn(i.lang);if(c!==void 0)i.message=typeof c==="function"?c(i):c;if(l)n.typed=!1;if(n.issues)n.issues.push(i);else n.issues=[i]}var ft=new WeakMap;function N(e){let t=ft.get(e);if(!t)t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},ht())}},ft.set(e,t);return t}function mt(e,t){let n=[...new Set(e)];if(n.length>1)return`(${n.join(` ${t} `)})`;return n[0]??"never"}var je=class extends Error{constructor(e){super(e[0].message);this.name="ValiError",this.issues=e}};function Gn(e,t,n){return typeof e.fallback==="function"?e.fallback(t,n):e.fallback}function yt(e,t,n){return typeof e.default==="function"?e.default(t,n):e.default}function V(e,t){return{kind:"schema",type:"array",reference:V,expects:"Array",async:!1,item:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r=n.value;if(Array.isArray(r)){n.typed=!0,n.value=[];for(let u=0;u<r.length;u++){let o=r[u],a=this.item["~run"]({value:o},s);if(a.issues){let i={type:"array",origin:"value",input:r,key:u,value:o};for(let l of a.issues){if(l.path)l.path.unshift(i);else l.path=[i];n.issues?.push(l)}if(!n.issues)n.issues=a.issues;if(s.abortEarly){n.typed=!1;break}}if(!a.typed)n.typed=!1;n.value.push(a.value)}}else P(this,"type",n,s);return n}}}function Q(e){return{kind:"schema",type:"boolean",reference:Q,expects:"boolean",async:!1,message:e,get "~standard"(){return N(this)},"~run"(t,n){if(typeof t.value==="boolean")t.typed=!0;else P(this,"type",t,n);return t}}}function Te(e,t){return{kind:"schema",type:"literal",reference:Te,expects:Fe(e),async:!1,literal:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){if(n.value===this.literal)n.typed=!0;else P(this,"type",n,s);return n}}}function z(e,t){return{kind:"schema",type:"object",reference:z,expects:"Object",async:!1,entries:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r=n.value;if(r&&typeof r==="object"){n.typed=!0,n.value={};for(let u in this.entries){let o=this.entries[u];if(u in r||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=u in r?r[u]:yt(o),i=o["~run"]({value:a},s);if(i.issues){let l={type:"object",origin:"value",input:r,key:u,value:a};for(let c of i.issues){if(c.path)c.path.unshift(l);else c.path=[l];n.issues?.push(c)}if(!n.issues)n.issues=i.issues;if(s.abortEarly){n.typed=!1;break}}if(!i.typed)n.typed=!1;n.value[u]=i.value}else if(o.fallback!==void 0)n.value[u]=Gn(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"){if(P(this,"key",n,s,{input:void 0,expected:`"${u}"`,path:[{type:"object",origin:"key",input:r,key:u,value:r[u]}]}),s.abortEarly)break}}}else P(this,"type",n,s);return n}}}function ee(e,t){return{kind:"schema",type:"optional",reference:ee,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get "~standard"(){return N(this)},"~run"(n,s){if(n.value===void 0){if(this.default!==void 0)n.value=yt(this,n,s);if(n.value===void 0)return n.typed=!0,n}return this.wrapped["~run"](n,s)}}}function te(e,t){return{kind:"schema",type:"picklist",reference:te,expects:mt(e.map(Fe),"|"),async:!1,options:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){if(this.options.includes(n.value))n.typed=!0;else P(this,"type",n,s);return n}}}function D(e){return{kind:"schema",type:"string",reference:D,expects:"string",async:!1,message:e,get "~standard"(){return N(this)},"~run"(t,n){if(typeof t.value==="string")t.typed=!0;else P(this,"type",t,n);return t}}}function pt(e){let t;if(e)for(let n of e)if(t)for(let s of n.issues)t.push(s);else t=n.issues;return t}function ne(e,t){return{kind:"schema",type:"union",reference:ne,expects:mt(e.map((n)=>n.expects),"|"),async:!1,options:e,message:t,get "~standard"(){return N(this)},"~run"(n,s){let r,u,o;for(let a of this.options){let i=a["~run"]({value:n.value},s);if(i.typed)if(i.issues)if(u)u.push(i);else u=[i];else{r=i;break}else if(o)o.push(i);else o=[i]}if(r)return r;if(u){if(u.length===1)return u[0];P(this,"type",n,s,{issues:pt(u)}),n.typed=!0}else if(o?.length===1)return o[0];else P(this,"type",n,s,{issues:pt(o)});return n}}}function fe(e,t,n){let s=e["~run"]({value:t},ht(n));if(s.issues)throw new je(s.issues);return s.value}function Re(e,t){let n={};for(let s in e.entries)n[s]=!t||t.includes(s)?ee(e.entries[s]):e.entries[s];return{...e,entries:n,get "~standard"(){return N(this)}}}import{stdout as Ue,stdin as Dt}from"process";import*as H from"readline";import ss from"readline";var dt=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let n=0;e.lastIndex=0;while(e.test(t))n+=1;return t.length-n}})(),gt=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,vt=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var qn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Un=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,$t=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Bn=/\t{1,1000}/y,bt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,Wn=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,zn=/\p{M}+/gu,Hn={limit:1/0,ellipsis:""},kt=(e,t={},n={})=>{let s=t.limit??1/0,r=t.ellipsis??"",u=t?.ellipsisWidth??(r?kt(r,Hn,n).width:0),o=0,a=n.controlWidth??0,i=n.tabWidth??8,l=n.emojiWidth??2,c=2,f=n.regularWidth??1,h=n.wideWidth??2,g=[[Wn,f],[qn,0],[Un,a],[Bn,i],[bt,l],[$t,h]],m=0,y=0,F=e.length,U=0,B=!1,O=F,j=Math.max(0,s-u),I=0,Z=0,M=0,E=0;e:while(!0){if(Z>I||y>=F&&y>m){let W=e.slice(I,Z)||e.slice(m,y);U=0;for(let X of W.replaceAll(zn,"")){let S=X.codePointAt(0)||0;if(gt(S))E=2;else if(vt(S))E=h;else E=f;if(M+E>j)O=Math.min(O,Math.max(I,m)+U);if(M+E>s){B=!0;break e}U+=X.length,M+=E}I=Z=0}if(y>=F)break e;for(let W=0,X=g.length;W<X;W++){let[S,ue]=g[W];if(S.lastIndex=y,S.test(e)){if(U=S===$t?dt(e.slice(y,S.lastIndex)):S===bt?1:S.lastIndex-y,E=U*ue,M+E>j)O=Math.min(O,y+Math.floor((j-M)/ue));if(M+E>s){B=!0;break e}M+=E,I=m,Z=y,y=m=S.lastIndex;continue e}}y+=1}return{width:B?j:M,index:B?O:F,truncated:B,ellipsed:B&&s>=u}},wt=kt;var Kn={limit:1/0,ellipsis:"",ellipsisWidth:0},Xn=(e,t={})=>wt(e,Kn,t).width,w=Xn;var he="\x1B",St="\x9B",Jn=39,Ne="\x07",Ct="[",Zn="]",At="m",Ve=`${Zn}8;;`,xt=new RegExp(`(?:\\${Ct}(?<code>\\d+)m|\\${Ve}(?<uri>.*)${Ne})`,"y"),_t=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},Et=(e)=>`${he}${Ct}${e}${At}`,It=(e)=>`${he}${Ve}${e}${Ne}`,Pe=(e,t,n)=>{let s=t[Symbol.iterator](),r=!1,u=!1,o=e.at(-1),a=o===void 0?0:w(o),i=s.next(),l=s.next(),c=0;while(!i.done){let f=i.value,h=w(f);if(a+h<=n)e[e.length-1]+=f;else e.push(f),a=0;if(f===he||f===St)r=!0,u=t.startsWith(Ve,c+1);if(r){if(u){if(f===Ne)r=!1,u=!1}else if(f===At)r=!1}else if(a+=h,a===n&&!l.done)e.push(""),a=0;i=l,l=s.next(),c+=f.length}if(o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1)e[e.length-2]+=e.pop()},Yn=(e)=>{let t=e.split(" "),n=t.length;while(n){if(w(t[n-1]))break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Qn=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,u,o=e.split(" "),a=[""],i=0;for(let f=0;f<o.length;f++){let h=o[f];if(n.trim!==!1){let m=a.at(-1)??"",y=m.trimStart();if(m.length!==y.length)a[a.length-1]=y,i=w(y)}if(f!==0){if(i>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),i=0;if(i||n.trim===!1)a[a.length-1]+=" ",i++}let g=w(h);if(n.hard&&g>t){let m=t-i,y=1+Math.floor((g-m-1)/t);if(Math.floor((g-1)/t)<y)a.push("");Pe(a,h,t),i=w(a.at(-1)??"");continue}if(i+g>t&&i&&g){if(n.wordWrap===!1&&i<t){Pe(a,h,t),i=w(a.at(-1)??"");continue}a.push(""),i=0}if(i+g>t&&n.wordWrap===!1){Pe(a,h,t),i=w(a.at(-1)??"");continue}a[a.length-1]+=h,i+=g}if(n.trim!==!1)a=a.map((f)=>Yn(f));let l=a.join(`
|
|
11
|
+
`),c=!1;for(let f=0;f<l.length;f++){let h=l[f];if(s+=h,!c){if(c=h>="\uD800"&&h<="\uDBFF",c)continue}else c=!1;if(h===he||h===St){xt.lastIndex=f+1;let m=xt.exec(l)?.groups;if(m?.code!==void 0){let y=Number.parseFloat(m.code);r=y===Jn?void 0:y}else if(m?.uri!==void 0)u=m.uri.length===0?void 0:m.uri}if(l[f+1]===`
|
|
12
|
+
`){if(u)s+=It("");let g=r?_t(r):void 0;if(r&&g)s+=Et(g)}else if(h===`
|
|
13
|
+
`){if(r&&_t(r))s+=Et(r);if(u)s+=It(u)}}return s},es=/\r?\n/;function L(e,t,n){return String(e).normalize().split(es).map((s)=>Qn(s,t,n)).join(`
|
|
14
|
+
`)}var k=st(Ge(),1);import{ReadStream as Mt}from"tty";var rs=["up","down","left","right","space","enter","cancel"],is=["January","February","March","April","May","June","July","August","September","October","November","December"],_={actions:new Set(rs),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...is],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:(e)=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:(e)=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Be(e,t){if(typeof e=="string")return _.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Be(n,t))return!0;return!1}function us(e,t){if(e===t)return;let n=e.split(`
|
|
15
|
+
`),s=t.split(`
|
|
16
|
+
`),r=Math.max(n.length,s.length),u=[];for(let o=0;o<r;o++)n[o]!==s[o]&&u.push(o);return{lines:u,numLinesBefore:n.length,numLinesAfter:s.length,numLines:r}}var os=globalThis.process.platform.startsWith("win"),qe=Symbol("clack:cancel");function ye(e){return e===qe}function me(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Ft({input:e=Dt,output:t=Ue,overwrite:n=!0,hideCursor:s=!0}={}){let r=H.createInterface({input:e,output:t,prompt:"",tabSize:1});H.emitKeypressEvents(e,r),e instanceof Mt&&e.isTTY&&e.setRawMode(!0);let u=(o,{name:a,sequence:i})=>{let l=String(o);if(Be([l,a,i],"cancel")){s&&t.write(k.cursor.show),process.exit(0);return}if(!n)return;H.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{H.clearLine(t,1,()=>{e.once("keypress",u)})})};return s&&t.write(k.cursor.hide),e.once("keypress",u),()=>{e.off("keypress",u),s&&t.write(k.cursor.show),e instanceof Mt&&e.isTTY&&!os&&e.setRawMode(!1),r.terminal=!1,r.close()}}var de=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,jt=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20;function Tt(e,t,n,s=n,r=n,u){let o=de(e??Ue);return L(t,o-n.length,{hard:!0,trim:!1}).split(`
|
|
17
|
+
`).map((a,i,l)=>{let c=u?u(a,i):a;return i===0?`${s}${c}`:i===l.length-1?`${r}${c}`:`${n}${c}`}).join(`
|
|
18
|
+
`)}function Rt(e,t){if("~standard"in e){let n=e["~standard"].validate(t);if(n instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return n.issues?.at(0)?.message}return e(t)}class Pt{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:n=Dt,output:s=Ue,render:r,signal:u,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=r.bind(this),this._track=t,this._abortSignal=u,this.input=n,this.output=s}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],s=[];for(let r of n)r.cb(...t),r.once&&s.push(()=>n.splice(n.indexOf(r),1));for(let r of s)r()}prompt(){return new Promise((e)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(qe);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ss.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),me(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),me(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(k.cursor.show),this.output.off("resize",this.render),me(this.input,!1),e(qe)})})}_isActionKey(e,t){return e==="\t"}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&_.aliases.has(t.name)&&this.emit("cursor",_.aliases.get(t.name)),_.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let n=Rt(this.opts.validate,this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Be([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
19
|
+
`),me(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=L(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
20
|
+
`).length-1;this.output.write(k.cursor.move(-999,e*-1))}render(){let e=L(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(k.cursor.hide);else{let t=us(this._prevFrame,e),n=jt(this.output);if(this.restoreCursor(),t){let s=Math.max(0,t.numLinesAfter-n),r=Math.max(0,t.numLinesBefore-n),u=t.lines.find((o)=>o>=s);if(u===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(k.cursor.move(0,u-r)),this.output.write(k.erase.lines(1));let o=e.split(`
|
|
21
|
+
`);this.output.write(o[u]),this._prevFrame=e,this.output.write(k.cursor.move(0,o.length-u-1));return}else if(t.lines.length>1){if(s<r)u=s;else{let a=u-r;a>0&&this.output.write(k.cursor.move(0,a))}this.output.write(k.erase.down());let o=e.split(`
|
|
22
|
+
`).slice(u);this.output.write(o.join(`
|
|
23
|
+
`)),this._prevFrame=e;return}}this.output.write(k.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}class We extends Pt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(k.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}import{styleText as p,stripVTControlCharacters as Rr}from"util";import A from"process";var se=st(Ge(),1);function as(){if(A.platform!=="win32")return A.env.TERM!=="linux";return Boolean(A.env.CI)||Boolean(A.env.WT_SESSION)||Boolean(A.env.TERMINUS_SUBLIME)||A.env.ConEmuTask==="{cmd::Cmder}"||A.env.TERM_PROGRAM==="Terminus-Sublime"||A.env.TERM_PROGRAM==="vscode"||A.env.TERM==="xterm-256color"||A.env.TERM==="alacritty"||A.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ze=as(),ls=()=>process.env.CI==="true";var d=(e,t)=>ze?e:t,cs=d("\u25C6","*"),Gt=d("\u25A0","x"),qt=d("\u25B2","x"),ge=d("\u25C7","o"),fs=d("\u250C","T"),x=d("\u2502","|"),Ut=d("\u2514","\u2014"),Lr=d("\u2510","T"),Gr=d("\u2518","\u2014"),Nt=d("\u25CF",">"),Vt=d("\u25CB"," "),qr=d("\u25FB","[\u2022]"),Ur=d("\u25FC","[+]"),Br=d("\u25FB","[ ]"),Wr=d("\u25AA","\u2022"),Lt=d("\u2500","-"),ps=d("\u256E","+"),hs=d("\u251C","+"),ms=d("\u256F","+"),ys=d("\u2570","+"),zr=d("\u256D","+"),ds=d("\u25CF","\u2022"),gs=d("\u25C6","*"),vs=d("\u25B2","!"),$s=d("\u25A0","x"),bs=(e)=>{switch(e){case"initial":case"active":return p("cyan",cs);case"cancel":return p("red",Gt);case"error":return p("yellow",qt);case"submit":return p("green",ge)}};var Bt=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new We({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let s=e.withGuide??_.withGuide,r=`${bs(this.state)} `,u=s?`${p("gray",x)} `:"",o=Tt(e.output,e.message,u,r),a=`${s?`${p("gray",x)}
|
|
24
|
+
`:""}${o}
|
|
25
|
+
`,i=this.value?t:n;switch(this.state){case"submit":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p("dim",i)}`}case"cancel":{let l=s?`${p("gray",x)} `:"";return`${a}${l}${p(["strikethrough","dim"],i)}${s?`
|
|
26
|
+
${p("gray",x)}`:""}`}default:{let l=s?`${p("cyan",x)} `:"",c=s?p("cyan",Ut):"";return`${a}${l}${this.value?`${p("green",Nt)} ${t}`:`${p("dim",Vt)} ${p("dim",t)}`}${e.vertical?s?`
|
|
27
|
+
${p("cyan",x)} `:`
|
|
28
|
+
`:` ${p("dim","/")} `}${this.value?`${p("dim",Vt)} ${p("dim",n)}`:`${p("green",Nt)} ${n}`}
|
|
29
|
+
${c}
|
|
30
|
+
`}}}}).prompt()};var Hr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Space:")} select`,`${p("dim","Enter:")} confirm`];var v={message:(e=[],{symbol:t=p("gray",x),secondarySymbol:n=p("gray",x),output:s=process.stdout,spacing:r=1,withGuide:u}={})=>{let o=[],a=u??_.withGuide,i=a?n:"",l=a?`${t} `:"",c=a?`${n} `:"";for(let h=0;h<r;h++)o.push(i);let f=Array.isArray(e)?e:e.split(`
|
|
31
|
+
`);if(f.length>0){let[h,...g]=f;h.length>0?o.push(`${l}${h}`):o.push(a?t:"");for(let m of g)m.length>0?o.push(`${c}${m}`):o.push(a?n:"")}s.write(`${o.join(`
|
|
38
32
|
`)}
|
|
39
|
-
`)},info:(
|
|
40
|
-
`)},
|
|
41
|
-
${
|
|
33
|
+
`)},info:(e,t)=>{v.message(e,{...t,symbol:p("blue",ds)})},success:(e,t)=>{v.message(e,{...t,symbol:p("green",gs)})},step:(e,t)=>{v.message(e,{...t,symbol:p("green",ge)})},warn:(e,t)=>{v.message(e,{...t,symbol:p("yellow",vs)})},warning:(e,t)=>{v.warn(e,t)},error:(e,t)=>{v.message(e,{...t,symbol:p("red",$s)})}};var ve=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",fs)} `:"";n.write(`${s}${e}
|
|
34
|
+
`)},Wt=(e="",t)=>{let n=t?.output??process.stdout,s=t?.withGuide??_.withGuide?`${p("gray",x)}
|
|
35
|
+
${p("gray",Ut)} `:"";n.write(`${s}${e}
|
|
42
36
|
|
|
43
|
-
`)};var
|
|
44
|
-
`),
|
|
45
|
-
`).map(
|
|
46
|
-
`),
|
|
47
|
-
`:"",
|
|
48
|
-
${
|
|
49
|
-
${
|
|
50
|
-
`)};var
|
|
51
|
-
`);let
|
|
52
|
-
`);
|
|
53
|
-
`);let
|
|
54
|
-
`):
|
|
55
|
-
`)),
|
|
56
|
-
`),"System Environment",{withGuide:!0}),
|
|
57
|
-
`);for(let
|
|
58
|
-
`)})(),"Config To Apply");let
|
|
37
|
+
`)};var ks=(e)=>e,ws=(e,t,n)=>{let s={hard:!0,trim:!1},r=L(e,t,s).split(`
|
|
38
|
+
`),u=r.reduce((i,l)=>Math.max(w(l),i),0),o=r.map(n).reduce((i,l)=>Math.max(w(l),i),0),a=t-(o-u);return L(e,a,s)},$e=(e="",t="",n)=>{let s=n?.output??A.stdout,r=n?.withGuide??_.withGuide,u=n?.format??ks,o=["",...ws(e,de(s)-6,u).split(`
|
|
39
|
+
`).map(u),""],a=w(t),i=Math.max(o.reduce((h,g)=>{let m=w(g);return m>h?m:h},0),a)+2,l=o.map((h)=>`${p("gray",x)} ${h}${" ".repeat(i-w(h))}${p("gray",x)}`).join(`
|
|
40
|
+
`),c=r?`${p("gray",x)}
|
|
41
|
+
`:"",f=r?hs:ys;s.write(`${c}${p("green",ge)} ${p("reset",t)} ${p("gray",Lt.repeat(Math.max(i-a-1,1))+ps)}
|
|
42
|
+
${l}
|
|
43
|
+
${p("gray",f+Lt.repeat(i+2)+ms)}
|
|
44
|
+
`)};var xs=(e)=>p("magenta",e),be=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:s,errorMessage:r,frames:u=ze?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=ze?80:120,signal:a,...i}={})=>{let l=ls(),c,f,h=!1,g=!1,m="",y,F=performance.now(),U=de(n),B=i?.styleFrame??xs,O=(b)=>{let C=b>1?r??_.messages.error:s??_.messages.cancel;g=b===1,h&&(Y(C,b),g&&typeof t=="function"&&t())},j=()=>O(2),I=()=>O(1),Z=()=>{process.on("uncaughtExceptionMonitor",j),process.on("unhandledRejection",j),process.on("SIGINT",I),process.on("SIGTERM",I),process.on("exit",O),a&&a.addEventListener("abort",I)},M=()=>{process.removeListener("uncaughtExceptionMonitor",j),process.removeListener("unhandledRejection",j),process.removeListener("SIGINT",I),process.removeListener("SIGTERM",I),process.removeListener("exit",O),a&&a.removeEventListener("abort",I)},E=()=>{if(y===void 0)return;l&&n.write(`
|
|
45
|
+
`);let b=L(y,U,{hard:!0,trim:!1}).split(`
|
|
46
|
+
`);b.length>1&&n.write(se.cursor.up(b.length-1)),n.write(se.cursor.to(0)),n.write(se.erase.down())},W=(b)=>b.replace(/\.+$/,""),X=(b)=>{let C=(performance.now()-b)/1000,T=Math.floor(C/60),R=Math.floor(C%60);return T>0?`[${T}m ${R}s]`:`[${R}s]`},S=i.withGuide??_.withGuide,ue=(b="")=>{h=!0,c=Ft({output:n}),m=W(b),F=performance.now(),S&&n.write(`${p("gray",x)}
|
|
47
|
+
`);let C=0,T=0;Z(),f=setInterval(()=>{if(l&&m===y)return;E(),y=m;let R=B(u[C]),oe;if(l)oe=`${R} ${m}...`;else if(e==="timer")oe=`${R} ${m} ${X(F)}`;else{let yn=".".repeat(Math.floor(T)).slice(0,3);oe=`${R} ${m}${yn}`}let mn=L(oe,U,{hard:!0,trim:!1});n.write(mn),C=C+1<u.length?C+1:0,T=T<4?T+0.125:0},o)},Y=(b="",C=0,T=!1)=>{if(!h)return;h=!1,clearInterval(f),E();let R=C===0?p("green",ge):C===1?p("red",Gt):p("red",qt);m=b??m,T||(e==="timer"?n.write(`${R} ${m} ${X(F)}
|
|
48
|
+
`):n.write(`${R} ${m}
|
|
49
|
+
`)),M(),c()};return{start:ue,stop:(b="")=>Y(b,0),message:(b="")=>{m=W(b??m)},cancel:(b="")=>Y(b,1),error:(b="")=>Y(b,2),clear:()=>Y("",0,!0),get isCancelled(){return g}}},Kr={light:d("\u2500","-"),heavy:d("\u2501","="),block:d("\u2588","#")};var Xr=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Enter:")} confirm`];var Jr=`${p("gray",x)} `;var{$:He}=globalThis.Bun;var _s={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},zt=(e)=>{for(let[t,n]of Object.entries(_s))if(n.includes(e))return t;return null};var Ht={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function G(e){return Ht[e]}function q(e,t){Ht[e]=t}async function Ke(e){try{return await He`which ${e}`.quiet(),!0}catch{return!1}}async function Es(){let e=[];if(await Ke("yay"))e.push("yay");if(await Ke("paru"))e.push("paru");return e}async function Is(){if(process.platform==="linux"){let e=await He`cat /etc/os-release | grep ^NAME`.quiet().text()||"",t=await He`cat /etc/os-release | grep ^ID`.quiet().text()||"",n=e.trim().slice(5).replace(/"/g,"");return{id:t.trim().slice(3).replace(/"/g,""),name:n}}return{id:"unknown",name:"unknown"}}async function ke(){let{name:e="",id:t=""}=await Is(),n=zt(t),s=n==="pacman"?await Es():null,r=await Ke("flatpak");if(q("osName",e),q("osId",t),q("flatpak",r),s)q("helperAur",s[0]);if(n)q("packageManager",n);return{osName:e,osId:t,packageManager:n,aurHelper:s,flatpak:r}}async function Kt(){ve("\uD83D\uDD0D Scanning system");let e=be();e.start("Detecting environment...");let t=await ke();return e.stop("Environment detected"),$e([`OS ${t.osName} (${t.osId})`,`Package Manager ${t.packageManager}`,t.aurHelper?`AUR Helper ${t.aurHelper}`:null,`Flatpak ${t.flatpak?"Enabled":"Disabled"}`].filter(Boolean).join(`
|
|
50
|
+
`),"System Environment",{withGuide:!0}),Wt("Scan completed"),t}import Xt from"path";import{homedir as Ss}from"os";function we(e){if(e.startsWith("~"))return Xt.join(Ss(),e.slice(1));return Xt.resolve(e)}var Cs=Re(z({flatpak:Q(),backup:Q(),aur_helper:te(["yay","paru"])})),As=z({source:D(),target:D(),sudo:ee(Q())}),Os=te(["aur","pacman"]),Ms=ne([D(),V(D()),V(V(D()))]),Ds=z({name:D(),post_hooks:ee(Ms)}),Jt=V(ne([D(),Ds])),Fs=z({manager:Os,items:Jt}),js=z({manager:Te("flatpak"),scope:te(["system","user"]),items:Jt}),xe=Re(z({imports:V(D()),settings:Cs,packages:V(ne([js,Fs])),symlinks:V(As)}));import Ee from"path";var K={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},fi={defaultMerge:K.defaultMerge};function Ts(e,t){return t}function Rs(e,t){return e.filter((n)=>n!==void 0)}var Zt;(function(e){e[e.NOT=0]="NOT",e[e.RECORD=1]="RECORD",e[e.ARRAY=2]="ARRAY",e[e.SET=3]="SET",e[e.MAP=4]="MAP",e[e.OTHER=5]="OTHER"})(Zt||(Zt={}));function Yt(e){if(typeof e!=="object"||e===null)return 0;if(Array.isArray(e))return 2;if(Vs(e))return 1;if(e instanceof Set)return 3;if(e instanceof Map)return 4;return 5}function Ps(e){let t=new Set;for(let n of e)for(let s of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(s);return t}function Ns(e,t){return typeof e==="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function en(e){let t=0,n=e[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(n===void 0)return{done:!0,value:void 0};let s=n.next();if(s.done===!0){t+=1,n=e[t]?.[Symbol.iterator]();continue}return{done:!1,value:s.value}}while(!0)}}}}}var Qt=["[object Object]","[object Module]"];function Vs(e){if(!Qt.includes(Object.prototype.toString.call(e)))return!1;let{constructor:t}=e;if(t===void 0)return!0;let n=t.prototype;if(n===null||typeof n!=="object"||!Qt.includes(Object.prototype.toString.call(n)))return!1;if(!n.hasOwnProperty("isPrototypeOf"))return!1;return!0}function Ls(e,t,n){let s={};for(let r of Ps(e)){let u=[];for(let i of e)if(Ns(i,r))u.push(i[r]);if(u.length===0)continue;let o=t.metaDataUpdater(n,{key:r,parents:e}),a=tn(u,t,o);if(a===K.skip)continue;if(r==="__proto__")Object.defineProperty(s,r,{value:a,configurable:!0,enumerable:!0,writable:!0});else s[r]=a}return s}function Gs(e){return e.flat()}function qs(e){return new Set(en(e))}function Us(e){return new Map(en(e))}function Bs(e){return e.at(-1)}var _e={mergeRecords:Ls,mergeArrays:Gs,mergeSets:qs,mergeMaps:Us,mergeOthers:Bs};function ie(...e){return Ws({})(...e)}function Ws(e,t){let n=zs(e,s);function s(...r){return tn(r,n,t)}return s}function zs(e,t){return{defaultMergeFunctions:_e,mergeFunctions:{..._e,...Object.fromEntries(Object.entries(e).filter(([n,s])=>Object.hasOwn(_e,n)).map(([n,s])=>s===!1?[n,_e.mergeOthers]:[n,s]))},metaDataUpdater:e.metaDataUpdater??Ts,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??Rs,actions:K}}function tn(e,t,n){let s=t.filterValues?.(e,n)??e;if(s.length===0)return;if(s.length===1)return Xe(s,t,n);let r=Yt(s[0]);if(r!==0&&r!==5)for(let u=1;u<s.length;u++){if(Yt(s[u])===r)continue;return Xe(s,t,n)}switch(r){case 1:return Hs(s,t,n);case 2:return Ks(s,t,n);case 3:return Xs(s,t,n);case 4:return Js(s,t,n);default:return Xe(s,t,n)}}function Hs(e,t,n){let s=t.mergeFunctions.mergeRecords(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords)return t.defaultMergeFunctions.mergeRecords(e,t,n);return s}function Ks(e,t,n){let s=t.mergeFunctions.mergeArrays(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays)return t.defaultMergeFunctions.mergeArrays(e);return s}function Xs(e,t,n){let s=t.mergeFunctions.mergeSets(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets)return t.defaultMergeFunctions.mergeSets(e);return s}function Js(e,t,n){let s=t.mergeFunctions.mergeMaps(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps)return t.defaultMergeFunctions.mergeMaps(e);return s}function Xe(e,t,n){let s=t.mergeFunctions.mergeOthers(e,t,n);if(s===K.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers)return t.defaultMergeFunctions.mergeOthers(e);return s}async function Je(e,t=new Set){let n=Ee.resolve(e);if(t.has(n))throw Error(`Circular dependency detected: ${n}`);t.add(n);let s=await Bun.file(n).text(),r=Bun.TOML.parse(s),u=fe(xe,r),{imports:o=[],symlinks:a=[]}=u;delete u.imports;let i=Ee.dirname(n);u.symlinks=Zs(i,a);let l={};for(let c of o){let f=Ee.resolve(i,c),h=await Je(f,t);l=ie(l,h)}return ie(u,l)}function Zs(e,t){if(!t||t.length===0)return[];let n=[];for(let s of t){if(!s)continue;let{source:r,target:u}=s,o=Ee.resolve(e,r),a=we(u);n.push({source:o,target:a})}return n}async function Ie(e){let t=we(e);v.step("Validating Configuration");let n=be();n.start("Validating...");let s=await Je(t),r=fe(xe,s);return n.stop("Successfully validated with no errors!"),r}import tr from"path";var{deepEquals:un}=globalThis.Bun;import Ze from"path";import Ye from"fs/promises";var Se={};function Ce(){return Se}function nn(e,t){Se[e]=t}async function sn(e){let t=e??G("configDir"),n=Ze.resolve(t||".",".state/hofii-lock.json");if(await Ye.exists(n)){let s=await Bun.file(n).json();Object.assign(Se,s.config)}}async function rn(){let e=Ze.resolve(G("configDir")||".",".state");if(!await Ye.exists(e))await Ye.mkdir(e,{recursive:!0});let t={config:Se};await Bun.write(Ze.resolve(e,"hofii-lock.json"),JSON.stringify(t,null,2))}function Ys(e,t){let n=t?.filter((r)=>!e?.some((u)=>un(r,u,!0)))??[],s=e?.filter((r)=>!t?.some((u)=>un(r,u,!0)))??[];return{added:n,removed:s}}function on(e){let t=Ce();return{symlinks:Ys(t.symlinks,e.symlinks)}}function an(e){let{symlinks:t}=e;return[(()=>{let s=["SYMLINKS"],{added:r=[],removed:u=[]}=t;if(r?.length===0&&u?.length===0)return s.push(" - No changes to apply with symlinks"),s.join(`
|
|
51
|
+
`);for(let o of r)s.push(` - [ADDED] ${o.sudo?"(sudo) ":""}${o.source} -> ${o.target}`);for(let o of u)s.push(` - [REMOVED] ${o.sudo?"(sudo) ":""}${o.source} -> ${o.target}`);return s.join(`
|
|
52
|
+
`)})()].join("/n")}var{deepEquals:Qs}=globalThis.Bun;import er from"fs/promises";import Oe from"fs/promises";async function Ae({cmd:e,errMsg:t,opt:n={stdin:"inherit",stdout:"inherit",stderr:"inherit"}}){let s=Bun.spawn(e,{stdin:n.stdin,stdout:n.stdout,stderr:n.stderr}),r=n.stdout==="pipe"?new Response(s.stdout).text():void 0,u=n.stderr==="pipe"?new Response(s.stderr).text():void 0,o=s.exited,[a,i,l]=await Promise.all([r,u,o]);if(l!==0)throw Error(t??`Error caused with exit code ${l}`);return{stdout:a,stderr:i,exitCode:l}}async function Qe(e,t,n=!1){if(n){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","ln","-s",e,t],errMsg:`Failed create symlink ${e+" -> "+t}`})}else await Oe.symlink(e,t)}async function et(e,t=!1){if(t){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","rm",e],errMsg:`Failed remove symlink ${e}`})}else await Oe.unlink(e)}async function tt(e){try{return await Oe.lstat(e)}catch(t){return null}}async function ln({oldPath:e,newPath:t,sudo:n=!1}){if(n){if(G("platform")!=="linux"){v.warn("Sudo only support in Linux");return}await Ae({cmd:["sudo","mv",e,t],errMsg:`Failed rename file ${e+" -> "+t}`})}else await Oe.rename(e,t)}async function pn(e){if(!e)return;let t=G("settings")?.backup??!0,{added:n=[],removed:s=[]}=e,r=[],u=[];try{let o=fn(await Promise.allSettled(s.map(async(i)=>{let l=await tt(i.target);if(!l){v.warn(`Target doesn't exist: ${i.target}, did you remove it manually?`),u.push(i);return}if(!l.isSymbolicLink()){v.warn(`${i.target} not a symlink, did you remove it manually?`),u.push(i);return}await et(i.target,i.sudo),u.push(i),v.success(`Succesfully remove symlink ${i.target}`)}))),a=fn(await Promise.allSettled(n.map(async(i)=>{let l=await tt(i.target);if(l){if(l.isSymbolicLink()){let c=await er.readlink(i.target);if(c===i.source){await et(i.target,i.sudo),await Qe(i.source,i.target,i.sudo),r.push(i),v.warn(`Recreate ${c} -> ${i.target}`);return}}if(t)await ln({oldPath:i.target,newPath:i.target+".bak",sudo:i.sudo});else{v.error(`Target already exists, skip create: ${i.target}`);return}}await Qe(i.source,i.target,i.sudo),r.push(i),v.success(`Succesfully create symlink ${i.source} -> ${i.target}`)})));for(let i of a)console.error(`Failed to add symlink: ${cn(i)}`);for(let i of o)console.error(`Failed to remove symlink: ${cn(i)}`);if(a.length>0||o.length>0)v.error(" [FATAL] Error caused while applying symlinks"),process.exitCode=1}catch(o){console.error(o),v.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let i=((Ce()??{}).symlinks??[]).filter((l)=>!u.some((c)=>Qs(c,l))).concat(r);v.info(`Updated symlinks state: ${i.length}`),nn("symlinks",i)}}function cn(e){if(e instanceof Error)return`[${"code"in e?String(e.code):"ERROR"}] ${e.message}`;return`[ERROR] ${String(e)}`}function fn(e){return e.filter((t)=>t.status==="rejected")}async function hn(e){let t=tr.join(e,"config.toml");q("configDir",e),await sn(e),ve("Switching configuration"),v.info("Scanning system environment..."),await ke();let n=await Ie(t);q("settings",ie(n.settings,{backup:!0}));let s=on(n),r=an(s);$e(r,"Config To Apply");let u=await Bt({message:"Apply config changes? (Please review the changes first!!)"});if(!u||ye(u))v.warn("Config changes not applied."),process.exit(0);await pn(s.symlinks)}var J=ct("hofii");J.version("0.0.3");J.command("scan","Detect system environment").alias("s").action(async()=>{await Kt(),process.exit(0)});J.command("validate [dir]","Validate configuration files").alias("v").action(async(e)=>{await Ie(e),process.exit(0)});J.command("switch [dir]","Switch to new configuration").alias("sw").action(async(e)=>{let t=nr.resolve(e);await hn(t)});try{if(process.argv.slice(2).length===0)J.outputHelp(),process.exit(0);J.help().parse(process.argv,{run:!1}),await J.runMatchedCommand()}catch(e){if(e instanceof je){let t=e.issues.map((n)=>{let s=n.path.at(-1)?.input;return[`\u2717 ${n.message}`,` at: ${JSON.stringify(s)}`].join(`
|
|
59
53
|
`)}).join(`
|
|
60
54
|
|
|
61
|
-
`);console.error(
|
|
55
|
+
`);console.error(t)}console.error(e)}finally{await rn()}
|
package/package.json
CHANGED