1
1
const { writeFileSync } = require ( 'fs' )
2
2
const path = require ( 'path' )
3
3
4
- const standards = require ( '../data/standards .json' )
4
+ const checks = require ( '../data/checks .json' )
5
5
6
6
const projectStatus = [ 'incubating' , 'active' , 'retiring' ]
7
7
const implementationPriority = [ 'expected' , 'deferrable' , 'recommended' ]
8
8
const data = { }
9
9
const files = { }
10
+ const capitalizeWords = str => str . split ( ' ' ) . map ( w => w [ 0 ] . toUpperCase ( ) + w . slice ( 1 ) . toLowerCase ( ) ) . join ( ' ' )
10
11
11
12
// Basic structure of the data object
12
13
projectStatus . forEach ( status => {
@@ -18,19 +19,23 @@ projectStatus.forEach(status => {
18
19
} )
19
20
20
21
// 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
+ )
29
34
30
35
const addHeader = ( ) => `
31
36
| Section | Item | Priority Group | Details |
32
37
| --- | --- | --- | --- |`
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 } ) |`
34
39
35
40
// Prepare the markdown files
36
41
projectStatus . forEach ( ( status , index ) => {
@@ -53,6 +58,6 @@ ${data[status][priority].map(addRow).join('\n')}
53
58
`
54
59
} ) . join ( '\n' )
55
60
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 )
58
63
} )
0 commit comments