@@ -12,6 +12,9 @@ type PackageMap = Map<string, ReportLeafNode | VersionMap>
1212type EcoMap = Map < string , ReportLeafNode | PackageMap >
1313export type ViolationsMap = Map < string , EcoMap >
1414
15+ export interface ShortScanReport {
16+ healthy : boolean
17+ }
1518export interface ScanReport {
1619 orgSlug : string
1720 scanId : string
@@ -35,14 +38,16 @@ export function generateReport(
3538 fold,
3639 orgSlug,
3740 reportLevel,
38- scanId
41+ scanId,
42+ short
3943 } : {
40- orgSlug : string
41- scanId : string
4244 fold : 'pkg' | 'version' | 'file' | 'none'
45+ orgSlug : string
4346 reportLevel : 'defer' | 'ignore' | 'monitor' | 'warn' | 'error'
47+ scanId : string
48+ short : boolean
4449 }
45- ) : ScanReport {
50+ ) : ScanReport | ShortScanReport {
4651 const now = Date . now ( )
4752
4853 // Lazily access constants.spinner.
@@ -95,20 +100,22 @@ export function generateReport(
95100 switch ( action ) {
96101 case 'error' : {
97102 healthy = false
98- addAlert (
99- artifact ,
100- violations ,
101- fold ,
102- ecosystem ,
103- pkgName ,
104- version ,
105- alert ,
106- action
107- )
103+ if ( ! short ) {
104+ addAlert (
105+ artifact ,
106+ violations ,
107+ fold ,
108+ ecosystem ,
109+ pkgName ,
110+ version ,
111+ alert ,
112+ action
113+ )
114+ }
108115 break
109116 }
110117 case 'warn' : {
111- if ( reportLevel !== 'error' ) {
118+ if ( ! short && reportLevel !== 'error' ) {
112119 addAlert (
113120 artifact ,
114121 violations ,
@@ -123,7 +130,7 @@ export function generateReport(
123130 break
124131 }
125132 case 'monitor' : {
126- if ( reportLevel !== 'warn' && reportLevel !== 'error' ) {
133+ if ( ! short && reportLevel !== 'warn' && reportLevel !== 'error' ) {
127134 addAlert (
128135 artifact ,
129136 violations ,
@@ -140,6 +147,7 @@ export function generateReport(
140147
141148 case 'ignore' : {
142149 if (
150+ ! short &&
143151 reportLevel !== 'warn' &&
144152 reportLevel !== 'error' &&
145153 reportLevel !== 'monitor'
@@ -160,7 +168,7 @@ export function generateReport(
160168
161169 case 'defer' : {
162170 // Not sure but ignore for now. Defer to later ;)
163- if ( reportLevel === 'defer' ) {
171+ if ( ! short && reportLevel === 'defer' ) {
164172 addAlert (
165173 artifact ,
166174 violations ,
@@ -186,13 +194,15 @@ export function generateReport(
186194
187195 spinner . successAndStop ( `Generated reported in ${ Date . now ( ) - now } ms` )
188196
189- const report = {
190- healthy,
191- orgSlug,
192- scanId,
193- options : { fold, reportLevel } ,
194- alerts : violations
195- }
197+ const report = short
198+ ? { healthy }
199+ : {
200+ healthy,
201+ orgSlug,
202+ scanId,
203+ options : { fold, reportLevel } ,
204+ alerts : violations
205+ }
196206
197207 return report
198208}
0 commit comments