From ac782ba07e5acaa8e4076977ef13c1afb1a7abba Mon Sep 17 00:00:00 2001 From: Tobias Schlatter <schlatter.tobias@gmail.com> Date: Thu, 20 Feb 2025 08:15:32 +0100 Subject: [PATCH] refactor(bazel-module): Move files that support parsing to ./parser (#34299) --- lib/modules/manager/bazel-module/extract.ts | 2 +- lib/modules/manager/bazel-module/parser/common.ts | 4 ++-- lib/modules/manager/bazel-module/{ => parser}/context.spec.ts | 2 +- lib/modules/manager/bazel-module/{ => parser}/context.ts | 0 lib/modules/manager/bazel-module/parser/extension-tags.ts | 2 +- .../manager/bazel-module/{ => parser}/fragments.spec.ts | 2 +- lib/modules/manager/bazel-module/{ => parser}/fragments.ts | 2 +- lib/modules/manager/bazel-module/parser/index.spec.ts | 2 +- lib/modules/manager/bazel-module/parser/index.ts | 4 ++-- lib/modules/manager/bazel-module/parser/maven.ts | 2 +- lib/modules/manager/bazel-module/parser/oci.ts | 2 +- lib/modules/manager/bazel-module/parser/rules.ts | 2 +- .../manager/bazel-module/{ => parser}/starlark.spec.ts | 2 +- lib/modules/manager/bazel-module/{ => parser}/starlark.ts | 0 lib/modules/manager/bazel-module/rules.spec.ts | 2 +- lib/modules/manager/bazel-module/rules.ts | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) rename lib/modules/manager/bazel-module/{ => parser}/context.spec.ts (96%) rename lib/modules/manager/bazel-module/{ => parser}/context.ts (100%) rename lib/modules/manager/bazel-module/{ => parser}/fragments.spec.ts (98%) rename lib/modules/manager/bazel-module/{ => parser}/fragments.ts (98%) rename lib/modules/manager/bazel-module/{ => parser}/starlark.spec.ts (85%) rename lib/modules/manager/bazel-module/{ => parser}/starlark.ts (100%) diff --git a/lib/modules/manager/bazel-module/extract.ts b/lib/modules/manager/bazel-module/extract.ts index ce16ba3c17..d1a3b9ddcd 100644 --- a/lib/modules/manager/bazel-module/extract.ts +++ b/lib/modules/manager/bazel-module/extract.ts @@ -4,8 +4,8 @@ import { isNotNullOrUndefined } from '../../../util/array'; import { LooseArray } from '../../../util/schema-utils'; import type { PackageDependency, PackageFileContent } from '../types'; import * as bazelrc from './bazelrc'; -import type { ResultFragment } from './fragments'; import { parse } from './parser'; +import type { ResultFragment } from './parser/fragments'; import { RuleToMavenPackageDep, fillRegistryUrls } from './parser/maven'; import { RuleToDockerPackageDep } from './parser/oci'; import { diff --git a/lib/modules/manager/bazel-module/parser/common.ts b/lib/modules/manager/bazel-module/parser/common.ts index 5fe3ad7718..c35c084fdc 100644 --- a/lib/modules/manager/bazel-module/parser/common.ts +++ b/lib/modules/manager/bazel-module/parser/common.ts @@ -1,7 +1,7 @@ import { query as q } from 'good-enough-parser'; import { regEx } from '../../../../util/regex'; -import type { Ctx } from '../context'; -import * as starlark from '../starlark'; +import type { Ctx } from './context'; +import * as starlark from './starlark'; const booleanValuesRegex = regEx(`^${starlark.booleanStringValues.join('|')}$`); diff --git a/lib/modules/manager/bazel-module/context.spec.ts b/lib/modules/manager/bazel-module/parser/context.spec.ts similarity index 96% rename from lib/modules/manager/bazel-module/context.spec.ts rename to lib/modules/manager/bazel-module/parser/context.spec.ts index 68361cfef1..61af85178f 100644 --- a/lib/modules/manager/bazel-module/context.spec.ts +++ b/lib/modules/manager/bazel-module/parser/context.spec.ts @@ -1,7 +1,7 @@ import { Ctx, CtxProcessingError } from './context'; import * as fragments from './fragments'; -describe('modules/manager/bazel-module/context', () => { +describe('modules/manager/bazel-module/parser/context', () => { describe('Ctx (failures cases)', () => { describe('extension tag', () => { it('throws if there is no current', () => { diff --git a/lib/modules/manager/bazel-module/context.ts b/lib/modules/manager/bazel-module/parser/context.ts similarity index 100% rename from lib/modules/manager/bazel-module/context.ts rename to lib/modules/manager/bazel-module/parser/context.ts diff --git a/lib/modules/manager/bazel-module/parser/extension-tags.ts b/lib/modules/manager/bazel-module/parser/extension-tags.ts index 231112c091..a0a114d0c1 100644 --- a/lib/modules/manager/bazel-module/parser/extension-tags.ts +++ b/lib/modules/manager/bazel-module/parser/extension-tags.ts @@ -1,7 +1,7 @@ import { query as q } from 'good-enough-parser'; import { regEx } from '../../../../util/regex'; -import type { Ctx } from '../context'; import { kvParams } from './common'; +import type { Ctx } from './context'; import { mavenExtensionPrefix, mavenExtensionTags } from './maven'; import { ociExtensionPrefix, ociExtensionTags } from './oci'; diff --git a/lib/modules/manager/bazel-module/fragments.spec.ts b/lib/modules/manager/bazel-module/parser/fragments.spec.ts similarity index 98% rename from lib/modules/manager/bazel-module/fragments.spec.ts rename to lib/modules/manager/bazel-module/parser/fragments.spec.ts index e352b35898..278fe212b1 100644 --- a/lib/modules/manager/bazel-module/fragments.spec.ts +++ b/lib/modules/manager/bazel-module/parser/fragments.spec.ts @@ -9,7 +9,7 @@ import { } from './fragments'; import * as fragments from './fragments'; -describe('modules/manager/bazel-module/fragments', () => { +describe('modules/manager/bazel-module/parser/fragments', () => { it('.string()', () => { const result = fragments.string('hello'); expect(() => StringFragmentSchema.parse(result)).not.toThrow(); diff --git a/lib/modules/manager/bazel-module/fragments.ts b/lib/modules/manager/bazel-module/parser/fragments.ts similarity index 98% rename from lib/modules/manager/bazel-module/fragments.ts rename to lib/modules/manager/bazel-module/parser/fragments.ts index 4d686d2288..4a3d38d8cc 100644 --- a/lib/modules/manager/bazel-module/fragments.ts +++ b/lib/modules/manager/bazel-module/parser/fragments.ts @@ -1,5 +1,5 @@ import { z } from 'zod'; -import { LooseArray, LooseRecord } from '../../../util/schema-utils'; +import { LooseArray, LooseRecord } from '../../../../util/schema-utils'; import * as starlark from './starlark'; export const StringFragmentSchema = z.object({ diff --git a/lib/modules/manager/bazel-module/parser/index.spec.ts b/lib/modules/manager/bazel-module/parser/index.spec.ts index cbb629ed0a..d5c2a3817a 100644 --- a/lib/modules/manager/bazel-module/parser/index.spec.ts +++ b/lib/modules/manager/bazel-module/parser/index.spec.ts @@ -1,5 +1,5 @@ import { codeBlock } from 'common-tags'; -import * as fragments from '../fragments'; +import * as fragments from './fragments'; import { parse } from '.'; describe('modules/manager/bazel-module/parser/index', () => { diff --git a/lib/modules/manager/bazel-module/parser/index.ts b/lib/modules/manager/bazel-module/parser/index.ts index cd25ead145..f0f760eb30 100644 --- a/lib/modules/manager/bazel-module/parser/index.ts +++ b/lib/modules/manager/bazel-module/parser/index.ts @@ -1,7 +1,7 @@ import { lang, query as q } from 'good-enough-parser'; -import { Ctx } from '../context'; -import type { ResultFragment } from '../fragments'; +import { Ctx } from './context'; import { extensionTags } from './extension-tags'; +import type { ResultFragment } from './fragments'; import { rules } from './rules'; const rule = q.alt<Ctx>(rules, extensionTags); diff --git a/lib/modules/manager/bazel-module/parser/maven.ts b/lib/modules/manager/bazel-module/parser/maven.ts index 9b6bf797b7..beee25129f 100644 --- a/lib/modules/manager/bazel-module/parser/maven.ts +++ b/lib/modules/manager/bazel-module/parser/maven.ts @@ -6,7 +6,7 @@ import { ExtensionTagFragmentSchema, StringArrayFragmentSchema, StringFragmentSchema, -} from '../fragments'; +} from './fragments'; const artifactTag = 'artifact'; const installTag = 'install'; diff --git a/lib/modules/manager/bazel-module/parser/oci.ts b/lib/modules/manager/bazel-module/parser/oci.ts index f295a987af..63d34ac73c 100644 --- a/lib/modules/manager/bazel-module/parser/oci.ts +++ b/lib/modules/manager/bazel-module/parser/oci.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { DockerDatasource } from '../../../datasource/docker'; import type { PackageDependency } from '../../types'; -import { ExtensionTagFragmentSchema, StringFragmentSchema } from '../fragments'; +import { ExtensionTagFragmentSchema, StringFragmentSchema } from './fragments'; export const ociExtensionPrefix = 'oci'; diff --git a/lib/modules/manager/bazel-module/parser/rules.ts b/lib/modules/manager/bazel-module/parser/rules.ts index dfcadaf5db..016b0270f7 100644 --- a/lib/modules/manager/bazel-module/parser/rules.ts +++ b/lib/modules/manager/bazel-module/parser/rules.ts @@ -1,7 +1,7 @@ import { query as q } from 'good-enough-parser'; import { regEx } from '../../../../util/regex'; -import type { Ctx } from '../context'; import { kvParams } from './common'; +import type { Ctx } from './context'; // For the purpose of parsing bazel module files in Renovate, we consider a rule // to be any "direct function application". For example: diff --git a/lib/modules/manager/bazel-module/starlark.spec.ts b/lib/modules/manager/bazel-module/parser/starlark.spec.ts similarity index 85% rename from lib/modules/manager/bazel-module/starlark.spec.ts rename to lib/modules/manager/bazel-module/parser/starlark.spec.ts index f98cce37a1..5f183ef1fc 100644 --- a/lib/modules/manager/bazel-module/starlark.spec.ts +++ b/lib/modules/manager/bazel-module/parser/starlark.spec.ts @@ -1,6 +1,6 @@ import * as starlark from './starlark'; -describe('modules/manager/bazel-module/starlark', () => { +describe('modules/manager/bazel-module/parser/starlark', () => { it.each` a | exp ${'True'} | ${true} diff --git a/lib/modules/manager/bazel-module/starlark.ts b/lib/modules/manager/bazel-module/parser/starlark.ts similarity index 100% rename from lib/modules/manager/bazel-module/starlark.ts rename to lib/modules/manager/bazel-module/parser/starlark.ts diff --git a/lib/modules/manager/bazel-module/rules.spec.ts b/lib/modules/manager/bazel-module/rules.spec.ts index 53d67a7f5e..cb595b9952 100644 --- a/lib/modules/manager/bazel-module/rules.spec.ts +++ b/lib/modules/manager/bazel-module/rules.spec.ts @@ -2,7 +2,7 @@ import deepmerge from 'deepmerge'; import { BazelDatasource } from '../../datasource/bazel'; import { GithubTagsDatasource } from '../../datasource/github-tags'; import type { PackageDependency } from '../types'; -import * as fragments from './fragments'; +import * as fragments from './parser/fragments'; import type { BasePackageDep, BazelModulePackageDep, diff --git a/lib/modules/manager/bazel-module/rules.ts b/lib/modules/manager/bazel-module/rules.ts index 5c2b133ebb..342498f2c5 100644 --- a/lib/modules/manager/bazel-module/rules.ts +++ b/lib/modules/manager/bazel-module/rules.ts @@ -8,7 +8,7 @@ import { regEx } from '../../../util/regex'; import { BazelDatasource } from '../../datasource/bazel'; import { GithubTagsDatasource } from '../../datasource/github-tags'; import type { PackageDependency } from '../types'; -import { RuleFragmentSchema, StringFragmentSchema } from './fragments'; +import { RuleFragmentSchema, StringFragmentSchema } from './parser/fragments'; // Rule Schemas -- GitLab