From 49d45a77ca3407b13b32a870f756356d1d5ce032 Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Thu, 24 Aug 2023 14:03:04 +0200 Subject: [PATCH 1/4] feat: include new version in composer update command --- .../manager/composer/artifacts.spec.ts | 22 +++++++++++++++++++ lib/modules/manager/composer/artifacts.ts | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index 779ac1bdf5dff6..fc056df521900c 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -1183,4 +1183,26 @@ describe('modules/manager/composer/artifacts', () => { }, ]); }); + + it('includes new dependency version in update command', async () => { + fs.readLocalFile.mockResolvedValueOnce('{}'); + const execSnapshots = mockExecAll(); + fs.readLocalFile.mockResolvedValueOnce('{}'); + git.getRepoStatus.mockResolvedValueOnce(repoStatus); + + expect( + await composer.updateArtifacts({ + packageFileName: 'composer.json', + updatedDeps: [{ depName: 'foo', newVersion: '1.1.0' }], + newPackageFileContent: '{}', + config, + }) + ).toBeNull(); + expect(execSnapshots).toMatchObject([ + { + cmd: 'composer update foo:1.1.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader --no-plugins', + options: { cwd: '/tmp/github/some/repo' }, + }, + ]); + }); }); diff --git a/lib/modules/manager/composer/artifacts.ts b/lib/modules/manager/composer/artifacts.ts index 104cbfe0c5e477..74113bff12fc45 100644 --- a/lib/modules/manager/composer/artifacts.ts +++ b/lib/modules/manager/composer/artifacts.ts @@ -179,7 +179,9 @@ export async function updateArtifacts({ ( 'update ' + updatedDeps - .map((dep) => dep.depName) + .map((dep) => + dep.newVersion ? `${dep.depName}:${dep.newVersion}` : dep.depName + ) .filter(is.string) .map((dep) => quote(dep)) .join(' ') From fbe676a4dc527e6f68f368d53c5ceec405cafaab Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Thu, 24 Aug 2023 14:51:07 +0200 Subject: [PATCH 2/4] test: add newVersion to existing test cases --- lib/modules/manager/composer/artifacts.spec.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index fc056df521900c..11f8d496d569b2 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -92,14 +92,17 @@ describe('modules/manager/composer/artifacts', () => { expect( await composer.updateArtifacts({ packageFileName: 'composer.json', - updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], + updatedDeps: [ + { depName: 'foo', newVersion: '1' }, + { depName: 'bar', newVersion: '2' }, + ], newPackageFileContent: '{}', config, }) ).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction', + cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction', options: { cwd: '/tmp/github/some/repo', env: { @@ -1146,14 +1149,17 @@ describe('modules/manager/composer/artifacts', () => { expect( await composer.updateArtifacts({ packageFileName: 'composer.json', - updatedDeps: [{ depName: 'foo' }, { depName: 'bar' }], + updatedDeps: [ + { depName: 'foo', newVersion: '1' }, + { depName: 'bar', newVersion: '2' }, + ], newPackageFileContent: '{}', config, }) ).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'composer update foo bar --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader', + cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader', options: { cwd: '/tmp/github/some/repo' }, }, ]); From d845c593b0fc770a29f146b96acc41ff741ca97d Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Thu, 24 Aug 2023 15:00:56 +0200 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Rhys Arkins --- lib/modules/manager/composer/artifacts.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index 11f8d496d569b2..0d98c40496fbe1 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -93,8 +93,8 @@ describe('modules/manager/composer/artifacts', () => { await composer.updateArtifacts({ packageFileName: 'composer.json', updatedDeps: [ - { depName: 'foo', newVersion: '1' }, - { depName: 'bar', newVersion: '2' }, + { depName: 'foo', newVersion: '1.0.0' }, + { depName: 'bar', newVersion: '2.0.0' }, ], newPackageFileContent: '{}', config, @@ -102,7 +102,7 @@ describe('modules/manager/composer/artifacts', () => { ).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction', + cmd: 'composer update foo:1.0.0 bar:2.0.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction', options: { cwd: '/tmp/github/some/repo', env: { From 5dcb64433657f6c8113b9a853e6dfd3564fb6c95 Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Thu, 24 Aug 2023 15:07:44 +0200 Subject: [PATCH 4/4] Update artifacts.spec.ts --- lib/modules/manager/composer/artifacts.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index 0d98c40496fbe1..7ad1a8bc212fc6 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -1150,8 +1150,8 @@ describe('modules/manager/composer/artifacts', () => { await composer.updateArtifacts({ packageFileName: 'composer.json', updatedDeps: [ - { depName: 'foo', newVersion: '1' }, - { depName: 'bar', newVersion: '2' }, + { depName: 'foo', newVersion: '1.0.0' }, + { depName: 'bar', newVersion: '2.0.0' }, ], newPackageFileContent: '{}', config, @@ -1159,7 +1159,7 @@ describe('modules/manager/composer/artifacts', () => { ).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'composer update foo:1 bar:2 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader', + cmd: 'composer update foo:1.0.0 bar:2.0.0 --with-dependencies --ignore-platform-reqs --no-ansi --no-interaction --no-scripts --no-autoloader', options: { cwd: '/tmp/github/some/repo' }, }, ]);