Skip to content

Commit 701598b

Browse files
committed
test(ci-e2e): set up nx monorepo fixture and test push event
1 parent 6a6c2f3 commit 701598b

22 files changed

+246
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { resolveConfig } from '../../code-pushup.preset.js';
2+
3+
export default resolveConfig(import.meta.url);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "api",
3+
"projectType": "application",
4+
"targets": {
5+
"code-pushup": {
6+
"command": "npx @code-pushup/cli --no-progress --config=apps/api/code-pushup.config.js"
7+
}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello, world!');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { resolveConfig } from '../../code-pushup.preset.js';
2+
3+
export default resolveConfig(import.meta.url);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "cms",
3+
"projectType": "application",
4+
"targets": {
5+
"code-pushup": {
6+
"command": "npx @code-pushup/cli --no-progress --config=apps/cms/code-pushup.config.js"
7+
}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello, world!');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { resolveConfig } from '../../code-pushup.preset.js';
2+
3+
export default resolveConfig(import.meta.url);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "web",
3+
"projectType": "application",
4+
"targets": {
5+
"code-pushup": {
6+
"command": "npx @code-pushup/cli --no-progress --config=apps/web/code-pushup.config.js"
7+
}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello, world!');
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { crawlFileSystem } from '@code-pushup/utils';
4+
5+
export function resolveConfig(url) {
6+
const directory = fileURLToPath(dirname(url));
7+
return {
8+
persist: {
9+
outputDir: join(directory, '.code-pushup'),
10+
},
11+
plugins: [
12+
{
13+
slug: 'ts-migration',
14+
title: 'TypeScript migration',
15+
icon: 'typescript',
16+
audits: [
17+
{
18+
slug: 'ts-files',
19+
title: 'Source files converted from JavaScript to TypeScript',
20+
},
21+
],
22+
runner: async () => {
23+
const paths = await crawlFileSystem({
24+
directory,
25+
pattern: /\.[jt]s$/,
26+
});
27+
const jsPaths = paths.filter(path => path.endsWith('.js'));
28+
const tsPaths = paths.filter(path => path.endsWith('.ts'));
29+
const jsFileCount = jsPaths.length;
30+
const tsFileCount = tsPaths.length;
31+
const ratio = tsFileCount / (jsFileCount + tsFileCount);
32+
const percentage = Math.round(ratio * 100);
33+
return [
34+
{
35+
slug: 'ts-files',
36+
value: percentage,
37+
score: ratio,
38+
displayValue: `${percentage}% converted`,
39+
details: {
40+
issues: jsPaths.map(file => ({
41+
message: 'Use .ts file extension instead of .js',
42+
severity: 'warning',
43+
source: { file },
44+
})),
45+
},
46+
},
47+
];
48+
},
49+
},
50+
],
51+
categories: [
52+
{
53+
slug: 'ts-migration',
54+
title: 'TypeScript migration',
55+
refs: [
56+
{
57+
type: 'audit',
58+
plugin: 'ts-migration',
59+
slug: 'ts-files',
60+
weight: 1,
61+
},
62+
],
63+
},
64+
],
65+
};
66+
}

0 commit comments

Comments
 (0)