mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
f1d0b7b5fe
Ref #5555
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { coerce } from 'semver';
|
|
import { logger } from '../../logger';
|
|
import { PackageFile, PackageDependency } from '../common';
|
|
import * as semverVersioning from '../../versioning/semver';
|
|
import { DATASOURCE_GRADLE_VERSION } from '../../constants/data-binary-source';
|
|
|
|
export function extractPackageFile(fileContent: string): PackageFile | null {
|
|
logger.debug('gradle-wrapper.extractPackageFile()');
|
|
const lines = fileContent.split('\n');
|
|
|
|
let lineNumber = 0;
|
|
for (const line of lines) {
|
|
const match = /^distributionUrl=.*-((\d|\.)+)-(bin|all)\.zip\s*$/.exec(
|
|
line
|
|
);
|
|
if (match) {
|
|
const dependency: PackageDependency = {
|
|
datasource: DATASOURCE_GRADLE_VERSION,
|
|
depType: 'gradle-wrapper',
|
|
depName: 'gradle',
|
|
currentValue: coerce(match[1]).toString(),
|
|
managerData: { lineNumber, gradleWrapperType: match[3] },
|
|
versioning: semverVersioning.id,
|
|
};
|
|
|
|
let shaLineNumber = 0;
|
|
for (const shaLine of lines) {
|
|
const shaMatch = /^distributionSha256Sum=((\w){64}).*$/.test(shaLine);
|
|
if (shaMatch) {
|
|
dependency.managerData.checksumLineNumber = shaLineNumber;
|
|
break;
|
|
}
|
|
shaLineNumber += 1;
|
|
}
|
|
|
|
logger.debug(dependency, 'Gradle Wrapper');
|
|
return { deps: [dependency] };
|
|
}
|
|
lineNumber += 1;
|
|
}
|
|
return null;
|
|
}
|