| 202 | let migrationNotified = false; |
| 203 | |
| 204 | export default class API { |
| 205 | apiRoot: string; |
| 206 | token: string; |
| 207 | tokenKeyword: string; |
| 208 | branch: string; |
| 209 | useOpenAuthoring?: boolean; |
| 210 | repo: string; |
| 211 | originRepo: string; |
| 212 | repoOwner: string; |
| 213 | repoName: string; |
| 214 | originRepoOwner: string; |
| 215 | originRepoName: string; |
| 216 | repoURL: string; |
| 217 | originRepoURL: string; |
| 218 | mergeMethod: string; |
| 219 | initialWorkflowStatus: string; |
| 220 | cmsLabelPrefix: string; |
| 221 | baseUrl?: string; |
| 222 | getUser: ({ token }: { token: string }) => Promise<GitHubUser>; |
| 223 | _userPromise?: Promise<GitHubUser>; |
| 224 | _metadataSemaphore?: Semaphore; |
| 225 | |
| 226 | commitAuthor?: {}; |
| 227 | |
| 228 | constructor(config: Config) { |
| 229 | this.apiRoot = config.apiRoot || 'https://api.github.com'; |
| 230 | this.token = config.token || ''; |
| 231 | this.tokenKeyword = config.tokenKeyword || 'token'; |
| 232 | this.branch = config.branch || 'master'; |
| 233 | this.useOpenAuthoring = config.useOpenAuthoring; |
| 234 | this.repo = config.repo || ''; |
| 235 | this.originRepo = config.originRepo || this.repo; |
| 236 | this.repoURL = `/repos/${this.repo}`; |
| 237 | // when not in 'useOpenAuthoring' mode originRepoURL === repoURL |
| 238 | this.originRepoURL = `/repos/${this.originRepo}`; |
| 239 | |
| 240 | const [repoParts, originRepoParts] = [this.repo.split('/'), this.originRepo.split('/')]; |
| 241 | this.repoOwner = repoParts[0]; |
| 242 | this.repoName = repoParts[1]; |
| 243 | |
| 244 | this.originRepoOwner = originRepoParts[0]; |
| 245 | this.originRepoName = originRepoParts[1]; |
| 246 | |
| 247 | this.mergeMethod = config.squashMerges ? 'squash' : 'merge'; |
| 248 | this.cmsLabelPrefix = config.cmsLabelPrefix; |
| 249 | this.initialWorkflowStatus = config.initialWorkflowStatus; |
| 250 | this.baseUrl = config.baseUrl; |
| 251 | this.getUser = config.getUser; |
| 252 | } |
| 253 | |
| 254 | static DEFAULT_COMMIT_MESSAGE = 'Automatically generated by Decap CMS'; |
| 255 | |
| 256 | user(): Promise<{ name: string; login: string; email?: string }> { |
| 257 | if (!this._userPromise) { |
| 258 | this._userPromise = this.getUser({ token: this.token }); |
| 259 | } |
| 260 | return this._userPromise.then(user => ({ |
| 261 | name: user.name || 'Unknown', |
nothing calls this directly
no test coverage detected