@aiot-toolkit/aiotpack 2.0.1-alpha.9 → 2.0.2-batchmanifest-beta.1
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/compiler/enum/CompileMode.js +0 -2
- package/lib/compiler/interface/ICompileParam.js +0 -2
- package/lib/compiler/interface/ICompiler.js +0 -2
- package/lib/compiler/interface/ISignConfig.js +0 -2
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +1 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +51 -18
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +1 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +5 -3
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +17 -5
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +0 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +0 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +1 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +11 -7
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +0 -2
- package/lib/compiler/javascript/vela/enum/EntryType.js +0 -2
- package/lib/compiler/javascript/vela/interface/IChunk.js +0 -2
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +3 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +0 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +0 -2
- package/lib/compiler/javascript/vela/model/Package.js +2 -4
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +19 -24
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +4 -7
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +3 -5
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +6 -8
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +14 -12
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +0 -2
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +59 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +20 -0
- package/lib/config/UxConfig.d.ts +8 -19
- package/lib/config/UxConfig.js +69 -13
- package/lib/config/XtsConfig.d.ts +5 -2
- package/lib/config/XtsConfig.js +12 -5
- package/lib/{utils → followWorks}/ux/UxFollowWorks.d.ts +1 -0
- package/lib/{utils → followWorks}/ux/UxFollowWorks.js +72 -14
- package/lib/followWorks/xts/entryTemplate.d.ts +2 -2
- package/lib/followWorks/xts/entryTemplate.js +61 -44
- package/lib/followWorks/xts/generateRpk.js +1 -3
- package/lib/followWorks/xts/ts2wasm.js +3 -14
- package/lib/index.js +0 -2
- package/lib/interface/ICompileOptions.d.ts +1 -1
- package/lib/interface/ICompileOptions.js +1 -3
- package/lib/interface/IDeviceList.js +0 -2
- package/lib/loader/ux/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/AppUxLoader.js +14 -4
- package/lib/loader/ux/HmlLoader.d.ts +24 -0
- package/lib/loader/ux/HmlLoader.js +63 -0
- package/lib/loader/ux/JsLoader.d.ts +11 -0
- package/lib/loader/ux/JsLoader.js +40 -0
- package/lib/loader/ux/PngLoader.js +4 -9
- package/lib/loader/ux/UxLoader.d.ts +2 -0
- package/lib/loader/ux/UxLoader.js +15 -4
- package/lib/loader/xts/XtsLoader.js +3 -9
- package/lib/preWorks/ux/UxPreWorks.d.ts +10 -0
- package/lib/preWorks/ux/UxPreWorks.js +31 -0
- package/lib/preWorks/xts/preInstall.js +4 -12
- package/lib/utils/PngUtils.js +0 -2
- package/lib/utils/PreWorkUtils.d.ts +5 -0
- package/lib/utils/PreWorkUtils.js +45 -12
- package/lib/utils/ux/ManifestSchema.d.ts +3 -0
- package/lib/utils/ux/ManifestSchema.js +207 -0
- package/lib/utils/ux/UxFileUtils.d.ts +21 -4
- package/lib/utils/ux/UxFileUtils.js +74 -5
- package/lib/utils/ux/UxLoaderUtils.d.ts +14 -7
- package/lib/utils/ux/UxLoaderUtils.js +144 -38
- package/lib/utils/xts/XtsFollowWorks.js +3 -12
- package/package.json +8 -10
- package/lib/compiler/enum/CompileMode.js.map +0 -1
- package/lib/compiler/interface/ICompileParam.js.map +0 -1
- package/lib/compiler/interface/ICompiler.js.map +0 -1
- package/lib/compiler/interface/ISignConfig.js.map +0 -1
- package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
- package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
- package/lib/config/UxConfig.js.map +0 -1
- package/lib/config/XtsConfig.js.map +0 -1
- package/lib/followWorks/xts/entryTemplate.js.map +0 -1
- package/lib/followWorks/xts/generateRpk.js.map +0 -1
- package/lib/followWorks/xts/ts2wasm.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface/ICompileOptions.js.map +0 -1
- package/lib/interface/IDeviceList.js.map +0 -1
- package/lib/loader/ux/AppUxLoader.js.map +0 -1
- package/lib/loader/ux/PngLoader.js.map +0 -1
- package/lib/loader/ux/UxLoader.js.map +0 -1
- package/lib/loader/xts/XtsLoader.js.map +0 -1
- package/lib/preWorks/xts/preInstall.js.map +0 -1
- package/lib/utils/PngUtils.js.map +0 -1
- package/lib/utils/PreWorkUtils.js.map +0 -1
- package/lib/utils/ux/UxFileUtils.js.map +0 -1
- package/lib/utils/ux/UxFollowWorks.js.map +0 -1
- package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
- package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
|
@@ -12,7 +12,7 @@ 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
|
|
15
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
16
16
|
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
17
17
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
18
18
|
const crypto_1 = __importDefault(require("crypto"));
|
|
@@ -44,14 +44,16 @@ class SignUtil {
|
|
|
44
44
|
case CompileMode_1.default.DEVELOPMENT:
|
|
45
45
|
privatekeyPath = path_1.default.join(__dirname, 'pem', 'private.pem');
|
|
46
46
|
certificatePath = path_1.default.join(__dirname, 'pem', 'certificate.pem');
|
|
47
|
+
ColorConsole_1.default.info(`User debug signature is enabled by project build`);
|
|
47
48
|
break;
|
|
48
49
|
case CompileMode_1.default.PRODUCTION:
|
|
49
50
|
privatekeyPath = path_1.default.join(projectPath, signRoot, 'private.pem');
|
|
50
51
|
certificatePath = path_1.default.join(projectPath, signRoot, 'certificate.pem');
|
|
52
|
+
ColorConsole_1.default.info(`release signature is enabled by project build`);
|
|
51
53
|
break;
|
|
52
54
|
default:
|
|
53
55
|
// 打印信息, 模式未定义
|
|
54
|
-
|
|
56
|
+
ColorConsole_1.default.error(`Error: mode ${mode} undefined`);
|
|
55
57
|
break;
|
|
56
58
|
}
|
|
57
59
|
// 检查路径是否真实存在
|
|
@@ -64,8 +66,8 @@ class SignUtil {
|
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
68
|
else {
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
+
// 结束程序
|
|
70
|
+
process.exit();
|
|
69
71
|
}
|
|
70
72
|
return signConfig;
|
|
71
73
|
}
|
|
@@ -85,8 +87,8 @@ class SignUtil {
|
|
|
85
87
|
};
|
|
86
88
|
const signedMetaBuffer = SignUtil.doSign(metaBuffer, [metaHash], privatekey, certificate);
|
|
87
89
|
if (signedMetaBuffer === false) {
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
+
// META-INF/CERT签名失败
|
|
91
|
+
ColorConsole_1.default.throw('META-INF/CERT signature failed');
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
92
94
|
fileList.push({
|
|
@@ -112,6 +114,10 @@ class SignUtil {
|
|
|
112
114
|
const newZipBuffer = yield ZipUtil_1.default.createZipBufferFromFileList(fileList, zipInstWrap.comment);
|
|
113
115
|
// 对新ZIP流重新签名
|
|
114
116
|
const signedZipBuffer = SignUtil.doSign(newZipBuffer, fileDigestHash, privatekey, certificate);
|
|
117
|
+
if (signedZipBuffer === false) {
|
|
118
|
+
// 签名失败
|
|
119
|
+
ColorConsole_1.default.throw('package signature failed');
|
|
120
|
+
}
|
|
115
121
|
return signedZipBuffer;
|
|
116
122
|
});
|
|
117
123
|
}
|
|
@@ -174,15 +180,13 @@ class SignUtil {
|
|
|
174
180
|
static unZipFiles(fileBuffer, files) {
|
|
175
181
|
// 1. 读取zip文件
|
|
176
182
|
if (!fileBuffer || fileBuffer.length <= 4) {
|
|
177
|
-
|
|
178
|
-
console.error('【SignUtil】Zip file open failed');
|
|
183
|
+
ColorConsole_1.default.error('Zip file open failed');
|
|
179
184
|
return false;
|
|
180
185
|
}
|
|
181
186
|
// 2. 检查文件格式是否正确
|
|
182
187
|
const fileMagic = fileBuffer.readInt32LE(0);
|
|
183
188
|
if (fileMagic !== 0x4034b50) {
|
|
184
|
-
|
|
185
|
-
console.error('【SignUtil】Zip file format is wrong');
|
|
189
|
+
ColorConsole_1.default.error('Zip file format is wrong');
|
|
186
190
|
return false;
|
|
187
191
|
}
|
|
188
192
|
// 3. 解析数据块
|
|
@@ -709,5 +713,3 @@ class SignUtil {
|
|
|
709
713
|
}
|
|
710
714
|
SignUtil.SigMagic = 'RPK Sig Block 42';
|
|
711
715
|
exports.default = SignUtil;
|
|
712
|
-
|
|
713
|
-
//# sourceMappingURL=SignUtil.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
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 SourceMapUtil_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/utils/SourceMapUtil"));
|
|
16
|
+
function addColSourceMap(source, map) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const callback = this.async();
|
|
19
|
+
if (!map) {
|
|
20
|
+
callback(null, source, map);
|
|
21
|
+
}
|
|
22
|
+
let { consumer, tempGenerator } = yield SourceMapUtil_1.default.createConsumerAndGenerator(JSON.stringify(map));
|
|
23
|
+
let recordLine = -1;
|
|
24
|
+
consumer.eachMapping((mapping) => {
|
|
25
|
+
if (mapping.source === consumer.sources[consumer.sources.length - 1]) {
|
|
26
|
+
if (recordLine < mapping.generatedLine &&
|
|
27
|
+
(mapping.generatedColumn !== 0 || mapping.originalColumn !== 0)) {
|
|
28
|
+
tempGenerator.addMapping({
|
|
29
|
+
generated: {
|
|
30
|
+
line: mapping.generatedLine,
|
|
31
|
+
column: 0
|
|
32
|
+
},
|
|
33
|
+
original: {
|
|
34
|
+
line: mapping.originalLine,
|
|
35
|
+
column: 0
|
|
36
|
+
},
|
|
37
|
+
source: mapping.source,
|
|
38
|
+
name: ''
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
recordLine = mapping.generatedLine;
|
|
42
|
+
}
|
|
43
|
+
tempGenerator.addMapping({
|
|
44
|
+
generated: {
|
|
45
|
+
line: mapping.generatedLine,
|
|
46
|
+
column: mapping.generatedColumn
|
|
47
|
+
},
|
|
48
|
+
original: {
|
|
49
|
+
line: mapping.originalLine,
|
|
50
|
+
column: mapping.originalColumn
|
|
51
|
+
},
|
|
52
|
+
source: mapping.source,
|
|
53
|
+
name: mapping.name
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
callback(null, source, JSON.parse(tempGenerator.toString()));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.default = addColSourceMap;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function extractMapData(source, map) {
|
|
9
|
+
const enterFilePath = this.resourcePath;
|
|
10
|
+
// 获取当前文件夹和文件名
|
|
11
|
+
const dirName = path_1.default.dirname(enterFilePath);
|
|
12
|
+
const fileName = path_1.default.basename(enterFilePath);
|
|
13
|
+
// 取到对应的map文件内容
|
|
14
|
+
const mapFilePath = path_1.default.join(dirName, fileName + '.map');
|
|
15
|
+
if (fs_1.default.existsSync(mapFilePath)) {
|
|
16
|
+
map = fs_1.default.readFileSync(mapFilePath, { encoding: 'utf-8' });
|
|
17
|
+
}
|
|
18
|
+
this.callback(null, source, map && JSON.parse(map));
|
|
19
|
+
}
|
|
20
|
+
exports.default = extractMapData;
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
-
import
|
|
4
|
-
import PngLoader from '../loader/ux/PngLoader';
|
|
5
|
-
import UxLoader from '../loader/ux/UxLoader';
|
|
3
|
+
import { IRule } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
6
4
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
7
5
|
readonly projectPath: string;
|
|
8
6
|
constructor(projectPath: string);
|
|
9
|
-
exclude: RegExp[];
|
|
10
|
-
include: RegExp[];
|
|
7
|
+
exclude: (RegExp | ((filePath: string) => boolean))[];
|
|
11
8
|
get output(): string;
|
|
12
9
|
module: {
|
|
13
|
-
rules:
|
|
14
|
-
test: string[];
|
|
15
|
-
loader: (typeof AppUxLoader)[];
|
|
16
|
-
exclude?: undefined;
|
|
17
|
-
} | {
|
|
18
|
-
test: RegExp[];
|
|
19
|
-
exclude: RegExp[];
|
|
20
|
-
loader: (typeof UxLoader)[];
|
|
21
|
-
} | {
|
|
22
|
-
test: RegExp[];
|
|
23
|
-
loader: (typeof PngLoader)[];
|
|
24
|
-
exclude?: undefined;
|
|
25
|
-
})[];
|
|
10
|
+
rules: IRule[];
|
|
26
11
|
};
|
|
27
12
|
preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
|
|
28
|
-
followWorks:
|
|
13
|
+
followWorks: {
|
|
14
|
+
worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>;
|
|
15
|
+
workerDescribe: string;
|
|
16
|
+
}[];
|
|
17
|
+
watchIgnores: RegExp[];
|
|
29
18
|
}
|
|
30
19
|
export default UxConfig;
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -5,15 +5,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const AppUxLoader_1 = __importDefault(require("../loader/ux/AppUxLoader"));
|
|
8
|
+
const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
|
|
8
9
|
const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
|
|
9
10
|
const UxLoader_1 = __importDefault(require("../loader/ux/UxLoader"));
|
|
10
11
|
const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
|
|
11
|
-
const UxFollowWorks_1 = __importDefault(require("../
|
|
12
|
+
const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
|
|
13
|
+
const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
|
|
14
|
+
const HmlLoader_1 = __importDefault(require("../loader/ux/HmlLoader"));
|
|
15
|
+
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
12
18
|
class UxConfig {
|
|
13
19
|
constructor(projectPath) {
|
|
14
20
|
this.projectPath = projectPath;
|
|
15
|
-
this.exclude = [
|
|
16
|
-
|
|
21
|
+
this.exclude = [
|
|
22
|
+
/node_modules/,
|
|
23
|
+
/dist/,
|
|
24
|
+
/build/,
|
|
25
|
+
(filePath) => {
|
|
26
|
+
// 如果 是 script, style文件,且同路径下存在同名 hml,则忽略
|
|
27
|
+
const { ext, name } = path_1.default.parse(filePath);
|
|
28
|
+
if (![...parser_1.ExtensionConfig.SCRIPTS, ...parser_1.ExtensionConfig.STYLES].includes(ext)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const hmlPath = FileUtil_1.default.updatePath(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
|
|
32
|
+
if (fs_1.default.existsSync(hmlPath)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
];
|
|
17
38
|
this.module = {
|
|
18
39
|
rules: [
|
|
19
40
|
{
|
|
@@ -26,20 +47,57 @@ class UxConfig {
|
|
|
26
47
|
loader: [UxLoader_1.default]
|
|
27
48
|
},
|
|
28
49
|
{
|
|
29
|
-
test: [/.+\.
|
|
50
|
+
test: [/.+\.hml$/],
|
|
51
|
+
loader: [HmlLoader_1.default, UxLoader_1.default]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
test: [/.+\.js$/],
|
|
55
|
+
loader: [JsLoader_1.default]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
test: [/.+\.9.png/],
|
|
30
59
|
loader: [PngLoader_1.default]
|
|
31
60
|
}
|
|
32
61
|
]
|
|
33
62
|
};
|
|
34
|
-
this.preWorks = [
|
|
63
|
+
this.preWorks = [
|
|
64
|
+
UxPreWorks_1.default.validateManifest,
|
|
65
|
+
UxPreWorks_1.default.validateSitemap,
|
|
66
|
+
PreWorkUtils_1.default.clean,
|
|
67
|
+
PreWorkUtils_1.default.getEntries,
|
|
68
|
+
PreWorkUtils_1.default.getGlobalVar
|
|
69
|
+
];
|
|
35
70
|
this.followWorks = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
71
|
+
{
|
|
72
|
+
worker: UxFollowWorks_1.default.symlinkNodeModule,
|
|
73
|
+
workerDescribe: 'Create a soft link to the node_modules folder'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
worker: UxFollowWorks_1.default.webpack,
|
|
77
|
+
workerDescribe: 'Compile the project using webpack'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
worker: UxFollowWorks_1.default.copyResource,
|
|
81
|
+
workerDescribe: 'Copy resource files'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
worker: UxFollowWorks_1.default.jsc,
|
|
85
|
+
workerDescribe: 'Generate jsc bytecode'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
worker: UxFollowWorks_1.default.protobuf,
|
|
89
|
+
workerDescribe: 'Generate protobuf json'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
worker: UxFollowWorks_1.default.toRpk,
|
|
93
|
+
workerDescribe: 'Package the project into an RPK file'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
worker: UxFollowWorks_1.default.moveBackResult,
|
|
97
|
+
workerDescribe: 'Migrate temporary project'
|
|
98
|
+
}
|
|
42
99
|
];
|
|
100
|
+
this.watchIgnores = [/node_modules/];
|
|
43
101
|
}
|
|
44
102
|
get output() {
|
|
45
103
|
const name = path_1.default.basename(this.projectPath);
|
|
@@ -48,5 +106,3 @@ class UxConfig {
|
|
|
48
106
|
}
|
|
49
107
|
}
|
|
50
108
|
exports.default = UxConfig;
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=UxConfig.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import XtsLoader from '../loader/xts/XtsLoader';
|
|
3
|
+
import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
3
4
|
/**
|
|
4
5
|
* XtsConfig
|
|
5
6
|
*/
|
|
@@ -12,7 +13,9 @@ declare class XtsConfig implements IFileLaneConfig {
|
|
|
12
13
|
loader: (typeof XtsLoader)[];
|
|
13
14
|
}[];
|
|
14
15
|
};
|
|
15
|
-
preWorks:
|
|
16
|
-
followWorks:
|
|
16
|
+
preWorks: PreWork[];
|
|
17
|
+
followWorks: {
|
|
18
|
+
worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<import("../interface/ICompileOptions").IXtsCompileOptions>;
|
|
19
|
+
}[];
|
|
17
20
|
}
|
|
18
21
|
export default XtsConfig;
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -7,7 +7,6 @@ const entryTemplate_1 = require("../followWorks/xts/entryTemplate");
|
|
|
7
7
|
const generateRpk_1 = require("../followWorks/xts/generateRpk");
|
|
8
8
|
const ts2wasm_1 = require("../followWorks/xts/ts2wasm");
|
|
9
9
|
const XtsLoader_1 = __importDefault(require("../loader/xts/XtsLoader"));
|
|
10
|
-
const preInstall_1 = require("../preWorks/xts/preInstall");
|
|
11
10
|
/**
|
|
12
11
|
* XtsConfig
|
|
13
12
|
*/
|
|
@@ -23,10 +22,18 @@ class XtsConfig {
|
|
|
23
22
|
}
|
|
24
23
|
]
|
|
25
24
|
};
|
|
26
|
-
this.preWorks = [
|
|
27
|
-
this.followWorks = [
|
|
25
|
+
this.preWorks = [];
|
|
26
|
+
this.followWorks = [
|
|
27
|
+
{
|
|
28
|
+
worker: entryTemplate_1.generateEntryFile
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
worker: ts2wasm_1.ts2wasm
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
worker: generateRpk_1.generateRpk
|
|
35
|
+
}
|
|
36
|
+
];
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
exports.default = XtsConfig;
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=XtsConfig.js.map
|
|
@@ -5,6 +5,7 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
|
|
|
5
5
|
*/
|
|
6
6
|
declare class UxFollowWorks {
|
|
7
7
|
static webpack: FollowWork<IJavascriptCompileOption>;
|
|
8
|
+
static protobuf: FollowWork<IJavascriptCompileOption>;
|
|
8
9
|
static jsc: FollowWork<IJavascriptCompileOption>;
|
|
9
10
|
static toRpk: FollowWork<IJavascriptCompileOption>;
|
|
10
11
|
/**
|
|
@@ -13,6 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const TranslateCache_1 = __importDefault(require("@aiot-toolkit/parser/lib//ux/translate/vela/TranslateCache"));
|
|
17
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
16
19
|
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
17
20
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
18
21
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -23,7 +26,8 @@ const JavascriptCompiler_1 = __importDefault(require("../../compiler/javascript/
|
|
|
23
26
|
const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler/javascript/JavascriptDefaultCompileOption"));
|
|
24
27
|
const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
25
28
|
const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
26
|
-
const UxFileUtils_1 = __importDefault(require("
|
|
29
|
+
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
30
|
+
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
27
31
|
/**
|
|
28
32
|
* UxFollowWorks
|
|
29
33
|
*/
|
|
@@ -31,10 +35,50 @@ class UxFollowWorks {
|
|
|
31
35
|
}
|
|
32
36
|
_a = UxFollowWorks;
|
|
33
37
|
UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
|
|
38
|
+
return new JavascriptCompiler_1.default()
|
|
39
|
+
.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))
|
|
40
|
+
.then(() => {
|
|
41
|
+
ColorConsole_1.default.info(`webpack complete`);
|
|
42
|
+
})
|
|
43
|
+
.catch(({ errors, warnings }) => {
|
|
44
|
+
const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
|
|
45
|
+
const messages = [`webpack error:\r\n`];
|
|
46
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
47
|
+
messages.push({
|
|
48
|
+
word: errors
|
|
49
|
+
.map((item, index) => {
|
|
50
|
+
return `${index + 1}. ${item.message}`;
|
|
51
|
+
})
|
|
52
|
+
.join('\r\n'),
|
|
53
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
|
|
57
|
+
messages.push({
|
|
58
|
+
word: warnings
|
|
59
|
+
.map((item, index) => {
|
|
60
|
+
return `${errorLength + index + 1}. ${item.message}`;
|
|
61
|
+
})
|
|
62
|
+
.join('\r\n'),
|
|
63
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
67
|
+
ColorConsole_1.default.throw(...messages);
|
|
68
|
+
throw new Error();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
ColorConsole_1.default.warn(...messages);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
UxFollowWorks.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
|
|
77
|
+
BinaryPlugin.createBinFiles();
|
|
78
|
+
}
|
|
35
79
|
});
|
|
36
80
|
UxFollowWorks.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
if (compilerOption && !compilerOption.
|
|
81
|
+
if (compilerOption && !compilerOption.disabledJsc) {
|
|
38
82
|
return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
39
83
|
}
|
|
40
84
|
});
|
|
@@ -54,6 +98,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
54
98
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
55
99
|
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
56
100
|
const { deviceTypeList } = manifest;
|
|
101
|
+
// 生成设备的 manifest 文件,规则为:manifest.json + config-设备类型.json
|
|
57
102
|
if (deviceTypeList) {
|
|
58
103
|
deviceTypeList.forEach((deviceType) => {
|
|
59
104
|
let data = Object.assign({}, manifest);
|
|
@@ -87,7 +132,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
87
132
|
'md',
|
|
88
133
|
'ux',
|
|
89
134
|
'mix',
|
|
90
|
-
'DS_Store'
|
|
135
|
+
'DS_Store',
|
|
136
|
+
'map'
|
|
91
137
|
];
|
|
92
138
|
const excludeReg = `\.(${excludeExtList.join('|')})$`;
|
|
93
139
|
FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
|
|
@@ -108,6 +154,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
108
154
|
if (!content.packageInfo) {
|
|
109
155
|
content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
|
|
110
156
|
}
|
|
157
|
+
if (TranslateCache_1.default.featureCache.size) {
|
|
158
|
+
const featureSet = new Set([
|
|
159
|
+
...Array.from(TranslateCache_1.default.featureCache),
|
|
160
|
+
...(content.features || []).map((item) => item.name)
|
|
161
|
+
]);
|
|
162
|
+
content.features = Array.from(featureSet).map((item) => {
|
|
163
|
+
return { name: item };
|
|
164
|
+
});
|
|
165
|
+
}
|
|
111
166
|
fs_extra_1.default.writeJSONSync(path_1.default.join(projectPath, outputPath, UxFileUtils_1.default.CONFIG_FILE_NAME), content, {
|
|
112
167
|
spaces: 2
|
|
113
168
|
});
|
|
@@ -141,8 +196,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
141
196
|
});
|
|
142
197
|
if (compilerOption) {
|
|
143
198
|
copyResourceFiles(compilerOption);
|
|
144
|
-
genDeviceManifests(compilerOption);
|
|
145
199
|
updateManifest(compilerOption);
|
|
200
|
+
genDeviceManifests(compilerOption);
|
|
146
201
|
yield genMetaFiles(compilerOption);
|
|
147
202
|
}
|
|
148
203
|
});
|
|
@@ -187,14 +242,17 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
|
|
|
187
242
|
if (!compilerOption) {
|
|
188
243
|
return;
|
|
189
244
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
fs_extra_1.default.
|
|
195
|
-
|
|
196
|
-
|
|
245
|
+
try {
|
|
246
|
+
const foldList = ['node_modules'];
|
|
247
|
+
foldList.forEach((item) => {
|
|
248
|
+
const sourcePath = path_1.default.join(context.projectPath, item);
|
|
249
|
+
if (fs_extra_1.default.existsSync(sourcePath)) {
|
|
250
|
+
fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item), 'junction');
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
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.`);
|
|
256
|
+
}
|
|
197
257
|
});
|
|
198
258
|
exports.default = UxFollowWorks;
|
|
199
|
-
|
|
200
|
-
//# sourceMappingURL=UxFollowWorks.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
2
2
|
export interface Aspects {
|
|
3
3
|
path: string;
|
|
4
4
|
name: string;
|
|
@@ -18,4 +18,4 @@ export declare const XtsEntryFileName = "__entry__.ts";
|
|
|
18
18
|
* 生成 __entry__.ts 文件
|
|
19
19
|
* @param context
|
|
20
20
|
*/
|
|
21
|
-
export declare
|
|
21
|
+
export declare const generateEntryFile: FollowWork;
|