@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.
- package/dist/fnet/index.DBSKvJyG.js +1 -0
- package/dist/fnet/index.DrwlOzAe.js +1 -0
- package/dist/fnet/index.js +1 -1
- package/dist/fnode/index.53yND1Av.js +1 -0
- package/dist/fnode/index.B1zLg4Y2.js +1 -0
- package/dist/fnode/index.B2LXSSn7.js +1 -0
- package/dist/fnode/index.BBrItYB9.js +1 -0
- package/dist/fnode/index.BSQp_bJN.js +1 -0
- package/dist/fnode/index.Bqzc7Bx8.js +1 -0
- package/dist/fnode/index.BwhWziH6.js +1 -0
- package/dist/fnode/index.CLlKzCGk.js +1 -0
- package/dist/fnode/index.Chvv_TJm.js +1 -0
- package/dist/fnode/index.D4KQB1ot.js +1 -0
- package/dist/fnode/index.DItyYiZ_.js +1 -0
- package/dist/fnode/index.DrwlOzAe.js +1 -0
- package/dist/fnode/index.js +1 -1
- package/dist/frun/index.js +126 -0
- package/package.json +8 -9
- package/readme.md +117 -25
- package/template/fnet/bun/fnet/flows.yaml.njk +1 -0
- package/template/fnet/bun/fnet.yaml.njk +1 -0
- package/template/fnet/bun/src/app/index.html.njk +67 -0
- package/template/fnet/bun/src/app/index.js.njk +36 -0
- package/template/fnet/bun/src/cli/index.js.njk +44 -0
- package/template/fnet/bun/src/default/blocks/assign.js.njk +40 -0
- package/template/fnet/bun/src/default/blocks/call.js.njk +92 -0
- package/template/fnet/bun/src/default/blocks/for.js.njk +81 -0
- package/template/fnet/bun/src/default/blocks/form.js.njk +65 -0
- package/template/fnet/bun/src/default/blocks/jump.js.njk +31 -0
- package/template/fnet/bun/src/default/blocks/modules.js.njk +50 -0
- package/template/fnet/bun/src/default/blocks/operation.js.njk +24 -0
- package/template/fnet/bun/src/default/blocks/raise.js.njk +25 -0
- package/template/fnet/bun/src/default/blocks/return.js.njk +27 -0
- package/template/fnet/bun/src/default/blocks/steps.js.njk +56 -0
- package/template/fnet/bun/src/default/blocks/switch.js.njk +73 -0
- package/template/fnet/bun/src/default/blocks/tryexcept.js.njk +65 -0
- package/template/fnet/bun/src/default/engine.js.njk +79 -0
- package/template/fnet/bun/src/default/macros/block-body-header.js.njk +7 -0
- package/template/fnet/bun/src/default/macros/block-footer.js.njk +3 -0
- package/template/fnet/bun/src/default/macros/block-header.js.njk +14 -0
- package/template/fnet/bun/src/default/macros/block-library-header.js.njk +19 -0
- package/template/fnet/bun/src/default/macros/block-modules-header.js.njk +8 -0
- package/template/fnet/bun/src/default/macros/block-modules.js.njk +29 -0
- package/template/fnet/bun/src/default/macros/block-next-header.js.njk +6 -0
- package/template/fnet/bun/src/default/macros/block-next.js.njk +20 -0
- package/template/fnet/bun/src/default/macros/block-run-form.js.njk +32 -0
- package/template/fnet/bun/src/default/macros/block-run-header.js.njk +39 -0
- package/template/fnet/bun/src/default/macros/page.js.njk +8 -0
- package/template/fnet/bun/src/default/macros/workflow-header.js.njk +7 -0
- package/template/fnet/bun/src/default/to.args.js.njk +120 -0
- package/template/fnet/bun/src/default/workflow.js.njk +117 -0
- package/template/fnet/core/assert.js +6 -0
- package/template/fnet/core/message.js +3 -0
- package/template/fnet/core/object.js +43 -0
- package/template/fnet/core/print.js +1 -0
- package/template/fnet/core/sleep.js +5 -0
- package/template/fnet/node/.gitignore.njk +8 -0
- package/template/fnet/node/fnet/flows.yaml.njk +1 -0
- package/template/fnet/node/fnet.yaml.njk +1 -0
- package/template/fnet/node/package.json.njk +90 -0
- package/template/fnet/node/readme.md.njk +21 -0
- package/template/fnet/node/rollup.config.mjs.njk +363 -0
- package/template/fnet/node/rollup_config_external.njk +8 -0
- package/template/fnet/node/rollup_config_onwarn.njk +9 -0
- package/template/fnet/node/rollup_config_output_banner.njk +3 -0
- package/template/fnet/node/rollup_config_output_footer.njk +5 -0
- package/template/fnet/node/rollup_config_output_globals.njk +9 -0
- package/template/fnet/node/rollup_config_output_name.njk +3 -0
- package/template/fnet/node/rollup_config_plugins.njk +90 -0
- package/template/fnet/node/src/app/index.html.njk +67 -0
- package/template/fnet/node/src/app/index.js.njk +36 -0
- package/template/fnet/node/src/cli/index.js.njk +44 -0
- package/template/fnet/node/src/default/blocks/assign.js.njk +40 -0
- package/template/fnet/node/src/default/blocks/call.js.njk +92 -0
- package/template/fnet/node/src/default/blocks/for.js.njk +81 -0
- package/template/fnet/node/src/default/blocks/form.js.njk +65 -0
- package/template/fnet/node/src/default/blocks/jump.js.njk +31 -0
- package/template/fnet/node/src/default/blocks/modules.js.njk +50 -0
- package/template/fnet/node/src/default/blocks/operation.js.njk +24 -0
- package/template/fnet/node/src/default/blocks/raise.js.njk +25 -0
- package/template/fnet/node/src/default/blocks/return.js.njk +27 -0
- package/template/fnet/node/src/default/blocks/steps.js.njk +56 -0
- package/template/fnet/node/src/default/blocks/switch.js.njk +73 -0
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +65 -0
- package/template/fnet/node/src/default/engine.js.njk +79 -0
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-header.js.njk +14 -0
- package/template/fnet/node/src/default/macros/block-library-header.js.njk +19 -0
- package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
- package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
- package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
- package/template/fnet/node/src/default/macros/block-next.js.njk +20 -0
- package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
- package/template/fnet/node/src/default/macros/block-run-header.js.njk +39 -0
- package/template/fnet/node/src/default/macros/page.js.njk +8 -0
- package/template/fnet/node/src/default/macros/workflow-header.js.njk +7 -0
- package/template/fnet/node/src/default/to.args.js.njk +120 -0
- package/template/fnet/node/src/default/workflow.js.njk +117 -0
- package/template/fnet/node/tsconfig.json.njk +16 -0
- package/template/fnet/project/.gitignore.njk +7 -0
- package/template/fnet/project/.vscode/launch.json +41 -0
- package/template/fnet/project/.vscode/tasks.json +46 -0
- package/template/fnet/project/fnet/flows.yaml.njk +4 -0
- package/template/fnet/project/fnet/targets.yaml.njk +7 -0
- package/template/fnet/project/fnet.yaml.njk +3 -0
- package/template/fnode/bun/.gitignore.njk +8 -0
- package/template/fnode/bun/build.js.njk +156 -0
- package/template/fnode/bun/fnode.yaml.njk +1 -0
- package/template/fnode/bun/package.json.njk +89 -0
- package/template/fnode/bun/readme.md.njk +21 -0
- package/template/fnode/bun/src/app/index-js-with-react-host.njk +50 -0
- package/template/fnode/bun/src/app/index-js-without-react-host.njk +23 -0
- package/template/fnode/bun/src/app/index.html.njk +67 -0
- package/template/fnode/bun/src/app/index.js.njk +9 -0
- package/template/fnode/bun/src/cli/index.js.njk +81 -0
- package/template/fnode/bun/src/default/engine.js.njk +17 -0
- package/template/fnode/bun/src/default/to.args.js.njk +120 -0
- package/template/fnode/bun/tsconfig.json.njk +16 -0
- package/template/fnode/node/.gitignore.njk +8 -0
- package/template/fnode/node/fnode.yaml.njk +1 -0
- package/template/fnode/node/package.json.njk +90 -0
- package/template/fnode/node/readme.md.njk +21 -0
- package/template/fnode/node/rollup.config.mjs.njk +363 -0
- package/template/fnode/node/rollup_config_external.njk +8 -0
- package/template/fnode/node/rollup_config_onwarn.njk +9 -0
- package/template/fnode/node/rollup_config_output_banner.njk +3 -0
- package/template/fnode/node/rollup_config_output_footer.njk +5 -0
- package/template/fnode/node/rollup_config_output_globals.njk +9 -0
- package/template/fnode/node/rollup_config_output_name.njk +3 -0
- package/template/fnode/node/rollup_config_plugins.njk +90 -0
- package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
- package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
- package/template/fnode/node/src/app/index.html.njk +67 -0
- package/template/fnode/node/src/app/index.js.njk +9 -0
- package/template/fnode/node/src/cli/index.js.njk +81 -0
- package/template/fnode/node/src/default/engine.js.njk +17 -0
- package/template/fnode/node/src/default/to.args.js.njk +120 -0
- package/template/fnode/node/tsconfig.json.njk +16 -0
- package/template/fnode/project/.gitignore.njk +11 -0
- package/template/fnode/project/.vscode/launch.json.njk +78 -0
- package/template/fnode/project/.vscode/tasks.json.njk +46 -0
- package/template/fnode/project/fnet/targets.yaml.njk +25 -0
- package/template/fnode/project/fnode.yaml.njk +12 -0
- package/template/fnode/python/.gitignore.njk +7 -0
- package/template/fnode/python/fnode.yaml.njk +1 -0
- package/template/fnode/python/package.json.njk +4 -0
- package/template/fnode/python/pyproject.toml.njk +3 -0
- package/template/fnode/python/readme.md.njk +12 -0
- package/template/fnode/python/setup.py.njk +19 -0
- package/template/fnode/python/src/cli/index.py.njk +25 -0
- package/template/schemas/to-npm.yaml +14 -0
- package/dist/fnet/index.DZbefC4O.js +0 -1
- package/dist/fnode/index.DrdnDArw.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
{% include "src/default/macros/block-header.js.njk" %}
|
|
3
|
+
|
|
4
|
+
{# {% include "src/default/macros/block-next-header.js.njk" %} #}
|
|
5
|
+
|
|
6
|
+
{% include "src/default/macros/block-modules-header.js.njk" %}
|
|
7
|
+
|
|
8
|
+
{% for child in childs %}
|
|
9
|
+
{% if not child.definition.dynamic %}
|
|
10
|
+
// CHILD: {{child.indexKey}}
|
|
11
|
+
import {{child.codeKey}} from "./{{child.codeKey}}";
|
|
12
|
+
{% endif %}
|
|
13
|
+
{% endfor%}
|
|
14
|
+
|
|
15
|
+
export default function Block(context) {
|
|
16
|
+
|
|
17
|
+
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
18
|
+
|
|
19
|
+
this.run= function (){
|
|
20
|
+
|
|
21
|
+
const args=Array.from(arguments);
|
|
22
|
+
|
|
23
|
+
return new Promise(async (resolve,reject)=>{
|
|
24
|
+
|
|
25
|
+
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
26
|
+
|
|
27
|
+
{% include "src/default/macros/page.js.njk" %}
|
|
28
|
+
|
|
29
|
+
{% include "src/default/macros/block-modules.js.njk" %}
|
|
30
|
+
|
|
31
|
+
try{
|
|
32
|
+
|
|
33
|
+
{% if context.try.definition.dynamic %}
|
|
34
|
+
const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}");
|
|
35
|
+
{% endif %}
|
|
36
|
+
|
|
37
|
+
const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c });
|
|
38
|
+
|
|
39
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
40
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
41
|
+
{% endif %}
|
|
42
|
+
|
|
43
|
+
return resolve(await current.run.apply(current,args));
|
|
44
|
+
}
|
|
45
|
+
catch({{context.except.context.transform.as | safe}}){
|
|
46
|
+
|
|
47
|
+
{% if context.except.definition.dynamic %}
|
|
48
|
+
const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}");
|
|
49
|
+
{% endif %}
|
|
50
|
+
|
|
51
|
+
const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c });
|
|
52
|
+
|
|
53
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
54
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
57
|
+
return resolve(await current.run.apply(current,args));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Object.freeze(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
{% include "src/default/macros/block-footer.js.njk" %}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Object from "../core/object";
|
|
2
|
+
|
|
3
|
+
import { default as Workflow } from "./{{flow.codeKey}}";
|
|
4
|
+
|
|
5
|
+
{% set form_enabled = false if flow.name === 'cli' else flow.parent.context.atom.doc.features.form_enabled %}
|
|
6
|
+
|
|
7
|
+
{% set form_enabled = false if flow.definition.features.server === true else form_enabled %}
|
|
8
|
+
|
|
9
|
+
{% if form_enabled %}
|
|
10
|
+
import { App } from "{{ui.package}}";
|
|
11
|
+
{% endif %}
|
|
12
|
+
|
|
13
|
+
export default class Engine extends Object {
|
|
14
|
+
|
|
15
|
+
#main;
|
|
16
|
+
{% if form_enabled %}
|
|
17
|
+
#app;
|
|
18
|
+
#appOwner;
|
|
19
|
+
{% endif %}
|
|
20
|
+
|
|
21
|
+
constructor(context) {
|
|
22
|
+
super(context);
|
|
23
|
+
|
|
24
|
+
this.#main = new Workflow({ engine: this });
|
|
25
|
+
|
|
26
|
+
{% if form_enabled %}
|
|
27
|
+
this.#app =context?.app || new App();
|
|
28
|
+
this.#appOwner = !!context?.app;
|
|
29
|
+
{% endif %}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async #init(context) {
|
|
33
|
+
{% if form_enabled %}
|
|
34
|
+
await this.#initApp(context);
|
|
35
|
+
{% endif %}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
{% if form_enabled %}
|
|
39
|
+
|
|
40
|
+
async #initApp(context) {
|
|
41
|
+
const container = context.params?.container;
|
|
42
|
+
await this.#app.init({ container });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async setActiveForm(context) {
|
|
46
|
+
const form = context.form;
|
|
47
|
+
const props = context.props;
|
|
48
|
+
|
|
49
|
+
await this.#app.setActiveForm({form,props});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get app(){
|
|
53
|
+
return this.#app;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
{% endif %}
|
|
57
|
+
|
|
58
|
+
// Main entry function to run workflow
|
|
59
|
+
async run(params) {
|
|
60
|
+
|
|
61
|
+
{% if flow.parent.context.atom.doc.features.print_steps %}
|
|
62
|
+
console.log(new Date().toLocaleString(),'{{ flow.parent.context.atom.doc.title or flow.parent.context.atom.doc.name }}');
|
|
63
|
+
{% endif %}
|
|
64
|
+
|
|
65
|
+
await this.#init({ params });
|
|
66
|
+
|
|
67
|
+
const response = await this.#main.run({ params });
|
|
68
|
+
|
|
69
|
+
return response?.value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async destroy() {
|
|
73
|
+
{% if form_enabled %}
|
|
74
|
+
if (this.#appOwner) {
|
|
75
|
+
await this.#app.destroy();
|
|
76
|
+
}
|
|
77
|
+
{% endif %}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// BLOCK: {{indexKey}}
|
|
2
|
+
|
|
3
|
+
import Message from "../../core/message";
|
|
4
|
+
{% if context.transform.print %}
|
|
5
|
+
import print from "../../core/print";
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
{% if context.transform.sleep %}
|
|
9
|
+
import sleep from "../../core/sleep";
|
|
10
|
+
{% endif %}
|
|
11
|
+
|
|
12
|
+
{% if context.transform.assert %}
|
|
13
|
+
import assert from "../../core/assert";
|
|
14
|
+
{% endif %}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{% if context.lib.type==='atom'%}
|
|
2
|
+
// LIBRARY: {{context.lib.atom.name}}
|
|
3
|
+
{% if context.lib.atom.relativePath %}
|
|
4
|
+
{% if context.transform.import %}
|
|
5
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
6
|
+
{% else %}
|
|
7
|
+
import { default as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
8
|
+
{% endif %}
|
|
9
|
+
{% else %}
|
|
10
|
+
{% if context.transform.import %}
|
|
11
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
12
|
+
{% else %}
|
|
13
|
+
import { default as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
14
|
+
{% endif %}
|
|
15
|
+
{% endif %}
|
|
16
|
+
{% elseif context.lib.type==='subworkflow' %}
|
|
17
|
+
// LIBRARY: {{context.lib.indexKey}}
|
|
18
|
+
import { default as {{context.lib.codeKey}} } from "../{{context.lib.codeKey}}";
|
|
19
|
+
{% endif %}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{% for child in childs %}
|
|
2
|
+
|
|
3
|
+
{% if child.module===true%}
|
|
4
|
+
|
|
5
|
+
// MODULE : {{child.indexKey}}
|
|
6
|
+
{% if child.definition.dynamic %}
|
|
7
|
+
const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}");
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
m['{{child.name}}']=async function(){
|
|
11
|
+
const entry=new {{child.codeKey}}({engine,flow,parent:_this,caller:c,module:true});
|
|
12
|
+
const nextBlock=await entry.run.apply(entry,arguments);
|
|
13
|
+
|
|
14
|
+
if(nextBlock?.type==='return') return nextBlock.value;
|
|
15
|
+
else if(nextBlock?.type==='block') {
|
|
16
|
+
{% if workflow.parent.context.atom.doc.features.print_module_final_next %}
|
|
17
|
+
console.log('MODULE FINAL NEXT:',nextBlock);
|
|
18
|
+
{% endif %}
|
|
19
|
+
resolve(nextBlock);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
{% if child.context.transform.export %}
|
|
24
|
+
flow.setModule({{child.context.transform.export | safe}}, m['{{child.name}}']);
|
|
25
|
+
{% endif %}
|
|
26
|
+
|
|
27
|
+
{% endif %}
|
|
28
|
+
|
|
29
|
+
{% endfor%}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{% if context.next %}
|
|
2
|
+
|
|
3
|
+
// NEXT : {{context.next.indexKey}}
|
|
4
|
+
{% if context.next.definition.dynamic %}
|
|
5
|
+
const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}");
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
return resolve ({
|
|
10
|
+
type: 'block',
|
|
11
|
+
from: _this,
|
|
12
|
+
fromType: _this.constructor,
|
|
13
|
+
fromClosure: c,
|
|
14
|
+
toType:{{context.next.codeKey}},
|
|
15
|
+
{% if context.transform.nextArgs %}
|
|
16
|
+
withArgs: {{context.transform.nextArgs | safe}},
|
|
17
|
+
{% endif %}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
{% endif %}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{% if context.transform.props %}
|
|
2
|
+
const formProps ={{context.transform.props | safe}} ;
|
|
3
|
+
{% else %}
|
|
4
|
+
const formProps={};
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
function actionClick(){
|
|
8
|
+
flow.continueForNext({key:'{{indexKey}}'});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
formProps.form=form;
|
|
12
|
+
|
|
13
|
+
formProps.actionClick=actionClick;
|
|
14
|
+
|
|
15
|
+
function Form(){
|
|
16
|
+
React.useEffect(()=>{
|
|
17
|
+
|
|
18
|
+
{% if workflow.parent.context.atom.doc.features.print_form_mounts %}
|
|
19
|
+
console.log('MOUNT:','{{indexKey}}');
|
|
20
|
+
{% endif %}
|
|
21
|
+
|
|
22
|
+
return ()=>{
|
|
23
|
+
{% if workflow.parent.context.atom.doc.features.print_form_mounts %}
|
|
24
|
+
console.log('UNMOUNT:','{{indexKey}}');
|
|
25
|
+
{% endif %}
|
|
26
|
+
}
|
|
27
|
+
},[]);
|
|
28
|
+
|
|
29
|
+
return React.createElement(formLib,formProps);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
engine.setActiveForm({ form: Form, props:formProps });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{# variables #}
|
|
2
|
+
const v=flow.get();
|
|
3
|
+
|
|
4
|
+
{# module #}
|
|
5
|
+
{% if hasModules %}
|
|
6
|
+
const m={};
|
|
7
|
+
{% else %}
|
|
8
|
+
const m = null;
|
|
9
|
+
{% endif %}
|
|
10
|
+
|
|
11
|
+
{# form #}
|
|
12
|
+
{% if type === 'form' %}
|
|
13
|
+
const form={};
|
|
14
|
+
{% else %}
|
|
15
|
+
const form=null;
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{# closure #}
|
|
19
|
+
const c={ caller, resolve, reject, args, get form(){return form||caller?.form}, get module(){return m||caller?.module} };
|
|
20
|
+
|
|
21
|
+
{% if workflow.parent.context.atom.doc.features.print_steps %}
|
|
22
|
+
console.log(new Date().toLocaleString(),'{{indexKey}}');
|
|
23
|
+
{% endif %}
|
|
24
|
+
|
|
25
|
+
{% if definition.debugger %}
|
|
26
|
+
debugger;
|
|
27
|
+
{% endif %}
|
|
28
|
+
|
|
29
|
+
{% if context.transform.print %}
|
|
30
|
+
print({{context.transform.print | safe}});
|
|
31
|
+
{% endif%}
|
|
32
|
+
|
|
33
|
+
{% if context.transform.assert %}
|
|
34
|
+
assert({{context.transform.assert | safe}});
|
|
35
|
+
{% endif%}
|
|
36
|
+
|
|
37
|
+
{% if context.transform.sleep %}
|
|
38
|
+
await sleep({{context.transform.sleep}});
|
|
39
|
+
{% endif %}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{% if atom.doc.features.project.format === 'esm' %}
|
|
2
|
+
import fnetArgs from '@fnet/args';
|
|
3
|
+
import validate from "./validate_input";
|
|
4
|
+
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
5
|
+
const fnetArgs = require('@fnet/args');
|
|
6
|
+
const validate = require("./validate_input");
|
|
7
|
+
{% endif %}
|
|
8
|
+
|
|
9
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
10
|
+
|
|
11
|
+
const get_fargs = (argv) => {
|
|
12
|
+
const fargsIndex = argv.indexOf('--fargs');
|
|
13
|
+
if (fargsIndex !== -1 && argv[fargsIndex + 1]) return argv[fargsIndex + 1];
|
|
14
|
+
{% if atom.doc.features.cli.fargs.default %}
|
|
15
|
+
else return "{{atom.doc.features.cli.fargs.default}}";
|
|
16
|
+
{% endif %}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const get_ftags = (argv) => {
|
|
20
|
+
const ftags = [];
|
|
21
|
+
for (let i = 0; i < argv.length; i++) {
|
|
22
|
+
if (argv[i] === '--ftag' && argv[i + 1]) {
|
|
23
|
+
ftags.push(argv[i + 1]);
|
|
24
|
+
i++;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
{% if atom.doc.features.cli.fargs.tags %}
|
|
29
|
+
return ftags.length > 0 ? ftags : {{atom.doc.features.cli.fargs.tags | dump | safe}};
|
|
30
|
+
{% else %}
|
|
31
|
+
return ftags.length > 0 ? ftags : undefined;
|
|
32
|
+
{% endif %}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
{% endif %}
|
|
36
|
+
|
|
37
|
+
{% if atom.doc.features.project.format === 'esm' %}
|
|
38
|
+
|
|
39
|
+
export default async () => {
|
|
40
|
+
|
|
41
|
+
let schema = {{options | dump | safe}};
|
|
42
|
+
let initial;
|
|
43
|
+
|
|
44
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
45
|
+
const fargs = get_fargs(process.argv.slice(2));
|
|
46
|
+
const ftags = get_ftags(process.argv.slice(2));
|
|
47
|
+
|
|
48
|
+
if (fargs) {
|
|
49
|
+
const { default: fnetConfig } = await import("@fnet/config");
|
|
50
|
+
const config = await fnetConfig({ name: fargs, tags: ftags });
|
|
51
|
+
if (config?.data) {
|
|
52
|
+
initial=config.data;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
{% endif %}
|
|
56
|
+
|
|
57
|
+
const packageCallback = async () => {
|
|
58
|
+
const { default: url } = await import("node:url");
|
|
59
|
+
const { default: path } = await import("node:path");
|
|
60
|
+
const { default: fs } = await import("node:fs");
|
|
61
|
+
let currentDir = path.dirname(url.fileURLToPath(import.meta.url));
|
|
62
|
+
let firstPackageJson = path.join(currentDir, "package.json");
|
|
63
|
+
while (currentDir !== path.parse(currentDir).root && !fs.existsSync(firstPackageJson)) {
|
|
64
|
+
currentDir = path.dirname(currentDir);
|
|
65
|
+
firstPackageJson = path.join(currentDir, "package.json");
|
|
66
|
+
}
|
|
67
|
+
if (!fs.existsSync(firstPackageJson)) return {
|
|
68
|
+
name: "Unknown",
|
|
69
|
+
version: "Unknown"
|
|
70
|
+
}
|
|
71
|
+
else return await JSON.parse(fs.readFileSync(firstPackageJson, "utf8"));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return await fnetArgs({schema,initial,validate,packageCallback});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
78
|
+
|
|
79
|
+
module.exports = async () => {
|
|
80
|
+
let schema = {{options | dump | safe}};
|
|
81
|
+
let initial;
|
|
82
|
+
|
|
83
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
84
|
+
const fargs = get_fargs(process.argv.slice(2));
|
|
85
|
+
const ftags = get_ftags(process.argv.slice(2));
|
|
86
|
+
|
|
87
|
+
if (fargs) {
|
|
88
|
+
const { default: fnetConfig } = await import("@fnet/config");
|
|
89
|
+
const config = await fnetConfig({ name: fargs, tags: ftags });
|
|
90
|
+
if (config?.data) {
|
|
91
|
+
initial=config.data;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
{% endif %}
|
|
95
|
+
|
|
96
|
+
const packageCallback = async () => {
|
|
97
|
+
const path = require("node:path");
|
|
98
|
+
const fs = require("node:fs");
|
|
99
|
+
|
|
100
|
+
let currentDir = __dirname;
|
|
101
|
+
let firstPackageJson = path.join(currentDir, "package.json");
|
|
102
|
+
|
|
103
|
+
while (currentDir !== path.parse(currentDir).root && !fs.existsSync(firstPackageJson)) {
|
|
104
|
+
currentDir = path.dirname(currentDir);
|
|
105
|
+
firstPackageJson = path.join(currentDir, "package.json");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!fs.existsSync(firstPackageJson)) {
|
|
109
|
+
return {
|
|
110
|
+
name: "Unknown",
|
|
111
|
+
version: "Unknown"
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
return JSON.parse(fs.readFileSync(firstPackageJson, "utf8"));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return await fnetArgs({schema,initial,validate,packageCallback});
|
|
119
|
+
};
|
|
120
|
+
{% endif %}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{% include "src/default/macros/workflow-header.js.njk" %}
|
|
2
|
+
|
|
3
|
+
{% if context.next %}
|
|
4
|
+
{% if not context.next.definition.dynamic %}
|
|
5
|
+
// NEXT: {{context.next.indexKey}}
|
|
6
|
+
import {{context.next.codeKey}} from "./blocks/{{context.next.codeKey}}";
|
|
7
|
+
{% endif %}
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
export default class Workflow extends Object {
|
|
11
|
+
|
|
12
|
+
#waitContext;
|
|
13
|
+
|
|
14
|
+
constructor(context) {
|
|
15
|
+
super(context);
|
|
16
|
+
|
|
17
|
+
this.engine=context.engine;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async init(context) {
|
|
21
|
+
|
|
22
|
+
{% if context.transform.params %}
|
|
23
|
+
const params = context?.params;
|
|
24
|
+
|
|
25
|
+
{% for param in context.transform.params %}
|
|
26
|
+
{% if param.hasDefault%}
|
|
27
|
+
{% if param.type ==='string'%}
|
|
28
|
+
this.set('{{param.key}}', params?.hasOwnProperty('{{param.key}}')? params['{{param.key}}']:'{{param.default}}');
|
|
29
|
+
{% else %}
|
|
30
|
+
this.set('{{param.key}}', params?.hasOwnProperty('{{param.key}}')? params['{{param.key}}']:{{param.default | dump}});
|
|
31
|
+
{% endif %}
|
|
32
|
+
{% else %}
|
|
33
|
+
this.set('{{param.key}}',this.getValue(params,'{{param.key}}'));
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endfor%}
|
|
36
|
+
|
|
37
|
+
this.set('$params',params);
|
|
38
|
+
|
|
39
|
+
{% endif %}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
waitForNext(context){
|
|
43
|
+
this.#waitContext=context;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async continueForNext(context){
|
|
47
|
+
const next=this.#waitContext?.next;
|
|
48
|
+
this.#waitContext=undefined;
|
|
49
|
+
next && await next();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async run(context) {
|
|
53
|
+
|
|
54
|
+
{% if workflow.parent.context.atom.doc.features.print_steps %}
|
|
55
|
+
console.log(new Date().toLocaleString(),'{{indexKey}}');
|
|
56
|
+
{% endif %}
|
|
57
|
+
|
|
58
|
+
{% if definition.debugger %}
|
|
59
|
+
debugger;
|
|
60
|
+
{% endif %}
|
|
61
|
+
|
|
62
|
+
{% if context.transform.print %}
|
|
63
|
+
print({{context.transform.print | safe}});
|
|
64
|
+
{% endif%}
|
|
65
|
+
|
|
66
|
+
{% if context.transform.assert %}
|
|
67
|
+
assert({{context.transform.assert | safe}});
|
|
68
|
+
{% endif%}
|
|
69
|
+
|
|
70
|
+
{% if context.transform.sleep %}
|
|
71
|
+
await sleep({{context.transform.sleep}});
|
|
72
|
+
{% endif %}
|
|
73
|
+
|
|
74
|
+
await this.init(context);
|
|
75
|
+
|
|
76
|
+
{% if context.next %}
|
|
77
|
+
|
|
78
|
+
{% if context.next.definition.dynamic %}
|
|
79
|
+
// NEXT : {{context.next.indexKey}}
|
|
80
|
+
const { default: {{context.next.codeKey}} } = await import("./blocks/{{context.next.codeKey}}");
|
|
81
|
+
{% endif %}
|
|
82
|
+
|
|
83
|
+
{# closure #}
|
|
84
|
+
const c={};
|
|
85
|
+
|
|
86
|
+
let current=new {{context.next.codeKey}}({ parent:this, engine:this.engine, flow:this, caller:c });
|
|
87
|
+
let currentArgs;
|
|
88
|
+
|
|
89
|
+
do {
|
|
90
|
+
|
|
91
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
92
|
+
console.log(new Date().toLocaleString(),' * ', this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
93
|
+
{% endif %}
|
|
94
|
+
|
|
95
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
96
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if(nextBlock?.type==='return') return nextBlock;
|
|
100
|
+
else if(nextBlock?.type!=='block') break;
|
|
101
|
+
|
|
102
|
+
if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
|
|
103
|
+
throw new Error('Unknown situation');
|
|
104
|
+
|
|
105
|
+
current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c });
|
|
106
|
+
currentArgs=nextBlock.withArgs;
|
|
107
|
+
|
|
108
|
+
} while(true);
|
|
109
|
+
|
|
110
|
+
{% endif %}
|
|
111
|
+
|
|
112
|
+
return this.result;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Workflow.TypeId="{{typeId}}";
|
|
117
|
+
Workflow.IndexKey="{{indexKey}}";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import getValue from "get-value";
|
|
2
|
+
import setValue from "set-value";
|
|
3
|
+
import print from "./print";
|
|
4
|
+
|
|
5
|
+
export default class Object {
|
|
6
|
+
#property;
|
|
7
|
+
#context;
|
|
8
|
+
#module;
|
|
9
|
+
|
|
10
|
+
constructor(context) {
|
|
11
|
+
|
|
12
|
+
this.#property = {}
|
|
13
|
+
this.#module = {};
|
|
14
|
+
this.#context = context;
|
|
15
|
+
|
|
16
|
+
this.get = (path, options) => {
|
|
17
|
+
return getValue(this.#property, path, options);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.set = (path, value, options) => {
|
|
21
|
+
return setValue(this.#property, path, value, options);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.print = print;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getModule(path) {
|
|
28
|
+
return getValue(this.#module, path);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setModule(path, module) {
|
|
32
|
+
if (typeof module !== "function") throw new Error("Module must be a function");
|
|
33
|
+
return setValue(this.#module, path, module);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get getValue() {
|
|
37
|
+
return getValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get setValue() {
|
|
41
|
+
return setValue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default console.log;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{content | safe}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{content | safe}}
|