@aiot-toolkit/aiotpack 2.0.3-beta.2 → 2.0.3-beta.4

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.
@@ -22,10 +22,7 @@ class UxBeforeCompile {
22
22
  _a = UxBeforeCompile;
23
23
  UxBeforeCompile.validateManifest = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
24
24
  const { projectPath } = context;
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
- }
25
+ yield UxFileUtils_1.default.validateManifest(projectPath);
29
26
  });
30
27
  UxBeforeCompile.validateSitemap = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
31
28
  const { projectPath } = context;
@@ -28,11 +28,11 @@ export declare class UxFileUtils {
28
28
  * @param sourceRoot 源码路径--相对项目根目录
29
29
  * @returns
30
30
  */
31
- static validateManifest(projectPath: string, sourceRoot?: string): Error[] | undefined;
31
+ static validateManifest(projectPath: string, sourceRoot?: string): void;
32
32
  /**
33
33
  * 检查 sitemap.json 文件,并显示错误信息
34
34
  *
35
- * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
35
+ * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
36
36
  * @param projectPath
37
37
  * @param sourceRoot
38
38
  */
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.UxFileUtils = void 0;
7
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
8
- const ILog_1 = require("@aiot-toolkit/shared-utils/lib/interface/ILog");
9
7
  const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
10
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
11
9
  const path_1 = __importDefault(require("path"));
@@ -44,10 +42,7 @@ class UxFileUtils {
44
42
  static validateManifest(projectPath, sourceRoot = 'src') {
45
43
  const path = UxFileUtils.getManifestFilePath(projectPath, sourceRoot);
46
44
  if (!fs_extra_1.default.existsSync(path)) {
47
- ColorConsole_1.default.throw(`file is missing`, {
48
- word: path,
49
- style: ColorConsole_1.default.getStyle(ILog_1.Loglevel.THROW)
50
- });
45
+ throw new Error(`no such file: '${path}'`);
51
46
  }
52
47
  // 1
53
48
  const jsonData = this.getMainfestInfo(projectPath, sourceRoot);
@@ -59,41 +54,34 @@ class UxFileUtils {
59
54
  errors.push(new TypeError(`router.entry content: ${entry}, is missing in router.pages`));
60
55
  }
61
56
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
62
- ColorConsole_1.default.warn(`Manefest.json error: `, ...errors.map((item, index) => {
63
- return {
64
- word: `\r\n${index + 1}. ${item.message}`,
65
- style: item instanceof TypeError
66
- ? ColorConsole_1.default.getStyle(ILog_1.Loglevel.ERROR)
67
- : ColorConsole_1.default.getStyle(ILog_1.Loglevel.WARN)
68
- };
69
- }));
57
+ const message = `Manifest.json error: ${errors.map((item, index) => {
58
+ return `\r\n${index + 1}. ${item.message}`;
59
+ })}`;
60
+ throw new Error(message);
70
61
  }
71
- return errors.length ? errors : undefined;
72
62
  }
73
63
  /**
74
64
  * 检查 sitemap.json 文件,并显示错误信息
75
65
  *
76
- * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
66
+ * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
77
67
  * @param projectPath
78
68
  * @param sourceRoot
79
69
  */
80
70
  static validateSitemap(projectPath, sourceRoot = 'src') {
81
71
  const sitemapPath = path_1.default.join(projectPath, sourceRoot, 'sitemap.json');
82
72
  if (fs_extra_1.default.existsSync(sitemapPath)) {
83
- try {
84
- const rules = fs_extra_1.default.readJSONSync(sitemapPath).rules;
85
- const manifest = this.getMainfestInfo(projectPath, sourceRoot);
86
- const pages = Object.keys(manifest.router.pages || {});
87
- rules.forEach((item, index) => {
88
- const page = item.page;
89
- if (page !== '*' && !pages.includes(page)) {
90
- ColorConsole_1.default.throw(`The ${index + 1}th item of sitemap rules is configured incorrectly, the page ${page} does not exist`);
91
- }
92
- return page;
93
- });
94
- }
95
- catch (error) {
96
- ColorConsole_1.default.warn(error === null || error === void 0 ? void 0 : error.toString());
73
+ const rules = fs_extra_1.default.readJSONSync(sitemapPath).rules;
74
+ const manifest = this.getMainfestInfo(projectPath, sourceRoot);
75
+ const pages = Object.keys(manifest.router.pages || {});
76
+ const errorList = [];
77
+ rules.forEach((item, index) => {
78
+ const page = item.page;
79
+ if (page !== '*' && !pages.includes(page)) {
80
+ errorList.push(`The ${index + 1}th item of sitemap rules is configured incorrectly, the page ${page} does not exist`);
81
+ }
82
+ });
83
+ if (errorList.length) {
84
+ throw new Error(errorList.join('\r\n'));
97
85
  }
98
86
  }
99
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.3-beta.2",
3
+ "version": "2.0.3-beta.4",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,16 +19,16 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.3-beta.2",
23
- "@aiot-toolkit/parser": "2.0.3-beta.2",
24
- "@aiot-toolkit/shared-utils": "2.0.3-beta.2",
22
+ "@aiot-toolkit/generator": "2.0.3-beta.4",
23
+ "@aiot-toolkit/parser": "2.0.3-beta.4",
24
+ "@aiot-toolkit/shared-utils": "2.0.3-beta.4",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.0.0",
27
27
  "aiot-parse5": "^1.0.0",
28
28
  "archiver": "^7.0.1",
29
29
  "babel-loader": "^9.1.3",
30
30
  "fast-glob": "^3.3.2",
31
- "file-lane": "2.0.3-beta.2",
31
+ "file-lane": "2.0.3-beta.4",
32
32
  "file-loader": "^6.2.0",
33
33
  "fs-extra": "^11.2.0",
34
34
  "jsrsasign": "^11.1.0",
@@ -45,5 +45,5 @@
45
45
  "@types/jsrsasign": "^10.5.12",
46
46
  "@types/webpack-sources": "^3.2.3"
47
47
  },
48
- "gitHead": "7776973f6a81d7f13eb330be8df5801d9143c83c"
48
+ "gitHead": "a79707d6a498ab01ac10ff3ba23d6271e2ac2ed8"
49
49
  }