2017-10-24 11:30:18 +00:00
|
|
|
const npmApi = require('./registry');
|
|
|
|
const versions = require('../../workers/package/versions');
|
2017-09-13 19:20:07 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
renovateNpmPackage,
|
|
|
|
};
|
|
|
|
|
|
|
|
async function renovateNpmPackage(config) {
|
|
|
|
const { logger } = config;
|
|
|
|
let results = [];
|
|
|
|
if (!versions.isValidVersion(config.currentVersion)) {
|
|
|
|
results.push({
|
|
|
|
depName: config.depName,
|
|
|
|
type: 'warning',
|
|
|
|
message: `Dependency uses tag "\`${config.currentVersion}\`" as its version so that will never be changed by Renovate`,
|
|
|
|
});
|
|
|
|
logger.debug(results[0].message);
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
const npmDep = await npmApi.getDependency(config.depName, logger);
|
|
|
|
if (npmDep) {
|
|
|
|
results = await versions.determineUpgrades(npmDep, config);
|
|
|
|
if (results.length > 0) {
|
|
|
|
logger.info(
|
|
|
|
{ dependency: config.depName },
|
|
|
|
`${results.length} result(s): ${results.map(
|
|
|
|
upgrade => upgrade.newVersion
|
|
|
|
)}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If dependency lookup fails then warn and return
|
|
|
|
const result = {
|
2017-09-16 05:39:27 +00:00
|
|
|
type: 'warning',
|
2017-09-13 19:20:07 +00:00
|
|
|
message: 'Failed to look up dependency',
|
|
|
|
};
|
2017-10-08 03:52:58 +00:00
|
|
|
if (config.yarnLock || config.packageLock) {
|
2017-09-13 19:20:07 +00:00
|
|
|
result.message +=
|
|
|
|
'. This will block *all* dependencies from being updated due to presence of lock file.';
|
|
|
|
}
|
|
|
|
results = [result];
|
2017-09-16 06:25:31 +00:00
|
|
|
logger.info(result.message);
|
2017-09-13 19:20:07 +00:00
|
|
|
}
|
|
|
|
for (const result of results) {
|
|
|
|
result.repositoryUrl =
|
|
|
|
npmDep && npmDep.repositoryUrl && npmDep.repositoryUrl.length
|
|
|
|
? npmDep.repositoryUrl
|
|
|
|
: null;
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
}
|