@fnet/cli 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fbin/index.js +2 -0
- package/dist/fnet/index.-SGbq2cI.js +1 -0
- package/dist/fnet/index.B0TQiWy6.js +1 -0
- package/dist/fnet/index.B5XE4ChJ.js +1 -0
- package/dist/fnet/index.Bft2w7m3.js +1 -0
- package/dist/fnet/index.BuYxdKtK.js +1 -0
- package/dist/fnet/index.C2S9JYhS.js +1 -0
- package/dist/fnet/index.C7saWH6d.js +1 -0
- package/dist/fnet/index.CDct_kkF.js +1 -0
- package/dist/fnet/index.CMC8mlye.js +1 -0
- package/dist/fnet/index.CmMM-Ek9.js +1 -0
- package/dist/fnet/index.CuMyez3E.js +1 -0
- package/dist/fnet/index.CzAV0S36.js +1 -0
- package/dist/fnet/index.D2N9YZmA.js +1 -0
- package/dist/fnet/index.D3p7pncT.js +1 -0
- package/dist/fnet/index.DG8TqL-1.js +1 -0
- package/dist/fnet/index.DI3yyTtl.js +1 -0
- package/dist/fnet/index.DWpw12No.js +1 -0
- package/dist/fnet/index.DrwlOzAe.js +1 -0
- package/dist/fnet/index.Q-CYRcna.js +1 -0
- package/dist/fnet/index.W6RYgypK.js +1 -0
- package/dist/fnet/index.js +2 -0
- package/dist/fnet/index.rSKuKke7.js +1 -0
- package/dist/fnet/index.xd8c7XMr.js +1 -0
- package/dist/fnode/index.-SGbq2cI.js +1 -0
- package/dist/fnode/index.1IxoA5DY.js +1 -0
- package/dist/fnode/index.B5XE4ChJ.js +1 -0
- package/dist/fnode/index.Bft2w7m3.js +1 -0
- package/dist/fnode/index.BuYxdKtK.js +1 -0
- package/dist/fnode/index.C2S9JYhS.js +1 -0
- package/dist/fnode/index.C7saWH6d.js +1 -0
- package/dist/fnode/index.CDct_kkF.js +1 -0
- package/dist/fnode/index.CJ4EhqPO.js +1 -0
- package/dist/fnode/index.CMC8mlye.js +1 -0
- package/dist/fnode/index.CmMM-Ek9.js +1 -0
- package/dist/fnode/index.CuMyez3E.js +1 -0
- package/dist/fnode/index.CzAV0S36.js +1 -0
- package/dist/fnode/index.D2N9YZmA.js +1 -0
- package/dist/fnode/index.D3p7pncT.js +1 -0
- package/dist/fnode/index.DG8TqL-1.js +1 -0
- package/dist/fnode/index.DI3yyTtl.js +1 -0
- package/dist/fnode/index.DWpw12No.js +1 -0
- package/dist/fnode/index.DrwlOzAe.js +1 -0
- package/dist/fnode/index.N_a5FdgA.js +1 -0
- package/dist/fnode/index.Q-CYRcna.js +1 -0
- package/dist/fnode/index.UNoFg95r.js +1 -0
- package/dist/fnode/index.W6RYgypK.js +1 -0
- package/dist/fnode/index.js +2 -0
- package/dist/fnode/index.tq-9YxMP.js +1 -0
- package/dist/fnode/index.xd8c7XMr.js +1 -0
- package/dist/frun/index.js +2 -0
- package/dist/fservice/index.js +2 -0
- package/package.json +89 -0
- package/readme.md +251 -0
- package/template/fnet/core/assert.js +6 -0
- package/template/fnet/core/message.js +3 -0
- package/template/fnet/core/object.js +47 -0
- package/template/fnet/core/print.js +1 -0
- package/template/fnet/core/sleep.js +5 -0
- package/template/fnet/node/.gitignore.njk +9 -0
- package/template/fnet/node/build.js.njk +153 -0
- package/template/fnet/node/package.json.njk +118 -0
- package/template/fnet/node/readme.md.njk +21 -0
- package/template/fnet/node/rollup.config.mjs.njk +498 -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 +319 -0
- package/template/fnet/node/src/default/blocks/assign.js.njk +53 -0
- package/template/fnet/node/src/default/blocks/call.js.njk +156 -0
- package/template/fnet/node/src/default/blocks/for.js.njk +87 -0
- package/template/fnet/node/src/default/blocks/form.js.njk +69 -0
- package/template/fnet/node/src/default/blocks/modules.js.njk +57 -0
- package/template/fnet/node/src/default/blocks/new.js.njk +87 -0
- package/template/fnet/node/src/default/blocks/next.js.njk +37 -0
- package/template/fnet/node/src/default/blocks/output.js.njk +53 -0
- package/template/fnet/node/src/default/blocks/raise.js.njk +31 -0
- package/template/fnet/node/src/default/blocks/return.js.njk +33 -0
- package/template/fnet/node/src/default/blocks/signal.js.njk +37 -0
- package/template/fnet/node/src/default/blocks/steps.js.njk +63 -0
- package/template/fnet/node/src/default/blocks/switch.js.njk +79 -0
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +74 -0
- package/template/fnet/node/src/default/blocks/wait.js.njk +34 -0
- package/template/fnet/node/src/default/engine.js.njk +79 -0
- package/template/fnet/node/src/default/input.args.js.njk +122 -0
- package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-entry-args.js.njk +2 -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 +43 -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 +21 -0
- package/template/fnet/node/src/default/macros/block-run-footer.js.njk +7 -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 +31 -0
- package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -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/workflow.js.njk +123 -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.njk +41 -0
- package/template/fnet/project/.vscode/tasks.json.njk +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/node/.gitignore.njk +9 -0
- package/template/fnode/node/build.js.njk +149 -0
- package/template/fnode/node/package.json.njk +120 -0
- package/template/fnode/node/readme.md.njk +21 -0
- package/template/fnode/node/rollup.config.mjs.njk +498 -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 +403 -0
- package/template/fnode/node/src/default/engine.js.njk +17 -0
- package/template/fnode/node/src/default/input.args.js.njk +122 -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/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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{% if atom.doc.features.project.format === 'esm' %}
|
|
2
|
+
import fnetArgs from '@fnet/args';
|
|
3
|
+
import validate,{schema as inputSchema} from "./validate_input.js";
|
|
4
|
+
|
|
5
|
+
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
6
|
+
const fnetArgs = require('@fnet/args');
|
|
7
|
+
const validate,{schema as inputSchema} = require("./validate_input.js");
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
11
|
+
|
|
12
|
+
const get_fargs = (argv) => {
|
|
13
|
+
const fargsIndex = argv.indexOf('--fargs');
|
|
14
|
+
if (fargsIndex !== -1 && argv[fargsIndex + 1]) return argv[fargsIndex + 1];
|
|
15
|
+
{% if atom.doc.features.cli.fargs.default %}
|
|
16
|
+
else return "{{atom.doc.features.cli.fargs.default}}";
|
|
17
|
+
{% endif %}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const get_ftags = (argv) => {
|
|
21
|
+
const ftags = [];
|
|
22
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23
|
+
if (argv[i] === '--ftag' && argv[i + 1]) {
|
|
24
|
+
ftags.push(argv[i + 1]);
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
{% if atom.doc.features.cli.fargs.tags %}
|
|
30
|
+
return ftags.length > 0 ? ftags : {{atom.doc.features.cli.fargs.tags | dump | safe}};
|
|
31
|
+
{% else %}
|
|
32
|
+
return ftags.length > 0 ? ftags : undefined;
|
|
33
|
+
{% endif %}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
{% endif %}
|
|
37
|
+
|
|
38
|
+
{% if atom.doc.features.project.format === 'esm' %}
|
|
39
|
+
|
|
40
|
+
export default async () => {
|
|
41
|
+
|
|
42
|
+
let schema = inputSchema;
|
|
43
|
+
let initial;
|
|
44
|
+
|
|
45
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
46
|
+
const fargs = get_fargs(process.argv.slice(2));
|
|
47
|
+
const ftags = get_ftags(process.argv.slice(2));
|
|
48
|
+
|
|
49
|
+
if (fargs) {
|
|
50
|
+
const { default: fnetConfig } = await import("@fnet/config");
|
|
51
|
+
const config = await fnetConfig({ name: fargs, tags: ftags });
|
|
52
|
+
if (config?.data) {
|
|
53
|
+
initial=config.data;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
{% endif %}
|
|
57
|
+
|
|
58
|
+
const packageCallback = async () => {
|
|
59
|
+
const { default: url } = await import("node:url");
|
|
60
|
+
const { default: path } = await import("node:path");
|
|
61
|
+
const { default: fs } = await import("node:fs");
|
|
62
|
+
let currentDir = path.dirname(url.fileURLToPath(import.meta.url));
|
|
63
|
+
let firstPackageJson = path.join(currentDir, "package.json");
|
|
64
|
+
while (currentDir !== path.parse(currentDir).root && !fs.existsSync(firstPackageJson)) {
|
|
65
|
+
currentDir = path.dirname(currentDir);
|
|
66
|
+
firstPackageJson = path.join(currentDir, "package.json");
|
|
67
|
+
}
|
|
68
|
+
if (!fs.existsSync(firstPackageJson)) return {
|
|
69
|
+
name: "Unknown",
|
|
70
|
+
version: "Unknown"
|
|
71
|
+
}
|
|
72
|
+
else return await JSON.parse(fs.readFileSync(firstPackageJson, "utf8"));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return await fnetArgs({schema,initial,validate,packageCallback});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
{% elif atom.doc.features.project.format === 'cjs' %}
|
|
79
|
+
|
|
80
|
+
module.exports = async () => {
|
|
81
|
+
|
|
82
|
+
let schema = inputSchema;
|
|
83
|
+
let initial;
|
|
84
|
+
|
|
85
|
+
{% if atom.doc.features.cli.fargs and atom.doc.features.cli.fargs?.enabled !== false %}
|
|
86
|
+
const fargs = get_fargs(process.argv.slice(2));
|
|
87
|
+
const ftags = get_ftags(process.argv.slice(2));
|
|
88
|
+
|
|
89
|
+
if (fargs) {
|
|
90
|
+
const { default: fnetConfig } = await import("@fnet/config");
|
|
91
|
+
const config = await fnetConfig({ name: fargs, tags: ftags });
|
|
92
|
+
if (config?.data) {
|
|
93
|
+
initial=config.data;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
{% endif %}
|
|
97
|
+
|
|
98
|
+
const packageCallback = async () => {
|
|
99
|
+
const path = require("node:path");
|
|
100
|
+
const fs = require("node:fs");
|
|
101
|
+
|
|
102
|
+
let currentDir = __dirname;
|
|
103
|
+
let firstPackageJson = path.join(currentDir, "package.json");
|
|
104
|
+
|
|
105
|
+
while (currentDir !== path.parse(currentDir).root && !fs.existsSync(firstPackageJson)) {
|
|
106
|
+
currentDir = path.dirname(currentDir);
|
|
107
|
+
firstPackageJson = path.join(currentDir, "package.json");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!fs.existsSync(firstPackageJson)) {
|
|
111
|
+
return {
|
|
112
|
+
name: "Unknown",
|
|
113
|
+
version: "Unknown"
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
return JSON.parse(fs.readFileSync(firstPackageJson, "utf8"));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return await fnetArgs({schema,initial,validate,packageCallback});
|
|
121
|
+
};
|
|
122
|
+
{% endif %}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// BLOCK: {{indexKey}}
|
|
2
|
+
|
|
3
|
+
import Message from "../../core/message.js";
|
|
4
|
+
{% if context.transform.print %}
|
|
5
|
+
import print from "../../core/print.js";
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
{% if context.transform.sleep %}
|
|
9
|
+
import sleep from "../../core/sleep.js";
|
|
10
|
+
{% endif %}
|
|
11
|
+
|
|
12
|
+
{% if context.transform.assert %}
|
|
13
|
+
import assert from "../../core/assert.js";
|
|
14
|
+
{% endif %}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{% if context.lib.type==='atom'%}
|
|
2
|
+
{# Check if this is a use: protocol (native JS) #}
|
|
3
|
+
{% if context.lib.atom.protocol==='use:' %}
|
|
4
|
+
{# NO IMPORT for use: protocol - it's native JS #}
|
|
5
|
+
// LIBRARY: {{context.lib.atom.name}} (native)
|
|
6
|
+
{% else %}
|
|
7
|
+
// LIBRARY: {{context.lib.atom.name}}
|
|
8
|
+
{% if context.lib.atom.relativePath %}
|
|
9
|
+
{% if context.transform.from and context.transform.import %}
|
|
10
|
+
{# NEW: from + import pattern (e.g., from: npm:eventemitter3, import: EventEmitter) #}
|
|
11
|
+
import { {{ context.transform.import | safe }} as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
12
|
+
{% elseif context.transform.import %}
|
|
13
|
+
{# EXISTING: import pattern (e.g., import: npm:lodash, call: cloneDeep) #}
|
|
14
|
+
{% if context.transform.libExp %}
|
|
15
|
+
import { default as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
16
|
+
{% else %}
|
|
17
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
18
|
+
{% endif %}
|
|
19
|
+
{% else %}
|
|
20
|
+
{# EXISTING: default import #}
|
|
21
|
+
import { default as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
22
|
+
{% endif %}
|
|
23
|
+
{% else %}
|
|
24
|
+
{% if context.transform.from and context.transform.import %}
|
|
25
|
+
{# NEW: from + import pattern for non-relative paths #}
|
|
26
|
+
{% if context.transform.libExp %}
|
|
27
|
+
import { default as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
28
|
+
{% else %}
|
|
29
|
+
import { {{ context.transform.import | safe }} as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
30
|
+
{% endif %}
|
|
31
|
+
{% elseif context.transform.import %}
|
|
32
|
+
{# EXISTING: import pattern for non-relative paths #}
|
|
33
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
34
|
+
{% else %}
|
|
35
|
+
{# EXISTING: default import for non-relative paths #}
|
|
36
|
+
import { default as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
37
|
+
{% endif %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% endif %}
|
|
40
|
+
{% elseif context.lib.type==='subworkflow' %}
|
|
41
|
+
// LIBRARY: {{context.lib.indexKey}}
|
|
42
|
+
import { default as {{context.lib.codeKey}} } from "../{{context.lib.codeKey}}.js";
|
|
43
|
+
{% 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}}.js");
|
|
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,21 @@
|
|
|
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}}.js");
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
resolve ({
|
|
10
|
+
type: 'block',
|
|
11
|
+
from: _this,
|
|
12
|
+
fromType: _this.constructor,
|
|
13
|
+
fromClosure: c,
|
|
14
|
+
toType:{{context.next.codeKey}},
|
|
15
|
+
onError,
|
|
16
|
+
{% if context.transform.output %}
|
|
17
|
+
input: {{context.transform.output | safe}},
|
|
18
|
+
{% endif %}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
{% 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,31 @@
|
|
|
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.sleep %}
|
|
30
|
+
await sleep({{context.transform.sleep}});
|
|
31
|
+
{% endif %}
|
|
@@ -0,0 +1,123 @@
|
|
|
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}}.js";
|
|
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}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:'{{param.default}}');
|
|
29
|
+
{% elif param.type ==='object' %}
|
|
30
|
+
this.set('{{param.key}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:{{param.default | dump | safe}});
|
|
31
|
+
{% else %}
|
|
32
|
+
this.set('{{param.key}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:{{param.default | dump}});
|
|
33
|
+
{% endif %}
|
|
34
|
+
{% else %}
|
|
35
|
+
this.set('{{param.key}}',this.getValue(params,'{{param.key}}'));
|
|
36
|
+
{% endif %}
|
|
37
|
+
{% endfor%}
|
|
38
|
+
|
|
39
|
+
this.set('$params',params);
|
|
40
|
+
|
|
41
|
+
{% endif %}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
waitForNext(context){
|
|
45
|
+
this.#waitContext=context;
|
|
46
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
47
|
+
this.#waitContext.timeoutId = setInterval(() => {}, 0x7FFFFFFF);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async continueForNext(context){
|
|
51
|
+
const next=this.#waitContext?.next;
|
|
52
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
53
|
+
this.#waitContext=undefined;
|
|
54
|
+
next && await next();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async run(context) {
|
|
58
|
+
|
|
59
|
+
{% if workflow.parent.context.atom.doc.features.print_steps %}
|
|
60
|
+
console.log(new Date().toLocaleString(),'{{indexKey}}');
|
|
61
|
+
{% endif %}
|
|
62
|
+
|
|
63
|
+
{% if definition.debugger %}
|
|
64
|
+
debugger;
|
|
65
|
+
{% endif %}
|
|
66
|
+
|
|
67
|
+
{% if context.transform.sleep %}
|
|
68
|
+
await sleep({{context.transform.sleep}});
|
|
69
|
+
{% endif %}
|
|
70
|
+
|
|
71
|
+
await this.init(context);
|
|
72
|
+
|
|
73
|
+
{% if context.next %}
|
|
74
|
+
|
|
75
|
+
{% if context.next.definition.dynamic %}
|
|
76
|
+
// NEXT : {{context.next.indexKey}}
|
|
77
|
+
const { default: {{context.next.codeKey}} } = await import("./blocks/{{context.next.codeKey}}.js");
|
|
78
|
+
{% endif %}
|
|
79
|
+
|
|
80
|
+
{# closure #}
|
|
81
|
+
const c={};
|
|
82
|
+
|
|
83
|
+
let current=new {{context.next.codeKey}}({ parent:this, engine:this.engine, flow:this, caller:c });
|
|
84
|
+
let currentArgs;
|
|
85
|
+
|
|
86
|
+
do {
|
|
87
|
+
|
|
88
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
89
|
+
console.log(new Date().toLocaleString(),' * ', this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
90
|
+
{% endif %}
|
|
91
|
+
|
|
92
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
93
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if(nextBlock?.type==='return') return nextBlock;
|
|
97
|
+
else if(nextBlock?.type!=='block') break;
|
|
98
|
+
|
|
99
|
+
if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
|
|
100
|
+
throw new Error('Unknown situation');
|
|
101
|
+
|
|
102
|
+
current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c });
|
|
103
|
+
currentArgs=nextBlock.input;
|
|
104
|
+
|
|
105
|
+
} while(true);
|
|
106
|
+
|
|
107
|
+
{% endif %}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
{% if context.transform.print %}
|
|
111
|
+
print({{context.transform.print | safe}});
|
|
112
|
+
{% endif%}
|
|
113
|
+
|
|
114
|
+
{% if context.transform.assert %}
|
|
115
|
+
assert({{context.transform.assert | safe}});
|
|
116
|
+
{% endif%}
|
|
117
|
+
|
|
118
|
+
return this.result;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Workflow.TypeId="{{typeId}}";
|
|
123
|
+
Workflow.IndexKey="{{indexKey}}";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*.js"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "./types",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"emitDeclarationOnly": true,
|
|
10
|
+
"target": "es5",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"jsx": "react-jsx"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "debug-fnet-cli",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"program": "${workspaceFolder}/.workspace/src/cli/index.js",
|
|
15
|
+
"cwd": "${workspaceFolder}/.workspace",
|
|
16
|
+
"preLaunchTask": "fnet-watch",
|
|
17
|
+
"console": "integratedTerminal"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "debug-fnet-app",
|
|
21
|
+
"type": "chrome",
|
|
22
|
+
"request": "launch",
|
|
23
|
+
"url": "http://localhost:3000/dist/app/esm/",
|
|
24
|
+
"webRoot": "${workspaceFolder}/.workspace",
|
|
25
|
+
"preLaunchTask": "fnet-watch",
|
|
26
|
+
// "userDataDir": false,
|
|
27
|
+
// "runtimeArgs": [
|
|
28
|
+
// "--profile-directory=<profile-name>",
|
|
29
|
+
// ]
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
// "compounds": [
|
|
33
|
+
// {
|
|
34
|
+
// "name": "debug-fnet-all",
|
|
35
|
+
// "configurations": [
|
|
36
|
+
// "debug-fnet-cli",
|
|
37
|
+
// "debug-fnet-app"
|
|
38
|
+
// ]
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "fnet-build",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "fnet build",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"label": "fnet-watch",
|
|
11
|
+
"type": "shell",
|
|
12
|
+
"command": "fnet watch",
|
|
13
|
+
"isBackground": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "fnet-deploy",
|
|
17
|
+
"type": "shell",
|
|
18
|
+
"command": "fnet deploy",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"label": "fnet-cli",
|
|
22
|
+
"type": "shell",
|
|
23
|
+
"command": "fnet cli",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"label": "fnet-app",
|
|
27
|
+
"type": "shell",
|
|
28
|
+
"command": "fnet app",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"label": "fnet-project-update",
|
|
32
|
+
"type": "shell",
|
|
33
|
+
"command": "fnet project -u",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"label": "fnet-npm-update",
|
|
37
|
+
"type": "shell",
|
|
38
|
+
"command": "fnet npm update",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "fnet-npm-outdated",
|
|
42
|
+
"type": "shell",
|
|
43
|
+
"command": "fnet npm outdated",
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|