renovate/lib/manager/gradle-wrapper/extract.js
Rhys Arkins a9332a8db0
feat: replace purl with datasource (#3154)
This deprecates the (internal) use of package URLs and instead replaces with `datasource`/`lookupName`.

Closes #3005
2019-02-04 09:41:22 +01:00

44 lines
1.1 KiB
JavaScript

const { coerce } = require('semver');
module.exports = {
extractPackageFile,
};
function extractPackageFile(fileContent) {
logger.debug('gradle-wrapper.extractPackageFile()');
const lines = fileContent.split('\n');
let lineNumber = 0;
for (const line of lines) {
const match = line.match(
/^distributionUrl=.*-((\d|\.)+)-(bin|all)\.zip\s*$/
);
if (match) {
const dependency = {
datasource: 'gradleVersion',
depType: 'gradle-wrapper',
depName: 'gradle',
currentValue: coerce(match[1]).toString(),
lineNumber,
versionScheme: 'semver',
/* gradle specifics ... */
gradleWrapperType: match[3],
};
let shaLineNumber = 0;
for (const shaLine of lines) {
const shaMatch = shaLine.match(/^distributionSha256Sum=((\w){64}).*$/);
if (shaMatch) {
dependency.checksumLineNumber = shaLineNumber;
break;
}
shaLineNumber += 1;
}
logger.info(dependency, 'Gradle Wrapper');
return { deps: [dependency] };
}
lineNumber += 1;
}
return null;
}