@heroku-cli/command
Version:
base class for Heroku CLI commands
65 lines (64 loc) • 2.04 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.vars = exports.Vars = void 0;
const tslib_1 = require("tslib");
const url = tslib_1.__importStar(require("node:url"));
class Vars {
get apiHost() {
if (this.host.startsWith('http')) {
const u = url.parse(this.host);
if (u.host)
return u.host;
}
return `api.${this.host}`;
}
get apiUrl() {
return this.host.startsWith('http') ? this.host : `https://api.${this.host}`;
}
get envGitHost() {
return process.env.HEROKU_GIT_HOST;
}
get envHost() {
return process.env.HEROKU_HOST;
}
get envParticleboardUrl() {
return process.env.HEROKU_PARTICLEBOARD_URL;
}
get gitHost() {
if (this.envGitHost)
return this.envGitHost;
if (this.host.startsWith('http')) {
const u = url.parse(this.host);
if (u.host)
return u.host;
}
return this.host;
}
get gitPrefixes() {
return [`git@${this.gitHost}:`, `ssh://git@${this.gitHost}/`, `https://${this.httpGitHost}/`];
}
get host() {
return this.envHost || 'heroku.com';
}
get httpGitHost() {
if (this.envGitHost)
return this.envGitHost;
if (this.host.startsWith('http')) {
const u = url.parse(this.host);
if (u.host)
return u.host;
}
return `git.${this.host}`;
}
// This should be fixed after we make our staging hostnames consistent throughout all services
// changing the staging cloud URL to `particleboard.staging.herokudev.com`.
get particleboardUrl() {
if (this.envParticleboardUrl)
return this.envParticleboardUrl;
return process.env.HEROKU_CLOUD === 'staging'
? 'https://particleboard-staging-cloud.herokuapp.com'
: 'https://particleboard.heroku.com';
}
}
exports.Vars = Vars;
exports.vars = new Vars();