heroku / heroku-cli-command
1
import * as url from 'url'
2

3
export class Vars {
4
  get host(): string {
5 3
    return this.envHost || 'heroku.com'
6
  }
7
  get apiUrl(): string {
8 3
    return this.host.startsWith('http') ? this.host : `https://api.${this.host}`
9
  }
10
  get apiHost(): string {
11 3
    if (this.host.startsWith('http')) {
12 0
      const u = url.parse(this.host)
13 3
      if (u.host) return u.host
14
    }
15 0
    return `api.${this.host}`
16
  }
17

18
  get envHost(): string | undefined {
19 0
    return process.env.HEROKU_HOST
20
  }
21

22
  get envGitHost(): string | undefined {
23 0
    return process.env.HEROKU_GIT_HOST
24
  }
25

26
  get gitHost(): string {
27 3
    if (this.envGitHost) return this.envGitHost
28 3
    if (this.host.startsWith('http')) {
29 0
      const u = url.parse(this.host)
30 3
      if (u.host) return u.host
31
    }
32 0
    return this.host
33
  }
34
  get httpGitHost(): string {
35 3
    if (this.envGitHost) return this.envGitHost
36 3
    if (this.host.startsWith('http')) {
37 0
      const u = url.parse(this.host)
38 3
      if (u.host) return u.host
39
    }
40 0
    return `git.${this.host}`
41
  }
42

43
  get gitPrefixes(): string[] {
44 0
    return [`git@${this.gitHost}:`, `ssh://git@${this.gitHost}/`, `https://${this.httpGitHost}/`]
45
  }
46
}
47

48 0
export const vars = new Vars()

Read our documentation on viewing source code .

Loading