hofii 0.0.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/main.js +58 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yogaeru
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Manage dotfile declaratively in Linux
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var O9=Object.create;var{getPrototypeOf:b9,defineProperty:Q1,getOwnPropertyNames:C9}=Object;var R9=Object.prototype.hasOwnProperty;function A9(Z){return this[Z]}var E9,D9,F1=(Z,J,Q)=>{var F=Z!=null&&typeof Z==="object";if(F){var Y=J?E9??=new WeakMap:D9??=new WeakMap,H=Y.get(Z);if(H)return H}Q=Z!=null?O9(b9(Z)):{};let z=J||!Z||!Z.__esModule?Q1(Q,"default",{value:Z,enumerable:!0}):Q;for(let U of C9(Z))if(!R9.call(z,U))Q1(z,U,{get:A9.bind(Z,U),enumerable:!0});if(F)Y.set(Z,z);return z};var I9=(Z,J)=>()=>(J||Z((J={exports:{}}).exports,J),J.exports);var v0=I9((k6,A1)=>{var h0={to(Z,J){if(!J)return`\x1B[${Z+1}G`;return`\x1B[${J+1};${Z+1}H`},move(Z,J){let Q="";if(Z<0)Q+=`\x1B[${-Z}D`;else if(Z>0)Q+=`\x1B[${Z}C`;if(J<0)Q+=`\x1B[${-J}A`;else if(J>0)Q+=`\x1B[${J}B`;return Q},up:(Z=1)=>`\x1B[${Z}A`,down:(Z=1)=>`\x1B[${Z}B`,forward:(Z=1)=>`\x1B[${Z}C`,backward:(Z=1)=>`\x1B[${Z}D`,nextLine:(Z=1)=>"\x1B[E".repeat(Z),prevLine:(Z=1)=>"\x1B[F".repeat(Z),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},e9={up:(Z=1)=>"\x1B[S".repeat(Z),down:(Z=1)=>"\x1B[T".repeat(Z)},t9={screen:"\x1B[2J",up:(Z=1)=>"\x1B[1J".repeat(Z),down:(Z=1)=>"\x1B[J".repeat(Z),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Z){let J="";for(let Q=0;Q<Z;Q++)J+=this.line+(Q<Z-1?h0.up():"");if(Z)J+=h0.left;return J}};A1.exports={cursor:h0,scroll:e9,erase:t9,beep:"\x07"}});function I0(Z){return Z==null?[]:Array.isArray(Z)?Z:[Z]}function x9(Z,J,Q,F){var Y,H=Z[J],z=~F.string.indexOf(J)?Q==null||Q===!0?"":String(Q):typeof Q==="boolean"?Q:~F.boolean.indexOf(J)?Q==="false"?!1:Q==="true"||(Z._.push((Y=+Q,Y*0===0)?Y:Q),!!Q):(Y=+Q,Y*0===0)?Y:Q;Z[J]=H==null?z:Array.isArray(H)?H.concat(z):[H,z]}function T9(Z,J){Z=Z||[],J=J||{};var Q,F,Y,H,z,U={_:[]},W=0,L=0,K=0,X=Z.length;let M=J.alias!==void 0,N=J.unknown!==void 0,j=J.default!==void 0;if(J.alias=J.alias||{},J.string=I0(J.string),J.boolean=I0(J.boolean),M)for(Q in J.alias){F=J.alias[Q]=I0(J.alias[Q]);for(W=0;W<F.length;W++)(J.alias[F[W]]=F.concat(Q)).splice(W,1)}for(W=J.boolean.length;W-- >0;){F=J.alias[J.boolean[W]]||[];for(L=F.length;L-- >0;)J.boolean.push(F[L])}for(W=J.string.length;W-- >0;){F=J.alias[J.string[W]]||[];for(L=F.length;L-- >0;)J.string.push(F[L])}if(j){for(Q in J.default)if(H=typeof J.default[Q],F=J.alias[Q]=J.alias[Q]||[],J[H]!==void 0){J[H].push(Q);for(W=0;W<F.length;W++)J[H].push(F[W])}}let w=N?Object.keys(J.alias):[];for(W=0;W<X;W++){if(Y=Z[W],Y==="--"){U._=U._.concat(Z.slice(++W));break}for(L=0;L<Y.length;L++)if(Y.charCodeAt(L)!==45)break;if(L===0)U._.push(Y);else if(Y.substring(L,L+3)==="no-"){if(H=Y.substring(L+3),N&&!~w.indexOf(H))return J.unknown(Y);U[H]=!1}else{for(K=L+1;K<Y.length;K++)if(Y.charCodeAt(K)===61)break;H=Y.substring(L,K),z=Y.substring(++K)||W+1===X||(""+Z[W+1]).charCodeAt(0)===45||Z[++W],F=L===2?[H]:H;for(K=0;K<F.length;K++){if(H=F[K],N&&!~w.indexOf(H))return J.unknown("-".repeat(L)+H);x9(U,H,K+1<F.length||z,J)}}}if(j){for(Q in J.default)if(U[Q]===void 0)U[Q]=J.default[Q]}if(M)for(Q in U){F=J.alias[Q]||[];while(F.length>0)U[F.shift()]=U[Q]}return U}function W1(Z){return Z.replace(/[<[].+/,"").trim()}function S9(Z){let J=/<([^>]+)>/g,Q=/\[([^\]]+)\]/g,F=[],Y=(U)=>{let W=!1,L=U[1];if(L.startsWith("..."))L=L.slice(3),W=!0;return{required:U[0].startsWith("<"),value:L,variadic:W}},H;while(H=J.exec(Z))F.push(Y(H));let z;while(z=Q.exec(Z))F.push(Y(z));return F}function k9(Z){let J={alias:{},boolean:[]};for(let[Q,F]of Z.entries()){if(F.names.length>1)J.alias[F.names[0]]=F.names.slice(1);if(F.isBoolean)if(F.negated){if(!Z.some((Y,H)=>{return H!==Q&&Y.names.some((z)=>F.names.includes(z))&&typeof Y.required==="boolean"}))J.boolean.push(F.names[0])}else J.boolean.push(F.names[0])}return J}function Y1(Z){return Z.sort((J,Q)=>{return J.length>Q.length?-1:1})[0]}function H1(Z,J){return Z.length>=J?Z:`${Z}${" ".repeat(J-Z.length)}`}function h9(Z){return Z.replaceAll(/([a-z])-([a-z])/g,(J,Q,F)=>{return Q+F.toUpperCase()})}function v9(Z,J,Q){let F=Z;for(let Y=0;Y<J.length;Y++){let H=J[Y];if(Y===J.length-1){F[H]=Q;return}if(F[H]==null){let z=+J[Y+1]>-1;F[H]=z?[]:{}}F=F[H]}}function _9(Z,J){for(let Q of Object.keys(J)){let F=J[Q];if(F.shouldTransform){if(Z[Q]=[Z[Q]].flat(),typeof F.transformFunction==="function")Z[Q]=Z[Q].map(F.transformFunction)}}}function f9(Z){let J=/([^\\/]+)$/.exec(Z);return J?J[1]:""}function z1(Z){return Z.split(".").map((J,Q)=>{return Q===0?h9(J):J}).join(".")}var U0=class extends Error{constructor(Z){super(Z);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error(Z).stack}},y9=class{rawName;description;name;names;isBoolean;required;config;negated;constructor(Z,J,Q){if(this.rawName=Z,this.description=J,this.config=Object.assign({},Q),Z=Z.replaceAll(".*",""),this.negated=!1,this.names=W1(Z).split(",").map((F)=>{let Y=F.trim().replace(/^-{1,2}/,"");if(Y.startsWith("no-"))this.negated=!0,Y=Y.replace(/^no-/,"");return z1(Y)}).sort((F,Y)=>F.length>Y.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if(Z.includes("<"))this.required=!0;else if(Z.includes("["))this.required=!1;else this.isBoolean=!0}},x0,L0;if(typeof process<"u"){let Z;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")Z="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")Z="bun";else Z="node";L0=`${process.platform}-${process.arch} ${Z}-${process.version}`,x0=process.argv}else if(typeof navigator>"u")L0="unknown";else L0=`${navigator.platform} ${navigator.userAgent}`;var U1=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor(Z,J,Q={},F){this.rawName=Z,this.description=J,this.config=Q,this.cli=F,this.options=[],this.aliasNames=[],this.name=W1(Z),this.args=S9(Z),this.examples=[]}usage(Z){return this.usageText=Z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(Z,J="-v, --version"){return this.versionNumber=Z,this.option(J,"Display version number"),this}example(Z){return this.examples.push(Z),this}option(Z,J,Q){let F=new y9(Z,J,Q);return this.options.push(F),this}alias(Z){return this.aliasNames.push(Z),this}action(Z){return this.commandAction=Z,this}isMatched(Z){return this.name===Z||this.aliasNames.includes(Z)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof L1}hasOption(Z){return Z=Z.split(".")[0],this.options.find((J)=>{return J.names.includes(Z)})}outputHelp(){let{name:Z,commands:J}=this.cli,{versionNumber:Q,options:F,helpCallback:Y}=this.cli.globalCommand,H=[{body:`${Z}${Q?`/${Q}`:""}`}];if(H.push({title:"Usage",body:` $ ${Z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&J.length>0){let U=Y1(J.map((W)=>W.rawName));H.push({title:"Commands",body:J.map((W)=>{return` ${H1(W.rawName,U.length)} ${W.description}`}).join(`
|
|
4
|
+
`)},{title:"For more info, run any command with the `--help` flag",body:J.map((W)=>` $ ${Z}${W.name===""?"":` ${W.name}`} --help`).join(`
|
|
5
|
+
`)})}let z=this.isGlobalCommand?F:[...this.options,...F||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)z=z.filter((U)=>U.name!=="version");if(z.length>0){let U=Y1(z.map((W)=>W.rawName));H.push({title:"Options",body:z.map((W)=>{return` ${H1(W.rawName,U.length)} ${W.description} ${W.config.default===void 0?"":`(default: ${W.config.default})`}`}).join(`
|
|
6
|
+
`)})}if(this.examples.length>0)H.push({title:"Examples",body:this.examples.map((U)=>{if(typeof U==="function")return U(Z);return U}).join(`
|
|
7
|
+
`)});if(Y)H=Y(H)||H;console.info(H.map((U)=>{return U.title?`${U.title}:
|
|
8
|
+
${U.body}`:U.body}).join(`
|
|
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(", ")}`)}},L1=class extends U1{constructor(Z){super("@@global@@","",{},Z)}},$9=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 L1(this),this.globalCommand.usage("<command> [options]")}usage(Z){return this.globalCommand.usage(Z),this}command(Z,J,Q){let F=new U1(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(!x0)throw Error("No argv provided and runtime process argv is not available.");Z=x0}if(this.rawArgs=Z,!this.name)this.name=Z[1]?f9(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=k9(Q),Y=[],H=Z.indexOf("--");if(H!==-1)Y=Z.slice(H+1),Z=Z.slice(0,H);let z=T9(Z,F);z=Object.keys(z).reduce((X,M)=>{return{...X,[z1(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!=="_")v9(W,X.split("."),z[X]),_9(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)}},K1=(Z="")=>new $9(Z);import V6 from"path";import{styleText as f0}from"util";import{stdout as g0,stdin as x1}from"process";import*as u from"readline";import Z8 from"readline";var X1=(()=>{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}})(),M1=(Z)=>{return Z===12288||Z>=65281&&Z<=65376||Z>=65504&&Z<=65510},G1=(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 p9=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,g9=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,j1=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,l9=/\t{1,1000}/y,N1=/[\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,c9=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,m9=/\p{M}+/gu,u9={limit:1/0,ellipsis:""},w1=(Z,J={},Q={})=>{let F=J.limit??1/0,Y=J.ellipsis??"",H=J?.ellipsisWidth??(Y?w1(Y,u9,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=[[c9,X],[p9,0],[g9,U],[l9,W],[N1,L],[j1,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(m9,"")){let E=i.codePointAt(0)||0;if(M1(E))R=2;else if(G1(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===j1?X1(Z.slice(w,E.lastIndex)):E===N1?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}},V1=w1;var r9={limit:1/0,ellipsis:"",ellipsisWidth:0},o9=(Z,J={})=>{return V1(Z,r9,J).width},b=o9;var K0="\x1B",b1="\x9B",n9=39,S0="\x07",C1="[",i9="]",R1="m",k0=`${i9}8;;`,B1=new RegExp(`(?:\\${C1}(?<code>\\d+)m|\\${k0}(?<uri>.*)${S0})`,"y"),q1=(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},P1=(Z)=>`${K0}${C1}${Z}${R1}`,O1=(Z)=>`${K0}${k0}${Z}${S0}`,T0=(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===K0||X===b1)Y=!0,H=J.startsWith(k0,K+1);if(Y){if(H){if(X===S0)Y=!1,H=!1}else if(X===R1)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()},d9=(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("")},s9=(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("");T0(U,M,J),W=b(U.at(-1)??"");continue}if(W+N>J&&W&&N){if(Q.wordWrap===!1&&W<J){T0(U,M,J),W=b(U.at(-1)??"");continue}U.push(""),W=0}if(W+N>J&&Q.wordWrap===!1){T0(U,M,J),W=b(U.at(-1)??"");continue}U[U.length-1]+=M,W+=N}if(Q.trim!==!1)U=U.map((X)=>d9(X));let L=U.join(`
|
|
11
|
+
`),K=!1;for(let X=0;X<L.length;X++){let M=L[X];if(F+=M,!K){if(K=M>="\uD800"&&M<="\uDBFF",K)continue}else K=!1;if(M===K0||M===b1){B1.lastIndex=X+1;let j=B1.exec(L)?.groups;if(j?.code!==void 0){let w=Number.parseFloat(j.code);Y=w===n9?void 0:w}else if(j?.uri!==void 0)H=j.uri.length===0?void 0:j.uri}if(L[X+1]===`
|
|
12
|
+
`){if(H)F+=O1("");let N=Y?q1(Y):void 0;if(Y&&N)F+=P1(N)}else if(M===`
|
|
13
|
+
`){if(Y&&q1(Y))F+=P1(Y);if(H)F+=O1(H)}}return F},a9=/\r?\n/;function f(Z,J,Q){return String(Z).normalize().split(a9).map((F)=>s9(F,J,Q)).join(`
|
|
14
|
+
`)}var P=F1(v0(),1);import{ReadStream as E1}from"tty";function y0(Z,J,Q){if(!Q.some((z)=>!z.disabled))return Z;let F=Z+J,Y=Math.max(Q.length-1,0),H=F<0?Y:F>Y?0:F;return Q[H]?.disabled?y0(H,J<0?-1:1,Q):H}function X0(Z,J,Q,F){let Y=F.split(`
|
|
15
|
+
`),H=0,z=Z;for(let W of Y){if(z<=W.length)break;z-=W.length+1,H++}for(H=Math.max(0,Math.min(Y.length-1,H+Q)),z=Math.min(z,Y[H].length)+J;z<0&&H>0;)H--,z+=Y[H].length+1;for(;z>Y[H].length&&H<Y.length-1;)z-=Y[H].length+1,H++;z=Math.max(0,Math.min(Y[H].length,z));let U=0;for(let W=0;W<H;W++)U+=Y[W].length+1;return U+z}var J8=["up","down","left","right","space","enter","cancel"],Q8=["January","February","March","April","May","June","July","August","September","October","November","December"],O={actions:new Set(J8),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:[...Q8],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(Z,J)=>`There are only ${Z} days in ${J}`,afterMin:(Z)=>`Date must be on or after ${Z.toISOString().slice(0,10)}`,beforeMax:(Z)=>`Date must be on or before ${Z.toISOString().slice(0,10)}`}}};function l0(Z,J){if(typeof Z=="string")return O.aliases.get(Z)===J;for(let Q of Z)if(Q!==void 0&&l0(Q,J))return!0;return!1}function F8(Z,J){if(Z===J)return;let Q=Z.split(`
|
|
16
|
+
`),F=J.split(`
|
|
17
|
+
`),Y=Math.max(Q.length,F.length),H=[];for(let z=0;z<Y;z++)Q[z]!==F[z]&&H.push(z);return{lines:H,numLinesBefore:Q.length,numLinesAfter:F.length,numLines:Y}}var Y8=globalThis.process.platform.startsWith("win"),$0=Symbol("clack:cancel");function j0(Z){return Z===$0}function M0(Z,J){let Q=Z;Q.isTTY&&Q.setRawMode(J)}function T1({input:Z=x1,output:J=g0,overwrite:Q=!0,hideCursor:F=!0}={}){let Y=u.createInterface({input:Z,output:J,prompt:"",tabSize:1});u.emitKeypressEvents(Z,Y),Z instanceof E1&&Z.isTTY&&Z.setRawMode(!0);let H=(z,{name:U,sequence:W})=>{let L=String(z);if(l0([L,U,W],"cancel")){F&&J.write(P.cursor.show),process.exit(0);return}if(!Q)return;u.moveCursor(J,U==="return"?0:-1,U==="return"?-1:0,()=>{u.clearLine(J,1,()=>{Z.once("keypress",H)})})};return F&&J.write(P.cursor.hide),Z.once("keypress",H),()=>{Z.off("keypress",H),F&&J.write(P.cursor.show),Z instanceof E1&&Z.isTTY&&!Y8&&Z.setRawMode(!1),Y.terminal=!1,Y.close()}}var N0=(Z)=>("columns"in Z)&&typeof Z.columns=="number"?Z.columns:80,S1=(Z)=>("rows"in Z)&&typeof Z.rows=="number"?Z.rows:20;function k1(Z,J,Q,F=Q,Y=Q,H){let z=N0(Z??g0);return f(J,z-Q.length,{hard:!0,trim:!1}).split(`
|
|
18
|
+
`).map((U,W,L)=>{let K=H?H(U,W):U;return W===0?`${F}${K}`:W===L.length-1?`${Y}${K}`:`${Q}${K}`}).join(`
|
|
19
|
+
`)}function h1(Z,J){if("~standard"in Z){let Q=Z["~standard"].validate(J);if(Q instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return Q.issues?.at(0)?.message}return Z(J)}class s{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(Z,J=!0){let{input:Q=x1,output:F=g0,render:Y,signal:H,...z}=Z;this.opts=z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=J,this._abortSignal=H,this.input=Q,this.output=F}unsubscribe(){this._subscribers.clear()}setSubscriber(Z,J){let Q=this._subscribers.get(Z)??[];Q.push(J),this._subscribers.set(Z,Q)}on(Z,J){this.setSubscriber(Z,{cb:J})}once(Z,J){this.setSubscriber(Z,{cb:J,once:!0})}emit(Z,...J){let Q=this._subscribers.get(Z)??[],F=[];for(let Y of Q)Y.cb(...J),Y.once&&F.push(()=>Q.splice(Q.indexOf(Y),1));for(let Y of F)Y()}prompt(){return new Promise((Z)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),Z($0);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Z8.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),M0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),M0(this.input,!1),Z(this.value)}),this.once("cancel",()=>{this.output.write(P.cursor.show),this.output.off("resize",this.render),M0(this.input,!1),Z($0)})})}_isActionKey(Z,J){return Z==="\t"}_shouldSubmit(Z,J){return!0}_setValue(Z){this.value=Z,this.emit("value",this.value)}_setUserInput(Z,J){this.userInput=Z??"",this.emit("userInput",this.userInput),J&&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(Z,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey(Z,J)&&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"),J?.name&&(!this._track&&O.aliases.has(J.name)&&this.emit("cursor",O.aliases.get(J.name)),O.actions.has(J.name)&&this.emit("cursor",J.name)),Z&&(Z.toLowerCase()==="y"||Z.toLowerCase()==="n")&&this.emit("confirm",Z.toLowerCase()==="y"),this.emit("key",Z,J),J?.name==="return"&&this._shouldSubmit(Z,J)){if(this.opts.validate){let Q=h1(this.opts.validate,this.value);Q&&(this.error=Q instanceof Error?Q.message:Q,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}l0([Z,J?.name,J?.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(`
|
|
20
|
+
`),M0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let Z=f(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
21
|
+
`).length-1;this.output.write(P.cursor.move(-999,Z*-1))}render(){let Z=f(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(Z!==this._prevFrame){if(this.state==="initial")this.output.write(P.cursor.hide);else{let J=F8(this._prevFrame,Z),Q=S1(this.output);if(this.restoreCursor(),J){let F=Math.max(0,J.numLinesAfter-Q),Y=Math.max(0,J.numLinesBefore-Q),H=J.lines.find((z)=>z>=F);if(H===void 0){this._prevFrame=Z;return}if(J.lines.length===1){this.output.write(P.cursor.move(0,H-Y)),this.output.write(P.erase.lines(1));let z=Z.split(`
|
|
22
|
+
`);this.output.write(z[H]),this._prevFrame=Z,this.output.write(P.cursor.move(0,z.length-H-1));return}else if(J.lines.length>1){if(F<Y)H=F;else{let U=H-Y;U>0&&this.output.write(P.cursor.move(0,U))}this.output.write(P.erase.down());let z=Z.split(`
|
|
23
|
+
`).slice(H);this.output.write(z.join(`
|
|
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 H8(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 W8(Z,J){return(J.label??String(J.value)).toLowerCase().includes(Z.toLowerCase())}function z8(Z,J){if(J)return Z?J:J[0]}var U8=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 f0(["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}${f0("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??W8;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=y0(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=z8(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=H8(this.focusedValue,this.filteredOptions);this.#J=y0(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 c0 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 L8={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function D1(Z){return[...Z].map((J)=>L8[J])}function K8(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 _0(Z){return Number.parseInt((Z||"0").replace(/_/g,"0"),10)||0}function G0(Z){return{year:_0(Z.year),month:_0(Z.month),day:_0(Z.day)}}function p0(Z,J){return new Date(Z||2001,J||1,0).getDate()}function v1(Z){let{year:J,month:Q,day:F}=G0(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 I1(Z){let J=v1(Z);return J?new Date(Date.UTC(J.year,J.month-1,J.day)):void 0}function X8(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:p0(J.year,J.month)}}class _1 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(I1(this.#Z)??void 0)}constructor(Z){let J=Z.format?{segments:D1(Z.format),separator:Z.separator??"/"}:K8(Z.locale),Q=Z.separator??J.separator,F=Z.format?D1(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=X8(Q.type,G0(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:v1(this.#Z);if(K){let{year:M,month:N}=K,j=p0(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}=G0(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}=G0(this.#Z);if(J&&Q&&F){let Y=p0(J,Q);this.#Z={...this.#Z,day:String(Math.min(F,Y)).padStart(2,"0")}}this.value=I1(this.#Z)??Z.defaultValue??void 0}}var M8=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}})}},G8=new Set(["up","down","left","right"]);class f1 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
|
+
`?`${J}\u2588
|
|
26
|
+
${F}`:`${J}${f0("inverse",Q)}${F}`}get cursor(){return this._cursor}#Z(Z){if(this.userInput.length===0){this._setUserInput(Z);return}this._setUserInput(this.userInput.slice(0,this.cursor)+Z+this.userInput.slice(this.cursor))}#H(Z){let J=this.value??"";switch(Z){case"up":this._cursor=X0(this._cursor,0,-1,J);return;case"down":this._cursor=X0(this._cursor,0,1,J);return;case"left":this._cursor=X0(this._cursor,-1,0,J);return;case"right":this._cursor=X0(this._cursor,1,0,J);return}}_shouldSubmit(Z,J){if(this.#Y)return this.focused==="submit"?!0:(this.#Z(`
|
|
27
|
+
`),this._cursor++,!1);let Q=this.#J;return this.#J=!0,Q&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
|
|
28
|
+
`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#Z(`
|
|
29
|
+
`),this._cursor++,!1)}constructor(Z){let J=Z.initialUserInput??Z.initialValue;super({...Z,initialUserInput:J},!1),J!==void 0&&(this._cursor=J.length),this.#Y=Z.showSubmit??!1,this.on("key",(Q,F)=>{if(F?.name&&G8.has(F.name)){this.#J=!1,this.#H(F.name);return}if(Q==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(F?.name!=="return"){if(this.#J=!1,F?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(F?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}Q&&(this.#Y&&this.focused==="submit"&&(this.focused="editor"),this.#Z(Q??""),this._cursor++)}}),this.on("userInput",(Q)=>{this._setValue(Q)}),this.on("finalize",()=>{this.value||(this.value=Z.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as G,stripVTControlCharacters as n6}from"util";import I from"process";var t=F1(v0(),1);function j8(){if(I.platform!=="win32")return I.env.TERM!=="linux";return Boolean(I.env.CI)||Boolean(I.env.WT_SESSION)||Boolean(I.env.TERMINUS_SUBLIME)||I.env.ConEmuTask==="{cmd::Cmder}"||I.env.TERM_PROGRAM==="Terminus-Sublime"||I.env.TERM_PROGRAM==="vscode"||I.env.TERM==="xterm-256color"||I.env.TERM==="alacritty"||I.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var m0=j8(),N8=()=>process.env.CI==="true";var V=(Z,J)=>m0?Z:J,w8=V("\u25C6","*"),g1=V("\u25A0","x"),l1=V("\u25B2","x"),w0=V("\u25C7","o"),V8=V("\u250C","T"),C=V("\u2502","|"),c1=V("\u2514","\u2014"),a6=V("\u2510","T"),e6=V("\u2518","\u2014"),y1=V("\u25CF",">"),$1=V("\u25CB"," "),t6=V("\u25FB","[\u2022]"),Z7=V("\u25FC","[+]"),J7=V("\u25FB","[ ]"),Q7=V("\u25AA","\u2022"),p1=V("\u2500","-"),B8=V("\u256E","+"),q8=V("\u251C","+"),P8=V("\u256F","+"),O8=V("\u2570","+"),F7=V("\u256D","+"),b8=V("\u25CF","\u2022"),C8=V("\u25C6","*"),R8=V("\u25B2","!"),A8=V("\u25A0","x"),E8=(Z)=>{switch(Z){case"initial":case"active":return G("cyan",w8);case"cancel":return G("red",g1);case"error":return G("yellow",l1);case"submit":return G("green",w0)}};var m1=(Z)=>{let J=Z.active??"Yes",Q=Z.inactive??"No";return new c0({active:J,inactive:Q,signal:Z.signal,input:Z.input,output:Z.output,initialValue:Z.initialValue??!0,render(){let F=Z.withGuide??O.withGuide,Y=`${E8(this.state)} `,H=F?`${G("gray",C)} `:"",z=k1(Z.output,Z.message,H,Y),U=`${F?`${G("gray",C)}
|
|
30
|
+
`:""}${z}
|
|
31
|
+
`,W=this.value?J:Q;switch(this.state){case"submit":{let L=F?`${G("gray",C)} `:"";return`${U}${L}${G("dim",W)}`}case"cancel":{let L=F?`${G("gray",C)} `:"";return`${U}${L}${G(["strikethrough","dim"],W)}${F?`
|
|
32
|
+
${G("gray",C)}`:""}`}default:{let L=F?`${G("cyan",C)} `:"",K=F?G("cyan",c1):"";return`${U}${L}${this.value?`${G("green",y1)} ${J}`:`${G("dim",$1)} ${G("dim",J)}`}${Z.vertical?F?`
|
|
33
|
+
${G("cyan",C)} `:`
|
|
34
|
+
`:` ${G("dim","/")} `}${this.value?`${G("dim",$1)} ${G("dim",Q)}`:`${G("green",y1)} ${Q}`}
|
|
35
|
+
${K}
|
|
36
|
+
`}}}}).prompt()};var Y7=[`${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(`
|
|
38
|
+
`)}
|
|
39
|
+
`)},info:(Z,J)=>{B.message(Z,{...J,symbol:G("blue",b8)})},success:(Z,J)=>{B.message(Z,{...J,symbol:G("green",C8)})},step:(Z,J)=>{B.message(Z,{...J,symbol:G("green",w0)})},warn:(Z,J)=>{B.message(Z,{...J,symbol:G("yellow",R8)})},warning:(Z,J)=>{B.warn(Z,J)},error:(Z,J)=>{B.message(Z,{...J,symbol:G("red",A8)})}};var V0=(Z="",J)=>{let Q=J?.output??process.stdout,F=J?.withGuide??O.withGuide?`${G("gray",V8)} `:"";Q.write(`${F}${Z}
|
|
40
|
+
`)},u1=(Z="",J)=>{let Q=J?.output??process.stdout,F=J?.withGuide??O.withGuide?`${G("gray",C)}
|
|
41
|
+
${G("gray",c1)} `:"";Q.write(`${F}${Z}
|
|
42
|
+
|
|
43
|
+
`)};var D8=(Z)=>Z,I8=(Z,J,Q)=>{let F={hard:!0,trim:!1},Y=f(Z,J,F).split(`
|
|
44
|
+
`),H=Y.reduce((W,L)=>Math.max(b(L),W),0),z=Y.map(Q).reduce((W,L)=>Math.max(b(L),W),0),U=J-(z-H);return f(Z,U,F)},B0=(Z="",J="",Q)=>{let F=Q?.output??I.stdout,Y=Q?.withGuide??O.withGuide,H=Q?.format??D8,z=["",...I8(Z,N0(F)-6,H).split(`
|
|
45
|
+
`).map(H),""],U=b(J),W=Math.max(z.reduce((M,N)=>{let j=b(N);return j>M?j:M},0),U)+2,L=z.map((M)=>`${G("gray",C)} ${M}${" ".repeat(W-b(M))}${G("gray",C)}`).join(`
|
|
46
|
+
`),K=Y?`${G("gray",C)}
|
|
47
|
+
`:"",X=Y?q8:O8;F.write(`${K}${G("green",w0)} ${G("reset",J)} ${G("gray",p1.repeat(Math.max(W-U-1,1))+B8)}
|
|
48
|
+
${L}
|
|
49
|
+
${G("gray",X+p1.repeat(W+2)+P8)}
|
|
50
|
+
`)};var x8=(Z)=>G("magenta",Z),q0=({indicator:Z="dots",onCancel:J,output:Q=process.stdout,cancelMessage:F,errorMessage:Y,frames:H=m0?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:z=m0?80:120,signal:U,...W}={})=>{let L=N8(),K,X,M=!1,N=!1,j="",w,k=performance.now(),l=N0(Q),c=W?.styleFrame??x8,x=(q)=>{let D=q>1?Y??O.messages.error:F??O.messages.cancel;N=q===1,M&&(e(D,q),N&&typeof J=="function"&&J())},h=()=>x(2),A=()=>x(1),d=()=>{process.on("uncaughtExceptionMonitor",h),process.on("unhandledRejection",h),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",x),U&&U.addEventListener("abort",A)},T=()=>{process.removeListener("uncaughtExceptionMonitor",h),process.removeListener("unhandledRejection",h),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",x),U&&U.removeEventListener("abort",A)},R=()=>{if(w===void 0)return;L&&Q.write(`
|
|
51
|
+
`);let q=f(w,l,{hard:!0,trim:!1}).split(`
|
|
52
|
+
`);q.length>1&&Q.write(t.cursor.up(q.length-1)),Q.write(t.cursor.to(0)),Q.write(t.erase.down())},m=(q)=>q.replace(/\.+$/,""),i=(q)=>{let D=(performance.now()-q)/1000,v=Math.floor(D/60),_=Math.floor(D%60);return v>0?`[${v}m ${_}s]`:`[${_}s]`},E=W.withGuide??O.withGuide,W0=(q="")=>{M=!0,K=T1({output:Q}),j=m(q),k=performance.now(),E&&Q.write(`${G("gray",C)}
|
|
53
|
+
`);let D=0,v=0;d(),X=setInterval(()=>{if(L&&j===w)return;R(),w=j;let _=c(H[D]),z0;if(L)z0=`${_} ${j}...`;else if(Z==="timer")z0=`${_} ${j} ${i(k)}`;else{let P9=".".repeat(Math.floor(v)).slice(0,3);z0=`${_} ${j}${P9}`}let q9=f(z0,l,{hard:!0,trim:!1});Q.write(q9),D=D+1<H.length?D+1:0,v=v<4?v+0.125:0},z)},e=(q="",D=0,v=!1)=>{if(!M)return;M=!1,clearInterval(X),R();let _=D===0?G("green",w0):D===1?G("red",g1):G("red",l1);j=q??j,v||(Z==="timer"?Q.write(`${_} ${j} ${i(k)}
|
|
54
|
+
`):Q.write(`${_} ${j}
|
|
55
|
+
`)),T(),K()};return{start:W0,stop:(q="")=>e(q,0),message:(q="")=>{j=m(q??j)},cancel:(q="")=>e(q,1),error:(q="")=>e(q,2),clear:()=>e("",0,!0),get isCancelled(){return N}}},H7={light:V("\u2500","-"),heavy:V("\u2501","="),block:V("\u2588","#")};var W7=[`${G("dim","\u2191/\u2193")} to navigate`,`${G("dim","Enter:")} confirm`];var z7=`${G("gray",C)} `;var{$:u0}=globalThis.Bun;var T8={pacman:["arch","endeavouros","manjaro","garuda","cachyos","arcolinux","rebornos","blendos","steamos","chimeraos"],dnf:["fedora","nobara","bazzite","ultramarine"]},r1=(Z)=>{for(let[J,Q]of Object.entries(T8))if(Q.includes(Z))return J;return null};var o1={osName:void 0,osId:void 0,platform:"linux",packageManager:void 0,helperAur:null,isFlatpak:!1,flatpak:!1};function r(Z){return o1[Z]}function y(Z,J){o1[Z]=J}async function r0(Z){try{return await u0`which ${Z}`.quiet(),!0}catch{return!1}}async function S8(){let Z=[];if(await r0("yay"))Z.push("yay");if(await r0("paru"))Z.push("paru");return Z}async function k8(){if(process.platform==="linux"){let Z=await u0`cat /etc/os-release | grep ^NAME`.quiet().text()||"",J=await u0`cat /etc/os-release | grep ^ID`.quiet().text()||"",Q=Z.trim().slice(5).replace(/"/g,"");return{id:J.trim().slice(3).replace(/"/g,""),name:Q}}return{id:"unknown",name:"unknown"}}async function P0(){let{name:Z="",id:J=""}=await k8(),Q=r1(J),F=Q==="pacman"?await S8():null,Y=await r0("flatpak");if(y("osName",Z),y("osId",J),y("flatpak",Y),F)y("helperAur",F[0]);if(Q)y("packageManager",Q);return{osName:Z,osId:J,packageManager:Q,aurHelper:F,flatpak:Y}}async function n1(){V0("\uD83D\uDD0D Scanning system");let Z=q0();Z.start("Detecting environment...");let J=await P0();return Z.stop("Environment detected"),B0([`OS ${J.osName} (${J.osId})`,`Package Manager ${J.packageManager}`,J.aurHelper?`AUR Helper ${J.aurHelper}`:null,`Flatpak ${J.flatpak?"Enabled":"Disabled"}`].filter(Boolean).join(`
|
|
56
|
+
`),"System Environment",{withGuide:!0}),u1("Scan completed"),J}var O0,h8={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function s1(Z){if(!Z&&!O0)return h8;return{lang:Z?.lang??O0?.lang,message:Z?.message,abortEarly:Z?.abortEarly??O0?.abortEarly,abortPipeEarly:Z?.abortPipeEarly??O0?.abortPipeEarly}}var v8;function _8(Z){return v8?.get(Z)}var f8;function y8(Z){return f8?.get(Z)}var $8;function p8(Z,J){return $8?.get(Z)?.get(J)}function o0(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 $(Z,J,Q,F,Y){let H=Y&&"input"in Y?Y.input:Q.value,z=Y?.expected??Z.expects??null,U=Y?.received??o0(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??p8(Z.reference,W.lang)??(L?y8(W.lang):null)??F.message??_8(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 i1=new WeakMap;function p(Z){let J=i1.get(Z);if(!J)J={version:1,vendor:"valibot",validate(Q){return Z["~run"]({value:Q},s1())}},i1.set(Z,J);return J}function a1(Z,J){let Q=[...new Set(Z)];if(Q.length>1)return`(${Q.join(` ${J} `)})`;return Q[0]??"never"}var g8=class extends Error{constructor(Z){super(Z[0].message);this.name="ValiError",this.issues=Z}};function l8(Z,J,Q){return typeof Z.fallback==="function"?Z.fallback(J,Q):Z.fallback}function e1(Z,J,Q){return typeof Z.default==="function"?Z.default(J,Q):Z.default}function g(Z,J){return{kind:"schema",type:"array",reference:g,expects:"Array",async:!1,item:Z,message:J,get "~standard"(){return p(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 $(this,"type",Q,F);return Q}}}function J0(Z){return{kind:"schema",type:"boolean",reference:J0,expects:"boolean",async:!1,message:Z,get "~standard"(){return p(this)},"~run"(J,Q){if(typeof J.value==="boolean")J.typed=!0;else $(this,"type",J,Q);return J}}}function n0(Z,J){return{kind:"schema",type:"literal",reference:n0,expects:o0(Z),async:!1,literal:Z,message:J,get "~standard"(){return p(this)},"~run"(Q,F){if(Q.value===this.literal)Q.typed=!0;else $(this,"type",Q,F);return Q}}}function o(Z,J){return{kind:"schema",type:"object",reference:o,expects:"Object",async:!1,entries:Z,message:J,get "~standard"(){return p(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]:e1(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]=l8(z);else if(z.type!=="exact_optional"&&z.type!=="optional"&&z.type!=="nullish"){if($(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 $(this,"type",Q,F);return Q}}}function Q0(Z,J){return{kind:"schema",type:"optional",reference:Q0,expects:`(${Z.expects} | undefined)`,async:!1,wrapped:Z,default:J,get "~standard"(){return p(this)},"~run"(Q,F){if(Q.value===void 0){if(this.default!==void 0)Q.value=e1(this,Q,F);if(Q.value===void 0)return Q.typed=!0,Q}return this.wrapped["~run"](Q,F)}}}function F0(Z,J){return{kind:"schema",type:"picklist",reference:F0,expects:a1(Z.map(o0),"|"),async:!1,options:Z,message:J,get "~standard"(){return p(this)},"~run"(Q,F){if(this.options.includes(Q.value))Q.typed=!0;else $(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 p(this)},"~run"(J,Q){if(typeof J.value==="string")J.typed=!0;else $(this,"type",J,Q);return J}}}function d1(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 Y0(Z,J){return{kind:"schema",type:"union",reference:Y0,expects:a1(Z.map((Q)=>Q.expects),"|"),async:!1,options:Z,message:J,get "~standard"(){return p(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];$(this,"type",Q,F,{issues:d1(H)}),Q.typed=!0}else if(z?.length===1)return z[0];else $(this,"type",Q,F,{issues:d1(z)});return Q}}}function t1(Z,J,Q){let F=Z["~run"]({value:J},s1(Q));if(F.issues)throw new g8(F.issues);return F.value}function i0(Z,J){let Q={};for(let F in Z.entries)Q[F]=!J||J.includes(F)?Q0(Z.entries[F]):Z.entries[F];return{...Z,entries:Q,get "~standard"(){return p(this)}}}import J9 from"path";import{homedir as c8}from"os";function b0(Z){if(Z.startsWith("~"))return J9.join(c8(),Z.slice(1));return J9.resolve(Z)}var m8=i0(o({flatpak:J0(),backup:J0(),aur_helper:F0(["yay","paru"])})),u8=o({source:S(),target:S(),sudo:Q0(J0())}),r8=F0(["aur","pacman"]),o8=Y0([S(),g(S()),g(g(S()))]),n8=o({name:S(),post_hooks:Q0(o8)}),Q9=g(Y0([S(),n8])),i8=o({manager:r8,items:Q9}),d8=o({manager:n0("flatpak"),scope:F0(["system","user"]),items:Q9}),F9=i0(o({imports:g(S()),settings:m8,packages:g(Y0([d8,i8])),symlinks:g(u8)}));import R0 from"path";var n={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},C7={defaultMerge:n.defaultMerge};function s8(Z,J){return J}function a8(Z,J){return Z.filter((Q)=>Q!==void 0)}var Y9;(function(Z){Z[Z.NOT=0]="NOT",Z[Z.RECORD=1]="RECORD",Z[Z.ARRAY=2]="ARRAY",Z[Z.SET=3]="SET",Z[Z.MAP=4]="MAP",Z[Z.OTHER=5]="OTHER"})(Y9||(Y9={}));function H9(Z){if(typeof Z!=="object"||Z===null)return 0;if(Array.isArray(Z))return 2;if(Z6(Z))return 1;if(Z instanceof Set)return 3;if(Z instanceof Map)return 4;return 5}function e8(Z){let J=new Set;for(let Q of Z)for(let F of[...Object.keys(Q),...Object.getOwnPropertySymbols(Q)])J.add(F);return J}function t8(Z,J){return typeof Z==="object"&&Object.prototype.propertyIsEnumerable.call(Z,J)}function z9(Z){let J=0,Q=Z[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(Q===void 0)return{done:!0,value:void 0};let F=Q.next();if(F.done===!0){J+=1,Q=Z[J]?.[Symbol.iterator]();continue}return{done:!1,value:F.value}}while(!0)}}}}}var W9=["[object Object]","[object Module]"];function Z6(Z){if(!W9.includes(Object.prototype.toString.call(Z)))return!1;let{constructor:J}=Z;if(J===void 0)return!0;let Q=J.prototype;if(Q===null||typeof Q!=="object"||!W9.includes(Object.prototype.toString.call(Q)))return!1;if(!Q.hasOwnProperty("isPrototypeOf"))return!1;return!0}function J6(Z,J,Q){let F={};for(let Y of e8(Z)){let H=[];for(let W of Z)if(t8(W,Y))H.push(W[Y]);if(H.length===0)continue;let z=J.metaDataUpdater(Q,{key:Y,parents:Z}),U=U9(H,J,z);if(U===n.skip)continue;if(Y==="__proto__")Object.defineProperty(F,Y,{value:U,configurable:!0,enumerable:!0,writable:!0});else F[Y]=U}return F}function Q6(Z){return Z.flat()}function F6(Z){return new Set(z9(Z))}function Y6(Z){return new Map(z9(Z))}function H6(Z){return Z.at(-1)}var C0={mergeRecords:J6,mergeArrays:Q6,mergeSets:F6,mergeMaps:Y6,mergeOthers:H6};function H0(...Z){return W6({})(...Z)}function W6(Z,J){let Q=z6(Z,F);function F(...Y){return U9(Y,Q,J)}return F}function z6(Z,J){return{defaultMergeFunctions:C0,mergeFunctions:{...C0,...Object.fromEntries(Object.entries(Z).filter(([Q,F])=>Object.hasOwn(C0,Q)).map(([Q,F])=>F===!1?[Q,C0.mergeOthers]:[Q,F]))},metaDataUpdater:Z.metaDataUpdater??s8,deepmerge:J,useImplicitDefaultMerging:Z.enableImplicitDefaultMerging??!1,filterValues:Z.filterValues===!1?void 0:Z.filterValues??a8,actions:n}}function U9(Z,J,Q){let F=J.filterValues?.(Z,Q)??Z;if(F.length===0)return;if(F.length===1)return d0(F,J,Q);let Y=H9(F[0]);if(Y!==0&&Y!==5)for(let H=1;H<F.length;H++){if(H9(F[H])===Y)continue;return d0(F,J,Q)}switch(Y){case 1:return U6(F,J,Q);case 2:return L6(F,J,Q);case 3:return K6(F,J,Q);case 4:return X6(F,J,Q);default:return d0(F,J,Q)}}function U6(Z,J,Q){let F=J.mergeFunctions.mergeRecords(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeRecords!==J.defaultMergeFunctions.mergeRecords)return J.defaultMergeFunctions.mergeRecords(Z,J,Q);return F}function L6(Z,J,Q){let F=J.mergeFunctions.mergeArrays(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeArrays!==J.defaultMergeFunctions.mergeArrays)return J.defaultMergeFunctions.mergeArrays(Z);return F}function K6(Z,J,Q){let F=J.mergeFunctions.mergeSets(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeSets!==J.defaultMergeFunctions.mergeSets)return J.defaultMergeFunctions.mergeSets(Z);return F}function X6(Z,J,Q){let F=J.mergeFunctions.mergeMaps(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeMaps!==J.defaultMergeFunctions.mergeMaps)return J.defaultMergeFunctions.mergeMaps(Z);return F}function d0(Z,J,Q){let F=J.mergeFunctions.mergeOthers(Z,J,Q);if(F===n.defaultMerge||J.useImplicitDefaultMerging&&F===void 0&&J.mergeFunctions.mergeOthers!==J.defaultMergeFunctions.mergeOthers)return J.defaultMergeFunctions.mergeOthers(Z);return F}async function s0(Z,J=new Set){let Q=R0.resolve(Z);if(J.has(Q))throw Error(`Circular dependency detected: ${Q}`);J.add(Q);let F=await Bun.file(Q).text(),Y=Bun.TOML.parse(F),{imports:H=[],symlinks:z=[]}=Y;delete Y.imports;let U=R0.dirname(Q);Y.symlinks=M6(U,z);let W={};for(let L of H){let K=R0.resolve(U,L),X=await s0(K,J);W=H0(W,X)}return H0(Y,W)}function M6(Z,J){if(!J||J.length===0)return[];let Q=[];for(let F of J){if(!F)continue;let{source:Y,target:H}=F,z=R0.resolve(Z,Y),U=b0(H);Q.push({source:z,target:U})}return Q}async function A0(Z){let J=b0(Z);B.step("Validating Configuration");let Q=q0();Q.start("Validating...");let F=await s0(J),Y=t1(F9,F);return Q.stop("Successfully validated with no errors!"),Y}import w6 from"path";var{deepEquals:M9}=globalThis.Bun;import a0 from"path";import e0 from"fs/promises";var E0={};function D0(){return E0}function L9(Z,J){E0[Z]=J}async function K9(Z){let J=Z??r("configDir"),Q=a0.resolve(J||".",".state/hofii-lock.json");if(await e0.exists(Q)){let F=await Bun.file(Q).json();Object.assign(E0,F.config)}}async function X9(){let Z=a0.resolve(r("configDir")||".",".state");if(!await e0.exists(Z))await e0.mkdir(Z,{recursive:!0});let J={config:E0};await Bun.write(a0.resolve(Z,"hofii-lock.json"),JSON.stringify(J,null,2))}function G6(Z,J){let Q=J?.filter((Y)=>!Z?.some((H)=>M9(Y,H,!0))),F=Z?.filter((Y)=>!J?.some((H)=>M9(Y,H,!0)));return{added:Q,removed:F}}function G9(Z){let J=D0();return{symlinks:G6(J.symlinks,Z.symlinks)}}import j6 from"fs/promises";var{deepEquals:N6}=globalThis.Bun;import Z1 from"fs/promises";async function t0({cmd:Z,errMsg:J,opt:Q={stdin:"inherit",stdout:"inherit",stderr:"inherit"}}){let F=Bun.spawn(Z,{stdin:Q.stdin,stdout:Q.stdout,stderr:Q.stderr}),Y=Q.stdout==="pipe"?new Response(F.stdout).text():void 0,H=Q.stderr==="pipe"?new Response(F.stderr).text():void 0,z=F.exited,[U,W,L]=await Promise.all([Y,H,z]);if(L!==0)throw Error(J??`Error caused with exit code ${L}`);return{stdout:U,stderr:W,exitCode:L}}async function j9(Z,J,Q=!1){let F=[Z,"->",J].join(" ");if(Q){if(r("platform")!=="linux"){B.warn("Sudo only support in Linux");return}await t0({cmd:["sudo","ln","-s",Z,J],errMsg:`Failed create symlink ${F}`})}else await Z1.symlink(Z,J);B.success(`Succesfully create symlink ${F}`)}async function N9(Z,J=!1){let Q=Z;if(J){if(r("platform")!=="linux"){B.warn("Sudo only support in Linux");return}await t0({cmd:["sudo","rm",Z],errMsg:`Failed remove symlink ${Q}`})}else await Z1.unlink(Z);B.success(`Succesfully remove symlink ${Q}`)}async function J1(Z){try{return await Z1.lstat(Z)}catch(J){return null}}async function V9(Z){if(!Z)return;let J=r("settings")?.backup??"",{added:Q=[],removed:F=[]}=Z,Y=[],H=[];try{let z=(await Promise.allSettled(F.map(async(W)=>{let L=await J1(W.target);if(!L){B.warn(`Target doesn't exist: ${W.target}, did you remove it manually?`),H.push(W);return}if(!L.isSymbolicLink()){B.warn(`File ${W.target} not a symlink, did you remove it manually?`),H.push(W);return}await N9(W.target,W.sudo),H.push(W)}))).filter((W)=>W.status==="rejected"),U=(await Promise.allSettled(Q.map(async(W)=>{if(await J1(W.target))if(J)await j6.rename(W.target,W.target+".bak");else{B.error(`Target already exists, skip create: ${W.target}`);return}await j9(W.source,W.target,W.sudo),Y.push(W)}))).filter((W)=>W.status==="rejected");for(let W of U)console.error(`Failed to add symlink: ${w9(W)}`);for(let W of z)console.error(`Failed to remove symlink: ${w9(W)}`);if(U.length>0||z.length>0)B.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}catch(z){console.error(z),B.error(" [FATAL] Failed to apply symlinks"),process.exitCode=1}finally{let W=((D0()??{}).symlinks??[]).filter((L)=>!H.some((K)=>N6(K,L))).concat(Y);B.info(`Updated symlinks state: ${W.length}`),L9("symlinks",W)}}function w9(Z){if(Z instanceof Error)return`[${"code"in Z?String(Z.code):"ERROR"}] ${Z.message}`;return`[ERROR] ${String(Z)}`}async function B9(Z){let J=w6.join(Z,"config.toml");y("configDir",Z),await K9(Z),V0("Switching configuration"),B.info("Scanning system environment..."),await P0();let Q=await A0(J);y("settings",H0(Q.settings,{backup:!0}));let F=G9(Q);B0((()=>{let z=["SYMLINKS"],U=F.symlinks,{added:W=[],removed:L=[]}=U;if(W?.length===0&&L?.length===0)return z.push(" - No changes to apply with symlinks"),z.join(`
|
|
57
|
+
`);for(let K of W)z.push(` - [ADDED] ${K.sudo?"(sudo) ":""}${K.source} -> ${K.target}`);for(let K of L)z.push(` - [REMOVED] ${K.sudo?"(sudo) ":""}${K.source} -> ${K.target}`);return z.join(`
|
|
58
|
+
`)})(),"Config To Apply");let H=await m1({message:"Apply config changes? (Please review the changes first!!)"});if(!H||j0(H))B.warn("Config changes not applied."),process.exit(0);await V9(F.symlinks)}var a=K1("hofii");a.version("0.0.1");a.command("scan","Detect system environment").alias("s").action(async()=>{await n1()});a.command("validate [dir]","Validate configuration files").alias("v").action(async(Z)=>{await A0(Z)});a.command("switch [dir]","Switch to new configuration").alias("sw").action(async(Z)=>{let J=V6.resolve(Z);await B9(J)});try{a.help().parse(process.argv,{run:!1}),await a.runMatchedCommand()}catch(Z){console.error(Z)}finally{await X9()}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hofii",
|
|
3
|
+
"description": "An orchestration tools for manage dotfiles and packages",
|
|
4
|
+
"module": "index.ts",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"hofii": "./dist/main.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "bun run index.ts",
|
|
14
|
+
"scan": "bun run index.ts scan",
|
|
15
|
+
"validate": "bun run index.ts validate",
|
|
16
|
+
"switch": "bun run index.ts switch",
|
|
17
|
+
"build": "bun build index.ts --target=bun --minify --outfile=dist/main.js"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/bun": "latest",
|
|
21
|
+
"typescript": "^5"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@clack/prompts": "^1.7.0",
|
|
25
|
+
"cac": "^7.0.0",
|
|
26
|
+
"deepmerge-ts": "^7.1.5",
|
|
27
|
+
"valibot": "^1.4.2"
|
|
28
|
+
},
|
|
29
|
+
"version": "0.0.1"
|
|
30
|
+
}
|