Skip to content

Commit bd1b8e1

Browse files
committed
cherry-pick
1 parent 7e6c29d commit bd1b8e1

File tree

13 files changed

+130
-125
lines changed

13 files changed

+130
-125
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
- name: E2E test affected projects
123123
run: npx nx affected -t nxv-e2e --exclude cli-e2e --parallel=1
124124
- name: E2E test cli-e2e project (due to bugs in the setup it has to run last :( )
125-
run: npx nx run cli-e2e:e2e-old
125+
run: npx nx run cli-e2e:nxv-e2e
126126

127127
build:
128128
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ node_modules
3333
/connect.lock
3434
/coverage
3535
/examples/react-todos-app/coverage
36+
/examples/react-todos-app/package.json
37+
/examples/react-todos-app/package-lock.json
3638
/libpeerconnection.log
3739
npm-debug.log
3840
yarn-error.log

e2e/cli-e2e/project.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111
"lintFilePatterns": ["e2e/cli-e2e/**/*.ts"]
1212
}
1313
},
14+
"nxv-env-setup": {
15+
"options": {
16+
"environmentRoot": "examples/react-todos-app"
17+
}
18+
},
1419
"e2e-old": {
1520
"executor": "@nx/vite:test",
1621
"options": {
17-
"configFile": "e2e/cli-e2e/vite.config.e2e.ts"
22+
"configFile": "e2e/cli-e2e/vite.config.e2e.ts",
23+
"environmentRoot": "examples/react-todos-app"
1824
}
1925
}
2026
},
2127
"implicitDependencies": [
22-
"models",
23-
"utils",
24-
"core",
2528
"cli",
2629
"plugin-eslint",
2730
"plugin-coverage",

e2e/cli-e2e/tests/collect.e2e.test.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ describe('CLI collect', () => {
5151

5252
it('should run ESLint plugin and create report.json', async () => {
5353
const { code, stderr } = await executeProcess({
54-
command: 'code-pushup',
55-
args: ['collect', '--no-progress', '--onlyPlugins=eslint'],
54+
command: 'npx',
55+
args: [
56+
'@code-pushup/cli',
57+
'collect',
58+
'--no-progress',
59+
'--onlyPlugins=eslint',
60+
],
5661
cwd: 'examples/react-todos-app',
5762
});
5863

@@ -83,14 +88,16 @@ describe('CLI collect', () => {
8388
);
8489

8590
const { code, stderr } = await executeProcess({
86-
command: 'code-pushup',
91+
command: 'npx',
8792
args: [
93+
'@code-pushup/cli',
8894
'collect',
8995
'--no-progress',
9096
`--config=${configPath}`,
9197
'--persist.outputDir=tmp/e2e',
9298
'--onlyPlugins=coverage',
9399
],
100+
cwd: 'examples/react-todos-app',
94101
});
95102

96103
expect(code).toBe(0);
@@ -104,8 +111,13 @@ describe('CLI collect', () => {
104111

105112
it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
106113
const { code, stderr } = await executeProcess({
107-
command: 'code-pushup',
108-
args: ['collect', '--no-progress', '--onlyPlugins=coverage'],
114+
command: 'npx',
115+
args: [
116+
'@code-pushup/cli',
117+
'collect',
118+
'--no-progress',
119+
'--onlyPlugins=coverage',
120+
],
109121
cwd: 'examples/react-todos-app',
110122
});
111123

@@ -120,8 +132,13 @@ describe('CLI collect', () => {
120132

121133
it('should create report.md', async () => {
122134
const { code, stderr } = await executeProcess({
123-
command: 'code-pushup',
124-
args: ['collect', '--persist.format=md', '--no-progress'],
135+
command: 'npx',
136+
args: [
137+
'@code-pushup/cli',
138+
'collect',
139+
'--persist.format=md',
140+
'--no-progress',
141+
],
125142
cwd: 'examples/react-todos-app',
126143
});
127144

@@ -137,8 +154,8 @@ describe('CLI collect', () => {
137154

138155
it('should print report summary to stdout', async () => {
139156
const { code, stdout, stderr } = await executeProcess({
140-
command: 'code-pushup',
141-
args: ['collect', '--no-progress'],
157+
command: 'npx',
158+
args: ['@code-pushup/cli', 'collect', '--no-progress'],
142159
cwd: 'examples/react-todos-app',
143160
});
144161

e2e/cli-e2e/tests/compare.e2e.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ describe('CLI compare', () => {
1414
}
1515
await cleanTestFolder('tmp/e2e/react-todos-app');
1616
await executeProcess({
17-
command: 'code-pushup',
17+
command: 'npx',
1818
args: [
19+
'@code-pushup/cli',
1920
'collect',
2021
'--persist.filename=source-report',
2122
'--onlyPlugins=eslint',
@@ -28,8 +29,9 @@ describe('CLI compare', () => {
2829
cwd: 'examples/react-todos-app',
2930
});
3031
await executeProcess({
31-
command: 'code-pushup',
32+
command: 'npx',
3233
args: [
34+
'@code-pushup/cli',
3335
'collect',
3436
'--persist.filename=target-report',
3537
'--onlyPlugins=eslint',
@@ -45,8 +47,9 @@ describe('CLI compare', () => {
4547

4648
it('should compare report.json files and create report-diff.json and report-diff.md', async () => {
4749
await executeProcess({
48-
command: 'code-pushup',
50+
command: 'npx',
4951
args: [
52+
'@code-pushup/cli',
5053
'compare',
5154
'--before=../../tmp/e2e/react-todos-app/source-report.json',
5255
'--after=../../tmp/e2e/react-todos-app/target-report.json',

e2e/cli-e2e/tests/help.e2e.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { executeProcess } from '@code-pushup/utils';
44
describe('CLI help', () => {
55
it('should print help with help command', async () => {
66
const { code, stdout, stderr } = await executeProcess({
7-
command: 'code-pushup',
8-
args: ['help'],
7+
command: 'npx',
8+
args: ['@code-pushup/cli', 'help'],
9+
cwd: 'examples/react-todos-app',
910
});
1011
expect(code).toBe(0);
1112
expect(stderr).toBe('');
@@ -14,12 +15,14 @@ describe('CLI help', () => {
1415

1516
it('should produce the same output to stdout for both help argument and help command', async () => {
1617
const helpArgResult = await executeProcess({
17-
command: 'code-pushup',
18-
args: ['help'],
18+
command: 'npx',
19+
args: ['@code-pushup/cli', 'help'],
20+
cwd: 'examples/react-todos-app',
1921
});
2022
const helpCommandResult = await executeProcess({
21-
command: 'code-pushup',
22-
args: ['--help'],
23+
command: 'npx',
24+
args: ['@code-pushup/cli', '--help'],
25+
cwd: 'examples/react-todos-app',
2326
});
2427
expect(helpArgResult.code).toBe(0);
2528
expect(helpCommandResult.code).toBe(0);

e2e/cli-e2e/tests/print-config.e2e.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,45 @@ const extensions = ['js', 'mjs', 'ts'] as const;
66
export const configFilePath = (ext: (typeof extensions)[number]) =>
77
join(process.cwd(), `e2e/cli-e2e/mocks/fixtures/code-pushup.config.${ext}`);
88

9-
describe('print-config', () => {
9+
describe('CLI print-config', () => {
1010
it.each(extensions)(
1111
'should load .%s config file with correct arguments',
1212
async ext => {
1313
const { code, stdout } = await executeProcess({
14-
command: 'code-pushup',
14+
command: 'npx',
1515
args: [
16+
'@code-pushup/cli',
1617
'print-config',
1718
'--no-progress',
18-
`--config=${configFilePath(ext)}`,
1919
'--tsconfig=tsconfig.base.json',
2020
'--persist.outputDir=output-dir',
2121
'--persist.format=md',
2222
`--persist.filename=${ext}-report`,
2323
'--onlyPlugins=coverage',
2424
],
25+
cwd: 'examples/react-todos-app',
2526
});
2627

2728
expect(code).toBe(0);
2829

2930
expect(JSON.parse(stdout)).toEqual(
3031
expect.objectContaining({
31-
config: expect.stringContaining(`code-pushup.config.${ext}`),
3232
tsconfig: 'tsconfig.base.json',
3333
// filled by command options
3434
persist: {
3535
outputDir: 'output-dir',
3636
filename: `${ext}-report`,
3737
format: ['md'],
3838
},
39-
upload: {
40-
organization: 'code-pushup',
41-
project: `cli-${ext}`,
42-
apiKey: 'e2e-api-key',
43-
server: 'https://e2e.com/api',
44-
},
45-
plugins: [
39+
plugins: expect.arrayContaining([
4640
expect.objectContaining({
4741
slug: 'coverage',
4842
title: 'Code coverage',
4943
}),
50-
],
51-
categories: [expect.objectContaining({ slug: 'code-coverage' })],
44+
]),
45+
categories: expect.arrayContaining([
46+
expect.objectContaining({ slug: 'code-coverage' }),
47+
]),
5248
onlyPlugins: ['coverage'],
5349
}),
5450
);

e2e/cli-e2e/vite.config.e2e.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default defineConfig({
1616
},
1717
environment: 'node',
1818
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19-
globalSetup: ['../../global-setup.e2e.ts'],
2019
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
2120
},
2221
});

examples/react-todos-app/.eslintrc.js

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es2021": true
6+
},
7+
"plugins": ["react", "react-hooks"],
8+
"overrides": [
9+
{
10+
"env": {
11+
"node": true
12+
},
13+
"files": [".eslintrc.{js,cjs}"],
14+
"parserOptions": {
15+
"sourceType": "script"
16+
}
17+
}
18+
],
19+
"parserOptions": {
20+
"ecmaVersion": "latest",
21+
"sourceType": "module",
22+
"ecmaFeatures": {
23+
"jsx": true
24+
}
25+
},
26+
"settings": {
27+
"react": {
28+
"version": "detect"
29+
}
30+
},
31+
"rules": {
32+
"no-cond-assign": "warn",
33+
"no-const-assign": "warn",
34+
"no-debugger": "warn",
35+
"no-invalid-regexp": "warn",
36+
"no-undef": "warn",
37+
"no-unreachable-loop": "warn",
38+
"no-unsafe-negation": "warn",
39+
"no-unsafe-optional-chaining": "warn",
40+
"no-unused-vars": "warn",
41+
"use-isnan": "warn",
42+
"valid-typeof": "warn",
43+
"arrow-body-style": "warn",
44+
"camelcase": "warn",
45+
"curly": "warn",
46+
"eqeqeq": "warn",
47+
"max-lines-per-function": "warn",
48+
"max-lines": "warn",
49+
"no-shadow": "warn",
50+
"no-var": "warn",
51+
"object-shorthand": "warn",
52+
"prefer-arrow-callback": "warn",
53+
"prefer-const": "warn",
54+
"prefer-object-spread": "warn",
55+
"yoda": "warn",
56+
"react/jsx-key": "warn",
57+
"react/prop-types": "warn",
58+
"react/react-in-jsx-scope": "warn",
59+
"react/jsx-uses-vars": "warn",
60+
"react/jsx-uses-react": "error",
61+
"react-hooks/rules-of-hooks": "error",
62+
"react-hooks/exhaustive-deps": "warn"
63+
}
64+
}

0 commit comments

Comments
 (0)