/** * The published package counts of this monorepo * * 本仓库已发布包的数量 */ export interface PackageCounts { /** The number of published plugins / 已发布插件的数量 */ plugins: number /** The number of published themes / 已发布主题的数量 */ themes: number /** The number of published tools / 已发布工具的数量 */ tools: number } /** * Matches the package count line in the README * * 匹配 README 中的包数量行 */ export const README_COUNT_PATTERN = /^This repo contains \d+ official plugins?, \d+ official themes? and \d+ tool packages?\.$/mu const pluralize = (count: number, singular: string, plural: string): string => count === 1 ? singular : plural /** * Format the package count line of the README * * 生成 README 中的包数量行 * * @example * formatPackageCountLine({ plugins: 62, themes: 2, tools: 8 }) * // => 'This repo contains 62 official plugins, 2 official themes and 8 tool packages.' * * @param counts - The package counts / 包数量 * @returns The formatted line / 生成的行 */ export const formatPackageCountLine = ({ plugins, themes, tools, }: PackageCounts): string => `This repo contains ${plugins} official ${pluralize(plugins, 'plugin', 'plugins')}, ${themes} official ${pluralize(themes, 'theme', 'themes')} and ${tools} ${pluralize(tools, 'tool package', 'tool packages')}.`