Skip to content

Commit b992caf

Browse files
committed
fix: revert changes
1 parent bb5afa3 commit b992caf

File tree

14 files changed

+31
-99
lines changed

14 files changed

+31
-99
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ export function configFromPatterns(
483483
outputDir: interpolate(persist.outputDir, variables),
484484
filename: interpolate(persist.filename, variables),
485485
format: persist.format,
486-
report: persist.report,
487486
},
488487
...(upload && {
489488
upload: {

packages/cli/README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,19 @@ 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-
| **`--cache.read`** | `boolean` | `false` | If plugin audit outputs should be read from file system cache. |
221-
| **`--cache.write`** | `boolean` | `false` | If plugin audit outputs should be written to file system cache. |
222-
| **`--onlyPlugins`** | `string[]` | `[]` | Only run the specified plugins. Applicable to all commands except `upload`. |
223-
| **`--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+
| **`--upload.organization`** | `string` | n/a | Organization slug from portal. |
216+
| **`--upload.project`** | `string` | n/a | Project slug from portal. |
217+
| **`--upload.server`** | `string` | n/a | URL to your portal server. |
218+
| **`--upload.apiKey`** | `string` | n/a | API key for the portal server. |
219+
| **`--cache.read`** | `boolean` | `false` | If plugin audit outputs should be read from file system cache. |
220+
| **`--cache.write`** | `boolean` | `false` | If plugin audit outputs should be written to file system cache. |
221+
| **`--onlyPlugins`** | `string[]` | `[]` | Only run the specified plugins. Applicable to all commands except `upload`. |
222+
| **`--skipPlugins`** | `string[]` | `[]` | Skip the specified plugins. Applicable to all commands except `upload`. |
224223

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('collect-command', () => {
3737
expect(collectAndPersistReports).toHaveBeenCalledWith(
3838
expect.objectContaining({
3939
config: '/test/code-pushup.config.ts',
40-
persist: expect.objectContaining<PersistConfig>({
40+
persist: expect.objectContaining<Required<PersistConfig>>({
4141
filename: DEFAULT_PERSIST_FILENAME,
4242
outputDir: DEFAULT_PERSIST_OUTPUT_DIR,
4343
format: DEFAULT_PERSIST_FORMAT,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export async function coreConfigMiddleware<
5959
format: normalizeFormats(
6060
cliPersist?.format ?? rcPersist?.format ?? DEFAULT_PERSIST_FORMAT,
6161
),
62-
report: !('no-report' in (cliPersist ?? {})),
6362
},
6463
...(upload != null && { upload }),
6564
...remainingRcConfig,

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,4 @@ describe('coreConfigMiddleware', () => {
7373
'apps/website/tsconfig.json',
7474
);
7575
});
76-
77-
it('should forward normalize --persist.report option', async () => {
78-
await coreConfigMiddleware({
79-
config: 'apps/website/code-pushup.config.ts',
80-
} as GeneralCliOptions & CoreConfigCliOptions & FilterOptions);
81-
expect(readRcByPath).toHaveBeenCalledWith(
82-
'apps/website/code-pushup.config.ts',
83-
'apps/website/tsconfig.json',
84-
);
85-
});
8676
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export type ConfigCliOptions = {
1919
verbose?: string;
2020
};
2121

22-
export type CoreConfigCliOptions = Pick<CoreConfig, 'persist' | 'cache'> & {
22+
export type CoreConfigCliOptions = Pick<CoreConfig, 'persist'> & {
2323
upload?: Partial<Omit<UploadConfig, 'timeout'>>;
2424
};

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

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
logStdoutSummary,
99
scoreReport,
1010
sortReport,
11-
ui,
1211
} from '@code-pushup/utils';
1312
import { collect } from './implementation/collect.js';
1413
import {
@@ -19,42 +18,30 @@ import type { GlobalOptions } from './types.js';
1918

2019
export type CollectAndPersistReportsOptions = Pick<
2120
CoreConfig,
22-
'plugins' | 'categories' | 'cache'
23-
> & {
24-
persist: Required<Omit<PersistConfig, 'report'>> &
25-
Pick<PersistConfig, 'report'>;
26-
} & Partial<GlobalOptions>;
21+
'plugins' | 'categories'
22+
> & { persist: Required<PersistConfig> } & Partial<GlobalOptions>;
2723

2824
export async function collectAndPersistReports(
2925
options: CollectAndPersistReportsOptions,
3026
): Promise<void> {
31-
const logger = ui().logger;
32-
const reportResult = await collect(options);
33-
const sortedScoredReport = sortReport(scoreReport(reportResult));
27+
const report = await collect(options);
28+
const sortedScoredReport = sortReport(scoreReport(report));
3429

35-
const { persist } = options;
36-
const { report: shouldGenerateReport = true, ...persistOptions } =
37-
persist ?? {};
38-
39-
if (shouldGenerateReport === true) {
40-
const persistResults = await persistReport(
41-
reportResult,
42-
sortedScoredReport,
43-
persistOptions,
44-
);
45-
46-
if (isVerbose()) {
47-
logPersistedResults(persistResults);
48-
}
49-
} else {
50-
logger.info('Skipping saving reports as `persist.report` is false');
51-
}
30+
const persistResults = await persistReport(
31+
report,
32+
sortedScoredReport,
33+
options.persist,
34+
);
5235

5336
// terminal output
5437
logStdoutSummary(sortedScoredReport);
5538

39+
if (isVerbose()) {
40+
logPersistedResults(persistResults);
41+
}
42+
5643
// validate report and throw if invalid
57-
reportResult.plugins.forEach(plugin => {
44+
report.plugins.forEach(plugin => {
5845
// Running checks after persisting helps while debugging as you can check the invalid output after the error is thrown
5946
pluginReportSchema.parse(plugin);
6047
});

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,6 @@ describe('collectAndPersistReports', () => {
115115
expect(logPersistedResults).toHaveBeenCalled();
116116
});
117117

118-
it('should call collect and not persistReport if report options is false in verbose mode', async () => {
119-
const sortedScoredReport = sortReport(scoreReport(MINIMAL_REPORT_MOCK));
120-
121-
vi.stubEnv('CP_VERBOSE', 'true');
122-
123-
const verboseConfig: CollectAndPersistReportsOptions = {
124-
...MINIMAL_CONFIG_MOCK,
125-
persist: {
126-
outputDir: 'output',
127-
filename: 'report',
128-
format: ['md'],
129-
report: false,
130-
},
131-
progress: false,
132-
};
133-
await collectAndPersistReports(verboseConfig);
134-
135-
expect(collect).toHaveBeenCalledWith(verboseConfig);
136-
137-
expect(persistReport).not.toHaveBeenCalled();
138-
expect(logPersistedResults).not.toHaveBeenCalled();
139-
140-
expect(logStdoutSummary).toHaveBeenCalledWith(sortedScoredReport);
141-
});
142-
143118
it('should print a summary to stdout', async () => {
144119
await collectAndPersistReports(
145120
MINIMAL_CONFIG_MOCK as CollectAndPersistReportsOptions,

packages/core/src/lib/implementation/persist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class PersistError extends Error {
2525
export async function persistReport(
2626
report: Report,
2727
sortedScoredReport: ScoredReport,
28-
options: Required<Omit<PersistConfig, 'report'>>,
28+
options: Required<PersistConfig>,
2929
): Promise<MultipleFileResults> {
3030
const { outputDir, filename, format } = options;
3131

packages/models/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export {
66
sourceFileLocationSchema,
77
type SourceFileLocation,
88
} from './lib/source.js';
9-
export { cacheConfigSchema, type CacheConfig } from './lib/cache-config.js';
109

1110
export {
1211
auditDetailsSchema,

0 commit comments

Comments
 (0)