@computesdk/cli 2.3.0 → 2.3.1
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 +22 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2449,6 +2449,14 @@ var packageJson = JSON.parse(
|
|
|
2449
2449
|
);
|
|
2450
2450
|
var isDevBuild = import.meta.url.includes("worktrees") || import.meta.url.includes("/packages/cli/");
|
|
2451
2451
|
var VERSION = isDevBuild ? `${packageJson.version}-dev` : packageJson.version;
|
|
2452
|
+
process.stdout.on("error", (err) => {
|
|
2453
|
+
if (err.code === "EPIPE") process.exit(0);
|
|
2454
|
+
throw err;
|
|
2455
|
+
});
|
|
2456
|
+
process.stderr.on("error", (err) => {
|
|
2457
|
+
if (err.code === "EPIPE") return;
|
|
2458
|
+
throw err;
|
|
2459
|
+
});
|
|
2452
2460
|
var program = new Command();
|
|
2453
2461
|
program.name("compute").description("ComputeSDK CLI").version(VERSION).enablePositionalOptions().passThroughOptions();
|
|
2454
2462
|
function envBaseUrl() {
|
|
@@ -2528,16 +2536,24 @@ program.command("login").description("Authenticate with ComputeSDK (OAuth device
|
|
|
2528
2536
|
await printSessionLine({ baseUrl: opts.baseUrl });
|
|
2529
2537
|
p.outro(pc4.green("Authenticated!"));
|
|
2530
2538
|
});
|
|
2531
|
-
program.command("logout").description("Clear stored credentials").action(async () => {
|
|
2539
|
+
program.command("logout").description("Clear stored credentials").option("--json", "print machine-readable JSON").action(async (opts) => {
|
|
2540
|
+
await runLogout();
|
|
2541
|
+
if (opts.json) {
|
|
2542
|
+
console.log(JSON.stringify({ loggedOut: true }, null, 2));
|
|
2543
|
+
return;
|
|
2544
|
+
}
|
|
2532
2545
|
console.log();
|
|
2533
2546
|
p.intro(pc4.cyan(`@computesdk/cli v${VERSION}`));
|
|
2534
|
-
await runLogout();
|
|
2535
2547
|
p.log.success("Logged out. Stored credentials removed.");
|
|
2536
2548
|
p.outro(pc4.green("Done!"));
|
|
2537
2549
|
});
|
|
2538
|
-
async function printWhoami() {
|
|
2550
|
+
async function printWhoami(options = {}) {
|
|
2539
2551
|
const { getMe } = await import("@benchsdk/cli");
|
|
2540
|
-
const me = await getMe(await benchAuth());
|
|
2552
|
+
const me = await getMe(await benchAuth({ baseUrl: options.baseUrl }));
|
|
2553
|
+
if (options.json) {
|
|
2554
|
+
console.log(JSON.stringify(me, null, 2));
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2541
2557
|
const active = me.organizations.find((o) => o.id === me.activeOrganizationId);
|
|
2542
2558
|
console.log(me.user.email ?? me.user.name ?? me.user.id);
|
|
2543
2559
|
console.log(
|
|
@@ -2584,8 +2600,8 @@ org.command("use <slug>").description("Set the active organization (persisted to
|
|
|
2584
2600
|
});
|
|
2585
2601
|
console.log(`Active organization set to ${result.organization.slug} (${result.organization.id})`);
|
|
2586
2602
|
});
|
|
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);
|
|
2603
|
+
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));
|
|
2604
|
+
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
2605
|
registerActionsCommands(program);
|
|
2590
2606
|
registerMarketCommands(program);
|
|
2591
2607
|
registerSandboxesCommands(program);
|