@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,10 +12,11 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
16
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const webpack_1 = require("webpack");
|
|
19
|
+
const AndroidWebpackConfigurator_1 = __importDefault(require("./android/AndroidWebpackConfigurator"));
|
|
19
20
|
const VelaWebpackConfigurator_1 = __importDefault(require("./vela/VelaWebpackConfigurator"));
|
|
20
21
|
const UxCompileUtil_1 = __importDefault(require("./vela/utils/UxCompileUtil"));
|
|
21
22
|
class JavascriptCompiler {
|
|
@@ -29,7 +30,7 @@ class JavascriptCompiler {
|
|
|
29
30
|
const config = this.createWebpackConfig(param);
|
|
30
31
|
(0, webpack_1.webpack)(config, (error, stats) => {
|
|
31
32
|
if (error) {
|
|
32
|
-
reject([error]);
|
|
33
|
+
reject({ errors: [error] });
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
const statsObj = stats === null || stats === void 0 ? void 0 : stats.toJson();
|
|
@@ -51,7 +52,7 @@ class JavascriptCompiler {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
createWebpackConfig(param) {
|
|
54
|
-
const configurator = this.getConfigurator();
|
|
55
|
+
const configurator = this.getConfigurator(param);
|
|
55
56
|
if (!configurator) {
|
|
56
57
|
throw new Error(`This project is not supported`);
|
|
57
58
|
}
|
|
@@ -63,7 +64,7 @@ class JavascriptCompiler {
|
|
|
63
64
|
}
|
|
64
65
|
const { projectPath, mode, devtool, outputPath } = param;
|
|
65
66
|
const buildPath = path_1.default.resolve(projectPath, outputPath);
|
|
66
|
-
const quickAppConfig =
|
|
67
|
+
const quickAppConfig = shared_utils_1.CommonUtil.requireModule(path_1.default.join(param.projectPath, this.QUICKAPP_CONFIG));
|
|
67
68
|
const result = {
|
|
68
69
|
context: projectPath,
|
|
69
70
|
mode,
|
|
@@ -77,15 +78,18 @@ class JavascriptCompiler {
|
|
|
77
78
|
module: {
|
|
78
79
|
rules: [
|
|
79
80
|
{
|
|
80
|
-
test: /\.
|
|
81
|
+
test: /\.ux$/,
|
|
81
82
|
use: [
|
|
82
83
|
{
|
|
83
|
-
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/
|
|
84
|
+
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/extractMapData.js')
|
|
84
85
|
}
|
|
85
86
|
]
|
|
86
87
|
}
|
|
87
88
|
]
|
|
88
89
|
},
|
|
90
|
+
resolve: {
|
|
91
|
+
extensions: ['.js', '.ts', '.ux']
|
|
92
|
+
},
|
|
89
93
|
stats: {
|
|
90
94
|
builtAt: false,
|
|
91
95
|
entrypoints: false,
|
|
@@ -108,6 +112,17 @@ class JavascriptCompiler {
|
|
|
108
112
|
Array.isArray(readyRules) && readyRules.length > 0
|
|
109
113
|
? [...configuratorRules, ...readyRules]
|
|
110
114
|
: configuratorRules;
|
|
115
|
+
// 判断devtool类型 inline-source-map时,添加第0列关系映射
|
|
116
|
+
if (devtool === 'inline-source-map') {
|
|
117
|
+
result.module.rules.unshift({
|
|
118
|
+
test: /\.ux$/,
|
|
119
|
+
use: [
|
|
120
|
+
{
|
|
121
|
+
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/addColSourceMap.js')
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
111
126
|
}
|
|
112
127
|
if (configurator.createPlugins) {
|
|
113
128
|
result.plugins = configurator.createPlugins();
|
|
@@ -117,8 +132,17 @@ class JavascriptCompiler {
|
|
|
117
132
|
}
|
|
118
133
|
return lodash_1.default.merge({}, result, quickAppConfig === null || quickAppConfig === void 0 ? void 0 : quickAppConfig.webpack);
|
|
119
134
|
}
|
|
120
|
-
getConfigurator() {
|
|
121
|
-
|
|
135
|
+
getConfigurator(param) {
|
|
136
|
+
const { projectPath, sourceRoot } = param;
|
|
137
|
+
const projectType = shared_utils_1.ProjectType.getProjectType(projectPath, sourceRoot);
|
|
138
|
+
switch (projectType) {
|
|
139
|
+
case shared_utils_1.ProjectType.VELA_UX:
|
|
140
|
+
return new VelaWebpackConfigurator_1.default();
|
|
141
|
+
case shared_utils_1.ProjectType.ANDDROID_UX:
|
|
142
|
+
return new AndroidWebpackConfigurator_1.default();
|
|
143
|
+
default:
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
122
146
|
}
|
|
123
147
|
clean(param) {
|
|
124
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import VelaWebpackConfigurator from '../vela/VelaWebpackConfigurator';
|
|
2
|
+
import WrapPlugin from './plugin/WrapPlugin';
|
|
3
|
+
/**
|
|
4
|
+
* AndroidWebpackConfigurator
|
|
5
|
+
*/
|
|
6
|
+
declare class AndroidWebpackConfigurator extends VelaWebpackConfigurator {
|
|
7
|
+
protected createWrapPlugin(): WrapPlugin;
|
|
8
|
+
}
|
|
9
|
+
export default AndroidWebpackConfigurator;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 VelaWebpackConfigurator_1 = __importDefault(require("../vela/VelaWebpackConfigurator"));
|
|
7
|
+
const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
8
|
+
/**
|
|
9
|
+
* AndroidWebpackConfigurator
|
|
10
|
+
*/
|
|
11
|
+
class AndroidWebpackConfigurator extends VelaWebpackConfigurator_1.default {
|
|
12
|
+
createWrapPlugin() {
|
|
13
|
+
return new WrapPlugin_1.default(this.param);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = AndroidWebpackConfigurator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Compiler } from 'webpack';
|
|
2
|
+
import IJavascriptCompileOption from '../../interface/IJavascriptCompileOption';
|
|
3
|
+
/**
|
|
4
|
+
* WrapPlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class WrapPlugin {
|
|
7
|
+
private readonly param;
|
|
8
|
+
constructor(param: IJavascriptCompileOption);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
/**
|
|
11
|
+
* 添加包含代码
|
|
12
|
+
*
|
|
13
|
+
* 1. 仅 page 文件添加
|
|
14
|
+
* @param compilation
|
|
15
|
+
*/
|
|
16
|
+
private wrap;
|
|
17
|
+
private wrapPage;
|
|
18
|
+
private wrapApp;
|
|
19
|
+
}
|
|
20
|
+
export default WrapPlugin;
|
|
@@ -0,0 +1,78 @@
|
|
|
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 webpack_1 = require("webpack");
|
|
7
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
8
|
+
const UxFileUtils_1 = __importDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
9
|
+
/**
|
|
10
|
+
* WrapPlugin
|
|
11
|
+
*/
|
|
12
|
+
class WrapPlugin {
|
|
13
|
+
constructor(param) {
|
|
14
|
+
this.param = param;
|
|
15
|
+
}
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
|
|
18
|
+
compilation.hooks.processAssets.tap({
|
|
19
|
+
name: 'WrapPlugin',
|
|
20
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
21
|
+
}, () => {
|
|
22
|
+
this.wrap(compilation);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 添加包含代码
|
|
28
|
+
*
|
|
29
|
+
* 1. 仅 page 文件添加
|
|
30
|
+
* @param compilation
|
|
31
|
+
*/
|
|
32
|
+
wrap(compilation) {
|
|
33
|
+
// 获取入口文件
|
|
34
|
+
const entrys = Object.keys(compilation.options.entry).map((item) => `${item}.js`);
|
|
35
|
+
entrys.forEach((entry) => {
|
|
36
|
+
if (compilation.assets[entry]) {
|
|
37
|
+
const source = compilation.assets[entry];
|
|
38
|
+
const isApp = entry === 'app.js';
|
|
39
|
+
compilation.assets[entry] = isApp
|
|
40
|
+
? this.wrapApp(source)
|
|
41
|
+
: this.wrapPage(source);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
wrapPage(source) {
|
|
46
|
+
return new webpack_sources_1.ConcatSource(`
|
|
47
|
+
(function () {
|
|
48
|
+
var createPageHandler = function () {
|
|
49
|
+
return`, source, `;
|
|
50
|
+
};
|
|
51
|
+
if (typeof window === "undefined") {
|
|
52
|
+
return createPageHandler();
|
|
53
|
+
} else {
|
|
54
|
+
window.createPageHandler = createPageHandler;
|
|
55
|
+
}
|
|
56
|
+
})();`);
|
|
57
|
+
}
|
|
58
|
+
wrapApp(source) {
|
|
59
|
+
const { projectPath, sourceRoot } = this.param;
|
|
60
|
+
return new webpack_sources_1.ConcatSource(`
|
|
61
|
+
(function () {
|
|
62
|
+
var $app_define_wrap$ = $app_define_wrap$ || function () {};
|
|
63
|
+
var manifestJson =${JSON.stringify(UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot))}
|
|
64
|
+
var createAppHandler = function () {
|
|
65
|
+
`, source, `
|
|
66
|
+
}
|
|
67
|
+
if (typeof window === "undefined") {
|
|
68
|
+
return createAppHandler();
|
|
69
|
+
} else {
|
|
70
|
+
window.createAppHandler = createAppHandler;
|
|
71
|
+
// H5注入manifest以获取features
|
|
72
|
+
global.manifest = manifestJson;
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = WrapPlugin;
|
|
@@ -22,6 +22,9 @@ export default interface IJavascriptCompileOption extends ICompileParam {
|
|
|
22
22
|
* 项目运行的代码覆盖率数据
|
|
23
23
|
*/
|
|
24
24
|
dataCoverage: string;
|
|
25
|
+
/**
|
|
26
|
+
* 记录“连接过的设备信息”的文件地址
|
|
27
|
+
*/
|
|
25
28
|
clientRecordPath: string;
|
|
26
29
|
/**
|
|
27
30
|
* 运行端口
|
|
@@ -36,9 +39,21 @@ export default interface IJavascriptCompileOption extends ICompileParam {
|
|
|
36
39
|
/**
|
|
37
40
|
* 禁用 jsc
|
|
38
41
|
*/
|
|
39
|
-
|
|
42
|
+
disabledJsc?: boolean;
|
|
40
43
|
/**
|
|
41
44
|
* 启用 protobuf
|
|
42
45
|
*/
|
|
43
46
|
enableProtobuf?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 启用应用自动化测试
|
|
49
|
+
*/
|
|
50
|
+
enableE2e?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 启用代码体积分析,会生成 report.html 文件,可查看打包后各模块占用体积
|
|
53
|
+
*/
|
|
54
|
+
enableStats?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 是否自动补全 manifest.json 中的 features 配置
|
|
57
|
+
*/
|
|
58
|
+
completeFeature?: boolean;
|
|
44
59
|
}
|
|
@@ -5,6 +5,8 @@ import IWebpackConfigurator from '../interface/IWebpackConfigurator';
|
|
|
5
5
|
declare class VelaWebpackConfigurator implements IWebpackConfigurator {
|
|
6
6
|
param: ICompileParam & IJavascriptCompileOption;
|
|
7
7
|
createPlugins(): WebpackPluginInstance[];
|
|
8
|
+
protected createWrapPlugin(): WebpackPluginInstance;
|
|
9
|
+
protected createBundleAnalyzerPlugin(): any;
|
|
8
10
|
/**
|
|
9
11
|
* 通过读取 manifest.json 生成 entry
|
|
10
12
|
* @returns
|
|
@@ -10,10 +10,24 @@ const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
|
10
10
|
const UxCompileUtil_1 = __importDefault(require("./utils/UxCompileUtil"));
|
|
11
11
|
class VelaWebpackConfigurator {
|
|
12
12
|
createPlugins() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// 包裹代码的插件
|
|
14
|
+
const result = [this.createWrapPlugin()];
|
|
15
|
+
// 如果开启 stats 参数,则添加 webpack-bundle-analyzer 插件
|
|
16
|
+
if (this.param.enableStats) {
|
|
17
|
+
result.push(this.createBundleAnalyzerPlugin());
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
createWrapPlugin() {
|
|
22
|
+
return new WrapPlugin_1.default();
|
|
23
|
+
}
|
|
24
|
+
createBundleAnalyzerPlugin() {
|
|
25
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
26
|
+
return new BundleAnalyzerPlugin({
|
|
27
|
+
analyzerMode: 'static',
|
|
28
|
+
openAnalyzer: false,
|
|
29
|
+
excludeAssets: /^@(system|service)\./
|
|
30
|
+
});
|
|
17
31
|
}
|
|
18
32
|
/**
|
|
19
33
|
* 通过读取 manifest.json 生成 entry
|
|
@@ -40,7 +54,6 @@ class VelaWebpackConfigurator {
|
|
|
40
54
|
{
|
|
41
55
|
loader: require.resolve('babel-loader'),
|
|
42
56
|
options: {
|
|
43
|
-
// configFile: getBabelConfigJsPath(cwd),
|
|
44
57
|
cwd: this.param.projectPath,
|
|
45
58
|
cacheDirectory: true
|
|
46
59
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
4
|
/**
|
|
8
5
|
* 定义文件包
|
|
9
6
|
*
|
|
@@ -38,7 +35,7 @@ class Package {
|
|
|
38
35
|
addResource(data) {
|
|
39
36
|
const { fileBuildPath } = data;
|
|
40
37
|
if (this.include(fileBuildPath)) {
|
|
41
|
-
|
|
38
|
+
shared_utils_1.ColorConsole.throw(`File ${fileBuildPath} is added repeatedly`);
|
|
42
39
|
return;
|
|
43
40
|
}
|
|
44
41
|
this._resourceDic[fileBuildPath] = true;
|
|
@@ -3,8 +3,7 @@ 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
|
|
7
|
-
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
6
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
8
7
|
const del_1 = __importDefault(require("del"));
|
|
9
8
|
/**
|
|
10
9
|
* Jsc
|
|
@@ -16,7 +15,7 @@ class Jsc {
|
|
|
16
15
|
}
|
|
17
16
|
jsc() {
|
|
18
17
|
const { projectPath, buildPath } = this;
|
|
19
|
-
return
|
|
18
|
+
return shared_utils_1.CommonUtil.requireNodeModule(projectPath, `@aiot-toolkit/jsc`)
|
|
20
19
|
.then((module) => {
|
|
21
20
|
return module.default(buildPath);
|
|
22
21
|
})
|
|
@@ -24,7 +23,7 @@ class Jsc {
|
|
|
24
23
|
return (0, del_1.default)(`${buildPath}/**/*.js`, { force: true });
|
|
25
24
|
})
|
|
26
25
|
.catch((error) => {
|
|
27
|
-
|
|
26
|
+
shared_utils_1.ColorConsole.throw(error.message);
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -3,7 +3,7 @@ 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
|
|
6
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const EntryType_1 = __importDefault(require("../enum/EntryType"));
|
|
@@ -37,7 +37,7 @@ class UxCompileUtil {
|
|
|
37
37
|
}
|
|
38
38
|
const appFile = this.resolveFile(path_1.default.join(codeDir, 'app'));
|
|
39
39
|
if (!fs_extra_1.default.existsSync(appFile)) {
|
|
40
|
-
|
|
40
|
+
shared_utils_1.ColorConsole.throw(`App file does not exist`);
|
|
41
41
|
}
|
|
42
42
|
const { pages = {}, widgets = {}, floatingWindows = {} } = router;
|
|
43
43
|
const confsList = [
|
|
@@ -130,7 +130,7 @@ class UxCompileUtil {
|
|
|
130
130
|
* @returns
|
|
131
131
|
*/
|
|
132
132
|
static getExtensionList(withDot = true) {
|
|
133
|
-
const result = ['
|
|
133
|
+
const result = ['ux', 'hml'];
|
|
134
134
|
if (withDot) {
|
|
135
135
|
return result.map((item) => `.${item}`);
|
|
136
136
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Dictionary } from '@aiot-toolkit/shared-utils
|
|
2
|
+
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
3
3
|
import JSZip from 'jszip';
|
|
4
4
|
import IJavascriptCompileOption from '../../interface/IJavascriptCompileOption';
|
|
5
5
|
import IManifest from '../interface/IManifest';
|
|
@@ -13,9 +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
|
|
17
|
-
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
18
|
-
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
16
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
19
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
18
|
const jszip_1 = __importDefault(require("jszip"));
|
|
21
19
|
const path_1 = __importDefault(require("path"));
|
|
@@ -51,7 +49,7 @@ class ZipUtil {
|
|
|
51
49
|
// 1
|
|
52
50
|
const files = this.getSortedFiles(dist, param, config);
|
|
53
51
|
if (!files.length) {
|
|
54
|
-
|
|
52
|
+
shared_utils_1.ColorConsole.error(`The build file is missing, stop generating the application package, please check carefully`);
|
|
55
53
|
return;
|
|
56
54
|
}
|
|
57
55
|
// 2
|
|
@@ -95,7 +93,7 @@ class ZipUtil {
|
|
|
95
93
|
const { releasePath, projectPath } = param;
|
|
96
94
|
const filePath = path_1.default.join(projectPath, releasePath, fileName);
|
|
97
95
|
fs_extra_1.default.outputFileSync(filePath, buffer);
|
|
98
|
-
|
|
96
|
+
shared_utils_1.ColorConsole.success(`Project build and generate files:${fileName}`);
|
|
99
97
|
});
|
|
100
98
|
}
|
|
101
99
|
static createZipBufferFromFileList(fileList, comment) {
|
|
@@ -133,7 +131,7 @@ class ZipUtil {
|
|
|
133
131
|
let metaZip = yield jszip_1.default.loadAsync(fileContentBuffer);
|
|
134
132
|
fileContentBuffer = (yield metaZip.generateAsync(Object.assign(Object.assign({}, ZipUtil.ZIP_OPTION), { comment: null })));
|
|
135
133
|
}
|
|
136
|
-
const fileContentDigest =
|
|
134
|
+
const fileContentDigest = shared_utils_1.CommonUtil.calcDataDigest(fileContentBuffer);
|
|
137
135
|
const resourceInfo = {
|
|
138
136
|
fileBuildPath,
|
|
139
137
|
fileContentBuffer,
|
|
@@ -174,13 +172,13 @@ class ZipUtil {
|
|
|
174
172
|
// 1. 排除META-INF 目录下的文件
|
|
175
173
|
// 2. 生产环境排除 .map 文件
|
|
176
174
|
const mapReg = /\.map$/;
|
|
177
|
-
let result =
|
|
175
|
+
let result = shared_utils_1.FileUtil.readAlldirSync(dist);
|
|
178
176
|
result = result
|
|
179
177
|
.filter((item) => {
|
|
180
178
|
return !(item.startsWith(UxCompileUtil_1.default.DIGEST_ZIP_DIR) ||
|
|
181
179
|
(param.mode === CompileMode_1.default.PRODUCTION && mapReg.test(item)));
|
|
182
180
|
})
|
|
183
|
-
.map((item) => path_1.default.relative(dist, item));
|
|
181
|
+
.map((item) => path_1.default.relative(dist, item).split(path_1.default.sep).join(path_1.default.posix.sep));
|
|
184
182
|
result.sort((a, b) => {
|
|
185
183
|
const indexA = getFileIndex(a);
|
|
186
184
|
const indexB = getFileIndex(b);
|
|
@@ -240,7 +238,7 @@ class ZipUtil {
|
|
|
240
238
|
// fullPackageBuffer
|
|
241
239
|
const fullPackageBuffer = yield SignUtil_1.default.signZipBufferForPackage(fullPackage, privatekey, certificate);
|
|
242
240
|
if (fullPackageBuffer === false) {
|
|
243
|
-
|
|
241
|
+
shared_utils_1.ColorConsole.throw('Fullpackage signature failed');
|
|
244
242
|
}
|
|
245
243
|
else {
|
|
246
244
|
fullPackage = fullPackageBuffer;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import ICompileParam from '../../../../interface/ICompileParam';
|
|
3
2
|
import IJavascriptCompileOption from '../../../interface/IJavascriptCompileOption';
|
|
4
3
|
/**
|
|
5
4
|
* SignUtil
|
|
@@ -7,11 +6,10 @@ import IJavascriptCompileOption from '../../../interface/IJavascriptCompileOptio
|
|
|
7
6
|
declare class SignUtil {
|
|
8
7
|
/**
|
|
9
8
|
* 获取签名相关的配置内容
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param param
|
|
9
|
+
* @param param IJavascriptCompileOption参数中获取签名目录等内容
|
|
10
|
+
* @returns
|
|
13
11
|
*/
|
|
14
|
-
static getProjectSignConfig(param:
|
|
12
|
+
static getProjectSignConfig(param: IJavascriptCompileOption): {
|
|
15
13
|
privatekey: Buffer;
|
|
16
14
|
certificate: Buffer;
|
|
17
15
|
};
|