coderail-watch 0.1.4 → 0.1.5

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/README.md CHANGED
@@ -8,6 +8,12 @@ Usage:
8
8
  npx coderail-watch --session-id <session_id> --project-key <project_public_id> --base-url http://localhost:8000
9
9
  ```
10
10
 
11
+ Switch base URL by env:
12
+
13
+ ```bash
14
+ npx coderail-watch --session-id <session_id> --project-key <project_public_id> --env staging
15
+ ```
16
+
11
17
  Watch a log file instead of stdin:
12
18
 
13
19
  ```bash
@@ -5,6 +5,11 @@ const fs = require("fs");
5
5
  const readline = require("readline");
6
6
 
7
7
  const DEFAULT_BASE_URL = "http://localhost:8000";
8
+ const ENV_BASE_URLS = {
9
+ local: "http://localhost:8000",
10
+ staging: "https://api.dev-coderail.local",
11
+ production: "https://api.coderail.local",
12
+ };
8
13
  const DEFAULT_RETRY_WAIT_MS = 2000;
9
14
  const ALERT_PREFIX = "[[CODERAIL_ERROR]] ";
10
15
  const ERROR_PATTERN = /(^|[\s:])(?:error|exception|traceback|panic|fatal)(?=[\s:])/i;
@@ -66,7 +71,10 @@ const buildWsUrl = (baseUrl, sessionId, projectKey, token) => {
66
71
  const args = parseArgs(process.argv.slice(2));
67
72
  const sessionId = args["session-id"];
68
73
  const projectKey = args["project-key"];
69
- const baseUrl = args["base-url"] || DEFAULT_BASE_URL;
74
+ const env = args["env"];
75
+ const baseUrl =
76
+ args["base-url"] ||
77
+ (env && ENV_BASE_URLS[env] ? ENV_BASE_URLS[env] : DEFAULT_BASE_URL);
70
78
  const token = args["token"];
71
79
  const retryWaitMs = Number(args["retry-wait"] || DEFAULT_RETRY_WAIT_MS);
72
80
  const logPath = args["log-path"];
@@ -76,6 +84,13 @@ if (!sessionId || !projectKey) {
76
84
  process.exit(1);
77
85
  }
78
86
 
87
+ if (env && !ENV_BASE_URLS[env]) {
88
+ log(
89
+ `Unknown env '${env}'. Use one of: ${Object.keys(ENV_BASE_URLS).join(", ")}`,
90
+ );
91
+ process.exit(1);
92
+ }
93
+
79
94
  const wsUrl = buildWsUrl(baseUrl, sessionId, projectKey, token);
80
95
  let socket = null;
81
96
  let isOpen = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coderail-watch",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Stream terminal output to CodeRail backend over WebSocket.",
5
5
  "bin": {
6
6
  "coderail-watch": "bin/coderail-watch.js"