fix(maven): Use fallback maven registry (#5613)

This commit is contained in:
Sergio Zharinov 2020-03-02 12:08:37 +04:00 committed by GitHub
parent 6f46153e09
commit 0691b13819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 90 additions and 74 deletions

View file

@ -1 +1,5 @@
export const id = 'maven'; export const id = 'maven';
export const MAVEN_REPO = 'https://repo.maven.apache.org/maven2';
export const MAVEN_REPO_DEPRECATED = 'https://central.maven.org/maven2';
export const CLOJARS_REPO = 'https://clojars.org/repo';

View file

@ -45,10 +45,10 @@ describe('datasource/maven', () => {
password: 'password', password: 'password',
}); });
nock.disableNetConnect(); nock.disableNetConnect();
nock('http://central.maven.org') nock('https://repo.maven.apache.org')
.get('/maven2/mysql/mysql-connector-java/maven-metadata.xml') .get('/maven2/mysql/mysql-connector-java/maven-metadata.xml')
.reply(200, MYSQL_MAVEN_METADATA); .reply(200, MYSQL_MAVEN_METADATA);
nock('http://central.maven.org') nock('https://repo.maven.apache.org')
.get( .get(
'/maven2/mysql/mysql-connector-java/8.0.12/mysql-connector-java-8.0.12.pom' '/maven2/mysql/mysql-connector-java/8.0.12/mysql-connector-java-8.0.12.pom'
) )
@ -150,7 +150,7 @@ describe('datasource/maven', () => {
const releases = await maven.getPkgReleases({ const releases = await maven.getPkgReleases({
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: ['http://central.maven.org/maven2/'], registryUrls: ['https://repo.maven.apache.org/maven2/'],
}); });
expect(releases.releases).toEqual(generateReleases(MYSQL_VERSIONS)); expect(releases.releases).toEqual(generateReleases(MYSQL_VERSIONS));
}); });
@ -160,7 +160,7 @@ describe('datasource/maven', () => {
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: [ registryUrls: [
'http://central.maven.org/maven2/', 'https://repo.maven.apache.org/maven2/',
'http://failed_repo/', 'http://failed_repo/',
'http://unauthorized_repo/', 'http://unauthorized_repo/',
'http://dns_error_repo', 'http://dns_error_repo',
@ -185,13 +185,28 @@ describe('datasource/maven', () => {
}) })
).rejects.toThrow(Error(DATASOURCE_FAILURE)); ).rejects.toThrow(Error(DATASOURCE_FAILURE));
}); });
it('should throw registry-failure if default maven repo fails', async () => {
nock('https://repo.maven.apache.org')
.get('/maven2/org/artifact/maven-metadata.xml')
.times(4)
.reply(503);
expect.assertions(1);
await expect(
maven.getPkgReleases({
...config,
lookupName: 'org:artifact',
registryUrls: ['https://repo.maven.apache.org/maven2/'],
})
).rejects.toThrow(Error(DATASOURCE_FAILURE));
});
it('should return all versions of a specific library if a repository fails because invalid protocol', async () => { it('should return all versions of a specific library if a repository fails because invalid protocol', async () => {
const releases = await maven.getPkgReleases({ const releases = await maven.getPkgReleases({
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: [ registryUrls: [
'http://central.maven.org/maven2/', 'https://repo.maven.apache.org/maven2/',
'http://failed_repo/', 'http://failed_repo/',
'ftp://protocol_error_repo', 'ftp://protocol_error_repo',
], ],
@ -217,7 +232,7 @@ describe('datasource/maven', () => {
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: [ registryUrls: [
'http://central.maven.org/maven2/', 'https://repo.maven.apache.org/maven2/',
'http://invalid_metadata_repo/maven2/', 'http://invalid_metadata_repo/maven2/',
], ],
}); });
@ -235,7 +250,7 @@ describe('datasource/maven', () => {
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: [ registryUrls: [
'http://central.maven.org/maven2/', 'https://repo.maven.apache.org/maven2/',
'http://invalid_metadata_repo/maven2/', 'http://invalid_metadata_repo/maven2/',
], ],
}); });
@ -246,7 +261,7 @@ describe('datasource/maven', () => {
const releases = await maven.getPkgReleases({ const releases = await maven.getPkgReleases({
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
registryUrls: ['http://central.maven.org/maven2'], registryUrls: ['https://repo.maven.apache.org/maven2'],
}); });
expect(releases).not.toBeNull(); expect(releases).not.toBeNull();
}); });
@ -256,7 +271,7 @@ describe('datasource/maven', () => {
...config, ...config,
lookupName: 'mysql:mysql-connector-java', lookupName: 'mysql:mysql-connector-java',
}); });
expect(releases).toBeNull(); expect(releases).not.toBeNull();
}); });
it('should return null for invalid registryUrls', async () => { it('should return null for invalid registryUrls', async () => {
const releases = await maven.getPkgReleases({ const releases = await maven.getPkgReleases({

View file

@ -7,6 +7,7 @@ import { compare } from '../../versioning/maven/compare';
import mavenVersion from '../../versioning/maven'; import mavenVersion from '../../versioning/maven';
import { downloadHttpProtocol } from './util'; import { downloadHttpProtocol } from './util';
import { GetReleasesConfig, ReleaseResult } from '../common'; import { GetReleasesConfig, ReleaseResult } from '../common';
import { MAVEN_REPO } from './common';
export { id } from './common'; export { id } from './common';
@ -139,18 +140,14 @@ export async function getPkgReleases({
lookupName, lookupName,
registryUrls, registryUrls,
}: GetReleasesConfig): Promise<ReleaseResult | null> { }: GetReleasesConfig): Promise<ReleaseResult | null> {
const versions: string[] = []; const registries = is.nonEmptyArray(registryUrls)
const dependency = getDependencyParts(lookupName); ? registryUrls
if (!is.nonEmptyArray(registryUrls)) { : [MAVEN_REPO];
logger.warn(`No repositories defined for ${dependency.display}`); const repositories = registries.map(repository =>
return null;
}
const repositories = registryUrls.map(repository =>
repository.replace(/\/?$/, '/') repository.replace(/\/?$/, '/')
); );
logger.debug( const dependency = getDependencyParts(lookupName);
`Found ${repositories.length} repositories for ${dependency.display}` const versions: string[] = [];
);
const repoForVersions = {}; const repoForVersions = {};
for (let i = 0; i < repositories.length; i += 1) { for (let i = 0; i < repositories.length; i += 1) {
const repoUrl = repositories[i]; const repoUrl = repositories[i];

View file

@ -3,12 +3,15 @@ import got from '../../util/got';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { DatasourceError } from '../common'; import { DatasourceError } from '../common';
import { id } from './common'; import { id, MAVEN_REPO, MAVEN_REPO_DEPRECATED } from './common';
const getHost = (x: string): string => new url.URL(x).host;
const defaultHosts = [MAVEN_REPO, MAVEN_REPO_DEPRECATED].map(getHost);
function isMavenCentral(pkgUrl: url.URL | string): boolean { function isMavenCentral(pkgUrl: url.URL | string): boolean {
return ( const host = typeof pkgUrl === 'string' ? pkgUrl : pkgUrl.host;
(typeof pkgUrl === 'string' ? pkgUrl : pkgUrl.host) === 'central.maven.org' return defaultHosts.includes(host);
);
} }
function isTemporalError(err: { code: string; statusCode: number }): boolean { function isTemporalError(err: { code: string; statusCode: number }): boolean {

View file

@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs'; import fs from 'fs';
import nock from 'nock'; import nock from 'nock';
import { getPkgReleases } from '.'; import { getPkgReleases } from '.';
import { DEFAULT_MAVEN_REPO } from '../../manager/maven/extract'; import { MAVEN_REPO } from '../maven/common';
import { parseIndexDir, SBT_PLUGINS_REPO } from '../sbt-plugin/util'; import { parseIndexDir, SBT_PLUGINS_REPO } from '../sbt-plugin/util';
const mavenIndexHtml = fs.readFileSync( const mavenIndexHtml = fs.readFileSync(
@ -110,7 +110,7 @@ describe('datasource/sbt', () => {
lookupName: 'org.scalatest:scalatest', lookupName: 'org.scalatest:scalatest',
registryUrls: [ registryUrls: [
'https://failed_repo/maven', 'https://failed_repo/maven',
DEFAULT_MAVEN_REPO, MAVEN_REPO,
SBT_PLUGINS_REPO, SBT_PLUGINS_REPO,
], ],
}) })
@ -124,7 +124,7 @@ describe('datasource/sbt', () => {
expect( expect(
await getPkgReleases({ await getPkgReleases({
lookupName: 'org.scalatest:scalatest_2.12', lookupName: 'org.scalatest:scalatest_2.12',
registryUrls: [DEFAULT_MAVEN_REPO, SBT_PLUGINS_REPO], registryUrls: [MAVEN_REPO, SBT_PLUGINS_REPO],
}) })
).toEqual({ ).toEqual({
dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest', dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest',

View file

@ -2,7 +2,7 @@ import path from 'path';
import fs from 'fs'; import fs from 'fs';
import nock from 'nock'; import nock from 'nock';
import { getPkgReleases } from '.'; import { getPkgReleases } from '.';
import { DEFAULT_MAVEN_REPO } from '../../manager/maven/extract'; import { MAVEN_REPO } from '../maven/common';
import { parseIndexDir, SBT_PLUGINS_REPO } from './util'; import { parseIndexDir, SBT_PLUGINS_REPO } from './util';
const mavenIndexHtml = fs.readFileSync( const mavenIndexHtml = fs.readFileSync(
@ -114,7 +114,7 @@ describe('datasource/sbt', () => {
expect( expect(
await getPkgReleases({ await getPkgReleases({
lookupName: 'org.foundweekends:sbt-bintray', lookupName: 'org.foundweekends:sbt-bintray',
registryUrls: [DEFAULT_MAVEN_REPO, SBT_PLUGINS_REPO], registryUrls: [MAVEN_REPO, SBT_PLUGINS_REPO],
}) })
).toEqual({ ).toEqual({
dependencyUrl: dependencyUrl:
@ -127,7 +127,7 @@ describe('datasource/sbt', () => {
expect( expect(
await getPkgReleases({ await getPkgReleases({
lookupName: 'org.foundweekends:sbt-bintray_2.12', lookupName: 'org.foundweekends:sbt-bintray_2.12',
registryUrls: [DEFAULT_MAVEN_REPO, SBT_PLUGINS_REPO], registryUrls: [MAVEN_REPO, SBT_PLUGINS_REPO],
}) })
).toEqual({ ).toEqual({
dependencyUrl: dependencyUrl:

View file

@ -9,7 +9,7 @@ Object {
"depName": "persistent-sorted-set:persistent-sorted-set", "depName": "persistent-sorted-set:persistent-sorted-set",
"fileReplacePosition": 53, "fileReplacePosition": 53,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -19,7 +19,7 @@ Object {
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"fileReplacePosition": 147, "fileReplacePosition": 147,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -29,7 +29,7 @@ Object {
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"fileReplacePosition": 241, "fileReplacePosition": 241,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -39,7 +39,7 @@ Object {
"depName": "org.clojure:clojurescript", "depName": "org.clojure:clojurescript",
"fileReplacePosition": 389, "fileReplacePosition": 389,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -49,7 +49,7 @@ Object {
"depName": "org.clojure:tools.namespace", "depName": "org.clojure:tools.namespace",
"fileReplacePosition": 451, "fileReplacePosition": 451,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -59,7 +59,7 @@ Object {
"depName": "org.clojure:clojurescript", "depName": "org.clojure:clojurescript",
"fileReplacePosition": 584, "fileReplacePosition": 584,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -69,7 +69,7 @@ Object {
"depName": "lambdaisland:kaocha", "depName": "lambdaisland:kaocha",
"fileReplacePosition": 644, "fileReplacePosition": 644,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -79,7 +79,7 @@ Object {
"depName": "lambdaisland:kaocha-cljs", "depName": "lambdaisland:kaocha-cljs",
"fileReplacePosition": 703, "fileReplacePosition": 703,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -89,7 +89,7 @@ Object {
"depName": "cider:cider-nrepl", "depName": "cider:cider-nrepl",
"fileReplacePosition": 810, "fileReplacePosition": 810,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -99,7 +99,7 @@ Object {
"depName": "nrepl:nrepl", "depName": "nrepl:nrepl",
"fileReplacePosition": 870, "fileReplacePosition": 870,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -109,7 +109,7 @@ Object {
"depName": "org.clojure:tools.namespace", "depName": "org.clojure:tools.namespace",
"fileReplacePosition": 929, "fileReplacePosition": 929,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },
@ -119,7 +119,7 @@ Object {
"depName": "com.datomic:datomic-free", "depName": "com.datomic:datomic-free",
"fileReplacePosition": 1141, "fileReplacePosition": 1141,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
], ],
}, },

View file

@ -1,5 +1,5 @@
import { DEFAULT_MAVEN_REPO } from '../maven/extract'; import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common';
import { expandDepName, DEFAULT_CLOJARS_REPO } from '../leiningen/extract'; import { expandDepName } from '../leiningen/extract';
import { PackageFile, PackageDependency } from '../common'; import { PackageFile, PackageDependency } from '../common';
import * as datasourceMaven from '../../datasource/maven'; import * as datasourceMaven from '../../datasource/maven';
@ -24,7 +24,7 @@ export function extractPackageFile(content: string): PackageFile {
depName: expandDepName(depName), depName: expandDepName(depName),
currentValue, currentValue,
fileReplacePosition, fileReplacePosition,
registryUrls: [DEFAULT_CLOJARS_REPO, DEFAULT_MAVEN_REPO], registryUrls: [CLOJARS_REPO, MAVEN_REPO],
}); });
} }

View file

@ -10,7 +10,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2747, "fileReplacePosition": 2747,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -25,7 +25,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2794, "fileReplacePosition": 2794,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -40,7 +40,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2862, "fileReplacePosition": 2862,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -55,7 +55,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2912, "fileReplacePosition": 2912,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -70,7 +70,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3223, "fileReplacePosition": 3223,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -85,7 +85,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3272, "fileReplacePosition": 3272,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -100,7 +100,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3330, "fileReplacePosition": 3330,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -115,7 +115,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11073, "fileReplacePosition": 11073,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -130,7 +130,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11139, "fileReplacePosition": 11139,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -145,7 +145,7 @@ Object {
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11287, "fileReplacePosition": 11287,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -160,7 +160,7 @@ Object {
"depType": "managed-dependencies", "depType": "managed-dependencies",
"fileReplacePosition": 4705, "fileReplacePosition": 4705,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -175,7 +175,7 @@ Object {
"depType": "managed-dependencies", "depType": "managed-dependencies",
"fileReplacePosition": 4754, "fileReplacePosition": 4754,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -190,7 +190,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5558, "fileReplacePosition": 5558,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -205,7 +205,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5591, "fileReplacePosition": 5591,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -220,7 +220,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5630, "fileReplacePosition": 5630,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -235,7 +235,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5661, "fileReplacePosition": 5661,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -250,7 +250,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5705, "fileReplacePosition": 5705,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -265,7 +265,7 @@ Object {
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 11489, "fileReplacePosition": 11489,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -280,7 +280,7 @@ Object {
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 26925, "fileReplacePosition": 26925,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -295,7 +295,7 @@ Object {
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 27372, "fileReplacePosition": 27372,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",
@ -310,7 +310,7 @@ Object {
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 27440, "fileReplacePosition": 27440,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo/", "https://clojars.org/repo",
"https://repo.maven.apache.org/maven2", "https://repo.maven.apache.org/maven2",
"https://download.java.net/maven/2", "https://download.java.net/maven/2",
"https://oss.sonatype.org/content/repositories/releases", "https://oss.sonatype.org/content/repositories/releases",

View file

@ -1,9 +1,7 @@
import { DEFAULT_MAVEN_REPO } from '../maven/extract'; import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common';
import { PackageDependency, PackageFile } from '../common'; import { PackageDependency, PackageFile } from '../common';
import * as datasourceMaven from '../../datasource/maven'; import * as datasourceMaven from '../../datasource/maven';
export const DEFAULT_CLOJARS_REPO = 'https://clojars.org/repo/';
export function trimAtKey(str: string, kwName: string): string | null { export function trimAtKey(str: string, kwName: string): string | null {
const regex = new RegExp(`:${kwName}(?=\\s)`); const regex = new RegExp(`:${kwName}(?=\\s)`);
const keyOffset = str.search(regex); const keyOffset = str.search(regex);
@ -92,7 +90,7 @@ export function extractFromVectors(
} }
function extractLeinRepos(content: string): string[] { function extractLeinRepos(content: string): string[] {
const result = [DEFAULT_CLOJARS_REPO, DEFAULT_MAVEN_REPO]; const result = [CLOJARS_REPO, MAVEN_REPO];
const repoContent = trimAtKey( const repoContent = trimAtKey(
content.replace(/;;.*(?=[\r\n])/g, ''), // get rid of comments content.replace(/;;.*(?=[\r\n])/g, ''), // get rid of comments

View file

@ -6,8 +6,7 @@ import { logger } from '../../logger';
import { ExtractConfig, PackageFile, PackageDependency } from '../common'; import { ExtractConfig, PackageFile, PackageDependency } from '../common';
import { platform } from '../../platform'; import { platform } from '../../platform';
import * as datasourceMaven from '../../datasource/maven'; import * as datasourceMaven from '../../datasource/maven';
import { MAVEN_REPO } from '../../datasource/maven/common';
export const DEFAULT_MAVEN_REPO = 'https://repo.maven.apache.org/maven2';
export function parsePom(raw: string): XmlDocument | null { export function parsePom(raw: string): XmlDocument | null {
let project: XmlDocument; let project: XmlDocument;
@ -53,7 +52,7 @@ function depFromNode(node: XmlElement): PackageDependency | null {
const versionNode = node.descendantWithPath('version'); const versionNode = node.descendantWithPath('version');
const fileReplacePosition = versionNode.position; const fileReplacePosition = versionNode.position;
const datasource = datasourceMaven.id; const datasource = datasourceMaven.id;
const registryUrls = [DEFAULT_MAVEN_REPO]; const registryUrls = [MAVEN_REPO];
return { return {
datasource, datasource,
depName, depName,

View file

@ -1,4 +1,4 @@
import { DEFAULT_MAVEN_REPO } from '../maven/extract'; import { MAVEN_REPO } from '../../datasource/maven/common';
import { PackageFile, PackageDependency } from '../common'; import { PackageFile, PackageDependency } from '../common';
import { get } from '../../versioning'; import { get } from '../../versioning';
import * as mavenVersioning from '../../versioning/maven'; import * as mavenVersioning from '../../versioning/maven';
@ -283,7 +283,7 @@ export function extractPackageFile(content: string): PackageFile {
const lines = content.split(/\n/); const lines = content.split(/\n/);
return lines.reduce(parseSbtLine, { return lines.reduce(parseSbtLine, {
fileOffset: 0, fileOffset: 0,
registryUrls: [DEFAULT_MAVEN_REPO], registryUrls: [MAVEN_REPO],
deps: [], deps: [],
isMultiDeps: false, isMultiDeps: false,
scalaVersion: null, scalaVersion: null,