0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 05:28:35 +00:00
renovatebot_renovate/tools/docs/versioning.ts
RahulGautamSingh 6dd189e3a6
docs: automate docs for releaseTimestamp and sourceUrl support (#29225)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2024-05-29 05:24:07 +00:00

71 lines
2.1 KiB
TypeScript

import { codeBlock } from 'common-tags';
import { getVersioningList } from '../../lib/modules/versioning';
import { readFile, updateFile } from '../utils';
import {
type OpenItems,
generateFeatureAndBugMarkdown,
} from './github-query-items';
import {
formatDescription,
formatUrls,
getModuleLink,
replaceContent,
} from './utils';
type Versioning = {
id: string;
displayName: string;
urls?: string[];
supportsRanges?: boolean;
supportedRangeStrategies?: string[];
};
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}`
)) as Versioning;
const { id, displayName, urls, supportsRanges, supportedRangeStrategies } =
definition;
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: ${(
supportedRangeStrategies ?? []
)
.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);
}