@aiot-toolkit/aiotpack 2.0.2-beta.12 → 2.0.2-beta.14
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/{followWorks/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +3 -3
- package/lib/{followWorks/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +12 -12
- package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
- package/lib/afterWorks/ux/UxAfterWorks.js +26 -0
- package/lib/{preWorks/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +3 -3
- package/lib/{preWorks/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +6 -6
- package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
- package/lib/beforeWorks/ux/UxBeforeWorks.js +25 -0
- package/lib/compiler/interface/ISignConfig.d.ts +6 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +1 -1
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -0
- package/lib/compiler/javascript/vela/utils/Jsc.js +15 -3
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +14 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +20 -15
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +19 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +24 -9
- package/lib/config/UxConfig.d.ts +16 -2
- package/lib/config/UxConfig.js +44 -17
- package/lib/config/XtsConfig.d.ts +2 -2
- package/lib/config/XtsConfig.js +5 -5
- package/lib/utils/{PreWorkUtils.d.ts → BeforeCompileUtils.d.ts} +6 -6
- package/lib/utils/BeforeCompileUtils.js +103 -0
- package/lib/utils/ux/UxFileUtils.js +13 -11
- package/lib/utils/ux/UxLoaderUtils.js +1 -3
- package/package.json +12 -8
- package/lib/utils/PreWorkUtils.js +0 -104
- /package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +0 -0
- /package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +0 -0
- /package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +0 -0
- /package/lib/{followWorks → afterCompile}/xts/generateRpk.js +0 -0
- /package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +0 -0
- /package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +0 -0
- /package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +0 -0
- /package/lib/{preWorks → beforeCompile}/xts/preInstall.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FollowWork } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* UxAfterCompile
|
|
5
5
|
*/
|
|
6
|
-
declare class
|
|
6
|
+
declare class UxAfterCompile {
|
|
7
7
|
static webpack: FollowWork<IJavascriptCompileOption>;
|
|
8
8
|
static protobuf: FollowWork<IJavascriptCompileOption>;
|
|
9
9
|
static jsc: FollowWork<IJavascriptCompileOption>;
|
|
@@ -33,4 +33,4 @@ declare class UxFollowWorks {
|
|
|
33
33
|
*/
|
|
34
34
|
static symlinkNodeModule: FollowWork<IJavascriptCompileOption>;
|
|
35
35
|
}
|
|
36
|
-
export default
|
|
36
|
+
export default UxAfterCompile;
|
|
@@ -25,12 +25,12 @@ const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/
|
|
|
25
25
|
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
26
26
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* UxAfterCompile
|
|
29
29
|
*/
|
|
30
|
-
class
|
|
30
|
+
class UxAfterCompile {
|
|
31
31
|
}
|
|
32
|
-
_a =
|
|
33
|
-
|
|
32
|
+
_a = UxAfterCompile;
|
|
33
|
+
UxAfterCompile.webpack = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
return new JavascriptCompiler_1.default()
|
|
35
35
|
.compile(Object.assign(Object.assign({ projectPath: path_1.default.join(context.projectPath, context.output), mode: CompileMode_1.default.DEVELOPMENT, devtool: false, platform: 'vela' }, JavascriptDefaultCompileOption_1.default), compilerOption))
|
|
36
36
|
.then(() => {
|
|
@@ -68,17 +68,17 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
UxAfterCompile.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
72
|
if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
|
|
73
73
|
BinaryPlugin.createBinFiles();
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
-
|
|
77
|
-
if (compilerOption && compilerOption.
|
|
76
|
+
UxAfterCompile.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
if (compilerOption && compilerOption.enableJsc === true) {
|
|
78
78
|
return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
|
|
81
|
+
UxAfterCompile.toRpk = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
82
|
if (compilerOption) {
|
|
83
83
|
return ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
|
|
84
84
|
}
|
|
@@ -89,7 +89,7 @@ UxFollowWorks.toRpk = (context, config, compilerOption) => __awaiter(void 0, voi
|
|
|
89
89
|
* @param config
|
|
90
90
|
* @param compilerOption
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
UxAfterCompile.copyResource = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
93
|
const genDeviceManifests = (compilerOption) => {
|
|
94
94
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
95
95
|
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
@@ -206,7 +206,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
206
206
|
* @param config
|
|
207
207
|
* @param compilerOption
|
|
208
208
|
*/
|
|
209
|
-
|
|
209
|
+
UxAfterCompile.moveBackResult = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
210
210
|
if (!compilerOption) {
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
@@ -232,7 +232,7 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
|
|
|
232
232
|
* @param config
|
|
233
233
|
* @param compilerOption
|
|
234
234
|
*/
|
|
235
|
-
|
|
235
|
+
UxAfterCompile.symlinkNodeModule = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
236
236
|
if (!compilerOption) {
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
@@ -250,4 +250,4 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
|
|
|
250
250
|
throw new Error(`${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}. Please check whether the file system of the current disk supports the creation of soft links.`);
|
|
251
251
|
}
|
|
252
252
|
});
|
|
253
|
-
exports.default =
|
|
253
|
+
exports.default = UxAfterCompile;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const file_lane_1 = require("file-lane");
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
class UxAfterWorks {
|
|
18
|
+
static cleanOutput(context) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
21
|
+
// 建议在支持es写法后使用del库替换fs
|
|
22
|
+
fs_extra_1.default.removeSync(outputPath);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = UxAfterWorks;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PreWork } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* UxBeforeCompile
|
|
5
5
|
*/
|
|
6
|
-
declare class
|
|
6
|
+
declare class UxBeforeCompile {
|
|
7
7
|
static validateManifest: PreWork<IJavascriptCompileOption>;
|
|
8
8
|
static validateSitemap: PreWork<IJavascriptCompileOption>;
|
|
9
9
|
}
|
|
10
|
-
export default
|
|
10
|
+
export default UxBeforeCompile;
|
|
@@ -15,17 +15,17 @@ var _a;
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* UxBeforeCompile
|
|
19
19
|
*/
|
|
20
|
-
class
|
|
20
|
+
class UxBeforeCompile {
|
|
21
21
|
}
|
|
22
|
-
_a =
|
|
23
|
-
|
|
22
|
+
_a = UxBeforeCompile;
|
|
23
|
+
UxBeforeCompile.validateManifest = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
const { projectPath } = context;
|
|
25
25
|
return UxFileUtils_1.default.validateManifest(projectPath);
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
UxBeforeCompile.validateSitemap = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
const { projectPath } = context;
|
|
29
29
|
UxFileUtils_1.default.validateSitemap(projectPath);
|
|
30
30
|
});
|
|
31
|
-
exports.default =
|
|
31
|
+
exports.default = UxBeforeCompile;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const del_1 = __importDefault(require("del"));
|
|
16
|
+
const file_lane_1 = require("file-lane");
|
|
17
|
+
class UxBeforeWorks {
|
|
18
|
+
static cleanOutput(context) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
21
|
+
yield (0, del_1.default)(outputPath, { force: true });
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = UxBeforeWorks;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -16,9 +25,12 @@ class Jsc {
|
|
|
16
25
|
jsc() {
|
|
17
26
|
const { projectPath, buildPath } = this;
|
|
18
27
|
return shared_utils_1.CommonUtil.requireNodeModule(projectPath, `@aiot-toolkit/jsc`)
|
|
19
|
-
.then((module) => {
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
.then((module) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const msg = yield module.default(buildPath);
|
|
30
|
+
if (msg) {
|
|
31
|
+
shared_utils_1.ColorConsole.success({ word: 'jsc command' }, msg);
|
|
32
|
+
}
|
|
33
|
+
}))
|
|
22
34
|
.then(() => {
|
|
23
35
|
return (0, del_1.default)(`${buildPath}/**/*.js`, { force: true });
|
|
24
36
|
})
|
|
@@ -35,6 +35,12 @@ declare class ZipUtil {
|
|
|
35
35
|
private static getFileName;
|
|
36
36
|
private static packageToZipBuffer;
|
|
37
37
|
private static generateDistFile;
|
|
38
|
+
/**
|
|
39
|
+
* 根据文件列表创建 zip 的 Buffer
|
|
40
|
+
* @param fileList 文件列表
|
|
41
|
+
* @param comment zip 的注释
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
38
44
|
static createZipBufferFromFileList(fileList: {
|
|
39
45
|
path: string;
|
|
40
46
|
content: string | Buffer;
|
|
@@ -70,6 +76,14 @@ declare class ZipUtil {
|
|
|
70
76
|
* 创建打包的注释属性
|
|
71
77
|
*/
|
|
72
78
|
static createComment(param: IJavascriptCompileOption): Dictionary<any>;
|
|
79
|
+
/**
|
|
80
|
+
* 生成rpk的最终的Buffer
|
|
81
|
+
*
|
|
82
|
+
* @description 使用证书对原始rpk包的 buffer 签名. 签名失败,返回原始包; 签名成功,返回新包
|
|
83
|
+
* @param fullPackage 原始包 buffer
|
|
84
|
+
* @param signConfig 证书信息
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
73
87
|
private static buildProjectAndOutput;
|
|
74
88
|
}
|
|
75
89
|
export default ZipUtil;
|
|
@@ -57,9 +57,7 @@ class ZipUtil {
|
|
|
57
57
|
const zipBuffer = yield this.packageToZipBuffer(fullPackage);
|
|
58
58
|
// 生产出带签名的rpk文件buffer
|
|
59
59
|
const signConfig = SignUtil_1.default.getProjectSignConfig(param);
|
|
60
|
-
const
|
|
61
|
-
// IDE 扫码预览打包 todo
|
|
62
|
-
// IDE 重置包名
|
|
60
|
+
const rpkBuffer = yield ZipUtil.buildProjectAndOutput(zipBuffer, signConfig);
|
|
63
61
|
// 3
|
|
64
62
|
this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
65
63
|
});
|
|
@@ -96,6 +94,12 @@ class ZipUtil {
|
|
|
96
94
|
shared_utils_1.ColorConsole.success(`Project build and generate files:${fileName}`);
|
|
97
95
|
});
|
|
98
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* 根据文件列表创建 zip 的 Buffer
|
|
99
|
+
* @param fileList 文件列表
|
|
100
|
+
* @param comment zip 的注释
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
99
103
|
static createZipBufferFromFileList(fileList, comment) {
|
|
100
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
105
|
const zip = new jszip_1.default();
|
|
@@ -229,27 +233,28 @@ class ZipUtil {
|
|
|
229
233
|
};
|
|
230
234
|
return obj;
|
|
231
235
|
}
|
|
232
|
-
|
|
236
|
+
/**
|
|
237
|
+
* 生成rpk的最终的Buffer
|
|
238
|
+
*
|
|
239
|
+
* @description 使用证书对原始rpk包的 buffer 签名. 签名失败,返回原始包; 签名成功,返回新包
|
|
240
|
+
* @param fullPackage 原始包 buffer
|
|
241
|
+
* @param signConfig 证书信息
|
|
242
|
+
* @returns
|
|
243
|
+
*/
|
|
244
|
+
static buildProjectAndOutput(zipBuffer, signConfig) {
|
|
233
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
|
|
235
|
-
// 2. 是否需要增加签名内容
|
|
246
|
+
let result = zipBuffer;
|
|
236
247
|
if (signConfig) {
|
|
237
248
|
const { privatekey, certificate } = signConfig;
|
|
238
|
-
|
|
239
|
-
const fullPackageBuffer = yield SignUtil_1.default.signZipBufferForPackage(fullPackage, privatekey, certificate);
|
|
249
|
+
const fullPackageBuffer = yield SignUtil_1.default.signZipBufferForPackage(zipBuffer, privatekey, certificate);
|
|
240
250
|
if (fullPackageBuffer === false) {
|
|
241
251
|
shared_utils_1.ColorConsole.throw('Fullpackage signature failed');
|
|
242
252
|
}
|
|
243
253
|
else {
|
|
244
|
-
|
|
254
|
+
result = fullPackageBuffer;
|
|
245
255
|
}
|
|
246
256
|
}
|
|
247
|
-
|
|
248
|
-
// 4. 生成rpks:不需要META和签名
|
|
249
|
-
// 5. 返回
|
|
250
|
-
return {
|
|
251
|
-
rpkBuffer: fullPackage
|
|
252
|
-
};
|
|
257
|
+
return result;
|
|
253
258
|
});
|
|
254
259
|
}
|
|
255
260
|
}
|
|
@@ -13,15 +13,34 @@ declare class SignUtil {
|
|
|
13
13
|
privatekey: Buffer;
|
|
14
14
|
certificate: Buffer;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* 对二进制zipBuffer签名
|
|
18
|
+
*
|
|
19
|
+
* 1. 解压 zip 流,获取文件列表
|
|
20
|
+
* 2. 对`META-INF/CERT`做签名,并生成新的`META-INF/CERT` buffer
|
|
21
|
+
* 3. "新`META-INF/CERT` + 其它文件"生成新的 zipBuffer
|
|
22
|
+
* 4. 对“新zipBuffer”,做整体签名
|
|
23
|
+
* @param zipBuffer
|
|
24
|
+
* @param privatekey
|
|
25
|
+
* @param certificate
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
16
28
|
static signZipBufferForPackage(zipBuffer: Buffer, privatekey: Buffer, certificate: Buffer): Promise<false | Buffer>;
|
|
17
29
|
/**
|
|
18
30
|
* 根据ZIP流获取文件实例
|
|
31
|
+
*
|
|
32
|
+
* 1. zipbuffer转换为JSZip对象
|
|
33
|
+
* 2. 提取文件列表,并生成每个文件的 buffer
|
|
34
|
+
* 3. 创建获取文件buffer的函数
|
|
35
|
+
*
|
|
19
36
|
* @param zipBuffer
|
|
20
37
|
* @returns
|
|
21
38
|
*/
|
|
22
39
|
private static createFileListFromZipBuffer;
|
|
23
40
|
/**
|
|
24
41
|
* 为 zip buffer 签名,返回签名后的buffer
|
|
42
|
+
*
|
|
43
|
+
* @description 根据zipBuffer + zip的文件列表 + 私钥 + 证书,对 zipbuffer 签名
|
|
25
44
|
* @param fileBuffer
|
|
26
45
|
* @param files
|
|
27
46
|
* @param privatekey
|
|
@@ -96,14 +96,26 @@ class SignUtil {
|
|
|
96
96
|
}
|
|
97
97
|
return signConfig;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* 对二进制zipBuffer签名
|
|
101
|
+
*
|
|
102
|
+
* 1. 解压 zip 流,获取文件列表
|
|
103
|
+
* 2. 对`META-INF/CERT`做签名,并生成新的`META-INF/CERT` buffer
|
|
104
|
+
* 3. "新`META-INF/CERT` + 其它文件"生成新的 zipBuffer
|
|
105
|
+
* 4. 对“新zipBuffer”,做整体签名
|
|
106
|
+
* @param zipBuffer
|
|
107
|
+
* @param privatekey
|
|
108
|
+
* @param certificate
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
99
111
|
static signZipBufferForPackage(zipBuffer, privatekey, certificate) {
|
|
100
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
// 1
|
|
113
|
+
// 1
|
|
102
114
|
const zipInstWrap = yield SignUtil.createFileListFromZipBuffer(zipBuffer);
|
|
103
|
-
// 摘要
|
|
115
|
+
// 摘要 和 文件列表
|
|
104
116
|
const fileDigestHash = [];
|
|
105
117
|
const fileList = [];
|
|
106
|
-
// 2.
|
|
118
|
+
// 2.1
|
|
107
119
|
const metaBuffer = zipInstWrap.getFileBuffer(ZipUtil_1.default.CERT_PATH);
|
|
108
120
|
if (metaBuffer) {
|
|
109
121
|
const metaHash = {
|
|
@@ -126,7 +138,7 @@ class SignUtil {
|
|
|
126
138
|
});
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
|
-
//
|
|
141
|
+
// 2.2
|
|
130
142
|
const files = zipInstWrap.fileList;
|
|
131
143
|
files.filter(SignUtil.fileFilter).map((item) => {
|
|
132
144
|
fileList.push(item);
|
|
@@ -148,6 +160,11 @@ class SignUtil {
|
|
|
148
160
|
}
|
|
149
161
|
/**
|
|
150
162
|
* 根据ZIP流获取文件实例
|
|
163
|
+
*
|
|
164
|
+
* 1. zipbuffer转换为JSZip对象
|
|
165
|
+
* 2. 提取文件列表,并生成每个文件的 buffer
|
|
166
|
+
* 3. 创建获取文件buffer的函数
|
|
167
|
+
*
|
|
151
168
|
* @param zipBuffer
|
|
152
169
|
* @returns
|
|
153
170
|
*/
|
|
@@ -169,17 +186,15 @@ class SignUtil {
|
|
|
169
186
|
comment: zipInst.comment,
|
|
170
187
|
getFileBuffer(path) {
|
|
171
188
|
const buffer = fileList.find((item) => item.path === path);
|
|
172
|
-
|
|
173
|
-
if (buffer) {
|
|
174
|
-
content = buffer.content;
|
|
175
|
-
}
|
|
176
|
-
return content;
|
|
189
|
+
return buffer === null || buffer === void 0 ? void 0 : buffer.content;
|
|
177
190
|
}
|
|
178
191
|
};
|
|
179
192
|
});
|
|
180
193
|
}
|
|
181
194
|
/**
|
|
182
195
|
* 为 zip buffer 签名,返回签名后的buffer
|
|
196
|
+
*
|
|
197
|
+
* @description 根据zipBuffer + zip的文件列表 + 私钥 + 证书,对 zipbuffer 签名
|
|
183
198
|
* @param fileBuffer
|
|
184
199
|
* @param files
|
|
185
200
|
* @param privatekey
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -5,16 +5,30 @@ import PngLoader from '../loader/ux/PngLoader';
|
|
|
5
5
|
import AppUxLoader from '../loader/ux/vela/AppUxLoader';
|
|
6
6
|
import HmlLoader from '../loader/ux/vela/HmlLoader';
|
|
7
7
|
import UxLoader from '../loader/ux/vela/UxLoader';
|
|
8
|
+
import UxBeforeWorks from '../beforeWorks/ux/UxBeforeWorks';
|
|
9
|
+
import UxAfterWorks from '../afterWorks/ux/UxAfterWorks';
|
|
8
10
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
9
11
|
readonly projectPath: string;
|
|
10
12
|
constructor(projectPath: string);
|
|
13
|
+
/**
|
|
14
|
+
* 1. 取项目中所有的真实文件
|
|
15
|
+
* 1.1 无entryFileList时,
|
|
16
|
+
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
17
|
+
* 2. 返回符合条件的文件列表
|
|
18
|
+
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
19
|
+
* @param entryFileList
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
collectFile: (entryFileList?: string[]) => string[];
|
|
11
23
|
exclude: (RegExp | ((filePath: string) => boolean))[];
|
|
12
24
|
get output(): string;
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
beforeWorks: (typeof UxBeforeWorks.cleanOutput)[];
|
|
26
|
+
beforeCompile: import("file-lane").PreWork<IJavascriptCompileOption>[];
|
|
27
|
+
afterCompile: {
|
|
15
28
|
worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
|
|
16
29
|
workerDescribe: string;
|
|
17
30
|
}[];
|
|
31
|
+
afterWorks: (typeof UxAfterWorks.cleanOutput)[];
|
|
18
32
|
watchIgnores: (string | RegExp)[];
|
|
19
33
|
/**
|
|
20
34
|
* 通过项目类型,返回模块配置
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -7,18 +7,43 @@ const parser_1 = require("@aiot-toolkit/parser");
|
|
|
7
7
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
|
|
11
10
|
const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
|
|
12
11
|
const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
|
|
13
12
|
const AppUxLoader_1 = __importDefault(require("../loader/ux/vela/AppUxLoader"));
|
|
14
13
|
const HmlLoader_1 = __importDefault(require("../loader/ux/vela/HmlLoader"));
|
|
15
14
|
const UxLoader_1 = __importDefault(require("../loader/ux/vela/UxLoader"));
|
|
16
|
-
const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
|
|
17
|
-
const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
|
|
18
15
|
const UxLoader_2 = __importDefault(require("../loader/ux/android/UxLoader"));
|
|
16
|
+
const UxBeforeWorks_1 = __importDefault(require("../beforeWorks/ux/UxBeforeWorks"));
|
|
17
|
+
const UxAfterWorks_1 = __importDefault(require("../afterWorks/ux/UxAfterWorks"));
|
|
18
|
+
const UxAfterCompile_1 = __importDefault(require("../afterCompile/ux/UxAfterCompile"));
|
|
19
|
+
const UxBeforeCompile_1 = __importDefault(require("../beforeCompile/ux/UxBeforeCompile"));
|
|
20
|
+
const BeforeCompileUtils_1 = __importDefault(require("../utils/BeforeCompileUtils"));
|
|
19
21
|
class UxConfig {
|
|
20
22
|
constructor(projectPath) {
|
|
21
23
|
this.projectPath = projectPath;
|
|
24
|
+
/**
|
|
25
|
+
* 1. 取项目中所有的真实文件
|
|
26
|
+
* 1.1 无entryFileList时,
|
|
27
|
+
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
28
|
+
* 2. 返回符合条件的文件列表
|
|
29
|
+
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
30
|
+
* @param entryFileList
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
this.collectFile = (entryFileList) => {
|
|
34
|
+
// 取项目中所有的真实文件
|
|
35
|
+
const getProjectFiles = () => {
|
|
36
|
+
const projectPath = this.projectPath;
|
|
37
|
+
let files = shared_utils_1.FileUtil.readAlldirSync(projectPath, undefined, this.exclude);
|
|
38
|
+
return files;
|
|
39
|
+
};
|
|
40
|
+
// 2.
|
|
41
|
+
if ((entryFileList === null || entryFileList === void 0 ? void 0 : entryFileList.findIndex((file) => !/\.(ux|json|js)$/.test(file))) === -1) {
|
|
42
|
+
return entryFileList.filter((filePath) => shared_utils_1.FileUtil.include(filePath, undefined, this.exclude));
|
|
43
|
+
}
|
|
44
|
+
// 1.
|
|
45
|
+
return getProjectFiles();
|
|
46
|
+
};
|
|
22
47
|
this.exclude = [
|
|
23
48
|
/node_modules/,
|
|
24
49
|
/dist/,
|
|
@@ -36,43 +61,45 @@ class UxConfig {
|
|
|
36
61
|
return false;
|
|
37
62
|
}
|
|
38
63
|
];
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
this.beforeWorks = [UxBeforeWorks_1.default.cleanOutput];
|
|
65
|
+
this.beforeCompile = [
|
|
66
|
+
UxBeforeCompile_1.default.validateManifest,
|
|
67
|
+
UxBeforeCompile_1.default.validateSitemap,
|
|
68
|
+
BeforeCompileUtils_1.default.clean,
|
|
69
|
+
BeforeCompileUtils_1.default.getEntries,
|
|
70
|
+
BeforeCompileUtils_1.default.getGlobalVar
|
|
45
71
|
];
|
|
46
|
-
this.
|
|
72
|
+
this.afterCompile = [
|
|
47
73
|
{
|
|
48
|
-
worker:
|
|
74
|
+
worker: UxAfterCompile_1.default.symlinkNodeModule,
|
|
49
75
|
workerDescribe: 'Create a soft link to the node_modules folder'
|
|
50
76
|
},
|
|
51
77
|
{
|
|
52
|
-
worker:
|
|
78
|
+
worker: UxAfterCompile_1.default.webpack,
|
|
53
79
|
workerDescribe: 'Compile the project using webpack'
|
|
54
80
|
},
|
|
55
81
|
{
|
|
56
|
-
worker:
|
|
82
|
+
worker: UxAfterCompile_1.default.copyResource,
|
|
57
83
|
workerDescribe: 'Copy resource files'
|
|
58
84
|
},
|
|
59
85
|
{
|
|
60
|
-
worker:
|
|
86
|
+
worker: UxAfterCompile_1.default.jsc,
|
|
61
87
|
workerDescribe: 'Generate jsc bytecode'
|
|
62
88
|
},
|
|
63
89
|
{
|
|
64
|
-
worker:
|
|
90
|
+
worker: UxAfterCompile_1.default.protobuf,
|
|
65
91
|
workerDescribe: 'Generate protobuf json'
|
|
66
92
|
},
|
|
67
93
|
{
|
|
68
|
-
worker:
|
|
94
|
+
worker: UxAfterCompile_1.default.toRpk,
|
|
69
95
|
workerDescribe: 'Package the project into an RPK file'
|
|
70
96
|
},
|
|
71
97
|
{
|
|
72
|
-
worker:
|
|
98
|
+
worker: UxAfterCompile_1.default.moveBackResult,
|
|
73
99
|
workerDescribe: 'Migrate temporary project'
|
|
74
100
|
}
|
|
75
101
|
];
|
|
102
|
+
this.afterWorks = [UxAfterWorks_1.default.cleanOutput];
|
|
76
103
|
this.watchIgnores = [/node_modules/, '/build/', '/dist/'];
|
|
77
104
|
}
|
|
78
105
|
get output() {
|
|
@@ -12,8 +12,8 @@ declare class XtsConfig implements IFileLaneConfig {
|
|
|
12
12
|
loader: (typeof XtsLoader)[];
|
|
13
13
|
}[];
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
beforeCompile: PreWork[];
|
|
16
|
+
afterCompile: {
|
|
17
17
|
worker: import("file-lane").FollowWork<import("..").IXtsCompileOptions>;
|
|
18
18
|
}[];
|
|
19
19
|
}
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const entryTemplate_1 = require("../
|
|
7
|
-
const generateRpk_1 = require("../
|
|
8
|
-
const ts2wasm_1 = require("../
|
|
6
|
+
const entryTemplate_1 = require("../afterCompile/xts/entryTemplate");
|
|
7
|
+
const generateRpk_1 = require("../afterCompile/xts/generateRpk");
|
|
8
|
+
const ts2wasm_1 = require("../afterCompile/xts/ts2wasm");
|
|
9
9
|
const XtsLoader_1 = __importDefault(require("../loader/xts/XtsLoader"));
|
|
10
10
|
/**
|
|
11
11
|
* XtsConfig
|
|
@@ -22,8 +22,8 @@ class XtsConfig {
|
|
|
22
22
|
}
|
|
23
23
|
]
|
|
24
24
|
};
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
25
|
+
this.beforeCompile = [];
|
|
26
|
+
this.afterCompile = [
|
|
27
27
|
{
|
|
28
28
|
worker: entryTemplate_1.generateEntryFile
|
|
29
29
|
},
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreWork } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* BeforeCompileUtils
|
|
5
5
|
*/
|
|
6
|
-
declare class
|
|
6
|
+
declare class BeforeCompileUtils {
|
|
7
7
|
/**
|
|
8
8
|
* 获取ux项目的路由入口
|
|
9
9
|
* @param context
|
|
10
10
|
* @param fileList
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
static getEntries
|
|
13
|
+
static getEntries: PreWork<IJavascriptCompileOption>;
|
|
14
14
|
static clean: PreWork<IJavascriptCompileOption>;
|
|
15
15
|
/**
|
|
16
16
|
* 获取项目的全局样式变量配置
|
|
17
17
|
* @param context
|
|
18
18
|
*/
|
|
19
|
-
static getGlobalVar
|
|
19
|
+
static getGlobalVar: PreWork<IJavascriptCompileOption>;
|
|
20
20
|
}
|
|
21
|
-
export default
|
|
21
|
+
export default BeforeCompileUtils;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
17
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
+
const del_1 = __importDefault(require("del"));
|
|
19
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const TranslateCache_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/TranslateCache"));
|
|
22
|
+
const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
|
|
23
|
+
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
24
|
+
/**
|
|
25
|
+
* BeforeCompileUtils
|
|
26
|
+
*/
|
|
27
|
+
class BeforeCompileUtils {
|
|
28
|
+
}
|
|
29
|
+
_a = BeforeCompileUtils;
|
|
30
|
+
/**
|
|
31
|
+
* 获取ux项目的路由入口
|
|
32
|
+
* @param context
|
|
33
|
+
* @param fileList
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
BeforeCompileUtils.getEntries = (context, fileList, config, compilerOption) => {
|
|
37
|
+
const { projectPath } = context;
|
|
38
|
+
const srcPath = path_1.default.join(projectPath, compilerOption.sourceRoot);
|
|
39
|
+
// 判断路径是否真实存在
|
|
40
|
+
const manifestContent = UxFileUtils_1.default.getMainfestInfo(projectPath);
|
|
41
|
+
// 存储entries
|
|
42
|
+
let entryList = [];
|
|
43
|
+
const { router } = manifestContent;
|
|
44
|
+
if (router) {
|
|
45
|
+
const { pages } = router;
|
|
46
|
+
if (pages) {
|
|
47
|
+
Object.keys(pages).map((page) => {
|
|
48
|
+
const pageContent = pages[page];
|
|
49
|
+
const entryDir = path_1.default.join(srcPath, page);
|
|
50
|
+
const entryPages = parser_1.ExtensionConfig.TEMPLATES.map((item) => `${pageContent.component}${item}`);
|
|
51
|
+
const entry = entryPages.find((item) => fs_extra_1.default.existsSync(path_1.default.join(entryDir, item)));
|
|
52
|
+
if (entry) {
|
|
53
|
+
entryList.push(path_1.default.join(entryDir, entry));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// 路径不存在
|
|
57
|
+
shared_utils_1.ColorConsole.throw(`### manifest ### path '${entryDir}/${entryPages.join(' | ')}' does not exist`);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// 没有pages配置
|
|
63
|
+
shared_utils_1.ColorConsole.throw(`### manifest ### No pages configuration`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// 没有router配置
|
|
68
|
+
shared_utils_1.ColorConsole.throw(`### manifest ### No router configuration`);
|
|
69
|
+
}
|
|
70
|
+
context['entries'] = entryList;
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
};
|
|
73
|
+
BeforeCompileUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
if (compileOption) {
|
|
75
|
+
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
|
|
76
|
+
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
|
|
77
|
+
}
|
|
78
|
+
context.translateCache = new TranslateCache_1.default();
|
|
79
|
+
BinaryPlugin.reset();
|
|
80
|
+
BinaryPlugin.config = {
|
|
81
|
+
projectPath: context.projectPath,
|
|
82
|
+
outputProjectPath: path_1.default.join(context.projectPath, context.output),
|
|
83
|
+
source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
|
|
84
|
+
output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* 获取项目的全局样式变量配置
|
|
89
|
+
* @param context
|
|
90
|
+
*/
|
|
91
|
+
BeforeCompileUtils.getGlobalVar = (context, fileList, config, compilerOption) => {
|
|
92
|
+
const { projectPath } = context;
|
|
93
|
+
const filePath = path_1.default.join(projectPath, compilerOption.sourceRoot, 'globalVar.json');
|
|
94
|
+
let globalVar = {};
|
|
95
|
+
// 判断文件是否存在
|
|
96
|
+
if (fs_extra_1.default.existsSync(filePath)) {
|
|
97
|
+
// 存在则取内容,否则内容为空
|
|
98
|
+
globalVar = fs_extra_1.default.readJSONSync(filePath);
|
|
99
|
+
}
|
|
100
|
+
context.globalVar = globalVar;
|
|
101
|
+
return Promise.resolve();
|
|
102
|
+
};
|
|
103
|
+
exports.default = BeforeCompileUtils;
|
|
@@ -4,7 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.UxFileUtils = void 0;
|
|
7
|
-
const
|
|
7
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
8
|
+
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
9
|
+
const ILog_1 = require("@aiot-toolkit/shared-utils/lib/interface/ILog");
|
|
8
10
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
11
|
const path_1 = __importDefault(require("path"));
|
|
10
12
|
const ManifestSchema_1 = __importDefault(require("./ManifestSchema"));
|
|
@@ -41,28 +43,28 @@ class UxFileUtils {
|
|
|
41
43
|
static validateManifest(projectPath, sourceRoot = 'src') {
|
|
42
44
|
const path = UxFileUtils.getManifestFilePath(projectPath, sourceRoot);
|
|
43
45
|
if (!fs_extra_1.default.existsSync(path)) {
|
|
44
|
-
|
|
46
|
+
ColorConsole_1.default.throw(`file is missing`, {
|
|
45
47
|
word: path,
|
|
46
|
-
style:
|
|
48
|
+
style: ColorConsole_1.default.getStyle(ILog_1.Loglevel.THROW)
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
const jsonData = this.getMainfestInfo(projectPath, sourceRoot);
|
|
50
52
|
const schema = ManifestSchema_1.default;
|
|
51
|
-
const errors =
|
|
53
|
+
const errors = CommonUtil_1.default.validateJson(jsonData, schema);
|
|
52
54
|
if (errors) {
|
|
53
|
-
|
|
55
|
+
ColorConsole_1.default.warn(`Manefest.json error: `, ...errors.map((item, index) => {
|
|
54
56
|
return {
|
|
55
57
|
word: `\r\n${index + 1}.${item.message}`,
|
|
56
58
|
style: item instanceof TypeError
|
|
57
|
-
?
|
|
58
|
-
:
|
|
59
|
+
? ColorConsole_1.default.getStyle(ILog_1.Loglevel.ERROR)
|
|
60
|
+
: ColorConsole_1.default.getStyle(ILog_1.Loglevel.WARN)
|
|
59
61
|
};
|
|
60
62
|
}));
|
|
61
63
|
const stop = Boolean(errors.find((item) => item instanceof TypeError));
|
|
62
64
|
if (stop) {
|
|
63
|
-
|
|
65
|
+
ColorConsole_1.default.throw({
|
|
64
66
|
word: `missing required content, program stoped`,
|
|
65
|
-
style:
|
|
67
|
+
style: ColorConsole_1.default.getStyle(ILog_1.Loglevel.THROW)
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -85,13 +87,13 @@ class UxFileUtils {
|
|
|
85
87
|
rules.forEach((item, index) => {
|
|
86
88
|
const page = item.page;
|
|
87
89
|
if (page !== '*' && !pages.includes(page)) {
|
|
88
|
-
|
|
90
|
+
ColorConsole_1.default.throw(`The ${index + 1}th item of sitemap rules is configured incorrectly, the page ${page} does not exist`);
|
|
89
91
|
}
|
|
90
92
|
return page;
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
catch (error) {
|
|
94
|
-
|
|
96
|
+
ColorConsole_1.default.warn(error === null || error === void 0 ? void 0 : error.toString());
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
}
|
|
@@ -42,7 +42,6 @@ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
|
42
42
|
const parse5 = __importStar(require("aiot-parse5"));
|
|
43
43
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
-
const ts_morph_1 = require("ts-morph");
|
|
46
45
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
47
46
|
const { extractFunctions } = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/protobufControl');
|
|
48
47
|
/**
|
|
@@ -58,7 +57,6 @@ class UxLoaderUtils {
|
|
|
58
57
|
*/
|
|
59
58
|
static compileUxToJavascript(file, context, isAppUx, compilerOption) {
|
|
60
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const project = new ts_morph_1.Project();
|
|
62
60
|
const logs = [];
|
|
63
61
|
const { path: filePath, content } = file;
|
|
64
62
|
const { name, ext } = path_1.default.parse(filePath);
|
|
@@ -131,7 +129,7 @@ class UxLoaderUtils {
|
|
|
131
129
|
`}`
|
|
132
130
|
];
|
|
133
131
|
};
|
|
134
|
-
const { targetTree, mapList, sourceMap } = yield new UxToTypescript_1.default(options,
|
|
132
|
+
const { targetTree, mapList, sourceMap } = yield new UxToTypescript_1.default(options, integrateFunction, compilerOption, context).translate(parserResult.ast, []);
|
|
135
133
|
const { code } = new generator_1.TypescriptGenerator().generate({
|
|
136
134
|
sourceFilePath: fullName,
|
|
137
135
|
targetFilePath: newFileName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.14",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,28 +19,32 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.2-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.2-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.2-beta.14",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.2-beta.14",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.2-beta.14",
|
|
24
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
|
+
"aiot-parse5": "^1.0.0",
|
|
25
27
|
"archiver": "^6.0.1",
|
|
26
28
|
"babel-loader": "^9.1.3",
|
|
27
|
-
"del": "^4.1.
|
|
29
|
+
"del": "^4.1.1",
|
|
28
30
|
"fast-glob": "^3.3.2",
|
|
29
|
-
"file-lane": "2.0.2-beta.
|
|
31
|
+
"file-lane": "2.0.2-beta.14",
|
|
30
32
|
"file-loader": "^6.2.0",
|
|
31
33
|
"fs-extra": "^11.2.0",
|
|
32
34
|
"jsrsasign": "^7.2.2",
|
|
33
35
|
"jszip": "^3.10.1",
|
|
34
|
-
"
|
|
36
|
+
"lodash": "^4.17.21",
|
|
37
|
+
"ts-morph": "^19.0.0",
|
|
35
38
|
"url-loader": "^4.1.1",
|
|
36
39
|
"webpack": "^5.89.0",
|
|
37
|
-
"webpack-bundle-analyzer": "^4.10.
|
|
40
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
38
41
|
"webpack-sources": "^3.2.3"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
44
|
+
"@types/archiver": "^6.0.2",
|
|
41
45
|
"@types/fs-extra": "^11.0.4",
|
|
42
46
|
"@types/jsrsasign": "^10.5.12",
|
|
43
47
|
"@types/webpack-sources": "^3.2.3"
|
|
44
48
|
},
|
|
45
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "c6093733d0267d2d1359fec0af8f7a253955e3e3"
|
|
46
50
|
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
var _a;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const parser_1 = require("@aiot-toolkit/parser");
|
|
17
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
-
const del_1 = __importDefault(require("del"));
|
|
19
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
|
-
const path_1 = __importDefault(require("path"));
|
|
21
|
-
const TranslateCache_1 = __importDefault(require("../../../parser/lib/ux/translate/vela/TranslateCache"));
|
|
22
|
-
const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
|
|
23
|
-
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
24
|
-
/**
|
|
25
|
-
* PreWorkUtils
|
|
26
|
-
*/
|
|
27
|
-
class PreWorkUtils {
|
|
28
|
-
/**
|
|
29
|
-
* 获取ux项目的路由入口
|
|
30
|
-
* @param context
|
|
31
|
-
* @param fileList
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
static getEntries(context) {
|
|
35
|
-
const { projectPath } = context;
|
|
36
|
-
const srcPath = path_1.default.join(projectPath, 'src');
|
|
37
|
-
// 判断路径是否真实存在
|
|
38
|
-
const manifestContent = UxFileUtils_1.default.getMainfestInfo(projectPath);
|
|
39
|
-
// 存储entries
|
|
40
|
-
let entryList = [];
|
|
41
|
-
const { router } = manifestContent;
|
|
42
|
-
if (router) {
|
|
43
|
-
const { pages } = router;
|
|
44
|
-
if (pages) {
|
|
45
|
-
Object.keys(pages).map((page) => {
|
|
46
|
-
const pageContent = pages[page];
|
|
47
|
-
const entryDir = path_1.default.join(srcPath, page);
|
|
48
|
-
const entryPages = parser_1.ExtensionConfig.TEMPLATES.map((item) => `${pageContent.component}${item}`);
|
|
49
|
-
const entry = entryPages.find((item) => fs_extra_1.default.existsSync(path_1.default.join(entryDir, item)));
|
|
50
|
-
if (entry) {
|
|
51
|
-
entryList.push(path_1.default.join(entryDir, entry));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// 路径不存在
|
|
55
|
-
shared_utils_1.ColorConsole.throw(`### manifest ### path '${entryDir}/${entryPages.join(' | ')}' does not exist`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// 没有pages配置
|
|
61
|
-
shared_utils_1.ColorConsole.throw(`### manifest ### No pages configuration`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
// 没有router配置
|
|
66
|
-
shared_utils_1.ColorConsole.throw(`### manifest ### No router configuration`);
|
|
67
|
-
}
|
|
68
|
-
context['entries'] = entryList;
|
|
69
|
-
return Promise.resolve();
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* 获取项目的全局样式变量配置
|
|
73
|
-
* @param context
|
|
74
|
-
*/
|
|
75
|
-
static getGlobalVar(context) {
|
|
76
|
-
const { projectPath } = context;
|
|
77
|
-
const filePath = path_1.default.join(projectPath, 'src', 'globalVar.json');
|
|
78
|
-
let globalVar = {};
|
|
79
|
-
// 判断文件是否存在
|
|
80
|
-
if (fs_extra_1.default.existsSync(filePath)) {
|
|
81
|
-
// 存在则取内容,否则内容为空
|
|
82
|
-
globalVar = fs_extra_1.default.readJSONSync(filePath);
|
|
83
|
-
}
|
|
84
|
-
context.globalVar = globalVar;
|
|
85
|
-
return Promise.resolve();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
_a = PreWorkUtils;
|
|
89
|
-
PreWorkUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
yield (0, del_1.default)(path_1.default.join(context.projectPath, context.output), { force: true });
|
|
91
|
-
if (compileOption) {
|
|
92
|
-
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
|
|
93
|
-
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
|
|
94
|
-
}
|
|
95
|
-
context.translateCache = new TranslateCache_1.default();
|
|
96
|
-
BinaryPlugin.reset();
|
|
97
|
-
BinaryPlugin.config = {
|
|
98
|
-
projectPath: context.projectPath,
|
|
99
|
-
outputProjectPath: path_1.default.join(context.projectPath, context.output),
|
|
100
|
-
source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
|
|
101
|
-
output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
exports.default = PreWorkUtils;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|