@aiot-toolkit/aiotpack 2.0.3-beta.1 → 2.0.3-beta.11
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.js +292 -266
- package/lib/afterCompile/xts/entryTemplate.js +111 -113
- package/lib/afterCompile/xts/generateRpk.js +25 -54
- package/lib/afterCompile/xts/ts2wasm.js +62 -63
- package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
- package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -28
- package/lib/beforeCompile/xts/preInstall.js +50 -55
- package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
- package/lib/compiler/enum/CompileMode.js +16 -23
- package/lib/compiler/interface/ICompileParam.js +1 -2
- package/lib/compiler/interface/ICompiler.js +1 -2
- package/lib/compiler/interface/ISignConfig.js +1 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +53 -49
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
- package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
- package/lib/compiler/javascript/vela/model/Package.js +80 -51
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +31 -27
- package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -276
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
- package/lib/config/UxConfig.js +145 -173
- package/lib/config/XtsConfig.js +30 -40
- package/lib/index.js +88 -41
- package/lib/interface/ICompileOptions.js +5 -2
- package/lib/interface/IDeviceList.js +1 -2
- package/lib/loader/ux/JsLoader.js +32 -30
- package/lib/loader/ux/PngLoader.js +47 -53
- package/lib/loader/ux/android/UxLoader.js +30 -31
- package/lib/loader/ux/vela/AppUxLoader.js +23 -24
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.js +29 -35
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -95
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.d.ts +2 -2
- package/lib/utils/ux/UxFileUtils.js +130 -128
- package/lib/utils/ux/UxLoaderUtils.d.ts +2 -1
- package/lib/utils/ux/UxLoaderUtils.js +295 -307
- package/lib/utils/ux/android/AndroidUx.js +88 -90
- package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
- package/lib/utils/xts/XtsFollowWorks.js +122 -129
- package/package.json +6 -6
|
@@ -1,290 +1,296 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const jszip_1 = __importDefault(require("jszip"));
|
|
19
|
-
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const UxFileUtils_1 = __importDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
21
|
-
const CompileMode_1 = __importDefault(require("../../../enum/CompileMode"));
|
|
22
|
-
const BuildNameFormatType_1 = __importDefault(require("../enum/BuildNameFormatType"));
|
|
23
|
-
const Package_1 = __importDefault(require("../model/Package"));
|
|
24
|
-
const UxCompileUtil_1 = __importDefault(require("./UxCompileUtil"));
|
|
25
|
-
const SignUtil_1 = __importDefault(require("./signature/SignUtil"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
+
var _jszip = _interopRequireDefault(require("jszip"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _UxFileUtils = _interopRequireDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
12
|
+
var _CompileMode = _interopRequireDefault(require("../../../enum/CompileMode"));
|
|
13
|
+
var _BuildNameFormatType = _interopRequireDefault(require("../enum/BuildNameFormatType"));
|
|
14
|
+
var _Package = _interopRequireDefault(require("../model/Package"));
|
|
15
|
+
var _UxCompileUtil = _interopRequireDefault(require("./UxCompileUtil"));
|
|
16
|
+
var _SignUtil = _interopRequireDefault(require("./signature/SignUtil"));
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
18
|
/**
|
|
27
19
|
* Zip 用于将打包成功的 build 目录按特定规则压缩成 rpk
|
|
28
20
|
*
|
|
29
21
|
* @see ZipUtil.createRpk 打包的完整规则
|
|
30
22
|
*/
|
|
31
23
|
class ZipUtil {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!files.length) {
|
|
52
|
-
shared_utils_1.ColorConsole.error(`The build file is missing, stop generating the application package, please check carefully`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
// 2
|
|
56
|
-
const { fullPackage } = yield this.createPackagesDefinition(param, config, files);
|
|
57
|
-
// 生产出带签名的rpk文件buffer
|
|
58
|
-
const signConfig = SignUtil_1.default.getProjectSignConfig(param);
|
|
59
|
-
const rpkBuffer = yield _a.buildProjectAndOutput(fullPackage, signConfig);
|
|
60
|
-
// 3
|
|
61
|
-
return this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
static getFileName(param, config, ext) {
|
|
65
|
-
const { mode, buildNameFormat } = param;
|
|
66
|
-
const { package: packageName } = config;
|
|
67
|
-
return [
|
|
68
|
-
packageName,
|
|
69
|
-
mode === CompileMode_1.default.DEVELOPMENT ? 'debug' : 'release',
|
|
70
|
-
buildNameFormat === BuildNameFormatType_1.default.ORIGINAL ? '' : config.versionName,
|
|
71
|
-
ext
|
|
72
|
-
]
|
|
73
|
-
.filter(Boolean)
|
|
74
|
-
.join('.');
|
|
75
|
-
}
|
|
76
|
-
static packageToZipBuffer(target) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const { resourceList, comment } = target;
|
|
79
|
-
const packageFileList = resourceList.map((item) => {
|
|
80
|
-
return {
|
|
81
|
-
path: item.fileBuildPath,
|
|
82
|
-
content: item.fileContentBuffer
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
return yield this.createZipBufferFromFileList(packageFileList, comment);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
90
|
-
* @param buffer
|
|
91
|
-
* @param param
|
|
92
|
-
* @param fileName
|
|
93
|
-
*
|
|
94
|
-
* @returns 生成的文件名
|
|
95
|
-
*/
|
|
96
|
-
static generateDistFile(buffer, param, fileName) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const { releasePath, projectPath } = param;
|
|
99
|
-
const filePath = path_1.default.join(projectPath, releasePath, fileName);
|
|
100
|
-
fs_extra_1.default.outputFileSync(filePath, buffer);
|
|
101
|
-
shared_utils_1.ColorConsole.success(`Project build and generate files:${fileName}`);
|
|
102
|
-
return fileName;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* 根据文件列表创建 zip 的 Buffer
|
|
107
|
-
* @param fileList 文件列表
|
|
108
|
-
* @param comment zip 的注释
|
|
109
|
-
* @returns
|
|
110
|
-
*/
|
|
111
|
-
static createZipBufferFromFileList(fileList, comment) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const zip = new jszip_1.default();
|
|
114
|
-
fileList.forEach((item) => {
|
|
115
|
-
zip.file(item.path, item.content);
|
|
116
|
-
});
|
|
117
|
-
return (yield zip.generateAsync(Object.assign(Object.assign({}, this.ZIP_OPTION), { comment })));
|
|
118
|
-
});
|
|
24
|
+
static DIGEST_HASH_JSON = 'hash.json';
|
|
25
|
+
|
|
26
|
+
// 摘要文件夹
|
|
27
|
+
static META_PATH = 'META-INF';
|
|
28
|
+
|
|
29
|
+
// 文件摘要包(zip 文件)
|
|
30
|
+
static CERT_PATH = `${this.META_PATH}/CERT`;
|
|
31
|
+
|
|
32
|
+
// 打包信息文件
|
|
33
|
+
static BUILD_FILE_PATH = `${this.META_PATH}/build.txt`;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* zip压缩参数
|
|
37
|
+
*/
|
|
38
|
+
static ZIP_OPTION = {
|
|
39
|
+
type: 'nodebuffer',
|
|
40
|
+
compression: 'DEFLATE',
|
|
41
|
+
compressionOptions: {
|
|
42
|
+
level: 9
|
|
119
43
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
fileContentBuffer = (yield metaZip.generateAsync(Object.assign(Object.assign({}, _a.ZIP_OPTION), { comment: null })));
|
|
145
|
-
}
|
|
146
|
-
const fileContentDigest = shared_utils_1.CommonUtil.calcDataDigest(fileContentBuffer);
|
|
147
|
-
const resourceInfo = {
|
|
148
|
-
fileBuildPath,
|
|
149
|
-
fileContentBuffer,
|
|
150
|
-
fileContentDigest
|
|
151
|
-
};
|
|
152
|
-
fullPackage.addResource(resourceInfo);
|
|
153
|
-
// 分包相关逻辑 todo
|
|
154
|
-
}
|
|
155
|
-
return { fullPackage };
|
|
156
|
-
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* dist 目录生成 rpk
|
|
48
|
+
* 1. 获取文件列表
|
|
49
|
+
* 1. 过滤出需要的文件
|
|
50
|
+
* 2. 按配置排序
|
|
51
|
+
* 2. 生成文件流
|
|
52
|
+
* 1. 每个文件生成加密串
|
|
53
|
+
* 2. 生成元数据流
|
|
54
|
+
* 3. 把元数据流和普通文件合并到一个流
|
|
55
|
+
* 3. 写入到硬盘
|
|
56
|
+
* @param dist
|
|
57
|
+
* @param param
|
|
58
|
+
* @returns 生成的 rpk 文件名
|
|
59
|
+
*/
|
|
60
|
+
static async createRpk(dist, param) {
|
|
61
|
+
const config = _UxFileUtils.default.getMainfestInfo(param.projectPath, param.sourceRoot);
|
|
62
|
+
|
|
63
|
+
// 1
|
|
64
|
+
const files = this.getSortedFiles(dist, param, config);
|
|
65
|
+
if (!files.length) {
|
|
66
|
+
_sharedUtils.ColorConsole.error(`The build file is missing, stop generating the application package, please check carefully`);
|
|
67
|
+
return;
|
|
157
68
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
69
|
+
|
|
70
|
+
// 2
|
|
71
|
+
const {
|
|
72
|
+
fullPackage
|
|
73
|
+
} = await this.createPackagesDefinition(param, config, files);
|
|
74
|
+
|
|
75
|
+
// 生产出带签名的rpk文件buffer
|
|
76
|
+
const signConfig = _SignUtil.default.getProjectSignConfig(param);
|
|
77
|
+
const rpkBuffer = await ZipUtil.buildProjectAndOutput(fullPackage, signConfig);
|
|
78
|
+
// 3
|
|
79
|
+
return this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
80
|
+
}
|
|
81
|
+
static getFileName(param, config, ext) {
|
|
82
|
+
const {
|
|
83
|
+
mode,
|
|
84
|
+
buildNameFormat
|
|
85
|
+
} = param;
|
|
86
|
+
const {
|
|
87
|
+
package: packageName
|
|
88
|
+
} = config;
|
|
89
|
+
return [packageName, mode === _CompileMode.default.DEVELOPMENT ? 'debug' : 'release', buildNameFormat === _BuildNameFormatType.default.ORIGINAL ? '' : config.versionName, ext].filter(Boolean).join('.');
|
|
90
|
+
}
|
|
91
|
+
static async packageToZipBuffer(target) {
|
|
92
|
+
const {
|
|
93
|
+
resourceList,
|
|
94
|
+
comment
|
|
95
|
+
} = target;
|
|
96
|
+
const packageFileList = resourceList.map(item => {
|
|
97
|
+
return {
|
|
98
|
+
path: item.fileBuildPath,
|
|
99
|
+
content: item.fileContentBuffer
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
return await this.createZipBufferFromFileList(packageFileList, comment);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param buffer
|
|
108
|
+
* @param param
|
|
109
|
+
* @param fileName
|
|
110
|
+
*
|
|
111
|
+
* @returns 生成的文件名
|
|
112
|
+
*/
|
|
113
|
+
static async generateDistFile(buffer, param, fileName) {
|
|
114
|
+
const {
|
|
115
|
+
releasePath,
|
|
116
|
+
projectPath
|
|
117
|
+
} = param;
|
|
118
|
+
const filePath = _path.default.join(projectPath, releasePath, fileName);
|
|
119
|
+
_fsExtra.default.outputFileSync(filePath, buffer);
|
|
120
|
+
_sharedUtils.ColorConsole.success(`Project build and generate files:${fileName}`);
|
|
121
|
+
return fileName;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 根据文件列表创建 zip 的 Buffer
|
|
126
|
+
* @param fileList 文件列表
|
|
127
|
+
* @param comment zip 的注释
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
static async createZipBufferFromFileList(fileList, comment) {
|
|
131
|
+
const zip = new _jszip.default();
|
|
132
|
+
fileList.forEach(item => {
|
|
133
|
+
zip.file(item.path, item.content);
|
|
134
|
+
});
|
|
135
|
+
return await zip.generateAsync({
|
|
136
|
+
...this.ZIP_OPTION,
|
|
137
|
+
comment
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 创建包,一个包对应一个 rpk 文件
|
|
143
|
+
* @param param
|
|
144
|
+
* @param config
|
|
145
|
+
* @param files
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
static async createPackagesDefinition(param, config, files) {
|
|
149
|
+
const {
|
|
150
|
+
projectPath,
|
|
151
|
+
outputPath
|
|
152
|
+
} = param;
|
|
153
|
+
const {
|
|
154
|
+
package: appPackage
|
|
155
|
+
} = config;
|
|
156
|
+
const comment = this.createComment(param);
|
|
157
|
+
const fullPackage = new _Package.default({
|
|
158
|
+
filePrefix: appPackage,
|
|
159
|
+
fileSuffix: 'rpk',
|
|
160
|
+
standalone: true,
|
|
161
|
+
comment: JSON.stringify(comment)
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// 写入文件
|
|
165
|
+
for (let fileBuildPath of files) {
|
|
166
|
+
const absPath = _path.default.join(projectPath, outputPath, fileBuildPath);
|
|
167
|
+
let fileContentBuffer = _fsExtra.default.readFileSync(absPath);
|
|
168
|
+
if (fileBuildPath === ZipUtil.CERT_PATH) {
|
|
169
|
+
let metaZip = await _jszip.default.loadAsync(fileContentBuffer);
|
|
170
|
+
fileContentBuffer = await metaZip.generateAsync({
|
|
171
|
+
...ZipUtil.ZIP_OPTION,
|
|
172
|
+
comment: null
|
|
198
173
|
});
|
|
199
|
-
|
|
174
|
+
}
|
|
175
|
+
const fileContentDigest = _sharedUtils.CommonUtil.calcDataDigest(fileContentBuffer);
|
|
176
|
+
const resourceInfo = {
|
|
177
|
+
fileBuildPath,
|
|
178
|
+
fileContentBuffer,
|
|
179
|
+
fileContentDigest
|
|
180
|
+
};
|
|
181
|
+
fullPackage.addResource(resourceInfo);
|
|
182
|
+
|
|
183
|
+
// 分包相关逻辑 todo
|
|
200
184
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
185
|
+
return {
|
|
186
|
+
fullPackage
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 获取有序的文件列表
|
|
192
|
+
*
|
|
193
|
+
* 打包后的文件夹生成vela 应用程序,需要先把文件排序,再进行压缩
|
|
194
|
+
*
|
|
195
|
+
* @see getPriorities 获取排序规则
|
|
196
|
+
*
|
|
197
|
+
* @param dist 打包后的文件目录的绝对路径
|
|
198
|
+
* @param param 打包参数
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
static getSortedFiles(dist, param, config) {
|
|
202
|
+
const priorities = this.getPriorities(config);
|
|
203
|
+
const getFileIndex = file => {
|
|
204
|
+
const result = priorities.findIndex(item => {
|
|
205
|
+
if (typeof item === 'string') {
|
|
206
|
+
return item === file;
|
|
207
|
+
}
|
|
208
|
+
return file.match(item);
|
|
209
|
+
});
|
|
210
|
+
if (result < 0) {
|
|
211
|
+
return Number.MAX_SAFE_INTEGER;
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
};
|
|
215
|
+
// 筛选中需要的文件并排序
|
|
216
|
+
// 1. 排除META-INF 目录下的文件
|
|
217
|
+
// 2. 生产环境排除 .map 文件
|
|
218
|
+
const mapReg = /\.map$/;
|
|
219
|
+
let result = _sharedUtils.FileUtil.readAlldirSync(dist);
|
|
220
|
+
result = result.filter(item => {
|
|
221
|
+
return !(item.startsWith(_UxCompileUtil.default.DIGEST_ZIP_DIR) || param.mode === _CompileMode.default.PRODUCTION && mapReg.test(item));
|
|
222
|
+
}).map(item => _path.default.relative(dist, item).split(_path.default.sep).join(_path.default.posix.sep));
|
|
223
|
+
result.sort((a, b) => {
|
|
224
|
+
const indexA = getFileIndex(a);
|
|
225
|
+
const indexB = getFileIndex(b);
|
|
226
|
+
return indexA - indexB;
|
|
227
|
+
});
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 根据 **固定规则**、**manifest.json入口配置**,获取压缩文件时使用的排序规则
|
|
233
|
+
*
|
|
234
|
+
* @param param
|
|
235
|
+
* @returns
|
|
236
|
+
*/
|
|
237
|
+
static getPriorities(config) {
|
|
238
|
+
const entrySkFiles = []; // todo
|
|
239
|
+
const {
|
|
240
|
+
entry
|
|
241
|
+
} = config.router;
|
|
242
|
+
const result = ['META-INF/CERT',
|
|
243
|
+
// 多语言配置文件要在 manifest 之前
|
|
244
|
+
/^i18n\/.+\.json$/i,
|
|
245
|
+
// 多终端配置文件如manifest-tv.json,也要在manifest之前,不然流式加载初始化的时候,会读不到对应的终端配置文件
|
|
246
|
+
/^manifest-\w+\.json$/, 'manifest.json', 'app.js', /page-chunks.json$/, /skeleton\/config\.json$/, ...entrySkFiles, new RegExp(`^${entry}/$`), new RegExp(`^${entry}/.+`), /^common\//i,
|
|
247
|
+
// 静态资源
|
|
248
|
+
/.+\.js/, 'META-INF/build.txt'];
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 创建打包的注释属性
|
|
254
|
+
*/
|
|
255
|
+
static createComment(param) {
|
|
256
|
+
const obj = {
|
|
257
|
+
originType: param.originType,
|
|
258
|
+
toolkit: require(_path.default.join(__dirname, '../../../../../package.json')).version,
|
|
259
|
+
timeStamp: new Date().toJSON(),
|
|
260
|
+
node: process.version,
|
|
261
|
+
platform: process.platform,
|
|
262
|
+
arch: process.arch,
|
|
263
|
+
component: true
|
|
264
|
+
};
|
|
265
|
+
return obj;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 生成rpk的最终的Buffer
|
|
270
|
+
*
|
|
271
|
+
* @description 使用证书对原始rpk包的 buffer 签名. 签名失败,返回原始包; 签名成功,返回新包
|
|
272
|
+
* @param fullPackage 原始包 buffer
|
|
273
|
+
* @param signConfig 证书信息
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
static async buildProjectAndOutput(target, signConfig) {
|
|
277
|
+
let result;
|
|
278
|
+
if (signConfig) {
|
|
279
|
+
const {
|
|
280
|
+
privatekey,
|
|
281
|
+
certificate
|
|
282
|
+
} = signConfig;
|
|
283
|
+
const fullPackageBuffer = await _SignUtil.default.signPackage(target, privatekey, certificate);
|
|
284
|
+
if (fullPackageBuffer === false) {
|
|
285
|
+
_sharedUtils.ColorConsole.throw('Fullpackage signature failed');
|
|
286
|
+
} else {
|
|
287
|
+
result = fullPackageBuffer;
|
|
288
|
+
}
|
|
243
289
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
*
|
|
247
|
-
* @description 使用证书对原始rpk包的 buffer 签名. 签名失败,返回原始包; 签名成功,返回新包
|
|
248
|
-
* @param fullPackage 原始包 buffer
|
|
249
|
-
* @param signConfig 证书信息
|
|
250
|
-
* @returns
|
|
251
|
-
*/
|
|
252
|
-
static buildProjectAndOutput(target, signConfig) {
|
|
253
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
let result;
|
|
255
|
-
if (signConfig) {
|
|
256
|
-
const { privatekey, certificate } = signConfig;
|
|
257
|
-
const fullPackageBuffer = yield SignUtil_1.default.signPackage(target, privatekey, certificate);
|
|
258
|
-
if (fullPackageBuffer === false) {
|
|
259
|
-
shared_utils_1.ColorConsole.throw('Fullpackage signature failed');
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
result = fullPackageBuffer;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (!result) {
|
|
266
|
-
result = yield this.packageToZipBuffer(target);
|
|
267
|
-
}
|
|
268
|
-
return result;
|
|
269
|
-
});
|
|
290
|
+
if (!result) {
|
|
291
|
+
result = await this.packageToZipBuffer(target);
|
|
270
292
|
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
271
295
|
}
|
|
272
|
-
|
|
273
|
-
ZipUtil.DIGEST_HASH_JSON = 'hash.json';
|
|
274
|
-
// 摘要文件夹
|
|
275
|
-
ZipUtil.META_PATH = 'META-INF';
|
|
276
|
-
// 文件摘要包(zip 文件)
|
|
277
|
-
ZipUtil.CERT_PATH = `${_a.META_PATH}/CERT`;
|
|
278
|
-
// 打包信息文件
|
|
279
|
-
ZipUtil.BUILD_FILE_PATH = `${_a.META_PATH}/build.txt`;
|
|
280
|
-
/**
|
|
281
|
-
* zip压缩参数
|
|
282
|
-
*/
|
|
283
|
-
ZipUtil.ZIP_OPTION = {
|
|
284
|
-
type: 'nodebuffer',
|
|
285
|
-
compression: 'DEFLATE',
|
|
286
|
-
compressionOptions: {
|
|
287
|
-
level: 9
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
exports.default = ZipUtil;
|
|
296
|
+
var _default = exports.default = ZipUtil;
|