@appthen/cli 1.2.4 → 1.2.5
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/index.js +51 -39
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -31527,6 +31527,16 @@ var pluginFactory$5 = function (_a) {
|
|
|
31527
31527
|
COMMON_CHUNK_NAME.FileUtilDefine,
|
|
31528
31528
|
],
|
|
31529
31529
|
});
|
|
31530
|
+
// 添加 defaultProps 静态属性(仅在非空对象时生成)
|
|
31531
|
+
if (ir.defaultProps && typeof ir.defaultProps === 'object' && Object.keys(ir.defaultProps).length > 0) {
|
|
31532
|
+
next.chunks.push({
|
|
31533
|
+
type: ChunkType.STRING,
|
|
31534
|
+
fileType: FileType.JSX,
|
|
31535
|
+
name: CLASS_DEFINE_CHUNK_NAME.StaticVar,
|
|
31536
|
+
content: "static defaultProps = ".concat(JSON.stringify(ir.defaultProps, null, 2), ";"),
|
|
31537
|
+
linkAfter: [CLASS_DEFINE_CHUNK_NAME.Start],
|
|
31538
|
+
});
|
|
31539
|
+
}
|
|
31530
31540
|
next.chunks.push({
|
|
31531
31541
|
type: ChunkType.STRING,
|
|
31532
31542
|
fileType: FileType.JSX,
|
|
@@ -31563,7 +31573,10 @@ var pluginFactory$5 = function (_a) {
|
|
|
31563
31573
|
fileType: FileType.JSX,
|
|
31564
31574
|
name: REACT_CHUNK_NAME.ClassDidMountEnd,
|
|
31565
31575
|
content: '}',
|
|
31566
|
-
linkAfter: [
|
|
31576
|
+
linkAfter: [
|
|
31577
|
+
REACT_CHUNK_NAME.ClassDidMountContent,
|
|
31578
|
+
REACT_CHUNK_NAME.ClassDidMountStart,
|
|
31579
|
+
],
|
|
31567
31580
|
});
|
|
31568
31581
|
next.chunks.push({
|
|
31569
31582
|
type: ChunkType.STRING,
|
|
@@ -36990,11 +37003,11 @@ var lastTimeKey$1 = '$__cacheTime';
|
|
|
36990
37003
|
* @returns {Promise<number>} 错误码
|
|
36991
37004
|
*/
|
|
36992
37005
|
function run(args, options) {
|
|
36993
|
-
var _a, _b, _c, _d, _e
|
|
37006
|
+
var _a, _b, _c, _d, _e;
|
|
36994
37007
|
return __awaiter(this, void 0, void 0, function () {
|
|
36995
|
-
var cacheDirPath, keyCacheDirPath, currentLastTimeKey, cacheTime, afterTime, result, schema, project, documents, componentDocs, packageJSON, projectDocuments, projectDocumentNames_1, subPageDocumentNames_1, clientType, isWeb, solution, outputPath_1, builder, envInfoItem,
|
|
36996
|
-
return __generator(this, function (
|
|
36997
|
-
switch (
|
|
37008
|
+
var cacheDirPath, keyCacheDirPath, currentLastTimeKey, cacheTime, afterTime, result, schema, project, documents, componentDocs, packageJSON, projectDocuments, projectDocumentNames_1, subPageDocumentNames_1, clientType, isWeb, solution, outputPath_1, builder, envInfoItem, generatedSourceCodes, publisher, subPageRoot_1, subPagePath, subPagePathIsExist, getPageUrl_1, transformFilePath, existFiles, existSubFiles, _f, files, syncMap, _loop_1, i, indexPage_1, indexPageUrl_1, globalStyle, globalStyleWithoutFirstLine, globalStyle, globalStyleWithoutFirstLine, appContent, appContentWithImport, utilsFilePath, portalImportCode, haveUpdate, installCmd, e_1;
|
|
37009
|
+
return __generator(this, function (_g) {
|
|
37010
|
+
switch (_g.label) {
|
|
36998
37011
|
case 0:
|
|
36999
37012
|
cacheDirPath = path__default["default"].join(os__default["default"].homedir(), '.cache', 'mengti_temp');
|
|
37000
37013
|
keyCacheDirPath = path__default["default"].join(os__default["default"].homedir(), '.cache', 'mengti_translate');
|
|
@@ -37003,9 +37016,9 @@ function run(args, options) {
|
|
|
37003
37016
|
removeDir(keyCacheDirPath);
|
|
37004
37017
|
}
|
|
37005
37018
|
currentLastTimeKey = path__default["default"].join(process.cwd() + '/' + (options.output || '')) + lastTimeKey$1;
|
|
37006
|
-
|
|
37019
|
+
_g.label = 1;
|
|
37007
37020
|
case 1:
|
|
37008
|
-
|
|
37021
|
+
_g.trys.push([1, 15, , 16]);
|
|
37009
37022
|
cacheTime = cache$1.getKey(currentLastTimeKey);
|
|
37010
37023
|
console.log('[最后同步时间] ', cacheTime ? new Date(Number(cacheTime)).toLocaleString() : '无');
|
|
37011
37024
|
afterTime = cacheTime && !options.clear ? Number(cacheTime) : 0;
|
|
@@ -37021,7 +37034,7 @@ function run(args, options) {
|
|
|
37021
37034
|
afterTime: afterTime,
|
|
37022
37035
|
})];
|
|
37023
37036
|
case 2:
|
|
37024
|
-
result =
|
|
37037
|
+
result = _g.sent();
|
|
37025
37038
|
console.log('[INFO] 项目下载完成... ');
|
|
37026
37039
|
schema = result.schema;
|
|
37027
37040
|
console.log('🔍 原始路由数据:',
|
|
@@ -37039,7 +37052,7 @@ function run(args, options) {
|
|
|
37039
37052
|
return [4 /*yield*/, updateProjectTemplate(solution)];
|
|
37040
37053
|
case 3:
|
|
37041
37054
|
// 更新项目模板
|
|
37042
|
-
|
|
37055
|
+
_g.sent();
|
|
37043
37056
|
console.log('[INFO] 项目模板更新完成... ');
|
|
37044
37057
|
// 检查是否有文件需要更新
|
|
37045
37058
|
if (!project || documents.length === 0) {
|
|
@@ -37061,15 +37074,17 @@ function run(args, options) {
|
|
|
37061
37074
|
}
|
|
37062
37075
|
}
|
|
37063
37076
|
console.log('[INFO] 处理环境配置... ');
|
|
37064
|
-
schemaStr = JSON.stringify(
|
|
37065
|
-
|
|
37077
|
+
// const schemaStr = JSON.stringify(
|
|
37078
|
+
// schema.componentsTree?.slice(0, 20).map((item) => item.fileName)
|
|
37079
|
+
// );
|
|
37080
|
+
// console.log('schemaStr: ', schemaStr);
|
|
37066
37081
|
// const isHaveCheckicon = schemaStr.indexOf('icon.style');
|
|
37067
37082
|
// console.log('isHaveCheck', schemaStr.slice(isHaveCheckicon - 20000, isHaveCheckicon + 20000));
|
|
37068
37083
|
// 生成代码
|
|
37069
37084
|
console.log('[INFO] 开始生成代码... ');
|
|
37070
37085
|
return [4 /*yield*/, builder.generateProject(JSON.parse(JSON.stringify(schema)))];
|
|
37071
37086
|
case 4:
|
|
37072
|
-
generatedSourceCodes =
|
|
37087
|
+
generatedSourceCodes = _g.sent();
|
|
37073
37088
|
console.log('[INFO] 代码生成完成... ');
|
|
37074
37089
|
generatedSourceCodes.files = generatedSourceCodes.files.filter(function (item) { return item.ext === 'css' || item.ext === 'jsx'; });
|
|
37075
37090
|
console.log('[INFO] 过滤代码... ');
|
|
@@ -37086,7 +37101,7 @@ function run(args, options) {
|
|
|
37086
37101
|
createProjectFolder: false,
|
|
37087
37102
|
})];
|
|
37088
37103
|
case 5:
|
|
37089
|
-
|
|
37104
|
+
_g.sent();
|
|
37090
37105
|
console.log('[INFO] 代码生成完成... ');
|
|
37091
37106
|
if (!fs.existsSync("./".concat(outputPath_1, "/"))) {
|
|
37092
37107
|
fs.mkdirSync("./".concat(outputPath_1, "/"), {
|
|
@@ -37121,20 +37136,20 @@ function run(args, options) {
|
|
|
37121
37136
|
};
|
|
37122
37137
|
return [4 /*yield*/, getAllFile("./".concat(outputPath_1, "/"))];
|
|
37123
37138
|
case 6:
|
|
37124
|
-
existFiles =
|
|
37139
|
+
existFiles = _g.sent();
|
|
37125
37140
|
if (!subPagePathIsExist) return [3 /*break*/, 8];
|
|
37126
37141
|
return [4 /*yield*/, getAllFile(subPagePath)];
|
|
37127
37142
|
case 7:
|
|
37128
|
-
|
|
37143
|
+
_f = _g.sent();
|
|
37129
37144
|
return [3 /*break*/, 9];
|
|
37130
37145
|
case 8:
|
|
37131
|
-
|
|
37132
|
-
|
|
37146
|
+
_f = [];
|
|
37147
|
+
_g.label = 9;
|
|
37133
37148
|
case 9:
|
|
37134
|
-
existSubFiles =
|
|
37149
|
+
existSubFiles = _f;
|
|
37135
37150
|
return [4 /*yield*/, getAllFile(cacheDirPath + '/')];
|
|
37136
37151
|
case 10:
|
|
37137
|
-
files =
|
|
37152
|
+
files = _g.sent();
|
|
37138
37153
|
syncMap = {
|
|
37139
37154
|
components: existFiles
|
|
37140
37155
|
.filter(function (_) { return ['tsx', 'jsx'].includes(_.ext) && _.path.includes('components'); })
|
|
@@ -37186,9 +37201,9 @@ function run(args, options) {
|
|
|
37186
37201
|
.map(function (_) { return getPageUrl_1(_, subPageRoot_1); }),
|
|
37187
37202
|
};
|
|
37188
37203
|
_loop_1 = function (i) {
|
|
37189
|
-
var file, fileName_1, extName, cssFilePath, cssStr, doc,
|
|
37190
|
-
return __generator(this, function (
|
|
37191
|
-
switch (
|
|
37204
|
+
var file, fileName_1, extName, cssFilePath, cssStr, doc, _h, code, images, svgs, configJsCode, iconsFile, iconsConsts, index, svg, index, image, e_2, realFilePath;
|
|
37205
|
+
return __generator(this, function (_j) {
|
|
37206
|
+
switch (_j.label) {
|
|
37192
37207
|
case 0:
|
|
37193
37208
|
file = files[i];
|
|
37194
37209
|
if (process.env.DEV) {
|
|
@@ -37205,8 +37220,8 @@ function run(args, options) {
|
|
|
37205
37220
|
if (!(file.fileName === 'utils.js')) return [3 /*break*/, 2];
|
|
37206
37221
|
return [4 /*yield*/, transformUtils(file, schema, project, solution)];
|
|
37207
37222
|
case 1:
|
|
37208
|
-
|
|
37209
|
-
|
|
37223
|
+
_j.sent();
|
|
37224
|
+
_j.label = 2;
|
|
37210
37225
|
case 2:
|
|
37211
37226
|
if (extName === 'css' || extName === 'scss') {
|
|
37212
37227
|
cssFilePath = file.path + '/' + file.fileName;
|
|
@@ -37255,7 +37270,7 @@ function run(args, options) {
|
|
|
37255
37270
|
}
|
|
37256
37271
|
return [4 /*yield*/, transformJsx(file, solution, outputPath_1)];
|
|
37257
37272
|
case 3:
|
|
37258
|
-
|
|
37273
|
+
_h = _j.sent(), code = _h.code, images = _h.images, svgs = _h.svgs;
|
|
37259
37274
|
console.log('[BUILD SUCCESS]', file.name);
|
|
37260
37275
|
// 写入暂存文件夹
|
|
37261
37276
|
fs.writeFileSync(file.path + '/' + file.fileName, code);
|
|
@@ -37301,23 +37316,23 @@ function run(args, options) {
|
|
|
37301
37316
|
.join('\n'));
|
|
37302
37317
|
}
|
|
37303
37318
|
index = 0;
|
|
37304
|
-
|
|
37319
|
+
_j.label = 4;
|
|
37305
37320
|
case 4:
|
|
37306
37321
|
if (!(index < images.length)) return [3 /*break*/, 9];
|
|
37307
37322
|
image = images[index];
|
|
37308
37323
|
if (!(image.url && image.fileName)) return [3 /*break*/, 8];
|
|
37309
|
-
|
|
37324
|
+
_j.label = 5;
|
|
37310
37325
|
case 5:
|
|
37311
|
-
|
|
37326
|
+
_j.trys.push([5, 7, , 8]);
|
|
37312
37327
|
if (!fs.existsSync(file.path + '/images')) {
|
|
37313
37328
|
fs.mkdirSync(file.path + '/images');
|
|
37314
37329
|
}
|
|
37315
37330
|
return [4 /*yield*/, downloadFile(image.url, file.path + '/images/' + image.fileName)];
|
|
37316
37331
|
case 6:
|
|
37317
|
-
|
|
37332
|
+
_j.sent();
|
|
37318
37333
|
return [3 /*break*/, 8];
|
|
37319
37334
|
case 7:
|
|
37320
|
-
e_2 =
|
|
37335
|
+
e_2 = _j.sent();
|
|
37321
37336
|
console.log('[downloadFile Error] ', e_2);
|
|
37322
37337
|
return [3 /*break*/, 8];
|
|
37323
37338
|
case 8:
|
|
@@ -37334,35 +37349,32 @@ function run(args, options) {
|
|
|
37334
37349
|
if (fs.existsSync(realFilePath)) {
|
|
37335
37350
|
removeDir(realFilePath);
|
|
37336
37351
|
}
|
|
37337
|
-
console.log('realFilePath: ', realFilePath, doc === null || doc === void 0 ? void 0 : doc.fileName, doc === null || doc === void 0 ? void 0 : doc.type);
|
|
37338
37352
|
if ((doc === null || doc === void 0 ? void 0 : doc.type) === 'Page') {
|
|
37339
|
-
console.log('realFilePath: ', realFilePath);
|
|
37340
37353
|
fs.copySync("".concat(cacheDirPath, "/src/pages/").concat(file.name), realFilePath.replace(file.name, doc.fileName));
|
|
37341
37354
|
}
|
|
37342
37355
|
if ((doc === null || doc === void 0 ? void 0 : doc.type) === 'Component') {
|
|
37343
|
-
console.log('realFilePath1: ', realFilePath);
|
|
37344
37356
|
fs.copySync("".concat(cacheDirPath, "/src/components/").concat(file.name), realFilePath.replace(file.name, doc.fileName));
|
|
37345
37357
|
}
|
|
37346
|
-
|
|
37358
|
+
_j.label = 10;
|
|
37347
37359
|
case 10: return [2 /*return*/];
|
|
37348
37360
|
}
|
|
37349
37361
|
});
|
|
37350
37362
|
};
|
|
37351
37363
|
i = 0;
|
|
37352
|
-
|
|
37364
|
+
_g.label = 11;
|
|
37353
37365
|
case 11:
|
|
37354
37366
|
if (!(i < files.length)) return [3 /*break*/, 14];
|
|
37355
37367
|
return [5 /*yield**/, _loop_1(i)];
|
|
37356
37368
|
case 12:
|
|
37357
|
-
|
|
37358
|
-
|
|
37369
|
+
_g.sent();
|
|
37370
|
+
_g.label = 13;
|
|
37359
37371
|
case 13:
|
|
37360
37372
|
i++;
|
|
37361
37373
|
return [3 /*break*/, 11];
|
|
37362
37374
|
case 14:
|
|
37363
37375
|
// 更新同步时间
|
|
37364
37376
|
cache$1.setKey(currentLastTimeKey, String(Date.now()));
|
|
37365
|
-
indexPage_1 = (
|
|
37377
|
+
indexPage_1 = (_e = project.appConfig) === null || _e === void 0 ? void 0 : _e.indexPage;
|
|
37366
37378
|
if (indexPage_1) {
|
|
37367
37379
|
// 首页排序
|
|
37368
37380
|
syncMap.pages = syncMap.pages.sort(function (a, b) {
|
|
@@ -37453,7 +37465,7 @@ function run(args, options) {
|
|
|
37453
37465
|
console.log("[INFO ".concat(new Date().toLocaleString(), "] \u4EE3\u7801\u589E\u91CF\u540C\u6B65\u5B8C\u6210"));
|
|
37454
37466
|
return [2 /*return*/, 0];
|
|
37455
37467
|
case 15:
|
|
37456
|
-
e_1 =
|
|
37468
|
+
e_1 = _g.sent();
|
|
37457
37469
|
console.log(chalk__default["default"].red(getErrorMessage(e_1) || "Unexpected error: ".concat(e_1)));
|
|
37458
37470
|
// 保存缓存
|
|
37459
37471
|
cache$1.removeKey(currentLastTimeKey);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appthen/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Appthen Cli Tool",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@alilc/lowcode-types": "^1.3.1",
|
|
54
|
-
"@appthen/base-generator": "
|
|
54
|
+
"@appthen/base-generator": "link:/Users/huanglei/Documents/work/lowcode/alilc-engine/modules/code-generator",
|
|
55
55
|
"@babel/core": "^7.24.0",
|
|
56
56
|
"@babel/generator": "^7.24.0",
|
|
57
57
|
"@babel/helpers": "^7.24.0",
|