technical-debt-radar 1.0.9 → 1.1.1
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 +62 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19210,6 +19210,9 @@ function buildEnhancedPRCommentMarkdown(data) {
|
|
|
19210
19210
|
return lines.join("\n");
|
|
19211
19211
|
}
|
|
19212
19212
|
|
|
19213
|
+
// src/commands/scan.ts
|
|
19214
|
+
var import_child_process = require("child_process");
|
|
19215
|
+
|
|
19213
19216
|
// src/auth/config.ts
|
|
19214
19217
|
var fs = __toESM(require("fs"));
|
|
19215
19218
|
var path = __toESM(require("path"));
|
|
@@ -19293,6 +19296,30 @@ var RadarApiClient = class _RadarApiClient {
|
|
|
19293
19296
|
};
|
|
19294
19297
|
|
|
19295
19298
|
// src/commands/scan.ts
|
|
19299
|
+
function getGitBranch() {
|
|
19300
|
+
try {
|
|
19301
|
+
return (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", { encoding: "utf-8" }).trim();
|
|
19302
|
+
} catch {
|
|
19303
|
+
return "unknown";
|
|
19304
|
+
}
|
|
19305
|
+
}
|
|
19306
|
+
function getGitCommit() {
|
|
19307
|
+
try {
|
|
19308
|
+
return (0, import_child_process.execSync)("git rev-parse HEAD", { encoding: "utf-8" }).trim();
|
|
19309
|
+
} catch {
|
|
19310
|
+
return "unknown";
|
|
19311
|
+
}
|
|
19312
|
+
}
|
|
19313
|
+
function buildTopHotspots(violations) {
|
|
19314
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
19315
|
+
for (const v of violations) {
|
|
19316
|
+
const entry = byFile.get(v.file) ?? { violations: 0, debtPoints: 0 };
|
|
19317
|
+
entry.violations++;
|
|
19318
|
+
entry.debtPoints += v.debtPoints;
|
|
19319
|
+
byFile.set(v.file, entry);
|
|
19320
|
+
}
|
|
19321
|
+
return Array.from(byFile.entries()).map(([file, data]) => ({ file, ...data })).sort((a, b) => b.debtPoints - a.debtPoints).slice(0, 10);
|
|
19322
|
+
}
|
|
19296
19323
|
var ANON_SCAN_DIR = path2.join(os2.homedir(), ".radar");
|
|
19297
19324
|
var ANON_SCAN_FILE = path2.join(ANON_SCAN_DIR, ".anonymous-scan");
|
|
19298
19325
|
function checkAnonymousScanAllowed() {
|
|
@@ -19351,16 +19378,15 @@ async function enforceAuth(allowAnonymous = false) {
|
|
|
19351
19378
|
try {
|
|
19352
19379
|
scanCheck = await client.checkScanQuota();
|
|
19353
19380
|
} catch {
|
|
19354
|
-
|
|
19355
|
-
process.exit(1);
|
|
19381
|
+
return { client, isAnonymous: false };
|
|
19356
19382
|
}
|
|
19357
19383
|
if (!scanCheck.allowed) {
|
|
19358
|
-
|
|
19359
|
-
|
|
19360
|
-
|
|
19361
|
-
|
|
19384
|
+
const resetInfo = scanCheck.resetsAt ? ` Resets ${scanCheck.resetsAt}.` : "";
|
|
19385
|
+
console.error(import_chalk.default.red(
|
|
19386
|
+
`\u274C Monthly scan limit reached (${scanCheck.scansUsed}/${scanCheck.scanLimit}).${resetInfo}`
|
|
19387
|
+
));
|
|
19388
|
+
console.error(`Upgrade: ${import_chalk.default.cyan("radar upgrade")}
|
|
19362
19389
|
`);
|
|
19363
|
-
}
|
|
19364
19390
|
process.exit(1);
|
|
19365
19391
|
}
|
|
19366
19392
|
return { client, isAnonymous: false };
|
|
@@ -19477,15 +19503,39 @@ async function scanCommand(targetPath, options) {
|
|
|
19477
19503
|
printAnonymousScanCTA();
|
|
19478
19504
|
}
|
|
19479
19505
|
if (client) {
|
|
19480
|
-
|
|
19506
|
+
const blocking = result.violations.filter((v) => v.gateAction === "block");
|
|
19507
|
+
const warns = result.violations.filter((v) => v.gateAction === "warn");
|
|
19508
|
+
const byCat = countByCategory(result.violations);
|
|
19509
|
+
const reportData = {
|
|
19481
19510
|
repoName: path2.basename(path2.resolve(targetPath)),
|
|
19482
|
-
violations: result.violations.
|
|
19483
|
-
|
|
19511
|
+
violations: result.violations.map((v) => ({
|
|
19512
|
+
file: v.file,
|
|
19513
|
+
line: v.line,
|
|
19514
|
+
ruleId: v.ruleId,
|
|
19515
|
+
message: v.message,
|
|
19516
|
+
severity: v.severity,
|
|
19517
|
+
category: v.category,
|
|
19518
|
+
debtPoints: v.debtPoints,
|
|
19519
|
+
gateAction: v.gateAction
|
|
19520
|
+
})),
|
|
19521
|
+
debtScore: breakdown.total,
|
|
19522
|
+
filesScanned: files.length,
|
|
19523
|
+
blocking: blocking.length,
|
|
19524
|
+
warnings: warns.length,
|
|
19525
|
+
categoryBreakdown: byCat,
|
|
19526
|
+
topHotspots: buildTopHotspots(result.violations),
|
|
19527
|
+
branch: getGitBranch(),
|
|
19528
|
+
commit: getGitCommit(),
|
|
19484
19529
|
duration: Date.now() - scanStart,
|
|
19485
19530
|
usedAi: shouldRunAi,
|
|
19486
19531
|
aiCreditsUsed: 0
|
|
19487
|
-
}
|
|
19488
|
-
|
|
19532
|
+
};
|
|
19533
|
+
try {
|
|
19534
|
+
await client.reportScan(reportData);
|
|
19535
|
+
console.log(import_chalk.default.green(" \u2713 Results synced to dashboard: https://www.technicaldebtradar.com/dashboard"));
|
|
19536
|
+
} catch {
|
|
19537
|
+
console.log(import_chalk.default.yellow(" \u26A0\uFE0F Could not sync results to dashboard. Check your connection."));
|
|
19538
|
+
}
|
|
19489
19539
|
}
|
|
19490
19540
|
if (mode === "warn") {
|
|
19491
19541
|
if (gateEval.gateWouldFail) {
|