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;QACD,IAAI,CAAC,CAAC;YACJ,MAAM,CAAC,yBAAkB,CAAC,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;QACvE,CAAC;QACD,MAAM,CAAC,IAAI,CAAA;IACb,CAAC;CAAA","sourcesContent":["import { tsAwaiter } from \"./awaiter\"\nimport { fromUrl as parseRepositoryUrl, Info } from \"hosted-git-info\"\nimport { readText } from \"./promisifed-fs\"\nimport * as path from \"path\"\n\nconst __awaiter = tsAwaiter\nArray.isArray(__awaiter)\n\ninterface RepositoryInfo {\n url: string\n}\n\nexport interface Metadata {\n repository: string | RepositoryInfo\n}\n\nexport interface AppMetadata extends Metadata {\n version: string\n name: string\n description: string\n author: string\n\n build: BuildMetadata\n\n windowsPackager: any\n}\n\nexport interface BuildMetadata {\n iconUrl: string\n}\n\nexport interface ProjectMetadataProvider {\n metadata: AppMetadata\n devMetadata: Metadata\n}\n\nexport interface RepositorySlug {\n user: string\n project: string\n}\n\nexport class InfoRetriever {\n _info: Promise<Info>\n\n getInfo(provider: ProjectMetadataProvider): Promise<Info> {\n if (this._info == null) {\n this._info = getInfo(provider)\n }\n return this._info\n }\n}\n\nasync function getGitUrlFromGitConfig(): Promise<string> {\n let data: string = null\n try {\n data = await readText(path.join(\".git\", \"config\"))\n }\n catch (e) {\n if (e.code === \"ENOENT\") {\n return null\n }\n\n throw e\n }\n\n const conf = data.split(/\\r?\\n/)\n const i = conf.indexOf('[remote \"origin\"]')\n if (i !== -1) {\n let u = conf[i + 1]\n if (!u.match(/^\\s*url =/)) {\n u = conf[i + 2]\n }\n\n if (u.match(/^\\s*url =/)) {\n return u.replace(/^\\s*url = /, \"\")\n }\n }\n return null\n}\n\nasync function getInfo(provider: ProjectMetadataProvider): Promise<RepositorySlug> {\n const repo = provider.devMetadata.repository || provider.metadata.repository\n if (repo == null) {\n let url = process.env.TRAVIS_REPO_SLUG\n if (url == null) {\n const user: string = process.env.APPVEYOR_ACCOUNT_NAME || process.env.CIRCLE_PROJECT_USERNAME\n const project: string = process.env.APPVEYOR_PROJECT_NAME || process.env.CIRCLE_PROJECT_REPONAME\n if (user != null && project != null) {\n return {\n user: user,\n project: project,\n }\n }\n\n url = await getGitUrlFromGitConfig()\n }\n\n if (url != null) {\n return parseRepositoryUrl(url)\n }\n }\n else {\n return parseRepositoryUrl(typeof repo === \"string\" ? repo : repo.url)\n }\n return null\n}"]} |