@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/constants.js
CHANGED
|
@@ -1,133 +1,104 @@
|
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
];
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
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
|
-
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
|
+
};
|
package/lib/utils/git.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
} 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;
|
package/lib/utils/log.d.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.default = {
|
|
10
|
-
success
|
|
11
|
-
console.log(green(text));
|
|
12
|
-
},
|
|
13
|
-
info
|
|
14
|
-
console.info(blue(text));
|
|
15
|
-
},
|
|
16
|
-
warn
|
|
17
|
-
console.info(yellow(text));
|
|
18
|
-
},
|
|
19
|
-
error
|
|
20
|
-
console.error(red(text));
|
|
21
|
-
},
|
|
22
|
-
result
|
|
23
|
-
console.info(blue(
|
|
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
|
+
};
|
package/lib/utils/npm-type.d.ts
CHANGED
|
@@ -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;
|