@fnet/cli 0.111.0 → 0.111.2

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 (154) hide show
  1. package/dist/fnet/index.DBSKvJyG.js +1 -0
  2. package/dist/fnet/index.DrwlOzAe.js +1 -0
  3. package/dist/fnet/index.js +1 -1
  4. package/dist/fnode/index.53yND1Av.js +1 -0
  5. package/dist/fnode/index.B1zLg4Y2.js +1 -0
  6. package/dist/fnode/index.B2LXSSn7.js +1 -0
  7. package/dist/fnode/index.BBrItYB9.js +1 -0
  8. package/dist/fnode/index.BSQp_bJN.js +1 -0
  9. package/dist/fnode/index.Bqzc7Bx8.js +1 -0
  10. package/dist/fnode/index.BwhWziH6.js +1 -0
  11. package/dist/fnode/index.CLlKzCGk.js +1 -0
  12. package/dist/fnode/index.Chvv_TJm.js +1 -0
  13. package/dist/fnode/index.D4KQB1ot.js +1 -0
  14. package/dist/fnode/index.DItyYiZ_.js +1 -0
  15. package/dist/fnode/index.DrwlOzAe.js +1 -0
  16. package/dist/fnode/index.js +1 -1
  17. package/dist/frun/index.js +126 -0
  18. package/package.json +8 -9
  19. package/readme.md +117 -25
  20. package/template/fnet/bun/fnet/flows.yaml.njk +1 -0
  21. package/template/fnet/bun/fnet.yaml.njk +1 -0
  22. package/template/fnet/bun/src/app/index.html.njk +67 -0
  23. package/template/fnet/bun/src/app/index.js.njk +36 -0
  24. package/template/fnet/bun/src/cli/index.js.njk +44 -0
  25. package/template/fnet/bun/src/default/blocks/assign.js.njk +40 -0
  26. package/template/fnet/bun/src/default/blocks/call.js.njk +92 -0
  27. package/template/fnet/bun/src/default/blocks/for.js.njk +81 -0
  28. package/template/fnet/bun/src/default/blocks/form.js.njk +65 -0
  29. package/template/fnet/bun/src/default/blocks/jump.js.njk +31 -0
  30. package/template/fnet/bun/src/default/blocks/modules.js.njk +50 -0
  31. package/template/fnet/bun/src/default/blocks/operation.js.njk +24 -0
  32. package/template/fnet/bun/src/default/blocks/raise.js.njk +25 -0
  33. package/template/fnet/bun/src/default/blocks/return.js.njk +27 -0
  34. package/template/fnet/bun/src/default/blocks/steps.js.njk +56 -0
  35. package/template/fnet/bun/src/default/blocks/switch.js.njk +73 -0
  36. package/template/fnet/bun/src/default/blocks/tryexcept.js.njk +65 -0
  37. package/template/fnet/bun/src/default/engine.js.njk +79 -0
  38. package/template/fnet/bun/src/default/macros/block-body-header.js.njk +7 -0
  39. package/template/fnet/bun/src/default/macros/block-footer.js.njk +3 -0
  40. package/template/fnet/bun/src/default/macros/block-header.js.njk +14 -0
  41. package/template/fnet/bun/src/default/macros/block-library-header.js.njk +19 -0
  42. package/template/fnet/bun/src/default/macros/block-modules-header.js.njk +8 -0
  43. package/template/fnet/bun/src/default/macros/block-modules.js.njk +29 -0
  44. package/template/fnet/bun/src/default/macros/block-next-header.js.njk +6 -0
  45. package/template/fnet/bun/src/default/macros/block-next.js.njk +20 -0
  46. package/template/fnet/bun/src/default/macros/block-run-form.js.njk +32 -0
  47. package/template/fnet/bun/src/default/macros/block-run-header.js.njk +39 -0
  48. package/template/fnet/bun/src/default/macros/page.js.njk +8 -0
  49. package/template/fnet/bun/src/default/macros/workflow-header.js.njk +7 -0
  50. package/template/fnet/bun/src/default/to.args.js.njk +120 -0
  51. package/template/fnet/bun/src/default/workflow.js.njk +117 -0
  52. package/template/fnet/core/assert.js +6 -0
  53. package/template/fnet/core/message.js +3 -0
  54. package/template/fnet/core/object.js +43 -0
  55. package/template/fnet/core/print.js +1 -0
  56. package/template/fnet/core/sleep.js +5 -0
  57. package/template/fnet/node/.gitignore.njk +8 -0
  58. package/template/fnet/node/fnet/flows.yaml.njk +1 -0
  59. package/template/fnet/node/fnet.yaml.njk +1 -0
  60. package/template/fnet/node/package.json.njk +90 -0
  61. package/template/fnet/node/readme.md.njk +21 -0
  62. package/template/fnet/node/rollup.config.mjs.njk +363 -0
  63. package/template/fnet/node/rollup_config_external.njk +8 -0
  64. package/template/fnet/node/rollup_config_onwarn.njk +9 -0
  65. package/template/fnet/node/rollup_config_output_banner.njk +3 -0
  66. package/template/fnet/node/rollup_config_output_footer.njk +5 -0
  67. package/template/fnet/node/rollup_config_output_globals.njk +9 -0
  68. package/template/fnet/node/rollup_config_output_name.njk +3 -0
  69. package/template/fnet/node/rollup_config_plugins.njk +90 -0
  70. package/template/fnet/node/src/app/index.html.njk +67 -0
  71. package/template/fnet/node/src/app/index.js.njk +36 -0
  72. package/template/fnet/node/src/cli/index.js.njk +44 -0
  73. package/template/fnet/node/src/default/blocks/assign.js.njk +40 -0
  74. package/template/fnet/node/src/default/blocks/call.js.njk +92 -0
  75. package/template/fnet/node/src/default/blocks/for.js.njk +81 -0
  76. package/template/fnet/node/src/default/blocks/form.js.njk +65 -0
  77. package/template/fnet/node/src/default/blocks/jump.js.njk +31 -0
  78. package/template/fnet/node/src/default/blocks/modules.js.njk +50 -0
  79. package/template/fnet/node/src/default/blocks/operation.js.njk +24 -0
  80. package/template/fnet/node/src/default/blocks/raise.js.njk +25 -0
  81. package/template/fnet/node/src/default/blocks/return.js.njk +27 -0
  82. package/template/fnet/node/src/default/blocks/steps.js.njk +56 -0
  83. package/template/fnet/node/src/default/blocks/switch.js.njk +73 -0
  84. package/template/fnet/node/src/default/blocks/tryexcept.js.njk +65 -0
  85. package/template/fnet/node/src/default/engine.js.njk +79 -0
  86. package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
  87. package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
  88. package/template/fnet/node/src/default/macros/block-header.js.njk +14 -0
  89. package/template/fnet/node/src/default/macros/block-library-header.js.njk +19 -0
  90. package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
  91. package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
  92. package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
  93. package/template/fnet/node/src/default/macros/block-next.js.njk +20 -0
  94. package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
  95. package/template/fnet/node/src/default/macros/block-run-header.js.njk +39 -0
  96. package/template/fnet/node/src/default/macros/page.js.njk +8 -0
  97. package/template/fnet/node/src/default/macros/workflow-header.js.njk +7 -0
  98. package/template/fnet/node/src/default/to.args.js.njk +120 -0
  99. package/template/fnet/node/src/default/workflow.js.njk +117 -0
  100. package/template/fnet/node/tsconfig.json.njk +16 -0
  101. package/template/fnet/project/.gitignore.njk +7 -0
  102. package/template/fnet/project/.vscode/launch.json +41 -0
  103. package/template/fnet/project/.vscode/tasks.json +46 -0
  104. package/template/fnet/project/fnet/flows.yaml.njk +4 -0
  105. package/template/fnet/project/fnet/targets.yaml.njk +7 -0
  106. package/template/fnet/project/fnet.yaml.njk +3 -0
  107. package/template/fnode/bun/.gitignore.njk +8 -0
  108. package/template/fnode/bun/build.js.njk +156 -0
  109. package/template/fnode/bun/fnode.yaml.njk +1 -0
  110. package/template/fnode/bun/package.json.njk +89 -0
  111. package/template/fnode/bun/readme.md.njk +21 -0
  112. package/template/fnode/bun/src/app/index-js-with-react-host.njk +50 -0
  113. package/template/fnode/bun/src/app/index-js-without-react-host.njk +23 -0
  114. package/template/fnode/bun/src/app/index.html.njk +67 -0
  115. package/template/fnode/bun/src/app/index.js.njk +9 -0
  116. package/template/fnode/bun/src/cli/index.js.njk +81 -0
  117. package/template/fnode/bun/src/default/engine.js.njk +17 -0
  118. package/template/fnode/bun/src/default/to.args.js.njk +120 -0
  119. package/template/fnode/bun/tsconfig.json.njk +16 -0
  120. package/template/fnode/node/.gitignore.njk +8 -0
  121. package/template/fnode/node/fnode.yaml.njk +1 -0
  122. package/template/fnode/node/package.json.njk +90 -0
  123. package/template/fnode/node/readme.md.njk +21 -0
  124. package/template/fnode/node/rollup.config.mjs.njk +363 -0
  125. package/template/fnode/node/rollup_config_external.njk +8 -0
  126. package/template/fnode/node/rollup_config_onwarn.njk +9 -0
  127. package/template/fnode/node/rollup_config_output_banner.njk +3 -0
  128. package/template/fnode/node/rollup_config_output_footer.njk +5 -0
  129. package/template/fnode/node/rollup_config_output_globals.njk +9 -0
  130. package/template/fnode/node/rollup_config_output_name.njk +3 -0
  131. package/template/fnode/node/rollup_config_plugins.njk +90 -0
  132. package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
  133. package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
  134. package/template/fnode/node/src/app/index.html.njk +67 -0
  135. package/template/fnode/node/src/app/index.js.njk +9 -0
  136. package/template/fnode/node/src/cli/index.js.njk +81 -0
  137. package/template/fnode/node/src/default/engine.js.njk +17 -0
  138. package/template/fnode/node/src/default/to.args.js.njk +120 -0
  139. package/template/fnode/node/tsconfig.json.njk +16 -0
  140. package/template/fnode/project/.gitignore.njk +11 -0
  141. package/template/fnode/project/.vscode/launch.json.njk +78 -0
  142. package/template/fnode/project/.vscode/tasks.json.njk +46 -0
  143. package/template/fnode/project/fnet/targets.yaml.njk +25 -0
  144. package/template/fnode/project/fnode.yaml.njk +12 -0
  145. package/template/fnode/python/.gitignore.njk +7 -0
  146. package/template/fnode/python/fnode.yaml.njk +1 -0
  147. package/template/fnode/python/package.json.njk +4 -0
  148. package/template/fnode/python/pyproject.toml.njk +3 -0
  149. package/template/fnode/python/readme.md.njk +12 -0
  150. package/template/fnode/python/setup.py.njk +19 -0
  151. package/template/fnode/python/src/cli/index.py.njk +25 -0
  152. package/template/schemas/to-npm.yaml +14 -0
  153. package/dist/fnet/index.DZbefC4O.js +0 -1
  154. package/dist/fnode/index.DrdnDArw.js +0 -1
@@ -0,0 +1 @@
1
+ import e from"lodash.merge";import a from"node:fs";import s from"node:path";import r from"@flownet/lib-parse-imports-js";import{g as t,h as o,j as n,k as p,l,m as i}from"./index.CLlKzCGk.js";import c from"@fnet/npm-list-versions";import u from"nunjucks";import d from"@fnet/shelljs";function b({dir:e,name:r="index"}){let t=s.resolve(e,`./${r}.tsx`);if(a.existsSync(t)||(t=s.resolve(e,`./${r}.ts`)),a.existsSync(t)||(t=s.resolve(e,`./${r}.jsx`)),a.existsSync(t)||(t=s.resolve(e,`./${r}.js`)),!a.existsSync(t))return{};const o=t,n=s.extname(t);return{file:o,ext:n,ts:".ts"===n||".tsx"===n,name:r}}async function f(a){const{atom:c,context:u,setProgress:d}=a;d("Initializing features..."),c.doc.features=c.doc.features||{};const f=c.doc.features;f.project=f.project||{},f.project.format=f.project.format||f.project_format||"esm",f.project_format=f.project.format,f.dts_enabled=!0===f.dts||void 0!==f.dts&&!1!==f.dts;const _=s.resolve(u.project.projectDir),g=b({dir:s.resolve(_,"./app")});if(g.file){d("Parsing app entry imports...");let e=await r({file:g.file,recursive:!0}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type));f.app_uses_jsx=a,f.app_has_entry=!0,e=await r({file:g.file}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type)),f.app_entry_uses_jsx=a,f.app_entry_is_ts=g.ts,f.app_entry_ext=g.ext}const m=b({dir:s.resolve(_,"./cli")});if(m.file){d("Parsing cli entry imports...");let e=await r({file:m.file,recursive:!0}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type));f.cli_uses_jsx=a,f.cli_has_entry=!0,e=await r({file:m.file}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type)),f.cli_entry_uses_jsx=a,f.cli_entry_is_ts=m.ts,f.cli_entry_ext=m.ext}if("workflow.lib"===c.type){const e=b({dir:s.resolve(_,"./src")});if(e.file){d("Parsing src entry imports...");let a=await r({file:e.file,recursive:!0}),s=a.all.some((e=>!0===e.usesJSX&&"local"===e.type));f.src_uses_jsx=s,f.src_has_entry=!0,a=await r({file:e.file}),s=a.all.some((e=>!0===e.usesJSX&&"local"===e.type)),f.src_entry_uses_jsx=s,f.src_entry_is_ts=e.ts,f.src_entry_ext=e.ext}}const y=Reflect.has(f,"app_entry_uses_jsx")?!0===f.app_entry_uses_jsx:!0===f.src_entry_uses_jsx,v=Reflect.has(f,"cli_entry_uses_jsx")?!0===f.cli_entry_uses_jsx:!0===f.src_entry_uses_jsx;f.form_enabled=y||v||!0===f.form||!0===f.form?.enabled,f.multiple_enabled=f.multiple_enabled||!0===f.multiple||!0===f.multiple?.enabled,!1===f.app?f.app={enabled:!1}:!0===f.app?f.app={enabled:!0,extend:!0===f.app_has_entry,export:!0,react:y}:f.app={enabled:!0,extend:!0===f.app_has_entry,export:!0,react:y,...f.app||{}},f.app.enabled=!0===f.app.enabled&&(!0===c.doc.features.form_enabled||!0===f.app.extend||!0===f.app.enabled),f.app.format=f.app.format||"esm",f.app.folder=f.app.folder||f.app.format||"default",!1===f.cli?f.cli={enabled:!1}:!0===f.cli?f.cli={enabled:!0,extend:!0===f.cli_has_entry,export:!0,react:v}:f.cli={enabled:!0,extend:!0===f.cli_has_entry,export:!0,react:v,...f.cli||{}},f.cli.enabled=!0===f.cli.enabled&&(!1===c.doc.features.form_enabled||!0===f.cli.extend||!0===f.cli.enabled),f.cli.format=f.cli.format||"esm",f.cli.folder=f.cli.folder||f.cli.folder||"esm",f.cli.node_options=f.cli.node?.options||f.cli.node_options||"",f.json=f.cli.enabled||f.json;const x={cjs:{format:"cjs",context:f.form_enabled?"window":"global",babel:!0===f.src_uses_jsx||!1,browser:!1,replace:!0,terser:!0,enabled:!1!==f.cjs,copy:!1},esm:{format:"esm",context:f.form_enabled?"window":"global",babel:!0===f.src_uses_jsx||!1,browser:!1,replace:!0,terser:!1,enabled:!1!==f.esm,copy:!0},iife:{format:"iife",context:f.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:!0===f.iife,terser:!0,copy:!1}};!0===f.webos&&(x.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"}}}),!0===f.electron&&(x.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"}),!0===f.nextjs&&(x.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"}),!0===f.ios&&(x.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"}),!0===f.macos&&(x.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"}),!0===f.app.enabled&&(f.app.dir=`./dist/app/${f.app.folder}`,x.app={format:f.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:"./src/app/index.js",output_dir:f.app.dir,terser:!0,output_exports:!1===f.app.export?"none":"auto",browsersync:!0}),!0===f.cli.enabled&&(f.cli.dir=`./dist/cli/${f.cli.folder}`,x.cli={format:f.cli.format,context:"global",babel:!0===f.src_uses_jsx||!0===f.cli_uses_jsx||!1,browser:!1,replace:!0,enabled:!0,input:"./src/cli/index.js",output_dir:f.cli.dir,banner:"#!/usr/bin/env node",terser:!0,output_exports:!1===f.cli.export?"none":"auto"});const w={server:".",startPath:`${s.normalize(f.app.dir||".")}`,files:[s.normalize("./dist/**/*")],cors:!0,open:!1};f.babel_options=e({targets:{browsers:"last 9 versions, not dead",node:"18"}},f.babel_options||f.babel?.options),f.browsersync_options=e(w,f.browsersync_options||f.browsersync?.options||{}),f.replace_options=e({},f.replace_options||f.replace?.options||{}),Reflect.has(f.browsersync_options,"proxy")&&delete f.browsersync_options.server,f.rollup=f.rollup||{},f.rollup_output=e(x,f.rollup_output||f.rollup?.output||{}),f.preact_enabled=!0===f.preact||f.preact&&!1!==f.preact?.enabled;let k=Object.keys(x);for(const a of k){const s=x[a];s&&(!1!==f.rollup[a]?(s.babel_options=s.babel_options||f.babel_options,s.browsersync_options=e(f.browsersync_options,s.browsersync_options),s.replace_options=e(f.replace_options,s.replace_options),f.preact_enabled&&(s.alias_enabled=!0,s.alias=s.alias||{},s.alias.entries=s.alias.entries||{},s.alias.entries.react="preact/compat",s.alias.entries["react-dom"]="preact/compat"),(f.form_enabled||f.babel)&&(s.babel=!0)):delete f.rollup_output[a])}k=Object.keys(f.rollup_output),f.babel_enabled=k.some((e=>!0===f.rollup_output[e].babel)),f.browser_enabled=k.some((e=>!0===f.rollup_output[e].babel)),f.browsersync_enabled=!1!==f.browsersync&&k.some((e=>!0===f.rollup_output[e].browsersync)),f.browsersync_enabled=f.browsersync_enabled&&f.app.enabled,f.dependency_auto_enabled=!1!==f.dependency_auto&&!1!==f.dependency_auto?.enabled,f.npm_install_flags=f.npm_install_flags||"",f.react_version=f.react_version||f.react?.version||18,o(a),n(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:r,packageDevDependencies:s})}(a),p(a),l(a),i(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]]},features:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({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:r,packageDevDependencies:s})}(a),function(e){const{atom:a,packageDevDependencies:s}=e,r=a.doc.features;t({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:r,packageDevDependencies:s})}(a)}async function _({atom:e,packageDependencies:a,packageDevDependencies:s,setProgress:r}){r("Initializing dependencies");const t=e.doc.dependencies||[];if(t.filter((e=>!e.dev)).forEach((e=>a.push(e))),t.filter((e=>e.dev)).forEach((e=>s.push(e))),"workflow"===e.type&&(a.push({package:"get-value",version:"^3"}),a.push({package:"set-value",version:"^4"})),e.doc.features.form_enabled&&e.doc.features.dependency_auto_enabled){let s="^18.2";r("Fetching React versions");s=`^${(await c({name:"react",groupBy:{major:!0}})).find((a=>a[0]===e.doc.features.react_version.toString()))[0]}`,a.push({package:"react",version:s}),a.push({package:"react-dom",version:s}),"workflow"===e.type&&(a.push({package:"@fnet/react-app",version:"^0.1"}),a.push({package:"@fnet/react-app-state",version:"^0.1"}))}e.doc.features.preact_enabled&&a.push({package:"preact",version:"^10"}),!0===e.doc.features.cli.enabled&&(a.push({package:"@fnet/args",version:"^0.1"}),s.push({package:"ajv",version:"^8"}),e.doc.features.cli.fargs&&!1!==e.doc.features.cli.fargs?.enabled&&a.push({package:"@fnet/config",version:"0.2.21"})),e.doc.features.render&&!1!==e.doc.features.render.enabled&&s.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"}),s.push({package:"@babel/core",version:"^7"}),s.push({package:"@rollup/plugin-commonjs",version:"^28"}),s.push({package:"@rollup/plugin-node-resolve",version:"^16"}),s.push({package:"@rollup/plugin-replace",version:"^6"}),s.push({package:"rollup",version:"^4"}),e.doc.features.dts_enabled&&s.push({package:"rollup-plugin-dts",version:"^6"}),s.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),s.push({package:"@rollup/plugin-alias",version:"^5"}),s.push({package:"fs-extra",version:"^11"}),e.doc.features.babel_enabled&&(s.push({package:"@rollup/plugin-babel",version:"^6"}),s.push({package:"@babel/preset-env",version:"^7"}),s.push({package:"@babel/preset-react",version:"^7"}),e.doc.features.babel?.options?.plugins?.forEach((e=>{switch(e[0]){case"@babel/plugin-proposal-decorators":s.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":s.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":s.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":s.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":s.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"})}}))),s.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),e.doc.features.browsersync_enabled&&s.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}async function g({atom:e,setProgress:t,context:o,packageDependencies:n}){await t({message:"Creating rollup file."});const p={atom:e,packageDependencies:n},l=s.resolve(o.projectDir,"src","default/index.js");if(!a.existsSync(l))throw new Error(`Entry file not found: ${l}`);const i=(await r({file:l,recursive:!0})).all.filter((e=>"node"===e.type)).map((e=>e.path)),c=e.doc.features.rollup_output,d=Object.keys(c);for(let e=0;e<d.length;e++){const a=c[d[e]];if(!0===a.browser&&i.length>0){a.globals_enabled=!0,a.globals=a.globals||[],a.globals=a.globals.concat(i.map((e=>({key:e,value:e})))),a.alias_enabled=!0,a.alias=a.alias||{},a.alias.entries=a.alias.entries||{};for(let e=0;e<i.length;e++){const s=i[e];a.alias.entries[s]=`node:${s}`,a.alias.entries[`node:${s}`]=s}a.external_enabled=!0,a.external=a.external||[],a.external=a.external.concat(i)}}const b=o.templateDir;let f=u.compile(a.readFileSync(s.resolve(b,"rollup.config.mjs.njk"),"utf8"),u.configure(b)).render(p);const _=o.projectDir;let g=s.resolve(_,"rollup.config.mjs");a.writeFileSync(g,f,"utf8")}async function m({atom:e,setProgress:a,context:s}){if(!e.doc.features.dts_enabled)return;const r=s.projectDir;await a({message:"Creating .d.ts"});if(0!==(await d("tsc",{cwd:r})).code)throw new Error("Couldnt create .d.ts files.")}export{_ as a,m as b,g as c,f as i};
@@ -0,0 +1 @@
1
+ import t from"node:fs";import i from"node:path";import e from"nunjucks";import a from"@flownet/lib-parse-imports-js";import s from"@flownet/lib-parse-node-url";import{B as o}from"./index.Bqzc7Bx8.js";import{i as n,a as r,c as p,b as c}from"./index.D4KQB1ot.js";import{p as l,c as m,a as h,b as d,d as f,e as w,f as g,i as y,r as x}from"./index.CLlKzCGk.js";import{c as b,a as u}from"./index.BwhWziH6.js";import"node:crypto";import"yaml";import"chalk";import"@flownet/lib-atom-api-js";import"@fnet/config";import"@fnet/list-files";import"lodash.merge";import"@fnet/npm-list-versions";import"@fnet/shelljs";import"@flownet/lib-render-templates-dir";import"@fnet/npm-pick-versions";import"object-hash";import"ajv/dist/2020.js";import"ajv/dist/standalone/index.js";import"ajv-formats";import"./index.js";import"node:url";import"node:child_process";import"node:os";import"yargs";import"@fnet/prompt";import"@fnet/yaml";import"@fnet/shell-flow";import"node:util";import"tree-kill";import"redis";import"@flownet/lib-is-redis-online";class j extends o{async initRuntime(){await n(this.apiContext),await r(this.apiContext),await this.initLibraryDir(),await this.initNunjucks(),await this.initLibs()}async initLibs(){this.setProgress({message:"Initializing external libs."});const t=[{name:this.atom.doc.name,type:"atom",parent_id:this.atom.parent_id}];this.libs=t,await this.initAtomLibsAndDeps({libs:t,packageDependencies:this.apiContext.packageDependencies})}async initAtomLibsAndDeps({libs:t,packageDependencies:i}){const e=t.filter((t=>"atom"===t.type));for(let t=0;t<e.length;t++){const a=e[t],s=await this.findAtomLibrary({url:a.name});a.atom=s;const o=s.doc.dependencies?.filter((t=>void 0===t.repo||"npm"===t.repo));o?.forEach((t=>{const e=i.find((i=>i.package===t.package));e?"string"==typeof t.path?(e.path||[]).some((i=>i===t.path))||(e.path=e.path||[],e.path.push(t.path)):Array.isArray(t.path)&&t.path.forEach((t=>{(e.path||[]).some((i=>i===t))||(e.path=e.path||[],e.path.push(t))})):i.push(t)}))}i.sort(((t,i)=>t.package?.localeCompare(i.package)))}async findAtomLibrary({url:t}){const e=s({url:t});if(!e)throw new Error(`Invalid package name: ${t}`);if(e.protocol||(e.protocol=this.context.protocol),"ac:"===e.protocol){const i=e.pathname.split("/");if(1===i.length)return await this.apiContext.Atom.first({where:{name:t,parent_id:this.atomConfig.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(2===i.length){const t=await this.apiContext.Atom.first({where:{name:i[0],parent_id:this.atomConfig.env.ATOM_LIBRARIES_ID,type:"folder"}});return await this.apiContext.Atom.first({where:{name:i[1],parent_id:t.id,type:"workflow.lib"}})}}else if("local:"===e.protocol){const t=this.atom;t.protocol="local:",t.doc.dependencies=t.doc.dependencies||[],t.name=t.doc.name;const e=i.resolve(this.context.projectSrcDir,"index.js"),s=await a({file:e,recursive:!0}),o=t.doc.dependencies,n=s.all;for await(const t of n){if("npm"!==t.type)continue;if(o.find((i=>i.package===t.package)))continue;const i=await l({name:t.package,projectDir:this.context.projectDir,setProgress:this.apiContext.setProgress});o.push({package:t.package,subpath:t.subpath,version:i.minorRange,type:"npm"})}return t}}async createAtomLibFiles({libs:e}){await this.setProgress({message:"Creating external lib files."}),this.atom.typesDir="./types";const a=e.filter((t=>"atom"===t.type));for(let e=0;e<a.length;e++){const s=a[e].atom,o=this.context.projectDir;if("local:"===s.protocol){const e=i.resolve(this.context.projectSrcDir,`${s.fileName||s.name}.js`),a=i.relative(i.join(this.context.projectDir,"src","default"),e);if(!t.existsSync(e)){t.mkdirSync(i.dirname(e),{recursive:!0});let a="export default async (args)=>{\n";a+="}",t.writeFileSync(e,a,"utf8")}s.relativePath=a.split(i.sep).join("/"),this.atom.typesDir=`./types/${i.basename(o)}/src`}else{const e=i.join(o,"src","libs",`${s.id}.js`),a=s.doc.contents?.find((t=>"esm"===t.format))||s.doc;t.writeFileSync(e,a.content,"utf8")}}}async createEngine(){await this.setProgress({message:"Creating engine file."});const a={libs:this.libs.filter((t=>"atom"===t.type)),libraryAtom:this.atom,atom:this.atom},s=this.context.templateDir,o=e.compile(t.readFileSync(i.resolve(s,i.join("src","default","engine.js.njk")),"utf8"),this.apiContext.njEnv).render(a),n=this.context.projectDir,r=i.resolve(n,i.join("src","default","index.js"));t.writeFileSync(r,o,"utf8")}async build(){try{this.fileMode&&(await this.createAtomLibFiles({libs:this.libs}),await this.createEngine(),await this.createProjectYaml(),await b(this.apiContext),await m(this.apiContext),await u(this.apiContext),await h(this.apiContext),await d(this.apiContext),await f(this.apiContext),await p(this.apiContext),await w(this.apiContext),await g(this.apiContext),await c(this.apiContext),this.buildMode&&(await y(this.apiContext),await x(this.apiContext),this.deployMode&&await this.deploy())),await this._cache_set(this.buildKey,{status:"COMPLETED"})}catch(t){throw await this._cache_set(this.buildKey,{status:"FAILED",message:t.message||t}),console.log(t),t}}}export{j as default};
@@ -0,0 +1 @@
1
+ import e from"fs";import r from"path";import n from"@fnet/yaml";import t from"@fnet/shell-flow";async function o({projectType:e,group:r,tags:o,args:f,argv:i}){try{const m=await a(e),{parsed:s}=await n({file:m.path,tags:o}),c=s.commands;if(!c)throw new Error(`Commands section not found in ${m.name}`);const y=c[r];if(!y)throw new Error(`Command group '${r}' not found in ${m.name}`);await t({commands:y,context:{args:f,argv:i,projectType:m.type}})}catch(e){console.error(`Error: ${e.message}`),process.exit(1)}}async function a(n){const t=process.cwd(),o=r.resolve(t,"fnode.yaml"),a=r.resolve(t,"fnet.yaml");if("fnode"===n){if(e.existsSync(o))return{path:o,name:"fnode.yaml",type:"fnode"};throw new Error("fnode.yaml file not found in current directory")}if("fnet"===n){if(e.existsSync(a))return{path:a,name:"fnet.yaml",type:"fnet"};throw new Error("fnet.yaml file not found in current directory")}if(e.existsSync(o))return{path:o,name:"fnode.yaml",type:"fnode"};if(e.existsSync(a))return{path:a,name:"fnet.yaml",type:"fnet"};throw new Error("No project file (fnode.yaml or fnet.yaml) found in current directory")}export{a as detectProjectFile,o as runCommandGroup};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import e,{delimiter as t,join as a}from"node:path";import{fileURLToPath as o}from"node:url";import{spawn as i}from"node:child_process";import s from"node:os";import n,{existsSync as r}from"node:fs";import c from"yaml";import p from"yargs";import l from"@fnet/prompt";import d from"@fnet/shelljs";import m from"@fnet/yaml";import u from"@fnet/config";import f from"@fnet/shell-flow";import g from"@flownet/lib-render-templates-dir";import{promisify as y}from"node:util";import h from"tree-kill";import w from"nunjucks";import{randomUUID as b}from"node:crypto";import{Api as j,Atom as v}from"@flownet/lib-atom-api-js";import x from"@flownet/lib-parse-node-url";import k from"@flownet/lib-parse-imports-js";import D from"@fnet/list-files";import _ from"chalk";import S from"redis";import P from"@flownet/lib-is-redis-online";import C from"lodash.merge";import E from"@fnet/npm-list-versions";import $ from"@fnet/npm-pick-versions";import I from"object-hash";import A from"ajv/dist/2020.js";import T from"ajv/dist/standalone/index.js";import F from"ajv-formats";import R from"@fnet/auto-conda-env";const O=e.dirname(o(import.meta.url));var L=e=>{const o=process.env.PATH||"",i="win32"===process.platform?(process.env.PATHEXT||".EXE;.CMD;.BAT;.COM").split(";"):[""],s=o.split(t);for(const t of s)for(const o of i){const i=a(t,"win32"===process.platform?e+o:e);if(r(i))return i}return null};const M=y(h);let N=!1;async function z(e,t){if(N)return;if(N=!0,!e.killed&&e.pid)try{await M(e.pid,"SIGTERM").catch((()=>{})),await new Promise((e=>setTimeout(e,500))),e.killed||await M(e.pid,"SIGKILL").catch((()=>{}))}catch(e){}await new Promise((e=>setTimeout(e,100)));const a="SIGINT"===t?130:"SIGTERM"===t?143:1;process.exit(a)}function B(e){["SIGINT","SIGTERM","SIGQUIT"].forEach((t=>{process.once(t,(async()=>{await z(e,t)}))})),process.on("uncaughtException",(async t=>{await z(e)})),process.on("unhandledRejection",(async t=>{await z(e)})),e.on("close",(e=>{N||process.exit(e)}))}class J{init({config:e,accessToken:t}){return new Promise(((a,o)=>{if(j.set_api_url(e.data.url),t)return j.set_req_token(t),void a(t);fetch(`${e.data.issuer}/protocol/openid-connect/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(e.data.grant.params)}).then((async e=>{if(!e.ok)throw new Error(await e.text());return e.json()})).then((e=>{j.set_req_token(e.access_token),a(e.access_token)})).catch((e=>{j.set_req_token(),o(e)}))}))}}function H({feature:e,features:t,packageDevDependencies:a}){const{name:o,packages:i,options:s,extraCheck:n,explicit:r}=e,c=`${o}_enabled`,p=t.rollup_output||{},l=Object.keys(p);let d=s||{};const m=t[o]?.options;m&&(d=C(d,m));const u=!t[o]||!1===t[o]?.enabled;l.forEach((e=>{const a=t.rollup_output[e];if(a){if(Reflect.has(a,o)){if(u||!a[o]||!1===a[o]?.enabled)return void delete a[o];!0===a[o]&&(a[o]={enabled:!0,options:d})}else{if(u||r||!1===t[c])return;a[o]={enabled:!0}}a[o]=a[o]||{},a[o].options={...d,...a[o].options}}}));let f=l.some((e=>!0===t.rollup_output[e][o]?.enabled));n&&(f=n()&&f),t[c]=f,f&&i.forEach((e=>a.push({package:e[0],version:e[1]})))}function G({dir:t,name:a="index"}){let o=e.resolve(t,`./${a}.tsx`);if(n.existsSync(o)||(o=e.resolve(t,`./${a}.ts`)),n.existsSync(o)||(o=e.resolve(t,`./${a}.jsx`)),n.existsSync(o)||(o=e.resolve(t,`./${a}.js`)),!n.existsSync(o))return{};const i=o,s=e.extname(o);return{file:i,ext:s,ts:".ts"===s||".tsx"===s,name:a}}async function K(t){const{atom:a,context:o,setProgress:i}=t;i("Initializing features..."),a.doc.features=a.doc.features||{};const s=a.doc.features;s.project=s.project||{},s.project.format=s.project.format||s.project_format||"esm",s.project_format=s.project.format,s.dts_enabled=!0===s.dts||void 0!==s.dts&&!1!==s.dts;const n=e.resolve(o.project.projectDir),r=G({dir:e.resolve(n,"./app")});if(r.file){i("Parsing app entry imports...");let e=await k({file:r.file,recursive:!0}),t=e.all.some((e=>!0===e.usesJSX&&"local"===e.type));s.app_uses_jsx=t,s.app_has_entry=!0,e=await k({file:r.file}),t=e.all.some((e=>!0===e.usesJSX&&"local"===e.type)),s.app_entry_uses_jsx=t,s.app_entry_is_ts=r.ts,s.app_entry_ext=r.ext}const c=G({dir:e.resolve(n,"./cli")});if(c.file){i("Parsing cli entry imports...");let e=await k({file:c.file,recursive:!0}),t=e.all.some((e=>!0===e.usesJSX&&"local"===e.type));s.cli_uses_jsx=t,s.cli_has_entry=!0,e=await k({file:c.file}),t=e.all.some((e=>!0===e.usesJSX&&"local"===e.type)),s.cli_entry_uses_jsx=t,s.cli_entry_is_ts=c.ts,s.cli_entry_ext=c.ext}if("workflow.lib"===a.type){const t=G({dir:e.resolve(n,"./src")});if(t.file){i("Parsing src entry imports...");let e=await k({file:t.file,recursive:!0}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type));s.src_uses_jsx=a,s.src_has_entry=!0,e=await k({file:t.file}),a=e.all.some((e=>!0===e.usesJSX&&"local"===e.type)),s.src_entry_uses_jsx=a,s.src_entry_is_ts=t.ts,s.src_entry_ext=t.ext}}const p=Reflect.has(s,"app_entry_uses_jsx")?!0===s.app_entry_uses_jsx:!0===s.src_entry_uses_jsx,l=Reflect.has(s,"cli_entry_uses_jsx")?!0===s.cli_entry_uses_jsx:!0===s.src_entry_uses_jsx;s.form_enabled=p||l||!0===s.form||!0===s.form?.enabled,s.multiple_enabled=s.multiple_enabled||!0===s.multiple||!0===s.multiple?.enabled,!1===s.app?s.app={enabled:!1}:!0===s.app?s.app={enabled:!0,extend:!0===s.app_has_entry,export:!0,react:p}:s.app={enabled:!0,extend:!0===s.app_has_entry,export:!0,react:p,...s.app||{}},s.app.enabled=!0===s.app.enabled&&(!0===a.doc.features.form_enabled||!0===s.app.extend||!0===s.app.enabled),s.app.format=s.app.format||"esm",s.app.folder=s.app.folder||s.app.format||"default",!1===s.cli?s.cli={enabled:!1}:!0===s.cli?s.cli={enabled:!0,extend:!0===s.cli_has_entry,export:!0,react:l}:s.cli={enabled:!0,extend:!0===s.cli_has_entry,export:!0,react:l,...s.cli||{}},s.cli.enabled=!0===s.cli.enabled&&(!1===a.doc.features.form_enabled||!0===s.cli.extend||!0===s.cli.enabled),s.cli.format=s.cli.format||"esm",s.cli.folder=s.cli.folder||s.cli.folder||"esm",s.cli.node_options=s.cli.node?.options||s.cli.node_options||"",s.json=s.cli.enabled||s.json;const d={cjs:{format:"cjs",context:s.form_enabled?"window":"global",babel:!0===s.src_uses_jsx||!1,browser:!1,replace:!0,terser:!0,enabled:!1!==s.cjs,copy:!1},esm:{format:"esm",context:s.form_enabled?"window":"global",babel:!0===s.src_uses_jsx||!1,browser:!1,replace:!0,terser:!1,enabled:!1!==s.esm,copy:!0},iife:{format:"iife",context:s.form_enabled?"window":"global",babel:!0,browser:!0,replace:!0,enabled:!0===s.iife,terser:!0,copy:!1}};!0===s.webos&&(d.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"}}}),!0===s.electron&&(d.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"}),!0===s.nextjs&&(d.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"}),!0===s.ios&&(d.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"}),!0===s.macos&&(d.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"}),!0===s.app.enabled&&(s.app.dir=`./dist/app/${s.app.folder}`,d.app={format:s.app.format,browser:!0,babel:!0,context:"window",replace:!0,input:"./src/app/index.js",output_dir:s.app.dir,terser:!0,output_exports:!1===s.app.export?"none":"auto",browsersync:!0}),!0===s.cli.enabled&&(s.cli.dir=`./dist/cli/${s.cli.folder}`,d.cli={format:s.cli.format,context:"global",babel:!0===s.src_uses_jsx||!0===s.cli_uses_jsx||!1,browser:!1,replace:!0,enabled:!0,input:"./src/cli/index.js",output_dir:s.cli.dir,banner:"#!/usr/bin/env node",terser:!0,output_exports:!1===s.cli.export?"none":"auto"});const m={server:".",startPath:`${e.normalize(s.app.dir||".")}`,files:[e.normalize("./dist/**/*")],cors:!0,open:!1};s.babel_options=C({targets:{browsers:"last 9 versions, not dead",node:"18"}},s.babel_options||s.babel?.options),s.browsersync_options=C(m,s.browsersync_options||s.browsersync?.options||{}),s.replace_options=C({},s.replace_options||s.replace?.options||{}),Reflect.has(s.browsersync_options,"proxy")&&delete s.browsersync_options.server,s.rollup=s.rollup||{},s.rollup_output=C(d,s.rollup_output||s.rollup?.output||{}),s.preact_enabled=!0===s.preact||s.preact&&!1!==s.preact?.enabled;let u=Object.keys(d);for(const e of u){const t=d[e];t&&(!1!==s.rollup[e]?(t.babel_options=t.babel_options||s.babel_options,t.browsersync_options=C(s.browsersync_options,t.browsersync_options),t.replace_options=C(s.replace_options,t.replace_options),s.preact_enabled&&(t.alias_enabled=!0,t.alias=t.alias||{},t.alias.entries=t.alias.entries||{},t.alias.entries.react="preact/compat",t.alias.entries["react-dom"]="preact/compat"),(s.form_enabled||s.babel)&&(t.babel=!0)):delete s.rollup_output[e])}u=Object.keys(s.rollup_output),s.babel_enabled=u.some((e=>!0===s.rollup_output[e].babel)),s.browser_enabled=u.some((e=>!0===s.rollup_output[e].babel)),s.browsersync_enabled=!1!==s.browsersync&&u.some((e=>!0===s.rollup_output[e].browsersync)),s.browsersync_enabled=s.browsersync_enabled&&s.app.enabled,s.dependency_auto_enabled=!1!==s.dependency_auto&&!1!==s.dependency_auto?.enabled,s.npm_install_flags=s.npm_install_flags||"",s.react_version=s.react_version||s.react?.version||18,function(e){const{atom:t,packageDevDependencies:a}=e,o=t.doc.features,i=o.css&&!1!==o.css.enabled;let s=[];i&&(s.push(["rollup-plugin-postcss","^4"]),s.push(["sass","^1.66"]),(o.css?.options?.plugins||[]).forEach((e=>{switch(e.name){case"postcss-import":s.push(["postcss-import","^15"]);break;case"postcss-url":s.push(["postcss-url","^10"]);break;case"postcss-preset-env":s.push(["postcss-preset-env","^9"]);break;case"autoprefixer":s.push(["autoprefixer","^10"]);break;case"cssnano":s.push(["cssnano","^6"])}})));H({feature:{name:"css",packages:s},features:o,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e,o=t.doc.features,i={};!0===o.app?.enabled&&(i.targets=i.targets||[],i.targets.push({src:"./src/app/index.html",dest:o.app.dir}),Reflect.has(o.app,"copy")||Reflect.has(o,"copy")||(o.copy=!0)),H({feature:{name:"copy",packages:[["rollup-plugin-copy","^3"],["chokidar","^3"]],options:i},features:o,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"wasm",packages:[["@rollup/plugin-wasm","^6"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"terser",packages:[["@rollup/plugin-terser","^0.4"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"json",packages:[["@rollup/plugin-json","^6"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"string",packages:[["rollup-plugin-string","^3"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"image",packages:[["@rollup/plugin-image","^3"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"analyzer",packages:[["rollup-plugin-analyzer","^3"]],options:{summaryOnly:!0,limit:12},explicit:!0},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"visualizer",packages:[["rollup-plugin-visualizer","^5"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"polyfill",packages:[["rollup-plugin-node-polyfills","^0.2"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"nunjucks",packages:[["@fnet/rollup-plugin-nunjucks","0.1.8"]]},features:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({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:t.doc.features,packageDevDependencies:a})}(t),function(e){const{atom:t,packageDevDependencies:a}=e;H({feature:{name:"gzip",packages:[["rollup-plugin-gzip","^4"]],explicit:!0},features:t.doc.features,packageDevDependencies:a})}(t)}async function X({projectDir:t,name:a,setProgress:o,count:i=1}){let s;const r=I(["npm-pick-versions",a,i]),c=e.join(t,".cache"),p=e.join(c,r+".json");return n.existsSync(p)?(o&&o(`Picking npm version of ${a} from cache ...`),s=JSON.parse(n.readFileSync(p,"utf8"))):(o&&o(`Picking npm version of ${a} ...`),s=await $({name:a,count:i}),n.mkdirSync(c,{recursive:!0}),n.writeFileSync(p,JSON.stringify(s),"utf8")),s}async function U({atom:t,setProgress:a,context:o,packageDependencies:i}){await a({message:"Creating .gitignore"});const s={atom:t,packageDependencies:i},r=o.templateCommonDir,c=w.compile(n.readFileSync(e.resolve(r,".gitignore.njk"),"utf8"),w.configure(r)).render(s),p=o.projectDir,l=e.resolve(p,".gitignore");n.writeFileSync(l,c,"utf8")}async function q({atom:t,context:a,setProgress:o,Atom:i}){const s="readme.md",r=`Creating ${s}`;if(await o({message:r}),a.project?.readme){const t=a.projectDir,o={content:a.project.readme.doc.content},i=e.resolve(a.project.projectDir,"fnet/how-to.md");if(n.existsSync(i)){const e=n.readFileSync(i,"utf8");o.howto=e}const r=e.resolve(a.project.projectDir,"fnet/input.yaml");if(n.existsSync(r)){const e=await m({file:r,tags:a.tags});o.input=e.content}const c=e.resolve(a.project.projectDir,"fnet/output.yaml");if(n.existsSync(c)){const e=await m({file:c,tags:a.tags});o.output=e.content}const p=a.templateCommonDir,l=w.compile(n.readFileSync(e.resolve(p,`${s}.njk`),"utf8"),w.configure(p)).render(o),d=e.resolve(t,`${s}`);n.writeFileSync(d,l,"utf8")}else if(t.id){const o=await i.first({type:"wiki",parent_id:t.id});if(!o||"markdown"!==o.doc?.["content-type"])return;const{content:r,...c}=o.doc,p={content:r},l=a.templateCommonDir,d=w.compile(n.readFileSync(e.resolve(l,`${s}.njk`),"utf8"),w.configure(l)).render(p),m=a.projectDir,u=e.resolve(m,`${s}`);n.writeFileSync(u,d,"utf8")}}var Y=async e=>{const{atom:t,packageDependencies:a,context:o,deploymentProjectTarget:i,setProgress:s,deploymentProject:n,yamlTarget:r}=e;if(!0!==i.enabled)return;const c=i.type;try{if("lib"===c)await(await import("./index.DG8TqL-1.js")).default({...e});else if("red"===c)await(await import("./index.CmMM-Ek9.js")).default({...e});else if("npm"===c)await(await import("./index.DrdnDArw.js")).default({...e});else if("gcs"===c)await(await import("./index.UOds5XLl.js")).default({...e});else if("gitlab"===c)await(await import("./index.DI3yyTtl.js")).default({...e});else if("fnet-package"===c)await(await import("./index.Bfg4lyu-.js")).default({...e});else if("fnet-form"===c)await(await import("./index.Q-CYRcna.js")).default({...e});else if("fnet-node"===c)await(await import("./index.C2S9JYhS.js")).default({...e});else if("fnet-flow"===c)await(await import("./index.BuYxdKtK.js")).default({...e});else if("nextjs"===c)await(await import("./index.CDct_kkF.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("webos"===c)await(await import("./index.CMC8mlye.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("electron"===c)await(await import("./index.xd8c7XMr.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("docker"===c)await(await import("./index.D2N9YZmA.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("ios"===c)await(await import("./index.B5XE4ChJ.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("macos"===c)await(await import("./index.W6RYgypK.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else if("rust"===c)await(await import("./index.CzAV0S36.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0;else{if("pypi"!==c)return void console.warn(`No deployer found for type: ${c}`);await(await import("./index.C7saWH6d.js")).default({atom:t,target:i,onProgress:s,projectDir:o.projectDir,dependencies:a,context:o,yamlTarget:r}),n.isDirty=!0}}catch(e){throw console.error(`Error during deployment for type "${c}":`,e),e}};class V{#e;#t;#a;#o;#i;#s;#n;#r;#c;#p;#l;#d;#m;#u;#f;#g;#y;constructor(e){this.#e=new J,this.#t=e,this.#s=[],this.#n=[],this._expire_ttl=3600,this._expire_ttl_short=300,this.#y={packageDependencies:this.#s,packageDevDependencies:this.#n,setProgress:this.setProgress.bind(this),context:this.#t,Atom:v,registerToPackageManager:this.registerToPackageManager.bind(this)}}async _cache_set(e,t,a){this._redis_client&&await this._redis_client.SETEX(e,a||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async initAuth(){this.#t.id&&(this.#r=await this.#e.init({config:this.#d}),this.#y.atomAccessToken=this.#r)}async initLibrary(){const e=this.#t.id;this.#a=this.#t.project?.libraryAtom||await v.get({id:e});let t=this.#a.doc.bundleName;t=t||(this.#a.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#a.doc.bundleName=t,this.#a.type=this.#a.type||"workflow.lib",this.#y.atom=this.#a}async initLibraryDir(){this.setProgress({message:"Initializing library directory."});const t=this.#t.projectDir;this.setProgress({message:"Cleaning project directory."});const a=D({dir:t,ignore:[".cache","node_modules",".conda"],absolute:!0});for(const e of a)n.rmSync(e,{recursive:!0,force:!0});this.setProgress({message:"Creating project directory."});let o=t;n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),o=e.join(t,"src"),n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),o=e.join(t,"src","default"),n.existsSync()||n.mkdirSync(o,{recursive:!0})}async initLibraryDirPython(){this.setProgress({message:"Initializing library directory."});const t=this.#t.projectDir;this.setProgress({message:"Cleaning project directory."});const a=D({dir:t,ignore:[".cache","node_modules",".conda"],absolute:!0});for(const e of a)n.rmSync(e,{recursive:!0,force:!0});this.setProgress({message:"Creating project directory."});let o=t;n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),o=e.join(t,"src"),n.existsSync(o)||n.mkdirSync(o,{recursive:!0}),o=e.join(t,"src","default");const i=this.#t.projectSrcDir;if(!n.existsSync(o))try{"win32"===s.platform()?n.symlinkSync(i,o,"junction"):n.symlinkSync(i,o,"dir")}catch(e){throw new Error(`Couldn't create symlink. Error: ${e.message}`)}}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});const e=this.#t.templateDir;this.#o=w.configure(e,{watch:!1,dev:!0}),this.#y.njEnv=this.#o}async initLibs(){this.setProgress({message:"Initializing external libs."});const e=[{name:this.#a.doc.name,type:"atom",parent_id:this.#a.parent_id}];this.#i=e,await this.initAtomLibsAndDeps({libs:e,packageDependencies:this.#s})}async initLibsPython(){this.setProgress({message:"Initializing external libs."});const e=this.#a;e.protocol="local:",e.doc.dependencies=e.doc.dependencies||[],e.name=e.doc.name;const t=[{name:this.#a.doc.name,type:"atom",parent_id:this.#a.parent_id,atom:e}];this.#i=t}async initAtomLibsAndDeps({libs:e,packageDependencies:t}){const a=e.filter((e=>"atom"===e.type));for(let e=0;e<a.length;e++){const o=a[e],i=await this.findAtomLibrary({url:o.name});o.atom=i;const s=i.doc.dependencies?.filter((e=>void 0===e.repo||"npm"===e.repo));s?.forEach((e=>{const a=t.find((t=>t.package===e.package));a?"string"==typeof e.path?(a.path||[]).some((t=>t===e.path))||(a.path=a.path||[],a.path.push(e.path)):Array.isArray(e.path)&&e.path.forEach((e=>{(a.path||[]).some((t=>t===e))||(a.path=a.path||[],a.path.push(e))})):t.push(e)}))}t.sort(((e,t)=>e.package?.localeCompare(t.package)))}async findAtomLibrary({url:t}){const a=x({url:t});if(!a)throw new Error(`Invalid package name: ${t}`);if(a.protocol||(a.protocol=this.#l),"ac:"===a.protocol){const e=a.pathname.split("/");if(1===e.length)return await v.first({where:{name:t,parent_id:this.#d.env.ATOM_LIBRARIES_ID,type:"workflow.lib"}});if(2===e.length){const t=await v.first({where:{name:e[0],parent_id:this.#d.env.ATOM_LIBRARIES_ID,type:"folder"}});return await v.first({where:{name:e[1],parent_id:t.id,type:"workflow.lib"}})}}else if("local:"===a.protocol){const t=this.#a;t.protocol="local:",t.doc.dependencies=t.doc.dependencies||[],t.name=t.doc.name;const a=e.resolve(this.#t.projectSrcDir,"index.js"),o=await k({file:a,recursive:!0}),i=t.doc.dependencies,s=o.all;for await(const e of s){if("npm"!==e.type)continue;if(i.find((t=>t.package===e.package)))continue;const t=await X({name:e.package,projectDir:this.#t.projectDir,setProgress:this.#y.setProgress});i.push({package:e.package,subpath:e.subpath,version:t.minorRange,type:"npm"})}return t}}async createAtomLibFiles({libs:t}){await this.setProgress({message:"Creating external lib files."}),this.#a.typesDir="./types";const a=t.filter((e=>"atom"===e.type));for(let t=0;t<a.length;t++){const o=a[t].atom,i=this.#t.projectDir;if("local:"===o.protocol){const t=e.resolve(this.#t.projectSrcDir,`${o.fileName||o.name}.js`),a=e.relative(e.join(this.#t.projectDir,"src","default"),t);if(!n.existsSync(t)){n.mkdirSync(e.dirname(t),{recursive:!0});let a="export default async (args)=>{\n";a+="}",n.writeFileSync(t,a,"utf8")}o.relativePath=a.split(e.sep).join("/"),this.#a.typesDir=`./types/${e.basename(i)}/src`}else{const t=e.join(i,"src","libs",`${o.id}.js`),a=o.doc.contents?.find((e=>"esm"===e.format))||o.doc;n.writeFileSync(t,a.content,"utf8")}}}async createAtomLibFilesPython({libs:t}){await this.setProgress({message:"Creating external lib files."});const a=t.filter((e=>"atom"===e.type));for(let t=0;t<a.length;t++){const o=a[t].atom;if("local:"===o.protocol){const t=e.resolve(this.#t.projectSrcDir,`${o.fileName||o.name}.py`);if(!n.existsSync(t)){n.mkdirSync(e.dirname(t),{recursive:!0});let a="def default():\n";a+=' print("Hello world!")\n',n.writeFileSync(t,a,"utf8")}}}}async createEngine(){await this.setProgress({message:"Creating engine file."});const t={libs:this.#i.filter((e=>"atom"===e.type)),libraryAtom:this.#a,atom:this.#a},a=this.#t.templateDir,o=w.compile(n.readFileSync(e.resolve(a,e.join("src","default","engine.js.njk")),"utf8"),this.#o).render(t),i=this.#t.projectDir,s=e.resolve(i,e.join("src","default","index.js"));n.writeFileSync(s,o,"utf8")}async createProjectYaml(){const t="node.yaml",a=`Creating ${t}`;await this.setProgress({message:a});const{content:o,...i}=this.#a.doc,s={content:c.stringify(i)},r=this.#t.templateDir,p=w.compile(n.readFileSync(e.resolve(r,`${t}.njk`),"utf8"),this.#o).render(s),l=this.#t.projectDir,d=e.resolve(l,`${t}`);n.writeFileSync(d,p,"utf8")}async deploy(){if(await this.setProgress({message:"Deploying."}),this.#t.project?.devops){const e=[this.#t.project?.devops];for(let t=0;t<e.length;t++){let a=e[t];await this.deployProject({deploymentProject:a}),!0===a.isDirty&&await a.save()}}else if(this.#a.id){const e=await v.list({type:"library.deploy",parent_id:this.#a.id});for(let t=0;t<e.length;t++){let a=e[t];await this.deployProject({deploymentProject:a}),!0===a.isDirty&&(a=await v.update(a,{id:a.id}))}}}async deployProject(e){const{deploymentProject:t}=e,{yamlDocument:a}=t;if(t.doc.targets&&Array.isArray(t.doc.targets))throw new Error("Deployment project targets are deprecated. Please update targets in the yaml file.");const o=Object.keys(t.doc||{}),i=a||{};for(let e=0;e<o.length;e++){const a=t.doc[o[e]];a.name=o[e];const s=i.get(o[e]);await Y({...this.#y,deploymentProject:t,deploymentProjectTarget:a,yamlTarget:s})}}async registerToPackageManager(e){const{target:t,packageJSON:a}=e;if(!this.#t.id)return;let o=await v.first({name:t.params.name,parent_id:this.#d.env.ATOM_PACKAGES_ID});o?(o.doc.versions.splice(0,0,{v:a.version}),await v.update(o,{id:o.id})):o=await v.create({parent_id:this.#d.env.ATOM_PACKAGES_ID,doc:{name:t.params.name,type:"pm",versions:[{v:a.version}]}})}async setProgress(e){const t="string"==typeof e?e:e?.message;console.log(_.blue(t)),await this._cache_set(this.#p,{status:"IN_PROGRESS",message:t})}async initNode(){await K(this.#y),await async function({atom:e,packageDependencies:t,packageDevDependencies:a,setProgress:o}){o("Initializing dependencies");const i=e.doc.dependencies||[];if(i.filter((e=>!e.dev)).forEach((e=>t.push(e))),i.filter((e=>e.dev)).forEach((e=>a.push(e))),"workflow"===e.type&&(t.push({package:"get-value",version:"^3"}),t.push({package:"set-value",version:"^4"})),e.doc.features.form_enabled&&e.doc.features.dependency_auto_enabled){let a="^18.2";o("Fetching React versions"),a=`^${(await E({name:"react",groupBy:{major:!0}})).find((t=>t[0]===e.doc.features.react_version.toString()))[0]}`,t.push({package:"react",version:a}),t.push({package:"react-dom",version:a}),"workflow"===e.type&&(t.push({package:"@fnet/react-app",version:"^0.1"}),t.push({package:"@fnet/react-app-state",version:"^0.1"}))}e.doc.features.preact_enabled&&t.push({package:"preact",version:"^10"}),!0===e.doc.features.cli.enabled&&(t.push({package:"@fnet/args",version:"^0.1"}),a.push({package:"ajv",version:"^8"}),e.doc.features.cli.fargs&&!1!==e.doc.features.cli.fargs?.enabled&&t.push({package:"@fnet/config",version:"0.2.21"})),e.doc.features.render&&!1!==e.doc.features.render.enabled&&a.push({package:"@flownet/lib-render-templates-dir",version:"0.1.19"}),a.push({package:"@babel/core",version:"^7"}),a.push({package:"@rollup/plugin-commonjs",version:"^28"}),a.push({package:"@rollup/plugin-node-resolve",version:"^16"}),a.push({package:"@rollup/plugin-replace",version:"^6"}),a.push({package:"rollup",version:"^4"}),e.doc.features.dts_enabled&&a.push({package:"rollup-plugin-dts",version:"^6"}),a.push({package:"rollup-plugin-peer-deps-external",version:"^2"}),a.push({package:"@rollup/plugin-alias",version:"^5"}),a.push({package:"fs-extra",version:"^11"}),e.doc.features.babel_enabled&&(a.push({package:"@rollup/plugin-babel",version:"^6"}),a.push({package:"@babel/preset-env",version:"^7"}),a.push({package:"@babel/preset-react",version:"^7"}),e.doc.features.babel?.options?.plugins?.forEach((e=>{switch(e[0]){case"@babel/plugin-proposal-decorators":a.push({package:"@babel/plugin-proposal-decorators",version:"^7"});break;case"@babel/plugin-proposal-class-properties":a.push({package:"@babel/plugin-proposal-class-properties",version:"^7"});break;case"@babel/plugin-proposal-private-methods":a.push({package:"@babel/plugin-proposal-private-methods",version:"^7"});break;case"@babel/plugin-proposal-private-property-in-object":a.push({package:"@babel/plugin-proposal-private-property-in-object",version:"^7"});break;case"@babel/plugin-proposal-optional-chaining":a.push({package:"@babel/plugin-proposal-optional-chaining",version:"^7"})}}))),a.push({package:"@fnet/rollup-plugin-delete",version:"0.1.10"}),e.doc.features.browsersync_enabled&&a.push({package:"@fnet/rollup-plugin-browsersync",version:"0.1.11"})}(this.#y),await this.initLibraryDir(),await this.initNunjucks(),await this.initLibs()}async initPython(){await async function(e){const{atom:t,context:a,setProgress:o}=e;o("Initializing features..."),t.doc.features=t.doc.features||{};const i=t.doc.features;!1===i.cli?i.cli={enabled:!1}:(i.cli,i.cli={enabled:!0}),i.cli.enabled=!0===i.cli.enabled&&(!1===t.doc.features.form_enabled||!0===i.cli.extend||!0===i.cli.enabled)}(this.#y),await async function({atom:e,packageDependencies:t,packageDevDependencies:a,setProgress:o}){o("Initializing dependencies")}(this.#y),await this.initLibraryDirPython(),await this.initNunjucks(),await this.initLibsPython()}async nodeBuild(){this.#u&&(await this.createAtomLibFiles({libs:this.#i}),await this.createEngine(),await this.createProjectYaml(),await q(this.#y),await async function({atom:t,setProgress:a,context:o,packageDependencies:i}){await a({message:"Creating tsconfig.json."});const s={atom:t,packageDependencies:i},r=o.templateCommonDir,c=w.compile(n.readFileSync(e.resolve(r,"tsconfig.json.njk"),"utf8"),w.configure(r)).render(s),p=o.projectDir,l=e.resolve(p,"tsconfig.json");n.writeFileSync(l,c,"utf8")}(this.#y),await U(this.#y),await async function({atom:t,setProgress:a,context:o,njEnv:i}){if(!0!==t.doc.features.cli.enabled)return;await a({message:"Creating yargs."});let s={};if(s=t.doc.input?t.doc.input:{type:"object",properties:{},required:[]},t.doc.features.cli.fargs&&!1!==t.doc.features.cli.fargs?.enabled){const e=t.doc.features.cli.fargs,a={type:"string",description:"Config name to load args",hidden:!1},o={type:"array",description:"Tags to filter the config",hidden:!1};Reflect.has(e,"default")&&(a.default=e.default),s.properties&&(s.properties.fargs=a,s.properties.ftag=o)}const r={options:s,imports:[],atom:t},c=o.templateDir,p=w.compile(n.readFileSync(e.resolve(c,"src/default/to.args.js.njk"),"utf8"),i).render(r),l=o.projectDir,d=e.resolve(l,"src/default/to.args.js");n.writeFileSync(d,p,"utf8");const m=new A({allErrors:!0,useDefaults:!0,formats:{},strict:!1,code:{esm:!0,lines:!0,optimize:!1,source:!0}});F(m);const u=m.compile(s),f=T(m,u);n.writeFileSync(e.resolve(l,"src/default/validate_input.js"),f,"utf8")}(this.#y),await async function({atom:t,setProgress:a,context:o,packageDependencies:i}){if(!0!==t.doc.features.cli.enabled)return;await a({message:"Creating cli."});const s={atom:t,packageDependencies:i},r=o.templateDir,c=e.resolve(o.projectDir,"src/cli");n.existsSync(c)||n.mkdirSync(c,{recursive:!0}),await g({pattern:["index.js.njk"],dir:e.resolve(r,"src/cli"),outDir:c,context:s})}(this.#y),await async function({atom:t,setProgress:a,context:o,packageDependencies:i}){if(!0!==t.doc.features.app.enabled)return;await a({message:"Creating app folder"});const s={atom:t,packageDependencies:i,ts:Date.now()},r=o.templateDir,c=e.resolve(o.projectDir,"src/app");n.existsSync(c)||n.mkdirSync(c,{recursive:!0});let p=["index.js.njk"];!1!==t.doc.features.app.html&&p.push("index.html.njk"),await g({pattern:p,dir:e.resolve(r,"src/app"),outDir:c,context:s})}(this.#y),await async function({atom:t,setProgress:a,context:o,packageDependencies:i}){await a({message:"Creating rollup file."});const s={atom:t,packageDependencies:i},r=e.resolve(o.projectDir,"src","default/index.js");if(!n.existsSync(r))throw new Error(`Entry file not found: ${r}`);const c=(await k({file:r,recursive:!0})).all.filter((e=>"node"===e.type)).map((e=>e.path)),p=t.doc.features.rollup_output,l=Object.keys(p);for(let e=0;e<l.length;e++){const t=p[l[e]];if(!0===t.browser&&c.length>0){t.globals_enabled=!0,t.globals=t.globals||[],t.globals=t.globals.concat(c.map((e=>({key:e,value:e})))),t.alias_enabled=!0,t.alias=t.alias||{},t.alias.entries=t.alias.entries||{};for(let e=0;e<c.length;e++){const a=c[e];t.alias.entries[a]=`node:${a}`,t.alias.entries[`node:${a}`]=a}t.external_enabled=!0,t.external=t.external||[],t.external=t.external.concat(c)}}const d=o.templateCommonDir;let m=w.compile(n.readFileSync(e.resolve(d,"rollup.config.mjs.njk"),"utf8"),w.configure(d)).render(s);const u=o.projectDir;let f=e.resolve(u,"rollup.config.mjs");n.writeFileSync(f,m,"utf8")}(this.#y),await async function({atom:t,context:a,packageDependencies:o,packageDevDependencies:i,setProgress:s}){await s({message:"Creating package.json."}),o.filter((e=>!0===e.dev)).forEach((e=>{i.find((t=>t.package===e.package))||i.push(e);const t=o.findIndex((t=>t.package===e.package));o.splice(t,1)}));const r=o.find((e=>"react"===e.package)),c=o.find((e=>"react-dom"===e.package));r&&!c?o.push({package:"react-dom",version:r.version}):r&&c&&(c.version=r.version),r&&t.doc.features.react_version>=17&&(o.find((e=>"@emotion/react"===e.package))||o.push({package:"@emotion/react",version:"^11"}),o.find((e=>"@emotion/styled"===e.package))||o.push({package:"@emotion/styled",version:"^11"}));const p=[];!0===t.doc.features.app.enabled&&p.push({file:e.resolve(a.projectDir,"src/app/index.js"),dev:!1!==t.doc.features.app.dev}),!0===t.doc.features.cli.enabled&&p.push({file:e.resolve(a.projectDir,"src/cli/index.js"),dev:!1!==t.doc.features.cli.dev});for await(const e of p){const t=e.file;if(!n.existsSync(t))throw new Error(`App file not found: ${t}`);const r=(await k({file:t,recursive:!0})).all;for await(const t of r){if("npm"!==t.type)continue;if(o.find((e=>e.package===t.package)))continue;if(i.find((e=>e.package===t.package)))continue;const n=await X({name:t.package,projectDir:a.projectDir,setProgress:s});(!0===e.dev?i:o).push({package:t.package,subpath:t.subpath,version:n.minorRange,type:"npm"})}}const l={atom:t,packageDependencies:o,packageDevDependencies:i},d=a.templateCommonDir,m=w.compile(n.readFileSync(e.resolve(d,"package.json.njk"),"utf8"),w.configure(d)).render(l),u=a.projectDir,f=e.resolve(u,"package.json");n.writeFileSync(f,m,"utf8");const g=e.resolve(a.project.projectDir,"fnet");if(n.existsSync(g)){const t=e.resolve(a.projectDir,"fnet");n.existsSync(t)||n.mkdirSync(t);const o=n.readdirSync(g);for(const a of o){const o=e.resolve(g,a);if(!n.lstatSync(o).isFile())continue;const i=e.resolve(t,a);n.copyFileSync(o,i)}}}(this.#y),await async function({setProgress:t,context:a}){const o=a.projectDir;await t({message:"Prettifiying source files."});let i=e.join("src","**","*");if(L("bun")){const e=await d(`prettier --write ${i} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:o});if(0!==e.code)throw new Error(e.stderr)}else{const e=await d(`prettier --write ${i} *.{js,cjs,mjs,json,yaml,html} --no-error-on-unmatched-pattern`,{cwd:o});if(0!==e.code)throw new Error(e.stderr)}}(this.#y),await async function({atom:e,setProgress:t,context:a}){if(!e.doc.features.dts_enabled)return;const o=a.projectDir;if(await t({message:"Creating .d.ts"}),0!==(await d("tsc",{cwd:o})).code)throw new Error("Couldnt create .d.ts files.")}(this.#y),this.#f&&(await async function({setProgress:e,atom:t,context:a}){const o=a.projectDir;if(await e({message:"Installing npm packages."}),L("bun")){if(0!==(await d(`bun install ${t.doc.features.npm_install_flags}`,{cwd:o})).code)throw new Error("Couldnt install npm packages.")}else if(0!==(await d(`npm install ${t.doc.features.npm_install_flags}`,{cwd:o})).code)throw new Error("Couldnt install npm packages.")}(this.#y),await async function({setProgress:e,context:t}){const a=t.projectDir;if(await e({message:"Building main project."}),0!==(await d("npm run build",{cwd:a})).code)throw new Error("Couldnt build project.")}(this.#y),this.#g&&await this.deploy()))}async pythonBuild(){this.#u&&(await this.createAtomLibFilesPython({libs:this.#i}),await this.createProjectYaml(),await q(this.#y),await U(this.#y),await async function({atom:t,setProgress:a,context:o,packageDependencies:i}){if(!0!==t.doc.features.cli.enabled)return;await a({message:"Creating cli."});const s={atom:t,packageDependencies:i},r=o.templateDir,c=e.join(o.projectDir,"src","cli");n.existsSync(c)||n.mkdirSync(c,{recursive:!0}),await g({pattern:["index.py.njk","__init__.py.njk"],dir:e.join(r,"src","cli"),outDir:c,context:s})}(this.#y),this.#f&&(await async function(t){const{setProgress:a,atom:o,context:i}=t;a({message:"Installing Python packages"});const s=i.projectDir,n=await R({pythonVersion:"3.12",packages:[{package:"fnet-import-parser",version:"0.1.9"}]}),{errors:r,result:c}=await n.runBin("fnet_import_parser",["--entry_file",e.join(s,"src","default","index.py")],{captureName:"result"});if(r)throw new Error(r.format());const p=JSON.parse(c.items[0].stdout),l=p.required["third-party"]?.map((e=>({package:e.metadata?.package||e.path,version:e.metadata?.version||void 0,channel:e.metadata?.channel||void 0})))||[],d=o.doc.dependencies||[];for(const e of l)d.some((t=>t.package===e.package))||d.push(e);const m=e.join(s,".conda"),u=await R({envDir:m,pythonVersion:o.doc.features.runtime.version||"3.12",packages:d});i.pythonEnv=u,t.packageDependencies=d;const f=o.doc.features.render?.dirs||[];for(const t of f)t.dir=e.resolve(s,t.dir),t.outDir=e.resolve(s,t.outDir),await g(t);let y={params:{}};y.params.package_name=o.doc.name,y.params.version="0.1.0",y.params.bin_name=o.doc.name,y.params.python_requires=o.doc.features.runtime.version||">=3.12",y.params.dependencies=d,y.params.scripts=JSON.stringify({cli:`PYTHONPATH='${e.join("src")}' '${e.relative(i.projectDir,u.pythonBin)}' '${e.join("src","cli","index.py")}'`}),await g({pattern:["setup.py.njk","package.json.njk","pyproject.toml.njk"],dir:i.templateDir,outDir:i.projectDir,context:y})}(this.#y),this.#g&&await this.deploy()))}async init(){this._redis_client=await async function(){if(!await P({host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}))return;const e=S.createClient({socket:{host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}});return await e.connect(),e}(),this.#c=this.#t.buildId||b(),this.#y.buildId=this.#c,this.#m=this.#t.mode,this.#u=["all","deploy","build","file"].includes(this.#m),this.#f=["all","deploy","build"].includes(this.#m),this.#g=["all","deploy"].includes(this.#m),this.#l=this.#t.protocol,this.#p="BUILD:"+this.#c,this.#d=(await u({optional:!0,name:this.#t.atomConfig||"atom",dir:this.#t.projectDir,tags:this.#t.tags}))?.data;try{await this.setProgress({message:"Initialization started."}),await this.initAuth(),await this.initLibrary(),"node"===this.#a.doc.features.runtime.type?await this.initNode():"python"===this.#a.doc.features.runtime.type&&await this.initPython()}catch(e){throw await this._cache_set(this.#p,{status:"FAILED",message:e?.message||e}),e}}async build(){try{"node"===this.#a.doc.features.runtime.type?await this.nodeBuild():"python"===this.#a.doc.features.runtime.type&&await this.pythonBuild(),await this._cache_set(this.#p,{status:"COMPLETED"})}catch(e){throw await this._cache_set(this.#p,{status:"FAILED",message:e.message||e}),console.log(e),e}}}const Q=e.dirname(o(import.meta.url)),W=process.cwd();process.on("uncaughtException",(e=>{N||(N=!0,setTimeout((()=>process.exit(1)),500))})),process.on("unhandledRejection",(e=>{N||(N=!0,setTimeout((()=>process.exit(1)),500))})),u({name:["redis"],dir:W,optional:!0});const Z=function({baseDir:t}){let a=t=t||O;for(;a!==e.parse(a).root;){const t=e.join(a,"node_modules");if(n.existsSync(t))return t;a=e.dirname(a)}return null}({baseDir:Q}),ee="win32"===process.platform?";":":";Z&&(process.env.PATH=`${e.join(Z,"/.bin")}${ee}${process.env.PATH}`);let te=p(process.argv.slice(2)).command("create","Create flow node project",(e=>e.option("name",{type:"Project name",demandOption:!0}).option("vscode",{type:"boolean",default:!0,alias:"vs"}).option("runtime",{type:"string",default:"node",choices:["node","python"]})),(async t=>{try{const a=e.resolve(Z,"@fnet/cli-project-node/dist/template/project"),o=e.resolve(W,t.name);n.existsSync(o)||n.mkdirSync(o),await g({dir:a,outDir:o,context:{name:t.name,runtime:t.runtime,platform:s.platform()},copyUnmatchedAlso:!0});let i=await d("fnode build",{cwd:o});if(0!==i.code)throw new Error("Failed to build project.");if(L("git")&&(i=await d("git init --initial-branch=main",{cwd:o}),0!==i.code))throw new Error("Failed to initialize git.");if(L("code")&&t.vscode&&(i=await d(`cd ${o} && code .`),0!==i.code))throw new Error("Failed to open vscode.");console.log("Creating project succeeded!"),process.exit(0)}catch(e){console.error("Initialization failed!",e.message),process.exit(1)}})).command("project","Flow node project",(e=>e.option("update",{type:"boolean",default:!1,alias:"-u"})),(async t=>{try{const a=e.resolve(Z,"@fnet/cli-project-node/dist/template/project"),o=process.cwd(),i=await ie(t);if(t.update){if(await g({dir:a,outDir:o,context:{name:i.project.projectFileParsed.name,runtime:i.project.runtime.type,platform:s.platform()},copyUnmatchedAlso:!0}),0!==(await d("fnode build",{cwd:o})).code)throw new Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(e){console.error("Project failed.",e.message),process.exit(1)}})).command("build","Build flow node project",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"]}).option("ftag",{type:"array"})),(async e=>{try{const t=await ie(e),a=new V(t);await a.init(),await a.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}})).command("deploy","Build and deploy flow node project",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("ftag",{type:"array"})),(async e=>{try{const t=await ie({...e,mode:"all"}),a=new V(t);await a.init(),await a.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}})).command("file","Just create files",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("ftag",{type:"array"})),(async e=>{try{const t=await ie({...e,mode:"file"}),a=new V(t);await a.init(),await a.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}}));function ae(e,{name:t,bin:a,preArgs:o=[]}){return"function"==typeof a&&(a=a()),e.command(`${t||a} [commands..]`,`${a} ${o.join(" ")}`,(e=>e.help(!1).version(!1)),(async e=>{try{const t=await ie(e),{projectDir:s}=t,n=e=>e.includes(" ")?"win32"===process.platform?`"${e.replace(/(["^])/g,"^$1")}"`:`"${e.replace(/(["\\$`])/g,"\\$1")}"`:e,r=process.argv.slice(3).map(n);B(i(a,[...o,...r],{cwd:s,stdio:"inherit",shell:!0,detached:!0}))}catch(e){console.error(e.message),process.exit(1)}}))}function oe(t,{name:a,bin:o,preArgs:s=[]}){return t.command(`${a||o} [commands..]`,`${o} ${s.join(" ")}`,(e=>e.help(!1).version(!1)),(async t=>{try{const n=await ie(t),{projectDir:r}=n,c=e=>e.includes(" ")?"win32"===process.platform?`"${e.replace(/(["^])/g,"^$1")}"`:`"${e.replace(/(["\\$`])/g,"\\$1")}"`:e,p=process.argv.slice(3).map(c);o=e.join(r,".conda","bin",o||a);B(i(o,[...s,...p],{cwd:r,stdio:"inherit",shell:!0,detached:!0,env:{PYTHONPATH:r}}))}catch(e){console.error(e.message),process.exit(1)}}))}async function ie(t){if(t.id)return{id:t.id,buildId:t.buildId,mode:t.mode,protocol:t.protocol||"ac:",templateDir:e.resolve(Z,"./@fnet/cli-project-node/dist/template/default"),templateCommonDir:e.resolve(Z,"./@fnet/cli-project-common/dist/template/default"),projectDir:e.resolve(W,`./.output/${t.id}`),tags:t.ftag};{const a=await async function({tags:t}){const a=e.resolve(W,"node.yaml");if(!n.existsSync(a))throw new Error("node.yaml file not found in current directory.");const{raw:o,parsed:i}=await m({file:a,tags:t}),s=e.dirname(a);i.features=i.features||{};const r=i.features;r.runtime=r.runtime||{},r.runtime.type=r.runtime.type||"node","python"===r.runtime.type?r.runtime.template=r.runtime.template||"python":r.runtime.template=r.runtime.template||"default";const p={libraryAtom:{doc:{...i},fileName:"index"},projectDir:s,projectFilePath:a,projectFileContent:o,projectFileParsed:i,runtime:r.runtime};let l=e.resolve(s,"fnet/targets.yaml");if(!n.existsSync(l)&&(l=e.resolve(s,"node.devops.yaml"),n.existsSync(l))){const t=e.resolve(s,"fnet");n.existsSync(t)||n.mkdirSync(t),n.copyFileSync(l,e.resolve(s,"fnet/targets.yaml")),n.unlinkSync(l)}if(n.existsSync(l)){const{raw:e,parsed:a}=await m({file:l,tags:t}),o=c.parseDocument(e);p.devops={filePath:l,fileContent:e,yamlDocument:o,doc:{...a},type:"library.deploy",save:async()=>{n.writeFileSync(p.devops.filePath,o.toString())}}}const d=e.resolve(s,"readme.md");if(n.existsSync(d)){const e=n.readFileSync(d,"utf8");p.readme={filePath:d,fileContent:e,doc:{content:e,"content-type":"markdown"},type:"wiki"}}return p}({tags:t.ftag});return{buildId:t.buildId,mode:t.mode,protocol:t.protocol||"local:",templateDir:e.resolve(Z,`./@fnet/cli-project-node/dist/template/${a.runtime.template}`),templateCommonDir:e.resolve(Z,`./@fnet/cli-project-common/dist/template/${a.runtime.template}`),projectDir:e.resolve(a.projectDir,"./.workspace"),projectSrcDir:e.resolve(a.projectDir,"./src"),project:a,tags:t.ftag}}}te=te.command("input [name]","Create or modify an input config file",(e=>e.positional("name",{type:"string",demandOption:!1}).help(!1).version(!1)),(async t=>{try{const a=await ie(t),{project:o}=a,{projectDir:i,projectFileParsed:s}=o,r=s.input;if(!r)throw new Error("Config schema not found in project file.");if(!Reflect.has(t,"name")){const{inputName:e}=await l({type:"input",name:"inputName",message:"Input name:",initial:"dev"});t.name=e}const c=e.resolve(i,".fnet");n.existsSync(c)||n.mkdirSync(c);const p=e.resolve(c,`${t.name}.fnet`),d=n.existsSync(p),m=(await import("@fnet/object-from-schema")).default,u=await m({schema:r,format:"yaml",ref:d?p:void 0});n.writeFileSync(p,u)}catch(e){console.error(e.message),process.exit(1)}})),te=ae(te,{bin:"npm"}),te=ae(te,{bin:"node"}),te=ae(te,{bin:"bun"}),te=ae(te,{name:"serve",bin:"bun",preArgs:["run","serve","--"]}),te=ae(te,{name:"watch",bin:"bun",preArgs:["run","watch","--"]}),te=ae(te,{name:"app",bin:"bun",preArgs:["run","app","--"]}),te=ae(te,{name:"cli",bin:"bun",preArgs:["run","cli","--"]}),te=ae(te,{bin:"npx"}),te=ae(te,{bin:"cdk"}),te=ae(te,{bin:"aws"}),te=function(e,{name:t,preArgs:a=[]}){return e.command(`${t} <config> <command> [options..]`,"Run a command with a config context",(e=>e.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)),(async e=>{try{const t=await ie(e),{projectDir:o}=t,s=e.config,r=await u({name:s,dir:o,transferEnv:!1,optional:!0,tags:t.tags}),c=r?.data?.env||void 0,p=e.command,l=process.argv.slice(5);B(i(p,[...a,...l],{cwd:n.existsSync(o)?o:W,stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...c}}))}catch(e){console.error(e.message),process.exit(1)}}))}(te,{name:"with"}),te=function(e,{name:t}){return e.command(`${t} group [options..]`,"Run a command group.",(e=>e.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)),(async e=>{try{const t=await ie(e),{project:a}=t,{projectFileParsed:o}=a,i=o.commands;if(!i)throw new Error("Commands not found in project file.");const s=i[e.group];if(!s)throw new Error(`Command group '${e.group}' not found in project file.`);await f({commands:s,context:{args:e,argv:process.argv}})}catch(e){console.error(e.message),process.exit(1)}}))}(te,{name:"run"}),te=oe(te,{name:"python"}),te=oe(te,{name:"python3"}),te=oe(te,{name:"pip"}),te=oe(te,{name:"pip3"}),te.demandCommand(1,"You need at least one command before moving on").help().argv;export{L as w};
2
+ import e,{delimiter as t,join as o}from"node:path";import{fileURLToPath as n}from"node:url";import{spawn as r}from"node:child_process";import i from"node:os";import a,{existsSync as s}from"node:fs";import c from"yaml";import l from"yargs";import p from"@fnet/prompt";import d from"@fnet/shelljs";import m from"@fnet/yaml";import u from"@fnet/config";import"@fnet/shell-flow";import f from"@flownet/lib-render-templates-dir";import{promisify as y}from"node:util";import w from"tree-kill";const g=e.dirname(n(import.meta.url));var h=e=>{const n=process.env.PATH||"",r="win32"===process.platform?(process.env.PATHEXT||".EXE;.CMD;.BAT;.COM").split(";"):[""],i=n.split(t);for(const t of i)for(const n of r){const r=o(t,"win32"===process.platform?e+n:e);if(s(r))return r}return null};const b=y(w);let j=!1;async function v(e,t){if(j)return;if(j=!0,!e.killed&&e.pid)try{await b(e.pid,"SIGTERM").catch((()=>{})),await new Promise((e=>setTimeout(e,500))),e.killed||await b(e.pid,"SIGKILL").catch((()=>{}))}catch(e){}await new Promise((e=>setTimeout(e,100)));const o="SIGINT"===t?130:"SIGTERM"===t?143:1;process.exit(o)}function x(e){["SIGINT","SIGTERM","SIGQUIT"].forEach((t=>{process.once(t,(async()=>{await v(e,t)}))})),process.on("uncaughtException",(async t=>{await v(e)})),process.on("unhandledRejection",(async t=>{await v(e)})),e.on("close",(e=>{j||process.exit(e)}))}const S=e.dirname(n(import.meta.url)),$=process.cwd();function E(t){const o=e.resolve($,t);if(a.existsSync(o))return o;const n=e.resolve(S,"../..",t);if(a.existsSync(n))return n;throw new Error(`Template path not found: ${t}`)}class I{static async createBuilder(e){if(!e.project){return new(0,(await import("./index.BSQp_bJN.js")).default)(e)}const t=e.project?.runtime?.type||"node";try{return new(await this.loadBuilderClass(t))(e)}catch(o){console.warn(`Warning: Could not load builder for runtime '${t}'. Falling back to legacy builder.`),console.warn(`Error: ${o.message}`);return new(0,(await import("./index.BSQp_bJN.js")).default)(e)}}static async loadBuilderClass(e){switch(e.toLowerCase()){case"node":return(await import("./index.DItyYiZ_.js")).default;case"python":return(await import("./index.B2LXSSn7.js")).default;case"bun":return(await import("./index.Chvv_TJm.js")).default;default:throw new Error(`Unsupported runtime type: ${e}`)}}}const T=e.dirname(n(import.meta.url)),D=process.cwd();process.on("uncaughtException",(e=>{j||(j=!0,setTimeout((()=>process.exit(1)),500))})),process.on("unhandledRejection",(e=>{j||(j=!0,setTimeout((()=>process.exit(1)),500))})),u({name:["redis"],dir:D,optional:!0});const F=function({baseDir:t}){let o=t=t||g;for(;o!==e.parse(o).root;){const t=e.join(o,"node_modules");if(a.existsSync(t))return t;o=e.dirname(o)}return null}({baseDir:T}),P="win32"===process.platform?";":":";F&&(process.env.PATH=`${e.join(F,"/.bin")}${P}${process.env.PATH}`);let A=l(process.argv.slice(2)).command("create","Create flow node project",(e=>e.option("name",{type:"Project name",demandOption:!0}).option("vscode",{type:"boolean",default:!0,alias:"vs"}).option("runtime",{type:"string",default:"node",choices:["node","python","bun"]})),(async t=>{try{const o=E("./template/fnode/project"),n=e.resolve(D,t.name);a.existsSync(n)||a.mkdirSync(n),await f({dir:o,outDir:n,context:{name:t.name,runtime:t.runtime,platform:i.platform()},copyUnmatchedAlso:!0});let r=await d("fnode build",{cwd:n});if(0!==r.code)throw new Error("Failed to build project.");if(h("git")&&(r=await d("git init --initial-branch=main",{cwd:n}),0!==r.code))throw new Error("Failed to initialize git.");if(h("code")&&t.vscode&&(r=await d(`cd ${n} && code .`),0!==r.code))throw new Error("Failed to open vscode.");console.log("Creating project succeeded!"),process.exit(0)}catch(e){console.error("Initialization failed!",e.message),process.exit(1)}})).command("project","Flow node project",(e=>e.option("update",{type:"boolean",default:!1,alias:"-u"})),(async e=>{try{const t=E("./template/fnode/project"),o=process.cwd(),n=await k(e);if(e.update){if(await f({dir:t,outDir:o,context:{name:n.project.projectFileParsed.name,runtime:n.project.runtime.type,platform:i.platform()},copyUnmatchedAlso:!0}),0!==(await d("fnode build",{cwd:o})).code)throw new Error("Failed to build project.");console.log("Updating project succeeded!")}process.exit(0)}catch(e){console.error("Project failed.",e.message),process.exit(1)}})).command("build","Build flow node project",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("mode",{type:"string",default:"build",choices:["all","file","build","deploy","bpmn"]}).option("ftag",{type:"array"})),(async e=>{try{const t=await k(e),o=await I.createBuilder(t);await o.init(),await o.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}})).command("deploy","Build and deploy flow node project",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("ftag",{type:"array"})),(async e=>{try{const t=await k({...e,mode:"all"}),o=await I.createBuilder(t);await o.init(),await o.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}})).command("file","Just create files",(e=>e.option("id",{type:"string"}).option("buildId",{type:"string",alias:"bid"}).option("ftag",{type:"array"})),(async e=>{try{const t=await k({...e,mode:"file"}),o=await I.createBuilder(t);await o.init(),await o.build(),console.log("Building library succeeded!"),process.exit(0)}catch(e){console.error("Building library failed!",e.message),process.exit(1)}}));function B(e,{name:t,bin:o,preArgs:n=[]}){return"function"==typeof o&&(o=o()),e.command(`${t||o} [commands..]`,`${o} ${n.join(" ")}`,(e=>e.help(!1).version(!1)),(async e=>{try{const t=await k(e),{projectDir:i}=t,a=e=>e.includes(" ")?"win32"===process.platform?`"${e.replace(/(["^])/g,"^$1")}"`:`"${e.replace(/(["\\$`])/g,"\\$1")}"`:e,s=process.argv.slice(3).map(a);x(r(o,[...n,...s],{cwd:i,stdio:"inherit",shell:!0,detached:!0}))}catch(e){console.error(e.message),process.exit(1)}}))}function C(t,{name:o,bin:n,preArgs:i=[]}){return t.command(`${o||n} [commands..]`,`${n} ${i.join(" ")}`,(e=>e.help(!1).version(!1)),(async t=>{try{const a=await k(t),{projectDir:s}=a,c=e=>e.includes(" ")?"win32"===process.platform?`"${e.replace(/(["^])/g,"^$1")}"`:`"${e.replace(/(["\\$`])/g,"\\$1")}"`:e,l=process.argv.slice(3).map(c);n=e.join(s,".conda","bin",n||o);x(r(n,[...i,...l],{cwd:s,stdio:"inherit",shell:!0,detached:!0,env:{PYTHONPATH:s}}))}catch(e){console.error(e.message),process.exit(1)}}))}async function k(t){if(t.id)return{id:t.id,buildId:t.buildId,mode:t.mode,protocol:t.protocol||"ac:",templateDir:E("./template/fnode/node"),projectDir:e.resolve(D,`./.output/${t.id}`),tags:t.ftag};{const o=await async function({tags:t}){let o=function(t){const o=e.resolve(t,"node.yaml"),n=e.resolve(t,"fnode.yaml");if(a.existsSync(n))return n;if(a.existsSync(o))try{const e=a.readFileSync(o,"utf8");return a.writeFileSync(n,e,"utf8"),a.unlinkSync(o),console.log(`Migrated node.yaml to fnode.yaml in ${t}`),n}catch(e){return console.error(`Error migrating node.yaml to fnode.yaml: ${e.message}`),o}return n}(D);if(!a.existsSync(o))throw new Error("fnode.yaml file not found in current directory.");const{raw:n,parsed:r}=await m({file:o,tags:t}),i=e.dirname(o);r.features=r.features||{};const s=r.features;s.runtime=s.runtime||{},s.runtime.type=s.runtime.type||"node","python"===s.runtime.type?s.runtime.template=s.runtime.template||"python":"bun"===s.runtime.type?s.runtime.template=s.runtime.template||"bun":s.runtime.template=s.runtime.template||"node";const l={libraryAtom:{doc:{...r},fileName:"index"},projectDir:i,projectFilePath:o,projectFileContent:n,projectFileParsed:r,runtime:s.runtime};let p=e.resolve(i,"fnet/targets.yaml");if(!a.existsSync(p)&&(p=e.resolve(i,"node.devops.yaml"),a.existsSync(p))){const t=e.resolve(i,"fnet");a.existsSync(t)||a.mkdirSync(t),a.copyFileSync(p,e.resolve(i,"fnet/targets.yaml")),a.unlinkSync(p)}if(a.existsSync(p)){const{raw:e,parsed:o}=await m({file:p,tags:t}),n=c.parseDocument(e);l.devops={filePath:p,fileContent:e,yamlDocument:n,doc:{...o},type:"library.deploy",save:async()=>{a.writeFileSync(l.devops.filePath,n.toString())}}}const d=e.resolve(i,"readme.md");if(a.existsSync(d)){const e=a.readFileSync(d,"utf8");l.readme={filePath:d,fileContent:e,doc:{content:e,"content-type":"markdown"},type:"wiki"}}return l}({tags:t.ftag});return{buildId:t.buildId,mode:t.mode,protocol:t.protocol||"local:",templateDir:E(`./template/fnode/${o.runtime.template}`),projectDir:e.resolve(o.projectDir,"./.workspace"),projectSrcDir:e.resolve(o.projectDir,"./src"),project:o,tags:t.ftag}}}A=A.command("input [name]","Create or modify an input config file",(e=>e.positional("name",{type:"string",demandOption:!1}).help(!1).version(!1)),(async t=>{try{const o=await k(t),{project:n}=o,{projectDir:r,projectFileParsed:i}=n,s=i.input;if(!s)throw new Error("Config schema not found in project file.");if(!Reflect.has(t,"name")){const{inputName:e}=await p({type:"input",name:"inputName",message:"Input name:",initial:"dev"});t.name=e}const c=e.resolve(r,".fnet");a.existsSync(c)||a.mkdirSync(c);const l=e.resolve(c,`${t.name}.fnet`),d=a.existsSync(l),m=(await import("@fnet/object-from-schema")).default,u=await m({schema:s,format:"yaml",ref:d?l:void 0});a.writeFileSync(l,u)}catch(e){console.error(e.message),process.exit(1)}})),A=B(A,{bin:"npm"}),A=B(A,{bin:"node"}),A=B(A,{bin:"bun"}),A=B(A,{name:"serve",bin:"bun",preArgs:["run","serve","--"]}),A=B(A,{name:"watch",bin:"bun",preArgs:["run","watch","--"]}),A=B(A,{name:"app",bin:"bun",preArgs:["run","app","--"]}),A=B(A,{name:"cli",bin:"bun",preArgs:["run","cli","--"]}),A=B(A,{bin:"npx"}),A=B(A,{bin:"cdk"}),A=B(A,{bin:"aws"}),A=function(e,{name:t,preArgs:o=[]}){return e.command(`${t} <config> <command> [options..]`,"Run a command with a config context",(e=>e.positional("config",{type:"string"}).positional("command",{type:"string"}).help(!1).version(!1)),(async e=>{try{const t=await k(e),{projectDir:n}=t,i=e.config,s=await u({name:i,dir:n,transferEnv:!1,optional:!0,tags:t.tags}),c=s?.data?.env||void 0,l=e.command,p=process.argv.slice(5);x(r(l,[...o,...p],{cwd:a.existsSync(n)?n:D,stdio:"inherit",shell:!0,detached:!0,env:{...process.env,...c}}))}catch(e){console.error(e.message),process.exit(1)}}))}(A,{name:"with"}),A=function(e,{name:t}){return e.command(`${t} group [options..]`,"Run a command group.",(e=>e.positional("group",{type:"string"}).option("ftag",{type:"array"}).help(!1).version(!1)),(async e=>{try{const{runCommandGroup:t}=await import("./index.DrwlOzAe.js");await t({projectType:"fnode",group:e.group,tags:e.ftag,args:e,argv:process.argv})}catch(e){console.error(e.message),process.exit(1)}}))}(A,{name:"run"}),A=C(A,{name:"python"}),A=C(A,{name:"python3"}),A=C(A,{name:"pip"}),A=C(A,{name:"pip3"}),A.demandCommand(1,"You need at least one command before moving on").help().argv;export{E as r,h as w};
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs';
3
+ import { hideBin } from 'yargs/helpers';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import fnetYaml from '@fnet/yaml';
7
+ import fnetShellFlow from '@fnet/shell-flow';
8
+
9
+ /**
10
+ * Run a command group from a project file
11
+ *
12
+ * @param {Object} options - Options for running the command
13
+ * @param {string} options.projectType - Type of project ('fnode', 'fnet', or 'auto')
14
+ * @param {string} options.group - Command group to run
15
+ * @param {Array} options.tags - Tags for conditional configuration
16
+ * @param {Object} options.args - Command line arguments
17
+ * @param {Array} options.argv - Raw command line arguments
18
+ * @returns {Promise<void>}
19
+ */
20
+ async function runCommandGroup({ projectType, group, tags, args, argv }) {
21
+ try {
22
+ // Detect project file based on project type
23
+ const projectFile = await detectProjectFile(projectType);
24
+
25
+ // Load project file
26
+ const { parsed: projectFileParsed } = await fnetYaml({
27
+ file: projectFile.path,
28
+ tags
29
+ });
30
+
31
+ // Check if commands section exists
32
+ const commands = projectFileParsed.commands;
33
+ if (!commands) {
34
+ throw new Error(`Commands section not found in ${projectFile.name}`);
35
+ }
36
+
37
+ // Check if command group exists
38
+ const commandGroup = commands[group];
39
+ if (!commandGroup) {
40
+ throw new Error(`Command group '${group}' not found in ${projectFile.name}`);
41
+ }
42
+
43
+ // Run command group
44
+ // console.log(`Running command group '${group}' from ${projectFile.name}...`);
45
+ await fnetShellFlow({
46
+ commands: commandGroup,
47
+ context: {
48
+ args,
49
+ argv,
50
+ projectType: projectFile.type
51
+ }
52
+ });
53
+
54
+ } catch (error) {
55
+ console.error(`Error: ${error.message}`);
56
+ process.exit(1);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Detect project file based on project type
62
+ *
63
+ * @param {string} projectType - Type of project ('fnode', 'fnet', or 'auto')
64
+ * @returns {Promise<Object>} Project file information
65
+ */
66
+ async function detectProjectFile(projectType) {
67
+ const cwd = process.cwd();
68
+ const fnodeYamlPath = path.resolve(cwd, 'fnode.yaml');
69
+ const fnetYamlPath = path.resolve(cwd, 'fnet.yaml');
70
+
71
+ // For auto detection, check both files
72
+ if (fs.existsSync(fnodeYamlPath)) {
73
+ return {
74
+ path: fnodeYamlPath,
75
+ name: 'fnode.yaml',
76
+ type: 'fnode'
77
+ };
78
+ }
79
+
80
+ if (fs.existsSync(fnetYamlPath)) {
81
+ return {
82
+ path: fnetYamlPath,
83
+ name: 'fnet.yaml',
84
+ type: 'fnet'
85
+ };
86
+ }
87
+
88
+ throw new Error('No project file (fnode.yaml or fnet.yaml) found in current directory');
89
+ }
90
+
91
+ // Main function
92
+ async function main() {
93
+ const argv = yargs(hideBin(process.argv))
94
+ .usage('Usage: $0 <command> [options]')
95
+ .command('$0 <group> [options..]', 'Run a command group from project file', (yargs) => {
96
+ return yargs
97
+ .positional('group', {
98
+ type: 'string',
99
+ describe: 'Command group to run'
100
+ })
101
+ .option('ftag', {
102
+ type: 'array',
103
+ describe: 'Tags for conditional configuration'
104
+ })
105
+ .example('$0 build', 'Run the build command group')
106
+ .example('$0 test --ftag dev', 'Run the test command group with dev tag')
107
+ })
108
+ .help()
109
+ .version()
110
+ .argv;
111
+
112
+ // Run command group using the common utility
113
+ await runCommandGroup({
114
+ projectType: 'auto', // Auto-detect project type
115
+ group: argv.group,
116
+ tags: argv.ftag,
117
+ args: argv,
118
+ argv: process.argv
119
+ });
120
+ }
121
+
122
+ // Run main function
123
+ main().catch(error => {
124
+ console.error(`Fatal error: ${error.message}`);
125
+ process.exit(1);
126
+ });
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@fnet/cli",
3
- "version": "0.111.0",
3
+ "version": "0.111.2",
4
4
  "files": [
5
- "dist"
5
+ "dist",
6
+ "template"
6
7
  ],
7
8
  "type": "module",
8
9
  "description": "CLI for Flownet",
9
10
  "scripts": {
10
11
  "build": "rollup --config",
11
12
  "deploy": "bun publish --access public",
12
- "watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT"
13
+ "watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT",
14
+ "postbuild": "chmod +x dist/fnode/index.js dist/fnet/index.js dist/frun/index.js"
13
15
  },
14
16
  "repository": {
15
17
  "type": "git",
@@ -29,10 +31,6 @@
29
31
  "@flownet/lib-to-nextjs": "^0.3.10",
30
32
  "@flownet/lib-to-webos": "^0.3.16",
31
33
  "@fnet/auto-conda-env": "^0.1.24",
32
- "@fnet/cli-project-common": "^0.3.14",
33
- "@fnet/cli-project-flow": "^0.12.1",
34
- "@fnet/cli-project-node": "^0.4.1",
35
- "@fnet/cli-project-schemas": "^0.1.2",
36
34
  "@fnet/config": "^0.2.28",
37
35
  "@fnet/dir-zipper": "^0.1.8",
38
36
  "@fnet/expression": "^0.1.29",
@@ -43,7 +41,7 @@
43
41
  "@fnet/object-from-schema": "^0.1.25",
44
42
  "@fnet/prompt": "^0.2.16",
45
43
  "@fnet/rollup-plugin-delete": "^0.1.10",
46
- "@fnet/shell-flow": "^0.1.38",
44
+ "@fnet/shell-flow": "^0.1.39",
47
45
  "@fnet/shelljs": "^0.2.4",
48
46
  "@fnet/to-pyip": "^0.1.7",
49
47
  "@fnet/to-rust": "^0.1.14",
@@ -75,7 +73,8 @@
75
73
  },
76
74
  "bin": {
77
75
  "fnet": "dist/fnet/index.js",
78
- "fnode": "dist/fnode/index.js"
76
+ "fnode": "dist/fnode/index.js",
77
+ "frun": "dist/frun/index.js"
79
78
  },
80
79
  "devDependencies": {
81
80
  "@rollup/plugin-commonjs": "^28.0.3",
package/readme.md CHANGED
@@ -1,50 +1,142 @@
1
- # :warning: Warning
1
+ # @fnet/cli: Flownet CLI Tools
2
2
 
3
- This tool is in its early stages of development. Changes in its usage are highly likely. Please use with caution.
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/fnetai/cli/main/assets/flownet-logo.png" alt="Flownet Logo" width="200"/>
5
+ </p>
4
6
 
7
+ <p align="center">
8
+ <b>Focus on functional code, let Flownet handle the rest</b>
9
+ </p>
5
10
 
6
- # @fnet/cli: Flow Node & Flow Project Setup Guide
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@fnet/cli"><img src="https://img.shields.io/npm/v/@fnet/cli.svg" alt="npm version"></a>
13
+ <a href="https://www.npmjs.com/package/@fnet/cli"><img src="https://img.shields.io/npm/dm/@fnet/cli.svg" alt="npm downloads"></a>
14
+ <a href="https://github.com/fnetai/cli/blob/main/LICENSE"><img src="https://img.shields.io/github/license/fnetai/cli.svg" alt="license"></a>
15
+ </p>
7
16
 
8
17
  ## Overview
9
18
 
10
- The `@fnet/cli` is a command-line interface tool designed to facilitate the development and deployment of flow-based projects within the fnet ecosystem. It simplifies the processes of creating, managing, and deploying flow-based projects, acting as a bridge between developers and the fnet platform.
19
+ Flownet is a revolutionary development framework that isolates non-functional components, allowing developers to focus solely on functional code. The `@fnet/cli` package provides command-line tools to create, build, and manage Flownet projects.
11
20
 
12
- ## Prerequisites
21
+ ### Key Features
22
+
23
+ - **Language Agnostic**: Support for multiple programming languages (JavaScript, Python) in the same project
24
+ - **Runtime Flexibility**: Choose the best runtime for each task (Node.js, Python, Bun)
25
+ - **Unified Interface**: Consistent commands across different project types
26
+ - **Tag-Based Configuration**: Powerful conditional configuration with `--ftag` parameter
27
+ - **Isolated Workspace**: All build artifacts and dependencies are kept in `.workspace` directory
28
+
29
+ ## Installation
13
30
 
14
- Ensure you have `@fnet/cli` installed globally:
15
31
  ```bash
16
- npm i @fnet/cli -g
17
- ```
32
+ # Using npm
33
+ npm install -g @fnet/cli
18
34
 
19
- Upon installation, two binary commands become available: `fnet` (for flow projects) and `fnode` (for flow node projects).
35
+ # Using yarn
36
+ yarn global add @fnet/cli
20
37
 
21
- ## Identifying Project Type
38
+ # Using bun
39
+ bun install -g @fnet/cli
40
+ ```
22
41
 
23
- - Flow Node Project: Presence of `node.yaml`. Use `fnode` commands.
24
- - Flow Project: Presence of `fnet.yaml`. Use `fnet` commands.
42
+ ## Quick Start
25
43
 
26
- ## Building the Project
44
+ ### Create a New Project
27
45
 
28
- For Flow Node:
29
46
  ```bash
30
- fnode build
47
+ # Create a Node.js project
48
+ fnode create my-node-project
49
+
50
+ # Create a Python project
51
+ fnode create my-python-project --runtime python
52
+
53
+ # Create a Bun project
54
+ fnode create my-bun-project --runtime bun
55
+
56
+ # Create a workflow project
57
+ fnet create my-workflow-project
31
58
  ```
32
59
 
33
- For Flow:
60
+ ### Build and Run
61
+
34
62
  ```bash
35
- fnet build
63
+ # Build the project
64
+ frun build
65
+
66
+ # Run the project
67
+ fnode cli
68
+
69
+ # Execute a command group from project file
70
+ frun <command-group> [--ftag <tags>]
36
71
  ```
37
72
 
38
- Both commands generate a `.workspace` directory with files and configurations for debugging, building, and deploying.
73
+ ## Project Types
39
74
 
40
- ## Watching the Project (Development Mode)
75
+ Flownet supports two main project types:
41
76
 
42
- For Flow Node:
43
- ```bash
44
- fnode watch
77
+ ### fnode Project
78
+
79
+ An **fnode project** (Flow Node Project) is a classic/node-style project that focuses on creating reusable components or standalone applications. These projects:
80
+
81
+ - Use `fnode.yaml` as their configuration file
82
+ - Typically contain a single code file in the `src` directory
83
+ - Can be built with different runtimes (Node.js, Python, Bun)
84
+ - Support multiple programming languages simultaneously
85
+
86
+ ### fnet Project
87
+
88
+ An **fnet project** (Flow Project) is a workflow-oriented project that focuses on orchestrating multiple components. These projects:
89
+
90
+ - Use `fnet.yaml` as their configuration file
91
+ - Define workflows that connect multiple components
92
+ - Support complex data flows and transformations
93
+
94
+ ## CLI Tools
95
+
96
+ Flownet provides three main CLI tools:
97
+
98
+ - **`fnode`**: For Node/classic projects (uses `fnode.yaml`)
99
+ - **`fnet`**: For Workflow projects (uses `fnet.yaml`)
100
+ - **`frun`**: Unified interface that works with both project types (auto-detects project file)
101
+
102
+ ## Multi-Language Support
103
+
104
+ Flownet supports multiple programming languages simultaneously within the same project:
105
+
106
+ ```text
107
+ my-project/
108
+ ├── src/
109
+ │ ├── index.js # JavaScript implementation (used by both Node.js and Bun)
110
+ │ └── index.py # Python implementation
111
+ ├── fnode.yaml # Project configuration file
112
+ └── .workspace/ # Build infrastructure (managed by CLI)
45
113
  ```
46
114
 
47
- For Flow:
115
+ This allows you to:
116
+
117
+ - Write your core logic once and migrate it to other languages as needed
118
+ - Choose the best language for each specific use case
119
+ - Use JavaScript with Node.js for quick development, Python for data processing, and JavaScript with Bun for improved performance
120
+
121
+ ## Tag-Based Configuration
122
+
123
+ Both CLI tools support the `--ftag` parameter for powerful conditional configuration:
124
+
48
125
  ```bash
49
- fnet watch
50
- ```
126
+ frun build --ftag dev --ftag local
127
+ ```
128
+
129
+ This activates sections in your project file marked with `t::dev::` or `t::local::` tags:
130
+
131
+ ```yaml
132
+ # Base configuration
133
+ name: my-project
134
+
135
+ # Development environment configuration
136
+ t::dev::database:
137
+ url: "mongodb://localhost:27017"
138
+
139
+ # Production environment configuration
140
+ t::prod::database:
141
+ url: "mongodb://production-server:27017"
142
+ ```
@@ -0,0 +1 @@
1
+ {{content | safe}}
@@ -0,0 +1 @@
1
+ {{content | safe}}
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>{{atom.doc.title or atom.doc.name}}</title>
8
+
9
+ {% if atom.doc.features.css.options.extract===true %}
10
+ <link rel="stylesheet" href="./index.css" />
11
+ {% endif %}
12
+
13
+ {% if atom.doc.features.app.format==='iife' %}
14
+ <script src="./index.js"></script>
15
+ {% endif %}
16
+
17
+ </head>
18
+ <body style="height:100vh;margin:0;padding:0;background-color: #eeeeee;">
19
+ <div id="container" style="height:100%;"></div>
20
+ {% if atom.doc.features.app.export===true %}
21
+ {% if atom.doc.features.app.format==='esm' %}
22
+ <script type="module">
23
+ import { createApp } from "./index.js";
24
+ const run = createApp({container: document.getElementById("container")});
25
+ {% if atom.doc.features.app.props %}
26
+ const dispose=run({{ atom.doc.features.app.props | dump | safe }});
27
+ {% else %}
28
+ const dispose=run();
29
+ {% endif %}
30
+ </script>
31
+ {% endif %}
32
+
33
+ {% if atom.doc.features.app.format==='iife' %}
34
+ <script>
35
+ const { createApp } = window['{{atom.doc.bundleName}}'];
36
+ const run = createApp({container: document.getElementById("container")});
37
+ {% if atom.doc.features.app.props %}
38
+ const dispose=run({{ atom.doc.features.app.props | dump | safe }});
39
+ {% else %}
40
+ const dispose=run();
41
+ {% endif %}
42
+ </script>
43
+ {% endif %}
44
+ {% endif %}
45
+
46
+ {% if atom.doc.features.workbox_enabled %}
47
+ {% if atom.doc.features.rollup_output.app.workbox.enabled %}
48
+ <!-- Service Worker Registration -->
49
+ <script>
50
+ if ('serviceWorker' in navigator) {
51
+ window.addEventListener('load', () => {
52
+ navigator
53
+ .serviceWorker
54
+ .register('./sw.js', {scope: './'}) // Optionally add scope
55
+ .then((registration) => {
56
+ console.log('Service Worker registered with scope:', registration.scope);
57
+ })
58
+ .catch((error) => {
59
+ console.log('Service Worker registration failed:', error);
60
+ });
61
+ });
62
+ }
63
+ </script>
64
+ {% endif%}
65
+ {% endif%}
66
+ </body>
67
+ </html>