@fnet/cli 0.4.26 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/fbin/index.js +15 -0
  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 +20 -0
  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 +10 -0
  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 +2 -0
  51. package/dist/fservice/index.js +19 -0
  52. package/dist/fservice/index.q01yvaz0.js +2 -0
  53. package/package.json +74 -57
  54. package/readme.md +298 -0
  55. package/template/fnet/core/assert.js +6 -0
  56. package/template/fnet/core/message.js +3 -0
  57. package/template/fnet/core/object.js +47 -0
  58. package/template/fnet/core/sleep.js +5 -0
  59. package/template/fnet/node/.gitignore.njk +9 -0
  60. package/template/fnet/node/build.js.njk +153 -0
  61. package/template/fnet/node/package.json.njk +121 -0
  62. package/template/fnet/node/readme.md.njk +21 -0
  63. package/template/fnet/node/rollup.config.mjs.njk +498 -0
  64. package/template/fnet/node/src/app/index.html.njk +67 -0
  65. package/template/fnet/node/src/app/index.js.njk +36 -0
  66. package/template/fnet/node/src/cli/index.js.njk +9 -0
  67. package/template/fnet/node/src/cli/index.js.v1.njk +318 -0
  68. package/template/fnet/node/src/cli/v2/core/args-parser.njk +10 -0
  69. package/template/fnet/node/src/cli/v2/core/imports.njk +31 -0
  70. package/template/fnet/node/src/cli/v2/core/run-wrapper.njk +25 -0
  71. package/template/fnet/node/src/cli/v2/index.js.njk +184 -0
  72. package/template/fnet/node/src/cli/v2/modes/default/extend.njk +11 -0
  73. package/template/fnet/node/src/cli/v2/modes/default/standard.njk +20 -0
  74. package/template/fnet/node/src/cli/v2/modes/http/builtin.njk +66 -0
  75. package/template/fnet/node/src/cli/v2/modes/http/imports.njk +9 -0
  76. package/template/fnet/node/src/cli/v2/modes/http/index.njk +12 -0
  77. package/template/fnet/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  78. package/template/fnet/node/src/cli/v2/modes/mcp/index.njk +30 -0
  79. package/template/fnet/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  80. package/template/fnet/node/src/cli/v2/modes/mcp/tool-handlers.njk +46 -0
  81. package/template/fnet/node/src/cli/v2/modes/mcp/transport-http.njk +222 -0
  82. package/template/fnet/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  83. package/template/fnet/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  84. package/template/fnet/node/src/cli/v2/modes/pipeline/index.njk +113 -0
  85. package/template/fnet/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  86. package/template/fnet/node/src/cli/v2/modes/webhook/index.njk +127 -0
  87. package/template/fnet/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  88. package/template/fnet/node/src/cli/v2/modes/websocket/index.njk +104 -0
  89. package/template/fnet/node/src/default/blocks/assign.js.njk +15 -0
  90. package/template/fnet/node/src/default/blocks/call.js.njk +110 -0
  91. package/template/fnet/node/src/default/blocks/for.js.njk +71 -0
  92. package/template/fnet/node/src/default/blocks/form.js.njk +31 -0
  93. package/template/fnet/node/src/default/blocks/http.js.njk +135 -0
  94. package/template/fnet/node/src/default/blocks/modules.js.njk +15 -0
  95. package/template/fnet/node/src/default/blocks/new.js.njk +42 -0
  96. package/template/fnet/node/src/default/blocks/next.js.njk +15 -0
  97. package/template/fnet/node/src/default/blocks/output.js.njk +15 -0
  98. package/template/fnet/node/src/default/blocks/parallel.js.njk +64 -0
  99. package/template/fnet/node/src/default/blocks/pipeline.js.njk +109 -0
  100. package/template/fnet/node/src/default/blocks/raise.js.njk +15 -0
  101. package/template/fnet/node/src/default/blocks/retry.js.njk +70 -0
  102. package/template/fnet/node/src/default/blocks/return.js.njk +21 -0
  103. package/template/fnet/node/src/default/blocks/schedule.js.njk +66 -0
  104. package/template/fnet/node/src/default/blocks/signal.js.njk +15 -0
  105. package/template/fnet/node/src/default/blocks/steps.js.njk +47 -0
  106. package/template/fnet/node/src/default/blocks/switch.js.njk +49 -0
  107. package/template/fnet/node/src/default/blocks/tryexcept.js.njk +80 -0
  108. package/template/fnet/node/src/default/blocks/wait.js.njk +14 -0
  109. package/template/fnet/node/src/default/engine.js.njk +79 -0
  110. package/template/fnet/node/src/default/input.args.js.njk +125 -0
  111. package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
  112. package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
  113. package/template/fnet/node/src/default/macros/block-entry-args.js.njk +2 -0
  114. package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
  115. package/template/fnet/node/src/default/macros/block-header.js.njk +11 -0
  116. package/template/fnet/node/src/default/macros/block-library-header.js.njk +43 -0
  117. package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
  118. package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
  119. package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
  120. package/template/fnet/node/src/default/macros/block-next.js.njk +21 -0
  121. package/template/fnet/node/src/default/macros/block-run-footer.js.njk +7 -0
  122. package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
  123. package/template/fnet/node/src/default/macros/block-run-header.js.njk +43 -0
  124. package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -0
  125. package/template/fnet/node/src/default/macros/page.js.njk +8 -0
  126. package/template/fnet/node/src/default/types/block.js.njk +133 -0
  127. package/template/fnet/node/src/default/workflow.js.njk +125 -0
  128. package/template/fnet/node/tsconfig.json.njk +16 -0
  129. package/template/fnet/project/.gitignore.njk +7 -0
  130. package/template/fnet/project/.vscode/launch.json.njk +41 -0
  131. package/template/fnet/project/.vscode/tasks.json.njk +46 -0
  132. package/template/fnet/project/fnet/flows.yaml.njk +4 -0
  133. package/template/fnet/project/fnet/targets.yaml.njk +7 -0
  134. package/template/fnet/project/fnet.yaml.njk +3 -0
  135. package/template/fnode/node/.gitignore.njk +9 -0
  136. package/template/fnode/node/build.js.njk +149 -0
  137. package/template/fnode/node/package.json.njk +121 -0
  138. package/template/fnode/node/readme.md.njk +21 -0
  139. package/template/fnode/node/rollup.config.mjs.njk +498 -0
  140. package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
  141. package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
  142. package/template/fnode/node/src/app/index.html.njk +67 -0
  143. package/template/fnode/node/src/app/index.js.njk +9 -0
  144. package/template/fnode/node/src/cli/index.js.njk +9 -0
  145. package/template/fnode/node/src/cli/index.js.v1.njk +464 -0
  146. package/template/fnode/node/src/cli/v2/core/args-parser.njk +10 -0
  147. package/template/fnode/node/src/cli/v2/core/imports.njk +29 -0
  148. package/template/fnode/node/src/cli/v2/core/run-wrapper.njk +25 -0
  149. package/template/fnode/node/src/cli/v2/index.js.njk +184 -0
  150. package/template/fnode/node/src/cli/v2/modes/default/extend.njk +11 -0
  151. package/template/fnode/node/src/cli/v2/modes/default/standard.njk +19 -0
  152. package/template/fnode/node/src/cli/v2/modes/http/builtin.njk +61 -0
  153. package/template/fnode/node/src/cli/v2/modes/http/imports.njk +9 -0
  154. package/template/fnode/node/src/cli/v2/modes/http/index.njk +12 -0
  155. package/template/fnode/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  156. package/template/fnode/node/src/cli/v2/modes/mcp/index.njk +30 -0
  157. package/template/fnode/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  158. package/template/fnode/node/src/cli/v2/modes/mcp/tool-handlers.njk +41 -0
  159. package/template/fnode/node/src/cli/v2/modes/mcp/transport-http.njk +212 -0
  160. package/template/fnode/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  161. package/template/fnode/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  162. package/template/fnode/node/src/cli/v2/modes/pipeline/index.njk +103 -0
  163. package/template/fnode/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  164. package/template/fnode/node/src/cli/v2/modes/webhook/index.njk +122 -0
  165. package/template/fnode/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  166. package/template/fnode/node/src/cli/v2/modes/websocket/index.njk +99 -0
  167. package/template/fnode/node/src/default/engine.js.njk +17 -0
  168. package/template/fnode/node/src/default/input.args.js.njk +126 -0
  169. package/template/fnode/node/tsconfig.json.njk +16 -0
  170. package/template/fnode/project/.gitignore.njk +11 -0
  171. package/template/fnode/project/.vscode/launch.json.njk +78 -0
  172. package/template/fnode/project/.vscode/tasks.json.njk +46 -0
  173. package/template/fnode/project/fnet/targets.yaml.njk +25 -0
  174. package/template/fnode/project/fnode.yaml.njk +12 -0
  175. package/template/fnode/python/.gitignore.njk +7 -0
  176. package/template/fnode/python/package.json.njk +4 -0
  177. package/template/fnode/python/pyproject.toml.njk +3 -0
  178. package/template/fnode/python/readme.md.njk +12 -0
  179. package/template/fnode/python/setup.py.njk +19 -0
  180. package/template/fnode/python/src/cli/index.py.njk +25 -0
  181. package/template/schemas/to-npm.yaml +14 -0
  182. package/dist/builder/lib-cli.js +0 -2
  183. package/dist/builder/wf-cli.js +0 -2
  184. package/dist/index.js +0 -2
@@ -0,0 +1 @@
1
+ import"./index.r19p3bpa.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};
@@ -0,0 +1 @@
1
+ import"./index.r19p3bpa.js";import d from"@fnet/config";import l from"@flownet/lib-to-docker";import a from"lodash.clonedeep";import u from"semver";async function y({atom:r,target:e,onProgress:s,projectDir:o,dependencies:c,context:t,yamlTarget:f}){if(s)await s({message:"Deploying it as docker package."});let p=e?.config?await d({name:e.config,dir:o,optional:!0,transferEnv:!1,tags:t.tags}):void 0,n=u.inc(e.version||"0.1.0","patch");e.params.version=n,e.version=n,f.set("version",n);let i=a(e.params);i.dependencies=a(c);let m={atom:r,params:i,config:p?.config,src:o,dest:o};return{deployer:await l(m)}}export{y as default};
@@ -0,0 +1 @@
1
+ import"./index.r19p3bpa.js";import d from"@fnet/config";import l from"@flownet/lib-to-macos-app";import i from"lodash.clonedeep";import u from"semver";async function g({atom:p,target:e,onProgress:s,projectDir:n,dependencies:c,context:r,yamlTarget:t}){if(s)await s({message:"Deploying it as macos-app package."});let f=e?.config?await d({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:r.tags}):void 0,o=u.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,t.set("version",o);let a=i(e.params);a.dependencies=i(c);let m={atom:p,params:a,config:f?.config,src:n,dest:n};return{deployer:await l(m)}}export{g as default};
@@ -0,0 +1 @@
1
+ import"./index.r19p3bpa.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,2 @@
1
+ import{existsSync as c}from"node:fs";import{delimiter as f,join as i}from"node:path";var m=(t)=>{let r=process.env.PATH||"",s=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT;.COM").split(";"):[""],n=r.split(f);for(let p of n)for(let e of s){let o=i(p,process.platform==="win32"?t+e:t);if(c(o))return o}return null};
2
+ export{m as f};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import l from"@fnet/config";import d from"@fnet/to-rust";import a from"lodash.clonedeep";import u from"semver";async function y({atom:t,target:e,onProgress:s,projectDir:n,dependencies:r,context:f,yamlTarget:c}){if(s)await s({message:"Deploying it as Rust package."});let p=e?.config?await l({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:f.tags}):void 0,o=u.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,c.set("version",o);let i=a(e.params);i.dependencies=a(r);let m={atom:t,params:i,config:p?.config,src:n,dest:n};return{deployer:await d(m)}}export{y as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import C from"fs";import H from"path";import K from"@fnet/yaml";import L from"@fnet/shell-flow";async function U({projectType:B,group:A,tags:q,args:x,argv:I}){try{let z=await M(B),{parsed:J}=await K({file:z.path,tags:q}),D=J.commands;if(!D)throw Error(`Commands section not found in ${z.name}`);let E=D[A];if(!E)throw Error(`Command group '${A}' not found in ${z.name}`);await L({commands:E,context:{args:x,argv:I,projectType:z.type}})}catch(z){console.error(`Error: ${z.message}`),process.exit(1)}}async function M(B){let A=process.cwd(),q=H.resolve(A,"fnode.yaml"),x=H.resolve(A,"fnet.yaml");if(B==="fnode"){if(C.existsSync(q))return{path:q,name:"fnode.yaml",type:"fnode"};throw Error("fnode.yaml file not found in current directory")}if(B==="fnet"){if(C.existsSync(x))return{path:x,name:"fnet.yaml",type:"fnet"};throw Error("fnet.yaml file not found in current directory")}if(C.existsSync(q))return{path:q,name:"fnode.yaml",type:"fnode"};if(C.existsSync(x))return{path:x,name:"fnet.yaml",type:"fnet"};throw Error("No project file (fnode.yaml or fnet.yaml) found in current directory")}export{U as runCommandGroup,M as detectProjectFile};
@@ -0,0 +1,2 @@
1
+ import j from"node:path";import x from"node:fs";import{fileURLToPath as y}from"node:url";var z=j.dirname(y(import.meta.url)),A=process.cwd();function B(b){let q=j.resolve(A,b);if(x.existsSync(q))return q;let v=j.resolve(z,"../..",b);if(x.existsSync(v))return v;throw Error(`Template path not found: ${b}`)}
2
+ export{B as e};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import d from"@fnet/config";import l from"@flownet/lib-to-ios-app";import a from"lodash.clonedeep";import u from"semver";async function g({atom:p,target:e,onProgress:s,projectDir:n,dependencies:r,context:t,yamlTarget:f}){if(s)await s({message:"Deploying it as ios-app package."});let c=e?.config?await d({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:t.tags}):void 0,o=u.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,f.set("version",o);let i=a(e.params);i.dependencies=a(r);let m={atom:p,params:i,config:c?.config,src:n,dest:n};return{deployer:await l(m)}}export{g as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import E from"cli-table3";import j from"chalk";function B(q,x={}){let y={...{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},...x,head:q.map((z)=>j.bold(z))};return new E(y)}function H(q,x,A={}){let y=B(q,A);if(Array.isArray(x))x.forEach((z)=>{y.push(z)});return y.toString()}function I(q){switch(q){case"running":return j.green;case"stopped":return j.yellow;case"failed":return j.red;case"registered":return j.blue;default:return j.gray}}var L={createTable:B,createTableWithData:H,getStatusColor:I};export{I as getStatusColor,L as default,H as createTableWithData,B as createTable};
@@ -0,0 +1,2 @@
1
+ import{createRequire as k}from"node:module";var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var l=(a,b,c)=>{c=a!=null?g(h(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var m=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var o=k(import.meta.url);
2
+ export{l as g,m as h,o as i};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import d from"@fnet/config";import l from"@flownet/lib-to-docker";import a from"lodash.clonedeep";import u from"semver";async function y({atom:r,target:e,onProgress:s,projectDir:o,dependencies:c,context:t,yamlTarget:f}){if(s)await s({message:"Deploying it as docker package."});let p=e?.config?await d({name:e.config,dir:o,optional:!0,transferEnv:!1,tags:t.tags}):void 0,n=u.inc(e.version||"0.1.0","patch");e.params.version=n,e.version=n,f.set("version",n);let i=a(e.params);i.dependencies=a(c);let m={atom:r,params:i,config:p?.config,src:o,dest:o};return{deployer:await l(m)}}export{y as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import l from"@fnet/config";import d from"@flownet/lib-to-electron";import t from"lodash.clonedeep";import g from"semver";async function u({atom:a,target:e,onProgress:o,projectDir:n,dependencies:r,context:c,yamlTarget:f}){if(o)await o({message:"Deploying it as electron package."});let m=e?.config?await l({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:c.tags}):void 0,s=g.inc(e.version||"0.1.0","patch");e.version=s,f.set("version",s);let i=t(e.params);i.dependencies=t(r);let p={atom:a,params:i,config:m?.config,src:n,dest:n};return{deployer:await d(p)}}export{u as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import p from"node:fs";import f from"node:path";import w from"semver";import k from"@fnet/shelljs";import y from"@fnet/config";async function P({setProgress:A,context:i,deploymentProject:v,deploymentProjectTarget:o,yamlTarget:u}){await A({message:"Deploying it as fnet package."});let d=i.projectDir,a=f.resolve(d,"package.json"),m=p.readFileSync(a),t=JSON.parse(m);t.name=o.params.name,t.version=w.inc(o.version,"patch"),delete t.scripts,delete t.devDependencies,p.writeFileSync(a,JSON.stringify(t,null,"\t"));let{file:r,data:e}=await y({name:o.config||"fnet-package",dir:i.projectDir,tags:i.tags});if(!e.env.ATOM_API_URL)throw Error(`ATOM_API_URL is required in ${r}`);if(!e.env.ATOM_API_USERNAME)throw Error(`ATOM_API_USERNAME is required in ${r}`);if(!e.env.ATOM_API_PASSWORD)throw Error(`ATOM_API_PASSWORD is required in ${r}`);let l=`${e.env.ATOM_API_URL}/v1/auth/token`,h=e.env.ATOM_API_USERNAME,O=e.env.ATOM_API_PASSWORD,s=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:h,password:O})});if(!s.ok)throw Error(`Failed to fetch token: ${s.statusText}`);let _=(await s.json())?.access_token;if(!_)throw Error(`Invalid access_token from ${l}`);let n="fnet-files-to-gcs";if(n+=` --projectId='${e.env.GCS_PROJECT_ID}'`,n+=` --bucketName='${e.env.GCS_BUCKET_NAME}'`,n+=` --keyFilename='${f.resolve(f.dirname(r),e.env.GCS_UPLOADER_KEY_FILE)}'`,n+=` --dir='${d}'`,n+=" --pattern='dist/**/**'",n+=" --pattern='bin/**/**'",n+=" --pattern='test/**/**'",n+=" --pattern='*.html'",n+=` --destDir='${t.name}/${t.version}'`,n+=" --metadata.cacheControl='public, max-age=31536000, immutable'",e.env.DOMAIN)n+=` --domain='${e.env.DOMAIN}'`;if(o.dry_run===!0||o.params.dry_run===!0)n+=" --dryRun";if(await k(n),p.writeFileSync(a,m),o.dryRun===!0)return;v.isDirty=!0,o.version=t.version,u.set("version",t.version);let S=`${e.env.ATOM_API_URL}/v1/service/fnet-package/publish`,c=await fetch(S,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_}`},body:JSON.stringify({name:t.name,version:t.version,version_domain:e.env.DOMAIN,docs:o.params.docs,configs:o.params.configs})});if(!c.ok)throw Error(`Failed to publish fnet package: ${c.statusText}`);if((await c.json())?.error)throw Error("Failed to publish fnet package.")}export{P as default};
@@ -0,0 +1 @@
1
+ import{e as Z}from"./index.9qgtmxq3.js";import{f as _}from"./index.05n3mvs9.js";import"./index.cvxrf34y.js";import A from"node:fs";import E from"node:path";import u from"semver";import Y from"@fnet/shelljs";import v from"@fnet/config";import w from"@fnet/object-from-schema";import b from"yaml";import{fileURLToPath as F}from"node:url";var h=E.dirname(F(import.meta.url)),m=process.cwd();async function T({atom:y,setProgress:$,context:B,deploymentProject:L,deploymentProjectTarget:z,yamlTarget:R}){await $({message:"Deploying it as npm package."});let G=B.projectDir,H=E.resolve(G,"package.json"),V=A.readFileSync(H),q=JSON.parse(V);q.name=z.params.name,q.version=u.inc(z.version,"patch");let I=z.params.bin?.name||z.params.bin;if(z.params.bin?.enabled!==!1&&I&&typeof I==="string")q.bin={[I]:"dist/cli/esm/index.js"};delete q.scripts,delete q.devDependencies,q.scripts={serve:"npx serve ."},A.writeFileSync(H,JSON.stringify(q,null,"\t"));let W=z.config||"npm",K=(await v({name:W,dir:B.projectDir,tags:B.tags,optional:!0}))?.data;if(!K){let M=Z("./template/schemas/to-npm.yaml"),X=await w({schema:M,tags:B.tags}),U=B.project.projectDir,Q=E.resolve(U,".fnet");if(!A.existsSync(Q))A.mkdirSync(Q);A.writeFileSync(E.resolve(Q,`${W}.fnet`),b.stringify(X)),K=X}if(A.writeFileSync(E.resolve(G,".npmrc"),`//registry.npmjs.org/:_authToken=${K.env.NPM_TOKEN}`),z.dryRun===!0)return;if(_("bun")){if((await Y("bun publish --access public",{cwd:G})).code!==0)throw Error("Couldnt publish to npm")}else if((await Y("npm publish --access public",{cwd:G})).code!==0)throw Error("Couldnt publish to npm");A.writeFileSync(H,V),L.isDirty=!0,z.version=q.version,R.set("version",q.version)}export{T as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import d from"@fnet/config";import l from"@flownet/lib-to-nextjs";import a from"lodash.clonedeep";import u from"semver";async function g({atom:t,target:e,onProgress:s,projectDir:n,dependencies:r,context:f,yamlTarget:c}){if(s)await s({message:"Deploying it as nextjs package."});let m=e?.config?await d({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:f.tags}):void 0,o=u.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,c.set("version",o);let i=a(e.params);i.dependencies=a(r);let p={atom:t,params:i,config:m?.config,src:n,dest:n};return{deployer:await l(p)}}export{g as default};
@@ -0,0 +1,3 @@
1
+ import{a as A,b,c as v,d as w}from"./index.s0nk6cv8.js";import"./index.cvxrf34y.js";import K from"node:fs";import T from"node:path";import f from"node:os";async function U(I){let{atom:q,context:z,setProgress:H}=I;H("Initializing features..."),q.doc.features=q.doc.features||{};let _=q.doc.features;if(_.cli===!1)_.cli={enabled:!1};else if(_.cli===!0)_.cli={enabled:!0};else _.cli={enabled:!0};_.cli.enabled=_.cli.enabled===!0&&(q.doc.features.form_enabled===!1||_.cli.extend===!0||_.cli.enabled===!0)}async function V({atom:I,packageDependencies:q,packageDevDependencies:z,setProgress:H}){H("Initializing dependencies")}import Z from"node:fs";import $ from"node:path";import l from"@flownet/lib-render-templates-dir";async function W({atom:I,setProgress:q,context:z,packageDependencies:H}){if(I.doc.features.cli.enabled!==!0)return;await q({message:"Creating cli."});let _={atom:I,packageDependencies:H},N=z.templateDir,M=$.join(z.projectDir,"src","cli");if(!Z.existsSync(M))Z.mkdirSync(M,{recursive:!0});await l({pattern:["index.py.njk","__init__.py.njk"],dir:$.join(N,"src","cli"),outDir:M,context:_})}import Q from"node:path";import G from"@fnet/auto-conda-env";import u from"@flownet/lib-render-templates-dir";async function X(I){let{setProgress:q,atom:z,context:H}=I;q({message:"Installing Python packages"});let _=H.projectDir,N=await G({pythonVersion:"3.12",packages:[{package:"fnet-import-parser",version:"0.1.9"}]}),{errors:M,result:F}=await N.runBin("fnet_import_parser",["--entry_file",Q.join(_,"src","default","index.py")],{captureName:"result"});if(M)throw Error(M.format());let y=JSON.parse(F.items[0].stdout).required["third-party"]?.map((J)=>{return{package:J.metadata?.package||J.path,version:J.metadata?.version||void 0,channel:J.metadata?.channel||void 0}})||[],S=z.doc.dependencies||[];for(let J of y)if(!S.some((R)=>R.package===J.package))S.push(J);let E=Q.join(_,".conda"),Y=await G({envDir:E,pythonVersion:z.doc.features.runtime.version||"3.12",packages:S});H.pythonEnv=Y,I.packageDependencies=S;let L=z.doc.features.render?.dirs||[];for(let J of L)J.dir=Q.resolve(_,J.dir),J.outDir=Q.resolve(_,J.outDir),await u(J);let O={params:{}};O.params.package_name=z.doc.name,O.params.version="0.1.0",O.params.bin_name=z.doc.name,O.params.python_requires=z.doc.features.runtime.version||">=3.12",O.params.dependencies=S,O.params.scripts=JSON.stringify({cli:`PYTHONPATH='${Q.join("src")}' '${Q.relative(H.projectDir,Y.pythonBin)}' '${Q.join("src","cli","index.py")}'`}),await u({pattern:["setup.py.njk","package.json.njk","pyproject.toml.njk"],dir:H.templateDir,outDir:H.projectDir,context:O})}class B extends b{async initRuntime(){await U(this.apiContext),await V(this.apiContext),await this.initLibraryDirPython(),await this.initNunjucks(),await this.initLibsPython()}async initLibraryDirPython(){this.setProgress({message:"Initializing library directory."});let I=this.context.projectDir;this.setProgress({message:"Cleaning project directory."});let q=A({dir:I,ignore:[".cache","node_modules",".conda",".bin",".dev"],absolute:!0});for(let _ of q)K.rmSync(_,{recursive:!0,force:!0});this.setProgress({message:"Creating project directory."});let z=I;if(!K.existsSync(z))K.mkdirSync(z,{recursive:!0});if(z=T.join(I,"src"),!K.existsSync(z))K.mkdirSync(z,{recursive:!0});z=T.join(I,"src","default");let H=this.context.projectSrcDir;if(!K.existsSync(z))try{if(f.platform()==="win32")K.symlinkSync(H,z,"junction");else K.symlinkSync(H,z,"dir")}catch(_){throw Error(`Couldn't create symlink. Error: ${_.message}`)}if(z=T.join(I,".dev"),!K.existsSync(z))K.mkdirSync(z,{recursive:!0})}async initLibsPython(){this.setProgress({message:"Initializing external libs."});let I=this.atom;I.protocol="src:",I.doc.dependencies=I.doc.dependencies||[],I.name=I.doc.name;let q=[{name:this.atom.doc.name,type:"atom",parent_id:this.atom.parent_id,atom:I}];this.libs=q}async createAtomLibFilesPython({libs:I}){await this.setProgress({message:"Creating external lib files."});let q=I.filter((z)=>z.type==="atom");for(let z=0;z<q.length;z++){let _=q[z].atom;if(_.protocol==="src:"){let N=T.resolve(this.context.projectSrcDir,`${_.fileName||_.name}.py`);if(!K.existsSync(N)){K.mkdirSync(T.dirname(N),{recursive:!0});let M=`def default():
2
+ `;M+=` print("Hello world!")
3
+ `,K.writeFileSync(N,M,"utf8")}}}}async build(){try{if(this.fileMode){if(await this.createAtomLibFilesPython({libs:this.libs}),await this.createProjectYaml(),await w(this.apiContext),await v(this.apiContext),await W(this.apiContext),this.buildMode){if(await X(this.apiContext),this.deployMode)await this.deploy()}}await this._cache_set(this.buildKey,{status:"COMPLETED"})}catch(I){throw await this._cache_set(this.buildKey,{status:"FAILED",message:I.message||I}),console.log(I),I}}}var qz=B;export{qz as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import l from"node:fs";import f from"node:path";import u from"@fnet/config";async function j({atom:p,Atom:i,setProgress:y,context:r,packageDependencies:w,deploymentProject:m,deploymentProjectTarget:t}){await y({message:"Deploying it as workflow lib."});let s=(await u({name:"atom",dir:r.projectDir,tags:r.tags}))?.data,e,a,n,o=t.deploy.name.split("/");if(o.length===1)a=s.env.ATOM_LIBRARIES_ID,n=t.deploy.name;else if(o.length===2){let c=await i.first({where:{name:o[0],parent_id:s.env.ATOM_LIBRARIES_ID,type:"folder"},limit:1});if(!c)throw Error("Couldnt file lib folder.");a=c.id,n=o[1]}else throw Error("Wrong name path.");if(t.dryRun===!0)return;if(m.isDirty=!0,!t.deploy.id){if(e=await i.create({parent_id:a,doc:{name:n,type:"workflow.lib","content-type":"javascript",dependencies:[],content:void 0,subtype:"workflow"}}),!e)return;t.deploy.id=e.id}else if(e=await i.get({id:t.deploy.id}),!e)return;let d=r.projectDir;if(e.doc.contents=[{content:l.readFileSync(f.resolve(d,"dist/default/esm/index.js"),{encoding:"utf8",flag:"r"}),["content-type"]:"javascript",format:"esm"},{content:l.readFileSync(f.resolve(d,"dist/default/cjs/index.js"),{encoding:"utf8",flag:"r"}),["content-type"]:"javascript",format:"cjs"},{content:l.readFileSync(f.resolve(d,"dist/default/iife/index.js"),{encoding:"utf8",flag:"r"}),["content-type"]:"javascript",format:"iife"}],e.doc.name=n,e.doc.dependencies=w,p.type==="workflow.lib")e.doc.subtype="library";else if(p.type==="workflow")e.doc.subtype="workflow";e=await i.update(e,{id:e.id})}export{j as default};
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import{e as S}from"./index.9qgtmxq3.js";import{f as o}from"./index.05n3mvs9.js";import{g as x,i as k}from"./index.cvxrf34y.js";import q$ from"yargs";import B1 from"chalk";import{promisify as I1}from"node:util";import F1 from"tree-kill";var a=I1(F1),N=!1;async function n($,W){if(N)return;if(N=!0,!$.killed&&$.pid)try{if(await a($.pid,"SIGTERM").catch(()=>{}),await new Promise((q)=>setTimeout(q,500)),!$.killed)await a($.pid,"SIGKILL").catch(()=>{})}catch(q){}await new Promise((q)=>setTimeout(q,100));let z=W==="SIGINT"?130:W==="SIGTERM"?143:1;process.exit(z)}function u($){["SIGINT","SIGTERM","SIGQUIT"].forEach((W)=>{process.once(W,async()=>{await n($,W)})}),process.on("uncaughtException",async(W)=>{await n($)}),process.on("unhandledRejection",async(W)=>{await n($)}),$.on("close",(W)=>{if(!N)process.exit(W)})}function t(){process.on("uncaughtException",($)=>{if(!N)N=!0,setTimeout(()=>process.exit(1),500)}),process.on("unhandledRejection",($)=>{if(!N)N=!0,setTimeout(()=>process.exit(1),500)})}import E from"node:path";import{spawn as i}from"node:child_process";import v from"node:fs";import b from"chalk";import _1 from"@fnet/config";function C($,{name:W,bin:z,preArgs:q=[],createContext:G}){if(typeof z==="function")z=z();return $.command(`${W||z} [commands..]`,`${z} ${q.join(" ")}`,(Z)=>{return Z.help(!1).version(!1)},async(Z)=>{try{let Q=await G(Z),{projectDir:Y}=Q,O=(I)=>{if(!I.includes(" "))return I;if(process.platform==="win32")return`"${I.replace(/(["^])/g,"^$1")}"`;else return`"${I.replace(/(["\\$`])/g,"\\$1")}"`},M=process.argv.slice(3).map(O),J={...process.env},U=E.join(Y,"node_modules");J.NODE_PATH=U,J.NODE_PRESERVE_SYMLINKS=1;let T=i(z,[...q,...M],{cwd:Y,stdio:"inherit",shell:!0,detached:!0,env:J});u(T)}catch(Q){console.error(Q.message),process.exit(1)}})}function y($,{name:W,bin:z,preArgs:q=[],createContext:G}){return $.command(`${W||z} [commands..]`,`${z} ${q.join(" ")}`,(Z)=>{return Z.help(!1).version(!1)},async(Z)=>{try{let Q=await G(Z),{projectDir:Y}=Q,O=(U)=>{if(!U.includes(" "))return U;if(process.platform==="win32")return`"${U.replace(/(["^])/g,"^$1")}"`;else return`"${U.replace(/(["\\$`])/g,"\\$1")}"`},M=process.argv.slice(3).map(O);z=E.join(Y,".conda","bin",z||W);let J=i(z,[...q,...M],{cwd:Y,stdio:"inherit",shell:!0,detached:!0,env:{PYTHONPATH:Y}});u(J)}catch(Q){console.error(Q.message),process.exit(1)}})}function e($,{name:W,preArgs:z=[],createContext:q}){return $.command(`${W} <config> <command> [options..]`,"Run a command with a config context",(G)=>{return G.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)},async(G)=>{try{let Z=await q(G),{projectDir:Q}=Z,Y=G.config,M=(await _1({name:Y,dir:Q,transferEnv:!1,optional:!0,tags:Z.tags}))?.data?.env||void 0,J=G.command,U=process.argv.slice(5),T=i(J,[...z,...U],{cwd:v.existsSync(Q)?Q:process.cwd(),stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...M}});u(T)}catch(Z){console.error(Z.message),process.exit(1)}})}function $1($,{name:W,projectType:z="auto"}){return $.command(`${W} group [options..]`,"Run a command group.",(q)=>{return q.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)},async(q)=>{try{let{runCommandGroup:G}=await import("./index.2pnjg6dc.js");await G({projectType:z,group:q.group,tags:q.ftag,args:q,argv:process.argv})}catch(G){console.error(G.message),process.exit(1)}})}function W1($,{name:W,createContext:z}){return $.command(`${W} [options]`,"Install the project as a binary",(q)=>{return q.option("name",{alias:"n",describe:"Name to use for the installed binary",type:"string"}).option("force",{alias:"f",describe:"Force overwrite if binary already exists",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Automatically answer yes to all prompts",type:"boolean",default:!1})},async(q)=>{try{let G=await z(q),{projectDir:Z}=G;console.log(b.blue("Compiling project..."));let Q=E.join(Z,".bin");if(!v.existsSync(Q))v.mkdirSync(Q,{recursive:!0});let Y=E.basename(E.dirname(Z)),O=G.project?.projectFileParsed?.features?.cli?.bin,M=q.name||O||Y;console.log(b.blue(`Using binary name: ${M}`));let J=E.join(Q,M),{spawn:U}=await import("child_process"),T=U("bun",["build","./dist/cli/esm/index.js","--compile",`--outfile=${J}`],{cwd:Z,stdio:"inherit",shell:!0});if(await new Promise((f,F)=>{T.on("close",(_)=>{if(_===0)f();else F(Error(`Compilation failed with code ${_}`))}),T.on("error",(_)=>{F(_)})}),process.platform!=="win32")v.chmodSync(J,493);console.log(b.green(`Binary compiled successfully: ${J}`)),console.log(b.blue("Installing binary..."));let I=["install",J];if(q.name)I.push("--name",q.name);if(q.force)I.push("--force");if(q.yes)I.push("--yes");let D=U("fbin",I,{stdio:"inherit",shell:!0});await new Promise((f,F)=>{D.on("close",(_)=>{if(_===0)f();else F(Error(`Installation failed with code ${_}`))}),D.on("error",(_)=>{F(_)})})}catch(G){console.error(b.red(`Failed to install binary: ${G.message}`)),process.exit(1)}})}import B from"node:path";import w from"node:fs";import q1 from"@fnet/yaml";import A1 from"yaml";async function V($){if($.id)return{id:$.id,buildId:$.buildId,mode:$.mode,protocol:$.protocol||"ac:",templateDir:S("./template/fnode/node"),projectDir:B.resolve(process.cwd(),`./.output/${$.id}`),tags:$.ftag,dev:$.dev};else try{let W=await R1({tags:$.ftag}),z=W.runtime.type==="bun"?"node":W.runtime.type;return{buildId:$.buildId,mode:$.mode,protocol:$.protocol||"src:",templateDir:S(`./template/fnode/${z}`),projectDir:B.resolve(W.projectDir,"./.workspace"),projectSrcDir:B.resolve(W.projectDir,"./src"),projectSrcDirSymlink:B.resolve(W.projectDir,"./.workspace/src-core"),projectAppDir:B.resolve(W.projectDir,"./app"),projectAppDirSymlink:B.resolve(W.projectDir,"./.workspace/app"),projectCliDir:B.resolve(W.projectDir,"./cli"),projectCliDirSymlink:B.resolve(W.projectDir,"./.workspace/cli"),project:W,tags:$.ftag,dev:$.dev}}catch(W){return console.warn(`Warning: Could not load project: ${W.message}`),{projectDir:process.cwd(),tags:$.ftag}}}async function R1({tags:$}){let W=N1(process.cwd());if(!w.existsSync(W))throw Error("fnode.yaml file not found in current directory.");let{raw:z,parsed:q}=await q1({file:W,tags:$}),G=B.dirname(W);q.features=q.features||{};let Z=q.features;if(Z.runtime=Z.runtime||{},Z.runtime.type=Z.runtime.type||"node",Z.runtime.type==="python")Z.runtime.template=Z.runtime.template||"python";else if(Z.runtime.type==="bun")Z.runtime.template=Z.runtime.template||"node";else Z.runtime.template=Z.runtime.template||"node";let Q={libraryAtom:{doc:{...q},fileName:"index"},projectDir:G,projectFilePath:W,projectFileContent:z,projectFileParsed:q,runtime:Z.runtime},Y=B.resolve(G,"fnet/targets.yaml");if(!w.existsSync(Y)){if(Y=B.resolve(G,"node.devops.yaml"),w.existsSync(Y)){let M=B.resolve(G,"fnet");if(!w.existsSync(M))w.mkdirSync(M);w.copyFileSync(Y,B.resolve(G,"fnet/targets.yaml")),w.unlinkSync(Y)}}if(w.existsSync(Y)){let{raw:M,parsed:J}=await q1({file:Y,tags:$}),U=A1.parseDocument(M);Q.devops={filePath:Y,fileContent:M,yamlDocument:U,doc:{...J},type:"library.deploy",save:async()=>{w.writeFileSync(Q.devops.filePath,U.toString())}}}let O=B.resolve(G,"readme.md");if(w.existsSync(O)){let M=w.readFileSync(O,"utf8");Q.readme={filePath:O,fileContent:M,doc:{content:M,"content-type":"markdown"},type:"wiki"}}return Q}function N1($){let W=B.resolve($,"node.yaml"),z=B.resolve($,"fnode.yaml");if(w.existsSync(z))return z;if(w.existsSync(W))try{let q=w.readFileSync(W,"utf8");return w.writeFileSync(z,q,"utf8"),w.unlinkSync(W),console.log(`Migrated node.yaml to fnode.yaml in ${$}`),z}catch(q){return console.error(`Error migrating node.yaml to fnode.yaml: ${q.message}`),W}return z}import x1 from"node:path";import z1 from"node:fs";import k1 from"node:os";import S1 from"@flownet/lib-render-templates-dir";import c from"@fnet/shelljs";var E1={command:"create",describe:"Create a new fnode project",builder:($)=>{return $.option("name",{type:"string",describe:"Project name",demandOption:!0}).option("vscode",{type:"boolean",default:!0,alias:"vs",describe:"Open in VS Code after creation"}).option("runtime",{type:"string",default:"node",choices:["node","python","bun"],describe:"Runtime environment"})},handler:async($)=>{try{let W=process.cwd(),z=S("./template/fnode/project"),q=x1.resolve(W,$.name);if(!z1.existsSync(q))z1.mkdirSync(q);await S1({dir:z,outDir:q,context:{name:$.name,runtime:$.runtime,platform:k1.platform()},copyUnmatchedAlso:!0});let G=await c("fnode build",{cwd:q});if(G.code!==0)throw Error("Failed to build project.");if(o("git")){if(G=await c("git init --initial-branch=main",{cwd:q}),G.code!==0)throw Error("Failed to initialize git.")}if(o("code")&&$.vscode){if(G=await c(`cd ${q} && code .`),G.code!==0)throw Error("Failed to open vscode.")}console.log("Creating project succeeded!"),process.exit(0)}catch(W){console.error("Initialization failed!",W.message),process.exit(1)}}},G1=E1;import b1 from"node:os";import y1 from"@flownet/lib-render-templates-dir";import D1 from"@fnet/shelljs";var f1={command:"project",describe:"Manage fnode project",builder:($)=>{return $.option("update",{type:"boolean",default:!1,alias:"-u",describe:"Update project files"})},handler:async($)=>{try{let W=S("./template/fnode/project"),z=process.cwd(),q=await V($);if($.update){if(await y1({dir:W,outDir:z,context:{name:q.project.projectFileParsed.name,runtime:q.project.runtime.type,platform:b1.platform()},copyUnmatchedAlso:!0}),(await D1("fnode build",{cwd:z})).code!==0)throw Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(W){console.error("Project failed.",W.message),process.exit(1)}}},Q1=f1;class Z1{static async createBuilder($){if(!$.project)return console.warn("No project provided, defaulting to node runtime"),new(await import("./index.rzsfmek6.js")).default($);let W=$.project?.runtime?.type||"node";try{return new(await this.loadBuilderClass(W))($)}catch(z){throw Error(`Failed to create builder for runtime '${W}': ${z.message}`)}}static async loadBuilderClass($){switch($.toLowerCase()){case"node":case"bun":return(await import("./index.rzsfmek6.js")).default;case"python":return(await import("./index.hv4s25f0.js")).default;default:throw Error(`Unsupported runtime type: ${$}`)}}}var R=Z1;var u1={command:"build",describe:"Build fnode project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{let W=await V($),z=await R.createBuilder(W);await z.init(),await z.build(),console.log("Building library succeeded!"),process.exit(0)}catch(W){console.error("Building library failed!",W.message),process.exit(1)}}},Y1=u1;var v1={command:"build:dev",describe:"Build fnode project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"],describe:"Build mode"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"}).option("dev",{type:"boolean",default:!1,describe:"Development mode"})},handler:async($)=>{try{$.dev=!0;let W=await V($),z=await R.createBuilder(W);await z.init(),await z.build(),console.log("Building library succeeded!"),process.exit(0)}catch(W){console.error("Building library failed!",W.message),process.exit(1)}}},K1=v1;var P1={command:"deploy",describe:"Build and deploy fnode project",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let W=await V({...$,mode:"all"}),z=await R.createBuilder(W);await z.init(),await z.build(),console.log("Building library succeeded!"),process.exit(0)}catch(W){console.error("Building library failed!",W.message),process.exit(1)}}},U1=P1;var j1={command:"file",describe:"Just create files",builder:($)=>{return $.option("id",{type:"string",describe:"Project ID"}).option("buildId",{type:"string",alias:"bid",describe:"Build ID"}).option("ftag",{type:"array",describe:"Tags for conditional configuration"})},handler:async($)=>{try{let W=await V({...$,mode:"file"}),z=await R.createBuilder(W);await z.init(),await z.build(),console.log("Building library succeeded!"),process.exit(0)}catch(W){console.error("Building library failed!",W.message),process.exit(1)}}},H1=j1;import J1 from"node:path";import P from"node:fs";import d1 from"@fnet/prompt";var m1={command:"input [name]",describe:"Create or modify an input config file",builder:($)=>{return $.positional("name",{type:"string",demandOption:!1,describe:"Input name"})},handler:async($)=>{try{let W=await V($),{project:z}=W,{projectDir:q,projectFileParsed:G}=z,Z=G.input;if(!Z)throw Error("Config schema not found in project file.");if(!Reflect.has($,"name")){let{inputName:U}=await d1({type:"input",name:"inputName",message:"Input name:",initial:"dev"});$.name=U}let Q=J1.resolve(q,".fnet");if(!P.existsSync(Q))P.mkdirSync(Q);let Y=J1.resolve(Q,`${$.name}.fnet`),O=P.existsSync(Y),M=(await import("@fnet/object-from-schema")).default,J=await M({schema:Z,format:"yaml",ref:O?Y:void 0});P.writeFileSync(Y,J)}catch(W){console.error(W.message),process.exit(1)}}},M1=m1;import L from"node:path";import H from"node:fs";import d from"node:os";import{spawn as m}from"node:child_process";import K from"chalk";import A from"@fnet/prompt";import j from"chalk";import L1 from"@fnet/prompt";async function g1($){let{items:W,message:z,nameField:q="name",valueField:G="name",initialValue:Z=null,allowAbort:Q=!0}=$;if(!W||W.length===0)return console.log(j.yellow("No items available for selection.")),null;if(W.length===1&&!Q){let U=W[0],T=typeof U==="string"?U:U[G];return console.log(j.blue(`Only one option available: ${typeof U==="string"?U:U[q]}`)),T}let Y=W.map((U)=>{if(typeof U==="string")return{name:U,value:U,message:U};else return{name:U[G],value:U[G],message:U[q]||U[G]}});if(Q)Y.push({name:"cancel",value:null,message:j.yellow("Cancel")});let O=null;if(Z){let U=Y.findIndex((T)=>T.name===Z);if(U!==-1)O=U}let M="selectedItem",{[M]:J}=await L1({type:"select",name:M,message:z,choices:Y,initial:O});if(J==="cancel")return null;return J}async function l1($){let{items:W,message:z,nameField:q="name",valueField:G="name",initialValues:Z=[],allowAbort:Q=!0}=$;if(!W||W.length===0)return console.log(j.yellow("No items available for selection.")),null;let Y=W.map((U)=>{if(typeof U==="string")return{name:U,value:U,message:U};else return{name:U[G],value:U[G],message:U[q]||U[G]}}),O=[];if(Z&&Z.length>0)O=Y.map((U,T)=>Z.includes(U.name)?T:-1).filter((U)=>U!==-1);let M="selectedItems",J=await L1({type:"multiselect",name:M,message:z,choices:Y,initial:O,hint:"(Use space to select, enter to confirm)",validate:(U)=>{if(U.length===0&&!Q)return"Please select at least one item";return!0}});if(Q&&J[M].length===0)return null;return J[M]}var s={promptForSelection:g1,promptForMultipleSelection:l1};var X=L.join(d.homedir(),".fnet","express");async function V1($){$.command(["$0 [project-name]","create [project-name]"],"Create a new express project",(W)=>{return W.positional("project-name",{describe:"Name of the project",type:"string"}).option("yes",{alias:"y",describe:"Skip all prompts and use defaults",type:"boolean",default:!1}).option("runtime",{describe:"Runtime to use (node, python, bun)",type:"string",choices:["node","python","bun"],default:"node"})},async(W)=>{await h1(W)}).command("list","List express projects",(W)=>{return W.option("today",{describe:"Show only projects created today",type:"boolean",default:!1}).option("type",{describe:"Filter by project type (fnode or fnet)",type:"string",choices:["fnode","fnet"]}).option("all",{describe:"Show all projects regardless of type",type:"boolean",default:!1,alias:"a"}).option("name",{describe:"Filter by project name",type:"string"})},async(W)=>{await p1(W)}).command("open [project-name]","Open an express project",(W)=>{return W.positional("project-name",{describe:"Name of the project to open",type:"string"}).option("latest",{describe:"Open the most recent project",type:"boolean",default:!1})},async(W)=>{await n1(W)}).command("move [project-name] [destination]","Move an express project to a real project location",(W)=>{return W.positional("project-name",{describe:"Name of the project to move",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).option("latest",{describe:"Move the most recent project",type:"boolean",default:!1})},async(W)=>{await i1(W)}).command("remove [project-name]","Remove an express project",(W)=>{return W.positional("project-name",{describe:"Name of the project to remove",type:"string"}).option("latest",{describe:"Remove the most recent project",type:"boolean",default:!1}).option("yes",{alias:"y",describe:"Skip confirmation prompt",type:"boolean",default:!1})},async(W)=>{await o1(W)}).command("enter [project-name]","Enter the directory of an express project in the active terminal",(W)=>{return W.positional("project-name",{describe:"Name of the project to enter",type:"string"}).option("latest",{describe:"Enter the most recent project directory",type:"boolean",default:!1})},async(W)=>{await s1(W)}).demandCommand(1,"You need to specify a command").help()}async function h1($){try{if(!H.existsSync(X))H.mkdirSync(X,{recursive:!0});let W=new Date().toISOString().slice(0,10).replace(/-/g,""),z=L.join(X,W);if(!H.existsSync(z))H.mkdirSync(z,{recursive:!0});let q=$.projectName,G,Z=$.runtime;if(!$.yes){if(!q){let T=H.readdirSync(z).filter((F)=>F.startsWith("fnode-")).map((F)=>parseInt(F.replace("fnode-",""),10)).filter((F)=>!isNaN(F)),D=`fnode-${T.length>0?Math.max(...T)+1:1}`;q=(await A([{type:"input",name:"projectName",message:"Enter project name:",default:D}])).projectName}Z=(await A({type:"select",name:"runtime",message:"Select runtime:",choices:["node","python","bun"],initial:Z||"node"})).runtime}else{if(!q){let J=H.readdirSync(z).filter((T)=>T.startsWith("fnode-")).map((T)=>parseInt(T.replace("fnode-",""),10)).filter((T)=>!isNaN(T));q=`fnode-${J.length>0?Math.max(...J)+1:1}`}if(!Z)Z="node"}if(G=L.join(z,q),H.existsSync(G)){let J=1;while(H.existsSync(L.join(z,`${q}-${J}`)))J++;q=`${q}-${J}`,G=L.join(z,q)}if(!$.yes){if(!(await A([{type:"confirm",name:"proceed",message:`Create express project "${q}" in ${G}?`,default:!0}])).proceed){console.log(K.yellow("Project creation cancelled."));return}}console.log(K.blue(`Creating express project "${q}" in ${G}...`));let Q=L.dirname(G),O=["create","--name",L.basename(G)];if(O.push("--runtime",Z),$.yes)O.push("--yes");if(!H.existsSync(Q))H.mkdirSync(Q,{recursive:!0});let M=m("fnode",O,{stdio:"inherit",shell:!0,cwd:Q});return new Promise((J,U)=>{M.on("close",(T)=>{if(T===0)if(console.log(K.green(`
3
+ Express project "${q}" created successfully!`)),console.log(K.blue(`
4
+ Project location: ${G}`)),!$.yes)c1(G);else J();else console.error(K.red(`
5
+ Failed to create express project "${q}".`)),U(Error(`Process exited with code ${T}`))})})}catch(W){console.error(K.red(`Error creating express project: ${W.message}`)),process.exit(1)}}async function p1($){try{if(!H.existsSync(X)){console.log(K.yellow("No express projects found."));return}let W=H.readdirSync(X).filter((Q)=>/^\d{8}$/.test(Q)).sort((Q,Y)=>Y.localeCompare(Q));if($.today){let Q=new Date().toISOString().slice(0,10).replace(/-/g,""),Y=W.indexOf(Q);if(Y===-1){console.log(K.yellow("No express projects found for today."));return}W.splice(0,Y),W.splice(1)}let z=[];if(!$.type&&!$.all)$.type="fnode";for(let Q of W){let Y=L.join(X,Q),O=H.readdirSync(Y);for(let M of O){let J=L.join(Y,M),U=H.statSync(J),T="unknown";if(M.startsWith("fnode-")||H.existsSync(L.join(J,"fnode.yaml")))T="fnode";else if(M.startsWith("fnet-")||H.existsSync(L.join(J,"fnet.yaml")))T="fnet";if($.type&&T!==$.type)continue;if($.name&&!M.includes($.name))continue;let I=`${Q.slice(0,4)}-${Q.slice(4,6)}-${Q.slice(6,8)}`;z.push({name:M,type:T,date:I,path:J,created:U.birthtime})}}if(z.sort((Q,Y)=>Y.created-Q.created),z.length===0){console.log(K.yellow("No express projects found matching the criteria."));return}console.log(K.blue(`
6
+ Express Projects:`));let q=(await import("./index.bhapgrs7.js")).default,G=["NAME","TYPE","DATE","PATH"],Z=q.createTable(G,{chars:{mid:"","mid-mid":"","left-mid":"","right-mid":""}});for(let Q of z){let Y=Q.path;if(Y.startsWith(d.homedir()))Y="~"+Y.substring(d.homedir().length);Z.push([K.white(Q.name),Q.type==="fnet"?K.cyan(Q.type):Q.type==="fnode"?K.green(Q.type):Q.type,Q.date,Y])}console.log(Z.toString()),console.log(K.green("Projects: ")+K.yellow(z.filter((Q)=>Q.type==="fnode").length+" fnode, ")+K.cyan(z.filter((Q)=>Q.type==="fnet").length+" fnet")),console.log(K.blue(`
7
+ Total: ${z.length} projects`))}catch(W){console.error(K.red(`Error listing express projects: ${W.message}`)),process.exit(1)}}async function n1($){try{if(!H.existsSync(X)){console.log(K.yellow("No express projects found."));return}let W;if($.latest){if(W=await g(),!W){console.log(K.yellow("No express projects found."));return}}else if($.projectName){if(W=await l($.projectName),!W){console.log(K.yellow(`Project "${$.projectName}" not found.`));return}}else{let z=await h();if(!z){console.log(K.yellow("No project selected."));return}W=L.join(X,z)}await r(W)}catch(W){console.error(K.red(`Error opening express project: ${W.message}`)),process.exit(1)}}async function i1($){try{let W=process.cwd(),z=W.includes(X),q;if(z)q=W,console.log(K.blue(`Using current express project: ${L.basename(q)}`));else if($.latest){if(q=await g(),!q){console.log(K.yellow("No express projects found."));return}}else if($.projectName){if(q=await l($.projectName),!q){console.log(K.yellow(`Project "${$.projectName}" not found.`));return}}else{let Q=await h();if(!Q){console.log(K.yellow("No project selected."));return}q=L.join(X,Q)}let G=$.destination;if(!G)G=(await A({type:"input",name:"destination",message:"Enter destination directory:",initial:L.join(process.cwd(),L.basename(q))})).destination;if(G.startsWith("~"))G=L.join(d.homedir(),G.slice(1));if(G=L.resolve(G),G.startsWith(q+L.sep)||G===q){console.log(K.red("Destination cannot be inside the source directory."));return}if(H.existsSync(G)){if(!H.statSync(G).isDirectory()){console.log(K.red(`Destination "${G}" is not a directory.`));return}if(H.readdirSync(G).length>0){if(!(await A({type:"confirm",name:"overwrite",message:`Destination "${G}" is not empty. Continue anyway?`,initial:!1})).overwrite){console.log(K.yellow("Project move cancelled."));return}}}else H.mkdirSync(G,{recursive:!0});if(console.log(K.blue(`Moving project from ${q} to ${G}...`)),T1(q,G),console.log(K.green(`
8
+ Project moved successfully to ${G}`)),(await A({type:"confirm",name:"deleteOriginal",message:"Delete the original express project?",initial:!1})).deleteOriginal)H.rmSync(q,{recursive:!0,force:!0}),console.log(K.green("Original project deleted."));await r(G)}catch(W){console.error(K.red(`Error moving express project: ${W.message}`)),process.exit(1)}}async function g(){let $=H.readdirSync(X).filter((Q)=>/^\d{8}$/.test(Q)).sort((Q,Y)=>Y.localeCompare(Q));if($.length===0)return null;let W=$[0],z=L.join(X,W),q=H.readdirSync(z);if(q.length===0)return null;let G=null,Z=0;for(let Q of q){let Y=L.join(z,Q),O=H.statSync(Y);if(O.birthtimeMs>Z)Z=O.birthtimeMs,G=Y}return G}async function l($){let W=H.readdirSync(X).filter((z)=>/^\d{8}$/.test(z)).sort((z,q)=>q.localeCompare(z));for(let z of W){let q=L.join(X,z),G=H.readdirSync(q);if(G.includes($))return L.join(q,$);let Z=G.filter((Q)=>Q.includes($));if(Z.length>0)if(Z.length===1)return L.join(q,Z[0]);else{let Q=Z.map((O)=>({name:L.join(q,O),value:L.join(q,O),message:`${O} (${z})`})),Y=await s.promptForSelection({items:Q,message:`Multiple projects match "${$}". Please select one:`,nameField:"message",valueField:"value",allowAbort:!0});if(Y===null)return console.log(K.yellow("Operation cancelled.")),null;return Y}}return null}async function h(){let $=[],W=H.readdirSync(X).filter((q)=>/^\d{8}$/.test(q)).sort((q,G)=>G.localeCompare(q));for(let q of W){let G=L.join(X,q),Z=H.readdirSync(G);for(let Q of Z){let Y=L.join(G,Q),O=H.statSync(Y),M=`${q}/${Q}`;$.push({name:M,value:M,message:`${Q} (${q})`,created:O.birthtime})}}if($.sort((q,G)=>G.created-q.created),$.length===0)return null;let z=await s.promptForSelection({items:$,message:"Select a project:",nameField:"message",valueField:"value",allowAbort:!0});if(z===null)return console.log(K.yellow("Operation cancelled.")),null;return z}async function c1($){try{if((await A({type:"confirm",name:"openIDE",message:"Would you like to open the project in an IDE?",initial:!0})).openIDE)await r($)}catch(W){console.error(K.red(`Error opening IDE: ${W.message}`))}}async function r($){let W=await O1("code --version"),z=await O1("code-insiders --version"),q=null;if(W&&z)q=(await A({type:"select",name:"ide",message:"Which IDE would you like to use?",choices:[{name:"Visual Studio Code",value:"code"},{name:"Visual Studio Code Insiders",value:"code-insiders"}]})).ide;else if(W)q="code";else if(z)q="code-insiders";else{console.log(K.yellow("No supported IDE found. Please open the project manually.")),console.log(K.blue(`Project path: ${$}`));return}console.log(K.blue(`Opening project in ${q}...`)),console.log(K.blue(`Project path: ${$}`));let G=m(q,[$],{stdio:"inherit",shell:!0});return new Promise((Z,Q)=>{G.on("close",(Y)=>{if(Y===0)console.log(K.green(`Project opened in ${q}.`)),Z();else console.error(K.red(`Failed to open project in ${q}.`)),Q(Error(`Process exited with code ${Y}`))})})}async function O1($){return new Promise((W)=>{m($,{shell:!0,stdio:"ignore"}).on("close",(q)=>{W(q===0)})})}function T1($,W){if(!H.existsSync(W))H.mkdirSync(W,{recursive:!0});let z=H.readdirSync($,{withFileTypes:!0});for(let q of z){let G=L.join($,q.name),Z=L.join(W,q.name);if(q.isDirectory()){if(q.name===".git"||q.name===".workspace")continue;T1(G,Z)}else H.copyFileSync(G,Z)}}async function o1($){try{if(!H.existsSync(X)){console.log(K.yellow("No express projects found."));return}let W;if($.latest){if(W=await g(),!W){console.log(K.yellow("No express projects found."));return}}else if($.projectName){if(W=await l($.projectName),!W){console.log(K.yellow(`Project "${$.projectName}" not found.`));return}}else{let q=await h();if(!q){console.log(K.yellow("No project selected."));return}W=L.join(X,q)}let z=L.basename(W);if(!$.yes){if(!(await A({type:"confirm",name:"confirm",message:`Are you sure you want to remove project "${z}"?`,initial:!1})).confirm){console.log(K.yellow("Project removal cancelled."));return}}console.log(K.blue(`Removing project "${z}"...`)),H.rmSync(W,{recursive:!0,force:!0}),console.log(K.green(`Project "${z}" removed successfully.`))}catch(W){console.error(K.red(`Error removing express project: ${W.message}`)),process.exit(1)}}async function s1($){try{if(!H.existsSync(X)){console.log(K.yellow("No express projects found."));return}let W;if($.latest){if(W=await g(),!W){console.log(K.yellow("No express projects found."));return}}else if($.projectName){if(W=await l($.projectName),!W){console.log(K.yellow(`Project "${$.projectName}" not found.`));return}}else{let G=await h();if(!G){console.log(K.yellow("No project selected."));return}W=L.join(X,G)}console.log(K.blue(`Entering project directory: ${W}`)),console.log(K.yellow(`
9
+ Opening a new shell in the project directory...`));let z=process.env.SHELL||"/bin/bash",q=m(z,[],{stdio:"inherit",cwd:W,shell:!0});return new Promise((G)=>{q.on("close",()=>{console.log(K.green(`
10
+ Returned from project directory.`)),G()})})}catch(W){console.error(K.red(`Error entering express project directory: ${W.message}`)),process.exit(1)}}import C1 from"node:path";import{fileURLToPath as $$}from"node:url";import r1 from"node:fs";import p from"node:path";import{fileURLToPath as a1}from"node:url";var t1=p.dirname(a1(import.meta.url));function e1({baseDir:$}){$=$||t1;let W=$;while(W!==p.parse(W).root){let z=p.join(W,"node_modules");if(r1.existsSync(z))return z;W=p.dirname(W)}return null}var X1=e1;var W$=C1.dirname($$(import.meta.url));function w1(){let $=X1({baseDir:W$}),W=process.platform==="win32"?";":":";if($)process.env.PATH=`${C1.join($,"/.bin")}${W}${process.env.PATH}`}t();w1();async function z$(){try{let $=q$(process.argv.slice(2)).usage("Usage: $0 <command> [options]").command(G1).command(Q1).command(Y1).command(K1).command(U1).command(H1).command(M1).command("express","Create and manage express projects",V1);$=C($,{bin:"npm",createContext:V}),$=C($,{bin:"node",createContext:V}),$=C($,{bin:"bun",createContext:V}),$=C($,{name:"serve",bin:"bun",preArgs:["run","serve","--"],createContext:V}),$=C($,{name:"watch",bin:"bun",preArgs:["run","watch","--"],createContext:V}),$=C($,{name:"app",bin:"bun",preArgs:["run","app","--"],createContext:V}),$=C($,{name:"cli",bin:"bun",preArgs:["run","cli","--"],createContext:V}),$=C($,{name:"cli:dev",bin:"bun",preArgs:["run","cli:dev","--"],createContext:V}),$=C($,{name:"cli:compile",bin:"bun",preArgs:["run","cli:compile","--"],createContext:V}),$=C($,{name:"cli:compile:dev",bin:"bun",preArgs:["run","cli:compile:dev","--"],createContext:V}),$=C($,{name:"cli:install",bin:"bun",preArgs:["run","cli:install","--"],createContext:V}),$=C($,{name:"compile",bin:"bun",preArgs:["run","compile","--"],createContext:V}),$=W1($,{name:"install",createContext:V}),$=C($,{bin:"npx",createContext:V}),$=C($,{bin:"cdk",createContext:V}),$=C($,{bin:"aws",createContext:V}),$=e($,{name:"with",createContext:V}),$=$1($,{name:"run",projectType:"fnode"}),$=y($,{name:"python",createContext:V}),$=y($,{name:"python3",createContext:V}),$=y($,{name:"pip",createContext:V}),$=y($,{name:"pip3",createContext:V}),$.demandCommand(1,"You need at least one command before moving on").help().version().argv}catch($){console.error(B1.red(`Fatal error: ${$.message}`)),process.exit(1)}}z$().catch(($)=>{console.error(B1.red(`Fatal error: ${$.message}`)),process.exit(1)});
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import c from"@fnet/shelljs";import g from"@fnet/config";async function p({setProgress:e,context:r,deploymentProject:s,deploymentProjectTarget:i,buildId:m}){await e({message:"Deploying it as gitlab project."});let l=r.projectDir,a="fnet-to-gitlab",o=i.params.config||"gitlab",n=await g({name:o,dir:r.projectDir,tags:r.tags});if(!n)throw Error(`Couldnt load config ${o}`);let{data:t}=n.data;if(a+=` --projectGroupId=${t.projectGroupId}`,a+=` --projectPath='${l}'`,a+=` --projectName='${i.params.name}'`,a+=` --projectBranch='${i.params.branch||"main"}'`,a+=` --gitlabHost='${t.gitlabHost}'`,a+=` --gitlabToken='${t.gitlabToken}'`,a+=` --gitlabUsername='${t.gitlabUsername}'`,a+=` --gitlabUserEmail='${t.gitlabUserEmail}'`,i.dryRun===!0)return;await c(a),s.isDirty=!0}export{p as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import d from"@fnet/config";import l from"@flownet/lib-to-macos-app";import i from"lodash.clonedeep";import u from"semver";async function g({atom:p,target:e,onProgress:s,projectDir:n,dependencies:c,context:r,yamlTarget:t}){if(s)await s({message:"Deploying it as macos-app package."});let f=e?.config?await d({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:r.tags}):void 0,o=u.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,t.set("version",o);let a=i(e.params);a.dependencies=i(c);let m={atom:p,params:a,config:f?.config,src:n,dest:n};return{deployer:await l(m)}}export{g as default};
@@ -0,0 +1 @@
1
+ import"./index.cvxrf34y.js";import l from"@fnet/config";import d from"@fnet/to-pyip";import a from"lodash.clonedeep";import y from"semver";async function u({atom:p,target:e,onProgress:s,projectDir:n,dependencies:r,context:t,yamlTarget:f}){if(s)await s({message:"Deploying it as pypi package."});let c=e?.config?await l({name:e.config,dir:n,optional:!0,transferEnv:!1,tags:t.tags}):void 0,o=y.inc(e.version||"0.1.0","patch");e.params.version=o,e.version=o,f.set("version",o);let i=a(e.params);i.dependencies=a(r);let m={atom:p,params:i,config:c?.config,src:n,dest:n};return{deployer:await d(m)}}export{u as default};
@@ -0,0 +1,3 @@
1
+ import{b as CT,c as jT,d as hT}from"./index.s0nk6cv8.js";import{f as j}from"./index.05n3mvs9.js";import"./index.cvxrf34y.js";import F from"node:fs";import b from"node:path";import aT from"nunjucks";import eT from"@flownet/lib-parse-imports-js";import T0 from"@flownet/lib-parse-node-url";import I from"lodash.merge";import h from"node:fs";import N from"node:path";import _ from"@flownet/lib-parse-imports-js";import wT from"lodash.merge";function S({feature:$,features:z,packageDevDependencies:O}){let{name:W,packages:T,options:K,extraCheck:Z,explicit:G}=$,Q=`${W}_enabled`,M=z.rollup_output||{},A=Object.keys(M),J=K||{},V=z[W]?.options;if(V)J=wT(J,V);let X=!z[W]||z[W]?.enabled===!1;A.forEach((Y)=>{let q=z.rollup_output[Y];if(!q)return;if(Reflect.has(q,W)){if(X||!q[W]||q[W]?.enabled===!1){delete q[W];return}if(q[W]===!0)q[W]={enabled:!0,options:J}}else if(!X&&!G&&z[Q]!==!1)q[W]={enabled:!0};else return;q[W]=q[W]||{},q[W].options={...J,...q[W].options}});let y=A.some((Y)=>z.rollup_output[Y][W]?.enabled===!0);if(Z)y=Z()&&y;if(z[Q]=y,y)T.forEach((Y)=>O.push({package:Y[0],version:Y[1]}))}function w($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"workbox",packages:[["rollup-plugin-workbox","^8"]],options:{generate:{swDest:"dist/app/esm/sw.js",globDirectory:"dist/app/esm",globPatterns:["**/*.{html,js,css,png,jpg}"],skipWaiting:!0,clientsClaim:!0}},explicit:!0},features:W,packageDevDependencies:O})}function P($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:W,packageDevDependencies:O})}function v($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:W,packageDevDependencies:O})}function m($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:W,packageDevDependencies:O})}function k($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]],expilicit:!0},features:W,packageDevDependencies:O})}function g($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:W,packageDevDependencies:O})}function f($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:W,packageDevDependencies:O})}function i($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:W,packageDevDependencies:O})}function o($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;if(W.runtime.type==="bun")return;S({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:W,packageDevDependencies:O})}function u($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:W,packageDevDependencies:O})}function d($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;S({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:W,packageDevDependencies:O})}function D($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features;if(W.runtime.type==="bun")return;let T={};if(W.app?.enabled===!0){if(T.targets=T.targets||[],T.targets.push({src:"./src/app/index.html",dest:W.app.dir}),!Reflect.has(W.app,"copy")){if(!Reflect.has(W,"copy"))W.copy=!0}}S({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:T},features:W,packageDevDependencies:O})}function c($){let{atom:z,packageDevDependencies:O}=$,W=z.doc.features,T=W.css&&W.css.enabled!==!1,K=[];if(T)K.push(["rollup-plugin-postcss","^4"]),K.push(["sass","^1.66"]),(W.css?.options?.plugins||[]).forEach((G)=>{switch(G.name){case"postcss-import":K.push(["postcss-import","^15"]);break;case"postcss-url":K.push(["postcss-url","^10"]);break;case"postcss-preset-env":K.push(["postcss-preset-env","^9"]);break;case"autoprefixer":K.push(["autoprefixer","^10"]);break;case"cssnano":K.push(["cssnano","^6"]);break}});S({feature:{name:"css",packages:K},features:W,packageDevDependencies:O})}function r({dir:$,name:z="index"}){let O=N.resolve($,`./${z}.tsx`);if(!h.existsSync(O))O=N.resolve($,`./${z}.ts`);if(!h.existsSync(O))O=N.resolve($,`./${z}.jsx`);if(!h.existsSync(O))O=N.resolve($,`./${z}.js`);if(!h.existsSync(O))return{};let W=O,T=N.extname(O);return{file:W,ext:T,ts:T===".ts"||T===".tsx",name:z}}async function n($){let{atom:z,context:O,setProgress:W}=$;W("Initializing features..."),z.doc.features=z.doc.features||{};let T=z.doc.features;T.project=T.project||{},T.project.format=T.project.format||T.project_format||"esm",T.project_format=T.project.format,T.dts_enabled=T.dts===!0||typeof T.dts<"u"&&T.dts!==!1;let K=N.resolve(O.project.projectDir),Z=r({dir:N.resolve(K,"./app")});if(Z.file){W("Parsing app entry imports...");let Y=await _({file:Z.file,recursive:!0}),q=Y.all.some((H)=>H.usesJSX===!0&&H.type==="local");T.app_uses_jsx=q,T.app_has_entry=!0,Y=await _({file:Z.file}),q=Y.all.some((H)=>H.usesJSX===!0&&H.type==="local"),T.app_entry_uses_jsx=q,T.app_entry_is_ts=Z.ts,T.app_entry_ext=Z.ext}let G=r({dir:N.resolve(K,"./cli")});if(G.file){W("Parsing cli entry imports...");let Y=await _({file:G.file,recursive:!0}),q=Y.all.some((H)=>H.usesJSX===!0&&H.type==="local");T.cli_uses_jsx=q,T.cli_has_entry=!0,Y=await _({file:G.file}),q=Y.all.some((H)=>H.usesJSX===!0&&H.type==="local"),T.cli_entry_uses_jsx=q,T.cli_entry_is_ts=G.ts,T.cli_entry_ext=G.ext}if(z.type==="workflow.lib"){let Y=r({dir:N.resolve(K,"./src")});if(Y.file){W("Parsing src entry imports...");let q=await _({file:Y.file,recursive:!0}),H=q.all.some((U)=>U.usesJSX===!0&&U.type==="local");T.src_uses_jsx=H,T.src_has_entry=!0,q=await _({file:Y.file}),H=q.all.some((U)=>U.usesJSX===!0&&U.type==="local"),T.src_entry_uses_jsx=H,T.src_entry_is_ts=Y.ts,T.src_entry_ext=Y.ext}}let Q=Reflect.has(T,"app_entry_uses_jsx")?T.app_entry_uses_jsx===!0:T.src_entry_uses_jsx===!0,M=Reflect.has(T,"cli_entry_uses_jsx")?T.cli_entry_uses_jsx===!0:T.src_entry_uses_jsx===!0;if(T.form_enabled=Q||M||T.form===!0||T.form?.enabled===!0,T.multiple_enabled=T.multiple_enabled||T.multiple===!0||T.multiple?.enabled===!0,T.app===!1)T.app={enabled:!1};else if(T.app===!0)T.app={enabled:!0,extend:T.app_has_entry===!0,export:!0,react:Q};else T.app={enabled:!0,extend:T.app_has_entry===!0,export:!0,react:Q,...T.app||{}};if(T.app.enabled=T.app.enabled===!0&&(z.doc.features.form_enabled===!0||T.app.extend===!0||T.app.enabled===!0),T.app.format=T.app.format||"esm",T.app.folder=T.app.folder||T.app.format||"default",T.cli===!1)T.cli={enabled:!1};else if(T.cli===!0)T.cli={enabled:!0,extend:T.cli_has_entry===!0,export:!0,react:M};else T.cli={enabled:!0,extend:T.cli_has_entry===!0,export:!0,react:M,...T.cli||{}};if(T.cli.enabled=T.cli.enabled===!0&&(z.doc.features.form_enabled===!1||T.cli.extend===!0||T.cli.enabled===!0),T.cli.format=T.cli.format||"esm",T.cli.folder=T.cli.folder||T.cli.folder||"esm",T.cli.node_options=T.cli.node?.options||T.cli.node_options||"",T.cli.bin=T.cli.bin||z.doc.name,T.cli.installable=T.cli.installable===!0,T.cli.enabled)z.doc["npm::bin"]=T.cli.bin;T.json=T.cli.enabled||T.json;let A={cjs:{format:"cjs",context:T.form_enabled?"window":"global",babel:T.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!0,enabled:T.cjs!==!1,copy:!1},esm:{format:"esm",context:T.form_enabled?"window":"global",babel:T.src_uses_jsx===!0||!1,browser:!1,replace:!0,terser:!1,enabled:T.esm!==!1,copy:!0},iife:{format:"iife",context:T.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:T.iife===!0,terser:!0,copy:!1}},J={targets:{browsers:"last 9 versions, not dead",node:"18"}},V={};if(T.webos===!0)A.webos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,input:"./src/app/index.js",output_dir:"./dist/app/webos",copy:!1,babel_options:{targets:{chrome:"79"}}};if(T.electron===!0)A.electron={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/electron"};if(T.nextjs===!0)A.nextjs={format:"esm",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/nextjs"};if(T.ios===!0)A.ios={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/ios"};if(T.macos===!0)A.macos={format:"iife",browser:!0,babel:!0,context:"window",replace:!0,terser:!0,copy:!1,input:"./src/app/index.js",output_dir:"./dist/app/macos"};if(T.app.enabled===!0)T.app.dir=`./dist/app/${T.app.folder}`,T.app.output={file:`./dist/app/${T.app.folder}/index.js`,dir:`./dist/app/${T.app.folder}/`,...T.app.output||{}},T.app.input={file:"./src/app/index.js",dir:"./src/app/",...T.app.input||{}},A.app={format:T.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:T.app.input.file,output_dir:T.app.dir,terser:!0,output_exports:T.app.export===!1?"none":"auto",browsersync:!0};if(T.cli.enabled===!0)T.cli.dir=`./dist/cli/${T.cli.folder}`,T.cli.output={file:`./dist/cli/${T.cli.folder}/index.js`,dir:`./dist/cli/${T.cli.folder}/`,...T.cli.output||{}},T.cli.input={file:"./src/cli/index.js",dir:"./src/cli/",...T.cli.input||{}},A.cli={format:T.cli.format,context:"global",babel:T.src_uses_jsx===!0||T.cli_uses_jsx===!0||!1,browser:!1,replace:!0,enabled:!0,input:T.cli.input.file,output_dir:T.cli.dir,banner:"#!/usr/bin/env bun",terser:!0,output_exports:T.cli.export===!1?"none":"auto"};let X={server:".",startPath:`${N.normalize(T.app.dir||".")}`,files:[N.normalize("./dist/**/*")],cors:!0,open:!1};if(T.babel_options=I(J,T.babel_options||T.babel?.options),T.browsersync_options=I(X,T.browsersync_options||T.browsersync?.options||{}),T.replace_options=I(V,T.replace_options||T.replace?.options||{}),Reflect.has(T.browsersync_options,"proxy"))delete T.browsersync_options.server;T.rollup=T.rollup||{},T.rollup_output=I(A,T.rollup_output||T.rollup?.output||{}),T.preact_enabled=T.preact===!0||T.preact&&T.preact?.enabled!==!1;let y=Object.keys(A);for(let Y of y){let q=A[Y];if(!q)continue;if(T.rollup[Y]===!1){delete T.rollup_output[Y];continue}if(q.babel_options=q.babel_options||T.babel_options,q.browsersync_options=I(T.browsersync_options,q.browsersync_options),q.replace_options=I(T.replace_options,q.replace_options),T.preact_enabled)q.alias_enabled=!0,q.alias=q.alias||{},q.alias.entries=q.alias.entries||{},q.alias.entries.react="preact/compat",q.alias.entries["react-dom"]="preact/compat";if(T.form_enabled||T.babel)q.babel=!0}y=Object.keys(T.rollup_output),T.babel_enabled=y.some((Y)=>T.rollup_output[Y].babel===!0),T.browser_enabled=y.some((Y)=>T.rollup_output[Y].babel===!0),T.browsersync_enabled=T.browsersync!==!1&&y.some((Y)=>T.rollup_output[Y].browsersync===!0),T.browsersync_enabled=T.browsersync_enabled&&T.app.enabled,T.dependency_auto_enabled=T.dependency_auto!==!1&&T.dependency_auto?.enabled!==!1,T.npm_install_flags=T.npm_install_flags||"",T.react_version=T.react_version||T.react?.version||18,T.bpmn=T.bpmn||{},T.bpmn.enabled=T.bpmn.enabled!==!1,T.bpmn.per_flow=T.bpmn.per_flow===!0,c($),D($),d($),u($),o($),f($),i($),g($),k($),m($),v($),w($),P($)}import PT from"@fnet/npm-list-versions";async function p({atom:$,packageDependencies:z,packageDevDependencies:O,setProgress:W}){W("Initializing dependencies");let T=$.doc.dependencies||[];if(T.filter((K)=>!K.dev).forEach((K)=>z.push(K)),T.filter((K)=>K.dev).forEach((K)=>O.push(K)),$.type==="workflow")z.push({package:"dot-prop",version:"^10"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let K="^18.2";if(W("Fetching React versions"),K=`^${(await PT({name:"react",groupBy:{major:!0}})).find((Q)=>Q[0]===$.doc.features.react_version.toString())[0]}`,z.push({package:"react",version:K}),z.push({package:"react-dom",version:K}),$.type==="workflow")z.push({package:"@fnet/react-app",version:"^0.1"}),z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)z.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(z.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)z.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled===!0)z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),z.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)O.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"});if(O.push({package:"@babel/core",version:"^7"}),O.push({package:"@rollup/plugin-commonjs",version:"^28"}),O.push({package:"@rollup/plugin-node-resolve",version:"^16"}),O.push({package:"@rollup/plugin-replace",version:"^6"}),O.push({package:"rollup",version:"^4"}),$.doc.features.dts_enabled)O.push({package:"rollup-plugin-dts",version:"^6"});if(O.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),O.push({package:"@rollup/plugin-alias",version:"^5"}),O.push({package:"fs-extra",version:"^11"}),$.doc.features.babel_enabled)O.push({package:"@rollup/plugin-babel",version:"^6"}),O.push({package:"@babel/preset-env",version:"^7"}),O.push({package:"@babel/preset-react",version:"^7"}),$.doc.features.babel?.options?.plugins?.forEach((K)=>{switch(K[0]){case"@babel/plugin-proposal-decorators":O.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":O.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":O.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":O.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":O.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"});break}});if(O.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),$.doc.features.browsersync_enabled)O.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}import vT from"@fnet/npm-list-versions";async function s({atom:$,packageDependencies:z,packageDevDependencies:O,setProgress:W}){W("Initializing dependencies for Bun");let T=$.doc.dependencies||[];if(T.filter((K)=>!K.dev).forEach((K)=>z.push(K)),T.filter((K)=>K.dev).forEach((K)=>O.push(K)),$.type==="workflow")z.push({package:"dot-prop",version:"^10"});if($.doc.features.form_enabled){if($.doc.features.dependency_auto_enabled){let K="^18.2";if(W("Fetching React versions"),K=`^${(await vT({name:"react",groupBy:{major:!0}})).find((Q)=>Q[0]===$.doc.features.react_version.toString())[0]}`,z.push({package:"react",version:K}),z.push({package:"react-dom",version:K}),$.type==="workflow")z.push({package:"@fnet/react-app",version:"^0.1"}),z.push({package:"@fnet/react-app-state",version:"^0.1"})}}if($.doc.features.preact_enabled)z.push({package:"preact",version:"^10"});if($.doc.features.cli.enabled===!0){if(z.push({package:"@fnet/args",version:"^0.1"}),$.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1)z.push({package:"@fnet/config",version:"0.2.21"});if($.doc.features.cli.mcp&&$.doc.features.cli.mcp.enabled===!0)z.push({package:"@modelcontextprotocol/sdk",version:"^1.10"}),z.push({package:"express",version:"^4.18"})}if($.doc.features.render&&$.doc.features.render.enabled!==!1)O.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"})}import AT from"node:fs";import ST from"node:path";import mT from"@flownet/lib-render-templates-dir";async function t({atom:$,setProgress:z,context:O,packageDependencies:W}){if($.doc.features.app.enabled!==!0)return;await z({message:"Creating app folder"});let T={atom:$,packageDependencies:W,ts:Date.now()},K=O.templateDir,Z=ST.resolve(O.projectDir,"src/app");if(!AT.existsSync(Z))AT.mkdirSync(Z,{recursive:!0});let G=["index.js.njk"];if($.doc.features.app.html!==!1)G.push("index.html.njk");await mT({pattern:G,dir:ST.resolve(K,"src/app"),outDir:Z,context:T})}import yT from"nunjucks";import L from"node:fs";import E from"node:path";import fT from"@flownet/lib-parse-imports-js";import kT from"@fnet/npm-pick-versions";import gT from"object-hash";import l from"node:fs";import UT from"node:path";async function C({projectDir:$,name:z,setProgress:O,count:W=1}){let T,Z=gT(["npm-pick-versions",z,W]),G=UT.join($,".cache"),Q=UT.join(G,Z+".json");if(l.existsSync(Q)){if(O)O(`Picking npm version of ${z} from cache ...`);T=JSON.parse(l.readFileSync(Q,"utf8"))}else{if(O)O(`Picking npm version of ${z} ...`);T=await kT({name:z,count:W}),l.mkdirSync(G,{recursive:!0}),l.writeFileSync(Q,JSON.stringify(T),"utf8")}return T}async function a({atom:$,context:z,packageDependencies:O,packageDevDependencies:W,setProgress:T}){await T({message:"Creating package.json."}),O.filter((q)=>q.dev===!0).forEach((q)=>{if(!W.find((U)=>U.package===q.package))W.push(q);let H=O.findIndex((U)=>U.package===q.package);O.splice(H,1)});let Z=O.find((q)=>q.package==="react"),G=O.find((q)=>q.package==="react-dom");if(Z&&!G)O.push({package:"react-dom",version:Z.version});else if(Z&&G)G.version=Z.version;if(Z&&$.doc.features.react_version>=17){if(!O.find((q)=>q.package==="@emotion/react"))O.push({package:"@emotion/react",version:"^11"});if(!O.find((q)=>q.package==="@emotion/styled"))O.push({package:"@emotion/styled",version:"^11"})}let Q=[];if($.doc.features.app.enabled===!0)Q.push({file:E.resolve(z.projectDir,"src/app/index.js"),dev:$.doc.features.app.dev===!0});if($.doc.features.cli.enabled===!0)Q.push({file:E.resolve(z.projectDir,"src/cli/index.js"),dev:$.doc.features.cli.dev===!0});for await(let q of Q){let H=q.file;if(!L.existsSync(H))throw Error(`App file not found: ${H}`);let R=(await fT({file:H,recursive:!0,verbose:!1})).all;for await(let B of R){if(B.type!=="npm")continue;if(O.find((x)=>x.package===B.package))continue;if(W.find((x)=>x.package===B.package))continue;let xT=await C({name:B.package,projectDir:z.projectDir,setProgress:T});(q.dev===!0?W:O).push({package:B.package,subpath:B.subpath,version:xT.minorRange,type:"npm"})}}let M={atom:$,packageDependencies:O,packageDevDependencies:W},A=z.templateDir,V=yT.compile(L.readFileSync(E.resolve(A,"package.json.njk"),"utf8"),yT.configure(A)).render(M),X=z.projectDir,y=E.resolve(X,"package.json");L.writeFileSync(y,V,"utf8");let Y=E.resolve(z.project.projectDir,"fnet");if(L.existsSync(Y)){let q=E.resolve(z.projectDir,"fnet");if(!L.existsSync(q))L.mkdirSync(q);let H=L.readdirSync(Y);for(let U of H){let R=E.resolve(Y,U);if(!L.lstatSync(R).isFile())continue;let B=E.resolve(q,U);L.copyFileSync(R,B)}}}import XT from"node:fs";import VT from"node:path";import iT from"@flownet/lib-render-templates-dir";async function e({atom:$,setProgress:z,context:O,packageDependencies:W}){if($.doc.features.cli.enabled!==!0)return;await z({message:"Creating cli."});let T={atom:$,packageDependencies:W},K=O.templateDir,Z=VT.resolve(O.projectDir,"src/cli");if(!XT.existsSync(Z))XT.mkdirSync(Z,{recursive:!0});await iT({pattern:["index.js.njk"],dir:VT.resolve(K,"src/cli"),outDir:Z,context:T})}import TT from"node:fs";import $T from"node:path";import JT from"nunjucks";import oT from"@flownet/lib-parse-imports-js";async function OT({atom:$,setProgress:z,context:O,packageDependencies:W}){await z({message:"Creating rollup file."});let T={atom:$,packageDependencies:W},K=$T.resolve(O.projectDir,"src","default/index.js");if(!TT.existsSync(K))throw Error(`Entry file not found: ${K}`);let G=(await oT({file:K,recursive:!0})).all.filter((Y)=>Y.type==="node").map((Y)=>Y.path),Q=$.doc.features.rollup_output,M=Object.keys(Q);for(let Y=0;Y<M.length;Y++){let q=M[Y],H=Q[q];if(H.browser===!0){if(G.length>0){H.globals_enabled=!0,H.globals=H.globals||[],H.globals=H.globals.concat(G.map((U)=>{return{key:U,value:U}})),H.alias_enabled=!0,H.alias=H.alias||{},H.alias.entries=H.alias.entries||{};for(let U=0;U<G.length;U++){let R=G[U];H.alias.entries[R]=`node:${R}`,H.alias.entries[`node:${R}`]=R}H.external_enabled=!0,H.external=H.external||[],H.external=H.external.concat(G)}}}let A=O.templateDir,V=JT.compile(TT.readFileSync($T.resolve(A,"rollup.config.mjs.njk"),"utf8"),JT.configure(A)).render(T),X=O.projectDir,y=$T.resolve(X,"rollup.config.mjs");TT.writeFileSync(y,V,"utf8")}import zT from"node:fs";import bT from"node:path";import NT from"nunjucks";async function WT({atom:$,setProgress:z,context:O,packageDependencies:W}){await z({message:"Creating build.js file."});let T={atom:$,packageDependencies:W},K=O.templateDir,G=NT.compile(zT.readFileSync(bT.resolve(K,"build.js.njk"),"utf8"),NT.configure(K)).render(T),Q=O.projectDir,M=bT.resolve(Q,"build.js");zT.writeFileSync(M,G,"utf8"),zT.chmodSync(M,"755")}import KT from"node:fs";import qT from"node:path";import uT from"nunjucks";import dT from"ajv/dist/2020.js";import DT from"ajv/dist/standalone/index.js";import cT from"ajv-formats";async function GT({atom:$,setProgress:z,context:O,njEnv:W}){if($.doc.features.cli.enabled!==!0)return;await z({message:"Creating input args."});let T={},K=[];if($.doc.input)T=$.doc.input;else T={type:"object",properties:{},required:[]};if($.doc.features.cli.fargs&&$.doc.features.cli.fargs?.enabled!==!1){let H=$.doc.features.cli.fargs,U={type:"string",description:"Config name to load args",hidden:!1},R={type:"array",description:"Tags to filter the config",hidden:!1};if(Reflect.has(H,"default"))U.default=H.default}let G={imports:K,atom:$},Q=O.templateDir,A=uT.compile(KT.readFileSync(qT.resolve(Q,"src/default/input.args.js.njk"),"utf8"),W).render(G),J=O.projectDir,V=qT.resolve(J,"src/default/input.args.js");KT.writeFileSync(V,A,"utf8");let X=new dT({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});cT(X);let y=X.compile(T),q=DT(X,y)+`
2
+ export { schema31 as schema };`;KT.writeFileSync(qT.resolve(J,"src/default/validate_input.js"),q,"utf8")}import RT from"node:fs";import LT from"node:path";import BT from"nunjucks";async function QT({atom:$,setProgress:z,context:O,packageDependencies:W}){await z({message:"Creating tsconfig.json."});let T={atom:$,packageDependencies:W},K=O.templateDir,G=BT.compile(RT.readFileSync(LT.resolve(K,"tsconfig.json.njk"),"utf8"),BT.configure(K)).render(T),Q=O.projectDir,M=LT.resolve(Q,"tsconfig.json");RT.writeFileSync(M,G,"utf8")}import rT from"node:path";import ET from"@fnet/shelljs";async function YT({setProgress:$,context:z}){let O=z.projectDir;await $({message:"Prettifiying source files."});let W=rT.join("src","**","*");if(j("bun")){let T=await ET(`prettier --write ${W} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:O});if(T.code!==0)throw Error(T.stderr)}else{let T=await ET(`prettier --write ${W} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:O});if(T.code!==0)throw Error(T.stderr)}}import nT from"@fnet/shelljs";async function ZT({atom:$,setProgress:z,context:O}){if(!$.doc.features.dts_enabled)return;let W=O.projectDir;if(await z({message:"Creating .d.ts"}),(await nT("tsc",{cwd:W})).code!==0)throw Error("Couldnt create .d.ts files.")}import IT from"@fnet/shelljs";async function HT({setProgress:$,atom:z,context:O}){let W=O.projectDir;if(await $({message:"Installing npm packages."}),j("bun")){if((await IT(`bun install ${z.doc.features.npm_install_flags}`,{cwd:W})).code!==0)throw Error("Couldnt install npm packages.")}else if((await IT(`npm install ${z.doc.features.npm_install_flags}`,{cwd:W})).code!==0)throw Error("Couldnt install npm packages.")}import _T from"node:fs";import pT from"node:path";import{spawn as sT}from"node:child_process";async function FT($){let{projectDir:z,scriptName:O,args:W=[],env:T=process.env,shell:K=!0,detached:Z=!0,onSpawn:G}=$;if(!z||!O)throw Error("projectDir and scriptName are required");let Q=pT.resolve(z,"package.json");if(!_T.existsSync(Q))throw Error(`package.json not found at ${Q}`);let M=JSON.parse(_T.readFileSync(Q,"utf8")),A=M.scripts?.[O];if(!A){let X=Object.keys(M.scripts||{}).join(", ");throw Error(`Script '${O}' not found. Available: ${X}`)}let J=W.length>0?`${A} ${W.join(" ")}`:A,V=sT(J,[],{cwd:z,stdio:"inherit",shell:K,detached:Z,env:{...T}});if(G)G(V);return new Promise((X,y)=>{V.on("error",(Y)=>{y(Error(`Failed to start '${O}': ${Y.message}`))}),V.on("close",(Y)=>{X({subprocess:V,exitCode:Y})})})}import tT from"node:path";async function MT({setProgress:$,context:z}){let O=z.projectDir;await $({message:"Building main project."});let W=z.dev?"build:dev":"build",T={...process.env},K=tT.join(O,"node_modules");T.NODE_PATH=K,T.NODE_PRESERVE_SYMLINKS=1,await FT({projectDir:O,scriptName:W,shell:!0,detached:!0,env:T})}class lT extends CT{async initRuntime(){if(await n(this.apiContext),this.apiContext.context.project.runtime.type==="bun")await s(this.apiContext);else await p(this.apiContext);await this.initLibraryDir(),await this.initNunjucks(),await this.initLibs()}async initLibs(){this.setProgress({message:"Initializing external libs."});let $=[{name:this.atom.doc.name,type:"atom",parent_id:this.atom.parent_id}];this.libs=$,await this.initAtomLibsAndDeps({libs:$,packageDependencies:this.apiContext.packageDependencies})}async initAtomLibsAndDeps({libs:$,packageDependencies:z}){let O=$.filter((W)=>W.type==="atom");for(let W=0;W<O.length;W++){let T=O[W],K=await this.findAtomLibrary({url:T.name});T.atom=K,K.doc.dependencies?.filter((G)=>typeof G.repo>"u"||G.repo==="npm")?.forEach((G)=>{let Q=z.find((M)=>M.package===G.package);if(Q){if(typeof G.path==="string"){if(!(Q.path||[]).some((M)=>M===G.path))Q.path=Q.path||[],Q.path.push(G.path)}else if(Array.isArray(G.path))G.path.forEach((M)=>{if(!(Q.path||[]).some((A)=>A===M))Q.path=Q.path||[],Q.path.push(M)})}else z.push(G)})}z.sort((W,T)=>W.package?.localeCompare(T.package))}async findAtomLibrary({url:$}){let z=T0({url:$});if(!z)throw Error(`Invalid package name: ${$}`);if(!z.protocol)z.protocol=this.context.protocol;if(z.protocol==="ac:"){let O=z.pathname.split("/");if(O.length===1)return await this.apiContext.Atom.first({where:{name:$,parent_id:this.atomConfig.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(O.length===2){let W=await this.apiContext.Atom.first({where:{name:O[0],parent_id:this.atomConfig.env.ATOM_LIBRARIES_ID,type:"folder"}});return await this.apiContext.Atom.first({where:{name:O[1],parent_id:W.id,type:"workflow.lib"}})}}else if(z.protocol==="src:"){let O=this.atom;O.protocol="src:",O.doc.dependencies=O.doc.dependencies||[],O.name=O.doc.name;let W=b.resolve(this.context.projectSrcDir,"index.js"),T=await eT({file:W,recursive:!0}),K=O.doc.dependencies,Z=T.all;for await(let G of Z){if(G.type!=="npm")continue;if(K.find((M)=>M.package===G.package))continue;let Q=await C({name:G.package,projectDir:this.context.projectDir,setProgress:this.apiContext.setProgress});K.push({package:G.package,subpath:G.subpath,version:Q.minorRange,type:"npm"})}return O}}async createAtomLibFiles({libs:$}){await this.setProgress({message:"Creating external lib files."}),this.atom.typesDir="./types";let z=$.filter((O)=>O.type==="atom");for(let O=0;O<z.length;O++){let T=z[O].atom,K=this.context.projectDir;if(T.protocol==="src:"){let Z=b.resolve(this.context.projectSrcDir,`${T.fileName||T.name}.js`),G=b.relative(b.join(this.context.projectDir,"src","default"),Z);if(!F.existsSync(Z)){F.mkdirSync(b.dirname(Z),{recursive:!0});let Q=`export default async (input)=>{
3
+ `;Q+="}",F.writeFileSync(Z,Q,"utf8")}T.relativePath=G.split(b.sep).join("/"),this.atom.typesDir=`./types/${b.basename(K)}/src`}else{let Z=b.join(K,"src","libs",`${T.id}.js`),G=T.doc.contents?.find((Q)=>Q.format==="esm")||T.doc;F.writeFileSync(Z,G.content,"utf8")}}}async createEngine(){await this.setProgress({message:"Creating engine file."});let z={libs:this.libs.filter((G)=>G.type==="atom"),libraryAtom:this.atom,atom:this.atom},O=this.context.templateDir,T=aT.compile(F.readFileSync(b.resolve(O,b.join("src","default","engine.js.njk")),"utf8"),this.apiContext.njEnv).render(z),K=this.context.projectDir,Z=b.resolve(K,b.join("src","default","index.js"));F.writeFileSync(Z,T,"utf8")}async build(){try{if(this.fileMode){let $=this.apiContext.context.project;if(await this.createAtomLibFiles({libs:this.libs}),await this.createEngine(),await this.createProjectYaml(),await hT(this.apiContext),await QT(this.apiContext),await jT(this.apiContext),await GT(this.apiContext),await e(this.apiContext),await t(this.apiContext),$.runtime.type==="bun")await WT(this.apiContext);else await OT(this.apiContext);if(await a(this.apiContext),await YT(this.apiContext),await ZT(this.apiContext),this.buildMode){if(await HT(this.apiContext),await MT(this.apiContext),this.deployMode)await this.deploy()}}await this._cache_set(this.buildKey,{status:"COMPLETED"})}catch($){throw await this._cache_set(this.buildKey,{status:"FAILED",message:$.message||$}),console.log($),$}}}var B1=lT;export{B1 as default};
@@ -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};