@fnet/cli 0.114.0 → 0.115.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/fnet/index.js +1 -1
- package/dist/fnode/{index.mC936qdY.js → index.Brxbka97.js} +1 -1
- package/dist/fnode/{index.Cl6LPgIY.js → index.CoRsFBwp.js} +1 -1
- package/dist/fnode/index.DIZA_GzC.js +1 -0
- package/dist/fnode/{index.CLPC6OJN.js → index.Dg0hAD29.js} +1 -1
- package/dist/fnode/index.js +1 -1
- package/dist/fnode/{index.qJ6fWMSj.js → index.uPDSav7E.js} +1 -1
- package/package.json +1 -1
- package/template/fnet/bun/src/cli/index.js.njk +1 -1
- package/template/fnet/node/rollup.config.mjs.njk +144 -11
- package/template/fnet/node/src/cli/index.js.njk +195 -16
- package/template/fnode/bun/src/cli/index.js.njk +2 -2
- package/template/fnode/node/rollup.config.mjs.njk +144 -11
- package/template/fnode/node/src/cli/index.js.njk +388 -23
- package/dist/fnode/index.BlhtGEKB.js +0 -1
- package/template/fnet/bun/fnet/flows.yaml.njk +0 -1
- package/template/fnet/bun/fnet.yaml.njk +0 -1
- package/template/fnet/node/fnet/flows.yaml.njk +0 -1
- package/template/fnet/node/fnet.yaml.njk +0 -1
- package/template/fnet/node/rollup_config_external.njk +0 -8
- package/template/fnet/node/rollup_config_onwarn.njk +0 -9
- package/template/fnet/node/rollup_config_output_banner.njk +0 -3
- package/template/fnet/node/rollup_config_output_footer.njk +0 -5
- package/template/fnet/node/rollup_config_output_globals.njk +0 -9
- package/template/fnet/node/rollup_config_output_name.njk +0 -3
- package/template/fnet/node/rollup_config_plugins.njk +0 -90
- package/template/fnode/bun/fnode.yaml.njk +0 -1
- package/template/fnode/node/fnode.yaml.njk +0 -1
- package/template/fnode/node/rollup_config_external.njk +0 -8
- package/template/fnode/node/rollup_config_onwarn.njk +0 -9
- package/template/fnode/node/rollup_config_output_banner.njk +0 -3
- package/template/fnode/node/rollup_config_output_footer.njk +0 -5
- package/template/fnode/node/rollup_config_output_globals.njk +0 -9
- package/template/fnode/node/rollup_config_output_name.njk +0 -3
- package/template/fnode/node/rollup_config_plugins.njk +0 -90
- package/template/fnode/python/fnode.yaml.njk +0 -1
- /package/template/fnet/bun/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
- /package/template/fnet/node/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
- /package/template/fnet/project/.vscode/{launch.json → launch.json.njk} +0 -0
- /package/template/fnet/project/.vscode/{tasks.json → tasks.json.njk} +0 -0
- /package/template/fnode/bun/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
- /package/template/fnode/node/src/default/{to.args.js.njk → input.args.js.njk} +0 -0
|
@@ -2,36 +2,212 @@
|
|
|
2
2
|
|
|
3
3
|
{% if atom.doc.features.project.format==='esm' %}
|
|
4
4
|
|
|
5
|
-
import argv from '../default/
|
|
5
|
+
import argv from '../default/input.args.js';
|
|
6
6
|
|
|
7
7
|
{% if atom.doc.features.cli.extend===true %}
|
|
8
8
|
|
|
9
9
|
import Node from '../../../cli';
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
{% endif %}
|
|
15
|
+
|
|
16
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
17
|
+
// Using Node.js built-in http module instead of express
|
|
18
|
+
{% endif %}
|
|
19
|
+
|
|
20
|
+
const run = async () => {
|
|
21
|
+
const args = await argv();
|
|
22
|
+
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
23
|
+
|
|
24
|
+
if (cliMode === 'default') {
|
|
25
|
+
// Default mode code
|
|
26
|
+
return await Node(args);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
30
|
+
if (cliMode === 'mcp') {
|
|
31
|
+
// MCP mode code
|
|
32
|
+
const server = new McpServer({
|
|
33
|
+
name: "{{atom.doc.name}}",
|
|
34
|
+
version: "{{atom.doc.version}}"
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
server.tool(
|
|
38
|
+
"{{atom.doc.name}}",
|
|
39
|
+
async (toolArgs) => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await Node(toolArgs);
|
|
42
|
+
return {
|
|
43
|
+
content: [{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: JSON.stringify(result)
|
|
46
|
+
}]
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
content: [{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: `Error: ${error.message}`
|
|
53
|
+
}],
|
|
54
|
+
isError: true
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const transport = new StdioServerTransport();
|
|
61
|
+
await server.connect(transport);
|
|
62
|
+
console.log("MCP server started with stdio transport");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
{% endif %}
|
|
66
|
+
|
|
67
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
68
|
+
if (cliMode === 'http') {
|
|
69
|
+
// HTTP mode code using built-in http module
|
|
70
|
+
const http = require('http');
|
|
71
|
+
|
|
72
|
+
const server = http.createServer((req, res) => {
|
|
73
|
+
if (req.method === 'POST' && req.url === '/{{atom.doc.name}}') {
|
|
74
|
+
let body = '';
|
|
75
|
+
req.on('data', chunk => {
|
|
76
|
+
body += chunk.toString();
|
|
77
|
+
});
|
|
78
|
+
req.on('end', async () => {
|
|
79
|
+
try {
|
|
80
|
+
const data = JSON.parse(body);
|
|
81
|
+
const result = await Node(data);
|
|
82
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
83
|
+
res.end(JSON.stringify(result));
|
|
84
|
+
} catch (error) {
|
|
85
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
86
|
+
res.end(JSON.stringify({ error: error.message }));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
res.writeHead(404);
|
|
91
|
+
res.end();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const port = args['cli-port'] || args.cli_port || 3000;
|
|
96
|
+
server.listen(port, () => {
|
|
97
|
+
console.log(`HTTP server started on port ${port}`);
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
{% endif %}
|
|
102
|
+
|
|
103
|
+
console.error(`Unknown CLI mode: ${cliMode}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
};
|
|
106
|
+
|
|
11
107
|
run()
|
|
12
|
-
.then(() => {
|
|
108
|
+
.then(() => {
|
|
13
109
|
{# process.exit(0); #}
|
|
14
110
|
})
|
|
15
|
-
.catch((error) => {
|
|
111
|
+
.catch((error) => {
|
|
16
112
|
console.error(error.message);
|
|
17
113
|
process.exit(1);
|
|
18
114
|
});
|
|
19
115
|
|
|
20
116
|
{% else %}
|
|
21
117
|
import Node from '../../../src';
|
|
22
|
-
const run=async ()=>await Node(await argv());
|
|
23
118
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
119
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
120
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
121
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
122
|
+
{% endif %}
|
|
123
|
+
|
|
124
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
125
|
+
import express from 'express';
|
|
126
|
+
{% endif %}
|
|
127
|
+
|
|
128
|
+
const run = async () => {
|
|
129
|
+
const args = await argv();
|
|
130
|
+
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
131
|
+
|
|
132
|
+
if (cliMode === 'default') {
|
|
133
|
+
// Default mode code
|
|
134
|
+
const result = await Node(args);
|
|
135
|
+
|
|
136
|
+
if (typeof result !== 'undefined') {
|
|
137
|
+
const stdout_format = args['stdout-format'] || args.stdout_format || null;
|
|
138
|
+
|
|
139
|
+
if (stdout_format === 'json') console.log(JSON.stringify(result, null, 2));
|
|
31
140
|
else console.log(result);
|
|
32
141
|
}
|
|
33
|
-
|
|
34
|
-
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
146
|
+
if (cliMode === 'mcp') {
|
|
147
|
+
// MCP mode code
|
|
148
|
+
const server = new McpServer({
|
|
149
|
+
name: "{{atom.doc.name}}",
|
|
150
|
+
version: "{{atom.doc.version}}"
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
server.tool(
|
|
154
|
+
"{{atom.doc.name}}",
|
|
155
|
+
async (toolArgs) => {
|
|
156
|
+
try {
|
|
157
|
+
const result = await Node(toolArgs);
|
|
158
|
+
return {
|
|
159
|
+
content: [{
|
|
160
|
+
type: "text",
|
|
161
|
+
text: JSON.stringify(result)
|
|
162
|
+
}]
|
|
163
|
+
};
|
|
164
|
+
} catch (error) {
|
|
165
|
+
return {
|
|
166
|
+
content: [{
|
|
167
|
+
type: "text",
|
|
168
|
+
text: `Error: ${error.message}`
|
|
169
|
+
}],
|
|
170
|
+
isError: true
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const transport = new StdioServerTransport();
|
|
177
|
+
await server.connect(transport);
|
|
178
|
+
console.log("MCP server started with stdio transport");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
{% endif %}
|
|
182
|
+
|
|
183
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
184
|
+
if (cliMode === 'http') {
|
|
185
|
+
// HTTP mode code
|
|
186
|
+
const app = express();
|
|
187
|
+
app.use(express.json());
|
|
188
|
+
|
|
189
|
+
app.post('/{{atom.doc.name}}', async (req, res) => {
|
|
190
|
+
try {
|
|
191
|
+
const result = await Node(req.body);
|
|
192
|
+
res.json(result);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
res.status(500).json({ error: error.message });
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const port = args['cli-port'] || args.cli_port || 3000;
|
|
199
|
+
app.listen(port, () => {
|
|
200
|
+
console.log(`HTTP server started on port ${port}`);
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
{% endif %}
|
|
205
|
+
|
|
206
|
+
console.error(`Unknown CLI mode: ${cliMode}`);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
run()
|
|
35
211
|
.catch((error) => {
|
|
36
212
|
console.error(error.message);
|
|
37
213
|
process.exit(1);
|
|
@@ -40,12 +216,107 @@ run()
|
|
|
40
216
|
|
|
41
217
|
{% elif atom.doc.features.project.format==='cjs' %}
|
|
42
218
|
|
|
43
|
-
const argv = require('../default/
|
|
219
|
+
const argv = require('../default/input.args.js');
|
|
44
220
|
|
|
45
221
|
{% if atom.doc.features.cli.extend===true %}
|
|
46
222
|
|
|
47
223
|
const Node = require('../../../cli');
|
|
48
|
-
|
|
224
|
+
|
|
225
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
226
|
+
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
227
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
228
|
+
{% endif %}
|
|
229
|
+
|
|
230
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
231
|
+
// Using Node.js built-in http module instead of express
|
|
232
|
+
{% endif %}
|
|
233
|
+
|
|
234
|
+
const run = async () => {
|
|
235
|
+
const args = await argv();
|
|
236
|
+
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
237
|
+
|
|
238
|
+
if (cliMode === 'default') {
|
|
239
|
+
// Default mode code
|
|
240
|
+
return await Node(args);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
244
|
+
if (cliMode === 'mcp') {
|
|
245
|
+
// MCP mode code
|
|
246
|
+
const server = new McpServer({
|
|
247
|
+
name: "{{atom.doc.name}}",
|
|
248
|
+
version: "{{atom.doc.version}}"
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
server.tool(
|
|
252
|
+
"{{atom.doc.name}}",
|
|
253
|
+
async (toolArgs) => {
|
|
254
|
+
try {
|
|
255
|
+
const result = await Node(toolArgs);
|
|
256
|
+
return {
|
|
257
|
+
content: [{
|
|
258
|
+
type: "text",
|
|
259
|
+
text: JSON.stringify(result)
|
|
260
|
+
}]
|
|
261
|
+
};
|
|
262
|
+
} catch (error) {
|
|
263
|
+
return {
|
|
264
|
+
content: [{
|
|
265
|
+
type: "text",
|
|
266
|
+
text: `Error: ${error.message}`
|
|
267
|
+
}],
|
|
268
|
+
isError: true
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const transport = new StdioServerTransport();
|
|
275
|
+
await server.connect(transport);
|
|
276
|
+
console.log("MCP server started with stdio transport");
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
{% endif %}
|
|
280
|
+
|
|
281
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
282
|
+
if (cliMode === 'http') {
|
|
283
|
+
// HTTP mode code using built-in http module
|
|
284
|
+
const http = require('http');
|
|
285
|
+
|
|
286
|
+
const server = http.createServer((req, res) => {
|
|
287
|
+
if (req.method === 'POST' && req.url === '/{{atom.doc.name}}') {
|
|
288
|
+
let body = '';
|
|
289
|
+
req.on('data', chunk => {
|
|
290
|
+
body += chunk.toString();
|
|
291
|
+
});
|
|
292
|
+
req.on('end', async () => {
|
|
293
|
+
try {
|
|
294
|
+
const data = JSON.parse(body);
|
|
295
|
+
const result = await Node(data);
|
|
296
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
297
|
+
res.end(JSON.stringify(result));
|
|
298
|
+
} catch (error) {
|
|
299
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
300
|
+
res.end(JSON.stringify({ error: error.message }));
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
res.writeHead(404);
|
|
305
|
+
res.end();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
const port = args['cli-port'] || args.cli_port || 3000;
|
|
310
|
+
server.listen(port, () => {
|
|
311
|
+
console.log(`HTTP server started on port ${port}`);
|
|
312
|
+
});
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
{% endif %}
|
|
316
|
+
|
|
317
|
+
console.error(`Unknown CLI mode: ${cliMode}`);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
};
|
|
49
320
|
|
|
50
321
|
run()
|
|
51
322
|
.then(() => {
|
|
@@ -58,18 +329,112 @@ run()
|
|
|
58
329
|
|
|
59
330
|
{% else %}
|
|
60
331
|
const Node = require('../../../src');
|
|
61
|
-
const run = async () => await Node(await argv());
|
|
62
332
|
|
|
63
|
-
|
|
64
|
-
|
|
333
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
334
|
+
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
335
|
+
const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
336
|
+
{% endif %}
|
|
337
|
+
|
|
338
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
339
|
+
// Using Node.js built-in http module instead of express
|
|
340
|
+
{% endif %}
|
|
341
|
+
|
|
342
|
+
const run = async () => {
|
|
343
|
+
const args = await argv();
|
|
344
|
+
const cliMode = args['cli-mode'] || args.cli_mode || 'default';
|
|
345
|
+
|
|
346
|
+
if (cliMode === 'default') {
|
|
347
|
+
// Default mode code
|
|
348
|
+
const result = await Node(args);
|
|
349
|
+
|
|
65
350
|
if (typeof result !== 'undefined') {
|
|
66
|
-
|
|
67
|
-
|
|
351
|
+
const stdout_format = args['stdout-format'] || args.stdout_format || null;
|
|
352
|
+
|
|
68
353
|
if (stdout_format === 'json') console.log(JSON.stringify(result, null, 2));
|
|
69
354
|
else console.log(result);
|
|
70
355
|
}
|
|
71
|
-
|
|
72
|
-
}
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
{% if atom.doc.features.cli.mcp.enabled===true %}
|
|
360
|
+
if (cliMode === 'mcp') {
|
|
361
|
+
// MCP mode code
|
|
362
|
+
const server = new McpServer({
|
|
363
|
+
name: "{{atom.doc.name}}",
|
|
364
|
+
version: "{{atom.doc.version}}"
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
server.tool(
|
|
368
|
+
"{{atom.doc.name}}",
|
|
369
|
+
async (toolArgs) => {
|
|
370
|
+
try {
|
|
371
|
+
const result = await Node(toolArgs);
|
|
372
|
+
return {
|
|
373
|
+
content: [{
|
|
374
|
+
type: "text",
|
|
375
|
+
text: JSON.stringify(result)
|
|
376
|
+
}]
|
|
377
|
+
};
|
|
378
|
+
} catch (error) {
|
|
379
|
+
return {
|
|
380
|
+
content: [{
|
|
381
|
+
type: "text",
|
|
382
|
+
text: `Error: ${error.message}`
|
|
383
|
+
}],
|
|
384
|
+
isError: true
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
const transport = new StdioServerTransport();
|
|
391
|
+
await server.connect(transport);
|
|
392
|
+
console.log("MCP server started with stdio transport");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
{% endif %}
|
|
396
|
+
|
|
397
|
+
{% if atom.doc.features.cli.http.enabled===true %}
|
|
398
|
+
if (cliMode === 'http') {
|
|
399
|
+
// HTTP mode code using built-in http module
|
|
400
|
+
const http = require('http');
|
|
401
|
+
|
|
402
|
+
const server = http.createServer((req, res) => {
|
|
403
|
+
if (req.method === 'POST' && req.url === '/{{atom.doc.name}}') {
|
|
404
|
+
let body = '';
|
|
405
|
+
req.on('data', chunk => {
|
|
406
|
+
body += chunk.toString();
|
|
407
|
+
});
|
|
408
|
+
req.on('end', async () => {
|
|
409
|
+
try {
|
|
410
|
+
const data = JSON.parse(body);
|
|
411
|
+
const result = await Node(data);
|
|
412
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
413
|
+
res.end(JSON.stringify(result));
|
|
414
|
+
} catch (error) {
|
|
415
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
416
|
+
res.end(JSON.stringify({ error: error.message }));
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
} else {
|
|
420
|
+
res.writeHead(404);
|
|
421
|
+
res.end();
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
const port = args['cli-port'] || args.cli_port || 3000;
|
|
426
|
+
server.listen(port, () => {
|
|
427
|
+
console.log(`HTTP server started on port ${port}`);
|
|
428
|
+
});
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
{% endif %}
|
|
432
|
+
|
|
433
|
+
console.error(`Unknown CLI mode: ${cliMode}`);
|
|
434
|
+
process.exit(1);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
run()
|
|
73
438
|
.catch((error) => {
|
|
74
439
|
console.error(error.message);
|
|
75
440
|
process.exit(1);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import{randomUUID as i}from"node:crypto";import o from"yaml";import s from"nunjucks";import r from"chalk";import{Api as a,Atom as n}from"@flownet/lib-atom-api-js";import c from"@fnet/config";import d from"@fnet/list-files";import l from"redis";import p from"@flownet/lib-is-redis-online";import m from"@fnet/yaml";class g{init({config:e,accessToken:t}){return new Promise(((i,o)=>{if(a.set_api_url(e.data.url),t)return a.set_req_token(t),void i(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=>{a.set_req_token(e.access_token),i(e.access_token)})).catch((e=>{a.set_req_token(),o(e)}))}))}}var h=async e=>{const{atom:t,packageDependencies:i,context:o,deploymentProjectTarget:s,setProgress:r,deploymentProject:a,yamlTarget:n}=e;if(!0!==s.enabled)return;const c=s.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.xPP3GBoc.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:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("webos"===c)await(await import("./index.CMC8mlye.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("electron"===c)await(await import("./index.xd8c7XMr.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("docker"===c)await(await import("./index.D2N9YZmA.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("ios"===c)await(await import("./index.B5XE4ChJ.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("macos"===c)await(await import("./index.W6RYgypK.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0;else if("rust"===c)await(await import("./index.CzAV0S36.js")).default({atom:t,target:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.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:s,onProgress:r,projectDir:o.projectDir,dependencies:i,context:o,yamlTarget:n}),a.isDirty=!0}}catch(e){throw console.error(`Error during deployment for type "${c}":`,e),e}};class f{#e;#t;#i;#o;#s;#r;#a;#n;#c;#d;#l;#p;#m;#g;#h;#f;#y;constructor(e){this.#e=new g,this.#t=e,this.#r=[],this.#a=[],this._expire_ttl=3600,this._expire_ttl_short=300,this.#y={packageDependencies:this.#r,packageDevDependencies:this.#a,setProgress:this.setProgress.bind(this),context:this.#t,Atom:n,registerToPackageManager:this.registerToPackageManager.bind(this)}}get apiContext(){return this.#y}get context(){return this.#t}get atom(){return this.#i}get libs(){return this.#s}set libs(e){this.#s=e}get fileMode(){return this.#g}get buildMode(){return this.#h}get deployMode(){return this.#f}async _cache_set(e,t,i){this._redis_client&&await this._redis_client.SETEX(e,i||this._expire_ttl,JSON.stringify(t)).catch(console.error)}async initAuth(){this.#t.id&&(this.#n=await this.#e.init({config:this.#p}),this.#y.atomAccessToken=this.#n)}async initLibrary(){const e=this.#t.id;this.#i=this.#t.project?.libraryAtom||await n.get({id:e});let t=this.#i.doc.bundleName;t=t||(this.#i.doc.name||"").toUpperCase().replace(/[^A-Z0-9]/g,"_"),this.#i.doc.bundleName=t,this.#i.type=this.#i.type||"workflow.lib",this.#y.atom=this.#i}async initLibraryDir(){this.setProgress({message:"Initializing library directory."});const i=this.#t.projectDir;this.setProgress({message:"Cleaning project directory."});const o=d({dir:i,ignore:[".cache","node_modules",".conda",".bin"],absolute:!0});for(const t of o)e.rmSync(t,{recursive:!0,force:!0});this.setProgress({message:"Creating project directory."});let s=i;e.existsSync(s)||e.mkdirSync(s,{recursive:!0}),s=t.join(i,"src"),e.existsSync(s)||e.mkdirSync(s,{recursive:!0}),s=t.join(i,"src","default"),e.existsSync(s)||e.mkdirSync(s,{recursive:!0})}async initNunjucks(){this.setProgress({message:"Initializing nunjucks."});const e=this.#t.templateDir;this.#o=s.configure(e,{watch:!1,dev:!0}),this.#y.njEnv=this.#o}async createProjectYaml(){const i="fnode.yaml",r=`Creating ${i}`;await this.setProgress({message:r});const{content:a,...n}=this.#i.doc,c={content:o.stringify(n)},d=this.#t.templateDir,l=t.resolve(d,`${i}.njk`);if(!e.existsSync(l))throw new Error(`fnode.yaml.njk template not found in ${d}`);const p=s.compile(e.readFileSync(l,"utf8"),this.#o).render(c),m=this.#t.projectDir,g=t.resolve(m,`${i}`);e.writeFileSync(g,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 i=e[t];await this.deployProject({deploymentProject:i}),!0===i.isDirty&&await i.save()}}else if(this.#i.id){const e=await n.list({type:"library.deploy",parent_id:this.#i.id});for(let t=0;t<e.length;t++){let i=e[t];await this.deployProject({deploymentProject:i}),!0===i.isDirty&&(i=await n.update(i,{id:i.id}))}}}async deployProject(e){const{deploymentProject:t}=e,{yamlDocument:i}=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||{}),s=i||{};for(let e=0;e<o.length;e++){const i=t.doc[o[e]];i.name=o[e];const r=s.get(o[e]);await h({...this.#y,deploymentProject:t,deploymentProjectTarget:i,yamlTarget:r})}}async registerToPackageManager(e){const{target:t,packageJSON:i}=e;if(!this.#t.id)return;let o=await n.first({name:t.params.name,parent_id:this.#p.env.ATOM_PACKAGES_ID});o?(o.doc.versions.splice(0,0,{v:i.version}),await n.update(o,{id:o.id})):o=await n.create({parent_id:this.#p.env.ATOM_PACKAGES_ID,doc:{name:t.params.name,type:"pm",versions:[{v:i.version}]}})}async setProgress(e){const t="string"==typeof e?e:e?.message;console.log(r.blue(t)),await this._cache_set(this.#d,{status:"IN_PROGRESS",message:t})}async init(){this._redis_client=await async function(){if(!await p({host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}))return;const e=l.createClient({socket:{host:process.env.REDIS_HOST,port:process.env.REDIS_PORT}});return await e.connect(),e}(),this.#c=this.#t.buildId||i(),this.#y.buildId=this.#c,this.#m=this.#t.mode,this.#g=["all","deploy","build","file"].includes(this.#m),this.#h=["all","deploy","build"].includes(this.#m),this.#f=["all","deploy"].includes(this.#m),this.#l=this.#t.protocol,this.#d="BUILD:"+this.#c,this.#p=(await c({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(),await this.initRuntime()}catch(e){throw await this._cache_set(this.#d,{status:"FAILED",message:e?.message||e}),e}}async initRuntime(){throw new Error("initRuntime method must be implemented by runtime-specific builder")}async build(){throw new Error("build method must be implemented by runtime-specific builder")}}async function y({atom:i,setProgress:o,context:r,packageDependencies:a}){await o({message:"Creating .gitignore"});const n={atom:i,packageDependencies:a},c=r.templateDir,d=s.compile(e.readFileSync(t.resolve(c,".gitignore.njk"),"utf8"),s.configure(c)).render(n),l=r.projectDir,p=t.resolve(l,".gitignore");e.writeFileSync(p,d,"utf8")}async function u({atom:i,context:o,setProgress:r,Atom:a}){const n="readme.md",c=`Creating ${n}`;if(await r({message:c}),o.project?.readme){const i=o.projectDir,r={content:o.project.readme.doc.content},a=t.resolve(o.project.projectDir,"fnet/how-to.md");if(e.existsSync(a)){const t=e.readFileSync(a,"utf8");r.howto=t}const c=t.resolve(o.project.projectDir,"fnet/input.yaml");if(e.existsSync(c)){const e=await m({file:c,tags:o.tags});r.input=e.content}const d=t.resolve(o.project.projectDir,"fnet/output.yaml");if(e.existsSync(d)){const e=await m({file:d,tags:o.tags});r.output=e.content}const l=o.templateDir,p=s.compile(e.readFileSync(t.resolve(l,`${n}.njk`),"utf8"),s.configure(l)).render(r),g=t.resolve(i,`${n}`);e.writeFileSync(g,p,"utf8")}else if(i.id){const r=await a.first({type:"wiki",parent_id:i.id});if(!r||"markdown"!==r.doc?.["content-type"])return;const{content:c,...d}=r.doc,l={content:c},p=o.templateDir,m=s.compile(e.readFileSync(t.resolve(p,`${n}.njk`),"utf8"),s.configure(p)).render(l),g=o.projectDir,h=t.resolve(g,`${n}`);e.writeFileSync(h,m,"utf8")}}export{f as B,y as a,u as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
plugins: await initPlugins({
|
|
2
|
-
delete:{ targets: [path.normalize(groupDir + '{{key}}')], runOnce: DEVELOPMENT },
|
|
3
|
-
|
|
4
|
-
format:"{{ value.format }}",
|
|
5
|
-
|
|
6
|
-
{% if value.babel===true %}
|
|
7
|
-
babel:{{value.babel_options | dump | safe}},
|
|
8
|
-
{% endif %}
|
|
9
|
-
|
|
10
|
-
{% if value.replace ===true %}
|
|
11
|
-
replace:{{value.replace_options | dump | safe}},
|
|
12
|
-
{% endif %}
|
|
13
|
-
|
|
14
|
-
{% if value.browser===true %}
|
|
15
|
-
browser:true,
|
|
16
|
-
{% endif %}
|
|
17
|
-
|
|
18
|
-
{% if value.browsersync===true and atom.doc.features.browsersync_enabled===true%}
|
|
19
|
-
browsersync: {{value.browsersync_options | dump | safe}},
|
|
20
|
-
{% endif %}
|
|
21
|
-
|
|
22
|
-
{% if value.alias_enabled===true %}
|
|
23
|
-
alias:{{value.alias | dump | safe}},
|
|
24
|
-
{% endif %}
|
|
25
|
-
|
|
26
|
-
{# OK #}
|
|
27
|
-
{% if value.css %}
|
|
28
|
-
postcss:{{value.css | dump | safe}},
|
|
29
|
-
{% endif %}
|
|
30
|
-
|
|
31
|
-
{# OK #}
|
|
32
|
-
{% if value.copy %}
|
|
33
|
-
copy:{{value.copy | dump | safe}},
|
|
34
|
-
{% endif %}
|
|
35
|
-
|
|
36
|
-
{# OK #}
|
|
37
|
-
{% if value.terser%}
|
|
38
|
-
terser:{{value.terser | dump | safe}},
|
|
39
|
-
{% endif %}
|
|
40
|
-
|
|
41
|
-
{# OK #}
|
|
42
|
-
{% if value.json %}
|
|
43
|
-
json:{{value.json | dump | safe}},
|
|
44
|
-
{% endif %}
|
|
45
|
-
|
|
46
|
-
{# OK #}
|
|
47
|
-
{% if value.wasm %}
|
|
48
|
-
wasm: {{value.wasm | dump | safe}},
|
|
49
|
-
{% endif %}
|
|
50
|
-
|
|
51
|
-
{# OK #}
|
|
52
|
-
{% if value.string %}
|
|
53
|
-
string:{{value.string | dump | safe}},
|
|
54
|
-
{% endif %}
|
|
55
|
-
|
|
56
|
-
{# OK #}
|
|
57
|
-
{% if value.image %}
|
|
58
|
-
image:{{value.image | dump | safe}},
|
|
59
|
-
{% endif %}
|
|
60
|
-
|
|
61
|
-
{# OK #}
|
|
62
|
-
{% if value.analyzer %}
|
|
63
|
-
analyzer:{{value.analyzer | dump | safe}},
|
|
64
|
-
{% endif %}
|
|
65
|
-
|
|
66
|
-
{# OK #}
|
|
67
|
-
{% if value.visualizer %}
|
|
68
|
-
visualizer:{{value.visualizer | dump | safe}},
|
|
69
|
-
{% endif %}
|
|
70
|
-
|
|
71
|
-
{# OK #}
|
|
72
|
-
{% if value.polyfill %}
|
|
73
|
-
polyfill:{{value.polyfill | dump | safe}},
|
|
74
|
-
{% endif %}
|
|
75
|
-
|
|
76
|
-
{# OK #}
|
|
77
|
-
{% if value.nunjucks %}
|
|
78
|
-
nunjucks:{{value.nunjucks | dump | safe}},
|
|
79
|
-
{% endif %}
|
|
80
|
-
|
|
81
|
-
{# OK #}
|
|
82
|
-
{% if value.workbox %}
|
|
83
|
-
workbox:{{value.workbox | dump | safe}},
|
|
84
|
-
{% endif %}
|
|
85
|
-
|
|
86
|
-
{# OK #}
|
|
87
|
-
{% if value.gzip %}
|
|
88
|
-
gzip:{{value.gzip | dump | safe}},
|
|
89
|
-
{% endif %}
|
|
90
|
-
}),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{content | safe}}
|