@aiot-toolkit/aiotpack 2.0.2-dev.7 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{utils/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +11 -4
- package/lib/{utils/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +68 -43
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +14 -13
- package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/generateRpk.js +5 -4
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +7 -6
- package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
- package/lib/afterWorks/ux/UxAfterWorks.js +22 -0
- package/lib/{utils/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +4 -4
- package/lib/{utils/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +11 -8
- package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +1 -1
- package/lib/{preWorks → beforeCompile}/xts/preInstall.js +6 -5
- package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
- package/lib/beforeWorks/ux/UxBeforeWorks.js +22 -0
- package/lib/compiler/interface/ICompileParam.d.ts +1 -1
- package/lib/compiler/interface/ISignConfig.d.ts +6 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +45 -12
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
- 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 +91 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +4 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -1
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.d.ts +2 -2
- package/lib/compiler/javascript/vela/model/Package.js +5 -5
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +16 -2
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +19 -11
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +4 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +19 -3
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +34 -29
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +23 -7
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +94 -45
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
- 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 +45 -7
- package/lib/config/UxConfig.js +156 -40
- package/lib/config/XtsConfig.d.ts +6 -4
- package/lib/config/XtsConfig.js +22 -7
- 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} +12 -13
- package/lib/loader/xts/XtsLoader.js +6 -7
- package/lib/utils/BeforeCompileUtils.d.ts +21 -0
- package/lib/utils/BeforeCompileUtils.js +118 -0
- package/lib/utils/ux/ManifestSchema.d.ts +1 -1
- package/lib/utils/ux/UxFileUtils.d.ts +16 -3
- package/lib/utils/ux/UxFileUtils.js +50 -17
- package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
- package/lib/utils/ux/UxLoaderUtils.js +43 -25
- 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 +8 -8
- package/package.json +16 -8
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
- package/lib/utils/PreWorkUtils.d.ts +0 -22
- package/lib/utils/PreWorkUtils.js +0 -106
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FollowWork } from 'file-lane
|
|
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>;
|
|
@@ -15,6 +15,13 @@ declare class UxFollowWorks {
|
|
|
15
15
|
* @param compilerOption
|
|
16
16
|
*/
|
|
17
17
|
static copyResource: FollowWork<IJavascriptCompileOption>;
|
|
18
|
+
/**
|
|
19
|
+
* 对比 临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
20
|
+
* @param context
|
|
21
|
+
* @param config
|
|
22
|
+
* @param compilerOption
|
|
23
|
+
*/
|
|
24
|
+
static generateDiff: FollowWork<IJavascriptCompileOption>;
|
|
18
25
|
/**
|
|
19
26
|
* 打包结果移回源码项目,并删除中间项目
|
|
20
27
|
*
|
|
@@ -33,4 +40,4 @@ declare class UxFollowWorks {
|
|
|
33
40
|
*/
|
|
34
41
|
static symlinkNodeModule: FollowWork<IJavascriptCompileOption>;
|
|
35
42
|
}
|
|
36
|
-
export default
|
|
43
|
+
export default UxAfterCompile;
|
|
@@ -13,11 +13,7 @@ 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
16
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
-
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
19
|
-
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
20
|
-
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
21
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
22
18
|
const lodash_1 = __importDefault(require("lodash"));
|
|
23
19
|
const path_1 = __importDefault(require("path"));
|
|
@@ -26,19 +22,20 @@ const JavascriptCompiler_1 = __importDefault(require("../../compiler/javascript/
|
|
|
26
22
|
const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler/javascript/JavascriptDefaultCompileOption"));
|
|
27
23
|
const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
28
24
|
const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
29
|
-
const UxFileUtils_1 = __importDefault(require("
|
|
25
|
+
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
30
26
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
31
27
|
/**
|
|
32
|
-
*
|
|
28
|
+
* UxAfterCompile
|
|
33
29
|
*/
|
|
34
|
-
class
|
|
30
|
+
class UxAfterCompile {
|
|
35
31
|
}
|
|
36
|
-
_a =
|
|
37
|
-
|
|
32
|
+
_a = UxAfterCompile;
|
|
33
|
+
UxAfterCompile.webpack = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const { context, compilerOption } = params;
|
|
38
35
|
return new JavascriptCompiler_1.default()
|
|
39
36
|
.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
37
|
.then(() => {
|
|
41
|
-
|
|
38
|
+
shared_utils_1.ColorConsole.info(`webpack complete`);
|
|
42
39
|
})
|
|
43
40
|
.catch(({ errors, warnings }) => {
|
|
44
41
|
const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
|
|
@@ -50,7 +47,7 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
|
|
|
50
47
|
return `${index + 1}. ${item.message}`;
|
|
51
48
|
})
|
|
52
49
|
.join('\r\n'),
|
|
53
|
-
style:
|
|
50
|
+
style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW)
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
53
|
if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
|
|
@@ -60,29 +57,32 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
|
|
|
60
57
|
return `${errorLength + index + 1}. ${item.message}`;
|
|
61
58
|
})
|
|
62
59
|
.join('\r\n'),
|
|
63
|
-
style:
|
|
60
|
+
style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.WARN)
|
|
64
61
|
});
|
|
65
62
|
}
|
|
66
63
|
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
67
|
-
|
|
64
|
+
shared_utils_1.ColorConsole.throw(...messages);
|
|
68
65
|
throw new Error();
|
|
69
66
|
}
|
|
70
67
|
else {
|
|
71
|
-
|
|
68
|
+
shared_utils_1.ColorConsole.warn(...messages);
|
|
72
69
|
}
|
|
73
70
|
});
|
|
74
71
|
});
|
|
75
|
-
|
|
72
|
+
UxAfterCompile.protobuf = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const { compilerOption } = params;
|
|
76
74
|
if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
|
|
77
75
|
BinaryPlugin.createBinFiles();
|
|
78
76
|
}
|
|
79
77
|
});
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
UxAfterCompile.jsc = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const { context, compilerOption } = params;
|
|
80
|
+
if (compilerOption && compilerOption.enableJsc === true) {
|
|
82
81
|
return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
83
82
|
}
|
|
84
83
|
});
|
|
85
|
-
|
|
84
|
+
UxAfterCompile.toRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const { compilerOption } = params;
|
|
86
86
|
if (compilerOption) {
|
|
87
87
|
return ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
|
|
88
88
|
}
|
|
@@ -93,7 +93,8 @@ UxFollowWorks.toRpk = (context, config, compilerOption) => __awaiter(void 0, voi
|
|
|
93
93
|
* @param config
|
|
94
94
|
* @param compilerOption
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
UxAfterCompile.copyResource = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
+
const { context, compilerOption } = params;
|
|
97
98
|
const genDeviceManifests = (compilerOption) => {
|
|
98
99
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
99
100
|
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
@@ -115,7 +116,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
115
116
|
const copyResourceFiles = (compilerOption) => {
|
|
116
117
|
// 复制除 js/jsx/ts/tsx/json 外,但是包含manifest.json、sitemap.json的文件
|
|
117
118
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
118
|
-
const includeList = [
|
|
119
|
+
const includeList = [/sitemap\.json$/, /i18n(.+)\.json/];
|
|
119
120
|
const excludeExtList = [
|
|
120
121
|
'js',
|
|
121
122
|
'jsx',
|
|
@@ -128,16 +129,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
128
129
|
'sass',
|
|
129
130
|
'styl',
|
|
130
131
|
'html',
|
|
131
|
-
'json',
|
|
132
132
|
'md',
|
|
133
133
|
'ux',
|
|
134
134
|
'mix',
|
|
135
135
|
'DS_Store',
|
|
136
136
|
'map'
|
|
137
137
|
];
|
|
138
|
-
const excludeReg =
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
const excludeReg = `\\.(${excludeExtList.join('|')})$`;
|
|
139
|
+
shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
|
|
140
|
+
shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), undefined, includeList);
|
|
141
141
|
};
|
|
142
142
|
/**
|
|
143
143
|
* 写入 manifest.json 文件
|
|
@@ -146,17 +146,18 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
146
146
|
* @param compilerOption
|
|
147
147
|
*/
|
|
148
148
|
const updateManifest = (compilerOption) => {
|
|
149
|
-
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
149
|
+
const { projectPath, sourceRoot, outputPath, completeFeature } = compilerOption;
|
|
150
150
|
const content = UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot);
|
|
151
|
+
const translateCache = context.translateCache;
|
|
151
152
|
if (!content.minAPILevel) {
|
|
152
153
|
content.minAPILevel = 1;
|
|
153
154
|
}
|
|
154
155
|
if (!content.packageInfo) {
|
|
155
156
|
content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
|
|
156
157
|
}
|
|
157
|
-
if (
|
|
158
|
+
if (completeFeature && (translateCache === null || translateCache === void 0 ? void 0 : translateCache.featureCache.size)) {
|
|
158
159
|
const featureSet = new Set([
|
|
159
|
-
...Array.from(
|
|
160
|
+
...Array.from(translateCache.featureCache),
|
|
160
161
|
...(content.features || []).map((item) => item.name)
|
|
161
162
|
]);
|
|
162
163
|
content.features = Array.from(featureSet).map((item) => {
|
|
@@ -180,7 +181,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
180
181
|
const files = ZipUtil_1.default.getSortedFiles(outputAbsPath, compilerOption, UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot));
|
|
181
182
|
const digestDic = Object.fromEntries(files.map((item) => [
|
|
182
183
|
item,
|
|
183
|
-
|
|
184
|
+
shared_utils_1.CommonUtil.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
|
|
184
185
|
]));
|
|
185
186
|
const hashJson = [
|
|
186
187
|
{
|
|
@@ -195,12 +196,30 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
195
196
|
fs_extra_1.default.outputFileSync(path_1.default.join(outputAbsPath, ZipUtil_1.default.CERT_PATH), buffer);
|
|
196
197
|
});
|
|
197
198
|
if (compilerOption) {
|
|
198
|
-
copyResourceFiles(compilerOption);
|
|
199
|
-
updateManifest(compilerOption);
|
|
200
|
-
genDeviceManifests(compilerOption);
|
|
199
|
+
yield copyResourceFiles(compilerOption);
|
|
200
|
+
yield updateManifest(compilerOption);
|
|
201
|
+
yield genDeviceManifests(compilerOption);
|
|
201
202
|
yield genMetaFiles(compilerOption);
|
|
202
203
|
}
|
|
203
204
|
});
|
|
205
|
+
/**
|
|
206
|
+
* 对比 临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
207
|
+
* @param context
|
|
208
|
+
* @param config
|
|
209
|
+
* @param compilerOption
|
|
210
|
+
*/
|
|
211
|
+
UxAfterCompile.generateDiff = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
+
const { compilerOption, compalition } = params;
|
|
213
|
+
if (!compilerOption || !compalition) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const { outputPath, projectPath } = compilerOption;
|
|
217
|
+
// 读取临时项目build文件夹中所有文件路径
|
|
218
|
+
const tempBuildPath = path_1.default.join(projectPath, outputPath);
|
|
219
|
+
// 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
|
|
220
|
+
const tempFileList = shared_utils_1.FileUtil.readAlldirSync(tempBuildPath).map((filePath) => path_1.default.relative(tempBuildPath, filePath));
|
|
221
|
+
UxFileUtils_1.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
|
|
222
|
+
});
|
|
204
223
|
/**
|
|
205
224
|
* 打包结果移回源码项目,并删除中间项目
|
|
206
225
|
*
|
|
@@ -210,7 +229,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
210
229
|
* @param config
|
|
211
230
|
* @param compilerOption
|
|
212
231
|
*/
|
|
213
|
-
|
|
232
|
+
UxAfterCompile.moveBackResult = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
233
|
+
const { context, compilerOption } = params;
|
|
214
234
|
if (!compilerOption) {
|
|
215
235
|
return;
|
|
216
236
|
}
|
|
@@ -228,9 +248,7 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
|
|
|
228
248
|
];
|
|
229
249
|
targetList.forEach((item) => {
|
|
230
250
|
fs_extra_1.default.moveSync(item.from, item.to, { overwrite: true });
|
|
231
|
-
fs_extra_1.default.removeSync(item.from);
|
|
232
251
|
});
|
|
233
|
-
fs_extra_1.default.removeSync(projectPath);
|
|
234
252
|
});
|
|
235
253
|
/**
|
|
236
254
|
* 创建 node_module 软链
|
|
@@ -238,16 +256,23 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
|
|
|
238
256
|
* @param config
|
|
239
257
|
* @param compilerOption
|
|
240
258
|
*/
|
|
241
|
-
|
|
259
|
+
UxAfterCompile.symlinkNodeModule = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
|
+
const { context, compilerOption } = params;
|
|
242
261
|
if (!compilerOption) {
|
|
243
262
|
return;
|
|
244
263
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
264
|
+
try {
|
|
265
|
+
const foldList = ['node_modules'];
|
|
266
|
+
foldList.forEach((item) => {
|
|
267
|
+
const sourcePath = path_1.default.join(context.projectPath, item);
|
|
268
|
+
const targetPath = path_1.default.join(compilerOption.projectPath, item);
|
|
269
|
+
if (fs_extra_1.default.existsSync(sourcePath) && !fs_extra_1.default.existsSync(targetPath)) {
|
|
270
|
+
fs_extra_1.default.symlinkSync(sourcePath, targetPath, 'junction');
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
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.`);
|
|
276
|
+
}
|
|
252
277
|
});
|
|
253
|
-
exports.default =
|
|
278
|
+
exports.default = UxAfterCompile;
|
|
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.generateEntryFile = exports.XtsEntryFileName = exports.entryTemplate = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
17
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const entryTemplate = (options) => {
|
|
@@ -29,7 +29,7 @@ const entryTemplate = (options) => {
|
|
|
29
29
|
const { routes = [] } = aspect;
|
|
30
30
|
for (let r = 0; r < (routes === null || routes === void 0 ? void 0 : routes.length); r++) {
|
|
31
31
|
const route = routes[r];
|
|
32
|
-
imports += `import Page${i + 1}_${r + 1}, { ${
|
|
32
|
+
imports += `import Page${i + 1}_${r + 1}, { ${parser_1.HomeState.interface} as ${parser_1.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
return imports;
|
|
@@ -45,7 +45,7 @@ const entryTemplate = (options) => {
|
|
|
45
45
|
for (let r = 0; r < routes.length; r++) {
|
|
46
46
|
const route = routes[r];
|
|
47
47
|
res += `
|
|
48
|
-
pathPages_${i + 1}.set('${route.route}', function (params?: ${
|
|
48
|
+
pathPages_${i + 1}.set('${route.route}', function (params?: ${parser_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
|
|
49
49
|
return new Page${i + 1}_${r + 1}(params)
|
|
50
50
|
})
|
|
51
51
|
`;
|
|
@@ -76,7 +76,7 @@ const entryTemplate = (options) => {
|
|
|
76
76
|
|
|
77
77
|
// export function
|
|
78
78
|
on
|
|
79
|
-
} from '../node_modules/${
|
|
79
|
+
} from '../node_modules/${parser_1.tsFrameWork.name}/index'
|
|
80
80
|
|
|
81
81
|
// import app
|
|
82
82
|
import AppClass from './${options.appPath}'
|
|
@@ -122,24 +122,25 @@ exports.XtsEntryFileName = '__entry__.ts';
|
|
|
122
122
|
* 生成 __entry__.ts 文件
|
|
123
123
|
* @param context
|
|
124
124
|
*/
|
|
125
|
-
const generateEntryFile = function generateEntryFile(
|
|
126
|
-
var _a, _b;
|
|
125
|
+
const generateEntryFile = function generateEntryFile(params) {
|
|
127
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
const { context, compilerOption } = params;
|
|
128
129
|
const { projectPath, output } = context;
|
|
129
|
-
if ((_a =
|
|
130
|
-
|
|
130
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
131
|
+
shared_utils_1.ColorConsole.info(`### skip generate entry file due to --skip xts2ts}`);
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
+
shared_utils_1.ColorConsole.info(`Generating entry file`);
|
|
134
135
|
const buildDir = path_1.default.resolve(projectPath, output);
|
|
135
136
|
const appManifestPath = path_1.default.join(buildDir, 'app', 'manifest.json');
|
|
136
137
|
const appManifest = getManifest(appManifestPath);
|
|
137
138
|
if (!appManifest) {
|
|
138
|
-
|
|
139
|
+
shared_utils_1.ColorConsole.throw('not find app/manifest.json file !');
|
|
139
140
|
}
|
|
140
141
|
const appTs = path_1.default.join(buildDir, 'app', 'app.ts');
|
|
141
142
|
if (!fs_extra_1.default.existsSync(appTs)) {
|
|
142
|
-
|
|
143
|
+
shared_utils_1.ColorConsole.throw('not find app/app.ts file !');
|
|
143
144
|
}
|
|
144
145
|
function relativeDist(tar) {
|
|
145
146
|
return path_1.default.join('.', path_1.default.relative(buildDir, tar)).replace(path_1.default.sep, '/');
|
|
@@ -177,7 +178,7 @@ const generateEntryFile = function generateEntryFile(context, _, compilerOptions
|
|
|
177
178
|
}
|
|
178
179
|
const template = (0, exports.entryTemplate)(opt);
|
|
179
180
|
fs_extra_1.default.writeFileSync(path_1.default.join(projectPath, output, exports.XtsEntryFileName), template);
|
|
180
|
-
|
|
181
|
+
shared_utils_1.ColorConsole.info(`entry file built`);
|
|
181
182
|
});
|
|
182
183
|
};
|
|
183
184
|
exports.generateEntryFile = generateEntryFile;
|
|
@@ -38,12 +38,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
exports.generateRpk = void 0;
|
|
39
39
|
const path_1 = __importDefault(require("path"));
|
|
40
40
|
const XtsFollowWorks_1 = __importDefault(require("../../utils/xts/XtsFollowWorks"));
|
|
41
|
-
const
|
|
41
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
42
42
|
const ts2wasm_1 = require("./ts2wasm");
|
|
43
|
-
const generateRpk = (
|
|
43
|
+
const generateRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
44
|
var _a;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const { context, compilerOption } = params;
|
|
46
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
|
|
47
|
+
shared_utils_1.ColorConsole.info(`### skip package due to --skip ${compilerOption.skip.join(',')}`);
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
const manifestPath = path_1.default.resolve(context.projectPath, 'app', 'manifest.json');
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ts2wasm = exports.wasmPackageName = void 0;
|
|
16
|
-
const
|
|
16
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
17
|
const child_process_1 = require("child_process");
|
|
18
18
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
19
19
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -24,8 +24,9 @@ exports.wasmPackageName = 'wasmUnpacked';
|
|
|
24
24
|
* 将 __entry__.ts 文件打包成 warm 文件
|
|
25
25
|
* @param context
|
|
26
26
|
*/
|
|
27
|
-
const ts2wasm = (
|
|
27
|
+
const ts2wasm = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
var _a;
|
|
29
|
+
const { context, compilerOption } = params;
|
|
29
30
|
/** 1. 生成 app.wasm 文件 */
|
|
30
31
|
const { projectPath, output } = context;
|
|
31
32
|
const buildDir = path_1.default.resolve(projectPath, output);
|
|
@@ -37,14 +38,14 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
|
|
|
37
38
|
function compile() {
|
|
38
39
|
// TODO: 后续修改为 @mi
|
|
39
40
|
const ts2wasmpath = path_1.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
|
|
40
|
-
|
|
41
|
+
shared_utils_1.ColorConsole.info('### Waiting for generating app.wasm file.');
|
|
41
42
|
const res = (0, child_process_1.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
|
|
42
43
|
encoding: 'utf-8'
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
+
shared_utils_1.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
|
|
45
46
|
}
|
|
46
|
-
if ((_a =
|
|
47
|
-
|
|
47
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
|
|
48
|
+
shared_utils_1.ColorConsole.info(`### skip compile ts to wasm due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
compile();
|
|
@@ -0,0 +1,22 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
13
|
+
const file_lane_1 = require("file-lane");
|
|
14
|
+
class UxAfterWorks {
|
|
15
|
+
static cleanOutput(context) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
18
|
+
shared_utils_1.FileUtil.del(outputPath);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = UxAfterWorks;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PreWork } from 'file-lane
|
|
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;
|
|
@@ -13,19 +13,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const UxFileUtils_1 = __importDefault(require("
|
|
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 = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
|
|
24
24
|
const { projectPath } = context;
|
|
25
|
-
|
|
25
|
+
const errors = yield UxFileUtils_1.default.validateManifest(projectPath);
|
|
26
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
27
|
+
return Promise.reject(errors);
|
|
28
|
+
}
|
|
26
29
|
});
|
|
27
|
-
|
|
30
|
+
UxBeforeCompile.validateSitemap = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
|
|
28
31
|
const { projectPath } = context;
|
|
29
32
|
UxFileUtils_1.default.validateSitemap(projectPath);
|
|
30
33
|
});
|
|
31
|
-
exports.default =
|
|
34
|
+
exports.default = UxBeforeCompile;
|
|
@@ -13,14 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.preInstall = void 0;
|
|
16
|
-
const
|
|
16
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
17
17
|
const child_process_1 = require("child_process");
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const preInstall = (
|
|
20
|
+
const preInstall = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
var _a;
|
|
22
|
+
const { context, compilerOption } = params;
|
|
22
23
|
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('install')) {
|
|
23
|
-
|
|
24
|
+
shared_utils_1.ColorConsole.info(`### skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
const { projectPath } = context;
|
|
@@ -47,12 +48,12 @@ const preInstall = (context, _, __, compilerOption) => __awaiter(void 0, void 0,
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
shared_utils_1.ColorConsole.info('### Installing pre-dependencies. The initial build may take some time, please be patient...');
|
|
51
52
|
(0, child_process_1.execSync)('npm install', {
|
|
52
53
|
cwd: projectPath
|
|
53
54
|
});
|
|
54
55
|
// 目前ts2wasm不支持@符号
|
|
55
56
|
fs_1.default.renameSync(path_1.default.resolve(projectPath, 'node_modules/@mi'), path_1.default.resolve(projectPath, 'node_modules/mi'));
|
|
56
|
-
|
|
57
|
+
shared_utils_1.ColorConsole.info('### Dependencies installation complete.');
|
|
57
58
|
});
|
|
58
59
|
exports.preInstall = preInstall;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
13
|
+
const file_lane_1 = require("file-lane");
|
|
14
|
+
class UxBeforeWorks {
|
|
15
|
+
static cleanOutput(context) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
18
|
+
shared_utils_1.FileUtil.del(outputPath);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = UxBeforeWorks;
|