Files
renovate/lib/modules/manager/bazel-module/parser/rules.ts
T
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

37 lines
1.1 KiB
TypeScript

import { query as q } from '@renovatebot/good-enough-parser';
import { regEx } from '../../../../util/regex.ts';
import { kvParams } from './common.ts';
import type { Ctx } from './context.ts';
// For the purpose of parsing bazel module files in Renovate, we consider a rule
// to be any "direct function application". For example:
//
// bazel_dep(name = "platforms", version = "0.0.11")
// ^^^^^^^^^ --> the "rule"
//
// In bazel, rules have typically a more narrow definition. However:
// - They are syntactically indistinguishable from, say, macros.
// - In informal speech, "rule" is often used as umbrella term.
const supportedRules = [
'archive_override',
'bazel_dep',
'git_override',
'local_path_override',
'single_version_override',
'git_repository',
'new_git_repository',
];
const supportedRulesRegex = regEx(`^${supportedRules.join('|')}$`);
export const rules = q
.sym<Ctx>(supportedRulesRegex, (ctx, token) => ctx.startRule(token.value))
.join(
q.tree({
type: 'wrapped-tree',
maxDepth: 1,
search: kvParams,
postHandler: (ctx) => ctx.endRule(),
}),
);