@hasna/cloud 0.1.20 → 0.1.21

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/cli/index.js +56 -0
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -13065,6 +13065,62 @@ Done. ${results.length} services, ${totalApplied} migrations applied, ${totalErr
13065
13065
  }
13066
13066
  }
13067
13067
  });
13068
+ syncCmd.command("status").description("Show sync status for all discovered services").option("--service <name>", "Show status for a single service").option("--json", "Output as JSON").action(async (opts) => {
13069
+ const services = opts.service ? [opts.service] : discoverServices();
13070
+ const statuses = [];
13071
+ const { existsSync: existsSync9, statSync: statSync6 } = __require("fs");
13072
+ for (const service of services) {
13073
+ const dbPath = getDbPath2(service);
13074
+ const localExists = existsSync9(dbPath);
13075
+ let localSize = "\u2014";
13076
+ let tableCount = 0;
13077
+ if (localExists) {
13078
+ try {
13079
+ const stat = statSync6(dbPath);
13080
+ localSize = stat.size > 1024 * 1024 ? `${(stat.size / 1024 / 1024).toFixed(1)}MB` : `${(stat.size / 1024).toFixed(0)}KB`;
13081
+ } catch {}
13082
+ try {
13083
+ const local = new SqliteAdapter2(dbPath);
13084
+ const tables = listSqliteTables(local);
13085
+ tableCount = tables.length;
13086
+ local.close();
13087
+ } catch {}
13088
+ }
13089
+ let pgReachable = false;
13090
+ try {
13091
+ const connStr = getConnectionString(service);
13092
+ const pg2 = new PgAdapterAsync2(connStr);
13093
+ await pg2.all("SELECT 1");
13094
+ pgReachable = true;
13095
+ await pg2.close();
13096
+ } catch {}
13097
+ statuses.push({
13098
+ service,
13099
+ localDb: localExists ? dbPath : null,
13100
+ localSize,
13101
+ tables: tableCount,
13102
+ pgReachable
13103
+ });
13104
+ }
13105
+ if (opts.json) {
13106
+ console.log(JSON.stringify(statuses, null, 2));
13107
+ } else {
13108
+ const config = getCloudConfig();
13109
+ console.log(`Mode: ${config.mode}`);
13110
+ console.log(`Services: ${statuses.length}
13111
+ `);
13112
+ for (const s of statuses) {
13113
+ if (!s.localDb && !s.pgReachable)
13114
+ continue;
13115
+ const pgIcon = s.pgReachable ? "\u2713" : "\u2717";
13116
+ console.log(` ${s.service.padEnd(20)} ${s.localSize.padStart(8)} ${String(s.tables).padStart(3)} tables PG: ${pgIcon}`);
13117
+ }
13118
+ const withData = statuses.filter((s) => s.localDb);
13119
+ const pgOk = statuses.filter((s) => s.pgReachable);
13120
+ console.log(`
13121
+ ${withData.length} with local data, ${pgOk.length} with PG connection`);
13122
+ }
13123
+ });
13068
13124
  syncCmd.command("schedule").description("Manage scheduled background sync").option("--every <interval>", "Set sync interval (e.g. 5m, 10m, 1h)").option("--off", "Disable scheduled sync").option("--now", "Run a one-off sync immediately").action(async (opts) => {
13069
13125
  if (opts.off) {
13070
13126
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/cloud",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Shared cloud infrastructure — database adapter (SQLite + PostgreSQL), sync engine, feedback system, unified dotfile config",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",