@computesdk/cli 2.3.0 → 2.3.2

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/index.js CHANGED
@@ -1594,8 +1594,9 @@ function formatBook(book) {
1594
1594
  if (book.bids.length === 0) lines.push(pc2.dim(" no open offers"));
1595
1595
  for (const bid of book.bids) {
1596
1596
  const where = bid.region ? safeTerm(bid.region) : "anywhere";
1597
+ const yours = bid.mine ? pc2.cyan(" (yours)") : "";
1597
1598
  lines.push(
1598
- ` ${lane(bid.useCase)} pays up to ${formatRate(bid.maxUsd, bid.per)} ${safeTerm(bid.size)} ${where} ${pc2.dim(`posted ${bid.createdAt}`)}`
1599
+ ` ${lane(bid.useCase)} pays up to ${formatRate(bid.maxUsd, bid.per)} ${safeTerm(bid.size)} ${where} ${pc2.dim(`posted ${bid.createdAt}`)}${yours}`
1599
1600
  );
1600
1601
  }
1601
1602
  lines.push("");
@@ -2449,6 +2450,14 @@ var packageJson = JSON.parse(
2449
2450
  );
2450
2451
  var isDevBuild = import.meta.url.includes("worktrees") || import.meta.url.includes("/packages/cli/");
2451
2452
  var VERSION = isDevBuild ? `${packageJson.version}-dev` : packageJson.version;
2453
+ process.stdout.on("error", (err) => {
2454
+ if (err.code === "EPIPE") process.exit(0);
2455
+ throw err;
2456
+ });
2457
+ process.stderr.on("error", (err) => {
2458
+ if (err.code === "EPIPE") return;
2459
+ throw err;
2460
+ });
2452
2461
  var program = new Command();
2453
2462
  program.name("compute").description("ComputeSDK CLI").version(VERSION).enablePositionalOptions().passThroughOptions();
2454
2463
  function envBaseUrl() {
@@ -2528,16 +2537,24 @@ program.command("login").description("Authenticate with ComputeSDK (OAuth device
2528
2537
  await printSessionLine({ baseUrl: opts.baseUrl });
2529
2538
  p.outro(pc4.green("Authenticated!"));
2530
2539
  });
2531
- program.command("logout").description("Clear stored credentials").action(async () => {
2540
+ program.command("logout").description("Clear stored credentials").option("--json", "print machine-readable JSON").action(async (opts) => {
2541
+ await runLogout();
2542
+ if (opts.json) {
2543
+ console.log(JSON.stringify({ loggedOut: true }, null, 2));
2544
+ return;
2545
+ }
2532
2546
  console.log();
2533
2547
  p.intro(pc4.cyan(`@computesdk/cli v${VERSION}`));
2534
- await runLogout();
2535
2548
  p.log.success("Logged out. Stored credentials removed.");
2536
2549
  p.outro(pc4.green("Done!"));
2537
2550
  });
2538
- async function printWhoami() {
2551
+ async function printWhoami(options = {}) {
2539
2552
  const { getMe } = await import("@benchsdk/cli");
2540
- const me = await getMe(await benchAuth());
2553
+ const me = await getMe(await benchAuth({ baseUrl: options.baseUrl }));
2554
+ if (options.json) {
2555
+ console.log(JSON.stringify(me, null, 2));
2556
+ return;
2557
+ }
2541
2558
  const active = me.organizations.find((o) => o.id === me.activeOrganizationId);
2542
2559
  console.log(me.user.email ?? me.user.name ?? me.user.id);
2543
2560
  console.log(
@@ -2584,8 +2601,8 @@ org.command("use <slug>").description("Set the active organization (persisted to
2584
2601
  });
2585
2602
  console.log(`Active organization set to ${result.organization.slug} (${result.organization.id})`);
2586
2603
  });
2587
- org.command("current").description("Show the current user and active organization").action(printWhoami);
2588
- program.command("whoami").description("Show the current user and active organization").action(printWhoami);
2604
+ org.command("current").description("Show the current user and active organization").option("--base-url <url>", "platform URL to query").option("--json", "print machine-readable JSON").action((opts) => printWhoami(opts));
2605
+ program.command("whoami").description("Show the current user and active organization").option("--base-url <url>", "platform URL to query").option("--json", "print machine-readable JSON").action((opts) => printWhoami(opts));
2589
2606
  registerActionsCommands(program);
2590
2607
  registerMarketCommands(program);
2591
2608
  registerSandboxesCommands(program);