postgresai 0.11.0-alpha.3 → 0.11.0-alpha.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
@@ -10,9 +10,10 @@ npm install -g postgresai@alpha
10
10
 
11
11
  ## Usage
12
12
 
13
- The CLI provides two command aliases:
13
+ The CLI provides three command aliases:
14
14
  ```bash
15
15
  postgres-ai --help
16
+ postgresai --help
16
17
  pgai --help # short alias
17
18
  ```
18
19
 
@@ -123,7 +123,52 @@ program
123
123
  const code = await runCompose(args);
124
124
  if (code !== 0) process.exitCode = code;
125
125
  });
126
- program.command("health").description("health check").action(stub("health"));
126
+ program
127
+ .command("health")
128
+ .description("health check")
129
+ .action(async () => {
130
+ const { exec } = require("child_process");
131
+ const util = require("util");
132
+ const execPromise = util.promisify(exec);
133
+
134
+ console.log("Checking service health...\n");
135
+
136
+ const services = [
137
+ { name: "Grafana", url: "http://localhost:3000/api/health" },
138
+ { name: "Prometheus", url: "http://localhost:59090/-/healthy" },
139
+ { name: "PGWatch (Postgres)", url: "http://localhost:58080/health" },
140
+ { name: "PGWatch (Prometheus)", url: "http://localhost:58089/health" },
141
+ ];
142
+
143
+ let allHealthy = true;
144
+
145
+ for (const service of services) {
146
+ try {
147
+ const { stdout, stderr } = await execPromise(
148
+ `curl -sf -o /dev/null -w "%{http_code}" ${service.url}`,
149
+ { timeout: 5000 }
150
+ );
151
+ const code = stdout.trim();
152
+ if (code === "200") {
153
+ console.log(`✓ ${service.name}: healthy`);
154
+ } else {
155
+ console.log(`✗ ${service.name}: unhealthy (HTTP ${code})`);
156
+ allHealthy = false;
157
+ }
158
+ } catch (error) {
159
+ console.log(`✗ ${service.name}: unreachable`);
160
+ allHealthy = false;
161
+ }
162
+ }
163
+
164
+ console.log("");
165
+ if (allHealthy) {
166
+ console.log("All services are healthy");
167
+ } else {
168
+ console.log("Some services are unhealthy");
169
+ process.exitCode = 1;
170
+ }
171
+ });
127
172
  program
128
173
  .command("config")
129
174
  .description("show configuration")
@@ -359,7 +404,36 @@ program
359
404
  program
360
405
  .command("show-grafana-credentials")
361
406
  .description("show Grafana credentials")
362
- .action(stub("show-grafana-credentials"));
407
+ .action(async () => {
408
+ const fs = require("fs");
409
+ const path = require("path");
410
+ const cfgPath = path.resolve(process.cwd(), ".pgwatch-config");
411
+ if (!fs.existsSync(cfgPath)) {
412
+ console.error("Configuration file not found. Run 'quickstart' first.");
413
+ process.exitCode = 1;
414
+ return;
415
+ }
416
+ const content = fs.readFileSync(cfgPath, "utf8");
417
+ const lines = content.split(/\r?\n/);
418
+ let password = "";
419
+ for (const line of lines) {
420
+ const m = line.match(/^grafana_password=(.+)$/);
421
+ if (m) {
422
+ password = m[1].trim();
423
+ break;
424
+ }
425
+ }
426
+ if (!password) {
427
+ console.error("Grafana password not found in configuration");
428
+ process.exitCode = 1;
429
+ return;
430
+ }
431
+ console.log("\nGrafana credentials:");
432
+ console.log(" URL: http://localhost:3000");
433
+ console.log(" Username: monitor");
434
+ console.log(` Password: ${password}`);
435
+ console.log("");
436
+ });
363
437
 
364
438
  program.parseAsync(process.argv);
365
439
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresai",
3
- "version": "0.11.0-alpha.3",
3
+ "version": "0.11.0-alpha.5",
4
4
  "description": "PostgresAI CLI (Node.js)",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "bin": {
16
16
  "postgres-ai": "./bin/postgres-ai.js",
17
+ "postgresai": "./bin/postgres-ai.js",
17
18
  "pgai": "./bin/postgres-ai.js"
18
19
  },
19
20
  "type": "commonjs",