File tree Expand file tree Collapse file tree 3 files changed +13
-21
lines changed Expand file tree Collapse file tree 3 files changed +13
-21
lines changed Original file line number Diff line number Diff line change 1- import { pluginOutputSchema } from '@quality-metrics/models' ;
1+ import { pluginOutputSchema , Report } from '@quality-metrics/models' ;
22import {
33 collect ,
44 CollectOptions ,
@@ -12,7 +12,12 @@ export function yargsCollectCommandObject() {
1212 const handler = async (
1313 config : CollectOptions & { format : string } ,
1414 ) : Promise < void > => {
15- const report = await collect ( { ...config , packageJson } ) ;
15+ const collectReport = await collect ( config ) ;
16+ const report : Report = {
17+ ...collectReport ,
18+ packageName : packageJson . name ,
19+ version : packageJson . version ,
20+ } ;
1621
1722 await persistReport ( report , config ) ;
1823
Original file line number Diff line number Diff line change 11import { reportSchema } from '@quality-metrics/models' ;
22import { mockCoreConfig } from '@quality-metrics/models/testing' ;
3- import type { PackageJson } from 'type-fest' ;
43import { describe , expect , it } from 'vitest' ;
54import { CollectOptions , collect } from '../collect/' ;
65
@@ -13,13 +12,9 @@ const baseOptions: CollectOptions = {
1312
1413describe ( 'collect' , ( ) => {
1514 it ( 'should execute with valid options`' , async ( ) => {
16- const packageJson : PackageJson = {
17- name : '@code-pushup/cli' ,
18- version : '0.1.0' ,
19- } ;
20- const report = await collect ( { ...baseOptions , packageJson } ) ;
21- expect ( report . packageName ) . toBe ( packageJson . name ) ;
22- expect ( report . version ) . toBe ( packageJson . version ) ;
23- expect ( ( ) => reportSchema . parse ( report ) ) . not . toThrow ( ) ;
15+ const report = await collect ( baseOptions ) ;
16+ expect ( ( ) =>
17+ reportSchema . omit ( { packageName : true , version : true } ) . parse ( report ) ,
18+ ) . not . toThrow ( ) ;
2419 } ) ;
2520} ) ;
Original file line number Diff line number Diff line change @@ -19,19 +19,13 @@ export class CollectOutputError extends Error {
1919
2020export type CollectOptions = GlobalCliArgs & CoreConfig ;
2121
22- type PackageJson = {
23- name ?: string ;
24- version ?: string ;
25- } ;
26-
2722/**
2823 * Run audits, collect plugin output and aggregate it into a JSON object
2924 * @param options
3025 */
3126export async function collect (
32- options : CollectOptions & { packageJson : PackageJson } ,
33- ) : Promise < Report > {
34- const { version, name } = options . packageJson ;
27+ options : CollectOptions ,
28+ ) : Promise < Omit < Report , 'packageName' | 'version' > > {
3529 const { plugins, categories } = options ;
3630
3731 if ( ! plugins ?. length ) {
@@ -43,8 +37,6 @@ export async function collect(
4337 const pluginOutputs = await executePlugins ( plugins ) ;
4438
4539 return {
46- packageName : name ,
47- version,
4840 date,
4941 duration : calcDuration ( start ) ,
5042 categories,
You can’t perform that action at this time.
0 commit comments