@@ -19,8 +19,13 @@ function readJson(filePath) {
1919}
2020
2121function getExpectedPhases ( ) {
22+ const discovered = listPhaseDirectories ( )
23+ . map ( ( phaseDir ) => Number . parseInt ( phaseDir . slice ( "phase-" . length ) , 10 ) )
24+ . filter ( ( value ) => Number . isInteger ( value ) && value > 0 )
25+ . sort ( ( a , b ) => a - b ) ;
26+ const maxPhase = discovered . length > 0 ? discovered [ discovered . length - 1 ] : 0 ;
2227 const phases = [ ] ;
23- for ( let i = 1 ; i <= 15 ; i += 1 ) {
28+ for ( let i = 1 ; i <= maxPhase ; i += 1 ) {
2429 phases . push ( String ( i ) . padStart ( 2 , "0" ) ) ;
2530 }
2631 return phases ;
@@ -73,24 +78,27 @@ function assertSamplesSharedBoundary() {
7378 assert . equal ( fs . existsSync ( fullPath ) , true , `Missing canonical shared sample file: ${ fileName } ` ) ;
7479 }
7580
76- const compatibilityShims = [
77- "debugConfigUtils.js" ,
78- "lateSampleBootstrap.js" ,
79- "networkDebugUtils.js" ,
80- "numberUtils.js" ,
81- "platformerHelpers.js" ,
82- "sampleDetailPageEnhancement.js" ,
83- "snapshotCloneUtils.js" ,
84- ] ;
85- for ( const fileName of compatibilityShims ) {
86- const shimPath = path . join ( SAMPLES_ROOT , "_shared" , fileName ) ;
87- const content = fs . readFileSync ( shimPath , "utf8" ) ;
88- assert . match ( content , / \. \. \/ s h a r e d \/ / , `${ fileName } must proxy to samples/shared` ) ;
89- }
81+ const compatibilityShimsDir = path . join ( SAMPLES_ROOT , "_shared" ) ;
82+ if ( fs . existsSync ( compatibilityShimsDir ) ) {
83+ const compatibilityShims = [
84+ "debugConfigUtils.js" ,
85+ "lateSampleBootstrap.js" ,
86+ "networkDebugUtils.js" ,
87+ "numberUtils.js" ,
88+ "platformerHelpers.js" ,
89+ "sampleDetailPageEnhancement.js" ,
90+ "snapshotCloneUtils.js" ,
91+ ] ;
92+ for ( const fileName of compatibilityShims ) {
93+ const shimPath = path . join ( compatibilityShimsDir , fileName ) ;
94+ const content = fs . readFileSync ( shimPath , "utf8" ) ;
95+ assert . match ( content , / \. \. \/ s h a r e d \/ / , `${ fileName } must proxy to samples/shared` ) ;
96+ }
9097
91- const cssShimPath = path . join ( SAMPLES_ROOT , "_shared" , "sampleBaseLayout.css" ) ;
92- const cssShim = fs . readFileSync ( cssShimPath , "utf8" ) ;
93- assert . match ( cssShim , / \/ s a m p l e s \/ s h a r e d \/ s a m p l e B a s e L a y o u t \. c s s / ) ;
98+ const cssShimPath = path . join ( compatibilityShimsDir , "sampleBaseLayout.css" ) ;
99+ const cssShim = fs . readFileSync ( cssShimPath , "utf8" ) ;
100+ assert . match ( cssShim , / \/ s a m p l e s \/ s h a r e d \/ s a m p l e B a s e L a y o u t \. c s s / ) ;
101+ }
94102
95103 let sharedReferenceCount = 0 ;
96104 function walk ( dirPath ) {
@@ -124,8 +132,15 @@ function assertCurriculumProgression() {
124132 const curriculum = readJson ( path . join ( METADATA_ROOT , "samples.curriculum.validation.json" ) ) ;
125133 const indexMetadata = readJson ( path . join ( METADATA_ROOT , "samples.index.metadata.json" ) ) ;
126134 const expectedPhases = getExpectedPhases ( ) ;
135+ const curriculumPhaseOrder = curriculum ?. progression ?. phaseOrder || [ ] ;
127136
128- assert . deepEqual ( curriculum ?. progression ?. phaseOrder || [ ] , expectedPhases ) ;
137+ for ( const phase of curriculumPhaseOrder ) {
138+ assert . equal ( expectedPhases . includes ( String ( phase ) ) , true , `Unexpected curriculum phase: ${ phase } ` ) ;
139+ }
140+ assert . deepEqual (
141+ curriculumPhaseOrder . map ( ( phase ) => String ( phase ) ) ,
142+ [ ...curriculumPhaseOrder ] . map ( ( phase ) => String ( phase ) ) . sort ( )
143+ ) ;
129144 assert . equal ( curriculum ?. progression ?. hasDuplicateSampleIds , false ) ;
130145 assert . equal (
131146 Number ( curriculum ?. progression ?. totalSamples ) || 0 ,
0 commit comments