Skip to content
Snippets Groups Projects
Commit 0622c814 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: Revert "feat(internal): datasource defaultRegistryUrls / appendRegistry… (#5686)"

This reverts commit aa7f2912.
parent 7f0d3753
No related branches found
No related tags found
No related merge requests found
Showing
with 187 additions and 124 deletions
import { MAVEN_REPO } from '../maven/common';
export const id = 'clojure';
export const defaultRegistryUrls = ['https://clojars.org/repo', MAVEN_REPO];
export { getReleases } from '../maven';
...@@ -68,8 +68,6 @@ export interface Datasource { ...@@ -68,8 +68,6 @@ export interface Datasource {
id: string; id: string;
getDigest?(config: DigestConfig, newValue?: string): Promise<string | null>; getDigest?(config: DigestConfig, newValue?: string): Promise<string | null>;
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null>; getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null>;
defaultRegistryUrls?: string[];
appendRegistryUrls?: string[];
} }
export class DatasourceError extends Error { export class DatasourceError extends Error {
......
import is from '@sindresorhus/is';
import { logger } from '../logger'; import { logger } from '../logger';
import { addMetaData } from './metadata'; import { addMetaData } from './metadata';
import * as allVersioning from '../versioning'; import * as allVersioning from '../versioning';
...@@ -28,31 +27,16 @@ function load(datasource: string): Promise<Datasource> { ...@@ -28,31 +27,16 @@ function load(datasource: string): Promise<Datasource> {
type GetReleasesInternalConfig = GetReleasesConfig & GetPkgReleasesConfig; 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( async function fetchReleases(
config: GetReleasesInternalConfig config: GetReleasesInternalConfig
): Promise<ReleaseResult | null> { ): Promise<ReleaseResult | null> {
const { datasource: datasourceName } = config; const { datasource } = config;
if (!datasourceName || !datasources.has(datasourceName)) { if (!datasources.has(datasource)) {
logger.warn('Unknown datasource: ' + datasourceName); logger.warn('Unknown datasource: ' + datasource);
return null; return null;
} }
const datasource = await load(datasourceName); const dep = await (await load(datasource)).getReleases(config);
const registryUrls = resolveRegistryUrls(datasource, config.registryUrls); addMetaData(dep, datasource, config.lookupName);
const dep = await datasource.getReleases({
...config,
registryUrls,
});
addMetaData(dep, datasourceName, config.lookupName);
return dep; return dep;
} }
......
export const id = 'maven'; export const id = 'maven';
export const MAVEN_REPO = 'https://repo.maven.apache.org/maven2'; 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';
import is from '@sindresorhus/is';
import url from 'url'; import url from 'url';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { XmlDocument } from 'xmldoc'; import { XmlDocument } from 'xmldoc';
...@@ -10,8 +11,6 @@ import { MAVEN_REPO } from './common'; ...@@ -10,8 +11,6 @@ import { MAVEN_REPO } from './common';
export { id } from './common'; export { id } from './common';
export const defaultRegistryUrls = [MAVEN_REPO];
function containsPlaceholder(str: string): boolean { function containsPlaceholder(str: string): boolean {
return /\${.*?}/g.test(str); return /\${.*?}/g.test(str);
} }
...@@ -147,7 +146,10 @@ export async function getReleases({ ...@@ -147,7 +146,10 @@ export async function getReleases({
lookupName, lookupName,
registryUrls, registryUrls,
}: GetReleasesConfig): Promise<ReleaseResult | null> { }: GetReleasesConfig): Promise<ReleaseResult | null> {
const repositories = registryUrls.map(repository => const registries = is.nonEmptyArray(registryUrls)
? registryUrls
: [MAVEN_REPO];
const repositories = registries.map(repository =>
repository.replace(/\/?$/, '/') repository.replace(/\/?$/, '/')
); );
const dependency = getDependencyParts(lookupName); const dependency = getDependencyParts(lookupName);
......
...@@ -3,15 +3,17 @@ import { Http } from '../../util/http'; ...@@ -3,15 +3,17 @@ import { Http } from '../../util/http';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { DatasourceError } from '../common'; 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 http = new Http(id);
const getHost = (x: string): string => new url.URL(x).host; 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 {
const host = typeof pkgUrl === 'string' ? pkgUrl : pkgUrl.host; 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 { function isTemporalError(err: { code: string; statusCode: number }): boolean {
......
...@@ -5,8 +5,6 @@ import { logger } from '../../logger'; ...@@ -5,8 +5,6 @@ import { logger } from '../../logger';
export const id = 'pod'; export const id = 'pod';
export const defaultRegistryUrls = ['https://cdn.cocoapods.org'];
const cacheNamespace = `datasource-${id}`; const cacheNamespace = `datasource-${id}`;
const cacheMinutes = 30; const cacheMinutes = 30;
...@@ -112,6 +110,8 @@ async function getReleasesFromCDN( ...@@ -112,6 +110,8 @@ async function getReleasesFromCDN(
return null; return null;
} }
const defaultCDN = 'https://cdn.cocoapods.org';
function isDefaultRepo(url: string): boolean { function isDefaultRepo(url: string): boolean {
const match = githubRegex.exec(url); const match = githubRegex.exec(url);
if (match) { if (match) {
...@@ -123,10 +123,14 @@ function isDefaultRepo(url: string): boolean { ...@@ -123,10 +123,14 @@ function isDefaultRepo(url: string): boolean {
return false; return false;
} }
export async function getReleases({ export async function getReleases(
lookupName, config: GetReleasesConfig
registryUrls, ): Promise<ReleaseResult | null> {
}: GetReleasesConfig): Promise<ReleaseResult | null> { const { lookupName } = config;
let { registryUrls } = config;
registryUrls =
registryUrls && registryUrls.length ? registryUrls : [defaultCDN];
const podName = lookupName.replace(/\/.*$/, ''); const podName = lookupName.replace(/\/.*$/, '');
const cachedResult = await renovateCache.get<ReleaseResult>( const cachedResult = await renovateCache.get<ReleaseResult>(
...@@ -145,7 +149,7 @@ export async function getReleases({ ...@@ -145,7 +149,7 @@ export async function getReleases({
// In order to not abuse github API limits, query CDN instead // In order to not abuse github API limits, query CDN instead
if (isDefaultRepo(registryUrl)) { if (isDefaultRepo(registryUrl)) {
[registryUrl] = defaultRegistryUrls; registryUrl = defaultCDN;
} }
if (githubRegex.exec(registryUrl)) { if (githubRegex.exec(registryUrl)) {
......
export { getReleases } from './releases'; export { getReleases } from './releases';
export { id } from './common'; export { id } from './common';
export const defaultRegistryUrls = ['https://rubygems.org'];
import is from '@sindresorhus/is';
import { getDependency } from './get'; import { getDependency } from './get';
import { getRubygemsOrgDependency } from './get-rubygems-org'; import { getRubygemsOrgDependency } from './get-rubygems-org';
import { GetReleasesConfig, ReleaseResult } from '../common'; import { GetReleasesConfig, ReleaseResult } from '../common';
...@@ -6,7 +7,12 @@ export async function getReleases({ ...@@ -6,7 +7,12 @@ export async function getReleases({
lookupName, lookupName,
registryUrls, registryUrls,
}: GetReleasesConfig): Promise<ReleaseResult | null> { }: 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; let pkg: ReleaseResult;
// prettier-ignore // prettier-ignore
if (registry.endsWith('rubygems.org')) { // lgtm [js/incomplete-url-substring-sanitization] if (registry.endsWith('rubygems.org')) { // lgtm [js/incomplete-url-substring-sanitization]
......
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import nock from 'nock'; import nock from 'nock';
import { getPkgReleases } from '..'; import { getReleases } from '.';
import { MAVEN_REPO } from '../maven/common'; import { MAVEN_REPO } from '../maven/common';
import { parseIndexDir } from '../sbt-plugin/util'; import { parseIndexDir, SBT_PLUGINS_REPO } from '../sbt-plugin/util';
import * as sbtPlugin from '.';
import * as mavenVersioning from '../../versioning/maven';
const mavenIndexHtml = fs.readFileSync( const mavenIndexHtml = fs.readFileSync(
path.resolve(__dirname, `./__fixtures__/maven-index.html`), path.resolve(__dirname, `./__fixtures__/maven-index.html`),
...@@ -25,7 +23,7 @@ describe('datasource/sbt', () => { ...@@ -25,7 +23,7 @@ describe('datasource/sbt', () => {
expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot(); expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot();
}); });
describe('getPkgReleases', () => { describe('getReleases', () => {
beforeEach(() => { beforeEach(() => {
nock.disableNetConnect(); nock.disableNetConnect();
nock('https://failed_repo') nock('https://failed_repo')
...@@ -100,21 +98,21 @@ describe('datasource/sbt', () => { ...@@ -100,21 +98,21 @@ describe('datasource/sbt', () => {
it('returns null in case of errors', async () => { it('returns null in case of errors', async () => {
expect( expect(
await getPkgReleases({ await getReleases({
versioning: mavenVersioning.id, lookupName: 'org.scalatest:scalatest',
datasource: sbtPlugin.id,
depName: 'org.scalatest:scalatest',
registryUrls: ['https://failed_repo/maven'], registryUrls: ['https://failed_repo/maven'],
}) })
).toEqual(null); ).toEqual(null);
}); });
it('fetches releases from Maven', async () => { it('fetches releases from Maven', async () => {
expect( expect(
await getPkgReleases({ await getReleases({
versioning: mavenVersioning.id, lookupName: 'org.scalatest:scalatest',
datasource: sbtPlugin.id, registryUrls: [
depName: 'org.scalatest:scalatest', 'https://failed_repo/maven',
registryUrls: ['https://failed_repo/maven', MAVEN_REPO], 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',
...@@ -124,11 +122,9 @@ describe('datasource/sbt', () => { ...@@ -124,11 +122,9 @@ describe('datasource/sbt', () => {
releases: [{ version: '1.2.0' }, { version: '1.2.3' }], releases: [{ version: '1.2.0' }, { version: '1.2.3' }],
}); });
expect( expect(
await getPkgReleases({ await getReleases({
versioning: mavenVersioning.id, lookupName: 'org.scalatest:scalatest_2.12',
datasource: sbtPlugin.id, registryUrls: [MAVEN_REPO, SBT_PLUGINS_REPO],
depName: 'org.scalatest:scalatest_2.12',
registryUrls: [],
}) })
).toEqual({ ).toEqual({
dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest', dependencyUrl: 'https://repo.maven.apache.org/maven2/org/scalatest',
......
...@@ -3,12 +3,9 @@ import { downloadHttpProtocol } from '../maven/util'; ...@@ -3,12 +3,9 @@ import { downloadHttpProtocol } from '../maven/util';
import { parseIndexDir } from '../sbt-plugin/util'; import { parseIndexDir } from '../sbt-plugin/util';
import { logger } from '../../logger'; import { logger } from '../../logger';
import { GetReleasesConfig, ReleaseResult } from '../common'; import { GetReleasesConfig, ReleaseResult } from '../common';
import { MAVEN_REPO } from '../maven/common';
export const id = 'sbt-package'; export const id = 'sbt-package';
export const defaultRegistryUrls = [MAVEN_REPO];
const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/'); const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/');
export async function resolvePackageReleases( export async function resolvePackageReleases(
......
...@@ -7,8 +7,6 @@ import { resolvePackageReleases } from '../sbt-package'; ...@@ -7,8 +7,6 @@ import { resolvePackageReleases } from '../sbt-package';
export const id = 'sbt-plugin'; export const id = 'sbt-plugin';
export const defaultRegistryUrls = [SBT_PLUGINS_REPO];
const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/'); const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/');
async function resolvePluginReleases( async function resolvePluginReleases(
...@@ -60,8 +58,10 @@ async function resolvePluginReleases( ...@@ -60,8 +58,10 @@ async function resolvePluginReleases(
export async function getReleases({ export async function getReleases({
lookupName, lookupName,
registryUrls, registryUrls: configRegistryUrls,
}: GetReleasesConfig): Promise<ReleaseResult | null> { }: GetReleasesConfig): Promise<ReleaseResult | null> {
const registryUrls = [SBT_PLUGINS_REPO, ...configRegistryUrls];
const [groupId, artifactId] = lookupName.split(':'); const [groupId, artifactId] = lookupName.split(':');
const groupIdSplit = groupId.split('.'); const groupIdSplit = groupId.split('.');
const artifactIdSplit = artifactId.split('_'); const artifactIdSplit = artifactId.split('_');
......
...@@ -5,87 +5,123 @@ Object { ...@@ -5,87 +5,123 @@ Object {
"deps": Array [ "deps": Array [
Object { Object {
"currentValue": "0.1.2", "currentValue": "0.1.2",
"datasource": "clojure", "datasource": "maven",
"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://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "1.9.0", "currentValue": "1.9.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"fileReplacePosition": 147, "fileReplacePosition": 147,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "1.10.0", "currentValue": "1.10.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"fileReplacePosition": 241, "fileReplacePosition": 241,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "1.10.520", "currentValue": "1.10.520",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojurescript", "depName": "org.clojure:clojurescript",
"fileReplacePosition": 389, "fileReplacePosition": 389,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.2.11", "currentValue": "0.2.11",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:tools.namespace", "depName": "org.clojure:tools.namespace",
"fileReplacePosition": 451, "fileReplacePosition": 451,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "1.10.520", "currentValue": "1.10.520",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojurescript", "depName": "org.clojure:clojurescript",
"fileReplacePosition": 584, "fileReplacePosition": 584,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.0-389", "currentValue": "0.0-389",
"datasource": "clojure", "datasource": "maven",
"depName": "lambdaisland:kaocha", "depName": "lambdaisland:kaocha",
"fileReplacePosition": 644, "fileReplacePosition": 644,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.0-21", "currentValue": "0.0-21",
"datasource": "clojure", "datasource": "maven",
"depName": "lambdaisland:kaocha-cljs", "depName": "lambdaisland:kaocha-cljs",
"fileReplacePosition": 703, "fileReplacePosition": 703,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.21.1", "currentValue": "0.21.1",
"datasource": "clojure", "datasource": "maven",
"depName": "cider:cider-nrepl", "depName": "cider:cider-nrepl",
"fileReplacePosition": 810, "fileReplacePosition": 810,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.6.0", "currentValue": "0.6.0",
"datasource": "clojure", "datasource": "maven",
"depName": "nrepl:nrepl", "depName": "nrepl:nrepl",
"fileReplacePosition": 870, "fileReplacePosition": 870,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.2.11", "currentValue": "0.2.11",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:tools.namespace", "depName": "org.clojure:tools.namespace",
"fileReplacePosition": 929, "fileReplacePosition": 929,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
Object { Object {
"currentValue": "0.9.5703", "currentValue": "0.9.5703",
"datasource": "clojure", "datasource": "maven",
"depName": "com.datomic:datomic-free", "depName": "com.datomic:datomic-free",
"fileReplacePosition": 1141, "fileReplacePosition": 1141,
"registryUrls": Array [], "registryUrls": Array [
"https://clojars.org/repo",
"https://repo.maven.apache.org/maven2",
],
}, },
], ],
} }
......
import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common';
import { expandDepName } from '../leiningen/extract'; import { expandDepName } from '../leiningen/extract';
import { PackageFile, PackageDependency } from '../common'; import { PackageFile, PackageDependency } from '../common';
import * as datasourceClojure from '../../datasource/clojure'; import * as datasourceMaven from '../../datasource/maven';
export function extractPackageFile(content: string): PackageFile { export function extractPackageFile(content: string): PackageFile {
const deps: PackageDependency[] = []; const deps: PackageDependency[] = [];
...@@ -19,11 +20,11 @@ export function extractPackageFile(content: string): PackageFile { ...@@ -19,11 +20,11 @@ export function extractPackageFile(content: string): PackageFile {
match = regex.exec(rest); match = regex.exec(rest);
deps.push({ deps.push({
datasource: datasourceClojure.id, datasource: datasourceMaven.id,
depName: expandDepName(depName), depName: expandDepName(depName),
currentValue, currentValue,
fileReplacePosition, fileReplacePosition,
registryUrls: [], registryUrls: [CLOJARS_REPO, MAVEN_REPO],
}); });
} }
......
...@@ -5,11 +5,13 @@ Object { ...@@ -5,11 +5,13 @@ Object {
"deps": Array [ "deps": Array [
Object { Object {
"currentValue": "1.3.0", "currentValue": "1.3.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2747, "fileReplacePosition": 2747,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -18,11 +20,13 @@ Object { ...@@ -18,11 +20,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.0", "currentValue": "1.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.jclouds:jclouds", "depName": "org.jclouds:jclouds",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2794, "fileReplacePosition": 2794,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -31,11 +35,13 @@ Object { ...@@ -31,11 +35,13 @@ Object {
}, },
Object { Object {
"currentValue": "2.3.1", "currentValue": "2.3.1",
"datasource": "clojure", "datasource": "maven",
"depName": "net.sf.ehcache:ehcache", "depName": "net.sf.ehcache:ehcache",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2862, "fileReplacePosition": 2862,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -44,11 +50,13 @@ Object { ...@@ -44,11 +50,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.2.15", "currentValue": "1.2.15",
"datasource": "clojure", "datasource": "maven",
"depName": "log4j:log4j", "depName": "log4j:log4j",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 2912, "fileReplacePosition": 2912,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -57,11 +65,13 @@ Object { ...@@ -57,11 +65,13 @@ Object {
}, },
Object { Object {
"currentValue": "3.0.2", "currentValue": "3.0.2",
"datasource": "clojure", "datasource": "maven",
"depName": "net.3scale:3scale-api", "depName": "net.3scale:3scale-api",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3223, "fileReplacePosition": 3223,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -70,11 +80,13 @@ Object { ...@@ -70,11 +80,13 @@ Object {
}, },
Object { Object {
"currentValue": "2.8.5", "currentValue": "2.8.5",
"datasource": "clojure", "datasource": "maven",
"depName": "org.lwjgl.lwjgl:lwjgl", "depName": "org.lwjgl.lwjgl:lwjgl",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3272, "fileReplacePosition": 3272,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -83,11 +95,13 @@ Object { ...@@ -83,11 +95,13 @@ Object {
}, },
Object { Object {
"currentValue": "2.8.5", "currentValue": "2.8.5",
"datasource": "clojure", "datasource": "maven",
"depName": "org.lwjgl.lwjgl:lwjgl-platform", "depName": "org.lwjgl.lwjgl:lwjgl-platform",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 3330, "fileReplacePosition": 3330,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -96,11 +110,13 @@ Object { ...@@ -96,11 +110,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.4.0", "currentValue": "1.4.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11073, "fileReplacePosition": 11073,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -109,11 +125,13 @@ Object { ...@@ -109,11 +125,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.5.0", "currentValue": "1.5.0",
"datasource": "clojure", "datasource": "maven",
"depName": "org.clojure:clojure", "depName": "org.clojure:clojure",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11139, "fileReplacePosition": 11139,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -122,11 +140,13 @@ Object { ...@@ -122,11 +140,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.2.4", "currentValue": "0.2.4",
"datasource": "clojure", "datasource": "maven",
"depName": "clj-stacktrace:clj-stacktrace", "depName": "clj-stacktrace:clj-stacktrace",
"depType": "dependencies", "depType": "dependencies",
"fileReplacePosition": 11287, "fileReplacePosition": 11287,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -135,11 +155,13 @@ Object { ...@@ -135,11 +155,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.12.0", "currentValue": "0.12.0",
"datasource": "clojure", "datasource": "maven",
"depName": "clj-time:clj-time", "depName": "clj-time:clj-time",
"depType": "managed-dependencies", "depType": "managed-dependencies",
"fileReplacePosition": 4705, "fileReplacePosition": 4705,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -148,11 +170,13 @@ Object { ...@@ -148,11 +170,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.4.6", "currentValue": "1.4.6",
"datasource": "clojure", "datasource": "maven",
"depName": "me.raynes:fs", "depName": "me.raynes:fs",
"depType": "managed-dependencies", "depType": "managed-dependencies",
"fileReplacePosition": 4754, "fileReplacePosition": 4754,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -161,11 +185,13 @@ Object { ...@@ -161,11 +185,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.1.1", "currentValue": "1.1.1",
"datasource": "clojure", "datasource": "maven",
"depName": "lein-pprint:lein-pprint", "depName": "lein-pprint:lein-pprint",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5558, "fileReplacePosition": 5558,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -174,11 +200,13 @@ Object { ...@@ -174,11 +200,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.1.0", "currentValue": "0.1.0",
"datasource": "clojure", "datasource": "maven",
"depName": "lein-assoc:lein-assoc", "depName": "lein-assoc:lein-assoc",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5591, "fileReplacePosition": 5591,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -187,11 +215,13 @@ Object { ...@@ -187,11 +215,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.1.1", "currentValue": "1.1.1",
"datasource": "clojure", "datasource": "maven",
"depName": "s3-wagon-private:s3-wagon-private", "depName": "s3-wagon-private:s3-wagon-private",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5630, "fileReplacePosition": 5630,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -200,11 +230,13 @@ Object { ...@@ -200,11 +230,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.0.1", "currentValue": "0.0.1",
"datasource": "clojure", "datasource": "maven",
"depName": "lein-foo:lein-foo", "depName": "lein-foo:lein-foo",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5661, "fileReplacePosition": 5661,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -213,11 +245,13 @@ Object { ...@@ -213,11 +245,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.0.1", "currentValue": "0.0.1",
"datasource": "clojure", "datasource": "maven",
"depName": "lein-bar:lein-bar", "depName": "lein-bar:lein-bar",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 5705, "fileReplacePosition": 5705,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -226,11 +260,13 @@ Object { ...@@ -226,11 +260,13 @@ Object {
}, },
Object { Object {
"currentValue": "0.7.1", "currentValue": "0.7.1",
"datasource": "clojure", "datasource": "maven",
"depName": "cider:cider-nrepl", "depName": "cider:cider-nrepl",
"depType": "plugins", "depType": "plugins",
"fileReplacePosition": 11489, "fileReplacePosition": 11489,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -239,11 +275,13 @@ Object { ...@@ -239,11 +275,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.3.13", "currentValue": "1.3.13",
"datasource": "clojure", "datasource": "maven",
"depName": "com.theoryinpractise:clojure-maven-plugin", "depName": "com.theoryinpractise:clojure-maven-plugin",
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 26925, "fileReplacePosition": 26925,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -252,11 +290,13 @@ Object { ...@@ -252,11 +290,13 @@ Object {
}, },
Object { Object {
"currentValue": "2.1", "currentValue": "2.1",
"datasource": "clojure", "datasource": "maven",
"depName": "org.apache.tomcat.maven:tomcat7-maven-plugin", "depName": "org.apache.tomcat.maven:tomcat7-maven-plugin",
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 27372, "fileReplacePosition": 27372,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
...@@ -265,11 +305,13 @@ Object { ...@@ -265,11 +305,13 @@ Object {
}, },
Object { Object {
"currentValue": "1.9.68", "currentValue": "1.9.68",
"datasource": "clojure", "datasource": "maven",
"depName": "com.google.appengine:appengine-maven-plugin", "depName": "com.google.appengine:appengine-maven-plugin",
"depType": "pom-plugins", "depType": "pom-plugins",
"fileReplacePosition": 27440, "fileReplacePosition": 27440,
"registryUrls": Array [ "registryUrls": Array [
"https://clojars.org/repo",
"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",
"https://blueant.com/archiva/snapshots", "https://blueant.com/archiva/snapshots",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import { trimAtKey, extractFromVectors, extractPackageFile } from './extract'; import { trimAtKey, extractFromVectors, extractPackageFile } from './extract';
import * as datasourceClojure from '../../datasource/clojure'; import * as datasourceMaven from '../../datasource/maven';
const leinProjectClj = readFileSync( const leinProjectClj = readFileSync(
resolve(__dirname, `./__fixtures__/project.clj`), resolve(__dirname, `./__fixtures__/project.clj`),
...@@ -23,7 +23,7 @@ describe('manager/clojure/extract', () => { ...@@ -23,7 +23,7 @@ describe('manager/clojure/extract', () => {
expect(extractFromVectors('[[]]')).toEqual([]); expect(extractFromVectors('[[]]')).toEqual([]);
expect(extractFromVectors('[[foo/bar "1.2.3"]]')).toEqual([ expect(extractFromVectors('[[foo/bar "1.2.3"]]')).toEqual([
{ {
datasource: datasourceClojure.id, datasource: datasourceMaven.id,
depName: 'foo:bar', depName: 'foo:bar',
currentValue: '1.2.3', currentValue: '1.2.3',
fileReplacePosition: 11, fileReplacePosition: 11,
...@@ -33,13 +33,13 @@ describe('manager/clojure/extract', () => { ...@@ -33,13 +33,13 @@ describe('manager/clojure/extract', () => {
extractFromVectors('[\t[foo/bar "1.2.3"]\n["foo/baz" "4.5.6"] ]') extractFromVectors('[\t[foo/bar "1.2.3"]\n["foo/baz" "4.5.6"] ]')
).toEqual([ ).toEqual([
{ {
datasource: datasourceClojure.id, datasource: datasourceMaven.id,
depName: 'foo:bar', depName: 'foo:bar',
currentValue: '1.2.3', currentValue: '1.2.3',
fileReplacePosition: 12, fileReplacePosition: 12,
}, },
{ {
datasource: datasourceClojure.id, datasource: datasourceMaven.id,
depName: 'foo:baz', depName: 'foo:baz',
currentValue: '4.5.6', currentValue: '4.5.6',
fileReplacePosition: 33, fileReplacePosition: 33,
......
import { CLOJARS_REPO, MAVEN_REPO } from '../../datasource/maven/common';
import { PackageDependency, PackageFile } from '../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 { export function trimAtKey(str: string, kwName: string): string | null {
const regex = new RegExp(`:${kwName}(?=\\s)`); const regex = new RegExp(`:${kwName}(?=\\s)`);
...@@ -49,7 +50,7 @@ export function extractFromVectors( ...@@ -49,7 +50,7 @@ export function extractFromVectors(
if (artifactId && version && fileReplacePosition) { if (artifactId && version && fileReplacePosition) {
result.push({ result.push({
...ctx, ...ctx,
datasource: datasourceClojure.id, datasource: datasourceMaven.id,
depName: expandDepName(cleanStrLiteral(artifactId)), depName: expandDepName(cleanStrLiteral(artifactId)),
currentValue: cleanStrLiteral(version), currentValue: cleanStrLiteral(version),
fileReplacePosition, fileReplacePosition,
...@@ -95,7 +96,7 @@ export function extractFromVectors( ...@@ -95,7 +96,7 @@ export function extractFromVectors(
} }
function extractLeinRepos(content: string): string[] { function extractLeinRepos(content: string): string[] {
const result = []; 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment