relionhq 2.0.1 → 2.0.3

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 +26 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -493,8 +493,9 @@ async function scanCommand(targetPath, flags) {
493
493
  const startedAt = Date.now();
494
494
  const config = resolveConfig({ token: flags.token, apiUrl: flags.url, repoUrl: flags.repoUrl, commit: flags.commit, branch: flags.branch }, root);
495
495
  if (!config.token && !flags.dryRun) {
496
- printError("No API token found.", "Set RELION_TOKEN env var or run: relion login --token <token>");
497
- process.exit(1);
496
+ printError("No API token found.", "Run: relion login");
497
+ process.exitCode = 1;
498
+ return;
498
499
  }
499
500
  const meta = gitMeta(root);
500
501
  const branch = flags.branch ?? config.branch ?? meta.branch ?? void 0;
@@ -524,7 +525,8 @@ Relion v2.0.0${repoUrl ? ` \xB7 ${repoUrl.replace("https://github.com/", "")}`
524
525
  } else {
525
526
  process.stdout.write(JSON.stringify({ vendors: detected, dryRun: true }, null, 2) + "\n");
526
527
  }
527
- process.exit(detected.length === 0 ? 4 : 0);
528
+ process.exitCode = detected.length === 0 ? 4 : 0;
529
+ return;
528
530
  }
529
531
  spinner.start("Uploading API metadata");
530
532
  const payload = {
@@ -579,9 +581,9 @@ Relion v2.0.0${repoUrl ? ` \xB7 ${repoUrl.replace("https://github.com/", "")}`
579
581
  const global = readGlobalConfig();
580
582
  writeGlobalConfig({ ...global, lastScanId: receipt.scanId, lastScanAt: (/* @__PURE__ */ new Date()).toISOString(), lastDashboardUrl: receipt.dashboardUrl });
581
583
  }
582
- if (receipt.deployGate?.status === "blocked") process.exit(2);
583
- if (receipt.deployGate?.status === "pending") process.exit(3);
584
- if (detected.length === 0) process.exit(4);
584
+ if (receipt.deployGate?.status === "blocked") process.exitCode = 2;
585
+ else if (receipt.deployGate?.status === "pending") process.exitCode = 3;
586
+ else if (detected.length === 0) process.exitCode = 4;
585
587
  } catch (err) {
586
588
  spinner.fail("Scan failed");
587
589
  const msg = err instanceof Error ? err.message : String(err);
@@ -591,7 +593,7 @@ Relion v2.0.0${repoUrl ? ` \xB7 ${repoUrl.replace("https://github.com/", "")}`
591
593
  printError(msg);
592
594
  }
593
595
  if (flags.verbose) console.error(err);
594
- process.exit(1);
596
+ process.exitCode = 1;
595
597
  }
596
598
  }
597
599
  async function verifyToken(token, apiUrl) {
@@ -651,21 +653,25 @@ function openBrowser(url) {
651
653
  function waitForCallback(port, timeoutMs = 5 * 60 * 1e3) {
652
654
  return new Promise((resolve3) => {
653
655
  const timer = setTimeout(() => {
656
+ server.closeAllConnections();
654
657
  server.close();
655
658
  resolve3(null);
656
659
  }, timeoutMs);
657
660
  const server = http.createServer((req, res) => {
658
661
  const url = new URL(req.url ?? "/", `http://localhost:${port}`);
659
662
  const token = url.searchParams.get("token");
660
- res.writeHead(200, { "Content-Type": "text/html" });
661
- res.end(`<!DOCTYPE html><html><head><meta charset="utf-8">
663
+ const html = `<!DOCTYPE html><html><head><meta charset="utf-8">
662
664
  <style>body{font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;background:#070a12;color:#e2e8f0}
663
665
  .box{text-align:center;padding:2rem;max-width:320px}h1{font-size:1.1rem;margin-bottom:.5rem;color:#4fd1c5}p{font-size:.85rem;color:#94a3b8}</style>
664
666
  </head><body><div class="box"><h1>${token ? "\u2713 Authenticated" : "\u2717 No token received"}</h1>
665
- <p>${token ? "You can close this tab and return to your terminal." : "Something went wrong. Run relion login again."}</p></div></body></html>`);
666
- clearTimeout(timer);
667
- server.close();
668
- resolve3(token ?? null);
667
+ <p>${token ? "You can close this tab and return to your terminal." : "Something went wrong. Run relion login again."}</p></div></body></html>`;
668
+ res.writeHead(200, { "Content-Type": "text/html", "Connection": "close" });
669
+ res.end(html, () => {
670
+ clearTimeout(timer);
671
+ server.closeAllConnections();
672
+ server.close();
673
+ resolve3(token ?? null);
674
+ });
669
675
  });
670
676
  server.listen(port, "127.0.0.1");
671
677
  });
@@ -698,6 +704,7 @@ async function saveAndVerifyToken(token, apiUrl) {
698
704
  console.log(`
699
705
  ${color.green("\u2713")} ${color.bold("Authenticated")}${email ? ` as ${color.cyan(email)}` : ""}`);
700
706
  console.log(color.dim(" Token saved to ~/.relion/config.json\n"));
707
+ process.exit(0);
701
708
  }
702
709
  async function logoutCommand() {
703
710
  writeGlobalConfig({});
@@ -840,8 +847,9 @@ async function predeployCommand(targetPath, flags) {
840
847
  const config = resolveConfig({ token: flags.token, apiUrl: flags.url, repoUrl: flags.repoUrl, commit: flags.commit, branch: flags.branch }, root);
841
848
  const offline = flags.offline ?? !config.token;
842
849
  if (!config.token && !offline) {
843
- printError("No API token found.", "Set RELION_TOKEN env var or run: relion login --token <token>\nUse --offline to run without cloud lookup.");
844
- process.exit(1);
850
+ printError("No API token found.", "Run: relion login\nOr set RELION_TOKEN env var. Use --offline to skip cloud lookup.");
851
+ process.exitCode = 1;
852
+ return;
845
853
  }
846
854
  let scopeMode = "default";
847
855
  let diffBase;
@@ -866,7 +874,7 @@ Relion pre-deploy check \u2014 ${scopeLabel}
866
874
  if (changedFiles.length === 0) {
867
875
  spinner.succeed("No changed files found");
868
876
  if (!flags.json) console.log("\nNothing to check \u2014 no changed files detected.\n");
869
- process.exit(0);
877
+ return;
870
878
  }
871
879
  spinner.succeed(`${changedFiles.length} changed file${changedFiles.length === 1 ? "" : "s"}`);
872
880
  spinner.start("Detecting API dependencies");
@@ -945,7 +953,7 @@ Relion pre-deploy check \u2014 ${scopeLabel}
945
953
  }
946
954
  }
947
955
  }
948
- process.exit(exitCode);
956
+ process.exitCode = exitCode;
949
957
  } catch (err) {
950
958
  spinner.fail("Pre-deploy check failed");
951
959
  const msg = err instanceof Error ? err.message : String(err);
@@ -957,7 +965,7 @@ Relion pre-deploy check \u2014 ${scopeLabel}
957
965
  printError(msg);
958
966
  }
959
967
  if (flags.verbose) console.error(err);
960
- process.exit(1);
968
+ process.exitCode = 1;
961
969
  }
962
970
  }
963
971
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relionhq",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Relion CLI — pre-deploy API risk detection and monitoring client.",
5
5
  "license": "MIT",
6
6
  "bin": {