Skip to content

Commit

Permalink
fix: add missing modules to manifests (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j authored Aug 2, 2024
1 parent f17630b commit d029259
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifests/micro-utilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@
"category": "micro-utilities"
}
]
}
}
2 changes: 1 addition & 1 deletion manifests/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -1041,4 +1041,4 @@
"category": "native"
}
]
}
}
14 changes: 13 additions & 1 deletion manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,18 @@
"docPath": "mkdirp",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "materialize-css",
"docPath": "materialize-css",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "md5",
"docPath": "md5",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "mkdirp",
Expand Down Expand Up @@ -2077,4 +2089,4 @@
"category": "preferred"
}
]
}
}
27 changes: 26 additions & 1 deletion scripts/validate-module-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {readFile, readdir} from 'node:fs/promises';
const scriptDir = fileURLToPath(new URL('.', import.meta.url));
const moduleListDir = path.resolve(scriptDir, '..', 'docs', 'modules');
const moduleListReadmePath = path.resolve(moduleListDir, 'README.md');
const manifestsDir = path.resolve(scriptDir, '../manifests');

export async function validateModuleList() {
console.log('Validating README contains all documented modules...');
Expand All @@ -13,21 +14,45 @@ export async function validateModuleList() {
});
const listOfDocumentedModules =
moduleListReadme.split('## List of modules')[1];
const allDocPaths = [];

const manifests = await readdir(manifestsDir);

for (const manifestName of manifests) {
const manifestPath = path.join(manifestsDir, manifestName);
const manifestObj = JSON.parse(
await readFile(manifestPath, {encoding: 'utf8'})
);

for (const mod of manifestObj.moduleReplacements) {
if (mod.type === 'documented') {
allDocPaths.push(mod.docPath);
}
}
}

const files = await readdir(moduleListDir);
for (const file of files) {
if (!file.endsWith('.md') || file === 'README.md') {
continue;
}

const docName = file.slice(0, -3);

if (!listOfDocumentedModules.includes(file)) {
throw new Error(
`Module ${file} is not listed in the README.md but was found in modules documentation.
Please add
- [\`${file.slice(0, -3)}\`](./${file})
- [\`${docName}\`](./${file})
to ./docs/modules/README.md`
);
}

if (!allDocPaths.includes(docName)) {
throw new Error(
`Module ${docName} has documentation but does not exist in any manifest`
);
}
}
console.log('OK');
}

0 comments on commit d029259

Please sign in to comment.