From f33c0b034f4fbffb0909e49a0fd71fd482cb8d3f Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 12 Jun 2020 07:35:18 +0200 Subject: [PATCH 1/4] fix(gradle-wrapper): correct artifact filenames for subdirs --- lib/manager/gradle-wrapper/artifacts.ts | 26 ++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts index e396226e5c2b82..9b9f3fc4db89f2 100644 --- a/lib/manager/gradle-wrapper/artifacts.ts +++ b/lib/manager/gradle-wrapper/artifacts.ts @@ -4,7 +4,11 @@ import Git from 'simple-git/promise'; import { logger } from '../../logger'; import { platform } from '../../platform'; import { ExecOptions, exec } from '../../util/exec'; -import { readLocalFile, writeLocalFile } from '../../util/fs'; +import { + readLocalFile, + writeLocalFile, + getSiblingFileName, +} from '../../util/fs'; import { Http } from '../../util/http'; import { UpdateArtifact, UpdateArtifactsResult } from '../common'; import { gradleWrapperFileName, prepareGradleCommand } from '../gradle/index'; @@ -95,14 +99,22 @@ export async function updateArtifacts({ ); } const status = await platform.getRepoStatus(); + const artifactFileNames = [ + 'gradle/wrapper/gradle-wrapper.properties', + 'gradle/wrapper/gradle-wrapper.jar', + 'gradlew', + 'gradlew.bat', + ].map((filename) => + getSiblingFileName( + packageFileName.replace('gradle/wrapper/', ''), + filename + ) + ); const updateArtifactsResult = ( await Promise.all( - [ - 'gradle/wrapper/gradle-wrapper.properties', - 'gradle/wrapper/gradle-wrapper.jar', - 'gradlew', - 'gradlew.bat', - ].map(async (fileProjectPath) => addIfUpdated(status, fileProjectPath)) + artifactFileNames.map(async (fileProjectPath) => + addIfUpdated(status, fileProjectPath) + ) ) ).filter((e) => e != null); logger.debug( From 74a084eb21f34efd31c397984f35197870d53c1b Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 12 Jun 2020 08:30:54 +0200 Subject: [PATCH 2/4] fix lint --- lib/manager/gradle-wrapper/artifacts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts index 9b9f3fc4db89f2..17cfc0f6cfb4df 100644 --- a/lib/manager/gradle-wrapper/artifacts.ts +++ b/lib/manager/gradle-wrapper/artifacts.ts @@ -5,9 +5,9 @@ import { logger } from '../../logger'; import { platform } from '../../platform'; import { ExecOptions, exec } from '../../util/exec'; import { + getSiblingFileName, readLocalFile, writeLocalFile, - getSiblingFileName, } from '../../util/fs'; import { Http } from '../../util/http'; import { UpdateArtifact, UpdateArtifactsResult } from '../common'; From 1e549fc50c53e77e0f6163ba3ee40bdcba500e17 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 12 Jun 2020 08:41:30 +0200 Subject: [PATCH 3/4] fix tests --- lib/manager/gradle-wrapper/artifacts.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/manager/gradle-wrapper/artifacts.spec.ts b/lib/manager/gradle-wrapper/artifacts.spec.ts index 6a62ca92018a81..ff3a2da8893b6f 100644 --- a/lib/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts.spec.ts @@ -52,6 +52,7 @@ describe(getName(__filename), () => { resetPrefetchedImages(); fs.readLocalFile.mockResolvedValue('test'); + fs.getSiblingFileName.mockImplementation((a, b) => b); }); afterEach(() => { @@ -70,7 +71,7 @@ describe(getName(__filename), () => { const execSnapshots = mockExecAll(exec); const res = await dcUpdate.updateArtifacts({ - packageFileName: 'gradle-wrapper.properties', + packageFileName: 'gradle/wrapper/gradle-wrapper.properties', updatedDeps: [], newPackageFileContent: await readString( `./expectedFiles/gradle/wrapper/gradle-wrapper.properties` From 595bd0581f1af7c5ab4f3c5e1ce662f23b1a83f4 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 12 Jun 2020 11:05:16 +0200 Subject: [PATCH 4/4] fix windows path issues --- lib/manager/gradle-wrapper/artifacts.spec.ts | 1 - lib/manager/gradle-wrapper/artifacts.ts | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/manager/gradle-wrapper/artifacts.spec.ts b/lib/manager/gradle-wrapper/artifacts.spec.ts index ff3a2da8893b6f..d343734a36e4ce 100644 --- a/lib/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/manager/gradle-wrapper/artifacts.spec.ts @@ -52,7 +52,6 @@ describe(getName(__filename), () => { resetPrefetchedImages(); fs.readLocalFile.mockResolvedValue('test'); - fs.getSiblingFileName.mockImplementation((a, b) => b); }); afterEach(() => { diff --git a/lib/manager/gradle-wrapper/artifacts.ts b/lib/manager/gradle-wrapper/artifacts.ts index 17cfc0f6cfb4df..dc020ce7e44a69 100644 --- a/lib/manager/gradle-wrapper/artifacts.ts +++ b/lib/manager/gradle-wrapper/artifacts.ts @@ -4,11 +4,7 @@ import Git from 'simple-git/promise'; import { logger } from '../../logger'; import { platform } from '../../platform'; import { ExecOptions, exec } from '../../util/exec'; -import { - getSiblingFileName, - readLocalFile, - writeLocalFile, -} from '../../util/fs'; +import { readLocalFile, writeLocalFile } from '../../util/fs'; import { Http } from '../../util/http'; import { UpdateArtifact, UpdateArtifactsResult } from '../common'; import { gradleWrapperFileName, prepareGradleCommand } from '../gradle/index'; @@ -104,11 +100,11 @@ export async function updateArtifacts({ 'gradle/wrapper/gradle-wrapper.jar', 'gradlew', 'gradlew.bat', - ].map((filename) => - getSiblingFileName( - packageFileName.replace('gradle/wrapper/', ''), - filename - ) + ].map( + (filename) => + packageFileName + .replace('gradle/wrapper/', '') + .replace('gradle-wrapper.properties', '') + filename ); const updateArtifactsResult = ( await Promise.all(