-
Notifications
You must be signed in to change notification settings - Fork 1k
Docs CI - Check that nav.js matches the .md files list
#2984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
441e48a
[bfops/check-navjs]: do thing
bfops 0252e15
[bfops/check-navjs]: fix
bfops 6b1bb15
[bfops/check-navjs]: fix
bfops 3c3417f
[bfops/check-navjs]: REVERT THIS TEST COMMIT - add a test file
bfops f5e9dc1
[bfops/check-navjs]: revert previous commit
bfops c507380
[bfops/check-navjs]: REVERT THIS TEST COMMIT - test removing a file
bfops 51f1042
[bfops/check-navjs]: revert test commit
bfops 58fa8bb
[bfops/check-navjs]: review
bfops 4d06e78
[bfops/check-navjs]: tweak messages
bfops eab1b2a
[bfops/check-navjs]: revert
bfops 6953645
[bfops/check-navjs]: comment
bfops 63dabcb
[bfops/check-navjs]: messages
bfops 4ce7ddf
Merge branch 'master' into bfops/check-navjs
bfops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import { fileURLToPath, pathToFileURL } from 'url'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
|
|
||
| const navPath = '../docs/nav.mjs'; | ||
|
|
||
| const mdListPath = process.argv[2]; | ||
| if (!mdListPath) { | ||
| console.error('Usage: node checkNav.mjs <md-list-file>'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const navFile = path.resolve(__dirname, navPath); | ||
| const nav = await import(pathToFileURL(navFile).href).then(mod => mod.default); | ||
|
|
||
| const extractPathsFromNav = (items) => | ||
| items.filter(item => item.type === 'page').map(page => page.path); | ||
|
|
||
| const navPaths = extractPathsFromNav(nav.items); | ||
| const navPathSet = new Set(navPaths); | ||
|
|
||
| const expectedMdPaths = fs.readFileSync(path.resolve(__dirname, mdListPath), 'utf8') | ||
| .split('\n') | ||
| .map(line => line.trim()) | ||
| .filter(Boolean); | ||
| const expectedPathSet = new Set(expectedMdPaths); | ||
|
|
||
| const missingInNav = expectedMdPaths.filter(p => !navPathSet.has(p)); | ||
| const extraInNav = navPaths.filter(p => !expectedPathSet.has(p)); | ||
|
|
||
| let failed = false; | ||
|
|
||
| if (missingInNav.length > 0) { | ||
| console.error('❌ New docs added missing from nav:'); | ||
| missingInNav.forEach(p => console.error(`- ${p}`)); | ||
| failed = true; | ||
| } | ||
|
|
||
| if (extraInNav.length > 0) { | ||
| console.error('❌ Files listed in nav but not found on filesystem:'); | ||
| extraInNav.forEach(p => console.error(`- ${p}`)); | ||
| failed = true; | ||
| } | ||
|
|
||
| if (!failed) { | ||
| console.log('✅ nav list matches filesystem.'); | ||
| } else { | ||
| process.exit(1); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.