@fnet/cli 0.133.0 → 0.133.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.
Files changed (182) hide show
  1. package/dist/fbin/index.js +14 -1
  2. package/dist/fnet/index.0jcm9pn5.js +1 -0
  3. package/dist/fnet/index.2084z2ed.js +2 -0
  4. package/dist/fnet/index.33f1ggpr.js +1 -0
  5. package/dist/fnet/index.3exge2js.js +1 -0
  6. package/dist/fnet/index.3kfx538h.js +1 -0
  7. package/dist/fnet/index.490y87nc.js +1 -0
  8. package/dist/fnet/index.4g9yezkq.js +1 -0
  9. package/dist/fnet/index.4jkat7r4.js +1 -0
  10. package/dist/fnet/index.7crx8ky1.js +1 -0
  11. package/dist/fnet/index.7vw06nrn.js +1 -0
  12. package/dist/fnet/index.9567fa9x.js +1 -0
  13. package/dist/fnet/index.gh75wt1m.js +1 -0
  14. package/dist/fnet/index.hzsfswvp.js +1 -0
  15. package/dist/fnet/index.jgpc3grc.js +1 -0
  16. package/dist/fnet/index.js +19 -1
  17. package/dist/fnet/index.p0zb7e1b.js +1 -0
  18. package/dist/fnet/index.r19p3bpa.js +2 -0
  19. package/dist/fnet/index.r82rtnmz.js +1 -0
  20. package/dist/fnet/index.s662t98v.js +1 -0
  21. package/dist/fnet/index.w74dpnpn.js +1 -0
  22. package/dist/fnet/index.xeaw5xa9.js +1 -0
  23. package/dist/fnet/index.zm4kesg6.js +1 -0
  24. package/dist/fnode/index.05n3mvs9.js +2 -0
  25. package/dist/fnode/index.2hc9tbyx.js +1 -0
  26. package/dist/fnode/index.2pnjg6dc.js +1 -0
  27. package/dist/fnode/index.9qgtmxq3.js +2 -0
  28. package/dist/fnode/index.b1q7y05p.js +1 -0
  29. package/dist/fnode/index.bhapgrs7.js +1 -0
  30. package/dist/fnode/index.cvxrf34y.js +2 -0
  31. package/dist/fnode/index.dp9wyahp.js +1 -0
  32. package/dist/fnode/index.eqxmcpdc.js +1 -0
  33. package/dist/fnode/index.f2tb0x3t.js +1 -0
  34. package/dist/fnode/index.fbzv6wwf.js +1 -0
  35. package/dist/fnode/index.gazd9raq.js +1 -0
  36. package/dist/fnode/index.hv4s25f0.js +3 -0
  37. package/dist/fnode/index.j5z7dtsx.js +1 -0
  38. package/dist/fnode/index.js +9 -1
  39. package/dist/fnode/index.kb4e4bxf.js +1 -0
  40. package/dist/fnode/index.qn0schqp.js +1 -0
  41. package/dist/fnode/index.rht29phd.js +1 -0
  42. package/dist/fnode/index.rzsfmek6.js +3 -0
  43. package/dist/fnode/index.s0nk6cv8.js +4 -0
  44. package/dist/fnode/index.s66v6wt4.js +1 -0
  45. package/dist/fnode/index.sv7v0y60.js +1 -0
  46. package/dist/fnode/index.tgkhgnrp.js +1 -0
  47. package/dist/fnode/index.vq706f75.js +1 -0
  48. package/dist/fnode/index.y8pvdcny.js +1 -0
  49. package/dist/fnode/index.z4vz93ww.js +1 -0
  50. package/dist/frun/index.js +1 -1
  51. package/dist/fservice/index.js +18 -1
  52. package/dist/fservice/index.q01yvaz0.js +2 -0
  53. package/package.json +21 -18
  54. package/readme.md +62 -15
  55. package/template/fnet/core/object.js +10 -10
  56. package/template/fnet/node/package.json.njk +6 -3
  57. package/template/fnet/node/src/cli/index.js.njk +5 -315
  58. package/template/fnet/node/src/cli/index.js.v1.njk +318 -0
  59. package/template/fnet/node/src/cli/v2/core/args-parser.njk +10 -0
  60. package/template/fnet/node/src/cli/v2/core/imports.njk +31 -0
  61. package/template/fnet/node/src/cli/v2/core/run-wrapper.njk +25 -0
  62. package/template/fnet/node/src/cli/v2/index.js.njk +184 -0
  63. package/template/fnet/node/src/cli/v2/modes/default/extend.njk +11 -0
  64. package/template/fnet/node/src/cli/v2/modes/default/standard.njk +20 -0
  65. package/template/fnet/node/src/cli/v2/modes/http/builtin.njk +66 -0
  66. package/template/fnet/node/src/cli/v2/modes/http/imports.njk +9 -0
  67. package/template/fnet/node/src/cli/v2/modes/http/index.njk +12 -0
  68. package/template/fnet/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  69. package/template/fnet/node/src/cli/v2/modes/mcp/index.njk +30 -0
  70. package/template/fnet/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  71. package/template/fnet/node/src/cli/v2/modes/mcp/tool-handlers.njk +46 -0
  72. package/template/fnet/node/src/cli/v2/modes/mcp/transport-http.njk +222 -0
  73. package/template/fnet/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  74. package/template/fnet/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  75. package/template/fnet/node/src/cli/v2/modes/pipeline/index.njk +113 -0
  76. package/template/fnet/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  77. package/template/fnet/node/src/cli/v2/modes/webhook/index.njk +127 -0
  78. package/template/fnet/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  79. package/template/fnet/node/src/cli/v2/modes/websocket/index.njk +104 -0
  80. package/template/fnet/node/src/default/blocks/assign.js.njk +10 -48
  81. package/template/fnet/node/src/default/blocks/call.js.njk +110 -156
  82. package/template/fnet/node/src/default/blocks/for.js.njk +58 -74
  83. package/template/fnet/node/src/default/blocks/form.js.njk +21 -59
  84. package/template/fnet/node/src/default/blocks/http.js.njk +135 -0
  85. package/template/fnet/node/src/default/blocks/modules.js.njk +10 -52
  86. package/template/fnet/node/src/default/blocks/new.js.njk +40 -85
  87. package/template/fnet/node/src/default/blocks/next.js.njk +10 -32
  88. package/template/fnet/node/src/default/blocks/output.js.njk +10 -48
  89. package/template/fnet/node/src/default/blocks/parallel.js.njk +64 -0
  90. package/template/fnet/node/src/default/blocks/pipeline.js.njk +109 -0
  91. package/template/fnet/node/src/default/blocks/raise.js.njk +9 -25
  92. package/template/fnet/node/src/default/blocks/retry.js.njk +70 -0
  93. package/template/fnet/node/src/default/blocks/return.js.njk +13 -25
  94. package/template/fnet/node/src/default/blocks/schedule.js.njk +66 -0
  95. package/template/fnet/node/src/default/blocks/signal.js.njk +10 -32
  96. package/template/fnet/node/src/default/blocks/steps.js.njk +32 -48
  97. package/template/fnet/node/src/default/blocks/switch.js.njk +37 -67
  98. package/template/fnet/node/src/default/blocks/tryexcept.js.njk +58 -52
  99. package/template/fnet/node/src/default/blocks/wait.js.njk +10 -30
  100. package/template/fnet/node/src/default/input.args.js.njk +5 -2
  101. package/template/fnet/node/src/default/macros/block-body-header.js.njk +1 -1
  102. package/template/fnet/node/src/default/macros/block-header.js.njk +0 -3
  103. package/template/fnet/node/src/default/macros/block-next.js.njk +1 -1
  104. package/template/fnet/node/src/default/macros/block-run-footer.js.njk +1 -1
  105. package/template/fnet/node/src/default/macros/block-run-header.js.njk +14 -2
  106. package/template/fnet/node/src/default/macros/page.js.njk +1 -1
  107. package/template/fnet/node/src/default/types/block.js.njk +133 -0
  108. package/template/fnet/node/src/default/workflow.js.njk +8 -6
  109. package/template/fnode/node/package.json.njk +5 -4
  110. package/template/fnode/node/src/cli/index.js.njk +3 -397
  111. package/template/fnode/node/src/cli/index.js.v1.njk +464 -0
  112. package/template/fnode/node/src/cli/v2/core/args-parser.njk +10 -0
  113. package/template/fnode/node/src/cli/v2/core/imports.njk +29 -0
  114. package/template/fnode/node/src/cli/v2/core/run-wrapper.njk +25 -0
  115. package/template/fnode/node/src/cli/v2/index.js.njk +184 -0
  116. package/template/fnode/node/src/cli/v2/modes/default/extend.njk +11 -0
  117. package/template/fnode/node/src/cli/v2/modes/default/standard.njk +19 -0
  118. package/template/fnode/node/src/cli/v2/modes/http/builtin.njk +61 -0
  119. package/template/fnode/node/src/cli/v2/modes/http/imports.njk +9 -0
  120. package/template/fnode/node/src/cli/v2/modes/http/index.njk +12 -0
  121. package/template/fnode/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  122. package/template/fnode/node/src/cli/v2/modes/mcp/index.njk +30 -0
  123. package/template/fnode/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  124. package/template/fnode/node/src/cli/v2/modes/mcp/tool-handlers.njk +41 -0
  125. package/template/fnode/node/src/cli/v2/modes/mcp/transport-http.njk +212 -0
  126. package/template/fnode/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  127. package/template/fnode/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  128. package/template/fnode/node/src/cli/v2/modes/pipeline/index.njk +103 -0
  129. package/template/fnode/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  130. package/template/fnode/node/src/cli/v2/modes/webhook/index.njk +122 -0
  131. package/template/fnode/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  132. package/template/fnode/node/src/cli/v2/modes/websocket/index.njk +99 -0
  133. package/template/fnode/node/src/default/input.args.js.njk +6 -2
  134. package/dist/fnet/index.-SGbq2cI.js +0 -1
  135. package/dist/fnet/index.B5XE4ChJ.js +0 -1
  136. package/dist/fnet/index.Bft2w7m3.js +0 -1
  137. package/dist/fnet/index.BuYxdKtK.js +0 -1
  138. package/dist/fnet/index.C0YpfQ5j.js +0 -1
  139. package/dist/fnet/index.C2S9JYhS.js +0 -1
  140. package/dist/fnet/index.C7saWH6d.js +0 -1
  141. package/dist/fnet/index.CDct_kkF.js +0 -1
  142. package/dist/fnet/index.CMC8mlye.js +0 -1
  143. package/dist/fnet/index.CmMM-Ek9.js +0 -1
  144. package/dist/fnet/index.CuMyez3E.js +0 -1
  145. package/dist/fnet/index.CzAV0S36.js +0 -1
  146. package/dist/fnet/index.D2N9YZmA.js +0 -1
  147. package/dist/fnet/index.D3p7pncT.js +0 -1
  148. package/dist/fnet/index.DG8TqL-1.js +0 -1
  149. package/dist/fnet/index.DI3yyTtl.js +0 -1
  150. package/dist/fnet/index.DOYkqsYT.js +0 -1
  151. package/dist/fnet/index.DWpw12No.js +0 -1
  152. package/dist/fnet/index.DrwlOzAe.js +0 -1
  153. package/dist/fnet/index.Q-CYRcna.js +0 -1
  154. package/dist/fnet/index.W6RYgypK.js +0 -1
  155. package/dist/fnet/index.xd8c7XMr.js +0 -1
  156. package/dist/fnode/index.-SGbq2cI.js +0 -1
  157. package/dist/fnode/index.B5XE4ChJ.js +0 -1
  158. package/dist/fnode/index.B8gal9up.js +0 -1
  159. package/dist/fnode/index.BU1440aO.js +0 -1
  160. package/dist/fnode/index.BcGYSPne.js +0 -1
  161. package/dist/fnode/index.Bft2w7m3.js +0 -1
  162. package/dist/fnode/index.BuYxdKtK.js +0 -1
  163. package/dist/fnode/index.C2S9JYhS.js +0 -1
  164. package/dist/fnode/index.C7saWH6d.js +0 -1
  165. package/dist/fnode/index.CDct_kkF.js +0 -1
  166. package/dist/fnode/index.CMC8mlye.js +0 -1
  167. package/dist/fnode/index.CmMM-Ek9.js +0 -1
  168. package/dist/fnode/index.CuMyez3E.js +0 -1
  169. package/dist/fnode/index.CzAV0S36.js +0 -1
  170. package/dist/fnode/index.D2N9YZmA.js +0 -1
  171. package/dist/fnode/index.D3p7pncT.js +0 -1
  172. package/dist/fnode/index.DG8TqL-1.js +0 -1
  173. package/dist/fnode/index.DI3yyTtl.js +0 -1
  174. package/dist/fnode/index.DWpw12No.js +0 -1
  175. package/dist/fnode/index.DrwlOzAe.js +0 -1
  176. package/dist/fnode/index.N_a5FdgA.js +0 -1
  177. package/dist/fnode/index.Q-CYRcna.js +0 -1
  178. package/dist/fnode/index.UNoFg95r.js +0 -1
  179. package/dist/fnode/index.W6RYgypK.js +0 -1
  180. package/dist/fnode/index.xd8c7XMr.js +0 -1
  181. package/template/fnet/core/print.js +0 -1
  182. package/template/fnet/node/src/default/macros/workflow-header.js.njk +0 -7
@@ -0,0 +1,4 @@
1
+ import{g as I,h as B8,i as D}from"./index.cvxrf34y.js";var R8=B8((_5,M8)=>{M8.exports=w8;function w8(Q,X,$){if(Q instanceof RegExp)Q=U8(Q,$);if(X instanceof RegExp)X=U8(X,$);var Z=C8(Q,X,$);return Z&&{start:Z[0],end:Z[1],pre:$.slice(0,Z[0]),body:$.slice(Z[0]+Q.length,Z[1]),post:$.slice(Z[1]+X.length)}}function U8(Q,X){var $=X.match(Q);return $?$[0]:null}w8.range=C8;function C8(Q,X,$){var Z,J,V,q,_,Y=$.indexOf(Q),H=$.indexOf(X,Y+1),K=Y;if(Y>=0&&H>0){if(Q===X)return[Y,H];Z=[],V=$.length;while(K>=0&&!_){if(K==Y)Z.push(K),Y=$.indexOf(Q,K+1);else if(Z.length==1)_=[Z.pop(),H];else{if(J=Z.pop(),J<V)V=J,q=H;H=$.indexOf(X,K+1)}K=Y<H&&Y>=0?Y:H}if(Z.length)_=[V,q]}return _}});var P8=B8((Y5,v8)=>{var A8=R8();v8.exports=PQ;var I8="\x00SLASH"+Math.random()+"\x00",L8="\x00OPEN"+Math.random()+"\x00",s0="\x00CLOSE"+Math.random()+"\x00",O8="\x00COMMA"+Math.random()+"\x00",F8="\x00PERIOD"+Math.random()+"\x00";function a0(Q){return parseInt(Q,10)==Q?parseInt(Q,10):Q.charCodeAt(0)}function NQ(Q){return Q.split("\\\\").join(I8).split("\\{").join(L8).split("\\}").join(s0).split("\\,").join(O8).split("\\.").join(F8)}function vQ(Q){return Q.split(I8).join("\\").split(L8).join("{").split(s0).join("}").split(O8).join(",").split(F8).join(".")}function N8(Q){if(!Q)return[""];var X=[],$=A8("{","}",Q);if(!$)return Q.split(",");var{pre:Z,body:J,post:V}=$,q=Z.split(",");q[q.length-1]+="{"+J+"}";var _=N8(V);if(V.length)q[q.length-1]+=_.shift(),q.push.apply(q,_);return X.push.apply(X,q),X}function PQ(Q){if(!Q)return[];if(Q.substr(0,2)==="{}")Q="\\{\\}"+Q.substr(2);return G0(NQ(Q),!0).map(vQ)}function DQ(Q){return"{"+Q+"}"}function kQ(Q){return/^-?0\d/.test(Q)}function SQ(Q,X){return Q<=X}function TQ(Q,X){return Q>=X}function G0(Q,X){var $=[],Z=A8("{","}",Q);if(!Z)return[Q];var J=Z.pre,V=Z.post.length?G0(Z.post,!1):[""];if(/\$$/.test(Z.pre))for(var q=0;q<V.length;q++){var _=J+"{"+Z.body+"}"+V[q];$.push(_)}else{var Y=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(Z.body),H=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(Z.body),K=Y||H,G=Z.body.indexOf(",")>=0;if(!K&&!G){if(Z.post.match(/,.*\}/))return Q=Z.pre+"{"+Z.body+s0+Z.post,G0(Q);return[Q]}var W;if(K)W=Z.body.split(/\.\./);else if(W=N8(Z.body),W.length===1){if(W=G0(W[0],!1).map(DQ),W.length===1)return V.map(function(FQ){return Z.pre+W[0]+FQ})}var z;if(K){var j=a0(W[0]),U=a0(W[1]),B=Math.max(W[0].length,W[1].length),C=W.length==3?Math.abs(a0(W[2])):1,M=SQ,w=U<j;if(w)C*=-1,M=TQ;var R=W.some(kQ);z=[];for(var u=j;M(u,U);u+=C){var N;if(H){if(N=String.fromCharCode(u),N==="\\")N=""}else if(N=String(u),R){var t=B-N.length;if(t>0){var V0=Array(t+1).join("0");if(u<0)N="-"+V0+N.slice(1);else N=V0+N}}z.push(N)}}else{z=[];for(var g=0;g<W.length;g++)z.push.apply(z,G0(W[g],!1))}for(var g=0;g<z.length;g++)for(var q=0;q<V.length;q++){var _=J+z[g]+V[q];if(!X||K||_)$.push(_)}}return $}});var x8=I(P8(),1);var j0=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var bQ={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},z0=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),uQ=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),D8=(Q)=>Q.join(""),k8=(Q,X)=>{let $=X;if(Q.charAt($)!=="[")throw Error("not in a brace expression");let Z=[],J=[],V=$+1,q=!1,_=!1,Y=!1,H=!1,K=$,G="";Q:while(V<Q.length){let U=Q.charAt(V);if((U==="!"||U==="^")&&V===$+1){H=!0,V++;continue}if(U==="]"&&q&&!Y){K=V+1;break}if(q=!0,U==="\\"){if(!Y){Y=!0,V++;continue}}if(U==="["&&!Y){for(let[B,[C,M,w]]of Object.entries(bQ))if(Q.startsWith(B,V)){if(G)return["$.",!1,Q.length-$,!0];if(V+=B.length,w)J.push(C);else Z.push(C);_=_||M;continue Q}}if(Y=!1,G){if(U>G)Z.push(z0(G)+"-"+z0(U));else if(U===G)Z.push(z0(U));G="",V++;continue}if(Q.startsWith("-]",V+1)){Z.push(z0(U+"-")),V+=2;continue}if(Q.startsWith("-",V+1)){G=U,V+=2;continue}Z.push(z0(U)),V++}if(K<V)return["",!1,0,!1];if(!Z.length&&!J.length)return["$.",!1,Q.length-$,!0];if(J.length===0&&Z.length===1&&/^\\?.$/.test(Z[0])&&!H){let U=Z[0].length===2?Z[0].slice(-1):Z[0];return[uQ(U),!1,K-$,!1]}let W="["+(H?"^":"")+D8(Z)+"]",z="["+(H?"":"^")+D8(J)+"]";return[Z.length&&J.length?"("+W+"|"+z+")":Z.length?W:z,_,K-$,!0]};var h=(Q,{windowsPathsNoEscape:X=!1}={})=>{return X?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var EQ=new Set(["!","?","+","*","@"]),S8=(Q)=>EQ.has(Q),xQ="(?!(?:^|/)\\.\\.?(?:$|/))",D0="(?!\\.)",mQ=new Set(["[","."]),fQ=new Set(["..","."]),yQ=new Set("().*{}+?[]^$\\!"),gQ=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),e0="[^/]",T8=e0+"*?",b8=e0+"+?";class v{type;#Q;#X;#$=!1;#J=[];#q;#M;#U;#_=!1;#H;#Y;#K=!1;constructor(Q,X,$={}){if(this.type=Q,Q)this.#X=!0;if(this.#q=X,this.#Q=this.#q?this.#q.#Q:this,this.#H=this.#Q===this?$:this.#Q.#H,this.#U=this.#Q===this?[]:this.#Q.#U,Q==="!"&&!this.#Q.#_)this.#U.push(this);this.#M=this.#q?this.#q.#J.length:0}get hasMagic(){if(this.#X!==void 0)return this.#X;for(let Q of this.#J){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#X=!0}return this.#X}toString(){if(this.#Y!==void 0)return this.#Y;if(!this.type)return this.#Y=this.#J.map((Q)=>String(Q)).join("");else return this.#Y=this.type+"("+this.#J.map((Q)=>String(Q)).join("|")+")"}#Z(){if(this!==this.#Q)throw Error("should only call on root");if(this.#_)return this;this.toString(),this.#_=!0;let Q;while(Q=this.#U.pop()){if(Q.type!=="!")continue;let X=Q,$=X.#q;while($){for(let Z=X.#M+1;!$.type&&Z<$.#J.length;Z++)for(let J of Q.#J){if(typeof J==="string")throw Error("string part in extglob AST??");J.copyIn($.#J[Z])}X=$,$=X.#q}}return this}push(...Q){for(let X of Q){if(X==="")continue;if(typeof X!=="string"&&!(X instanceof v&&X.#q===this))throw Error("invalid part: "+X);this.#J.push(X)}}toJSON(){let Q=this.type===null?this.#J.slice().map((X)=>typeof X==="string"?X:X.toJSON()):[this.type,...this.#J.map((X)=>X.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#_&&this.#q?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#q?.isStart())return!1;if(this.#M===0)return!0;let Q=this.#q;for(let X=0;X<this.#M;X++){let $=Q.#J[X];if(!($ instanceof v&&$.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#q?.type==="!")return!0;if(!this.#q?.isEnd())return!1;if(!this.type)return this.#q?.isEnd();let Q=this.#q?this.#q.#J.length:0;return this.#M===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let X=new v(this.type,Q);for(let $ of this.#J)X.copyIn($);return X}static#G(Q,X,$,Z){let J=!1,V=!1,q=-1,_=!1;if(X.type===null){let W=$,z="";while(W<Q.length){let j=Q.charAt(W++);if(J||j==="\\"){J=!J,z+=j;continue}if(V){if(W===q+1){if(j==="^"||j==="!")_=!0}else if(j==="]"&&!(W===q+2&&_))V=!1;z+=j;continue}else if(j==="["){V=!0,q=W,_=!1,z+=j;continue}if(!Z.noext&&S8(j)&&Q.charAt(W)==="("){X.push(z),z="";let U=new v(j,X);W=v.#G(Q,U,W,Z),X.push(U);continue}z+=j}return X.push(z),W}let Y=$+1,H=new v(null,X),K=[],G="";while(Y<Q.length){let W=Q.charAt(Y++);if(J||W==="\\"){J=!J,G+=W;continue}if(V){if(Y===q+1){if(W==="^"||W==="!")_=!0}else if(W==="]"&&!(Y===q+2&&_))V=!1;G+=W;continue}else if(W==="["){V=!0,q=Y,_=!1,G+=W;continue}if(S8(W)&&Q.charAt(Y)==="("){H.push(G),G="";let z=new v(W,H);H.push(z),Y=v.#G(Q,z,Y,Z);continue}if(W==="|"){H.push(G),G="",K.push(H),H=new v(null,X);continue}if(W===")"){if(G===""&&X.#J.length===0)X.#K=!0;return H.push(G),G="",X.push(...K,H),Y}G+=W}return X.type=null,X.#X=void 0,X.#J=[Q.substring($-1)],Y}static fromGlob(Q,X={}){let $=new v(null,void 0,X);return v.#G(Q,$,0,X),$}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let Q=this.toString(),[X,$,Z,J]=this.toRegExpSource();if(!(Z||this.#X||this.#H.nocase&&!this.#H.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return $;let q=(this.#H.nocase?"i":"")+(J?"u":"");return Object.assign(new RegExp(`^${X}$`,q),{_src:X,_glob:Q})}get options(){return this.#H}toRegExpSource(Q){let X=Q??!!this.#H.dot;if(this.#Q===this)this.#Z();if(!this.type){let _=this.isStart()&&this.isEnd(),Y=this.#J.map((W)=>{let[z,j,U,B]=typeof W==="string"?v.#j(W,this.#X,_):W.toRegExpSource(Q);return this.#X=this.#X||U,this.#$=this.#$||B,z}).join(""),H="";if(this.isStart()){if(typeof this.#J[0]==="string"){if(!(this.#J.length===1&&fQ.has(this.#J[0]))){let z=mQ,j=X&&z.has(Y.charAt(0))||Y.startsWith("\\.")&&z.has(Y.charAt(2))||Y.startsWith("\\.\\.")&&z.has(Y.charAt(4)),U=!X&&!Q&&z.has(Y.charAt(0));H=j?xQ:U?D0:""}}}let K="";if(this.isEnd()&&this.#Q.#_&&this.#q?.type==="!")K="(?:$|\\/)";return[H+Y+K,h(Y),this.#X=!!this.#X,this.#$]}let $=this.type==="*"||this.type==="+",Z=this.type==="!"?"(?:(?!(?:":"(?:",J=this.#B(X);if(this.isStart()&&this.isEnd()&&!J&&this.type!=="!"){let _=this.toString();return this.#J=[_],this.type=null,this.#X=void 0,[_,h(this.toString()),!1,!1]}let V=!$||Q||X||!D0?"":this.#B(!0);if(V===J)V="";if(V)J=`(?:${J})(?:${V})*?`;let q="";if(this.type==="!"&&this.#K)q=(this.isStart()&&!X?D0:"")+b8;else{let _=this.type==="!"?"))"+(this.isStart()&&!X&&!Q?D0:"")+T8+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;q=Z+J+_}return[q,h(J),this.#X=!!this.#X,this.#$]}#B(Q){return this.#J.map((X)=>{if(typeof X==="string")throw Error("string type in extglob ast??");let[$,Z,J,V]=X.toRegExpSource(Q);return this.#$=this.#$||V,$}).filter((X)=>!(this.isStart()&&this.isEnd())||!!X).join("|")}static#j(Q,X,$=!1){let Z=!1,J="",V=!1;for(let q=0;q<Q.length;q++){let _=Q.charAt(q);if(Z){Z=!1,J+=(yQ.has(_)?"\\":"")+_;continue}if(_==="\\"){if(q===Q.length-1)J+="\\\\";else Z=!0;continue}if(_==="["){let[Y,H,K,G]=k8(Q,q);if(K){J+=Y,V=V||H,q+=K-1,X=X||G;continue}}if(_==="*"){if($&&Q==="*")J+=b8;else J+=T8;X=!0;continue}if(_==="?"){J+=e0,X=!0;continue}J+=gQ(_)}return[J,h(Q),!!X,V]}}var q0=(Q,{windowsPathsNoEscape:X=!1}={})=>{return X?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var S=(Q,X,$={})=>{if(j0(X),!$.nocomment&&X.charAt(0)==="#")return!1;return new m(X,$).match(Q)},hQ=/^\*+([^+@!?\*\[\(]*)$/,dQ=(Q)=>(X)=>!X.startsWith(".")&&X.endsWith(Q),cQ=(Q)=>(X)=>X.endsWith(Q),lQ=(Q)=>{return Q=Q.toLowerCase(),(X)=>!X.startsWith(".")&&X.toLowerCase().endsWith(Q)},oQ=(Q)=>{return Q=Q.toLowerCase(),(X)=>X.toLowerCase().endsWith(Q)},pQ=/^\*+\.\*+$/,iQ=(Q)=>!Q.startsWith(".")&&Q.includes("."),nQ=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),rQ=/^\.\*+$/,aQ=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),sQ=/^\*+$/,eQ=(Q)=>Q.length!==0&&!Q.startsWith("."),tQ=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",QX=/^\?+([^+@!?\*\[\(]*)?$/,XX=([Q,X=""])=>{let $=m8([Q]);if(!X)return $;return X=X.toLowerCase(),(Z)=>$(Z)&&Z.toLowerCase().endsWith(X)},$X=([Q,X=""])=>{let $=f8([Q]);if(!X)return $;return X=X.toLowerCase(),(Z)=>$(Z)&&Z.toLowerCase().endsWith(X)},ZX=([Q,X=""])=>{let $=f8([Q]);return!X?$:(Z)=>$(Z)&&Z.endsWith(X)},JX=([Q,X=""])=>{let $=m8([Q]);return!X?$:(Z)=>$(Z)&&Z.endsWith(X)},m8=([Q])=>{let X=Q.length;return($)=>$.length===X&&!$.startsWith(".")},f8=([Q])=>{let X=Q.length;return($)=>$.length===X&&$!=="."&&$!==".."},y8=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",u8={win32:{sep:"\\"},posix:{sep:"/"}},VX=y8==="win32"?u8.win32.sep:u8.posix.sep;S.sep=VX;var P=Symbol("globstar **");S.GLOBSTAR=P;var qX="[^/]",_X=qX+"*?",YX="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",KX="(?:(?!(?:\\/|^)\\.).)*?",HX=(Q,X={})=>($)=>S($,Q,X);S.filter=HX;var x=(Q,X={})=>Object.assign({},Q,X),WX=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return S;let X=S;return Object.assign((Z,J,V={})=>X(Z,J,x(Q,V)),{Minimatch:class extends X.Minimatch{constructor(J,V={}){super(J,x(Q,V))}static defaults(J){return X.defaults(x(Q,J)).Minimatch}},AST:class extends X.AST{constructor(J,V,q={}){super(J,V,x(Q,q))}static fromGlob(J,V={}){return X.AST.fromGlob(J,x(Q,V))}},unescape:(Z,J={})=>X.unescape(Z,x(Q,J)),escape:(Z,J={})=>X.escape(Z,x(Q,J)),filter:(Z,J={})=>X.filter(Z,x(Q,J)),defaults:(Z)=>X.defaults(x(Q,Z)),makeRe:(Z,J={})=>X.makeRe(Z,x(Q,J)),braceExpand:(Z,J={})=>X.braceExpand(Z,x(Q,J)),match:(Z,J,V={})=>X.match(Z,J,x(Q,V)),sep:X.sep,GLOBSTAR:P})};S.defaults=WX;var g8=(Q,X={})=>{if(j0(Q),X.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return x8.default(Q)};S.braceExpand=g8;var GX=(Q,X={})=>new m(Q,X).makeRe();S.makeRe=GX;var jX=(Q,X,$={})=>{let Z=new m(X,$);if(Q=Q.filter((J)=>Z.match(J)),Z.options.nonull&&!Q.length)Q.push(X);return Q};S.match=jX;var E8=/[?*]|[+@!]\(.*?\)|\[|\]/,zX=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class m{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Q,X={}){if(j0(Q),X=X||{},this.options=X,this.pattern=Q,this.platform=X.platform||y8,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!X.windowsPathsNoEscape||X.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!X.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!X.nonegate,this.comment=!1,this.empty=!1,this.partial=!!X.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=X.windowsNoMagicRoot!==void 0?X.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Q of this.set)for(let X of Q)if(typeof X!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,X=this.options;if(!X.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],X.debug)this.debug=(...J)=>console.error(...J);this.debug(this.pattern,this.globSet);let $=this.globSet.map((J)=>this.slashSplit(J));this.globParts=this.preprocess($),this.debug(this.pattern,this.globParts);let Z=this.globParts.map((J,V,q)=>{if(this.isWindows&&this.windowsNoMagicRoot){let _=J[0]===""&&J[1]===""&&(J[2]==="?"||!E8.test(J[2]))&&!E8.test(J[3]),Y=/^[a-z]:/i.test(J[0]);if(_)return[...J.slice(0,4),...J.slice(4).map((H)=>this.parse(H))];else if(Y)return[J[0],...J.slice(1).map((H)=>this.parse(H))]}return J.map((_)=>this.parse(_))});if(this.debug(this.pattern,Z),this.set=Z.filter((J)=>J.indexOf(!1)===-1),this.isWindows)for(let J=0;J<this.set.length;J++){let V=this.set[J];if(V[0]===""&&V[1]===""&&this.globParts[J][2]==="?"&&typeof V[3]==="string"&&/^[a-z]:$/i.test(V[3]))V[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let $=0;$<Q.length;$++)for(let Z=0;Z<Q[$].length;Z++)if(Q[$][Z]==="**")Q[$][Z]="*"}let{optimizationLevel:X=1}=this.options;if(X>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(X>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((X)=>{let $=-1;while(($=X.indexOf("**",$+1))!==-1){let Z=$;while(X[Z+1]==="**")Z++;if(Z!==$)X.splice($,Z-$)}return X})}levelOneOptimize(Q){return Q.map((X)=>{return X=X.reduce(($,Z)=>{let J=$[$.length-1];if(Z==="**"&&J==="**")return $;if(Z===".."){if(J&&J!==".."&&J!=="."&&J!=="**")return $.pop(),$}return $.push(Z),$},[]),X.length===0?[""]:X})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let X=!1;do{if(X=!1,!this.preserveMultipleSlashes){for(let Z=1;Z<Q.length-1;Z++){let J=Q[Z];if(Z===1&&J===""&&Q[0]==="")continue;if(J==="."||J==="")X=!0,Q.splice(Z,1),Z--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))X=!0,Q.pop()}let $=0;while(($=Q.indexOf("..",$+1))!==-1){let Z=Q[$-1];if(Z&&Z!=="."&&Z!==".."&&Z!=="**")X=!0,Q.splice($-1,2),$-=2}}while(X);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let X=!1;do{X=!1;for(let $ of Q){let Z=-1;while((Z=$.indexOf("**",Z+1))!==-1){let V=Z;while($[V+1]==="**")V++;if(V>Z)$.splice(Z+1,V-Z);let q=$[Z+1],_=$[Z+2],Y=$[Z+3];if(q!=="..")continue;if(!_||_==="."||_===".."||!Y||Y==="."||Y==="..")continue;X=!0,$.splice(Z,1);let H=$.slice(0);H[Z]="**",Q.push(H),Z--}if(!this.preserveMultipleSlashes){for(let V=1;V<$.length-1;V++){let q=$[V];if(V===1&&q===""&&$[0]==="")continue;if(q==="."||q==="")X=!0,$.splice(V,1),V--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))X=!0,$.pop()}let J=0;while((J=$.indexOf("..",J+1))!==-1){let V=$[J-1];if(V&&V!=="."&&V!==".."&&V!=="**"){X=!0;let _=J===1&&$[J+1]==="**"?["."]:[];if($.splice(J-1,2,..._),$.length===0)$.push("");J-=2}}}}while(X);return Q}secondPhasePreProcess(Q){for(let X=0;X<Q.length-1;X++)for(let $=X+1;$<Q.length;$++){let Z=this.partsMatch(Q[X],Q[$],!this.preserveMultipleSlashes);if(Z){Q[X]=[],Q[$]=Z;break}}return Q.filter((X)=>X.length)}partsMatch(Q,X,$=!1){let Z=0,J=0,V=[],q="";while(Z<Q.length&&J<X.length)if(Q[Z]===X[J])V.push(q==="b"?X[J]:Q[Z]),Z++,J++;else if($&&Q[Z]==="**"&&X[J]===Q[Z+1])V.push(Q[Z]),Z++;else if($&&X[J]==="**"&&Q[Z]===X[J+1])V.push(X[J]),J++;else if(Q[Z]==="*"&&X[J]&&(this.options.dot||!X[J].startsWith("."))&&X[J]!=="**"){if(q==="b")return!1;q="a",V.push(Q[Z]),Z++,J++}else if(X[J]==="*"&&Q[Z]&&(this.options.dot||!Q[Z].startsWith("."))&&Q[Z]!=="**"){if(q==="a")return!1;q="b",V.push(X[J]),Z++,J++}else return!1;return Q.length===X.length&&V}parseNegate(){if(this.nonegate)return;let Q=this.pattern,X=!1,$=0;for(let Z=0;Z<Q.length&&Q.charAt(Z)==="!";Z++)X=!X,$++;if($)this.pattern=Q.slice($);this.negate=X}matchOne(Q,X,$=!1){let Z=this.options;if(this.isWindows){let j=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),U=!j&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),B=typeof X[0]==="string"&&/^[a-z]:$/i.test(X[0]),C=!B&&X[0]===""&&X[1]===""&&X[2]==="?"&&typeof X[3]==="string"&&/^[a-z]:$/i.test(X[3]),M=U?3:j?0:void 0,w=C?3:B?0:void 0;if(typeof M==="number"&&typeof w==="number"){let[R,u]=[Q[M],X[w]];if(R.toLowerCase()===u.toLowerCase()){if(X[w]=R,w>M)X=X.slice(w);else if(M>w)Q=Q.slice(M)}}}let{optimizationLevel:J=1}=this.options;if(J>=2)Q=this.levelTwoFileOptimize(Q);this.debug("matchOne",this,{file:Q,pattern:X}),this.debug("matchOne",Q.length,X.length);for(var V=0,q=0,_=Q.length,Y=X.length;V<_&&q<Y;V++,q++){this.debug("matchOne loop");var H=X[q],K=Q[V];if(this.debug(X,H,K),H===!1)return!1;if(H===P){this.debug("GLOBSTAR",[X,H,K]);var G=V,W=q+1;if(W===Y){this.debug("** at the end");for(;V<_;V++)if(Q[V]==="."||Q[V]===".."||!Z.dot&&Q[V].charAt(0)===".")return!1;return!0}while(G<_){var z=Q[G];if(this.debug(`
2
+ globstar while`,Q,G,X,W,z),this.matchOne(Q.slice(G),X.slice(W),$))return this.debug("globstar found match!",G,_,z),!0;else{if(z==="."||z===".."||!Z.dot&&z.charAt(0)==="."){this.debug("dot detected!",Q,G,X,W);break}this.debug("globstar swallow a segment, and continue"),G++}}if($){if(this.debug(`
3
+ >>> no match, partial?`,Q,G,X,W),G===_)return!0}return!1}let j;if(typeof H==="string")j=K===H,this.debug("string match",H,K,j);else j=H.test(K),this.debug("pattern match",H,K,j);if(!j)return!1}if(V===_&&q===Y)return!0;else if(V===_)return $;else if(q===Y)return V===_-1&&Q[V]==="";else throw Error("wtf?")}braceExpand(){return g8(this.pattern,this.options)}parse(Q){j0(Q);let X=this.options;if(Q==="**")return P;if(Q==="")return"";let $,Z=null;if($=Q.match(sQ))Z=X.dot?tQ:eQ;else if($=Q.match(hQ))Z=(X.nocase?X.dot?oQ:lQ:X.dot?cQ:dQ)($[1]);else if($=Q.match(QX))Z=(X.nocase?X.dot?$X:XX:X.dot?ZX:JX)($);else if($=Q.match(pQ))Z=X.dot?nQ:iQ;else if($=Q.match(rQ))Z=aQ;let J=v.fromGlob(Q,this.options).toMMPattern();if(Z&&typeof J==="object")Reflect.defineProperty(J,"test",{value:Z});return J}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let X=this.options,$=X.noglobstar?_X:X.dot?YX:KX,Z=new Set(X.nocase?["i"]:[]),J=Q.map((_)=>{let Y=_.map((H)=>{if(H instanceof RegExp)for(let K of H.flags.split(""))Z.add(K);return typeof H==="string"?zX(H):H===P?P:H._src});return Y.forEach((H,K)=>{let G=Y[K+1],W=Y[K-1];if(H!==P||W===P)return;if(W===void 0)if(G!==void 0&&G!==P)Y[K+1]="(?:\\/|"+$+"\\/)?"+G;else Y[K]=$;else if(G===void 0)Y[K-1]=W+"(?:\\/|"+$+")?";else if(G!==P)Y[K-1]=W+"(?:\\/|\\/"+$+"\\/)"+G,Y[K+1]=P}),Y.filter((H)=>H!==P).join("/")}).join("|"),[V,q]=Q.length>1?["(?:",")"]:["",""];if(J="^"+V+J+q+"$",this.negate)J="^(?!"+J+").+$";try{this.regexp=new RegExp(J,[...Z].join(""))}catch(_){this.regexp=!1}return this.regexp}slashSplit(Q){if(this.preserveMultipleSlashes)return Q.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Q))return["",...Q.split(/\/+/)];else return Q.split(/\/+/)}match(Q,X=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&X)return!0;let $=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let Z=this.slashSplit(Q);this.debug(this.pattern,"split",Z);let J=this.set;this.debug(this.pattern,"set",J);let V=Z[Z.length-1];if(!V)for(let q=Z.length-2;!V&&q>=0;q--)V=Z[q];for(let q=0;q<J.length;q++){let _=J[q],Y=Z;if($.matchBase&&_.length===1)Y=[V];if(this.matchOne(Y,_,X)){if($.flipNegate)return!0;return!this.negate}}if($.flipNegate)return!1;return this.negate}static defaults(Q){return S.defaults(Q).Minimatch}}S.AST=v;S.Minimatch=m;S.escape=q0;S.unescape=h;import{fileURLToPath as pX}from"node:url";var _0=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,d8=new Set,t0=typeof process==="object"&&!!process?process:{},c8=(Q,X,$,Z)=>{typeof t0.emitWarning==="function"?t0.emitWarning(Q,X,$,Z):console.error(`[${$}] ${X}: ${Q}`)},k0=globalThis.AbortController,h8=globalThis.AbortSignal;if(typeof k0>"u"){h8=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Z,J){this._onabort.push(J)}},k0=class{constructor(){X()}signal=new h8;abort(Z){if(this.signal.aborted)return;this.signal.reason=Z,this.signal.aborted=!0;for(let J of this.signal._onabort)J(Z);this.signal.onabort?.(Z)}};let Q=t0.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",X=()=>{if(!Q)return;Q=!1,c8("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",X)}}var UX=(Q)=>!d8.has(Q),O5=Symbol("type"),a=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),l8=(Q)=>!a(Q)?null:Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?U0:null;class U0 extends Array{constructor(Q){super(Q);this.fill(0)}}class Y0{heap;length;static#Q=!1;static create(Q){let X=l8(Q);if(!X)return[];Y0.#Q=!0;let $=new Y0(Q,X);return Y0.#Q=!1,$}constructor(Q,X){if(!Y0.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new X(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}}class B0{#Q;#X;#$;#J;#q;#M;#U;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#_;#H;#Y;#K;#Z;#G;#B;#j;#z;#w;#R;#P;#L;#I;#A;#N;#C;#k;static unsafeExposeInternals(Q){return{starts:Q.#L,ttls:Q.#I,sizes:Q.#P,keyMap:Q.#Y,keyList:Q.#K,valList:Q.#Z,next:Q.#G,prev:Q.#B,get head(){return Q.#j},get tail(){return Q.#z},free:Q.#w,isBackgroundFetch:(X)=>Q.#W(X),backgroundFetch:(X,$,Z,J)=>Q.#E(X,$,Z,J),moveToTail:(X)=>Q.#f(X),indexes:(X)=>Q.#v(X),rindexes:(X)=>Q.#D(X),isStale:(X)=>Q.#F(X)}}get max(){return this.#Q}get maxSize(){return this.#X}get calculatedSize(){return this.#H}get size(){return this.#_}get fetchMethod(){return this.#M}get memoMethod(){return this.#U}get dispose(){return this.#$}get onInsert(){return this.#J}get disposeAfter(){return this.#q}constructor(Q){let{max:X=0,ttl:$,ttlResolution:Z=1,ttlAutopurge:J,updateAgeOnGet:V,updateAgeOnHas:q,allowStale:_,dispose:Y,onInsert:H,disposeAfter:K,noDisposeOnSet:G,noUpdateTTL:W,maxSize:z=0,maxEntrySize:j=0,sizeCalculation:U,fetchMethod:B,memoMethod:C,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:u,ignoreFetchAbort:N}=Q;if(X!==0&&!a(X))throw TypeError("max option must be a nonnegative integer");let t=X?l8(X):Array;if(!t)throw Error("invalid max value: "+X);if(this.#Q=X,this.#X=z,this.maxEntrySize=j||this.#X,this.sizeCalculation=U,this.sizeCalculation){if(!this.#X&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(C!==void 0&&typeof C!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#U=C,B!==void 0&&typeof B!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#M=B,this.#N=!!B,this.#Y=new Map,this.#K=Array(X).fill(void 0),this.#Z=Array(X).fill(void 0),this.#G=new t(X),this.#B=new t(X),this.#j=0,this.#z=0,this.#w=Y0.create(X),this.#_=0,this.#H=0,typeof Y==="function")this.#$=Y;if(typeof H==="function")this.#J=H;if(typeof K==="function")this.#q=K,this.#R=[];else this.#q=void 0,this.#R=void 0;if(this.#A=!!this.#$,this.#k=!!this.#J,this.#C=!!this.#q,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!W,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!u,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(this.#X!==0){if(!a(this.#X))throw TypeError("maxSize must be a positive integer if specified")}if(!a(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#g()}if(this.allowStale=!!_,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!V,this.updateAgeOnHas=!!q,this.ttlResolution=a(Z)||Z===0?Z:1,this.ttlAutopurge=!!J,this.ttl=$||0,this.ttl){if(!a(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#V()}if(this.#Q===0&&this.ttl===0&&this.#X===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#X){if(UX("LRU_CACHE_UNBOUNDED"))d8.add("LRU_CACHE_UNBOUNDED"),c8("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",B0)}}getRemainingTTL(Q){return this.#Y.has(Q)?1/0:0}#V(){let Q=new U0(this.#Q),X=new U0(this.#Q);this.#I=Q,this.#L=X,this.#S=(J,V,q=_0.now())=>{if(X[J]=V!==0?q:0,Q[J]=V,V!==0&&this.ttlAutopurge){let _=setTimeout(()=>{if(this.#F(J))this.#T(this.#K[J],"expire")},V+1);if(_.unref)_.unref()}},this.#b=(J)=>{X[J]=Q[J]!==0?_0.now():0},this.#O=(J,V)=>{if(Q[V]){let q=Q[V],_=X[V];if(!q||!_)return;J.ttl=q,J.start=_,J.now=$||Z();let Y=J.now-_;J.remainingTTL=q-Y}};let $=0,Z=()=>{let J=_0.now();if(this.ttlResolution>0){$=J;let V=setTimeout(()=>$=0,this.ttlResolution);if(V.unref)V.unref()}return J};this.getRemainingTTL=(J)=>{let V=this.#Y.get(J);if(V===void 0)return 0;let q=Q[V],_=X[V];if(!q||!_)return 1/0;let Y=($||Z())-_;return q-Y},this.#F=(J)=>{let V=X[J],q=Q[J];return!!q&&!!V&&($||Z())-V>q}}#b=()=>{};#O=()=>{};#S=()=>{};#F=()=>!1;#g(){let Q=new U0(this.#Q);this.#H=0,this.#P=Q,this.#u=(X)=>{this.#H-=Q[X],Q[X]=0},this.#h=(X,$,Z,J)=>{if(this.#W($))return 0;if(!a(Z))if(J){if(typeof J!=="function")throw TypeError("sizeCalculation must be a function");if(Z=J($,X),!a(Z))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Z},this.#x=(X,$,Z)=>{if(Q[X]=$,this.#X){let J=this.#X-Q[X];while(this.#H>J)this.#m(!0)}if(this.#H+=Q[X],Z)Z.entrySize=$,Z.totalCalculatedSize=this.#H}}#u=(Q)=>{};#x=(Q,X,$)=>{};#h=(Q,X,$,Z)=>{if($||Z)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#v({allowStale:Q=this.allowStale}={}){if(this.#_)for(let X=this.#z;;){if(!this.#d(X))break;if(Q||!this.#F(X))yield X;if(X===this.#j)break;else X=this.#B[X]}}*#D({allowStale:Q=this.allowStale}={}){if(this.#_)for(let X=this.#j;;){if(!this.#d(X))break;if(Q||!this.#F(X))yield X;if(X===this.#z)break;else X=this.#G[X]}}#d(Q){return Q!==void 0&&this.#Y.get(this.#K[Q])===Q}*entries(){for(let Q of this.#v())if(this.#Z[Q]!==void 0&&this.#K[Q]!==void 0&&!this.#W(this.#Z[Q]))yield[this.#K[Q],this.#Z[Q]]}*rentries(){for(let Q of this.#D())if(this.#Z[Q]!==void 0&&this.#K[Q]!==void 0&&!this.#W(this.#Z[Q]))yield[this.#K[Q],this.#Z[Q]]}*keys(){for(let Q of this.#v()){let X=this.#K[Q];if(X!==void 0&&!this.#W(this.#Z[Q]))yield X}}*rkeys(){for(let Q of this.#D()){let X=this.#K[Q];if(X!==void 0&&!this.#W(this.#Z[Q]))yield X}}*values(){for(let Q of this.#v())if(this.#Z[Q]!==void 0&&!this.#W(this.#Z[Q]))yield this.#Z[Q]}*rvalues(){for(let Q of this.#D())if(this.#Z[Q]!==void 0&&!this.#W(this.#Z[Q]))yield this.#Z[Q]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,X={}){for(let $ of this.#v()){let Z=this.#Z[$],J=this.#W(Z)?Z.__staleWhileFetching:Z;if(J===void 0)continue;if(Q(J,this.#K[$],this))return this.get(this.#K[$],X)}}forEach(Q,X=this){for(let $ of this.#v()){let Z=this.#Z[$],J=this.#W(Z)?Z.__staleWhileFetching:Z;if(J===void 0)continue;Q.call(X,J,this.#K[$],this)}}rforEach(Q,X=this){for(let $ of this.#D()){let Z=this.#Z[$],J=this.#W(Z)?Z.__staleWhileFetching:Z;if(J===void 0)continue;Q.call(X,J,this.#K[$],this)}}purgeStale(){let Q=!1;for(let X of this.#D({allowStale:!0}))if(this.#F(X))this.#T(this.#K[X],"expire"),Q=!0;return Q}info(Q){let X=this.#Y.get(Q);if(X===void 0)return;let $=this.#Z[X],Z=this.#W($)?$.__staleWhileFetching:$;if(Z===void 0)return;let J={value:Z};if(this.#I&&this.#L){let V=this.#I[X],q=this.#L[X];if(V&&q){let _=V-(_0.now()-q);J.ttl=_,J.start=Date.now()}}if(this.#P)J.size=this.#P[X];return J}dump(){let Q=[];for(let X of this.#v({allowStale:!0})){let $=this.#K[X],Z=this.#Z[X],J=this.#W(Z)?Z.__staleWhileFetching:Z;if(J===void 0||$===void 0)continue;let V={value:J};if(this.#I&&this.#L){V.ttl=this.#I[X];let q=_0.now()-this.#L[X];V.start=Math.floor(Date.now()-q)}if(this.#P)V.size=this.#P[X];Q.unshift([$,V])}return Q}load(Q){this.clear();for(let[X,$]of Q){if($.start){let Z=Date.now()-$.start;$.start=_0.now()-Z}this.set(X,$.value,$)}}set(Q,X,$={}){if(X===void 0)return this.delete(Q),this;let{ttl:Z=this.ttl,start:J,noDisposeOnSet:V=this.noDisposeOnSet,sizeCalculation:q=this.sizeCalculation,status:_}=$,{noUpdateTTL:Y=this.noUpdateTTL}=$,H=this.#h(Q,X,$.size||0,q);if(this.maxEntrySize&&H>this.maxEntrySize){if(_)_.set="miss",_.maxEntrySizeExceeded=!0;return this.#T(Q,"set"),this}let K=this.#_===0?void 0:this.#Y.get(Q);if(K===void 0){if(K=this.#_===0?this.#z:this.#w.length!==0?this.#w.pop():this.#_===this.#Q?this.#m(!1):this.#_,this.#K[K]=Q,this.#Z[K]=X,this.#Y.set(Q,K),this.#G[this.#z]=K,this.#B[K]=this.#z,this.#z=K,this.#_++,this.#x(K,H,_),_)_.set="add";if(Y=!1,this.#k)this.#J?.(X,Q,"add")}else{this.#f(K);let G=this.#Z[K];if(X!==G){if(this.#N&&this.#W(G)){G.__abortController.abort(Error("replaced"));let{__staleWhileFetching:W}=G;if(W!==void 0&&!V){if(this.#A)this.#$?.(W,Q,"set");if(this.#C)this.#R?.push([W,Q,"set"])}}else if(!V){if(this.#A)this.#$?.(G,Q,"set");if(this.#C)this.#R?.push([G,Q,"set"])}if(this.#u(K),this.#x(K,H,_),this.#Z[K]=X,_){_.set="replace";let W=G&&this.#W(G)?G.__staleWhileFetching:G;if(W!==void 0)_.oldValue=W}}else if(_)_.set="update";if(this.#k)this.onInsert?.(X,Q,X===G?"update":"replace")}if(Z!==0&&!this.#I)this.#V();if(this.#I){if(!Y)this.#S(K,Z,J);if(_)this.#O(_,K)}if(!V&&this.#C&&this.#R){let G=this.#R,W;while(W=G?.shift())this.#q?.(...W)}return this}pop(){try{while(this.#_){let Q=this.#Z[this.#j];if(this.#m(!0),this.#W(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#C&&this.#R){let Q=this.#R,X;while(X=Q?.shift())this.#q?.(...X)}}}#m(Q){let X=this.#j,$=this.#K[X],Z=this.#Z[X];if(this.#N&&this.#W(Z))Z.__abortController.abort(Error("evicted"));else if(this.#A||this.#C){if(this.#A)this.#$?.(Z,$,"evict");if(this.#C)this.#R?.push([Z,$,"evict"])}if(this.#u(X),Q)this.#K[X]=void 0,this.#Z[X]=void 0,this.#w.push(X);if(this.#_===1)this.#j=this.#z=0,this.#w.length=0;else this.#j=this.#G[X];return this.#Y.delete($),this.#_--,X}has(Q,X={}){let{updateAgeOnHas:$=this.updateAgeOnHas,status:Z}=X,J=this.#Y.get(Q);if(J!==void 0){let V=this.#Z[J];if(this.#W(V)&&V.__staleWhileFetching===void 0)return!1;if(!this.#F(J)){if($)this.#b(J);if(Z)Z.has="hit",this.#O(Z,J);return!0}else if(Z)Z.has="stale",this.#O(Z,J)}else if(Z)Z.has="miss";return!1}peek(Q,X={}){let{allowStale:$=this.allowStale}=X,Z=this.#Y.get(Q);if(Z===void 0||!$&&this.#F(Z))return;let J=this.#Z[Z];return this.#W(J)?J.__staleWhileFetching:J}#E(Q,X,$,Z){let J=X===void 0?void 0:this.#Z[X];if(this.#W(J))return J;let V=new k0,{signal:q}=$;q?.addEventListener("abort",()=>V.abort(q.reason),{signal:V.signal});let _={signal:V.signal,options:$,context:Z},Y=(j,U=!1)=>{let{aborted:B}=V.signal,C=$.ignoreFetchAbort&&j!==void 0;if($.status)if(B&&!U){if($.status.fetchAborted=!0,$.status.fetchError=V.signal.reason,C)$.status.fetchAbortIgnored=!0}else $.status.fetchResolved=!0;if(B&&!C&&!U)return K(V.signal.reason);let M=W;if(this.#Z[X]===W)if(j===void 0)if(M.__staleWhileFetching)this.#Z[X]=M.__staleWhileFetching;else this.#T(Q,"fetch");else{if($.status)$.status.fetchUpdated=!0;this.set(Q,j,_.options)}return j},H=(j)=>{if($.status)$.status.fetchRejected=!0,$.status.fetchError=j;return K(j)},K=(j)=>{let{aborted:U}=V.signal,B=U&&$.allowStaleOnFetchAbort,C=B||$.allowStaleOnFetchRejection,M=C||$.noDeleteOnFetchRejection,w=W;if(this.#Z[X]===W){if(!M||w.__staleWhileFetching===void 0)this.#T(Q,"fetch");else if(!B)this.#Z[X]=w.__staleWhileFetching}if(C){if($.status&&w.__staleWhileFetching!==void 0)$.status.returnedStale=!0;return w.__staleWhileFetching}else if(w.__returned===w)throw j},G=(j,U)=>{let B=this.#M?.(Q,J,_);if(B&&B instanceof Promise)B.then((C)=>j(C===void 0?void 0:C),U);V.signal.addEventListener("abort",()=>{if(!$.ignoreFetchAbort||$.allowStaleOnFetchAbort){if(j(void 0),$.allowStaleOnFetchAbort)j=(C)=>Y(C,!0)}})};if($.status)$.status.fetchDispatched=!0;let W=new Promise(G).then(Y,H),z=Object.assign(W,{__abortController:V,__staleWhileFetching:J,__returned:void 0});if(X===void 0)this.set(Q,z,{..._.options,status:void 0}),X=this.#Y.get(Q);else this.#Z[X]=z;return z}#W(Q){if(!this.#N)return!1;let X=Q;return!!X&&X instanceof Promise&&X.hasOwnProperty("__staleWhileFetching")&&X.__abortController instanceof k0}async fetch(Q,X={}){let{allowStale:$=this.allowStale,updateAgeOnGet:Z=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,ttl:V=this.ttl,noDisposeOnSet:q=this.noDisposeOnSet,size:_=0,sizeCalculation:Y=this.sizeCalculation,noUpdateTTL:H=this.noUpdateTTL,noDeleteOnFetchRejection:K=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:W=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:j,forceRefresh:U=!1,status:B,signal:C}=X;if(!this.#N){if(B)B.fetch="get";return this.get(Q,{allowStale:$,updateAgeOnGet:Z,noDeleteOnStaleGet:J,status:B})}let M={allowStale:$,updateAgeOnGet:Z,noDeleteOnStaleGet:J,ttl:V,noDisposeOnSet:q,size:_,sizeCalculation:Y,noUpdateTTL:H,noDeleteOnFetchRejection:K,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:z,ignoreFetchAbort:W,status:B,signal:C},w=this.#Y.get(Q);if(w===void 0){if(B)B.fetch="miss";let R=this.#E(Q,w,M,j);return R.__returned=R}else{let R=this.#Z[w];if(this.#W(R)){let g=$&&R.__staleWhileFetching!==void 0;if(B){if(B.fetch="inflight",g)B.returnedStale=!0}return g?R.__staleWhileFetching:R.__returned=R}let u=this.#F(w);if(!U&&!u){if(B)B.fetch="hit";if(this.#f(w),Z)this.#b(w);if(B)this.#O(B,w);return R}let N=this.#E(Q,w,M,j),V0=N.__staleWhileFetching!==void 0&&$;if(B){if(B.fetch=u?"stale":"refresh",V0&&u)B.returnedStale=!0}return V0?N.__staleWhileFetching:N.__returned=N}}async forceFetch(Q,X={}){let $=await this.fetch(Q,X);if($===void 0)throw Error("fetch() returned undefined");return $}memo(Q,X={}){let $=this.#U;if(!$)throw Error("no memoMethod provided to constructor");let{context:Z,forceRefresh:J,...V}=X,q=this.get(Q,V);if(!J&&q!==void 0)return q;let _=$(Q,q,{options:V,context:Z});return this.set(Q,_,V),_}get(Q,X={}){let{allowStale:$=this.allowStale,updateAgeOnGet:Z=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,status:V}=X,q=this.#Y.get(Q);if(q!==void 0){let _=this.#Z[q],Y=this.#W(_);if(V)this.#O(V,q);if(this.#F(q)){if(V)V.get="stale";if(!Y){if(!J)this.#T(Q,"expire");if(V&&$)V.returnedStale=!0;return $?_:void 0}else{if(V&&$&&_.__staleWhileFetching!==void 0)V.returnedStale=!0;return $?_.__staleWhileFetching:void 0}}else{if(V)V.get="hit";if(Y)return _.__staleWhileFetching;if(this.#f(q),Z)this.#b(q);return _}}else if(V)V.get="miss"}#c(Q,X){this.#B[X]=Q,this.#G[Q]=X}#f(Q){if(Q!==this.#z){if(Q===this.#j)this.#j=this.#G[Q];else this.#c(this.#B[Q],this.#G[Q]);this.#c(this.#z,Q),this.#z=Q}}delete(Q){return this.#T(Q,"delete")}#T(Q,X){let $=!1;if(this.#_!==0){let Z=this.#Y.get(Q);if(Z!==void 0)if($=!0,this.#_===1)this.#y(X);else{this.#u(Z);let J=this.#Z[Z];if(this.#W(J))J.__abortController.abort(Error("deleted"));else if(this.#A||this.#C){if(this.#A)this.#$?.(J,Q,X);if(this.#C)this.#R?.push([J,Q,X])}if(this.#Y.delete(Q),this.#K[Z]=void 0,this.#Z[Z]=void 0,Z===this.#z)this.#z=this.#B[Z];else if(Z===this.#j)this.#j=this.#G[Z];else{let V=this.#B[Z];this.#G[V]=this.#G[Z];let q=this.#G[Z];this.#B[q]=this.#B[Z]}this.#_--,this.#w.push(Z)}}if(this.#C&&this.#R?.length){let Z=this.#R,J;while(J=Z?.shift())this.#q?.(...J)}return $}clear(){return this.#y("delete")}#y(Q){for(let X of this.#D({allowStale:!0})){let $=this.#Z[X];if(this.#W($))$.__abortController.abort(Error("deleted"));else{let Z=this.#K[X];if(this.#A)this.#$?.($,Z,Q);if(this.#C)this.#R?.push([$,Z,Q])}}if(this.#Y.clear(),this.#Z.fill(void 0),this.#K.fill(void 0),this.#I&&this.#L)this.#I.fill(0),this.#L.fill(0);if(this.#P)this.#P.fill(0);if(this.#j=0,this.#z=0,this.#w.length=0,this.#H=0,this.#_=0,this.#C&&this.#R){let X=this.#R,$;while($=X?.shift())this.#q?.(...$)}}}import{posix as NX,win32 as K8}from"node:path";import{fileURLToPath as vX}from"node:url";import{lstatSync as PX,readdir as DX,readdirSync as kX,readlinkSync as SX,realpathSync as TX}from"fs";import*as bX from"node:fs";import{lstat as EX,readdir as xX,readlink as mX,realpath as fX}from"node:fs/promises";import{EventEmitter as V8}from"node:events";import r8 from"node:stream";import{StringDecoder as BX}from"node:string_decoder";var o8=typeof process==="object"&&process?process:{stdout:null,stderr:null},wX=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof X0||Q instanceof r8||CX(Q)||MX(Q)),CX=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof V8&&typeof Q.pipe==="function"&&Q.pipe!==r8.Writable.prototype.pipe,MX=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof V8&&typeof Q.write==="function"&&typeof Q.end==="function",n=Symbol("EOF"),r=Symbol("maybeEmitEnd"),s=Symbol("emittedEnd"),S0=Symbol("emittingEnd"),w0=Symbol("emittedError"),T0=Symbol("closed"),p8=Symbol("read"),b0=Symbol("flush"),i8=Symbol("flushChunk"),d=Symbol("encoding"),K0=Symbol("decoder"),L=Symbol("flowing"),C0=Symbol("paused"),H0=Symbol("resume"),O=Symbol("buffer"),T=Symbol("pipes"),F=Symbol("bufferLength"),Q8=Symbol("bufferPush"),u0=Symbol("bufferShift"),k=Symbol("objectMode"),A=Symbol("destroyed"),X8=Symbol("error"),$8=Symbol("emitData"),n8=Symbol("emitEnd"),Z8=Symbol("emitEnd2"),l=Symbol("async"),J8=Symbol("abort"),E0=Symbol("aborted"),M0=Symbol("signal"),Q0=Symbol("dataListeners"),E=Symbol("discarded"),R0=(Q)=>Promise.resolve().then(Q),RX=(Q)=>Q(),AX=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",IX=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,LX=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class q8{src;dest;opts;ondrain;constructor(Q,X,$){this.src=Q,this.dest=X,this.opts=$,this.ondrain=()=>Q[H0](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class a8 extends q8{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,X,$){super(Q,X,$);this.proxyErrors=(Z)=>X.emit("error",Z),Q.on("error",this.proxyErrors)}}var OX=(Q)=>!!Q.objectMode,FX=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class X0 extends V8{[L]=!1;[C0]=!1;[T]=[];[O]=[];[k];[d];[l];[K0];[n]=!1;[s]=!1;[S0]=!1;[T0]=!1;[w0]=null;[F]=0;[A]=!1;[M0];[E0]=!1;[Q0]=0;[E]=!1;writable=!0;readable=!0;constructor(...Q){let X=Q[0]||{};super();if(X.objectMode&&typeof X.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(OX(X))this[k]=!0,this[d]=null;else if(FX(X))this[d]=X.encoding,this[k]=!1;else this[k]=!1,this[d]=null;if(this[l]=!!X.async,this[K0]=this[d]?new BX(this[d]):null,X&&X.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[O]});if(X&&X.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[T]});let{signal:$}=X;if($)if(this[M0]=$,$.aborted)this[J8]();else $.addEventListener("abort",()=>this[J8]())}get bufferLength(){return this[F]}get encoding(){return this[d]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[k]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[l]}set["async"](Q){this[l]=this[l]||!!Q}[J8](){this[E0]=!0,this.emit("abort",this[M0]?.reason),this.destroy(this[M0]?.reason)}get aborted(){return this[E0]}set aborted(Q){}write(Q,X,$){if(this[E0])return!1;if(this[n])throw Error("write after end");if(this[A])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof X==="function")$=X,X="utf8";if(!X)X="utf8";let Z=this[l]?R0:RX;if(!this[k]&&!Buffer.isBuffer(Q)){if(LX(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(IX(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[k]){if(this[L]&&this[F]!==0)this[b0](!0);if(this[L])this.emit("data",Q);else this[Q8](Q);if(this[F]!==0)this.emit("readable");if($)Z($);return this[L]}if(!Q.length){if(this[F]!==0)this.emit("readable");if($)Z($);return this[L]}if(typeof Q==="string"&&!(X===this[d]&&!this[K0]?.lastNeed))Q=Buffer.from(Q,X);if(Buffer.isBuffer(Q)&&this[d])Q=this[K0].write(Q);if(this[L]&&this[F]!==0)this[b0](!0);if(this[L])this.emit("data",Q);else this[Q8](Q);if(this[F]!==0)this.emit("readable");if($)Z($);return this[L]}read(Q){if(this[A])return null;if(this[E]=!1,this[F]===0||Q===0||Q&&Q>this[F])return this[r](),null;if(this[k])Q=null;if(this[O].length>1&&!this[k])this[O]=[this[d]?this[O].join(""):Buffer.concat(this[O],this[F])];let X=this[p8](Q||null,this[O][0]);return this[r](),X}[p8](Q,X){if(this[k])this[u0]();else{let $=X;if(Q===$.length||Q===null)this[u0]();else if(typeof $==="string")this[O][0]=$.slice(Q),X=$.slice(0,Q),this[F]-=Q;else this[O][0]=$.subarray(Q),X=$.subarray(0,Q),this[F]-=Q}if(this.emit("data",X),!this[O].length&&!this[n])this.emit("drain");return X}end(Q,X,$){if(typeof Q==="function")$=Q,Q=void 0;if(typeof X==="function")$=X,X="utf8";if(Q!==void 0)this.write(Q,X);if($)this.once("end",$);if(this[n]=!0,this.writable=!1,this[L]||!this[C0])this[r]();return this}[H0](){if(this[A])return;if(!this[Q0]&&!this[T].length)this[E]=!0;if(this[C0]=!1,this[L]=!0,this.emit("resume"),this[O].length)this[b0]();else if(this[n])this[r]();else this.emit("drain")}resume(){return this[H0]()}pause(){this[L]=!1,this[C0]=!0,this[E]=!1}get destroyed(){return this[A]}get flowing(){return this[L]}get paused(){return this[C0]}[Q8](Q){if(this[k])this[F]+=1;else this[F]+=Q.length;this[O].push(Q)}[u0](){if(this[k])this[F]-=1;else this[F]-=this[O][0].length;return this[O].shift()}[b0](Q=!1){do;while(this[i8](this[u0]())&&this[O].length);if(!Q&&!this[O].length&&!this[n])this.emit("drain")}[i8](Q){return this.emit("data",Q),this[L]}pipe(Q,X){if(this[A])return Q;this[E]=!1;let $=this[s];if(X=X||{},Q===o8.stdout||Q===o8.stderr)X.end=!1;else X.end=X.end!==!1;if(X.proxyErrors=!!X.proxyErrors,$){if(X.end)Q.end()}else if(this[T].push(!X.proxyErrors?new q8(this,Q,X):new a8(this,Q,X)),this[l])R0(()=>this[H0]());else this[H0]();return Q}unpipe(Q){let X=this[T].find(($)=>$.dest===Q);if(X){if(this[T].length===1){if(this[L]&&this[Q0]===0)this[L]=!1;this[T]=[]}else this[T].splice(this[T].indexOf(X),1);X.unpipe()}}addListener(Q,X){return this.on(Q,X)}on(Q,X){let $=super.on(Q,X);if(Q==="data"){if(this[E]=!1,this[Q0]++,!this[T].length&&!this[L])this[H0]()}else if(Q==="readable"&&this[F]!==0)super.emit("readable");else if(AX(Q)&&this[s])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[w0]){let Z=X;if(this[l])R0(()=>Z.call(this,this[w0]));else Z.call(this,this[w0])}return $}removeListener(Q,X){return this.off(Q,X)}off(Q,X){let $=super.off(Q,X);if(Q==="data"){if(this[Q0]=this.listeners("data").length,this[Q0]===0&&!this[E]&&!this[T].length)this[L]=!1}return $}removeAllListeners(Q){let X=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[Q0]=0,!this[E]&&!this[T].length)this[L]=!1}return X}get emittedEnd(){return this[s]}[r](){if(!this[S0]&&!this[s]&&!this[A]&&this[O].length===0&&this[n]){if(this[S0]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[T0])this.emit("close");this[S0]=!1}}emit(Q,...X){let $=X[0];if(Q!=="error"&&Q!=="close"&&Q!==A&&this[A])return!1;else if(Q==="data")return!this[k]&&!$?!1:this[l]?(R0(()=>this[$8]($)),!0):this[$8]($);else if(Q==="end")return this[n8]();else if(Q==="close"){if(this[T0]=!0,!this[s]&&!this[A])return!1;let J=super.emit("close");return this.removeAllListeners("close"),J}else if(Q==="error"){this[w0]=$,super.emit(X8,$);let J=!this[M0]||this.listeners("error").length?super.emit("error",$):!1;return this[r](),J}else if(Q==="resume"){let J=super.emit("resume");return this[r](),J}else if(Q==="finish"||Q==="prefinish"){let J=super.emit(Q);return this.removeAllListeners(Q),J}let Z=super.emit(Q,...X);return this[r](),Z}[$8](Q){for(let $ of this[T])if($.dest.write(Q)===!1)this.pause();let X=this[E]?!1:super.emit("data",Q);return this[r](),X}[n8](){if(this[s])return!1;return this[s]=!0,this.readable=!1,this[l]?(R0(()=>this[Z8]()),!0):this[Z8]()}[Z8](){if(this[K0]){let X=this[K0].end();if(X){for(let $ of this[T])$.dest.write(X);if(!this[E])super.emit("data",X)}}for(let X of this[T])X.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[k])Q.dataLength=0;let X=this.promise();return this.on("data",($)=>{if(Q.push($),!this[k])Q.dataLength+=$.length}),await X,Q}async concat(){if(this[k])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[d]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,X)=>{this.on(A,()=>X(Error("stream destroyed"))),this.on("error",($)=>X($)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[E]=!1;let Q=!1,X=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return X();let Z=this.read();if(Z!==null)return Promise.resolve({done:!1,value:Z});if(this[n])return X();let J,V,q=(K)=>{this.off("data",_),this.off("end",Y),this.off(A,H),X(),V(K)},_=(K)=>{this.off("error",q),this.off("end",Y),this.off(A,H),this.pause(),J({value:K,done:!!this[n]})},Y=()=>{this.off("error",q),this.off("data",_),this.off(A,H),X(),J({done:!0,value:void 0})},H=()=>q(Error("stream destroyed"));return new Promise((K,G)=>{V=G,J=K,this.once(A,H),this.once("error",q),this.once("end",Y),this.once("data",_)})},throw:X,return:X,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[E]=!1;let Q=!1,X=()=>{return this.pause(),this.off(X8,X),this.off(A,X),this.off("end",X),Q=!0,{done:!0,value:void 0}},$=()=>{if(Q)return X();let Z=this.read();return Z===null?X():{done:!1,value:Z}};return this.once("end",X),this.once(X8,X),this.once(A,X),{next:$,throw:X,return:X,[Symbol.iterator](){return this}}}destroy(Q){if(this[A]){if(Q)this.emit("error",Q);else this.emit(A);return this}this[A]=!0,this[E]=!0,this[O].length=0,this[F]=0;let X=this;if(typeof X.close==="function"&&!this[T0])X.close();if(Q)this.emit("error",Q);else this.emit(A);return this}static get isStream(){return wX}}var uX=TX.native,I0={lstatSync:PX,readdir:DX,readdirSync:kX,readlinkSync:SX,realpathSync:uX,promises:{lstat:EX,readdir:xX,readlink:mX,realpath:fX}},XQ=(Q)=>!Q||Q===I0||Q===bX?I0:{...I0,...Q,promises:{...I0.promises,...Q.promises||{}}},$Q=/^\\\\\?\\([a-z]:)\\?$/i,yX=(Q)=>Q.replace(/\//g,"\\").replace($Q,"$1\\"),gX=/[\\\/]/,y=0,ZQ=1,JQ=2,o=4,VQ=6,qQ=8,$0=10,_Q=12,f=15,A0=~f,_8=16,s8=32,L0=64,c=128,x0=256,f0=512,e8=L0|c|f0,hX=1023,Y8=(Q)=>Q.isFile()?qQ:Q.isDirectory()?o:Q.isSymbolicLink()?$0:Q.isCharacterDevice()?JQ:Q.isBlockDevice()?VQ:Q.isSocket()?_Q:Q.isFIFO()?ZQ:y,t8=new Map,O0=(Q)=>{let X=t8.get(Q);if(X)return X;let $=Q.normalize("NFKD");return t8.set(Q,$),$},QQ=new Map,m0=(Q)=>{let X=QQ.get(Q);if(X)return X;let $=O0(Q.toLowerCase());return QQ.set(Q,$),$};class H8 extends B0{constructor(){super({max:256})}}class YQ extends B0{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(X)=>X.length+1})}}var KQ=Symbol("PathScurry setAsCwd");class b{name;root;roots;parent;nocase;isCWD=!1;#Q;#X;get dev(){return this.#X}#$;get mode(){return this.#$}#J;get nlink(){return this.#J}#q;get uid(){return this.#q}#M;get gid(){return this.#M}#U;get rdev(){return this.#U}#_;get blksize(){return this.#_}#H;get ino(){return this.#H}#Y;get size(){return this.#Y}#K;get blocks(){return this.#K}#Z;get atimeMs(){return this.#Z}#G;get mtimeMs(){return this.#G}#B;get ctimeMs(){return this.#B}#j;get birthtimeMs(){return this.#j}#z;get atime(){return this.#z}#w;get mtime(){return this.#w}#R;get ctime(){return this.#R}#P;get birthtime(){return this.#P}#L;#I;#A;#N;#C;#k;#V;#b;#O;#S;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,X=y,$,Z,J,V,q){if(this.name=Q,this.#L=J?m0(Q):O0(Q),this.#V=X&hX,this.nocase=J,this.roots=Z,this.root=$||this,this.#b=V,this.#A=q.fullpath,this.#C=q.relative,this.#k=q.relativePosix,this.parent=q.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=XQ(q.fs)}depth(){if(this.#I!==void 0)return this.#I;if(!this.parent)return this.#I=0;return this.#I=this.parent.depth()+1}childrenCache(){return this.#b}resolve(Q){if(!Q)return this;let X=this.getRootString(Q),Z=Q.substring(X.length).split(this.splitSep);return X?this.getRoot(X).#F(Z):this.#F(Z)}#F(Q){let X=this;for(let $ of Q)X=X.child($);return X}children(){let Q=this.#b.get(this);if(Q)return Q;let X=Object.assign([],{provisional:0});return this.#b.set(this,X),this.#V&=~_8,X}child(Q,X){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let $=this.children(),Z=this.nocase?m0(Q):O0(Q);for(let _ of $)if(_.#L===Z)return _;let J=this.parent?this.sep:"",V=this.#A?this.#A+J+Q:void 0,q=this.newChild(Q,y,{...X,parent:this,fullpath:V});if(!this.canReaddir())q.#V|=c;return $.push(q),q}relative(){if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let Q=this.name,X=this.parent;if(!X)return this.#C=this.name;let $=X.relative();return $+(!$||!X.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let Q=this.name,X=this.parent;if(!X)return this.#k=this.fullpathPosix();let $=X.relativePosix();return $+(!$||!X.parent?"":"/")+Q}fullpath(){if(this.#A!==void 0)return this.#A;let Q=this.name,X=this.parent;if(!X)return this.#A=this.name;let Z=X.fullpath()+(!X.parent?"":this.sep)+Q;return this.#A=Z}fullpathPosix(){if(this.#N!==void 0)return this.#N;if(this.sep==="/")return this.#N=this.fullpath();if(!this.parent){let Z=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Z))return this.#N=`//?/${Z}`;else return this.#N=Z}let Q=this.parent,X=Q.fullpathPosix(),$=X+(!X||!Q.parent?"":"/")+this.name;return this.#N=$}isUnknown(){return(this.#V&f)===y}isType(Q){return this[`is${Q}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#V&f)===qQ}isDirectory(){return(this.#V&f)===o}isCharacterDevice(){return(this.#V&f)===JQ}isBlockDevice(){return(this.#V&f)===VQ}isFIFO(){return(this.#V&f)===ZQ}isSocket(){return(this.#V&f)===_Q}isSymbolicLink(){return(this.#V&$0)===$0}lstatCached(){return this.#V&s8?this:void 0}readlinkCached(){return this.#O}realpathCached(){return this.#S}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#O)return!0;if(!this.parent)return!1;let Q=this.#V&f;return!(Q!==y&&Q!==$0||this.#V&x0||this.#V&c)}calledReaddir(){return!!(this.#V&_8)}isENOENT(){return!!(this.#V&c)}isNamed(Q){return!this.nocase?this.#L===O0(Q):this.#L===m0(Q)}async readlink(){let Q=this.#O;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let X=await this.#Q.promises.readlink(this.fullpath()),$=(await this.parent.realpath())?.resolve(X);if($)return this.#O=$}catch(X){this.#m(X.code);return}}readlinkSync(){let Q=this.#O;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let X=this.#Q.readlinkSync(this.fullpath()),$=this.parent.realpathSync()?.resolve(X);if($)return this.#O=$}catch(X){this.#m(X.code);return}}#g(Q){this.#V|=_8;for(let X=Q.provisional;X<Q.length;X++){let $=Q[X];if($)$.#u()}}#u(){if(this.#V&c)return;this.#V=(this.#V|c)&A0,this.#x()}#x(){let Q=this.children();Q.provisional=0;for(let X of Q)X.#u()}#h(){this.#V|=f0,this.#v()}#v(){if(this.#V&L0)return;let Q=this.#V;if((Q&f)===o)Q&=A0;this.#V=Q|L0,this.#x()}#D(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#v();else if(Q==="ENOENT")this.#u();else this.children().provisional=0}#d(Q=""){if(Q==="ENOTDIR")this.parent.#v();else if(Q==="ENOENT")this.#u()}#m(Q=""){let X=this.#V;if(X|=x0,Q==="ENOENT")X|=c;if(Q==="EINVAL"||Q==="UNKNOWN")X&=A0;if(this.#V=X,Q==="ENOTDIR"&&this.parent)this.parent.#v()}#E(Q,X){return this.#c(Q,X)||this.#W(Q,X)}#W(Q,X){let $=Y8(Q),Z=this.newChild(Q.name,$,{parent:this}),J=Z.#V&f;if(J!==o&&J!==$0&&J!==y)Z.#V|=L0;return X.unshift(Z),X.provisional++,Z}#c(Q,X){for(let $=X.provisional;$<X.length;$++){let Z=X[$];if((this.nocase?m0(Q.name):O0(Q.name))!==Z.#L)continue;return this.#f(Q,Z,$,X)}}#f(Q,X,$,Z){let J=X.name;if(X.#V=X.#V&A0|Y8(Q),J!==Q.name)X.name=Q.name;if($!==Z.provisional){if($===Z.length-1)Z.pop();else Z.splice($,1);Z.unshift(X)}return Z.provisional++,X}async lstat(){if((this.#V&c)===0)try{return this.#T(await this.#Q.promises.lstat(this.fullpath())),this}catch(Q){this.#d(Q.code)}}lstatSync(){if((this.#V&c)===0)try{return this.#T(this.#Q.lstatSync(this.fullpath())),this}catch(Q){this.#d(Q.code)}}#T(Q){let{atime:X,atimeMs:$,birthtime:Z,birthtimeMs:J,blksize:V,blocks:q,ctime:_,ctimeMs:Y,dev:H,gid:K,ino:G,mode:W,mtime:z,mtimeMs:j,nlink:U,rdev:B,size:C,uid:M}=Q;this.#z=X,this.#Z=$,this.#P=Z,this.#j=J,this.#_=V,this.#K=q,this.#R=_,this.#B=Y,this.#X=H,this.#M=K,this.#H=G,this.#$=W,this.#w=z,this.#G=j,this.#J=U,this.#U=B,this.#Y=C,this.#q=M;let w=Y8(Q);if(this.#V=this.#V&A0|w|s8,w!==y&&w!==o&&w!==$0)this.#V|=L0}#y=[];#o=!1;#p(Q){this.#o=!1;let X=this.#y.slice();this.#y.length=0,X.forEach(($)=>$(null,Q))}readdirCB(Q,X=!1){if(!this.canReaddir()){if(X)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let $=this.children();if(this.calledReaddir()){let J=$.slice(0,$.provisional);if(X)Q(null,J);else queueMicrotask(()=>Q(null,J));return}if(this.#y.push(Q),this.#o)return;this.#o=!0;let Z=this.fullpath();this.#Q.readdir(Z,{withFileTypes:!0},(J,V)=>{if(J)this.#D(J.code),$.provisional=0;else{for(let q of V)this.#E(q,$);this.#g($)}this.#p($.slice(0,$.provisional));return})}#l;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let X=this.fullpath();if(this.#l)await this.#l;else{let $=()=>{};this.#l=new Promise((Z)=>$=Z);try{for(let Z of await this.#Q.promises.readdir(X,{withFileTypes:!0}))this.#E(Z,Q);this.#g(Q)}catch(Z){this.#D(Z.code),Q.provisional=0}this.#l=void 0,$()}return Q.slice(0,Q.provisional)}readdirSync(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let X=this.fullpath();try{for(let $ of this.#Q.readdirSync(X,{withFileTypes:!0}))this.#E($,Q);this.#g(Q)}catch($){this.#D($.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#V&e8)return!1;let Q=f&this.#V;if(!(Q===y||Q===o||Q===$0))return!1;return!0}shouldWalk(Q,X){return(this.#V&o)===o&&!(this.#V&e8)&&!Q.has(this)&&(!X||X(this))}async realpath(){if(this.#S)return this.#S;if((f0|x0|c)&this.#V)return;try{let Q=await this.#Q.promises.realpath(this.fullpath());return this.#S=this.resolve(Q)}catch(Q){this.#h()}}realpathSync(){if(this.#S)return this.#S;if((f0|x0|c)&this.#V)return;try{let Q=this.#Q.realpathSync(this.fullpath());return this.#S=this.resolve(Q)}catch(Q){this.#h()}}[KQ](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let X=new Set([]),$=[],Z=this;while(Z&&Z.parent)X.add(Z),Z.#C=$.join(this.sep),Z.#k=$.join("/"),Z=Z.parent,$.push("..");Z=Q;while(Z&&Z.parent&&!X.has(Z))Z.#C=void 0,Z.#k=void 0,Z=Z.parent}}class y0 extends b{sep="\\";splitSep=gX;constructor(Q,X=y,$,Z,J,V,q){super(Q,X,$,Z,J,V,q)}newChild(Q,X=y,$={}){return new y0(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),$)}getRootString(Q){return K8.parse(Q).root}getRoot(Q){if(Q=yX(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[X,$]of Object.entries(this.roots))if(this.sameRoot(Q,X))return this.roots[Q]=$;return this.roots[Q]=new F0(Q,this).root}sameRoot(Q,X=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace($Q,"$1\\"),Q===X}}class g0 extends b{splitSep="/";sep="/";constructor(Q,X=y,$,Z,J,V,q){super(Q,X,$,Z,J,V,q)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,X=y,$={}){return new g0(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),$)}}class W8{root;rootPath;roots;cwd;#Q;#X;#$;nocase;#J;constructor(Q=process.cwd(),X,$,{nocase:Z,childrenCacheSize:J=16384,fs:V=I0}={}){if(this.#J=XQ(V),Q instanceof URL||Q.startsWith("file://"))Q=vX(Q);let q=X.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(q),this.#Q=new H8,this.#X=new H8,this.#$=new YQ(J);let _=q.substring(this.rootPath.length).split($);if(_.length===1&&!_[0])_.pop();if(Z===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Z,this.root=this.newRoot(this.#J),this.roots[this.rootPath]=this.root;let Y=this.root,H=_.length-1,K=X.sep,G=this.rootPath,W=!1;for(let z of _){let j=H--;Y=Y.child(z,{relative:Array(j).fill("..").join(K),relativePosix:Array(j).fill("..").join("/"),fullpath:G+=(W?"":K)+z}),W=!0}this.cwd=Y}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#$}resolve(...Q){let X="";for(let J=Q.length-1;J>=0;J--){let V=Q[J];if(!V||V===".")continue;if(X=X?`${V}/${X}`:V,this.isAbsolute(V))break}let $=this.#Q.get(X);if($!==void 0)return $;let Z=this.cwd.resolve(X).fullpath();return this.#Q.set(X,Z),Z}resolvePosix(...Q){let X="";for(let J=Q.length-1;J>=0;J--){let V=Q[J];if(!V||V===".")continue;if(X=X?`${V}/${X}`:V,this.isAbsolute(V))break}let $=this.#X.get(X);if($!==void 0)return $;let Z=this.cwd.resolve(X).fullpathPosix();return this.#X.set(X,Z),Z}relative(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relative()}relativePosix(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relativePosix()}basename(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.name}dirname(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return(Q.parent||Q).fullpath()}async readdir(Q=this.cwd,X={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$}=X;if(!Q.canReaddir())return[];else{let Z=await Q.readdir();return $?Z:Z.map((J)=>J.name)}}readdirSync(Q=this.cwd,X={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0}=X;if(!Q.canReaddir())return[];else if($)return Q.readdirSync();else return Q.readdirSync().map((Z)=>Z.name)}async lstat(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstat()}lstatSync(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstatSync()}async readlink(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q.withFileTypes,Q=this.cwd;let $=await Q.readlink();return X?$:$?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q.withFileTypes,Q=this.cwd;let $=Q.readlinkSync();return X?$:$?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q.withFileTypes,Q=this.cwd;let $=await Q.realpath();return X?$:$?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q.withFileTypes,Q=this.cwd;let $=Q.realpathSync();return X?$:$?.fullpath()}async walk(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:Z=!1,filter:J,walkFilter:V}=X,q=[];if(!J||J(Q))q.push($?Q:Q.fullpath());let _=new Set,Y=(K,G)=>{_.add(K),K.readdirCB((W,z)=>{if(W)return G(W);let j=z.length;if(!j)return G();let U=()=>{if(--j===0)G()};for(let B of z){if(!J||J(B))q.push($?B:B.fullpath());if(Z&&B.isSymbolicLink())B.realpath().then((C)=>C?.isUnknown()?C.lstat():C).then((C)=>C?.shouldWalk(_,V)?Y(C,U):U());else if(B.shouldWalk(_,V))Y(B,U);else U()}},!0)},H=Q;return new Promise((K,G)=>{Y(H,(W)=>{if(W)return G(W);K(q)})})}walkSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:Z=!1,filter:J,walkFilter:V}=X,q=[];if(!J||J(Q))q.push($?Q:Q.fullpath());let _=new Set([Q]);for(let Y of _){let H=Y.readdirSync();for(let K of H){if(!J||J(K))q.push($?K:K.fullpath());let G=K;if(K.isSymbolicLink()){if(!(Z&&(G=K.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(_,V))_.add(G)}}return q}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;return this.stream(Q,X)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:Z=!1,filter:J,walkFilter:V}=X;if(!J||J(Q))yield $?Q:Q.fullpath();let q=new Set([Q]);for(let _ of q){let Y=_.readdirSync();for(let H of Y){if(!J||J(H))yield $?H:H.fullpath();let K=H;if(H.isSymbolicLink()){if(!(Z&&(K=H.realpathSync())))continue;if(K.isUnknown())K.lstatSync()}if(K.shouldWalk(q,V))q.add(K)}}}stream(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:Z=!1,filter:J,walkFilter:V}=X,q=new X0({objectMode:!0});if(!J||J(Q))q.write($?Q:Q.fullpath());let _=new Set,Y=[Q],H=0,K=()=>{let G=!1;while(!G){let W=Y.shift();if(!W){if(H===0)q.end();return}H++,_.add(W);let z=(U,B,C=!1)=>{if(U)return q.emit("error",U);if(Z&&!C){let M=[];for(let w of B)if(w.isSymbolicLink())M.push(w.realpath().then((R)=>R?.isUnknown()?R.lstat():R));if(M.length){Promise.all(M).then(()=>z(null,B,!0));return}}for(let M of B)if(M&&(!J||J(M))){if(!q.write($?M:M.fullpath()))G=!0}H--;for(let M of B){let w=M.realpathCached()||M;if(w.shouldWalk(_,V))Y.push(w)}if(G&&!q.flowing)q.once("drain",K);else if(!j)K()},j=!0;W.readdirCB(z,!0),j=!1}};return K(),q}streamSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof b))X=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:Z=!1,filter:J,walkFilter:V}=X,q=new X0({objectMode:!0}),_=new Set;if(!J||J(Q))q.write($?Q:Q.fullpath());let Y=[Q],H=0,K=()=>{let G=!1;while(!G){let W=Y.shift();if(!W){if(H===0)q.end();return}H++,_.add(W);let z=W.readdirSync();for(let j of z)if(!J||J(j)){if(!q.write($?j:j.fullpath()))G=!0}H--;for(let j of z){let U=j;if(j.isSymbolicLink()){if(!(Z&&(U=j.realpathSync())))continue;if(U.isUnknown())U.lstatSync()}if(U.shouldWalk(_,V))Y.push(U)}}if(G&&!q.flowing)q.once("drain",K)};return K(),q}chdir(Q=this.cwd){let X=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[KQ](X)}}class F0 extends W8{sep="\\";constructor(Q=process.cwd(),X={}){let{nocase:$=!0}=X;super(Q,K8,"\\",{...X,nocase:$});this.nocase=$;for(let Z=this.cwd;Z;Z=Z.parent)Z.nocase=this.nocase}parseRootPath(Q){return K8.parse(Q).root.toUpperCase()}newRoot(Q){return new y0(this.rootPath,o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class N0 extends W8{sep="/";constructor(Q=process.cwd(),X={}){let{nocase:$=!1}=X;super(Q,NX,"/",{...X,nocase:$});this.nocase=$}parseRootPath(Q){return"/"}newRoot(Q){return new g0(this.rootPath,o,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class h0 extends N0{constructor(Q=process.cwd(),X={}){let{nocase:$=!0}=X;super(Q,{...X,nocase:$})}}var x5=process.platform==="win32"?y0:g0,HQ=process.platform==="win32"?F0:process.platform==="darwin"?h0:N0;var dX=(Q)=>Q.length>=1,cX=(Q)=>Q.length>=1;class W0{#Q;#X;#$;length;#J;#q;#M;#U;#_;#H;#Y=!0;constructor(Q,X,$,Z){if(!dX(Q))throw TypeError("empty pattern list");if(!cX(X))throw TypeError("empty glob list");if(X.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,$<0||$>=this.length)throw TypeError("index out of range");if(this.#Q=Q,this.#X=X,this.#$=$,this.#J=Z,this.#$===0){if(this.isUNC()){let[J,V,q,_,...Y]=this.#Q,[H,K,G,W,...z]=this.#X;if(Y[0]==="")Y.shift(),z.shift();let j=[J,V,q,_,""].join("/"),U=[H,K,G,W,""].join("/");this.#Q=[j,...Y],this.#X=[U,...z],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[J,...V]=this.#Q,[q,..._]=this.#X;if(V[0]==="")V.shift(),_.shift();let Y=J+"/",H=q+"/";this.#Q=[Y,...V],this.#X=[H,..._],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#$]}isString(){return typeof this.#Q[this.#$]==="string"}isGlobstar(){return this.#Q[this.#$]===P}isRegExp(){return this.#Q[this.#$]instanceof RegExp}globString(){return this.#M=this.#M||(this.#$===0?this.isAbsolute()?this.#X[0]+this.#X.slice(1).join("/"):this.#X.join("/"):this.#X.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#q!==void 0)return this.#q;if(!this.hasMore())return this.#q=null;return this.#q=new W0(this.#Q,this.#X,this.#$+1,this.#J),this.#q.#H=this.#H,this.#q.#_=this.#_,this.#q.#U=this.#U,this.#q}isUNC(){let Q=this.#Q;return this.#_!==void 0?this.#_:this.#_=this.#J==="win32"&&this.#$===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Q;return this.#U!==void 0?this.#U:this.#U=this.#J==="win32"&&this.#$===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Q;return this.#H!==void 0?this.#H:this.#H=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Q[0];return typeof Q==="string"&&this.isAbsolute()&&this.#$===0?Q:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#Y)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#Y)return!1;return this.#Y=!1,!0}}var lX=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class v0{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:X,nocase:$,noext:Z,noglobstar:J,platform:V=lX}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:X,nocase:$,noext:Z,noglobstar:J,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let q of Q)this.add(q)}add(Q){let X=new m(Q,this.mmopts);for(let $=0;$<X.set.length;$++){let Z=X.set[$],J=X.globParts[$];if(!Z||!J)throw Error("invalid pattern object");while(Z[0]==="."&&J[0]===".")Z.shift(),J.shift();let V=new W0(Z,J,0,this.platform),q=new m(V.globString(),this.mmopts),_=J[J.length-1]==="**",Y=V.isAbsolute();if(Y)this.absolute.push(q);else this.relative.push(q);if(_)if(Y)this.absoluteChildren.push(q);else this.relativeChildren.push(q)}}ignored(Q){let X=Q.fullpath(),$=`${X}/`,Z=Q.relative()||".",J=`${Z}/`;for(let V of this.relative)if(V.match(Z)||V.match(J))return!0;for(let V of this.absolute)if(V.match(X)||V.match($))return!0;return!1}childrenIgnored(Q){let X=Q.fullpath()+"/",$=(Q.relative()||".")+"/";for(let Z of this.relativeChildren)if(Z.match($))return!0;for(let Z of this.absoluteChildren)if(Z.match(X))return!0;return!1}}class G8{store;constructor(Q=new Map){this.store=Q}copy(){return new G8(new Map(this.store))}hasWalked(Q,X){return this.store.get(Q.fullpath())?.has(X.globString())}storeWalked(Q,X){let $=Q.fullpath(),Z=this.store.get($);if(Z)Z.add(X.globString());else this.store.set($,new Set([X.globString()]))}}class WQ{store=new Map;add(Q,X,$){let Z=(X?2:0)|($?1:0),J=this.store.get(Q);this.store.set(Q,J===void 0?Z:Z&J)}entries(){return[...this.store.entries()].map(([Q,X])=>[Q,!!(X&2),!!(X&1)])}}class GQ{store=new Map;add(Q,X){if(!Q.canReaddir())return;let $=this.store.get(Q);if($){if(!$.find((Z)=>Z.globString()===X.globString()))$.push(X)}else this.store.set(Q,[X])}get(Q){let X=this.store.get(Q);if(!X)throw Error("attempting to walk unknown path");return X}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class P0{hasWalkedCache;matches=new WQ;subwalks=new GQ;patterns;follow;dot;opts;constructor(Q,X){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=X?X.copy():new G8}processPatterns(Q,X){this.patterns=X;let $=X.map((Z)=>[Q,Z]);for(let[Z,J]of $){this.hasWalkedCache.storeWalked(Z,J);let V=J.root(),q=J.isAbsolute()&&this.opts.absolute!==!1;if(V){Z=Z.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let K=J.rest();if(!K){this.matches.add(Z,!0,!1);continue}else J=K}if(Z.isENOENT())continue;let _,Y,H=!1;while(typeof(_=J.pattern())==="string"&&(Y=J.rest()))Z=Z.resolve(_),J=Y,H=!0;if(_=J.pattern(),Y=J.rest(),H){if(this.hasWalkedCache.hasWalked(Z,J))continue;this.hasWalkedCache.storeWalked(Z,J)}if(typeof _==="string"){let K=_===".."||_===""||_===".";this.matches.add(Z.resolve(_),q,K);continue}else if(_===P){if(!Z.isSymbolicLink()||this.follow||J.checkFollowGlobstar())this.subwalks.add(Z,J);let K=Y?.pattern(),G=Y?.rest();if(!Y||(K===""||K===".")&&!G)this.matches.add(Z,q,K===""||K===".");else if(K===".."){let W=Z.parent||Z;if(!G)this.matches.add(W,q,!0);else if(!this.hasWalkedCache.hasWalked(W,G))this.subwalks.add(W,G)}}else if(_ instanceof RegExp)this.subwalks.add(Z,J)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new P0(this.opts,this.hasWalkedCache)}filterEntries(Q,X){let $=this.subwalks.get(Q),Z=this.child();for(let J of X)for(let V of $){let q=V.isAbsolute(),_=V.pattern(),Y=V.rest();if(_===P)Z.testGlobstar(J,V,Y,q);else if(_ instanceof RegExp)Z.testRegExp(J,_,Y,q);else Z.testString(J,_,Y,q)}return Z}testGlobstar(Q,X,$,Z){if(this.dot||!Q.name.startsWith(".")){if(!X.hasMore())this.matches.add(Q,Z,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,X);else if(Q.isSymbolicLink()){if($&&X.checkFollowGlobstar())this.subwalks.add(Q,$);else if(X.markFollowGlobstar())this.subwalks.add(Q,X)}}}if($){let J=$.pattern();if(typeof J==="string"&&J!==".."&&J!==""&&J!==".")this.testString(Q,J,$.rest(),Z);else if(J===".."){let V=Q.parent||Q;this.subwalks.add(V,$)}else if(J instanceof RegExp)this.testRegExp(Q,J,$.rest(),Z)}}testRegExp(Q,X,$,Z){if(!X.test(Q.name))return;if(!$)this.matches.add(Q,Z,!1);else this.subwalks.add(Q,$)}testString(Q,X,$,Z){if(!Q.isNamed(X))return;if(!$)this.matches.add(Q,Z,!1);else this.subwalks.add(Q,$)}}var oX=(Q,X)=>typeof Q==="string"?new v0([Q],X):Array.isArray(Q)?new v0(Q,X):Q;class j8{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#X;#$;signal;maxDepth;includeChildMatches;constructor(Q,X,$){if(this.patterns=Q,this.path=X,this.opts=$,this.#$=!$.posix&&$.platform==="win32"?"\\":"/",this.includeChildMatches=$.includeChildMatches!==!1,$.ignore||!this.includeChildMatches){if(this.#X=oX($.ignore??[],$),!this.includeChildMatches&&typeof this.#X.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=$.maxDepth||1/0,$.signal)this.signal=$.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#J(Q){return this.seen.has(Q)||!!this.#X?.ignored?.(Q)}#q(Q){return!!this.#X?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Q.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Q.push(Q)}async matchCheck(Q,X){if(X&&this.opts.nodir)return;let $;if(this.opts.realpath){if($=Q.realpathCached()||await Q.realpath(),!$)return;Q=$}let J=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&J?.isSymbolicLink()){let V=await J.realpath();if(V&&(V.isUnknown()||this.opts.stat))await V.lstat()}return this.matchCheckTest(J,X)}matchCheckTest(Q,X){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!X||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#J(Q)?Q:void 0}matchCheckSync(Q,X){if(X&&this.opts.nodir)return;let $;if(this.opts.realpath){if($=Q.realpathCached()||Q.realpathSync(),!$)return;Q=$}let J=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&J?.isSymbolicLink()){let V=J.realpathSync();if(V&&(V?.isUnknown()||this.opts.stat))V.lstatSync()}return this.matchCheckTest(J,X)}matchFinish(Q,X){if(this.#J(Q))return;if(!this.includeChildMatches&&this.#X?.add){let J=`${Q.relativePosix()}/**`;this.#X.add(J)}let $=this.opts.absolute===void 0?X:this.opts.absolute;this.seen.add(Q);let Z=this.opts.mark&&Q.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if($){let J=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(J+Z)}else{let J=this.opts.posix?Q.relativePosix():Q.relative(),V=this.opts.dotRelative&&!J.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!J?"."+Z:V+J+Z)}}async match(Q,X,$){let Z=await this.matchCheck(Q,$);if(Z)this.matchFinish(Z,X)}matchSync(Q,X,$){let Z=this.matchCheckSync(Q,$);if(Z)this.matchFinish(Z,X)}walkCB(Q,X,$){if(this.signal?.aborted)$();this.walkCB2(Q,X,new P0(this.opts),$)}walkCB2(Q,X,$,Z){if(this.#q(Q))return Z();if(this.signal?.aborted)Z();if(this.paused){this.onResume(()=>this.walkCB2(Q,X,$,Z));return}$.processPatterns(Q,X);let J=1,V=()=>{if(--J===0)Z()};for(let[q,_,Y]of $.matches.entries()){if(this.#J(q))continue;J++,this.match(q,_,Y).then(()=>V())}for(let q of $.subwalkTargets()){if(this.maxDepth!==1/0&&q.depth()>=this.maxDepth)continue;J++;let _=q.readdirCached();if(q.calledReaddir())this.walkCB3(q,_,$,V);else q.readdirCB((Y,H)=>this.walkCB3(q,H,$,V),!0)}V()}walkCB3(Q,X,$,Z){$=$.filterEntries(Q,X);let J=1,V=()=>{if(--J===0)Z()};for(let[q,_,Y]of $.matches.entries()){if(this.#J(q))continue;J++,this.match(q,_,Y).then(()=>V())}for(let[q,_]of $.subwalks.entries())J++,this.walkCB2(q,_,$.child(),V);V()}walkCBSync(Q,X,$){if(this.signal?.aborted)$();this.walkCB2Sync(Q,X,new P0(this.opts),$)}walkCB2Sync(Q,X,$,Z){if(this.#q(Q))return Z();if(this.signal?.aborted)Z();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,X,$,Z));return}$.processPatterns(Q,X);let J=1,V=()=>{if(--J===0)Z()};for(let[q,_,Y]of $.matches.entries()){if(this.#J(q))continue;this.matchSync(q,_,Y)}for(let q of $.subwalkTargets()){if(this.maxDepth!==1/0&&q.depth()>=this.maxDepth)continue;J++;let _=q.readdirSync();this.walkCB3Sync(q,_,$,V)}V()}walkCB3Sync(Q,X,$,Z){$=$.filterEntries(Q,X);let J=1,V=()=>{if(--J===0)Z()};for(let[q,_,Y]of $.matches.entries()){if(this.#J(q))continue;this.matchSync(q,_,Y)}for(let[q,_]of $.subwalks.entries())J++,this.walkCB2Sync(q,_,$.child(),V);V()}}class d0 extends j8{matches=new Set;constructor(Q,X,$){super(Q,X,$)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,X)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)X(this.signal.reason);else Q(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class c0 extends j8{results;constructor(Q,X,$){super(Q,X,$);this.results=new X0({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var iX=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class p{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Q,X){if(!X)throw TypeError("glob options required");if(this.withFileTypes=!!X.withFileTypes,this.signal=X.signal,this.follow=!!X.follow,this.dot=!!X.dot,this.dotRelative=!!X.dotRelative,this.nodir=!!X.nodir,this.mark=!!X.mark,!X.cwd)this.cwd="";else if(X.cwd instanceof URL||X.cwd.startsWith("file://"))X.cwd=pX(X.cwd);if(this.cwd=X.cwd||"",this.root=X.root,this.magicalBraces=!!X.magicalBraces,this.nobrace=!!X.nobrace,this.noext=!!X.noext,this.realpath=!!X.realpath,this.absolute=X.absolute,this.includeChildMatches=X.includeChildMatches!==!1,this.noglobstar=!!X.noglobstar,this.matchBase=!!X.matchBase,this.maxDepth=typeof X.maxDepth==="number"?X.maxDepth:1/0,this.stat=!!X.stat,this.ignore=X.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!X.windowsPathsNoEscape||X.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((_)=>_.replace(/\\/g,"/"));if(this.matchBase){if(X.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((_)=>_.includes("/")?_:`./**/${_}`)}if(this.pattern=Q,this.platform=X.platform||iX,this.opts={...X,platform:this.platform},X.scurry){if(this.scurry=X.scurry,X.nocase!==void 0&&X.nocase!==X.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let _=X.platform==="win32"?F0:X.platform==="darwin"?h0:X.platform?N0:HQ;this.scurry=new _(this.cwd,{nocase:X.nocase,fs:X.fs})}this.nocase=this.scurry.nocase;let $=this.platform==="darwin"||this.platform==="win32",Z={...X,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:$,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},J=this.pattern.map((_)=>new m(_,Z)),[V,q]=J.reduce((_,Y)=>{return _[0].push(...Y.set),_[1].push(...Y.globParts),_},[[],[]]);this.patterns=V.map((_,Y)=>{let H=q[Y];if(!H)throw Error("invalid pattern object");return new W0(_,H,0,this.platform)})}async walk(){return[...await new d0(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new d0(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new c0(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new c0(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var z8=(Q,X={})=>{if(!Array.isArray(Q))Q=[Q];for(let $ of Q)if(new m($,X).hasMagic())return!0;return!1};function l0(Q,X={}){return new p(Q,X).streamSync()}function UQ(Q,X={}){return new p(Q,X).stream()}function o0(Q,X={}){return new p(Q,X).walkSync()}async function jQ(Q,X={}){return new p(Q,X).walk()}function p0(Q,X={}){return new p(Q,X).iterateSync()}function BQ(Q,X={}){return new p(Q,X).iterate()}var nX=l0,rX=Object.assign(UQ,{sync:l0}),aX=p0,sX=Object.assign(BQ,{sync:p0}),eX=Object.assign(o0,{stream:l0,iterate:p0}),zQ=Object.assign(jQ,{glob:jQ,globSync:o0,sync:eX,globStream:UQ,stream:rX,globStreamSync:l0,streamSync:nX,globIterate:BQ,iterate:sX,globIterateSync:p0,iterateSync:aX,Glob:p,hasMagic:z8,escape:q0,unescape:h});zQ.glob=zQ;import tX from"node:path";var wQ=({dir:Q,pattern:X="*",nodir:$=!1,dot:Z=!0,ignore:J=[],absolute:V=!1,matchBase:q=!1,follow:_=!1})=>{if(Q=Q||process.cwd(),Q=tX.resolve(Q),X&&!Array.isArray(X))X=[X];else X=X||["*"];if(J&&!Array.isArray(J))J=[J];else J=J||[];return o0(X,{cwd:Q,nodir:$,dot:Z,ignore:J,absolute:V,matchBase:q,follow:_})};import i from"node:fs";import n0 from"node:path";import{randomUUID as Q5}from"node:crypto";import X5 from"yaml";import $5 from"nunjucks";import Z5 from"chalk";import{Atom as Z0}from"@flownet/lib-atom-api-js";import J5 from"@fnet/config";import{Api as i0}from"@flownet/lib-atom-api-js";class CQ{init({config:Q,accessToken:X}){return new Promise(($,Z)=>{if(i0.set_api_url(Q.data.url),X){i0.set_req_token(X),$(X);return}fetch(`${Q.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(Q.data.grant.params)}).then(async(J)=>{if(!J.ok)throw Error(await J.text());return J.json()}).then((J)=>{i0.set_req_token(J.access_token),$(J.access_token)}).catch((J)=>{i0.set_req_token(),Z(J)})})}}var MQ=async(Q)=>{let{atom:X,packageDependencies:$,context:Z,deploymentProjectTarget:J,setProgress:V,deploymentProject:q,yamlTarget:_}=Q;if(J.enabled!==!0)return;let Y=J.type;try{if(Y==="lib")await(await import("./index.j5z7dtsx.js")).default({...Q});else if(Y==="red")await(await import("./index.tgkhgnrp.js")).default({...Q});else if(Y==="npm")await(await import("./index.fbzv6wwf.js")).default({...Q});else if(Y==="gcs")await(await import("./index.s66v6wt4.js")).default({...Q});else if(Y==="gitlab")await(await import("./index.kb4e4bxf.js")).default({...Q});else if(Y==="fnet-package")await(await import("./index.f2tb0x3t.js")).default({...Q});else if(Y==="fnet-form")await(await import("./index.sv7v0y60.js")).default({...Q});else if(Y==="fnet-node")await(await import("./index.vq706f75.js")).default({...Q});else if(Y==="fnet-flow")await(await import("./index.z4vz93ww.js")).default({...Q});else if(Y==="nextjs")await(await import("./index.gazd9raq.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="webos")await(await import("./index.y8pvdcny.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="electron")await(await import("./index.eqxmcpdc.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="docker")await(await import("./index.dp9wyahp.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="ios")await(await import("./index.b1q7y05p.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="macos")await(await import("./index.qn0schqp.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="rust")await(await import("./index.2hc9tbyx.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else if(Y==="pypi")await(await import("./index.rht29phd.js")).default({atom:X,target:J,onProgress:V,projectDir:Z.projectDir,dependencies:$,context:Z,yamlTarget:_}),q.isDirty=!0;else{console.warn(`No deployer found for type: ${Y}`);return}}catch(H){throw console.error(`Error during deployment for type "${Y}":`,H),H}};class RQ{#Q;#X;#$;#J;#q;#M;#U;#_;#H;#Y;#K;#Z;#G;#B;#j;#z;#w;constructor(Q){this.#Q=new CQ,this.#X=Q,this.#M=[],this.#U=[],this._expire_ttl=3600,this._expire_ttl_short=300,this.#w={packageDependencies:this.#M,packageDevDependencies:this.#U,setProgress:this.setProgress.bind(this),context:this.#X,Atom:Z0,registerToPackageManager:this.registerToPackageManager.bind(this)}}get apiContext(){return this.#w}get context(){return this.#X}get atom(){return this.#$}get libs(){return this.#q}set libs(Q){this.#q=Q}get fileMode(){return this.#B}get buildMode(){return this.#j}get deployMode(){return this.#z}async _cache_set(Q,X,$){}async initAuth(){if(!this.#X.id)return;this.#_=await this.#Q.init({config:this.#Z}),this.#w.atomAccessToken=this.#_}async initLibrary(){let Q=this.#X.id;this.#$=this.#X.project?.libraryAtom||await Z0.get({id:Q});let X=this.#$.doc.bundleName;X=X||(this.#$.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#$.doc.bundleName=X,this.#$.type=this.#$.type||"workflow.lib",this.#w.atom=this.#$}async initLibraryDir(){this.setProgress({message:"Initializing library directory."});let Q=this.#X.projectDir;this.setProgress({message:"Cleaning project directory."});let X=wQ({dir:Q,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let Z of X)i.rmSync(Z,{recursive:!0,force:!0});this.setProgress({message:"Creating project directory."});let $=Q;if(!i.existsSync($))i.mkdirSync($,{recursive:!0});if($=n0.join(Q,"src"),!i.existsSync($))i.mkdirSync($,{recursive:!0});if($=n0.join(Q,"src","default"),!i.existsSync($))i.mkdirSync($,{recursive:!0});if($=n0.join(Q,".dev"),!i.existsSync($))i.mkdirSync($,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});let Q=this.#X.templateDir;this.#J=$5.configure(Q,{watch:!1,dev:!0}),this.#w.njEnv=this.#J}async createProjectYaml(){await this.setProgress({message:"Creating fnode.yaml"});let{content:$,...Z}=this.#$.doc,J=this.#X.projectDir,V=n0.resolve(J,"fnode.yaml");i.writeFileSync(V,X5.stringify(Z),"utf8")}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#X.project?.devops){let Q=[this.#X.project?.devops];for(let X=0;X<Q.length;X++){let $=Q[X];if(await this.deployProject({deploymentProject:$}),$.isDirty===!0)await $.save()}}else if(this.#$.id){let Q=await Z0.list({type:"library.deploy",parent_id:this.#$.id});for(let X=0;X<Q.length;X++){let $=Q[X];if(await this.deployProject({deploymentProject:$}),$.isDirty===!0)$=await Z0.update($,{id:$.id})}}}async deployProject(Q){let{deploymentProject:X}=Q,{yamlDocument:$}=X;if(X.doc.targets&&Array.isArray(X.doc.targets))throw Error("Deployment project targets are deprecated. Please update targets in the yaml file.");let Z=Object.keys(X.doc||{}),J=$||{};for(let V=0;V<Z.length;V++){let q=X.doc[Z[V]];q.name=Z[V];let _=J.get(Z[V]);await MQ({...this.#w,deploymentProject:X,deploymentProjectTarget:q,yamlTarget:_})}}async registerToPackageManager(Q){let{target:X,packageJSON:$}=Q;if(!this.#X.id)return;let Z=await Z0.first({name:X.params.name,parent_id:this.#Z.env.ATOM_PACKAGES_ID});if(!Z)Z=await Z0.create({parent_id:this.#Z.env.ATOM_PACKAGES_ID,doc:{name:X.params.name,type:"pm",versions:[{v:$.version}]}});else Z.doc.versions.splice(0,0,{v:$.version}),await Z0.update(Z,{id:Z.id})}async setProgress(Q){let X=typeof Q==="string"?Q:Q?.message;console.log(Z5.blue(X)),await this._cache_set(this.#Y,{status:"IN_PROGRESS",message:X})}async init(){this.#H=this.#X.buildId||Q5(),this.#w.buildId=this.#H,this.#G=this.#X.mode,this.#B=["all","deploy","build","file"].includes(this.#G),this.#j=["all","deploy","build"].includes(this.#G),this.#z=["all","deploy"].includes(this.#G),this.#K=this.#X.protocol,this.#Y="BUILD:"+this.#H,this.#Z=(await J5({optional:!0,name:this.#X.atomConfig||"atom",dir:this.#X.projectDir,tags:this.#X.tags}))?.data;try{await this.setProgress({message:"Initialization started."}),await this.initAuth(),await this.initLibrary(),await this.initRuntime()}catch(Q){throw await this._cache_set(this.#Y,{status:"FAILED",message:Q?.message||Q}),Q}}async initRuntime(){throw Error("initRuntime method must be implemented by runtime-specific builder")}async build(){throw Error("build method must be implemented by runtime-specific builder")}}var k6=RQ;import AQ from"node:fs";import IQ from"node:path";import LQ from"nunjucks";async function V5({atom:Q,setProgress:X,context:$,packageDependencies:Z}){await X({message:"Creating .gitignore"});let J={atom:Q,packageDependencies:Z},V=$.templateDir,_=LQ.compile(AQ.readFileSync(IQ.resolve(V,".gitignore.njk"),"utf8"),LQ.configure(V)).render(J),Y=$.projectDir,H=IQ.resolve(Y,".gitignore");AQ.writeFileSync(H,_,"utf8")}import r0 from"nunjucks";import e from"node:fs";import J0 from"node:path";import OQ from"@fnet/yaml";async function q5({atom:Q,context:X,setProgress:$,Atom:Z}){if(await $({message:"Creating readme.md"}),X.project?.readme){let q=X.projectDir,_={content:X.project.readme.doc.content},Y=J0.resolve(X.project.projectDir,"fnet/how-to.md");if(e.existsSync(Y)){let U=e.readFileSync(Y,"utf8");_.howto=U}let H=J0.resolve(X.project.projectDir,"fnet/input.yaml");if(e.existsSync(H)){let U=await OQ({file:H,tags:X.tags});_.input=U.content}let K=J0.resolve(X.project.projectDir,"fnet/output.yaml");if(e.existsSync(K)){let U=await OQ({file:K,tags:X.tags});_.output=U.content}let G=X.templateDir,z=r0.compile(e.readFileSync(J0.resolve(G,"readme.md.njk"),"utf8"),r0.configure(G)).render(_),j=J0.resolve(q,"readme.md");e.writeFileSync(j,z,"utf8")}else if(Q.id){let q=await Z.first({type:"wiki",parent_id:Q.id});if(!q||q.doc?.["content-type"]!=="markdown")return;let{content:_,...Y}=q.doc,H={content:_},K=X.templateDir,W=r0.compile(e.readFileSync(J0.resolve(K,"readme.md.njk"),"utf8"),r0.configure(K)).render(H),z=X.projectDir,j=J0.resolve(z,"readme.md");e.writeFileSync(j,W,"utf8")}}
4
+ export{wQ as a,k6 as b,V5 as c,q5 as d};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import o from"node:fs";import s from"node:path";import u from"semver";import y from"@fnet/shelljs";import g from"@fnet/config";async function S({setProgress:p,context:t,deploymentProject:l,deploymentProjectTarget:i,registerToPackageManager:d,yamlTarget:f}){await p({message:"Deploying it as gcs package."});let c=t.projectDir,a=s.resolve(c,"package.json"),m=o.readFileSync(a),n=JSON.parse(m);n.name=i.params.name,n.version=u.inc(i.version,"patch"),delete n.scripts,delete n.devDependencies,o.writeFileSync(a,JSON.stringify(n,null,"\t"));let{file:v,data:r}=await g({name:i.config||"gcs",dir:t.projectDir,tags:t.tags}),e="fnet-files-to-gcs";if(e+=` --projectId='${r.env.GCS_PROJECT_ID}'`,e+=` --bucketName='${r.env.GCS_BUCKET_NAME}'`,e+=` --keyFilename='${s.resolve(s.dirname(v),r.env.GCS_UPLOADER_KEY_FILE)}'`,e+=` --dir='${c}'`,e+=" --pattern='dist/**/**'",e+=" --pattern='bin/**/**'",e+=" --pattern='test/**/**'",e+=" --pattern='*.html'",e+=` --destDir='${n.name}/${n.version}'`,e+=" --metadata.cacheControl='public, max-age=31536000, immutable'",console.log(e),r.env.DOMAIN)e+=` --domain='${r.env.DOMAIN}'`;if(i.dry_run===!0||i.params.dry_run===!0)e+=" --dryRun";if(await y(e),o.writeFileSync(a,m),i.dryRun===!0)return;l.isDirty=!0,i.version=n.version,f.set("version",n.version),await d({target:i,packageJSON:n})}export{S as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import w from"semver";import d from"@fnet/config";async function T({setProgress:f,context:t,deploymentProject:p,deploymentProjectTarget:o,yamlTarget:A}){await f({message:"Deploying it as fnet form."});let{file:n,data:e}=await d({name:o.config||"fnet-form",dir:t.projectDir,tags:t.tags});if(!e.env.ATOM_API_URL)throw Error(`ATOM_API_URL is required in ${n}`);if(!e.env.ATOM_API_USERNAME)throw Error(`ATOM_API_USERNAME is required in ${n}`);if(!e.env.ATOM_API_PASSWORD)throw Error(`ATOM_API_PASSWORD is required in ${n}`);let a=`${e.env.ATOM_API_URL}/v1/auth/token`,m=e.env.ATOM_API_USERNAME,h=e.env.ATOM_API_PASSWORD,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:m,password:h})});if(!r.ok)throw Error(`Failed to fetch token: ${r.statusText}`);let c=(await r.json())?.access_token;if(!c)throw Error(`Invalid access_token from ${a}`);p.isDirty=!0;let s=w.inc(o.version,"patch");o.params.version=s,o.version=s,A.set("version",s);let _=`${e.env.ATOM_API_URL}/v1/service/fnet-form/publish`,i=await fetch(_,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:JSON.stringify({name:o.params.name,version:o.params.version,docs:o.params.docs,configs:o.params.configs})});if(!i.ok)throw Error(`Error publishing fnet form: ${i.statusText}`);if((await i.json())?.error)throw Error("Error publishing fnet form.")}export{T as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import a from"node:fs";import r from"node:path";import m from"node:os";import I from"nunjucks";import i from"@node-red/util";import T from"@fnet/config";async function D({atom:d,setProgress:h,context:o,deploymentProject:w,deploymentProjectTarget:e,buildId:F,packageDependencies:c,njEnv:j}){await h({message:"Deploying it as node-red flow."});let{projectDir:s,templateDir:$}=o,u=d.type==="workflow"?"WF":"LIB",p;if(e.deploy.template==="simple")p={atom:d,packageDependencies:c,red:{tab:{id:e.deploy.id||i.util.generateId(),label:`${u}/${d.id?d.id:m.hostname()}/${d.name}/${e.deploy.name||e.deploy.template}`},function:{id:i.util.generateId(),name:d.doc.name,initialize:{content:a.readFileSync(r.resolve(s,"dist/default/iife/index.js"),{encoding:"utf8",flag:"r"}),var:d.doc.bundleName}},inject:{id:i.util.generateId(),...e.params?.inject,payload:e.params?.inject?.payloadType==="json"?`'${JSON.stringify(e.params?.inject?.payload)}'`:e.params?.inject?.payload},debug:{id:i.util.generateId()}}};else if(e.deploy.template==="cronjob"){let l=e.params?.schedules?cloneDeep(e.params?.schedules):void 0;l?.forEach((t)=>{if(t.payloadType==="json")t.payload=`'${JSON.stringify(t.payload)}'`}),p={atom:d,packageDependencies:c,red:{tab:{id:e.deploy.id||i.util.generateId(),label:`${u}/${d.id?d.id:m.hostname()}/${e.deploy.name||e.deploy.template}`},function:{id:i.util.generateId(),name:d.doc.name,initialize:{content:a.readFileSync(r.resolve(s,"dist/default/iife/index.js"),{encoding:"utf8",flag:"r"}),var:d.doc.bundleName}},cronjob:{id:i.util.generateId(),schedules:l},debug:{id:i.util.generateId()}}}}else if(e.deploy.template==="http")p={atom:d,packageDependencies:c,red:{tab:{id:e.deploy.id||i.util.generateId(),label:`${u}/${d.id?d.id:m.hostname()}/${e.deploy.name||e.deploy.template}`},function:{id:i.util.generateId(),name:d.doc.name,initialize:{content:a.readFileSync(r.resolve(s,"dist/default/iife/index.js"),{encoding:"utf8",flag:"r"}),var:d.doc.bundleName}},httpin:{id:i.util.generateId(),method:e.params.method||"get",url:e.params.url},httpout:{id:i.util.generateId()},debug:{id:i.util.generateId()}}};else return;let n=I.compile(a.readFileSync(r.resolve($,`deploy/node-red/${e.deploy.template}.yaml.njk`),"utf8"),j).render(p);if(a.writeFileSync(r.resolve(s,"node-red.yaml"),n),n=yaml.load(n),e.dryRun===!0)return;w.isDirty=!0;let b=(await T({name:o.redConfig||"red",dir:o.projectDir,tags:o.tags}))?.data,y=e.deploy.url||b.env.RED_URL,f={};if(e.deploy.auth!==!1)f.Authorization="Bearer "+atomAccessToken;if(!e.deploy.id){let l=await fetch(`${y}/flow`,{method:"POST",headers:{...f,"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok)throw Error(`Failed to create flow: ${l.statusText}`);let t=await l.json();e.deploy.id=t.id}else if(e.actions?.delete===!0){let l=await fetch(`${y}/flow/${e.deploy.id}`,{method:"DELETE",headers:f});if(!l.ok)throw Error(`Failed to delete flow: ${l.statusText}`);delete e.actions.delete,delete e.deploy.id,e.enabled=!1}else{let l=await fetch(`${y}/flow/${e.deploy.id}`,{method:"PUT",headers:{...f,"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok)throw Error(`Failed to update flow: ${l.statusText}`)}}export{D as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import O from"semver";import P from"@fnet/config";import R from"node:fs";import S from"@fnet/shelljs";import D from"form-data";async function M({setProgress:u,context:n,deploymentProject:m,deploymentProjectTarget:e,yamlTarget:w}){await u({message:"Deploying it as fnet node."});let{file:t,data:o}=await P({name:e.config||"fnet-node",dir:n.project.projectDir,tags:n.tags});if(!o.env.ATOM_API_URL)throw Error(`ATOM_API_URL is required in ${t}`);if(!o.env.ATOM_API_USERNAME)throw Error(`ATOM_API_USERNAME is required in ${t}`);if(!o.env.ATOM_API_PASSWORD)throw Error(`ATOM_API_PASSWORD is required in ${t}`);let l=`${o.env.ATOM_API_URL}/v1/auth/token`,A=o.env.ATOM_API_USERNAME,_=o.env.ATOM_API_PASSWORD,s=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:A,password:_})});if(!s.ok)throw Error(`Failed to fetch token: ${s.statusText}`);let i=(await s.json())?.access_token;if(!i)throw Error(`Invalid access_token from ${l}`);m.isDirty=!0;let a=O.inc(e.version,"patch");e.params.version=a,e.version=a,w.set("version",a);let T=`${o.env.ATOM_API_URL}/v1/service/fnet-node/publish`,p=await fetch(T,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({name:e.params.name,version:e.params.version,docs:e.params.docs,configs:e.params.configs})});if(!p.ok)throw Error(`Error publishing fnet node: ${p.statusText}`);let h=await p.json();if(h?.error)throw Error("Error publishing fnet node.");let v=h?.upload.id,r="fnet-dir-zipper";r+=` --sourceDir='${n.project.projectDir}'`,r+=" --pattern=**/*",r+=" --stdout_format=json";let c=await S(r);if(c.code!==0)throw Error(c.stderr);let E=JSON.parse(c.stdout).path,d=new D;d.append("file",R.createReadStream(E));let f=await fetch(`${o.env.ATOM_API_URL}/v1/service/upload/single/${v}`,{method:"POST",headers:{...d.getHeaders(),Authorization:`Bearer ${i}`},body:d});if(!f.ok)throw Error(`Error uploading fnet node: ${f.statusText}`);if((await f.json())?.error)throw Error("Error uploading fnet node.")}export{M as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import d from"@fnet/config";import l from"@flownet/lib-to-webos";import a from"lodash.clonedeep";import u from"semver";async function g({atom:r,target:e,onProgress:s,projectDir:o,dependencies:t,context:f,yamlTarget:c}){if(s)await s({message:"Deploying it as webos package."});let m=e?.config?await d({name:e.config,dir:o,optional:!0,transferEnv:!1,tags:f.tags}):void 0,n=u.inc(e.version||"0.1.0","patch");e.params.version=n,e.version=n,c.set("version",n);let i=a(e.params);i.dependencies=a(t);let p={atom:r,params:i,config:m?.config,src:o,dest:o};return{deployer:await l(p)}}export{g as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import O from"semver";import P from"@fnet/config";import R from"node:fs";import S from"@fnet/shelljs";import D from"form-data";async function M({setProgress:h,context:t,deploymentProject:u,deploymentProjectTarget:o,yamlTarget:m}){await h({message:"Deploying it as fnet flow."});let{file:n,data:e}=await P({name:o.config||"fnet-flow",dir:t.project.projectDir,tags:t.tags});if(!e.env.ATOM_API_URL)throw Error(`ATOM_API_URL is required in ${n}`);if(!e.env.ATOM_API_USERNAME)throw Error(`ATOM_API_USERNAME is required in ${n}`);if(!e.env.ATOM_API_PASSWORD)throw Error(`ATOM_API_PASSWORD is required in ${n}`);let d=`${e.env.ATOM_API_URL}/v1/auth/token`,A=e.env.ATOM_API_USERNAME,_=e.env.ATOM_API_PASSWORD,s=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:A,password:_})});if(!s.ok)throw Error(`Failed to fetch token: ${s.statusText}`);let i=(await s.json())?.access_token;if(!i)throw Error(`Invalid access_token from ${d}`);u.isDirty=!0;let a=O.inc(o.version,"patch");o.params.version=a,o.version=a,m.set("version",a);let T=`${e.env.ATOM_API_URL}/v1/service/fnet-flow/publish`,p=await fetch(T,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({name:o.params.name,version:o.params.version,docs:o.params.docs,configs:o.params.configs})});if(!p.ok)throw Error(`Error publishing fnet flow: ${p.statusText}`);let w=await p.json();if(w?.error)throw Error("Error publishing fnet flow.");let v=w?.upload.id,r="fnet-dir-zipper";r+=` --sourceDir='${t.project.projectDir}'`,r+=" --pattern=**/*",r+=" --stdout_format=json";let f=await S(r);if(f.code!==0)throw Error(f.stderr);let E=JSON.parse(f.stdout).path,c=new D;c.append("file",R.createReadStream(E));let l=await fetch(`${e.env.ATOM_API_URL}/v1/service/upload/single/${v}`,{method:"POST",headers:{...c.getHeaders(),Authorization:`Bearer ${i}`},body:c});if(!l.ok)throw Error(`Error uploading fnet flow: ${l.statusText}`);if((await l.json())?.error)throw Error("Error uploading fnet flow.")}export{M as default};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import o from"yargs";import{hideBin as r}from"yargs/helpers";import{promisify as e}from"node:util";import t from"tree-kill";import a from"fs";import n from"path";import s from"@fnet/yaml";import c from"@fnet/shell-flow";e(t);let i=!1;async function m({projectType:o,group:r,tags:e,args:t,argv:i}){try{const o=await async function(){const o=process.cwd(),r=n.resolve(o,"fnode.yaml"),e=n.resolve(o,"fnet.yaml");if(a.existsSync(r))return{path:r,name:"fnode.yaml",type:"fnode"};if(a.existsSync(e))return{path:e,name:"fnet.yaml",type:"fnet"};throw new Error("No project file (fnode.yaml or fnet.yaml) found in current directory")}(),{parsed:m}=await s({file:o.path,tags:e}),p=m.commands;if(!p)throw new Error(`Commands section not found in ${o.name}`);const f=p[r];if(!f)throw new Error(`Command group '${r}' not found in ${o.name}`);await c({commands:f,context:{args:t,argv:i,projectType:o.type}})}catch(o){console.error(`Error: ${o.message}`),process.exit(1)}}const p={command:"$0 <group> [options..]",describe:"Run a command group from project file",builder:o=>o.positional("group",{type:"string",describe:"Command group to run"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).example("$0 build","Run the build command group").example("$0 test --ftag dev","Run the test command group with dev tag"),handler:async o=>{try{await m({projectType:"auto",group:o.group,tags:o.ftag,args:o,argv:process.argv})}catch(o){console.error(`Error: ${o.message}`),process.exit(1)}}};process.on("uncaughtException",(o=>{i||(i=!0,setTimeout((()=>process.exit(1)),500))})),process.on("unhandledRejection",(o=>{i||(i=!0,setTimeout((()=>process.exit(1)),500))})),async function(){try{o(r(process.argv)).usage("Usage: $0 <command> [options]").command(p).help().version().argv}catch(o){console.error(`Fatal error: ${o.message}`),process.exit(1)}}().catch((o=>{console.error(`Fatal error: ${o.message}`),process.exit(1)}));
2
+ import k from"yargs";import{hideBin as G}from"yargs/helpers";import{promisify as V}from"node:util";import W from"tree-kill";var S=V(W),M=!1;function C(){process.on("uncaughtException",($)=>{if(!M)M=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!M)M=!0,setTimeout(()=>process.exit(1),500)})}import U from"fs";import D from"path";import X from"@fnet/yaml";import Z from"@fnet/shell-flow";async function J({projectType:$,group:B,tags:H,args:I,argv:O}){try{let L=await _($),{parsed:Q}=await X({file:L.path,tags:H}),q=Q.commands;if(!q)throw Error(`Commands section not found in ${L.name}`);let z=q[B];if(!z)throw Error(`Command group '${B}' not found in ${L.name}`);await Z({commands:z,context:{args:I,argv:O,projectType:L.type}})}catch(L){console.error(`Error: ${L.message}`),process.exit(1)}}async function _($){let B=process.cwd(),H=D.resolve(B,"fnode.yaml"),I=D.resolve(B,"fnet.yaml");if($==="fnode"){if(U.existsSync(H))return{path:H,name:"fnode.yaml",type:"fnode"};throw Error("fnode.yaml file not found in current directory")}if($==="fnet"){if(U.existsSync(I))return{path:I,name:"fnet.yaml",type:"fnet"};throw Error("fnet.yaml file not found in current directory")}if(U.existsSync(H))return{path:H,name:"fnode.yaml",type:"fnode"};if(U.existsSync(I))return{path:I,name:"fnet.yaml",type:"fnet"};throw Error("No project file (fnode.yaml or fnet.yaml) found in current directory")}var R={command:"$0 <group> [options..]",describe:"Run a command group from project file",builder:($)=>{return $.positional("group",{type:"string",describe:"Command group to run"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).example("$0 build","Run the build command group").example("$0 test --ftag dev","Run the test command group with dev tag")},handler:async($)=>{try{await J({projectType:"auto",group:$.group,tags:$.ftag,args:$,argv:process.argv})}catch(B){console.error(`Error: ${B.message}`),process.exit(1)}}},N=R;C();async function A(){try{let $=k(G(process.argv)).usage("Usage: $0 <command> [options]").command(N).help().version().argv}catch($){console.error(`Fatal error: ${$.message}`),process.exit(1)}}A().catch(($)=>{console.error(`Fatal error: ${$.message}`),process.exit(1)});
@@ -1,2 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import e from"yargs";import{hideBin as t}from"yargs/helpers";import n from"chalk";import i from"node:fs";import r from"node:path";import o from"@fnet/object-from-schema";import s from"@fnet/prompt";import a from"node:os";import c from"yaml";import l from"@fnet/service";import d from"cli-table3";import{createRequire as m}from"module";function f(){return r.join(a.homedir(),".fnet","bin")}function u(){return r.join(a.homedir(),".fnet","metadata")}function p(){return r.join(u(),"binaries.json")}function g(){try{if("win32"===process.platform)return process.env.PSModulePath&&process.env.PSModulePath.includes("PowerShell")?"powershell-core":process.env.PSModulePath?"powershell":"cmd";const e=process.env.SHELL||"";return e.includes("bash")?"bash":e.includes("zsh")?"zsh":e.includes("fish")?"fish":e.includes("ksh")?"ksh":e.includes("csh")||e.includes("tcsh")?"csh":i.existsSync(r.join(a.homedir(),".bashrc"))?"bash":i.existsSync(r.join(a.homedir(),".zshrc"))?"zsh":i.existsSync(r.join(a.homedir(),".config","fish","config.fish"))?"fish":"unknown"}catch(e){return"unknown"}}function y(e){const t=a.homedir(),n=[];switch(e){case"bash":n.push({name:".bashrc",path:r.join(t,".bashrc")}),n.push({name:".bash_profile",path:r.join(t,".bash_profile")}),n.push({name:".profile",path:r.join(t,".profile")});break;case"zsh":n.push({name:".zshrc",path:r.join(t,".zshrc")}),n.push({name:".zprofile",path:r.join(t,".zprofile")});break;case"fish":n.push({name:"config.fish",path:r.join(t,".config","fish","config.fish")});break;case"ksh":n.push({name:".kshrc",path:r.join(t,".kshrc")}),n.push({name:".profile",path:r.join(t,".profile")});break;case"csh":n.push({name:".cshrc",path:r.join(t,".cshrc")}),n.push({name:".tcshrc",path:r.join(t,".tcshrc")});break;case"powershell":n.push({name:"Microsoft.PowerShell_profile.ps1",path:r.join(t,"Documents","WindowsPowerShell","Microsoft.PowerShell_profile.ps1")}),n.push({name:"profile.ps1",path:r.join(t,"Documents","WindowsPowerShell","profile.ps1")});break;case"powershell-core":n.push({name:"Microsoft.PowerShell_profile.ps1",path:r.join(t,"Documents","PowerShell","Microsoft.PowerShell_profile.ps1")}),n.push({name:"profile.ps1",path:r.join(t,"Documents","PowerShell","profile.ps1")});break;case"cmd":n.push({name:"fnet-path.bat",path:r.join(t,"fnet-path.bat")})}return n}function v(e,t){switch(e){case"bash":case"zsh":case"ksh":default:return`export PATH="${t}:$PATH"`;case"fish":return`set -gx PATH ${t} $PATH`;case"csh":return`setenv PATH ${t}:$PATH`;case"powershell":case"powershell-core":return`$env:PATH = "${t};" + $env:PATH`;case"cmd":return`@echo off\nSETX PATH "%PATH%;${t}"\necho Path updated successfully`}}function h(){return r.join(a.homedir(),".fnet","backups")}function S(){const e=(new Date).toISOString().replace(/:/g,"-").replace(/\..+/,""),t=r.join(h(),e);return i.existsSync(t)||i.mkdirSync(t,{recursive:!0}),t}function b(e,t,o=null){try{if(!i.existsSync(e))return!1;const n=o||r.basename(e),s=r.join(t,n),a=r.dirname(s);return i.existsSync(a)||i.mkdirSync(a,{recursive:!0}),i.copyFileSync(e,s),!0}catch(t){return console.error(n.red(`Failed to backup file ${e}: ${t.message}`)),!1}}function w(e,t={}){const n={timestamp:(new Date).toISOString(),type:t.type||"manual",message:t.message||"",command:t.command||"",files:t.files||[],...t},o=r.join(e,"metadata.json");i.writeFileSync(o,JSON.stringify(n,null,2))}function $(e){const t=r.join(h(),"latest");try{i.existsSync(t)&&i.unlinkSync(t),"win32"===process.platform?i.writeFileSync(t+".txt",e):i.symlinkSync(e,t)}catch(e){console.warn(n.yellow(`Could not create latest symlink: ${e.message}`))}}var x={getBinDirectory:f,getMetadataDirectory:u,getMetadataFilePath:p,checkIfInPath:function(e){return(process.env.PATH||"").split(r.delimiter).includes(e)},detectUserShell:g,getShellConfigPath:function(){const e=y(g());for(const t of e)if(i.existsSync(t.path))return t.path;return e.length>0?e[0].path:null},getAllShellConfigPaths:y,createBinDirectoryStructure:async function(){const e=f(),t=u(),n=p();i.existsSync(e)||i.mkdirSync(e,{recursive:!0}),i.existsSync(t)||i.mkdirSync(t,{recursive:!0}),i.existsSync(n)||i.writeFileSync(n,JSON.stringify({binaries:{},lastUpdated:(new Date).toISOString()},null,2))},getExportPathCommand:v,addBinToPath:async function(e,t,o,s={}){try{const{autoBackup:a=!0}=s,c=v(e,o);if("cmd"===e)return i.writeFileSync(t,c),console.log(n.yellow(`Created batch file at ${t}`)),console.log(n.yellow("Run this file to add the bin directory to your PATH")),!0;if("powershell"!==e&&"powershell-core"!==e||i.existsSync(r.dirname(t))||i.mkdirSync(r.dirname(t),{recursive:!0}),!i.existsSync(t)){const r="fish"===e?"# Fish shell configuration\n\n":"powershell"===e||"powershell-core"===e?"# PowerShell profile\n\n":"# Shell configuration\n\n";i.writeFileSync(t,r),console.log(n.green(`Created config file at ${t}`))}const l=i.readFileSync(t,"utf8");if(l.includes(o))return!0;if(a&&i.existsSync(t)){const e=S(),i=r.basename(t);b(t,r.join(e,"configs"),i)&&(w(e,{type:"auto",command:"addBinToPath",message:`Automatic backup before modifying ${i}`,files:[t]}),$(e),console.log(n.green(`✓ Backed up ${i} to ${e}`)))}const d=`${l.trim()}\n\n# Added by @fnet/cli\n${c}\n`;return i.writeFileSync(t,d),"powershell"!==e&&"powershell-core"!==e||(console.log(n.yellow("You may need to set the PowerShell execution policy to run scripts:")),console.log(n.green("Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned"))),!0}catch(e){return console.error(n.red(`Failed to add bin directory to PATH: ${e.message}`)),!1}},getBackupDirectory:h,createBackupDirectory:S,backupFile:b,createBackupMetadata:w,listBackups:function(){const e=h();if(!i.existsSync(e))return[];const t=[],n=i.readdirSync(e);for(const o of n){const n=r.join(e,o),s=i.statSync(n);if(s.isDirectory()&&"latest"!==o){const e=r.join(n,"metadata.json");let a={};if(i.existsSync(e))try{a=JSON.parse(i.readFileSync(e,"utf8"))}catch(e){}t.push({timestamp:o,path:n,created:s.mtime,...a})}}return t.sort(((e,t)=>new Date(t.created)-new Date(e.created))),t},updateLatestSymlink:$};function D(){return r.join(a.homedir(),".fnet","services")}function F(){return r.join(a.homedir(),".fnet","metadata")}function j(){return r.join(F(),"services.json")}function k(){const e=j();if(!i.existsSync(e))return{services:{},lastUpdated:(new Date).toISOString()};try{return JSON.parse(i.readFileSync(e,"utf8"))}catch(e){return console.warn(n.yellow(`Failed to parse service metadata file: ${e.message}`)),{services:{},lastUpdated:(new Date).toISOString()}}}function O(e){const t=j();e.lastUpdated=(new Date).toISOString(),i.writeFileSync(t,JSON.stringify(e,null,2))}function E(e){return r.join(D(),`${e}.yaml`)}function P(e){const t=E(e);if(!i.existsSync(t))return null;try{const e=i.readFileSync(t,"utf8");return c.parse(e)}catch(e){return console.warn(n.yellow(`Failed to parse service definition file: ${e.message}`)),null}}function M(e){const t=[];if(e.name||t.push("Service name is required"),e.binary||t.push("Binary name is required"),e.binary){const n=x.getBinDirectory(),o=r.join(n,e.binary);i.existsSync(o)||t.push(`Binary '${e.binary}' not found in bin directory`)}return{valid:0===t.length,errors:t}}var A={getServicesDirectory:D,getServiceMetadataDirectory:F,getServiceMetadataFilePath:j,createServiceDirectoryStructure:async function(){const e=D(),t=F(),n=j();i.existsSync(e)||i.mkdirSync(e,{recursive:!0}),i.existsSync(t)||i.mkdirSync(t,{recursive:!0}),i.existsSync(n)||i.writeFileSync(n,JSON.stringify({services:{},lastUpdated:(new Date).toISOString()},null,2))},loadServiceMetadata:k,saveServiceMetadata:O,getServiceDefinitionPath:E,serviceDefinitionExists:function(e){const t=E(e);return i.existsSync(t)},loadServiceDefinition:P,saveServiceDefinition:function(e,t){const r=E(e);try{const e=c.stringify(t);return i.writeFileSync(r,e),!0}catch(e){return console.error(n.red(`Failed to save service definition: ${e.message}`)),!1}},deleteServiceDefinition:function(e){const t=E(e);if(!i.existsSync(t))return!1;try{return i.unlinkSync(t),!0}catch(e){return console.error(n.red(`Failed to delete service definition: ${e.message}`)),!1}},listServiceDefinitions:function(){const e=D();if(!i.existsSync(e))return[];try{return i.readdirSync(e).filter((e=>e.endsWith(".yaml"))).map((e=>e.replace(".yaml","")))}catch(e){return console.error(n.red(`Failed to list service definitions: ${e.message}`)),[]}},validateServiceDefinition:M,registerService:async function(e,t={}){const n=P(e);if(!n)throw new Error(`Service definition '${e}' not found`);const i=M(n);if(!i.valid)throw new Error(`Invalid service definition: ${i.errors.join(", ")}`);const o=x.getBinDirectory(),s=r.join(o,n.binary);try{await l({action:"register",name:n.name,description:n.description||`Service for ${n.binary}`,command:[s,...n.args||[]],env:n.env||{},wdir:n.workingDir,system:!1!==n.system,autoStart:!0===n.autoStart,restartOnFailure:!1!==n.restartOnFailure,user:n.user});const t=k();return t.services[n.name]={definition:e,binary:n.binary,registered:(new Date).toISOString(),status:"registered"},O(t),{success:!0,name:n.name,definition:e}}catch(e){throw new Error(`Failed to register service: ${e.message}`)}}};async function N(e){await A.createServiceDirectoryStructure();return{servicesDir:A.getServicesDirectory(),metadataDir:A.getServiceMetadataDirectory(),metadata:A.loadServiceMetadata(),args:e}}var T={getServiceDefinitionSchema:function(e=!0){let t=[];if(e)try{const e=x.getBinDirectory(),n=x.getMetadataFilePath();if(i.existsSync(n)){const e=JSON.parse(i.readFileSync(n,"utf8"));t=Object.keys(e.binaries).map((t=>({name:t,message:`${t} (${e.binaries[t].version||"unknown"})`})))}else i.existsSync(e)&&(t=i.readdirSync(e).map((e=>({name:e,message:e}))))}catch(e){console.warn(`Failed to get binary choices: ${e.message}`)}return{type:"object",required:["name","binary"],properties:{name:{type:"string",description:"Service name","x-prompt":{type:"input",message:"Enter service name:"}},binary:{type:"string",description:"Binary name in the bin directory","x-prompt":{type:"select",message:"Select binary:",choices:t}},description:{type:"string",description:"Service description","x-prompt":{type:"input",message:"Enter service description:"}},args:{type:"array",items:{type:"string"},description:"Command line arguments","x-prompt":{type:"input",message:"Enter command line arguments (space-separated):",result:e=>e?e.split(" "):[]}},env:{type:"object",additionalProperties:{type:"string"},description:"Environment variables","x-prompt":{type:"input",message:"Enter environment variables (KEY=VALUE format, one per line):",result:e=>e?e.split("\n").filter((e=>e.includes("="))).reduce(((e,t)=>{const[n,...i]=t.split("=");return e[n.trim()]=i.join("=").trim(),e}),{}):{}}},workingDir:{type:"string",description:"Working directory","x-prompt":{type:"input",message:"Enter working directory (optional):"}},autoStart:{type:"boolean",description:"Start on boot",default:!1,"x-prompt":{type:"confirm",message:"Start service on boot?",initial:!1}},restartOnFailure:{type:"boolean",description:"Restart on failure",default:!0,"x-prompt":{type:"confirm",message:"Restart service on failure?",initial:!0}},system:{type:"boolean",description:"System service",default:!0,"x-prompt":{type:"confirm",message:"Register as system service?",initial:!0}},user:{type:"string",description:"User to run the service as","x-prompt":{type:"input",message:"Enter user to run the service as (optional):"}},instances:{type:"integer",description:"Number of instances to run",default:1,minimum:1,"x-prompt":{type:"number",message:"Enter number of instances to run:",initial:1}},metadata:{type:"object",additionalProperties:!0,description:"Custom metadata"}}}}};var I={promptForSelection:async function(e){const{items:t,message:i,nameField:r="name",valueField:o="name",initialValue:a=null,allowAbort:c=!0}=e;if(!t||0===t.length)return console.log(n.yellow("No items available for selection.")),null;if(1===t.length&&!c){const e=t[0],i="string"==typeof e?e:e[o];return console.log(n.blue(`Only one option available: ${"string"==typeof e?e:e[r]}`)),i}let l=t.map((e=>"string"==typeof e?{name:e,value:e,message:e}:{name:e[o],value:e[o],message:e[r]||e[o]}));c&&l.push({name:"cancel",value:null,message:n.yellow("Cancel")});let d=null;if(a){const e=l.findIndex((e=>e.name===a));-1!==e&&(d=e)}const m="selectedItem",{[m]:f}=await s({type:"select",name:m,message:i,choices:l,initial:d});return"cancel"===f?null:f},promptForMultipleSelection:async function(e){const{items:t,message:i,nameField:r="name",valueField:o="name",initialValues:a=[],allowAbort:c=!0}=e;if(!t||0===t.length)return console.log(n.yellow("No items available for selection.")),null;let l=t.map((e=>"string"==typeof e?{name:e,value:e,message:e}:{name:e[o],value:e[o],message:e[r]||e[o]})),d=[];a&&a.length>0&&(d=l.map(((e,t)=>a.includes(e.name)?t:-1)).filter((e=>-1!==e)));const m="selectedItems",f=await s({type:"multiselect",name:m,message:i,choices:l,initial:d,hint:"(Use space to select, enter to confirm)",validate:e=>!(0===e.length&&!c)||"Please select at least one item"});return c&&0===f[m].length?null:f[m]}};const B={command:"definition <subcommand>",describe:"Manage service definitions",builder:e=>e.command({command:"create",describe:"Create a new service definition",builder:e=>e.option("name",{describe:"Service definition name",type:"string"}).option("output",{describe:"Output file path",type:"string",alias:"o"}),handler:C}).command({command:"list",describe:"List service definitions",builder:e=>e.option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"}),handler:U}).command({command:"show [n]",describe:"Show service definition details",builder:e=>e.positional("name",{describe:"Service definition name",type:"string",demandOption:!1}).option("format",{describe:"Output format",type:"string",choices:["json","yaml"],default:"yaml"}),handler:R}).command({command:"edit [n]",describe:"Edit a service definition",builder:e=>e.positional("name",{describe:"Service definition name",type:"string",demandOption:!1}),handler:H}).command({command:"delete [n]",describe:"Delete a service definition",builder:e=>e.positional("name",{describe:"Service definition name",type:"string",demandOption:!1}).option("force",{describe:"Force deletion without confirmation",type:"boolean",default:!1,alias:"f"}),handler:z}).command({command:"validate [n]",describe:"Validate a service definition",builder:e=>e.positional("name",{describe:"Service definition name",type:"string",demandOption:!1}),handler:J}).demandCommand(1,"You need to specify a subcommand"),handler:()=>{}};async function C(e){try{await N(e);const t=T.getServiceDefinitionSchema(),i=await o({schema:t,format:"yaml"});let r;if(console.log("Result from fnetObjectFromSchema:",i),"string"==typeof i)try{r=(await import("yaml")).default.parse(i)}catch(e){console.warn(n.yellow(`Failed to parse YAML: ${e.message}`)),r={name:"service-"+Date.now()}}else r=i&&"object"==typeof i?i.data||i:{name:"service-"+Date.now()};console.log("Generated definition:",r);const a=e.name||(r&&r.name?r.name:"service-"+Date.now());if(A.serviceDefinitionExists(a)&&!e.force){const{confirmOverwrite:e}=await s({type:"confirm",name:"confirmOverwrite",message:`Service definition '${a}' already exists. Overwrite?`,initial:!1});if(!e)return void console.log(n.yellow("Operation cancelled."))}A.saveServiceDefinition(a,r)?(console.log(n.green(`Service definition '${a}' created successfully.`)),console.log(n.blue(`Location: ${A.getServiceDefinitionPath(a)}`))):console.error(n.red(`Failed to create service definition '${a}'.`))}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}async function U(e){try{await N(e);const t=A.listServiceDefinitions();if(0===t.length)return void console.log(n.yellow("No service definitions found."));if("json"===e.format)console.log(JSON.stringify(t,null,2));else if("text"===e.format)t.forEach((e=>console.log(e)));else{console.log(n.bold("\nService Definitions:"));const e=(await Promise.resolve().then((function(){return Z}))).default,i=["NAME","BINARY","DESCRIPTION"],r=e.createTable(i,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(const e of t){const t=A.loadServiceDefinition(e);t&&r.push([n.white(e),n.cyan(t.binary||"undefined"),t.description||""])}console.log(r.toString()),console.log(`Total: ${t.length} definition(s)`)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}async function R(e){try{await N(e);if(!e.name){const t=A.listServiceDefinitions();if(0===t.length)return void console.log(n.yellow("No service definitions found."));const i=await I.promptForSelection({items:t,message:"Select a service definition to show:",allowAbort:!0});if(null===i)return void console.log(n.yellow("Operation cancelled."));e.name=i}const t=A.loadServiceDefinition(e.name);if(t||(console.error(n.red(`Service definition '${e.name}' not found.`)),process.exit(1)),"json"===e.format)console.log(JSON.stringify(t,null,2));else{const e=(await import("yaml")).default;console.log(e.stringify(t))}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}async function H(e){try{await N(e);if(!e.name){const t=A.listServiceDefinitions();if(0===t.length)return void console.log(n.yellow("No service definitions found."));const i=await I.promptForSelection({items:t,message:"Select a service definition to edit:",allowAbort:!0});if(null===i)return void console.log(n.yellow("Operation cancelled."));e.name=i}const t=A.loadServiceDefinition(e.name);t||(console.error(n.red(`Service definition '${e.name}' not found.`)),process.exit(1));const i=T.getServiceDefinitionSchema(),r=(await o({schema:i,ref:t,format:"yaml"})).data;A.saveServiceDefinition(e.name,r)?console.log(n.green(`Service definition '${e.name}' updated successfully.`)):console.error(n.red(`Failed to update service definition '${e.name}'.`))}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}async function z(e){try{await N(e);if(!e.name){const t=A.listServiceDefinitions();if(0===t.length)return void console.log(n.yellow("No service definitions found."));const i=await I.promptForSelection({items:t,message:"Select a service definition to delete:",allowAbort:!0});if(null===i)return void console.log(n.yellow("Operation cancelled."));e.name=i}if(A.serviceDefinitionExists(e.name)||(console.error(n.red(`Service definition '${e.name}' not found.`)),process.exit(1)),!e.force){const{confirmDelete:t}=await s({type:"confirm",name:"confirmDelete",message:`Are you sure you want to delete service definition '${e.name}'?`,initial:!1});if(!t)return void console.log(n.yellow("Operation cancelled."))}A.deleteServiceDefinition(e.name)?console.log(n.green(`Service definition '${e.name}' deleted successfully.`)):console.error(n.red(`Failed to delete service definition '${e.name}'.`))}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}async function J(e){try{await N(e);if(!e.name){const t=A.listServiceDefinitions();if(0===t.length)return void console.log(n.yellow("No service definitions found."));const i=await I.promptForSelection({items:t,message:"Select a service definition to validate:",allowAbort:!0});if(null===i)return void console.log(n.yellow("Operation cancelled."));e.name=i}const t=A.loadServiceDefinition(e.name);t||(console.error(n.red(`Service definition '${e.name}' not found.`)),process.exit(1));const i=A.validateServiceDefinition(t);i.valid?console.log(n.green(`Service definition '${e.name}' is valid.`)):(console.error(n.red(`Service definition '${e.name}' is invalid:`)),i.errors.forEach((e=>{console.error(n.red(`- ${e}`))})),process.exit(1))}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}const _={command:"register",describe:"Register a service definition as a system service",builder:e=>e.option("definition",{describe:"Service definition name",type:"string",demandOption:!0,alias:"d"}).option("start",{describe:"Start the service after registration",type:"boolean",default:!1}),handler:async e=>{try{await N(e);A.serviceDefinitionExists(e.definition)||(console.error(n.red(`Service definition '${e.definition}' not found.`)),process.exit(1)),console.log(n.blue(`Registering service from definition '${e.definition}'...`));const t=await A.registerService(e.definition);if(console.log(n.green(`Service '${t.name}' registered successfully.`)),e.start){console.log(n.blue(`Starting service '${t.name}'...`));const e=(await import("@fnet/service")).default;try{await e({action:"start",name:t.name}),console.log(n.green(`Service '${t.name}' started successfully.`));const i=A.loadServiceMetadata();i.services[t.name]&&(i.services[t.name].status="running",i.services[t.name].lastStarted=(new Date).toISOString(),A.saveServiceMetadata(i))}catch(e){console.error(n.red(`Failed to start service: ${e.message}`))}}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},W={command:"unregister",describe:"Unregister a service from the system",builder:e=>e.option("name",{describe:"Service name",type:"string",demandOption:!0,alias:"n"}).option("keep-definition",{describe:"Keep the service definition",type:"boolean",default:!0}).option("force",{describe:"Force unregistration without confirmation",type:"boolean",default:!1,alias:"f"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();if(t.services[e.name]||(console.error(n.red(`Service '${e.name}' not found in metadata.`)),process.exit(1)),!e.force){const{confirmUnregister:t}=await s({type:"confirm",name:"confirmUnregister",message:`Are you sure you want to unregister service '${e.name}'?`,initial:!1});if(!t)return void console.log(n.yellow("Operation cancelled."))}console.log(n.blue(`Unregistering service '${e.name}'...`));const i=(await import("@fnet/service")).default;try{const r=t.services[e.name].definition,o=A.loadServiceDefinition(r);if(!o)throw new Error(`Service definition '${r}' not found`);const s=!1!==o.system;try{await i({action:"stop",name:e.name,system:s}),console.log(n.blue(`Service '${e.name}' stopped.`))}catch(e){console.warn(n.yellow(`Warning: Failed to stop service: ${e.message}`))}if(await i({action:"unregister",name:e.name,system:s}),console.log(n.green(`Service '${e.name}' unregistered successfully.`)),delete t.services[e.name],A.saveServiceMetadata(t),!e.keepDefinition&&r&&A.serviceDefinitionExists(r)){A.deleteServiceDefinition(r)?console.log(n.green(`Service definition '${r}' deleted.`)):console.warn(n.yellow(`Warning: Failed to delete service definition '${r}'.`))}}catch(e){console.error(n.red(`Failed to unregister service: ${e.message}`)),process.exit(1)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},L={command:"start",describe:"Start a registered service",builder:e=>e.option("name",{describe:"Service name",type:"string",demandOption:!0,alias:"n"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();t.services[e.name]||(console.error(n.red(`Service '${e.name}' not found in metadata.`)),process.exit(1)),console.log(n.blue(`Starting service '${e.name}'...`));const i=(await import("@fnet/service")).default;try{const r=t.services[e.name].definition,o=A.loadServiceDefinition(r);if(!o)throw new Error(`Service definition '${r}' not found`);await i({action:"start",name:e.name,system:!1!==o.system}),console.log(n.green(`Service '${e.name}' started successfully.`)),t.services[e.name].status="running",t.services[e.name].lastStarted=(new Date).toISOString(),A.saveServiceMetadata(t)}catch(e){console.error(n.red(`Failed to start service: ${e.message}`)),process.exit(1)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},Y={command:"stop",describe:"Stop a running service",builder:e=>e.option("name",{describe:"Service name",type:"string",demandOption:!0,alias:"n"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();t.services[e.name]||(console.error(n.red(`Service '${e.name}' not found in metadata.`)),process.exit(1)),console.log(n.blue(`Stopping service '${e.name}'...`));const i=(await import("@fnet/service")).default;try{const r=t.services[e.name].definition,o=A.loadServiceDefinition(r);if(!o)throw new Error(`Service definition '${r}' not found`);await i({action:"stop",name:e.name,system:!1!==o.system}),console.log(n.green(`Service '${e.name}' stopped successfully.`)),t.services[e.name].status="stopped",t.services[e.name].lastStopped=(new Date).toISOString(),A.saveServiceMetadata(t)}catch(e){console.error(n.red(`Failed to stop service: ${e.message}`)),process.exit(1)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},V={command:"restart",describe:"Restart a service",builder:e=>e.option("name",{describe:"Service name",type:"string",demandOption:!0,alias:"n"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();t.services[e.name]||(console.error(n.red(`Service '${e.name}' not found in metadata.`)),process.exit(1)),console.log(n.blue(`Restarting service '${e.name}'...`));const i=(await import("@fnet/service")).default;try{await i({action:"stop",name:e.name}),console.log(n.blue(`Service '${e.name}' stopped.`)),await i({action:"start",name:e.name}),console.log(n.green(`Service '${e.name}' restarted successfully.`)),t.services[e.name].status="running",t.services[e.name].lastRestarted=(new Date).toISOString(),A.saveServiceMetadata(t)}catch(e){console.error(n.red(`Failed to restart service: ${e.message}`)),process.exit(1)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},q={command:"status",describe:"Check the status of a service",builder:e=>e.option("name",{describe:"Service name",type:"string",demandOption:!0,alias:"n"}).option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();t.services[e.name]||(console.error(n.red(`Service '${e.name}' not found in metadata.`)),process.exit(1)),console.log(n.blue(`Checking status of service '${e.name}'...`));const i=(await import("@fnet/service")).default;try{const r=t.services[e.name].definition,o=A.loadServiceDefinition(r);if(!o)throw new Error(`Service definition '${r}' not found`);const s=await i({action:"status",name:e.name,system:!1!==o.system});console.log(n.green(`Service '${e.name}' status: ${s}`)),t.services[e.name].status=s||"unknown",t.services[e.name].lastChecked=(new Date).toISOString(),A.saveServiceMetadata(t),"json"===e.format?console.log(JSON.stringify({name:e.name,status:s||"unknown",definition:t.services[e.name].definition,binary:t.services[e.name].binary},null,2)):"text"===e.format?(console.log(`Name: ${e.name}`),console.log(`Status: ${s||"unknown"}`),console.log(`Definition: ${t.services[e.name].definition}`),console.log(`Binary: ${t.services[e.name].binary}`)):(console.log(n.bold("\nService Status:")),console.log(n.bold("─".repeat(50))),console.log(`${n.bold("Name:")} ${e.name}`),console.log(`${n.bold("Status:")} ${function(e){switch(e){case"running":return n.green;case"stopped":return n.yellow;case"failed":return n.red;default:return n.gray}}(s)(s||"unknown")}`),console.log(`${n.bold("Definition:")} ${t.services[e.name].definition}`),console.log(`${n.bold("Binary:")} ${t.services[e.name].binary}`),console.log(n.bold("─".repeat(50))))}catch(e){console.error(n.red(`Failed to check service status: ${e.message}`)),process.exit(1)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}};function K(e,t={}){const i={chars:{top:"─","top-mid":"─","top-left":" ","top-right":" ",bottom:"─","bottom-mid":"─","bottom-left":" ","bottom-right":" ",left:" ","left-mid":" ",mid:"─","mid-mid":"─",right:" ","right-mid":" ",middle:" "},style:{head:[],border:[],compact:!0},wordWrap:!0,...t,head:e.map((e=>n.bold(e)))};return new d(i)}function G(e,t,n={}){const i=K(e,n);return Array.isArray(t)&&t.forEach((e=>{i.push(e)})),i.toString()}function X(e){switch(e){case"running":return n.green;case"stopped":return n.yellow;case"failed":return n.red;case"registered":return n.blue;default:return n.gray}}var Q={createTable:K,createTableWithData:G,getStatusColor:X},Z=Object.freeze({__proto__:null,createTable:K,createTableWithData:G,default:Q,getStatusColor:X});const ee={command:"list",describe:"List all registered services",builder:e=>e.option("binary",{describe:"Filter by binary name",type:"string",alias:"b"}).option("status",{describe:"Filter by status",type:"string",choices:["running","stopped","failed","unknown"],alias:"s"}).option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"}),handler:async e=>{try{await N(e);const t=A.loadServiceMetadata();let i=Object.entries(t.services).map((([e,t])=>({name:e,...t})));if(e.binary&&(i=i.filter((t=>t.binary===e.binary))),e.status&&(i=i.filter((t=>t.status===e.status))),0===i.length)return void console.log(n.yellow("No services found."));if("json"===e.format)console.log(JSON.stringify(i,null,2));else if("text"===e.format)i.forEach((e=>{console.log(`${e.name} (${e.status||"unknown"})`)}));else{const e=["NAME","STATUS","BINARY","DEFINITION"],t=Q.createTable(e,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});i.forEach((e=>{const i=Q.getStatusColor(e.status);t.push([n.white(e.name),i(e.status||"unknown"),n.cyan(e.binary),e.definition])})),console.log(n.bold("\nRegistered Services:")),console.log(t.toString()),console.log(`Total: ${i.length} service(s)`)}}catch(e){console.error(n.red(`Error: ${e.message}`)),process.exit(1)}}},te=m(import.meta.url),{version:ne}=te("../../package.json");e(t(process.argv)).scriptName("fservice").usage("Usage: $0 <command> [options]").version(ne).command(B).command(_).command(W).command(L).command(Y).command(V).command(q).command(ee).demandCommand(1,"You need to specify a command").strict().help().alias("h","help").alias("v","version").fail(((e,t,i)=>{t?(console.error(n.red(`Error: ${t.message}`)),console.error(t)):console.error(n.red(`Error: ${e}`)),console.error(n.yellow("\nUsage:"),i.help()),process.exit(1)})).parse();
2
+ import{a as V,b as A,c as o}from"./index.q01yvaz0.js";import rz from"yargs";import{hideBin as sz}from"yargs/helpers";import l from"chalk";import T from"chalk";import Zz from"@fnet/object-from-schema";import _z from"@fnet/prompt";import H from"node:fs";import P from"node:path";import zz from"node:os";import S from"chalk";import Jz from"yaml";import Bz from"@fnet/service";import q from"node:fs";import $ from"node:path";import F from"node:os";import B from"chalk";function n(){return $.join(F.homedir(),".fnet","bin")}function f(){return $.join(F.homedir(),".fnet","metadata")}function c(){return $.join(f(),"binaries.json")}function Lz(z){return(process.env.PATH||"").split($.delimiter).includes(z)}function m(){try{if(process.platform==="win32"){if(process.env.PSModulePath&&process.env.PSModulePath.includes("PowerShell"))return"powershell-core";if(process.env.PSModulePath)return"powershell";return"cmd"}let z=process.env.SHELL||"";if(z.includes("bash"))return"bash";if(z.includes("zsh"))return"zsh";if(z.includes("fish"))return"fish";if(z.includes("ksh"))return"ksh";if(z.includes("csh")||z.includes("tcsh"))return"csh";if(q.existsSync($.join(F.homedir(),".bashrc")))return"bash";if(q.existsSync($.join(F.homedir(),".zshrc")))return"zsh";if(q.existsSync($.join(F.homedir(),".config","fish","config.fish")))return"fish";return"unknown"}catch(z){return"unknown"}}function r(z){let J=F.homedir(),Q=[];switch(z){case"bash":Q.push({name:".bashrc",path:$.join(J,".bashrc")}),Q.push({name:".bash_profile",path:$.join(J,".bash_profile")}),Q.push({name:".profile",path:$.join(J,".profile")});break;case"zsh":Q.push({name:".zshrc",path:$.join(J,".zshrc")}),Q.push({name:".zprofile",path:$.join(J,".zprofile")});break;case"fish":Q.push({name:"config.fish",path:$.join(J,".config","fish","config.fish")});break;case"ksh":Q.push({name:".kshrc",path:$.join(J,".kshrc")}),Q.push({name:".profile",path:$.join(J,".profile")});break;case"csh":Q.push({name:".cshrc",path:$.join(J,".cshrc")}),Q.push({name:".tcshrc",path:$.join(J,".tcshrc")});break;case"powershell":Q.push({name:"Microsoft.PowerShell_profile.ps1",path:$.join(J,"Documents","WindowsPowerShell","Microsoft.PowerShell_profile.ps1")}),Q.push({name:"profile.ps1",path:$.join(J,"Documents","WindowsPowerShell","profile.ps1")});break;case"powershell-core":Q.push({name:"Microsoft.PowerShell_profile.ps1",path:$.join(J,"Documents","PowerShell","Microsoft.PowerShell_profile.ps1")}),Q.push({name:"profile.ps1",path:$.join(J,"Documents","PowerShell","profile.ps1")});break;case"cmd":Q.push({name:"fnet-path.bat",path:$.join(J,"fnet-path.bat")});break;default:break}return Q}function Oz(){let z=m(),J=r(z);for(let Q of J)if(q.existsSync(Q.path))return Q.path;return J.length>0?J[0].path:null}async function wz(){let z=n(),J=f(),Q=c();if(!q.existsSync(z))q.mkdirSync(z,{recursive:!0});if(!q.existsSync(J))q.mkdirSync(J,{recursive:!0});if(!q.existsSync(Q))q.writeFileSync(Q,JSON.stringify({binaries:{},lastUpdated:new Date().toISOString()},null,2))}function s(z,J){switch(z){case"bash":case"zsh":case"ksh":return`export PATH="${J}:$PATH"`;case"fish":return`set -gx PATH ${J} $PATH`;case"csh":return`setenv PATH ${J}:$PATH`;case"powershell":case"powershell-core":return`$env:PATH = "${J};" + $env:PATH`;case"cmd":return`@echo off
3
+ SETX PATH "%PATH%;${J}"
4
+ echo Path updated successfully`;default:return`export PATH="${J}:$PATH"`}}async function Vz(z,J,Q,K={}){try{let{autoBackup:X=!0}=K,W=s(z,Q);if(z==="cmd")return q.writeFileSync(J,W),console.log(B.yellow(`Created batch file at ${J}`)),console.log(B.yellow("Run this file to add the bin directory to your PATH")),!0;if((z==="powershell"||z==="powershell-core")&&!q.existsSync($.dirname(J)))q.mkdirSync($.dirname(J),{recursive:!0});if(!q.existsSync(J)){let R=z==="fish"?`# Fish shell configuration
5
+
6
+ `:z==="powershell"||z==="powershell-core"?`# PowerShell profile
7
+
8
+ `:`# Shell configuration
9
+
10
+ `;q.writeFileSync(J,R),console.log(B.green(`Created config file at ${J}`))}let Z=q.readFileSync(J,"utf8");if(Z.includes(Q))return!0;if(X&&q.existsSync(J)){let R=i(),w=$.basename(J);if(t(J,$.join(R,"configs"),w))a(R,{type:"auto",command:"addBinToPath",message:`Automatic backup before modifying ${w}`,files:[J]}),e(R),console.log(B.green(`✓ Backed up ${w} to ${R}`))}let _=`${Z.trim()}
11
+
12
+ # Added by @fnet/cli
13
+ ${W}
14
+ `;if(q.writeFileSync(J,_),z==="powershell"||z==="powershell-core")console.log(B.yellow("You may need to set the PowerShell execution policy to run scripts:")),console.log(B.green("Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned"));return!0}catch(X){return console.error(B.red(`Failed to add bin directory to PATH: ${X.message}`)),!1}}function u(){return $.join(F.homedir(),".fnet","backups")}function i(){let z=new Date().toISOString().replace(/:/g,"-").replace(/\..+/,""),J=$.join(u(),z);if(!q.existsSync(J))q.mkdirSync(J,{recursive:!0});return J}function t(z,J,Q=null){try{if(!q.existsSync(z))return!1;let K=Q||$.basename(z),X=$.join(J,K),W=$.dirname(X);if(!q.existsSync(W))q.mkdirSync(W,{recursive:!0});return q.copyFileSync(z,X),!0}catch(K){return console.error(B.red(`Failed to backup file ${z}: ${K.message}`)),!1}}function a(z,J={}){let Q={timestamp:new Date().toISOString(),type:J.type||"manual",message:J.message||"",command:J.command||"",files:J.files||[],...J},K=$.join(z,"metadata.json");q.writeFileSync(K,JSON.stringify(Q,null,2))}function Az(){let z=u();if(!q.existsSync(z))return[];let J=[],Q=q.readdirSync(z);for(let K of Q){let X=$.join(z,K),W=q.statSync(X);if(W.isDirectory()&&K!=="latest"){let Z=$.join(X,"metadata.json"),_={};if(q.existsSync(Z))try{_=JSON.parse(q.readFileSync(Z,"utf8"))}catch(R){}J.push({timestamp:K,path:X,created:W.mtime,..._})}}return J.sort((K,X)=>new Date(X.created)-new Date(K.created)),J}function e(z){let J=$.join(u(),"latest");try{if(q.existsSync(J))q.unlinkSync(J);if(process.platform==="win32")q.writeFileSync(J+".txt",z);else q.symlinkSync(z,J)}catch(Q){console.warn(B.yellow(`Could not create latest symlink: ${Q.message}`))}}var D={getBinDirectory:n,getMetadataDirectory:f,getMetadataFilePath:c,checkIfInPath:Lz,detectUserShell:m,getShellConfigPath:Oz,getAllShellConfigPaths:r,createBinDirectoryStructure:wz,getExportPathCommand:s,addBinToPath:Vz,getBackupDirectory:u,createBackupDirectory:i,backupFile:t,createBackupMetadata:a,listBackups:Az,updateLatestSymlink:e};function k(){return P.join(zz.homedir(),".fnet","services")}function h(){return P.join(zz.homedir(),".fnet","metadata")}function p(){return P.join(h(),"services.json")}async function Uz(){let z=k(),J=h(),Q=p();if(!H.existsSync(z))H.mkdirSync(z,{recursive:!0});if(!H.existsSync(J))H.mkdirSync(J,{recursive:!0});if(!H.existsSync(Q))H.writeFileSync(Q,JSON.stringify({services:{},lastUpdated:new Date().toISOString()},null,2))}function Kz(){let z=p();if(!H.existsSync(z))return{services:{},lastUpdated:new Date().toISOString()};try{return JSON.parse(H.readFileSync(z,"utf8"))}catch(J){return console.warn(S.yellow(`Failed to parse service metadata file: ${J.message}`)),{services:{},lastUpdated:new Date().toISOString()}}}function Qz(z){let J=p();z.lastUpdated=new Date().toISOString(),H.writeFileSync(J,JSON.stringify(z,null,2))}function N(z){return P.join(k(),`${z}.yaml`)}function xz(z){let J=N(z);return H.existsSync(J)}function Wz(z){let J=N(z);if(!H.existsSync(J))return null;try{let Q=H.readFileSync(J,"utf8");return Jz.parse(Q)}catch(Q){return console.warn(S.yellow(`Failed to parse service manifest file: ${Q.message}`)),null}}function Fz(z,J){let Q=N(z);try{let K=Jz.stringify(J);return H.writeFileSync(Q,K),!0}catch(K){return console.error(S.red(`Failed to save service manifest: ${K.message}`)),!1}}function Mz(z){let J=N(z);if(!H.existsSync(J))return!1;try{return H.unlinkSync(J),!0}catch(Q){return console.error(S.red(`Failed to delete service manifest: ${Q.message}`)),!1}}function Cz(){let z=k();if(!H.existsSync(z))return[];try{return H.readdirSync(z).filter((J)=>J.endsWith(".yaml")).map((J)=>J.replace(".yaml",""))}catch(J){return console.error(S.red(`Failed to list service definitions: ${J.message}`)),[]}}function Xz(z){let J=[];if(!z.name)J.push("Service name is required");if(!z.binary)J.push("Binary name is required");if(z.binary){let Q=D.getBinDirectory(),K=P.join(Q,z.binary);if(!H.existsSync(K))J.push(`Binary '${z.binary}' not found in bin directory`)}return{valid:J.length===0,errors:J}}async function jz(z,J={}){let Q=Wz(z);if(!Q)throw Error(`Service manifest '${z}' not found`);let K=Xz(Q);if(!K.valid)throw Error(`Invalid service manifest: ${K.errors.join(", ")}`);let X=D.getBinDirectory(),W=P.join(X,Q.binary);try{await Bz({action:"register",name:Q.name,description:Q.description||`Service for ${Q.binary}`,command:[W,...Q.args||[]],env:Q.env||{},wdir:Q.workingDir,system:Q.system!==!1,autoStart:Q.autoStart===!0,restartOnFailure:Q.restartOnFailure!==!1,user:Q.user});let Z=Kz();return Z.services[Q.name]={manifest:z,binary:Q.binary,registered:new Date().toISOString(),status:"registered"},Qz(Z),{success:!0,name:Q.name,manifest:z}}catch(Z){throw Error(`Failed to register service: ${Z.message}`)}}var Y={getServicesDirectory:k,getServiceMetadataDirectory:h,getServiceMetadataFilePath:p,createServiceDirectoryStructure:Uz,loadServiceMetadata:Kz,saveServiceMetadata:Qz,getServiceManifestPath:N,servicManifestExists:xz,loadServiceManifest:Wz,saveServiceManifest:Fz,deleteServiceManifest:Mz,listServiceManifests:Cz,validateServiceManifest:Xz,registerService:jz};async function E(z){await Y.createServiceDirectoryStructure();let J=Y.getServicesDirectory(),Q=Y.getServiceMetadataDirectory(),K=Y.loadServiceMetadata();return{servicesDir:J,metadataDir:Q,metadata:K,args:z}}import d from"node:fs";function Dz(z=!0){let J=[];if(z)try{let Q=D.getBinDirectory(),K=D.getMetadataFilePath();if(d.existsSync(K)){let X=JSON.parse(d.readFileSync(K,"utf8"));J=Object.keys(X.binaries).map((W)=>({name:W,message:`${W} (${X.binaries[W].version||"unknown"})`}))}else if(d.existsSync(Q))J=d.readdirSync(Q).map((X)=>({name:X,message:X}))}catch(Q){console.warn(`Failed to get binary choices: ${Q.message}`)}return{type:"object",required:["name","binary"],properties:{name:{type:"string",description:"Service name","x-prompt":{type:"input",message:"Enter service name:"}},binary:{type:"string",description:"Binary name in the bin directory","x-prompt":{type:"select",message:"Select binary:",choices:J}},description:{type:"string",description:"Service description","x-prompt":{type:"input",message:"Enter service description:"}},args:{type:"array",items:{type:"string"},description:"Command line arguments","x-prompt":{type:"input",message:"Enter command line arguments (space-separated):",result:(Q)=>Q?Q.split(" "):[]}},env:{type:"object",additionalProperties:{type:"string"},description:"Environment variables","x-prompt":{type:"input",message:"Enter environment variables (KEY=VALUE format, one per line):",result:(Q)=>{if(!Q)return{};return Q.split(`
15
+ `).filter((K)=>K.includes("=")).reduce((K,X)=>{let[W,...Z]=X.split("=");return K[W.trim()]=Z.join("=").trim(),K},{})}}},workingDir:{type:"string",description:"Working directory","x-prompt":{type:"input",message:"Enter working directory (optional):"}},autoStart:{type:"boolean",description:"Start on boot",default:!1,"x-prompt":{type:"confirm",message:"Start service on boot?",initial:!1}},restartOnFailure:{type:"boolean",description:"Restart on failure",default:!0,"x-prompt":{type:"confirm",message:"Restart service on failure?",initial:!0}},system:{type:"boolean",description:"System service",default:!0,"x-prompt":{type:"confirm",message:"Register as system service?",initial:!0}},user:{type:"string",description:"User to run the service as","x-prompt":{type:"input",message:"Enter user to run the service as (optional):"}},instances:{type:"integer",description:"Number of instances to run",default:1,minimum:1,"x-prompt":{type:"number",message:"Enter number of instances to run:",initial:1}},metadata:{type:"object",additionalProperties:!0,description:"Custom metadata"}}}}var v={getServiceManifestSchema:Dz};import g from"chalk";import Yz from"@fnet/prompt";async function Pz(z){let{items:J,message:Q,nameField:K="name",valueField:X="name",initialValue:W=null,allowAbort:Z=!0}=z;if(!J||J.length===0)return console.log(g.yellow("No items available for selection.")),null;if(J.length===1&&!Z){let G=J[0],b=typeof G==="string"?G:G[X];return console.log(g.blue(`Only one option available: ${typeof G==="string"?G:G[K]}`)),b}let _=J.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[X],value:G[X],message:G[K]||G[X]}});if(Z)_.push({name:"cancel",value:null,message:g.yellow("Cancel")});let R=null;if(W){let G=_.findIndex((b)=>b.name===W);if(G!==-1)R=G}let w="selectedItem",{[w]:j}=await Yz({type:"select",name:w,message:Q,choices:_,initial:R});if(j==="cancel")return null;return j}async function bz(z){let{items:J,message:Q,nameField:K="name",valueField:X="name",initialValues:W=[],allowAbort:Z=!0}=z;if(!J||J.length===0)return console.log(g.yellow("No items available for selection.")),null;let _=J.map((G)=>{if(typeof G==="string")return{name:G,value:G,message:G};else return{name:G[X],value:G[X],message:G[K]||G[X]}}),R=[];if(W&&W.length>0)R=_.map((G,b)=>W.includes(G.name)?b:-1).filter((G)=>G!==-1);let w="selectedItems",j=await Yz({type:"multiselect",name:w,message:Q,choices:_,initial:R,hint:"(Use space to select, enter to confirm)",validate:(G)=>{if(G.length===0&&!Z)return"Please select at least one item";return!0}});if(Z&&j[w].length===0)return null;return j[w]}var L={promptForSelection:Pz,promptForMultipleSelection:bz};var Sz={command:"manifest <subcommand>",describe:"Manage service manifests",builder:(z)=>{return z.command({command:"create",describe:"Create a new service manifest",builder:(J)=>{return J.option("name",{describe:"Service manifest name",type:"string"}).option("output",{describe:"Output file path",type:"string",alias:"o"})},handler:Nz}).command({command:"list",describe:"List service manifests",builder:(J)=>{return J.option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"})},handler:yz}).command({command:"show [n]",describe:"Show service manifest details",builder:(J)=>{return J.positional("name",{describe:"Service manifest name",type:"string",demandOption:!1}).option("format",{describe:"Output format",type:"string",choices:["json","yaml"],default:"yaml"})},handler:uz}).command({command:"edit [n]",describe:"Edit a service manifest",builder:(J)=>{return J.positional("name",{describe:"Service manifest name",type:"string",demandOption:!1})},handler:kz}).command({command:"delete [n]",describe:"Delete a service manifest",builder:(J)=>{return J.positional("name",{describe:"Service manifest name",type:"string",demandOption:!1}).option("force",{describe:"Force deletion without confirmation",type:"boolean",default:!1,alias:"f"})},handler:pz}).command({command:"validate [n]",describe:"Validate a service manifest",builder:(J)=>{return J.positional("name",{describe:"Service manifest name",type:"string",demandOption:!1})},handler:dz}).demandCommand(1,"You need to specify a subcommand")},handler:()=>{}};async function Nz(z){try{let J=await E(z),Q=v.getServiceManifestSchema(),K=await Zz({schema:Q,format:"yaml"});console.log("Result from fnetObjectFromSchema:",K);let X;if(typeof K==="string")try{X=(await import("yaml")).default.parse(K)}catch(_){console.warn(T.yellow(`Failed to parse YAML: ${_.message}`)),X={name:"service-"+Date.now()}}else if(K&&typeof K==="object")X=K.data||K;else X={name:"service-"+Date.now()};console.log("Generated manifest:",X);let W=z.name||(X&&X.name?X.name:"service-"+Date.now());if(Y.servicManifestExists(W)&&!z.force){let{confirmOverwrite:_}=await _z({type:"confirm",name:"confirmOverwrite",message:`Service manifest '${W}' already exists. Overwrite?`,initial:!1});if(!_){console.log(T.yellow("Operation cancelled."));return}}if(Y.saveServiceManifest(W,X))console.log(T.green(`Service manifest '${W}' created successfully.`)),console.log(T.blue(`Location: ${Y.getServiceManifestPath(W)}`));else console.error(T.red(`Failed to create service manifest '${W}'.`))}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}async function yz(z){try{let J=await E(z),Q=Y.listServiceManifests();if(Q.length===0){console.log(T.yellow("No service manifests found."));return}if(z.format==="json")console.log(JSON.stringify(Q,null,2));else if(z.format==="text")Q.forEach((K)=>console.log(K));else{console.log(T.bold(`
16
+ Service Definitions:`));let K=(await import("./index.q01yvaz0.js")).default,X=["NAME","BINARY","DESCRIPTION"],W=K.createTable(X,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let Z of Q){let _=Y.loadServiceManifest(Z);if(_)W.push([T.white(Z),T.cyan(_.binary||"undefined"),_.description||""])}console.log(W.toString()),console.log(`Total: ${Q.length} manifest(s)`)}}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}async function uz(z){try{let J=await E(z);if(!z.name){let K=Y.listServiceManifests();if(K.length===0){console.log(T.yellow("No service manifests found."));return}let X=await L.promptForSelection({items:K,message:"Select a service manifest to show:",allowAbort:!0});if(X===null){console.log(T.yellow("Operation cancelled."));return}z.name=X}let Q=Y.loadServiceManifest(z.name);if(!Q)console.error(T.red(`Service manifest '${z.name}' not found.`)),process.exit(1);if(z.format==="json")console.log(JSON.stringify(Q,null,2));else{let K=(await import("yaml")).default;console.log(K.stringify(Q))}}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}async function kz(z){try{let J=await E(z);if(!z.name){let _=Y.listServiceManifests();if(_.length===0){console.log(T.yellow("No service manifests found."));return}let R=await L.promptForSelection({items:_,message:"Select a service manifest to edit:",allowAbort:!0});if(R===null){console.log(T.yellow("Operation cancelled."));return}z.name=R}let Q=Y.loadServiceManifest(z.name);if(!Q)console.error(T.red(`Service manifest '${z.name}' not found.`)),process.exit(1);let K=v.getServiceManifestSchema(),W=(await Zz({schema:K,ref:Q,format:"yaml"})).data;if(Y.saveServiceManifest(z.name,W))console.log(T.green(`Service manifest '${z.name}' updated successfully.`));else console.error(T.red(`Failed to update service manifest '${z.name}'.`))}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}async function pz(z){try{let J=await E(z);if(!z.name){let K=Y.listServiceManifests();if(K.length===0){console.log(T.yellow("No service manifests found."));return}let X=await L.promptForSelection({items:K,message:"Select a service manifest to delete:",allowAbort:!0});if(X===null){console.log(T.yellow("Operation cancelled."));return}z.name=X}if(!Y.servicManifestExists(z.name))console.error(T.red(`Service manifest '${z.name}' not found.`)),process.exit(1);if(!z.force){let{confirmDelete:K}=await _z({type:"confirm",name:"confirmDelete",message:`Are you sure you want to delete service manifest '${z.name}'?`,initial:!1});if(!K){console.log(T.yellow("Operation cancelled."));return}}if(Y.deleteServiceManifest(z.name))console.log(T.green(`Service manifest '${z.name}' deleted successfully.`));else console.error(T.red(`Failed to delete service manifest '${z.name}'.`))}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}async function dz(z){try{let J=await E(z);if(!z.name){let X=Y.listServiceManifests();if(X.length===0){console.log(T.yellow("No service manifests found."));return}let W=await L.promptForSelection({items:X,message:"Select a service manifest to validate:",allowAbort:!0});if(W===null){console.log(T.yellow("Operation cancelled."));return}z.name=W}let Q=Y.loadServiceManifest(z.name);if(!Q)console.error(T.red(`Service manifest '${z.name}' not found.`)),process.exit(1);let K=Y.validateServiceManifest(Q);if(K.valid)console.log(T.green(`Service manifest '${z.name}' is valid.`));else console.error(T.red(`Service manifest '${z.name}' is invalid:`)),K.errors.forEach((X)=>{console.error(T.red(`- ${X}`))}),process.exit(1)}catch(J){console.error(T.red(`Error: ${J.message}`)),process.exit(1)}}var $z=Sz;import U from"chalk";var gz={command:"register",describe:"Register a service manifest as a system service",builder:(z)=>{return z.option("manifest",{describe:"Service manifest name",type:"string",demandOption:!1,alias:"d"}).option("start",{describe:"Start the service after registration",type:"boolean",default:!1})},handler:async(z)=>{try{let J=await E(z),Q=z.manifest;if(!Q){let X=Y.listServiceManifests();if(X.length===0)console.log(U.yellow('No service manifests found. Create one first using "fservice manifest create".')),process.exit(1);if(Q=await L.promptForSelection({items:X,message:"Select a service manifest to register:",allowAbort:!0}),!Q){console.log(U.yellow("Operation cancelled."));return}}if(!Y.servicManifestExists(Q))console.error(U.red(`Service manifest '${Q}' not found.`)),process.exit(1);console.log(U.blue(`Registering service from manifest '${Q}'...`));let K=await Y.registerService(Q);if(console.log(U.green(`Service '${K.name}' registered successfully.`)),z.start){console.log(U.blue(`Starting service '${K.name}'...`));let X=(await import("@fnet/service")).default;try{await X({action:"start",name:K.name}),console.log(U.green(`Service '${K.name}' started successfully.`));let W=Y.loadServiceMetadata();if(W.services[K.name])W.services[K.name].status="running",W.services[K.name].lastStarted=new Date().toISOString(),Y.saveServiceMetadata(W)}catch(W){console.error(U.red(`Failed to start service: ${W.message}`))}}}catch(J){console.error(U.red(`Error: ${J.message}`)),process.exit(1)}}},Tz=gz;import O from"chalk";import fz from"@fnet/prompt";var hz={command:"unregister",describe:"Unregister a service from the system",builder:(z)=>{return z.option("name",{describe:"Service name",type:"string",demandOption:!1,alias:"n"}).option("keep-manifest",{describe:"Keep the service manifest",type:"boolean",default:!0}).option("force",{describe:"Force unregistration without confirmation",type:"boolean",default:!1,alias:"f"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=z.name;if(!K){let W=Object.keys(Q.services);if(W.length===0)console.log(O.yellow("No registered services found.")),process.exit(1);if(K=await L.promptForSelection({items:W,message:"Select a service to unregister:",allowAbort:!0}),!K){console.log(O.yellow("Operation cancelled."));return}}if(!Q.services[K])console.error(O.red(`Service '${K}' not found in metadata.`)),process.exit(1);if(!z.force){let{confirmUnregister:W}=await fz({type:"confirm",name:"confirmUnregister",message:`Are you sure you want to unregister service '${K}'?`,initial:!1});if(!W){console.log(O.yellow("Operation cancelled."));return}}console.log(O.blue(`Unregistering service '${K}'...`));let X=(await import("@fnet/service")).default;try{let W=Q.services[K].manifest,Z=Y.loadServiceManifest(W);if(!Z)throw Error(`Service manifest '${W}' not found`);let _=Z.system!==!1;try{await X({action:"stop",name:K,system:_}),console.log(O.blue(`Service '${K}' stopped.`))}catch(R){console.warn(O.yellow(`Warning: Failed to stop service: ${R.message}`))}if(await X({action:"unregister",name:K,system:_}),console.log(O.green(`Service '${K}' unregistered successfully.`)),delete Q.services[K],Y.saveServiceMetadata(Q),!z.keepDefinition&&W){if(Y.servicManifestExists(W))if(Y.deleteServiceManifest(W))console.log(O.green(`Service manifest '${W}' deleted.`));else console.warn(O.yellow(`Warning: Failed to delete service manifest '${W}'.`))}}catch(W){console.error(O.red(`Failed to unregister service: ${W.message}`)),process.exit(1)}}catch(J){console.error(O.red(`Error: ${J.message}`)),process.exit(1)}}},qz=hz;import M from"chalk";var vz={command:"start",describe:"Start a registered service",builder:(z)=>{return z.option("name",{describe:"Service name",type:"string",demandOption:!1,alias:"n"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=z.name;if(!K){let W=Object.keys(Q.services);if(W.length===0)console.log(M.yellow("No registered services found.")),process.exit(1);if(K=await L.promptForSelection({items:W,message:"Select a service to start:",allowAbort:!0}),!K){console.log(M.yellow("Operation cancelled."));return}}if(!Q.services[K])console.error(M.red(`Service '${K}' not found in metadata.`)),process.exit(1);console.log(M.blue(`Starting service '${K}'...`));let X=(await import("@fnet/service")).default;try{let W=Q.services[K].manifest,Z=Y.loadServiceManifest(W);if(!Z)throw Error(`Service manifest '${W}' not found`);await X({action:"start",name:K,system:Z.system!==!1}),console.log(M.green(`Service '${K}' started successfully.`)),Q.services[K].status="running",Q.services[K].lastStarted=new Date().toISOString(),Y.saveServiceMetadata(Q)}catch(W){console.error(M.red(`Failed to start service: ${W.message}`)),process.exit(1)}}catch(J){console.error(M.red(`Error: ${J.message}`)),process.exit(1)}}},Gz=vz;import C from"chalk";var oz={command:"stop",describe:"Stop a running service",builder:(z)=>{return z.option("name",{describe:"Service name",type:"string",demandOption:!1,alias:"n"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=z.name;if(!K){let W=Object.keys(Q.services);if(W.length===0)console.log(C.yellow("No registered services found.")),process.exit(1);if(K=await L.promptForSelection({items:W,message:"Select a service to stop:",allowAbort:!0}),!K){console.log(C.yellow("Operation cancelled."));return}}if(!Q.services[K])console.error(C.red(`Service '${K}' not found in metadata.`)),process.exit(1);console.log(C.blue(`Stopping service '${K}'...`));let X=(await import("@fnet/service")).default;try{let W=Q.services[K].manifest,Z=Y.loadServiceManifest(W);if(!Z)throw Error(`Service manifest '${W}' not found`);await X({action:"stop",name:K,system:Z.system!==!1}),console.log(C.green(`Service '${K}' stopped successfully.`)),Q.services[K].status="stopped",Q.services[K].lastStopped=new Date().toISOString(),Y.saveServiceMetadata(Q)}catch(W){console.error(C.red(`Failed to stop service: ${W.message}`)),process.exit(1)}}catch(J){console.error(C.red(`Error: ${J.message}`)),process.exit(1)}}},Ez=oz;import x from"chalk";var lz={command:"restart",describe:"Restart a service",builder:(z)=>{return z.option("name",{describe:"Service name",type:"string",demandOption:!1,alias:"n"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=z.name;if(!K){let W=Object.keys(Q.services);if(W.length===0)console.log(x.yellow("No registered services found.")),process.exit(1);if(K=await L.promptForSelection({items:W,message:"Select a service to restart:",allowAbort:!0}),!K){console.log(x.yellow("Operation cancelled."));return}}if(!Q.services[K])console.error(x.red(`Service '${K}' not found in metadata.`)),process.exit(1);console.log(x.blue(`Restarting service '${K}'...`));let X=(await import("@fnet/service")).default;try{await X({action:"stop",name:K}),console.log(x.blue(`Service '${K}' stopped.`)),await X({action:"start",name:K}),console.log(x.green(`Service '${K}' restarted successfully.`)),Q.services[K].status="running",Q.services[K].lastRestarted=new Date().toISOString(),Y.saveServiceMetadata(Q)}catch(W){console.error(x.red(`Failed to restart service: ${W.message}`)),process.exit(1)}}catch(J){console.error(x.red(`Error: ${J.message}`)),process.exit(1)}}},Rz=lz;import I from"chalk";var nz={command:"status",describe:"Check the status of a service",builder:(z)=>{return z.option("name",{describe:"Service name",type:"string",demandOption:!1,alias:"n"}).option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=z.name;if(!K){let W=Object.keys(Q.services);if(W.length===0)console.log(I.yellow("No registered services found.")),process.exit(1);if(K=await L.promptForSelection({items:W,message:"Select a service to check status:",allowAbort:!0}),!K){console.log(I.yellow("Operation cancelled."));return}}if(!Q.services[K])console.error(I.red(`Service '${K}' not found in metadata.`)),process.exit(1);console.log(I.blue(`Checking status of service '${K}'...`));let X=(await import("@fnet/service")).default;try{let W=Q.services[K].manifest,Z=Y.loadServiceManifest(W);if(!Z)throw Error(`Service manifest '${W}' not found`);let _=await X({action:"status",name:K,system:Z.system!==!1});if(console.log(I.green(`Service '${K}' status: ${_}`)),Q.services[K].status=_||"unknown",Q.services[K].lastChecked=new Date().toISOString(),Y.saveServiceMetadata(Q),z.format==="json")console.log(JSON.stringify({name:K,status:_||"unknown",manifest:W,binary:Q.services[K].binary},null,2));else if(z.format==="text")console.log(`Name: ${K}`),console.log(`Status: ${_||"unknown"}`),console.log(`Definition: ${W}`),console.log(`Binary: ${Q.services[K].binary}`);else console.log(I.bold(`
17
+ Service Status:`)),console.log(I.bold("─".repeat(50))),console.log(`${I.bold("Name:")} ${K}`),console.log(`${I.bold("Status:")} ${cz(_)(_||"unknown")}`),console.log(`${I.bold("Definition:")} ${W}`),console.log(`${I.bold("Binary:")} ${Q.services[K].binary}`),console.log(I.bold("─".repeat(50)))}catch(W){console.error(I.red(`Failed to check service status: ${W.message}`)),process.exit(1)}}catch(J){console.error(I.red(`Error: ${J.message}`)),process.exit(1)}}};function cz(z){switch(z){case"running":return I.green;case"stopped":return I.yellow;case"failed":return I.red;default:return I.gray}}var Hz=nz;import y from"chalk";var mz={command:"list",describe:"List all registered services",builder:(z)=>{return z.option("binary",{describe:"Filter by binary name",type:"string",alias:"b"}).option("status",{describe:"Filter by status",type:"string",choices:["running","stopped","failed","unknown"],alias:"s"}).option("format",{describe:"Output format",type:"string",choices:["json","text","table"],default:"table"})},handler:async(z)=>{try{let J=await E(z),Q=Y.loadServiceMetadata(),K=Object.entries(Q.services).map(([X,W])=>({name:X,...W}));if(z.binary)K=K.filter((X)=>X.binary===z.binary);if(z.status)K=K.filter((X)=>X.status===z.status);if(K.length===0){console.log(y.yellow("No services found."));return}if(z.format==="json")console.log(JSON.stringify(K,null,2));else if(z.format==="text")K.forEach((X)=>{console.log(`${X.name} (${X.status||"unknown"})`)});else{let X=["NAME","STATUS","BINARY","DEFINITION"],W=o.createTable(X,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});K.forEach((Z)=>{let _=o.getStatusColor(Z.status);W.push([y.white(Z.name),_(Z.status||"unknown"),y.cyan(Z.binary),Z.manifest])}),console.log(y.bold(`
18
+ Registered Services:`)),console.log(W.toString()),console.log(`Total: ${K.length} service(s)`)}}catch(J){console.error(y.red(`Error: ${J.message}`)),process.exit(1)}}},Iz=mz;import{createRequire as iz}from"module";var tz=iz(import.meta.url),{version:az}=tz("../../package.json"),BK=rz(sz(process.argv)).scriptName("fservice").usage("Usage: $0 <command> [options]").version(az).command($z).command(Tz).command(qz).command(Gz).command(Ez).command(Rz).command(Hz).command(Iz).demandCommand(1,"You need to specify a command").strict().help().alias("h","help").alias("v","version").fail((z,J,Q)=>{if(J)console.error(l.red(`Error: ${J.message}`)),console.error(J);else console.error(l.red(`Error: ${z}`));console.error(l.yellow(`
19
+ Usage:`),Q.help()),process.exit(1)}).parse();
@@ -0,0 +1,2 @@
1
+ import{createRequire as L}from"node:module";var H=Object.create;var{getPrototypeOf:I,defineProperty:B,getOwnPropertyNames:J}=Object;var K=Object.prototype.hasOwnProperty;var Q=(j,y,z)=>{z=j!=null?H(I(j)):{};let q=y||!j||!j.__esModule?B(z,"default",{value:j,enumerable:!0}):z;for(let x of J(j))if(!K.call(q,x))B(q,x,{get:()=>j[x],enumerable:!0});return q};var U=L(import.meta.url);import M from"cli-table3";import A from"chalk";function E(j,y={}){let q={...{chars:{top:"─","top-mid":"─","top-left":" ","top-right":" ",bottom:"─","bottom-mid":"─","bottom-left":" ","bottom-right":" ",left:" ","left-mid":" ",mid:"─","mid-mid":"─",right:" ","right-mid":" ",middle:" "},style:{head:[],border:[],compact:!0},wordWrap:!0},...y,head:j.map((x)=>A.bold(x))};return new M(q)}function N(j,y,z={}){let q=E(j,z);if(Array.isArray(y))y.forEach((x)=>{q.push(x)});return q.toString()}function P(j){switch(j){case"running":return A.green;case"stopped":return A.yellow;case"failed":return A.red;case"registered":return A.blue;default:return A.gray}}var Z={createTable:E,createTableWithData:N,getStatusColor:P};export{P as getStatusColor,Z as default,N as createTableWithData,E as createTable};
2
+ export{Q as a,U as b,Z as c};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnet/cli",
3
- "version": "0.133.0",
3
+ "version": "0.133.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "template"
@@ -8,10 +8,13 @@
8
8
  "type": "module",
9
9
  "description": "CLI for Flownet",
10
10
  "scripts": {
11
- "build": "rollup --config",
12
- "build:dev": "rollup --config --sourcemap --environment DEVELOPMENT",
11
+ "build": "bun run build.js",
12
+ "build:dev": "DEVELOPMENT=1 bun run build.js",
13
+ "watch": "DEVELOPMENT=1 bun run build.js --watch",
13
14
  "deploy": "bun publish --access public",
14
- "watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT"
15
+ "old:build": "rollup --config",
16
+ "old:build:dev": "rollup --config --sourcemap --environment DEVELOPMENT",
17
+ "old:watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT --environment FLOWNET_WATCH"
15
18
  },
16
19
  "repository": {
17
20
  "type": "git",
@@ -21,7 +24,7 @@
21
24
  "dependencies": {
22
25
  "@flownet/lib-atom-api-js": "^0.2.3",
23
26
  "@flownet/lib-is-redis-online": "^0.1.15",
24
- "@flownet/lib-parse-imports-js": "^0.4.3",
27
+ "@flownet/lib-parse-imports-js": "^0.4.4",
25
28
  "@flownet/lib-parse-node-url": "^0.1.18",
26
29
  "@flownet/lib-render-templates-dir": "^0.1.19",
27
30
  "@flownet/lib-to-docker": "^0.3.26",
@@ -30,10 +33,9 @@
30
33
  "@flownet/lib-to-macos-app": "^0.3.13",
31
34
  "@flownet/lib-to-nextjs": "^0.3.10",
32
35
  "@flownet/lib-to-webos": "^0.3.16",
33
- "@fnet/auto-conda-env": "^0.1.24",
34
- "@fnet/config": "^0.2.28",
36
+ "@fnet/auto-conda-env": "^0.2.1",
37
+ "@fnet/config": "^0.2.29",
35
38
  "@fnet/dir-zipper": "^0.1.8",
36
- "@fnet/expression": "^0.1.30",
37
39
  "@fnet/files-to-gcs": "^0.3.12",
38
40
  "@fnet/key-value-transformer": "^0.1.4",
39
41
  "@fnet/npm-list-versions": "^0.1.35",
@@ -41,14 +43,14 @@
41
43
  "@fnet/object-from-schema": "^0.1.25",
42
44
  "@fnet/prompt": "^0.2.16",
43
45
  "@fnet/rollup-plugin-delete": "^0.1.10",
44
- "@fnet/service": "^0.1.7",
45
- "@fnet/shell-flow": "^0.1.52",
46
+ "@fnet/service": "^0.1.8",
47
+ "@fnet/shell-flow": "^0.2.8",
46
48
  "@fnet/shelljs": "^0.2.4",
47
- "@fnet/to-pyip": "^0.1.7",
49
+ "@fnet/to-pyip": "^0.2.1",
48
50
  "@fnet/to-rust": "^0.1.14",
49
51
  "@fnet/up-list-files": "^0.1.14",
50
- "@fnet/yaml": "^0.1.42",
51
- "@node-red/util": "^4.1.0",
52
+ "@fnet/yaml": "^0.1.45",
53
+ "@node-red/util": "^4.1.1",
52
54
  "ajv": "^8.17.1",
53
55
  "ajv-formats": "^3.0.1",
54
56
  "bpmn-moddle": "^9.0.4",
@@ -63,13 +65,14 @@
63
65
  "nunjucks": "^3.2.4",
64
66
  "object-hash": "^3.0.0",
65
67
  "prettier": "^3.6.2",
66
- "redis": "^4.7.1",
67
68
  "semver": "^7.7.3",
68
69
  "set-value": "^4.1.0",
69
70
  "tree-kill": "^1.2.2",
70
71
  "typescript": "^5.9.3",
72
+ "winston": "^3.18.3",
71
73
  "yaml": "^2.8.1",
72
- "yargs": "^17.7.2"
74
+ "yargs": "^18.0.0",
75
+ "rollup": "^4.52.5"
73
76
  },
74
77
  "bin": {
75
78
  "fnet": "dist/fnet/index.js",
@@ -79,11 +82,11 @@
79
82
  "fservice": "dist/fservice/index.js"
80
83
  },
81
84
  "devDependencies": {
82
- "@rollup/plugin-commonjs": "^28.0.6",
85
+ "@rollup/plugin-commonjs": "^28.0.8",
83
86
  "@rollup/plugin-json": "^6.1.0",
84
- "@rollup/plugin-node-resolve": "^16.0.2",
87
+ "@rollup/plugin-node-resolve": "^16.0.3",
85
88
  "@rollup/plugin-replace": "^6.0.2",
86
89
  "@rollup/plugin-terser": "^0.4.4",
87
- "rollup": "^4.52.4"
90
+ "peggy": "^5.0.6"
88
91
  }
89
92
  }