@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,133 +1,104 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
- var __importDefault = (this && this.__importDefault) || function (mod) {
28
- return (mod && mod.__esModule) ? mod : { "default": mod };
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.PRETTIER_IGNORE_PATTERN = exports.PRETTIER_FILE_EXT = exports.MARKDOWN_LINT_IGNORE_PATTERN = exports.MARKDOWN_LINT_FILE_EXT = exports.STYLELINT_IGNORE_PATTERN = exports.STYLELINT_FILE_EXT = exports.ESLINT_IGNORE_PATTERN = exports.ESLINT_FILE_EXT = exports.PROJECT_TYPES = exports.PKG_VERSION = exports.PKG_NAME = exports.UNICODE = void 0;
32
- var path_1 = __importDefault(require("path"));
33
- var fs_extra_1 = __importDefault(require("fs-extra"));
34
- var pkg = JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json'), 'utf8'));
35
- var UNICODE;
36
- (function (UNICODE) {
37
- UNICODE["success"] = "\u2714";
38
- UNICODE["failure"] = "\u2716";
39
- })(UNICODE = exports.UNICODE || (exports.UNICODE = {}));
40
- exports.PKG_NAME = pkg.name;
41
- exports.PKG_VERSION = pkg.version;
42
- exports.PROJECT_TYPES = [
43
- {
44
- name: '未使用 React、Vue、Node.js 的项目(JavaScript)',
45
- value: 'index',
46
- },
47
- {
48
- name: '未使用 React、Vue、Node.js 的项目(TypeScript)',
49
- value: 'typescript',
50
- },
51
- {
52
- name: 'React 项目(JavaScript)',
53
- value: 'react',
54
- },
55
- {
56
- name: 'React 项目(TypeScript)',
57
- value: 'typescript/react',
58
- },
59
- {
60
- name: 'Rax 项目(JavaScript)',
61
- value: 'rax',
62
- },
63
- {
64
- name: 'Rax 项目(TypeScript)',
65
- value: 'typescript/rax',
66
- },
67
- {
68
- name: 'Vue 项目(JavaScript)',
69
- value: 'vue',
70
- },
71
- {
72
- name: 'Vue 项目(TypeScript)',
73
- value: 'typescript/vue',
74
- },
75
- {
76
- name: 'Node.js 项目(JavaScript)',
77
- value: 'node',
78
- },
79
- {
80
- name: 'Node.js 项目(TypeScript)',
81
- value: 'typescript/node',
82
- },
83
- {
84
- name: '使用 ES5 及之前版本 JavaScript 的老项目',
85
- value: 'es5',
86
- },
87
- {
88
- name: '使用 @antfu/eslint-config',
89
- value: 'ESNext',
90
- },
91
- ];
92
- exports.ESLINT_FILE_EXT = ['.js', '.jsx', '.ts', '.tsx', '.vue'];
93
- exports.ESLINT_IGNORE_PATTERN = [
94
- 'node_modules',
95
- 'build',
96
- 'dist',
97
- 'coverage',
98
- 'es',
99
- 'lib',
100
- '**/*.min.js',
101
- '**/*-min.js',
102
- '**/*.bundle.js',
103
- ];
104
- exports.STYLELINT_FILE_EXT = ['.css', '.scss', '.less', '.acss'];
105
- exports.STYLELINT_IGNORE_PATTERN = [
106
- 'node_modules/',
107
- 'build/',
108
- 'dist/',
109
- 'coverage/',
110
- 'es/',
111
- 'lib/',
112
- '**/*.min.css',
113
- '**/*-min.css',
114
- '**/*.bundle.css',
115
- ];
116
- exports.MARKDOWN_LINT_FILE_EXT = ['.md'];
117
- exports.MARKDOWN_LINT_IGNORE_PATTERN = [
118
- 'node_modules/',
119
- 'build/',
120
- 'dist/',
121
- 'coverage/',
122
- 'es/',
123
- 'lib/',
124
- ];
125
- exports.PRETTIER_FILE_EXT = __spreadArray(__spreadArray(__spreadArray([], __read(exports.STYLELINT_FILE_EXT), false), __read(exports.ESLINT_FILE_EXT), false), __read(exports.MARKDOWN_LINT_FILE_EXT), false);
126
- exports.PRETTIER_IGNORE_PATTERN = [
127
- 'node_modules/**/*',
128
- 'build/**/*',
129
- 'dist/**/*',
130
- 'lib/**/*',
131
- 'es/**/*',
132
- 'coverage/**/*',
133
- ];
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
+ exports.PRETTIER_IGNORE_PATTERN = exports.PRETTIER_FILE_EXT = exports.MARKDOWN_LINT_IGNORE_PATTERN = exports.MARKDOWN_LINT_FILE_EXT = exports.STYLELINT_IGNORE_PATTERN = exports.STYLELINT_FILE_EXT = exports.ESLINT_IGNORE_PATTERN = exports.ESLINT_FILE_EXT = exports.PROJECT_TYPES = exports.PKG_VERSION = exports.PKG_NAME = exports.UNICODE = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const pkg = JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json'), 'utf8'));
10
+ var UNICODE;
11
+ (function (UNICODE) {
12
+ UNICODE["success"] = "\u2714";
13
+ UNICODE["failure"] = "\u2716";
14
+ })(UNICODE = exports.UNICODE || (exports.UNICODE = {}));
15
+ exports.PKG_NAME = pkg.name;
16
+ exports.PKG_VERSION = pkg.version;
17
+ exports.PROJECT_TYPES = [
18
+ {
19
+ name: '未使用 React、Vue、Node.js 的项目(JavaScript)',
20
+ value: 'index',
21
+ },
22
+ {
23
+ name: '未使用 React、Vue、Node.js 的项目(TypeScript)',
24
+ value: 'typescript',
25
+ },
26
+ {
27
+ name: 'React 项目(JavaScript)',
28
+ value: 'react',
29
+ },
30
+ {
31
+ name: 'React 项目(TypeScript)',
32
+ value: 'typescript/react',
33
+ },
34
+ {
35
+ name: 'Vue 项目(JavaScript)',
36
+ value: 'vue',
37
+ },
38
+ {
39
+ name: 'Vue 项目(TypeScript)',
40
+ value: 'typescript/vue',
41
+ },
42
+ {
43
+ name: 'Node.js 项目(JavaScript)',
44
+ value: 'node',
45
+ },
46
+ {
47
+ name: 'Node.js 项目(TypeScript)',
48
+ value: 'typescript/node',
49
+ },
50
+ {
51
+ name: '使用 ES5 及之前版本 JavaScript 的老项目',
52
+ value: 'es5',
53
+ },
54
+ {
55
+ name: '使用自定义/社区预设(如 @antfu/eslint-config 等)',
56
+ value: 'custom',
57
+ },
58
+ ];
59
+ exports.ESLINT_FILE_EXT = ['.js', '.jsx', '.ts', '.tsx', '.vue'];
60
+ exports.ESLINT_IGNORE_PATTERN = [
61
+ 'node_modules',
62
+ 'build',
63
+ 'dist',
64
+ 'coverage',
65
+ 'es',
66
+ 'lib',
67
+ '**/*.min.js',
68
+ '**/*-min.js',
69
+ '**/*.bundle.js',
70
+ ];
71
+ exports.STYLELINT_FILE_EXT = ['.css', '.scss', '.less', '.acss'];
72
+ exports.STYLELINT_IGNORE_PATTERN = [
73
+ 'node_modules/',
74
+ 'build/',
75
+ 'dist/',
76
+ 'coverage/',
77
+ 'es/',
78
+ 'lib/',
79
+ '**/*.min.css',
80
+ '**/*-min.css',
81
+ '**/*.bundle.css',
82
+ ];
83
+ exports.MARKDOWN_LINT_FILE_EXT = ['.md'];
84
+ exports.MARKDOWN_LINT_IGNORE_PATTERN = [
85
+ 'node_modules/',
86
+ 'build/',
87
+ 'dist/',
88
+ 'coverage/',
89
+ 'es/',
90
+ 'lib/',
91
+ ];
92
+ exports.PRETTIER_FILE_EXT = [
93
+ ...exports.STYLELINT_FILE_EXT,
94
+ ...exports.ESLINT_FILE_EXT,
95
+ ...exports.MARKDOWN_LINT_FILE_EXT,
96
+ ];
97
+ exports.PRETTIER_IGNORE_PATTERN = [
98
+ 'node_modules/**/*',
99
+ 'build/**/*',
100
+ 'dist/**/*',
101
+ 'lib/**/*',
102
+ 'es/**/*',
103
+ 'coverage/**/*',
104
+ ];
@@ -1,2 +1,2 @@
1
- declare const _default: (cwd: string, data: Record<string, any>, vscode?: boolean) => void;
2
- export default _default;
1
+ declare const _default: (cwd: string, data: Record<string, any>, vscode?: boolean) => void;
2
+ export default _default;
@@ -1,99 +1,53 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
- if (ar || !(i in from)) {
32
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
- ar[i] = from[i];
34
- }
35
- }
36
- return to.concat(ar || Array.prototype.slice.call(from));
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 lodash_1 = __importDefault(require("lodash"));
56
- var glob_1 = __importDefault(require("glob"));
57
- var ejs_1 = __importDefault(require("ejs"));
58
- var constants_1 = require("./constants");
59
- var mergeVSCodeConfig = function (filepath, content) {
60
- if (!fs_extra_1.default.existsSync(filepath))
61
- return content;
62
- try {
63
- var targetData = fs_extra_1.default.readJSONSync(filepath);
64
- var sourceData = JSON.parse(content);
65
- return JSON.stringify(lodash_1.default.mergeWith(targetData, sourceData, function (target, source) {
66
- if (Array.isArray(target) && Array.isArray(source)) {
67
- return __spreadArray([], __read(new Set(source.concat(target))), false);
68
- }
69
- }), null, 2);
70
- }
71
- catch (e) {
72
- return '';
73
- }
74
- };
75
- exports.default = (function (cwd, data, vscode) {
76
- var e_1, _a;
77
- var templatePath = path_1.default.resolve(__dirname, '../config');
78
- var templates = glob_1.default.sync("".concat(vscode ? '_vscode' : '**', "/*.ejs"), { cwd: templatePath });
79
- try {
80
- for (var templates_1 = __values(templates), templates_1_1 = templates_1.next(); !templates_1_1.done; templates_1_1 = templates_1.next()) {
81
- var name_1 = templates_1_1.value;
82
- var filepath = path_1.default.resolve(cwd, name_1.replace(/\.ejs$/, '').replace(/^_/, '.'));
83
- var content = ejs_1.default.render(fs_extra_1.default.readFileSync(path_1.default.resolve(templatePath, name_1), 'utf8'), __assign({ eslintIgnores: constants_1.ESLINT_IGNORE_PATTERN, stylelintExt: constants_1.STYLELINT_FILE_EXT, stylelintIgnores: constants_1.STYLELINT_IGNORE_PATTERN, markdownLintIgnores: constants_1.MARKDOWN_LINT_IGNORE_PATTERN }, data));
84
- if (/^_vscode/.test(name_1)) {
85
- content = mergeVSCodeConfig(filepath, content);
86
- }
87
- if (!content.trim())
88
- continue;
89
- fs_extra_1.default.outputFileSync(filepath, content, 'utf8');
90
- }
91
- }
92
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
93
- finally {
94
- try {
95
- if (templates_1_1 && !templates_1_1.done && (_a = templates_1.return)) _a.call(templates_1);
96
- }
97
- finally { if (e_1) throw e_1.error; }
98
- }
99
- });
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 lodash_1 = __importDefault(require("lodash"));
9
+ const glob_1 = __importDefault(require("glob"));
10
+ const ejs_1 = __importDefault(require("ejs"));
11
+ const constants_1 = require("./constants");
12
+ const mergeVSCodeConfig = (filepath, content) => {
13
+ if (!fs_extra_1.default.existsSync(filepath))
14
+ return content;
15
+ try {
16
+ const targetData = fs_extra_1.default.readJSONSync(filepath);
17
+ const sourceData = JSON.parse(content);
18
+ return JSON.stringify(lodash_1.default.mergeWith(targetData, sourceData, (target, source) => {
19
+ if (Array.isArray(target) && Array.isArray(source)) {
20
+ return [...new Set(source.concat(target))];
21
+ }
22
+ }), null, 2);
23
+ }
24
+ catch (e) {
25
+ return '';
26
+ }
27
+ };
28
+ exports.default = (cwd, data, vscode) => {
29
+ const templatePath = path_1.default.resolve(__dirname, '../config');
30
+ const templates = glob_1.default.sync(`${vscode ? '_vscode' : '**'}/*.ejs`, { cwd: templatePath });
31
+ for (const name of templates) {
32
+ const filepath = path_1.default.resolve(cwd, name.replace(/\.ejs$/, '').replace(/^_/, '.'));
33
+ let content = ejs_1.default.render(fs_extra_1.default.readFileSync(path_1.default.resolve(templatePath, name), 'utf8'), {
34
+ eslintIgnores: constants_1.ESLINT_IGNORE_PATTERN,
35
+ stylelintExt: constants_1.STYLELINT_FILE_EXT,
36
+ stylelintIgnores: constants_1.STYLELINT_IGNORE_PATTERN,
37
+ markdownLintIgnores: constants_1.MARKDOWN_LINT_IGNORE_PATTERN,
38
+ ...data,
39
+ });
40
+ if (name === 'eslint.config.mjs.ejs' && !data.enableFlatConfig) {
41
+ continue;
42
+ }
43
+ if (name === '_eslintrc.js.ejs' && data.enableFlatConfig) {
44
+ continue;
45
+ }
46
+ if (/^_vscode/.test(name)) {
47
+ content = mergeVSCodeConfig(filepath, content);
48
+ }
49
+ if (!content.trim())
50
+ continue;
51
+ fs_extra_1.default.outputFileSync(filepath, content, 'utf8');
52
+ }
53
+ };
@@ -1,3 +1,3 @@
1
- import execa from 'execa';
2
- export declare const getCommitFiles: (options?: execa.Options) => Promise<string[]>;
3
- export declare const getAmendFiles: (options?: execa.Options) => Promise<string>;
1
+ import execa from 'execa';
2
+ export declare const getCommitFiles: (options?: execa.Options) => Promise<string[]>;
3
+ export declare const getAmendFiles: (options?: execa.Options) => Promise<string>;
package/lib/utils/git.js CHANGED
@@ -1,105 +1,44 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
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
- exports.getAmendFiles = exports.getCommitFiles = void 0;
54
- var execa_1 = __importDefault(require("execa"));
55
- var getCommitFiles = function (options) {
56
- if (options === void 0) { options = {}; }
57
- return __awaiter(void 0, void 0, void 0, function () {
58
- var stdout, e_1;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0:
62
- _a.trys.push([0, 2, , 3]);
63
- return [4, (0, execa_1.default)('git', [
64
- 'diff',
65
- '--staged',
66
- '--diff-filter=ACMR',
67
- '--name-only',
68
- '--ignore-submodules',
69
- ], __assign(__assign({}, options), { all: true, cwd: options.cwd || process.cwd() }))];
70
- case 1:
71
- stdout = (_a.sent()).stdout;
72
- return [2, stdout ? stdout.split(/\s/).filter(Boolean) : []];
73
- case 2:
74
- e_1 = _a.sent();
75
- return [2, []];
76
- case 3: return [2];
77
- }
78
- });
79
- });
80
- };
81
- exports.getCommitFiles = getCommitFiles;
82
- var getAmendFiles = function (options) {
83
- if (options === void 0) { options = {}; }
84
- return __awaiter(void 0, void 0, void 0, function () {
85
- var stdout, e_2;
86
- return __generator(this, function (_a) {
87
- switch (_a.label) {
88
- case 0:
89
- _a.trys.push([0, 2, , 3]);
90
- return [4, (0, execa_1.default)('git', [
91
- 'diff',
92
- '--name-only',
93
- ], __assign(__assign({}, options), { all: true, cwd: options.cwd || process.cwd() }))];
94
- case 1:
95
- stdout = (_a.sent()).stdout;
96
- return [2, stdout];
97
- case 2:
98
- e_2 = _a.sent();
99
- return [2, ''];
100
- case 3: return [2];
101
- }
102
- });
103
- });
104
- };
105
- exports.getAmendFiles = getAmendFiles;
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
+ exports.getAmendFiles = exports.getCommitFiles = void 0;
7
+ const execa_1 = __importDefault(require("execa"));
8
+ const getCommitFiles = async (options = {}) => {
9
+ try {
10
+ const { stdout } = await (0, execa_1.default)('git', [
11
+ 'diff',
12
+ '--staged',
13
+ '--diff-filter=ACMR',
14
+ '--name-only',
15
+ '--ignore-submodules',
16
+ ], {
17
+ ...options,
18
+ all: true,
19
+ cwd: options.cwd || process.cwd(),
20
+ });
21
+ return stdout ? stdout.split(/\s/).filter(Boolean) : [];
22
+ }
23
+ catch (e) {
24
+ return [];
25
+ }
26
+ };
27
+ exports.getCommitFiles = getCommitFiles;
28
+ const getAmendFiles = async (options = {}) => {
29
+ try {
30
+ const { stdout } = await (0, execa_1.default)('git', [
31
+ 'diff',
32
+ '--name-only',
33
+ ], {
34
+ ...options,
35
+ all: true,
36
+ cwd: options.cwd || process.cwd(),
37
+ });
38
+ return stdout;
39
+ }
40
+ catch (e) {
41
+ return '';
42
+ }
43
+ };
44
+ exports.getAmendFiles = getAmendFiles;
@@ -1,8 +1,8 @@
1
- declare const _default: {
2
- success(text: string): void;
3
- info(text: string): void;
4
- warn(text: string): void;
5
- error(text: string): void;
6
- result(text: string, pass: boolean): void;
7
- };
8
- export default _default;
1
+ declare const _default: {
2
+ success(text: string): void;
3
+ info(text: string): void;
4
+ warn(text: string): void;
5
+ error(text: string): void;
6
+ result(text: string, pass: boolean): void;
7
+ };
8
+ export default _default;
package/lib/utils/log.js CHANGED
@@ -1,25 +1,25 @@
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
- var chalk_1 = __importDefault(require("chalk"));
7
- var constants_1 = require("./constants");
8
- var green = chalk_1.default.green, blue = chalk_1.default.blue, yellow = chalk_1.default.yellow, red = chalk_1.default.red;
9
- exports.default = {
10
- success: function (text) {
11
- console.log(green(text));
12
- },
13
- info: function (text) {
14
- console.info(blue(text));
15
- },
16
- warn: function (text) {
17
- console.info(yellow(text));
18
- },
19
- error: function (text) {
20
- console.error(red(text));
21
- },
22
- result: function (text, pass) {
23
- console.info(blue("[".concat(constants_1.PKG_NAME, "] ").concat(text)), pass ? green(constants_1.UNICODE.success) : red(constants_1.UNICODE.failure));
24
- },
25
- };
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 constants_1 = require("./constants");
8
+ const { green, blue, yellow, red } = chalk_1.default;
9
+ exports.default = {
10
+ success(text) {
11
+ console.log(green(text));
12
+ },
13
+ info(text) {
14
+ console.info(blue(text));
15
+ },
16
+ warn(text) {
17
+ console.info(yellow(text));
18
+ },
19
+ error(text) {
20
+ console.error(red(text));
21
+ },
22
+ result(text, pass) {
23
+ console.info(blue(`[${constants_1.PKG_NAME}] ${text}`), pass ? green(constants_1.UNICODE.success) : red(constants_1.UNICODE.failure));
24
+ },
25
+ };
@@ -1,2 +1,2 @@
1
- declare const promise: Promise<'npm' | 'pnpm'>;
2
- export default promise;
1
+ declare const promise: Promise<'npm' | 'pnpm'>;
2
+ export default promise;