mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 07:20:39 +00:00
930cf6633c
fix: Additional vi.mock path corrections and prettier formatting
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { regEx } from '../../../util/regex.ts';
|
|
import { Unity3dDatasource } from '../../datasource/unity3d/index.ts';
|
|
import type { PackageDependency, PackageFileContent } from '../types.ts';
|
|
|
|
const supportedKeys = ['m_EditorVersion', 'm_EditorVersionWithRevision'];
|
|
|
|
const UnityVersionRegex = regEx(/^(?<depName>.+): (?<currentValue>.+)/);
|
|
|
|
function extractVersions(content: string): PackageDependency[] {
|
|
const deps: PackageDependency[] = [];
|
|
|
|
for (const line of content.split('\n')) {
|
|
const matches = UnityVersionRegex.exec(line);
|
|
|
|
if (!matches?.groups) {
|
|
continue;
|
|
}
|
|
|
|
const key = matches.groups.depName;
|
|
const value = matches.groups.currentValue;
|
|
|
|
if (!supportedKeys.includes(key)) {
|
|
continue;
|
|
}
|
|
|
|
deps.push({
|
|
currentValue: value,
|
|
datasource: Unity3dDatasource.id,
|
|
depName: 'Unity Editor',
|
|
packageName: key,
|
|
});
|
|
}
|
|
|
|
return deps;
|
|
}
|
|
|
|
export function extractPackageFile(content: string): PackageFileContent | null {
|
|
const deps: PackageDependency[] = [];
|
|
|
|
deps.push(...extractVersions(content));
|
|
|
|
if (!deps.length) {
|
|
return null;
|
|
}
|
|
|
|
return { deps };
|
|
}
|