-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcode-pushup.config.ts
126 lines (118 loc) · 2.92 KB
/
code-pushup.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import 'dotenv/config';
import { join } from 'node:path';
import { z } from 'zod';
import {
LIGHTHOUSE_OUTPUT_FILE_DEFAULT,
fileSizePlugin,
fileSizeRecommendedRefs,
lighthouseCorePerfGroupRefs,
lighthousePlugin,
packageJsonDocumentationGroupRef,
packageJsonPerformanceGroupRef,
packageJsonPlugin,
} from './dist/examples/plugins';
import coveragePlugin, {
getNxCoveragePaths,
} from './dist/packages/plugin-coverage';
import eslintPlugin, {
eslintConfigFromNxProjects,
} from './dist/packages/plugin-eslint';
import type { CoreConfig } from './packages/models/src';
// load upload configuration from environment
const envSchema = z
.object({
CP_SERVER: z.string().url(),
CP_API_KEY: z.string().min(1),
CP_ORGANIZATION: z.string().min(1),
CP_PROJECT: z.string().min(1),
})
.partial();
const env = await envSchema.parseAsync(process.env);
const config: CoreConfig = {
persist: {
outputDir: '.code-pushup',
filename: 'report',
format: ['json', 'md'],
},
...(env.CP_SERVER &&
env.CP_API_KEY &&
env.CP_ORGANIZATION &&
env.CP_PROJECT && {
upload: {
server: env.CP_SERVER,
apiKey: env.CP_API_KEY,
organization: env.CP_ORGANIZATION,
project: env.CP_PROJECT,
},
}),
plugins: [
await eslintPlugin(await eslintConfigFromNxProjects()),
await coveragePlugin({
coverageToolCommand: {
command: 'npx',
args: [
'nx',
'run-many',
'-t',
'unit-test',
'integration-test',
'--coverage',
'--skipNxCache',
],
},
reports: await getNxCoveragePaths(['unit-test', 'integration-test']),
}),
fileSizePlugin({
directory: './dist/examples/react-todos-app',
pattern: /\.js$/,
budget: 174_080, // 170 kB
}),
packageJsonPlugin({
directory: './dist/packages',
license: 'MIT',
type: 'module',
}),
await lighthousePlugin({
url: 'https://staging.code-pushup.dev/login',
outputPath: join('.code-pushup', LIGHTHOUSE_OUTPUT_FILE_DEFAULT),
headless: true,
}),
],
categories: [
{
slug: 'bug-prevention',
title: 'Bug prevention',
refs: [{ type: 'group', plugin: 'eslint', slug: 'problems', weight: 1 }],
},
{
slug: 'code-style',
title: 'Code style',
refs: [
{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
],
},
{
slug: 'code-coverage',
title: 'Code coverage',
refs: [
{
type: 'group',
plugin: 'coverage',
slug: 'coverage',
weight: 1,
},
],
},
{
slug: 'custom-checks',
title: 'Custom checks',
refs: [
...fileSizeRecommendedRefs,
packageJsonPerformanceGroupRef,
packageJsonDocumentationGroupRef,
...lighthouseCorePerfGroupRefs,
],
},
],
};
export default config;