Files
renovate/tools/docs/platforms.ts
T
Rhys Arkins dca3418bbd refactor: lib/modules (#14488)
Moves datasource, manager, platform and versioning code from lib/ into new lib/modules/

BREAKING CHANGE: External tools must update paths to datasource, manager, platform and versioning
2022-03-04 09:04:02 +01:00

28 lines
1008 B
TypeScript

import { getPlatformList } from '../../lib/modules/platform';
import { readFile, updateFile } from '../utils';
import { replaceContent } from './utils';
function getModuleLink(module: string, title: string): string {
return `[${title ?? module}](${module}/)`;
}
export async function generatePlatforms(dist: string): Promise<void> {
let platformContent = 'Supported values for `platform` are: ';
const platforms = getPlatformList();
for (const platform of platforms) {
const readme = await readFile(`lib/modules/platform/${platform}/index.md`);
await updateFile(`${dist}/modules/platform/${platform}/index.md`, readme);
}
platformContent += platforms
.map((v) => getModuleLink(v, `\`${v}\``))
.join(', ');
platformContent += '.\n';
const indexFileName = `docs/usage/modules/platform.md`;
let indexContent = await readFile(indexFileName);
indexContent = replaceContent(indexContent, platformContent);
await updateFile(`${dist}/modules/platform.md`, indexContent);
}