0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/manager/fvm/extract.ts
2024-04-29 13:09:44 +00:00

36 lines
1.0 KiB
TypeScript

import { logger } from '../../../logger';
import { Json } from '../../../util/schema-utils';
import { FlutterVersionDatasource } from '../../datasource/flutter-version';
import type { PackageDependency, PackageFileContent } from '../types';
import { FvmConfig } from './schema';
export function extractPackageFile(
content: string,
packageFile: string,
): PackageFileContent | null {
let flutterVersion: string | undefined;
try {
const config = Json.pipe(FvmConfig).parse(content);
flutterVersion = config.flutter ?? config.flutterSdkVersion;
if (!flutterVersion) {
logger.debug(
{ contents: config },
'FVM config does not have a flutter version specified',
);
return null;
}
} catch (err) {
logger.debug({ packageFile, err }, 'Invalid FVM config');
return null;
}
const dep: PackageDependency = {
depName: 'flutter',
currentValue: flutterVersion,
datasource: FlutterVersionDatasource.id,
packageName: 'flutter/flutter',
};
return { deps: [dep] };
}