convex
Version:
Client for the Convex Cloud
28 lines (27 loc) • 1.08 kB
JavaScript
;
import { Command } from "commander";
import chalk from "chalk";
import { readProjectConfig } from "./lib/config.js";
import open from "open";
import { oneoffContext } from "./lib/context.js";
export const dashboard = new Command("dashboard").description("Open the dashboard in the browser").option(
"--no-open",
"Don't automatically open the dashboard in the default browser"
).action(async (options) => {
const ctx = oneoffContext;
const loginUrl = await dashboardUrl(ctx);
if (options.open) {
console.log(chalk.gray(`Opening ${loginUrl} in the default browser...`));
await open(loginUrl);
} else {
console.log(loginUrl);
}
});
async function dashboardUrl(ctx) {
const { projectConfig } = await readProjectConfig(ctx);
const { project, team, prodUrl } = projectConfig;
const host = process.env.CONVEX_PROVISION_HOST ? "http://localhost:3000" : "https://dashboard.convex.dev";
const deployment = prodUrl.match(/https?:\/\/([^.]*)[.]/)[1];
return `${host}/${team}/${project}/${deployment}`;
}
//# sourceMappingURL=dashboard.js.map