From 718561df063388ef47e3359304ccc54d0c08443e Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Tue, 5 Oct 2021 12:38:51 +0300 Subject: [PATCH 01/38] test: Finish versioning test refactoring (#12017) --- .../ruby/__snapshots__/index.spec.ts.snap | 3 - lib/versioning/ruby/index.spec.ts | 889 ++++++------------ lib/versioning/semver/index.spec.ts | 89 +- lib/versioning/swift/index.spec.ts | 206 ++-- lib/versioning/ubuntu/index.spec.ts | 484 +++++----- 5 files changed, 704 insertions(+), 967 deletions(-) delete mode 100644 lib/versioning/ruby/__snapshots__/index.spec.ts.snap diff --git a/lib/versioning/ruby/__snapshots__/index.spec.ts.snap b/lib/versioning/ruby/__snapshots__/index.spec.ts.snap deleted file mode 100644 index ff84a3d593a27f..00000000000000 --- a/lib/versioning/ruby/__snapshots__/index.spec.ts.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`versioning/ruby/index .getNewValue does not error 1`] = `">= 3.2, < 6.0.2"`; diff --git a/lib/versioning/ruby/index.spec.ts b/lib/versioning/ruby/index.spec.ts index ed0cfb358e739c..3e2c9af76f2fda 100644 --- a/lib/versioning/ruby/index.spec.ts +++ b/lib/versioning/ruby/index.spec.ts @@ -1,609 +1,332 @@ -import type { RangeStrategy } from '../../types'; import { api as semverRuby } from '.'; describe('versioning/ruby/index', () => { - describe('.equals', () => { - it('returns true when versions are equal', () => { - expect(semverRuby.equals('1.0.0', '1')).toBe(true); - expect(semverRuby.equals('1.2.0', '1.2')).toBe(true); - expect(semverRuby.equals('1.2.0', '1.2.0')).toBe(true); - expect(semverRuby.equals('1.0.0.rc1', '1.0.0.rc1')).toBe(true); - }); - - it('returns false when versions are different', () => { - expect(semverRuby.equals('1.2.0', '2')).toBe(false); - expect(semverRuby.equals('1.2.0', '1.1')).toBe(false); - expect(semverRuby.equals('1.2.0', '1.2.1')).toBe(false); - expect(semverRuby.equals('1.0.0.rc1', '1.0.0.rc2')).toBe(false); - }); - }); - - describe('.getMajor', () => { - it('returns major segment of version', () => { - expect(semverRuby.getMajor('1')).toEqual(1); - expect(semverRuby.getMajor('1.2')).toEqual(1); - expect(semverRuby.getMajor('1.2.0')).toEqual(1); - expect(semverRuby.getMajor('1.2.0.alpha.4')).toEqual(1); - }); - }); - - describe('.getMinor', () => { - it('returns minor segment of version when it present', () => { - expect(semverRuby.getMinor('1.2')).toEqual(2); - expect(semverRuby.getMinor('1.2.0')).toEqual(2); - expect(semverRuby.getMinor('1.2.0.alpha.4')).toEqual(2); - }); - - it('returns null when minor segment absent', () => { - expect(semverRuby.getMinor('1')).toBeNull(); - }); + test.each` + a | b | expected + ${'1.0.0'} | ${'1'} | ${true} + ${'1.2.0'} | ${'1.2'} | ${true} + ${'1.2.0'} | ${'1.2.0'} | ${true} + ${'1.0.0.rc1'} | ${'1.0.0.rc1'} | ${true} + ${'1.2.0'} | ${'2'} | ${false} + ${'1.2.0'} | ${'1.1'} | ${false} + ${'1.2.0'} | ${'1.2.1'} | ${false} + ${'1.0.0.rc1'} | ${'1.0.0.rc2'} | ${false} + `('equals("$a", "$b") === $expected', ({ a, b, expected }) => { + expect(semverRuby.equals(a, b)).toBe(expected); }); - describe('.getPatch', () => { - it('returns patch segment of version when it present', () => { - expect(semverRuby.getPatch('1.2.2')).toEqual(2); - expect(semverRuby.getPatch('1.2.1.alpha.4')).toEqual(1); - }); - - it('returns null when patch segment absent', () => { - expect(semverRuby.getPatch('1')).toBeNull(); - expect(semverRuby.getPatch('1.2')).toBeNull(); - }); - }); - - describe('.isVersion', () => { - it('returns true when version is valid', () => { - expect(semverRuby.isVersion('0')).toBe(true); - expect(semverRuby.isVersion('v0')).toBe(true); - expect(semverRuby.isVersion('v1')).toBe(true); - expect(semverRuby.isVersion('v1.2')).toBe(true); - expect(semverRuby.isVersion('v1.2.3')).toBe(true); - expect(semverRuby.isVersion('1')).toBe(true); - expect(semverRuby.isVersion('1.1')).toBe(true); - expect(semverRuby.isVersion('1.1.2')).toBe(true); - expect(semverRuby.isVersion('1.1.2.3')).toBe(true); - expect(semverRuby.isVersion('1.1.2-4')).toBe(true); - expect(semverRuby.isVersion('1.1.2.pre.4')).toBe(true); - expect(semverRuby.isVersion('v1.1.2.pre.4')).toBe(true); - }); - - it('returns false when version is invalid', () => { - expect(semverRuby.isVersion(undefined)).toBe(false); - expect(semverRuby.isVersion('')).toBe(false); - expect(semverRuby.isVersion(null)).toBe(false); - expect(semverRuby.isVersion('v')).toBe(false); - expect(semverRuby.isVersion('tottally-not-a-version')).toBe(false); - }); + test.each` + version | major | minor | patch + ${'1'} | ${1} | ${null} | ${null} + ${'1.2'} | ${1} | ${2} | ${null} + ${'1.2.0'} | ${1} | ${2} | ${0} + ${'1.2.0.alpha.4'} | ${1} | ${2} | ${0} + `( + 'getMajor, getMinor, getPatch for "$version"', + ({ version, major, minor, patch }) => { + expect(semverRuby.getMajor(version)).toBe(major); + expect(semverRuby.getMinor(version)).toBe(minor); + expect(semverRuby.getPatch(version)).toBe(patch); + } + ); + + test.each` + version | expected + ${'0'} | ${true} + ${'v0'} | ${true} + ${'v1'} | ${true} + ${'v1.2'} | ${true} + ${'v1.2.3'} | ${true} + ${'1'} | ${true} + ${'1.1'} | ${true} + ${'1.1.2'} | ${true} + ${'1.1.2.3'} | ${true} + ${'1.1.2-4'} | ${true} + ${'1.1.2.pre.4'} | ${true} + ${'v1.1.2.pre.4'} | ${true} + ${undefined} | ${false} + ${''} | ${false} + ${null} | ${false} + ${'v'} | ${false} + ${'tottally-not-a-version'} | ${false} + `('isVersion("$version") === $expected', ({ version, expected }) => { + expect(!!semverRuby.isVersion(version)).toBe(expected); }); - describe('.isGreaterThan', () => { - it('returns true when version is greater than another', () => { - expect(semverRuby.isGreaterThan('2', '1')).toBe(true); - expect(semverRuby.isGreaterThan('2.2', '2.1')).toBe(true); - expect(semverRuby.isGreaterThan('2.2.1', '2.2.0')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0.rc2', '3.0.0.rc1')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0-rc.2', '3.0.0-rc.1')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0.rc1', '3.0.0.beta')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0-rc.1', '3.0.0-beta')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0.beta', '3.0.0.alpha')).toBe(true); - expect(semverRuby.isGreaterThan('3.0.0-beta', '3.0.0-alpha')).toBe(true); - expect(semverRuby.isGreaterThan('5.0.1.rc1', '5.0.1.beta1')).toBe(true); - expect(semverRuby.isGreaterThan('5.0.1-rc.1', '5.0.1-beta.1')).toBe(true); - }); - - it('returns false when version is lower than another', () => { - expect(semverRuby.isGreaterThan('1', '2')).toBe(false); - expect(semverRuby.isGreaterThan('2.1', '2.2')).toBe(false); - expect(semverRuby.isGreaterThan('2.2.0', '2.2.1')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.rc1', '3.0.0.rc2')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0-rc.1', '3.0.0-rc.2')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.beta', '3.0.0.rc1')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0-beta', '3.0.0-rc.1')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.alpha', '3.0.0.beta')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0-alpha', '3.0.0-beta')).toBe(false); - expect(semverRuby.isGreaterThan('5.0.1.beta1', '5.0.1.rc1')).toBe(false); - expect(semverRuby.isGreaterThan('5.0.1-beta.1', '5.0.1-rc.1')).toBe( - false - ); - }); - - it('returns false when versions are equal', () => { - expect(semverRuby.isGreaterThan('1', '1')).toBe(false); - expect(semverRuby.isGreaterThan('2.1', '2.1')).toBe(false); - expect(semverRuby.isGreaterThan('2.2.0', '2.2.0')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.rc1', '3.0.0.rc1')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0-rc.1', '3.0.0-rc.1')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.beta', '3.0.0.beta')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0-beta', '3.0.0-beta')).toBe(false); - expect(semverRuby.isGreaterThan('3.0.0.alpha', '3.0.0.alpha')).toBe( - false - ); - expect(semverRuby.isGreaterThan('3.0.0-alpha', '3.0.0-alpha')).toBe( - false - ); - expect(semverRuby.isGreaterThan('5.0.1.beta1', '5.0.1.beta1')).toBe( - false - ); - expect(semverRuby.isGreaterThan('5.0.1-beta.1', '5.0.1-beta.1')).toBe( - false - ); - }); + test.each` + a | b | expected + ${'2'} | ${'1'} | ${true} + ${'2.2'} | ${'2.1'} | ${true} + ${'2.2.1'} | ${'2.2.0'} | ${true} + ${'3.0.0.rc2'} | ${'3.0.0.rc1'} | ${true} + ${'3.0.0-rc.2'} | ${'3.0.0-rc.1'} | ${true} + ${'3.0.0.rc1'} | ${'3.0.0.beta'} | ${true} + ${'3.0.0-rc.1'} | ${'3.0.0-beta'} | ${true} + ${'3.0.0.beta'} | ${'3.0.0.alpha'} | ${true} + ${'3.0.0-beta'} | ${'3.0.0-alpha'} | ${true} + ${'5.0.1.rc1'} | ${'5.0.1.beta1'} | ${true} + ${'5.0.1-rc.1'} | ${'5.0.1-beta.1'} | ${true} + ${'1'} | ${'2'} | ${false} + ${'2.1'} | ${'2.2'} | ${false} + ${'2.2.0'} | ${'2.2.1'} | ${false} + ${'3.0.0.rc1'} | ${'3.0.0.rc2'} | ${false} + ${'3.0.0-rc.1'} | ${'3.0.0-rc.2'} | ${false} + ${'3.0.0.beta'} | ${'3.0.0.rc1'} | ${false} + ${'3.0.0-beta'} | ${'3.0.0-rc.1'} | ${false} + ${'3.0.0.alpha'} | ${'3.0.0.beta'} | ${false} + ${'3.0.0-alpha'} | ${'3.0.0-beta'} | ${false} + ${'5.0.1.beta1'} | ${'5.0.1.rc1'} | ${false} + ${'5.0.1-beta.1'} | ${'5.0.1-rc.1'} | ${false} + ${'1'} | ${'1'} | ${false} + ${'2.1'} | ${'2.1'} | ${false} + ${'2.2.0'} | ${'2.2.0'} | ${false} + ${'3.0.0.rc1'} | ${'3.0.0.rc1'} | ${false} + ${'3.0.0-rc.1'} | ${'3.0.0-rc.1'} | ${false} + ${'3.0.0.beta'} | ${'3.0.0.beta'} | ${false} + ${'3.0.0-beta'} | ${'3.0.0-beta'} | ${false} + ${'3.0.0.alpha'} | ${'3.0.0.alpha'} | ${false} + ${'3.0.0-alpha'} | ${'3.0.0-alpha'} | ${false} + ${'5.0.1.beta1'} | ${'5.0.1.beta1'} | ${false} + ${'5.0.1-beta.1'} | ${'5.0.1-beta.1'} | ${false} + `('isGreaterThan("$a", "$b") === $expected', ({ a, b, expected }) => { + expect(semverRuby.isGreaterThan(a, b)).toBe(expected); }); - describe('.isStable', () => { - it('returns true when version is stable', () => { - expect(semverRuby.isStable('1')).toBe(true); - expect(semverRuby.isStable('1.2')).toBe(true); - expect(semverRuby.isStable('1.2.3')).toBe(true); - }); - - it('returns false when version is prerelease', () => { - expect(semverRuby.isStable('1.2.0-alpha')).toBe(false); - expect(semverRuby.isStable('1.2.0.alpha')).toBe(false); - expect(semverRuby.isStable('1.2.0.alpha1')).toBe(false); - expect(semverRuby.isStable('1.2.0-alpha.1')).toBe(false); - }); - - it('returns false when version is invalid', () => { - expect(semverRuby.isStable(undefined)).toBe(false); - expect(semverRuby.isStable('')).toBe(false); - expect(semverRuby.isStable(null)).toBe(false); - expect(semverRuby.isStable('tottally-not-a-version')).toBe(false); - }); + test.each` + version | expected + ${'1'} | ${true} + ${'1.2'} | ${true} + ${'1.2.3'} | ${true} + ${'1.2.0-alpha'} | ${false} + ${'1.2.0.alpha'} | ${false} + ${'1.2.0.alpha1'} | ${false} + ${'1.2.0-alpha.1'} | ${false} + ${undefined} | ${false} + ${''} | ${false} + ${null} | ${false} + ${'tottally-not-a-version'} | ${false} + `('isStable("$version") === $expected', ({ version, expected }) => { + const res = !!semverRuby.isStable(version); + expect(res).toBe(expected); }); - describe('.sortVersions', () => { - it('sorts versions in an ascending order', () => { - expect( - ['1.2.3-beta', '2.0.1', '1.3.4', '1.2.3'].sort(semverRuby.sortVersions) - ).toEqual(['1.2.3-beta', '1.2.3', '1.3.4', '2.0.1']); - }); + test.each` + versions | expected + ${['1.2.3-beta', '2.0.1', '1.3.4', '1.2.3']} | ${['1.2.3-beta', '1.2.3', '1.3.4', '2.0.1']} + `('$versions -> sortVersions -> $expected ', ({ versions, expected }) => { + expect(versions.sort(semverRuby.sortVersions)).toEqual(expected); }); - describe('.minSatisfyingVersion', () => { - it('returns lowest version that matches range', () => { - expect( - semverRuby.minSatisfyingVersion(['2.1.5', '2.1.6'], '~> 2.1') - ).toEqual('2.1.5'); - - expect( - semverRuby.minSatisfyingVersion(['2.1.6', '2.1.5'], '~> 2.1.6') - ).toEqual('2.1.6'); - - expect( - semverRuby.minSatisfyingVersion( - ['4.7.3', '4.7.4', '4.7.5', '4.7.9'], - '~> 4.7, >= 4.7.4' - ) - ).toEqual('4.7.4'); - - expect( - semverRuby.minSatisfyingVersion( - ['2.5.3', '2.5.4', '2.5.5', '2.5.6'], - '~>2.5.3' - ) - ).toEqual('2.5.3'); - - expect( - semverRuby.minSatisfyingVersion( - ['2.1.0', '3.0.0.beta', '2.3', '3.0.0-rc.1', '3.0.0', '3.1.1'], - '~> 3.0' - ) - ).toEqual('3.0.0'); - }); - - it('returns null if version that matches range absent', () => { - expect( - semverRuby.minSatisfyingVersion(['1.2.3', '1.2.4'], '>= 3.5.0') - ).toBeNull(); - }); + test.each` + versions | range | expected + ${['2.1.5', '2.1.6']} | ${'~> 2.1'} | ${'2.1.5'} + ${['2.1.6', '2.1.5']} | ${'~> 2.1.6'} | ${'2.1.6'} + ${['4.7.3', '4.7.4', '4.7.5', '4.7.9']} | ${'~> 4.7, >= 4.7.4'} | ${'4.7.4'} + ${['2.5.3', '2.5.4', '2.5.5', '2.5.6']} | ${'~>2.5.3'} | ${'2.5.3'} + ${['2.1.0', '3.0.0.beta', '2.3', '3.0.0-rc.1', '3.0.0', '3.1.1']} | ${'~> 3.0'} | ${'3.0.0'} + ${['1.2.3', '1.2.4']} | ${'>= 3.5.0'} | ${null} + `( + 'minSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(semverRuby.minSatisfyingVersion(versions, range)).toBe(expected); + } + ); + + test.each` + versions | range | expected + ${['2.1.5', '2.1.6']} | ${'~> 2.1'} | ${'2.1.6'} + ${['2.1.6', '2.1.5']} | ${'~> 2.1.6'} | ${'2.1.6'} + ${['4.7.3', '4.7.4', '4.7.5', '4.7.9']} | ${'~> 4.7, >= 4.7.4'} | ${'4.7.9'} + ${['2.5.3', '2.5.4', '2.5.5', '2.5.6']} | ${'~>2.5.3'} | ${'2.5.6'} + ${['2.1.0', '3.0.0.beta', '2.3', '3.0.0-rc.1', '3.0.0', '3.1.1']} | ${'~> 3.0'} | ${'3.1.1'} + ${['1.2.3', '1.2.4']} | ${'>= 3.5.0'} | ${null} + `( + 'getSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(semverRuby.getSatisfyingVersion(versions, range)).toBe(expected); + } + ); + + test.each` + version | range | expected + ${'1.2'} | ${'>= 1.2'} | ${true} + ${'1.2.3'} | ${'~> 1.2.1'} | ${true} + ${'1.2.7'} | ${'1.2.7'} | ${true} + ${'1.1.6'} | ${'>= 1.1.5, < 2.0'} | ${true} + ${'1.2'} | ${'>= 1.3'} | ${false} + ${'1.3.8'} | ${'~> 1.2.1'} | ${false} + ${'1.3.9'} | ${'1.3.8'} | ${false} + ${'2.0.0'} | ${'>= 1.1.5, < 2.0'} | ${false} + `( + 'matches("$version", "$range") === "$expected"', + ({ version, range, expected }) => { + expect(semverRuby.matches(version, range)).toBe(expected); + } + ); + + test.each` + version | range | expected + ${'1.2.2'} | ${'< 1.2.2'} | ${true} + ${'1.1.4'} | ${'>= 1.1.5, < 2.0'} | ${true} + ${'1.2.0-alpha'} | ${'1.2.0-beta'} | ${true} + ${'1.2.2'} | ${'> 1.2.2, ~> 2.0.0'} | ${true} + ${'1.2.2'} | ${'<= 1.2.2'} | ${false} + ${'2.0.0'} | ${'>= 1.1.5, < 2.0'} | ${false} + ${'1.2.0-beta'} | ${'1.2.0-alpha'} | ${false} + ${'2.0.0'} | ${'> 1.2.2, ~> 2.0.0'} | ${false} + ${'asdf'} | ${'> 1.2.2, ~> 2.0.0'} | ${null} + ${null} | ${'> 1.2.2, ~> 2.0.0'} | ${null} + `( + 'isLessThanRange("$version", "$range") === "$expected"', + ({ version, range, expected }) => { + expect(semverRuby.isLessThanRange(version, range)).toBe(expected); + } + ); + + test.each` + version | expected + ${'1'} | ${true} + ${'1.2'} | ${true} + ${'1.2.3'} | ${true} + ${'^1.2.3'} | ${false} + ${'~1.2.3'} | ${false} + ${'1.2.*'} | ${false} + ${'< 3.0, >= 1.0.0 <= 2.0.0'} | ${false} + ${'< 3.0, >= 1.0.0 <= 2.0.0, = 5.1.2'} | ${false} + `('isValid("$version") === $expected', ({ version, expected }) => { + expect(!!semverRuby.isValid(version)).toBe(expected); }); - describe('.getSatisfyingVersion', () => { - it('returns greatest version that matches range', () => { - expect( - semverRuby.getSatisfyingVersion(['2.1.5', '2.1.6'], '~> 2.1') - ).toEqual('2.1.6'); - - expect( - semverRuby.getSatisfyingVersion(['2.1.6', '2.1.5'], '~> 2.1.6') - ).toEqual('2.1.6'); - - expect( - semverRuby.getSatisfyingVersion( - ['4.7.3', '4.7.4', '4.7.5', '4.7.9'], - '~> 4.7, >= 4.7.4' - ) - ).toEqual('4.7.9'); - - expect( - semverRuby.getSatisfyingVersion( - ['2.5.3', '2.5.4', '2.5.5', '2.5.6'], - '~>2.5.3' - ) - ).toEqual('2.5.6'); - - expect( - semverRuby.getSatisfyingVersion( - ['2.1.0', '3.0.0.beta', '2.3', '3.0.0-rc.1', '3.0.0', '3.1.1'], - '~> 3.0' - ) - ).toEqual('3.1.1'); - }); - - it('returns null if version that matches range absent', () => { - expect( - semverRuby.getSatisfyingVersion(['1.2.3', '1.2.4'], '>= 3.5.0') - ).toBeNull(); - }); + test.each` + version | expected + ${'1'} | ${true} + ${'1.1'} | ${true} + ${'1.1.2'} | ${true} + ${'1.2.0.alpha1'} | ${true} + ${'1.2.0-alpha.1'} | ${true} + ${'= 1'} | ${true} + ${'!= 1.1'} | ${true} + ${'> 1.1.2'} | ${true} + ${'< 1.0.0-beta'} | ${true} + ${'>= 1.0.0.beta'} | ${true} + ${'<= 1.2.0.alpha1'} | ${true} + ${'~> 1.2.0-alpha.1'} | ${true} + ${'>= 3.0.5, < 3.2'} | ${true} + ${'+ 1'} | ${false} + ${'- 1.1'} | ${false} + ${'=== 1.1.2'} | ${false} + ${'! 1.0.0-beta'} | ${false} + ${'& 1.0.0.beta'} | ${false} + `('isValid("$version") === $expected', ({ version, expected }) => { + expect(!!semverRuby.isValid(version)).toBe(expected); }); - describe('.matches', () => { - it('returns true when version match range', () => { - expect(semverRuby.matches('1.2', '>= 1.2')).toBe(true); - expect(semverRuby.matches('1.2.3', '~> 1.2.1')).toBe(true); - expect(semverRuby.matches('1.2.7', '1.2.7')).toBe(true); - expect(semverRuby.matches('1.1.6', '>= 1.1.5, < 2.0')).toBe(true); - }); - - it('returns false when version not match range', () => { - expect(semverRuby.matches('1.2', '>= 1.3')).toBe(false); - expect(semverRuby.matches('1.3.8', '~> 1.2.1')).toBe(false); - expect(semverRuby.matches('1.3.9', '1.3.8')).toBe(false); - expect(semverRuby.matches('2.0.0', '>= 1.1.5, < 2.0')).toBe(false); - }); + test.each` + version | expected + ${'1'} | ${true} + ${'1.2'} | ${true} + ${'1.2.1'} | ${true} + ${'=1'} | ${true} + ${'=1.2'} | ${true} + ${'=1.2.1'} | ${true} + ${'= 1'} | ${true} + ${'= 1.2'} | ${true} + ${'= 1.2.1'} | ${true} + ${'1.2.1.rc1'} | ${true} + ${'1.2.1-rc.1'} | ${true} + ${'= 1.2.0.alpha'} | ${true} + ${'= 1.2.0-alpha'} | ${true} + ${'!= 1'} | ${false} + ${'> 1.2'} | ${false} + ${'< 1.2.1'} | ${false} + ${'>= 1'} | ${false} + ${'<= 1.2'} | ${false} + ${'~> 1.2.1'} | ${false} + ${undefined} | ${false} + ${''} | ${false} + ${null} | ${false} + ${'tottally-not-a-version'} | ${false} + `('isSingleVersion("$version") === $expected', ({ version, expected }) => { + expect(!!semverRuby.isSingleVersion(version)).toBe(expected); }); - describe('.isLessThanRange', () => { - it('returns true when version less than range', () => { - expect(semverRuby.isLessThanRange('1.2.2', '< 1.2.2')).toBe(true); - expect(semverRuby.isLessThanRange('1.1.4', '>= 1.1.5, < 2.0')).toBe(true); - expect(semverRuby.isLessThanRange('1.2.0-alpha', '1.2.0-beta')).toBe( - true - ); - expect(semverRuby.isLessThanRange('1.2.2', '> 1.2.2, ~> 2.0.0')).toBe( - true - ); - }); - - it('returns false when version greater or satisfies range', () => { - expect(semverRuby.isLessThanRange('1.2.2', '<= 1.2.2')).toBe(false); - expect(semverRuby.isLessThanRange('2.0.0', '>= 1.1.5, < 2.0')).toBe( - false - ); - expect(semverRuby.isLessThanRange('1.2.0-beta', '1.2.0-alpha')).toBe( - false - ); - expect(semverRuby.isLessThanRange('2.0.0', '> 1.2.2, ~> 2.0.0')).toBe( - false - ); - }); - - it('returns null for garbage version input', () => { - expect( - semverRuby.isLessThanRange('asdf', '> 1.2.2, ~> 2.0.0') - ).toBeNull(); - expect( - semverRuby.isLessThanRange(null as string, '> 1.2.2, ~> 2.0.0') - ).toBeNull(); - }); - }); - - describe('.isValid', () => { - it('returns true when version is valid', () => { - expect(semverRuby.isValid('1')).toBe(true); - expect(semverRuby.isValid('1.1')).toBe(true); - expect(semverRuby.isValid('1.1.2')).toBe(true); - expect(semverRuby.isValid('1.2.0.alpha1')).toBe(true); - expect(semverRuby.isValid('1.2.0-alpha.1')).toBe(true); - - expect(semverRuby.isValid('= 1')).toBe(true); - expect(semverRuby.isValid('!= 1.1')).toBe(true); - expect(semverRuby.isValid('> 1.1.2')).toBe(true); - expect(semverRuby.isValid('< 1.0.0-beta')).toBe(true); - expect(semverRuby.isValid('>= 1.0.0.beta')).toBe(true); - expect(semverRuby.isValid('<= 1.2.0.alpha1')).toBe(true); - expect(semverRuby.isValid('~> 1.2.0-alpha.1')).toBe(true); - }); - - it('returns true when range is valid', () => { - expect(semverRuby.isValid('>= 3.0.5, < 3.2')).toBe(true); - }); - - it('returns false when version is invalid', () => { - expect(semverRuby.isVersion(undefined)).toBe(false); - expect(semverRuby.isVersion('')).toBe(false); - expect(semverRuby.isVersion(null)).toBe(false); - expect(semverRuby.isVersion('tottally-not-a-version')).toBe(false); - - expect(semverRuby.isValid('+ 1')).toBe(false); - expect(semverRuby.isValid('- 1.1')).toBe(false); - expect(semverRuby.isValid('=== 1.1.2')).toBe(false); - expect(semverRuby.isValid('! 1.0.0-beta')).toBe(false); - expect(semverRuby.isValid('& 1.0.0.beta')).toBe(false); - }); - }); - - describe('.isSingleVersion', () => { - it('returns true when version is single', () => { - expect(semverRuby.isSingleVersion('1')).toBe(true); - expect(semverRuby.isSingleVersion('1.2')).toBe(true); - expect(semverRuby.isSingleVersion('1.2.1')).toBe(true); - - expect(semverRuby.isSingleVersion('=1')).toBe(true); - expect(semverRuby.isSingleVersion('=1.2')).toBe(true); - expect(semverRuby.isSingleVersion('=1.2.1')).toBe(true); - - expect(semverRuby.isSingleVersion('= 1')).toBe(true); - expect(semverRuby.isSingleVersion('= 1.2')).toBe(true); - expect(semverRuby.isSingleVersion('= 1.2.1')).toBe(true); - - expect(semverRuby.isSingleVersion('1.2.1.rc1')).toBe(true); - expect(semverRuby.isSingleVersion('1.2.1-rc.1')).toBe(true); - - expect(semverRuby.isSingleVersion('= 1.2.0.alpha')).toBe(true); - expect(semverRuby.isSingleVersion('= 1.2.0-alpha')).toBe(true); - }); - - it('returns false when version is multiple', () => { - expect(semverRuby.isSingleVersion('!= 1')).toBe(false); - expect(semverRuby.isSingleVersion('> 1.2')).toBe(false); - expect(semverRuby.isSingleVersion('< 1.2.1')).toBe(false); - expect(semverRuby.isSingleVersion('>= 1')).toBe(false); - expect(semverRuby.isSingleVersion('<= 1.2')).toBe(false); - expect(semverRuby.isSingleVersion('~> 1.2.1')).toBe(false); - }); - - it('returns false when version is invalid', () => { - expect(semverRuby.isSingleVersion(undefined)).toBe(false); - expect(semverRuby.isSingleVersion('')).toBe(false); - expect(semverRuby.isSingleVersion(null)).toBe(false); - expect(semverRuby.isSingleVersion('tottally-not-a-version')).toBe(false); - }); - }); - - describe('.getNewValue', () => { - it('returns correct version for pin strategy', () => { - [ - ['1.2.3', '1.0.3', 'pin', '1.0.3', '1.2.3'], - ['v1.2.3', 'v1.0.3', 'pin', '1.0.3', '1.2.3'], - ['= 1.2.3', '= 1.0.3', 'pin', '1.0.3', '1.2.3'], - ['1.2.3', '!= 1.0.3', 'pin', '1.0.4', '1.2.3'], - ['1.2.3', '> 1.0.3', 'pin', '1.0.4', '1.2.3'], - ['1.2.3', '< 1.0.3', 'pin', '1.0.2', '1.2.3'], - ['1.2.3', '>= 1.0.3', 'pin', '1.0.4', '1.2.3'], - ['1.2.3', '<= 1.0.3', 'pin', '1.0.3', '1.2.3'], - ['1.2.3', '~> 1.0.3', 'pin', '1.0.4', '1.2.3'], - ['4.7.8', '~> 4.7, >= 4.7.4', 'pin', '4.7.5', '4.7.8'], - [ - "'>= 3.0.5', '< 3.3'", - "'>= 3.0.5', '< 3.2'", - 'replace', - '3.1.5', - '3.2.1', - ], - ["'0.0.11'", "'0.0.10'", 'auto', '0.0.10', '0.0.11'], - ["'0.0.11'", "'0.0.10'", 'replace', '0.0.10', '0.0.11'], - ].forEach( - ([ - expected, - currentValue, - rangeStrategy, - currentVersion, - newVersion, - ]) => { - expect( - semverRuby.getNewValue({ - currentValue, - rangeStrategy: rangeStrategy as RangeStrategy, - currentVersion, - newVersion, - }) - ).toEqual(expected); - } - ); - }); - - it('returns correct version for bump strategy', () => { - [ - ['1.2.3', '1.0.3', 'bump', '1.0.3', '1.2.3'], - ['v1.2.3', 'v1.0.3', 'bump', '1.0.3', '1.2.3'], - ['= 1.2.3', '= 1.0.3', 'bump', '1.0.3', '1.2.3'], - ['!= 1.0.3', '!= 1.0.3', 'bump', '1.0.0', '1.2.3'], - ['> 1.2.2', '> 1.0.3', 'bump', '1.0.4', '1.2.3'], - ['> 1.2.3', '> 1.2.3', 'bump', '1.0.0', '1.0.3'], - ['< 1.2.4', '< 1.0.3', 'bump', '1.0.0', '1.2.3'], - ['< 1.2.3', '< 1.2.3', 'bump', '1.0.0', '1.0.3'], - ['< 1.2.4', '< 1.2.2', 'bump', '1.0.0', '1.2.3'], - ['< 1.2.4', '< 1.2.3', 'bump', '1.0.0', '1.2.3'], - ['< 1.3', '< 1.2', 'bump', '1.0.0', '1.2.3'], - ['< 2', '< 1', 'bump', '0.9.0', '1.2.3'], - ['>= 1.2.3', '>= 1.0.3', 'bump', '1.0.3', '1.2.3'], - ['<= 1.2.3', '<= 1.0.3', 'bump', '1.0.3', '1.2.3'], - ['~> 1.2.0', '~> 1.0.3', 'bump', '1.0.3', '1.2.3'], - ['~> 1.0.0', '~> 1.0.3', 'bump', '1.0.3', '1.0.4'], - ['~> 4.7.0, >= 4.7.9', '~> 4.7, >= 4.7.4', 'bump', '4.7.5', '4.7.9'], - ].forEach(([expected, currentValue, rangeStrategy, from, newVersion]) => { - expect( - semverRuby.getNewValue({ - currentValue, - rangeStrategy: rangeStrategy as RangeStrategy, - newVersion, - }) - ).toEqual(expected); - }); - }); - - it('does not error', () => { - // FIXME: explicit assert condition - expect( - semverRuby.getNewValue({ - currentValue: '>= 3.2, < 5.0', - rangeStrategy: 'replace', - currentVersion: '4.0.2', - newVersion: '6.0.1', - }) - ).toMatchSnapshot(); - }); - it('handles updates to bundler common complex ranges major', () => { - expect( - semverRuby.getNewValue({ - currentValue: '~> 5.2, >= 5.2.5', - rangeStrategy: 'replace', - currentVersion: '5.3.0', - newVersion: '6.0.1', - }) - ).toEqual('~> 6.0, >= 6.0.1'); - }); - it('handles updates to bundler common complex ranges minor', () => { + test.each` + currentValue | rangeStrategy | currentVersion | newVersion | expected + ${'1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'1.2.3'} + ${'v1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'v1.2.3'} + ${'= 1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'= 1.2.3'} + ${'!= 1.0.3'} | ${'pin'} | ${'1.0.4'} | ${'1.2.3'} | ${'1.2.3'} + ${'> 1.0.3'} | ${'pin'} | ${'1.0.4'} | ${'1.2.3'} | ${'1.2.3'} + ${'< 1.0.3'} | ${'pin'} | ${'1.0.2'} | ${'1.2.3'} | ${'1.2.3'} + ${'>= 1.0.3'} | ${'pin'} | ${'1.0.4'} | ${'1.2.3'} | ${'1.2.3'} + ${'<= 1.0.3'} | ${'pin'} | ${'1.0.3'} | ${'1.2.3'} | ${'1.2.3'} + ${'~> 1.0.3'} | ${'pin'} | ${'1.0.4'} | ${'1.2.3'} | ${'1.2.3'} + ${'~> 4.7, >= 4.7.4'} | ${'pin'} | ${'4.7.5'} | ${'4.7.8'} | ${'4.7.8'} + ${"'>= 3.0.5', '< 3.2'"} | ${'replace'} | ${'3.1.5'} | ${'3.2.1'} | ${"'>= 3.0.5', '< 3.3'"} + ${"'0.0.10'"} | ${'auto'} | ${'0.0.10'} | ${'0.0.11'} | ${"'0.0.11'"} + ${"'0.0.10'"} | ${'replace'} | ${'0.0.10'} | ${'0.0.11'} | ${"'0.0.11'"} + ${'1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'1.2.3'} + ${'v1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'v1.2.3'} + ${'= 1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'= 1.2.3'} + ${'!= 1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'!= 1.0.3'} + ${'> 1.0.3'} | ${'bump'} | ${'1.0.4'} | ${'1.2.3'} | ${'> 1.2.2'} + ${'> 1.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.0.3'} | ${'> 1.2.3'} + ${'< 1.0.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.0.3'} | ${'< 1.2.3'} + ${'< 1.2.2'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2.3'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2'} | ${'bump'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.3'} + ${'< 1'} | ${'bump'} | ${'0.9.0'} | ${'1.2.3'} | ${'< 2'} + ${'>= 1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'>= 1.2.3'} + ${'<= 1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'<= 1.2.3'} + ${'~> 1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.2.3'} | ${'~> 1.2.0'} + ${'~> 1.0.3'} | ${'bump'} | ${'1.0.3'} | ${'1.0.4'} | ${'~> 1.0.0'} + ${'~> 4.7, >= 4.7.4'} | ${'bump'} | ${'4.7.5'} | ${'4.7.9'} | ${'~> 4.7.0, >= 4.7.9'} + ${'>= 3.2, < 5.0'} | ${'replace'} | ${'4.0.2'} | ${'6.0.1'} | ${'>= 3.2, < 6.0.2'} + ${'~> 5.2, >= 5.2.5'} | ${'replace'} | ${'5.3.0'} | ${'6.0.1'} | ${'~> 6.0, >= 6.0.1'} + ${'~> 5.2.0, >= 5.2.5'} | ${'replace'} | ${'5.2.5'} | ${'5.3.1'} | ${'~> 5.3.0, >= 5.3.1'} + ${'4.2.0'} | ${'replace'} | ${'4.2.0'} | ${'4.2.5.1'} | ${'4.2.5.1'} + ${'4.2.5.1'} | ${'replace'} | ${'0.1'} | ${'4.3.0'} | ${'4.3.0'} + ${'~> 1'} | ${'replace'} | ${'1.2.0'} | ${'2.0.3'} | ${'~> 2'} + ${'= 5.2.2'} | ${'replace'} | ${'5.2.2'} | ${'5.2.2.1'} | ${'= 5.2.2.1'} + ${'1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.3'} | ${'1.2.3'} + ${'v1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.3'} | ${'v1.2.3'} + ${'= 1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.3'} | ${'= 1.2.3'} + ${'!= 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'!= 1.0.3'} + ${'< 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2.2'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.2.4'} + ${'< 1.2'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'< 1.3'} + ${'< 1'} | ${'replace'} | ${'0.9.0'} | ${'1.2.3'} | ${'< 2'} + ${'< 1.2.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.2'} | ${'< 1.2.3'} + ${'>= 1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.3'} | ${'>= 1.0.3'} + ${'<= 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'<= 1.2.3'} + ${'<= 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.0.2'} | ${'<= 1.0.3'} + ${'~> 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.2.3'} | ${'~> 1.2.0'} + ${'~> 1.0.3'} | ${'replace'} | ${'1.0.0'} | ${'1.0.4'} | ${'~> 1.0.3'} + ${'~> 4.7, >= 4.7.4'} | ${'replace'} | ${'1.0.0'} | ${'4.7.9'} | ${'~> 4.7, >= 4.7.4'} + ${'>= 2.0.0, <= 2.15'} | ${'replace'} | ${'2.15.0'} | ${'2.20.1'} | ${'>= 2.0.0, <= 2.20.1'} + ${'~> 5.2.0'} | ${'replace'} | ${'5.2.4.1'} | ${'6.0.2.1'} | ${'~> 6.0.0'} + ${'~> 4.0, < 5'} | ${'replace'} | ${'4.7.5'} | ${'5.0.0'} | ${'~> 5.0, < 6'} + ${'~> 4.0, < 5'} | ${'replace'} | ${'4.7.5'} | ${'5.0.1'} | ${'~> 5.0, < 6'} + ${'~> 4.0, < 5'} | ${'replace'} | ${'4.7.5'} | ${'5.1.0'} | ${'~> 5.1, < 6'} + ${'< 1.0.3'} | ${'auto'} | ${'1.0.3'} | ${'1.2.4'} | ${'< 1.2.5'} + ${'< 1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.4'} | ${'< 1.2.5'} + ${'< 1.0.3'} | ${'widen'} | ${'1.0.3'} | ${'1.2.4'} | ${'< 1.2.5'} + ${'< 1.0.3'} | ${'replace'} | ${'1.0.3'} | ${'1.2.4'} | ${'< 1.2.5'} + ${'~> 6.0.0'} | ${'update-lockfile'} | ${'6.0.2'} | ${'6.0.3'} | ${'~> 6.0.0'} + ${'~> 6.0.0'} | ${'update-lockfile'} | ${'6.0.2'} | ${'7.0.0'} | ${'~> 7.0.0'} + `( + 'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"', + ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => { expect( semverRuby.getNewValue({ - currentValue: '~> 5.2.0, >= 5.2.5', - rangeStrategy: 'replace', - currentVersion: '5.2.5', - newVersion: '5.3.1', - }) - ).toEqual('~> 5.3.0, >= 5.3.1'); - }); - it('handles change in precision', () => { - expect( - semverRuby.getNewValue({ - currentValue: '4.2.0', - rangeStrategy: 'replace', - currentVersion: '4.2.0', - newVersion: '4.2.5.1', - }) - ).toEqual('4.2.5.1'); - expect( - semverRuby.getNewValue({ - currentValue: '4.2.5.1', - rangeStrategy: 'replace', - currentVersion: '4.2.5.1', - newVersion: '4.3.0', - }) - ).toEqual('4.3.0'); - }); - it('handles major ranges', () => { - expect( - semverRuby.getNewValue({ - currentValue: '~> 1', - rangeStrategy: 'replace', - currentVersion: '1.2.0', - newVersion: '2.0.3', - }) - ).toEqual('~> 2'); - }); - it('handles explicit equals', () => { - expect( - semverRuby.getNewValue({ - currentValue: '= 5.2.2', - rangeStrategy: 'replace', - currentVersion: '5.2.2', - newVersion: '5.2.2.1', - }) - ).toEqual('= 5.2.2.1'); - }); - - it('returns correct version for replace strategy', () => { - [ - ['1.2.3', '1.0.3', 'replace', '1.0.3', '1.2.3'], - ['v1.2.3', 'v1.0.3', 'replace', '1.0.3', '1.2.3'], - ['= 1.2.3', '= 1.0.3', 'replace', '1.0.3', '1.2.3'], - ['!= 1.0.3', '!= 1.0.3', 'replace', '1.0.0', '1.2.3'], - ['< 1.2.4', '< 1.0.3', 'replace', '1.0.0', '1.2.3'], - ['< 1.2.4', '< 1.2.2', 'replace', '1.0.0', '1.2.3'], - ['< 1.2.4', '< 1.2.3', 'replace', '1.0.0', '1.2.3'], - ['< 1.3', '< 1.2', 'replace', '1.0.0', '1.2.3'], - ['< 2', '< 1', 'replace', '0.9.0', '1.2.3'], - ['< 1.2.3', '< 1.2.3', 'replace', '1.0.0', '1.2.2'], - ['>= 1.0.3', '>= 1.0.3', 'replace', '1.0.3', '1.2.3'], - ['<= 1.2.3', '<= 1.0.3', 'replace', '1.0.0', '1.2.3'], - ['<= 1.0.3', '<= 1.0.3', 'replace', '1.0.0', '1.0.2'], - ['~> 1.2.0', '~> 1.0.3', 'replace', '1.0.0', '1.2.3'], - ['~> 1.0.3', '~> 1.0.3', 'replace', '1.0.0', '1.0.4'], - ['~> 4.7, >= 4.7.4', '~> 4.7, >= 4.7.4', 'replace', '1.0.0', '4.7.9'], - [ - '>= 2.0.0, <= 2.20.1', - '>= 2.0.0, <= 2.15', - 'replace', - '2.15.0', - '2.20.1', - ], - ['~> 6.0.0', '~> 5.2.0', 'replace', '5.2.4.1', '6.0.2.1'], - ['~> 5.0, < 6', '~> 4.0, < 5', 'replace', '4.7.5', '5.0.0'], - ['~> 5.0, < 6', '~> 4.0, < 5', 'replace', '4.7.5', '5.0.1'], - ['~> 5.1, < 6', '~> 4.0, < 5', 'replace', '4.7.5', '5.1.0'], // ideally this should be ~> 5.0 - ].forEach( - ([ - expected, currentValue, rangeStrategy, currentVersion, newVersion, - ]) => { - expect( - semverRuby.getNewValue({ - currentValue, - rangeStrategy: rangeStrategy as RangeStrategy, - currentVersion, - newVersion, - }) - ).toEqual(expected); - } - ); - }); - - it('falls back to "replace" from "auto" and "widen" strategies', () => { - [ - ['< 1.2.5', '< 1.0.3', 'auto', '1.0.3', '1.2.4'], - ['< 1.2.5', '< 1.0.3', 'widen', '1.0.3', '1.2.4'], - ].forEach( - ([ - expected, - currentValue, - rangeStrategy, - currentVersion, - newVersion, - ]) => { - const res = semverRuby.getNewValue({ - currentValue, - rangeStrategy: rangeStrategy as RangeStrategy, - currentVersion, - newVersion, - }); - const fallbackRes = semverRuby.getNewValue({ - currentValue, - rangeStrategy: 'replace', - currentVersion, - newVersion, - }); - expect(res).toEqual(expected); - expect(res).toEqual(fallbackRes); - } - ); - }); - it('returns correct version for update-lockfile strategy', () => { - [ - ['~> 6.0.0', '~> 6.0.0', 'update-lockfile', '6.0.2', '6.0.3'], - ['~> 7.0.0', '~> 6.0.0', 'update-lockfile', '6.0.2', '7.0.0'], - ].forEach( - ([ - expected, - currentValue, - rangeStrategy, - currentVersion, - newVersion, - ]) => { - expect( - semverRuby.getNewValue({ - currentValue, - rangeStrategy: rangeStrategy as RangeStrategy, - currentVersion, - newVersion, - }) - ).toEqual(expected); - } - ); - }); - }); + }) + ).toBe(expected); + } + ); }); diff --git a/lib/versioning/semver/index.spec.ts b/lib/versioning/semver/index.spec.ts index eacb76892ff2cf..5a3c3ff65fd18f 100644 --- a/lib/versioning/semver/index.spec.ts +++ b/lib/versioning/semver/index.spec.ts @@ -1,55 +1,46 @@ import semver from '.'; describe('versioning/semver/index', () => { - describe('semver.isValid(input)', () => { - it('should return null for irregular versions', () => { - expect(semver.isValid('17.04.0')).toBeFalsy(); - }); - it('should support simple semver', () => { - expect(semver.isValid('1.2.3')).toBeTruthy(); - }); - it('should support semver with dash', () => { - expect(semver.isValid('1.2.3-foo')).toBeTruthy(); - }); - it('should reject semver without dash', () => { - expect(semver.isValid('1.2.3foo')).toBeFalsy(); - }); - it('should reject ranges', () => { - expect(semver.isValid('~1.2.3')).toBeFalsy(); - expect(semver.isValid('^1.2.3')).toBeFalsy(); - expect(semver.isValid('>1.2.3')).toBeFalsy(); - }); - it('should reject github repositories', () => { - expect(semver.isValid('renovatebot/renovate')).toBeFalsy(); - expect(semver.isValid('renovatebot/renovate#master')).toBeFalsy(); - expect( - semver.isValid('https://github.com/renovatebot/renovate.git') - ).toBeFalsy(); - }); + test.each` + version | expected + ${'17.04.0'} | ${false} + ${'1.2.3'} | ${true} + ${'1.2.3-foo'} | ${true} + ${'1.2.3foo'} | ${false} + ${'~1.2.3'} | ${false} + ${'^1.2.3'} | ${false} + ${'>1.2.3'} | ${false} + ${'renovatebot/renovate'} | ${false} + ${'renovatebot/renovate#master'} | ${false} + ${'https://github.com/renovatebot/renovate.git'} | ${false} + `('isValid("$version") === $expected', ({ version, expected }) => { + expect(!!semver.isValid(version)).toBe(expected); }); - describe('semver.isSingleVersion()', () => { - it('returns true if naked version', () => { - expect(semver.isSingleVersion('1.2.3')).toBeTruthy(); - expect(semver.isSingleVersion('1.2.3-alpha.1')).toBeTruthy(); - }); - it('returns false if equals', () => { - expect(semver.isSingleVersion('=1.2.3')).toBeFalsy(); - expect(semver.isSingleVersion('= 1.2.3')).toBeFalsy(); - }); - it('returns false when not version', () => { - expect(semver.isSingleVersion('1.x')).toBeFalsy(); - }); - }); - describe('semver.getNewValue()', () => { - it('uses newVersion', () => { - expect( - semver.getNewValue({ - currentValue: '=1.0.0', - rangeStrategy: 'bump', - currentVersion: '1.0.0', - newVersion: '1.1.0', - }) - ).toEqual('1.1.0'); - }); + + test.each` + version | expected + ${'1.2.3'} | ${true} + ${'1.2.3-alpha.1'} | ${true} + ${'=1.2.3'} | ${false} + ${'= 1.2.3'} | ${false} + ${'1.x'} | ${false} + `('isSingleVersion("$version") === $expected', ({ version, expected }) => { + expect(!!semver.isSingleVersion(version)).toBe(expected); }); + + test.each` + currentValue | rangeStrategy | currentVersion | newVersion | expected + ${'=1.0.0'} | ${'bump'} | ${'1.0.0'} | ${'1.1.0'} | ${'1.1.0'} + `( + 'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"', + ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => { + const res = semver.getNewValue({ + currentValue, + rangeStrategy, + currentVersion, + newVersion, + }); + expect(res).toEqual(expected); + } + ); }); diff --git a/lib/versioning/swift/index.spec.ts b/lib/versioning/swift/index.spec.ts index f5503a2e21022a..9bc5a45d99308b 100644 --- a/lib/versioning/swift/index.spec.ts +++ b/lib/versioning/swift/index.spec.ts @@ -1,4 +1,3 @@ -import type { RangeStrategy } from '../../types'; import swift from '.'; const { @@ -12,105 +11,120 @@ const { } = swift; describe('versioning/swift/index', () => { - describe('isValid(input)', () => { - it('supports isVersion', () => { - expect(isVersion('from: "1.2.3"')).toBe(false); - expect(isVersion('1.2.3')).toBe(true); - }); - it('understands Swift version ranges', () => { - expect(isValid('from: "1.2.3"')).toBe(true); - expect(isValid('from : "1.2.3"')).toBe(true); - expect(isValid('from:"1.2.3"')).toBe(true); - expect(isValid(' from:"1.2.3" ')).toBe(true); - expect(isValid(' from : "1.2.3" ')).toBe(true); + test.each` + version | expected + ${'from: "1.2.3"'} | ${false} + ${'1.2.3'} | ${true} + `('isVersion("$version") === $expected', ({ version, expected }) => { + expect(!!isVersion(version)).toBe(expected); + }); - expect(isValid('"1.2.3"..."1.2.4"')).toBe(true); - expect(isValid(' "1.2.3" ... "1.2.4" ')).toBe(true); + test.each` + version | expected + ${'from: "1.2.3"'} | ${true} + ${'from : "1.2.3"'} | ${true} + ${'from:"1.2.3"'} | ${true} + ${' from:"1.2.3" '} | ${true} + ${' from : "1.2.3" '} | ${true} + ${'"1.2.3"..."1.2.4"'} | ${true} + ${' "1.2.3" ... "1.2.4" '} | ${true} + ${'"1.2.3"...'} | ${true} + ${' "1.2.3" ... '} | ${true} + ${'..."1.2.4"'} | ${true} + ${' ... "1.2.4" '} | ${true} + ${'"1.2.3"..<"1.2.4"'} | ${true} + ${' "1.2.3" ..< "1.2.4" '} | ${true} + ${'..<"1.2.4"'} | ${true} + ${' ..< "1.2.4" '} | ${true} + ${'17.04.0'} | ${false} + ${'1.2.3'} | ${true} + ${'v1.2.3'} | ${true} + ${'1.2.3-foo'} | ${true} + ${'1.2.3foo'} | ${false} + ${'~1.2.3'} | ${false} + ${'^1.2.3'} | ${false} + ${'from: "1.2.3"'} | ${true} + ${'"1.2.3"..."1.2.4"'} | ${true} + ${'"1.2.3"..."1.2.4"'} | ${true} + ${'"1.2.3"..<"1.2.4"'} | ${true} + ${'"1.2.3"..<"1.2.4"'} | ${true} + ${'..."1.2.3"'} | ${true} + ${'..<"1.2.4"'} | ${true} + `('isValid("$version") === $expected', ({ version, expected }) => { + expect(!!isValid(version)).toBe(expected); + }); - expect(isValid('"1.2.3"...')).toBe(true); - expect(isValid(' "1.2.3" ... ')).toBe(true); + test.each` + versions | range | expected + ${['1.2.3', '1.2.4', '1.2.5']} | ${'..<"1.2.4"'} | ${'1.2.3'} + ${['v1.2.3', 'v1.2.4', 'v1.2.5']} | ${'..<"1.2.4"'} | ${'1.2.3'} + `( + 'minSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(minSatisfyingVersion(versions, range)).toBe(expected); + } + ); - expect(isValid('..."1.2.4"')).toBe(true); - expect(isValid(' ... "1.2.4" ')).toBe(true); + test.each` + versions | range | expected + ${['1.2.3', '1.2.4', '1.2.5']} | ${'..<"1.2.4"'} | ${'1.2.3'} + ${['v1.2.3', 'v1.2.4', 'v1.2.5']} | ${'..<"1.2.4"'} | ${'1.2.3'} + ${['1.2.3', '1.2.4', '1.2.5']} | ${'..."1.2.4"'} | ${'1.2.4'} + `( + 'getSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(getSatisfyingVersion(versions, range)).toBe(expected); + } + ); - expect(isValid('"1.2.3"..<"1.2.4"')).toBe(true); - expect(isValid(' "1.2.3" ..< "1.2.4" ')).toBe(true); + test.each` + version | range | expected + ${'1.2.3'} | ${'..."1.2.4"'} | ${false} + ${'v1.2.3'} | ${'..."1.2.4"'} | ${false} + ${'1.2.3'} | ${'"1.2.4"...'} | ${true} + ${'v1.2.3'} | ${'"1.2.4"...'} | ${true} + `( + 'isLessThanRange("$version", "$range") === "$expected"', + ({ version, range, expected }) => { + expect(isLessThanRange(version, range)).toBe(expected); + } + ); - expect(isValid('..<"1.2.4"')).toBe(true); - expect(isValid(' ..< "1.2.4" ')).toBe(true); - }); - it('should return null for irregular versions', () => { - expect(isValid('17.04.0')).toBeFalsy(); - }); - it('should support simple semver', () => { - expect(isValid('1.2.3')).toBe(true); - expect(isValid('v1.2.3')).toBe(true); - }); - it('should support semver with dash', () => { - expect(isValid('1.2.3-foo')).toBe(true); - }); - it('should reject semver without dash', () => { - expect(isValid('1.2.3foo')).toBeFalsy(); - }); - it('should support ranges', () => { - expect(isValid('~1.2.3')).toBeFalsy(); - expect(isValid('^1.2.3')).toBeFalsy(); - expect(isValid('from: "1.2.3"')).toBe(true); - expect(isValid('"1.2.3"..."1.2.4"')).toBe(true); - expect(isValid('"1.2.3"..."1.2.4"')).toBe(true); - expect(isValid('"1.2.3"..<"1.2.4"')).toBe(true); - expect(isValid('"1.2.3"..<"1.2.4"')).toBe(true); - expect(isValid('..."1.2.3"')).toBe(true); - expect(isValid('..<"1.2.4"')).toBe(true); - expect( - minSatisfyingVersion(['1.2.3', '1.2.4', '1.2.5'], '..<"1.2.4"') - ).toBe('1.2.3'); - expect( - minSatisfyingVersion(['v1.2.3', 'v1.2.4', 'v1.2.5'], '..<"1.2.4"') - ).toBe('1.2.3'); - expect( - getSatisfyingVersion(['1.2.3', '1.2.4', '1.2.5'], '..<"1.2.4"') - ).toBe('1.2.3'); - expect( - getSatisfyingVersion(['v1.2.3', 'v1.2.4', 'v1.2.5'], '..<"1.2.4"') - ).toBe('1.2.3'); - expect( - getSatisfyingVersion(['1.2.3', '1.2.4', '1.2.5'], '..."1.2.4"') - ).toBe('1.2.4'); - expect(isLessThanRange('1.2.3', '..."1.2.4"')).toBe(false); - expect(isLessThanRange('v1.2.3', '..."1.2.4"')).toBe(false); - expect(isLessThanRange('1.2.3', '"1.2.4"...')).toBe(true); - expect(isLessThanRange('v1.2.3', '"1.2.4"...')).toBe(true); + test.each` + version | range | expected + ${'1.2.4'} | ${'..."1.2.4"'} | ${true} + ${'v1.2.4'} | ${'..."1.2.4"'} | ${true} + ${'1.2.4'} | ${'..."1.2.3"'} | ${false} + ${'v1.2.4'} | ${'..."1.2.3"'} | ${false} + `( + 'matches("$version", "$range") === "$expected"', + ({ version, range, expected }) => { + expect(matches(version, range)).toBe(expected); + } + ); - expect(matches('1.2.4', '..."1.2.4"')).toBe(true); - expect(matches('v1.2.4', '..."1.2.4"')).toBe(true); - expect(matches('1.2.4', '..."1.2.3"')).toBe(false); - expect(matches('v1.2.4', '..."1.2.3"')).toBe(false); - }); - }); - describe('getNewValue()', () => { - it('supports range update', () => { - [ - ['1.2.3', 'auto', '1.2.3', '1.2.4', '1.2.3'], - ['v1.2.3', 'auto', 'v1.2.3', 'v1.2.4', 'v1.2.3'], - ['from: "1.2.3"', 'auto', '1.2.3', '1.2.4', 'from: "1.2.4"'], - ['from: "1.2.2"', 'auto', '1.2.3', '1.2.4', 'from: "1.2.4"'], - ['"1.2.3"...', 'auto', '1.2.3', '1.2.4', '"1.2.4"...'], - ['"1.2.3"..."1.2.4"', 'auto', '1.2.3', '1.2.5', '"1.2.3"..."1.2.5"'], - ['"1.2.3"..<"1.2.4"', 'auto', '1.2.3', '1.2.5', '"1.2.3"..<"1.2.5"'], - ['..."1.2.4"', 'auto', '1.2.3', '1.2.5', '..."1.2.5"'], - ['..<"1.2.4"', 'auto', '1.2.3', '1.2.5', '..<"1.2.5"'], - ].forEach( - ([range, rangeStrategy, currentVersion, newVersion, result]) => { - const newValue = getNewValue({ - currentValue: range, - rangeStrategy: rangeStrategy as RangeStrategy, - currentVersion, - newVersion, - }); - expect(newValue).toEqual(result); - } - ); - }); - }); + test.each` + currentValue | rangeStrategy | currentVersion | newVersion | expected + ${'1.2.3'} | ${'auto'} | ${'1.2.3'} | ${'1.2.4'} | ${'1.2.3'} + ${'v1.2.3'} | ${'auto'} | ${'v1.2.3'} | ${'v1.2.4'} | ${'v1.2.3'} + ${'from: "1.2.3"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.4'} | ${'from: "1.2.4"'} + ${'from: "1.2.2"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.4'} | ${'from: "1.2.4"'} + ${'"1.2.3"...'} | ${'auto'} | ${'1.2.3'} | ${'1.2.4'} | ${'"1.2.4"...'} + ${'"1.2.3"..."1.2.4"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.5'} | ${'"1.2.3"..."1.2.5"'} + ${'"1.2.3"..<"1.2.4"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.5'} | ${'"1.2.3"..<"1.2.5"'} + ${'..."1.2.4"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.5'} | ${'..."1.2.5"'} + ${'..<"1.2.4"'} | ${'auto'} | ${'1.2.3'} | ${'1.2.5'} | ${'..<"1.2.5"'} + `( + 'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"', + ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => { + expect( + getNewValue({ + currentValue, + rangeStrategy, + currentVersion, + newVersion, + }) + ).toBe(expected); + } + ); }); diff --git a/lib/versioning/ubuntu/index.spec.ts b/lib/versioning/ubuntu/index.spec.ts index f9f8d774fa8748..4f7362b4679767 100644 --- a/lib/versioning/ubuntu/index.spec.ts +++ b/lib/versioning/ubuntu/index.spec.ts @@ -1,254 +1,266 @@ import { api as ubuntu } from '.'; describe('versioning/ubuntu/index', () => { - // validation - - it('isValid', () => { - expect(ubuntu.isValid(undefined)).toBe(false); - expect(ubuntu.isValid(null)).toBe(false); - expect(ubuntu.isValid('')).toBe(false); - expect(ubuntu.isValid('xenial')).toBe(false); - - expect(ubuntu.isValid('04.10')).toBe(true); - expect(ubuntu.isValid('05.04')).toBe(true); - expect(ubuntu.isValid('05.10')).toBe(true); - expect(ubuntu.isValid('6.06')).toBe(true); - expect(ubuntu.isValid('6.10')).toBe(true); - expect(ubuntu.isValid('7.04')).toBe(true); - expect(ubuntu.isValid('7.10')).toBe(true); - expect(ubuntu.isValid('8.04')).toBe(true); - expect(ubuntu.isValid('8.10')).toBe(true); - expect(ubuntu.isValid('9.04')).toBe(true); - expect(ubuntu.isValid('9.10')).toBe(true); - expect(ubuntu.isValid('10.04.4')).toBe(true); - expect(ubuntu.isValid('10.10')).toBe(true); - expect(ubuntu.isValid('11.04')).toBe(true); - expect(ubuntu.isValid('11.10')).toBe(true); - expect(ubuntu.isValid('12.04.5')).toBe(true); - expect(ubuntu.isValid('12.10')).toBe(true); - expect(ubuntu.isValid('13.04')).toBe(true); - expect(ubuntu.isValid('13.10')).toBe(true); - expect(ubuntu.isValid('14.04.6')).toBe(true); - expect(ubuntu.isValid('14.10')).toBe(true); - expect(ubuntu.isValid('15.04')).toBe(true); - expect(ubuntu.isValid('15.10')).toBe(true); - expect(ubuntu.isValid('16.04.7')).toBe(true); - expect(ubuntu.isValid('16.10')).toBe(true); - expect(ubuntu.isValid('17.04')).toBe(true); - expect(ubuntu.isValid('17.10')).toBe(true); - expect(ubuntu.isValid('18.04.5')).toBe(true); - expect(ubuntu.isValid('18.10')).toBe(true); - expect(ubuntu.isValid('19.04')).toBe(true); - expect(ubuntu.isValid('19.10')).toBe(true); - expect(ubuntu.isValid('20.04')).toBe(true); - expect(ubuntu.isValid('20.10')).toBe(true); - expect(ubuntu.isValid('2020.04')).toBe(false); + test.each` + version | expected + ${undefined} | ${false} + ${null} | ${false} + ${''} | ${false} + ${'xenial'} | ${false} + ${'04.10'} | ${true} + ${'05.04'} | ${true} + ${'05.10'} | ${true} + ${'6.06'} | ${true} + ${'6.10'} | ${true} + ${'7.04'} | ${true} + ${'7.10'} | ${true} + ${'8.04'} | ${true} + ${'8.10'} | ${true} + ${'9.04'} | ${true} + ${'9.10'} | ${true} + ${'10.04.4'} | ${true} + ${'10.10'} | ${true} + ${'11.04'} | ${true} + ${'11.10'} | ${true} + ${'12.04.5'} | ${true} + ${'12.10'} | ${true} + ${'13.04'} | ${true} + ${'13.10'} | ${true} + ${'14.04.6'} | ${true} + ${'14.10'} | ${true} + ${'15.04'} | ${true} + ${'15.10'} | ${true} + ${'16.04.7'} | ${true} + ${'16.10'} | ${true} + ${'17.04'} | ${true} + ${'17.10'} | ${true} + ${'18.04.5'} | ${true} + ${'18.10'} | ${true} + ${'19.04'} | ${true} + ${'19.10'} | ${true} + ${'20.04'} | ${true} + ${'20.10'} | ${true} + ${'2020.04'} | ${false} + `('isValid("$version") === $expected', ({ version, expected }) => { + expect(!!ubuntu.isValid(version)).toBe(expected); }); - it('isCompatible', () => { - expect(ubuntu.isCompatible(undefined)).toBe(false); - expect(ubuntu.isCompatible(null)).toBe(false); - expect(ubuntu.isCompatible('')).toBe(false); - - expect(ubuntu.isCompatible('04.10')).toBe(true); - expect(ubuntu.isCompatible('20.10')).toBe(true); + test.each` + version | range | expected + ${undefined} | ${undefined} | ${false} + ${null} | ${undefined} | ${false} + ${''} | ${undefined} | ${false} + ${'04.10'} | ${undefined} | ${true} + ${'20.10'} | ${undefined} | ${true} + `( + 'isCompatible("$version") === $expected', + ({ version, range, expected }) => { + const res = ubuntu.isCompatible(version, range); + expect(!!res).toBe(expected); + } + ); + + test.each` + version | expected + ${undefined} | ${false} + ${null} | ${false} + ${''} | ${false} + ${'20.04'} | ${true} + ${'>=20.04'} | ${false} + `('isSingleVersion("$version") === $expected', ({ version, expected }) => { + expect(!!ubuntu.isSingleVersion(version)).toBe(expected); }); - it('isSingleVersion', () => { - expect(ubuntu.isSingleVersion(undefined)).toBeNull(); - expect(ubuntu.isSingleVersion(null)).toBeNull(); - expect(ubuntu.isSingleVersion('')).toBeNull(); - expect(ubuntu.isSingleVersion('20.04')).toBe(true); - expect(ubuntu.isSingleVersion('>=20.04')).toBeNull(); + test.each` + version | expected + ${undefined} | ${false} + ${null} | ${false} + ${''} | ${false} + ${'04.10'} | ${false} + ${'05.04'} | ${false} + ${'05.10'} | ${false} + ${'6.06'} | ${false} + ${'6.10'} | ${false} + ${'7.04'} | ${false} + ${'7.10'} | ${false} + ${'8.04'} | ${true} + ${'8.10'} | ${false} + ${'9.04'} | ${false} + ${'9.10'} | ${false} + ${'10.04.4'} | ${true} + ${'10.10'} | ${false} + ${'11.04'} | ${false} + ${'11.10'} | ${false} + ${'12.04.5'} | ${true} + ${'12.10'} | ${false} + ${'13.04'} | ${false} + ${'13.10'} | ${false} + ${'14.04.6'} | ${true} + ${'14.10'} | ${false} + ${'15.04'} | ${false} + ${'15.10'} | ${false} + ${'16.04.7'} | ${true} + ${'16.10'} | ${false} + ${'17.04'} | ${false} + ${'17.10'} | ${false} + ${'18.04.5'} | ${true} + ${'18.10'} | ${false} + ${'19.04'} | ${false} + ${'19.10'} | ${false} + ${'20.04'} | ${true} + ${'20.10'} | ${false} + ${'42.01'} | ${false} + ${'42.02'} | ${false} + ${'42.03'} | ${false} + ${'42.04'} | ${true} + ${'42.05'} | ${false} + ${'42.06'} | ${false} + ${'42.07'} | ${false} + ${'42.08'} | ${false} + ${'42.09'} | ${false} + ${'42.10'} | ${false} + ${'42.11'} | ${false} + ${'2020.04'} | ${false} + `('isStable("$version") === $expected', ({ version, expected }) => { + const res = !!ubuntu.isStable(version); + expect(res).toBe(expected); }); - it('isStable', () => { - expect(ubuntu.isStable(undefined)).toBe(false); - expect(ubuntu.isStable(null)).toBe(false); - expect(ubuntu.isStable('')).toBe(false); - - expect(ubuntu.isStable('04.10')).toBe(false); - expect(ubuntu.isStable('05.04')).toBe(false); - expect(ubuntu.isStable('05.10')).toBe(false); - expect(ubuntu.isStable('6.06')).toBe(false); // it's okay - expect(ubuntu.isStable('6.10')).toBe(false); - expect(ubuntu.isStable('7.04')).toBe(false); - expect(ubuntu.isStable('7.10')).toBe(false); - expect(ubuntu.isStable('8.04')).toBe(true); - expect(ubuntu.isStable('8.10')).toBe(false); - expect(ubuntu.isStable('9.04')).toBe(false); - expect(ubuntu.isStable('9.10')).toBe(false); - expect(ubuntu.isStable('10.04.4')).toBe(true); - expect(ubuntu.isStable('10.10')).toBe(false); - expect(ubuntu.isStable('11.04')).toBe(false); - expect(ubuntu.isStable('11.10')).toBe(false); - expect(ubuntu.isStable('12.04.5')).toBe(true); - expect(ubuntu.isStable('12.10')).toBe(false); - expect(ubuntu.isStable('13.04')).toBe(false); - expect(ubuntu.isStable('13.10')).toBe(false); - expect(ubuntu.isStable('14.04.6')).toBe(true); - expect(ubuntu.isStable('14.10')).toBe(false); - expect(ubuntu.isStable('15.04')).toBe(false); - expect(ubuntu.isStable('15.10')).toBe(false); - expect(ubuntu.isStable('16.04.7')).toBe(true); - expect(ubuntu.isStable('16.10')).toBe(false); - expect(ubuntu.isStable('17.04')).toBe(false); - expect(ubuntu.isStable('17.10')).toBe(false); - expect(ubuntu.isStable('18.04.5')).toBe(true); - expect(ubuntu.isStable('18.10')).toBe(false); - expect(ubuntu.isStable('19.04')).toBe(false); - expect(ubuntu.isStable('19.10')).toBe(false); - expect(ubuntu.isStable('20.04')).toBe(true); - expect(ubuntu.isStable('20.10')).toBe(false); - - expect(ubuntu.isStable('42.01')).toBe(false); - expect(ubuntu.isStable('42.02')).toBe(false); - expect(ubuntu.isStable('42.03')).toBe(false); - expect(ubuntu.isStable('42.04')).toBe(true); - expect(ubuntu.isStable('42.05')).toBe(false); - expect(ubuntu.isStable('42.06')).toBe(false); - expect(ubuntu.isStable('42.07')).toBe(false); - expect(ubuntu.isStable('42.08')).toBe(false); - expect(ubuntu.isStable('42.09')).toBe(false); - expect(ubuntu.isStable('42.10')).toBe(false); - expect(ubuntu.isStable('42.11')).toBe(false); - - expect(ubuntu.isStable('2020.04')).toBe(false); + test.each` + version | expected + ${undefined} | ${false} + ${null} | ${false} + ${''} | ${false} + ${'02.10'} | ${false} + ${'04.10'} | ${true} + ${'05.04'} | ${true} + ${'6.06'} | ${true} + ${'8.04'} | ${true} + ${'9.04'} | ${true} + ${'10.04.4'} | ${true} + ${'12.04.5'} | ${true} + ${'13.04'} | ${true} + ${'14.04.6'} | ${true} + ${'15.04'} | ${true} + ${'16.04.7'} | ${true} + ${'16.10'} | ${true} + ${'17.04'} | ${true} + ${'18.04.5'} | ${true} + ${'18.10'} | ${true} + ${'20.04'} | ${true} + ${'20.10'} | ${true} + ${'30.11'} | ${true} + ${'2020.04'} | ${false} + `('isVersion("$version") === $expected', ({ version, expected }) => { + expect(!!ubuntu.isVersion(version)).toBe(expected); }); - it('isVersion', () => { - expect(ubuntu.isVersion(undefined)).toBe(false); - expect(ubuntu.isVersion(null)).toBe(false); - expect(ubuntu.isVersion('')).toBe(false); - - expect(ubuntu.isVersion('02.10')).toBe(false); - expect(ubuntu.isVersion('04.10')).toBe(true); - expect(ubuntu.isVersion('05.04')).toBe(true); - expect(ubuntu.isVersion('6.06')).toBe(true); - expect(ubuntu.isVersion('8.04')).toBe(true); - expect(ubuntu.isVersion('9.04')).toBe(true); - expect(ubuntu.isVersion('10.04.4')).toBe(true); - expect(ubuntu.isVersion('12.04.5')).toBe(true); - expect(ubuntu.isVersion('13.04')).toBe(true); - expect(ubuntu.isVersion('14.04.6')).toBe(true); - expect(ubuntu.isVersion('15.04')).toBe(true); - expect(ubuntu.isVersion('16.04.7')).toBe(true); - expect(ubuntu.isVersion('16.10')).toBe(true); - expect(ubuntu.isVersion('17.04')).toBe(true); - expect(ubuntu.isVersion('18.04.5')).toBe(true); - expect(ubuntu.isVersion('18.10')).toBe(true); - expect(ubuntu.isVersion('20.04')).toBe(true); - expect(ubuntu.isVersion('20.10')).toBe(true); - expect(ubuntu.isVersion('30.11')).toBe(true); - expect(ubuntu.isVersion('2020.04')).toBe(false); + test.each` + version | major | minor | patch + ${undefined} | ${null} | ${null} | ${null} + ${null} | ${null} | ${null} | ${null} + ${''} | ${null} | ${null} | ${null} + ${'42'} | ${null} | ${null} | ${null} + ${'2020.04'} | ${null} | ${null} | ${null} + ${'04.10'} | ${4} | ${10} | ${null} + ${'18.04.5'} | ${18} | ${4} | ${5} + ${'20.04'} | ${20} | ${4} | ${null} + `( + 'getMajor, getMinor, getPatch for "$version"', + ({ version, major, minor, patch }) => { + expect(ubuntu.getMajor(version)).toBe(major); + expect(ubuntu.getMinor(version)).toBe(minor); + expect(ubuntu.getPatch(version)).toBe(patch); + } + ); + + test.each` + a | b | expected + ${'20.04'} | ${'2020.04'} | ${false} + ${'focal'} | ${'20.04'} | ${false} + ${'20.04'} | ${'focal'} | ${false} + ${'19.10'} | ${'19.10'} | ${true} + `('equals($a, $b) === $expected', ({ a, b, expected }) => { + expect(ubuntu.equals(a, b)).toBe(expected); }); - // digestion of version - - it('getMajor', () => { - expect(ubuntu.getMajor(undefined)).toBeNull(); - expect(ubuntu.getMajor(null)).toBeNull(); - expect(ubuntu.getMajor('')).toBeNull(); - expect(ubuntu.getMajor('42')).toBeNull(); - expect(ubuntu.getMajor('2020.04')).toBeNull(); - - expect(ubuntu.getMajor('04.10')).toBe(4); - - expect(ubuntu.getMajor('18.04.5')).toBe(18); - - expect(ubuntu.getMajor('20.04')).toBe(20); + test.each` + a | b | expected + ${'20.04'} | ${'20.10'} | ${false} + ${'20.10'} | ${'20.04'} | ${true} + ${'19.10'} | ${'20.04'} | ${false} + ${'20.04'} | ${'19.10'} | ${true} + ${'16.04'} | ${'16.04.7'} | ${false} + ${'16.04.7'} | ${'16.04'} | ${true} + ${'16.04.1'} | ${'16.04.7'} | ${false} + ${'16.04.7'} | ${'16.04.1'} | ${true} + ${'19.10.1'} | ${'20.04.1'} | ${false} + ${'20.04.1'} | ${'19.10.1'} | ${true} + `('isGreaterThan("$a", "$b") === $expected', ({ a, b, expected }) => { + expect(ubuntu.isGreaterThan(a, b)).toBe(expected); }); - it('getMinor', () => { - expect(ubuntu.getMinor(undefined)).toBeNull(); - expect(ubuntu.getMinor(null)).toBeNull(); - expect(ubuntu.getMinor('')).toBeNull(); - expect(ubuntu.getMinor('42')).toBeNull(); - expect(ubuntu.getMinor('2020.04')).toBeNull(); - - expect(ubuntu.getMinor('04.10')).toBe(10); - - expect(ubuntu.getMinor('18.04.5')).toBe(4); - - expect(ubuntu.getMinor('20.04')).toBe(4); - }); - - it('getPatch', () => { - expect(ubuntu.getPatch(undefined)).toBeNull(); - expect(ubuntu.getPatch(null)).toBeNull(); - expect(ubuntu.getPatch('')).toBeNull(); - expect(ubuntu.getPatch('42')).toBeNull(); - expect(ubuntu.getPatch('2020.04')).toBeNull(); - - expect(ubuntu.getPatch('04.10')).toBeNull(); - - expect(ubuntu.getPatch('18.04.5')).toBe(5); - - expect(ubuntu.getPatch('20.04')).toBeNull(); + test.each` + versions | range | expected + ${['18.10', '19.04', '19.10', '20.04']} | ${'2020.04'} | ${null} + ${['18.10', '19.04', '19.10', '20.04']} | ${'foobar'} | ${null} + ${['18.10', '19.04', '19.10', '20.04']} | ${'20.04'} | ${'20.04'} + ${['18.10', '19.04', '19.10', '20.04']} | ${'19.10'} | ${'19.10'} + ${['18.10', '19.04', '19.10', '20.04']} | ${'04.10'} | ${null} + `( + 'getSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(ubuntu.getSatisfyingVersion(versions, range)).toBe(expected); + } + ); + + test.each` + versions | range | expected + ${['18.10', '19.04', '19.10', '20.04']} | ${'2020.04'} | ${null} + ${['18.10', '19.04', '19.10', '20.04']} | ${'foobar'} | ${null} + ${['18.10', '19.04', '19.10', '20.04']} | ${'20.04'} | ${'20.04'} + ${['18.10', '19.04', '19.10', '20.04']} | ${'19.10'} | ${'19.10'} + ${['18.10', '19.04', '19.10', '20.04']} | ${'04.10'} | ${null} + `( + 'minSatisfyingVersion($versions, "$range") === "$expected"', + ({ versions, range, expected }) => { + expect(ubuntu.minSatisfyingVersion(versions, range)).toBe(expected); + } + ); + + test.each` + currentValue | rangeStrategy | currentVersion | newVersion | expected + ${undefined} | ${undefined} | ${undefined} | ${'foobar'} | ${'foobar'} + `( + 'getNewValue("$currentValue", "$rangeStrategy", "$currentVersion", "$newVersion") === "$expected"', + ({ currentValue, rangeStrategy, currentVersion, newVersion, expected }) => { + expect( + ubuntu.getNewValue({ + currentValue, + rangeStrategy, + currentVersion, + newVersion, + }) + ).toBe(expected); + } + ); + + test.each` + versions | expected + ${['17.03', '18.04', '18.04', '6.10', '19.10']} | ${['6.10', '17.03', '18.04', '18.04', '19.10']} + `('$versions -> sortVersions -> $expected ', ({ versions, expected }) => { + expect(versions.sort(ubuntu.sortVersions)).toEqual(expected); }); - // comparison - - it('equals', () => { - expect(ubuntu.equals('20.04', '2020.04')).toBe(false); - - expect(ubuntu.equals('focal', '20.04')).toBe(false); - expect(ubuntu.equals('20.04', 'focal')).toBe(false); - - expect(ubuntu.equals('19.10', '19.10')).toBe(true); - }); - - it('isGreaterThan', () => { - expect(ubuntu.isGreaterThan('20.04', '20.10')).toBe(false); - expect(ubuntu.isGreaterThan('20.10', '20.04')).toBe(true); - - expect(ubuntu.isGreaterThan('19.10', '20.04')).toBe(false); - expect(ubuntu.isGreaterThan('20.04', '19.10')).toBe(true); - - expect(ubuntu.isGreaterThan('16.04', '16.04.7')).toBe(false); - expect(ubuntu.isGreaterThan('16.04.7', '16.04')).toBe(true); - expect(ubuntu.isGreaterThan('16.04.1', '16.04.7')).toBe(false); - expect(ubuntu.isGreaterThan('16.04.7', '16.04.1')).toBe(true); - expect(ubuntu.isGreaterThan('19.10.1', '20.04.1')).toBe(false); - expect(ubuntu.isGreaterThan('20.04.1', '19.10.1')).toBe(true); - }); - - it('getSatisfyingVersion', () => { - const versions = ['18.10', '19.04', '19.10', '20.04']; - expect(ubuntu.getSatisfyingVersion(versions, '2020.04')).toBeNull(); - expect(ubuntu.getSatisfyingVersion(versions, 'foobar')).toBeNull(); - expect(ubuntu.getSatisfyingVersion(versions, '20.04')).toBe('20.04'); - expect(ubuntu.getSatisfyingVersion(versions, '19.10')).toBe('19.10'); - expect(ubuntu.getSatisfyingVersion(versions, '04.10')).toBeNull(); - }); - - it('minSatisfyingVersion', () => { - const versions = ['18.10', '19.04', '19.10', '20.04']; - expect(ubuntu.minSatisfyingVersion(versions, '2020.04')).toBeNull(); - expect(ubuntu.minSatisfyingVersion(versions, 'foobar')).toBeNull(); - expect(ubuntu.minSatisfyingVersion(versions, '20.04')).toBe('20.04'); - expect(ubuntu.minSatisfyingVersion(versions, '19.10')).toBe('19.10'); - expect(ubuntu.minSatisfyingVersion(versions, '04.10')).toBeNull(); - }); - - it('getNewValue simply returns newVersion', () => { - expect(ubuntu.getNewValue({ newVersion: 'foobar' } as never)).toEqual( - 'foobar' - ); - }); - - it('sortVersions', () => { - const sortedVersions = ['6.10', '17.03', '18.04', '18.04', '19.10']; - const versions = [ - ...sortedVersions.slice(2), - ...sortedVersions.slice(0, 2), - ]; - expect(versions.sort(ubuntu.sortVersions)).toEqual(sortedVersions); - }); - - it('matches', () => { - expect(ubuntu.matches('20.04', '2020.04')).toBe(false); - expect(ubuntu.matches('20.04', '20.04')).toBe(true); - expect(ubuntu.matches('20.04', '20.04.0')).toBe(false); - }); + test.each` + version | range | expected + ${'20.04'} | ${'2020.04'} | ${false} + ${'20.04'} | ${'20.04'} | ${true} + ${'20.04'} | ${'20.04.0'} | ${false} + `( + 'matches("$version", "$range") === "$expected"', + ({ version, range, expected }) => { + expect(ubuntu.matches(version, range)).toBe(expected); + } + ); }); From 8f0fd1d303850b7b6588e79358587c678ec11996 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 11:58:45 +0000 Subject: [PATCH 02/38] chore(deps): update github/codeql-action action to v1.0.16 (#12014) Co-authored-by: Renovate Bot --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 41f91a21595403..0f15bd55249021 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -26,7 +26,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@1b37538d9c22dd3f3d0c52992fa20da98683bd34 # renovate: tag=v1.0.15 + uses: github/codeql-action/init@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 with: config-file: ./.github/codeql/codeql-config.yml @@ -36,7 +36,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@1b37538d9c22dd3f3d0c52992fa20da98683bd34 # renovate: tag=v1.0.15 + uses: github/codeql-action/autobuild@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -50,4 +50,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1b37538d9c22dd3f3d0c52992fa20da98683bd34 # renovate: tag=v1.0.15 + uses: github/codeql-action/analyze@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 From e416df1865c575b7e148348412d9f95aca633de5 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Tue, 5 Oct 2021 14:21:11 +0200 Subject: [PATCH 03/38] feat(manager/regex): allow defining autoReplaceStringTemplate (#12019) --- docs/usage/configuration-options.md | 38 +++++++++++++++++++ lib/config/options/index.ts | 9 +++++ lib/config/types.ts | 1 + lib/config/validation.ts | 1 + .../regex/__snapshots__/index.spec.ts.snap | 19 ++++++++++ lib/manager/regex/index.spec.ts | 19 ++++++++++ lib/manager/regex/index.ts | 3 ++ lib/manager/types.ts | 2 + 8 files changed, 92 insertions(+) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index daf4c3c28270a0..8dfac52d901fc2 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2163,6 +2163,44 @@ It will be compiled using Handlebars and the regex `groups` result. If the `registryUrls` for a dependency is not captured with a named group then it can be defined in config using this field. It will be compiled using Handlebars and the regex `groups` result. +### autoReplaceStringTemplate + +Allows overwriting how the matched string is replaced. +This allows for some migration strategies. +E.g. moving from one Docker image repository to another one. + +helm-values.yaml: + +```yaml +# The image of the service //: +image: my.old.registry/aRepository/andImage:1.18-alpine +``` + +regex definition: + +```json +{ + "regexManagers": [ + { + "fileMatch": ["values.yaml$"], + "matchStrings": [ + "image:\\s+(?my\\.old\\.registry\\/aRepository\\/andImage):(?[^\\s]+)" + ], + "depNameTemplate": "my.new.registry/aRepository/andImage", + "autoReplaceStringTemplate": "image: {{{depName}}}:{{{newValue}}}", + "datasourceTemplate": "docker" + } + ] +} +``` + +This will lead to following update where `1.21-alpine` is the newest version of `my.new.registry/aRepository/andImage`: + +```yaml +# The image of the service //: +image: my.new.registry/aRepository/andImage:1.21-alpine +``` + ## registryUrls Usually Renovate is able to either (a) use the default registries for a datasource, or (b) automatically detect during the manager extract phase which custom registries are in use. diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 382a560472d5f4..dc557c23e756fc 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2016,6 +2016,15 @@ const options: RenovateOptions[] = [ cli: false, env: false, }, + { + name: 'autoReplaceStringTemplate', + description: + 'Optional extractVersion for extracted dependencies. Valid only within a `regexManagers` object.', + type: 'string', + parent: 'regexManagers', + cli: false, + env: false, + }, { name: 'fetchReleaseNotes', description: 'Allow to disable release notes fetching.', diff --git a/lib/config/types.ts b/lib/config/types.ts index a773d15247b841..c13b6fc752710b 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -150,6 +150,7 @@ export interface CustomManager { datasourceTemplate?: string; lookupNameTemplate?: string; versioningTemplate?: string; + autoReplaceStringTemplate?: string; } // TODO: Proper typings diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 0684c3445691fd..905b22a1658192 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -388,6 +388,7 @@ export async function validateConfig( 'registryUrlTemplate', 'currentValueTemplate', 'extractVersionTemplate', + 'autoReplaceStringTemplate', ]; // TODO: fix types for (const regexManager of val as any[]) { diff --git a/lib/manager/regex/__snapshots__/index.spec.ts.snap b/lib/manager/regex/__snapshots__/index.spec.ts.snap index 94aa2090dce108..6071a39e352525 100644 --- a/lib/manager/regex/__snapshots__/index.spec.ts.snap +++ b/lib/manager/regex/__snapshots__/index.spec.ts.snap @@ -41,6 +41,25 @@ Object { } `; +exports[`manager/regex/index extracts dependency with autoReplaceStringTemplate 1`] = ` +Object { + "autoReplaceStringTemplate": "image: {{{depName}}}:{{{newValue}}}", + "datasourceTemplate": "docker", + "depNameTemplate": "my.new.registry/aRepository/andImage", + "deps": Array [ + Object { + "currentValue": "1.18-alpine", + "datasource": "docker", + "depName": "my.new.registry/aRepository/andImage", + "replaceString": "image: my.old.registry/aRepository/andImage:1.18-alpine", + }, + ], + "matchStrings": Array [ + "image:\\\\s+(?my\\\\.old\\\\.registry\\\\/aRepository\\\\/andImage):(?[^\\\\s]+)", + ], +} +`; + exports[`manager/regex/index extracts extractVersion 1`] = ` Object { "deps": Array [ diff --git a/lib/manager/regex/index.spec.ts b/lib/manager/regex/index.spec.ts index 035c2854cc1886..7f3d9bdfc68026 100644 --- a/lib/manager/regex/index.spec.ts +++ b/lib/manager/regex/index.spec.ts @@ -168,6 +168,25 @@ describe('manager/regex/index', () => { 'maven' ); }); + + it('extracts dependency with autoReplaceStringTemplate', async () => { + const config = { + matchStrings: [ + 'image:\\s+(?my\\.old\\.registry\\/aRepository\\/andImage):(?[^\\s]+)', + ], + depNameTemplate: 'my.new.registry/aRepository/andImage', + autoReplaceStringTemplate: 'image: {{{depName}}}:{{{newValue}}}', + datasourceTemplate: 'docker', + }; + const res = await extractPackageFile( + 'image: my.old.registry/aRepository/andImage:1.18-alpine', + 'values.yaml', + config + ); + expect(res).toMatchSnapshot(); + expect(res.deps).toHaveLength(1); + }); + it('extracts with combination strategy', async () => { const config: CustomExtractConfig = { matchStrings: [ diff --git a/lib/manager/regex/index.ts b/lib/manager/regex/index.ts index 9c38450312e9a6..70f9c181ef11f5 100644 --- a/lib/manager/regex/index.ts +++ b/lib/manager/regex/index.ts @@ -221,6 +221,9 @@ export function extractPackageFile( res[field] = config[field]; } } + if (config.autoReplaceStringTemplate) { + res.autoReplaceStringTemplate = config.autoReplaceStringTemplate; + } return res; } diff --git a/lib/manager/types.ts b/lib/manager/types.ts index bb512be8b2546a..c84b69c132a69f 100644 --- a/lib/manager/types.ts +++ b/lib/manager/types.ts @@ -27,6 +27,7 @@ export interface ExtractConfig { } export interface CustomExtractConfig extends ExtractConfig { + autoReplaceStringTemplate?: string; matchStrings: string[]; matchStringsStrategy?: MatchStringsStrategy; depNameTemplate?: string; @@ -69,6 +70,7 @@ export interface NpmLockFiles { export interface PackageFile> extends NpmLockFiles, ManagerData { + autoReplaceStringTemplate?: string; hasYarnWorkspaces?: boolean; constraints?: Record; datasource?: string; From c976b77a63d683ab9a40dc24eead46ef64b051e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 15:39:33 +0000 Subject: [PATCH 04/38] chore(deps): update jest monorepo to v27.2.3 (#12018) Co-authored-by: Renovate Bot --- package.json | 8 ++--- yarn.lock | 90 ++++++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 08152fa91ce1c5..e2c2d70fc63553 100644 --- a/package.json +++ b/package.json @@ -200,9 +200,9 @@ }, "devDependencies": { "@actions/core": "1.5.0", - "@jest/globals": "27.2.2", - "@jest/reporters": "27.2.2", - "@jest/test-result": "27.2.2", + "@jest/globals": "27.2.3", + "@jest/reporters": "27.2.3", + "@jest/test-result": "27.2.3", "@ls-lint/ls-lint": "1.10.0", "@renovate/eslint-plugin": "https://github.com/renovatebot/eslint-plugin#v0.0.3", "@semantic-release/exec": "6.0.1", @@ -253,7 +253,7 @@ "glob": "7.2.0", "graphql": "15.6.0", "husky": "7.0.2", - "jest": "27.2.2", + "jest": "27.2.3", "jest-extended": "0.11.5", "jest-github-actions-reporter": "1.0.3", "jest-junit": "12.3.0", diff --git a/yarn.lock b/yarn.lock index deb62cf1f5493b..d0ebd0c7abbca3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1023,7 +1023,7 @@ chalk "^2.0.1" slash "^2.0.0" -"@jest/console@^27.2.2", "@jest/console@^27.2.4": +"@jest/console@^27.2.3", "@jest/console@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.2.4.tgz#2f1a4bf82b9940065d4818fac271def99ec55e5e" integrity sha512-94znCKynPZpDpYHQ6esRJSc11AmONrVkBOBZiD7S+bSubHhrUfbS95EY5HIOxhm4PQO7cnvZkL3oJcY0oMA+Wg== @@ -1035,7 +1035,7 @@ jest-util "^27.2.4" slash "^3.0.0" -"@jest/core@^27.2.2", "@jest/core@^27.2.4": +"@jest/core@^27.2.3", "@jest/core@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/core/-/core-27.2.4.tgz#0b932da787d64848eab720dbb88e5b7a3f86e539" integrity sha512-UNQLyy+rXoojNm2MGlapgzWhZD1CT1zcHZQYeiD0xE7MtJfC19Q6J5D/Lm2l7i4V97T30usKDoEtjI8vKwWcLg== @@ -1069,7 +1069,7 @@ slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/environment@^27.2.2", "@jest/environment@^27.2.4": +"@jest/environment@^27.2.3", "@jest/environment@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.2.4.tgz#db3e60f7dd30ab950f6ce2d6d7293ed9a6b7cbcd" integrity sha512-wkuui5yr3SSQW0XD0Qm3TATUbL/WE3LDEM3ulC+RCQhMf2yxhci8x7svGkZ4ivJ6Pc94oOzpZ6cdHBAMSYd1ew== @@ -1091,14 +1091,14 @@ jest-mock "^27.2.4" jest-util "^27.2.4" -"@jest/globals@27.2.2": - version "27.2.2" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.2.tgz#df66aaafda5c69b2bb0dae548e3cfb345f549c31" - integrity sha512-fWa/Luwod1hyehnuep+zCnOTqTVvyc4HLUU/1VpFNOEu0tCWNSODyvKSSOjtb1bGOpCNjgaDcyjzo5f7rl6a7g== +"@jest/globals@27.2.3": + version "27.2.3" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.3.tgz#6b8d652083d78709b243d9571457058f1c6c5fea" + integrity sha512-JVjQDs5z34XvFME0qHmKwWtgzRnBa/i22nfWjzlIUvkdFCzndN+JTLEWNXAgyBbGnNYuMZ8CpvgF9uhKt/cR3g== dependencies: - "@jest/environment" "^27.2.2" - "@jest/types" "^27.1.1" - expect "^27.2.2" + "@jest/environment" "^27.2.3" + "@jest/types" "^27.2.3" + expect "^27.2.3" "@jest/globals@^27.2.4": version "27.2.4" @@ -1109,16 +1109,16 @@ "@jest/types" "^27.2.4" expect "^27.2.4" -"@jest/reporters@27.2.2": - version "27.2.2" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.2.tgz#e2d41cd9f8088676b81b9a9908cb1ba67bdbee78" - integrity sha512-ufwZ8XoLChEfPffDeVGroYbhbcYPom3zKDiv4Flhe97rr/o2IfUXoWkDUDoyJ3/V36RFIMjokSu0IJ/pbFtbHg== +"@jest/reporters@27.2.3": + version "27.2.3" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.3.tgz#47c27be7c3e2069042b6fba12c1f8f62f91302db" + integrity sha512-zc9gQDjUAnkRQ5C0LW2u4JU9Ojqp9qc8OXQkMSmAbou6lN0mvDGEl4PG5HrZxpW4nE2FjIYyX6JAn05QT3gLbw== dependencies: "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^27.2.2" - "@jest/test-result" "^27.2.2" - "@jest/transform" "^27.2.2" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.3" + "@jest/test-result" "^27.2.3" + "@jest/transform" "^27.2.3" + "@jest/types" "^27.2.3" chalk "^4.0.0" collect-v8-coverage "^1.0.0" exit "^0.1.2" @@ -1129,15 +1129,15 @@ istanbul-lib-report "^3.0.0" istanbul-lib-source-maps "^4.0.0" istanbul-reports "^3.0.2" - jest-haste-map "^27.2.2" - jest-resolve "^27.2.2" - jest-util "^27.2.0" - jest-worker "^27.2.2" + jest-haste-map "^27.2.3" + jest-resolve "^27.2.3" + jest-util "^27.2.3" + jest-worker "^27.2.3" slash "^3.0.0" source-map "^0.6.0" string-length "^4.0.1" terminal-link "^2.0.0" - v8-to-istanbul "^8.0.0" + v8-to-istanbul "^8.1.0" "@jest/reporters@^27.2.4": version "27.2.4" @@ -1187,13 +1187,13 @@ graceful-fs "^4.2.4" source-map "^0.6.0" -"@jest/test-result@27.2.2": - version "27.2.2" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.2.tgz#cd4ba1ca9b0521e463bd4b32349ba1842277563b" - integrity sha512-yENoDEoWlEFI7l5z7UYyJb/y5Q8RqbPd4neAVhKr6l+vVaQOPKf8V/IseSMJI9+urDUIxgssA7RGNyCRhGjZvw== +"@jest/test-result@27.2.3": + version "27.2.3" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.3.tgz#7d8f790186c7ec7600edc1d8781656268f038255" + integrity sha512-+pRxO4xSJyUxoA0ENiTq8wT+5RCFOxK4nlNY2lUes/VF33uB54GBkZeXlljZcZjuzS1Yarz4hZI/a4mBtv9jQA== dependencies: - "@jest/console" "^27.2.2" - "@jest/types" "^27.1.1" + "@jest/console" "^27.2.3" + "@jest/types" "^27.2.3" "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" @@ -1206,7 +1206,7 @@ "@jest/types" "^24.9.0" "@types/istanbul-lib-coverage" "^2.0.0" -"@jest/test-result@^27.2.2", "@jest/test-result@^27.2.4": +"@jest/test-result@^27.2.3", "@jest/test-result@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.4.tgz#d1ca8298d168f1b0be834bfb543b1ac0294c05d7" integrity sha512-eU+PRo0+lIS01b0dTmMdVZ0TtcRSxEaYquZTRFMQz6CvsehGhx9bRzi9Zdw6VROviJyv7rstU+qAMX5pNBmnfQ== @@ -1226,7 +1226,7 @@ jest-haste-map "^27.2.4" jest-runtime "^27.2.4" -"@jest/transform@^27.2.2", "@jest/transform@^27.2.4": +"@jest/transform@^27.2.3", "@jest/transform@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-27.2.4.tgz#2fe5b6836895f7a1b8bdec442c51e83943c62733" integrity sha512-n5FlX2TH0oQGwyVDKPxdJ5nI2sO7TJBFe3u3KaAtt7TOiV4yL+Y+rSFDl+Ic5MpbiA/eqXmLAQxjnBmWgS2rEA== @@ -1267,7 +1267,7 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@jest/types@^27.1.1", "@jest/types@^27.2.4": +"@jest/types@^27.2.3", "@jest/types@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.4.tgz#2430042a66e00dc5b140c3636f4474d464c21ee8" integrity sha512-IDO2ezTxeMvQAHxzG/ZvEyA47q0aVfzT95rGFl7bZs/Go0aIucvfDbS2rmnoEdXxlLQhcolmoG/wvL/uKx4tKA== @@ -4268,7 +4268,7 @@ expect@^24.1.0: jest-message-util "^24.9.0" jest-regex-util "^24.9.0" -expect@^27.2.2, expect@^27.2.4: +expect@^27.2.3, expect@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/expect/-/expect-27.2.4.tgz#4debf546050bcdad8914a8c95fec7662e02bf67c" integrity sha512-gOtuonQ8TCnbNNCSw2fhVzRf8EFYDII4nB5NmG4IEV0rbUnW1I5zXvoTntU4iicB/Uh0oZr20NGlOLdJiwsOZA== @@ -5607,7 +5607,7 @@ jest-circus@^27.2.4: stack-utils "^2.0.3" throat "^6.0.1" -jest-cli@^27.2.2: +jest-cli@^27.2.3: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-27.2.4.tgz#acda7f367aa6e674723fc1a7334e0ae1799448d2" integrity sha512-4kpQQkg74HYLaXo3nzwtg4PYxSLgL7puz1LXHj5Tu85KmlIpxQFjRkXlx4V47CYFFIDoyl3rHA/cXOxUWyMpNg== @@ -5746,7 +5746,7 @@ jest-github-actions-reporter@1.0.3: dependencies: "@actions/core" "^1.2.0" -jest-haste-map@^27.2.2, jest-haste-map@^27.2.4: +jest-haste-map@^27.2.3, jest-haste-map@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.2.4.tgz#f8974807bedf07348ca9fd24e5861ab7c8e61aba" integrity sha512-bkJ4bT00T2K+1NZXbRcyKnbJ42I6QBvoDNMTAQQDBhaGNnZreiQKUNqax0e6hLTx7E75pKDeltVu3V1HAdu+YA== @@ -5905,7 +5905,7 @@ jest-resolve-dependencies@^27.2.4: jest-regex-util "^27.0.6" jest-snapshot "^27.2.4" -jest-resolve@^27.2.2, jest-resolve@^27.2.4: +jest-resolve@^27.2.3, jest-resolve@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-27.2.4.tgz#d3b999f073ff84a8ae109ce99ff7f3223048701a" integrity sha512-IsAO/3+3BZnKjI2I4f3835TBK/90dxR7Otgufn3mnrDFTByOSXclDi3G2XJsawGV4/18IMLARJ+V7Wm7t+J89Q== @@ -6040,7 +6040,7 @@ jest-util@^26.0.0: is-ci "^2.0.0" micromatch "^4.0.2" -jest-util@^27.0.0, jest-util@^27.2.0, jest-util@^27.2.4: +jest-util@^27.0.0, jest-util@^27.2.3, jest-util@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.2.4.tgz#3d7ce081b2e7f4cfe0156452ac01f3cb456cc656" integrity sha512-mW++4u+fSvAt3YBWm5IpbmRAceUqa2B++JlUZTiuEt2AmNYn0Yw5oay4cP17TGsMINRNPSGiJ2zNnX60g+VbFg== @@ -6077,7 +6077,7 @@ jest-watcher@^27.2.4: jest-util "^27.2.4" string-length "^4.0.1" -jest-worker@^27.2.2, jest-worker@^27.2.4: +jest-worker@^27.2.3, jest-worker@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.2.4.tgz#881455df75e22e7726a53f43703ab74d6b36f82d" integrity sha512-Zq9A2Pw59KkVjBBKD1i3iE2e22oSjXhUKKuAK1HGX8flGwkm6NMozyEYzKd41hXc64dbd/0eWFeEEuxqXyhM+g== @@ -6086,14 +6086,14 @@ jest-worker@^27.2.2, jest-worker@^27.2.4: merge-stream "^2.0.0" supports-color "^8.0.0" -jest@27.2.2: - version "27.2.2" - resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.2.tgz#445a4c16aa4c4ae6e512d62fb6f8b2624cbd6c26" - integrity sha512-XAB/9akDTe3/V0wPNKWfP9Y/NT1QPiCqyRBYGbC66EA9EvgAzdaFEqhFGLaDJ5UP2yIyXUMtju9a9IMrlYbZTQ== +jest@27.2.3: + version "27.2.3" + resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.3.tgz#9c2af9ce874a3eb202f83d92fbc1cc61ccc73248" + integrity sha512-r4ggA29J5xUg93DpvbsX+AXlFMWE3hZ5Y6BfgTl8PJvWelVezNPkmrsixuGoDBTHTCwScRSH0O4wsoeUgLie2w== dependencies: - "@jest/core" "^27.2.2" + "@jest/core" "^27.2.3" import-local "^3.0.2" - jest-cli "^27.2.2" + jest-cli "^27.2.3" js-tokens@^4.0.0: version "4.0.0" @@ -9753,7 +9753,7 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== -v8-to-istanbul@^8.0.0, v8-to-istanbul@^8.1.0: +v8-to-istanbul@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.0.tgz#0aeb763894f1a0a1676adf8a8b7612a38902446c" integrity sha512-/PRhfd8aTNp9Ggr62HPzXg2XasNFGy5PBt0Rp04du7/8GNNSgxFL6WBTkgMKSL9bFjH+8kKEG3f37FmxiTqUUA== From 8dfc8d3234305bc467dc6ed0875c9a2fe7721f7c Mon Sep 17 00:00:00 2001 From: Anne Stellingwerf Date: Tue, 5 Oct 2021 18:53:39 +0200 Subject: [PATCH 05/38] feat(preset/monorepo): Monorepo preset for Netty (#11992) Co-authored-by: Michael Kriese From 27d034638ff8a27dce7dcc79d7c5ae1c46455224 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 20:39:13 +0000 Subject: [PATCH 06/38] chore(deps): update dependency @actions/core to v1.6.0 (#12026) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e2c2d70fc63553..98b6d2bd1e4120 100644 --- a/package.json +++ b/package.json @@ -199,7 +199,7 @@ "re2": "1.16.0" }, "devDependencies": { - "@actions/core": "1.5.0", + "@actions/core": "1.6.0", "@jest/globals": "27.2.3", "@jest/reporters": "27.2.3", "@jest/test-result": "27.2.3", diff --git a/yarn.lock b/yarn.lock index d0ebd0c7abbca3..1e2dd4f7da4233 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,7 @@ # yarn lockfile v1 -"@actions/core@1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.5.0.tgz#885b864700001a1b9a6fba247833a036e75ad9d3" - integrity sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ== - -"@actions/core@^1.2.0", "@actions/core@^1.2.6": +"@actions/core@1.6.0", "@actions/core@^1.2.0", "@actions/core@^1.2.6": version "1.6.0" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb" integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw== From d7e1f7c24da25b589bdd5b69965f17b75c230ac3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 22:40:06 +0000 Subject: [PATCH 07/38] chore(deps): update dependency eslint-plugin-jest to v24.4.3 (#12027) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 98b6d2bd1e4120..47cd6e63c7b889 100644 --- a/package.json +++ b/package.json @@ -248,7 +248,7 @@ "eslint-config-prettier": "8.3.0", "eslint-formatter-gha": "1.2.0", "eslint-plugin-import": "2.24.2", - "eslint-plugin-jest": "24.4.2", + "eslint-plugin-jest": "24.4.3", "eslint-plugin-promise": "5.1.0", "glob": "7.2.0", "graphql": "15.6.0", diff --git a/yarn.lock b/yarn.lock index 1e2dd4f7da4233..146aa9fd2063fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4065,10 +4065,10 @@ eslint-plugin-import@2.24.2: resolve "^1.20.0" tsconfig-paths "^3.11.0" -eslint-plugin-jest@24.4.2: - version "24.4.2" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.4.2.tgz#9e8cf05ee6a0e3025e6149df2f36950abfa8d5bf" - integrity sha512-jNMnqwX75z0RXRMXkxwb/+9ylKJYJLJ8nT8nBT0XFM5qx4IQGxP4edMawa0qGkSbHae0BDPBmi8I2QF0/F04XQ== +eslint-plugin-jest@24.4.3: + version "24.4.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.4.3.tgz#dd59e32a7d233a92672468082c24c337a5954873" + integrity sha512-cZPTqF/35/usP9gvjslj6pE+2lpr1KoZvjvDWRlfCP27LSRHBUhJV6hBPk47TksH3lSt28sDpIlp8owK0hWtsA== dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" From 1f86b71fd5f9175cdb6ab8c673dbdf83082c2c2e Mon Sep 17 00:00:00 2001 From: Maksim Date: Wed, 6 Oct 2021 07:43:32 +0200 Subject: [PATCH 08/38] refactor: constants (#11690) --- lib/config/migration.spec.ts | 4 ++-- lib/config/options/index.ts | 4 ++-- lib/config/presets/local/index.ts | 21 ++++++----------- lib/constants/index.ts | 1 + lib/constants/platform.spec.ts | 19 ++++----------- lib/constants/platforms.ts | 18 ++++++++------- lib/datasource/go/index.ts | 4 ++-- lib/manager/composer/artifacts.spec.ts | 9 +++----- lib/manager/composer/artifacts.ts | 9 +++----- lib/manager/gomod/artifacts.ts | 4 ++-- lib/manager/pre-commit/extract.ts | 12 ++++------ lib/platform/azure/azure-got-wrapper.spec.ts | 8 +++---- lib/platform/azure/azure-got-wrapper.ts | 4 ++-- lib/platform/azure/index.ts | 4 ++-- lib/platform/bitbucket-server/index.ts | 4 ++-- lib/platform/bitbucket/index.ts | 4 ++-- lib/platform/gitea/index.ts | 6 ++--- lib/platform/github/index.ts | 10 ++++---- lib/platform/gitlab/index.ts | 4 ++-- lib/platform/index.spec.ts | 6 ++--- lib/util/host-rules.spec.ts | 23 ++++++++----------- lib/util/http/auth.spec.ts | 16 +++++-------- lib/util/http/auth.ts | 6 ++--- lib/util/http/bitbucket-server.spec.ts | 4 ++-- lib/util/http/bitbucket-server.ts | 4 ++-- lib/util/http/bitbucket.spec.ts | 4 ++-- lib/util/http/bitbucket.ts | 4 ++-- lib/util/http/gitea.ts | 4 ++-- lib/util/http/github.ts | 14 +++++------ lib/util/http/gitlab.spec.ts | 8 +++---- lib/util/http/gitlab.ts | 13 ++++------- lib/util/http/host-rules.spec.ts | 16 +++++-------- lib/util/http/host-rules.ts | 13 +++++------ lib/workers/global/autodiscover.spec.ts | 10 ++++---- lib/workers/global/config/parse/env.spec.ts | 13 ++++------- lib/workers/global/config/parse/env.ts | 4 ++-- lib/workers/global/index.spec.ts | 11 ++++----- lib/workers/pr/changelog/github.spec.ts | 8 +++---- lib/workers/pr/changelog/gitlab.spec.ts | 10 ++++---- lib/workers/pr/changelog/index.spec.ts | 10 ++++---- lib/workers/pr/changelog/source-github.ts | 4 ++-- lib/workers/pr/index.spec.ts | 4 ++-- .../repository/dependency-dashboard.spec.ts | 4 ++-- lib/workers/repository/finalise/prune.spec.ts | 4 ++-- 44 files changed, 161 insertions(+), 205 deletions(-) create mode 100644 lib/constants/index.ts diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index 462124b8e28b83..4aa9d4625c0db6 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_GITHUB } from '../constants/platforms'; +import { PlatformId } from '../constants'; import { getConfig } from './defaults'; import { setGlobalConfig } from './global'; import * as configMigration from './migration'; @@ -20,7 +20,7 @@ describe('config/migration', () => { const config: TestRenovateConfig = { endpoints: [{}] as never, enabled: true, - platform: PLATFORM_TYPE_GITHUB, + platform: PlatformId.Github, hostRules: [ { platform: 'docker', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index dc557c23e756fc..5030ea0a24d250 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { getManagers } from '../../manager'; import { getPlatformList } from '../../platform'; import { getVersioningList } from '../../versioning'; @@ -559,7 +559,7 @@ const options: RenovateOptions[] = [ description: 'Platform type of repository.', type: 'string', allowedValues: getPlatformList(), - default: PLATFORM_TYPE_GITHUB, + default: PlatformId.Github, globalOnly: true, }, { diff --git a/lib/config/presets/local/index.ts b/lib/config/presets/local/index.ts index 319d513ce58b70..440197771eb268 100644 --- a/lib/config/presets/local/index.ts +++ b/lib/config/presets/local/index.ts @@ -1,11 +1,4 @@ -import { - PLATFORM_TYPE_AZURE, - PLATFORM_TYPE_BITBUCKET, - PLATFORM_TYPE_BITBUCKET_SERVER, - PLATFORM_TYPE_GITEA, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import * as azure from '../azure'; import * as bitbucket from '../bitbucket'; import * as bitbucketServer from '../bitbucket-server'; @@ -15,12 +8,12 @@ import * as gitlab from '../gitlab'; import type { Preset, PresetConfig } from '../types'; const resolvers = { - [PLATFORM_TYPE_AZURE]: azure, - [PLATFORM_TYPE_BITBUCKET]: bitbucket, - [PLATFORM_TYPE_BITBUCKET_SERVER]: bitbucketServer, - [PLATFORM_TYPE_GITEA]: gitea, - [PLATFORM_TYPE_GITHUB]: github, - [PLATFORM_TYPE_GITLAB]: gitlab, + [PlatformId.Azure]: azure, + [PlatformId.Bitbucket]: bitbucket, + [PlatformId.BitbucketServer]: bitbucketServer, + [PlatformId.Gitea]: gitea, + [PlatformId.Github]: github, + [PlatformId.Gitlab]: gitlab, }; export function getPreset({ diff --git a/lib/constants/index.ts b/lib/constants/index.ts new file mode 100644 index 00000000000000..fef29321c3b365 --- /dev/null +++ b/lib/constants/index.ts @@ -0,0 +1 @@ +export * from './platforms'; diff --git a/lib/constants/platform.spec.ts b/lib/constants/platform.spec.ts index 7b2f536b8d3e40..c02a997356c320 100644 --- a/lib/constants/platform.spec.ts +++ b/lib/constants/platform.spec.ts @@ -7,8 +7,7 @@ import { id as POD_DS } from '../datasource/pod'; import { GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, + PlatformId, } from './platforms'; describe('constants/platform', () => { @@ -20,29 +19,21 @@ describe('constants/platform', () => { expect( GITLAB_API_USING_HOST_TYPES.includes(GitlabPackagesDatasource.id) ).toBeTrue(); - expect( - GITLAB_API_USING_HOST_TYPES.includes(PLATFORM_TYPE_GITLAB) - ).toBeTrue(); + expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeTrue(); }); it('should be not part of the GITLAB_API_USING_HOST_TYPES ', () => { - expect( - GITLAB_API_USING_HOST_TYPES.includes(PLATFORM_TYPE_GITHUB) - ).toBeFalse(); + expect(GITLAB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeFalse(); }); it('should be part of the GITHUB_API_USING_HOST_TYPES ', () => { expect(GITHUB_API_USING_HOST_TYPES.includes(GH_TAGS_DS)).toBeTrue(); expect(GITHUB_API_USING_HOST_TYPES.includes(GH_RELEASES_DS)).toBeTrue(); expect(GITHUB_API_USING_HOST_TYPES.includes(POD_DS)).toBeTrue(); - expect( - GITHUB_API_USING_HOST_TYPES.includes(PLATFORM_TYPE_GITHUB) - ).toBeTrue(); + expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Github)).toBeTrue(); }); it('should be not part of the GITHUB_API_USING_HOST_TYPES ', () => { - expect( - GITHUB_API_USING_HOST_TYPES.includes(PLATFORM_TYPE_GITLAB) - ).toBeFalse(); + expect(GITHUB_API_USING_HOST_TYPES.includes(PlatformId.Gitlab)).toBeFalse(); }); }); diff --git a/lib/constants/platforms.ts b/lib/constants/platforms.ts index 0bee6d8191f78b..83ce1e763c20ab 100644 --- a/lib/constants/platforms.ts +++ b/lib/constants/platforms.ts @@ -1,19 +1,21 @@ -export const PLATFORM_TYPE_AZURE = 'azure'; -export const PLATFORM_TYPE_BITBUCKET = 'bitbucket'; -export const PLATFORM_TYPE_BITBUCKET_SERVER = 'bitbucket-server'; -export const PLATFORM_TYPE_GITEA = 'gitea'; -export const PLATFORM_TYPE_GITHUB = 'github'; -export const PLATFORM_TYPE_GITLAB = 'gitlab'; +export const enum PlatformId { + Azure = 'azure', + Bitbucket = 'bitbucket', + BitbucketServer = 'bitbucket-server', + Gitea = 'gitea', + Github = 'github', + Gitlab = 'gitlab', +} export const GITHUB_API_USING_HOST_TYPES = [ - PLATFORM_TYPE_GITHUB, + PlatformId.Github, 'github-releases', 'github-tags', 'pod', ]; export const GITLAB_API_USING_HOST_TYPES = [ - PLATFORM_TYPE_GITLAB, + PlatformId.Gitlab, 'gitlab-releases', 'gitlab-tags', 'gitlab-packages', diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts index 4936c3a721970f..42581e7c6dc335 100644 --- a/lib/datasource/go/index.ts +++ b/lib/datasource/go/index.ts @@ -1,5 +1,5 @@ import URL from 'url'; -import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { logger } from '../../logger'; import * as hostRules from '../../util/host-rules'; import { regEx } from '../../util/regex'; @@ -92,7 +92,7 @@ async function getDatasource(goModule: string): Promise { } const opts = hostRules.find({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, url: goSourceUrl, }); if (opts.token) { diff --git a/lib/manager/composer/artifacts.spec.ts b/lib/manager/composer/artifacts.spec.ts index 0f168ff823842e..42cfe6ea50ad2f 100644 --- a/lib/manager/composer/artifacts.spec.ts +++ b/lib/manager/composer/artifacts.spec.ts @@ -3,10 +3,7 @@ import { envMock, exec, mockExecAll } from '../../../test/exec-util'; import { env, fs, git, mocked, partial } from '../../../test/util'; import { setGlobalConfig } from '../../config/global'; import type { RepoGlobalConfig } from '../../config/types'; -import { - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as _datasource from '../../datasource'; import * as datasourcePackagist from '../../datasource/packagist'; import * as docker from '../../util/exec/docker'; @@ -97,12 +94,12 @@ describe('manager/composer/artifacts', () => { it('uses hostRules to set COMPOSER_AUTH', async () => { hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'api.github.com', token: 'github-token', }); hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, matchHost: 'gitlab.com', token: 'gitlab-token', }); diff --git a/lib/manager/composer/artifacts.ts b/lib/manager/composer/artifacts.ts index 916cde6b32281a..50862c753bbcd9 100644 --- a/lib/manager/composer/artifacts.ts +++ b/lib/manager/composer/artifacts.ts @@ -1,14 +1,11 @@ import is from '@sindresorhus/is'; import { quote } from 'shlex'; import { getGlobalConfig } from '../../config/global'; +import { PlatformId } from '../../constants'; import { SYSTEM_INSUFFICIENT_DISK_SPACE, TEMPORARY_ERROR, } from '../../constants/error-messages'; -import { - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; import * as datasourcePackagist from '../../datasource/packagist'; import { logger } from '../../logger'; import { ExecOptions, exec } from '../../util/exec'; @@ -36,7 +33,7 @@ function getAuthJson(): string | null { const authJson: AuthJson = {}; const githubCredentials = hostRules.find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url: 'https://api.github.com/', }); if (githubCredentials?.token) { @@ -46,7 +43,7 @@ function getAuthJson(): string | null { } hostRules - .findAll({ hostType: PLATFORM_TYPE_GITLAB }) + .findAll({ hostType: PlatformId.Gitlab }) ?.forEach((gitlabHostRule) => { if (gitlabHostRule?.token) { const host = gitlabHostRule.resolvedHost || 'gitlab.com'; diff --git a/lib/manager/gomod/artifacts.ts b/lib/manager/gomod/artifacts.ts index 63faa1101dac48..a4dc7a33b89141 100644 --- a/lib/manager/gomod/artifacts.ts +++ b/lib/manager/gomod/artifacts.ts @@ -2,8 +2,8 @@ import is from '@sindresorhus/is'; import { quote } from 'shlex'; import { dirname, join } from 'upath'; import { getGlobalConfig } from '../../config/global'; +import { PlatformId } from '../../constants'; import { TEMPORARY_ERROR } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; import { logger } from '../../logger'; import { ExecOptions, exec } from '../../util/exec'; import { ensureCacheDir, readLocalFile, writeLocalFile } from '../../util/fs'; @@ -19,7 +19,7 @@ import type { function getPreCommands(): string[] | null { const credentials = find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url: 'https://api.github.com/', }); let preCommands = null; diff --git a/lib/manager/pre-commit/extract.ts b/lib/manager/pre-commit/extract.ts index 2708d1ddd86e2f..aef244b22b20cf 100644 --- a/lib/manager/pre-commit/extract.ts +++ b/lib/manager/pre-commit/extract.ts @@ -1,10 +1,6 @@ import is from '@sindresorhus/is'; import { load } from 'js-yaml'; -import { - PLATFORM_TYPE_GITEA, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { id as githubTagsId } from '../../datasource/github-tags'; import { id as gitlabTagsId } from '../../datasource/gitlab-tags'; import { logger } from '../../logger'; @@ -55,9 +51,9 @@ function determineDatasource( return { skipReason: SkipReason.UnknownRegistry, registryUrls: [hostname] }; } for (const [hostType, sourceId] of [ - [PLATFORM_TYPE_GITEA, gitlabTagsId], - [PLATFORM_TYPE_GITHUB, githubTagsId], - [PLATFORM_TYPE_GITLAB, gitlabTagsId], + [PlatformId.Gitea, gitlabTagsId], + [PlatformId.Github, githubTagsId], + [PlatformId.Gitlab, gitlabTagsId], ]) { if (!isEmptyObject(find({ hostType, url: hostUrl }))) { logger.debug( diff --git a/lib/platform/azure/azure-got-wrapper.spec.ts b/lib/platform/azure/azure-got-wrapper.spec.ts index 1907cb3285faf9..bf7e14a4eb5c04 100644 --- a/lib/platform/azure/azure-got-wrapper.spec.ts +++ b/lib/platform/azure/azure-got-wrapper.spec.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_AZURE } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as _hostRules from '../../util/host-rules'; describe('platform/azure/azure-got-wrapper', () => { @@ -19,7 +19,7 @@ describe('platform/azure/azure-got-wrapper', () => { }); it('should set personal access token and endpoint', () => { hostRules.add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, token: '123test', matchHost: 'https://dev.azure.com/renovate1', }); @@ -35,7 +35,7 @@ describe('platform/azure/azure-got-wrapper', () => { }); it('should set bearer token and endpoint', () => { hostRules.add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, token: 'testtoken', matchHost: 'https://dev.azure.com/renovate2', }); @@ -52,7 +52,7 @@ describe('platform/azure/azure-got-wrapper', () => { it('should set password and endpoint', () => { hostRules.add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, username: 'user', password: 'pass', matchHost: 'https://dev.azure.com/renovate3', diff --git a/lib/platform/azure/azure-got-wrapper.ts b/lib/platform/azure/azure-got-wrapper.ts index 9b1c6c76aed3ed..e0f06a0ccaf8ee 100644 --- a/lib/platform/azure/azure-got-wrapper.ts +++ b/lib/platform/azure/azure-got-wrapper.ts @@ -4,11 +4,11 @@ import { ICoreApi } from 'azure-devops-node-api/CoreApi'; import { IGitApi } from 'azure-devops-node-api/GitApi'; import { IPolicyApi } from 'azure-devops-node-api/PolicyApi'; import { IRequestHandler } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces'; -import { PLATFORM_TYPE_AZURE } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { HostRule } from '../../types'; import * as hostRules from '../../util/host-rules'; -const hostType = PLATFORM_TYPE_AZURE; +const hostType = PlatformId.Azure; let endpoint: string; function getAuthenticationHandler(config: HostRule): IRequestHandler { diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index a280295d6262bf..9d19e3d2ef283b 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -8,8 +8,8 @@ import { PullRequestStatus, } from 'azure-devops-node-api/interfaces/GitInterfaces'; import delay from 'delay'; +import { PlatformId } from '../../constants'; import { REPOSITORY_EMPTY } from '../../constants/error-messages'; -import { PLATFORM_TYPE_AZURE } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import * as git from '../../util/git'; @@ -73,7 +73,7 @@ const defaults: { endpoint?: string; hostType: string; } = { - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, }; export function initPlatform({ diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 2bc866b66464fd..d88faecdf32dfe 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -2,12 +2,12 @@ import url from 'url'; import is from '@sindresorhus/is'; import delay from 'delay'; import type { PartialDeep } from 'type-fest'; +import { PlatformId } from '../../constants'; import { REPOSITORY_CHANGED, REPOSITORY_EMPTY, REPOSITORY_NOT_FOUND, } from '../../constants/error-messages'; -import { PLATFORM_TYPE_BITBUCKET_SERVER } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import { GitProtocol } from '../../types/git'; @@ -68,7 +68,7 @@ const defaults: { endpoint?: string; hostType: string; } = { - hostType: PLATFORM_TYPE_BITBUCKET_SERVER, + hostType: PlatformId.BitbucketServer, }; /* istanbul ignore next */ diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index d9df2f0870e30f..04ff05b3cd90de 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -1,8 +1,8 @@ import URL from 'url'; import is from '@sindresorhus/is'; import parseDiff from 'parse-diff'; +import { PlatformId } from '../../constants'; import { REPOSITORY_NOT_FOUND } from '../../constants/error-messages'; -import { PLATFORM_TYPE_BITBUCKET } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import * as git from '../../util/git'; @@ -127,7 +127,7 @@ export async function initRepo({ }: RepoParams): Promise { logger.debug(`initRepo("${repository}")`); const opts = hostRules.find({ - hostType: PLATFORM_TYPE_BITBUCKET, + hostType: PlatformId.Bitbucket, url: defaults.endpoint, }); config = { diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index c6f34b19bd1c19..fa055a6ce78e48 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -1,6 +1,7 @@ import URL from 'url'; import is from '@sindresorhus/is'; import { lt } from 'semver'; +import { PlatformId } from '../../constants'; import { REPOSITORY_ACCESS_FORBIDDEN, REPOSITORY_ARCHIVED, @@ -9,7 +10,6 @@ import { REPOSITORY_EMPTY, REPOSITORY_MIRRORED, } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITEA } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import * as git from '../../util/git'; @@ -50,7 +50,7 @@ interface GiteaRepoConfig { } const defaults = { - hostType: PLATFORM_TYPE_GITEA, + hostType: PlatformId.Gitea, endpoint: 'https://gitea.com/api/v1/', version: '0.0.0', }; @@ -287,7 +287,7 @@ const platform: Platform = { // Find options for current host and determine Git endpoint const opts = hostRules.find({ - hostType: PLATFORM_TYPE_GITEA, + hostType: PlatformId.Gitea, url: defaults.endpoint, }); const gitEndpoint = URL.parse(repo.clone_url); diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index bc76286e56fb65..04b4c146d7d37c 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -2,6 +2,7 @@ import URL from 'url'; import is from '@sindresorhus/is'; import delay from 'delay'; import { DateTime } from 'luxon'; +import { PlatformId } from '../../constants'; import { PLATFORM_INTEGRATION_UNAUTHORIZED, REPOSITORY_ACCESS_FORBIDDEN, @@ -15,7 +16,6 @@ import { REPOSITORY_NOT_FOUND, REPOSITORY_RENAMED, } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import { ExternalHostError } from '../../types/errors/external-host-error'; @@ -69,7 +69,7 @@ const githubApi = new githubHttp.GithubHttp(); let config: LocalRepoConfig = {} as any; const defaults = { - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, endpoint: 'https://api.github.com/', }; @@ -188,7 +188,7 @@ export async function initRepo({ githubHttp.setBaseUrl(endpoint); } const opts = hostRules.find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url: defaults.endpoint, }); config.isGhe = URL.parse(defaults.endpoint).host !== 'api.github.com'; @@ -665,7 +665,7 @@ export async function getPrList(): Promise { ).body; } catch (err) /* istanbul ignore next */ { logger.debug({ err }, 'getPrList err'); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } config.prList = prList .filter( @@ -1275,7 +1275,7 @@ async function getComments(issueNo: number): Promise { } catch (err) /* istanbul ignore next */ { if (err.statusCode === 404) { logger.debug('404 response when retrieving comments'); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } throw err; } diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 236bc5f8595385..25ba11b2a0a9b2 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -3,6 +3,7 @@ import is from '@sindresorhus/is'; import delay from 'delay'; import pAll from 'p-all'; import { lt } from 'semver'; +import { PlatformId } from '../../constants'; import { CONFIG_GIT_URL_UNAVAILABLE, PLATFORM_AUTHENTICATION_ERROR, @@ -15,7 +16,6 @@ import { REPOSITORY_NOT_FOUND, TEMPORARY_ERROR, } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import * as git from '../../util/git'; @@ -66,7 +66,7 @@ let config: { } = {} as any; const defaults = { - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, endpoint: 'https://gitlab.com/api/v4/', version: '0.0.0', }; diff --git a/lib/platform/index.spec.ts b/lib/platform/index.spec.ts index 1a29be4909fd66..08262220769875 100644 --- a/lib/platform/index.spec.ts +++ b/lib/platform/index.spec.ts @@ -1,6 +1,6 @@ import * as httpMock from '../../test/http-mock'; +import { PlatformId } from '../constants'; import { PLATFORM_NOT_FOUND } from '../constants/error-messages'; -import { PLATFORM_TYPE_BITBUCKET } from '../constants/platforms'; import { loadModules } from '../util/modules'; import type { Platform } from './types'; import * as platform from '.'; @@ -51,7 +51,7 @@ describe('platform/index', () => { .basicAuth({ user: 'abc', pass: '123' }) .reply(200, { uuid: 123 }); const config = { - platform: PLATFORM_TYPE_BITBUCKET, + platform: PlatformId.Bitbucket, gitAuthor: 'user@domain.com', username: 'abc', password: '123', @@ -67,7 +67,7 @@ describe('platform/index', () => { username: 'abc', }, ], - platform: PLATFORM_TYPE_BITBUCKET, + platform: PlatformId.Bitbucket, }); }); }); diff --git a/lib/util/host-rules.spec.ts b/lib/util/host-rules.spec.ts index 7bc63e902dde7d..04c965b43d5f3e 100644 --- a/lib/util/host-rules.spec.ts +++ b/lib/util/host-rules.spec.ts @@ -1,7 +1,4 @@ -import { - PLATFORM_TYPE_AZURE, - PLATFORM_TYPE_GITHUB, -} from '../constants/platforms'; +import { PlatformId } from '../constants'; import * as datasourceNuget from '../datasource/nuget'; import { add, clear, find, findAll, hosts } from './host-rules'; @@ -13,7 +10,7 @@ describe('util/host-rules', () => { it('throws if both domainName and hostName', () => { expect(() => add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, domainName: 'github.com', hostName: 'api.github.com', } as any) @@ -22,7 +19,7 @@ describe('util/host-rules', () => { it('throws if both domainName and baseUrl', () => { expect(() => add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, domainName: 'github.com', matchHost: 'https://api.github.com', } as any) @@ -31,7 +28,7 @@ describe('util/host-rules', () => { it('throws if both hostName and baseUrl', () => { expect(() => add({ - hostType: PLATFORM_TYPE_AZURE, + hostType: PlatformId.Azure, hostName: 'api.github.com', matchHost: 'https://api.github.com', } as any) @@ -113,25 +110,25 @@ describe('util/host-rules', () => { it('matches on specific path', () => { // Initialized platform holst rule add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com', token: 'abc', }); // Initialized generic host rule for github platform add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com', token: 'abc', }); // specific host rule for using other token in different org add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com/repos/org-b/', token: 'def', }); expect( find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url: 'https://api.github.com/repos/org-b/someRepo/tags?per_page=100', }).token ).toEqual('def'); @@ -144,7 +141,7 @@ describe('util/host-rules', () => { }); expect( find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url: 'https://api.github.com/repos/org-b/someRepo/tags?per_page=100', }).token ).toEqual('abc'); @@ -158,7 +155,7 @@ describe('util/host-rules', () => { it('matches if hostType is configured and host rule is filtered with datasource', () => { add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com', token: 'abc', }); diff --git a/lib/util/http/auth.spec.ts b/lib/util/http/auth.spec.ts index 8737d084b25933..72da33c84b21fc 100644 --- a/lib/util/http/auth.spec.ts +++ b/lib/util/http/auth.spec.ts @@ -1,10 +1,6 @@ import { NormalizedOptions } from 'got'; import { partial } from '../../../test/util'; -import { - PLATFORM_TYPE_GITEA, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { applyAuthorization, removeAuthorization } from './auth'; import { GotOptions } from './types'; @@ -33,7 +29,7 @@ describe('util/http/auth', () => { it('gitea password', () => { const opts: GotOptions = { headers: {}, - hostType: PLATFORM_TYPE_GITEA, + hostType: PlatformId.Gitea, password: 'XXXX', }; @@ -54,7 +50,7 @@ describe('util/http/auth', () => { const opts: GotOptions = { headers: {}, token: 'XXXX', - hostType: PLATFORM_TYPE_GITEA, + hostType: PlatformId.Gitea, }; applyAuthorization(opts); @@ -74,7 +70,7 @@ describe('util/http/auth', () => { const opts: GotOptions = { headers: {}, token: 'XXX', - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, }; applyAuthorization(opts); @@ -112,7 +108,7 @@ describe('util/http/auth', () => { headers: {}, // Personal Access Token is exactly 20 characters long token: '0123456789012345test', - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, }; applyAuthorization(opts); @@ -133,7 +129,7 @@ describe('util/http/auth', () => { headers: {}, token: 'a40bdd925a0c0b9c4cdd19d101c0df3b2bcd063ab7ad6706f03bcffcec01test', - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, }; applyAuthorization(opts); diff --git a/lib/util/http/auth.ts b/lib/util/http/auth.ts index a8dfc3f42f4448..59dba806f71564 100644 --- a/lib/util/http/auth.ts +++ b/lib/util/http/auth.ts @@ -3,8 +3,8 @@ import type { NormalizedOptions } from 'got'; import { GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PLATFORM_TYPE_GITEA, -} from '../../constants/platforms'; + PlatformId, +} from '../../constants'; import type { GotOptions } from './types'; export function applyAuthorization(inOptions: GotOptions): GotOptions { @@ -15,7 +15,7 @@ export function applyAuthorization(inOptions: GotOptions): GotOptions { } if (options.token) { - if (options.hostType === PLATFORM_TYPE_GITEA) { + if (options.hostType === PlatformId.Gitea) { options.headers.authorization = `token ${options.token}`; } else if (GITHUB_API_USING_HOST_TYPES.includes(options.hostType)) { options.headers.authorization = `token ${options.token}`; diff --git a/lib/util/http/bitbucket-server.spec.ts b/lib/util/http/bitbucket-server.spec.ts index 65cf77d7d607ae..a1608178e7e833 100644 --- a/lib/util/http/bitbucket-server.spec.ts +++ b/lib/util/http/bitbucket-server.spec.ts @@ -1,5 +1,5 @@ import * as httpMock from '../../../test/http-mock'; -import { PLATFORM_TYPE_BITBUCKET_SERVER } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as hostRules from '../host-rules'; import { BitbucketServerHttp, setBaseUrl } from './bitbucket-server'; @@ -16,7 +16,7 @@ describe('util/http/bitbucket-server', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_BITBUCKET_SERVER, + hostType: PlatformId.BitbucketServer, matchHost: baseUrl, token: 'token', }); diff --git a/lib/util/http/bitbucket-server.ts b/lib/util/http/bitbucket-server.ts index dd96385b99d0b1..6d2d91aa3e96a7 100644 --- a/lib/util/http/bitbucket-server.ts +++ b/lib/util/http/bitbucket-server.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_BITBUCKET_SERVER } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { resolveBaseUrl } from '../url'; import { Http, HttpOptions, HttpResponse, InternalHttpOptions } from '.'; @@ -9,7 +9,7 @@ export const setBaseUrl = (url: string): void => { export class BitbucketServerHttp extends Http { constructor(options?: HttpOptions) { - super(PLATFORM_TYPE_BITBUCKET_SERVER, options); + super(PlatformId.BitbucketServer, options); } protected override request( diff --git a/lib/util/http/bitbucket.spec.ts b/lib/util/http/bitbucket.spec.ts index ace4b8a50c755a..ae38ead34ebdda 100644 --- a/lib/util/http/bitbucket.spec.ts +++ b/lib/util/http/bitbucket.spec.ts @@ -1,5 +1,5 @@ import * as httpMock from '../../../test/http-mock'; -import { PLATFORM_TYPE_BITBUCKET } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as hostRules from '../host-rules'; import { BitbucketHttp, setBaseUrl } from './bitbucket'; @@ -16,7 +16,7 @@ describe('util/http/bitbucket', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_BITBUCKET, + hostType: PlatformId.Bitbucket, matchHost: baseUrl, token: 'token', }); diff --git a/lib/util/http/bitbucket.ts b/lib/util/http/bitbucket.ts index 10f56e4a25664c..1eaaab9e531d3e 100644 --- a/lib/util/http/bitbucket.ts +++ b/lib/util/http/bitbucket.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_BITBUCKET } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { Http, HttpOptions, HttpResponse, InternalHttpOptions } from '.'; let baseUrl = 'https://api.bitbucket.org/'; @@ -9,7 +9,7 @@ export const setBaseUrl = (url: string): void => { export class BitbucketHttp extends Http { constructor(options?: HttpOptions) { - super(PLATFORM_TYPE_BITBUCKET, options); + super(PlatformId.Bitbucket, options); } protected override request( diff --git a/lib/util/http/gitea.ts b/lib/util/http/gitea.ts index 5410284e3852eb..ff53983fc856d7 100644 --- a/lib/util/http/gitea.ts +++ b/lib/util/http/gitea.ts @@ -1,4 +1,4 @@ -import { PLATFORM_TYPE_GITEA } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { resolveBaseUrl } from '../url'; import { Http, HttpOptions, HttpResponse, InternalHttpOptions } from '.'; @@ -30,7 +30,7 @@ function resolveUrl(path: string, base: string): URL { export class GiteaHttp extends Http { constructor(options?: HttpOptions) { - super(PLATFORM_TYPE_GITEA, options); + super(PlatformId.Gitea, options); } protected override async request( diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index 478c72f54f1233..e555fed6310891 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -1,13 +1,13 @@ import is from '@sindresorhus/is'; import pAll from 'p-all'; import parseLinkHeader from 'parse-link-header'; +import { PlatformId } from '../../constants'; import { PLATFORM_BAD_CREDENTIALS, PLATFORM_INTEGRATION_UNAUTHORIZED, PLATFORM_RATE_LIMIT_EXCEEDED, REPOSITORY_CHANGED, } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; import { maskToken } from '../mask'; @@ -55,15 +55,15 @@ function handleGotError( err.code === 'ECONNRESET') ) { logger.debug({ err }, 'GitHub failure: RequestError'); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } if (err.name === 'ParseError') { logger.debug({ err }, ''); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } if (err.statusCode >= 500 && err.statusCode < 600) { logger.debug({ err }, 'GitHub failure: 5xx'); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } if ( err.statusCode === 403 && @@ -100,7 +100,7 @@ function handleGotError( 'GitHub failure: Bad credentials' ); if (rateLimit === '60') { - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } throw new Error(PLATFORM_BAD_CREDENTIALS); } @@ -120,7 +120,7 @@ function handleGotError( throw err; } logger.debug({ err }, '422 Error thrown from GitHub'); - throw new ExternalHostError(err, PLATFORM_TYPE_GITHUB); + throw new ExternalHostError(err, PlatformId.Github); } if ( err.statusCode === 410 && @@ -159,7 +159,7 @@ function constructAcceptString(input?: any): string { export class GithubHttp extends Http { constructor( - hostType: string = PLATFORM_TYPE_GITHUB, + hostType: string = PlatformId.Github, options?: GithubHttpOptions ) { super(hostType, options); diff --git a/lib/util/http/gitlab.spec.ts b/lib/util/http/gitlab.spec.ts index 103640c7b078b2..729ac29c28dacc 100644 --- a/lib/util/http/gitlab.spec.ts +++ b/lib/util/http/gitlab.spec.ts @@ -1,12 +1,12 @@ import * as httpMock from '../../../test/http-mock'; +import { PlatformId } from '../../constants'; import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages'; -import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms'; import { GitlabReleasesDatasource } from '../../datasource/gitlab-releases'; import * as hostRules from '../host-rules'; import { GitlabHttp, setBaseUrl } from './gitlab'; hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, token: '123test', }); @@ -22,7 +22,7 @@ describe('util/http/gitlab', () => { delete process.env.GITLAB_IGNORE_REPO_URL; hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, token: 'abc123', }); }); @@ -79,7 +79,7 @@ describe('util/http/gitlab', () => { it('supports different datasources', async () => { const gitlabApiDatasource = new GitlabHttp(GitlabReleasesDatasource.id); - hostRules.add({ hostType: PLATFORM_TYPE_GITLAB, token: 'abc' }); + hostRules.add({ hostType: PlatformId.Gitlab, token: 'abc' }); hostRules.add({ hostType: GitlabReleasesDatasource.id, token: 'def', diff --git a/lib/util/http/gitlab.ts b/lib/util/http/gitlab.ts index 18eacdd2240f81..7c6589ce98aa50 100644 --- a/lib/util/http/gitlab.ts +++ b/lib/util/http/gitlab.ts @@ -1,5 +1,5 @@ import parseLinkHeader from 'parse-link-header'; -import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { logger } from '../../logger'; import { ExternalHostError } from '../../types/errors/external-host-error'; import { parseUrl } from '../url'; @@ -20,10 +20,7 @@ export interface GitlabHttpOptions extends InternalHttpOptions { } export class GitlabHttp extends Http { - constructor( - type: string = PLATFORM_TYPE_GITLAB, - options?: GitlabHttpOptions - ) { + constructor(type: string = PlatformId.Gitlab, options?: GitlabHttpOptions) { super(type, options); } @@ -73,7 +70,7 @@ export class GitlabHttp extends Http { err.statusCode === 429 || (err.statusCode >= 500 && err.statusCode < 600) ) { - throw new ExternalHostError(err, PLATFORM_TYPE_GITLAB); + throw new ExternalHostError(err, PlatformId.Gitlab); } const platformFailureCodes = [ 'EAI_AGAIN', @@ -82,10 +79,10 @@ export class GitlabHttp extends Http { 'UNABLE_TO_VERIFY_LEAF_SIGNATURE', ]; if (platformFailureCodes.includes(err.code)) { - throw new ExternalHostError(err, PLATFORM_TYPE_GITLAB); + throw new ExternalHostError(err, PlatformId.Gitlab); } if (err.name === 'ParseError') { - throw new ExternalHostError(err, PLATFORM_TYPE_GITLAB); + throw new ExternalHostError(err, PlatformId.Gitlab); } throw err; } diff --git a/lib/util/http/host-rules.spec.ts b/lib/util/http/host-rules.spec.ts index b4c8ebfd944c50..00e04a386ee76c 100644 --- a/lib/util/http/host-rules.spec.ts +++ b/lib/util/http/host-rules.spec.ts @@ -1,8 +1,4 @@ -import { - PLATFORM_TYPE_GITEA, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import { bootstrap } from '../../proxy'; import * as hostRules from '../host-rules'; import { applyHostRules } from './host-rules'; @@ -13,7 +9,7 @@ jest.mock('global-agent'); describe('util/http/host-rules', () => { const options = { - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, }; beforeEach(() => { // reset module @@ -24,11 +20,11 @@ describe('util/http/host-rules', () => { // clean up hostRules hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, token: 'token', }); hostRules.add({ - hostType: PLATFORM_TYPE_GITEA, + hostType: PlatformId.Gitea, password: 'password', }); @@ -39,7 +35,7 @@ describe('util/http/host-rules', () => { }); hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, token: 'abc', }); @@ -67,7 +63,7 @@ describe('util/http/host-rules', () => { }); it('adds auth', () => { - expect(applyHostRules(url, { hostType: PLATFORM_TYPE_GITEA })) + expect(applyHostRules(url, { hostType: PlatformId.Gitea })) .toMatchInlineSnapshot(` Object { "hostType": "gitea", diff --git a/lib/util/http/host-rules.ts b/lib/util/http/host-rules.ts index 86537e4ea12c17..4d86c913d65219 100644 --- a/lib/util/http/host-rules.ts +++ b/lib/util/http/host-rules.ts @@ -1,9 +1,8 @@ import { GITHUB_API_USING_HOST_TYPES, GITLAB_API_USING_HOST_TYPES, - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; + PlatformId, +} from '../../constants'; import { logger } from '../../logger'; import { hasProxy } from '../../proxy'; import type { HostRule } from '../../types'; @@ -22,11 +21,11 @@ function findMatchingRules(options: GotOptions, url: string): HostRule { // Fallback to `github` hostType if ( GITHUB_API_USING_HOST_TYPES.includes(hostType) && - hostType !== PLATFORM_TYPE_GITHUB + hostType !== PlatformId.Github ) { res = { ...hostRules.find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url, }), ...res, @@ -36,11 +35,11 @@ function findMatchingRules(options: GotOptions, url: string): HostRule { // Fallback to `gitlab` hostType if ( GITLAB_API_USING_HOST_TYPES.includes(hostType) && - hostType !== PLATFORM_TYPE_GITLAB + hostType !== PlatformId.Gitlab ) { res = { ...hostRules.find({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, url, }), ...res, diff --git a/lib/workers/global/autodiscover.spec.ts b/lib/workers/global/autodiscover.spec.ts index b5cdaaa7700f5b..076d179cc3fa9c 100644 --- a/lib/workers/global/autodiscover.spec.ts +++ b/lib/workers/global/autodiscover.spec.ts @@ -1,5 +1,5 @@ import type { RenovateConfig } from '../../config/types'; -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as platform from '../../platform'; import * as _ghApi from '../../platform/github'; import * as _hostRules from '../../util/host-rules'; @@ -18,7 +18,7 @@ describe('workers/global/autodiscover', () => { jest.resetAllMocks(); config = {}; await platform.initPlatform({ - platform: PLATFORM_TYPE_GITHUB, + platform: PlatformId.Github, token: '123test', endpoint: 'endpoint', }); @@ -28,7 +28,7 @@ describe('workers/global/autodiscover', () => { }); it('autodiscovers github but empty', async () => { config.autodiscover = true; - config.platform = PLATFORM_TYPE_GITHUB; + config.platform = PlatformId.Github; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -38,7 +38,7 @@ describe('workers/global/autodiscover', () => { }); it('autodiscovers github repos', async () => { config.autodiscover = true; - config.platform = PLATFORM_TYPE_GITHUB; + config.platform = PlatformId.Github; hostRules.find = jest.fn(() => ({ token: 'abc', })); @@ -49,7 +49,7 @@ describe('workers/global/autodiscover', () => { it('filters autodiscovered github repos', async () => { config.autodiscover = true; config.autodiscoverFilter = 'project/re*'; - config.platform = PLATFORM_TYPE_GITHUB; + config.platform = PlatformId.Github; hostRules.find = jest.fn(() => ({ token: 'abc', })); diff --git a/lib/workers/global/config/parse/env.spec.ts b/lib/workers/global/config/parse/env.spec.ts index 528179ea0a99ea..714d2732eb6d0b 100644 --- a/lib/workers/global/config/parse/env.spec.ts +++ b/lib/workers/global/config/parse/env.spec.ts @@ -1,8 +1,5 @@ import type { RenovateOptions } from '../../../../config/types'; -import { - PLATFORM_TYPE_BITBUCKET, - PLATFORM_TYPE_GITLAB, -} from '../../../../constants/platforms'; +import { PlatformId } from '../../../../constants'; import * as env from './env'; describe('workers/global/config/parse/env', () => { @@ -74,7 +71,7 @@ describe('workers/global/config/parse/env', () => { }); it('supports GitLab token', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PLATFORM_TYPE_GITLAB, + RENOVATE_PLATFORM: PlatformId.Gitlab, RENOVATE_TOKEN: 'a gitlab.com token', }; // FIXME: explicit assert condition @@ -82,7 +79,7 @@ describe('workers/global/config/parse/env', () => { }); it('supports GitLab custom endpoint', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PLATFORM_TYPE_GITLAB, + RENOVATE_PLATFORM: PlatformId.Gitlab, RENOVATE_TOKEN: 'a gitlab token', RENOVATE_ENDPOINT: 'a gitlab endpoint', }; @@ -158,7 +155,7 @@ describe('workers/global/config/parse/env', () => { }); it('supports Bitbucket token', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PLATFORM_TYPE_BITBUCKET, + RENOVATE_PLATFORM: PlatformId.Bitbucket, RENOVATE_ENDPOINT: 'a bitbucket endpoint', RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', @@ -168,7 +165,7 @@ describe('workers/global/config/parse/env', () => { }); it('supports Bitbucket username/password', () => { const envParam: NodeJS.ProcessEnv = { - RENOVATE_PLATFORM: PLATFORM_TYPE_BITBUCKET, + RENOVATE_PLATFORM: PlatformId.Bitbucket, RENOVATE_ENDPOINT: 'a bitbucket endpoint', RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', diff --git a/lib/workers/global/config/parse/env.ts b/lib/workers/global/config/parse/env.ts index 10dc8abcfb40e9..a6e91c219ff710 100644 --- a/lib/workers/global/config/parse/env.ts +++ b/lib/workers/global/config/parse/env.ts @@ -2,7 +2,7 @@ import is from '@sindresorhus/is'; import { getOptions } from '../../../../config/options'; import type { AllConfig, RenovateOptions } from '../../../../config/types'; -import { PLATFORM_TYPE_GITHUB } from '../../../../constants/platforms'; +import { PlatformId } from '../../../../constants'; import { getDatasourceList } from '../../../../datasource'; import { logger } from '../../../../logger'; import type { HostRule } from '../../../../types'; @@ -82,7 +82,7 @@ export function getConfig(env: NodeJS.ProcessEnv): AllConfig { if (env.GITHUB_COM_TOKEN) { logger.debug(`Converting GITHUB_COM_TOKEN into a global host rule`); config.hostRules.push({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'github.com', token: env.GITHUB_COM_TOKEN, }); diff --git a/lib/workers/global/index.spec.ts b/lib/workers/global/index.spec.ts index 13d93bcba47971..92f46e7e91ca4f 100644 --- a/lib/workers/global/index.spec.ts +++ b/lib/workers/global/index.spec.ts @@ -1,10 +1,7 @@ import { expect } from '@jest/globals'; import { ERROR, WARN } from 'bunyan'; import { fs, logger } from '../../../test/util'; -import { - PLATFORM_TYPE_GITHUB, - PLATFORM_TYPE_GITLAB, -} from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import * as datasourceDocker from '../../datasource/docker'; import * as _platform from '../../platform'; import * as _repositoryWorker from '../repository'; @@ -114,7 +111,7 @@ describe('workers/global/index', () => { it('github', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: ['a'], - platform: PLATFORM_TYPE_GITHUB, + platform: PlatformId.Github, endpoint: 'https://github.com/', }); await globalWorker.start(); @@ -124,7 +121,7 @@ describe('workers/global/index', () => { it('gitlab', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: [{ repository: 'a' }], - platform: PLATFORM_TYPE_GITLAB, + platform: PlatformId.Gitlab, endpoint: 'https://my.gitlab.com/', }); await globalWorker.start(); @@ -137,7 +134,7 @@ describe('workers/global/index', () => { it('successfully write file', async () => { configParser.parseConfigs.mockResolvedValueOnce({ repositories: ['myOrg/myRepo'], - platform: PLATFORM_TYPE_GITHUB, + platform: PlatformId.Github, endpoint: 'https://github.com/', writeDiscoveredRepos: '/tmp/renovate-output.json', }); diff --git a/lib/workers/pr/changelog/github.spec.ts b/lib/workers/pr/changelog/github.spec.ts index 8a260df07a9327..95bfe0d6b85557 100644 --- a/lib/workers/pr/changelog/github.spec.ts +++ b/lib/workers/pr/changelog/github.spec.ts @@ -1,5 +1,5 @@ import * as httpMock from '../../../../test/http-mock'; -import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import * as hostRules from '../../../util/host-rules'; import * as semverVersioning from '../../../versioning/semver'; import type { BranchUpgradeConfig } from '../../types'; @@ -39,7 +39,7 @@ describe('workers/pr/changelog/github', () => { beforeEach(() => { hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com/', token: 'abc', }); @@ -167,7 +167,7 @@ describe('workers/pr/changelog/github', () => { it('supports github enterprise and github.com changelog', async () => { hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, token: 'super_secret', matchHost: 'https://github-enterprise.example.com/', }); @@ -182,7 +182,7 @@ describe('workers/pr/changelog/github', () => { it('supports github enterprise and github enterprise changelog', async () => { hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); diff --git a/lib/workers/pr/changelog/gitlab.spec.ts b/lib/workers/pr/changelog/gitlab.spec.ts index 1235d29d958f5e..7894bc600812a7 100644 --- a/lib/workers/pr/changelog/gitlab.spec.ts +++ b/lib/workers/pr/changelog/gitlab.spec.ts @@ -1,5 +1,5 @@ import * as httpMock from '../../../../test/http-mock'; -import { PLATFORM_TYPE_GITLAB } from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import * as hostRules from '../../../util/host-rules'; import * as semverVersioning from '../../../versioning/semver'; import type { BranchUpgradeConfig } from '../../types'; @@ -40,7 +40,7 @@ describe('workers/pr/changelog/gitlab', () => { beforeEach(() => { hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, matchHost, token: 'abc', }); @@ -181,7 +181,7 @@ describe('workers/pr/changelog/gitlab', () => { }); it('supports gitlab enterprise and gitlab enterprise changelog', async () => { hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, matchHost: 'https://gitlab-enterprise.example.com/', token: 'abc', }); @@ -198,7 +198,7 @@ describe('workers/pr/changelog/gitlab', () => { it('supports self-hosted gitlab changelog', async () => { httpMock.scope('https://git.test.com').persist().get(/.*/).reply(200, []); hostRules.add({ - hostType: PLATFORM_TYPE_GITLAB, + hostType: PlatformId.Gitlab, matchHost: 'https://git.test.com/', token: 'abc', }); @@ -207,7 +207,7 @@ describe('workers/pr/changelog/gitlab', () => { expect( await getChangeLogJSON({ ...upgrade, - platform: PLATFORM_TYPE_GITLAB, + platform: PlatformId.Gitlab, sourceUrl: 'https://git.test.com/meno/dropzone/', endpoint: 'https://git.test.com/api/v4/', }) diff --git a/lib/workers/pr/changelog/index.spec.ts b/lib/workers/pr/changelog/index.spec.ts index ae462fceeca812..051a141def702d 100644 --- a/lib/workers/pr/changelog/index.spec.ts +++ b/lib/workers/pr/changelog/index.spec.ts @@ -1,6 +1,6 @@ import * as httpMock from '../../../../test/http-mock'; import { partial } from '../../../../test/util'; -import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import * as hostRules from '../../../util/host-rules'; import * as semverVersioning from '../../../versioning/semver'; import type { BranchConfig } from '../../types'; @@ -36,7 +36,7 @@ describe('workers/pr/changelog/index', () => { beforeEach(() => { hostRules.clear(); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://api.github.com/', token: 'abc', }); @@ -193,7 +193,7 @@ describe('workers/pr/changelog/index', () => { it('supports github enterprise and github.com changelog', async () => { httpMock.scope(githubApiHost).persist().get(/.*/).reply(200, []); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, token: 'super_secret', matchHost: 'https://github-enterprise.example.com/', }); @@ -213,7 +213,7 @@ describe('workers/pr/changelog/index', () => { .get(/.*/) .reply(200, []); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); @@ -236,7 +236,7 @@ describe('workers/pr/changelog/index', () => { .get(/.*/) .reply(200, []); hostRules.add({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, matchHost: 'https://github-enterprise.example.com/', token: 'abc', }); diff --git a/lib/workers/pr/changelog/source-github.ts b/lib/workers/pr/changelog/source-github.ts index 3dee765d2e0825..720ef8c4d8b0c1 100644 --- a/lib/workers/pr/changelog/source-github.ts +++ b/lib/workers/pr/changelog/source-github.ts @@ -1,5 +1,5 @@ import URL from 'url'; -import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import type { Release } from '../../../datasource/types'; import { logger } from '../../../logger'; import * as memCache from '../../../util/cache/memory'; @@ -47,7 +47,7 @@ export async function getChangeLogJSON({ ? 'https://api.github.com/' : sourceUrl; const config = hostRules.find({ - hostType: PLATFORM_TYPE_GITHUB, + hostType: PlatformId.Github, url, }); // istanbul ignore if diff --git a/lib/workers/pr/index.spec.ts b/lib/workers/pr/index.spec.ts index d82283479371cd..63e7ae7cab6f42 100644 --- a/lib/workers/pr/index.spec.ts +++ b/lib/workers/pr/index.spec.ts @@ -1,5 +1,5 @@ import { getConfig, git, mocked, partial, platform } from '../../../test/util'; -import { PLATFORM_TYPE_GITLAB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import type { Pr } from '../../platform/types'; import { BranchStatus } from '../../types'; import * as _limits from '../global/limits'; @@ -621,7 +621,7 @@ describe('workers/pr/index', () => { git.getBranchLastCommitTime.mockResolvedValueOnce(new Date()); config.prCreation = 'not-pending'; config.artifactErrors = [{}]; - config.platform = PLATFORM_TYPE_GITLAB; + config.platform = PlatformId.Gitlab; const { pr } = await prWorker.ensurePr(config); expect(pr).toMatchObject({ displayNumber: 'New Pull Request' }); }); diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts index d2c34f78cfd011..ef16629b7a969c 100644 --- a/lib/workers/repository/dependency-dashboard.spec.ts +++ b/lib/workers/repository/dependency-dashboard.spec.ts @@ -8,7 +8,7 @@ import { platform, } from '../../../test/util'; import { setGlobalConfig } from '../../config/global'; -import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms'; +import { PlatformId } from '../../constants'; import type { Platform } from '../../platform'; import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types'; import * as dependencyDashboard from './dependency-dashboard'; @@ -19,7 +19,7 @@ let config: RenovateConfig; beforeEach(() => { jest.clearAllMocks(); config = getConfig(); - config.platform = PLATFORM_TYPE_GITHUB; + config.platform = PlatformId.Github; config.errors = []; config.warnings = []; }); diff --git a/lib/workers/repository/finalise/prune.spec.ts b/lib/workers/repository/finalise/prune.spec.ts index 05868f977131b0..6e2c0c7418e180 100644 --- a/lib/workers/repository/finalise/prune.spec.ts +++ b/lib/workers/repository/finalise/prune.spec.ts @@ -5,7 +5,7 @@ import { platform, } from '../../../../test/util'; import { setGlobalConfig } from '../../../config/global'; -import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms'; +import { PlatformId } from '../../../constants'; import * as cleanup from './prune'; jest.mock('../../../util/git'); @@ -14,7 +14,7 @@ let config: RenovateConfig; beforeEach(() => { jest.resetAllMocks(); config = getConfig(); - config.platform = PLATFORM_TYPE_GITHUB; + config.platform = PlatformId.Github; config.errors = []; config.warnings = []; }); From dd0f18346a9dcb59cf8c5754dd7fd6565dd1bb88 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 09:33:09 +0000 Subject: [PATCH 09/38] chore(deps): update dependency eslint-plugin-jest to v24.5.0 (#12038) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 47cd6e63c7b889..f0f52af67b5aa9 100644 --- a/package.json +++ b/package.json @@ -248,7 +248,7 @@ "eslint-config-prettier": "8.3.0", "eslint-formatter-gha": "1.2.0", "eslint-plugin-import": "2.24.2", - "eslint-plugin-jest": "24.4.3", + "eslint-plugin-jest": "24.5.0", "eslint-plugin-promise": "5.1.0", "glob": "7.2.0", "graphql": "15.6.0", diff --git a/yarn.lock b/yarn.lock index 146aa9fd2063fa..11143f3fd92014 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4065,10 +4065,10 @@ eslint-plugin-import@2.24.2: resolve "^1.20.0" tsconfig-paths "^3.11.0" -eslint-plugin-jest@24.4.3: - version "24.4.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.4.3.tgz#dd59e32a7d233a92672468082c24c337a5954873" - integrity sha512-cZPTqF/35/usP9gvjslj6pE+2lpr1KoZvjvDWRlfCP27LSRHBUhJV6hBPk47TksH3lSt28sDpIlp8owK0hWtsA== +eslint-plugin-jest@24.5.0: + version "24.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.5.0.tgz#a223a0040a19af749a161807254f0e47f5bfdcc3" + integrity sha512-Cm+XdX7Nms2UXGRnivHFVcM3ZmlKheHvc9VD78iZLO1XcqB59WbVjrMSiesCbHDlToxWjMJDiJMgc1CzFE13Vg== dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" From 82cab2312767d9b046349ddaf79371b7b853f013 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 16:42:20 +0000 Subject: [PATCH 10/38] chore(deps): update dependency @types/node to v14.17.20 (#12043) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f0f52af67b5aa9..cc78ea571b1009 100644 --- a/package.json +++ b/package.json @@ -227,7 +227,7 @@ "@types/markdown-table": "2.0.0", "@types/moo": "0.5.5", "@types/nock": "10.0.3", - "@types/node": "14.17.19", + "@types/node": "14.17.20", "@types/node-emoji": "1.8.1", "@types/parse-link-header": "1.0.0", "@types/registry-auth-token": "4.2.1", diff --git a/yarn.lock b/yarn.lock index 11143f3fd92014..e879b2922a403f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2018,10 +2018,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.2.tgz#5764ca9aa94470adb4e1185fe2e9f19458992b2e" integrity sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ== -"@types/node@14.17.19": - version "14.17.19" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.19.tgz#7341e9ac1b5d748d7a3ddc04336ed536a6f91c31" - integrity sha512-jjYI6NkyfXykucU6ELEoT64QyKOdvaA6enOqKtP4xUsGY0X0ZUZz29fUmrTRo+7v7c6TgDu82q3GHHaCEkqZwA== +"@types/node@14.17.20": + version "14.17.20" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.20.tgz#74cc80438fd0467dc4377ee5bbad89a886df3c10" + integrity sha512-gI5Sl30tmhXsqkNvopFydP7ASc4c2cLfGNQrVKN3X90ADFWFsPEsotm/8JHSUJQKTHbwowAHtcJPeyVhtKv0TQ== "@types/node@^13.7.0": version "13.13.52" From acc9886efd1ec9d9bb68aece0d60d04c431cf974 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 17:58:25 +0000 Subject: [PATCH 11/38] chore(deps): update dependency yarn to v1.22.13 (#12044) Co-authored-by: Renovate Bot --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6897ef241ab20b..d9048f67da85b3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,4 +2,4 @@ FROM containerbase/node:v14.18.0@sha256:50de253d90cbb55711d47927e56850c32ea5fcb7 # renovate: datasource=npm -RUN install-tool yarn 1.22.11 +RUN install-tool yarn 1.22.13 From 112d6d891ccfea0a5ca5db0d8149290d149014a8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 19:18:11 +0000 Subject: [PATCH 12/38] chore(deps): update jest monorepo to v27.2.4 (#12046) Co-authored-by: Renovate Bot --- package.json | 8 ++--- yarn.lock | 99 +++++++++++++--------------------------------------- 2 files changed, 29 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index cc78ea571b1009..f1ccdfd086a4b7 100644 --- a/package.json +++ b/package.json @@ -200,9 +200,9 @@ }, "devDependencies": { "@actions/core": "1.6.0", - "@jest/globals": "27.2.3", - "@jest/reporters": "27.2.3", - "@jest/test-result": "27.2.3", + "@jest/globals": "27.2.4", + "@jest/reporters": "27.2.4", + "@jest/test-result": "27.2.4", "@ls-lint/ls-lint": "1.10.0", "@renovate/eslint-plugin": "https://github.com/renovatebot/eslint-plugin#v0.0.3", "@semantic-release/exec": "6.0.1", @@ -253,7 +253,7 @@ "glob": "7.2.0", "graphql": "15.6.0", "husky": "7.0.2", - "jest": "27.2.3", + "jest": "27.2.4", "jest-extended": "0.11.5", "jest-github-actions-reporter": "1.0.3", "jest-junit": "12.3.0", diff --git a/yarn.lock b/yarn.lock index e879b2922a403f..2721aba585c2e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1018,7 +1018,7 @@ chalk "^2.0.1" slash "^2.0.0" -"@jest/console@^27.2.3", "@jest/console@^27.2.4": +"@jest/console@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.2.4.tgz#2f1a4bf82b9940065d4818fac271def99ec55e5e" integrity sha512-94znCKynPZpDpYHQ6esRJSc11AmONrVkBOBZiD7S+bSubHhrUfbS95EY5HIOxhm4PQO7cnvZkL3oJcY0oMA+Wg== @@ -1030,7 +1030,7 @@ jest-util "^27.2.4" slash "^3.0.0" -"@jest/core@^27.2.3", "@jest/core@^27.2.4": +"@jest/core@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/core/-/core-27.2.4.tgz#0b932da787d64848eab720dbb88e5b7a3f86e539" integrity sha512-UNQLyy+rXoojNm2MGlapgzWhZD1CT1zcHZQYeiD0xE7MtJfC19Q6J5D/Lm2l7i4V97T30usKDoEtjI8vKwWcLg== @@ -1064,7 +1064,7 @@ slash "^3.0.0" strip-ansi "^6.0.0" -"@jest/environment@^27.2.3", "@jest/environment@^27.2.4": +"@jest/environment@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.2.4.tgz#db3e60f7dd30ab950f6ce2d6d7293ed9a6b7cbcd" integrity sha512-wkuui5yr3SSQW0XD0Qm3TATUbL/WE3LDEM3ulC+RCQhMf2yxhci8x7svGkZ4ivJ6Pc94oOzpZ6cdHBAMSYd1ew== @@ -1086,16 +1086,7 @@ jest-mock "^27.2.4" jest-util "^27.2.4" -"@jest/globals@27.2.3": - version "27.2.3" - resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.3.tgz#6b8d652083d78709b243d9571457058f1c6c5fea" - integrity sha512-JVjQDs5z34XvFME0qHmKwWtgzRnBa/i22nfWjzlIUvkdFCzndN+JTLEWNXAgyBbGnNYuMZ8CpvgF9uhKt/cR3g== - dependencies: - "@jest/environment" "^27.2.3" - "@jest/types" "^27.2.3" - expect "^27.2.3" - -"@jest/globals@^27.2.4": +"@jest/globals@27.2.4", "@jest/globals@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-27.2.4.tgz#0aeb22b011f8c8c4b8ff3b4dbd1ee0392fe0dd8a" integrity sha512-DRsRs5dh0i+fA9mGHylTU19+8fhzNJoEzrgsu+zgJoZth3x8/0juCQ8nVVdW1er4Cqifb/ET7/hACYVPD0dBEA== @@ -1104,37 +1095,7 @@ "@jest/types" "^27.2.4" expect "^27.2.4" -"@jest/reporters@27.2.3": - version "27.2.3" - resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.3.tgz#47c27be7c3e2069042b6fba12c1f8f62f91302db" - integrity sha512-zc9gQDjUAnkRQ5C0LW2u4JU9Ojqp9qc8OXQkMSmAbou6lN0mvDGEl4PG5HrZxpW4nE2FjIYyX6JAn05QT3gLbw== - dependencies: - "@bcoe/v8-coverage" "^0.2.3" - "@jest/console" "^27.2.3" - "@jest/test-result" "^27.2.3" - "@jest/transform" "^27.2.3" - "@jest/types" "^27.2.3" - chalk "^4.0.0" - collect-v8-coverage "^1.0.0" - exit "^0.1.2" - glob "^7.1.2" - graceful-fs "^4.2.4" - istanbul-lib-coverage "^3.0.0" - istanbul-lib-instrument "^4.0.3" - istanbul-lib-report "^3.0.0" - istanbul-lib-source-maps "^4.0.0" - istanbul-reports "^3.0.2" - jest-haste-map "^27.2.3" - jest-resolve "^27.2.3" - jest-util "^27.2.3" - jest-worker "^27.2.3" - slash "^3.0.0" - source-map "^0.6.0" - string-length "^4.0.1" - terminal-link "^2.0.0" - v8-to-istanbul "^8.1.0" - -"@jest/reporters@^27.2.4": +"@jest/reporters@27.2.4", "@jest/reporters@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-27.2.4.tgz#1482ff007f2e919d85c54b1563abb8b2ea2d5198" integrity sha512-LHeSdDnDZkDnJ8kvnjcqV8P1Yv/32yL4d4XfR5gBiy3xGO0onwll1QEbvtW96fIwhx2nejug0GTaEdNDoyr3fQ== @@ -1182,13 +1143,13 @@ graceful-fs "^4.2.4" source-map "^0.6.0" -"@jest/test-result@27.2.3": - version "27.2.3" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.3.tgz#7d8f790186c7ec7600edc1d8781656268f038255" - integrity sha512-+pRxO4xSJyUxoA0ENiTq8wT+5RCFOxK4nlNY2lUes/VF33uB54GBkZeXlljZcZjuzS1Yarz4hZI/a4mBtv9jQA== +"@jest/test-result@27.2.4", "@jest/test-result@^27.2.4": + version "27.2.4" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.4.tgz#d1ca8298d168f1b0be834bfb543b1ac0294c05d7" + integrity sha512-eU+PRo0+lIS01b0dTmMdVZ0TtcRSxEaYquZTRFMQz6CvsehGhx9bRzi9Zdw6VROviJyv7rstU+qAMX5pNBmnfQ== dependencies: - "@jest/console" "^27.2.3" - "@jest/types" "^27.2.3" + "@jest/console" "^27.2.4" + "@jest/types" "^27.2.4" "@types/istanbul-lib-coverage" "^2.0.0" collect-v8-coverage "^1.0.0" @@ -1201,16 +1162,6 @@ "@jest/types" "^24.9.0" "@types/istanbul-lib-coverage" "^2.0.0" -"@jest/test-result@^27.2.3", "@jest/test-result@^27.2.4": - version "27.2.4" - resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-27.2.4.tgz#d1ca8298d168f1b0be834bfb543b1ac0294c05d7" - integrity sha512-eU+PRo0+lIS01b0dTmMdVZ0TtcRSxEaYquZTRFMQz6CvsehGhx9bRzi9Zdw6VROviJyv7rstU+qAMX5pNBmnfQ== - dependencies: - "@jest/console" "^27.2.4" - "@jest/types" "^27.2.4" - "@types/istanbul-lib-coverage" "^2.0.0" - collect-v8-coverage "^1.0.0" - "@jest/test-sequencer@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-27.2.4.tgz#df66422a3e9e7440ce8b7498e255fa6b52c0bc03" @@ -1221,7 +1172,7 @@ jest-haste-map "^27.2.4" jest-runtime "^27.2.4" -"@jest/transform@^27.2.3", "@jest/transform@^27.2.4": +"@jest/transform@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-27.2.4.tgz#2fe5b6836895f7a1b8bdec442c51e83943c62733" integrity sha512-n5FlX2TH0oQGwyVDKPxdJ5nI2sO7TJBFe3u3KaAtt7TOiV4yL+Y+rSFDl+Ic5MpbiA/eqXmLAQxjnBmWgS2rEA== @@ -1262,7 +1213,7 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@jest/types@^27.2.3", "@jest/types@^27.2.4": +"@jest/types@^27.2.4": version "27.2.4" resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.4.tgz#2430042a66e00dc5b140c3636f4474d464c21ee8" integrity sha512-IDO2ezTxeMvQAHxzG/ZvEyA47q0aVfzT95rGFl7bZs/Go0aIucvfDbS2rmnoEdXxlLQhcolmoG/wvL/uKx4tKA== @@ -4263,7 +4214,7 @@ expect@^24.1.0: jest-message-util "^24.9.0" jest-regex-util "^24.9.0" -expect@^27.2.3, expect@^27.2.4: +expect@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/expect/-/expect-27.2.4.tgz#4debf546050bcdad8914a8c95fec7662e02bf67c" integrity sha512-gOtuonQ8TCnbNNCSw2fhVzRf8EFYDII4nB5NmG4IEV0rbUnW1I5zXvoTntU4iicB/Uh0oZr20NGlOLdJiwsOZA== @@ -5602,7 +5553,7 @@ jest-circus@^27.2.4: stack-utils "^2.0.3" throat "^6.0.1" -jest-cli@^27.2.3: +jest-cli@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-27.2.4.tgz#acda7f367aa6e674723fc1a7334e0ae1799448d2" integrity sha512-4kpQQkg74HYLaXo3nzwtg4PYxSLgL7puz1LXHj5Tu85KmlIpxQFjRkXlx4V47CYFFIDoyl3rHA/cXOxUWyMpNg== @@ -5741,7 +5692,7 @@ jest-github-actions-reporter@1.0.3: dependencies: "@actions/core" "^1.2.0" -jest-haste-map@^27.2.3, jest-haste-map@^27.2.4: +jest-haste-map@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.2.4.tgz#f8974807bedf07348ca9fd24e5861ab7c8e61aba" integrity sha512-bkJ4bT00T2K+1NZXbRcyKnbJ42I6QBvoDNMTAQQDBhaGNnZreiQKUNqax0e6hLTx7E75pKDeltVu3V1HAdu+YA== @@ -5900,7 +5851,7 @@ jest-resolve-dependencies@^27.2.4: jest-regex-util "^27.0.6" jest-snapshot "^27.2.4" -jest-resolve@^27.2.3, jest-resolve@^27.2.4: +jest-resolve@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-27.2.4.tgz#d3b999f073ff84a8ae109ce99ff7f3223048701a" integrity sha512-IsAO/3+3BZnKjI2I4f3835TBK/90dxR7Otgufn3mnrDFTByOSXclDi3G2XJsawGV4/18IMLARJ+V7Wm7t+J89Q== @@ -6035,7 +5986,7 @@ jest-util@^26.0.0: is-ci "^2.0.0" micromatch "^4.0.2" -jest-util@^27.0.0, jest-util@^27.2.3, jest-util@^27.2.4: +jest-util@^27.0.0, jest-util@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.2.4.tgz#3d7ce081b2e7f4cfe0156452ac01f3cb456cc656" integrity sha512-mW++4u+fSvAt3YBWm5IpbmRAceUqa2B++JlUZTiuEt2AmNYn0Yw5oay4cP17TGsMINRNPSGiJ2zNnX60g+VbFg== @@ -6072,7 +6023,7 @@ jest-watcher@^27.2.4: jest-util "^27.2.4" string-length "^4.0.1" -jest-worker@^27.2.3, jest-worker@^27.2.4: +jest-worker@^27.2.4: version "27.2.4" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.2.4.tgz#881455df75e22e7726a53f43703ab74d6b36f82d" integrity sha512-Zq9A2Pw59KkVjBBKD1i3iE2e22oSjXhUKKuAK1HGX8flGwkm6NMozyEYzKd41hXc64dbd/0eWFeEEuxqXyhM+g== @@ -6081,14 +6032,14 @@ jest-worker@^27.2.3, jest-worker@^27.2.4: merge-stream "^2.0.0" supports-color "^8.0.0" -jest@27.2.3: - version "27.2.3" - resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.3.tgz#9c2af9ce874a3eb202f83d92fbc1cc61ccc73248" - integrity sha512-r4ggA29J5xUg93DpvbsX+AXlFMWE3hZ5Y6BfgTl8PJvWelVezNPkmrsixuGoDBTHTCwScRSH0O4wsoeUgLie2w== +jest@27.2.4: + version "27.2.4" + resolved "https://registry.yarnpkg.com/jest/-/jest-27.2.4.tgz#70e27bef873138afc123aa4769f7124c50ad3efb" + integrity sha512-h4uqb1EQLfPulWyUFFWv9e9Nn8sCqsJ/j3wk/KCY0p4s4s0ICCfP3iMf6hRf5hEhsDyvyrCgKiZXma63gMz16A== dependencies: - "@jest/core" "^27.2.3" + "@jest/core" "^27.2.4" import-local "^3.0.2" - jest-cli "^27.2.3" + jest-cli "^27.2.4" js-tokens@^4.0.0: version "4.0.0" From b8209beaa3b44df31c6a027fd325478e9338714c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Oct 2021 20:52:31 +0000 Subject: [PATCH 13/38] build(deps): update dependency simple-git to v2.46.0 (#12047) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f1ccdfd086a4b7..65ebc8a37e8235 100644 --- a/package.json +++ b/package.json @@ -187,7 +187,7 @@ "semver-utils": "1.1.4", "shlex": "2.1.0", "shortid": "2.2.16", - "simple-git": "2.45.1", + "simple-git": "2.46.0", "slugify": "1.6.0", "traverse": "0.6.6", "upath": "2.0.1", diff --git a/yarn.lock b/yarn.lock index 2721aba585c2e2..e83d3e2b8144e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8679,10 +8679,10 @@ signale@^1.2.1: figures "^2.0.0" pkg-conf "^2.1.0" -simple-git@2.45.1: - version "2.45.1" - resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-2.45.1.tgz#27d26ae59f734ffd7e1dea16a1ee3b309d68f5ef" - integrity sha512-NmEoThiLTJxl26WNtZxtJTue18ReTcSrf3so5vJG/O8KY9uMxH+yAhXV/DElBJyOYZrrBbVsH8JOFxgENdc9Xg== +simple-git@2.46.0: + version "2.46.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-2.46.0.tgz#d564856705cee9d2ef1d1f98c7143e2bc00e7c3e" + integrity sha512-6eumII1vfP4NpRqxZcVWCcIT5xHH6dRyvBZSjkH4dJRDRpv+0f75hrN5ysp++y23Mfr3AbRC/dO2NDbfj1lJpQ== dependencies: "@kwsites/file-exists" "^1.1.1" "@kwsites/promise-deferred" "^1.1.1" From a9829ba424620745f6369dc4cf410f4bb5893007 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 02:31:05 +0000 Subject: [PATCH 14/38] chore(deps): update dependency yarn to v1.22.14 (#12055) Co-authored-by: Renovate Bot --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d9048f67da85b3..9e36d1a4b5a7b5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,4 +2,4 @@ FROM containerbase/node:v14.18.0@sha256:50de253d90cbb55711d47927e56850c32ea5fcb7 # renovate: datasource=npm -RUN install-tool yarn 1.22.13 +RUN install-tool yarn 1.22.14 From ce736f595bcf54d38d56b3416c98376d93fdf51f Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 7 Oct 2021 07:03:25 +0200 Subject: [PATCH 15/38] chore: run dessant/label-actions on discussions (#12037) --- .github/workflows/label-actions.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml index ed90a008ecfa7f..41f1597fd81879 100644 --- a/.github/workflows/label-actions.yml +++ b/.github/workflows/label-actions.yml @@ -3,10 +3,13 @@ name: 'Label Actions' on: issues: types: [labeled] + discussion: + types: [labeled] permissions: contents: read issues: write + discussions: write jobs: reaction: @@ -15,4 +18,4 @@ jobs: - uses: dessant/label-actions@93ea5ec1d65e6a21427a1571a18a5b8861206b0b # renovate: tag=v2.2.0 with: github-token: ${{ github.token }} - process-only: 'issues' + process-only: 'issues, discussions' From 9b4b6ce27505b03b38e275631bd5fcfcb5ea02a6 Mon Sep 17 00:00:00 2001 From: Oleg Krivtsov Date: Thu, 7 Oct 2021 12:15:23 +0700 Subject: [PATCH 16/38] feat: enabledManagers log warning when empty (#11902) --- lib/workers/repository/extract/index.spec.ts | 9 +++++++++ lib/workers/repository/extract/index.ts | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/workers/repository/extract/index.spec.ts b/lib/workers/repository/extract/index.spec.ts index ee87d1e10875cc..caab536b4ae922 100644 --- a/lib/workers/repository/extract/index.spec.ts +++ b/lib/workers/repository/extract/index.spec.ts @@ -1,5 +1,6 @@ import { defaultConfig, git, mocked } from '../../../../test/util'; import type { RenovateConfig } from '../../../config/types'; +import { logger } from '../../../logger'; import * as _managerFiles from './manager-files'; import { extractAllDependencies } from '.'; @@ -29,6 +30,14 @@ describe('workers/repository/extract/index', () => { // FIXME: explicit assert condition expect(res).toMatchSnapshot(); }); + + it('warns if no packages found for a enabled manager', async () => { + config.enabledManagers = ['npm']; + managerFiles.getManagerPackageFiles.mockResolvedValue([]); + expect(await extractAllDependencies(config)).toEqual({}); + expect(logger.warn).toHaveBeenCalled(); + }); + it('checks custom managers', async () => { managerFiles.getManagerPackageFiles.mockResolvedValue([{} as never]); config.regexManagers = [{ fileMatch: ['README'], matchStrings: [''] }]; diff --git a/lib/workers/repository/extract/index.ts b/lib/workers/repository/extract/index.ts index 9d99e5e7f2432d..de37b808a09dd4 100644 --- a/lib/workers/repository/extract/index.ts +++ b/lib/workers/repository/extract/index.ts @@ -56,5 +56,19 @@ export async function extractAllDependencies( } } logger.debug(`Found ${fileCount} package file(s)`); + + // If enabledManagers is non-empty, check that each of them has at least one extraction. + // If not, log a warning to indicate possible misconfiguration. + if (is.nonEmptyArray(config.enabledManagers)) { + for (const enabledManager of config.enabledManagers) { + if (!(enabledManager in extractions)) { + logger.warn( + { manager: enabledManager }, + `Manager explicitly enabled in "enabledManagers" config, but found no results. Possible config error?` + ); + } + } + } + return extractions; } From d80bc01ebe4fd3e168c0a0de7161ffa99f428128 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer Date: Thu, 7 Oct 2021 09:09:04 +0200 Subject: [PATCH 17/38] feat(helm-values): support inline image definitions (#12041) --- .../__fixtures__/multi_and_nested_image_values.yaml | 2 ++ .../helm-values/__snapshots__/extract.spec.ts.snap | 8 ++++++++ lib/manager/helm-values/extract.spec.ts | 2 +- lib/manager/helm-values/extract.ts | 8 +++++++- lib/manager/helm-values/util.ts | 7 +++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/manager/helm-values/__fixtures__/multi_and_nested_image_values.yaml b/lib/manager/helm-values/__fixtures__/multi_and_nested_image_values.yaml index 23690cdd966d18..afb39690328d71 100644 --- a/lib/manager/helm-values/__fixtures__/multi_and_nested_image_values.yaml +++ b/lib/manager/helm-values/__fixtures__/multi_and_nested_image_values.yaml @@ -1,4 +1,6 @@ --- +inline_image: docker.io/library/nginx:1.18-alpine + api: image: image: diff --git a/lib/manager/helm-values/__snapshots__/extract.spec.ts.snap b/lib/manager/helm-values/__snapshots__/extract.spec.ts.snap index 7c463545d41844..ae90d042fbadaf 100644 --- a/lib/manager/helm-values/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/helm-values/__snapshots__/extract.spec.ts.snap @@ -3,6 +3,14 @@ exports[`manager/helm-values/extract extractPackageFile() extracts from complex values file correctly" 1`] = ` Object { "deps": Array [ + Object { + "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}", + "currentDigest": undefined, + "currentValue": "1.18-alpine", + "datasource": "docker", + "depName": "docker.io/library/nginx", + "replaceString": "docker.io/library/nginx:1.18-alpine", + }, Object { "autoReplaceStringTemplate": "{{newValue}}{{#if newDigest}}@{{newDigest}}{{/if}}", "currentDigest": undefined, diff --git a/lib/manager/helm-values/extract.spec.ts b/lib/manager/helm-values/extract.spec.ts index 08213783dce1a5..a2a1c6196d4cb9 100644 --- a/lib/manager/helm-values/extract.spec.ts +++ b/lib/manager/helm-values/extract.spec.ts @@ -40,7 +40,7 @@ describe('manager/helm-values/extract', () => { it('extracts from complex values file correctly"', () => { const result = extractPackageFile(helmMultiAndNestedImageValues); expect(result).toMatchSnapshot(); - expect(result.deps).toHaveLength(4); + expect(result.deps).toHaveLength(5); }); }); }); diff --git a/lib/manager/helm-values/extract.ts b/lib/manager/helm-values/extract.ts index 6b962e598713ba..a57a2876a0a136 100644 --- a/lib/manager/helm-values/extract.ts +++ b/lib/manager/helm-values/extract.ts @@ -4,7 +4,10 @@ import { id as dockerVersioning } from '../../versioning/docker'; import { getDep } from '../dockerfile/extract'; import type { PackageDependency, PackageFile } from '../types'; import type { HelmDockerImageDependency } from './types'; -import { matchesHelmValuesDockerHeuristic } from './util'; +import { + matchesHelmValuesDockerHeuristic, + matchesHelmValuesInlineImage, +} from './util'; function getHelmDep({ registry, @@ -45,6 +48,9 @@ function findDependencies( const repository = String(currentItem.repository); const tag = String(currentItem.tag); packageDependencies.push(getHelmDep({ repository, tag, registry })); + } else if (matchesHelmValuesInlineImage(key, parsedContent[key])) { + const currentItem = parsedContent[key]; + packageDependencies.push(getDep(currentItem)); } else { findDependencies(parsedContent[key], packageDependencies); } diff --git a/lib/manager/helm-values/util.ts b/lib/manager/helm-values/util.ts index ffc9ee74cbc502..f1707aef7bff60 100644 --- a/lib/manager/helm-values/util.ts +++ b/lib/manager/helm-values/util.ts @@ -30,3 +30,10 @@ export function matchesHelmValuesDockerHeuristic( hasKey('tag', data) ); } + +export function matchesHelmValuesInlineImage( + parentKey: string, + data: unknown +): data is string { + return parentKeyRe.test(parentKey) && data && typeof data === 'string'; +} From 0c977e47f742d0202b50b125a6a24dc96fc9dcb1 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Thu, 7 Oct 2021 03:20:54 -0400 Subject: [PATCH 18/38] fix: bitbucket inactive reviewers (#11834) --- .../__snapshots__/index.spec.ts.snap | 154 ++++++++++++++++++ lib/platform/bitbucket/index.spec.ts | 63 +++++++ lib/platform/bitbucket/index.ts | 67 ++++++-- lib/platform/bitbucket/utils.ts | 15 +- 4 files changed, 288 insertions(+), 11 deletions(-) diff --git a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap index a2e14ba769ec51..8484e51d2693da 100644 --- a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -1611,6 +1611,160 @@ Array [ ] `; +exports[`platform/bitbucket/index updatePr() removes inactive reviewers when updating pr 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests/5", + }, + Object { + "body": Object { + "description": "body", + "reviewers": Array [ + Object { + "account_id": "456", + "display_name": "Jane Smith", + "uuid": "{90b6646d-1724-4a64-9fd9-539515fe94e9}", + }, + Object { + "account_id": "123", + "display_name": "Bob Smith", + "uuid": "{d2238482-2e9f-48b3-8630-de22ccb9e42f}", + }, + ], + "title": "title", + }, + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "content-length": "245", + "content-type": "application/json", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests/5", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/users/456", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/users/123", + }, + Object { + "body": Object { + "description": "body", + "reviewers": Array [ + Object { + "account_id": "456", + "display_name": "Jane Smith", + "uuid": "{90b6646d-1724-4a64-9fd9-539515fe94e9}", + }, + ], + "title": "title", + }, + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "content-length": "149", + "content-type": "application/json", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests/5", + }, +] +`; + +exports[`platform/bitbucket/index updatePr() rethrows exception when PR update error not due to inactive reviewers 1`] = `"Response code 400 (Bad Request)"`; + +exports[`platform/bitbucket/index updatePr() rethrows exception when PR update error not due to inactive reviewers 2`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo", + }, + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests/5", + }, + Object { + "body": Object { + "description": "body", + "reviewers": Array [ + Object { + "display_name": "Jane Smith", + "uuid": "{90b6646d-1724-4a64-9fd9-539515fe94e9}", + }, + ], + "title": "title", + }, + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Basic YWJjOjEyMw==", + "content-length": "130", + "content-type": "application/json", + "host": "api.bitbucket.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "PUT", + "url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests/5", + }, +] +`; + exports[`platform/bitbucket/index updatePr() throws an error on failure to get current list of reviewers 1`] = `"Response code 500 (Internal Server Error)"`; exports[`platform/bitbucket/index updatePr() throws an error on failure to get current list of reviewers 2`] = ` diff --git a/lib/platform/bitbucket/index.spec.ts b/lib/platform/bitbucket/index.spec.ts index 4716c77ab5e5f7..27b42e88955f9a 100644 --- a/lib/platform/bitbucket/index.spec.ts +++ b/lib/platform/bitbucket/index.spec.ts @@ -765,6 +765,69 @@ describe('platform/bitbucket/index', () => { await bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' }); expect(httpMock.getTrace()).toMatchSnapshot(); }); + it('removes inactive reviewers when updating pr', async () => { + const inactiveReviewer = { + display_name: 'Bob Smith', + uuid: '{d2238482-2e9f-48b3-8630-de22ccb9e42f}', + account_id: '123', + }; + const activeReviewer = { + display_name: 'Jane Smith', + uuid: '{90b6646d-1724-4a64-9fd9-539515fe94e9}', + account_id: '456', + }; + const scope = await initRepoMock(); + scope + .get('/2.0/repositories/some/repo/pullrequests/5') + .reply(200, { reviewers: [activeReviewer, inactiveReviewer] }) + .put('/2.0/repositories/some/repo/pullrequests/5') + .reply(400, { + type: 'error', + error: { + fields: { + reviewers: ['Malformed reviewers list'], + }, + message: 'reviewers: Malformed reviewers list', + }, + }) + .get('/2.0/users/123') + .reply(200, { + account_status: 'inactive', + }) + .get('/2.0/users/456') + .reply(200, { + account_status: 'active', + }) + .put('/2.0/repositories/some/repo/pullrequests/5') + .reply(200); + await bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + it('rethrows exception when PR update error not due to inactive reviewers', async () => { + const reviewer = { + display_name: 'Jane Smith', + uuid: '{90b6646d-1724-4a64-9fd9-539515fe94e9}', + }; + + const scope = await initRepoMock(); + scope + .get('/2.0/repositories/some/repo/pullrequests/5') + .reply(200, { reviewers: [reviewer] }) + .put('/2.0/repositories/some/repo/pullrequests/5') + .reply(400, { + type: 'error', + error: { + fields: { + reviewers: ['Some other unhandled error'], + }, + message: 'Some other unhandled error', + }, + }); + await expect(() => + bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' }) + ).rejects.toThrowErrorMatchingSnapshot(); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); it('throws an error on failure to get current list of reviewers', async () => { const scope = await initRepoMock(); scope diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 04ff05b3cd90de..aca5adc95bf1e4 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -30,7 +30,13 @@ import { smartTruncate } from '../utils/pr-body'; import { readOnlyIssueBody } from '../utils/read-only-issue-body'; import * as comments from './comments'; import * as utils from './utils'; -import { PrResponse, RepoInfoBody, mergeBodyTransformer } from './utils'; +import { + PrResponse, + PrReviewer, + RepoInfoBody, + UserResponse, + mergeBodyTransformer, +} from './utils'; const bitbucketHttp = new BitbucketHttp(); @@ -712,16 +718,57 @@ export async function updatePr({ ) ).body; - await bitbucketHttp.putJson( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}`, - { - body: { - title, - description: sanitize(description), - reviewers: pr.reviewers, - }, + try { + await bitbucketHttp.putJson( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}`, + { + body: { + title, + description: sanitize(description), + reviewers: pr.reviewers, + }, + } + ); + } catch (err) { + if ( + err.statusCode === 400 && + err.body?.error?.message.includes('reviewers: Malformed reviewers list') + ) { + logger.warn( + { err }, + 'PR contains inactive reviewer accounts. Will try setting only active reviewers' + ); + + // Bitbucket returns a 400 if any of the PR reviewer accounts are now inactive (ie: disabled/suspended) + const activeReviewers: PrReviewer[] = []; + + // Validate that each previous PR reviewer account is still active + for (const reviewer of pr.reviewers) { + const reviewerUser = ( + await bitbucketHttp.getJson( + `/2.0/users/${reviewer.account_id}` + ) + ).body; + + if (reviewerUser.account_status === 'active') { + activeReviewers.push(reviewer); + } + } + + await bitbucketHttp.putJson( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}`, + { + body: { + title, + description: sanitize(description), + reviewers: activeReviewers, + }, + } + ); + } else { + throw err; } - ); + } if (state === PrState.Closed && pr) { await bitbucketHttp.postJson( diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts index c20b2ec28c9239..b68e42b63b2ec7 100644 --- a/lib/platform/bitbucket/utils.ts +++ b/lib/platform/bitbucket/utils.ts @@ -190,7 +190,7 @@ export interface PrResponse { name: string; }; }; - reviewers: Array; + reviewers: Array; created_on: string; } @@ -208,3 +208,16 @@ export function prInfo(pr: PrResponse): Pr { createdAt: pr.created_on, }; } + +export interface UserResponse { + display_name: string; + account_id: string; + nickname: string; + account_status: string; +} + +export interface PrReviewer { + display_name: string; + account_id: string; + nickname: string; +} From ac557cd3ec9d093760fc597a5f9ccc6c741d706b Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:22:58 +0200 Subject: [PATCH 19/38] fix(config): capitalize proper noun Docker (#12057) --- lib/config/presets/internal/docker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/config/presets/internal/docker.ts b/lib/config/presets/internal/docker.ts index b047e68a5bfe93..62d451a8a0b53b 100644 --- a/lib/config/presets/internal/docker.ts +++ b/lib/config/presets/internal/docker.ts @@ -2,7 +2,7 @@ import type { Preset } from '../types'; export const presets: Record = { disable: { - description: 'Disable docker updates', + description: 'Disable Docker updates', docker: { enabled: false, }, @@ -14,7 +14,7 @@ export const presets: Record = { }, }, enableMajor: { - description: 'Enable docker major updates', + description: 'Enable Docker major updates', packageRules: [ { matchDatasources: ['docker'], @@ -24,7 +24,7 @@ export const presets: Record = { ], }, disableMajor: { - description: 'Disable docker major updates', + description: 'Disable Docker major updates', packageRules: [ { matchDatasources: ['docker'], From 030a378e915cfe38b0d62b83c5b0e11f50ec9167 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:33:27 +0200 Subject: [PATCH 20/38] fix(config): improve descriptions for group presets (#12058) Co-authored-by: Michael Kriese --- lib/config/presets/internal/group.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/config/presets/internal/group.ts b/lib/config/presets/internal/group.ts index beb1af01fba592..79686c6d5c016c 100644 --- a/lib/config/presets/internal/group.ts +++ b/lib/config/presets/internal/group.ts @@ -140,7 +140,7 @@ const staticGroups = { ], }, fusionjs: { - description: 'Fusion.js packages', + description: 'Group Fusion.js packages together', matchPackageNames: [ 'fusion-cli', 'fusion-core', @@ -160,7 +160,7 @@ const staticGroups = { ], }, illuminate: { - description: 'Group PHP illuminate packages together', + description: 'Group PHP Illuminate packages together', packageRules: [ { matchPackagePrefixes: ['illuminate/'], @@ -170,7 +170,7 @@ const staticGroups = { ], }, symfony: { - description: 'Group PHP symfony packages together', + description: 'Group PHP Symfony packages together', packageRules: [ { matchPackagePrefixes: ['symfony/'], @@ -451,7 +451,7 @@ const staticGroups = { ], }, postcss: { - description: 'Group postcss packages together', + description: 'Group PostCSS packages together', packageRules: [ { extends: 'packages:postcss', @@ -460,7 +460,7 @@ const staticGroups = { ], }, jekyllEcosystem: { - description: 'Group jekyll and related ruby packages together', + description: 'Group Jekyll and related Ruby packages together', packageRules: [ { matchSourceUrlPrefixes: [ @@ -472,7 +472,7 @@ const staticGroups = { ], }, rubyOmniauth: { - description: 'Group omniauth packages together', + description: 'Group OmniAuth packages together', packageRules: [ { matchDatasources: ['rubygems'], @@ -587,7 +587,7 @@ const staticGroups = { ], }, jestPlusTSJest: { - description: 'Add ts-jest major update to jest monorepo', + description: 'Add ts-jest major update to Jest monorepo', packageRules: [ { matchSourceUrlPrefixes: ['https://github.com/kulshekhar/ts-jest'], From 2af5d33ef784ffbd2d591f6141e6bfc6baaf5334 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:12:44 +0200 Subject: [PATCH 21/38] fix(config): improve descriptions for package presets (#12059) Co-authored-by: Michael Kriese --- lib/config/presets/internal/packages.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/config/presets/internal/packages.ts b/lib/config/presets/internal/packages.ts index 3d72e7ad277e16..1dfd003832bd69 100644 --- a/lib/config/presets/internal/packages.ts +++ b/lib/config/presets/internal/packages.ts @@ -2,7 +2,7 @@ import type { Preset } from '../types'; export const presets: Record = { angularJs: { - description: 'All angular.js packages', + description: 'All AngularJS packages', matchPackageNames: [ 'angular', 'angular-animate', @@ -11,7 +11,7 @@ export const presets: Record = { ], }, react: { - description: 'All react packages', + description: 'All React packages', matchPackageNames: ['@types/react'], matchPackagePrefixes: ['react'], }, @@ -28,7 +28,7 @@ export const presets: Record = { matchPackagePrefixes: ['ember-template-lint'], }, eslint: { - description: 'All eslint packages', + description: 'All ESLint packages', matchPackageNames: ['@types/eslint', 'babel-eslint'], matchPackagePrefixes: ['@typescript-eslint/', 'eslint'], }, @@ -37,7 +37,7 @@ export const presets: Record = { matchPackagePrefixes: ['stylelint'], }, tslint: { - description: 'All tslint packages', + description: 'All TSLint packages', matchPackageNames: ['codelyzer'], matchPackagePatterns: ['\\btslint\\b'], }, @@ -52,12 +52,12 @@ export const presets: Record = { matchPackageNames: ['remark-lint'], }, postcss: { - description: 'All postcss packages', + description: 'All PostCSS packages', matchPackageNames: ['postcss'], matchPackagePrefixes: ['postcss-'], }, jsUnitTest: { - description: 'Unit test packages for javascript', + description: 'Unit test packages for JavaScript', matchPackageNames: [ '@types/chai', '@types/ember-mocha', From b9930407f40b5f1fa0a3a4be55cf710c58c70d50 Mon Sep 17 00:00:00 2001 From: Sergey Vedmak Date: Thu, 7 Oct 2021 12:54:51 +0300 Subject: [PATCH 22/38] fix(monorepo): load changelog.md file from gitlab monorepo (#12053) --- .../__snapshots__/gitlab.spec.ts.snap | 6 +++++ .../__snapshots__/release-notes.spec.ts.snap | 2 +- lib/workers/pr/changelog/gitlab/index.ts | 22 ++++++++----------- .../pr/changelog/release-notes.spec.ts | 8 +++---- lib/workers/pr/changelog/source-gitlab.ts | 2 ++ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap index cc229009feb0d3..d02b4cdfbaf35f 100644 --- a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap @@ -8,6 +8,7 @@ Object { "baseUrl": "https://gitlab.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", "type": "gitlab", }, @@ -156,6 +157,7 @@ Object { "baseUrl": "https://gitlab-enterprise.example.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://gitlab-enterprise.example.com/meno/dropzone/", "type": "gitlab", }, @@ -200,6 +202,7 @@ Object { "baseUrl": "https://git.test.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://git.test.com/meno/dropzone/", "type": "gitlab", }, @@ -244,6 +247,7 @@ Object { "baseUrl": "https://gitlab.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", "type": "gitlab", }, @@ -408,6 +412,7 @@ Object { "baseUrl": "https://gitlab.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", "type": "gitlab", }, @@ -556,6 +561,7 @@ Object { "baseUrl": "https://gitlab.com/", "depName": "renovate", "repository": "meno/dropzone", + "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", "type": "gitlab", }, diff --git a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap index 976f87b5a518a1..4386f098d4e6cd 100644 --- a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap @@ -366,7 +366,7 @@ Array [ "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", }, "method": "GET", - "url": "https://gitlab.com/api/v4/projects/itentialopensource%2fadapter-utils/repository/tree?per_page=100", + "url": "https://gitlab.com/api/v4/projects/itentialopensource%2fadapter-utils/repository/tree?per_page=100&path=packages/foo", }, Object { "headers": Object { diff --git a/lib/workers/pr/changelog/gitlab/index.ts b/lib/workers/pr/changelog/gitlab/index.ts index ab7e71625d4f12..282e2f5c218b1f 100644 --- a/lib/workers/pr/changelog/gitlab/index.ts +++ b/lib/workers/pr/changelog/gitlab/index.ts @@ -60,23 +60,19 @@ export async function getReleaseNotesMd( // https://docs.gitlab.com/13.2/ee/api/repositories.html#list-repository-tree const tree = ( - await http.getJson(`${apiPrefix}tree?per_page=100`, { - paginate: true, - }) + await http.getJson( + `${apiPrefix}tree?per_page=100${ + sourceDirectory ? `&path=${sourceDirectory}` : '' + }`, + { + paginate: true, + } + ) ).body; const allFiles = tree.filter((f) => f.type === 'blob'); let files: GitlabTreeNode[] = []; - if (sourceDirectory?.length) { - files = allFiles - .filter((f) => f.path.startsWith(sourceDirectory)) - .filter((f) => - changelogFilenameRegex.test( - f.path.replace(ensureTrailingSlash(sourceDirectory), '') - ) - ); - } if (!files.length) { - files = allFiles.filter((f) => changelogFilenameRegex.test(f.path)); + files = allFiles.filter((f) => changelogFilenameRegex.test(f.name)); } if (!files.length) { logger.trace('no changelog file found'); diff --git a/lib/workers/pr/changelog/release-notes.spec.ts b/lib/workers/pr/changelog/release-notes.spec.ts index 622b0d618b3e37..9967a40d7936ac 100644 --- a/lib/workers/pr/changelog/release-notes.spec.ts +++ b/lib/workers/pr/changelog/release-notes.spec.ts @@ -37,9 +37,9 @@ const githubTreeResponse = { }; const gitlabTreeResponse = [ - { path: 'lib', type: 'tree' }, - { path: 'CHANGELOG.md', type: 'blob', id: 'abcd' }, - { path: 'README.md', type: 'blob' }, + { path: 'lib', name: 'lib', type: 'tree' }, + { path: 'CHANGELOG.md', name: 'CHANGELOG.md', type: 'blob', id: 'abcd' }, + { path: 'README.md', name: 'README.md', type: 'blob' }, ]; const githubProject = { @@ -615,7 +615,7 @@ describe('workers/pr/changelog/release-notes', () => { httpMock .scope('https://gitlab.com/') .get( - '/api/v4/projects/itentialopensource%2fadapter-utils/repository/tree?per_page=100' + `/api/v4/projects/itentialopensource%2fadapter-utils/repository/tree?per_page=100&path=${sourceDirectory}` ) .reply(200, response) .get( diff --git a/lib/workers/pr/changelog/source-gitlab.ts b/lib/workers/pr/changelog/source-gitlab.ts index c241bb9a04f741..9eb713d13b03f1 100644 --- a/lib/workers/pr/changelog/source-gitlab.ts +++ b/lib/workers/pr/changelog/source-gitlab.ts @@ -36,6 +36,7 @@ export async function getChangeLogJSON({ releases, depName, manager, + sourceDirectory, }: BranchUpgradeConfig): Promise { logger.trace('getChangeLogJSON for gitlab'); const version = allVersioning.get(versioning); @@ -134,6 +135,7 @@ export async function getChangeLogJSON({ repository, sourceUrl, depName, + sourceDirectory, }, versions: changelogReleases, }; From 00e191795ce9a56752ece1891b41d0b6b92cba77 Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Thu, 7 Oct 2021 12:26:08 +0200 Subject: [PATCH 23/38] fix(config): capitalize SemVer in description (#12061) --- lib/config/presets/internal/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config/presets/internal/config.ts b/lib/config/presets/internal/config.ts index c045aeb595310d..d861013c0b192b 100644 --- a/lib/config/presets/internal/config.ts +++ b/lib/config/presets/internal/config.ts @@ -25,7 +25,7 @@ export const presets: Record = { }, semverAllMonthly: { description: - 'Preserve semver ranges and update everything together once a month', + 'Preserve SemVer ranges and update everything together once a month', separateMajorMinor: false, extends: [ ':preserveSemverRanges', From e10e58172865fc739a4edf0212ac7bc9c5848964 Mon Sep 17 00:00:00 2001 From: Danilo Pianini Date: Thu, 7 Oct 2021 17:30:51 +0200 Subject: [PATCH 24/38] feat(manager/github-actions): Support composite actions (#11533) --- lib/manager/github-actions/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/manager/github-actions/index.ts b/lib/manager/github-actions/index.ts index 769977a6f62e84..62ec7b3d9ca848 100644 --- a/lib/manager/github-actions/index.ts +++ b/lib/manager/github-actions/index.ts @@ -3,5 +3,8 @@ import { extractPackageFile } from './extract'; export { extractPackageFile }; export const defaultConfig = { - fileMatch: ['^(workflow-templates|\\.github\\/workflows)\\/[^/]+\\.ya?ml$'], + fileMatch: [ + '^(workflow-templates|\\.github\\/workflows)\\/[^/]+\\.ya?ml$', + '(^|\\/)action\\.ya?ml$', + ], }; From 7c1dc758bfd8ae18b3e35f9635b9844ffba36018 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 20:35:51 +0000 Subject: [PATCH 25/38] chore(deps): update github/codeql-action action to v1.0.17 (#12066) Co-authored-by: Renovate Bot --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0f15bd55249021..71762a19071691 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -26,7 +26,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 + uses: github/codeql-action/init@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 with: config-file: ./.github/codeql/codeql-config.yml @@ -36,7 +36,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 + uses: github/codeql-action/autobuild@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -50,4 +50,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1ddd8a5632ff73c3f5c27437cf052373e3318e39 # renovate: tag=v1.0.16 + uses: github/codeql-action/analyze@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 From a9c9aa02d8ae900e651a4e0051c834249631dddf Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Fri, 8 Oct 2021 06:22:25 +0200 Subject: [PATCH 26/38] docs: add `build` capture group to regex docs (#12065) --- lib/versioning/regex/readme.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/versioning/regex/readme.md b/lib/versioning/regex/readme.md index 92122b42eab1f5..bd6f40c4ed29c2 100644 --- a/lib/versioning/regex/readme.md +++ b/lib/versioning/regex/readme.md @@ -1,9 +1,11 @@ -Regular Expression Versioning is designed to be like a flexible fallback versioning approach is Renovate's other versioning schemes don't do the job. +Regular Expression Versioning is designed to be a flexible fallback versioning approach if Renovate's other versioning schemes don't do the job. -The `regex` scheme makes use of Regular Express capture groups. The valid capture groups for `regex` versioning are: +The `regex` scheme makes use of Regular Express capture groups. +The valid capture groups for `regex` versioning are: -- `major`, `minor`, and `patch`: at least one of these must be provided. When determining whether a package has updated, these values will be compared in the standard semantic versioning fashion. If any of these fields are omitted, they will be treated as if they were `0` -- in this way, you can describe versioning schemes with up to three incrementing values. -- `prerelease`: this value, if captured, will mark a given release as a prerelease (eg. unstable). If this value is captured and you have configured `"ignoreUnstable": true`, the given release will be skipped. +- `major`, `minor`, and `patch`: at least one of these must be provided. When determining whether a package has updates, these values will be compared in the standard semantic versioning fashion. If any of these fields are omitted, they will be treated as if they were `0` -- in this way, you can describe versioning schemes with up to three incrementing values. +- `build`: this capture group can be used after you've already used the `major`, `minor` and `patch` capture groups and need a fourth version component. `build` updates are handled like `patch` updates. +- `prerelease`: this value, if captured, will mark a given release as a prerelease (e.g. unstable). If this value is captured and you have configured `"ignoreUnstable": true`, the given release will be skipped. - `compatibility`: this value defines the "build compatibility" of a given dependency. A proposed Renovate update will never change the specified compatibility value. For example, if you are pinning to `1.2.3-linux` (and `linux` is captured as the compatibility value), Renovate will not update you to `1.2.4-osx`. The compatibility concept was originally introduced for Docker versioning but sometimes package authors may use/misuse suffixes to mean compatibility in other versioning schemes. From b8c1e331e58755efbb1439aa93723ac9de68ddd6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:29:40 +0000 Subject: [PATCH 27/38] chore(deps): update github/codeql-action action to v1.0.18 (#12076) Co-authored-by: Renovate Bot --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 71762a19071691..5e7a3d4b38c7b6 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -26,7 +26,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 + uses: github/codeql-action/init@fd3190bba58b65cbefb742009518a03a07af24d7 # renovate: tag=v1.0.18 with: config-file: ./.github/codeql/codeql-config.yml @@ -36,7 +36,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 + uses: github/codeql-action/autobuild@fd3190bba58b65cbefb742009518a03a07af24d7 # renovate: tag=v1.0.18 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -50,4 +50,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@03e7dda1b95c7f6aae67e875850e96fad898d31e # renovate: tag=v1.0.17 + uses: github/codeql-action/analyze@fd3190bba58b65cbefb742009518a03a07af24d7 # renovate: tag=v1.0.18 From 8b200c19e6b5cd6a65ecf1cbae09901768a6810f Mon Sep 17 00:00:00 2001 From: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Date: Sat, 9 Oct 2021 05:29:38 +0200 Subject: [PATCH 28/38] fix(config): add missing descriptions (#12060) --- lib/config/presets/internal/compatibility.ts | 2 ++ lib/config/presets/internal/helpers.ts | 1 + lib/config/presets/internal/workarounds.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/config/presets/internal/compatibility.ts b/lib/config/presets/internal/compatibility.ts index ce1175f569fb34..436846b4793b29 100644 --- a/lib/config/presets/internal/compatibility.ts +++ b/lib/config/presets/internal/compatibility.ts @@ -2,6 +2,8 @@ import { Preset } from '../types'; export const presets: Record = { additionalBranchPrefix: { + description: + 'Backwards-compatibility preset to restore additionalBranchPrefix settings for multiple managers which were removed in v25', buildkite: { additionalBranchPrefix: 'buildkite-', }, diff --git a/lib/config/presets/internal/helpers.ts b/lib/config/presets/internal/helpers.ts index 60b124c8eadf13..7116e175defac7 100644 --- a/lib/config/presets/internal/helpers.ts +++ b/lib/config/presets/internal/helpers.ts @@ -2,6 +2,7 @@ import type { Preset } from '../types'; export const presets: Record = { disableTypesNodeMajor: { + description: 'Disable major updates to @types/node', packageRules: [ { matchPackageNames: ['@types/node'], diff --git a/lib/config/presets/internal/workarounds.ts b/lib/config/presets/internal/workarounds.ts index 4eaa35bd4d8803..71ea42eb6820dc 100644 --- a/lib/config/presets/internal/workarounds.ts +++ b/lib/config/presets/internal/workarounds.ts @@ -14,6 +14,7 @@ export const presets: Record = { ], }, mavenCommonsAncientVersion: { + description: 'Fix some problems with very old Maven commons versions', packageRules: [ { matchDatasources: ['maven', 'sbt-package'], From 5a23e9b4dcda5fbed6de1e1c951979a8b3be0fe3 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 9 Oct 2021 05:50:00 +0200 Subject: [PATCH 29/38] fix: no warn for enabledManagers --- lib/workers/repository/extract/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/repository/extract/index.ts b/lib/workers/repository/extract/index.ts index de37b808a09dd4..c8d5d3f1eaf3b7 100644 --- a/lib/workers/repository/extract/index.ts +++ b/lib/workers/repository/extract/index.ts @@ -62,7 +62,7 @@ export async function extractAllDependencies( if (is.nonEmptyArray(config.enabledManagers)) { for (const enabledManager of config.enabledManagers) { if (!(enabledManager in extractions)) { - logger.warn( + logger.debug( { manager: enabledManager }, `Manager explicitly enabled in "enabledManagers" config, but found no results. Possible config error?` ); From afb1369be77dc85bb8c2fbcf4c96233728422ffb Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 9 Oct 2021 05:51:30 +0200 Subject: [PATCH 30/38] test: fix enabledManagers test --- lib/workers/repository/extract/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/workers/repository/extract/index.spec.ts b/lib/workers/repository/extract/index.spec.ts index caab536b4ae922..2e75237e523db3 100644 --- a/lib/workers/repository/extract/index.spec.ts +++ b/lib/workers/repository/extract/index.spec.ts @@ -35,7 +35,7 @@ describe('workers/repository/extract/index', () => { config.enabledManagers = ['npm']; managerFiles.getManagerPackageFiles.mockResolvedValue([]); expect(await extractAllDependencies(config)).toEqual({}); - expect(logger.warn).toHaveBeenCalled(); + expect(logger.debug).toHaveBeenCalled(); }); it('checks custom managers', async () => { From 807f124d399909d2bfc7bcc50281f60fb1c0a35d Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Sat, 9 Oct 2021 14:44:33 +0900 Subject: [PATCH 31/38] fix(git): support setting file mode (#12081) --- lib/manager/npm/post-update/types.ts | 1 + lib/util/git/index.spec.ts | 17 +++++++++++++++++ lib/util/git/index.ts | 13 +++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/manager/npm/post-update/types.ts b/lib/manager/npm/post-update/types.ts index 035ac3d39d47c2..2b780ddc89ee9d 100644 --- a/lib/manager/npm/post-update/types.ts +++ b/lib/manager/npm/post-update/types.ts @@ -19,6 +19,7 @@ export interface ArtifactError { export interface UpdatedArtifacts { name: string; contents: string | Buffer; + mode?: string | number; } export interface WriteExistingFilesResult { diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index d7412b37208283..a3e6d78857ba72 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -412,6 +412,23 @@ describe('util/git/index', () => { expect.objectContaining({ '--no-verify': null }) ); }); + + it('creates file with specified mode', async () => { + const file = { + name: 'some-executable', + contents: 'some new-contents', + mode: 0o755, + }; + const commit = await git.commitFiles({ + branchName: 'renovate/past_branch', + files: [file], + message: 'Create something', + }); + const { mode } = await fs.stat(tmpDir.path + '/some-executable'); + expect(commit).not.toBeNull(); + // eslint-disable-next-line no-bitwise + expect(mode & 0o777).toBe(0o755); + }); }); describe('getCommitMessages()', () => { diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 3c7610ecb4562b..fa5998ada00ce0 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -653,6 +653,11 @@ export interface File { * file contents */ contents: string | Buffer; + + /** + * file mode + */ + mode?: fs.Mode; } export type CommitFilesConfig = { @@ -698,7 +703,8 @@ export async function commitFiles({ ignoredFiles.push(fileName); } } else { - if (await isDirectory(join(localDir, fileName))) { + const path = join(localDir, fileName); + if (await isDirectory(path)) { // This is usually a git submodule update logger.trace({ fileName }, 'Adding directory commit'); } else { @@ -709,7 +715,10 @@ export async function commitFiles({ } else { contents = file.contents; } - await fs.outputFile(join(localDir, fileName), contents); + await fs.outputFile(path, contents); + if (file.mode) { + await fs.chmod(path, file.mode); + } } try { await git.add(fileName); From 2cf51bb681e92347847007ac5fe06e0637df1afa Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 9 Oct 2021 08:22:00 +0200 Subject: [PATCH 32/38] Revert "fix(git): support setting file mode (#12081)" (#12082) --- lib/manager/npm/post-update/types.ts | 1 - lib/util/git/index.spec.ts | 17 ----------------- lib/util/git/index.ts | 13 ++----------- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/lib/manager/npm/post-update/types.ts b/lib/manager/npm/post-update/types.ts index 2b780ddc89ee9d..035ac3d39d47c2 100644 --- a/lib/manager/npm/post-update/types.ts +++ b/lib/manager/npm/post-update/types.ts @@ -19,7 +19,6 @@ export interface ArtifactError { export interface UpdatedArtifacts { name: string; contents: string | Buffer; - mode?: string | number; } export interface WriteExistingFilesResult { diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index a3e6d78857ba72..d7412b37208283 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -412,23 +412,6 @@ describe('util/git/index', () => { expect.objectContaining({ '--no-verify': null }) ); }); - - it('creates file with specified mode', async () => { - const file = { - name: 'some-executable', - contents: 'some new-contents', - mode: 0o755, - }; - const commit = await git.commitFiles({ - branchName: 'renovate/past_branch', - files: [file], - message: 'Create something', - }); - const { mode } = await fs.stat(tmpDir.path + '/some-executable'); - expect(commit).not.toBeNull(); - // eslint-disable-next-line no-bitwise - expect(mode & 0o777).toBe(0o755); - }); }); describe('getCommitMessages()', () => { diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index fa5998ada00ce0..3c7610ecb4562b 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -653,11 +653,6 @@ export interface File { * file contents */ contents: string | Buffer; - - /** - * file mode - */ - mode?: fs.Mode; } export type CommitFilesConfig = { @@ -703,8 +698,7 @@ export async function commitFiles({ ignoredFiles.push(fileName); } } else { - const path = join(localDir, fileName); - if (await isDirectory(path)) { + if (await isDirectory(join(localDir, fileName))) { // This is usually a git submodule update logger.trace({ fileName }, 'Adding directory commit'); } else { @@ -715,10 +709,7 @@ export async function commitFiles({ } else { contents = file.contents; } - await fs.outputFile(path, contents); - if (file.mode) { - await fs.chmod(path, file.mode); - } + await fs.outputFile(join(localDir, fileName), contents); } try { await git.add(fileName); From 1b6ea2447f335feadda9f6b72b9f19da64396041 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Sat, 9 Oct 2021 10:08:00 +0300 Subject: [PATCH 33/38] refactor(config): Better prefix handling and enhanced coverage (#12083) --- lib/workers/global/config/parse/env.spec.ts | 174 ++++++++++++++++---- lib/workers/global/config/parse/env.ts | 30 +++- 2 files changed, 161 insertions(+), 43 deletions(-) diff --git a/lib/workers/global/config/parse/env.spec.ts b/lib/workers/global/config/parse/env.spec.ts index 714d2732eb6d0b..216be52a5989fc 100644 --- a/lib/workers/global/config/parse/env.spec.ts +++ b/lib/workers/global/config/parse/env.spec.ts @@ -1,5 +1,6 @@ import type { RenovateOptions } from '../../../../config/types'; import { PlatformId } from '../../../../constants'; +import { logger } from '../../../../logger'; import * as env from './env'; describe('workers/global/config/parse/env', () => { @@ -32,25 +33,68 @@ describe('workers/global/config/parse/env', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_TOKEN: 'a' }; expect(env.getConfig(envParam).token).toBe('a'); }); + it('supports custom prefixes', () => { + const envParam: NodeJS.ProcessEnv = { + ENV_PREFIX: 'FOOBAR_', + FOOBAR_TOKEN: 'abc', + }; + const res = env.getConfig(envParam); + expect(res).toMatchObject({ token: 'abc' }); + }); it('supports json', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_LOCK_FILE_MAINTENANCE: '{}', }; expect(env.getConfig(envParam).lockFileMaintenance).toEqual({}); }); + it('supports arrays of objects', () => { + const envParam: NodeJS.ProcessEnv = { + RENOVATE_HOST_RULES: JSON.stringify([{ foo: 'bar' }]), + }; + const res = env.getConfig(envParam); + expect(res).toMatchObject({ hostRules: [{ foo: 'bar' }] }); + }); + it('skips misconfigured arrays', () => { + const envName = 'RENOVATE_HOST_RULES'; + const val = JSON.stringify('foobar'); + const envParam: NodeJS.ProcessEnv = { [envName]: val }; + + const res = env.getConfig(envParam); + + expect(res).toEqual({ hostRules: [] }); + expect(logger.debug).toHaveBeenLastCalledWith( + { val, envName }, + 'Could not parse object array' + ); + }); + it('skips garbage array values', () => { + const envName = 'RENOVATE_HOST_RULES'; + const val = '!@#'; + const envParam: NodeJS.ProcessEnv = { [envName]: val }; + + const res = env.getConfig(envParam); + + expect(res).toEqual({ hostRules: [] }); + expect(logger.debug).toHaveBeenLastCalledWith( + { val, envName }, + 'Could not parse environment variable' + ); + }); it('supports GitHub token', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_TOKEN: 'github.com token', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + token: 'github.com token', + }); }); it('supports GitHub custom endpoint', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_ENDPOINT: 'a ghe endpoint', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'a ghe endpoint', + }); }); it('supports GitHub custom endpoint and github.com', () => { const envParam: NodeJS.ProcessEnv = { @@ -58,24 +102,37 @@ describe('workers/global/config/parse/env', () => { RENOVATE_ENDPOINT: 'a ghe endpoint', RENOVATE_TOKEN: 'a ghe token', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'a ghe endpoint', + hostRules: [ + { + hostType: 'github', + matchHost: 'github.com', + token: 'a github.com token', + }, + ], + token: 'a ghe token', + }); }); it('supports GitHub custom endpoint and gitlab.com', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_ENDPOINT: 'a ghe endpoint', RENOVATE_TOKEN: 'a ghe token', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'a ghe endpoint', + token: 'a ghe token', + }); }); it('supports GitLab token', () => { const envParam: NodeJS.ProcessEnv = { RENOVATE_PLATFORM: PlatformId.Gitlab, RENOVATE_TOKEN: 'a gitlab.com token', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + platform: 'gitlab', + token: 'a gitlab.com token', + }); }); it('supports GitLab custom endpoint', () => { const envParam: NodeJS.ProcessEnv = { @@ -83,8 +140,11 @@ describe('workers/global/config/parse/env', () => { RENOVATE_TOKEN: 'a gitlab token', RENOVATE_ENDPOINT: 'a gitlab endpoint', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'a gitlab endpoint', + platform: 'gitlab', + token: 'a gitlab token', + }); }); it('supports Azure DevOps', () => { const envParam: NodeJS.ProcessEnv = { @@ -92,23 +152,34 @@ describe('workers/global/config/parse/env', () => { RENOVATE_TOKEN: 'an Azure DevOps token', RENOVATE_ENDPOINT: 'an Azure DevOps endpoint', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'an Azure DevOps endpoint', + platform: 'azure', + token: 'an Azure DevOps token', + }); }); it('supports docker username/password', () => { const envParam: NodeJS.ProcessEnv = { DOCKER_USERNAME: 'some-username', DOCKER_PASSWORD: 'some-password', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + hostRules: [ + { + hostType: 'docker', + password: 'some-password', + username: 'some-username', + }, + ], + }); }); it('supports password-only', () => { const envParam: NodeJS.ProcessEnv = { NPM_PASSWORD: 'some-password', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + hostRules: [{ hostType: 'npm', password: 'some-password' }], + }); }); it('supports domain and host names with case insensitivity', () => { const envParam: NodeJS.ProcessEnv = { @@ -116,8 +187,12 @@ describe('workers/global/config/parse/env', () => { pypi_my_CUSTOM_HOST_passWORD: 'some-password', }; const res = env.getConfig(envParam); - expect(res).toMatchSnapshot(); - expect(res.hostRules).toHaveLength(2); + expect(res).toMatchSnapshot({ + hostRules: [ + { matchHost: 'github.com', token: 'some-token' }, + { matchHost: 'my.custom.host', password: 'some-password' }, + ], + }); }); it('regression test for #10937', () => { const envParam: NodeJS.ProcessEnv = { @@ -125,21 +200,24 @@ describe('workers/global/config/parse/env', () => { GIT__TAGS_GITLAB_EXAMPLE__DOMAIN_NET_PASSWORD: 'some-password', }; const res = env.getConfig(envParam); - expect(res.hostRules).toMatchObject([ - { - hostType: 'git-tags', - matchHost: 'gitlab.example-domain.net', - password: 'some-password', - username: 'some-user', - }, - ]); + expect(res).toMatchObject({ + hostRules: [ + { + hostType: 'git-tags', + matchHost: 'gitlab.example-domain.net', + password: 'some-password', + username: 'some-user', + }, + ], + }); }); it('supports datasource env token', () => { const envParam: NodeJS.ProcessEnv = { PYPI_TOKEN: 'some-token', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + hostRules: [{ hostType: 'pypi', token: 'some-token' }], + }); }); it('rejects incomplete datasource env token', () => { const envParam: NodeJS.ProcessEnv = { @@ -160,8 +238,12 @@ describe('workers/global/config/parse/env', () => { RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + platform: 'bitbucket', + endpoint: 'a bitbucket endpoint', + username: 'some-username', + password: 'app-password', + }); }); it('supports Bitbucket username/password', () => { const envParam: NodeJS.ProcessEnv = { @@ -170,8 +252,13 @@ describe('workers/global/config/parse/env', () => { RENOVATE_USERNAME: 'some-username', RENOVATE_PASSWORD: 'app-password', }; - // FIXME: explicit assert condition - expect(env.getConfig(envParam)).toMatchSnapshot(); + expect(env.getConfig(envParam)).toMatchSnapshot({ + endpoint: 'a bitbucket endpoint', + hostRules: [], + password: 'app-password', + platform: 'bitbucket', + username: 'some-username', + }); }); it('merges full config from env', () => { const envParam: NodeJS.ProcessEnv = { @@ -182,6 +269,25 @@ describe('workers/global/config/parse/env', () => { expect(config.enabled).toBe(false); expect(config.token).toBe('a'); }); + describe('malformed RENOVATE_CONFIG', () => { + let processExit: jest.SpyInstance; + + beforeAll(() => { + processExit = jest + .spyOn(process, 'exit') + .mockImplementation((() => {}) as never); + }); + + afterAll(() => { + processExit.mockRestore(); + }); + + it('crashes', () => { + const envParam: NodeJS.ProcessEnv = { RENOVATE_CONFIG: '!@#' }; + env.getConfig(envParam); + expect(processExit).toHaveBeenCalledWith(1); + }); + }); }); describe('.getEnvName(definition)', () => { it('returns empty', () => { diff --git a/lib/workers/global/config/parse/env.ts b/lib/workers/global/config/parse/env.ts index a6e91c219ff710..3425a5be880591 100644 --- a/lib/workers/global/config/parse/env.ts +++ b/lib/workers/global/config/parse/env.ts @@ -7,13 +7,21 @@ import { getDatasourceList } from '../../../../datasource'; import { logger } from '../../../../logger'; import type { HostRule } from '../../../../types'; -// istanbul ignore if -if (process.env.ENV_PREFIX) { - for (const [key, val] of Object.entries(process.env)) { - if (key.startsWith(process.env.ENV_PREFIX)) { - process.env[key.replace(process.env.ENV_PREFIX, 'RENOVATE_')] = val; +function normalizePrefixes( + env: NodeJS.ProcessEnv, + prefix: string | undefined +): NodeJS.ProcessEnv { + const result = { ...env }; + if (prefix) { + for (const [key, val] of Object.entries(result)) { + if (key.startsWith(prefix)) { + const newKey = key.replace(prefix, 'RENOVATE_'); + result[newKey] = val; + delete result[key]; + } } } + return result; } export function getEnvName(option: Partial): string { @@ -27,7 +35,9 @@ export function getEnvName(option: Partial): string { return `RENOVATE_${nameWithUnderscores.toUpperCase()}`; } -export function getConfig(env: NodeJS.ProcessEnv): AllConfig { +export function getConfig(inputEnv: NodeJS.ProcessEnv): AllConfig { + const env = normalizePrefixes(inputEnv, inputEnv.ENV_PREFIX); + const options = getOptions(); let config: AllConfig = {}; @@ -36,7 +46,7 @@ export function getConfig(env: NodeJS.ProcessEnv): AllConfig { try { config = JSON.parse(env.RENOVATE_CONFIG); logger.debug({ config }, 'Detected config in env RENOVATE_CONFIG'); - } catch (err) /* istanbul ignore next */ { + } catch (err) { logger.fatal({ err }, 'Could not parse RENOVATE_CONFIG'); process.exit(1); } @@ -56,7 +66,6 @@ export function getConfig(env: NodeJS.ProcessEnv): AllConfig { if (option.env !== false) { const envName = getEnvName(option); if (env[envName]) { - // istanbul ignore if if (option.type === 'array' && option.subType === 'object') { try { const parsed = JSON.parse(env[envName]); @@ -69,7 +78,10 @@ export function getConfig(env: NodeJS.ProcessEnv): AllConfig { ); } } catch (err) { - logger.debug({ val: env[envName], envName }, 'Could not parse CLI'); + logger.debug( + { val: env[envName], envName }, + 'Could not parse environment variable' + ); } } else { const coerce = coersions[option.type]; From 8f81bb01656081489f94a9039c990e9e3d3fb221 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 9 Oct 2021 08:35:43 +0000 Subject: [PATCH 34/38] chore(deps): update dependency markdownlint-cli2 to v0.3.2 (#12084) Co-authored-by: Renovate Bot --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 65ebc8a37e8235..954ccb33b21052 100644 --- a/package.json +++ b/package.json @@ -259,7 +259,7 @@ "jest-junit": "12.3.0", "jest-mock-extended": "2.0.4", "jest-silent-reporter": "0.5.0", - "markdownlint-cli2": "0.3.1", + "markdownlint-cli2": "0.3.2", "mockdate": "3.0.5", "nock": "13.1.3", "npm-run-all": "4.1.5", diff --git a/yarn.lock b/yarn.lock index e83d3e2b8144e7..388d7fe498fc2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6596,10 +6596,10 @@ markdownlint-cli2-formatter-default@^0.0.2: resolved "https://registry.yarnpkg.com/markdownlint-cli2-formatter-default/-/markdownlint-cli2-formatter-default-0.0.2.tgz#76f1a064d70966178dfe3bb489af9423d830ca79" integrity sha512-jIz1X3SIC8sX4NDFqQFUXL+JEtfnDoN4i+xocEu+etcxGX455pHb6sx86f/yVk4mKJ2o7aNe2ydSx9an22BfBg== -markdownlint-cli2@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/markdownlint-cli2/-/markdownlint-cli2-0.3.1.tgz#dcdd23a024ff471c6d2117297555c6ddae90d79a" - integrity sha512-6t2EhSEpu355IBPdm5DAMAo8ihWWUfIA0pB9FmTUNw78tENAStZPvBL7ym0/4ub9u/J0zslV2ONUTfEhro1KOA== +markdownlint-cli2@0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/markdownlint-cli2/-/markdownlint-cli2-0.3.2.tgz#328774b5ab981997fdd6fa8f72ea7feaed84722b" + integrity sha512-Wj4iQy2J49m9CVkWkLTdFxMTPDqD3AyL3NbLQgz/nUnTu8LnDguFCbQtFhdzQPvncHVjrKT2vYqg7DifzVP4tA== dependencies: globby "~11.0.4" markdownlint "~0.24.0" From d55650ff191e417377aae0e66806d231d1182ddf Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Sat, 9 Oct 2021 18:02:12 +0900 Subject: [PATCH 35/38] fix(git): support setting executable bit (#12085) --- lib/manager/npm/post-update/types.ts | 1 + lib/util/git/index.spec.ts | 18 ++++++++++++++++++ lib/util/git/index.ts | 14 +++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/manager/npm/post-update/types.ts b/lib/manager/npm/post-update/types.ts index 035ac3d39d47c2..8b4605f2274cd4 100644 --- a/lib/manager/npm/post-update/types.ts +++ b/lib/manager/npm/post-update/types.ts @@ -19,6 +19,7 @@ export interface ArtifactError { export interface UpdatedArtifacts { name: string; contents: string | Buffer; + executable?: boolean; } export interface WriteExistingFilesResult { diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index d7412b37208283..42bae467a5b059 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -412,6 +412,24 @@ describe('util/git/index', () => { expect.objectContaining({ '--no-verify': null }) ); }); + + it('creates file with the executable bit', async () => { + const file = { + name: 'some-executable', + contents: 'some new-contents', + executable: true, + }; + const commit = await git.commitFiles({ + branchName: 'renovate/past_branch', + files: [file], + message: 'Create something', + }); + expect(commit).not.toBeNull(); + + const repo = Git(tmpDir.path); + const result = await repo.raw(['ls-tree', 'HEAD', 'some-executable']); + expect(result).toStartWith('100755'); + }); }); describe('getCommitMessages()', () => { diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 3c7610ecb4562b..ebcbcf19812433 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -653,6 +653,11 @@ export interface File { * file contents */ contents: string | Buffer; + + /** + * the executable bit + */ + executable?: boolean; } export type CommitFilesConfig = { @@ -709,10 +714,17 @@ export async function commitFiles({ } else { contents = file.contents; } - await fs.outputFile(join(localDir, fileName), contents); + // some file systems including Windows don't support the mode + // so the index should be manually updated after adding the file + await fs.outputFile(join(localDir, fileName), contents, { + mode: file.executable ? 0o777 : 0o666, + }); } try { await git.add(fileName); + if (file.executable) { + await git.raw(['update-index', '--chmod=+x', fileName]); + } addedModifiedFiles.push(fileName); } catch (err) /* istanbul ignore next */ { if ( From f5db1cb56a4d737d5d5045849dbb88a1187e65c2 Mon Sep 17 00:00:00 2001 From: Ben Foster Date: Sun, 10 Oct 2021 03:41:51 -0400 Subject: [PATCH 36/38] fix(datasource/maven): look for maven snapshot pom (#11327) --- .../clojure/__snapshots__/index.spec.ts.snap | 452 +++++++++++++++ lib/datasource/clojure/index.spec.ts | 71 +++ .../metadata-snapshot-version-invalid.xml | 12 + .../metadata-snapshot-version.xml | 11 + .../maven/__fixtures__/metadata.xml | 3 + .../maven/__snapshots__/index.spec.ts.snap | 525 ++++++++++++++++++ lib/datasource/maven/index.spec.ts | 79 +++ lib/datasource/maven/index.ts | 106 +++- 8 files changed, 1245 insertions(+), 14 deletions(-) create mode 100644 lib/datasource/maven/__fixtures__/metadata-snapshot-version-invalid.xml create mode 100644 lib/datasource/maven/__fixtures__/metadata-snapshot-version.xml diff --git a/lib/datasource/clojure/__snapshots__/index.spec.ts.snap b/lib/datasource/clojure/__snapshots__/index.spec.ts.snap index 1f8904dcf844d8..aed87d93324495 100644 --- a/lib/datasource/clojure/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/clojure/__snapshots__/index.spec.ts.snap @@ -11,6 +11,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -38,6 +56,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -47,6 +92,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -98,6 +152,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -153,6 +211,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -180,6 +256,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -189,6 +292,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -212,6 +324,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -239,6 +369,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -248,6 +405,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -266,6 +432,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -293,6 +477,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -302,6 +513,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -320,6 +540,10 @@ Array [ "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -338,6 +562,24 @@ Array [ "method": "GET", "url": "http://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -365,6 +607,33 @@ Array [ "method": "HEAD", "url": "http://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -374,6 +643,15 @@ Array [ "method": "HEAD", "url": "http://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -398,6 +676,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -417,6 +699,24 @@ Array [ "method": "GET", "url": "https://custom.registry.renovatebot.com/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -444,6 +744,33 @@ Array [ "method": "HEAD", "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -453,6 +780,15 @@ Array [ "method": "HEAD", "url": "https://custom.registry.renovatebot.com/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -477,6 +813,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -505,6 +845,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -532,6 +890,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -541,6 +926,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -565,6 +959,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -593,6 +991,24 @@ Array [ "method": "GET", "url": "https://clojars.org/repo/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -620,6 +1036,33 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -629,6 +1072,15 @@ Array [ "method": "HEAD", "url": "https://clojars.org/repo/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "clojars.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://clojars.org/repo/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", diff --git a/lib/datasource/clojure/index.spec.ts b/lib/datasource/clojure/index.spec.ts index 15196c461c4c6e..642829eb34ae8a 100644 --- a/lib/datasource/clojure/index.spec.ts +++ b/lib/datasource/clojure/index.spec.ts @@ -9,6 +9,12 @@ import { ClojureDatasource } from '.'; const baseUrl = 'https://clojars.org/repo'; const baseUrlCustom = 'https://custom.registry.renovatebot.com'; +interface SnapshotOpts { + version: string; + jarStatus?: number; + meta?: string; +} + interface MockOpts { dep?: string; base?: string; @@ -16,6 +22,7 @@ interface MockOpts { pom?: string | null; latest?: string; jars?: Record | null; + snapshots?: SnapshotOpts[] | null; } function mockGenericPackage(opts: MockOpts = {}) { @@ -41,6 +48,29 @@ function mockGenericPackage(opts: MockOpts = {}) { '2.0.0': 200, } : opts.jars; + const snapshots = + opts.snapshots === undefined + ? [ + { + version: '1.0.3-SNAPSHOT', + meta: loadFixture( + 'metadata-snapshot-version.xml', + upath.join('..', 'maven') + ), + jarStatus: 200, + }, + { + version: '1.0.4-SNAPSHOT', + meta: loadFixture( + 'metadata-snapshot-version-invalid.xml', + upath.join('..', 'maven') + ), + }, + { + version: '1.0.5-SNAPSHOT', + }, + ] + : opts.snapshots; const scope = httpMock.scope(base); @@ -69,6 +99,45 @@ function mockGenericPackage(opts: MockOpts = {}) { .reply(status, '', { 'Last-Modified': timestamp }); }); } + + if (snapshots) { + snapshots.forEach((snapshot) => { + if (snapshot.meta) { + scope + .get(`/${packagePath}/${snapshot.version}/maven-metadata.xml`) + .reply(200, snapshot.meta); + } else { + scope + .get(`/${packagePath}/${snapshot.version}/maven-metadata.xml`) + .reply(404, ''); + } + + if (snapshot.jarStatus) { + const [major, minor, patch] = snapshot.version + .replace('-SNAPSHOT', '') + .split('.') + .map((x) => parseInt(x, 10)) + .map((x) => (x < 10 ? `0${x}` : `${x}`)); + const timestamp = `2020-01-01T${major}:${minor}:${patch}.000Z`; + scope + .head( + `/${packagePath}/${ + snapshot.version + }/${artifact}-${snapshot.version.replace( + '-SNAPSHOT', + '' + )}-20200101.${major}${minor}${patch}-${parseInt(patch, 10)}.pom` + ) + .reply(snapshot.jarStatus, '', { 'Last-Modified': timestamp }); + } else { + scope + .head( + `/${packagePath}/${snapshot.version}/${artifact}-${snapshot.version}.pom` + ) + .reply(404, ''); + } + }); + } } function get( depName = 'org.example:package', @@ -109,6 +178,7 @@ describe('datasource/clojure/index', () => { meta: loadFixture('metadata-extra.xml', upath.join('..', 'maven')), latest: '3.0.0', jars: { '3.0.0': 200 }, + snapshots: [], }); const { releases } = await get( @@ -119,6 +189,7 @@ describe('datasource/clojure/index', () => { expect(releases).toMatchObject([ { version: '1.0.0' }, + { version: '1.0.3-SNAPSHOT' }, { version: '2.0.0' }, { version: '3.0.0' }, ]); diff --git a/lib/datasource/maven/__fixtures__/metadata-snapshot-version-invalid.xml b/lib/datasource/maven/__fixtures__/metadata-snapshot-version-invalid.xml new file mode 100644 index 00000000000000..9a0bb8e92420de --- /dev/null +++ b/lib/datasource/maven/__fixtures__/metadata-snapshot-version-invalid.xml @@ -0,0 +1,12 @@ + + org.example + package + 1.0.4-SNAPSHOT + + + 4 + + + 20130301200000 + + diff --git a/lib/datasource/maven/__fixtures__/metadata-snapshot-version.xml b/lib/datasource/maven/__fixtures__/metadata-snapshot-version.xml new file mode 100644 index 00000000000000..e91402d64e2559 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/metadata-snapshot-version.xml @@ -0,0 +1,11 @@ + + org.example + package + 1.0.3-SNAPSHOT + + + 20200101.010003 + 3 + + + \ No newline at end of file diff --git a/lib/datasource/maven/__fixtures__/metadata.xml b/lib/datasource/maven/__fixtures__/metadata.xml index a355205eb254e2..aa8588fb848e35 100644 --- a/lib/datasource/maven/__fixtures__/metadata.xml +++ b/lib/datasource/maven/__fixtures__/metadata.xml @@ -9,6 +9,9 @@ 1.0.0 1.0.1 1.0.2 + 1.0.3-SNAPSHOT + 1.0.4-SNAPSHOT + 1.0.5-SNAPSHOT 2.0.0 20210101000000 diff --git a/lib/datasource/maven/__snapshots__/index.spec.ts.snap b/lib/datasource/maven/__snapshots__/index.spec.ts.snap index e3fda6990f1a09..799a466c033d0c 100644 --- a/lib/datasource/maven/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/maven/__snapshots__/index.spec.ts.snap @@ -11,6 +11,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -38,6 +56,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -47,6 +92,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -101,6 +155,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -156,6 +214,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -183,6 +259,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -192,6 +295,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -575,6 +687,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -602,6 +732,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -611,6 +768,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -629,6 +795,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -656,6 +840,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -665,6 +876,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -683,6 +903,10 @@ Array [ "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -701,6 +925,24 @@ Array [ "method": "GET", "url": "http://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -728,6 +970,33 @@ Array [ "method": "HEAD", "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -737,6 +1006,15 @@ Array [ "method": "HEAD", "url": "http://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "http://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -766,6 +1044,15 @@ Object { Object { "version": "1.0.2", }, + Object { + "version": "1.0.3-SNAPSHOT", + }, + Object { + "version": "1.0.4-SNAPSHOT", + }, + Object { + "version": "1.0.5-SNAPSHOT", + }, Object { "version": "2.0.0", }, @@ -842,6 +1129,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -861,6 +1152,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -888,6 +1197,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -897,6 +1233,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -921,6 +1266,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -941,6 +1290,26 @@ Array [ "method": "GET", "url": "https://custom.registry.renovatebot.com/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -971,6 +1340,36 @@ Array [ "method": "HEAD", "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -981,6 +1380,16 @@ Array [ "method": "HEAD", "url": "https://custom.registry.renovatebot.com/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer 123test", + "host": "custom.registry.renovatebot.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://custom.registry.renovatebot.com/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1006,6 +1415,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -1034,6 +1447,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1061,6 +1492,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1070,6 +1528,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1094,6 +1561,10 @@ Object { "releaseTimestamp": "2020-01-01T01:00:00.000Z", "version": "1.0.0", }, + Object { + "releaseTimestamp": "2020-01-01T01:00:03.000Z", + "version": "1.0.3-SNAPSHOT", + }, Object { "releaseTimestamp": "2020-01-01T02:00:00.000Z", "version": "2.0.0", @@ -1122,6 +1593,24 @@ Array [ "method": "GET", "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1149,6 +1638,33 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.2/package-1.0.2.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.3-SNAPSHOT/package-1.0.3-20200101.010003-3.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.4-SNAPSHOT/package-1.0.4-SNAPSHOT.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/maven-metadata.xml", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", @@ -1158,6 +1674,15 @@ Array [ "method": "HEAD", "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/1.0.5-SNAPSHOT/package-1.0.5-SNAPSHOT.pom", + }, Object { "headers": Object { "accept-encoding": "gzip, deflate, br", diff --git a/lib/datasource/maven/index.spec.ts b/lib/datasource/maven/index.spec.ts index 6a73422dc90220..5361a99e6226e4 100644 --- a/lib/datasource/maven/index.spec.ts +++ b/lib/datasource/maven/index.spec.ts @@ -9,6 +9,12 @@ import { id as datasource } from '.'; const baseUrl = 'https://repo.maven.apache.org/maven2'; const baseUrlCustom = 'https://custom.registry.renovatebot.com'; +interface SnapshotOpts { + version: string; + jarStatus?: number; + meta?: string; +} + interface MockOpts { dep?: string; base?: string; @@ -16,6 +22,7 @@ interface MockOpts { pom?: string | null; latest?: string; jars?: Record | null; + snapshots?: SnapshotOpts[] | null; } function mockGenericPackage(opts: MockOpts = {}) { @@ -37,6 +44,24 @@ function mockGenericPackage(opts: MockOpts = {}) { } : opts.jars; + const snapshots = + opts.snapshots === undefined + ? [ + { + version: '1.0.3-SNAPSHOT', + meta: loadFixture('metadata-snapshot-version.xml'), + jarStatus: 200, + }, + { + version: '1.0.4-SNAPSHOT', + meta: loadFixture('metadata-snapshot-version-invalid.xml'), + }, + { + version: '1.0.5-SNAPSHOT', + }, + ] + : opts.snapshots; + const scope = httpMock.scope(base); const [group, artifact] = dep.split(':'); @@ -55,6 +80,7 @@ function mockGenericPackage(opts: MockOpts = {}) { if (jars) { Object.entries(jars).forEach(([version, status]) => { const [major, minor, patch] = version + .replace('-SNAPSHOT', '') .split('.') .map((x) => parseInt(x, 10)) .map((x) => (x < 10 ? `0${x}` : `${x}`)); @@ -64,6 +90,45 @@ function mockGenericPackage(opts: MockOpts = {}) { .reply(status, '', { 'Last-Modified': timestamp }); }); } + + if (snapshots) { + snapshots.forEach((snapshot) => { + if (snapshot.meta) { + scope + .get(`/${packagePath}/${snapshot.version}/maven-metadata.xml`) + .reply(200, snapshot.meta); + } else { + scope + .get(`/${packagePath}/${snapshot.version}/maven-metadata.xml`) + .reply(404, ''); + } + + if (snapshot.jarStatus) { + const [major, minor, patch] = snapshot.version + .replace('-SNAPSHOT', '') + .split('.') + .map((x) => parseInt(x, 10)) + .map((x) => (x < 10 ? `0${x}` : `${x}`)); + const timestamp = `2020-01-01T${major}:${minor}:${patch}.000Z`; + scope + .head( + `/${packagePath}/${ + snapshot.version + }/${artifact}-${snapshot.version.replace( + '-SNAPSHOT', + '' + )}-20200101.${major}${minor}${patch}-${parseInt(patch, 10)}.pom` + ) + .reply(snapshot.jarStatus, '', { 'Last-Modified': timestamp }); + } else { + scope + .head( + `/${packagePath}/${snapshot.version}/${artifact}-${snapshot.version}.pom` + ) + .reply(404, ''); + } + }); + } } function get( @@ -126,6 +191,7 @@ describe('datasource/maven/index', () => { meta: loadFixture('metadata-extra.xml'), latest: '3.0.0', jars: { '3.0.0': 200 }, + snapshots: [], }); const { releases } = await get( @@ -136,6 +202,7 @@ describe('datasource/maven/index', () => { expect(releases).toMatchObject([ { version: '1.0.0' }, + { version: '1.0.3-SNAPSHOT' }, { version: '2.0.0' }, { version: '3.0.0' }, ]); @@ -313,6 +380,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('parent-scm-homepage/pom.xml'), latest: '1.0.0', jars: null, + snapshots: [], }; it('should get source and homepage from parent', async () => { @@ -321,6 +389,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-no-info/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); mockGenericPackage(parentPackage); @@ -339,6 +408,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-empty/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); const res = await get(); @@ -361,6 +431,7 @@ describe('datasource/maven/index', () => { pom: parentPom, latest: '2.0.0', jars: null, + snapshots: [], }; const childMeta = loadFixture('child-parent-cycle/child.meta.xml'); @@ -371,12 +442,14 @@ describe('datasource/maven/index', () => { pom: childPom, latest: '2.0.0', jars: null, + snapshots: [], }; mockGenericPackage({ ...childPomMock, meta: childMeta, jars: { '2.0.0': 200 }, + snapshots: [], }); mockGenericPackage(parentPomMock); mockGenericPackage(childPomMock); @@ -398,6 +471,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-scm/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); mockGenericPackage(parentPackage); @@ -416,6 +490,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-url/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); mockGenericPackage(parentPackage); @@ -434,6 +509,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-all-info/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); const res = await get(); @@ -451,6 +527,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-scm-gitatcolon/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); const res = await get(); @@ -467,6 +544,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-scm-gitatslash/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); const res = await get(); @@ -482,6 +560,7 @@ describe('datasource/maven/index', () => { pom: loadFixture('child-scm-gitprotocol/pom.xml'), latest: '2.0.0', jars: { '2.0.0': 200 }, + snapshots: [], }); const res = await get(); diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 20e6aef5764e94..e5399bdd14c691 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -1,5 +1,4 @@ -import url from 'url'; -import pAll from 'p-all'; +import pMap from 'p-map'; import { XmlDocument } from 'xmldoc'; import { logger } from '../../logger'; import * as packageCache from '../../util/cache/package'; @@ -95,6 +94,81 @@ function isValidArtifactsInfo( return versions.every((v) => info[v] !== undefined); } +function isSnapshotVersion(version: string): boolean { + if (version.endsWith('-SNAPSHOT')) { + return true; + } + return false; +} + +function extractSnapshotVersion(metadata: XmlDocument): string | null { + // Parse the maven-metadata.xml for the snapshot version and determine + // the fixed version of the latest deployed snapshot. + // The metadata descriptor can be found at + // https://maven.apache.org/ref/3.3.3/maven-repository-metadata/repository-metadata.html + // + // Basically, we need to replace -SNAPSHOT with the artifact timestanp & build number, + // so for example 1.0.0-SNAPSHOT will become 1.0.0-- + const version = metadata + .descendantWithPath('version') + ?.val?.replace('-SNAPSHOT', ''); + + const snapshot = metadata.descendantWithPath('versioning.snapshot'); + const timestamp = snapshot?.childNamed('timestamp')?.val; + const build = snapshot?.childNamed('buildNumber')?.val; + + // If we weren't able to parse out the required 3 version elements, + // return null because we can't determine the fixed version of the latest snapshot. + if (!version || !timestamp || !build) { + return null; + } + return `${version}-${timestamp}-${build}`; +} + +async function getSnapshotFullVersion( + version: string, + dependency: MavenDependency, + repoUrl: string +): Promise { + // To determine what actual files are available for the snapshot, first we have to fetch and parse + // the metadata located at http://////maven-metadata.xml + const metadataUrl = getMavenUrl( + dependency, + repoUrl, + `${version}/maven-metadata.xml` + ); + + const { xml: mavenMetadata } = await downloadMavenXml(metadataUrl); + if (!mavenMetadata) { + return null; + } + + return extractSnapshotVersion(mavenMetadata); +} + +async function createUrlForDependencyPom( + version: string, + dependency: MavenDependency, + repoUrl: string +): Promise { + if (isSnapshotVersion(version)) { + // By default, Maven snapshots are deployed to the repository with fixed file names. + // Resolve the full, actual pom file name for the version. + const fullVersion = await getSnapshotFullVersion( + version, + dependency, + repoUrl + ); + + // If we were able to resolve the version, use that, otherwise fall back to using -SNAPSHOT + if (fullVersion !== null) { + return `${version}/${dependency.name}-${fullVersion}.pom`; + } + } + + return `${version}/${dependency.name}-${version}.pom`; +} + async function filterMissingArtifacts( dependency: MavenDependency, repoUrl: string, @@ -105,23 +179,26 @@ async function filterMissingArtifacts( let artifactsInfo: ArtifactsInfo | null = await packageCache.get(cacheNamespace, cacheKey); + // If the cache contains any artifacts that we were previously unable to determine if they exist, + // retry the existence checks on them. if (!isValidArtifactsInfo(artifactsInfo, versions)) { - const queue = versions - .map((version): [string, url.URL | null] => { + // For each version, determine if there is a POM file available for it + const results: ArtifactInfoResult[] = await pMap( + versions, + async (version): Promise => { + // Create the URL that the POM file should be available at const artifactUrl = getMavenUrl( dependency, repoUrl, - `${version}/${dependency.name}-${version}.pom` + await createUrlForDependencyPom(version, dependency, repoUrl) ); - return [version, artifactUrl]; - }) - .filter(([_, artifactUrl]) => Boolean(artifactUrl)) - .map( - ([version, artifactUrl]) => - async (): Promise => - [version, await isHttpResourceExists(artifactUrl)] - ); - const results = await pAll(queue, { concurrency: 5 }); + + // Return an ArtifactInfoResult that maps the version to the result of the check if the POM file exists in the repo + return [version, await isHttpResourceExists(artifactUrl)]; + }, + { concurrency: 5 } + ); + artifactsInfo = results.reduce( (acc, [key, value]) => ({ ...acc, @@ -138,6 +215,7 @@ async function filterMissingArtifacts( await packageCache.set(cacheNamespace, cacheKey, artifactsInfo, cacheTTL); } + // Create releases for every version that exists in the repository return versions .filter((v) => artifactsInfo[v]) .map((version) => { From 95003a6c045bc21f0699dea5f60f03a0c8fc2a1a Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sun, 10 Oct 2021 17:24:54 +0200 Subject: [PATCH 37/38] fix(git): catch common branch push errors (#12096) --- lib/util/git/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index ebcbcf19812433..3b66f06f96d6a6 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -840,6 +840,20 @@ export async function commitFiles({ logger.error({ err }, 'Error committing files.'); return null; } + if (err.message.includes('[rejected] (stale info)')) { + logger.info( + 'Branch update was rejected because local copy is not up-to-date.' + ); + return null; + } + if (err.message.includes('denying non-fast-forward')) { + logger.debug({ err }, 'Permission denied to update branch'); + const error = new Error(CONFIG_VALIDATION); + error.validationSource = branchName; + error.validationError = 'Force push denied'; + error.validationMessage = `Renovate is unable to update branch(es) due to force pushes being disallowed.`; + throw error; + } logger.debug({ err }, 'Unknown error committing files'); // We don't know why this happened, so this will cause bubble up to a branch error throw err; From f74404b3c29dc7b45f65cd42a53678665e0c2381 Mon Sep 17 00:00:00 2001 From: Maksim Date: Sun, 10 Oct 2021 18:13:45 +0200 Subject: [PATCH 38/38] fix: run unit tests in UTC timezone (#12098) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 954ccb33b21052..0a72db699443e5 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "generate": "run-s generate:*", "generate:imports": "node tools/generate-imports.mjs", "git-check": "node tools/check-git-version.mjs", - "jest": "cross-env NODE_ENV=test LOG_LEVEL=fatal node --expose-gc node_modules/jest/bin/jest.js --logHeapUsage", + "jest": "cross-env NODE_ENV=test LOG_LEVEL=fatal TZ=UTC node --expose-gc node_modules/jest/bin/jest.js --logHeapUsage", "jest-debug": "cross-env NODE_OPTIONS=--inspect-brk yarn jest", "jest-silent": "cross-env yarn jest --reporters jest-silent-reporter", "lint": "run-s ls-lint eslint prettier markdown-lint git-check",