Files
renovate/tools/docs/manager/github-actions/community.ts
T
Sebastian Poxhofer e0cec3dc95 refactor(lint): add types-location rule and enable it for lib/modules (#45497)
feat(lint): add `types-location` rule and enable it for `lib/modules`

Reviewers consistently ask for exported types to be moved into a
colocated `types.ts`. Add a `renovate/types-location` oxlint rule that
reports `export interface` / `export type` declarations outside such a
file, and turn it on across `lib/modules`.

Re-exports (`export type { X }`, `export type *`), file-local types, and
values (enums, classes, functions) are left alone. `schema.ts` files and
`schema/` directories are excluded via config, matching how
`zod-schema-location` is configured — inferred types belong next to the
schema they are derived from.

Relocating the 87 existing violations means:

- new `types.ts` files for the modules that had none
- `terragrunt/common.ts` folded into its `types.ts`, as it held nothing
  else
- `RangeBound` in `versioning/gradle/compare.ts` un-exported, since only
  a file-local interface referenced it
- `bazel-module/parser/fragments.ts` split from its inferred types, which
  now live in `parser/types.ts` and infer through a namespace import so
  each schema keeps its merged name
2026-08-27 19:52:09 +00:00

65 lines
2.0 KiB
TypeScript

import { codeBlock } from 'common-tags';
import { z } from 'zod/v4';
import { communityActions } from '../../../../lib/modules/manager/github-actions/community.ts';
import type { CommunityActionConfig } from '../../../../lib/modules/manager/github-actions/types.ts';
import { readFile, updateFile } from '../../../utils/index.ts';
import { replaceContent } from '../../utils.ts';
function getWithSchemaFields(
schema: CommunityActionConfig['withSchema'],
): string[] {
if (!schema) {
return ['version'];
}
// `z.object({...}).transform(...)` produces a ZodPipe in Zod v4, where
// `def.in` is the source ZodObject. Walk through any pipes until we hit it.
let current: z.ZodType = schema;
while ('in' in current.def) {
current = current.def.in as z.ZodType;
}
if (current instanceof z.ZodObject) {
return Object.keys(current.shape);
}
return ['version'];
}
function determineDependencyToUpdate({
depName,
packageName,
}: CommunityActionConfig): string {
if (!depName && !packageName) {
// some actions determine the depName and packageName dynamically
return '(determined from `with` input(s))';
}
return `[\`${depName ?? packageName}\`](https://github.com/${packageName})`;
}
function generateToolingTable(): string {
let table = codeBlock`
| Action | \`with\` input(s) used | Dependency |
| --- | --- | --- |
`;
table += '\n';
for (const [name, cfg] of Object.entries(communityActions)) {
const withFields = getWithSchemaFields(cfg.withSchema);
table += `| [\`${name}\`](https://github.com/${name}) | \`${withFields.join('`, `')}\` | ${determineDependencyToUpdate(cfg)} |\n`;
}
return table;
}
export async function generateManagerGithubActionsCommunity(
dist: string,
): Promise<void> {
const indexFileName = `${dist}/modules/manager/github-actions/index.md`;
let indexContent = await readFile(indexFileName);
indexContent = replaceContent(indexContent, generateToolingTable());
await updateFile(
`${dist}/modules/manager/github-actions/index.md`,
indexContent,
);
}