0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-27 05:09:37 +00:00
renovatebot_renovate/lib/modules/manager/scalafmt/extract.ts
Gaël Jourdan-Weil 1119d609fd
feat(manager/scalafmt): implement manager (#28192)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
2024-04-01 13:02:27 +00:00

30 lines
916 B
TypeScript

import { regEx } from '../../../util/regex';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
import * as semverVersioning from '../../versioning/semver';
import type { PackageDependency, PackageFileContent } from '../types';
const scalafmtVersionRegex = regEx(
'version *= *(?<version>\\d+\\.\\d+\\.\\d+)',
);
export function extractPackageFile(content: string): PackageFileContent | null {
const regexResult = scalafmtVersionRegex.exec(content);
const scalafmtVersion = regexResult?.groups?.version;
if (!scalafmtVersion) {
return null;
}
const scalafmtDependency: PackageDependency = {
datasource: GithubReleasesDatasource.id,
depName: 'scalafmt',
packageName: 'scalameta/scalafmt',
versioning: semverVersioning.id,
currentValue: scalafmtVersion,
extractVersion: '^v(?<version>\\S+)',
};
return {
deps: [scalafmtDependency],
};
}