@kvbox/cli 0.6.4 → 0.6.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/dist/kvbox.js CHANGED
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
164
164
  }
165
165
 
166
166
  // src/version.ts
167
- var VERSION = versionOf(import.meta.url, true ? "0.6.4" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.6.5" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
170
  import { Command as Command37 } from "commander";
@@ -1886,7 +1886,7 @@ async function resolveTarget(opts, p = paths()) {
1886
1886
  const session = await readSession(p);
1887
1887
  if (session) return { kind: "cloud", url: session.url, token: session.token, user: session.user, ...org === void 0 ? {} : { org } };
1888
1888
  }
1889
- return { kind: "local", socketPath: p.serverSock };
1889
+ return { kind: "local", socketPath: p.serverSock, ...opts.local ? {} : { noLogin: true } };
1890
1890
  }
1891
1891
  var allQuery = (opts) => opts.all ? "?all=1" : "";
1892
1892
  var ServerClient = class {
@@ -1925,7 +1925,10 @@ var ServerClient = class {
1925
1925
  if (this.target.kind === "local") {
1926
1926
  if (this.autoStart && !this.startedOnce) {
1927
1927
  this.startedOnce = true;
1928
- await spin("starting kvbox-server\u2026", startLocalServer(paths(), 5e3));
1928
+ const { noLogin } = this.target;
1929
+ await spin("starting kvbox-server\u2026", startLocalServer(paths(), 5e3)).catch((err2) => {
1930
+ throw noLogin && err2 instanceof KvboxError && err2.message === NOT_A_HOST_HINT ? new KvboxError(NOT_LOGGED_IN) : err2;
1931
+ });
1929
1932
  return this.call(method, path, schema, body, org, timeoutMs);
1930
1933
  }
1931
1934
  throw new KvboxError(`kvbox-server is not running (${String(code)}); start it with: kvbox-server start -d`);
@@ -2443,6 +2446,7 @@ async function checkDirect(ep) {
2443
2446
  throw new KvboxError(`--direct: cannot reach ${ep.host}:${ep.port}; it works only on the box's host (leave it out to go through the public address)`);
2444
2447
  });
2445
2448
  }
2449
+ var NOT_LOGGED_IN = "you are not logged in. Run: kvbox login";
2446
2450
  var NOT_A_HOST_HINT = "kvbox-server is not installed, so this machine is not a kvbox host. Set it up with install-server.sh, or log in to the cloud with: kvbox login";
2447
2451
  async function lastErrorLine(logPath, from = 0) {
2448
2452
  const { readFile: readFile8 } = await import("fs/promises");
@@ -4556,17 +4560,17 @@ import { Command as Command54 } from "commander";
4556
4560
  import { Command as Command49 } from "commander";
4557
4561
 
4558
4562
  // src/commands/org/context.ts
4559
- var NOT_LOGGED_IN = "orgs live on the control plane: kvbox login first";
4563
+ var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
4560
4564
  async function cloudClientFor(opts) {
4561
4565
  const client = await clientFor(opts, { autoStart: false });
4562
4566
  if (client.target.kind === "local") {
4563
4567
  await client.close();
4564
- throw new KvboxError(NOT_LOGGED_IN);
4568
+ throw new KvboxError(NOT_LOGGED_IN2);
4565
4569
  }
4566
4570
  return client;
4567
4571
  }
4568
4572
  function orgFor(opts, target) {
4569
- if (target.kind === "local") throw new KvboxError(NOT_LOGGED_IN);
4573
+ if (target.kind === "local") throw new KvboxError(NOT_LOGGED_IN2);
4570
4574
  const slug = opts.org ?? target.org;
4571
4575
  if (slug === void 0) throw new KvboxError("no org: pass --org <slug>");
4572
4576
  return slug;