technical-debt-radar 1.7.0 → 1.7.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.
Files changed (2) hide show
  1. package/dist/index.js +29 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -20355,19 +20355,35 @@ var RadarApiClient = class _RadarApiClient {
20355
20355
  return null;
20356
20356
  }
20357
20357
  async fetch(path9, init) {
20358
- const res = await fetch(`${this.apiUrl}${path9}`, {
20359
- ...init,
20360
- headers: {
20361
- "Authorization": `Bearer ${this.token}`,
20362
- "Content-Type": "application/json",
20363
- ...init?.headers
20364
- }
20365
- });
20358
+ const url = `${this.apiUrl}${path9}`;
20359
+ let res;
20360
+ try {
20361
+ res = await fetch(url, {
20362
+ ...init,
20363
+ headers: {
20364
+ "Authorization": `Bearer ${this.token}`,
20365
+ "Content-Type": "application/json",
20366
+ ...init?.headers
20367
+ }
20368
+ });
20369
+ } catch (err) {
20370
+ const cause = err?.cause?.message || err?.cause?.code || "";
20371
+ throw new Error(`Network error connecting to ${url}: ${err.message}${cause ? ` (${cause})` : ""}`);
20372
+ }
20366
20373
  if (!res.ok) {
20367
20374
  const body = await res.text().catch(() => "");
20368
- throw new Error(`API error ${res.status}: ${body}`);
20375
+ throw new Error(`API error ${res.status} on ${path9}: ${body}`);
20376
+ }
20377
+ const contentType = res.headers.get("content-type") ?? "";
20378
+ const text = await res.text();
20379
+ if (!text || text.trim().length === 0) {
20380
+ return void 0;
20381
+ }
20382
+ try {
20383
+ return JSON.parse(text);
20384
+ } catch {
20385
+ return void 0;
20369
20386
  }
20370
- return res.json();
20371
20387
  }
20372
20388
  async verifyToken() {
20373
20389
  return this.fetch("/cli/auth/verify");
@@ -20674,8 +20690,9 @@ async function scanCommand(targetPath, options) {
20674
20690
  }).catch(() => {
20675
20691
  });
20676
20692
  console.log(import_chalk.default.green(" \u2713 Results synced to dashboard: https://www.technicaldebtradar.com/dashboard"));
20677
- } catch {
20678
- console.log(import_chalk.default.yellow(" \u26A0\uFE0F Could not sync results to dashboard. Check your connection."));
20693
+ } catch (err) {
20694
+ const detail = err?.message ? `: ${err.message}` : "";
20695
+ console.log(import_chalk.default.yellow(` \u26A0\uFE0F Could not sync results to dashboard${detail}`));
20679
20696
  }
20680
20697
  }
20681
20698
  if (mode === "warn") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "technical-debt-radar",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
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",