@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,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,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 @@
|
|
|
1
|
+
{{content | safe}}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{atom.doc['npm::name'] or atom.doc['name'] or atom['id']}}",
|
|
3
|
+
"version": "{{atom.doc['npm::version'] or '0.1.0'}}",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist/*",
|
|
6
|
+
"fnet/input.yaml",
|
|
7
|
+
"fnet/output.yaml"
|
|
8
|
+
],
|
|
9
|
+
{# "sideEffects": false, #}
|
|
10
|
+
{% if atom.doc['npm::author'] %}
|
|
11
|
+
"author": "{{atom.doc['npm::author'] | safe}}",
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if atom.doc['npm::description'] %}
|
|
15
|
+
"description": "{{atom.doc['npm::description'] | safe}}",
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
19
|
+
{% if atom.doc.features.rollup_output.esm.enabled === true%}
|
|
20
|
+
"main": "dist/default/esm/index.js",
|
|
21
|
+
"type":"module",
|
|
22
|
+
{% else %}
|
|
23
|
+
"main": "dist/default/cjs/index.cjs",
|
|
24
|
+
{% endif %}
|
|
25
|
+
{% if atom.doc.features.dts_enabled ===true %}
|
|
26
|
+
"types": "dist/default/types/index.d.ts",
|
|
27
|
+
{% endif %}
|
|
28
|
+
"exports":{
|
|
29
|
+
".":{
|
|
30
|
+
"import":"./dist/default/esm/index.js",
|
|
31
|
+
"require":"./dist/default/cjs/index.cjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{% else %}
|
|
35
|
+
"main": "dist/default/esm/index.js",
|
|
36
|
+
{% if atom.doc.features.dts_enabled ===true %}
|
|
37
|
+
"types": "dist/default/types/index.d.ts",
|
|
38
|
+
{% endif %}
|
|
39
|
+
"type":"module",
|
|
40
|
+
"exports":{
|
|
41
|
+
".":{
|
|
42
|
+
"import":"./dist/default/esm/index.js",
|
|
43
|
+
"require":"./dist/default/cjs/index.cjs"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{% endif %}
|
|
47
|
+
|
|
48
|
+
{% if atom.doc.repo.url %}
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "{{atom.doc.repo.type or 'git'}}",
|
|
51
|
+
"url": "{{atom.doc.repo.url}}"
|
|
52
|
+
},
|
|
53
|
+
{% endif %}
|
|
54
|
+
"license": "{{atom.doc.license or 'MIT'}}",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "rollup --config",
|
|
57
|
+
"watch": "rollup --config --watch --sourcemap --environment DEVELOPMENT",
|
|
58
|
+
"serve": "bunx serve ./"
|
|
59
|
+
{% if atom.doc.features.cli.enabled %}
|
|
60
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
61
|
+
,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs"
|
|
62
|
+
{% else %}
|
|
63
|
+
,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/"
|
|
64
|
+
{% endif %}
|
|
65
|
+
|
|
66
|
+
{% endif %}
|
|
67
|
+
{% if atom.doc.features.app.enabled %}
|
|
68
|
+
,"app": "bunx serve {{atom.doc.features.app.dir}}/"
|
|
69
|
+
{% endif %}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
{% for dep in packageDevDependencies %}
|
|
73
|
+
"{{dep.package}}":"{{dep.version}}" {% if not loop.last%},{%endif%}
|
|
74
|
+
{% endfor%}
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
{% for dep in packageDependencies %}
|
|
78
|
+
"{{dep.package}}":"{{dep.version}}" {% if not loop.last%},{%endif%}
|
|
79
|
+
{% endfor%}
|
|
80
|
+
}
|
|
81
|
+
{% if atom.doc.features.cli.enabled and atom.doc['npm::bin'] %}
|
|
82
|
+
,"bin":{
|
|
83
|
+
{% if atom.doc.features.project.format ==='cjs' %}
|
|
84
|
+
"{{atom.doc['npm::bin']}}":"{{atom.doc.features.cli.dir}}/index.cjs"
|
|
85
|
+
{% else %}
|
|
86
|
+
"{{atom.doc['npm::bin']}}":"{{atom.doc.features.cli.dir}}/index.js"
|
|
87
|
+
{% endif %}
|
|
88
|
+
}
|
|
89
|
+
{% endif %}
|
|
90
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{{content | safe}}
|
|
2
|
+
|
|
3
|
+
{% if howto %}
|
|
4
|
+
{{howto | safe}}
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
{% if input %}
|
|
8
|
+
# Input Schema
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
{{ input | safe}}
|
|
12
|
+
```
|
|
13
|
+
{% endif %}
|
|
14
|
+
|
|
15
|
+
{% if output %}
|
|
16
|
+
# Output Schema
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
{{ output | safe}}
|
|
20
|
+
```
|
|
21
|
+
{% endif %}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
2
|
+
import { nodeResolve as resolve } from "@rollup/plugin-node-resolve";
|
|
3
|
+
import external from "rollup-plugin-peer-deps-external";
|
|
4
|
+
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
const DEVELOPMENT = process.env.DEVELOPMENT ? true : false;
|
|
9
|
+
const extensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
|
|
10
|
+
|
|
11
|
+
{% if atom.doc.features.copy_enabled===true %}
|
|
12
|
+
const copyFiles = async (src, dest) => {
|
|
13
|
+
try {
|
|
14
|
+
await fs.copy(src, dest);
|
|
15
|
+
console.log(`Copied files from ${src} to ${dest}`);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error('Error copying files:', err);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const watchFiles = async (targets) => {
|
|
22
|
+
const chokidar = await import('chokidar');
|
|
23
|
+
targets.forEach(target => {
|
|
24
|
+
const watcher = chokidar.watch(target.src, { persistent: true });
|
|
25
|
+
|
|
26
|
+
watcher.on('add', async filePath => {
|
|
27
|
+
const destPath = target.dest;
|
|
28
|
+
const relativePath = path.relative(path.dirname(target.src), filePath);
|
|
29
|
+
await copyFiles(filePath, path.join(destPath, relativePath));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
watcher.on('change', async filePath => {
|
|
33
|
+
const destPath = target.dest;
|
|
34
|
+
const relativePath = path.relative(path.dirname(target.src), filePath);
|
|
35
|
+
await copyFiles(filePath, path.join(destPath, relativePath));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
watcher.on('unlink', async filePath => {
|
|
39
|
+
const destPath = target.dest;
|
|
40
|
+
const relativePath = path.relative(path.dirname(target.src), filePath);
|
|
41
|
+
try {
|
|
42
|
+
await fs.remove(path.join(destPath, relativePath));
|
|
43
|
+
console.log(`Removed files from ${path.join(destPath, relativePath)}`);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error('Error removing files:', err);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
{% endif %}
|
|
51
|
+
|
|
52
|
+
const initPlugins = async (options) => {
|
|
53
|
+
const plugins = [];
|
|
54
|
+
|
|
55
|
+
{# DELETE #}
|
|
56
|
+
if (options.delete) {
|
|
57
|
+
const {default:del} = await import('@fnet/rollup-plugin-delete');
|
|
58
|
+
plugins.push(del(options.delete));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
{# REPLACE #}
|
|
62
|
+
if (options.replace) {
|
|
63
|
+
const {default:replace} = await import("@rollup/plugin-replace");
|
|
64
|
+
plugins.push(replace({
|
|
65
|
+
"process.env.NODE_ENV": JSON.stringify(DEVELOPMENT ? 'development' : 'production'),
|
|
66
|
+
preventAssignment: true,
|
|
67
|
+
...options.replace
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
{# ALIAS #}
|
|
72
|
+
if (options.alias) {
|
|
73
|
+
const {default:alias} = await import('@rollup/plugin-alias');
|
|
74
|
+
plugins.push(alias(options.alias));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
{# NUNJUCKS #}
|
|
78
|
+
{% if atom.doc.features.nunjucks_enabled===true %}
|
|
79
|
+
if (options.nunjucks) {
|
|
80
|
+
const {default:nunjucks} = await import('@fnet/rollup-plugin-nunjucks');
|
|
81
|
+
plugins.push(nunjucks(options.nunjucks.options));
|
|
82
|
+
}
|
|
83
|
+
{% endif %}
|
|
84
|
+
|
|
85
|
+
{# COPY #}
|
|
86
|
+
{% if atom.doc.features.copy_enabled===true %}
|
|
87
|
+
if (options.copy) {
|
|
88
|
+
const {default:copy} = await import('rollup-plugin-copy');
|
|
89
|
+
plugins.push(copy(options.copy.options));
|
|
90
|
+
|
|
91
|
+
if (DEVELOPMENT) watchFiles(options.copy.options.targets);
|
|
92
|
+
}
|
|
93
|
+
{% endif %}
|
|
94
|
+
|
|
95
|
+
{# STRING #}
|
|
96
|
+
{% if atom.doc.features.string_enabled===true %}
|
|
97
|
+
if (options.string) {
|
|
98
|
+
const { string } = await import('rollup-plugin-string');
|
|
99
|
+
plugins.push(string(options.string.options));
|
|
100
|
+
}
|
|
101
|
+
{% endif %}
|
|
102
|
+
|
|
103
|
+
{# IMAGE #}
|
|
104
|
+
{% if atom.doc.features.image_enabled===true %}
|
|
105
|
+
if (options.image) {
|
|
106
|
+
const {default:image} = await import('@rollup/plugin-image');
|
|
107
|
+
plugins.push(image(options.image.options));
|
|
108
|
+
}
|
|
109
|
+
{% endif %}
|
|
110
|
+
|
|
111
|
+
{# WASM #}
|
|
112
|
+
{% if atom.doc.features.wasm_enabled===true %}
|
|
113
|
+
if (options.wasm) {
|
|
114
|
+
const { wasm } = await import('@rollup/plugin-wasm');
|
|
115
|
+
plugins.push(wasm(options.wasm.options));
|
|
116
|
+
}
|
|
117
|
+
{% endif %}
|
|
118
|
+
|
|
119
|
+
{# POSTCSS #}
|
|
120
|
+
{% if atom.doc.features.css_enabled===true %}
|
|
121
|
+
if (options.postcss) {
|
|
122
|
+
const {default:postcss} = await import('rollup-plugin-postcss');
|
|
123
|
+
const { plugins: cssPlugins, ...cssOptions } = options.postcss.options;
|
|
124
|
+
const postcssPlugins = [];
|
|
125
|
+
|
|
126
|
+
if (cssPlugins) {
|
|
127
|
+
for (const plugin of cssPlugins) {
|
|
128
|
+
let pluginLib;
|
|
129
|
+
switch (plugin.name) {
|
|
130
|
+
case "postcss-import":
|
|
131
|
+
pluginLib = (await import("postcss-import")).default;
|
|
132
|
+
break;
|
|
133
|
+
case "postcss-url":
|
|
134
|
+
pluginLib = (await import("postcss-url")).default;
|
|
135
|
+
break;
|
|
136
|
+
case "postcss-preset-env":
|
|
137
|
+
pluginLib = (await import("postcss-preset-env")).default;
|
|
138
|
+
break;
|
|
139
|
+
case "autoprefixer":
|
|
140
|
+
pluginLib = (await import("autoprefixer")).default;
|
|
141
|
+
break;
|
|
142
|
+
case "cssnano":
|
|
143
|
+
pluginLib = (await import("cssnano")).default;
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
postcssPlugins.push(pluginLib(plugin.options));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
plugins.push(postcss({
|
|
153
|
+
...cssOptions,
|
|
154
|
+
plugins: postcssPlugins
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
{% endif %}
|
|
158
|
+
|
|
159
|
+
{# JSON #}
|
|
160
|
+
{% if atom.doc.features.json_enabled===true %}
|
|
161
|
+
if (options.json) {
|
|
162
|
+
const {default:json} = await import('@rollup/plugin-json');
|
|
163
|
+
plugins.push(json(options.json.options));
|
|
164
|
+
}
|
|
165
|
+
{% endif %}
|
|
166
|
+
|
|
167
|
+
{# EXTERNAL #}
|
|
168
|
+
plugins.push(external({
|
|
169
|
+
includeDependencies: !options.browser
|
|
170
|
+
}));
|
|
171
|
+
|
|
172
|
+
{# RESOLVE #}
|
|
173
|
+
plugins.push(resolve({
|
|
174
|
+
extensions: extensions,
|
|
175
|
+
browser: options?.browser === true,
|
|
176
|
+
preferBuiltins: true,
|
|
177
|
+
modulePaths: ['./node_modules']
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
{# COMMONJS #}
|
|
181
|
+
plugins.push(commonjs({
|
|
182
|
+
{% if atom.doc.features.project.format ==='esm' %}
|
|
183
|
+
include: /node_modules/,
|
|
184
|
+
ignore: ["fsevents"],
|
|
185
|
+
{% endif %}
|
|
186
|
+
}));
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
{# POLYFILL #}
|
|
190
|
+
{% if atom.doc.features.polyfill_enabled===true %}
|
|
191
|
+
if(options.polyfill){
|
|
192
|
+
const {default:polyfills} = await import('rollup-plugin-node-polyfills');
|
|
193
|
+
plugins.push(polyfills(options.polyfill.options));
|
|
194
|
+
}
|
|
195
|
+
{% endif %}
|
|
196
|
+
|
|
197
|
+
{# WORKBOX #}
|
|
198
|
+
{% if atom.doc.features.workbox_enabled===true %}
|
|
199
|
+
if (options?.workbox) {
|
|
200
|
+
const {generateSW,injectManifest} = await import('rollup-plugin-workbox');
|
|
201
|
+
if(options.workbox.options?.generate) plugins.push(generateSW(options.workbox.options.generate));
|
|
202
|
+
if(options.workbox.options?.inject) plugins.push(injectManifest(options.workbox.options.inject));
|
|
203
|
+
}
|
|
204
|
+
{% endif %}
|
|
205
|
+
|
|
206
|
+
{# BABEL #}
|
|
207
|
+
{% if atom.doc.features.babel_enabled===true %}
|
|
208
|
+
if (options?.babel) {
|
|
209
|
+
const { babel } = await import('@rollup/plugin-babel');
|
|
210
|
+
plugins.push(
|
|
211
|
+
babel({
|
|
212
|
+
babelHelpers: "bundled",
|
|
213
|
+
presets: [
|
|
214
|
+
["@babel/preset-env", {
|
|
215
|
+
targets: options.babel.targets || "defaults",
|
|
216
|
+
}],
|
|
217
|
+
["@babel/preset-react"]
|
|
218
|
+
],
|
|
219
|
+
extensions: extensions,
|
|
220
|
+
exclude: "node_modules/**",
|
|
221
|
+
plugins: options.babel.plugins || [],
|
|
222
|
+
sourceMaps: DEVELOPMENT
|
|
223
|
+
})
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
{% endif %}
|
|
227
|
+
|
|
228
|
+
{# TERSER #}
|
|
229
|
+
{% if atom.doc.features.terser_enabled===true %}
|
|
230
|
+
if (options.terser) {
|
|
231
|
+
const {default:terser} = await import("@rollup/plugin-terser");
|
|
232
|
+
plugins.push(terser(options.terser.options));
|
|
233
|
+
}
|
|
234
|
+
{% endif %}
|
|
235
|
+
|
|
236
|
+
{# GZIP #}
|
|
237
|
+
{% if atom.doc.features.gzip_enabled===true %}
|
|
238
|
+
if (options.gzip) {
|
|
239
|
+
const {default:gzip} = await import('rollup-plugin-gzip');
|
|
240
|
+
if(options.gzip.options) plugins.push(gzip(options.gzip.options));
|
|
241
|
+
}
|
|
242
|
+
{% endif %}
|
|
243
|
+
|
|
244
|
+
{# ANALYZER #}
|
|
245
|
+
{% if atom.doc.features.analyzer_enabled===true %}
|
|
246
|
+
if (options.analyzer) {
|
|
247
|
+
const { default: analyzer } = await import("rollup-plugin-analyzer");
|
|
248
|
+
plugins.push(analyzer(options.analyzer.options));
|
|
249
|
+
}
|
|
250
|
+
{% endif %}
|
|
251
|
+
|
|
252
|
+
{# VISUALIZER #}
|
|
253
|
+
{% if atom.doc.features.visualizer_enabled===true %}
|
|
254
|
+
if (options.visualizer) {
|
|
255
|
+
const { visualizer } = await import("rollup-plugin-visualizer");
|
|
256
|
+
plugins.push(visualizer(options.visualizer.options));
|
|
257
|
+
}
|
|
258
|
+
{% endif %}
|
|
259
|
+
|
|
260
|
+
{# BROWSERSYNC #}
|
|
261
|
+
{% if atom.doc.features.browsersync_enabled===true %}
|
|
262
|
+
if (options.browsersync && DEVELOPMENT) {
|
|
263
|
+
const {default:browsersync} = await import('@fnet/rollup-plugin-browsersync');
|
|
264
|
+
options.browsersync.middleware = function (req, res, next) {
|
|
265
|
+
if (req.method === 'OPTIONS') {
|
|
266
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
267
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
268
|
+
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
|
|
269
|
+
res.setHeader('Access-Control-Allow-Credentials', true);
|
|
270
|
+
res.end();
|
|
271
|
+
} else {
|
|
272
|
+
next();
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
plugins.push(browsersync(options.browsersync));
|
|
276
|
+
}
|
|
277
|
+
{% endif %}
|
|
278
|
+
|
|
279
|
+
return plugins;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const groups = [
|
|
283
|
+
{ name: "default" }
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
const configs = [];
|
|
287
|
+
|
|
288
|
+
const createConfigs = async () => {
|
|
289
|
+
for (const group of groups) {
|
|
290
|
+
let groupDir = path.normalize(`./dist/${group.name}/`);
|
|
291
|
+
if (!fs.existsSync(groupDir)) {
|
|
292
|
+
fs.mkdirSync(groupDir, { recursive: true });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
{% for key, value in atom.doc.features.rollup_output %}
|
|
296
|
+
{% if value and value.enabled !== false %}
|
|
297
|
+
{
|
|
298
|
+
// {{key | upper}}
|
|
299
|
+
const config = {
|
|
300
|
+
input: path.normalize(`{{value.input or 'src/${group.name}/index.js'}}`),
|
|
301
|
+
output: {
|
|
302
|
+
dir: path.normalize(`{{value.output_dir or 'dist/${group.name}/' + key}}`),
|
|
303
|
+
format: "{{value.format}}",
|
|
304
|
+
{% if atom.doc.features.sourcemap === true %}
|
|
305
|
+
sourcemap: true,
|
|
306
|
+
{% endif %}
|
|
307
|
+
{% if value.format === 'cjs' %}
|
|
308
|
+
exports: "{{value.output_exports or 'named'}}",
|
|
309
|
+
interop: "auto",
|
|
310
|
+
entryFileNames: "[name].cjs",
|
|
311
|
+
chunkFileNames: "[name]-[hash].cjs",
|
|
312
|
+
{% endif %}
|
|
313
|
+
{% include 'rollup_config_output_name.njk' %}
|
|
314
|
+
{% include 'rollup_config_output_globals.njk' %}
|
|
315
|
+
{% include 'rollup_config_output_banner.njk' %}
|
|
316
|
+
{% include 'rollup_config_output_footer.njk' %}
|
|
317
|
+
},
|
|
318
|
+
{% if value.context %}
|
|
319
|
+
context: "{{value.context}}",
|
|
320
|
+
{% endif %}
|
|
321
|
+
{% include 'rollup_config_external.njk' %}
|
|
322
|
+
{% include 'rollup_config_onwarn.njk' %}
|
|
323
|
+
{% include 'rollup_config_plugins.njk' %}
|
|
324
|
+
}
|
|
325
|
+
configs.push(config);
|
|
326
|
+
}
|
|
327
|
+
{% endif %}
|
|
328
|
+
{% endfor %}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
{# DTS #}
|
|
332
|
+
{% if atom.doc.features.dts_enabled ===true %}
|
|
333
|
+
const { dts } = await import("rollup-plugin-dts");
|
|
334
|
+
const typesConfig = {
|
|
335
|
+
input: path.normalize('{{atom.typesDir}}/default/index.d.ts'),
|
|
336
|
+
output: {
|
|
337
|
+
file: path.normalize("./dist/default/types/index.d.ts"),
|
|
338
|
+
format: "es"
|
|
339
|
+
},
|
|
340
|
+
plugins: [dts()],
|
|
341
|
+
}
|
|
342
|
+
configs.push(typesConfig);
|
|
343
|
+
{% endif %}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
{% if atom.doc.features.render and atom.doc.features.render.enabled !== false %}
|
|
347
|
+
async function render(){
|
|
348
|
+
const { default:fnetRender } = await import('@flownet/lib-render-templates-dir');
|
|
349
|
+
|
|
350
|
+
const dirs={{atom.doc.features.render.dirs | default([]) | dump | safe}};
|
|
351
|
+
|
|
352
|
+
for (const dir of dirs) {
|
|
353
|
+
await fnetRender(dir);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
{% endif %}
|
|
357
|
+
export default async () => {
|
|
358
|
+
{% if atom.doc.features.render and atom.doc.features.render.enabled !== false %}
|
|
359
|
+
await render();
|
|
360
|
+
{% endif %}
|
|
361
|
+
await createConfigs();
|
|
362
|
+
return configs;
|
|
363
|
+
};
|