0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-12 22:29:06 +00:00
renovatebot_renovate/lib/modules/manager/bitrise/extract.ts
2024-07-26 09:34:20 +00:00

38 lines
1 KiB
TypeScript

import is from '@sindresorhus/is';
import { logger } from '../../../logger';
import { parseSingleYaml } from '../../../util/yaml';
import type { PackageDependency, PackageFileContent } from '../types';
import { BitriseFile } from './schema';
import { parseStep } from './utils';
export function extractPackageFile(
content: string,
packageFile: string,
): PackageFileContent | null {
const deps: PackageDependency[] = [];
try {
const parsed = parseSingleYaml(content, {
customSchema: BitriseFile,
});
const workflows = Object.values(parsed.workflows);
for (const workflow of workflows) {
const steps = workflow.steps.flatMap((step) => Object.keys(step));
for (const step of steps) {
const dep = parseStep(step, parsed.default_step_lib_source);
if (!is.nullOrUndefined(dep)) {
deps.push(dep);
}
}
}
} catch (err) {
logger.debug({ err, packageFile }, `Failed to parse Bitrise YAML config`);
}
if (!deps.length) {
return null;
}
return { deps };
}