@aiot-toolkit/aiotpack 2.0.2-dev.8 → 2.0.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/{utils/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +11 -4
  2. package/lib/{utils/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +95 -44
  3. package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +1 -1
  4. package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +14 -13
  5. package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +1 -1
  6. package/lib/{followWorks → afterCompile}/xts/generateRpk.js +5 -4
  7. package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +1 -1
  8. package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +7 -6
  9. package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
  10. package/lib/afterWorks/ux/UxAfterWorks.js +22 -0
  11. package/lib/{utils/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +4 -4
  12. package/lib/{utils/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +11 -8
  13. package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +1 -1
  14. package/lib/{preWorks → beforeCompile}/xts/preInstall.js +6 -5
  15. package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
  16. package/lib/beforeWorks/ux/UxBeforeWorks.js +22 -0
  17. package/lib/compiler/interface/ICompileParam.d.ts +1 -1
  18. package/lib/compiler/interface/ISignConfig.d.ts +6 -1
  19. package/lib/compiler/javascript/JavascriptCompiler.js +45 -12
  20. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
  21. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
  22. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
  23. package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
  24. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +91 -0
  25. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
  26. package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
  27. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +4 -2
  28. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
  29. package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -1
  30. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
  31. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
  32. package/lib/compiler/javascript/vela/model/Package.d.ts +2 -2
  33. package/lib/compiler/javascript/vela/model/Package.js +5 -5
  34. package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
  35. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +16 -2
  36. package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
  37. package/lib/compiler/javascript/vela/utils/Jsc.js +19 -11
  38. package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
  39. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +4 -4
  40. package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +29 -5
  41. package/lib/compiler/javascript/vela/utils/ZipUtil.js +45 -31
  42. package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
  43. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +23 -7
  44. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +94 -45
  45. package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
  46. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
  47. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +56 -0
  48. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
  49. package/lib/compiler/javascript/vela/utils/webpackLoader/{splitMap.js → extractMapData.js} +2 -2
  50. package/lib/config/UxConfig.d.ts +45 -7
  51. package/lib/config/UxConfig.js +156 -40
  52. package/lib/config/XtsConfig.d.ts +8 -4
  53. package/lib/config/XtsConfig.js +24 -8
  54. package/lib/index.d.ts +9 -1
  55. package/lib/index.js +35 -1
  56. package/lib/loader/ux/JsLoader.d.ts +2 -0
  57. package/lib/loader/ux/JsLoader.js +6 -9
  58. package/lib/loader/ux/PngLoader.js +4 -5
  59. package/lib/loader/ux/android/UxLoader.d.ts +13 -0
  60. package/lib/loader/ux/android/UxLoader.js +38 -0
  61. package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +3 -1
  62. package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +5 -3
  63. package/lib/loader/ux/vela/HmlLoader.d.ts +24 -0
  64. package/lib/loader/ux/vela/HmlLoader.js +63 -0
  65. package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +3 -1
  66. package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +11 -14
  67. package/lib/loader/xts/XtsLoader.js +6 -7
  68. package/lib/utils/BeforeCompileUtils.d.ts +21 -0
  69. package/lib/utils/BeforeCompileUtils.js +118 -0
  70. package/lib/utils/ux/ManifestSchema.d.ts +1 -1
  71. package/lib/utils/ux/UxFileUtils.d.ts +16 -3
  72. package/lib/utils/ux/UxFileUtils.js +53 -17
  73. package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
  74. package/lib/utils/ux/UxLoaderUtils.js +43 -25
  75. package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
  76. package/lib/utils/ux/android/AndroidUx.js +98 -0
  77. package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
  78. package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
  79. package/lib/utils/xts/XtsFollowWorks.js +8 -8
  80. package/package.json +15 -8
  81. package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
  82. package/lib/utils/PreWorkUtils.d.ts +0 -22
  83. package/lib/utils/PreWorkUtils.js +0 -106
@@ -1,9 +1,9 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
3
  /**
4
- * UxFollowWorks
4
+ * UxAfterCompile
5
5
  */
6
- declare class UxFollowWorks {
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 UxFollowWorks;
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,22 @@ 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("./UxFileUtils"));
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"));
30
28
  const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
31
29
  /**
32
- * UxFollowWorks
30
+ * UxAfterCompile
33
31
  */
34
- class UxFollowWorks {
32
+ class UxAfterCompile {
35
33
  }
36
- _a = UxFollowWorks;
37
- UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
34
+ _a = UxAfterCompile;
35
+ UxAfterCompile.webpack = (params) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const { context, compilerOption } = params;
38
37
  return new JavascriptCompiler_1.default()
39
38
  .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
39
  .then(() => {
41
- ColorConsole_1.default.info(`webpack complete`);
40
+ shared_utils_1.ColorConsole.info(`webpack complete`);
42
41
  })
43
42
  .catch(({ errors, warnings }) => {
44
43
  const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
@@ -50,7 +49,7 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
50
49
  return `${index + 1}. ${item.message}`;
51
50
  })
52
51
  .join('\r\n'),
53
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
52
+ style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW)
54
53
  });
55
54
  }
56
55
  if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
@@ -60,31 +59,38 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
60
59
  return `${errorLength + index + 1}. ${item.message}`;
61
60
  })
62
61
  .join('\r\n'),
63
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
62
+ style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.WARN)
64
63
  });
65
64
  }
66
65
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
67
- ColorConsole_1.default.throw(...messages);
66
+ shared_utils_1.ColorConsole.throw(...messages);
68
67
  throw new Error();
69
68
  }
70
69
  else {
71
- ColorConsole_1.default.warn(...messages);
70
+ shared_utils_1.ColorConsole.warn(...messages);
72
71
  }
73
72
  });
74
73
  });
75
- UxFollowWorks.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
74
+ UxAfterCompile.protobuf = (params) => __awaiter(void 0, void 0, void 0, function* () {
75
+ const { compilerOption } = params;
76
76
  if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
77
77
  BinaryPlugin.createBinFiles();
78
78
  }
79
79
  });
80
- UxFollowWorks.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
81
- if (compilerOption && compilerOption.disabledJSC === false) {
80
+ UxAfterCompile.jsc = (params) => __awaiter(void 0, void 0, void 0, function* () {
81
+ const { context, compilerOption } = params;
82
+ if (compilerOption && compilerOption.enableJsc === true) {
82
83
  return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
83
84
  }
84
85
  });
85
- UxFollowWorks.toRpk = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
86
+ UxAfterCompile.toRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
87
+ const { compilerOption, compalition, config } = params;
86
88
  if (compilerOption) {
87
- return ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
89
+ const fileName = yield ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
90
+ if (compalition && fileName) {
91
+ compalition.info.rpk = path_1.default.join(config.projectPath, compilerOption.releasePath, fileName);
92
+ }
93
+ return fileName;
88
94
  }
89
95
  });
90
96
  /**
@@ -93,7 +99,8 @@ UxFollowWorks.toRpk = (context, config, compilerOption) => __awaiter(void 0, voi
93
99
  * @param config
94
100
  * @param compilerOption
95
101
  */
96
- UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
102
+ UxAfterCompile.copyResource = (params) => __awaiter(void 0, void 0, void 0, function* () {
103
+ const { context, compilerOption } = params;
97
104
  const genDeviceManifests = (compilerOption) => {
98
105
  const { projectPath, sourceRoot, outputPath } = compilerOption;
99
106
  const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
@@ -115,7 +122,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
115
122
  const copyResourceFiles = (compilerOption) => {
116
123
  // 复制除 js/jsx/ts/tsx/json 外,但是包含manifest.json、sitemap.json的文件
117
124
  const { projectPath, sourceRoot, outputPath } = compilerOption;
118
- const includeList = ['sitemap.json', /i18n(.+)\.json/];
125
+ const includeList = [/sitemap\.json$/, /i18n(.+)\.json/];
119
126
  const excludeExtList = [
120
127
  'js',
121
128
  'jsx',
@@ -128,16 +135,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
128
135
  'sass',
129
136
  'styl',
130
137
  'html',
131
- 'json',
132
138
  'md',
133
139
  'ux',
134
140
  'mix',
135
141
  'DS_Store',
136
142
  'map'
137
143
  ];
138
- const excludeReg = `\.(${excludeExtList.join('|')})$`;
139
- FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
140
- FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), undefined, includeList);
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);
141
147
  };
142
148
  /**
143
149
  * 写入 manifest.json 文件
@@ -146,17 +152,18 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
146
152
  * @param compilerOption
147
153
  */
148
154
  const updateManifest = (compilerOption) => {
149
- const { projectPath, sourceRoot, outputPath } = compilerOption;
155
+ const { projectPath, sourceRoot, outputPath, completeFeature } = compilerOption;
150
156
  const content = UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot);
157
+ const translateCache = context.translateCache;
151
158
  if (!content.minAPILevel) {
152
159
  content.minAPILevel = 1;
153
160
  }
154
161
  if (!content.packageInfo) {
155
162
  content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
156
163
  }
157
- if (TranslateCache_1.default.featureCache.size) {
164
+ if (completeFeature && (translateCache === null || translateCache === void 0 ? void 0 : translateCache.featureCache.size)) {
158
165
  const featureSet = new Set([
159
- ...Array.from(TranslateCache_1.default.featureCache),
166
+ ...Array.from(translateCache.featureCache),
160
167
  ...(content.features || []).map((item) => item.name)
161
168
  ]);
162
169
  content.features = Array.from(featureSet).map((item) => {
@@ -180,7 +187,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
180
187
  const files = ZipUtil_1.default.getSortedFiles(outputAbsPath, compilerOption, UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot));
181
188
  const digestDic = Object.fromEntries(files.map((item) => [
182
189
  item,
183
- CommonUtil_1.default.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
190
+ shared_utils_1.CommonUtil.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
184
191
  ]));
185
192
  const hashJson = [
186
193
  {
@@ -195,12 +202,50 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
195
202
  fs_extra_1.default.outputFileSync(path_1.default.join(outputAbsPath, ZipUtil_1.default.CERT_PATH), buffer);
196
203
  });
197
204
  if (compilerOption) {
198
- copyResourceFiles(compilerOption);
199
- updateManifest(compilerOption);
200
- genDeviceManifests(compilerOption);
205
+ yield copyResourceFiles(compilerOption);
206
+ yield updateManifest(compilerOption);
207
+ yield genDeviceManifests(compilerOption);
201
208
  yield genMetaFiles(compilerOption);
202
209
  }
203
210
  });
211
+ /**
212
+ * 如果是更新触发,则对比临时项目build文件夹 和 项目build文件夹,生成diff.json
213
+ * @param context
214
+ * @param config
215
+ * @param compilerOption
216
+ */
217
+ UxAfterCompile.generateDiff = (params) => __awaiter(void 0, void 0, void 0, function* () {
218
+ const { compilerOption, compalition, config } = params;
219
+ if (!compilerOption || !compalition) {
220
+ return;
221
+ }
222
+ if (compalition.trigger === FileLaneTriggerType_1.default.START) {
223
+ return;
224
+ }
225
+ const { outputPath, projectPath } = compilerOption;
226
+ // 读取临时项目build文件夹中所有文件路径
227
+ const tempBuildPath = path_1.default.join(projectPath, outputPath);
228
+ // 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
229
+ const tempFileList = shared_utils_1.FileUtil.readAlldirSync(tempBuildPath).map((filePath) => path_1.default.relative(tempBuildPath, filePath));
230
+ const diffList = UxFileUtils_1.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
231
+ // 所有差异文件,压缩到 .diff.rpk 中
232
+ if (diffList === null || diffList === void 0 ? void 0 : diffList.length) {
233
+ const buildFold = path_1.default.join(compilerOption.projectPath, compilerOption.outputPath);
234
+ const distFold = path_1.default.join(compilerOption.projectPath, compilerOption.releasePath);
235
+ const diffFileName = `.diff.rpk`;
236
+ const diffPath = path_1.default.join(distFold, diffFileName);
237
+ const diffStream = fs_extra_1.default.createWriteStream(diffPath);
238
+ const archiver = (0, archiver_1.default)('zip', { zlib: { level: 9 } });
239
+ archiver.pipe(diffStream);
240
+ diffList.forEach((item) => {
241
+ const filePath = path_1.default.join(buildFold, item);
242
+ archiver.append(fs_extra_1.default.createReadStream(filePath), { name: item });
243
+ });
244
+ yield archiver.finalize();
245
+ compalition.info.diffList = diffList;
246
+ compalition.info.diffFile = path_1.default.join(config.projectPath, compilerOption.releasePath, diffFileName);
247
+ }
248
+ });
204
249
  /**
205
250
  * 打包结果移回源码项目,并删除中间项目
206
251
  *
@@ -210,7 +255,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
210
255
  * @param config
211
256
  * @param compilerOption
212
257
  */
213
- UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
258
+ UxAfterCompile.moveBackResult = (params) => __awaiter(void 0, void 0, void 0, function* () {
259
+ const { context, compilerOption } = params;
214
260
  if (!compilerOption) {
215
261
  return;
216
262
  }
@@ -228,9 +274,7 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
228
274
  ];
229
275
  targetList.forEach((item) => {
230
276
  fs_extra_1.default.moveSync(item.from, item.to, { overwrite: true });
231
- fs_extra_1.default.removeSync(item.from);
232
277
  });
233
- fs_extra_1.default.removeSync(projectPath);
234
278
  });
235
279
  /**
236
280
  * 创建 node_module 软链
@@ -238,16 +282,23 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
238
282
  * @param config
239
283
  * @param compilerOption
240
284
  */
241
- UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
285
+ UxAfterCompile.symlinkNodeModule = (params) => __awaiter(void 0, void 0, void 0, function* () {
286
+ const { context, compilerOption } = params;
242
287
  if (!compilerOption) {
243
288
  return;
244
289
  }
245
- const foldList = ['node_modules'];
246
- foldList.forEach((item) => {
247
- const sourcePath = path_1.default.join(context.projectPath, item);
248
- if (fs_extra_1.default.existsSync(sourcePath)) {
249
- fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item), 'junction');
250
- }
251
- });
290
+ try {
291
+ const foldList = ['node_modules'];
292
+ foldList.forEach((item) => {
293
+ const sourcePath = path_1.default.join(context.projectPath, item);
294
+ const targetPath = path_1.default.join(compilerOption.projectPath, item);
295
+ if (fs_extra_1.default.existsSync(sourcePath) && !fs_extra_1.default.existsSync(targetPath)) {
296
+ fs_extra_1.default.symlinkSync(sourcePath, targetPath, 'junction');
297
+ }
298
+ });
299
+ }
300
+ catch (error) {
301
+ 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.`);
302
+ }
252
303
  });
253
- exports.default = UxFollowWorks;
304
+ exports.default = UxAfterCompile;
@@ -1,4 +1,4 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  export interface Aspects {
3
3
  path: string;
4
4
  name: string;
@@ -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 Framework_1 = require("@aiot-toolkit/parser/lib/xts/enum/Framework");
17
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
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}, { ${Framework_1.HomeState.interface} as ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
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?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
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/${Framework_1.tsFrameWork.name}/index'
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(context, _, compilerOptions) {
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 = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
130
- ColorConsole_1.default.info(`### skip generate entry file due to --skip xts2ts}`);
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
- ColorConsole_1.default.info(`Generating entry file`);
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
- ColorConsole_1.default.throw('not find app/manifest.json file !');
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
- ColorConsole_1.default.throw('not find app/app.ts file !');
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
- ColorConsole_1.default.info(`entry file built`);
181
+ shared_utils_1.ColorConsole.info(`entry file built`);
181
182
  });
182
183
  };
183
184
  exports.generateEntryFile = generateEntryFile;
@@ -1,3 +1,3 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import { IXtsCompileOptions } from '../../interface/ICompileOptions';
3
3
  export declare const generateRpk: FollowWork<IXtsCompileOptions>;
@@ -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 ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
41
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
42
42
  const ts2wasm_1 = require("./ts2wasm");
43
- const generateRpk = (context, _, compilerOptions) => __awaiter(void 0, void 0, void 0, function* () {
43
+ const generateRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
44
44
  var _a;
45
- if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
46
- ColorConsole_1.default.info(`### skip package due to --skip ${compilerOptions.skip.join(',')}`);
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');
@@ -1,4 +1,4 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import { IXtsCompileOptions } from '../../interface/ICompileOptions';
3
3
  export declare const wasmPackageName = "wasmUnpacked";
4
4
  /**
@@ -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 ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
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 = (context, _, compilerOptions) => __awaiter(void 0, void 0, void 0, function* () {
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
- ColorConsole_1.default.info('### Waiting for generating app.wasm file.');
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
- ColorConsole_1.default.info(`### ts2wasm ### ${res.toString()}`);
45
+ shared_utils_1.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
45
46
  }
46
- if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
47
- ColorConsole_1.default.info(`### skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`);
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,5 @@
1
+ import { IFileLaneContext } from 'file-lane';
2
+ declare class UxAfterWorks {
3
+ static cleanOutput(context: IFileLaneContext): Promise<void>;
4
+ }
5
+ export default UxAfterWorks;
@@ -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/lib/interface/IFileLaneConfig';
1
+ import { PreWork } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
3
  /**
4
- * UxPreWorks
4
+ * UxBeforeCompile
5
5
  */
6
- declare class UxPreWorks {
6
+ declare class UxBeforeCompile {
7
7
  static validateManifest: PreWork<IJavascriptCompileOption>;
8
8
  static validateSitemap: PreWork<IJavascriptCompileOption>;
9
9
  }
10
- export default UxPreWorks;
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("./UxFileUtils"));
16
+ const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
17
17
  /**
18
- * UxPreWorks
18
+ * UxBeforeCompile
19
19
  */
20
- class UxPreWorks {
20
+ class UxBeforeCompile {
21
21
  }
22
- _a = UxPreWorks;
23
- UxPreWorks.validateManifest = (context) => __awaiter(void 0, void 0, void 0, function* () {
22
+ _a = UxBeforeCompile;
23
+ UxBeforeCompile.validateManifest = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
24
24
  const { projectPath } = context;
25
- return UxFileUtils_1.default.validateManifest(projectPath);
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
- UxPreWorks.validateSitemap = (context) => __awaiter(void 0, void 0, void 0, function* () {
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 = UxPreWorks;
34
+ exports.default = UxBeforeCompile;
@@ -1,3 +1,3 @@
1
- import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { PreWork } from 'file-lane';
2
2
  import { IXtsCompileOptions } from '../../interface/ICompileOptions';
3
3
  export declare const preInstall: PreWork<IXtsCompileOptions>;
@@ -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 ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
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 = (context, _, __, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
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
- ColorConsole_1.default.info(`### skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
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
- ColorConsole_1.default.info('### Installing pre-dependencies. The initial build may take some time, please be patient...');
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
- ColorConsole_1.default.info('### Dependencies installation complete.');
57
+ shared_utils_1.ColorConsole.info('### Dependencies installation complete.');
57
58
  });
58
59
  exports.preInstall = preInstall;
@@ -0,0 +1,5 @@
1
+ import { IFileLaneContext } from 'file-lane';
2
+ declare class UxBeforeWorks {
3
+ static cleanOutput(context: IFileLaneContext): Promise<void>;
4
+ }
5
+ export default UxBeforeWorks;
@@ -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;
@@ -1,4 +1,4 @@
1
- import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type';
1
+ import { Dictionary } from '@aiot-toolkit/shared-utils';
2
2
  import CompileMode from '../enum/CompileMode';
3
3
  /**
4
4
  * 编译参数
@@ -1,8 +1,13 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * ISignConfig
4
3
  */
5
4
  export default interface ISignConfig {
5
+ /**
6
+ * 私钥
7
+ */
6
8
  privatekey: Buffer;
9
+ /**
10
+ * 证书
11
+ */
7
12
  certificate: Buffer;
8
13
  }