diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 210e35757150011..0ee8034b1b48463 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -40,6 +40,7 @@ jobs: with: path: ./* key: ${{ github.sha }} + - run: ./scripts/check-manifests.js - run: yarn lint checkPrecompiled: diff --git a/errors/manifest.json b/errors/manifest.json index 09bc27b3a8e7e76..4d42da82bef7370 100644 --- a/errors/manifest.json +++ b/errors/manifest.json @@ -430,6 +430,14 @@ { "title": "sharp-missing-in-production", "path": "/errors/sharp-missing-in-production.md" + }, + { + "title": "max-custom-routes-reached", + "path": "/errors/max-custom-routes-reached.md" + }, + { + "title": "module-not-found", + "path": "/errors/module-not-found.md" } ] } diff --git a/scripts/check-manifests.js b/scripts/check-manifests.js new file mode 100755 index 000000000000000..7531c2efb78408f --- /dev/null +++ b/scripts/check-manifests.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node + +const fs = require('fs') +const path = require('path') +const globOrig = require('glob') +const { promisify } = require('util') +const glob = promisify(globOrig) + +function collectPaths(routes, paths = []) { + for (const route of routes) { + if (route.path) { + paths.push(route.path) + } + + if (route.routes) { + collectPaths(route.routes, paths) + } + } +} + +async function main() { + const manifests = ['errors/manifest.json', 'docs/manifest.json'] + let hadMissing = false + + for (const manifest of manifests) { + const dir = path.dirname(manifest) + const files = await glob(path.join(dir, '**/*.md')) + + const manifestData = JSON.parse( + await fs.promises.readFile(manifest, 'utf8') + ) + + const paths = [] + collectPaths(manifestData.routes, paths) + + const missingFiles = files.filter( + (file) => !paths.includes(`/${file}`) && file !== 'errors/template.md' + ) + + if (missingFiles.length) { + hadMissing = true + console.log(`Missing paths in ${manifest}:\n${missingFiles.join('\n')}`) + } else { + console.log(`No missing paths in ${manifest}`) + } + } + + if (hadMissing) { + throw new Error('missing manifest items detected see above') + } +} + +main() + .then(() => console.log('success')) + .catch(console.error)