technical-debt-radar 1.1.3 → 1.2.0

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 (2) hide show
  1. package/dist/index.js +29 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19293,6 +19293,12 @@ var RadarApiClient = class _RadarApiClient {
19293
19293
  body: JSON.stringify(data)
19294
19294
  });
19295
19295
  }
19296
+ async pushPolicyConfig(data) {
19297
+ await this.fetch("/cli/push-config", {
19298
+ method: "POST",
19299
+ body: JSON.stringify(data)
19300
+ });
19301
+ }
19296
19302
  };
19297
19303
 
19298
19304
  // src/commands/scan.ts
@@ -19394,7 +19400,9 @@ async function enforceAuth(allowAnonymous = false) {
19394
19400
  async function scanCommand(targetPath, options) {
19395
19401
  const { client, isAnonymous } = await enforceAuth(true);
19396
19402
  const scanStart = Date.now();
19397
- const policy = await loadPolicy(options.config, options.rules);
19403
+ const loaded = await loadPolicy(options.config, options.rules);
19404
+ if (!loaded) return;
19405
+ const policy = loaded.compiled;
19398
19406
  const files = await collectTsFiles(targetPath);
19399
19407
  if (files.length === 0) {
19400
19408
  console.log(import_chalk.default.yellow("No .ts/.tsx/.js/.jsx files found."));
@@ -19532,6 +19540,13 @@ async function scanCommand(targetPath, options) {
19532
19540
  };
19533
19541
  try {
19534
19542
  await client.reportScan(reportData);
19543
+ await client.pushPolicyConfig({
19544
+ repoName: path2.basename(path2.resolve(targetPath)),
19545
+ radarYaml: loaded.radarYaml,
19546
+ rulesYaml: loaded.rulesYaml,
19547
+ parsedConfig: loaded.parsedConfig
19548
+ }).catch(() => {
19549
+ });
19535
19550
  console.log(import_chalk.default.green(" \u2713 Results synced to dashboard: https://www.technicaldebtradar.com/dashboard"));
19536
19551
  } catch {
19537
19552
  console.log(import_chalk.default.yellow(" \u26A0\uFE0F Could not sync results to dashboard. Check your connection."));
@@ -19552,7 +19567,7 @@ async function scanCommand(targetPath, options) {
19552
19567
  }
19553
19568
  async function checkCommand(filePath, options) {
19554
19569
  const { isAnonymous } = await enforceAuth(true);
19555
- const policy = await loadPolicy(options.config, options.rules);
19570
+ const { compiled: policy } = await loadPolicy(options.config, options.rules);
19556
19571
  const absolutePath = path2.resolve(filePath);
19557
19572
  let content;
19558
19573
  try {
@@ -19602,9 +19617,10 @@ async function loadPolicy(configPath, rulesPath) {
19602
19617
  const config = (0, import_policy_engine.parsePolicy)(yamlContent);
19603
19618
  const rulesFile = rulesPath ?? path2.join(path2.dirname(resolved), "rules.yml");
19604
19619
  let rulesConfig = null;
19620
+ let rulesYaml;
19605
19621
  try {
19606
- const rulesContent = await fs2.readFile(path2.resolve(rulesFile), "utf-8");
19607
- rulesConfig = (0, import_policy_engine.parseRulesYml)(rulesContent);
19622
+ rulesYaml = await fs2.readFile(path2.resolve(rulesFile), "utf-8");
19623
+ rulesConfig = (0, import_policy_engine.parseRulesYml)(rulesYaml);
19608
19624
  } catch {
19609
19625
  if (rulesPath) {
19610
19626
  console.error(import_chalk.default.red(`Could not read rules file: ${rulesFile}`));
@@ -19632,7 +19648,12 @@ async function loadPolicy(configPath, rulesPath) {
19632
19648
  process.exit(1);
19633
19649
  return void 0;
19634
19650
  }
19635
- return (0, import_policy_engine.compilePolicy)(config);
19651
+ return {
19652
+ compiled: (0, import_policy_engine.compilePolicy)(config),
19653
+ radarYaml: yamlContent,
19654
+ rulesYaml,
19655
+ parsedConfig: config
19656
+ };
19636
19657
  }
19637
19658
  async function collectTsFiles(targetPath) {
19638
19659
  const resolved = path2.resolve(targetPath);
@@ -20665,7 +20686,7 @@ function applyFix(filePath, fix) {
20665
20686
  fsSync2.writeFileSync(filePath, lines.join("\n"), "utf-8");
20666
20687
  }
20667
20688
  async function runScan(targetPath, options) {
20668
- const policy = await loadPolicy(options.config, options.rules);
20689
+ const { compiled: policy } = await loadPolicy(options.config, options.rules);
20669
20690
  let files = await collectTsFiles(targetPath);
20670
20691
  if (options.file) {
20671
20692
  const target = path5.resolve(options.file);
@@ -20693,7 +20714,7 @@ async function runScan(targetPath, options) {
20693
20714
  };
20694
20715
  }
20695
20716
  async function runTextOnlyFix(targetPath, options) {
20696
- const policy = await loadPolicy(options.config, options.rules);
20717
+ const { compiled: policy } = await loadPolicy(options.config, options.rules);
20697
20718
  const files = await collectTsFiles(targetPath);
20698
20719
  if (files.length === 0) {
20699
20720
  console.log(import_chalk4.default.yellow("No .ts/.tsx files found."));
@@ -20970,7 +20991,7 @@ async function runCommand(targetPath, options) {
20970
20991
  process.exit(1);
20971
20992
  }
20972
20993
  const isTTY = process.stdout.isTTY ?? false;
20973
- const policy = await loadPolicy(options.config, options.rules);
20994
+ const { compiled: policy } = await loadPolicy(options.config, options.rules);
20974
20995
  const files = await collectTsFiles(targetPath);
20975
20996
  if (files.length === 0) {
20976
20997
  console.log("No .ts/.tsx files found.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "technical-debt-radar",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Stop Node.js production crashes before merge. 47 detection patterns across 5 categories.",
5
5
  "bin": {
6
6
  "radar": "dist/index.js",