@huangjunsen/encode-fe-lint 1.0.6 → 1.0.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.
Files changed (77) hide show
  1. package/lib/actions/init.d.ts +3 -3
  2. package/lib/actions/init.js +168 -223
  3. package/lib/actions/scan.d.ts +3 -3
  4. package/lib/actions/scan.js +63 -137
  5. package/lib/actions/update.d.ts +2 -2
  6. package/lib/actions/update.js +51 -112
  7. package/lib/cli.d.ts +2 -2
  8. package/lib/cli.js +152 -230
  9. package/lib/config/_editorconfig.ejs +13 -13
  10. package/lib/config/_eslintignore.ejs +9 -9
  11. package/lib/config/_eslintrc.js.ejs +21 -3
  12. package/lib/config/_markdownlint.json.ejs +1 -1
  13. package/lib/config/_markdownlintignore.ejs +5 -5
  14. package/lib/config/_prettierrc.js.ejs +3 -8
  15. package/lib/config/_stylelintignore.ejs +5 -5
  16. package/lib/config/_stylelintrc.js.ejs +5 -5
  17. package/lib/config/_vscode/extensions.json.ejs +7 -7
  18. package/lib/config/_vscode/settings.json.ejs +55 -54
  19. package/lib/config/commitlint.config.js.ejs +3 -3
  20. package/lib/config/encode-fe-lint.config.js.ejs +6 -6
  21. package/lib/config/eslint.config.mjs.ejs +5 -0
  22. package/lib/index.d.ts +5 -5
  23. package/lib/index.js +36 -93
  24. package/lib/lints/eslint/doEslint.d.ts +6 -6
  25. package/lib/lints/eslint/doEslint.js +44 -80
  26. package/lib/lints/eslint/formatESLintResults.d.ts +3 -3
  27. package/lib/lints/eslint/formatESLintResults.js +28 -39
  28. package/lib/lints/eslint/getESLintConfig.d.ts +3 -3
  29. package/lib/lints/eslint/getESLintConfig.js +43 -67
  30. package/lib/lints/eslint/getESLintConfigType.d.ts +2 -2
  31. package/lib/lints/eslint/getESLintConfigType.js +23 -26
  32. package/lib/lints/eslint/index.d.ts +3 -3
  33. package/lib/lints/eslint/index.js +19 -19
  34. package/lib/lints/index.d.ts +4 -4
  35. package/lib/lints/index.js +20 -20
  36. package/lib/lints/markdownlint/doMarkdownlint.d.ts +6 -6
  37. package/lib/lints/markdownlint/doMarkdownlint.js +52 -119
  38. package/lib/lints/markdownlint/formatMarkdownlintResults.d.ts +3 -3
  39. package/lib/lints/markdownlint/formatMarkdownlintResults.js +35 -39
  40. package/lib/lints/markdownlint/getMarkdownlintConfig.d.ts +7 -7
  41. package/lib/lints/markdownlint/getMarkdownlintConfig.js +31 -31
  42. package/lib/lints/markdownlint/index.d.ts +3 -3
  43. package/lib/lints/markdownlint/index.js +19 -19
  44. package/lib/lints/prettier/doPrettier.d.ts +4 -4
  45. package/lib/lints/prettier/doPrettier.js +32 -106
  46. package/lib/lints/prettier/index.d.ts +1 -1
  47. package/lib/lints/prettier/index.js +17 -17
  48. package/lib/lints/stylelint/doStylelint.d.ts +5 -5
  49. package/lib/lints/stylelint/doStylelint.js +31 -86
  50. package/lib/lints/stylelint/formatStylelintResults.d.ts +3 -3
  51. package/lib/lints/stylelint/formatStylelintResults.js +38 -39
  52. package/lib/lints/stylelint/getStylelintConfig.d.ts +3 -3
  53. package/lib/lints/stylelint/getStylelintConfig.js +37 -36
  54. package/lib/lints/stylelint/getStylelintDocUrl.d.ts +1 -1
  55. package/lib/lints/stylelint/getStylelintDocUrl.js +13 -13
  56. package/lib/lints/stylelint/index.d.ts +3 -3
  57. package/lib/lints/stylelint/index.js +19 -19
  58. package/lib/types/index.d.ts +73 -73
  59. package/lib/types/index.js +2 -2
  60. package/lib/utils/conflict-resolve.d.ts +3 -3
  61. package/lib/utils/conflict-resolve.js +95 -175
  62. package/lib/utils/constants.d.ts +18 -18
  63. package/lib/utils/constants.js +104 -133
  64. package/lib/utils/generate-template.d.ts +2 -2
  65. package/lib/utils/generate-template.js +53 -99
  66. package/lib/utils/git.d.ts +3 -3
  67. package/lib/utils/git.js +44 -105
  68. package/lib/utils/log.d.ts +8 -8
  69. package/lib/utils/log.js +25 -25
  70. package/lib/utils/npm-type.d.ts +2 -2
  71. package/lib/utils/npm-type.js +10 -10
  72. package/lib/utils/print-report.d.ts +3 -3
  73. package/lib/utils/print-report.js +86 -109
  74. package/package.json +18 -14
  75. package/LICENSE +0 -21
  76. package/lib/utils/update.d.ts +0 -2
  77. package/lib/utils/update.js +0 -112
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var command_exists_1 = require("command-exists");
4
- var promise = new Promise(function (resolve, reject) {
5
- if (!(0, command_exists_1.sync)('pnpm')) {
6
- resolve('npm');
7
- }
8
- resolve('pnpm');
9
- });
10
- exports.default = promise;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_exists_1 = require("command-exists");
4
+ const promise = new Promise((resolve) => {
5
+ if (!(0, command_exists_1.sync)('pnpm')) {
6
+ return resolve('npm');
7
+ }
8
+ resolve('pnpm');
9
+ });
10
+ exports.default = promise;
@@ -1,3 +1,3 @@
1
- import type { ScanResult } from '../types';
2
- declare const _default: (results: ScanResult[], fix: boolean) => void;
3
- export default _default;
1
+ import type { ScanResult } from '../types';
2
+ declare const _default: (results: ScanResult[], fix: boolean) => void;
3
+ export default _default;
@@ -1,109 +1,86 @@
1
- "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- var chalk_1 = __importDefault(require("chalk"));
18
- var text_table_1 = __importDefault(require("text-table"));
19
- var terminal_link_1 = __importDefault(require("terminal-link"));
20
- var is_docker_1 = __importDefault(require("is-docker"));
21
- var strip_ansi_1 = __importDefault(require("strip-ansi"));
22
- var constants_1 = require("./constants");
23
- exports.default = (function (results, fix) {
24
- var e_1, _a;
25
- var output = '\n';
26
- var errorCount = 0;
27
- var warningCount = 0;
28
- var fixableErrorCount = 0;
29
- var fixableWarningCount = 0;
30
- var summaryColor = 'yellow';
31
- var transformMessage = function (_a) {
32
- var line = _a.line, column = _a.column, rule = _a.rule, url = _a.url, message = _a.message, errored = _a.errored;
33
- if (errored)
34
- summaryColor = 'red';
35
- var text = '';
36
- if (rule && url) {
37
- text = (0, terminal_link_1.default)(chalk_1.default.blue(rule), chalk_1.default.dim(" ".concat(url, " ")), { fallback: !(0, is_docker_1.default)() });
38
- }
39
- else if (rule) {
40
- text = chalk_1.default.blue(rule);
41
- }
42
- return [
43
- '',
44
- chalk_1.default.dim("".concat(line, ":").concat(column)),
45
- errored ? chalk_1.default.red('error') : chalk_1.default.yellow('warning'),
46
- message,
47
- text,
48
- ];
49
- };
50
- try {
51
- for (var results_1 = __values(results), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {
52
- var result = results_1_1.value;
53
- if (result.messages.length === 0)
54
- continue;
55
- var messages = result.messages;
56
- errorCount += result.errorCount;
57
- warningCount += result.warningCount;
58
- fixableErrorCount += result.fixableErrorCount;
59
- fixableWarningCount += result.fixableWarningCount;
60
- output += "".concat(chalk_1.default.underline(result.filePath), "\n");
61
- output += "".concat((0, text_table_1.default)(messages.map(transformMessage), {
62
- align: ['.', 'r', 'l'],
63
- stringLength: function (str) { return (0, strip_ansi_1.default)(str).length; },
64
- }), "\n\n");
65
- }
66
- }
67
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
68
- finally {
69
- try {
70
- if (results_1_1 && !results_1_1.done && (_a = results_1.return)) _a.call(results_1);
71
- }
72
- finally { if (e_1) throw e_1.error; }
73
- }
74
- var total = errorCount + warningCount;
75
- var pluralize = function (word, count) { return (count === 1 ? word : "".concat(word, "s")); };
76
- if (fix)
77
- output += chalk_1.default.green('代码规范问题自动修复完成,请通过 git diff 确认修复效果 :D\n');
78
- if (fix && total > 0) {
79
- output += chalk_1.default.green('ps. 以上显示的是无法被自动修复的问题,需要手动进行修复\n');
80
- }
81
- if (!fix && total > 0) {
82
- output += chalk_1.default[summaryColor].bold([
83
- "".concat(constants_1.UNICODE.failure, " "),
84
- total,
85
- pluralize(' problem', total),
86
- ' (',
87
- errorCount,
88
- pluralize(' error', errorCount),
89
- ', ',
90
- warningCount,
91
- pluralize(' warning', warningCount),
92
- ')\n',
93
- ].join(''));
94
- if (fixableErrorCount > 0 || fixableWarningCount > 0) {
95
- output += chalk_1.default[summaryColor].bold([
96
- ' ',
97
- fixableErrorCount,
98
- pluralize(' error', fixableErrorCount),
99
- ' and ',
100
- fixableWarningCount,
101
- pluralize(' warning', fixableWarningCount),
102
- " potentially fixable with the `".concat(constants_1.PKG_NAME, " fix`"),
103
- ].join(''));
104
- }
105
- }
106
- if (!fix && total === 0)
107
- output = chalk_1.default.green.bold("".concat(constants_1.UNICODE.success, " no problems"));
108
- console.log(chalk_1.default.reset(output));
109
- });
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 chalk_1 = __importDefault(require("chalk"));
7
+ const text_table_1 = __importDefault(require("text-table"));
8
+ const terminal_link_1 = __importDefault(require("terminal-link"));
9
+ const is_docker_1 = __importDefault(require("is-docker"));
10
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
11
+ const constants_1 = require("./constants");
12
+ exports.default = (results, fix) => {
13
+ let output = '\n';
14
+ let errorCount = 0;
15
+ let warningCount = 0;
16
+ let fixableErrorCount = 0;
17
+ let fixableWarningCount = 0;
18
+ let summaryColor = 'yellow';
19
+ const transformMessage = ({ line, column, rule, url, message, errored }) => {
20
+ if (errored)
21
+ summaryColor = 'red';
22
+ let text = '';
23
+ if (rule && url) {
24
+ text = (0, terminal_link_1.default)(chalk_1.default.blue(rule), chalk_1.default.dim(` ${url} `), { fallback: !(0, is_docker_1.default)() });
25
+ }
26
+ else if (rule) {
27
+ text = chalk_1.default.blue(rule);
28
+ }
29
+ return [
30
+ '',
31
+ chalk_1.default.dim(`${line}:${column}`),
32
+ errored ? chalk_1.default.red('error') : chalk_1.default.yellow('warning'),
33
+ message,
34
+ text,
35
+ ];
36
+ };
37
+ for (const result of results) {
38
+ if (result.messages.length === 0)
39
+ continue;
40
+ const { messages } = result;
41
+ errorCount += result.errorCount;
42
+ warningCount += result.warningCount;
43
+ fixableErrorCount += result.fixableErrorCount;
44
+ fixableWarningCount += result.fixableWarningCount;
45
+ output += `${chalk_1.default.underline(result.filePath)}\n`;
46
+ output += `${(0, text_table_1.default)(messages.map(transformMessage), {
47
+ align: ['.', 'r', 'l'],
48
+ stringLength: (str) => (0, strip_ansi_1.default)(str).length,
49
+ })}\n\n`;
50
+ }
51
+ const total = errorCount + warningCount;
52
+ const pluralize = (word, count) => (count === 1 ? word : `${word}s`);
53
+ if (fix)
54
+ output += chalk_1.default.green('代码规范问题自动修复完成,请通过 git diff 确认修复效果 :D\n');
55
+ if (fix && total > 0) {
56
+ output += chalk_1.default.green('ps. 以上显示的是无法被自动修复的问题,需要手动进行修复\n');
57
+ }
58
+ if (!fix && total > 0) {
59
+ output += chalk_1.default[summaryColor].bold([
60
+ `${constants_1.UNICODE.failure} `,
61
+ total,
62
+ pluralize(' problem', total),
63
+ ' (',
64
+ errorCount,
65
+ pluralize(' error', errorCount),
66
+ ', ',
67
+ warningCount,
68
+ pluralize(' warning', warningCount),
69
+ ')\n',
70
+ ].join(''));
71
+ if (fixableErrorCount > 0 || fixableWarningCount > 0) {
72
+ output += chalk_1.default[summaryColor].bold([
73
+ ' ',
74
+ fixableErrorCount,
75
+ pluralize(' error', fixableErrorCount),
76
+ ' and ',
77
+ fixableWarningCount,
78
+ pluralize(' warning', fixableWarningCount),
79
+ ` potentially fixable with the \`${constants_1.PKG_NAME} fix\``,
80
+ ].join(''));
81
+ }
82
+ }
83
+ if (!fix && total === 0)
84
+ output = chalk_1.default.green.bold(`${constants_1.UNICODE.success} no problems`);
85
+ console.log(chalk_1.default.reset(output));
86
+ };
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "@huangjunsen/encode-fe-lint",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "前端编码规范工程化标准脚手架",
5
5
  "bin": "./lib/cli.js",
6
6
  "main": "./lib/index.js",
7
+ "scripts": {
8
+ "dev": "npm run copyfiles && tsc -w",
9
+ "build": "rm -rf lib && npm run copyfiles && tsc",
10
+ "copyfiles": "copyfiles -a -u 1 \"src/config/**\" lib",
11
+ "test": "npm run build && jest",
12
+ "coverage": "nyc jest --silent --forceExit",
13
+ "prepublishOnly": "npm run test"
14
+ },
7
15
  "files": [
8
- "lib/"
16
+ "lib/",
17
+ "README.md"
9
18
  ],
10
19
  "engines": {
11
20
  "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@@ -22,6 +31,7 @@
22
31
  "@types/eslint": "^8.56.10",
23
32
  "@types/fs-extra": "^9.0.13",
24
33
  "@types/glob": "^7.2.0",
34
+ "@types/inquirer": "^7.3.3",
25
35
  "@types/lodash": "^4.17.0",
26
36
  "@types/node": "^20.12.7",
27
37
  "@types/prettier": "^2.7.3",
@@ -37,10 +47,11 @@
37
47
  "@babel/eslint-parser": "^7.24.1",
38
48
  "@babel/preset-react": "^7.24.1",
39
49
  "@commitlint/cli": "^16.3.0",
40
- "@huangjunsen/commitlint-config": "^1.0.0",
41
- "@huangjunsen/eslint-config": "^1.0.0",
42
- "@huangjunsen/markdownlint-config": "^1.0.0",
43
- "@huangjunsen/stylelint-config": "^1.0.0",
50
+ "@huangjunsen/commitlint-config": "workspace:^",
51
+ "@huangjunsen/eslint-config": "workspace:^",
52
+ "@huangjunsen/markdownlint-config": "workspace:^",
53
+ "@huangjunsen/prettier-config": "workspace:^",
54
+ "@huangjunsen/stylelint-config": "workspace:^",
44
55
  "@typescript-eslint/eslint-plugin": "^5.62.0",
45
56
  "@typescript-eslint/parser": "^5.62.0",
46
57
  "chalk": "^4.1.2",
@@ -86,12 +97,5 @@
86
97
  },
87
98
  "bugs": {
88
99
  "url": "https://github.com/Huang-junsen/js-encode-fe-spec/issues"
89
- },
90
- "scripts": {
91
- "dev": "npm run copyfiles && tsc -w",
92
- "build": "rm -rf lib && npm run copyfiles && tsc",
93
- "copyfiles": "copyfiles -a -u 1 \"src/config/**\" lib",
94
- "test": "npm run build && jest",
95
- "coverage": "nyc jest --silent --forceExit"
96
100
  }
97
- }
101
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 黄俊森
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,2 +0,0 @@
1
- declare const _default: (install?: boolean) => Promise<void>;
2
- export default _default;
@@ -1,112 +0,0 @@
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
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var child_process_1 = require("child_process");
43
- var ora_1 = __importDefault(require("ora"));
44
- var log_1 = __importDefault(require("../utils/log"));
45
- var npm_type_1 = __importDefault(require("../utils/npm-type"));
46
- var constants_1 = require("../utils/constants");
47
- var checkLatestVersion = function () { return __awaiter(void 0, void 0, void 0, function () {
48
- var npm, latestVersion, compareArr, beComparedArr, i;
49
- return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0: return [4, npm_type_1.default];
52
- case 1:
53
- npm = _a.sent();
54
- latestVersion = (0, child_process_1.execSync)("".concat(npm, " view ").concat(constants_1.PKG_NAME, " version")).toString('utf-8').trim();
55
- if (constants_1.PKG_VERSION === latestVersion)
56
- return [2, null];
57
- compareArr = constants_1.PKG_VERSION.split('.').map(Number);
58
- beComparedArr = latestVersion.split('.').map(Number);
59
- for (i = 0; i < compareArr.length; i++) {
60
- if (compareArr[i] > beComparedArr[i]) {
61
- return [2, null];
62
- }
63
- else if (compareArr[i] < beComparedArr[i]) {
64
- return [2, latestVersion];
65
- }
66
- }
67
- return [2];
68
- }
69
- });
70
- }); };
71
- exports.default = (function (install) {
72
- if (install === void 0) { install = true; }
73
- return __awaiter(void 0, void 0, void 0, function () {
74
- var checking, npm, latestVersion, update, e_1;
75
- return __generator(this, function (_a) {
76
- switch (_a.label) {
77
- case 0:
78
- checking = (0, ora_1.default)("[".concat(constants_1.PKG_NAME, "] \u6B63\u5728\u68C0\u67E5\u6700\u65B0\u7248\u672C..."));
79
- checking.start();
80
- _a.label = 1;
81
- case 1:
82
- _a.trys.push([1, 4, , 5]);
83
- return [4, npm_type_1.default];
84
- case 2:
85
- npm = _a.sent();
86
- return [4, checkLatestVersion()];
87
- case 3:
88
- latestVersion = _a.sent();
89
- checking.stop();
90
- if (latestVersion && install) {
91
- update = (0, ora_1.default)("[".concat(constants_1.PKG_NAME, "] \u5B58\u5728\u65B0\u7248\u672C\uFF0C\u5C06\u5347\u7EA7\u81F3 ").concat(latestVersion));
92
- update.start();
93
- (0, child_process_1.execSync)("".concat(npm, " i -g ").concat(constants_1.PKG_NAME));
94
- update.stop();
95
- }
96
- else if (latestVersion) {
97
- log_1.default.warn("\u6700\u65B0\u7248\u672C\u4E3A ".concat(latestVersion, "\uFF0C\u672C\u5730\u7248\u672C\u4E3A ").concat(constants_1.PKG_VERSION, "\uFF0C\u8BF7\u5C3D\u5FEB\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u3002\n\u4F60\u53EF\u4EE5\u6267\u884C ").concat(npm, " install -g ").concat(constants_1.PKG_NAME, "@latest \u6765\u5B89\u88C5\u6B64\u7248\u672C\n"));
98
- }
99
- else if (install) {
100
- log_1.default.info("\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u7684\u66F4\u65B0");
101
- }
102
- return [3, 5];
103
- case 4:
104
- e_1 = _a.sent();
105
- checking.stop();
106
- log_1.default.error(e_1);
107
- return [3, 5];
108
- case 5: return [2];
109
- }
110
- });
111
- });
112
- });