From 0622c81419143758366bc6ac807c49774cc04d77 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 7 Apr 2020 14:59:18 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Revert=20"feat(internal):=20datasource?= =?UTF-8?q?=20defaultRegistryUrls=20/=20appendRegistry=E2=80=A6=20(#5686)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit aa7f29127554b63aac08b53cbfe88749fc9b0295. --- lib/datasource/clojure/index.ts | 7 -- lib/datasource/common.ts | 2 - lib/datasource/index.ts | 26 ++---- lib/datasource/maven/common.ts | 2 + lib/datasource/maven/index.ts | 8 +- lib/datasource/maven/util.ts | 6 +- lib/datasource/pod/index.ts | 18 ++-- lib/datasource/rubygems/index.ts | 1 - lib/datasource/rubygems/releases.ts | 8 +- lib/datasource/sbt-package/index.spec.ts | 34 ++++---- lib/datasource/sbt-package/index.ts | 3 - lib/datasource/sbt-plugin/index.ts | 6 +- .../__snapshots__/extract.spec.ts.snap | 84 +++++++++++++------ lib/manager/deps-edn/extract.ts | 7 +- .../__snapshots__/extract.spec.ts.snap | 84 ++++++++++++++----- lib/manager/leiningen/extract.spec.ts | 8 +- lib/manager/leiningen/extract.ts | 7 +- 17 files changed, 187 insertions(+), 124 deletions(-) delete mode 100644 lib/datasource/clojure/index.ts diff --git a/lib/datasource/clojure/index.ts b/lib/datasource/clojure/index.ts deleted file mode 100644 index 05dfdf989d..0000000000 --- a/lib/datasource/clojure/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { MAVEN_REPO } from '../maven/common'; - -export const id = 'clojure'; - -export const defaultRegistryUrls = ['https://clojars.org/repo', MAVEN_REPO]; - -export { getReleases } from '../maven'; diff --git a/lib/datasource/common.ts b/lib/datasource/common.ts index 8ae1040dbe..ebdc7116dc 100644 --- a/lib/datasource/common.ts +++ b/lib/datasource/common.ts @@ -68,8 +68,6 @@ export interface Datasource { id: string; getDigest?(config: DigestConfig, newValue?: string): Promise<string | null>; getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null>; - defaultRegistryUrls?: string[]; - appendRegistryUrls?: string[]; } export class DatasourceError extends Error { diff --git a/lib/datasource/index.ts b/lib/datasource/index.ts index 7eb1ca8dc0..7c69d2a6ed 100644 --- a/lib/datasource/index.ts +++ b/lib/datasource/index.ts @@ -1,4 +1,3 @@ -import is from '@sindresorhus/is'; import { logger } from '../logger'; import { addMetaData } from './metadata'; import * as allVersioning from '../versioning'; @@ -28,31 +27,16 @@ function load(datasource: string): Promise<Datasource> { type GetReleasesInternalConfig = GetReleasesConfig & GetPkgReleasesConfig; -function resolveRegistryUrls( - datasource: Datasource, - extractedUrls: string[] -): string[] { - const { defaultRegistryUrls = [], appendRegistryUrls = [] } = datasource; - return is.nonEmptyArray(extractedUrls) - ? [...extractedUrls, ...appendRegistryUrls] - : [...defaultRegistryUrls, ...appendRegistryUrls]; -} - async function fetchReleases( config: GetReleasesInternalConfig ): Promise<ReleaseResult | null> { - const { datasource: datasourceName } = config; - if (!datasourceName || !datasources.has(datasourceName)) { - logger.warn('Unknown datasource: ' + datasourceName); + const { datasource } = config; + if (!datasources.has(datasource)) { + logger.warn('Unknown datasource: ' + datasource); return null; } - const datasource = await load(datasourceName); - const registryUrls = resolveRegistryUrls(datasource, config.registryUrls); - const dep = await datasource.getReleases({ - ...config, - registryUrls, - }); - addMetaData(dep, datasourceName, config.lookupName); + const dep = await (await load(datasource)).getReleases(config); + addMetaData(dep, datasource, config.lookupName); return dep; } diff --git a/lib/datasource/maven/common.ts b/lib/datasource/maven/common.ts index d516319326..5f0d7d808f 100644 --- a/lib/datasource/maven/common.ts +++ b/lib/datasource/maven/common.ts @@ -1,3 +1,5 @@ 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'; diff --git a/lib/datasource/maven/index.ts b/lib/datasource/maven/index.ts index 958e346a9b..9c93c87564 100644 --- a/lib/datasource/maven/index.ts +++ b/lib/datasource/maven/index.ts @@ -1,3 +1,4 @@ +import is from '@sindresorhus/is'; import url from 'url'; import fs from 'fs-extra'; import { XmlDocument } from 'xmldoc'; @@ -10,8 +11,6 @@ import { MAVEN_REPO } from './common'; export { id } from './common'; -export const defaultRegistryUrls = [MAVEN_REPO]; - function containsPlaceholder(str: string): boolean { return /\${.*?}/g.test(str); } @@ -147,7 +146,10 @@ export async function getReleases({ lookupName, registryUrls, }: GetReleasesConfig): Promise<ReleaseResult | null> { - const repositories = registryUrls.map(repository => + const registries = is.nonEmptyArray(registryUrls) + ? registryUrls + : [MAVEN_REPO]; + const repositories = registries.map(repository => repository.replace(/\/?$/, '/') ); const dependency = getDependencyParts(lookupName); diff --git a/lib/datasource/maven/util.ts b/lib/datasource/maven/util.ts index a80701dc5e..aa1814739d 100644 --- a/lib/datasource/maven/util.ts +++ b/lib/datasource/maven/util.ts @@ -3,15 +3,17 @@ import { Http } from '../../util/http'; import { logger } from '../../logger'; import { DatasourceError } from '../common'; -import { id, MAVEN_REPO } from './common'; +import { id, MAVEN_REPO, MAVEN_REPO_DEPRECATED } from './common'; const http = new Http(id); 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 { const host = typeof pkgUrl === 'string' ? pkgUrl : pkgUrl.host; - return getHost(MAVEN_REPO) === host; + return defaultHosts.includes(host); } function isTemporalError(err: { code: string; statusCode: number }): boolean { diff --git a/lib/datasource/pod/index.ts b/lib/datasource/pod/index.ts index 88a8408b49..e41dcbc50c 100644 --- a/lib/datasource/pod/index.ts +++ b/lib/datasource/pod/index.ts @@ -5,8 +5,6 @@ import { logger } from '../../logger'; export const id = 'pod'; -export const defaultRegistryUrls = ['https://cdn.cocoapods.org']; - const cacheNamespace = `datasource-${id}`; const cacheMinutes = 30; @@ -112,6 +110,8 @@ async function getReleasesFromCDN( return null; } +const defaultCDN = 'https://cdn.cocoapods.org'; + function isDefaultRepo(url: string): boolean { const match = githubRegex.exec(url); if (match) { @@ -123,10 +123,14 @@ function isDefaultRepo(url: string): boolean { return false; } -export async function getReleases({ - lookupName, - registryUrls, -}: GetReleasesConfig): Promise<ReleaseResult | null> { +export async function getReleases( + config: GetReleasesConfig +): Promise<ReleaseResult | null> { + const { lookupName } = config; + let { registryUrls } = config; + registryUrls = + registryUrls && registryUrls.length ? registryUrls : [defaultCDN]; + const podName = lookupName.replace(/\/.*$/, ''); const cachedResult = await renovateCache.get<ReleaseResult>( @@ -145,7 +149,7 @@ export async function getReleases({ // In order to not abuse github API limits, query CDN instead if (isDefaultRepo(registryUrl)) { - [registryUrl] = defaultRegistryUrls; + registryUrl = defaultCDN; } if (githubRegex.exec(registryUrl)) { diff --git a/lib/datasource/rubygems/index.ts b/lib/datasource/rubygems/index.ts index ddc9e60c98..d4d80f7c2f 100644 --- a/lib/datasource/rubygems/index.ts +++ b/lib/datasource/rubygems/index.ts @@ -1,3 +1,2 @@ export { getReleases } from './releases'; export { id } from './common'; -export const defaultRegistryUrls = ['https://rubygems.org']; diff --git a/lib/datasource/rubygems/releases.ts b/lib/datasource/rubygems/releases.ts index 3ed2ce1a04..5f558c65a5 100644 --- a/lib/datasource/rubygems/releases.ts +++ b/lib/datasource/rubygems/releases.ts @@ -1,3 +1,4 @@ +import is from '@sindresorhus/is'; import { getDependency } from './get'; import { getRubygemsOrgDependency } from './get-rubygems-org'; import { GetReleasesConfig, ReleaseResult } from '../common'; @@ -6,7 +7,12 @@ export async function getReleases({ lookupName, registryUrls, }: GetReleasesConfig): Promise<ReleaseResult | null> { - for (const registry of registryUrls) { + const defaultRegistry = 'https://rubygems.org'; + const registries = is.nonEmptyArray(registryUrls) + ? registryUrls + : [defaultRegistry]; + + for (const registry of registries) { let pkg: ReleaseResult; // prettier-ignore if (registry.endsWith('rubygems.org')) { // lgtm [js/incomplete-url-substring-sanitization] diff --git a/lib/datasource/sbt-package/index.spec.ts b/lib/datasource/sbt-package/index.spec.ts index c985c49c81..308ffbaee0 100644 --- a/lib/datasource/sbt-package/index.spec.ts +++ b/lib/datasource/sbt-package/index.spec.ts @@ -1,11 +1,9 @@ import path from 'path'; import fs from 'fs'; import nock from 'nock'; -import { getPkgReleases } from '..'; +import { getReleases } from '.'; import { MAVEN_REPO } from '../maven/common'; -import { parseIndexDir } from '../sbt-plugin/util'; -import * as sbtPlugin from '.'; -import * as mavenVersioning from '../../versioning/maven'; +import { parseIndexDir, SBT_PLUGINS_REPO } from '../sbt-plugin/util'; const mavenIndexHtml = fs.readFileSync( path.resolve(__dirname, `./__fixtures__/maven-index.html`), @@ -25,7 +23,7 @@ describe('datasource/sbt', () => { expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot(); }); - describe('getPkgReleases', () => { + describe('getReleases', () => { beforeEach(() => { nock.disableNetConnect(); nock('https://failed_repo') @@ -100,21 +98,21 @@ describe('datasource/sbt', () => { it('returns null in case of errors', async () => { expect( - await getPkgReleases({ - versioning: mavenVersioning.id, - datasource: sbtPlugin.id, - depName: 'org.scalatest:scalatest', + await getReleases({ + lookupName: 'org.scalatest:scalatest', registryUrls: ['https://failed_repo/maven'], }) ).toEqual(null); }); it('fetches releases from Maven', async () => { expect( - await getPkgReleases({ - versioning: mavenVersioning.id, - datasource: sbtPlugin.id, - depName: 'org.scalatest:scalatest', - registryUrls: ['https://failed_repo/maven', MAVEN_REPO], + await getReleases({ + lookupName: 'org.scalatest:scalatest', + registryUrls: [ + 'https://failed_repo/maven', + MAVEN_REPO, + SBT_PLUGINS_REPO, + ], }) ).toEqual({ dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest', @@ -124,11 +122,9 @@ describe('datasource/sbt', () => { releases: [{ version: '1.2.0' }, { version: '1.2.3' }], }); expect( - await getPkgReleases({ - versioning: mavenVersioning.id, - datasource: sbtPlugin.id, - depName: 'org.scalatest:scalatest_2.12', - registryUrls: [], + await getReleases({ + lookupName: 'org.scalatest:scalatest_2.12', + registryUrls: [MAVEN_REPO, SBT_PLUGINS_REPO], }) ).toEqual({ dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest', diff --git a/lib/datasource/sbt-package/index.ts b/lib/datasource/sbt-package/index.ts index 011e490dab..4976c2ac8f 100644 --- a/lib/datasource/sbt-package/index.ts +++ b/lib/datasource/sbt-package/index.ts @@ -3,12 +3,9 @@ import { downloadHttpProtocol } from '../maven/util'; import { parseIndexDir } from '../sbt-plugin/util'; import { logger } from '../../logger'; import { GetReleasesConfig, ReleaseResult } from '../common'; -import { MAVEN_REPO } from '../maven/common'; export const id = 'sbt-package'; -export const defaultRegistryUrls = [MAVEN_REPO]; - const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/'); export async function resolvePackageReleases( diff --git a/lib/datasource/sbt-plugin/index.ts b/lib/datasource/sbt-plugin/index.ts index 99fca4260f..5626429532 100644 --- a/lib/datasource/sbt-plugin/index.ts +++ b/lib/datasource/sbt-plugin/index.ts @@ -7,8 +7,6 @@ import { resolvePackageReleases } from '../sbt-package'; export const id = 'sbt-plugin'; -export const defaultRegistryUrls = [SBT_PLUGINS_REPO]; - const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/'); async function resolvePluginReleases( @@ -60,8 +58,10 @@ async function resolvePluginReleases( export async function getReleases({ lookupName, - registryUrls, + registryUrls: configRegistryUrls, }: GetReleasesConfig): Promise<ReleaseResult | null> { + const registryUrls = [SBT_PLUGINS_REPO, ...configRegistryUrls]; + const [groupId, artifactId] = lookupName.split(':'); const groupIdSplit = groupId.split('.'); const artifactIdSplit = artifactId.split('_'); diff --git a/lib/manager/deps-edn/__snapshots__/extract.spec.ts.snap b/lib/manager/deps-edn/__snapshots__/extract.spec.ts.snap index 691c60ed69..9924dd41aa 100644 --- a/lib/manager/deps-edn/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/deps-edn/__snapshots__/extract.spec.ts.snap @@ -5,87 +5,123 @@ Object { "deps": Array [ Object { "currentValue": "0.1.2", - "datasource": "clojure", + "datasource": "maven", "depName": "persistent-sorted-set:persistent-sorted-set", "fileReplacePosition": 53, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "1.9.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojure", "fileReplacePosition": 147, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "1.10.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojure", "fileReplacePosition": 241, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "1.10.520", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojurescript", "fileReplacePosition": 389, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.2.11", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:tools.namespace", "fileReplacePosition": 451, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "1.10.520", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojurescript", "fileReplacePosition": 584, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.0-389", - "datasource": "clojure", + "datasource": "maven", "depName": "lambdaisland:kaocha", "fileReplacePosition": 644, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.0-21", - "datasource": "clojure", + "datasource": "maven", "depName": "lambdaisland:kaocha-cljs", "fileReplacePosition": 703, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.21.1", - "datasource": "clojure", + "datasource": "maven", "depName": "cider:cider-nrepl", "fileReplacePosition": 810, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.6.0", - "datasource": "clojure", + "datasource": "maven", "depName": "nrepl:nrepl", "fileReplacePosition": 870, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.2.11", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:tools.namespace", "fileReplacePosition": 929, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, Object { "currentValue": "0.9.5703", - "datasource": "clojure", + "datasource": "maven", "depName": "com.datomic:datomic-free", "fileReplacePosition": 1141, - "registryUrls": Array [], + "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", + ], }, ], } diff --git a/lib/manager/deps-edn/extract.ts b/lib/manager/deps-edn/extract.ts index 0c451815b5..49435c9394 100644 --- a/lib/manager/deps-edn/extract.ts +++ b/lib/manager/deps-edn/extract.ts @@ -1,6 +1,7 @@ +import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common'; import { expandDepName } from '../leiningen/extract'; import { PackageFile, PackageDependency } from '../common'; -import * as datasourceClojure from '../../datasource/clojure'; +import * as datasourceMaven from '../../datasource/maven'; export function extractPackageFile(content: string): PackageFile { const deps: PackageDependency[] = []; @@ -19,11 +20,11 @@ export function extractPackageFile(content: string): PackageFile { match = regex.exec(rest); deps.push({ - datasource: datasourceClojure.id, + datasource: datasourceMaven.id, depName: expandDepName(depName), currentValue, fileReplacePosition, - registryUrls: [], + registryUrls: [CLOJARS_REPO, MAVEN_REPO], }); } diff --git a/lib/manager/leiningen/__snapshots__/extract.spec.ts.snap b/lib/manager/leiningen/__snapshots__/extract.spec.ts.snap index d3d21a15a7..f229cd5bf1 100644 --- a/lib/manager/leiningen/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/leiningen/__snapshots__/extract.spec.ts.snap @@ -5,11 +5,13 @@ Object { "deps": Array [ Object { "currentValue": "1.3.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojure", "depType": "dependencies", "fileReplacePosition": 2747, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -18,11 +20,13 @@ Object { }, Object { "currentValue": "1.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.jclouds:jclouds", "depType": "dependencies", "fileReplacePosition": 2794, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -31,11 +35,13 @@ Object { }, Object { "currentValue": "2.3.1", - "datasource": "clojure", + "datasource": "maven", "depName": "net.sf.ehcache:ehcache", "depType": "dependencies", "fileReplacePosition": 2862, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -44,11 +50,13 @@ Object { }, Object { "currentValue": "1.2.15", - "datasource": "clojure", + "datasource": "maven", "depName": "log4j:log4j", "depType": "dependencies", "fileReplacePosition": 2912, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -57,11 +65,13 @@ Object { }, Object { "currentValue": "3.0.2", - "datasource": "clojure", + "datasource": "maven", "depName": "net.3scale:3scale-api", "depType": "dependencies", "fileReplacePosition": 3223, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -70,11 +80,13 @@ Object { }, Object { "currentValue": "2.8.5", - "datasource": "clojure", + "datasource": "maven", "depName": "org.lwjgl.lwjgl:lwjgl", "depType": "dependencies", "fileReplacePosition": 3272, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -83,11 +95,13 @@ Object { }, Object { "currentValue": "2.8.5", - "datasource": "clojure", + "datasource": "maven", "depName": "org.lwjgl.lwjgl:lwjgl-platform", "depType": "dependencies", "fileReplacePosition": 3330, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -96,11 +110,13 @@ Object { }, Object { "currentValue": "1.4.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojure", "depType": "dependencies", "fileReplacePosition": 11073, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -109,11 +125,13 @@ Object { }, Object { "currentValue": "1.5.0", - "datasource": "clojure", + "datasource": "maven", "depName": "org.clojure:clojure", "depType": "dependencies", "fileReplacePosition": 11139, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -122,11 +140,13 @@ Object { }, Object { "currentValue": "0.2.4", - "datasource": "clojure", + "datasource": "maven", "depName": "clj-stacktrace:clj-stacktrace", "depType": "dependencies", "fileReplacePosition": 11287, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -135,11 +155,13 @@ Object { }, Object { "currentValue": "0.12.0", - "datasource": "clojure", + "datasource": "maven", "depName": "clj-time:clj-time", "depType": "managed-dependencies", "fileReplacePosition": 4705, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -148,11 +170,13 @@ Object { }, Object { "currentValue": "1.4.6", - "datasource": "clojure", + "datasource": "maven", "depName": "me.raynes:fs", "depType": "managed-dependencies", "fileReplacePosition": 4754, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -161,11 +185,13 @@ Object { }, Object { "currentValue": "1.1.1", - "datasource": "clojure", + "datasource": "maven", "depName": "lein-pprint:lein-pprint", "depType": "plugins", "fileReplacePosition": 5558, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -174,11 +200,13 @@ Object { }, Object { "currentValue": "0.1.0", - "datasource": "clojure", + "datasource": "maven", "depName": "lein-assoc:lein-assoc", "depType": "plugins", "fileReplacePosition": 5591, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -187,11 +215,13 @@ Object { }, Object { "currentValue": "1.1.1", - "datasource": "clojure", + "datasource": "maven", "depName": "s3-wagon-private:s3-wagon-private", "depType": "plugins", "fileReplacePosition": 5630, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -200,11 +230,13 @@ Object { }, Object { "currentValue": "0.0.1", - "datasource": "clojure", + "datasource": "maven", "depName": "lein-foo:lein-foo", "depType": "plugins", "fileReplacePosition": 5661, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -213,11 +245,13 @@ Object { }, Object { "currentValue": "0.0.1", - "datasource": "clojure", + "datasource": "maven", "depName": "lein-bar:lein-bar", "depType": "plugins", "fileReplacePosition": 5705, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -226,11 +260,13 @@ Object { }, Object { "currentValue": "0.7.1", - "datasource": "clojure", + "datasource": "maven", "depName": "cider:cider-nrepl", "depType": "plugins", "fileReplacePosition": 11489, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -239,11 +275,13 @@ Object { }, Object { "currentValue": "1.3.13", - "datasource": "clojure", + "datasource": "maven", "depName": "com.theoryinpractise:clojure-maven-plugin", "depType": "pom-plugins", "fileReplacePosition": 26925, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -252,11 +290,13 @@ Object { }, Object { "currentValue": "2.1", - "datasource": "clojure", + "datasource": "maven", "depName": "org.apache.tomcat.maven:tomcat7-maven-plugin", "depType": "pom-plugins", "fileReplacePosition": 27372, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", @@ -265,11 +305,13 @@ Object { }, Object { "currentValue": "1.9.68", - "datasource": "clojure", + "datasource": "maven", "depName": "com.google.appengine:appengine-maven-plugin", "depType": "pom-plugins", "fileReplacePosition": 27440, "registryUrls": Array [ + "https://clojars.org/repo", + "https://repo.maven.apache.org/maven2", "https://download.java.net/maven/2", "https://oss.sonatype.org/content/repositories/releases", "https://blueant.com/archiva/snapshots", diff --git a/lib/manager/leiningen/extract.spec.ts b/lib/manager/leiningen/extract.spec.ts index 33ec4b5300..7bff374f5f 100644 --- a/lib/manager/leiningen/extract.spec.ts +++ b/lib/manager/leiningen/extract.spec.ts @@ -2,7 +2,7 @@ import { readFileSync } from 'fs'; import { resolve } from 'path'; import { trimAtKey, extractFromVectors, extractPackageFile } from './extract'; -import * as datasourceClojure from '../../datasource/clojure'; +import * as datasourceMaven from '../../datasource/maven'; const leinProjectClj = readFileSync( resolve(__dirname, `./__fixtures__/project.clj`), @@ -23,7 +23,7 @@ describe('manager/clojure/extract', () => { expect(extractFromVectors('[[]]')).toEqual([]); expect(extractFromVectors('[[foo/bar "1.2.3"]]')).toEqual([ { - datasource: datasourceClojure.id, + datasource: datasourceMaven.id, depName: 'foo:bar', currentValue: '1.2.3', fileReplacePosition: 11, @@ -33,13 +33,13 @@ describe('manager/clojure/extract', () => { extractFromVectors('[\t[foo/bar "1.2.3"]\n["foo/baz" "4.5.6"] ]') ).toEqual([ { - datasource: datasourceClojure.id, + datasource: datasourceMaven.id, depName: 'foo:bar', currentValue: '1.2.3', fileReplacePosition: 12, }, { - datasource: datasourceClojure.id, + datasource: datasourceMaven.id, depName: 'foo:baz', currentValue: '4.5.6', fileReplacePosition: 33, diff --git a/lib/manager/leiningen/extract.ts b/lib/manager/leiningen/extract.ts index 8404a462f8..ef930a2d1c 100644 --- a/lib/manager/leiningen/extract.ts +++ b/lib/manager/leiningen/extract.ts @@ -1,5 +1,6 @@ +import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common'; import { PackageDependency, PackageFile } from '../common'; -import * as datasourceClojure from '../../datasource/clojure'; +import * as datasourceMaven from '../../datasource/maven'; export function trimAtKey(str: string, kwName: string): string | null { const regex = new RegExp(`:${kwName}(?=\\s)`); @@ -49,7 +50,7 @@ export function extractFromVectors( if (artifactId && version && fileReplacePosition) { result.push({ ...ctx, - datasource: datasourceClojure.id, + datasource: datasourceMaven.id, depName: expandDepName(cleanStrLiteral(artifactId)), currentValue: cleanStrLiteral(version), fileReplacePosition, @@ -95,7 +96,7 @@ export function extractFromVectors( } function extractLeinRepos(content: string): string[] { - const result = []; + const result = [CLOJARS_REPO, MAVEN_REPO]; const repoContent = trimAtKey( content.replace(/;;.*(?=[\r\n])/g, ''), // get rid of comments -- GitLab