Skip to content

Commit 4268ecc

Browse files
author
John Doe
committed
Merge branch 'refs/heads/main' into refactor/utils/command-helper
2 parents 9a5eb15 + f335d20 commit 4268ecc

Some content is hidden

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

47 files changed

+1957
-466
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
## 0.81.0 (2025-10-22)
2+
3+
### 🚀 Features
4+
5+
- **utils:** add utility for rounding to max decimals, use in formatDuration ([be80d99c](https://github.com/code-pushup/cli/commit/be80d99c))
6+
- **utils:** add settlePromise helper for convenient rejected promise handling ([9fa7df9e](https://github.com/code-pushup/cli/commit/9fa7df9e))
7+
- **utils:** add unix timestamp conversion ([b95877e9](https://github.com/code-pushup/cli/commit/b95877e9))
8+
- **utils:** implement custom logger with groups and tasks ([3d158ff6](https://github.com/code-pushup/cli/commit/3d158ff6))
9+
- **utils:** throw if invalid group/spinner combinations used in logger ([899ab764](https://github.com/code-pushup/cli/commit/899ab764))
10+
- **utils:** export shared logger instance ([009bc0eb](https://github.com/code-pushup/cli/commit/009bc0eb))
11+
12+
### 🩹 Fixes
13+
14+
- **utils:** ensure multiline logs during spinner are indented properly ([2ca91c08](https://github.com/code-pushup/cli/commit/2ca91c08))
15+
- **utils:** avoid formatting milliseconds with decimals ([3c22e5d0](https://github.com/code-pushup/cli/commit/3c22e5d0))
16+
17+
### ❤️ Thank You
18+
19+
- Matěj Chalk
20+
121
## 0.80.2 (2025-09-26)
222

323
### 🩹 Fixes

e2e/nx-plugin-e2e/tests/__snapshots__/plugin-create-nodes.e2e.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`nx-plugin > should add configuration target dynamically 1`] = `
1717
"configurations": {},
1818
"executor": "nx:run-commands",
1919
"options": {
20-
"command": "nx g @code-pushup/nx-plugin:configuration --skipTarget --targetName="code-pushup" --project="my-lib"",
20+
"command": "nx g @code-pushup/nx-plugin:configuration --project="my-lib"",
2121
},
2222
"parallelism": true,
2323
},

e2e/nx-plugin-e2e/tests/generator-configuration.e2e.test.ts

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('nx-plugin g configuration', () => {
3535
await teardownTestFolder(testFileDir);
3636
});
3737

38-
it('should generate code-pushup.config.ts file and add target to project.json', async () => {
38+
it('should generate code-pushup.config.ts file', async () => {
3939
const cwd = path.join(testFileDir, 'configure');
4040
await materializeTree(tree, cwd);
4141

@@ -64,22 +64,7 @@ describe('nx-plugin g configuration', () => {
6464
'NX Generating @code-pushup/nx-plugin:configuration',
6565
);
6666
expect(cleanedStdout).toMatch(/^CREATE.*code-pushup.config.ts/m);
67-
expect(cleanedStdout).toMatch(/^UPDATE.*project.json/m);
6867

69-
const projectJson = await readFile(
70-
path.join(cwd, 'libs', project, 'project.json'),
71-
'utf8',
72-
);
73-
74-
expect(JSON.parse(projectJson)).toStrictEqual(
75-
expect.objectContaining({
76-
targets: expect.objectContaining({
77-
'code-pushup': {
78-
executor: '@code-pushup/nx-plugin:cli',
79-
},
80-
}),
81-
}),
82-
);
8368
await expect(
8469
readFile(
8570
path.join(cwd, 'libs', project, 'code-pushup.config.ts'),
@@ -111,21 +96,6 @@ describe('nx-plugin g configuration', () => {
11196
'NX Generating @code-pushup/nx-plugin:configuration',
11297
);
11398
expect(cleanedStdout).not.toMatch(/^CREATE.*code-pushup.config.ts/m);
114-
expect(cleanedStdout).toMatch(/^UPDATE.*project.json/m);
115-
116-
const projectJson = await readFile(
117-
path.join(cwd, 'libs', project, 'project.json'),
118-
'utf8',
119-
);
120-
expect(JSON.parse(projectJson)).toStrictEqual(
121-
expect.objectContaining({
122-
targets: expect.objectContaining({
123-
'code-pushup': {
124-
executor: '@code-pushup/nx-plugin:cli',
125-
},
126-
}),
127-
}),
128-
);
12999
});
130100

131101
it('should NOT create a code-pushup.config.ts file if skipConfig is given', async () => {
@@ -152,21 +122,6 @@ describe('nx-plugin g configuration', () => {
152122
'NX Generating @code-pushup/nx-plugin:configuration',
153123
);
154124
expect(cleanedStdout).not.toMatch(/^CREATE.*code-pushup.config.ts/m);
155-
expect(cleanedStdout).toMatch(/^UPDATE.*project.json/m);
156-
157-
const projectJson = await readFile(
158-
path.join(cwd, 'libs', project, 'project.json'),
159-
'utf8',
160-
);
161-
expect(JSON.parse(projectJson)).toStrictEqual(
162-
expect.objectContaining({
163-
targets: expect.objectContaining({
164-
'code-pushup': {
165-
executor: '@code-pushup/nx-plugin:cli',
166-
},
167-
}),
168-
}),
169-
);
170125

171126
await expect(
172127
readFile(
@@ -176,53 +131,6 @@ describe('nx-plugin g configuration', () => {
176131
).rejects.toThrow('no such file or directory');
177132
});
178133

179-
it('should NOT add target to project.json if skipTarget is given', async () => {
180-
const cwd = path.join(testFileDir, 'configure-skip-target');
181-
await materializeTree(tree, cwd);
182-
183-
const { code, stdout } = await executeProcess({
184-
command: 'npx',
185-
args: [
186-
'nx',
187-
'g',
188-
'@code-pushup/nx-plugin:configuration',
189-
project,
190-
'--skipTarget',
191-
],
192-
cwd,
193-
});
194-
expect(code).toBe(0);
195-
196-
const cleanedStdout = removeColorCodes(stdout);
197-
198-
expect(cleanedStdout).toContain(
199-
'NX Generating @code-pushup/nx-plugin:configuration',
200-
);
201-
expect(cleanedStdout).toMatch(/^CREATE.*code-pushup.config.ts/m);
202-
expect(cleanedStdout).not.toMatch(/^UPDATE.*project.json/m);
203-
204-
const projectJson = await readFile(
205-
path.join(cwd, 'libs', project, 'project.json'),
206-
'utf8',
207-
);
208-
expect(JSON.parse(projectJson)).toStrictEqual(
209-
expect.objectContaining({
210-
targets: expect.not.objectContaining({
211-
'code-pushup': {
212-
executor: '@code-pushup/nx-plugin:cli',
213-
},
214-
}),
215-
}),
216-
);
217-
218-
await expect(
219-
readFile(
220-
path.join(cwd, 'libs', project, 'code-pushup.config.ts'),
221-
'utf8',
222-
),
223-
).resolves.toStrictEqual(expect.any(String));
224-
});
225-
226134
it('should inform about dry run', async () => {
227135
const cwd = path.join(testFileDir, 'configure');
228136
await materializeTree(tree, cwd);

e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('nx-plugin', () => {
5151
configurations: {},
5252
executor: 'nx:run-commands',
5353
options: {
54-
command: `nx g @code-pushup/nx-plugin:configuration --skipTarget --targetName="code-pushup" --project="${project}"`,
54+
command: `nx g @code-pushup/nx-plugin:configuration --project="${project}"`,
5555
},
5656
parallelism: true,
5757
},
@@ -120,7 +120,7 @@ describe('nx-plugin', () => {
120120
expect(projectJson.targets).toStrictEqual({
121121
'code-pushup--configuration': expect.objectContaining({
122122
options: {
123-
command: `nx g XYZ:configuration --skipTarget --targetName="code-pushup" --project="${project}"`,
123+
command: `nx g XYZ:configuration --project="${project}"`,
124124
},
125125
}),
126126
});

examples/plugins/src/file-size/src/file-size.plugin.int.test.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { vol } from 'memfs';
2-
import { beforeEach, describe, expect, it } from 'vitest';
1+
import { mkdir, rm, writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { describe, expect, it } from 'vitest';
34
import { executePlugin } from '@code-pushup/core';
45
import {
56
auditSchema,
67
categoryRefSchema,
78
pluginConfigSchema,
89
} from '@code-pushup/models';
9-
import { MEMFS_VOLUME } from '@code-pushup/test-utils';
1010
import {
1111
type PluginOptions,
1212
audits,
@@ -27,24 +27,31 @@ const projectJson = JSON.stringify(
2727
2,
2828
);
2929
const testJs = `
30-
const str = 'Hello World'
31-
const num = 42;
32-
const obj = ${projectJson};
33-
`;
30+
const str = 'Hello World';
31+
const num = 42;
32+
const obj = ${projectJson};
33+
`;
3434

3535
describe('create', () => {
36+
const workDir = path.join(
37+
'tmp',
38+
'int-tests',
39+
'examples-plugins',
40+
'package-json',
41+
);
42+
3643
const baseOptions: PluginOptions = {
37-
directory: '/',
44+
directory: workDir,
3845
};
3946

40-
beforeEach(() => {
41-
vol.fromJSON(
42-
{
43-
'project.json': projectJson,
44-
'src/test.js': testJs,
45-
},
46-
MEMFS_VOLUME,
47-
);
47+
beforeAll(async () => {
48+
await mkdir(workDir, { recursive: true });
49+
await writeFile(path.join(workDir, 'project.json'), projectJson);
50+
await writeFile(path.join(workDir, 'test.js'), testJs);
51+
});
52+
53+
afterAll(async () => {
54+
await rm(workDir, { recursive: true, force: true });
4855
});
4956

5057
it('should return valid PluginConfig', () => {

examples/plugins/src/package-json/src/package-json.plugin.int.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { vol } from 'memfs';
1+
import { mkdir, rm, writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
23
import { describe, expect, it } from 'vitest';
34
import { executePlugin } from '@code-pushup/core';
45
import {
@@ -7,7 +8,6 @@ import {
78
pluginConfigSchema,
89
pluginReportSchema,
910
} from '@code-pushup/models';
10-
import { MEMFS_VOLUME } from '@code-pushup/test-utils';
1111
import { audits, pluginSlug as slug } from './constants.js';
1212
import { type PluginOptions, create } from './package-json.plugin.js';
1313
import {
@@ -18,17 +18,24 @@ import {
1818
} from './scoring.js';
1919

2020
describe('create-package-json', () => {
21+
const workDir = path.join(
22+
'tmp',
23+
'int-tests',
24+
'examples-plugins',
25+
'package-json',
26+
);
27+
2128
const baseOptions: PluginOptions = {
22-
directory: '/',
29+
directory: workDir,
2330
};
2431

25-
beforeEach(() => {
26-
vol.fromJSON(
27-
{
28-
'package.json': '{}',
29-
},
30-
MEMFS_VOLUME,
31-
);
32+
beforeAll(async () => {
33+
await mkdir(workDir, { recursive: true });
34+
await writeFile(path.join(workDir, 'package.json'), '{}');
35+
});
36+
37+
afterAll(async () => {
38+
await rm(workDir, { recursive: true, force: true });
3239
});
3340

3441
it('should return valid PluginConfig', () => {

examples/plugins/vitest.int.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default defineConfig({
2222
include: ['src/**/*.int.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2323
globalSetup: ['../../global-setup.ts'],
2424
setupFiles: [
25-
'../../testing/test-setup/src/lib/fs.mock.ts',
2625
'../../testing/test-setup/src/lib/git.mock.ts',
2726
'../../testing/test-setup/src/lib/console.mock.ts',
2827
'../../testing/test-setup/src/lib/reset.mocks.ts',

0 commit comments

Comments
 (0)