File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 4141 with :
4242 path : ./*
4343 key : ${{ github.sha }}
44+ - run : ./scripts/check-manifests.js
4445 - run : yarn lint
4546
4647 checkPrecompiled :
Original file line number Diff line number Diff line change 430430 {
431431 "title" : " sharp-missing-in-production" ,
432432 "path" : " /errors/sharp-missing-in-production.md"
433+ },
434+ {
435+ "title" : " max-custom-routes-reached" ,
436+ "path" : " /errors/max-custom-routes-reached.md"
437+ },
438+ {
439+ "title" : " module-not-found" ,
440+ "path" : " /errors/module-not-found.md"
433441 }
434442 ]
435443 }
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const fs = require ( 'fs' )
4+ const path = require ( 'path' )
5+ const globOrig = require ( 'glob' )
6+ const { promisify } = require ( 'util' )
7+ const glob = promisify ( globOrig )
8+
9+ function collectPaths ( routes , paths = [ ] ) {
10+ for ( const route of routes ) {
11+ if ( route . path ) {
12+ paths . push ( route . path )
13+ }
14+
15+ if ( route . routes ) {
16+ collectPaths ( route . routes , paths )
17+ }
18+ }
19+ }
20+
21+ async function main ( ) {
22+ const manifests = [ 'errors/manifest.json' , 'docs/manifest.json' ]
23+ let hadMissing = false
24+
25+ for ( const manifest of manifests ) {
26+ const dir = path . dirname ( manifest )
27+ const files = await glob ( path . join ( dir , '**/*.md' ) )
28+
29+ const manifestData = JSON . parse (
30+ await fs . promises . readFile ( manifest , 'utf8' )
31+ )
32+
33+ const paths = [ ]
34+ collectPaths ( manifestData . routes , paths )
35+
36+ const missingFiles = files . filter (
37+ ( file ) => ! paths . includes ( `/${ file } ` ) && file !== 'errors/template.md'
38+ )
39+
40+ if ( missingFiles . length ) {
41+ hadMissing = true
42+ console . log ( `Missing paths in ${ manifest } :\n${ missingFiles . join ( '\n' ) } ` )
43+ } else {
44+ console . log ( `No missing paths in ${ manifest } ` )
45+ }
46+ }
47+
48+ if ( hadMissing ) {
49+ throw new Error ( 'missing manifest items detected see above' )
50+ }
51+ }
52+
53+ main ( )
54+ . then ( ( ) => console . log ( 'success' ) )
55+ . catch ( console . error )
You can’t perform that action at this time.
0 commit comments