@huangjunsen/encode-fe-lint 1.0.6 → 1.0.7
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/actions/init.d.ts +3 -3
- package/lib/actions/init.js +151 -223
- package/lib/actions/scan.d.ts +3 -3
- package/lib/actions/scan.js +60 -137
- package/lib/actions/update.d.ts +2 -2
- package/lib/actions/update.js +51 -112
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +145 -230
- package/lib/config/_editorconfig.ejs +13 -13
- package/lib/config/_eslintignore.ejs +9 -9
- package/lib/config/_eslintrc.js.ejs +21 -3
- package/lib/config/_markdownlint.json.ejs +1 -1
- package/lib/config/_markdownlintignore.ejs +5 -5
- package/lib/config/_prettierrc.js.ejs +3 -8
- package/lib/config/_stylelintignore.ejs +5 -5
- package/lib/config/_stylelintrc.js.ejs +5 -5
- package/lib/config/_vscode/extensions.json.ejs +7 -7
- package/lib/config/_vscode/settings.json.ejs +55 -54
- package/lib/config/commitlint.config.js.ejs +3 -3
- package/lib/config/encode-fe-lint.config.js.ejs +6 -6
- package/lib/config/eslint.config.mjs.ejs +5 -0
- package/lib/index.d.ts +5 -5
- package/lib/index.js +36 -93
- package/lib/lints/eslint/doEslint.d.ts +6 -6
- package/lib/lints/eslint/doEslint.js +44 -80
- package/lib/lints/eslint/formatESLintResults.d.ts +3 -3
- package/lib/lints/eslint/formatESLintResults.js +28 -39
- package/lib/lints/eslint/getESLintConfig.d.ts +3 -3
- package/lib/lints/eslint/getESLintConfig.js +43 -67
- package/lib/lints/eslint/getESLintConfigType.d.ts +2 -2
- package/lib/lints/eslint/getESLintConfigType.js +23 -26
- package/lib/lints/eslint/index.d.ts +3 -3
- package/lib/lints/eslint/index.js +19 -19
- package/lib/lints/index.d.ts +4 -4
- package/lib/lints/index.js +20 -20
- package/lib/lints/markdownlint/doMarkdownlint.d.ts +6 -6
- package/lib/lints/markdownlint/doMarkdownlint.js +52 -119
- package/lib/lints/markdownlint/formatMarkdownlintResults.d.ts +3 -3
- package/lib/lints/markdownlint/formatMarkdownlintResults.js +35 -39
- package/lib/lints/markdownlint/getMarkdownlintConfig.d.ts +7 -7
- package/lib/lints/markdownlint/getMarkdownlintConfig.js +31 -31
- package/lib/lints/markdownlint/index.d.ts +3 -3
- package/lib/lints/markdownlint/index.js +19 -19
- package/lib/lints/prettier/doPrettier.d.ts +4 -4
- package/lib/lints/prettier/doPrettier.js +32 -106
- package/lib/lints/prettier/index.d.ts +1 -1
- package/lib/lints/prettier/index.js +17 -17
- package/lib/lints/stylelint/doStylelint.d.ts +5 -5
- package/lib/lints/stylelint/doStylelint.js +31 -86
- package/lib/lints/stylelint/formatStylelintResults.d.ts +3 -3
- package/lib/lints/stylelint/formatStylelintResults.js +38 -39
- package/lib/lints/stylelint/getStylelintConfig.d.ts +3 -3
- package/lib/lints/stylelint/getStylelintConfig.js +36 -36
- package/lib/lints/stylelint/getStylelintDocUrl.d.ts +1 -1
- package/lib/lints/stylelint/getStylelintDocUrl.js +13 -13
- package/lib/lints/stylelint/index.d.ts +3 -3
- package/lib/lints/stylelint/index.js +19 -19
- package/lib/types/index.d.ts +73 -73
- package/lib/types/index.js +2 -2
- package/lib/utils/conflict-resolve.d.ts +3 -3
- package/lib/utils/conflict-resolve.js +95 -175
- package/lib/utils/constants.d.ts +18 -18
- package/lib/utils/constants.js +104 -133
- package/lib/utils/generate-template.d.ts +2 -2
- package/lib/utils/generate-template.js +53 -99
- package/lib/utils/git.d.ts +3 -3
- package/lib/utils/git.js +44 -105
- package/lib/utils/log.d.ts +8 -8
- package/lib/utils/log.js +25 -25
- package/lib/utils/npm-type.d.ts +2 -2
- package/lib/utils/npm-type.js +10 -10
- package/lib/utils/print-report.d.ts +3 -3
- package/lib/utils/print-report.js +86 -109
- package/package.json +13 -8
- package/lib/utils/update.d.ts +0 -2
- package/lib/utils/update.js +0 -112
package/lib/utils/npm-type.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huangjunsen/encode-fe-lint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "前端编码规范工程化标准脚手架",
|
|
5
|
-
"bin": "./lib/cli.js",
|
|
6
5
|
"main": "./lib/index.js",
|
|
7
6
|
"files": [
|
|
8
|
-
"lib/"
|
|
7
|
+
"lib/",
|
|
8
|
+
"README.md"
|
|
9
9
|
],
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@types/eslint": "^8.56.10",
|
|
23
23
|
"@types/fs-extra": "^9.0.13",
|
|
24
24
|
"@types/glob": "^7.2.0",
|
|
25
|
+
"@types/inquirer": "^7.3.3",
|
|
25
26
|
"@types/lodash": "^4.17.0",
|
|
26
27
|
"@types/node": "^20.12.7",
|
|
27
28
|
"@types/prettier": "^2.7.3",
|
|
@@ -37,10 +38,6 @@
|
|
|
37
38
|
"@babel/eslint-parser": "^7.24.1",
|
|
38
39
|
"@babel/preset-react": "^7.24.1",
|
|
39
40
|
"@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",
|
|
44
41
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
45
42
|
"@typescript-eslint/parser": "^5.62.0",
|
|
46
43
|
"chalk": "^4.1.2",
|
|
@@ -75,7 +72,12 @@
|
|
|
75
72
|
"stylelint-scss": "^4.7.0",
|
|
76
73
|
"terminal-link": "^2.1.1",
|
|
77
74
|
"text-table": "^0.2.0",
|
|
78
|
-
"vue-eslint-parser": "^7.11.0"
|
|
75
|
+
"vue-eslint-parser": "^7.11.0",
|
|
76
|
+
"@huangjunsen/markdownlint-config": "^1.0.0",
|
|
77
|
+
"@huangjunsen/eslint-config": "^1.0.1",
|
|
78
|
+
"@huangjunsen/prettier-config": "^1.0.1",
|
|
79
|
+
"@huangjunsen/commitlint-config": "^1.0.1",
|
|
80
|
+
"@huangjunsen/stylelint-config": "^1.0.0"
|
|
79
81
|
},
|
|
80
82
|
"author": "Huangjunsen <951434130@qq.com>",
|
|
81
83
|
"homepage": "https://github.com/Huang-junsen/js-encode-fe-spec#readme",
|
|
@@ -93,5 +95,8 @@
|
|
|
93
95
|
"copyfiles": "copyfiles -a -u 1 \"src/config/**\" lib",
|
|
94
96
|
"test": "npm run build && jest",
|
|
95
97
|
"coverage": "nyc jest --silent --forceExit"
|
|
98
|
+
},
|
|
99
|
+
"bin": {
|
|
100
|
+
"encode-fe-lint": "./lib/cli.js"
|
|
96
101
|
}
|
|
97
102
|
}
|
package/lib/utils/update.d.ts
DELETED
package/lib/utils/update.js
DELETED
|
@@ -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
|
-
});
|