auto-cr-cmd 2.0.101 → 2.0.105

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/dist/index.js CHANGED
@@ -71,6 +71,7 @@ var report_1 = require("./report");
71
71
  var i18n_1 = require("./i18n");
72
72
  var file_1 = require("./utils/file");
73
73
  var stdin_1 = require("./utils/stdin");
74
+ var path_2 = require("./utils/path");
74
75
  var analyzeFile_1 = require("./scan/analyzeFile");
75
76
  var runtime_1 = require("./scan/runtime");
76
77
  var workerPool_1 = require("./scan/workerPool");
@@ -131,7 +132,7 @@ var resolveWorkerCount = function (totalFiles) {
131
132
  */
132
133
  function run() {
133
134
  return __awaiter(this, arguments, void 0, function (filePaths, ruleDir, format, configPath, ignorePath, progressOption) {
134
- var t, notifications, progressMode, progressStream, progressStreamHasTty, progressEnabled, progressPinned, progressStyle, progressTotal, progressCurrent, progressLastPercent, clearProgressLine, renderProgress, startProgress, advanceProgress, finishProgress, reporterHooks, createNotification, logRecord, log, validPaths, ignoreConfig, isIgnored_1, allFiles, _i, validPaths_1, targetPath, stat, directoryFiles, scannableFiles_2, customRules, rcConfig, rules, filesWithErrors_1, filesWithWarnings_1, filesWithOptimizing_1, totalViolations_1, totalErrorViolations_1, totalWarningViolations_1, totalOptimizingViolations_1, fileSummaries_1, analysisFormat, workerCount, applyFileSummary_1, fileOccurrences_1, uniqueFiles, pendingResults_1, nextOutputIndex_1, flushReadyResults_1, initData, fileSummaryCache, _loop_1, _a, scannableFiles_1, file, error_1;
135
+ var t, notifications, progressMode, progressStream, progressStreamHasTty, progressEnabled, progressPinned, progressStyle, progressTotal, progressCurrent, progressLastPercent, clearProgressLine, renderProgress, startProgress, advanceProgress, finishProgress, reporterHooks, createNotification, logRecord, log, ignoreConfig, isIgnored_1, filteredPaths, validPaths, allFiles, _i, validPaths_1, targetPath, stat, directoryFiles, scannableFiles_2, customRules, rcConfig, rules, filesWithErrors_1, filesWithWarnings_1, filesWithOptimizing_1, totalViolations_1, totalErrorViolations_1, totalWarningViolations_1, totalOptimizingViolations_1, fileSummaries_1, analysisFormat, workerCount, applyFileSummary_1, fileOccurrences_1, uniqueFiles, pendingResults_1, nextOutputIndex_1, flushReadyResults_1, initData, fileSummaryCache, _loop_1, _a, scannableFiles_1, file, error_1;
135
136
  var _b;
136
137
  if (filePaths === void 0) { filePaths = []; }
137
138
  return __generator(this, function (_c) {
@@ -285,7 +286,23 @@ function run() {
285
286
  notifications: notifications,
286
287
  }];
287
288
  }
288
- validPaths = filePaths.filter(function (candidate) { return (0, file_1.checkPathExists)(candidate); });
289
+ ignoreConfig = (0, ignore_1.loadIgnoreConfig)(ignorePath);
290
+ ignoreConfig.warnings.forEach(function (warning) { return log('warn', warning); });
291
+ isIgnored_1 = (0, ignore_1.createIgnoreMatcher)(ignoreConfig.patterns, ignoreConfig.baseDir);
292
+ filteredPaths = filePaths.filter(function (candidate) { return !isIgnored_1(candidate); });
293
+ if (filteredPaths.length === 0) {
294
+ log('info', t.noFilesFound());
295
+ return [2 /*return*/, {
296
+ scannedFiles: 0,
297
+ filesWithErrors: 0,
298
+ filesWithWarnings: 0,
299
+ filesWithOptimizing: 0,
300
+ violationTotals: { total: 0, error: 0, warning: 0, optimizing: 0 },
301
+ files: [],
302
+ notifications: notifications,
303
+ }];
304
+ }
305
+ validPaths = filteredPaths.filter(function (candidate) { return (0, file_1.checkPathExists)(candidate); });
289
306
  if (validPaths.length === 0) {
290
307
  log('error', t.allPathsMissing());
291
308
  return [2 /*return*/, {
@@ -298,9 +315,6 @@ function run() {
298
315
  notifications: notifications,
299
316
  }];
300
317
  }
301
- ignoreConfig = (0, ignore_1.loadIgnoreConfig)(ignorePath);
302
- ignoreConfig.warnings.forEach(function (warning) { return log('warn', warning); });
303
- isIgnored_1 = (0, ignore_1.createIgnoreMatcher)(ignoreConfig.patterns, ignoreConfig.baseDir);
304
318
  allFiles = [];
305
319
  for (_i = 0, validPaths_1 = validPaths; _i < validPaths_1.length; _i++) {
306
320
  targetPath = validPaths_1[_i];
@@ -627,7 +641,7 @@ catch (error) {
627
641
  }
628
642
  ;
629
643
  (function () { return __awaiter(void 0, void 0, void 0, function () {
630
- var stdinTargets, combinedTargets, filePaths, result, t, payload, exitCode, language, resultMessage, exitCode, error_2, t, detail, payload;
644
+ var stdinTargets, combinedTargets, normalizedTargets, filePaths, result, t, payload, exitCode, language, resultMessage, exitCode, error_2, t, detail, payload;
631
645
  return __generator(this, function (_a) {
632
646
  switch (_a.label) {
633
647
  case 0:
@@ -636,7 +650,8 @@ catch (error) {
636
650
  case 1:
637
651
  stdinTargets = _a.sent();
638
652
  combinedTargets = __spreadArray(__spreadArray([], cliArguments, true), stdinTargets, true);
639
- filePaths = combinedTargets.map(function (target) { return path_1.default.resolve(process.cwd(), target); });
653
+ normalizedTargets = combinedTargets.map(function (target) { return (0, path_2.normalizeInputPath)(target); });
654
+ filePaths = normalizedTargets.map(function (target) { return path_1.default.resolve(process.cwd(), target); });
640
655
  return [4 /*yield*/, run(filePaths, options.ruleDir, outputFormat, options.config, options.ignorePath, progressOption)];
641
656
  case 2:
642
657
  result = _a.sent();
@@ -0,0 +1 @@
1
+ export declare const normalizeInputPath: (input: string) => string;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeInputPath = void 0;
4
+ var ESCAPE_BYTES = {
5
+ a: 0x07,
6
+ b: 0x08,
7
+ t: 0x09,
8
+ n: 0x0a,
9
+ v: 0x0b,
10
+ f: 0x0c,
11
+ r: 0x0d,
12
+ '"': 0x22,
13
+ '\\': 0x5c,
14
+ };
15
+ var isOctalDigit = function (char) { return char >= '0' && char <= '7'; };
16
+ var isHexDigit = function (char) {
17
+ return (char >= '0' && char <= '9') || (char >= 'a' && char <= 'f') || (char >= 'A' && char <= 'F');
18
+ };
19
+ var pushUtf8Bytes = function (bytes, text) {
20
+ var buffer = Buffer.from(text, 'utf8');
21
+ for (var index = 0; index < buffer.length; index += 1) {
22
+ bytes.push(buffer[index]);
23
+ }
24
+ };
25
+ var decodeGitQuotedPath = function (input) {
26
+ var _a;
27
+ if (input.length < 2 || input[0] !== '"' || input[input.length - 1] !== '"') {
28
+ return input;
29
+ }
30
+ var body = input.slice(1, -1);
31
+ var bytes = [];
32
+ for (var i = 0; i < body.length; i += 1) {
33
+ var current = body[i];
34
+ if (current !== '\\') {
35
+ var codePoint = (_a = body.codePointAt(i)) !== null && _a !== void 0 ? _a : 0;
36
+ if (codePoint <= 0x7f) {
37
+ bytes.push(codePoint);
38
+ }
39
+ else {
40
+ pushUtf8Bytes(bytes, String.fromCodePoint(codePoint));
41
+ if (codePoint > 0xffff) {
42
+ i += 1;
43
+ }
44
+ }
45
+ continue;
46
+ }
47
+ if (i + 1 >= body.length) {
48
+ bytes.push(0x5c);
49
+ continue;
50
+ }
51
+ var next = body[i + 1];
52
+ if (isOctalDigit(next)) {
53
+ var octal = next;
54
+ var consumed = 1;
55
+ while (consumed < 3 && i + 1 + consumed < body.length) {
56
+ var digit = body[i + 1 + consumed];
57
+ if (!isOctalDigit(digit)) {
58
+ break;
59
+ }
60
+ octal += digit;
61
+ consumed += 1;
62
+ }
63
+ bytes.push(parseInt(octal, 8));
64
+ i += consumed;
65
+ continue;
66
+ }
67
+ if ((next === 'x' || next === 'X') && i + 3 < body.length) {
68
+ var hex1 = body[i + 2];
69
+ var hex2 = body[i + 3];
70
+ if (isHexDigit(hex1) && isHexDigit(hex2)) {
71
+ bytes.push(parseInt("".concat(hex1).concat(hex2), 16));
72
+ i += 3;
73
+ continue;
74
+ }
75
+ }
76
+ var escaped = ESCAPE_BYTES[next];
77
+ if (escaped !== undefined) {
78
+ bytes.push(escaped);
79
+ i += 1;
80
+ continue;
81
+ }
82
+ bytes.push(0x5c);
83
+ }
84
+ return Buffer.from(bytes).toString('utf8');
85
+ };
86
+ // 兼容 git quotePath 输出的 C-style 字符串,确保非 ASCII 路径可解析。
87
+ var normalizeInputPath = function (input) { return decodeGitQuotedPath(input); };
88
+ exports.normalizeInputPath = normalizeInputPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-cr-cmd",
3
- "version": "2.0.101",
3
+ "version": "2.0.105",
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",
@@ -33,13 +33,13 @@
33
33
  },
34
34
  "sideEffects": false,
35
35
  "dependencies": {
36
- "@swc/core": "^1.15.8",
37
- "@swc/wasm": "^1.15.8",
36
+ "@swc/core": "^1.15.10",
37
+ "@swc/wasm": "^1.15.10",
38
38
  "commander": "^14.0.2",
39
39
  "consola": "^3.4.2",
40
40
  "jsonc-parser": "^3.3.1",
41
41
  "picomatch": "^4.0.3",
42
- "auto-cr-rules": "2.0.101"
42
+ "auto-cr-rules": "2.0.105"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@eslint/js": "^9.39.2",
@@ -47,14 +47,14 @@
47
47
  "@types/node": "^25.0.9",
48
48
  "@types/picomatch": "^4.0.2",
49
49
  "eslint": "^9.39.2",
50
- "eslint-plugin-prettier": "^5.5.4",
50
+ "eslint-plugin-prettier": "^5.5.5",
51
51
  "globals": "^17.0.0",
52
52
  "jiti": "^2.5.1",
53
- "prettier": "^3.7.4",
53
+ "prettier": "^3.8.0",
54
54
  "ts-node": "^10.9.2",
55
55
  "tslib": "^2.8.1",
56
56
  "typescript": "^5.9.2",
57
- "typescript-eslint": "^8.51.0"
57
+ "typescript-eslint": "^8.53.1"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "tsc --build tsconfig.json",