eas-cli
Version:
EAS command line tool
42 lines (41 loc) • 1.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const better_opn_1 = tslib_1.__importDefault(require("better-opn"));
const url_1 = require("../build/utils/url");
const EasCommand_1 = tslib_1.__importDefault(require("../commandUtils/EasCommand"));
const ora_1 = require("../ora");
const projectUtils_1 = require("../project/projectUtils");
class Open extends EasCommand_1.default {
static description = 'open the project page in a web browser';
static contextDefinition = {
...this.ContextOptions.ProjectConfig,
...this.ContextOptions.LoggedIn,
};
async runAsync() {
// this command is interactive by nature (only really run by humans in a terminal)
const { privateProjectConfig: { projectId, exp }, loggedIn: { graphqlClient }, } = await this.getContextAsync(Open, {
nonInteractive: false,
withServerSideEnvironment: null,
});
const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
const projectName = exp.slug;
const projectDashboardUrl = (0, url_1.getProjectDashboardUrl)(account.name, projectName);
const failedMessage = `Unable to open a web browser. Project page is available at: ${projectDashboardUrl}`;
const spinner = (0, ora_1.ora)(`Opening ${projectDashboardUrl}`).start();
try {
const opened = await (0, better_opn_1.default)(projectDashboardUrl);
if (opened) {
spinner.succeed(`Opened ${projectDashboardUrl}`);
}
else {
spinner.fail(failedMessage);
}
}
catch (error) {
spinner.fail(failedMessage);
throw error;
}
}
}
exports.default = Open;
;