@@ -74,6 +74,23 @@ export function formatMissingPathWarningForCli (warning, useColor) {
7474 return bullet + warningPath + ownerLabel + ownerText
7575}
7676
77+ /**
78+ * Format an oversized CODEOWNERS warning for CLI output.
79+ * @param {import('./types.js').OversizedCodeownersWarning } warning
80+ * @param {boolean } useColor
81+ * @returns {string }
82+ */
83+ export function formatOversizedCodeownersWarningForCli ( warning , useColor ) {
84+ const bullet = colorizeCliText ( '- ' , [ ANSI_DIM ] , useColor )
85+ const warningPath = colorizeCliText ( warning . codeownersPath , [ ANSI_YELLOW ] , useColor )
86+ const detail = colorizeCliText (
87+ ` is ignored because it is ${ formatByteCount ( warning . sizeBytes ) } and exceeds GitHub's 3 MB limit (${ formatByteCount ( warning . sizeLimitBytes ) } ).` ,
88+ [ ANSI_DIM ] ,
89+ useColor
90+ )
91+ return bullet + warningPath + detail
92+ }
93+
7794/**
7895 * Format an invalid GitHub owner warning for CLI output.
7996 * @param {import('./types.js').InvalidOwnerWarning } warning
@@ -138,6 +155,15 @@ export function formatCodeownersOwnersList (owners) {
138155 return owners . join ( ', ' )
139156}
140157
158+ /**
159+ * Format a raw byte count for human-readable CLI output.
160+ * @param {number } value
161+ * @returns {string }
162+ */
163+ export function formatByteCount ( value ) {
164+ return `${ new Intl . NumberFormat ( 'en-US' ) . format ( value ) } bytes`
165+ }
166+
141167/**
142168 * Format invalid owner reasons for human-readable output.
143169 * @param {import('./types.js').InvalidOwnerEntry[]|undefined } invalidOwners
@@ -158,6 +184,7 @@ export function formatInvalidOwnerReasons (invalidOwners) {
158184 * unownedFiles: string[],
159185 * codeownersValidationMeta?: {
160186 * discoveryWarnings?: import('./types.js').DiscoveryWarning[],
187+ * oversizedCodeownersWarnings?: import('./types.js').OversizedCodeownersWarning[],
161188 * missingPathWarnings?: import('./types.js').MissingPathWarning[],
162189 * invalidOwnerWarnings?: import('./types.js').InvalidOwnerWarning[],
163190 * ownerValidationWarnings?: string[],
@@ -169,6 +196,7 @@ export function formatInvalidOwnerReasons (invalidOwners) {
169196 * noReport: boolean,
170197 * listUnowned: boolean,
171198 * failOnUnowned: boolean,
199+ * failOnOversizedCodeowners: boolean,
172200 * failOnMissingPaths: boolean,
173201 * failOnInvalidOwners: boolean,
174202 * failOnMissingDirectorySlashes: boolean,
@@ -190,6 +218,10 @@ export function outputUnownedReportResults (report, options) {
190218 ? report . codeownersValidationMeta . discoveryWarnings
191219 : [ ]
192220 const locationWarningCount = discoveryWarnings . length
221+ const oversizedCodeownersWarnings = Array . isArray ( report . codeownersValidationMeta ?. oversizedCodeownersWarnings )
222+ ? report . codeownersValidationMeta . oversizedCodeownersWarnings
223+ : [ ]
224+ const oversizedCodeownersWarningCount = oversizedCodeownersWarnings . length
193225 const missingPathWarnings = Array . isArray ( report . codeownersValidationMeta ?. missingPathWarnings )
194226 ? report . codeownersValidationMeta . missingPathWarnings
195227 : [ ]
@@ -238,6 +270,20 @@ export function outputUnownedReportResults (report, options) {
238270 console . error ( '' )
239271 }
240272
273+ if ( options . noReport && oversizedCodeownersWarningCount > 0 ) {
274+ console . error (
275+ colorizeCliText (
276+ `Oversized CODEOWNERS files (${ oversizedCodeownersWarningCount } ):` ,
277+ [ ANSI_BOLD , ANSI_YELLOW ] ,
278+ colorStderr
279+ )
280+ )
281+ for ( const warning of oversizedCodeownersWarnings ) {
282+ console . error ( '%s' , formatOversizedCodeownersWarningForCli ( warning , colorStderr ) )
283+ }
284+ console . error ( '' )
285+ }
286+
241287 if ( options . noReport && invalidOwnerWarningCount > 0 ) {
242288 console . error (
243289 colorizeCliText (
@@ -318,6 +364,7 @@ export function outputUnownedReportResults (report, options) {
318364 : [ ] ) ,
319365 `${ colorizeCliText ( 'analyzed files:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( report . totals . files ) , [ ANSI_BOLD ] , colorStdout ) } ` ,
320366 `${ colorizeCliText ( 'unknown files:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( report . totals . unowned ) , report . totals . unowned > 0 ? [ ANSI_BOLD , ANSI_RED ] : [ ANSI_BOLD , ANSI_GREEN ] , colorStdout ) } ` ,
367+ `${ colorizeCliText ( 'oversized CODEOWNERS warnings:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( oversizedCodeownersWarningCount ) , oversizedCodeownersWarningCount > 0 ? [ ANSI_BOLD , ANSI_YELLOW ] : [ ANSI_BOLD , ANSI_GREEN ] , colorStdout ) } ` ,
321368 `${ colorizeCliText ( 'missing path warnings:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( missingPathWarningCount ) , missingPathWarningCount > 0 ? [ ANSI_BOLD , ANSI_YELLOW ] : [ ANSI_BOLD , ANSI_GREEN ] , colorStdout ) } ` ,
322369 `${ colorizeCliText ( 'invalid owner warnings:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( invalidOwnerWarningCount ) , invalidOwnerWarningCount > 0 ? [ ANSI_BOLD , ANSI_YELLOW ] : [ ANSI_BOLD , ANSI_GREEN ] , colorStdout ) } ` ,
323370 `${ colorizeCliText ( 'owner validation warnings:' , [ ANSI_DIM ] , colorStdout ) } ${ colorizeCliText ( String ( ownerValidationWarningCount ) , ownerValidationWarningCount > 0 ? [ ANSI_BOLD , ANSI_YELLOW ] : [ ANSI_BOLD , ANSI_GREEN ] , colorStdout ) } ` ,
@@ -338,6 +385,10 @@ export function outputUnownedReportResults (report, options) {
338385 process . exitCode = EXIT_CODE_UNCOVERED
339386 }
340387
388+ if ( options . failOnOversizedCodeowners && oversizedCodeownersWarningCount > 0 ) {
389+ process . exitCode = EXIT_CODE_UNCOVERED
390+ }
391+
341392 if ( options . failOnMissingPaths && missingPathWarningCount > 0 ) {
342393 process . exitCode = EXIT_CODE_UNCOVERED
343394 }
0 commit comments