@aiot-toolkit/aiotpack 2.0.2-beta.1 → 2.0.2-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/compiler/interface/ICompileParam.d.ts +1 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +32 -8
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +78 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +2 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.js +2 -5
- package/lib/compiler/javascript/vela/utils/Jsc.js +3 -4
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +3 -3
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +7 -9
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +3 -5
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +53 -28
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +56 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/{splitMap.js → extractMapData.js} +2 -2
- package/lib/config/UxConfig.d.ts +29 -7
- package/lib/config/UxConfig.js +110 -33
- package/lib/config/XtsConfig.d.ts +5 -3
- package/lib/config/XtsConfig.js +12 -3
- package/lib/{utils → followWorks}/ux/UxFollowWorks.d.ts +1 -1
- package/lib/{utils → followWorks}/ux/UxFollowWorks.js +31 -31
- package/lib/followWorks/xts/entryTemplate.d.ts +1 -1
- package/lib/followWorks/xts/entryTemplate.js +10 -10
- package/lib/followWorks/xts/generateRpk.d.ts +1 -1
- package/lib/followWorks/xts/generateRpk.js +2 -2
- package/lib/followWorks/xts/ts2wasm.d.ts +1 -1
- package/lib/followWorks/xts/ts2wasm.js +4 -4
- package/lib/index.d.ts +9 -1
- package/lib/index.js +35 -1
- package/lib/loader/ux/JsLoader.d.ts +2 -0
- package/lib/loader/ux/JsLoader.js +6 -9
- package/lib/loader/ux/PngLoader.js +4 -5
- package/lib/loader/ux/android/UxLoader.d.ts +11 -0
- package/lib/loader/ux/android/UxLoader.js +39 -0
- package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +1 -1
- package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +6 -3
- package/lib/loader/ux/vela/HmlLoader.d.ts +24 -0
- package/lib/loader/ux/vela/HmlLoader.js +63 -0
- package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +1 -1
- package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +4 -13
- package/lib/loader/xts/XtsLoader.js +6 -7
- package/lib/{utils → preWorks}/ux/UxPreWorks.d.ts +1 -1
- package/lib/{utils → preWorks}/ux/UxPreWorks.js +1 -1
- package/lib/preWorks/xts/preInstall.d.ts +1 -1
- package/lib/preWorks/xts/preInstall.js +4 -4
- package/lib/utils/PreWorkUtils.d.ts +1 -2
- package/lib/utils/PreWorkUtils.js +28 -30
- package/lib/utils/ux/ManifestSchema.d.ts +1 -1
- package/lib/utils/ux/UxFileUtils.js +11 -13
- package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
- package/lib/utils/ux/UxLoaderUtils.js +43 -23
- package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
- package/lib/utils/ux/android/AndroidUx.js +98 -0
- package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
- package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
- package/lib/utils/xts/XtsFollowWorks.js +7 -7
- package/package.json +9 -5
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
|
@@ -12,9 +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
|
|
16
|
-
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
17
|
-
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
15
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
16
|
const crypto_1 = __importDefault(require("crypto"));
|
|
19
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
18
|
const jsrsasign_1 = __importDefault(require("jsrsasign"));
|
|
@@ -31,43 +29,70 @@ const Signer_1 = __importDefault(require("./Signer"));
|
|
|
31
29
|
class SignUtil {
|
|
32
30
|
/**
|
|
33
31
|
* 获取签名相关的配置内容
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param param
|
|
32
|
+
* @param param IJavascriptCompileOption参数中获取签名目录等内容
|
|
33
|
+
* @returns
|
|
37
34
|
*/
|
|
38
35
|
static getProjectSignConfig(param) {
|
|
39
36
|
const { mode, projectPath, signRoot } = param;
|
|
37
|
+
const signPathFolder = path_1.default.join(projectPath, signRoot || 'sign');
|
|
38
|
+
const signPathConfig = {
|
|
39
|
+
debug: {
|
|
40
|
+
privatekey: path_1.default.join(signPathFolder, 'debug', 'private.pem'),
|
|
41
|
+
certificate: path_1.default.join(signPathFolder, 'debug', 'certificate.pem')
|
|
42
|
+
},
|
|
43
|
+
sign: {
|
|
44
|
+
privatekey: path_1.default.join(signPathFolder, 'private.pem'),
|
|
45
|
+
certificate: path_1.default.join(signPathFolder, 'certificate.pem')
|
|
46
|
+
},
|
|
47
|
+
defaultDevelopment: {
|
|
48
|
+
privatekey: path_1.default.join(__dirname, 'pem', 'private.pem'),
|
|
49
|
+
certificate: path_1.default.join(__dirname, 'pem', 'certificate.pem')
|
|
50
|
+
},
|
|
51
|
+
oldRelease: {
|
|
52
|
+
privatekey: path_1.default.join(signPathFolder, 'release', 'private.pem'),
|
|
53
|
+
certificate: path_1.default.join(signPathFolder, 'release', 'certificate.pem')
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// build模式 优先sign/debug/证书 其次sign/证书 最后toolkit中默认的证书
|
|
57
|
+
const developmentSignConfig = [
|
|
58
|
+
signPathConfig.debug,
|
|
59
|
+
signPathConfig.sign,
|
|
60
|
+
signPathConfig.defaultDevelopment
|
|
61
|
+
];
|
|
62
|
+
// release模式 优先sign/release/证书 其次sign/证书
|
|
63
|
+
const releaseSignConfig = [signPathConfig.oldRelease, signPathConfig.sign];
|
|
64
|
+
let modeSignConfig = [];
|
|
40
65
|
let signConfig;
|
|
41
|
-
let privatekeyPath;
|
|
42
|
-
let certificatePath;
|
|
43
66
|
switch (mode) {
|
|
44
67
|
case CompileMode_1.default.DEVELOPMENT:
|
|
45
|
-
|
|
46
|
-
certificatePath = path_1.default.join(__dirname, 'pem', 'certificate.pem');
|
|
47
|
-
ColorConsole_1.default.info(`User debug signature is enabled by project build`);
|
|
68
|
+
modeSignConfig = developmentSignConfig;
|
|
48
69
|
break;
|
|
49
70
|
case CompileMode_1.default.PRODUCTION:
|
|
50
|
-
|
|
51
|
-
certificatePath = path_1.default.join(projectPath, signRoot, 'certificate.pem');
|
|
52
|
-
ColorConsole_1.default.info(`release signature is enabled by project build`);
|
|
71
|
+
modeSignConfig = releaseSignConfig;
|
|
53
72
|
break;
|
|
54
73
|
default:
|
|
55
74
|
// 打印信息, 模式未定义
|
|
56
|
-
|
|
75
|
+
shared_utils_1.ColorConsole.error(`Error: mode ${mode} undefined`);
|
|
57
76
|
break;
|
|
58
77
|
}
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
// 寻找有效的证书路径
|
|
79
|
+
const findPath = modeSignConfig.find(({ privatekey, certificate }) => shared_utils_1.FileUtil.checkFilePath([privatekey, certificate]));
|
|
80
|
+
if (findPath) {
|
|
81
|
+
let { privatekey: privatekeyPath, certificate: certificatePath } = findPath;
|
|
82
|
+
shared_utils_1.ColorConsole.info('privatekeyPath is ', {
|
|
83
|
+
word: privatekeyPath
|
|
84
|
+
}, `\ncertificatePath is `, {
|
|
85
|
+
word: certificatePath
|
|
86
|
+
});
|
|
87
|
+
// 读取证书内容
|
|
63
88
|
signConfig = {
|
|
64
89
|
privatekey: fs_extra_1.default.readFileSync(privatekeyPath),
|
|
65
90
|
certificate: fs_extra_1.default.readFileSync(certificatePath)
|
|
66
91
|
};
|
|
67
92
|
}
|
|
68
93
|
else {
|
|
69
|
-
//
|
|
70
|
-
|
|
94
|
+
// 抛出错误,在指定模式下未找到证书
|
|
95
|
+
throw new Error(`The current mode is ${mode}, and there is a problem with the certification path`);
|
|
71
96
|
}
|
|
72
97
|
return signConfig;
|
|
73
98
|
}
|
|
@@ -83,12 +108,12 @@ class SignUtil {
|
|
|
83
108
|
if (metaBuffer) {
|
|
84
109
|
const metaHash = {
|
|
85
110
|
name: ZipUtil_1.default.DIGEST_HASH_JSON,
|
|
86
|
-
hash:
|
|
111
|
+
hash: shared_utils_1.CommonUtil.calcDataDigest(metaBuffer)
|
|
87
112
|
};
|
|
88
113
|
const signedMetaBuffer = SignUtil.doSign(metaBuffer, [metaHash], privatekey, certificate);
|
|
89
114
|
if (signedMetaBuffer === false) {
|
|
90
115
|
// META-INF/CERT签名失败
|
|
91
|
-
|
|
116
|
+
shared_utils_1.ColorConsole.throw('META-INF/CERT signature failed');
|
|
92
117
|
}
|
|
93
118
|
else {
|
|
94
119
|
fileList.push({
|
|
@@ -97,7 +122,7 @@ class SignUtil {
|
|
|
97
122
|
});
|
|
98
123
|
fileDigestHash.push({
|
|
99
124
|
name: ZipUtil_1.default.CERT_PATH,
|
|
100
|
-
hash:
|
|
125
|
+
hash: shared_utils_1.CommonUtil.calcDataDigest(signedMetaBuffer)
|
|
101
126
|
});
|
|
102
127
|
}
|
|
103
128
|
}
|
|
@@ -107,7 +132,7 @@ class SignUtil {
|
|
|
107
132
|
fileList.push(item);
|
|
108
133
|
fileDigestHash.push({
|
|
109
134
|
name: item.path,
|
|
110
|
-
hash:
|
|
135
|
+
hash: shared_utils_1.CommonUtil.calcDataDigest(item.content)
|
|
111
136
|
});
|
|
112
137
|
});
|
|
113
138
|
// 因为META变化,重新创建ZIP流
|
|
@@ -116,7 +141,7 @@ class SignUtil {
|
|
|
116
141
|
const signedZipBuffer = SignUtil.doSign(newZipBuffer, fileDigestHash, privatekey, certificate);
|
|
117
142
|
if (signedZipBuffer === false) {
|
|
118
143
|
// 签名失败
|
|
119
|
-
|
|
144
|
+
shared_utils_1.ColorConsole.throw('package signature failed');
|
|
120
145
|
}
|
|
121
146
|
return signedZipBuffer;
|
|
122
147
|
});
|
|
@@ -180,13 +205,13 @@ class SignUtil {
|
|
|
180
205
|
static unZipFiles(fileBuffer, files) {
|
|
181
206
|
// 1. 读取zip文件
|
|
182
207
|
if (!fileBuffer || fileBuffer.length <= 4) {
|
|
183
|
-
|
|
208
|
+
shared_utils_1.ColorConsole.error('Zip file open failed');
|
|
184
209
|
return false;
|
|
185
210
|
}
|
|
186
211
|
// 2. 检查文件格式是否正确
|
|
187
212
|
const fileMagic = fileBuffer.readInt32LE(0);
|
|
188
213
|
if (fileMagic !== 0x4034b50) {
|
|
189
|
-
|
|
214
|
+
shared_utils_1.ColorConsole.error('Zip file format is wrong');
|
|
190
215
|
return false;
|
|
191
216
|
}
|
|
192
217
|
// 3. 解析数据块
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
13
|
+
function addColSourceMap(source, map) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const callback = this.async();
|
|
16
|
+
if (!map) {
|
|
17
|
+
callback(null, source, map);
|
|
18
|
+
}
|
|
19
|
+
let { consumer, tempGenerator } = yield parser_1.SourceMapUtil.createConsumerAndGenerator(JSON.stringify(map));
|
|
20
|
+
let recordLine = -1;
|
|
21
|
+
consumer.eachMapping((mapping) => {
|
|
22
|
+
if (mapping.source === consumer.sources[consumer.sources.length - 1]) {
|
|
23
|
+
if (recordLine < mapping.generatedLine &&
|
|
24
|
+
(mapping.generatedColumn !== 0 || mapping.originalColumn !== 0)) {
|
|
25
|
+
tempGenerator.addMapping({
|
|
26
|
+
generated: {
|
|
27
|
+
line: mapping.generatedLine,
|
|
28
|
+
column: 0
|
|
29
|
+
},
|
|
30
|
+
original: {
|
|
31
|
+
line: mapping.originalLine,
|
|
32
|
+
column: 0
|
|
33
|
+
},
|
|
34
|
+
source: mapping.source,
|
|
35
|
+
name: ''
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
recordLine = mapping.generatedLine;
|
|
39
|
+
}
|
|
40
|
+
tempGenerator.addMapping({
|
|
41
|
+
generated: {
|
|
42
|
+
line: mapping.generatedLine,
|
|
43
|
+
column: mapping.generatedColumn
|
|
44
|
+
},
|
|
45
|
+
original: {
|
|
46
|
+
line: mapping.originalLine,
|
|
47
|
+
column: mapping.originalColumn
|
|
48
|
+
},
|
|
49
|
+
source: mapping.source,
|
|
50
|
+
name: mapping.name
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
callback(null, source, JSON.parse(tempGenerator.toString()));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.default = addColSourceMap;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
function
|
|
8
|
+
function extractMapData(source, map) {
|
|
9
9
|
const enterFilePath = this.resourcePath;
|
|
10
10
|
// 获取当前文件夹和文件名
|
|
11
11
|
const dirName = path_1.default.dirname(enterFilePath);
|
|
@@ -17,4 +17,4 @@ function splitMap(source, map) {
|
|
|
17
17
|
}
|
|
18
18
|
this.callback(null, source, map && JSON.parse(map));
|
|
19
19
|
}
|
|
20
|
-
exports.default =
|
|
20
|
+
exports.default = extractMapData;
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
-
import AppUxLoader from '../loader/ux/AppUxLoader';
|
|
4
3
|
import JsLoader from '../loader/ux/JsLoader';
|
|
5
|
-
import
|
|
4
|
+
import PngLoader from '../loader/ux/PngLoader';
|
|
5
|
+
import AppUxLoader from '../loader/ux/vela/AppUxLoader';
|
|
6
|
+
import HmlLoader from '../loader/ux/vela/HmlLoader';
|
|
7
|
+
import UxLoader from '../loader/ux/vela/UxLoader';
|
|
6
8
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
7
9
|
readonly projectPath: string;
|
|
8
10
|
constructor(projectPath: string);
|
|
9
|
-
exclude: RegExp[];
|
|
11
|
+
exclude: (RegExp | ((filePath: string) => boolean))[];
|
|
10
12
|
get output(): string;
|
|
11
|
-
|
|
13
|
+
preWorks: import("file-lane").PreWork<IJavascriptCompileOption>[];
|
|
14
|
+
followWorks: {
|
|
15
|
+
worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
|
|
16
|
+
workerDescribe: string;
|
|
17
|
+
}[];
|
|
18
|
+
watchIgnores: (string | RegExp)[];
|
|
19
|
+
/**
|
|
20
|
+
* 通过项目类型,返回模块配置
|
|
21
|
+
*/
|
|
22
|
+
get module(): {
|
|
12
23
|
rules: ({
|
|
13
24
|
test: string[];
|
|
14
25
|
loader: (typeof AppUxLoader)[];
|
|
@@ -17,14 +28,25 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
|
17
28
|
test: RegExp[];
|
|
18
29
|
exclude: RegExp[];
|
|
19
30
|
loader: (typeof UxLoader)[];
|
|
31
|
+
} | {
|
|
32
|
+
test: RegExp[];
|
|
33
|
+
loader: (typeof HmlLoader | typeof UxLoader)[];
|
|
34
|
+
exclude?: undefined;
|
|
20
35
|
} | {
|
|
21
36
|
test: RegExp[];
|
|
22
37
|
loader: (typeof JsLoader)[];
|
|
23
38
|
exclude?: undefined;
|
|
39
|
+
} | {
|
|
40
|
+
test: RegExp[];
|
|
41
|
+
loader: (typeof PngLoader)[];
|
|
42
|
+
exclude?: undefined;
|
|
24
43
|
})[];
|
|
25
44
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
/**
|
|
46
|
+
* 判断项目类型
|
|
47
|
+
*
|
|
48
|
+
* 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
|
|
49
|
+
*/
|
|
50
|
+
private getProjectType;
|
|
29
51
|
}
|
|
30
52
|
export default UxConfig;
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -3,39 +3,39 @@ 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 parser_1 = require("@aiot-toolkit/parser");
|
|
7
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
6
9
|
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const
|
|
10
|
+
const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
|
|
8
11
|
const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
|
|
9
12
|
const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
|
|
10
|
-
const
|
|
13
|
+
const AppUxLoader_1 = __importDefault(require("../loader/ux/vela/AppUxLoader"));
|
|
14
|
+
const HmlLoader_1 = __importDefault(require("../loader/ux/vela/HmlLoader"));
|
|
15
|
+
const UxLoader_1 = __importDefault(require("../loader/ux/vela/UxLoader"));
|
|
16
|
+
const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
|
|
11
17
|
const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
|
|
12
|
-
const
|
|
13
|
-
const UxPreWorks_1 = __importDefault(require("../utils/ux/UxPreWorks"));
|
|
18
|
+
const UxLoader_2 = __importDefault(require("../loader/ux/android/UxLoader"));
|
|
14
19
|
class UxConfig {
|
|
15
20
|
constructor(projectPath) {
|
|
16
21
|
this.projectPath = projectPath;
|
|
17
|
-
this.exclude = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
exclude: [/app\.ux/],
|
|
27
|
-
loader: [UxLoader_1.default]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
test: [/.+\.js$/],
|
|
31
|
-
loader: [JsLoader_1.default]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
test: [/.+\.9.png/],
|
|
35
|
-
loader: [PngLoader_1.default]
|
|
22
|
+
this.exclude = [
|
|
23
|
+
/node_modules/,
|
|
24
|
+
/dist/,
|
|
25
|
+
/build/,
|
|
26
|
+
(filePath) => {
|
|
27
|
+
// 如果 是 script, style文件,且同路径下存在同名 hml,则忽略
|
|
28
|
+
const { ext, name } = path_1.default.parse(filePath);
|
|
29
|
+
if (![...parser_1.ExtensionConfig.SCRIPTS, ...parser_1.ExtensionConfig.STYLES].includes(ext)) {
|
|
30
|
+
return false;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const hmlPath = shared_utils_1.FileUtil.updateFileName(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
|
|
33
|
+
if (fs_1.default.existsSync(hmlPath)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
39
|
this.preWorks = [
|
|
40
40
|
UxPreWorks_1.default.validateManifest,
|
|
41
41
|
UxPreWorks_1.default.validateSitemap,
|
|
@@ -44,20 +44,97 @@ class UxConfig {
|
|
|
44
44
|
PreWorkUtils_1.default.getGlobalVar
|
|
45
45
|
];
|
|
46
46
|
this.followWorks = [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
{
|
|
48
|
+
worker: UxFollowWorks_1.default.symlinkNodeModule,
|
|
49
|
+
workerDescribe: 'Create a soft link to the node_modules folder'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
worker: UxFollowWorks_1.default.webpack,
|
|
53
|
+
workerDescribe: 'Compile the project using webpack'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
worker: UxFollowWorks_1.default.copyResource,
|
|
57
|
+
workerDescribe: 'Copy resource files'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
worker: UxFollowWorks_1.default.jsc,
|
|
61
|
+
workerDescribe: 'Generate jsc bytecode'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
worker: UxFollowWorks_1.default.protobuf,
|
|
65
|
+
workerDescribe: 'Generate protobuf json'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
worker: UxFollowWorks_1.default.toRpk,
|
|
69
|
+
workerDescribe: 'Package the project into an RPK file'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
worker: UxFollowWorks_1.default.moveBackResult,
|
|
73
|
+
workerDescribe: 'Migrate temporary project'
|
|
74
|
+
}
|
|
54
75
|
];
|
|
55
|
-
this.watchIgnores = [/node_modules/];
|
|
76
|
+
this.watchIgnores = [/node_modules/, '/build/', '/dist/'];
|
|
56
77
|
}
|
|
57
78
|
get output() {
|
|
58
79
|
const name = path_1.default.basename(this.projectPath);
|
|
59
80
|
const result = `../.temp_${name}`;
|
|
60
81
|
return result;
|
|
61
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* 通过项目类型,返回模块配置
|
|
85
|
+
*/
|
|
86
|
+
get module() {
|
|
87
|
+
const isVela = this.getProjectType() === shared_utils_1.ProjectType.VELA_UX;
|
|
88
|
+
return isVela
|
|
89
|
+
? {
|
|
90
|
+
rules: [
|
|
91
|
+
{
|
|
92
|
+
test: ['app.ux'],
|
|
93
|
+
loader: [AppUxLoader_1.default]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
test: [/.+\.ux$/],
|
|
97
|
+
exclude: [/app\.ux/],
|
|
98
|
+
loader: [UxLoader_1.default]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
test: [/.+\.hml$/],
|
|
102
|
+
loader: [HmlLoader_1.default, UxLoader_1.default]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: [/.+\.js$/],
|
|
106
|
+
loader: [JsLoader_1.default]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
test: [/.+\.9.png/],
|
|
110
|
+
loader: [PngLoader_1.default]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
: {
|
|
115
|
+
rules: [
|
|
116
|
+
{
|
|
117
|
+
test: [/.+\.ux$/],
|
|
118
|
+
loader: [UxLoader_2.default]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
test: [/.+\.js$/],
|
|
122
|
+
loader: [JsLoader_1.default]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
test: [/.+\.9.png/],
|
|
126
|
+
loader: [PngLoader_1.default]
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 判断项目类型
|
|
133
|
+
*
|
|
134
|
+
* 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
|
|
135
|
+
*/
|
|
136
|
+
getProjectType() {
|
|
137
|
+
return shared_utils_1.ProjectType.getProjectType(this.projectPath);
|
|
138
|
+
}
|
|
62
139
|
}
|
|
63
140
|
exports.default = UxConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IFileLaneConfig } from 'file-lane';
|
|
1
|
+
import { IFileLaneConfig, PreWork } from 'file-lane';
|
|
2
2
|
import XtsLoader from '../loader/xts/XtsLoader';
|
|
3
3
|
/**
|
|
4
4
|
* XtsConfig
|
|
@@ -12,7 +12,9 @@ declare class XtsConfig implements IFileLaneConfig {
|
|
|
12
12
|
loader: (typeof XtsLoader)[];
|
|
13
13
|
}[];
|
|
14
14
|
};
|
|
15
|
-
preWorks:
|
|
16
|
-
followWorks:
|
|
15
|
+
preWorks: PreWork[];
|
|
16
|
+
followWorks: {
|
|
17
|
+
worker: import("file-lane").FollowWork<import("..").IXtsCompileOptions>;
|
|
18
|
+
}[];
|
|
17
19
|
}
|
|
18
20
|
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,8 +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;
|