Skip to content

Commit 957c865

Browse files
committed
fix: adjust report logic
1 parent 44257f4 commit 957c865

File tree

14 files changed

+36
-41
lines changed

14 files changed

+36
-41
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ describe('CLI collect', () => {
6161
expect(md).toContain(dummyAuditTitle);
6262
});
6363

64-
it('should not create reports if --persist.no-report is given', async () => {
64+
it('should not create reports if --persist.skipReports is given', async () => {
6565
const { code } = await executeProcess({
6666
command: 'npx',
6767
args: [
6868
'@code-pushup/cli',
6969
'--no-progress',
7070
'collect',
71-
'--persist.no-report',
71+
'--persist.skipReports',
7272
],
7373
cwd: dummyDir,
7474
});

packages/ci/src/lib/run-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ export function configFromPatterns(
483483
outputDir: interpolate(persist.outputDir, variables),
484484
filename: interpolate(persist.filename, variables),
485485
format: persist.format,
486-
report: persist.report,
486+
skipReports: persist.skipReports,
487487
},
488488
...(upload && {
489489
upload: {

packages/cli/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,18 @@ Each example is fully tested to demonstrate best practices for plugin testing as
207207

208208
### Common Command Options
209209

210-
| Option | Type | Default | Description |
211-
| --------------------------- | -------------------- | -------- | -------------------------------------------------------------------------------- |
212-
| **`--persist.outputDir`** | `string` | n/a | Directory for the produced reports. |
213-
| **`--persist.filename`** | `string` | `report` | Filename for the produced reports without extension. |
214-
| **`--persist.format`** | `('json' \| 'md')[]` | `json` | Format(s) of the report file. |
215-
| **`--persist.report`** | `boolean` | `true` | Generate the report files for given formats. (useful in combination wit caching) |
216-
| **`--upload.organization`** | `string` | n/a | Organization slug from portal. |
217-
| **`--upload.project`** | `string` | n/a | Project slug from portal. |
218-
| **`--upload.server`** | `string` | n/a | URL to your portal server. |
219-
| **`--upload.apiKey`** | `string` | n/a | API key for the portal server. |
220-
| **`--onlyPlugins`** | `string[]` | `[]` | Only run the specified plugins. Applicable to all commands except `upload`. |
221-
| **`--skipPlugins`** | `string[]` | `[]` | Skip the specified plugins. Applicable to all commands except `upload`. |
210+
| Option | Type | Default | Description |
211+
| --------------------------- | -------------------- | -------- | --------------------------------------------------------------------------- |
212+
| **`--persist.outputDir`** | `string` | n/a | Directory for the produced reports. |
213+
| **`--persist.filename`** | `string` | `report` | Filename for the produced reports without extension. |
214+
| **`--persist.format`** | `('json' \| 'md')[]` | `json` | Format(s) of the report file. |
215+
| **`--persist.skipReports`** | `boolean` | `false` | Skip generating report files. (useful in combination wit caching) |
216+
| **`--upload.organization`** | `string` | n/a | Organization slug from portal. |
217+
| **`--upload.project`** | `string` | n/a | Project slug from portal. |
218+
| **`--upload.server`** | `string` | n/a | URL to your portal server. |
219+
| **`--upload.apiKey`** | `string` | n/a | API key for the portal server. |
220+
| **`--onlyPlugins`** | `string[]` | `[]` | Only run the specified plugins. Applicable to all commands except `upload`. |
221+
| **`--skipPlugins`** | `string[]` | `[]` | Skip the specified plugins. Applicable to all commands except `upload`. |
222222

223223
> [!NOTE]
224224
> All common options, except `--onlyPlugins` and `--skipPlugins`, can be specified in the configuration file as well.

packages/cli/src/lib/compare/compare-command.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('compare-command', () => {
4141
outputDir: DEFAULT_PERSIST_OUTPUT_DIR,
4242
filename: DEFAULT_PERSIST_FILENAME,
4343
format: DEFAULT_PERSIST_FORMAT,
44-
report: true,
44+
skipReports: false,
4545
},
4646
upload: expect.any(Object),
4747
},

packages/cli/src/lib/implementation/core-config.int.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('parsing values from CLI and middleware', () => {
6464
filename: DEFAULT_PERSIST_FILENAME,
6565
format: DEFAULT_PERSIST_FORMAT,
6666
outputDir: DEFAULT_PERSIST_OUTPUT_DIR,
67-
report: true,
67+
skipReports: false,
6868
});
6969
});
7070

@@ -86,7 +86,7 @@ describe('parsing values from CLI and middleware', () => {
8686
filename: 'cli-filename',
8787
format: ['md'],
8888
outputDir: 'cli-outputDir',
89-
report: true,
89+
skipReports: false,
9090
});
9191
});
9292

@@ -103,7 +103,7 @@ describe('parsing values from CLI and middleware', () => {
103103
filename: 'rc-filename',
104104
format: ['json', 'md'],
105105
outputDir: 'rc-outputDir',
106-
report: true,
106+
skipReports: false,
107107
});
108108
});
109109

@@ -125,7 +125,7 @@ describe('parsing values from CLI and middleware', () => {
125125
filename: 'cli-filename',
126126
format: ['md'],
127127
outputDir: 'cli-outputDir',
128-
report: true,
128+
skipReports: false,
129129
});
130130
});
131131

@@ -145,7 +145,7 @@ describe('parsing values from CLI and middleware', () => {
145145
filename: 'rc-filename',
146146
format: DEFAULT_PERSIST_FORMAT,
147147
outputDir: 'cli-outputdir',
148-
report: true,
148+
skipReports: false,
149149
});
150150
});
151151

packages/cli/src/lib/implementation/core-config.middleware.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ export async function coreConfigMiddleware<
5353
format: normalizeFormats(
5454
cliPersist?.format ?? rcPersist?.format ?? DEFAULT_PERSIST_FORMAT,
5555
),
56-
report: normalizeBooleanWithNegation(
57-
'report',
58-
cliPersist as Record<string, unknown>,
59-
rcPersist as Record<string, unknown>,
60-
),
56+
skipReports: cliPersist?.skipReports ?? rcPersist?.skipReports ?? false,
6157
},
6258
...(upload != null && { upload }),
6359
...remainingRcConfig,

packages/cli/src/lib/implementation/core-config.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type PersistConfigCliOptions = {
44
'persist.outputDir'?: string;
55
'persist.filename'?: string;
66
'persist.format'?: Format;
7-
'persist.report'?: boolean;
7+
'persist.skipReports'?: boolean;
88
};
99

1010
export type UploadConfigCliOptions = {

packages/cli/src/lib/implementation/core-config.options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export function yargsPersistConfigOptionsDefinition(): Record<
3131
describe: 'Format of the report output. e.g. `md`, `json`',
3232
type: 'array',
3333
},
34-
'persist.report': {
34+
'persist.skipReports': {
3535
describe:
36-
'Generate the report files for given formats. (useful in combination with caching)',
36+
'Skip generating report files. (useful in combination with caching)',
3737
type: 'boolean',
3838
},
3939
};

packages/cli/src/lib/merge-diffs/merge-diffs-command.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('merge-diffs-command', () => {
4747
outputDir: DEFAULT_PERSIST_OUTPUT_DIR,
4848
filename: DEFAULT_PERSIST_FILENAME,
4949
format: DEFAULT_PERSIST_FORMAT,
50-
report: true,
50+
skipReports: false,
5151
},
5252
);
5353
});

packages/core/src/lib/collect-and-persist.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export type CollectAndPersistReportsOptions = Pick<
2121
CoreConfig,
2222
'plugins' | 'categories'
2323
> & {
24-
persist: Required<Omit<PersistConfig, 'report'>> &
25-
Pick<PersistConfig, 'report'>;
24+
persist: Required<Omit<PersistConfig, 'skipReports'>> &
25+
Pick<PersistConfig, 'skipReports'>;
2626
} & Partial<GlobalOptions>;
2727

2828
export async function collectAndPersistReports(
@@ -33,10 +33,9 @@ export async function collectAndPersistReports(
3333
const sortedScoredReport = sortReport(scoreReport(reportResult));
3434

3535
const { persist } = options;
36-
const { report: shouldGenerateReport = true, ...persistOptions } =
37-
persist ?? {};
36+
const { skipReports = false, ...persistOptions } = persist ?? {};
3837

39-
if (shouldGenerateReport === true) {
38+
if (skipReports !== true) {
4039
const persistResults = await persistReport(
4140
reportResult,
4241
sortedScoredReport,
@@ -47,7 +46,7 @@ export async function collectAndPersistReports(
4746
logPersistedResults(persistResults);
4847
}
4948
} else {
50-
logger.info('Skipping saving reports as `persist.report` is false');
49+
logger.info('Skipping saving reports as `persist.skipReports` is true');
5150
}
5251

5352
// terminal output

0 commit comments

Comments
 (0)