{
  "version": 3,
  "sources": ["../../../bin/continuous-integration.ts"],
  "sourcesContent": ["import * as child_process from 'node:child_process'\n\nclass ContinuousIntegrationSingleton {\n  public service = ''\n  public build_number = 0\n  public tag = ''\n  public commit_message = ''\n  public branch = ''\n  public pull_request = false\n  public issue = ''\n\n  constructor() {\n    for (const [id, name] of Object.entries({ CIRCLECI: 'Circle', TRAVIS: 'Travis', SEMAPHORE: 'Semaphore', GITHUB_ACTIONS: 'GitHub' })) {\n      if (process.env[id] === 'true') this.service = name\n    }\n\n    switch (this.service) {\n      case 'Circle':\n        this.build_number = this.parseInt(this.env('CIRCLE_BUILD_NUM'))\n        try {\n          const sha = this.env('CIRCLE_SHA1')\n          this.tag = child_process.execSync(`git describe --exact-match ${sha}`, { stdio: 'pipe' }).toString().trim()\n        }\n        catch (err) {\n          this.tag = ''\n        }\n        this.commit_message = child_process.execSync(`git log --format=%B -n 1 ${this.env('CIRCLE_SHA1')}`).toString().trim()\n        this.branch = this.env('CIRCLE_BRANCH')\n        this.pull_request = !!process.env.CIRCLE_PULL_REQUEST\n        break\n\n      case 'GitHub':\n        this.build_number = this.parseInt(this.env('GITHUB_RUN_NUMBER'))\n        this.commit_message = child_process.execSync(`git log --format=%B -n 1 ${this.env('GITHUB_SHA')}`).toString().trim()\n        this.pull_request = this.env('GITHUB_EVENT_NAME').startsWith('pull-request')\n\n        const githubRef = this.env('GITHUB_REF')\n\n        if (process.env.GITHUB_HEAD_REF) {\n          this.branch = process.env.GITHUB_HEAD_REF.split('/').pop() || ''\n        }\n        else if (githubRef.startsWith('refs/tags/')) {\n          // leave branch undefined when tagged... not great\n          this.tag = githubRef.split('/').pop() || ''\n        }\n        else if (githubRef.startsWith('refs/heads/')) {\n          this.branch = githubRef.split('/').pop() || ''\n        }\n        this.branch = this.branch || ''\n        this.issue = this.branch.match(/^gh-([0-9]+)$/)?.[1] || ''\n        break\n\n      default:\n        if (process.env.CI === 'true') throw new Error(`Unexpected CI service ${this.service}`)\n    }\n  }\n\n  private env(name: string): string {\n    const value = process.env[name]\n    if (!value) throw new Error(`${name} is not set`)\n    return value\n  }\n\n  private parseInt(n: number | string | undefined): number {\n    if (typeof n === 'undefined') throw new Error('missing integer value')\n    if (typeof n === 'number') return n\n    const int = parseInt(n)\n    if (isNaN(int)) throw new Error(`${n} is not an integer`)\n    return int\n  }\n}\n\nexport const ContinuousIntegration = new ContinuousIntegrationSingleton() // eslint-disable-line @typescript-eslint/naming-convention,no-underscore-dangle,id-blacklist,id-match\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAE/B,IAAM,iCAAN,MAAqC;AAAA,EAC5B,UAAU;AAAA,EACV,eAAe;AAAA,EACf,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,eAAe;AAAA,EACf,QAAQ;AAAA,EAEf,cAAc;AACZ,eAAW,CAAC,IAAI,IAAI,KAAK,OAAO,QAAQ,EAAE,UAAU,UAAU,QAAQ,UAAU,WAAW,aAAa,gBAAgB,SAAS,CAAC,GAAG;AACnI,UAAI,QAAQ,IAAI,EAAE,MAAM,OAAQ,MAAK,UAAU;AAAA,IACjD;AAEA,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,aAAK,eAAe,KAAK,SAAS,KAAK,IAAI,kBAAkB,CAAC;AAC9D,YAAI;AACF,gBAAM,MAAM,KAAK,IAAI,aAAa;AAClC,eAAK,MAAoB,uBAAS,8BAA8B,GAAG,IAAI,EAAE,OAAO,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK;AAAA,QAC5G,SACO,KAAK;AACV,eAAK,MAAM;AAAA,QACb;AACA,aAAK,iBAA+B,uBAAS,4BAA4B,KAAK,IAAI,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK;AACpH,aAAK,SAAS,KAAK,IAAI,eAAe;AACtC,aAAK,eAAe,CAAC,CAAC,QAAQ,IAAI;AAClC;AAA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