UNPKG

convex

Version:

Client for the Convex Cloud

73 lines (72 loc) 2.92 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var dashboard_exports = {}; __export(dashboard_exports, { dashboard: () => dashboard }); module.exports = __toCommonJS(dashboard_exports); var import_commander = require("commander"); var import_chalk = __toESM(require("chalk"), 1); var import_config = require("./lib/config.js"); var import_open = __toESM(require("open"), 1); var import_axios = __toESM(require("axios"), 1); var import__ = require("../index.js"); var import_utils = require("./lib/utils.js"); var import_api = require("./lib/api.js"); var import_context = require("./lib/context.js"); const dashboard = new import_commander.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 = import_context.oneoffContext; const { projectConfig } = await (0, import_config.readProjectConfig)(ctx); const { url, adminKey } = await (0, import_api.getUrlAndAdminKey)( ctx, projectConfig.project, projectConfig.team, "prod" ); const loginUrl = await dashboardLogin(ctx, url, adminKey); if (options.open) { console.log(import_chalk.default.gray(`Opening ${loginUrl} in the default browser...`)); await (0, import_open.default)(loginUrl); } else { console.log(loginUrl); } }); async function dashboardLogin(ctx, instanceOrigin, adminKey) { try { return (await import_axios.default.post(`${instanceOrigin}/api/${import__.version}/one_time_login_url`, { version: import__.version, adminKey })).data.loginUrl; } catch (err) { console.error( import_chalk.default.red("Error: Unable to login to dashboard at ", instanceOrigin) ); return await (0, import_utils.fatalServerErr)(ctx, err); } } //# sourceMappingURL=dashboard.js.map