UNPKG

1.48 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.vars = exports.Vars = void 0;
4const tslib_1 = require("tslib");
5const url = tslib_1.__importStar(require("url"));
6class Vars {
7 get host() {
8 return this.envHost || 'heroku.com';
9 }
10 get apiUrl() {
11 return this.host.startsWith('http') ? this.host : `https://api.${this.host}`;
12 }
13 get apiHost() {
14 if (this.host.startsWith('http')) {
15 const u = url.parse(this.host);
16 if (u.host)
17 return u.host;
18 }
19 return `api.${this.host}`;
20 }
21 get envHost() {
22 return process.env.HEROKU_HOST;
23 }
24 get envGitHost() {
25 return process.env.HEROKU_GIT_HOST;
26 }
27 get gitHost() {
28 if (this.envGitHost)
29 return this.envGitHost;
30 if (this.host.startsWith('http')) {
31 const u = url.parse(this.host);
32 if (u.host)
33 return u.host;
34 }
35 return this.host;
36 }
37 get httpGitHost() {
38 if (this.envGitHost)
39 return this.envGitHost;
40 if (this.host.startsWith('http')) {
41 const u = url.parse(this.host);
42 if (u.host)
43 return u.host;
44 }
45 return `git.${this.host}`;
46 }
47 get gitPrefixes() {
48 return [`git@${this.gitHost}:`, `ssh://git@${this.gitHost}/`, `https://${this.httpGitHost}/`];
49 }
50}
51exports.Vars = Vars;
52exports.vars = new Vars();