diff --git a/lib/modules/datasource/conan/index.ts b/lib/modules/datasource/conan/index.ts index dd3fb0a12b4c99f..c4a7179b781ae69 100644 --- a/lib/modules/datasource/conan/index.ts +++ b/lib/modules/datasource/conan/index.ts @@ -58,9 +58,10 @@ export class ConanDatasource extends Datasource { const res = await this.githubHttp.get(url, { headers: { accept: 'application/vnd.github.v3.raw' }, }); - const doc = parseSingleYaml(res.body, { + // TODO: use schema (#9610) + const doc = parseSingleYaml(res.body, { json: true, - }) as ConanYAML; + }); return { releases: Object.keys(doc?.versions ?? {}).map((version) => ({ version, diff --git a/lib/modules/datasource/helm/common.spec.ts b/lib/modules/datasource/helm/common.spec.ts index 09ad126e72b396d..678ab1188160228 100644 --- a/lib/modules/datasource/helm/common.spec.ts +++ b/lib/modules/datasource/helm/common.spec.ts @@ -4,9 +4,9 @@ import { findSourceUrl } from './common'; import type { HelmRepository } from './types'; // Truncated index.yaml file -const repo = parseSingleYaml(Fixtures.get('sample.yaml'), { +const repo = parseSingleYaml(Fixtures.get('sample.yaml'), { json: true, -}) as HelmRepository; +}); describe('modules/datasource/helm/common', () => { describe('findSourceUrl', () => { diff --git a/lib/modules/datasource/helm/index.ts b/lib/modules/datasource/helm/index.ts index 20c691794a21d22..ada0c21779c1b85 100644 --- a/lib/modules/datasource/helm/index.ts +++ b/lib/modules/datasource/helm/index.ts @@ -48,9 +48,10 @@ export class HelmDatasource extends Datasource { this.handleGenericErrors(err); } try { - const doc = parseSingleYaml(res.body, { + // TODO: use schema (#9610) + const doc = parseSingleYaml(res.body, { json: true, - }) as HelmRepository; + }); if (!is.plainObject(doc)) { logger.warn( { helmRepository }, diff --git a/lib/modules/manager/argocd/extract.ts b/lib/modules/manager/argocd/extract.ts index cd3b44d8543d1c8..26fdc84cec4eb04 100644 --- a/lib/modules/manager/argocd/extract.ts +++ b/lib/modules/manager/argocd/extract.ts @@ -33,7 +33,8 @@ export function extractPackageFile( let definitions: ApplicationDefinition[]; try { - definitions = parseYaml(content) as ApplicationDefinition[]; + // TODO: use schema (#9610) + definitions = parseYaml(content); } catch (err) { logger.debug({ err, packageFile }, 'Failed to parse ArgoCD definition.'); return null; diff --git a/lib/modules/manager/docker-compose/extract.ts b/lib/modules/manager/docker-compose/extract.ts index 03761162e804380..6b254ae20f6c224 100644 --- a/lib/modules/manager/docker-compose/extract.ts +++ b/lib/modules/manager/docker-compose/extract.ts @@ -36,8 +36,8 @@ export function extractPackageFile( logger.debug(`docker-compose.extractPackageFile(${packageFile})`); let config: DockerComposeConfig; try { - // TODO: fix me (#9610) - config = parseSingleYaml(content, { json: true }) as DockerComposeConfig; + // TODO: use schema (#9610) + config = parseSingleYaml(content, { json: true }); if (!config) { logger.debug( { packageFile }, diff --git a/lib/modules/manager/fleet/extract.ts b/lib/modules/manager/fleet/extract.ts index 06b6b3ef2e9411d..6ea8a2434761589 100644 --- a/lib/modules/manager/fleet/extract.ts +++ b/lib/modules/manager/fleet/extract.ts @@ -119,16 +119,20 @@ export function extractPackageFile( try { if (regEx('fleet.ya?ml').test(packageFile)) { - // TODO: fix me (#9610) - const docs = parseYaml(content, null, { json: true }) as FleetFile[]; + // TODO: use schema (#9610) + const docs = parseYaml(content, null, { + json: true, + }); const fleetDeps = docs .filter((doc) => is.truthy(doc?.helm)) .flatMap((doc) => extractFleetFile(doc)); deps.push(...fleetDeps); } else { - // TODO: fix me (#9610) - const docs = parseYaml(content, null, { json: true }) as GitRepo[]; + // TODO: use schema (#9610) + const docs = parseYaml(content, null, { + json: true, + }); const gitRepoDeps = docs .filter((doc) => doc.kind === 'GitRepo') // ensure only GitRepo manifests are processed .flatMap((doc) => extractGitRepo(doc)); diff --git a/lib/modules/manager/flux/extract.ts b/lib/modules/manager/flux/extract.ts index b5c6469392e24a0..2b03f05eac54c8d 100644 --- a/lib/modules/manager/flux/extract.ts +++ b/lib/modules/manager/flux/extract.ts @@ -52,7 +52,8 @@ function readManifest( }; let resources: FluxResource[]; try { - resources = parseYaml(content, null, { json: true }) as FluxResource[]; + // TODO: use schema (#9610) + resources = parseYaml(content, null, { json: true }); } catch (err) { logger.debug({ err, packageFile }, 'Failed to parse Flux manifest'); return null; diff --git a/lib/modules/manager/github-actions/extract.ts b/lib/modules/manager/github-actions/extract.ts index d8fff7ea0825f50..c1446e5f84a2bdb 100644 --- a/lib/modules/manager/github-actions/extract.ts +++ b/lib/modules/manager/github-actions/extract.ts @@ -166,7 +166,8 @@ function extractWithYAMLParser( let pkg: Workflow; try { - pkg = parseSingleYaml(content, { json: true }) as Workflow; + // TODO: use schema (#9610) + pkg = parseSingleYaml(content, { json: true }); } catch (err) { logger.debug( { packageFile, err }, diff --git a/lib/modules/manager/gitlabci-include/common.spec.ts b/lib/modules/manager/gitlabci-include/common.spec.ts index 40528525a69fcc8..da66940cf4ad2a1 100644 --- a/lib/modules/manager/gitlabci-include/common.spec.ts +++ b/lib/modules/manager/gitlabci-include/common.spec.ts @@ -10,9 +10,10 @@ import { } from './common'; const yamlFileMultiConfig = Fixtures.get('gitlab-ci.1.yaml'); -const pipeline = parseSingleYaml( +// TODO: use schema (#9610) +const pipeline = parseSingleYaml( replaceReferenceTags(yamlFileMultiConfig), -) as GitlabPipeline; +); const includeLocal = { local: 'something' }; const includeProject = { project: 'something' }; diff --git a/lib/modules/manager/gitlabci-include/extract.ts b/lib/modules/manager/gitlabci-include/extract.ts index 95a98dc87af54de..78c84dd0e9dabd1 100644 --- a/lib/modules/manager/gitlabci-include/extract.ts +++ b/lib/modules/manager/gitlabci-include/extract.ts @@ -71,9 +71,10 @@ export function extractPackageFile( const platform = GlobalConfig.get('platform'); const endpoint = GlobalConfig.get('endpoint'); try { - const doc = parseSingleYaml(replaceReferenceTags(content), { + // TODO: use schema (#9610) + const doc = parseSingleYaml(replaceReferenceTags(content), { json: true, - }) as GitlabPipeline; + }); const includes = getAllIncludeProjects(doc); for (const includeObj of includes) { const dep = extractDepFromIncludeFile(includeObj); diff --git a/lib/modules/manager/gitlabci/extract.ts b/lib/modules/manager/gitlabci/extract.ts index 8f5a6ce0164751f..8a7fdae5375602a 100644 --- a/lib/modules/manager/gitlabci/extract.ts +++ b/lib/modules/manager/gitlabci/extract.ts @@ -83,9 +83,10 @@ export function extractPackageFile( ): PackageFileContent | null { let deps: PackageDependency[] = []; try { + // TODO: use schema (#9610) const doc = parseSingleYaml(replaceReferenceTags(content), { json: true, - }) as Record; + }); if (is.object(doc)) { for (const [property, value] of Object.entries(doc)) { switch (property) { @@ -146,9 +147,10 @@ export async function extractAllPackageFiles( } let doc: GitlabPipeline; try { + // TODO: use schema (#9610) doc = parseSingleYaml(replaceReferenceTags(content), { json: true, - }) as GitlabPipeline; + }); } catch (err) { logger.debug( { err, packageFile: file }, diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 237a15157a09cf8..e570afe4f4d0379 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -35,10 +35,11 @@ export async function extractPackageFile( // Record kustomization usage for all deps, since updating artifacts is run on the helmfile.yaml as a whole. let needKustomize = false; try { + // TODO: use schema (#9610) docs = parseYaml(content, null, { removeTemplates: true, json: true, - }) as Doc[]; + }); } catch (err) { logger.debug( { err, packageFile }, diff --git a/lib/modules/manager/helmsman/extract.ts b/lib/modules/manager/helmsman/extract.ts index 697c2fdf4403a97..631478452124868 100644 --- a/lib/modules/manager/helmsman/extract.ts +++ b/lib/modules/manager/helmsman/extract.ts @@ -68,10 +68,10 @@ export function extractPackageFile( _config: ExtractConfig, ): PackageFileContent | null { try { - // TODO: fix me (#9610) - const doc = parseSingleYaml(content, { + // TODO: use schema (#9610) + const doc = parseSingleYaml(content, { json: true, - }) as HelmsmanDocument; + }); if (!doc.apps) { logger.debug({ packageFile }, `Missing apps keys`); return null; diff --git a/lib/modules/manager/helmv3/artifacts.ts b/lib/modules/manager/helmv3/artifacts.ts index f7d18c092efe0b4..abc8e6887b65626 100644 --- a/lib/modules/manager/helmv3/artifacts.ts +++ b/lib/modules/manager/helmv3/artifacts.ts @@ -114,12 +114,13 @@ export async function updateArtifacts({ } try { // get repositories and registries defined in the package file - const packages = yaml.parseSingleYaml( + // TODO: use schema (#9610) + const packages = yaml.parseSingleYaml( newPackageFileContent, - ) as ChartDefinition; //TODO #9610 + ); const locks = existingLockFileContent - ? (yaml.parseSingleYaml(existingLockFileContent) as ChartDefinition) - : { dependencies: [] }; //TODO #9610 + ? yaml.parseSingleYaml(existingLockFileContent) + : { dependencies: [] }; const chartDefinitions: ChartDefinition[] = []; // prioritize registryAlias naming for Helm repositories diff --git a/lib/modules/manager/helmv3/extract.ts b/lib/modules/manager/helmv3/extract.ts index 758b5d66b511265..5e633dca673ebc0 100644 --- a/lib/modules/manager/helmv3/extract.ts +++ b/lib/modules/manager/helmv3/extract.ts @@ -22,8 +22,8 @@ export async function extractPackageFile( dependencies: Array<{ name: string; version: string; repository: string }>; }; try { - // TODO: fix me (#9610) - chart = parseSingleYaml(content, { json: true }) as any; + // TODO: use schema (#9610) + chart = parseSingleYaml(content, { json: true }); if (!(chart?.apiVersion && chart.name && chart.version)) { logger.debug( { packageFile }, diff --git a/lib/modules/manager/jenkins/extract.ts b/lib/modules/manager/jenkins/extract.ts index 161b356f3768789..0b88ea5dfa45fca 100644 --- a/lib/modules/manager/jenkins/extract.ts +++ b/lib/modules/manager/jenkins/extract.ts @@ -57,7 +57,8 @@ function extractYaml( const deps: PackageDependency[] = []; try { - const doc = parseSingleYaml(content, { json: true }) as JenkinsPlugins; + // TODO: use schema (#9610) + const doc = parseSingleYaml(content, { json: true }); if (is.nonEmptyArray(doc?.plugins)) { for (const plugin of doc.plugins) { if (plugin.artifactId) { diff --git a/lib/modules/manager/kubernetes/extract.ts b/lib/modules/manager/kubernetes/extract.ts index 69a819184ea3225..3ecad886571adc3 100644 --- a/lib/modules/manager/kubernetes/extract.ts +++ b/lib/modules/manager/kubernetes/extract.ts @@ -70,7 +70,8 @@ function extractApis( let doc: KubernetesConfiguration[]; try { - doc = parseYaml(content) as KubernetesConfiguration[]; + // TODO: use schema (#9610) + doc = parseYaml(content); } catch (err) { logger.debug({ err, packageFile }, 'Failed to parse Kubernetes manifest.'); return []; diff --git a/lib/modules/manager/kustomize/extract.ts b/lib/modules/manager/kustomize/extract.ts index 60ad65dbeaa7a7a..3c021d6fad7bd94 100644 --- a/lib/modules/manager/kustomize/extract.ts +++ b/lib/modules/manager/kustomize/extract.ts @@ -158,7 +158,8 @@ export function parseKustomize( ): Kustomize | null { let pkg: Kustomize | null = null; try { - pkg = parseSingleYaml(content, { json: true }) as Kustomize; + // TODO: use schema (#9610) + pkg = parseSingleYaml(content, { json: true }); } catch (e) /* istanbul ignore next */ { logger.debug({ packageFile }, 'Error parsing kustomize file'); return null; diff --git a/lib/modules/manager/npm/extract/pnpm.ts b/lib/modules/manager/npm/extract/pnpm.ts index dc87f14e0d71580..c4fa0d79510bf6d 100644 --- a/lib/modules/manager/npm/extract/pnpm.ts +++ b/lib/modules/manager/npm/extract/pnpm.ts @@ -23,10 +23,13 @@ export async function extractPnpmFilters( fileName: string, ): Promise { try { - // TODO #22198 - const contents = parseSingleYaml((await readLocalFile(fileName, 'utf8'))!, { - json: true, - }) as PnpmWorkspaceFile; + // TODO: use schema (#9610,#22198) + const contents = parseSingleYaml( + (await readLocalFile(fileName, 'utf8'))!, + { + json: true, + }, + ); if ( !Array.isArray(contents.packages) || !contents.packages.every((item) => is.string(item)) diff --git a/lib/modules/manager/npm/post-update/index.ts b/lib/modules/manager/npm/post-update/index.ts index 19f23356714780c..20adb0c2658e5ff 100644 --- a/lib/modules/manager/npm/post-update/index.ts +++ b/lib/modules/manager/npm/post-update/index.ts @@ -390,9 +390,9 @@ export async function updateYarnBinary( return existingYarnrcYmlContent; } - const oldYarnPath = (parseSingleYaml(yarnrcYml) as YarnRcYmlFile)?.yarnPath; - const newYarnPath = (parseSingleYaml(newYarnrcYml) as YarnRcYmlFile) - ?.yarnPath; + // TODO: use schema (#9610) + const oldYarnPath = parseSingleYaml(yarnrcYml)?.yarnPath; + const newYarnPath = parseSingleYaml(newYarnrcYml)?.yarnPath; if ( !is.nonEmptyStringAndNotWhitespace(oldYarnPath) || !is.nonEmptyStringAndNotWhitespace(newYarnPath) @@ -569,9 +569,10 @@ export async function getAdditionalFiles( existingYarnrcYmlContent = await readLocalFile(yarnRcYmlFilename, 'utf8'); if (existingYarnrcYmlContent) { try { - const existingYarnrRcYml = parseSingleYaml( + // TODO: use schema (#9610) + const existingYarnrRcYml = parseSingleYaml>( existingYarnrcYmlContent, - ) as Record; + ); const updatedYarnYrcYml = deepmerge( existingYarnrRcYml, additionalYarnRcYml, diff --git a/lib/modules/manager/npm/post-update/pnpm.ts b/lib/modules/manager/npm/post-update/pnpm.ts index 31989b62caff164..b2b5bcf043f2ce1 100644 --- a/lib/modules/manager/npm/post-update/pnpm.ts +++ b/lib/modules/manager/npm/post-update/pnpm.ts @@ -126,7 +126,8 @@ export async function getConstraintFromLockFile( if (!lockfileContent) { return null; } - const pnpmLock = parseSingleYaml(lockfileContent) as PnpmLockFile; + // TODO: use schema (#9610) + const pnpmLock = parseSingleYaml(lockfileContent); if (!is.number(pnpmLock?.lockfileVersion)) { return null; } diff --git a/lib/modules/manager/pre-commit/extract.ts b/lib/modules/manager/pre-commit/extract.ts index fb183b8828f8fa1..fc493014e7cc048 100644 --- a/lib/modules/manager/pre-commit/extract.ts +++ b/lib/modules/manager/pre-commit/extract.ts @@ -158,7 +158,8 @@ export function extractPackageFile( type ParsedContent = Record | PreCommitConfig; let parsedContent: ParsedContent; try { - parsedContent = parseSingleYaml(content, { json: true }) as ParsedContent; + // TODO: use schema (#9610) + parsedContent = parseSingleYaml(content, { json: true }); } catch (err) { logger.debug( { filename: packageFile, err }, diff --git a/lib/modules/manager/tekton/extract.ts b/lib/modules/manager/tekton/extract.ts index 1a56a07d82981e2..a61c78745a0254c 100644 --- a/lib/modules/manager/tekton/extract.ts +++ b/lib/modules/manager/tekton/extract.ts @@ -22,7 +22,8 @@ export function extractPackageFile( const deps: PackageDependency[] = []; let docs: TektonResource[]; try { - docs = parseYaml(content) as TektonResource[]; + // TODO: use schema (#9610) + docs = parseYaml(content); } catch (err) { logger.debug( { err, packageFile }, diff --git a/lib/modules/manager/travis/extract.ts b/lib/modules/manager/travis/extract.ts index 11000afffbddfc0..79da049c494d53e 100644 --- a/lib/modules/manager/travis/extract.ts +++ b/lib/modules/manager/travis/extract.ts @@ -11,9 +11,10 @@ export function extractPackageFile( ): PackageFileContent | null { let doc: TravisYaml; try { + // TODO: use schema (#9610) doc = parseSingleYaml(content, { json: true, - }) as TravisYaml; + }); } catch (err) { logger.debug({ err, packageFile }, 'Failed to parse .travis.yml file.'); return null; diff --git a/lib/modules/manager/velaci/extract.ts b/lib/modules/manager/velaci/extract.ts index 7446933e69982e3..dfdbf90656b7cfa 100644 --- a/lib/modules/manager/velaci/extract.ts +++ b/lib/modules/manager/velaci/extract.ts @@ -9,10 +9,11 @@ export function extractPackageFile( file: string, packageFile?: string, ): PackageFileContent | null { - let doc: VelaPipelineConfiguration | undefined; + let doc: VelaPipelineConfiguration; try { - doc = parseSingleYaml(file, { json: true }) as VelaPipelineConfiguration; + // TODO: use schema (#9610) + doc = parseSingleYaml(file, { json: true }); } catch (err) { logger.debug({ err, packageFile }, 'Failed to parse Vela file.'); return null; diff --git a/lib/modules/manager/woodpecker/extract.ts b/lib/modules/manager/woodpecker/extract.ts index 2bc5969dfe25f8e..0877a3c81cd3c06 100644 --- a/lib/modules/manager/woodpecker/extract.ts +++ b/lib/modules/manager/woodpecker/extract.ts @@ -22,8 +22,8 @@ export function extractPackageFile( logger.debug('woodpecker.extractPackageFile()'); let config: WoodpeckerConfig; try { - // TODO: fix me (#9610) - config = parseSingleYaml(content, { json: true }) as WoodpeckerConfig; + // TODO: use schema (#9610) + config = parseSingleYaml(content, { json: true }); if (!config) { logger.debug( { packageFile }, diff --git a/lib/workers/global/config/parse/file.ts b/lib/workers/global/config/parse/file.ts index 5de5c61bb233701..9b06e91a68a3fcc 100644 --- a/lib/workers/global/config/parse/file.ts +++ b/lib/workers/global/config/parse/file.ts @@ -18,7 +18,7 @@ export async function getParsedContent(file: string): Promise { case '.yml': return parseSingleYaml(await readSystemFile(file, 'utf8'), { json: true, - }) as RenovateConfig; + }); case '.json5': case '.json': return parseJson(