auto-cr-cmd 2.0.87 → 2.0.92
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/index.js +18 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Common flags:
|
|
|
43
43
|
- `--language <zh|en>`: Switch CLI output language (defaults to auto-detection).
|
|
44
44
|
- `--rule-dir <directory>`: Load additional custom rules from a directory or package.
|
|
45
45
|
- `--output <text|json>`: Choose between human-friendly text logs or structured JSON results (defaults to `text`).
|
|
46
|
-
- `--progress [
|
|
46
|
+
- `--progress [tty-only|yes|no]`: Progress mode (text output only, default `tty-only`); output goes to `stderr`.
|
|
47
47
|
- `--config <path>`: Point to a `.autocrrc.json` or `.autocrrc.js` file to enable/disable rules.
|
|
48
48
|
- `--ignore-path <path>`: Point to a `.autocrignore.json` or `.autocrignore.js` file to exclude files/directories from scanning.
|
|
49
49
|
- `--tsconfig <path>`: Use a custom `tsconfig.json` (defaults to `<cwd>/tsconfig.json`).
|
package/README.zh-CN.md
CHANGED
|
@@ -43,7 +43,7 @@ npx auto-cr-cmd --language zh [需要扫描的代码目录]
|
|
|
43
43
|
- `--language <zh|en>`:切换 CLI 输出语言(默认为自动检测)。
|
|
44
44
|
- `--rule-dir <directory>`:加载额外的自定义规则目录或包。
|
|
45
45
|
- `--output <text|json>`:选择输出格式,`text` 为友好的终端日志,`json` 用于集成脚本(默认为 `text`)。
|
|
46
|
-
- `--progress [
|
|
46
|
+
- `--progress [tty-only|yes|no]`:进度显示模式(仅 text 输出,默认 `tty-only`),输出到 stderr。
|
|
47
47
|
- `--config <path>`:指定 `.autocrrc.json` 或 `.autocrrc.js` 配置文件路径,用于开启/关闭规则。
|
|
48
48
|
- `--ignore-path <path>`:指定 `.autocrignore.json` 或 `.autocrignore.js` 忽略文件路径,用于排除扫描。
|
|
49
49
|
- `--tsconfig <path>`:指定自定义 `tsconfig.json` 路径(默认读取 `<cwd>/tsconfig.json`)。
|
package/dist/index.js
CHANGED
|
@@ -127,7 +127,7 @@ function resolveLocalRulesRuntime() {
|
|
|
127
127
|
*/
|
|
128
128
|
function run() {
|
|
129
129
|
return __awaiter(this, arguments, void 0, function (filePaths, ruleDir, format, configPath, ignorePath, progressOption) {
|
|
130
|
-
var t, notifications,
|
|
130
|
+
var t, notifications, progressMode, progressStream, progressStreamHasTty, progressEnabled, progressPinned, progressStyle, progressTotal, progressCurrent, progressLastPercent, clearProgressLine, renderProgress, startProgress, advanceProgress, finishProgress, reporterHooks, log, validPaths, ignoreConfig, isIgnored_1, allFiles, _i, validPaths_1, targetPath, stat, directoryFiles, scannableFiles, customRules, rcConfig, rules, filesWithErrors, filesWithWarnings, filesWithOptimizing, totalViolations, totalErrorViolations, totalWarningViolations, totalOptimizingViolations, fileSummaries, _a, scannableFiles_1, file, summary, error_1;
|
|
131
131
|
var _b;
|
|
132
132
|
if (filePaths === void 0) { filePaths = []; }
|
|
133
133
|
return __generator(this, function (_c) {
|
|
@@ -135,13 +135,11 @@ function run() {
|
|
|
135
135
|
case 0:
|
|
136
136
|
t = (0, i18n_1.getTranslator)();
|
|
137
137
|
notifications = [];
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
forceProgress = Boolean(progressOption === null || progressOption === void 0 ? void 0 : progressOption.force);
|
|
138
|
+
progressMode = (_b = progressOption === null || progressOption === void 0 ? void 0 : progressOption.mode) !== null && _b !== void 0 ? _b : 'tty-only';
|
|
139
|
+
progressStream = process.stderr;
|
|
141
140
|
progressStreamHasTty = Boolean(progressStream.isTTY);
|
|
142
|
-
progressEnabled = format === 'text' && (
|
|
143
|
-
progressPinned = progressEnabled;
|
|
144
|
-
progressFlushLine = progressEnabled && !progressStreamHasTty;
|
|
141
|
+
progressEnabled = format === 'text' && progressMode !== 'no' && (progressMode === 'yes' || progressStreamHasTty);
|
|
142
|
+
progressPinned = progressEnabled && progressStreamHasTty;
|
|
145
143
|
progressStyle = progressStreamHasTty
|
|
146
144
|
? { prefix: '\x1b[44m\x1b[97m', reset: '\x1b[0m' }
|
|
147
145
|
: { prefix: '', reset: '' };
|
|
@@ -158,7 +156,7 @@ function run() {
|
|
|
158
156
|
progressStream.write('\x1b[2K');
|
|
159
157
|
progressStream.write('\x1b8');
|
|
160
158
|
}
|
|
161
|
-
else {
|
|
159
|
+
else if (progressStreamHasTty) {
|
|
162
160
|
progressStream.write('\r\x1b[2K');
|
|
163
161
|
}
|
|
164
162
|
};
|
|
@@ -183,12 +181,9 @@ function run() {
|
|
|
183
181
|
progressStream.write('\x1b[K');
|
|
184
182
|
progressStream.write(progressStyle.reset);
|
|
185
183
|
}
|
|
186
|
-
if (progressFlushLine) {
|
|
187
|
-
progressStream.write('\n');
|
|
188
|
-
}
|
|
189
184
|
progressStream.write('\x1b8');
|
|
190
185
|
}
|
|
191
|
-
else {
|
|
186
|
+
else if (progressStreamHasTty) {
|
|
192
187
|
progressStream.write("\r".concat(styledMessage));
|
|
193
188
|
if (progressStyle.prefix) {
|
|
194
189
|
progressStream.write('\x1b[K');
|
|
@@ -198,6 +193,9 @@ function run() {
|
|
|
198
193
|
progressStream.write('\x1b[K');
|
|
199
194
|
}
|
|
200
195
|
}
|
|
196
|
+
else {
|
|
197
|
+
progressStream.write("".concat(styledMessage, "\n"));
|
|
198
|
+
}
|
|
201
199
|
};
|
|
202
200
|
startProgress = function (total) {
|
|
203
201
|
if (!progressEnabled) {
|
|
@@ -583,20 +581,20 @@ function parseOutputFormat(value) {
|
|
|
583
581
|
throw new Error("Unsupported output format: ".concat(value, ". Use \"text\" or \"json\"."));
|
|
584
582
|
}
|
|
585
583
|
function parseProgressOption(value) {
|
|
586
|
-
if (
|
|
587
|
-
return
|
|
584
|
+
if (value === undefined) {
|
|
585
|
+
return { mode: 'tty-only' };
|
|
588
586
|
}
|
|
589
587
|
if (value === true) {
|
|
590
|
-
return {
|
|
588
|
+
return { mode: 'yes' };
|
|
591
589
|
}
|
|
592
590
|
if (typeof value === 'string') {
|
|
593
591
|
var normalized = value.toLowerCase();
|
|
594
|
-
if (normalized === '
|
|
595
|
-
return {
|
|
592
|
+
if (normalized === 'tty-only' || normalized === 'yes' || normalized === 'no') {
|
|
593
|
+
return { mode: normalized };
|
|
596
594
|
}
|
|
597
|
-
throw new Error("Unsupported progress
|
|
595
|
+
throw new Error("Unsupported progress mode: ".concat(value, ". Use \"tty-only\", \"yes\", or \"no\"."));
|
|
598
596
|
}
|
|
599
|
-
return
|
|
597
|
+
return { mode: 'tty-only' };
|
|
600
598
|
}
|
|
601
599
|
function severityToLabel(severity) {
|
|
602
600
|
switch (severity) {
|
|
@@ -656,7 +654,7 @@ commander_1.program
|
|
|
656
654
|
.option('-c, --config <path>', '配置文件路径 (.autocrrc.json|.autocrrc.js) / Config file path (.autocrrc.json|.autocrrc.js)')
|
|
657
655
|
.option('--ignore-path <path>', '忽略文件列表路径 (.autocrignore.json|.autocrignore.js) / Ignore file path (.autocrignore.json|.autocrignore.js)')
|
|
658
656
|
.option('--tsconfig <path>', '自定义 tsconfig 路径 / Custom tsconfig path')
|
|
659
|
-
.option('--progress [
|
|
657
|
+
.option('--progress [mode]', '进度显示模式 tty-only/yes/no(默认 tty-only,输出到 stderr) / Progress mode tty-only/yes/no (default tty-only, outputs to stderr)')
|
|
660
658
|
.option('--stdin', '从标准输入读取扫描路径 / Read file paths from STDIN')
|
|
661
659
|
.parse(process.argv.filter(function (arg) { return arg !== '--'; }));
|
|
662
660
|
var options = commander_1.program.opts();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auto-cr-cmd",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.92",
|
|
4
4
|
"description": "Fast automated code review CLI powered by SWC-based static analysis",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@swc/core": "^1.15.8",
|
|
49
49
|
"@swc/wasm": "^1.15.8",
|
|
50
|
-
"auto-cr-rules": "^2.0.
|
|
50
|
+
"auto-cr-rules": "^2.0.89",
|
|
51
51
|
"commander": "^14.0.2",
|
|
52
52
|
"consola": "^3.4.2",
|
|
53
53
|
"jsonc-parser": "^3.3.1",
|