Skip to content

Commit d726b1f

Browse files
committed
Merge branch 'main' into extend-utils
# Conflicts: # packages/utils/src/index.ts
2 parents 15057fc + 3dcc4b1 commit d726b1f

129 files changed

Lines changed: 4341 additions & 254 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code-pushup.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { z } from 'zod';
33
import {
44
coverageCoreConfigNx,
55
eslintCoreConfigNx,
6+
jsDocsCoreConfig,
67
jsPackagesCoreConfig,
78
lighthouseCoreConfig,
89
} from './code-pushup.preset.js';
@@ -39,4 +40,12 @@ export default mergeConfigs(
3940
'https://github.com/code-pushup/cli?tab=readme-ov-file#code-pushup-cli/',
4041
),
4142
await eslintCoreConfigNx(),
43+
jsDocsCoreConfig([
44+
'packages/**/src/**/*.ts',
45+
'!packages/**/node_modules',
46+
'!packages/**/{mocks,mock}',
47+
'!**/*.{spec,test}.ts',
48+
'!**/implementation/**',
49+
'!**/internal/**',
50+
]),
4251
);

code-pushup.preset.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ import eslintPlugin, {
1010
eslintConfigFromNxProject,
1111
} from './packages/plugin-eslint/src/index.js';
1212
import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js';
13+
import jsDocsPlugin, {
14+
JsDocsPluginConfig,
15+
} from './packages/plugin-jsdocs/src/index.js';
16+
import {
17+
PLUGIN_SLUG,
18+
groups,
19+
} from './packages/plugin-jsdocs/src/lib/constants.js';
20+
import { filterGroupsByOnlyAudits } from './packages/plugin-jsdocs/src/lib/utils.js';
1321
import lighthousePlugin, {
1422
lighthouseGroupRef,
1523
} from './packages/plugin-lighthouse/src/index.js';
@@ -82,6 +90,24 @@ export const eslintCategories: CategoryConfig[] = [
8290
},
8391
];
8492

93+
export function getJsDocsCategories(
94+
config: JsDocsPluginConfig,
95+
): CategoryConfig[] {
96+
return [
97+
{
98+
slug: 'docs',
99+
title: 'Documentation',
100+
description: 'Measures how much of your code is **documented**.',
101+
refs: filterGroupsByOnlyAudits(groups, config).map(group => ({
102+
weight: 1,
103+
type: 'group',
104+
plugin: PLUGIN_SLUG,
105+
slug: group.slug,
106+
})),
107+
},
108+
];
109+
}
110+
85111
export const coverageCategories: CategoryConfig[] = [
86112
{
87113
slug: 'code-coverage',
@@ -114,6 +140,19 @@ export const lighthouseCoreConfig = async (
114140
};
115141
};
116142

143+
export const jsDocsCoreConfig = (
144+
config: JsDocsPluginConfig | string[],
145+
): CoreConfig => {
146+
return {
147+
plugins: [
148+
jsDocsPlugin(Array.isArray(config) ? { patterns: config } : config),
149+
],
150+
categories: getJsDocsCategories(
151+
Array.isArray(config) ? { patterns: config } : config,
152+
),
153+
};
154+
};
155+
117156
export const eslintCoreConfigNx = async (
118157
projectName?: string,
119158
): Promise<CoreConfig> => {

e2e/nx-plugin-e2e/tests/executor-cli.e2e.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { type Tree, updateProjectConfiguration } from '@nx/devkit';
22
import path from 'node:path';
33
import { readProjectConfiguration } from 'nx/src/generators/utils/project-configuration';
44
import { afterEach, expect } from 'vitest';
5-
import { generateCodePushupConfig } from '@code-pushup/nx-plugin';
5+
import {
6+
type AutorunCommandExecutorOptions,
7+
generateCodePushupConfig,
8+
} from '@code-pushup/nx-plugin';
69
import {
710
generateWorkspaceAndProject,
811
materializeTree,
@@ -20,6 +23,7 @@ import { INLINE_PLUGIN } from './inline-plugin.js';
2023
async function addTargetToWorkspace(
2124
tree: Tree,
2225
options: { cwd: string; project: string },
26+
executorOptions?: AutorunCommandExecutorOptions,
2327
) {
2428
const { cwd, project } = options;
2529
const projectCfg = readProjectConfiguration(tree, project);
@@ -29,6 +33,7 @@ async function addTargetToWorkspace(
2933
...projectCfg.targets,
3034
'code-pushup': {
3135
executor: '@code-pushup/nx-plugin:cli',
36+
...(executorOptions && { options: executorOptions }),
3237
},
3338
},
3439
});
@@ -95,6 +100,42 @@ describe('executor command', () => {
95100
).rejects.toThrow('');
96101
});
97102

103+
it('should execute collect executor and merge target and command-line options', async () => {
104+
const cwd = path.join(testFileDir, 'execute-collect-with-merged-options');
105+
await addTargetToWorkspace(
106+
tree,
107+
{ cwd, project },
108+
{
109+
persist: {
110+
outputDir: '.reports',
111+
filename: 'report',
112+
},
113+
},
114+
);
115+
116+
const { stdout, code } = await executeProcess({
117+
command: 'npx',
118+
args: [
119+
'nx',
120+
'run',
121+
`${project}:code-pushup`,
122+
'collect',
123+
'--persist.filename=terminal-report',
124+
],
125+
cwd,
126+
});
127+
128+
expect(code).toBe(0);
129+
const cleanStdout = removeColorCodes(stdout);
130+
expect(cleanStdout).toContain(
131+
'nx run my-lib:code-pushup collect --persist.filename=terminal-report',
132+
);
133+
134+
await expect(
135+
readJsonFile(path.join(cwd, '.reports', 'terminal-report.json')),
136+
).resolves.not.toThrow();
137+
});
138+
98139
it('should execute collect executor and add report to sub folder named by project', async () => {
99140
const cwd = path.join(testFileDir, 'execute-collect-command');
100141
await addTargetToWorkspace(tree, { cwd, project });
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tseslint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
3+
4+
export default tseslint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import jsDocsPlugin from '@code-pushup/jsdocs-plugin';
2+
3+
export default {
4+
plugins: [jsDocsPlugin(['**/*.ts'])],
5+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
h1 {
2+
color: #336699;
3+
text-align: center;
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>{{ title }}</h1>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function notRealisticFunction() {
2+
return 'notRealisticFunction';
3+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Basic Angular component that displays a welcome message
3+
*/
4+
export class AppComponent {
5+
protected readonly title = 'My Angular App';
6+
7+
/**
8+
* Dummy method that returns a welcome message
9+
* @returns {string} - The welcome message
10+
*/
11+
getWelcomeMessage() {
12+
return 'Welcome to My Angular App!';
13+
}
14+
15+
sendEvent() {
16+
return 'Event sent';
17+
}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const someVariable = 'Hello World 1';
2+
3+
export function mapEventToCustomEvent(event: string) {
4+
return event;
5+
}
6+
7+
/** Commented */
8+
export function mapCustomEventToEvent(event: string) {
9+
return event;
10+
}

0 commit comments

Comments
 (0)