MCPcopy Index your code
hub / github.com/code-pushup/cli / addCategories

Function addCategories

packages/create-cli/src/lib/setup/codegen-categories.ts:15–43  ·  view source on GitHub ↗
(
  builder: CodeBuilder,
  plugins: PluginCodegenResult[],
  depth = 1,
)

Source from the content-addressed store, hash-verified

13};
14
15export function addCategories(
16 builder: CodeBuilder,
17 plugins: PluginCodegenResult[],
18 depth = 1,
19): void {
20 const categories = mergeCategoriesBySlug(
21 plugins.flatMap(p => p.categories ?? []).map(toMergedCategory),
22 );
23 if (categories.length === 0) {
24 return;
25 }
26 builder.addLine('categories: [', depth);
27 categories.forEach(
28 ({ slug, title, description, docsUrl, refs, refsExpressions }) => {
29 builder.addLine('{', depth + 1);
30 builder.addLine(`slug: '${slug}',`, depth + 2);
31 builder.addLine(`title: ${singleQuote(title)},`, depth + 2);
32 if (description) {
33 builder.addLine(`description: ${singleQuote(description)},`, depth + 2);
34 }
35 if (docsUrl) {
36 builder.addLine(`docsUrl: ${singleQuote(docsUrl)},`, depth + 2);
37 }
38 addCategoryRefs(builder, refs, refsExpressions, depth + 2);
39 builder.addLine('},', depth + 1);
40 },
41 );
42 builder.addLine('],', depth);
43}
44
45function toMergedCategory(category: CategoryCodegenConfig): MergedCategory {
46 return {

Callers 2

generateConfigSourceFunction · 0.85
addPresetExportFunction · 0.85

Calls 4

singleQuoteFunction · 0.90
addCategoryRefsFunction · 0.85
addLineMethod · 0.80
mergeCategoriesBySlugFunction · 0.70

Tested by

no test coverage detected