diff --git a/manifests/micro-utilities.json b/manifests/micro-utilities.json index 9d3b478..b366d94 100644 --- a/manifests/micro-utilities.json +++ b/manifests/micro-utilities.json @@ -127,4 +127,4 @@ "category": "micro-utilities" } ] -} \ No newline at end of file +} diff --git a/manifests/native.json b/manifests/native.json index c769d2d..0bce64d 100644 --- a/manifests/native.json +++ b/manifests/native.json @@ -1041,4 +1041,4 @@ "category": "native" } ] -} \ No newline at end of file +} diff --git a/manifests/preferred.json b/manifests/preferred.json index 2c1d6bf..19ba853 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -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", @@ -2077,4 +2089,4 @@ "category": "preferred" } ] -} \ No newline at end of file +} diff --git a/scripts/validate-module-list.js b/scripts/validate-module-list.js index 6c3c98f..a9ceb7d 100644 --- a/scripts/validate-module-list.js +++ b/scripts/validate-module-list.js @@ -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...'); @@ -13,6 +14,22 @@ 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) { @@ -20,14 +37,22 @@ export async function validateModuleList() { 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'); }