diff --git a/lib/datasource/git-submodules/index.ts b/lib/datasource/git-submodules/index.ts index 446313077924f8259f87602ddd8a8f6f2facff61..61f6358fef5e2c693a3413f2014eb78670d78be2 100644 --- a/lib/datasource/git-submodules/index.ts +++ b/lib/datasource/git-submodules/index.ts @@ -21,11 +21,9 @@ export async function getPkgReleases({ const git = Git(); try { - const newHash = (await git.listRemote([ - '--refs', - registryUrls[0], - registryUrls[1], - ])) + const newHash = ( + await git.listRemote(['--refs', registryUrls[0], registryUrls[1]]) + ) .trim() .split(/\t/)[0]; diff --git a/lib/datasource/github/index.ts b/lib/datasource/github/index.ts index ae42534c0828bdcd08cbf211ae1e9f195ba43246..83b15f8d6418412f8a516b62108be85179606c8e 100644 --- a/lib/datasource/github/index.ts +++ b/lib/datasource/github/index.ts @@ -188,9 +188,11 @@ export async function getPkgReleases({ tag_name: string; }[]; - versions = (await ghGot<GitHubRelease>(url, { - paginate: true, - })).body.map(o => o.tag_name); + versions = ( + await ghGot<GitHubRelease>(url, { + paginate: true, + }) + ).body.map(o => o.tag_name); } else { // tag const url = `https://api.github.com/repos/${repo}/tags?per_page=100`; @@ -198,9 +200,11 @@ export async function getPkgReleases({ name: string; }[]; - versions = (await ghGot<GitHubTag>(url, { - paginate: true, - })).body.map(o => o.name); + versions = ( + await ghGot<GitHubTag>(url, { + paginate: true, + }) + ).body.map(o => o.name); } } catch (err) { logger.info({ repo, err }, 'Error retrieving from github'); diff --git a/lib/datasource/gitlab/index.ts b/lib/datasource/gitlab/index.ts index 1ec57d42db33d1f61bfa70311d06fa52032db5b3..091a26afa7f3a26d3e571aeb307ee57f54e75b36 100644 --- a/lib/datasource/gitlab/index.ts +++ b/lib/datasource/gitlab/index.ts @@ -100,9 +100,11 @@ export async function getPkgReleases({ tag_name: string; }[]; - versions = (await glGot<GlRelease>(url, { - paginate: true, - })).body.map(o => o.tag_name); + versions = ( + await glGot<GlRelease>(url, { + paginate: true, + }) + ).body.map(o => o.tag_name); } else { // tag const url = `${depHost}/api/v4/projects/${urlEncodedRepo}/repository/tags?per_page=100`; @@ -110,9 +112,11 @@ export async function getPkgReleases({ name: string; }[]; - versions = (await glGot<GlTag>(url, { - paginate: true, - })).body.map(o => o.name); + versions = ( + await glGot<GlTag>(url, { + paginate: true, + }) + ).body.map(o => o.name); } } catch (err) { // istanbul ignore next diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts index 989dc699d8d38e1ce9ebc6780c5ed905cf48ed4e..51cdb10d334d7cec749970c9654aa5f949a82cfa 100644 --- a/lib/datasource/go/index.ts +++ b/lib/datasource/go/index.ts @@ -28,9 +28,11 @@ async function getDatasource(name: string): Promise<DataSource | null> { } const pkgUrl = `https://${name}?go-get=1`; try { - const res = (await got(pkgUrl, { - hostType: 'go', - })).body; + const res = ( + await got(pkgUrl, { + hostType: 'go', + }) + ).body; const sourceMatch = res.match( regEx(`<meta\\s+name="go-source"\\s+content="${name}\\s+([^\\s]+)`) ); diff --git a/lib/datasource/orb/index.ts b/lib/datasource/orb/index.ts index fd0e95547ba0b1c6e7832132e5dd675f4870e594..c4a3e9660e771df55773e147ac55ae27e61fd679 100644 --- a/lib/datasource/orb/index.ts +++ b/lib/datasource/orb/index.ts @@ -34,11 +34,13 @@ export async function getPkgReleases({ variables: {}, }; try { - const res: OrbRelease = (await got.post(url, { - body, - json: true, - retry: 5, - })).body.data.orb; + const res: OrbRelease = ( + await got.post(url, { + body, + json: true, + retry: 5, + }) + ).body.data.orb; if (!res) { logger.info({ lookupName }, 'Failed to look up orb'); return null; diff --git a/lib/datasource/packagist/index.ts b/lib/datasource/packagist/index.ts index bad5aefb52e95e49ca5889281bb1be72dfd1f36c..de6f639a39465bf150a7c7f71c3511c21c4b59e4 100644 --- a/lib/datasource/packagist/index.ts +++ b/lib/datasource/packagist/index.ts @@ -219,10 +219,12 @@ async function packagistOrgLookup(name: string): Promise<ReleaseResult> { let dep: ReleaseResult = null; const regUrl = 'https://packagist.org'; const pkgUrl = URL.resolve(regUrl, `/p/${name}.json`); - const res = (await got(pkgUrl, { - json: true, - retry: 5, - })).body.packages[name]; + const res = ( + await got(pkgUrl, { + json: true, + retry: 5, + }) + ).body.packages[name]; if (res) { dep = extractDepReleases(res); dep.name = name; diff --git a/lib/datasource/terraform-provider/index.ts b/lib/datasource/terraform-provider/index.ts index 3c446f6b7afe79f3e72aef50ccf1f0fec84199e6..fba18d1a02d3eaa815c03168c7704f1266296b23 100644 --- a/lib/datasource/terraform-provider/index.ts +++ b/lib/datasource/terraform-provider/index.ts @@ -33,10 +33,12 @@ export async function getPkgReleases({ return cachedResult; } try { - const res: TerraformProvider = (await got(pkgUrl, { - json: true, - hostType: 'terraform', - })).body; + const res: TerraformProvider = ( + await got(pkgUrl, { + json: true, + hostType: 'terraform', + }) + ).body; // Simplify response before caching and returning const dep: ReleaseResult = { name: repository, diff --git a/lib/datasource/terraform/index.ts b/lib/datasource/terraform/index.ts index c602810bf78a7270023ead294a674223deaa3362..045d2bf044078b281b660f608422cb30dbd0be35 100644 --- a/lib/datasource/terraform/index.ts +++ b/lib/datasource/terraform/index.ts @@ -67,10 +67,12 @@ export async function getPkgReleases({ return cachedResult; } try { - const res: TerraformRelease = (await got(pkgUrl, { - json: true, - hostType: 'terraform', - })).body; + const res: TerraformRelease = ( + await got(pkgUrl, { + json: true, + hostType: 'terraform', + }) + ).body; const returnedName = res.namespace + '/' + res.name + '/' + res.provider; if (returnedName !== repository) { logger.warn({ pkgUrl }, 'Terraform registry result mismatch'); diff --git a/lib/manager/bazel/update.ts b/lib/manager/bazel/update.ts index 0fa5ba23812b5ac631788557261f0fe9d65b680c..7877606fe1fd148c0302f4e88dbf1060dadc7b08 100644 --- a/lib/manager/bazel/update.ts +++ b/lib/manager/bazel/update.ts @@ -62,9 +62,9 @@ async function getHashFromUrl(url: string): Promise<string | null> { } async function getHashFromUrls(urls: string[]): Promise<string | null> { - const hashes = (await Promise.all( - urls.map(url => getHashFromUrl(url)) - )).filter(Boolean); + const hashes = ( + await Promise.all(urls.map(url => getHashFromUrl(url))) + ).filter(Boolean); const distinctHashes = [...new Set(hashes)]; if (!distinctHashes.length) { logger.debug({ hashes, urls }, 'Could not calculate hash for URLs'); diff --git a/lib/manager/composer/extract.ts b/lib/manager/composer/extract.ts index 6a577620c780bc9f14b2dbb2eb9d52459e9502e5..2da742fd4aed89e09951b1d45fb1a45de2ea53a5 100644 --- a/lib/manager/composer/extract.ts +++ b/lib/manager/composer/extract.ts @@ -123,9 +123,9 @@ export async function extractPackageFile( for (const depType of depTypes) { if (composerJson[depType]) { try { - for (const [depName, version] of Object.entries(composerJson[ - depType - ] as Record<string, string>)) { + for (const [depName, version] of Object.entries( + composerJson[depType] as Record<string, string> + )) { const currentValue = version.trim(); // Default datasource and lookupName let datasource = DATASOURCE_PACKAGIST; diff --git a/lib/manager/git-submodules/extract.ts b/lib/manager/git-submodules/extract.ts index ed6e99440241c7e2d31dabd3f6cbfca3ac9185a6..dca6d6e5523a38937ca2d7c1afbb7cc4047e627b 100644 --- a/lib/manager/git-submodules/extract.ts +++ b/lib/manager/git-submodules/extract.ts @@ -10,21 +10,21 @@ async function getUrl( gitModulesPath: string, submoduleName: string ): Promise<string> { - const path = (await Git().raw([ - 'config', - '--file', - gitModulesPath, - '--get', - `submodule.${submoduleName}.url`, - ])).trim(); + const path = ( + await Git().raw([ + 'config', + '--file', + gitModulesPath, + '--get', + `submodule.${submoduleName}.url`, + ]) + ).trim(); if (!path.startsWith('../')) { return path; } - const remoteUrl = (await git.raw([ - 'config', - '--get', - 'remote.origin.url', - ])).trim(); + const remoteUrl = ( + await git.raw(['config', '--get', 'remote.origin.url']) + ).trim(); return URL.resolve(`${remoteUrl}/`, path); } diff --git a/lib/manager/gomod/artifacts.ts b/lib/manager/gomod/artifacts.ts index e94b4367df8bf09ea0a3bbcff912839b62590beb..496d1a96ad2302d7f28c212893f32558c750cce2 100644 --- a/lib/manager/gomod/artifacts.ts +++ b/lib/manager/gomod/artifacts.ts @@ -163,10 +163,9 @@ export async function updateArtifacts( }); } } - const finalGoModContent = (await readFile( - localGoModFileName, - 'utf8' - )).replace(/\/\/ renovate-replace /g, ''); + const finalGoModContent = ( + await readFile(localGoModFileName, 'utf8') + ).replace(/\/\/ renovate-replace /g, ''); if (finalGoModContent !== newGoModContent) { logger.info('Found updated go.mod after go.sum update'); res.push({ diff --git a/lib/manager/npm/extract/index.ts b/lib/manager/npm/extract/index.ts index ec3567775848154a1f8c8cd3efcc178ea3e9ad9d..b2fdbe6202c1cbcea1c6c17ed9c8b6fab6216e32 100644 --- a/lib/manager/npm/extract/index.ts +++ b/lib/manager/npm/extract/index.ts @@ -267,9 +267,9 @@ export async function extractPackageFile( for (const depType of Object.keys(depTypes)) { if (packageJson[depType]) { try { - for (const [depName, val] of Object.entries(packageJson[ - depType - ] as Record<string, any>)) { + for (const [depName, val] of Object.entries( + packageJson[depType] as Record<string, any> + )) { const dep: PackageDependency = { depType, depName, diff --git a/lib/manager/npm/extract/npm.ts b/lib/manager/npm/extract/npm.ts index 47a3a3b82d4e10b12734cc1fc1a65d31a806f24c..668b0b149f846de6cf739fa04b67b9281c15f823 100644 --- a/lib/manager/npm/extract/npm.ts +++ b/lib/manager/npm/extract/npm.ts @@ -9,8 +9,9 @@ export async function getNpmLock( try { const lockParsed = JSON.parse(lockRaw); const lockFile: Record<string, string> = {}; - for (const [entry, val] of Object.entries((lockParsed.dependencies || - {}) as LockFileEntry)) { + for (const [entry, val] of Object.entries( + (lockParsed.dependencies || {}) as LockFileEntry + )) { logger.trace({ entry, version: val.version }); lockFile[entry] = val.version; } diff --git a/lib/manager/travis/package.ts b/lib/manager/travis/package.ts index ade8a333d940ee88c3b430e94d58327bed050f11..c18b03bdf84845a5e718f076a76090d7e7671187 100644 --- a/lib/manager/travis/package.ts +++ b/lib/manager/travis/package.ts @@ -98,11 +98,13 @@ export async function getPackageUpdates( .sort((a, b) => a - b); const newMajor = newValue[newValue.length - 1]; if (config.rangeStrategy === 'pin' || isVersion(config.currentValue[0])) { - const versions = (await getPkgReleases({ - ...config, - datasource: 'github', - depName: 'nodejs/node', - })).releases.map(release => release.version); + const versions = ( + await getPkgReleases({ + ...config, + datasource: 'github', + depName: 'nodejs/node', + }) + ).releases.map(release => release.version); newValue = newValue.map(value => maxSatisfyingVersion(versions, `${value}`) ); diff --git a/lib/platform/azure/azure-helper.ts b/lib/platform/azure/azure-helper.ts index 266e298896eb8d88eafdd41b049acc6d1d1ed214..b1baa1714088bb8c42e13d515173763d9b999557 100644 --- a/lib/platform/azure/azure-helper.ts +++ b/lib/platform/azure/azure-helper.ts @@ -232,9 +232,9 @@ export async function getMergeMethod( repoId: string, project: string ): Promise<GitPullRequestMergeStrategy> { - const policyConfigurations = (await (await azureApi.policyApi()).getPolicyConfigurations( - project - )) + const policyConfigurations = ( + await (await azureApi.policyApi()).getPolicyConfigurations(project) + ) .filter( p => p.settings.scope.some(s => s.repositoryId === repoId) && diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 3f46fa1149a44dcf49a29e5d8925bd6862e799e4..025eddca8405e2bf5095f5e26ce15c562e592ce6 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -199,14 +199,18 @@ export async function initRepo({ }); try { - const info = (await api.get( - `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}` - )).body; + const info = ( + await api.get( + `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}` + ) + ).body; config.owner = info.project.key; logger.debug(`${repository} owner = ${config.owner}`); - config.defaultBranch = (await api.get( - `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/branches/default` - )).body.displayId; + config.defaultBranch = ( + await api.get( + `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/branches/default` + ) + ).body.displayId; config.baseBranch = config.defaultBranch; config.mergeMethod = 'merge'; const repoConfig: RepoConfig = { @@ -303,10 +307,12 @@ export async function getPr( pr.isConflicted = !!mergeRes.body.conflicted; pr.canMerge = !!mergeRes.body.canMerge; - const prCommits = (await api.get( - `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/commits?withCounts=true`, - { useCache: !refreshCache } - )).body; + const prCommits = ( + await api.get( + `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/commits?withCounts=true`, + { useCache: !refreshCache } + ) + ).body; if (prCommits.totalCount === 1) { if (global.gitAuthor) { @@ -499,10 +505,11 @@ async function getStatus( ): Promise<utils.BitbucketCommitStatus> { const branchCommit = await config.storage.getBranchCommit(branchName); - return (await api.get( - `./rest/build-status/1.0/commits/stats/${branchCommit}`, - { useCache } - )).body; + return ( + await api.get(`./rest/build-status/1.0/commits/stats/${branchCommit}`, { + useCache, + }) + ).body; } // Returns the combined status for a branch. @@ -763,9 +770,11 @@ async function getCommentVersion( commentId: number ): Promise<number> { // GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} - const { version } = (await api.get( - `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}` - )).body; + const { version } = ( + await api.get( + `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests/${prNo}/comments/${commentId}` + ) + ).body; return version; } @@ -887,17 +896,21 @@ export async function createPr({ /* istanbul ignore else */ if (config.bbUseDefaultReviewers) { logger.debug(`fetching default reviewers`); - const { id } = (await api.get( - `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}` - )).body; - - const defReviewers = (await api.get( - `./rest/default-reviewers/1.0/projects/${config.projectKey}/repos/${ - config.repositorySlug - }/reviewers?sourceRefId=refs/heads/${escapeHash( - branchName - )}&targetRefId=refs/heads/${base}&sourceRepoId=${id}&targetRepoId=${id}` - )).body; + const { id } = ( + await api.get( + `./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}` + ) + ).body; + + const defReviewers = ( + await api.get( + `./rest/default-reviewers/1.0/projects/${config.projectKey}/repos/${ + config.repositorySlug + }/reviewers?sourceRefId=refs/heads/${escapeHash( + branchName + )}&targetRefId=refs/heads/${base}&sourceRepoId=${id}&targetRepoId=${id}` + ) + ).body; reviewers = defReviewers.map((u: { name: string }) => ({ user: { name: u.name }, diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index bc3551a59eff84e7c7841fb67776892b90eb0475..ce9d47790f917038d1bee19d1b5aa0b5c2037cd0 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -99,9 +99,11 @@ export async function initRepo({ let renovateConfig: RenovateConfig; try { - renovateConfig = (await api.get<RenovateConfig>( - `/2.0/repositories/${repository}/src/${info.mainbranch}/renovate.json` - )).body; + renovateConfig = ( + await api.get<RenovateConfig>( + `/2.0/repositories/${repository}/src/${info.mainbranch}/renovate.json` + ) + ).body; } catch { // Do nothing } @@ -291,19 +293,21 @@ export function getCommitMessages(): Promise<string[]> { } async function isPrConflicted(prNo: number): Promise<boolean> { - const diff = (await api.get( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}/diff`, - { json: false } as any - )).body; + const diff = ( + await api.get( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}/diff`, + { json: false } as any + ) + ).body; return utils.isConflicted(parseDiff(diff)); } // Gets details for a PR export async function getPr(prNo: number): Promise<Pr | null> { - const pr = (await api.get( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}` - )).body; + const pr = ( + await api.get(`/2.0/repositories/${config.repository}/pullrequests/${prNo}`) + ).body; // istanbul ignore if if (!pr) { @@ -361,11 +365,13 @@ const escapeHash = (input: string): string => // Return the commit SHA for a branch async function getBranchCommit(branchName: string): Promise<string | null> { try { - const branch = (await api.get( - `/2.0/repositories/${config.repository}/refs/branches/${escapeHash( - branchName - )}` - )).body; + const branch = ( + await api.get( + `/2.0/repositories/${config.repository}/refs/branches/${escapeHash( + branchName + )}` + ) + ).body; return branch.target.hash; } catch (err) /* istanbul ignore next */ { logger.debug({ err }, `getBranchCommit('${branchName}') failed'`); @@ -482,9 +488,11 @@ async function findOpenIssues(title: string): Promise<BbIssue[]> { ].join(' AND ') ); return ( - (await api.get( - `/2.0/repositories/${config.repository}/issues?q=${filter}` - )).body.values || /* istanbul ignore next */ [] + ( + await api.get( + `/2.0/repositories/${config.repository}/issues?q=${filter}` + ) + ).body.values || /* istanbul ignore next */ [] ); } catch (err) /* istanbul ignore next */ { logger.warn({ err }, 'Error finding issues'); @@ -605,9 +613,11 @@ export /* istanbul ignore next */ async function getIssueList(): Promise< ].join(' AND ') ); return ( - (await api.get( - `/2.0/repositories/${config.repository}/issues?q=${filter}` - )).body.values || /* istanbul ignore next */ [] + ( + await api.get( + `/2.0/repositories/${config.repository}/issues?q=${filter}` + ) + ).body.values || /* istanbul ignore next */ [] ); } catch (err) /* istanbul ignore next */ { logger.warn({ err }, 'Error finding issues'); @@ -698,9 +708,11 @@ export async function createPr({ let reviewers = []; if (config.bbUseDefaultReviewers) { - const reviewersResponse = (await api.get<utils.PagedResult<Reviewer>>( - `/2.0/repositories/${config.repository}/default-reviewers` - )).body; + const reviewersResponse = ( + await api.get<utils.PagedResult<Reviewer>>( + `/2.0/repositories/${config.repository}/default-reviewers` + ) + ).body; reviewers = reviewersResponse.values.map((reviewer: Reviewer) => ({ uuid: reviewer.uuid, })); @@ -723,10 +735,11 @@ export async function createPr({ reviewers, }; - const prInfo = (await api.post( - `/2.0/repositories/${config.repository}/pullrequests`, - { body } - )).body; + const prInfo = ( + await api.post(`/2.0/repositories/${config.repository}/pullrequests`, { + body, + }) + ).body; // TODO: fix types const pr: Pr = { number: prInfo.id, @@ -751,10 +764,12 @@ interface Commit { // Return a list of all modified files in a PR export async function getPrFiles(prNo: number): Promise<string[]> { logger.debug({ prNo }, 'getPrFiles'); - const diff = (await api.get( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}/diff`, - { json: false } as any - )).body; + const diff = ( + await api.get( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}/diff`, + { json: false } as any + ) + ).body; const files = parseDiff(diff).map(file => file.to); return files; } diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index 62d4b11d3bf74c9b3d3aa5414d2468bff78aabcf..0e0e40d5763cd0be750bbaf68e72e35aa2a043e1 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -279,10 +279,9 @@ export class Storage { this._config.baseBranch = branchName; try { if (branchName !== 'master') { - this._config.baseBranchSha = (await this._git!.raw([ - 'rev-parse', - 'origin/' + branchName, - ])).trim(); + this._config.baseBranchSha = ( + await this._git!.raw(['rev-parse', 'origin/' + branchName]) + ).trim(); } await this._git!.checkout([branchName, '-f']); await this._git!.reset('hard'); diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 250b9773698e00e71946fd33973fd7106fb30e0d..3b1f3e4514b60655149cb184e6c40b90d0c65ed8 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -121,9 +121,11 @@ export async function initPlatform({ let gitAuthor: string; let renovateUsername: string; try { - const userData = (await api.get(defaults.endpoint + 'user', { - token, - })).body; + const userData = ( + await api.get(defaults.endpoint + 'user', { + token, + }) + ).body; renovateUsername = userData.login; gitAuthor = userData.name; } catch (err) { @@ -131,9 +133,11 @@ export async function initPlatform({ throw new Error('Init: Authentication failure'); } try { - const userEmail = (await api.get(defaults.endpoint + 'user/emails', { - token, - })).body; + const userEmail = ( + await api.get(defaults.endpoint + 'user/emails', { + token, + }) + ).body; if (userEmail.length && userEmail[0].email) { gitAuthor += ` <${userEmail[0].email}>`; } else { @@ -258,9 +262,11 @@ export async function initRepo({ try { const renovateConfig = JSON.parse( Buffer.from( - (await api.get( - `repos/${config.repository}/contents/${defaultConfigFile}` - )).body.content, + ( + await api.get( + `repos/${config.repository}/contents/${defaultConfigFile}` + ) + ).body.content, 'base64' ).toString() ); @@ -289,9 +295,11 @@ export async function initRepo({ try { renovateConfig = JSON.parse( Buffer.from( - (await api.get( - `repos/${config.repository}/contents/${defaultConfigFile}` - )).body.content, + ( + await api.get( + `repos/${config.repository}/contents/${defaultConfigFile}` + ) + ).body.content, 'base64' ).toString() ); @@ -364,17 +372,18 @@ export async function initRepo({ config.parentRepo = config.repository; config.repository = null; // Get list of existing repos - const existingRepos = (await api.get<{ full_name: string }[]>( - 'user/repos?per_page=100', - { + const existingRepos = ( + await api.get<{ full_name: string }[]>('user/repos?per_page=100', { token: forkToken || opts.token, paginate: true, - } - )).body.map(r => r.full_name); + }) + ).body.map(r => r.full_name); try { - config.repository = (await api.post(`repos/${repository}/forks`, { - token: forkToken || opts.token, - })).body.full_name; + config.repository = ( + await api.post(`repos/${repository}/forks`, { + token: forkToken || opts.token, + }) + ).body.full_name; } catch (err) /* istanbul ignore next */ { logger.info({ err }, 'Error forking repository'); throw new Error(REPOSITORY_CANNOT_FORK); @@ -843,9 +852,11 @@ export async function getPr(prNo: number): Promise<Pr | null> { { prNo }, 'PR not found in open or closed PRs list - trying to fetch it directly' ); - const pr = (await api.get( - `repos/${config.parentRepo || config.repository}/pulls/${prNo}` - )).body; + const pr = ( + await api.get( + `repos/${config.parentRepo || config.repository}/pulls/${prNo}` + ) + ).body; if (!pr) { return null; } @@ -865,10 +876,12 @@ export async function getPr(prNo: number): Promise<Pr | null> { if (pr.commits === 1) { if (global.gitAuthor) { // Check against gitAuthor - const commitAuthorEmail = (await api.get( - `repos/${config.parentRepo || - config.repository}/pulls/${prNo}/commits` - )).body[0].commit.author.email; + const commitAuthorEmail = ( + await api.get( + `repos/${config.parentRepo || + config.repository}/pulls/${prNo}/commits` + ) + ).body[0].commit.author.email; if (commitAuthorEmail === global.gitAuthor.email) { logger.debug( { prNo }, @@ -896,9 +909,12 @@ export async function getPr(prNo: number): Promise<Pr | null> { } else { // Check if only one author of all commits logger.debug({ prNo }, 'Checking all commits'); - const prCommits = (await api.get( - `repos/${config.parentRepo || config.repository}/pulls/${prNo}/commits` - )).body; + const prCommits = ( + await api.get( + `repos/${config.parentRepo || + config.repository}/pulls/${prNo}/commits` + ) + ).body; // Filter out "Update branch" presses const remainingCommits = prCommits.filter( (commit: { @@ -1277,9 +1293,11 @@ export async function findIssue(title: string): Promise<Issue | null> { return null; } logger.debug('Found issue ' + issue.number); - const issueBody = (await api.get( - `repos/${config.parentRepo || config.repository}/issues/${issue.number}` - )).body.body; + const issueBody = ( + await api.get( + `repos/${config.parentRepo || config.repository}/issues/${issue.number}` + ) + ).body.body; return { number: issue.number, body: issueBody, @@ -1325,9 +1343,13 @@ export async function ensureIssue({ await closeIssue(i.number); } } - const issueBody = (await api.get( - `repos/${config.parentRepo || config.repository}/issues/${issue.number}` - )).body.body; + const issueBody = ( + await api.get( + `repos/${config.parentRepo || config.repository}/issues/${ + issue.number + }` + ) + ).body.body; if (issueBody === body && issue.state === 'open') { logger.info('Issue is open and up to date - nothing to do'); return null; @@ -1489,9 +1511,11 @@ async function getComments(issueNo: number): Promise<Comment[]> { const url = `repos/${config.parentRepo || config.repository}/issues/${issueNo}/comments?per_page=100`; try { - const comments = (await api.get<Comment[]>(url, { - paginate: true, - })).body; + const comments = ( + await api.get<Comment[]>(url, { + paginate: true, + }) + ).body; logger.debug(`Found ${comments.length} comments`); return comments; } catch (err) /* istanbul ignore next */ { @@ -1614,10 +1638,12 @@ export async function createPr({ options.body.maintainer_can_modify = true; } logger.debug({ title, head, base }, 'Creating PR'); - const pr = (await api.post<Pr>( - `repos/${config.parentRepo || config.repository}/pulls`, - options - )).body; + const pr = ( + await api.post<Pr>( + `repos/${config.parentRepo || config.repository}/pulls`, + options + ) + ).body; logger.debug({ branch: branchName, pr: pr.number }, 'PR created'); // istanbul ignore if if (config.prList) { @@ -1646,9 +1672,11 @@ export async function getPrFiles(prNo: number): Promise<string[]> { if (!prNo) { return []; } - const files = (await api.get( - `repos/${config.parentRepo || config.repository}/pulls/${prNo}/files` - )).body; + const files = ( + await api.get( + `repos/${config.parentRepo || config.repository}/pulls/${prNo}/files` + ) + ).body; return files.map((f: { filename: string }) => f.filename); } diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 15da3fbc2e50575e23c97c63e3bd74cb83f2b40d..f8ac2c87b68df47f2821e732ea9045765f03fd99 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -174,9 +174,11 @@ export async function initRepo({ try { renovateConfig = JSON.parse( Buffer.from( - (await api.get( - `projects/${config.repository}/repository/files/${defaultConfigFile}?ref=${res.body.default_branch}` - )).body.content, + ( + await api.get( + `projects/${config.repository}/repository/files/${defaultConfigFile}?ref=${res.body.default_branch}` + ) + ).body.content, 'base64' ).toString() ); @@ -449,9 +451,11 @@ export async function getPrFiles(mrNo: number): Promise<string[]> { if (!mrNo) { return []; } - const files = (await api.get( - `projects/${config.repository}/merge_requests/${mrNo}/changes` - )).body.changes; + const files = ( + await api.get( + `projects/${config.repository}/merge_requests/${mrNo}/changes` + ) + ).body.changes; return files.map((f: { new_path: string }) => f.new_path); } @@ -685,9 +689,9 @@ export async function findIssue(title: string): Promise<Issue | null> { if (!issue) { return null; } - const issueBody = (await api.get( - `projects/${config.repository}/issues/${issue.iid}` - )).body.description; + const issueBody = ( + await api.get(`projects/${config.repository}/issues/${issue.iid}`) + ).body.description; return { number: issue.iid, body: issueBody, @@ -708,9 +712,9 @@ export async function ensureIssue({ const issueList = await getIssueList(); const issue = issueList.find((i: { title: string }) => i.title === title); if (issue) { - const existingDescription = (await api.get( - `projects/${config.repository}/issues/${issue.iid}` - )).body.description; + const existingDescription = ( + await api.get(`projects/${config.repository}/issues/${issue.iid}`) + ).body.description; if (existingDescription !== description) { logger.debug('Updating issue body'); await api.put(`projects/${config.repository}/issues/${issue.iid}`, { diff --git a/lib/util/got/util.ts b/lib/util/got/util.ts index c3187b439ca4d98359c6e1b21440abfd560ff6c6..8d476f54579fb2fd0badbcb82510c1fc5edc6df3 100644 --- a/lib/util/got/util.ts +++ b/lib/util/got/util.ts @@ -3,7 +3,7 @@ import { Got } from './common'; // TODO: missing types export const mergeInstances = (got as any).mergeInstances as ( - ...args: (got.GotInstance<any>)[] + ...args: got.GotInstance<any>[] ) => Got; // TODO: missing types diff --git a/lib/versioning/maven/compare.ts b/lib/versioning/maven/compare.ts index 767661d93b1ca104277387847fafdc97098655e5..913d3cc97cc41f64fb1c3f006ac140df9ff17cea 100644 --- a/lib/versioning/maven/compare.ts +++ b/lib/versioning/maven/compare.ts @@ -327,34 +327,31 @@ function parseRange(rangeStr: string): any { const lastIdx = result.length - 1; let prevValue: string = null; - return result.reduce( - (acc, range, idx) => { - const { leftType, leftValue, rightType, rightValue } = range; - - if (idx === 0 && leftValue === '') { - if (leftType === EXCLUDING_POINT && isVersion(rightValue)) { - prevValue = rightValue; - return [...acc, { ...range, leftValue: null }]; - } - return null; - } - if (idx === lastIdx && rightValue === '') { - if (rightType === EXCLUDING_POINT && isVersion(leftValue)) { - if (prevValue && compare(prevValue, leftValue) === 1) return null; - return [...acc, { ...range, rightValue: null }]; - } - return null; + return result.reduce((acc, range, idx) => { + const { leftType, leftValue, rightType, rightValue } = range; + + if (idx === 0 && leftValue === '') { + if (leftType === EXCLUDING_POINT && isVersion(rightValue)) { + prevValue = rightValue; + return [...acc, { ...range, leftValue: null }]; } - if (isVersion(leftValue) && isVersion(rightValue)) { - if (compare(leftValue, rightValue) === 1) return null; + return null; + } + if (idx === lastIdx && rightValue === '') { + if (rightType === EXCLUDING_POINT && isVersion(leftValue)) { if (prevValue && compare(prevValue, leftValue) === 1) return null; - prevValue = rightValue; - return [...acc, range]; + return [...acc, { ...range, rightValue: null }]; } return null; - }, - [] as Range[] - ); + } + if (isVersion(leftValue) && isVersion(rightValue)) { + if (compare(leftValue, rightValue) === 1) return null; + if (prevValue && compare(prevValue, leftValue) === 1) return null; + prevValue = rightValue; + return [...acc, range]; + } + return null; + }, [] as Range[]); } function isValid(str: string): boolean { diff --git a/package.json b/package.json index fecf20707807717a5bff12d1dc260d07795af98c..c183508f52cfc5cde5474c657ac1bae72b49ed6d 100644 --- a/package.json +++ b/package.json @@ -218,7 +218,7 @@ "mockdate": "2.0.5", "nock": "11.7.2", "npm-run-all": "4.1.5", - "prettier": "1.18.2", + "prettier": "1.19.1", "pretty-quick": "2.0.1", "rimraf": "3.0.0", "semantic-release": "15.14.0", diff --git a/test/manager/gradle/index.spec.ts b/test/manager/gradle/index.spec.ts index 0e7f98f1548719886dfb3ac29de6091f70803a94..d3c6ae213db415b0d6539ae695c65f25d8d8082d 100644 --- a/test/manager/gradle/index.spec.ts +++ b/test/manager/gradle/index.spec.ts @@ -75,10 +75,12 @@ describe('manager/gradle', () => { it('should return empty if there are no dependencies', async () => { const execSnapshots = mockExecAll(exec, gradleOutput); - fs.readFile.mockResolvedValue(fsReal.readFileSync( - 'test/datasource/gradle/_fixtures/updatesReportEmpty.json', - 'utf8' - ) as any); + fs.readFile.mockResolvedValue( + fsReal.readFileSync( + 'test/datasource/gradle/_fixtures/updatesReportEmpty.json', + 'utf8' + ) as any + ); const dependencies = await manager.extractAllPackageFiles(config, [ 'build.gradle', ]); diff --git a/test/platform/azure/azure-helper.spec.ts b/test/platform/azure/azure-helper.spec.ts index f531481cd9e5a624ba5773249b6276239fdf07ef..fc631a784d85cd07b31bc7f012217568d4589839 100644 --- a/test/platform/azure/azure-helper.spec.ts +++ b/test/platform/azure/azure-helper.spec.ts @@ -3,9 +3,7 @@ import { GitPullRequestMergeStrategy } from 'azure-devops-node-api/interfaces/Gi describe('platform/azure/helpers', () => { let azureHelper: typeof import('../../../lib/platform/azure/azure-helper'); - let azureApi: jest.Mocked< - typeof import('../../../lib/platform/azure/azure-got-wrapper') - >; + let azureApi: jest.Mocked<typeof import('../../../lib/platform/azure/azure-got-wrapper')>; beforeEach(() => { // reset module diff --git a/test/platform/azure/index.spec.ts b/test/platform/azure/index.spec.ts index 2e54f5dd893aa66e7670c7ec686c5550373f5208..8ddcf5dcf3c5dce46b25fca4377155c81a137598 100644 --- a/test/platform/azure/index.spec.ts +++ b/test/platform/azure/index.spec.ts @@ -6,12 +6,8 @@ import { REPOSITORY_DISABLED } from '../../../lib/constants/error-messages'; describe('platform/azure', () => { let hostRules: jest.Mocked<typeof _hostRules>; let azure: jest.Mocked<typeof import('../../../lib/platform/azure')>; - let azureApi: jest.Mocked< - typeof import('../../../lib/platform/azure/azure-got-wrapper') - >; - let azureHelper: jest.Mocked< - typeof import('../../../lib/platform/azure/azure-helper') - >; + let azureApi: jest.Mocked<typeof import('../../../lib/platform/azure/azure-got-wrapper')>; + let azureHelper: jest.Mocked<typeof import('../../../lib/platform/azure/azure-helper')>; let GitStorage; beforeEach(() => { // reset module diff --git a/test/platform/bitbucket/utils.spec.ts b/test/platform/bitbucket/utils.spec.ts index 75a2cd7a09588c9759599b3289efc5dc5624570b..c073c8a85f14a8aea2c13beb581fb3459e3fecaf 100644 --- a/test/platform/bitbucket/utils.spec.ts +++ b/test/platform/bitbucket/utils.spec.ts @@ -3,9 +3,8 @@ import { GotApi } from '../../../lib/platform/common'; jest.mock('../../../lib/platform/bitbucket/bb-got-wrapper'); -const api: jest.Mocked< - GotApi -> = require('../../../lib/platform/bitbucket/bb-got-wrapper').api; +const api: jest.Mocked<GotApi> = require('../../../lib/platform/bitbucket/bb-got-wrapper') + .api; const range = (count: number) => [...Array(count).keys()]; diff --git a/test/platform/gitlab/index.spec.ts b/test/platform/gitlab/index.spec.ts index 1209c40c9006b0af81845d02c09873eb05b9858a..afc26843378f330d62f92769b41353c6b7ba7f9a 100644 --- a/test/platform/gitlab/index.spec.ts +++ b/test/platform/gitlab/index.spec.ts @@ -9,9 +9,7 @@ import { describe('platform/gitlab', () => { let gitlab: typeof import('../../../lib/platform/gitlab'); - let api: jest.Mocked< - typeof import('../../../lib/platform/gitlab/gl-got-wrapper').api - >; + let api: jest.Mocked<typeof import('../../../lib/platform/gitlab/gl-got-wrapper').api>; let hostRules: jest.Mocked<typeof _hostRules>; let GitStorage: jest.Mocked< typeof import('../../../lib/platform/git/storage') diff --git a/test/static-files.spec.ts b/test/static-files.spec.ts index 72f090a0cbdbd20b98557b95a013abf95c572325..d8280b6bef3a6d18cec36ded635df0ca5fe1c6fc 100644 --- a/test/static-files.spec.ts +++ b/test/static-files.spec.ts @@ -11,9 +11,9 @@ function filterFiles(files: string[]): string[] { } async function getFiles(dir: string): Promise<string[]> { - return filterFiles(await glob(`${dir}/**/*`, { dot: true, nodir: true })).map( - (file: string) => file.replace(`${dir}/`, '') - ); + return filterFiles( + await glob(`${dir}/**/*`, { dot: true, nodir: true }) + ).map((file: string) => file.replace(`${dir}/`, '')); } describe('static-files', () => { diff --git a/yarn.lock b/yarn.lock index 2e80ab62b1e5eebd95a2859a58245354da5d2c50..d5a1bef8c2c1854b3c62eb047367d36deec9f92e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7327,10 +7327,10 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@1.18.2: - version "1.18.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" - integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== +prettier@1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== pretty-format@^24.9.0: version "24.9.0"