feat(manager/sbt): support proxy registries (#27276)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
This commit is contained in:
Lakshmipriya Sivakumar 2024-02-27 15:28:20 -05:00 committed by GitHub
parent 7e7124ef93
commit 5de12e7f09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 219 additions and 96 deletions

View file

@ -8,9 +8,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -18,9 +16,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"datasource": "sbt-package",
"depName": "com.example:foo",
"packageName": "com.example:foo_2.13.0-RC5",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
{
"currentValue": "1.2.3",
@ -28,9 +24,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"depName": "com.abc:abc",
"groupName": "abcVersion",
"packageName": "com.abc:abc",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"variableName": "abcVersion",
},
],
@ -46,9 +40,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -56,9 +48,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"datasource": "sbt-package",
"depName": "com.example:foo",
"packageName": "com.example:foo_2.13.0-RC5",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
{
"currentValue": "1.2.3",
@ -66,9 +56,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"depName": "com.abc:abc",
"groupName": "abcVersion",
"packageName": "com.abc:abc",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"variableName": "abcVersion",
},
{
@ -77,9 +65,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"depName": "com.abc:abc-a",
"groupName": "abcVersion",
"packageName": "com.abc:abc-a",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"variableName": "abcVersion",
},
{
@ -88,9 +74,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"depName": "com.abc:abc-b",
"groupName": "abcVersion",
"packageName": "com.abc:abc-b",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"variableName": "abcVersion",
},
{
@ -99,9 +83,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extract deps from nati
"depName": "com.abc:abc-c",
"groupName": "abcVersion",
"packageName": "com.abc:abc-c",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"variableName": "abcVersion",
},
],
@ -118,7 +100,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -133,7 +114,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:foo",
"packageName": "org.example:foo",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -147,7 +127,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:bar",
"packageName": "org.example:bar_2.9.10",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -161,7 +140,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:baz",
"packageName": "org.example:baz_2.9.10",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -175,7 +153,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:qux",
"packageName": "org.example:qux",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -190,7 +167,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depType": "sources",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -204,7 +180,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:quux",
"packageName": "org.example:quux",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -219,7 +194,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depType": "test",
"packageName": "org.example:quuz_2.9.10",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -234,7 +208,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depType": "test",
"packageName": "org.example:abc_2.9.10",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -249,7 +222,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depType": "Provided",
"packageName": "org.example:corge",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -265,7 +237,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"groupName": "versionExample",
"packageName": "org.example:grault",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -281,13 +252,11 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depType": "plugin",
"packageName": "org.example:waldo",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
"https://example.com/repos/4/",
"https://example.com/repos/5/",
"https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases",
],
},
{
@ -296,7 +265,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps for gene
"depName": "org.example:fred",
"packageName": "org.example:fred",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -318,7 +286,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -333,7 +300,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "org.example:foo",
"packageName": "org.example:foo",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -347,7 +313,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "org.example:bar",
"packageName": "org.example:bar_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -361,7 +326,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "org.example:baz",
"packageName": "org.example:baz_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -375,7 +339,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "org.example:qux",
"packageName": "org.example:qux",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -389,7 +352,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depName": "org.example:quux",
"packageName": "org.example:quux",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -404,7 +366,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depType": "test",
"packageName": "org.example:quuz_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -419,7 +380,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depType": "Provided",
"packageName": "org.example:corge",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -435,7 +395,6 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"groupName": "versionExample",
"packageName": "org.example:grault",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
@ -451,13 +410,11 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"depType": "plugin",
"packageName": "org.example:waldo",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://example.com/repos/1/",
"https://example.com/repos/2/",
"https://example.com/repos/3/",
"https://example.com/repos/4/",
"https://example.com/repos/5/",
"https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases",
],
},
],
@ -473,9 +430,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -483,9 +438,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "sbt-package",
"depName": "org.example:bar",
"packageName": "org.example:bar_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
],
"packageFileVersion": undefined,
@ -500,9 +453,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -510,9 +461,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "sbt-package",
"depName": "org.example:bar",
"packageName": "org.example:bar_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
],
"packageFileVersion": undefined,
@ -527,9 +476,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -537,9 +484,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "sbt-package",
"depName": "org.example:bar",
"packageName": "org.example:bar_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
],
"packageFileVersion": undefined,
@ -554,9 +499,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "maven",
"depName": "scala",
"packageName": "org.scala-lang:scala-library",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
"separateMinorPatch": true,
},
{
@ -564,9 +507,7 @@ exports[`modules/manager/sbt/extract extractPackageFile() extracts deps when sca
"datasource": "sbt-package",
"depName": "org.example:bar",
"packageName": "org.example:bar_2.12",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
],
"registryUrls": [],
},
],
"packageFileVersion": undefined,

View file

@ -1,6 +1,12 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { extractPackageFile as extract } from '.';
import { fs } from '../../../../test/util';
import {
extractPackageFile as extract,
extractAllPackageFiles,
} from './extract';
jest.mock('../../../util/fs');
const extractPackageFile = (content: string) => extract(content, 'build.sbt');
@ -124,7 +130,7 @@ describe('modules/manager/sbt/extract', () => {
datasource: 'sbt-package',
depName: 'org.scalatest:scalatest',
packageName: 'org.scalatest:scalatest',
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
},
{
currentValue: '1.0.11',
@ -133,10 +139,7 @@ describe('modules/manager/sbt/extract', () => {
depType: 'plugin',
groupName: 'sbtReleaseVersion',
packageName: 'com.github.gseitz:sbt-release',
registryUrls: [
'https://repo.maven.apache.org/maven2',
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases',
],
registryUrls: [],
variableName: 'sbtReleaseVersion',
},
],
@ -297,7 +300,7 @@ describe('modules/manager/sbt/extract', () => {
expect(extractPackageFile(content)).toMatchObject({
deps: [
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
datasource: 'maven',
depName: 'scala',
packageName: 'org.scala-lang:scala-library',
@ -305,14 +308,14 @@ describe('modules/manager/sbt/extract', () => {
separateMinorPatch: true,
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
depName: 'com.typesafe.scala-logging:scala-logging',
packageName: 'com.typesafe.scala-logging:scala-logging_2.13',
currentValue: '3.9.4',
datasource: 'sbt-package',
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
depName: 'ch.qos.logback:logback-classic',
packageName: 'ch.qos.logback:logback-classic',
currentValue: '1.2.10',
@ -337,7 +340,7 @@ describe('modules/manager/sbt/extract', () => {
expect(extractPackageFile(content)).toMatchObject({
deps: [
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
datasource: 'maven',
depName: 'scala',
packageName: 'org.scala-lang:scala-library',
@ -345,14 +348,14 @@ describe('modules/manager/sbt/extract', () => {
separateMinorPatch: true,
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
depName: 'com.typesafe.scala-logging:scala-logging',
packageName: 'com.typesafe.scala-logging:scala-logging_2.13',
currentValue: '3.9.4',
datasource: 'sbt-package',
},
{
registryUrls: ['https://repo.maven.apache.org/maven2'],
registryUrls: [],
depName: 'ch.qos.logback:logback-classic',
packageName: 'ch.qos.logback:logback-classic',
currentValue: '1.2.10',
@ -438,4 +441,120 @@ describe('modules/manager/sbt/extract', () => {
).toBeNull();
});
});
describe('extractAllPackageFiles()', () => {
it('extracts proxy repositories', async () => {
const repositoryContent = codeBlock`
[repositories]
local
my-maven-repo: http://example.org/repo
my-ivy-repo: https://example.org/ivy-repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]
maven-central
`;
fs.readLocalFile
.mockResolvedValueOnce(repositoryContent)
.mockResolvedValueOnce(sbtDependencyFile);
const packages = await extractAllPackageFiles({}, [
'repositories',
'build.sbt',
]);
const expected_packages = [
{
deps: [
{
packageName: 'org.scala-lang:scala-library',
currentValue: '2.13.0-RC5',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
{
packageName: 'com.example:foo_2.13.0-RC5',
currentValue: '0.7.1',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
{
packageName: 'com.abc:abc',
currentValue: '1.2.3',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
{
packageName: 'com.abc:abc-a',
currentValue: '1.2.3',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
{
packageName: 'com.abc:abc-b',
currentValue: '1.2.3',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
{
packageName: 'com.abc:abc-c',
currentValue: '1.2.3',
registryUrls: [
'http://example.org/repo',
'https://example.org/ivy-repo/',
'https://repo1.maven.org/maven2',
],
},
],
},
];
expect(packages).toMatchObject(expected_packages);
});
it('should include default registryUrls if no repositories file is provided', async () => {
fs.readLocalFile.mockResolvedValueOnce(sbt);
const packages = await extractAllPackageFiles({}, ['build.sbt']);
for (const pkg of packages) {
for (const dep of pkg.deps.filter((d) => d.depType === 'plugin')) {
expect(dep.registryUrls).toStrictEqual([
'https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases',
'https://repo1.maven.org/maven2',
'https://example.com/repos/1/',
'https://example.com/repos/2/',
'https://example.com/repos/3/',
'https://example.com/repos/4/',
'https://example.com/repos/5/',
]);
}
}
for (const pkg of packages) {
for (const dep of pkg.deps.filter((d) => d.depType !== 'plugin')) {
expect(dep.registryUrls).toStrictEqual([
'https://repo1.maven.org/maven2',
'https://example.com/repos/1/',
'https://example.com/repos/2/',
'https://example.com/repos/3/',
'https://example.com/repos/4/',
'https://example.com/repos/5/',
]);
}
}
});
it('should return empty packagefiles is no content is provided', async () => {
fs.readLocalFile.mockResolvedValueOnce('');
const packages = await extractAllPackageFiles({}, ['build.sbt']);
expect(packages).toBeEmpty();
});
});
});

View file

@ -1,6 +1,7 @@
import { lang, query as q } from 'good-enough-parser';
import { logger } from '../../../logger';
import { regEx } from '../../../util/regex';
import { readLocalFile } from '../../../util/fs';
import { newlineRegex, regEx } from '../../../util/regex';
import { parseUrl } from '../../../util/url';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { MavenDatasource } from '../../datasource/maven';
@ -12,8 +13,12 @@ import {
import { get } from '../../versioning';
import * as mavenVersioning from '../../versioning/maven';
import * as semverVersioning from '../../versioning/semver';
import { REGISTRY_URLS } from '../gradle/parser/common';
import type { PackageDependency, PackageFileContent } from '../types';
import type {
ExtractConfig,
PackageDependency,
PackageFile,
PackageFileContent,
} from '../types';
import { normalizeScalaVersion } from './util';
type Vars = Record<string, string>;
@ -36,12 +41,18 @@ interface Ctx {
variableName?: string;
}
const SBT_MVN_REPO = 'https://repo1.maven.org/maven2';
const scala = lang.createLang('scala');
const sbtVersionRegex = regEx(
'sbt\\.version *= *(?<version>\\d+\\.\\d+\\.\\d+)',
);
const sbtProxyUrlRegex = regEx(
/^\s*(?<repoName>\S+):\s+(?<proxy>https?:\/\/[\w./-]+)/,
);
const scalaVersionMatch = q
.sym<Ctx>('scalaVersion')
.op(':=')
@ -268,9 +279,6 @@ const addResolverMatch = q.sym<Ctx>('resolvers').alt(
function registryUrlHandler(ctx: Ctx): Ctx {
for (const dep of ctx.deps) {
dep.registryUrls = [...ctx.registryUrls];
if (dep.depType === 'plugin') {
dep.registryUrls.push(SBT_PLUGINS_REPO);
}
}
return ctx;
}
@ -289,6 +297,23 @@ const query = q.tree<Ctx>({
postHandler: registryUrlHandler,
});
export function extractProxyUrls(
content: string,
packageFile: string,
): string[] {
const extractedProxyUrls: string[] = [];
logger.debug(`Parsing proxy repository file ${packageFile}`);
for (const line of content.split(newlineRegex)) {
const extraction = sbtProxyUrlRegex.exec(line);
if (extraction?.groups?.proxy) {
extractedProxyUrls.push(extraction.groups.proxy);
} else if (line.trim() === 'maven-central') {
extractedProxyUrls.push(SBT_MVN_REPO);
}
}
return extractedProxyUrls;
}
export function extractPackageFile(
content: string,
packageFile: string,
@ -325,7 +350,7 @@ export function extractPackageFile(
parsedResult = scala.query(content, query, {
vars: {},
deps: [],
registryUrls: [REGISTRY_URLS.mavenCentral],
registryUrls: [],
});
} catch (err) /* istanbul ignore next */ {
logger.debug({ err, packageFile }, 'Sbt parsing error');
@ -343,3 +368,40 @@ export function extractPackageFile(
return { deps, packageFileVersion };
}
export async function extractAllPackageFiles(
_config: ExtractConfig,
packageFiles: string[],
): Promise<PackageFile[]> {
const packages: PackageFile[] = [];
const proxyUrls: string[] = [];
for (const packageFile of packageFiles) {
const content = await readLocalFile(packageFile, 'utf8');
if (!content) {
logger.debug({ packageFile }, 'packageFile has no content');
continue;
}
if (packageFile === 'repositories') {
const urls = extractProxyUrls(content, packageFile);
proxyUrls.push(...urls);
} else {
const pkg = extractPackageFile(content, packageFile);
if (pkg) {
packages.push({ deps: pkg.deps, packageFile });
}
}
}
for (const pkg of packages) {
for (const dep of pkg.deps) {
if (proxyUrls.length > 0) {
dep.registryUrls!.unshift(...proxyUrls);
} else if (dep.depType === 'plugin') {
dep.registryUrls!.unshift(SBT_PLUGINS_REPO, SBT_MVN_REPO);
} else {
dep.registryUrls!.unshift(SBT_MVN_REPO);
}
}
}
return packages;
}

View file

@ -5,7 +5,7 @@ import { SbtPackageDatasource } from '../../datasource/sbt-package';
import { SbtPluginDatasource } from '../../datasource/sbt-plugin';
import * as ivyVersioning from '../../versioning/ivy';
export { extractPackageFile } from './extract';
export { extractAllPackageFiles } from './extract';
export { bumpPackageVersion } from './update';
export const supportedDatasources = [
@ -20,6 +20,7 @@ export const defaultConfig = {
'\\.sbt$',
'project/[^/]*\\.scala$',
'project/build\\.properties$',
'(^|/)repositories$',
],
versioning: ivyVersioning.id,
};