Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 5703528

Browse files
committed
feat: migrate populate-implementations script to the new data source
1 parent 5550e40 commit 5703528

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

scripts/populate-implementations.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const { writeFileSync } = require('fs')
22
const path = require('path')
33

4-
const standards = require('../data/standards.json')
4+
const checks = require('../data/checks.json')
55

66
const projectStatus = ['incubating', 'active', 'retiring']
77
const implementationPriority = ['expected', 'deferrable', 'recommended']
88
const data = {}
99
const 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
1213
projectStatus.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

3035
const 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
3641
projectStatus.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

Comments
 (0)