mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
feat(composer): lazy repository url (#6982)
This commit is contained in:
parent
43b2a2390d
commit
54cf4c1253
3 changed files with 99 additions and 7 deletions
|
@ -505,6 +505,47 @@ Array [
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`datasource/packagist getReleases supports lazy repositories 1`] = `
|
||||||
|
Object {
|
||||||
|
"name": "guzzlehttp/guzzle",
|
||||||
|
"releases": Array [
|
||||||
|
Object {
|
||||||
|
"gitRef": "5.3.4",
|
||||||
|
"version": "5.3.4",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"gitRef": "7.0.0-beta.1",
|
||||||
|
"version": "7.0.0-beta.1",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`datasource/packagist getReleases supports lazy repositories 2`] = `
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"headers": Object {
|
||||||
|
"accept": "application/json",
|
||||||
|
"accept-encoding": "gzip, deflate",
|
||||||
|
"host": "composer.renovatebot.com",
|
||||||
|
"user-agent": "https://github.com/renovatebot/renovate",
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://composer.renovatebot.com/composer/lazy/packages.json",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"headers": Object {
|
||||||
|
"accept": "application/json",
|
||||||
|
"accept-encoding": "gzip, deflate",
|
||||||
|
"host": "composer.renovatebot.com",
|
||||||
|
"user-agent": "https://github.com/renovatebot/renovate",
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://composer.renovatebot.com/composer/lazy/p/guzzlehttp/guzzle.json",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`datasource/packagist getReleases supports plain packages 1`] = `
|
exports[`datasource/packagist getReleases supports plain packages 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"name": "vendor/package-name",
|
"name": "vendor/package-name",
|
||||||
|
|
|
@ -153,6 +153,45 @@ describe('datasource/packagist', () => {
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
expect(httpMock.getTrace()).toMatchSnapshot();
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
it('supports lazy repositories', async () => {
|
||||||
|
const packagesJson = {
|
||||||
|
packages: [],
|
||||||
|
'providers-lazy-url':
|
||||||
|
'https://composer.renovatebot.com/composer/lazy/p/%package%.json',
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
registryUrls: ['https://composer.renovatebot.com/composer/lazy'],
|
||||||
|
};
|
||||||
|
const fileJson = {
|
||||||
|
packages: {
|
||||||
|
'guzzlehttp/guzzle': {
|
||||||
|
'5.3.4': {
|
||||||
|
name: 'guzzlehttp/guzzle',
|
||||||
|
version: '5.3.4',
|
||||||
|
},
|
||||||
|
'7.0.0-beta.1': {
|
||||||
|
name: 'guzzlehttp/guzzle',
|
||||||
|
version: '7.0.0-beta.1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
httpMock
|
||||||
|
.scope('https://composer.renovatebot.com')
|
||||||
|
.get('/composer/lazy/packages.json')
|
||||||
|
.reply(200, packagesJson)
|
||||||
|
.get('/composer/lazy/p/guzzlehttp/guzzle.json')
|
||||||
|
.reply(200, fileJson);
|
||||||
|
const res = await getPkgReleases({
|
||||||
|
...config,
|
||||||
|
datasource,
|
||||||
|
versioning,
|
||||||
|
depName: 'guzzlehttp/guzzle',
|
||||||
|
});
|
||||||
|
expect(res).toMatchSnapshot();
|
||||||
|
expect(res).not.toBeNull();
|
||||||
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
||||||
|
});
|
||||||
it('supports provider-includes', async () => {
|
it('supports provider-includes', async () => {
|
||||||
const packagesJson = {
|
const packagesJson = {
|
||||||
packages: [],
|
packages: [],
|
||||||
|
|
|
@ -44,6 +44,7 @@ interface RegistryMeta {
|
||||||
files?: RegistryFile[];
|
files?: RegistryFile[];
|
||||||
providerPackages: Record<string, string>;
|
providerPackages: Record<string, string>;
|
||||||
providersUrl?: string;
|
providersUrl?: string;
|
||||||
|
providersLazyUrl?: string;
|
||||||
includesFiles?: RegistryFile[];
|
includesFiles?: RegistryFile[];
|
||||||
packages?: Record<string, RegistryFile>;
|
packages?: Record<string, RegistryFile>;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +70,9 @@ async function getRegistryMeta(regUrl: string): Promise<RegistryMeta | null> {
|
||||||
if (res['providers-url']) {
|
if (res['providers-url']) {
|
||||||
meta.providersUrl = res['providers-url'];
|
meta.providersUrl = res['providers-url'];
|
||||||
}
|
}
|
||||||
|
if (res['providers-lazy-url']) {
|
||||||
|
meta.providersLazyUrl = res['providers-lazy-url'];
|
||||||
|
}
|
||||||
if (res['provider-includes']) {
|
if (res['provider-includes']) {
|
||||||
meta.files = [];
|
meta.files = [];
|
||||||
for (const [key, val] of Object.entries(res['provider-includes'])) {
|
for (const [key, val] of Object.entries(res['provider-includes'])) {
|
||||||
|
@ -148,6 +152,7 @@ function extractDepReleases(versions: RegistryFile): ReleaseResult {
|
||||||
interface AllPackages {
|
interface AllPackages {
|
||||||
packages: Record<string, RegistryFile>;
|
packages: Record<string, RegistryFile>;
|
||||||
providersUrl: string;
|
providersUrl: string;
|
||||||
|
providersLazyUrl: string;
|
||||||
providerPackages: Record<string, string>;
|
providerPackages: Record<string, string>;
|
||||||
|
|
||||||
includesPackages: Record<string, ReleaseResult>;
|
includesPackages: Record<string, ReleaseResult>;
|
||||||
|
@ -158,6 +163,7 @@ async function getAllPackages(regUrl: string): Promise<AllPackages | null> {
|
||||||
const {
|
const {
|
||||||
packages,
|
packages,
|
||||||
providersUrl,
|
providersUrl,
|
||||||
|
providersLazyUrl,
|
||||||
files,
|
files,
|
||||||
includesFiles,
|
includesFiles,
|
||||||
providerPackages,
|
providerPackages,
|
||||||
|
@ -189,6 +195,7 @@ async function getAllPackages(regUrl: string): Promise<AllPackages | null> {
|
||||||
const allPackages: AllPackages = {
|
const allPackages: AllPackages = {
|
||||||
packages,
|
packages,
|
||||||
providersUrl,
|
providersUrl,
|
||||||
|
providersLazyUrl,
|
||||||
providerPackages,
|
providerPackages,
|
||||||
includesPackages,
|
includesPackages,
|
||||||
};
|
};
|
||||||
|
@ -245,6 +252,7 @@ async function packageLookup(
|
||||||
const {
|
const {
|
||||||
packages,
|
packages,
|
||||||
providersUrl,
|
providersUrl,
|
||||||
|
providersLazyUrl,
|
||||||
providerPackages,
|
providerPackages,
|
||||||
includesPackages,
|
includesPackages,
|
||||||
} = allPackages;
|
} = allPackages;
|
||||||
|
@ -256,15 +264,19 @@ async function packageLookup(
|
||||||
if (includesPackages?.[name]) {
|
if (includesPackages?.[name]) {
|
||||||
return includesPackages[name];
|
return includesPackages[name];
|
||||||
}
|
}
|
||||||
if (!providerPackages?.[name]) {
|
let pkgUrl;
|
||||||
return null;
|
if (providerPackages?.[name]) {
|
||||||
}
|
pkgUrl = URL.resolve(
|
||||||
const pkgUrl = URL.resolve(
|
|
||||||
regUrl,
|
regUrl,
|
||||||
providersUrl
|
providersUrl
|
||||||
.replace('%package%', name)
|
.replace('%package%', name)
|
||||||
.replace('%hash%', providerPackages[name])
|
.replace('%hash%', providerPackages[name])
|
||||||
);
|
);
|
||||||
|
} else if (providersLazyUrl) {
|
||||||
|
pkgUrl = URL.resolve(regUrl, providersLazyUrl.replace('%package%', name));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const opts = getHostOpts(regUrl);
|
const opts = getHostOpts(regUrl);
|
||||||
// TODO: fix types
|
// TODO: fix types
|
||||||
const versions = (await http.getJson<any>(pkgUrl, opts)).body.packages[
|
const versions = (await http.getJson<any>(pkgUrl, opts)).body.packages[
|
||||||
|
|
Loading…
Reference in a new issue