@@ -2,49 +2,29 @@ const fs = require('node:fs');
22const path = require ( 'node:path' ) ;
33
44const root = path . resolve ( __dirname , '..' , 'website' , 'src' , 'components' , 'VisualElements' ) ;
5- const names = [
6- 'AgentWorkStabilityDiagram' ,
7- 'ContextMechanismMap' ,
8- 'ContextWindowAnatomyDiagram' ,
9- 'ErrorReasonComparisonDiagram' ,
10- 'ExecutionPortfolioDiagram' ,
11- 'GroundingDistillationDiagram' ,
12- 'HarnessContextLoop' ,
13- 'HarnessDeltaExplorer' ,
14- 'HarnessLoopDiagram' ,
15- 'InstructionLayerAuthority' ,
16- 'InteractiveHarnessWorkbench' ,
17- 'LivingContextWindowStream' ,
18- 'LocalChoicesGlobalCoherenceDiagram' ,
19- 'LongContextBenchmarkExplorer' ,
20- 'ModelEncodingAtlas' ,
21- 'OperatorCycleDiagram' ,
22- 'OwnershipBoundaryDiagram' ,
23- 'PlanningContractCheckpointDiagram' ,
24- 'PostTrainingTuningBoard' ,
25- 'ProbabilityIsNotLogicDiagram' ,
26- 'SpecExecutionRunsDiagram' ,
27- 'SpeedAccuracyTradeoff' ,
28- 'StructuredControlPlaneWorkbench' ,
29- 'SubAgentFanoutDiagram' ,
30- 'TokenPredictionDiagram' ,
31- 'UShapeAttentionCurve' ,
32- 'ValidationClaimBenchDiagram' ,
33- 'ValidationEvidenceLifecycle' ,
34- ] ;
5+
6+ // Self-maintaining: any component that opts into ResponsiveDiagram joins the
7+ // audit, so a new paired diagram can never ship unlisted.
8+ const names = fs
9+ . readdirSync ( root , { withFileTypes : true } )
10+ . filter ( ( entry ) => entry . isFile ( ) && entry . name . endsWith ( '.tsx' ) )
11+ . map ( ( entry ) => entry . name . replace ( / \. t s x $ / , '' ) )
12+ . filter ( ( name ) => name !== 'ResponsiveDiagram' )
13+ . filter ( ( name ) =>
14+ fs . readFileSync ( path . join ( root , `${ name } .tsx` ) , 'utf8' ) . includes ( 'ResponsiveDiagram' )
15+ ) ;
16+
3517const variantSelector =
3618 / \. (?: d e s k t o p D i a g r a m | m o b i l e D i a g r a m | d e s k t o p | m o b i l e | o p e r a t o r D e s k t o p | o p e r a t o r M o b i l e | v a l i d a t i o n D e s k t o p | v a l i d a t i o n M o b i l e | d e s k t o p C h a r t | m o b i l e C h a r t ) \b / ;
3719const failures = [ ] ;
3820
3921for ( const name of names ) {
40- const tsxPath = path . join ( root , `${ name } .tsx` ) ;
4122 const cssPath = path . join ( root , `${ name } .module.css` ) ;
42- const tsx = fs . readFileSync ( tsxPath , 'utf8' ) ;
43- const css = fs . readFileSync ( cssPath , 'utf8' ) ;
44-
45- if ( ! tsx . includes ( 'ResponsiveDiagram' ) ) {
46- failures . push ( `${ name } : paired diagram does not use ResponsiveDiagram` ) ;
23+ if ( ! fs . existsSync ( cssPath ) ) {
24+ failures . push ( `${ name } : missing paired stylesheet ${ name } .module.css` ) ;
25+ continue ;
4726 }
27+ const css = fs . readFileSync ( cssPath , 'utf8' ) ;
4828
4929 for ( const match of css . matchAll ( / ( [ ^ { } ] + ) \{ ( [ ^ { } ] * ) \} / g) ) {
5030 const selector = match [ 1 ] ;
@@ -76,4 +56,5 @@ if (failures.length) {
7656 process . exitCode = 1 ;
7757} else {
7858 console . log ( `responsive diagram audit passed (${ names . length } paired diagrams)` ) ;
59+ console . log ( names . map ( ( name ) => `- ${ name } ` ) . join ( '\n' ) ) ;
7960}
0 commit comments