22var chalk_1 = require ( 'chalk' ) ;
33var validKeys = {
44 info : [ 'title' , 'description' ] ,
5- chapter : [ 'title' , 'description' , 'pages' ] ,
65 page : [ 'title' , 'description' , 'onPageComplete' , 'tasks' , 'video' , 'link' ] ,
76 task : [ 'description' , 'tests' , 'actions' , 'hints' ]
87} ;
@@ -18,58 +17,39 @@ function lintOutput(json) {
1817 } ) ;
1918 }
2019 } ) ;
21- json . chapters . forEach ( function ( chapter , cIndex ) {
22- var chKeys = Object . keys ( chapter ) ;
23- chKeys . forEach ( function ( key ) {
24- if ( validKeys . chapter . indexOf ( key ) < 0 ) {
20+ json . pages . forEach ( function ( page , pIndex ) {
21+ var pKeys = Object . keys ( page ) ;
22+ pKeys . forEach ( function ( key ) {
23+ if ( validKeys . page . indexOf ( key ) < 0 ) {
2524 invalidKeys . push ( {
26- error : "Invalid Chapter key \"" + key + "\"" ,
27- location : "ch : " + ( cIndex + 1 )
25+ error : "Invalid Page key \"" + key + "\"" ,
26+ location : "page : " + ( pIndex + 1 )
2827 } ) ;
2928 }
3029 } ) ;
31- if ( chapter . pages && chapter . pages . length > 0 ) {
32- chapter . pages . forEach ( function ( page , pIndex ) {
33- var pKeys = Object . keys ( page ) ;
34- pKeys . forEach ( function ( key ) {
35- if ( validKeys . page . indexOf ( key ) < 0 ) {
30+ if ( page . tasks && page . tasks . length > 0 ) {
31+ page . tasks . forEach ( function ( task , tIndex ) {
32+ var tKeys = Object . keys ( task ) ;
33+ tKeys . forEach ( function ( key ) {
34+ if ( validKeys . task . indexOf ( key ) < 0 ) {
3635 invalidKeys . push ( {
37- error : "Invalid Page key \"" + key + "\"" ,
38- location : "ch : " + ( cIndex + 1 ) + ", page : " + ( pIndex + 1 )
36+ error : "Invalid Task key \"" + key + "\"" ,
37+ location : "page : " + ( pIndex + 1 ) + ", task : " + ( tIndex + 1 )
3938 } ) ;
4039 }
4140 } ) ;
42- if ( page . tasks && page . tasks . length > 0 ) {
43- page . tasks . forEach ( function ( task , tIndex ) {
44- var tKeys = Object . keys ( task ) ;
45- tKeys . forEach ( function ( key ) {
46- if ( validKeys . task . indexOf ( key ) < 0 ) {
47- invalidKeys . push ( {
48- error : "Invalid Task key \"" + key + "\"" ,
49- location : "ch: " + ( cIndex + 1 ) + ", page: " + ( pIndex + 1 ) + ", task: " + ( tIndex + 1 )
50- } ) ;
51- }
52- } ) ;
53- if ( ! task . tests || task . tests . length < 1 ) {
54- invalidKeys . push ( {
55- error : 'Missing Task Test' ,
56- location : "ch: " + ( cIndex + 1 ) + ", page: " + ( pIndex + 1 ) + ", task: " + ( tIndex + 1 )
57- } ) ;
58- }
59- } ) ;
60- }
61- else {
62- warningKeys . push ( {
63- warning : 'Missing page tasks' ,
64- location : "ch: " + ( cIndex + 1 ) + ", page: " + ( pIndex + 1 )
41+ if ( ! task . tests || task . tests . length < 1 ) {
42+ invalidKeys . push ( {
43+ error : 'Missing Task Test' ,
44+ location : "page: " + ( pIndex + 1 ) + ", task: " + ( tIndex + 1 )
6545 } ) ;
6646 }
6747 } ) ;
6848 }
6949 else {
7050 warningKeys . push ( {
71- warning : 'Missing pages ' ,
72- location : "ch : " + ( cIndex + 1 )
51+ warning : 'Missing page tasks ' ,
52+ location : "page : " + ( pIndex + 1 )
7353 } ) ;
7454 }
7555 } ) ;
@@ -104,7 +84,7 @@ function hasTutorialInfo(json) {
10484}
10585exports . hasTutorialInfo = hasTutorialInfo ;
10686function hasPage ( json ) {
107- if ( ! ( json . chapters [ 0 ] . pages . length > 0 && ! ! json . chapters [ 0 ] . pages [ 0 ] . title ) ) {
87+ if ( ! ( json . pages . length > 0 && ! ! json . pages [ 0 ] . title ) ) {
10888 console . log ( chalk_1 . red ( '\nYour tutorial requires at least one page.' ) ) ;
10989 process . exit ( 1 ) ;
11090 }
0 commit comments