@ldsg/cli 0.3.49 → 0.3.51
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/.rush/temp/package-deps_build.json +5 -5
- package/.tsbuildinfo +1 -1
- package/CHANGELOG.json +58 -0
- package/CHANGELOG.md +15 -1
- package/dist/commands/generate/utils/generate-application/index.js +36 -2
- package/dist/commands/generate/utils/generate-application/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js +2 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js.map +1 -1
- package/package.json +6 -6
- package/src/commands/generate/utils/generate-application/index.ts +69 -4
- package/src/commands/generate/utils/generate-application/utils/load-generator-app/index.ts +4 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/cli",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.3.51",
|
|
6
|
+
"tag": "@ldsg/cli_v0.3.51",
|
|
7
|
+
"date": "Thu, 05 Nov 2026 14:38:34 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "发布更新"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@ldsg/generator-app\" to `0.3.51`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.51`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@ldsg/resource\" to `0.3.51`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.51`"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.51`"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"version": "0.3.50",
|
|
35
|
+
"tag": "@ldsg/cli_v0.3.50",
|
|
36
|
+
"date": "Thu, 05 Nov 2026 13:10:58 GMT",
|
|
37
|
+
"comments": {
|
|
38
|
+
"patch": [
|
|
39
|
+
{
|
|
40
|
+
"comment": "发布更新"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"dependency": [
|
|
44
|
+
{
|
|
45
|
+
"comment": "Updating dependency \"@ldsg/generator-app\" to `0.3.50`"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.50`"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"comment": "Updating dependency \"@ldsg/resource\" to `0.3.50`"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.50`"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.50`"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
4
62
|
{
|
|
5
63
|
"version": "0.3.49",
|
|
6
64
|
"tag": "@ldsg/cli_v0.3.49",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @ldsg/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu, 05 Nov 2026
|
|
3
|
+
This log was last generated on Thu, 05 Nov 2026 14:38:34 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.51
|
|
6
|
+
Thu, 05 Nov 2026 14:38:34 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- 发布更新
|
|
11
|
+
|
|
12
|
+
## 0.3.50
|
|
13
|
+
Thu, 05 Nov 2026 13:10:58 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- 发布更新
|
|
4
18
|
|
|
5
19
|
## 0.3.49
|
|
6
20
|
Thu, 05 Nov 2026 00:13:54 GMT
|
|
@@ -20,6 +20,22 @@ const generateApplication = async (params) => {
|
|
|
20
20
|
requiredResourceKinds: generatorRequiredResourceKinds,
|
|
21
21
|
resourceRecords: dataResourceRecords,
|
|
22
22
|
}).requiredResourceRecords;
|
|
23
|
+
const rawRootResourceId = dataResourceRecords.find((resourceRecord) => !resourceRecord.parentId).id;
|
|
24
|
+
generatorRequiredResourceRecords = lodash_1.default.map(generatorRequiredResourceRecords, (resourceRecord) => {
|
|
25
|
+
const { kind } = resourceRecord;
|
|
26
|
+
if (kind === "generator_app") {
|
|
27
|
+
return lodash_1.default.omit(resourceRecord, "parentId");
|
|
28
|
+
}
|
|
29
|
+
return resourceRecord;
|
|
30
|
+
});
|
|
31
|
+
const newRootResourceId = generatorRequiredResourceRecords.find((resourceRecord) => !resourceRecord.parentId).id;
|
|
32
|
+
const oldResourceIdToNewResourceIdMap = {
|
|
33
|
+
[rawRootResourceId]: newRootResourceId,
|
|
34
|
+
};
|
|
35
|
+
generatorRequiredResourceRecords = (0, utils_1.replaceResourceIds)({
|
|
36
|
+
source: generatorRequiredResourceRecords,
|
|
37
|
+
oldResourceIdToNewResourceIdMap,
|
|
38
|
+
}).replacement;
|
|
23
39
|
const generatorResourceRecords = lodash_1.default.filter(generatorRequiredResourceRecords, (resourceRecord) => {
|
|
24
40
|
const { kind } = resourceRecord;
|
|
25
41
|
return kind === "generator";
|
|
@@ -33,15 +49,33 @@ const generateApplication = async (params) => {
|
|
|
33
49
|
{
|
|
34
50
|
const hasMetaGenerator = generatorNames.includes("meta");
|
|
35
51
|
if (hasMetaGenerator) {
|
|
36
|
-
const
|
|
52
|
+
const buildMetaGeneratorAppParams = {
|
|
53
|
+
...params,
|
|
54
|
+
data: {
|
|
55
|
+
...(params.data ?? {}),
|
|
56
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const buildMetaGeneratorAppRes = await (0, utils_2.buildMetaGeneratorApp)(buildMetaGeneratorAppParams);
|
|
37
60
|
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
38
61
|
}
|
|
39
62
|
}
|
|
63
|
+
console.debug("metaGenerator", metaGenerator);
|
|
40
64
|
let appGenerator;
|
|
41
65
|
{
|
|
42
66
|
const hasAppGenerator = generatorNames.includes("app");
|
|
43
67
|
if (hasAppGenerator) {
|
|
44
|
-
const
|
|
68
|
+
const buildAppGeneratorAppParams = {
|
|
69
|
+
...params,
|
|
70
|
+
data: {
|
|
71
|
+
...(params.data ?? {}),
|
|
72
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const buildAppGeneratorAppRes = await (0, utils_2.buildAppGeneratorApp)({
|
|
76
|
+
metaGenerator,
|
|
77
|
+
...buildAppGeneratorAppParams,
|
|
78
|
+
});
|
|
45
79
|
appGenerator = buildAppGeneratorAppRes.appGenerator;
|
|
46
80
|
}
|
|
47
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/generate/utils/generate-application/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/generate/utils/generate-application/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAoG;AACpG,wDAA0B;AAC1B,oDAAuB;AACvB,0DAA6B;AAE7B,mCAMiB;AAaV,MAAM,mBAAmB,GAAwB,KAAK,EAAE,MAAM,EAAE,EAAE;IACvE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAE3C,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,IAAI,CAAC;IAEtD,IAAI,gCAAiD,CAAC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,mBAAW,EAAC,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAKtE,CAAC;QACC,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;QAEnC,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,aAAa,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YAEvD,MAAM,kBAAE,CAAC,UAAU,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,IAAA,0BAAkB,EAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AA5JW,QAAA,mBAAmB,uBA4J9B"}
|
|
@@ -22,7 +22,9 @@ const loadGeneratorApp = async (params) => {
|
|
|
22
22
|
const entryUrl = `${(0, node_url_1.pathToFileURL)(entryPath).href}?t=${Date.now()}`;
|
|
23
23
|
const { instantiateAppResource } = (await importModule(entryUrl));
|
|
24
24
|
const appResource = await instantiateAppResource();
|
|
25
|
+
console.debug("loadGeneratorApp appResource", appResource);
|
|
25
26
|
const { app: generatorApp } = appResource.createGeneratorApp();
|
|
27
|
+
console.debug("loadGeneratorApp generatorApp", generatorApp);
|
|
26
28
|
return generatorApp;
|
|
27
29
|
};
|
|
28
30
|
exports.loadGeneratorApp = loadGeneratorApp;
|
package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/load-generator-app/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA8F;AAE9F,wDAA0B;AAC1B,0DAA6B;AAC7B,uCAAyC;AAiBlC,MAAM,gBAAgB,GAAqB,KAAK,EAAE,MAAM,EAAE,EAAE;IACjE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAKvC,MAAM,kBAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE5B,IAAA,0BAAkB,EAAC;QACjB,OAAO;QACP,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,IAAA,2BAAmB,EAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;IAE/C,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;IAOlD,MAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEpD,CAAC;IAEtB,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAK5D,MAAM,QAAQ,GAAG,GAAG,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAEpE,MAAM,EAAE,sBAAsB,EAAE,GAAG,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,CAE/D,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,EAAE,CAAC;IAEnD,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC,kBAAkB,EAAE,CAAC;IAE/D,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/load-generator-app/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA8F;AAE9F,wDAA0B;AAC1B,0DAA6B;AAC7B,uCAAyC;AAiBlC,MAAM,gBAAgB,GAAqB,KAAK,EAAE,MAAM,EAAE,EAAE;IACjE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAKvC,MAAM,kBAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE5B,IAAA,0BAAkB,EAAC;QACjB,OAAO;QACP,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,IAAA,2BAAmB,EAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;IAE/C,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;IAOlD,MAAM,YAAY,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEpD,CAAC;IAEtB,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAK5D,MAAM,QAAQ,GAAG,GAAG,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAEpE,MAAM,EAAE,sBAAsB,EAAE,GAAG,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,CAE/D,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,EAAE,CAAC;IAEnD,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,WAAW,CAAC,CAAC;IAE3D,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC,kBAAkB,EAAE,CAAC;IAE/D,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,YAAY,CAAC,CAAC;IAE7D,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AA9CW,QAAA,gBAAgB,oBA8C3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.51",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"commander": "^12.0.0",
|
|
18
18
|
"fs-extra": "^11.3.0",
|
|
19
19
|
"js-yaml": "^4.1.0",
|
|
20
|
-
"@ldsg/
|
|
21
|
-
"@ldsg/resource": "0.3.
|
|
22
|
-
"@ldsg/
|
|
23
|
-
"@ldsg/
|
|
20
|
+
"@ldsg/handler": "0.3.51",
|
|
21
|
+
"@ldsg/resource": "0.3.51",
|
|
22
|
+
"@ldsg/utils": "0.3.51",
|
|
23
|
+
"@ldsg/generator-app": "0.3.51"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"tslib": "^2.8.1",
|
|
41
41
|
"typescript": "^5.3.3",
|
|
42
|
-
"@ldsg/types": "0.3.
|
|
42
|
+
"@ldsg/types": "0.3.51"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { extractZipToFolder, filterRequiredResourceRecords } from "@ldsg/utils";
|
|
1
|
+
import { extractZipToFolder, filterRequiredResourceRecords, replaceResourceIds } from "@ldsg/utils";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { GenerateParams, Generator, ResourceRecords } from "@ldsg/types";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
buildAppGeneratorApp,
|
|
8
|
+
BuildAppGeneratorAppParams,
|
|
9
|
+
buildMetaGeneratorApp,
|
|
10
|
+
BuildMetaGeneratorAppParams,
|
|
11
|
+
generateApp,
|
|
12
|
+
} from "./utils";
|
|
7
13
|
|
|
8
14
|
interface GenerateApplicationParams extends GenerateParams {}
|
|
9
15
|
|
|
@@ -36,6 +42,39 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
36
42
|
resourceRecords: dataResourceRecords,
|
|
37
43
|
}).requiredResourceRecords;
|
|
38
44
|
|
|
45
|
+
/**
|
|
46
|
+
* 找出原应用的根资源ID
|
|
47
|
+
*/
|
|
48
|
+
const rawRootResourceId = dataResourceRecords.find(
|
|
49
|
+
(resourceRecord) => !resourceRecord.parentId,
|
|
50
|
+
).id;
|
|
51
|
+
|
|
52
|
+
generatorRequiredResourceRecords = _.map(generatorRequiredResourceRecords, (resourceRecord) => {
|
|
53
|
+
const { kind } = resourceRecord;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 通过移除 parentId 以提升为 generator_app 资源为根资源
|
|
57
|
+
*/
|
|
58
|
+
if (kind === "generator_app") {
|
|
59
|
+
return _.omit(resourceRecord, "parentId");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return resourceRecord;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const newRootResourceId = generatorRequiredResourceRecords.find(
|
|
66
|
+
(resourceRecord) => !resourceRecord.parentId,
|
|
67
|
+
).id;
|
|
68
|
+
|
|
69
|
+
const oldResourceIdToNewResourceIdMap: Record<string, string> = {
|
|
70
|
+
[rawRootResourceId]: newRootResourceId,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
generatorRequiredResourceRecords = replaceResourceIds({
|
|
74
|
+
source: generatorRequiredResourceRecords,
|
|
75
|
+
oldResourceIdToNewResourceIdMap,
|
|
76
|
+
}).replacement;
|
|
77
|
+
|
|
39
78
|
const generatorResourceRecords = _.filter(
|
|
40
79
|
generatorRequiredResourceRecords,
|
|
41
80
|
(resourceRecord) => {
|
|
@@ -67,12 +106,22 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
67
106
|
const hasMetaGenerator = generatorNames.includes("meta");
|
|
68
107
|
|
|
69
108
|
if (hasMetaGenerator) {
|
|
70
|
-
const
|
|
109
|
+
const buildMetaGeneratorAppParams: BuildMetaGeneratorAppParams = {
|
|
110
|
+
...params,
|
|
111
|
+
data: {
|
|
112
|
+
...(params.data ?? {}),
|
|
113
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const buildMetaGeneratorAppRes = await buildMetaGeneratorApp(buildMetaGeneratorAppParams);
|
|
71
118
|
|
|
72
119
|
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
73
120
|
}
|
|
74
121
|
}
|
|
75
122
|
|
|
123
|
+
console.debug("metaGenerator", metaGenerator);
|
|
124
|
+
|
|
76
125
|
let appGenerator: Generator | undefined;
|
|
77
126
|
|
|
78
127
|
/**
|
|
@@ -88,7 +137,23 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
88
137
|
const hasAppGenerator = generatorNames.includes("app");
|
|
89
138
|
|
|
90
139
|
if (hasAppGenerator) {
|
|
91
|
-
|
|
140
|
+
/**
|
|
141
|
+
* 与元生成器一致,仅使用生成器相关资源记录:
|
|
142
|
+
* 应用生成器应用只需要生成器与 handler,若带入全量资源记录,
|
|
143
|
+
* 其会包含 database 等无法在加载阶段初始化的资源(如缺少 uri)
|
|
144
|
+
*/
|
|
145
|
+
const buildAppGeneratorAppParams: BuildAppGeneratorAppParams = {
|
|
146
|
+
...params,
|
|
147
|
+
data: {
|
|
148
|
+
...(params.data ?? {}),
|
|
149
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const buildAppGeneratorAppRes = await buildAppGeneratorApp({
|
|
154
|
+
metaGenerator,
|
|
155
|
+
...buildAppGeneratorAppParams,
|
|
156
|
+
});
|
|
92
157
|
|
|
93
158
|
appGenerator = buildAppGeneratorAppRes.appGenerator;
|
|
94
159
|
}
|
|
@@ -58,7 +58,11 @@ export const loadGeneratorApp: LoadGeneratorApp = async (params) => {
|
|
|
58
58
|
|
|
59
59
|
const appResource = await instantiateAppResource();
|
|
60
60
|
|
|
61
|
+
console.debug("loadGeneratorApp appResource", appResource);
|
|
62
|
+
|
|
61
63
|
const { app: generatorApp } = appResource.createGeneratorApp();
|
|
62
64
|
|
|
65
|
+
console.debug("loadGeneratorApp generatorApp", generatorApp);
|
|
66
|
+
|
|
63
67
|
return generatorApp;
|
|
64
68
|
};
|