postgresai 0.14.0-dev.60 → 0.14.0-dev.62

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.
@@ -1765,34 +1765,68 @@ mon
1765
1765
  });
1766
1766
  mon
1767
1767
  .command("clean")
1768
- .description("cleanup monitoring services artifacts")
1769
- .action(async () => {
1770
- console.log("Cleaning up Docker resources...\n");
1768
+ .description("cleanup monitoring services artifacts (stops services and removes volumes)")
1769
+ .option("--keep-volumes", "keep data volumes (only stop and remove containers)")
1770
+ .action(async (options: { keepVolumes?: boolean }) => {
1771
+ console.log("Cleaning up monitoring services...\n");
1771
1772
 
1772
1773
  try {
1773
- // Remove stopped containers
1774
- const { stdout: containers } = await execFilePromise("docker", ["ps", "-aq", "--filter", "status=exited"]);
1775
- if (containers.trim()) {
1776
- const containerIds = containers.trim().split('\n');
1777
- await execFilePromise("docker", ["rm", ...containerIds]);
1778
- console.log("✓ Removed stopped containers");
1774
+ // First, use docker-compose down to properly stop and remove containers/volumes
1775
+ const downArgs = options.keepVolumes ? ["down"] : ["down", "-v"];
1776
+ console.log(options.keepVolumes
1777
+ ? "Stopping and removing containers (keeping volumes)..."
1778
+ : "Stopping and removing containers and volumes...");
1779
+
1780
+ const downCode = await runCompose(downArgs);
1781
+ if (downCode === 0) {
1782
+ console.log("✓ Monitoring services stopped and removed");
1779
1783
  } else {
1780
- console.log(" No stopped containers to remove");
1784
+ console.log(" Could not stop services (may not be running)");
1785
+ }
1786
+
1787
+ // Remove orphaned volumes from previous installs with different project names
1788
+ if (!options.keepVolumes) {
1789
+ const volumePatterns = [
1790
+ "monitoring_grafana_data",
1791
+ "monitoring_postgres_ai_configs",
1792
+ "monitoring_sink_postgres_data",
1793
+ "monitoring_target_db_data",
1794
+ "monitoring_victoria_metrics_data",
1795
+ "postgres_ai_configs_grafana_data",
1796
+ "postgres_ai_configs_sink_postgres_data",
1797
+ "postgres_ai_configs_target_db_data",
1798
+ "postgres_ai_configs_victoria_metrics_data",
1799
+ "postgres_ai_configs_postgres_ai_configs",
1800
+ ];
1801
+
1802
+ const { stdout: existingVolumes } = await execFilePromise("docker", ["volume", "ls", "-q"]);
1803
+ const volumeList = existingVolumes.trim().split('\n').filter(Boolean);
1804
+ const orphanedVolumes = volumeList.filter(v => volumePatterns.includes(v));
1805
+
1806
+ if (orphanedVolumes.length > 0) {
1807
+ let removedCount = 0;
1808
+ for (const vol of orphanedVolumes) {
1809
+ try {
1810
+ await execFilePromise("docker", ["volume", "rm", vol]);
1811
+ removedCount++;
1812
+ } catch {
1813
+ // Volume might be in use, skip silently
1814
+ }
1815
+ }
1816
+ if (removedCount > 0) {
1817
+ console.log(`✓ Removed ${removedCount} orphaned volume(s) from previous installs`);
1818
+ }
1819
+ }
1781
1820
  }
1782
1821
 
1783
- // Remove unused volumes
1784
- await execFilePromise("docker", ["volume", "prune", "-f"]);
1785
- console.log("✓ Removed unused volumes");
1786
-
1787
- // Remove unused networks
1822
+ // Remove any dangling resources
1788
1823
  await execFilePromise("docker", ["network", "prune", "-f"]);
1789
1824
  console.log("✓ Removed unused networks");
1790
1825
 
1791
- // Remove dangling images
1792
1826
  await execFilePromise("docker", ["image", "prune", "-f"]);
1793
1827
  console.log("✓ Removed dangling images");
1794
1828
 
1795
- console.log("\nCleanup completed");
1829
+ console.log("\n✓ Cleanup completed - ready for fresh install");
1796
1830
  } catch (error) {
1797
1831
  const message = error instanceof Error ? error.message : String(error);
1798
1832
  console.error(`Error during cleanup: ${message}`);
package/bunfig.toml CHANGED
@@ -2,9 +2,10 @@
2
2
  # https://bun.sh/docs/runtime/bunfig
3
3
 
4
4
  [test]
5
- # Default timeout for all tests (30 seconds)
5
+ # Default timeout for all tests (60 seconds)
6
6
  # Integration tests that connect to databases need longer timeouts
7
- timeout = 30000
7
+ # PostgreSQL startup can take up to 30s in slow CI environments
8
+ timeout = 60000
8
9
 
9
10
  # Coverage settings - enabled by default for test runs
10
11
  coverage = true
@@ -13064,7 +13064,7 @@ var {
13064
13064
  // package.json
13065
13065
  var package_default = {
13066
13066
  name: "postgresai",
13067
- version: "0.14.0-dev.60",
13067
+ version: "0.14.0-dev.62",
13068
13068
  description: "postgres_ai CLI",
13069
13069
  license: "Apache-2.0",
13070
13070
  private: false,
@@ -15887,7 +15887,7 @@ var Result = import_lib.default.Result;
15887
15887
  var TypeOverrides = import_lib.default.TypeOverrides;
15888
15888
  var defaults = import_lib.default.defaults;
15889
15889
  // package.json
15890
- var version = "0.14.0-dev.60";
15890
+ var version = "0.14.0-dev.62";
15891
15891
  var package_default2 = {
15892
15892
  name: "postgresai",
15893
15893
  version,
@@ -27748,27 +27748,54 @@ Stopping services and removing data...`);
27748
27748
  process.exitCode = 1;
27749
27749
  }
27750
27750
  });
27751
- mon.command("clean").description("cleanup monitoring services artifacts").action(async () => {
27752
- console.log(`Cleaning up Docker resources...
27751
+ mon.command("clean").description("cleanup monitoring services artifacts (stops services and removes volumes)").option("--keep-volumes", "keep data volumes (only stop and remove containers)").action(async (options) => {
27752
+ console.log(`Cleaning up monitoring services...
27753
27753
  `);
27754
27754
  try {
27755
- const { stdout: containers } = await execFilePromise("docker", ["ps", "-aq", "--filter", "status=exited"]);
27756
- if (containers.trim()) {
27757
- const containerIds = containers.trim().split(`
27758
- `);
27759
- await execFilePromise("docker", ["rm", ...containerIds]);
27760
- console.log("\u2713 Removed stopped containers");
27755
+ const downArgs = options.keepVolumes ? ["down"] : ["down", "-v"];
27756
+ console.log(options.keepVolumes ? "Stopping and removing containers (keeping volumes)..." : "Stopping and removing containers and volumes...");
27757
+ const downCode = await runCompose(downArgs);
27758
+ if (downCode === 0) {
27759
+ console.log("\u2713 Monitoring services stopped and removed");
27761
27760
  } else {
27762
- console.log("\u2713 No stopped containers to remove");
27761
+ console.log("\u26A0 Could not stop services (may not be running)");
27762
+ }
27763
+ if (!options.keepVolumes) {
27764
+ const volumePatterns = [
27765
+ "monitoring_grafana_data",
27766
+ "monitoring_postgres_ai_configs",
27767
+ "monitoring_sink_postgres_data",
27768
+ "monitoring_target_db_data",
27769
+ "monitoring_victoria_metrics_data",
27770
+ "postgres_ai_configs_grafana_data",
27771
+ "postgres_ai_configs_sink_postgres_data",
27772
+ "postgres_ai_configs_target_db_data",
27773
+ "postgres_ai_configs_victoria_metrics_data",
27774
+ "postgres_ai_configs_postgres_ai_configs"
27775
+ ];
27776
+ const { stdout: existingVolumes } = await execFilePromise("docker", ["volume", "ls", "-q"]);
27777
+ const volumeList = existingVolumes.trim().split(`
27778
+ `).filter(Boolean);
27779
+ const orphanedVolumes = volumeList.filter((v) => volumePatterns.includes(v));
27780
+ if (orphanedVolumes.length > 0) {
27781
+ let removedCount = 0;
27782
+ for (const vol of orphanedVolumes) {
27783
+ try {
27784
+ await execFilePromise("docker", ["volume", "rm", vol]);
27785
+ removedCount++;
27786
+ } catch {}
27787
+ }
27788
+ if (removedCount > 0) {
27789
+ console.log(`\u2713 Removed ${removedCount} orphaned volume(s) from previous installs`);
27790
+ }
27791
+ }
27763
27792
  }
27764
- await execFilePromise("docker", ["volume", "prune", "-f"]);
27765
- console.log("\u2713 Removed unused volumes");
27766
27793
  await execFilePromise("docker", ["network", "prune", "-f"]);
27767
27794
  console.log("\u2713 Removed unused networks");
27768
27795
  await execFilePromise("docker", ["image", "prune", "-f"]);
27769
27796
  console.log("\u2713 Removed dangling images");
27770
27797
  console.log(`
27771
- Cleanup completed`);
27798
+ \u2713 Cleanup completed - ready for fresh install`);
27772
27799
  } catch (error2) {
27773
27800
  const message = error2 instanceof Error ? error2.message : String(error2);
27774
27801
  console.error(`Error during cleanup: ${message}`);
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED FILE - DO NOT EDIT
2
2
  // Generated from config/pgwatch-prometheus/metrics.yml by scripts/embed-metrics.ts
3
- // Generated at: 2025-12-29T23:50:47.972Z
3
+ // Generated at: 2025-12-30T01:05:22.697Z
4
4
 
5
5
  /**
6
6
  * Metric definition from metrics.yml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresai",
3
- "version": "0.14.0-dev.60",
3
+ "version": "0.14.0-dev.62",
4
4
  "description": "postgres_ai CLI",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -131,11 +131,11 @@ async function createTempPostgres(): Promise<TempPostgres> {
131
131
  return c;
132
132
  };
133
133
 
134
- // Wait for Postgres to start
134
+ // Wait for Postgres to start (30s timeout for slower CI environments)
135
135
  await waitFor(async () => {
136
136
  const c = await connect();
137
137
  await c.end();
138
- });
138
+ }, { timeoutMs: 30000, intervalMs: 100 });
139
139
 
140
140
  return { port, socketDir, cleanup, connect };
141
141
  }
@@ -172,15 +172,16 @@ describe.skipIf(!!skipReason)("checkup integration: express mode schema compatib
172
172
  let pg: TempPostgres;
173
173
  let client: Client;
174
174
 
175
+ // 60s timeout for hooks - PostgreSQL startup can take 30s+ in slow CI
175
176
  beforeAll(async () => {
176
177
  pg = await createTempPostgres();
177
178
  client = await pg.connect();
178
- });
179
+ }, { timeout: 60000 });
179
180
 
180
181
  afterAll(async () => {
181
182
  if (client) await client.end();
182
183
  if (pg) await pg.cleanup();
183
- });
184
+ }, { timeout: 60000 });
184
185
 
185
186
  // Test all checks supported by express mode
186
187
  const expressChecks = Object.keys(checkup.CHECK_INFO);
@@ -137,10 +137,11 @@ async function createTempPostgres(): Promise<TempPostgres> {
137
137
  return c;
138
138
  };
139
139
 
140
+ // Wait for Postgres to start (30s timeout for slower CI environments)
140
141
  await waitFor(async () => {
141
142
  const c = await connectLocal();
142
143
  await c.end();
143
- });
144
+ }, { timeoutMs: 30000, intervalMs: 100 });
144
145
 
145
146
  const postgresPassword = "postgrespw";
146
147
  {