mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
82a649d8b9
As a follow-up from #36261, we should auto-generate this in our documentation to keep it up-to-date. If the `getPinnedValue` function is present, we should imply `rangeStrategy=pin`. Co-authored-by: Claude Sonnet 4.5 <jamie.tanna+github-copilot@mend.io>
86 lines
2.4 KiB
TypeScript
86 lines
2.4 KiB
TypeScript
import { codeBlock } from 'common-tags';
|
|
import {
|
|
type VersioningApi,
|
|
getVersioningList,
|
|
} from '../../lib/modules/versioning/index.ts';
|
|
import type { RangeStrategy } from '../../lib/types/versioning.ts';
|
|
import { readFile, updateFile } from '../utils/index.ts';
|
|
import {
|
|
type OpenItems,
|
|
generateFeatureAndBugMarkdown,
|
|
} from './github-query-items.ts';
|
|
import {
|
|
formatDescription,
|
|
formatUrls,
|
|
getModuleLink,
|
|
replaceContent,
|
|
} from './utils.ts';
|
|
|
|
interface Versioning {
|
|
id: string;
|
|
displayName: string;
|
|
urls: string[];
|
|
supportsRanges: boolean;
|
|
supportedRangeStrategies?: RangeStrategy[];
|
|
api: VersioningApi;
|
|
}
|
|
|
|
export async function generateVersioning(
|
|
dist: string,
|
|
versioningIssuesMap: OpenItems,
|
|
): Promise<void> {
|
|
const versioningList = getVersioningList();
|
|
let versioningContent = '\nSupported values for `versioning` are:\n\n';
|
|
for (const versioning of versioningList) {
|
|
const definition = (await import(
|
|
`../../lib/modules/versioning/${versioning}/index.ts`
|
|
)) as Versioning;
|
|
const {
|
|
id,
|
|
displayName,
|
|
urls,
|
|
supportsRanges,
|
|
supportedRangeStrategies,
|
|
api,
|
|
} = definition;
|
|
|
|
let strategies = supportedRangeStrategies ?? [];
|
|
if (api.getPinnedValue && !strategies.includes('pin')) {
|
|
strategies = [...strategies, 'pin'];
|
|
}
|
|
|
|
versioningContent += `* ${getModuleLink(
|
|
versioning,
|
|
`\`${versioning}\``,
|
|
)}\n`;
|
|
let md = codeBlock`
|
|
---
|
|
title: ${displayName}
|
|
edit_url: https://github.com/renovatebot/renovate/edit/main/lib/modules/versioning/${versioning}/readme.md
|
|
---
|
|
|
|
# ${displayName} Versioning
|
|
`;
|
|
md += '\n\n';
|
|
md += `## Identifier\n\n \`${id}\` \n\n`;
|
|
md += formatUrls(urls);
|
|
md += `## Ranges/Constraints\n\n`;
|
|
if (supportsRanges) {
|
|
md += `✅ Ranges are supported.\n\nValid \`rangeStrategy\` values are: ${strategies
|
|
.map((strategy: string) => `\`${strategy}\``)
|
|
.join(', ')}\n\n`;
|
|
} else {
|
|
md += `❌ No range support.\n\n`;
|
|
}
|
|
md += await formatDescription('versioning', versioning);
|
|
md += `\n----\n\n`;
|
|
md += generateFeatureAndBugMarkdown(versioningIssuesMap, versioning);
|
|
|
|
await updateFile(`${dist}/modules/versioning/${versioning}/index.md`, md);
|
|
}
|
|
|
|
let indexContent = await readFile(`docs/usage/modules/versioning/index.md`);
|
|
indexContent = replaceContent(indexContent, versioningContent);
|
|
await updateFile(`${dist}/modules/versioning/index.md`, indexContent);
|
|
}
|