mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 21:59:05 +00:00
feat(manager/scalafmt): implement manager (#28192)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
This commit is contained in:
parent
103e54a21c
commit
1119d609fd
5 changed files with 85 additions and 0 deletions
lib/modules/manager
|
@ -75,6 +75,7 @@ import * as puppet from './puppet';
|
|||
import * as pyenv from './pyenv';
|
||||
import * as rubyVersion from './ruby-version';
|
||||
import * as sbt from './sbt';
|
||||
import * as scalafmt from './scalafmt';
|
||||
import * as setupCfg from './setup-cfg';
|
||||
import * as swift from './swift';
|
||||
import * as tekton from './tekton';
|
||||
|
@ -169,6 +170,7 @@ api.set('puppet', puppet);
|
|||
api.set('pyenv', pyenv);
|
||||
api.set('ruby-version', rubyVersion);
|
||||
api.set('sbt', sbt);
|
||||
api.set('scalafmt', scalafmt);
|
||||
api.set('setup-cfg', setupCfg);
|
||||
api.set('swift', swift);
|
||||
api.set('tekton', tekton);
|
||||
|
|
38
lib/modules/manager/scalafmt/extract.spec.ts
Normal file
38
lib/modules/manager/scalafmt/extract.spec.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { codeBlock } from 'common-tags';
|
||||
import { extractPackageFile } from './extract';
|
||||
|
||||
describe('modules/manager/scalafmt/extract', () => {
|
||||
describe('extractPackageFile()', () => {
|
||||
it('extracts version correctly', () => {
|
||||
const scalafmtConf = codeBlock`
|
||||
version = 3.8.0
|
||||
`;
|
||||
const packages = extractPackageFile(scalafmtConf);
|
||||
expect(packages).toMatchObject({
|
||||
deps: [
|
||||
{
|
||||
datasource: 'github-releases',
|
||||
packageName: 'scalameta/scalafmt',
|
||||
depName: 'scalafmt',
|
||||
currentValue: '3.8.0',
|
||||
versioning: 'semver',
|
||||
extractVersion: '^v(?<version>\\S+)',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('ignore file if no version specified', () => {
|
||||
const scalafmtConf = codeBlock`
|
||||
maxColumn = 80
|
||||
`;
|
||||
const packages = extractPackageFile(scalafmtConf);
|
||||
expect(packages).toBeNull();
|
||||
});
|
||||
|
||||
it('should return empty packagefiles is no content is provided', () => {
|
||||
const packages = extractPackageFile('');
|
||||
expect(packages).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
30
lib/modules/manager/scalafmt/extract.ts
Normal file
30
lib/modules/manager/scalafmt/extract.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
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],
|
||||
};
|
||||
}
|
12
lib/modules/manager/scalafmt/index.ts
Normal file
12
lib/modules/manager/scalafmt/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import type { Category } from '../../../constants';
|
||||
import { GithubReleasesDatasource } from '../../datasource/github-releases';
|
||||
|
||||
export { extractPackageFile } from './extract';
|
||||
|
||||
export const supportedDatasources = [GithubReleasesDatasource.id];
|
||||
|
||||
export const defaultConfig = {
|
||||
fileMatch: ['(^|/)\\.scalafmt.conf$'],
|
||||
};
|
||||
|
||||
export const categories: Category[] = ['java'];
|
3
lib/modules/manager/scalafmt/readme.md
Normal file
3
lib/modules/manager/scalafmt/readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Extracts scalafmt version from `.scalafmt.conf` file.
|
||||
|
||||
New versions of Scalafmt are looked up on Github Releases.
|
Loading…
Reference in a new issue