Skip to content

Commit c1dc139

Browse files
authored
Merge 20aeeb3 into a72e87c
2 parents a72e87c + 20aeeb3 commit c1dc139

Some content is hidden

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

43 files changed

+315
-797
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type Tree, updateProjectConfiguration } from '@nx/devkit';
22
import path from 'node:path';
33
import { readProjectConfiguration } from 'nx/src/generators/utils/project-configuration';
4-
import { afterAll, afterEach, beforeEach, expect, vi } from 'vitest';
4+
import { afterAll, afterEach, beforeEach, expect } from 'vitest';
55
import {
66
type AutorunCommandExecutorOptions,
77
generateCodePushupConfig,
@@ -17,7 +17,7 @@ import {
1717
removeColorCodes,
1818
teardownTestFolder,
1919
} from '@code-pushup/test-utils';
20-
import { executeProcess, readJsonFile } from '@code-pushup/utils';
20+
import { executeProcess, logger, readJsonFile } from '@code-pushup/utils';
2121
import { INLINE_PLUGIN } from '../mocks/inline-plugin.js';
2222

2323
async function addTargetToWorkspace(
@@ -62,15 +62,16 @@ describe('executor command', () => {
6262
Object.entries(process.env).filter(([k]) => k.startsWith('CP_')),
6363
);
6464

65-
/* eslint-disable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
6665
beforeAll(() => {
6766
Object.entries(process.env)
6867
.filter(([k]) => k.startsWith('CP_'))
69-
.forEach(([k]) => delete process.env[k]);
68+
.forEach(([k]) => {
69+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-dynamic-delete
70+
delete process.env[k];
71+
});
7072
});
7173

7274
beforeEach(async () => {
73-
vi.unstubAllEnvs();
7475
tree = await generateWorkspaceAndProject(project);
7576
});
7677

@@ -79,9 +80,11 @@ describe('executor command', () => {
7980
});
8081

8182
afterAll(() => {
82-
Object.entries(processEnvCP).forEach(([k, v]) => (process.env[k] = v));
83+
Object.entries(processEnvCP).forEach(([k, v]) => {
84+
// eslint-disable-next-line functional/immutable-data
85+
process.env[k] = v;
86+
});
8387
});
84-
/* eslint-enable functional/immutable-data, @typescript-eslint/no-dynamic-delete */
8588

8689
it('should execute no specific command by default', async () => {
8790
const cwd = path.join(testFileDir, 'execute-default-command');
@@ -179,6 +182,7 @@ describe('executor command', () => {
179182
},
180183
},
181184
);
185+
logger.setVerbose(true);
182186

183187
const { stdout, code } = await executeProcess({
184188
command: 'npx',

packages/ci/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ Optionally, you can override default options for further customization:
103103
| `nxProjectsFilter` | `string \| string[]` | `'--with-target={task}'` | Arguments passed to [`nx show projects`](https://nx.dev/nx-api/nx/documents/show#projects), only relevant for Nx in [monorepo mode](#monorepo-mode) [^2] |
104104
| `directory` | `string` | `process.cwd()` | Directory in which Code PushUp CLI should run |
105105
| `config` | `string \| null` | `null` [^1] | Path to config file (`--config` option) |
106-
| `silent` | `boolean` | `false` | Hides logs from CLI commands (errors will be printed) |
107106
| `bin` | `string` | `'npx --no-install code-pushup'` | Command for executing Code PushUp CLI |
108107
| `detectNewIssues` | `boolean` | `true` | Toggles if new issues should be detected and returned in `newIssues` property |
109108
| `skipComment` | `boolean` | `false` | Toggles if comparison comment is posted to PR |

packages/ci/src/lib/cli/commands/collect.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { executeProcess } from '@code-pushup/utils';
33
import type { CommandContext } from '../context.js';
44

55
export async function runCollect(
6-
{ bin, config, directory, observer }: CommandContext,
6+
{ bin, config, directory }: CommandContext,
77
{ hasFormats }: { hasFormats: boolean },
88
): Promise<void> {
99
await executeProcess({
@@ -15,6 +15,5 @@ export async function runCollect(
1515
: DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`)),
1616
],
1717
cwd: directory,
18-
observer,
1918
});
2019
}

packages/ci/src/lib/cli/commands/compare.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { executeProcess } from '@code-pushup/utils';
33
import type { CommandContext } from '../context.js';
44

55
export async function runCompare(
6-
{ bin, config, directory, observer }: CommandContext,
6+
{ bin, config, directory }: CommandContext,
77
{ hasFormats }: { hasFormats: boolean },
88
): Promise<void> {
99
await executeProcess({
@@ -16,6 +16,5 @@ export async function runCompare(
1616
: DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`)),
1717
],
1818
cwd: directory,
19-
observer,
2019
});
2120
}

packages/ci/src/lib/cli/commands/merge-diffs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { CommandContext } from '../context.js';
88

99
export async function runMergeDiffs(
1010
files: string[],
11-
{ bin, config, directory, observer }: CommandContext,
11+
{ bin, config, directory }: CommandContext,
1212
): Promise<string> {
1313
const outputDir = path.join(directory, DEFAULT_PERSIST_OUTPUT_DIR);
1414
const filename = `merged-${DEFAULT_PERSIST_FILENAME}`;
@@ -23,7 +23,6 @@ export async function runMergeDiffs(
2323
`--persist.filename=${filename}`,
2424
],
2525
cwd: directory,
26-
observer,
2726
});
2827

2928
return path.join(outputDir, `${filename}-diff.md`);

packages/ci/src/lib/cli/commands/print-config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export async function runPrintConfig({
1212
config,
1313
directory,
1414
project,
15-
observer,
1615
}: CommandContext): Promise<unknown> {
1716
// unique file name per project so command can be run in parallel
1817
const outputFile = ['code-pushup', 'config', project, 'json']
@@ -33,7 +32,6 @@ export async function runPrintConfig({
3332
`--output=${outputPath}`,
3433
],
3534
cwd: directory,
36-
observer,
3735
});
3836

3937
try {

packages/ci/src/lib/cli/context.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import type { ProcessObserver } from '@code-pushup/utils';
2-
import { createExecutionObserver } from '../create-execution-observer.js';
31
import type { Settings } from '../models.js';
42
import type { ProjectConfig } from '../monorepo/index.js';
53

64
export type CommandContext = Pick<Settings, 'bin' | 'config' | 'directory'> & {
75
project?: string;
8-
observer?: ProcessObserver;
96
};
107

118
export function createCommandContext(
12-
{ config, bin, directory, silent }: Settings,
9+
{ config, bin, directory }: Settings,
1310
project: ProjectConfig | null | undefined,
1411
): CommandContext {
1512
return {
1613
bin: project?.bin ?? bin,
1714
directory: project?.directory ?? directory,
1815
config,
1916
...(project?.name && { project: project.name }),
20-
observer: createExecutionObserver({ silent }),
2117
};
2218
}

packages/ci/src/lib/cli/context.unit.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@ import { expect } from 'vitest';
22
import { type CommandContext, createCommandContext } from './context.js';
33

44
describe('createCommandContext', () => {
5-
const expectedObserver = expect.objectContaining({
6-
onStderr: expect.any(Function),
7-
onStdout: expect.any(Function),
8-
});
9-
105
it('should pick CLI-related settings in standalone mode', () => {
116
expect(
127
createCommandContext(
138
{
149
bin: 'npx --no-install code-pushup',
1510
config: null,
16-
debug: false,
1711
detectNewIssues: true,
1812
directory: '/test',
19-
logger: console,
2013
monorepo: false,
2114
parallel: false,
2215
nxProjectsFilter: '--with-target={task}',
2316
projects: null,
24-
silent: false,
2517
task: 'code-pushup',
2618
skipComment: false,
2719
configPatterns: null,
20+
searchCommits: false,
2821
},
2922
null,
3023
),
3124
).toStrictEqual<CommandContext>({
3225
bin: 'npx --no-install code-pushup',
3326
directory: '/test',
3427
config: null,
35-
observer: expectedObserver,
3628
});
3729
});
3830

@@ -42,18 +34,16 @@ describe('createCommandContext', () => {
4234
{
4335
bin: 'npx --no-install code-pushup',
4436
config: null,
45-
debug: false,
4637
detectNewIssues: true,
4738
directory: '/test',
48-
logger: console,
4939
monorepo: false,
5040
parallel: false,
5141
nxProjectsFilter: '--with-target={task}',
5242
projects: null,
53-
silent: false,
5443
task: 'code-pushup',
5544
skipComment: false,
5645
configPatterns: null,
46+
searchCommits: false,
5747
},
5848
{
5949
name: 'ui',
@@ -66,7 +56,6 @@ describe('createCommandContext', () => {
6656
directory: '/test/ui',
6757
config: null,
6858
project: 'ui',
69-
observer: expectedObserver,
7059
});
7160
});
7261
});

packages/ci/src/lib/create-execution-observer.int.test.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/ci/src/lib/create-execution-observer.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)