@aiot-toolkit/aiotpack 2.0.2 → 2.0.3-beta.2
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/lib/afterCompile/ux/UxAfterCompile.d.ts +1 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +31 -5
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +10 -2
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +11 -2
- package/lib/config/XtsConfig.d.ts +2 -0
- package/lib/config/XtsConfig.js +2 -1
- package/lib/loader/ux/android/UxLoader.d.ts +2 -0
- package/lib/loader/ux/android/UxLoader.js +1 -2
- package/lib/loader/ux/vela/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/AppUxLoader.js +1 -2
- package/lib/loader/ux/vela/UxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/UxLoader.js +4 -6
- package/lib/utils/ux/UxFileUtils.d.ts +1 -1
- package/lib/utils/ux/UxFileUtils.js +4 -1
- package/package.json +6 -6
|
@@ -16,7 +16,7 @@ declare class UxAfterCompile {
|
|
|
16
16
|
*/
|
|
17
17
|
static copyResource: FollowWork<IJavascriptCompileOption>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 如果是更新触发,则对比临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
20
20
|
* @param context
|
|
21
21
|
* @param config
|
|
22
22
|
* @param compilerOption
|
|
@@ -23,6 +23,8 @@ const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler
|
|
|
23
23
|
const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
24
24
|
const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
25
25
|
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
26
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
27
|
+
const FileLaneTriggerType_1 = __importDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
|
|
26
28
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
27
29
|
/**
|
|
28
30
|
* UxAfterCompile
|
|
@@ -82,9 +84,13 @@ UxAfterCompile.jsc = (params) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
82
84
|
}
|
|
83
85
|
});
|
|
84
86
|
UxAfterCompile.toRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
-
const { compilerOption } = params;
|
|
87
|
+
const { compilerOption, compalition, config } = params;
|
|
86
88
|
if (compilerOption) {
|
|
87
|
-
|
|
89
|
+
const fileName = yield ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
|
|
90
|
+
if (compalition && fileName) {
|
|
91
|
+
compalition.info.rpk = path_1.default.join(config.projectPath, compilerOption.releasePath, fileName);
|
|
92
|
+
}
|
|
93
|
+
return fileName;
|
|
88
94
|
}
|
|
89
95
|
});
|
|
90
96
|
/**
|
|
@@ -203,22 +209,42 @@ UxAfterCompile.copyResource = (params) => __awaiter(void 0, void 0, void 0, func
|
|
|
203
209
|
}
|
|
204
210
|
});
|
|
205
211
|
/**
|
|
206
|
-
*
|
|
212
|
+
* 如果是更新触发,则对比临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
207
213
|
* @param context
|
|
208
214
|
* @param config
|
|
209
215
|
* @param compilerOption
|
|
210
216
|
*/
|
|
211
217
|
UxAfterCompile.generateDiff = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
-
const { compilerOption, compalition } = params;
|
|
218
|
+
const { compilerOption, compalition, config } = params;
|
|
213
219
|
if (!compilerOption || !compalition) {
|
|
214
220
|
return;
|
|
215
221
|
}
|
|
222
|
+
if (compalition.trigger === FileLaneTriggerType_1.default.START) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
216
225
|
const { outputPath, projectPath } = compilerOption;
|
|
217
226
|
// 读取临时项目build文件夹中所有文件路径
|
|
218
227
|
const tempBuildPath = path_1.default.join(projectPath, outputPath);
|
|
219
228
|
// 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
|
|
220
229
|
const tempFileList = shared_utils_1.FileUtil.readAlldirSync(tempBuildPath).map((filePath) => path_1.default.relative(tempBuildPath, filePath));
|
|
221
|
-
UxFileUtils_1.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
|
|
230
|
+
const diffList = UxFileUtils_1.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
|
|
231
|
+
// 所有差异文件,压缩到 .diff.rpk 中
|
|
232
|
+
if (diffList === null || diffList === void 0 ? void 0 : diffList.length) {
|
|
233
|
+
const buildFold = path_1.default.join(compilerOption.projectPath, compilerOption.outputPath);
|
|
234
|
+
const distFold = path_1.default.join(compilerOption.projectPath, compilerOption.releasePath);
|
|
235
|
+
const diffFileName = `.diff.rpk`;
|
|
236
|
+
const diffPath = path_1.default.join(distFold, diffFileName);
|
|
237
|
+
const diffStream = fs_extra_1.default.createWriteStream(diffPath);
|
|
238
|
+
const archiver = (0, archiver_1.default)('zip', { zlib: { level: 9 } });
|
|
239
|
+
archiver.pipe(diffStream);
|
|
240
|
+
diffList.forEach((item) => {
|
|
241
|
+
const filePath = path_1.default.join(buildFold, item);
|
|
242
|
+
archiver.append(fs_extra_1.default.createReadStream(filePath), { name: item });
|
|
243
|
+
});
|
|
244
|
+
yield archiver.finalize();
|
|
245
|
+
compalition.info.diffList = diffList;
|
|
246
|
+
compalition.info.diffFile = path_1.default.join(config.projectPath, compilerOption.releasePath, diffFileName);
|
|
247
|
+
}
|
|
222
248
|
});
|
|
223
249
|
/**
|
|
224
250
|
* 打包结果移回源码项目,并删除中间项目
|
|
@@ -29,11 +29,19 @@ declare class ZipUtil {
|
|
|
29
29
|
* 3. 写入到硬盘
|
|
30
30
|
* @param dist
|
|
31
31
|
* @param param
|
|
32
|
-
* @returns
|
|
32
|
+
* @returns 生成的 rpk 文件名
|
|
33
33
|
*/
|
|
34
|
-
static createRpk(dist: string, param: IJavascriptCompileOption): Promise<
|
|
34
|
+
static createRpk(dist: string, param: IJavascriptCompileOption): Promise<string | undefined>;
|
|
35
35
|
private static getFileName;
|
|
36
36
|
private static packageToZipBuffer;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param buffer
|
|
40
|
+
* @param param
|
|
41
|
+
* @param fileName
|
|
42
|
+
*
|
|
43
|
+
* @returns 生成的文件名
|
|
44
|
+
*/
|
|
37
45
|
private static generateDistFile;
|
|
38
46
|
/**
|
|
39
47
|
* 根据文件列表创建 zip 的 Buffer
|
|
@@ -41,7 +41,7 @@ class ZipUtil {
|
|
|
41
41
|
* 3. 写入到硬盘
|
|
42
42
|
* @param dist
|
|
43
43
|
* @param param
|
|
44
|
-
* @returns
|
|
44
|
+
* @returns 生成的 rpk 文件名
|
|
45
45
|
*/
|
|
46
46
|
static createRpk(dist, param) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -58,7 +58,7 @@ class ZipUtil {
|
|
|
58
58
|
const signConfig = SignUtil_1.default.getProjectSignConfig(param);
|
|
59
59
|
const rpkBuffer = yield _a.buildProjectAndOutput(fullPackage, signConfig);
|
|
60
60
|
// 3
|
|
61
|
-
this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
61
|
+
return this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
static getFileName(param, config, ext) {
|
|
@@ -85,12 +85,21 @@ class ZipUtil {
|
|
|
85
85
|
return yield this.createZipBufferFromFileList(packageFileList, comment);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param buffer
|
|
91
|
+
* @param param
|
|
92
|
+
* @param fileName
|
|
93
|
+
*
|
|
94
|
+
* @returns 生成的文件名
|
|
95
|
+
*/
|
|
88
96
|
static generateDistFile(buffer, param, fileName) {
|
|
89
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
98
|
const { releasePath, projectPath } = param;
|
|
91
99
|
const filePath = path_1.default.join(projectPath, releasePath, fileName);
|
|
92
100
|
fs_extra_1.default.outputFileSync(filePath, buffer);
|
|
93
101
|
shared_utils_1.ColorConsole.success(`Project build and generate files:${fileName}`);
|
|
102
|
+
return fileName;
|
|
94
103
|
});
|
|
95
104
|
}
|
|
96
105
|
/**
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -11,7 +11,8 @@ const XtsLoader_1 = __importDefault(require("../loader/xts/XtsLoader"));
|
|
|
11
11
|
* XtsConfig
|
|
12
12
|
*/
|
|
13
13
|
class XtsConfig {
|
|
14
|
-
constructor() {
|
|
14
|
+
constructor(projectPath) {
|
|
15
|
+
this.projectPath = projectPath;
|
|
15
16
|
this.exclude = [
|
|
16
17
|
'**/node_modules{,/**}',
|
|
17
18
|
'**/dist{,/**}',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
3
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
4
|
/**
|
|
@@ -6,6 +7,7 @@ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJa
|
|
|
6
7
|
declare class UxLoader implements ILoader {
|
|
7
8
|
context: IFileLaneContext;
|
|
8
9
|
compilerOption: IJavascriptCompileOption;
|
|
10
|
+
logs?: ILog[] | undefined;
|
|
9
11
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
12
|
}
|
|
11
13
|
export default UxLoader;
|
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const path_1 = __importDefault(require("path"));
|
|
17
16
|
const AndroidUx_1 = __importDefault(require("../../../utils/ux/android/AndroidUx"));
|
|
18
17
|
/**
|
|
@@ -29,7 +28,7 @@ class UxLoader {
|
|
|
29
28
|
file: item,
|
|
30
29
|
compilerOption: this.compilerOption
|
|
31
30
|
});
|
|
32
|
-
|
|
31
|
+
this.logs = logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' })));
|
|
33
32
|
result.push(...files);
|
|
34
33
|
}
|
|
35
34
|
return result;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
3
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
4
|
/**
|
|
@@ -7,6 +8,7 @@ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJa
|
|
|
7
8
|
declare class AppUxLoader implements ILoader {
|
|
8
9
|
context: IFileLaneContext;
|
|
9
10
|
compilerOption: IJavascriptCompileOption;
|
|
11
|
+
logs?: ILog[] | undefined;
|
|
10
12
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
11
13
|
}
|
|
12
14
|
export default AppUxLoader;
|
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const path_1 = __importDefault(require("path"));
|
|
17
16
|
const UxLoaderUtils_1 = __importDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
18
17
|
/**
|
|
@@ -24,7 +23,7 @@ class AppUxLoader {
|
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
24
|
const { projectPath } = this.context;
|
|
26
25
|
const { files: resultFiles, logs } = yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
|
|
27
|
-
|
|
26
|
+
this.logs = logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' })));
|
|
28
27
|
return resultFiles;
|
|
29
28
|
});
|
|
30
29
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
import { ILog } from '@aiot-toolkit/shared-utils/lib/interface/ILog';
|
|
3
4
|
declare class UxLoader implements ILoader {
|
|
4
5
|
context: IFileLaneContext;
|
|
5
6
|
compilerOption: IJavascriptCompileOption;
|
|
7
|
+
logs?: ILog[] | undefined;
|
|
6
8
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
7
9
|
}
|
|
8
10
|
export default UxLoader;
|
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const path_1 = __importDefault(require("path"));
|
|
17
16
|
const UxLoaderUtils_1 = __importDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
18
17
|
class UxLoader {
|
|
@@ -23,15 +22,14 @@ class UxLoader {
|
|
|
23
22
|
for (const file of files) {
|
|
24
23
|
// 转换每个文件
|
|
25
24
|
const { files: compiledFiles, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
|
|
26
|
-
|
|
27
|
-
shared_utils_1.CommonUtil.processingLogsInTerminal(logs.map((item) => {
|
|
25
|
+
this.logs = logs.map((item) => {
|
|
28
26
|
var _a;
|
|
29
|
-
return
|
|
27
|
+
return Object.assign(Object.assign({}, item), { filePath: ((_a = item.position) === null || _a === void 0 ? void 0 : _a.source)
|
|
30
28
|
? item.position.source
|
|
31
29
|
: item.filePath
|
|
32
30
|
? path_1.default.relative(projectPath, item.filePath)
|
|
33
|
-
: '' })
|
|
34
|
-
})
|
|
31
|
+
: '' });
|
|
32
|
+
});
|
|
35
33
|
resultFiles.push(...compiledFiles);
|
|
36
34
|
}
|
|
37
35
|
return resultFiles;
|
|
@@ -47,6 +47,6 @@ export declare class UxFileUtils {
|
|
|
47
47
|
* @param newFileList 新文件列表
|
|
48
48
|
* @returns
|
|
49
49
|
*/
|
|
50
|
-
static getDiffJSON(compilation: FileLaneCompilation, newFileList: string[], buildPath: string):
|
|
50
|
+
static getDiffJSON(compilation: FileLaneCompilation, newFileList: string[], buildPath: string): string[];
|
|
51
51
|
}
|
|
52
52
|
export default UxFileUtils;
|
|
@@ -110,6 +110,9 @@ class UxFileUtils {
|
|
|
110
110
|
static getDiffJSON(compilation, newFileList, buildPath) {
|
|
111
111
|
var _a;
|
|
112
112
|
const oldFileList = compilation.buildFileList;
|
|
113
|
+
if (!oldFileList.length) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
113
116
|
let diffList = [];
|
|
114
117
|
// 1.
|
|
115
118
|
for (let i = 0; i < oldFileList.length; i++) {
|
|
@@ -128,7 +131,7 @@ class UxFileUtils {
|
|
|
128
131
|
}
|
|
129
132
|
// 2.
|
|
130
133
|
newFileList.length > 0 && newFileList.forEach((file) => diffList.push(file));
|
|
131
|
-
|
|
134
|
+
return diffList;
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
exports.UxFileUtils = UxFileUtils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.2",
|
|
3
|
+
"version": "2.0.3-beta.2",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.2",
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.2",
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0.2",
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.3-beta.2",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.3-beta.2",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.3-beta.2",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
26
|
"@rspack/core": "^1.0.0",
|
|
27
27
|
"aiot-parse5": "^1.0.0",
|
|
28
28
|
"archiver": "^7.0.1",
|
|
29
29
|
"babel-loader": "^9.1.3",
|
|
30
30
|
"fast-glob": "^3.3.2",
|
|
31
|
-
"file-lane": "2.0.2",
|
|
31
|
+
"file-lane": "2.0.3-beta.2",
|
|
32
32
|
"file-loader": "^6.2.0",
|
|
33
33
|
"fs-extra": "^11.2.0",
|
|
34
34
|
"jsrsasign": "^11.1.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@types/jsrsasign": "^10.5.12",
|
|
46
46
|
"@types/webpack-sources": "^3.2.3"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "7776973f6a81d7f13eb330be8df5801d9143c83c"
|
|
49
49
|
}
|