@aiot-toolkit/aiotpack 2.0.3-beta.7 → 2.0.3-beta.8
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/afterCompile/ux/UxAfterCompile.js +301 -266
- package/lib/afterCompile/xts/entryTemplate.js +111 -113
- package/lib/afterCompile/xts/generateRpk.js +25 -54
- package/lib/afterCompile/xts/ts2wasm.js +62 -63
- package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
- package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -25
- package/lib/beforeCompile/xts/preInstall.js +50 -55
- package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
- package/lib/compiler/enum/CompileMode.js +16 -23
- package/lib/compiler/interface/ICompileParam.js +1 -2
- package/lib/compiler/interface/ICompiler.js +1 -2
- package/lib/compiler/interface/ISignConfig.js +1 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +52 -48
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
- package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
- package/lib/compiler/javascript/vela/model/Package.js +80 -51
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +30 -26
- package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -276
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
- package/lib/config/UxConfig.js +145 -173
- package/lib/config/XtsConfig.js +30 -40
- package/lib/index.js +88 -41
- package/lib/interface/ICompileOptions.js +5 -2
- package/lib/interface/IDeviceList.js +1 -2
- package/lib/loader/ux/JsLoader.js +32 -30
- package/lib/loader/ux/PngLoader.js +47 -53
- package/lib/loader/ux/android/UxLoader.js +30 -31
- package/lib/loader/ux/vela/AppUxLoader.js +23 -24
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.js +29 -35
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -92
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.js +130 -116
- package/lib/utils/ux/UxLoaderUtils.js +292 -307
- package/lib/utils/ux/android/AndroidUx.js +88 -90
- package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
- package/lib/utils/xts/XtsFollowWorks.js +122 -129
- package/package.json +6 -6
|
@@ -1,305 +1,340 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const CompileMode_1 = __importDefault(require("../../compiler/enum/CompileMode"));
|
|
21
|
-
const JavascriptCompiler_1 = __importDefault(require("../../compiler/javascript/JavascriptCompiler"));
|
|
22
|
-
const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler/javascript/JavascriptDefaultCompileOption"));
|
|
23
|
-
const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
24
|
-
const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
25
|
-
const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
26
|
-
const archiver_1 = __importDefault(require("archiver"));
|
|
27
|
-
const FileLaneTriggerType_1 = __importDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _CompileMode = _interopRequireDefault(require("../../compiler/enum/CompileMode"));
|
|
12
|
+
var _JavascriptCompiler = _interopRequireDefault(require("../../compiler/javascript/JavascriptCompiler"));
|
|
13
|
+
var _JavascriptDefaultCompileOption = _interopRequireDefault(require("../../compiler/javascript/JavascriptDefaultCompileOption"));
|
|
14
|
+
var _Jsc = _interopRequireDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
15
|
+
var _ZipUtil = _interopRequireDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
16
|
+
var _UxFileUtils = _interopRequireDefault(require("../../utils/ux/UxFileUtils"));
|
|
17
|
+
var _archiver = _interopRequireDefault(require("archiver"));
|
|
18
|
+
var _FileLaneTriggerType = _interopRequireDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
20
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
21
|
+
|
|
29
22
|
/**
|
|
30
23
|
* UxAfterCompile
|
|
31
24
|
*/
|
|
32
25
|
class UxAfterCompile {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
static webpack = async params => {
|
|
27
|
+
const {
|
|
28
|
+
context,
|
|
29
|
+
compilerOption
|
|
30
|
+
} = params;
|
|
31
|
+
return new _JavascriptCompiler.default().compile({
|
|
32
|
+
projectPath: _path.default.join(context.projectPath, context.output),
|
|
33
|
+
mode: _CompileMode.default.DEVELOPMENT,
|
|
34
|
+
devtool: false,
|
|
35
|
+
platform: 'vela',
|
|
36
|
+
..._JavascriptDefaultCompileOption.default,
|
|
37
|
+
...compilerOption
|
|
38
|
+
}).then(() => {
|
|
39
|
+
_sharedUtils.ColorConsole.info(`webpack complete`);
|
|
40
|
+
}).catch(_ref => {
|
|
41
|
+
let {
|
|
42
|
+
errors,
|
|
43
|
+
warnings
|
|
44
|
+
} = _ref;
|
|
45
|
+
const errorLength = errors?.length || 0;
|
|
46
|
+
const messages = [`webpack error:\r\n`];
|
|
47
|
+
if (errors?.length) {
|
|
48
|
+
messages.push({
|
|
49
|
+
word: errors.map((item, index) => {
|
|
50
|
+
return `${index + 1}. ${item.message}`;
|
|
51
|
+
}).join('\r\n'),
|
|
52
|
+
style: _sharedUtils.ColorConsole.getStyle(_sharedUtils.Loglevel.THROW)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (warnings?.length) {
|
|
56
|
+
messages.push({
|
|
57
|
+
word: warnings.map((item, index) => {
|
|
58
|
+
return `${errorLength + index + 1}. ${item.message}`;
|
|
59
|
+
}).join('\r\n'),
|
|
60
|
+
style: _sharedUtils.ColorConsole.getStyle(_sharedUtils.Loglevel.WARN)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (errors?.length) {
|
|
64
|
+
_sharedUtils.ColorConsole.throw(...messages);
|
|
65
|
+
throw new Error();
|
|
66
|
+
} else {
|
|
67
|
+
_sharedUtils.ColorConsole.warn(...messages);
|
|
68
|
+
}
|
|
72
69
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const {
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
};
|
|
71
|
+
static protobuf = async params => {
|
|
72
|
+
const {
|
|
73
|
+
compilerOption
|
|
74
|
+
} = params;
|
|
75
|
+
if (compilerOption?.enableProtobuf) {
|
|
76
|
+
BinaryPlugin.createBinFiles();
|
|
78
77
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const {
|
|
78
|
+
};
|
|
79
|
+
static jsc = async params => {
|
|
80
|
+
const {
|
|
81
|
+
context,
|
|
82
|
+
compilerOption
|
|
83
|
+
} = params;
|
|
82
84
|
if (compilerOption && compilerOption.enableJsc === true) {
|
|
83
|
-
|
|
85
|
+
return new _Jsc.default(context.projectPath, _path.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
84
86
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const {
|
|
87
|
+
};
|
|
88
|
+
static toRpk = async params => {
|
|
89
|
+
const {
|
|
90
|
+
compilerOption,
|
|
91
|
+
compalition,
|
|
92
|
+
config
|
|
93
|
+
} = params;
|
|
88
94
|
if (compilerOption) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
const fileName = await _ZipUtil.default.createRpk(_path.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
|
|
96
|
+
if (compalition && fileName) {
|
|
97
|
+
compalition.info.rpk = _path.default.join(config.projectPath, compilerOption.releasePath, fileName);
|
|
98
|
+
}
|
|
99
|
+
return fileName;
|
|
94
100
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 复制各类资源文件,例如图片、视频等
|
|
105
|
+
* @param context
|
|
106
|
+
* @param config
|
|
107
|
+
* @param compilerOption
|
|
108
|
+
*/
|
|
109
|
+
static copyResource = async params => {
|
|
110
|
+
const {
|
|
111
|
+
context,
|
|
112
|
+
compilerOption
|
|
113
|
+
} = params;
|
|
114
|
+
const genDeviceManifests = compilerOption => {
|
|
115
|
+
const {
|
|
116
|
+
projectPath,
|
|
117
|
+
sourceRoot,
|
|
118
|
+
outputPath
|
|
119
|
+
} = compilerOption;
|
|
120
|
+
const manifest = _fsExtra.default.readJSONSync(_path.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
121
|
+
const {
|
|
122
|
+
deviceTypeList
|
|
123
|
+
} = manifest;
|
|
124
|
+
// 生成设备的 manifest 文件,规则为:manifest.json + config-设备类型.json
|
|
125
|
+
if (deviceTypeList) {
|
|
126
|
+
deviceTypeList.forEach(deviceType => {
|
|
127
|
+
let data = {
|
|
128
|
+
...manifest
|
|
129
|
+
};
|
|
130
|
+
const deviceConfigPath = _path.default.join(projectPath, sourceRoot, `config-${deviceType}.json`);
|
|
131
|
+
if (_fsExtra.default.existsSync(deviceConfigPath)) {
|
|
132
|
+
const deviceJson = _fsExtra.default.readJSONSync(deviceConfigPath);
|
|
133
|
+
data = _lodash.default.merge({}, data, deviceJson);
|
|
134
|
+
}
|
|
135
|
+
const buildPath = _path.default.join(projectPath, outputPath, `manifest-${deviceType}.json`);
|
|
136
|
+
_fsExtra.default.writeFileSync(buildPath, JSON.stringify(data, undefined, 2));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
121
139
|
};
|
|
122
|
-
const copyResourceFiles =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
'less',
|
|
135
|
-
'sass',
|
|
136
|
-
'styl',
|
|
137
|
-
'html',
|
|
138
|
-
'md',
|
|
139
|
-
'ux',
|
|
140
|
-
'mix',
|
|
141
|
-
'DS_Store',
|
|
142
|
-
'map'
|
|
143
|
-
];
|
|
144
|
-
const excludeReg = `\\.(${excludeExtList.join('|')})$`;
|
|
145
|
-
shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
|
|
146
|
-
shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), undefined, includeList);
|
|
140
|
+
const copyResourceFiles = compilerOption => {
|
|
141
|
+
// 复制除 js/jsx/ts/tsx/json 外,但是包含manifest.json、sitemap.json的文件
|
|
142
|
+
const {
|
|
143
|
+
projectPath,
|
|
144
|
+
sourceRoot,
|
|
145
|
+
outputPath
|
|
146
|
+
} = compilerOption;
|
|
147
|
+
const includeList = [/sitemap\.json$/, /i18n(.+)\.json/];
|
|
148
|
+
const excludeExtList = ['js', 'jsx', 'coffee', 'ts', 'tsx', 'vue', 'css', 'less', 'sass', 'styl', 'html', 'md', 'ux', 'mix', 'DS_Store', 'map'];
|
|
149
|
+
const excludeReg = `\\.(${excludeExtList.join('|')})$`;
|
|
150
|
+
_sharedUtils.FileUtil.copyFiles(_path.default.join(projectPath, sourceRoot), _path.default.join(projectPath, outputPath), new RegExp(excludeReg));
|
|
151
|
+
_sharedUtils.FileUtil.copyFiles(_path.default.join(projectPath, sourceRoot), _path.default.join(projectPath, outputPath), undefined, includeList);
|
|
147
152
|
};
|
|
153
|
+
|
|
148
154
|
/**
|
|
149
155
|
* 写入 manifest.json 文件
|
|
150
156
|
*
|
|
151
157
|
* 需要在源码manifest.json基础加一些额外的内容
|
|
152
158
|
* @param compilerOption
|
|
153
159
|
*/
|
|
154
|
-
const updateManifest =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
const updateManifest = compilerOption => {
|
|
161
|
+
const {
|
|
162
|
+
projectPath,
|
|
163
|
+
sourceRoot,
|
|
164
|
+
outputPath,
|
|
165
|
+
completeFeature
|
|
166
|
+
} = compilerOption;
|
|
167
|
+
const content = _UxFileUtils.default.getMainfestInfo(projectPath, sourceRoot);
|
|
168
|
+
const translateCache = context.translateCache;
|
|
169
|
+
if (!content.minAPILevel) {
|
|
170
|
+
content.minAPILevel = 1;
|
|
171
|
+
}
|
|
172
|
+
if (!content.packageInfo) {
|
|
173
|
+
content.packageInfo = _ZipUtil.default.createComment(compilerOption);
|
|
174
|
+
}
|
|
175
|
+
if (completeFeature && translateCache?.featureCache.size) {
|
|
176
|
+
const featureSet = new Set([...Array.from(translateCache.featureCache), ...(content.features || []).map(item => item.name)]);
|
|
177
|
+
content.features = Array.from(featureSet).map(item => {
|
|
178
|
+
return {
|
|
179
|
+
name: item
|
|
180
|
+
};
|
|
175
181
|
});
|
|
182
|
+
}
|
|
183
|
+
_fsExtra.default.writeJSONSync(_path.default.join(projectPath, outputPath, _UxFileUtils.default.CONFIG_FILE_NAME), content, {
|
|
184
|
+
spaces: 2
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
const genMetaFiles = async compilerOption => {
|
|
188
|
+
const {
|
|
189
|
+
projectPath,
|
|
190
|
+
outputPath,
|
|
191
|
+
sourceRoot
|
|
192
|
+
} = compilerOption;
|
|
193
|
+
const outputAbsPath = _path.default.join(projectPath, outputPath);
|
|
194
|
+
const comment = _ZipUtil.default.createComment(compilerOption);
|
|
195
|
+
|
|
196
|
+
// build.txt
|
|
197
|
+
const content = Object.keys(comment).map(key => `${key}=${comment[key]}`).join('\n');
|
|
198
|
+
_fsExtra.default.outputFileSync(_path.default.join(outputAbsPath, _ZipUtil.default.BUILD_FILE_PATH), content);
|
|
199
|
+
// cert
|
|
200
|
+
const files = _ZipUtil.default.getSortedFiles(outputAbsPath, compilerOption, _UxFileUtils.default.getMainfestInfo(projectPath, sourceRoot));
|
|
201
|
+
const digestDic = Object.fromEntries(files.map(item => [item, _sharedUtils.CommonUtil.calcDataDigest(_fsExtra.default.readFileSync(_path.default.join(outputAbsPath, item))).toString('hex')]));
|
|
202
|
+
const hashJson = [{
|
|
203
|
+
path: _ZipUtil.default.DIGEST_HASH_JSON,
|
|
204
|
+
content: JSON.stringify({
|
|
205
|
+
algorithm: 'SHA-256',
|
|
206
|
+
digests: digestDic
|
|
207
|
+
})
|
|
208
|
+
}];
|
|
209
|
+
const buffer = await _ZipUtil.default.createZipBufferFromFileList(hashJson, JSON.stringify(comment));
|
|
210
|
+
_fsExtra.default.outputFileSync(_path.default.join(outputAbsPath, _ZipUtil.default.CERT_PATH), buffer);
|
|
176
211
|
};
|
|
177
|
-
const genMetaFiles = (compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
-
const { projectPath, outputPath, sourceRoot } = compilerOption;
|
|
179
|
-
const outputAbsPath = path_1.default.join(projectPath, outputPath);
|
|
180
|
-
const comment = ZipUtil_1.default.createComment(compilerOption);
|
|
181
|
-
// build.txt
|
|
182
|
-
const content = Object.keys(comment)
|
|
183
|
-
.map((key) => `${key}=${comment[key]}`)
|
|
184
|
-
.join('\n');
|
|
185
|
-
fs_extra_1.default.outputFileSync(path_1.default.join(outputAbsPath, ZipUtil_1.default.BUILD_FILE_PATH), content);
|
|
186
|
-
// cert
|
|
187
|
-
const files = ZipUtil_1.default.getSortedFiles(outputAbsPath, compilerOption, UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot));
|
|
188
|
-
const digestDic = Object.fromEntries(files.map((item) => [
|
|
189
|
-
item,
|
|
190
|
-
shared_utils_1.CommonUtil.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
|
|
191
|
-
]));
|
|
192
|
-
const hashJson = [
|
|
193
|
-
{
|
|
194
|
-
path: ZipUtil_1.default.DIGEST_HASH_JSON,
|
|
195
|
-
content: JSON.stringify({
|
|
196
|
-
algorithm: 'SHA-256',
|
|
197
|
-
digests: digestDic
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
];
|
|
201
|
-
const buffer = yield ZipUtil_1.default.createZipBufferFromFileList(hashJson, JSON.stringify(comment));
|
|
202
|
-
fs_extra_1.default.outputFileSync(path_1.default.join(outputAbsPath, ZipUtil_1.default.CERT_PATH), buffer);
|
|
203
|
-
});
|
|
204
212
|
if (compilerOption) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
213
|
+
await copyResourceFiles(compilerOption);
|
|
214
|
+
await updateManifest(compilerOption);
|
|
215
|
+
await genDeviceManifests(compilerOption);
|
|
216
|
+
await genMetaFiles(compilerOption);
|
|
209
217
|
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const {
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* 如果是更新触发,则对比临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
221
|
+
* @param context
|
|
222
|
+
* @param config
|
|
223
|
+
* @param compilerOption
|
|
224
|
+
*/
|
|
225
|
+
static generateDiff = async params => {
|
|
226
|
+
const {
|
|
227
|
+
compilerOption,
|
|
228
|
+
compalition,
|
|
229
|
+
config
|
|
230
|
+
} = params;
|
|
219
231
|
if (!compilerOption || !compalition) {
|
|
220
|
-
|
|
232
|
+
return;
|
|
221
233
|
}
|
|
222
|
-
if (compalition.trigger ===
|
|
223
|
-
|
|
234
|
+
if (compalition.trigger === _FileLaneTriggerType.default.START) {
|
|
235
|
+
return;
|
|
224
236
|
}
|
|
225
|
-
const {
|
|
237
|
+
const {
|
|
238
|
+
outputPath,
|
|
239
|
+
projectPath
|
|
240
|
+
} = compilerOption;
|
|
226
241
|
// 读取临时项目build文件夹中所有文件路径
|
|
227
|
-
const tempBuildPath =
|
|
242
|
+
const tempBuildPath = _path.default.join(projectPath, outputPath);
|
|
228
243
|
// 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
|
|
229
|
-
const tempFileList =
|
|
230
|
-
const diffList =
|
|
244
|
+
const tempFileList = _sharedUtils.FileUtil.readAlldirSync(tempBuildPath).map(filePath => _path.default.relative(tempBuildPath, filePath));
|
|
245
|
+
const diffList = _UxFileUtils.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
|
|
246
|
+
|
|
231
247
|
// 所有差异文件,压缩到 .diff.rpk 中
|
|
232
|
-
if (diffList
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
if (diffList?.length) {
|
|
249
|
+
const buildFold = _path.default.join(compilerOption.projectPath, compilerOption.outputPath);
|
|
250
|
+
const distFold = _path.default.join(compilerOption.projectPath, compilerOption.releasePath);
|
|
251
|
+
const diffFileName = `.diff.rpk`;
|
|
252
|
+
const diffPath = _path.default.join(distFold, diffFileName);
|
|
253
|
+
const diffStream = _fsExtra.default.createWriteStream(diffPath);
|
|
254
|
+
const archiver = (0, _archiver.default)('zip', {
|
|
255
|
+
zlib: {
|
|
256
|
+
level: 9
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
archiver.pipe(diffStream);
|
|
260
|
+
diffList.forEach(item => {
|
|
261
|
+
const filePath = _path.default.join(buildFold, item);
|
|
262
|
+
archiver.append(_fsExtra.default.createReadStream(filePath), {
|
|
263
|
+
name: item
|
|
243
264
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
265
|
+
});
|
|
266
|
+
await archiver.finalize();
|
|
267
|
+
compalition.info.diffList = diffList;
|
|
268
|
+
compalition.info.diffFile = _path.default.join(config.projectPath, compilerOption.releasePath, diffFileName);
|
|
247
269
|
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 打包结果移回源码项目,并删除中间项目
|
|
274
|
+
*
|
|
275
|
+
* 1. 把 build和rpk 目录从**中间项目**移回**源码项目**
|
|
276
|
+
* 2. 删除中间项目
|
|
277
|
+
* @param context
|
|
278
|
+
* @param config
|
|
279
|
+
* @param compilerOption
|
|
280
|
+
*/
|
|
281
|
+
static moveBackResult = async params => {
|
|
282
|
+
const {
|
|
283
|
+
context,
|
|
284
|
+
compilerOption
|
|
285
|
+
} = params;
|
|
260
286
|
if (!compilerOption) {
|
|
261
|
-
|
|
287
|
+
return;
|
|
262
288
|
}
|
|
263
|
-
const {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
289
|
+
const {
|
|
290
|
+
outputPath,
|
|
291
|
+
releasePath,
|
|
292
|
+
projectPath
|
|
293
|
+
} = compilerOption;
|
|
294
|
+
const {
|
|
295
|
+
projectPath: orgProjectPath
|
|
296
|
+
} = context;
|
|
297
|
+
const targetList = [{
|
|
298
|
+
from: _path.default.join(projectPath, outputPath),
|
|
299
|
+
to: _path.default.join(orgProjectPath, outputPath)
|
|
300
|
+
}, {
|
|
301
|
+
from: _path.default.join(projectPath, releasePath),
|
|
302
|
+
to: _path.default.join(orgProjectPath, releasePath)
|
|
303
|
+
}];
|
|
304
|
+
targetList.forEach(item => {
|
|
305
|
+
_fsExtra.default.removeSync(item.to);
|
|
306
|
+
_fsExtra.default.moveSync(item.from, item.to, {
|
|
307
|
+
overwrite: true
|
|
308
|
+
});
|
|
278
309
|
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 创建 node_module 软链
|
|
314
|
+
* @param context
|
|
315
|
+
* @param config
|
|
316
|
+
* @param compilerOption
|
|
317
|
+
*/
|
|
318
|
+
static symlinkNodeModule = async params => {
|
|
319
|
+
const {
|
|
320
|
+
context,
|
|
321
|
+
compilerOption
|
|
322
|
+
} = params;
|
|
288
323
|
if (!compilerOption) {
|
|
289
|
-
|
|
324
|
+
return;
|
|
290
325
|
}
|
|
291
326
|
try {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
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.`);
|
|
327
|
+
const foldList = ['node_modules'];
|
|
328
|
+
foldList.forEach(item => {
|
|
329
|
+
const sourcePath = _path.default.join(context.projectPath, item);
|
|
330
|
+
const targetPath = _path.default.join(compilerOption.projectPath, item);
|
|
331
|
+
if (_fsExtra.default.existsSync(sourcePath) && !_fsExtra.default.existsSync(targetPath)) {
|
|
332
|
+
_fsExtra.default.symlinkSync(sourcePath, targetPath, 'junction');
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
} catch (error) {
|
|
336
|
+
throw new Error(`${error?.toString() || 'unknown error'}. Please check whether the file system of the current disk supports the creation of soft links.`);
|
|
303
337
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
var _default = exports.default = UxAfterCompile;
|