@ldsg/cli 0.3.48 → 0.3.50
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 +7 -7
- package/.tsbuildinfo +1 -1
- package/CHANGELOG.json +58 -0
- package/CHANGELOG.md +15 -1
- package/dist/commands/generate/utils/generate-application/index.js +29 -3
- package/dist/commands/generate/utils/generate-application/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.d.ts +1 -1
- package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.js +7 -1
- package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/generate-app/index.d.ts +2 -4
- package/dist/commands/generate/utils/generate-application/utils/generate-app/index.js +6 -1
- package/dist/commands/generate/utils/generate-application/utils/generate-app/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 +57 -5
- package/src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts +17 -6
- package/src/commands/generate/utils/generate-application/utils/generate-app/index.ts +9 -5
- 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.50",
|
|
6
|
+
"tag": "@ldsg/cli_v0.3.50",
|
|
7
|
+
"date": "Thu, 05 Nov 2026 13:10:58 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "发布更新"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@ldsg/generator-app\" to `0.3.50`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.50`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@ldsg/resource\" to `0.3.50`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.50`"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.50`"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"version": "0.3.49",
|
|
35
|
+
"tag": "@ldsg/cli_v0.3.49",
|
|
36
|
+
"date": "Thu, 05 Nov 2026 00:13:54 GMT",
|
|
37
|
+
"comments": {
|
|
38
|
+
"patch": [
|
|
39
|
+
{
|
|
40
|
+
"comment": "发布更新"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"dependency": [
|
|
44
|
+
{
|
|
45
|
+
"comment": "Updating dependency \"@ldsg/generator-app\" to `0.3.49`"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.49`"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"comment": "Updating dependency \"@ldsg/resource\" to `0.3.49`"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.49`"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.49`"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
4
62
|
{
|
|
5
63
|
"version": "0.3.48",
|
|
6
64
|
"tag": "@ldsg/cli_v0.3.48",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @ldsg/cli
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 05 Nov 2026 13:10:58 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.50
|
|
6
|
+
Thu, 05 Nov 2026 13:10:58 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- 发布更新
|
|
11
|
+
|
|
12
|
+
## 0.3.49
|
|
13
|
+
Thu, 05 Nov 2026 00:13:54 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- 发布更新
|
|
4
18
|
|
|
5
19
|
## 0.3.48
|
|
6
20
|
Wed, 04 Nov 2026 15:43:23 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";
|
|
@@ -29,15 +45,25 @@ const generateApplication = async (params) => {
|
|
|
29
45
|
return lodash_1.default.snakeCase(slug);
|
|
30
46
|
});
|
|
31
47
|
}
|
|
32
|
-
|
|
48
|
+
console.debug("generatorNames", generatorNames);
|
|
49
|
+
await fs_extra_1.default.writeJSON("a.json", generatorRequiredResourceRecords);
|
|
50
|
+
let metaGenerator;
|
|
33
51
|
{
|
|
34
52
|
const hasMetaGenerator = generatorNames.includes("meta");
|
|
35
53
|
if (hasMetaGenerator) {
|
|
36
|
-
const
|
|
54
|
+
const buildMetaGeneratorAppParams = {
|
|
55
|
+
...params,
|
|
56
|
+
data: {
|
|
57
|
+
...(params.data ?? {}),
|
|
58
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const buildMetaGeneratorAppRes = await (0, utils_2.buildMetaGeneratorApp)(buildMetaGeneratorAppParams);
|
|
37
62
|
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
38
63
|
}
|
|
39
64
|
}
|
|
40
|
-
|
|
65
|
+
console.debug("metaGenerator", metaGenerator);
|
|
66
|
+
let appGenerator;
|
|
41
67
|
{
|
|
42
68
|
const hasAppGenerator = generatorNames.includes("app");
|
|
43
69
|
if (hasAppGenerator) {
|
|
@@ -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,mCAKiB;AAaV,MAAM,mBAAmB,G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AoB,EAAC,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;YAEzF,YAAY,GAAG,uBAAuB,CAAC,YAAY,CAAC;QACtD,CAAC;IACH,CAAC;IAKD,MAAM,cAAc,GAAG,MAAM,IAAA,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;AAhJW,QAAA,mBAAmB,uBAgJ9B"}
|
package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.js
CHANGED
|
@@ -9,7 +9,13 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
9
9
|
const load_generator_app_1 = require("../load-generator-app");
|
|
10
10
|
const buildAppGeneratorApp = async (params) => {
|
|
11
11
|
const { metaGenerator, ...restParams } = params;
|
|
12
|
-
|
|
12
|
+
let generateRes;
|
|
13
|
+
if (metaGenerator) {
|
|
14
|
+
generateRes = await metaGenerator.generate({ ...restParams });
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
}
|
|
18
|
+
const { archive } = generateRes;
|
|
13
19
|
const generatorApp = await (0, load_generator_app_1.loadGeneratorApp)({
|
|
14
20
|
archive,
|
|
15
21
|
outputPath: node_path_1.default.join(node_os_1.default.homedir(), ".ldsg", "app-generator"),
|
package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts"],"names":[],"mappings":";;;;;;AACA,sDAAyB;AACzB,0DAA6B;AAC7B,8DAAyD;AAclD,MAAM,oBAAoB,GAAyB,KAAK,EAAE,MAAM,EAAE,EAAE;IACzE,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts"],"names":[],"mappings":";;;;;;AACA,sDAAyB;AACzB,0DAA6B;AAC7B,8DAAyD;AAclD,MAAM,oBAAoB,GAAyB,KAAK,EAAE,MAAM,EAAE,EAAE;IACzE,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAEhD,IAAI,WAAwB,CAAC;IAE7B,IAAI,aAAa,EAAE,CAAC;QAIlB,WAAW,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IAChE,CAAC;SAAM,CAAC;IAKR,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;IAEhC,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAgB,EAAC;QAC1C,OAAO;QACP,UAAU,EAAE,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC;KAC9D,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,GAAG,GAA4B;QACnC,YAAY;KACb,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA/BW,QAAA,oBAAoB,wBA+B/B"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { GenerateParams, GenerateRes, Generator } from "@ldsg/types";
|
|
2
2
|
export interface GenerateAppParams extends GenerateParams {
|
|
3
|
-
appGenerator
|
|
3
|
+
appGenerator?: Generator;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
}
|
|
7
|
-
export type GenerateApp = (params: GenerateAppParams) => Promise<GenerateAppRes>;
|
|
5
|
+
export type GenerateApp = (params: GenerateAppParams) => Promise<GenerateRes>;
|
|
8
6
|
export declare const generateApp: GenerateApp;
|
|
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateApp = void 0;
|
|
4
4
|
const generateApp = async (params) => {
|
|
5
5
|
const { appGenerator, ...restParams } = params;
|
|
6
|
-
|
|
6
|
+
let res;
|
|
7
|
+
if (appGenerator) {
|
|
8
|
+
res = await appGenerator.generate({ ...restParams });
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
}
|
|
7
12
|
return res;
|
|
8
13
|
};
|
|
9
14
|
exports.generateApp = generateApp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/generate-app/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/generate-app/index.ts"],"names":[],"mappings":";;;AAQO,MAAM,WAAW,GAAgB,KAAK,EAAE,MAAM,EAAE,EAAE;IACvD,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAE/C,IAAI,GAAgB,CAAC;IAErB,IAAI,YAAY,EAAE,CAAC;QACjB,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;IAER,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAZW,QAAA,WAAW,eAYtB"}
|
|
@@ -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.50",
|
|
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/generator-app": "0.3.
|
|
21
|
-
"@ldsg/
|
|
22
|
-
"@ldsg/
|
|
23
|
-
"@ldsg/
|
|
20
|
+
"@ldsg/generator-app": "0.3.50",
|
|
21
|
+
"@ldsg/resource": "0.3.50",
|
|
22
|
+
"@ldsg/utils": "0.3.50",
|
|
23
|
+
"@ldsg/handler": "0.3.50"
|
|
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.50"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -1,9 +1,14 @@
|
|
|
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
|
+
buildMetaGeneratorApp,
|
|
9
|
+
BuildMetaGeneratorAppParams,
|
|
10
|
+
generateApp,
|
|
11
|
+
} from "./utils";
|
|
7
12
|
|
|
8
13
|
interface GenerateApplicationParams extends GenerateParams {}
|
|
9
14
|
|
|
@@ -36,6 +41,39 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
36
41
|
resourceRecords: dataResourceRecords,
|
|
37
42
|
}).requiredResourceRecords;
|
|
38
43
|
|
|
44
|
+
/**
|
|
45
|
+
* 找出原应用的根资源ID
|
|
46
|
+
*/
|
|
47
|
+
const rawRootResourceId = dataResourceRecords.find(
|
|
48
|
+
(resourceRecord) => !resourceRecord.parentId,
|
|
49
|
+
).id;
|
|
50
|
+
|
|
51
|
+
generatorRequiredResourceRecords = _.map(generatorRequiredResourceRecords, (resourceRecord) => {
|
|
52
|
+
const { kind } = resourceRecord;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 通过移除 parentId 以提升为 generator_app 资源为根资源
|
|
56
|
+
*/
|
|
57
|
+
if (kind === "generator_app") {
|
|
58
|
+
return _.omit(resourceRecord, "parentId");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return resourceRecord;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const newRootResourceId = generatorRequiredResourceRecords.find(
|
|
65
|
+
(resourceRecord) => !resourceRecord.parentId,
|
|
66
|
+
).id;
|
|
67
|
+
|
|
68
|
+
const oldResourceIdToNewResourceIdMap: Record<string, string> = {
|
|
69
|
+
[rawRootResourceId]: newRootResourceId,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
generatorRequiredResourceRecords = replaceResourceIds({
|
|
73
|
+
source: generatorRequiredResourceRecords,
|
|
74
|
+
oldResourceIdToNewResourceIdMap,
|
|
75
|
+
}).replacement;
|
|
76
|
+
|
|
39
77
|
const generatorResourceRecords = _.filter(
|
|
40
78
|
generatorRequiredResourceRecords,
|
|
41
79
|
(resourceRecord) => {
|
|
@@ -52,7 +90,11 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
52
90
|
});
|
|
53
91
|
}
|
|
54
92
|
|
|
55
|
-
|
|
93
|
+
console.debug("generatorNames", generatorNames);
|
|
94
|
+
|
|
95
|
+
await fs.writeJSON("a.json", generatorRequiredResourceRecords);
|
|
96
|
+
|
|
97
|
+
let metaGenerator: Generator | undefined;
|
|
56
98
|
|
|
57
99
|
/**
|
|
58
100
|
* 1. 基于资源记录,使用此应用(@ldsg/cli)内置能力构建(含生成、依赖安装、构建)元生成器(Meta Generator):
|
|
@@ -67,13 +109,23 @@ export const generateApplication: GenerateApplication = async (params) => {
|
|
|
67
109
|
const hasMetaGenerator = generatorNames.includes("meta");
|
|
68
110
|
|
|
69
111
|
if (hasMetaGenerator) {
|
|
70
|
-
const
|
|
112
|
+
const buildMetaGeneratorAppParams: BuildMetaGeneratorAppParams = {
|
|
113
|
+
...params,
|
|
114
|
+
data: {
|
|
115
|
+
...(params.data ?? {}),
|
|
116
|
+
resourceRecords: generatorRequiredResourceRecords,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const buildMetaGeneratorAppRes = await buildMetaGeneratorApp(buildMetaGeneratorAppParams);
|
|
71
121
|
|
|
72
122
|
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
73
123
|
}
|
|
74
124
|
}
|
|
75
125
|
|
|
76
|
-
|
|
126
|
+
console.debug("metaGenerator", metaGenerator);
|
|
127
|
+
|
|
128
|
+
let appGenerator: Generator | undefined;
|
|
77
129
|
|
|
78
130
|
/**
|
|
79
131
|
* 2. 基于资源记录,使用元生成器(Meta Generator)能力构建(含生成、依赖安装、构建)应用生成器(App Generator);
|
package/src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GenerateParams, Generator } from "@ldsg/types";
|
|
1
|
+
import { GenerateParams, GenerateRes, Generator } from "@ldsg/types";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { loadGeneratorApp } from "../load-generator-app";
|
|
5
5
|
|
|
6
6
|
export interface BuildAppGeneratorAppParams extends GenerateParams {
|
|
7
|
-
metaGenerator
|
|
7
|
+
metaGenerator?: Generator;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface BuildAppGeneratorAppRes {
|
|
@@ -18,10 +18,21 @@ export type BuildAppGeneratorApp = (
|
|
|
18
18
|
export const buildAppGeneratorApp: BuildAppGeneratorApp = async (params) => {
|
|
19
19
|
const { metaGenerator, ...restParams } = params;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
let generateRes: GenerateRes;
|
|
22
|
+
|
|
23
|
+
if (metaGenerator) {
|
|
24
|
+
/**
|
|
25
|
+
* 使用元生成器生成应用生成器应用
|
|
26
|
+
*/
|
|
27
|
+
generateRes = await metaGenerator.generate({ ...restParams });
|
|
28
|
+
} else {
|
|
29
|
+
/**
|
|
30
|
+
* 使用内置通用生成器生成
|
|
31
|
+
*/
|
|
32
|
+
// generateRes = await generate({ ...restParams });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { archive } = generateRes;
|
|
25
36
|
|
|
26
37
|
const generatorApp = await loadGeneratorApp({
|
|
27
38
|
archive,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { GenerateParams, GenerateRes, Generator } from "@ldsg/types";
|
|
2
2
|
|
|
3
3
|
export interface GenerateAppParams extends GenerateParams {
|
|
4
|
-
appGenerator
|
|
4
|
+
appGenerator?: Generator;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export type GenerateApp = (params: GenerateAppParams) => Promise<GenerateAppRes>;
|
|
7
|
+
export type GenerateApp = (params: GenerateAppParams) => Promise<GenerateRes>;
|
|
10
8
|
|
|
11
9
|
export const generateApp: GenerateApp = async (params) => {
|
|
12
10
|
const { appGenerator, ...restParams } = params;
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
let res: GenerateRes;
|
|
13
|
+
|
|
14
|
+
if (appGenerator) {
|
|
15
|
+
res = await appGenerator.generate({ ...restParams });
|
|
16
|
+
} else {
|
|
17
|
+
// res = await generate({ ...restParams });
|
|
18
|
+
}
|
|
15
19
|
|
|
16
20
|
return res;
|
|
17
21
|
};
|
|
@@ -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
|
};
|