@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.
Files changed (76) hide show
  1. package/lib/actions/init.d.ts +3 -3
  2. package/lib/actions/init.js +151 -223
  3. package/lib/actions/scan.d.ts +3 -3
  4. package/lib/actions/scan.js +60 -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 +145 -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 +36 -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 +13 -8
  75. package/lib/utils/update.d.ts +0 -2
  76. package/lib/utils/update.js +0 -112
@@ -1,73 +1,73 @@
1
- import { ESLint } from 'eslint';
2
- import stylelint from 'stylelint';
3
- import markdownlint from 'markdownlint';
4
- export interface PKG {
5
- eslintConfig?: any;
6
- eslintIgnore?: string[];
7
- stylelint?: any;
8
- peerDependencies?: Record<string, string>;
9
- devDependencies?: Record<string, string>;
10
- dependencies?: Record<string, string>;
11
- [key: string]: any;
12
- }
13
- export interface Config {
14
- enableESLint?: boolean;
15
- enableStylelint?: boolean;
16
- enableMarkdownlint?: boolean;
17
- enablePrettier?: boolean;
18
- eslintOptions?: ESLint.Options;
19
- stylelintOptions?: stylelint.LinterOptions;
20
- markdownlintOptions?: markdownlint.Options;
21
- }
22
- export interface ScanOptions {
23
- cwd: string;
24
- include: string;
25
- files?: string[];
26
- quiet?: boolean;
27
- ignore?: boolean;
28
- fix?: boolean;
29
- outputReport?: boolean;
30
- config?: Config;
31
- }
32
- export interface ScanResult {
33
- filePath: string;
34
- errorCount: number;
35
- warningCount: number;
36
- fixableErrorCount: number;
37
- fixableWarningCount: number;
38
- messages: Array<{
39
- line: number;
40
- column: number;
41
- rule: string;
42
- url: string;
43
- message: string;
44
- errored: boolean;
45
- }>;
46
- }
47
- export interface ScanReport {
48
- results: ScanResult[];
49
- errorCount: number;
50
- warningCount: number;
51
- runErrors: Error[];
52
- }
53
- export interface InitOptions {
54
- cwd: string;
55
- checkVersionUpdate: boolean;
56
- rewriteConfig?: boolean;
57
- eslintType?: string;
58
- enableESLint?: boolean;
59
- enableStylelint?: boolean;
60
- enableMarkdownlint?: boolean;
61
- enablePrettier?: boolean;
62
- disableNpmInstall?: boolean;
63
- }
64
- export interface IGetLintConfig {
65
- (options: ScanOptions, pkg: PKG, config: Config): ESLint.Options;
66
- (options: ScanOptions, pkg: PKG, config: Config): stylelint.LinterOptions;
67
- (options: ScanOptions, pkg: PKG, config: Config): markdownlint.Options;
68
- }
69
- export interface IFormatResults {
70
- (results: ESLint.LintResult[], quiet: boolean): ScanResult[];
71
- (results: stylelint.LintResult[], quiet: boolean): ScanResult[];
72
- (results: markdownlint.LintResults, quiet: boolean): ScanResult[];
73
- }
1
+ import { ESLint } from 'eslint';
2
+ import stylelint from 'stylelint';
3
+ import markdownlint from 'markdownlint';
4
+ export interface PKG {
5
+ eslintConfig?: any;
6
+ eslintIgnore?: string[];
7
+ stylelint?: any;
8
+ peerDependencies?: Record<string, string>;
9
+ devDependencies?: Record<string, string>;
10
+ dependencies?: Record<string, string>;
11
+ [key: string]: any;
12
+ }
13
+ export interface Config {
14
+ enableESLint?: boolean;
15
+ enableStylelint?: boolean;
16
+ enableMarkdownlint?: boolean;
17
+ enablePrettier?: boolean;
18
+ eslintOptions?: ESLint.Options;
19
+ stylelintOptions?: stylelint.LinterOptions;
20
+ markdownlintOptions?: markdownlint.Options;
21
+ }
22
+ export interface ScanOptions {
23
+ cwd: string;
24
+ include: string;
25
+ files?: string[];
26
+ quiet?: boolean;
27
+ ignore?: boolean;
28
+ fix?: boolean;
29
+ outputReport?: boolean;
30
+ config?: Config;
31
+ }
32
+ export interface ScanResult {
33
+ filePath: string;
34
+ errorCount: number;
35
+ warningCount: number;
36
+ fixableErrorCount: number;
37
+ fixableWarningCount: number;
38
+ messages: Array<{
39
+ line: number;
40
+ column: number;
41
+ rule: string;
42
+ url: string;
43
+ message: string;
44
+ errored: boolean;
45
+ }>;
46
+ }
47
+ export interface ScanReport {
48
+ results: ScanResult[];
49
+ errorCount: number;
50
+ warningCount: number;
51
+ runErrors: Error[];
52
+ }
53
+ export interface InitOptions {
54
+ cwd: string;
55
+ checkVersionUpdate: boolean;
56
+ rewriteConfig?: boolean;
57
+ eslintType?: string;
58
+ enableESLint?: boolean;
59
+ enableStylelint?: boolean;
60
+ enableMarkdownlint?: boolean;
61
+ enablePrettier?: boolean;
62
+ disableNpmInstall?: boolean;
63
+ }
64
+ export interface IGetLintConfig {
65
+ (options: ScanOptions, pkg: PKG, config: Config): ESLint.Options;
66
+ (options: ScanOptions, pkg: PKG, config: Config): stylelint.LinterOptions;
67
+ (options: ScanOptions, pkg: PKG, config: Config): markdownlint.Options;
68
+ }
69
+ export interface IFormatResults {
70
+ (results: ESLint.LintResult[], quiet: boolean): ScanResult[];
71
+ (results: stylelint.LintResult[], quiet: boolean): ScanResult[];
72
+ (results: markdownlint.LintResults, quiet: boolean): ScanResult[];
73
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,3 @@
1
- import type { PKG } from '../types';
2
- declare const _default: (cwd: string, rewriteConfig?: boolean) => Promise<PKG>;
3
- export default _default;
1
+ import type { PKG } from '../types';
2
+ declare const _default: (cwd: string, rewriteConfig?: boolean) => Promise<PKG>;
3
+ export default _default;
@@ -1,175 +1,95 @@
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 __values = (this && this.__values) || function(o) {
39
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
- if (m) return m.call(o);
41
- if (o && typeof o.length === "number") return {
42
- next: function () {
43
- if (o && i >= o.length) o = void 0;
44
- return { value: o && o[i++], done: !o };
45
- }
46
- };
47
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- var path_1 = __importDefault(require("path"));
54
- var fs_extra_1 = __importDefault(require("fs-extra"));
55
- var glob_1 = __importDefault(require("glob"));
56
- var inquirer_1 = __importDefault(require("inquirer"));
57
- var log_1 = __importDefault(require("./log"));
58
- var constants_1 = require("./constants");
59
- var packageNamesToRemove = [
60
- '@babel/eslint-parser',
61
- '@commitlint/cli',
62
- '@iceworks/spec',
63
- 'babel-eslint',
64
- 'eslint',
65
- 'husky',
66
- 'markdownlint',
67
- 'prettier',
68
- 'stylelint',
69
- 'tslint',
70
- ];
71
- var packagePrefixesToRemove = [
72
- '@commitlint/',
73
- '@typescript-eslint/',
74
- 'eslint-',
75
- 'stylelint-',
76
- 'markdownlint-',
77
- 'commitlint-',
78
- ];
79
- var checkUselessConfig = function (cwd) {
80
- return []
81
- .concat(glob_1.default.sync('.eslintrc?(.@(yaml|yml|json))', { cwd: cwd }))
82
- .concat(glob_1.default.sync('.stylelintrc?(.@(yaml|yml|json))', { cwd: cwd }))
83
- .concat(glob_1.default.sync('.markdownlint@(rc|.@(yaml|yml|jsonc))', { cwd: cwd }))
84
- .concat(glob_1.default.sync('.prettierrc?(.@(cjs|config.js|config.cjs|yaml|yml|json|json5|toml))', { cwd: cwd }))
85
- .concat(glob_1.default.sync('tslint.@(yaml|yml|json)', { cwd: cwd }))
86
- .concat(glob_1.default.sync('.kylerc?(.@(yaml|yml|json))', { cwd: cwd }));
87
- };
88
- var checkReWriteConfig = function (cwd) {
89
- return glob_1.default
90
- .sync('**/*.ejs', { cwd: path_1.default.resolve(__dirname, '../config') })
91
- .map(function (name) { return name.replace(/^_/, '.').replace(/\.ejs$/, ''); })
92
- .filter(function (filename) { return fs_extra_1.default.existsSync(path_1.default.resolve(cwd, filename)); });
93
- };
94
- exports.default = (function (cwd, rewriteConfig) { return __awaiter(void 0, void 0, void 0, function () {
95
- var pkgPath, pkg, dependencies, willRemovePackage, uselessConfig, reWriteConfig, willChangeCount, isOverWrite, uselessConfig_1, uselessConfig_1_1, name_1, willRemovePackage_1, willRemovePackage_1_1, name_2;
96
- var e_1, _a, e_2, _b;
97
- return __generator(this, function (_c) {
98
- switch (_c.label) {
99
- case 0:
100
- pkgPath = path_1.default.resolve(cwd, 'package.json');
101
- pkg = fs_extra_1.default.readJSONSync(pkgPath);
102
- dependencies = [].concat(Object.keys(pkg.dependencies || {}), Object.keys(pkg.devDependencies || []));
103
- willRemovePackage = dependencies.filter(function (name) {
104
- return packageNamesToRemove.includes(name) ||
105
- packagePrefixesToRemove.some(function (prefix) { return name.startsWith(prefix); });
106
- });
107
- uselessConfig = checkUselessConfig(cwd);
108
- reWriteConfig = checkReWriteConfig(cwd);
109
- willChangeCount = willRemovePackage.length + uselessConfig.length + reWriteConfig.length;
110
- if (!(willChangeCount > 0)) return [3, 3];
111
- log_1.default.warn("\u68C0\u6D4B\u5230\u9879\u76EE\u4E2D\u5B58\u5728\u53EF\u80FD\u4E0E ".concat(constants_1.PKG_NAME, " \u51B2\u7A81\u7684\u4F9D\u8D56\u548C\u914D\u7F6E\uFF0C\u4E3A\u4FDD\u8BC1\u6B63\u5E38\u8FD0\u884C\u5C06"));
112
- if (willRemovePackage.length > 0) {
113
- log_1.default.warn('删除以下依赖:');
114
- log_1.default.warn(JSON.stringify(willRemovePackage, null, 2));
115
- }
116
- if (uselessConfig.length > 0) {
117
- log_1.default.warn('删除以下配置文件:');
118
- log_1.default.warn(JSON.stringify(uselessConfig, null, 2));
119
- }
120
- if (reWriteConfig.length > 0) {
121
- log_1.default.warn('覆盖以下配置文件:');
122
- log_1.default.warn(JSON.stringify(reWriteConfig, null, 2));
123
- }
124
- if (!(typeof rewriteConfig === 'undefined')) return [3, 2];
125
- return [4, inquirer_1.default.prompt({
126
- type: 'confirm',
127
- name: 'isOverWrite',
128
- message: '请确认是否继续:',
129
- })];
130
- case 1:
131
- isOverWrite = (_c.sent()).isOverWrite;
132
- if (!isOverWrite)
133
- process.exit(0);
134
- return [3, 3];
135
- case 2:
136
- if (!reWriteConfig) {
137
- process.exit(0);
138
- }
139
- _c.label = 3;
140
- case 3:
141
- try {
142
- for (uselessConfig_1 = __values(uselessConfig), uselessConfig_1_1 = uselessConfig_1.next(); !uselessConfig_1_1.done; uselessConfig_1_1 = uselessConfig_1.next()) {
143
- name_1 = uselessConfig_1_1.value;
144
- fs_extra_1.default.removeSync(path_1.default.resolve(cwd, name_1));
145
- }
146
- }
147
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
148
- finally {
149
- try {
150
- if (uselessConfig_1_1 && !uselessConfig_1_1.done && (_a = uselessConfig_1.return)) _a.call(uselessConfig_1);
151
- }
152
- finally { if (e_1) throw e_1.error; }
153
- }
154
- delete pkg.eslintConfig;
155
- delete pkg.eslintIgnore;
156
- delete pkg.stylelint;
157
- try {
158
- for (willRemovePackage_1 = __values(willRemovePackage), willRemovePackage_1_1 = willRemovePackage_1.next(); !willRemovePackage_1_1.done; willRemovePackage_1_1 = willRemovePackage_1.next()) {
159
- name_2 = willRemovePackage_1_1.value;
160
- delete (pkg.dependencies || {})[name_2];
161
- delete (pkg.devDependencies || {})[name_2];
162
- }
163
- }
164
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
165
- finally {
166
- try {
167
- if (willRemovePackage_1_1 && !willRemovePackage_1_1.done && (_b = willRemovePackage_1.return)) _b.call(willRemovePackage_1);
168
- }
169
- finally { if (e_2) throw e_2.error; }
170
- }
171
- fs_extra_1.default.writeFileSync(path_1.default.resolve(cwd, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
172
- return [2, pkg];
173
- }
174
- });
175
- }); });
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 path_1 = __importDefault(require("path"));
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const glob_1 = __importDefault(require("glob"));
9
+ const inquirer_1 = __importDefault(require("inquirer"));
10
+ const log_1 = __importDefault(require("./log"));
11
+ const constants_1 = require("./constants");
12
+ const packageNamesToRemove = [
13
+ '@babel/eslint-parser',
14
+ '@commitlint/cli',
15
+ '@iceworks/spec',
16
+ 'babel-eslint',
17
+ 'eslint',
18
+ 'husky',
19
+ 'markdownlint',
20
+ 'prettier',
21
+ 'stylelint',
22
+ 'tslint',
23
+ ];
24
+ const packagePrefixesToRemove = [
25
+ '@commitlint/',
26
+ '@typescript-eslint/',
27
+ 'eslint-',
28
+ 'stylelint-',
29
+ 'markdownlint-',
30
+ 'commitlint-',
31
+ ];
32
+ const checkUselessConfig = (cwd) => {
33
+ return []
34
+ .concat(glob_1.default.sync('.eslintrc?(.@(yaml|yml|json))', { cwd }))
35
+ .concat(glob_1.default.sync('.stylelintrc?(.@(yaml|yml|json))', { cwd }))
36
+ .concat(glob_1.default.sync('.markdownlint@(rc|.@(yaml|yml|jsonc))', { cwd }))
37
+ .concat(glob_1.default.sync('.prettierrc?(.@(cjs|config.js|config.cjs|yaml|yml|json|json5|toml))', { cwd }))
38
+ .concat(glob_1.default.sync('tslint.@(yaml|yml|json)', { cwd }))
39
+ .concat(glob_1.default.sync('.kylerc?(.@(yaml|yml|json))', { cwd }));
40
+ };
41
+ const checkReWriteConfig = (cwd) => {
42
+ return glob_1.default
43
+ .sync('**/*.ejs', { cwd: path_1.default.resolve(__dirname, '../config') })
44
+ .map((name) => name.replace(/^_/, '.').replace(/\.ejs$/, ''))
45
+ .filter((filename) => fs_extra_1.default.existsSync(path_1.default.resolve(cwd, filename)));
46
+ };
47
+ exports.default = async (cwd, rewriteConfig) => {
48
+ const pkgPath = path_1.default.resolve(cwd, 'package.json');
49
+ const pkg = fs_extra_1.default.readJSONSync(pkgPath);
50
+ const dependencies = [].concat(Object.keys(pkg.dependencies || {}), Object.keys(pkg.devDependencies || []));
51
+ const willRemovePackage = dependencies.filter((name) => packageNamesToRemove.includes(name) ||
52
+ packagePrefixesToRemove.some((prefix) => name.startsWith(prefix)));
53
+ const uselessConfig = checkUselessConfig(cwd);
54
+ const reWriteConfig = checkReWriteConfig(cwd);
55
+ const willChangeCount = willRemovePackage.length + uselessConfig.length + reWriteConfig.length;
56
+ if (willChangeCount > 0) {
57
+ log_1.default.warn(`检测到项目中存在可能与 ${constants_1.PKG_NAME} 冲突的依赖和配置,为保证正常运行将`);
58
+ if (willRemovePackage.length > 0) {
59
+ log_1.default.warn('删除以下依赖:');
60
+ log_1.default.warn(JSON.stringify(willRemovePackage, null, 2));
61
+ }
62
+ if (uselessConfig.length > 0) {
63
+ log_1.default.warn('删除以下配置文件:');
64
+ log_1.default.warn(JSON.stringify(uselessConfig, null, 2));
65
+ }
66
+ if (reWriteConfig.length > 0) {
67
+ log_1.default.warn('覆盖以下配置文件:');
68
+ log_1.default.warn(JSON.stringify(reWriteConfig, null, 2));
69
+ }
70
+ if (typeof rewriteConfig === 'undefined') {
71
+ const { isOverWrite } = await inquirer_1.default.prompt({
72
+ type: 'confirm',
73
+ name: 'isOverWrite',
74
+ message: '请确认是否继续:',
75
+ });
76
+ if (!isOverWrite)
77
+ process.exit(0);
78
+ }
79
+ else if (!reWriteConfig) {
80
+ process.exit(0);
81
+ }
82
+ }
83
+ for (const name of uselessConfig) {
84
+ fs_extra_1.default.removeSync(path_1.default.resolve(cwd, name));
85
+ }
86
+ delete pkg.eslintConfig;
87
+ delete pkg.eslintIgnore;
88
+ delete pkg.stylelint;
89
+ for (const name of willRemovePackage) {
90
+ delete (pkg.dependencies || {})[name];
91
+ delete (pkg.devDependencies || {})[name];
92
+ }
93
+ fs_extra_1.default.writeFileSync(path_1.default.resolve(cwd, 'package.json'), JSON.stringify(pkg, null, 2), 'utf8');
94
+ return pkg;
95
+ };
@@ -1,18 +1,18 @@
1
- export declare enum UNICODE {
2
- success = "\u2714",
3
- failure = "\u2716"
4
- }
5
- export declare const PKG_NAME: string;
6
- export declare const PKG_VERSION: string;
7
- export declare const PROJECT_TYPES: Array<{
8
- name: string;
9
- value: string;
10
- }>;
11
- export declare const ESLINT_FILE_EXT: string[];
12
- export declare const ESLINT_IGNORE_PATTERN: string[];
13
- export declare const STYLELINT_FILE_EXT: string[];
14
- export declare const STYLELINT_IGNORE_PATTERN: string[];
15
- export declare const MARKDOWN_LINT_FILE_EXT: string[];
16
- export declare const MARKDOWN_LINT_IGNORE_PATTERN: string[];
17
- export declare const PRETTIER_FILE_EXT: string[];
18
- export declare const PRETTIER_IGNORE_PATTERN: string[];
1
+ export declare enum UNICODE {
2
+ success = "\u2714",
3
+ failure = "\u2716"
4
+ }
5
+ export declare const PKG_NAME: string;
6
+ export declare const PKG_VERSION: string;
7
+ export declare const PROJECT_TYPES: Array<{
8
+ name: string;
9
+ value: string;
10
+ }>;
11
+ export declare const ESLINT_FILE_EXT: string[];
12
+ export declare const ESLINT_IGNORE_PATTERN: string[];
13
+ export declare const STYLELINT_FILE_EXT: string[];
14
+ export declare const STYLELINT_IGNORE_PATTERN: string[];
15
+ export declare const MARKDOWN_LINT_FILE_EXT: string[];
16
+ export declare const MARKDOWN_LINT_IGNORE_PATTERN: string[];
17
+ export declare const PRETTIER_FILE_EXT: string[];
18
+ export declare const PRETTIER_IGNORE_PATTERN: string[];