MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / run

Function run

modules/code-generator/src/standalone-worker.ts:16–59  ·  view source on GitHub ↗
(msg: { solution: string; schema: IPublicTypeProjectSchema; flattenResult?: boolean })

Source from the content-addressed store, hash-verified

14self.postMessage({ type: 'ready' });
15
16async function run(msg: { solution: string; schema: IPublicTypeProjectSchema; flattenResult?: boolean }) {
17 try {
18 print('begin run...');
19 self.postMessage({ type: 'run:begin' });
20
21 const { solution } = msg;
22 if (!solution) {
23 throw new Error('solution is required');
24 }
25
26 const createAppBuilder = CodeGen.solutions[solution as 'icejs' | 'rax'];
27 if (typeof createAppBuilder !== 'function') {
28 throw new Error(`solution '${solution}' is invalid`);
29 }
30
31 const appBuilder = createAppBuilder();
32
33 print('generating from schema: %o', msg.schema);
34
35 const result = await appBuilder.generateProject(msg.schema);
36
37 print('generated result: %o', result);
38
39 const finalResult = msg.flattenResult
40 ? CodeGen.utils.resultHelper.flattenResult(result)
41 : result;
42
43 if (msg.flattenResult) {
44 print('flatten result: %o', finalResult);
45 }
46
47 self.postMessage({
48 type: 'run:end',
49 result: finalResult,
50 });
51 } catch (e) {
52 printErr(`${e}`);
53 self.postMessage({
54 type: 'run:error',
55 errorMsg: `${(e as Error | null)?.message || e}`,
56 errorDetail: `${e}`,
57 });
58 }
59}
60
61function print(text: string, ...args: any[]) {
62 console.debug(`[code-generator/worker]: ${text}`, ...args);

Callers 1

Calls 3

generateProjectMethod · 0.80
printFunction · 0.70
printErrFunction · 0.70

Tested by

no test coverage detected