mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
45 lines
939 B
JavaScript
45 lines
939 B
JavaScript
const { parse } = require('../util/purl');
|
|
|
|
const docker = require('./docker');
|
|
const github = require('./github');
|
|
const npm = require('./npm');
|
|
const nuget = require('./nuget');
|
|
const packagist = require('./packagist');
|
|
const pypi = require('./pypi');
|
|
|
|
const datasources = {
|
|
docker,
|
|
github,
|
|
npm,
|
|
nuget,
|
|
packagist,
|
|
pypi,
|
|
};
|
|
|
|
function getDependency(purlStr, config) {
|
|
const purl = parse(purlStr);
|
|
if (!purl) {
|
|
return null;
|
|
}
|
|
if (!datasources[purl.type]) {
|
|
logger.warn('Unknown purl type: ' + purl.type);
|
|
return null;
|
|
}
|
|
return datasources[purl.type].getDependency(purl, config);
|
|
}
|
|
|
|
function supportsDigests(purlStr) {
|
|
const purl = parse(purlStr);
|
|
return !!datasources[purl.type].getDependency;
|
|
}
|
|
|
|
function getDigest(config, value) {
|
|
const purl = parse(config.purl);
|
|
return datasources[purl.type].getDigest(config, value);
|
|
}
|
|
|
|
module.exports = {
|
|
getDependency,
|
|
supportsDigests,
|
|
getDigest,
|
|
};
|