@ldsg/cli 0.3.46 → 0.3.48
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 +11 -9
- package/.rush/temp/shrinkwrap-deps.json +1 -2
- package/.tsbuildinfo +1 -1
- package/CHANGELOG.json +52 -0
- package/CHANGELOG.md +15 -1
- package/dist/commands/generate/utils/generate-application/index.js +36 -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.js +7 -14
- 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/build-meta-generator-app/index.js +8 -24
- package/dist/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/generate-app/index.js +1 -1
- package/dist/commands/generate/utils/generate-application/utils/generate-app/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/index.d.ts +1 -0
- package/dist/commands/generate/utils/generate-application/utils/index.js +1 -0
- package/dist/commands/generate/utils/generate-application/utils/index.js.map +1 -1
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.d.ts +7 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js +29 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js.map +1 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/types.d.ts +2 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/types.js +3 -0
- package/dist/commands/generate/utils/generate-application/utils/load-generator-app/types.js.map +1 -0
- package/package.json +6 -4
- package/src/commands/generate/utils/generate-application/index.ts +73 -7
- package/src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts +11 -19
- package/src/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.ts +9 -66
- package/src/commands/generate/utils/generate-application/utils/generate-app/index.ts +1 -1
- package/src/commands/generate/utils/generate-application/utils/index.ts +1 -0
- package/src/commands/generate/utils/generate-application/utils/load-generator-app/index.ts +64 -0
- package/src/commands/generate/utils/generate-application/utils/load-generator-app/types.ts +3 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/cli",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.3.48",
|
|
6
|
+
"tag": "@ldsg/cli_v0.3.48",
|
|
7
|
+
"date": "Wed, 04 Nov 2026 15:43:23 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "发布更新"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@ldsg/generator-app\" to `0.3.48`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.48`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"comment": "Updating dependency \"@ldsg/resource\" to `0.3.48`"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.48`"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.48`"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"version": "0.3.47",
|
|
35
|
+
"tag": "@ldsg/cli_v0.3.47",
|
|
36
|
+
"date": "Wed, 04 Nov 2026 04:53:36 GMT",
|
|
37
|
+
"comments": {
|
|
38
|
+
"patch": [
|
|
39
|
+
{
|
|
40
|
+
"comment": "发布更新"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"dependency": [
|
|
44
|
+
{
|
|
45
|
+
"comment": "Updating dependency \"@ldsg/handler\" to `0.3.47`"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"comment": "Updating dependency \"@ldsg/utils\" to `0.3.47`"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"comment": "Updating dependency \"@ldsg/types\" to `0.3.47`"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
4
56
|
{
|
|
5
57
|
"version": "0.3.46",
|
|
6
58
|
"tag": "@ldsg/cli_v0.3.46",
|
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 Wed, 04 Nov 2026 15:43:23 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.3.48
|
|
6
|
+
Wed, 04 Nov 2026 15:43:23 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- 发布更新
|
|
11
|
+
|
|
12
|
+
## 0.3.47
|
|
13
|
+
Wed, 04 Nov 2026 04:53:36 GMT
|
|
14
|
+
|
|
15
|
+
### Patches
|
|
16
|
+
|
|
17
|
+
- 发布更新
|
|
4
18
|
|
|
5
19
|
## 0.3.46
|
|
6
20
|
Tue, 03 Nov 2026 14:23:20 GMT
|
|
@@ -6,12 +6,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generateApplication = void 0;
|
|
7
7
|
const utils_1 = require("@ldsg/utils");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
11
|
const utils_2 = require("./utils");
|
|
11
12
|
const generateApplication = async (params) => {
|
|
12
|
-
const { outputPath, isZip } = params;
|
|
13
|
-
const {
|
|
14
|
-
|
|
13
|
+
const { data, outputPath, isZip } = params;
|
|
14
|
+
const { resourceRecords: dataResourceRecords } = data;
|
|
15
|
+
let generatorRequiredResourceRecords;
|
|
16
|
+
let generatorNames;
|
|
17
|
+
{
|
|
18
|
+
const generatorRequiredResourceKinds = ["generator", "generator_app"];
|
|
19
|
+
generatorRequiredResourceRecords = (0, utils_1.filterRequiredResourceRecords)({
|
|
20
|
+
requiredResourceKinds: generatorRequiredResourceKinds,
|
|
21
|
+
resourceRecords: dataResourceRecords,
|
|
22
|
+
}).requiredResourceRecords;
|
|
23
|
+
const generatorResourceRecords = lodash_1.default.filter(generatorRequiredResourceRecords, (resourceRecord) => {
|
|
24
|
+
const { kind } = resourceRecord;
|
|
25
|
+
return kind === "generator";
|
|
26
|
+
});
|
|
27
|
+
generatorNames = lodash_1.default.map(generatorResourceRecords, (resourceRecord) => {
|
|
28
|
+
const { slug } = resourceRecord.settings;
|
|
29
|
+
return lodash_1.default.snakeCase(slug);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
let metaGenerator = {};
|
|
33
|
+
{
|
|
34
|
+
const hasMetaGenerator = generatorNames.includes("meta");
|
|
35
|
+
if (hasMetaGenerator) {
|
|
36
|
+
const buildMetaGeneratorAppRes = await (0, utils_2.buildMetaGeneratorApp)(params);
|
|
37
|
+
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let appGenerator = {};
|
|
41
|
+
{
|
|
42
|
+
const hasAppGenerator = generatorNames.includes("app");
|
|
43
|
+
if (hasAppGenerator) {
|
|
44
|
+
const buildAppGeneratorAppRes = await (0, utils_2.buildAppGeneratorApp)({ metaGenerator, ...params });
|
|
45
|
+
appGenerator = buildAppGeneratorAppRes.appGenerator;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
15
48
|
const generateAppRes = await (0, utils_2.generateApp)({ appGenerator, ...params });
|
|
16
49
|
{
|
|
17
50
|
const { archive } = generateAppRes;
|
|
@@ -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,uCAAgF;AAChF,wDAA0B;AAC1B,oDAAuB;AACvB,0DAA6B;AAE7B,mCAAmF;AAa5E,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;IAEtD,IAAI,cAAwB,CAAC;IAE7B,CAAC;QAIC,MAAM,8BAA8B,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAEtE,gCAAgC,GAAG,IAAA,qCAA6B,EAAC;YAC/D,qBAAqB,EAAE,8BAA8B;YACrD,eAAe,EAAE,mBAAmB;SACrC,CAAC,CAAC,uBAAuB,CAAC;QAE3B,MAAM,wBAAwB,GAAG,gBAAC,CAAC,MAAM,CACvC,gCAAgC,EAChC,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC;YAEhC,OAAO,IAAI,KAAK,WAAW,CAAC;QAC9B,CAAC,CACF,CAAC;QAEF,cAAc,GAAG,gBAAC,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC,cAAc,EAAE,EAAE;YAClE,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,QAAQ,CAAC;YAEzC,OAAO,gBAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,aAAa,GAAc,EAAe,CAAC;IAQ/C,CAAC;QAIC,MAAM,gBAAgB,GAAG,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEzD,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,wBAAwB,GAAG,MAAM,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;YAErE,aAAa,GAAG,wBAAwB,CAAC,aAAa,CAAC;QACzD,CAAC;IACH,CAAC;IAED,IAAI,YAAY,GAAc,EAAe,CAAC;IAQ9C,CAAC;QAIC,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEvD,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,uBAAuB,GAAG,MAAM,IAAA,4BAAoB,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;AAjGW,QAAA,mBAAmB,uBAiG9B"}
|
package/dist/commands/generate/utils/generate-application/utils/build-app-generator-app/index.js
CHANGED
|
@@ -4,26 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildAppGeneratorApp = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
7
|
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const load_generator_app_1 = require("../load-generator-app");
|
|
11
10
|
const buildAppGeneratorApp = async (params) => {
|
|
12
11
|
const { metaGenerator, ...restParams } = params;
|
|
13
|
-
const { archive } = await metaGenerator.generate({ ...restParams
|
|
14
|
-
const
|
|
15
|
-
(0, utils_1.extractZipToFolder)({
|
|
12
|
+
const { archive } = await metaGenerator.generate({ ...restParams });
|
|
13
|
+
const generatorApp = await (0, load_generator_app_1.loadGeneratorApp)({
|
|
16
14
|
archive,
|
|
17
|
-
outputPath,
|
|
15
|
+
outputPath: node_path_1.default.join(node_os_1.default.homedir(), ".ldsg", "app-generator"),
|
|
18
16
|
});
|
|
17
|
+
const appGenerator = generatorApp.generators["app"];
|
|
19
18
|
const res = {
|
|
20
|
-
appGenerator
|
|
21
|
-
generate: async () => {
|
|
22
|
-
return {
|
|
23
|
-
archive,
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
},
|
|
19
|
+
appGenerator,
|
|
27
20
|
};
|
|
28
21
|
return res;
|
|
29
22
|
};
|
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,
|
|
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;IAKhD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IAEpE,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;AApBW,QAAA,oBAAoB,wBAoB/B"}
|
package/dist/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.js
CHANGED
|
@@ -5,32 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildMetaGeneratorApp = void 0;
|
|
7
7
|
const utils_1 = require("@ldsg/utils");
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
8
|
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const load_generator_app_1 = require("../load-generator-app");
|
|
12
11
|
const buildMetaGeneratorApp = async (params) => {
|
|
13
|
-
const { archive } = await (0, utils_1.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
archive,
|
|
20
|
-
outputPath,
|
|
21
|
-
});
|
|
22
|
-
await (0, utils_1.installDependencies)({ cwd: outputPath });
|
|
23
|
-
await (0, utils_1.buildWithPnpmWorkspace)({
|
|
24
|
-
cwd: outputPath,
|
|
25
|
-
});
|
|
26
|
-
const importModule = new Function("specifier", "return import(specifier)");
|
|
27
|
-
const entryPath = node_path_1.default.join(outputPath, "dist", "index.js");
|
|
28
|
-
const entryUrl = `${(0, node_url_1.pathToFileURL)(entryPath).href}?t=${Date.now()}`;
|
|
29
|
-
const { generate } = (await importModule(entryUrl));
|
|
30
|
-
metaGenerator = {
|
|
31
|
-
generate,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
12
|
+
const { archive } = await (0, utils_1.generateGeneratorApp)(params);
|
|
13
|
+
const generatorApp = await (0, load_generator_app_1.loadGeneratorApp)({
|
|
14
|
+
archive,
|
|
15
|
+
outputPath: node_path_1.default.join(node_os_1.default.homedir(), ".ldsg", "meta-generator"),
|
|
16
|
+
});
|
|
17
|
+
const metaGenerator = generatorApp.generators["meta"];
|
|
34
18
|
const res = {
|
|
35
19
|
metaGenerator,
|
|
36
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAmD;AAEnD,sDAAyB;AACzB,0DAA6B;AAC7B,8DAAyD;AAYlD,MAAM,qBAAqB,GAA0B,KAAK,EAAE,MAAM,EAAE,EAAE;IAC3E,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,4BAAoB,EAAC,MAAM,CAAC,CAAC;IAEvD,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAgB,EAAC;QAC1C,OAAO;QACP,UAAU,EAAE,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,CAAC;KAC/D,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEtD,MAAM,GAAG,GAA6B;QACpC,aAAa;KACd,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAfW,QAAA,qBAAqB,yBAehC"}
|
|
@@ -3,7 +3,7 @@ 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
|
-
const res = await appGenerator.generate(restParams);
|
|
6
|
+
const res = await appGenerator.generate({ ...restParams });
|
|
7
7
|
return res;
|
|
8
8
|
};
|
|
9
9
|
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":";;;AAUO,MAAM,WAAW,GAAgB,KAAK,EAAE,MAAM,EAAE,EAAE;IACvD,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAE/C,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/generate-app/index.ts"],"names":[],"mappings":";;;AAUO,MAAM,WAAW,GAAgB,KAAK,EAAE,MAAM,EAAE,EAAE;IACvD,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IAE/C,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IAE3D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB"}
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./build-app-generator-app"), exports);
|
|
18
18
|
__exportStar(require("./build-meta-generator-app"), exports);
|
|
19
19
|
__exportStar(require("./generate-app"), exports);
|
|
20
|
+
__exportStar(require("./load-generator-app"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/generate/utils/generate-application/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,6DAA2C;AAC3C,iDAA+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/commands/generate/utils/generate-application/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,6DAA2C;AAC3C,iDAA+B;AAC/B,uDAAqC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GeneratorApp } from "@ldsg/generator-app";
|
|
2
|
+
export interface LoadGeneratorAppParams {
|
|
3
|
+
archive: Buffer<ArrayBufferLike>;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
}
|
|
6
|
+
export type LoadGeneratorApp = (params: LoadGeneratorAppParams) => Promise<GeneratorApp>;
|
|
7
|
+
export declare const loadGeneratorApp: LoadGeneratorApp;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadGeneratorApp = void 0;
|
|
7
|
+
const utils_1 = require("@ldsg/utils");
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_url_1 = require("node:url");
|
|
11
|
+
const loadGeneratorApp = async (params) => {
|
|
12
|
+
const { archive, outputPath } = params;
|
|
13
|
+
await fs_extra_1.default.remove(outputPath);
|
|
14
|
+
(0, utils_1.extractZipToFolder)({
|
|
15
|
+
archive,
|
|
16
|
+
outputPath,
|
|
17
|
+
});
|
|
18
|
+
await (0, utils_1.installDependencies)({ cwd: outputPath });
|
|
19
|
+
await (0, utils_1.buildWithPnpmWorkspace)({ cwd: outputPath });
|
|
20
|
+
const importModule = new Function("specifier", "return import(specifier)");
|
|
21
|
+
const entryPath = node_path_1.default.join(outputPath, "dist", "index.js");
|
|
22
|
+
const entryUrl = `${(0, node_url_1.pathToFileURL)(entryPath).href}?t=${Date.now()}`;
|
|
23
|
+
const { instantiateAppResource } = (await importModule(entryUrl));
|
|
24
|
+
const appResource = await instantiateAppResource();
|
|
25
|
+
const { app: generatorApp } = appResource.createGeneratorApp();
|
|
26
|
+
return generatorApp;
|
|
27
|
+
};
|
|
28
|
+
exports.loadGeneratorApp = loadGeneratorApp;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
package/dist/commands/generate/utils/generate-application/utils/load-generator-app/index.js.map
ADDED
|
@@ -0,0 +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;AA1CW,QAAA,gBAAgB,oBA0C3B"}
|
package/dist/commands/generate/utils/generate-application/utils/load-generator-app/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/commands/generate/utils/generate-application/utils/load-generator-app/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,8 +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/
|
|
20
|
+
"@ldsg/generator-app": "0.3.48",
|
|
21
|
+
"@ldsg/handler": "0.3.48",
|
|
22
|
+
"@ldsg/resource": "0.3.48",
|
|
23
|
+
"@ldsg/utils": "0.3.48"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -37,7 +39,7 @@
|
|
|
37
39
|
"ts-node": "^10.9.2",
|
|
38
40
|
"tslib": "^2.8.1",
|
|
39
41
|
"typescript": "^5.3.3",
|
|
40
|
-
"@ldsg/types": "0.3.
|
|
42
|
+
"@ldsg/types": "0.3.48"
|
|
41
43
|
},
|
|
42
44
|
"scripts": {
|
|
43
45
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { extractZipToFolder } from "@ldsg/utils";
|
|
1
|
+
import { extractZipToFolder, filterRequiredResourceRecords } from "@ldsg/utils";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
+
import _ from "lodash";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import type { GenerateParams } from "@ldsg/types";
|
|
5
|
+
import type { GenerateParams, Generator, ResourceRecords } from "@ldsg/types";
|
|
5
6
|
import { buildAppGeneratorApp, buildMetaGeneratorApp, generateApp } from "./utils";
|
|
6
7
|
|
|
7
8
|
interface GenerateApplicationParams extends GenerateParams {}
|
|
@@ -16,20 +17,85 @@ type GenerateApplication = (params: GenerateApplicationParams) => Promise<void>;
|
|
|
16
17
|
* 4. 输出压缩包或解压至目标输出路径。
|
|
17
18
|
*/
|
|
18
19
|
export const generateApplication: GenerateApplication = async (params) => {
|
|
19
|
-
const { outputPath, isZip } = params;
|
|
20
|
+
const { data, outputPath, isZip } = params;
|
|
21
|
+
|
|
22
|
+
const { resourceRecords: dataResourceRecords } = data;
|
|
23
|
+
|
|
24
|
+
let generatorRequiredResourceRecords: ResourceRecords;
|
|
25
|
+
|
|
26
|
+
let generatorNames: string[];
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* 生成器所需资源类型
|
|
31
|
+
*/
|
|
32
|
+
const generatorRequiredResourceKinds = ["generator", "generator_app"];
|
|
33
|
+
|
|
34
|
+
generatorRequiredResourceRecords = filterRequiredResourceRecords({
|
|
35
|
+
requiredResourceKinds: generatorRequiredResourceKinds,
|
|
36
|
+
resourceRecords: dataResourceRecords,
|
|
37
|
+
}).requiredResourceRecords;
|
|
38
|
+
|
|
39
|
+
const generatorResourceRecords = _.filter(
|
|
40
|
+
generatorRequiredResourceRecords,
|
|
41
|
+
(resourceRecord) => {
|
|
42
|
+
const { kind } = resourceRecord;
|
|
43
|
+
|
|
44
|
+
return kind === "generator";
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
generatorNames = _.map(generatorResourceRecords, (resourceRecord) => {
|
|
49
|
+
const { slug } = resourceRecord.settings;
|
|
50
|
+
|
|
51
|
+
return _.snakeCase(slug);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let metaGenerator: Generator = {} as Generator;
|
|
20
56
|
|
|
21
57
|
/**
|
|
22
|
-
* 1. 基于资源记录,使用此应用(@ldsg/cli)内置能力构建(含生成、依赖安装、构建)元生成器(Meta Generator
|
|
58
|
+
* 1. 基于资源记录,使用此应用(@ldsg/cli)内置能力构建(含生成、依赖安装、构建)元生成器(Meta Generator):
|
|
59
|
+
* 1.1. 检查资源记录中,是否有元生成器资源记录;
|
|
60
|
+
* 1.2. 若有,则使用此应用(@ldsg/cli)内置能力根据元生成器资源记录构建(含生成、依赖安装、构建)元生成器(Meta Generator);
|
|
61
|
+
* 1.3. 若没有,则跳过生成元生成器,直接使用默认元生成器。
|
|
23
62
|
*/
|
|
24
|
-
|
|
63
|
+
{
|
|
64
|
+
/**
|
|
65
|
+
* 是否有元生成器
|
|
66
|
+
*/
|
|
67
|
+
const hasMetaGenerator = generatorNames.includes("meta");
|
|
68
|
+
|
|
69
|
+
if (hasMetaGenerator) {
|
|
70
|
+
const buildMetaGeneratorAppRes = await buildMetaGeneratorApp(params);
|
|
71
|
+
|
|
72
|
+
metaGenerator = buildMetaGeneratorAppRes.metaGenerator;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let appGenerator: Generator = {} as Generator;
|
|
25
77
|
|
|
26
78
|
/**
|
|
27
79
|
* 2. 基于资源记录,使用元生成器(Meta Generator)能力构建(含生成、依赖安装、构建)应用生成器(App Generator);
|
|
80
|
+
* 2.1. 检查资源记录中,是否有应用生成器资源记录;
|
|
81
|
+
* 2.2. 若有,则使用此应用(@ldsg/cli)内置能力根据应用生成器资源记录构建(含生成、依赖安装、构建)应用生成器;
|
|
82
|
+
* 2.3. 若没有,则跳过生成应用生成器,直接使用默认应用生成器。
|
|
28
83
|
*/
|
|
29
|
-
|
|
84
|
+
{
|
|
85
|
+
/**
|
|
86
|
+
* 是否有应用的生成器
|
|
87
|
+
*/
|
|
88
|
+
const hasAppGenerator = generatorNames.includes("app");
|
|
89
|
+
|
|
90
|
+
if (hasAppGenerator) {
|
|
91
|
+
const buildAppGeneratorAppRes = await buildAppGeneratorApp({ metaGenerator, ...params });
|
|
92
|
+
|
|
93
|
+
appGenerator = buildAppGeneratorAppRes.appGenerator;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
30
96
|
|
|
31
97
|
/**
|
|
32
|
-
* 3. 基于资源记录,使用应用生成器(App Generator
|
|
98
|
+
* 3. 基于资源记录,使用应用生成器(App Generator)能力根据应用资源记录生成(仅含生成,不含依赖安装、构建)生成应用(App)压缩包;
|
|
33
99
|
*/
|
|
34
100
|
const generateAppRes = await generateApp({ appGenerator, ...params });
|
|
35
101
|
|
package/src/commands/generate/utils/generate-application/utils/build-app-generator-app/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GenerateParams, Generator } from "@ldsg/types";
|
|
2
|
-
import path from "node:path";
|
|
3
2
|
import os from "node:os";
|
|
4
|
-
import
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { loadGeneratorApp } from "../load-generator-app";
|
|
5
5
|
|
|
6
6
|
export interface BuildAppGeneratorAppParams extends GenerateParams {
|
|
7
7
|
metaGenerator: Generator;
|
|
@@ -15,31 +15,23 @@ export type BuildAppGeneratorApp = (
|
|
|
15
15
|
params: BuildAppGeneratorAppParams,
|
|
16
16
|
) => Promise<BuildAppGeneratorAppRes>;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* 元生成器在生成器集合中的 kind,与默认生成器资源 settings.kind 一致
|
|
20
|
-
*/
|
|
21
|
-
const META_GENERATOR_KIND = "meta_generator";
|
|
22
|
-
|
|
23
18
|
export const buildAppGeneratorApp: BuildAppGeneratorApp = async (params) => {
|
|
24
19
|
const { metaGenerator, ...restParams } = params;
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 使用元生成器生成应用生成器应用
|
|
23
|
+
*/
|
|
24
|
+
const { archive } = await metaGenerator.generate({ ...restParams });
|
|
27
25
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
extractZipToFolder({
|
|
26
|
+
const generatorApp = await loadGeneratorApp({
|
|
31
27
|
archive,
|
|
32
|
-
outputPath,
|
|
28
|
+
outputPath: path.join(os.homedir(), ".ldsg", "app-generator"),
|
|
33
29
|
});
|
|
34
30
|
|
|
31
|
+
const appGenerator = generatorApp.generators["app"];
|
|
32
|
+
|
|
35
33
|
const res: BuildAppGeneratorAppRes = {
|
|
36
|
-
appGenerator
|
|
37
|
-
generate: async () => {
|
|
38
|
-
return {
|
|
39
|
-
archive,
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
},
|
|
34
|
+
appGenerator,
|
|
43
35
|
};
|
|
44
36
|
|
|
45
37
|
return res;
|
package/src/commands/generate/utils/generate-application/utils/build-meta-generator-app/index.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildWithPnpmWorkspace,
|
|
3
|
-
extractZipToFolder,
|
|
4
|
-
generateMetaGeneratorApp,
|
|
5
|
-
installDependencies,
|
|
6
|
-
} from "@ldsg/utils";
|
|
1
|
+
import { generateGeneratorApp } from "@ldsg/utils";
|
|
7
2
|
import { GenerateParams, Generator } from "@ldsg/types";
|
|
8
|
-
import path from "node:path";
|
|
9
3
|
import os from "node:os";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { loadGeneratorApp } from "../load-generator-app";
|
|
12
6
|
|
|
13
7
|
export interface BuildMetaGeneratorAppParams extends GenerateParams {}
|
|
14
8
|
|
|
@@ -21,65 +15,14 @@ export type BuildMetaGeneratorApp = (
|
|
|
21
15
|
) => Promise<BuildMetaGeneratorAppRes>;
|
|
22
16
|
|
|
23
17
|
export const buildMetaGeneratorApp: BuildMetaGeneratorApp = async (params) => {
|
|
24
|
-
const { archive } = await
|
|
25
|
-
|
|
26
|
-
let metaGenerator: Generator;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 解压、安装依赖、编辑、导出模块
|
|
30
|
-
*/
|
|
31
|
-
{
|
|
32
|
-
const outputPath = path.join(os.homedir(), ".ldsg", "meta-generator");
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 清理上一次构建产物,避免旧的 dist 残留被动态导入
|
|
36
|
-
*/
|
|
37
|
-
await fs.remove(outputPath);
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 解压至指定目录
|
|
41
|
-
*/
|
|
42
|
-
extractZipToFolder({
|
|
43
|
-
archive,
|
|
44
|
-
outputPath,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 安装依赖
|
|
49
|
-
*/
|
|
50
|
-
await installDependencies({ cwd: outputPath });
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 构建
|
|
54
|
-
*/
|
|
55
|
-
await buildWithPnpmWorkspace({
|
|
56
|
-
cwd: outputPath,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 产物为 ESM 单文件模块(模板 package.json 的 type 为 module,vite ssr 构建全量内联),
|
|
61
|
-
* 而 @ldsg/cli 编译为 commonjs,tsc 会把 import() 降级为 require(),
|
|
62
|
-
* 故通过 Function 保留原生动态 import。
|
|
63
|
-
*/
|
|
64
|
-
const importModule = new Function("specifier", "return import(specifier)") as (
|
|
65
|
-
specifier: string,
|
|
66
|
-
) => Promise<unknown>;
|
|
67
|
-
|
|
68
|
-
const entryPath = path.join(outputPath, "dist", "index.js");
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 追加时间戳,避免 Node 的 ESM 模块缓存复用上一次构建的产物
|
|
72
|
-
*/
|
|
73
|
-
const entryUrl = `${pathToFileURL(entryPath).href}?t=${Date.now()}`;
|
|
18
|
+
const { archive } = await generateGeneratorApp(params);
|
|
74
19
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
20
|
+
const generatorApp = await loadGeneratorApp({
|
|
21
|
+
archive,
|
|
22
|
+
outputPath: path.join(os.homedir(), ".ldsg", "meta-generator"),
|
|
23
|
+
});
|
|
78
24
|
|
|
79
|
-
|
|
80
|
-
generate,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
25
|
+
const metaGenerator = generatorApp.generators["meta"];
|
|
83
26
|
|
|
84
27
|
const res: BuildMetaGeneratorAppRes = {
|
|
85
28
|
metaGenerator,
|
|
@@ -11,7 +11,7 @@ export type GenerateApp = (params: GenerateAppParams) => Promise<GenerateAppRes>
|
|
|
11
11
|
export const generateApp: GenerateApp = async (params) => {
|
|
12
12
|
const { appGenerator, ...restParams } = params;
|
|
13
13
|
|
|
14
|
-
const res = await appGenerator.generate(restParams);
|
|
14
|
+
const res = await appGenerator.generate({ ...restParams });
|
|
15
15
|
|
|
16
16
|
return res;
|
|
17
17
|
};
|