@theholocron/cli 5.0.0-alpha.173 → 5.0.0-alpha.174

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/dist/cli.mjs CHANGED
@@ -2209,7 +2209,8 @@ async function runDeployFromFiles(input) {
2209
2209
  * issues → `doctor()` (rich report)
2210
2210
  * secrets → `listSecrets({ kind: 'repo' })`
2211
2211
  * ci → `listRuns({ limit: 1 })`
2212
- * errors → `describe()`
2212
+ * auth → `whoami()` (required on every provider)
2213
+ * errors → `whoami()` (org reachability) or `describe()`
2213
2214
  * logs → `whoami()` (dataset reachability) or `describe()`
2214
2215
  * others → just "loaded" (no smoke endpoint defined yet)
2215
2216
  *
@@ -2276,67 +2277,89 @@ async function runDoctor(input) {
2276
2277
  summary
2277
2278
  };
2278
2279
  }
2280
+ /** A stalled provider request must not hang the whole report forever. */
2281
+ const SMOKE_CHECK_TIMEOUT_MS = 1e4;
2282
+ /** Rejects after `ms` if `promise` hasn't settled yet — races, never cancels the original call. */
2283
+ function withTimeout(promise, ms) {
2284
+ return new Promise((resolve, reject) => {
2285
+ const timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`timed out after ${ms}ms`)), ms);
2286
+ promise.then((value) => {
2287
+ clearTimeout(timer);
2288
+ resolve(value);
2289
+ }, (err) => {
2290
+ clearTimeout(timer);
2291
+ reject(err);
2292
+ });
2293
+ });
2294
+ }
2279
2295
  async function smokeCheck(key, provider, impl) {
2280
2296
  try {
2281
- switch (key) {
2282
- case "source": return mk(key, provider, "ok", `whoami: ${(await impl.whoami()).login}`);
2283
- case "issues": {
2284
- const report = await impl.doctor();
2285
- return mk(key, provider, "ok", `${report.authedAs} / ${report.projectLabel} (${countResolvedLifecycle(report)})`);
2286
- }
2287
- case "secrets": return mk(key, provider, "ok", `repo secrets: ${(await impl.listSecrets({ kind: "repo" })).length} configured`);
2288
- case "ci": {
2289
- const runs = await impl.listRuns({ limit: 1 });
2290
- return mk(key, provider, "ok", runs.length === 0 ? "no recent runs" : `most recent: ${runs[0].workflowName} (${runs[0].status})`);
2291
- }
2292
- case "vault": return mk(key, provider, "ok", `${(await impl.list()).length} keys available`);
2293
- case "deployment": return mk(key, provider, "ok", `${(await impl.listProjects()).length} project(s) visible`);
2294
- case "environments": return mk(key, provider, "ok", `${(await impl.listEnvironments()).length} environment(s) configured`);
2295
- case "dns": {
2296
- const dns = impl;
2297
- if (dns.whoami) {
2298
- const who = await dns.whoami();
2299
- return mk(key, provider, who.ok ? "ok" : "fail", `${who.zones} zone(s) visible`);
2300
- }
2301
- return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2302
- }
2303
- case "workers": {
2304
- const workers = impl;
2305
- if (workers.whoami) {
2306
- const who = await workers.whoami();
2307
- return mk(key, provider, who.ok ? "ok" : "fail", `${who.scripts} script(s) visible`);
2308
- }
2309
- return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2310
- }
2311
- case "auth": {
2312
- const desc = await impl.describe();
2313
- return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
2297
+ return await withTimeout(runSmokeCheck(key, provider, impl), SMOKE_CHECK_TIMEOUT_MS);
2298
+ } catch (err) {
2299
+ return mk(key, provider, "fail", errorMessage(err));
2300
+ }
2301
+ }
2302
+ async function runSmokeCheck(key, provider, impl) {
2303
+ switch (key) {
2304
+ case "source": return mk(key, provider, "ok", `whoami: ${(await impl.whoami()).login}`);
2305
+ case "issues": {
2306
+ const report = await impl.doctor();
2307
+ return mk(key, provider, "ok", `${report.authedAs} / ${report.projectLabel} (${countResolvedLifecycle(report)})`);
2308
+ }
2309
+ case "secrets": return mk(key, provider, "ok", `repo secrets: ${(await impl.listSecrets({ kind: "repo" })).length} configured`);
2310
+ case "ci": {
2311
+ const runs = await impl.listRuns({ limit: 1 });
2312
+ return mk(key, provider, "ok", runs.length === 0 ? "no recent runs" : `most recent: ${runs[0].workflowName} (${runs[0].status})`);
2313
+ }
2314
+ case "vault": return mk(key, provider, "ok", `${(await impl.list()).length} keys available`);
2315
+ case "deployment": return mk(key, provider, "ok", `${(await impl.listProjects()).length} project(s) visible`);
2316
+ case "environments": return mk(key, provider, "ok", `${(await impl.listEnvironments()).length} environment(s) configured`);
2317
+ case "dns": {
2318
+ const dns = impl;
2319
+ if (dns.whoami) {
2320
+ const who = await dns.whoami();
2321
+ return mk(key, provider, who.ok ? "ok" : "fail", `${who.zones} zone(s) visible`);
2314
2322
  }
2315
- case "errors": {
2316
- const desc = await impl.describe();
2317
- return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
2323
+ return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2324
+ }
2325
+ case "workers": {
2326
+ const workers = impl;
2327
+ if (workers.whoami) {
2328
+ const who = await workers.whoami();
2329
+ return mk(key, provider, who.ok ? "ok" : "fail", `${who.scripts} script(s) visible`);
2318
2330
  }
2319
- case "logs": {
2320
- const logs = impl;
2321
- const desc = await logs.describe();
2322
- if (logs.whoami) {
2323
- const who = await logs.whoami();
2324
- return mk(key, provider, who.ok ? "ok" : "fail", `dataset: ${who.dataset}`);
2325
- }
2326
- return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
2331
+ return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2332
+ }
2333
+ case "auth": {
2334
+ const who = await impl.whoami();
2335
+ const details = who.details ? ` (${Object.entries(who.details).map(([k, v]) => `${k}=${v}`).join(", ")})` : "";
2336
+ return mk(key, provider, "ok", `whoami: ${who.provider}${details}`);
2337
+ }
2338
+ case "errors": {
2339
+ const errors = impl;
2340
+ const who = errors.whoami ? await errors.whoami() : null;
2341
+ if (who) return mk(key, provider, "ok", `org: ${who.org}`);
2342
+ const desc = await errors.describe();
2343
+ return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
2344
+ }
2345
+ case "logs": {
2346
+ const logs = impl;
2347
+ const desc = await logs.describe();
2348
+ if (logs.whoami) {
2349
+ const who = await logs.whoami();
2350
+ return mk(key, provider, who.ok ? "ok" : "fail", `dataset: ${who.dataset}`);
2327
2351
  }
2328
- case "monitoring": {
2329
- const monitoring = impl;
2330
- if (monitoring.whoami) {
2331
- const who = await monitoring.whoami();
2332
- return mk(key, provider, who.ok ? "ok" : "fail", who.ok ? "token verified" : "token check failed");
2333
- }
2334
- return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2352
+ return mk(key, provider, "ok", `provider: ${desc.provider}; env keys: ${desc.envKeys.join(", ")}`);
2353
+ }
2354
+ case "monitoring": {
2355
+ const monitoring = impl;
2356
+ if (monitoring.whoami) {
2357
+ const who = await monitoring.whoami();
2358
+ return mk(key, provider, who.ok ? "ok" : "fail", who.ok ? "token verified" : "token check failed");
2335
2359
  }
2336
- default: return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2360
+ return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2337
2361
  }
2338
- } catch (err) {
2339
- return mk(key, provider, "fail", errorMessage(err));
2362
+ default: return mk(key, provider, "skip", "loaded (no smoke check defined for this capability)");
2340
2363
  }
2341
2364
  }
2342
2365
  function countResolvedLifecycle(report) {