11const { writeFileSync } = require ( 'fs' )
22const path = require ( 'path' )
33
4- const standards = require ( '../data/standards .json' )
4+ const checks = require ( '../data/checks .json' )
55
66const projectStatus = [ 'incubating' , 'active' , 'retiring' ]
77const implementationPriority = [ 'expected' , 'deferrable' , 'recommended' ]
88const data = { }
99const files = { }
10+ const capitalizeWords = str => str . split ( ' ' ) . map ( w => w [ 0 ] . toUpperCase ( ) + w . slice ( 1 ) . toLowerCase ( ) ) . join ( ' ' )
1011
1112// Basic structure of the data object
1213projectStatus . forEach ( status => {
@@ -18,19 +19,23 @@ projectStatus.forEach(status => {
1819} )
1920
2021// Populate the data object
21- standards . forEach ( item =>
22- projectStatus . forEach ( status => {
23- const statusData = item [ status ] ?. toLowerCase ( )
24- if ( implementationPriority . includes ( statusData ) ) {
25- data [ status ] [ statusData ] . push ( item )
26- }
27- } )
28- )
22+ checks
23+ // @TODO : Remove this sort when the checks.json is sorted when generated in the dashboard script
24+ . sort ( ( a , b ) => a . id - b . id )
25+ . forEach ( item =>
26+ projectStatus . forEach ( status => {
27+ const statusKey = `level_${ status } _status`
28+ const statusData = item [ statusKey ] ?. toLowerCase ( )
29+ if ( implementationPriority . includes ( statusData ) ) {
30+ data [ status ] [ statusData ] . push ( item )
31+ }
32+ } )
33+ )
2934
3035const addHeader = ( ) => `
3136| Section | Item | Priority Group | Details |
3237| --- | --- | --- | --- |`
33- const addRow = ( item ) => `| ${ item . section } | ${ item . title } | ${ item [ 'priority group' ] } | [details](/details/${ item . slug } ) |`
38+ const addRow = ( item ) => `| ${ item . section_number } . ${ capitalizeWords ( item . section_name ) } | ${ item . title } | ${ item . priority_group } | [details](/details/${ item . code_name } ) |`
3439
3540// Prepare the markdown files
3641projectStatus . forEach ( ( status , index ) => {
@@ -53,6 +58,6 @@ ${data[status][priority].map(addRow).join('\n')}
5358 `
5459 } ) . join ( '\n' )
5560
56- const detination = path . join ( process . cwd ( ) , `docs/implementation/${ status } .mdx` )
57- writeFileSync ( detination , fileContent )
61+ const destination = path . join ( process . cwd ( ) , `docs/implementation/${ status } .mdx` )
62+ writeFileSync ( destination , fileContent )
5863} )
0 commit comments