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 41
41
with :
42
42
path : ./*
43
43
key : ${{ github.sha }}
44
+ - run : ./scripts/check-manifests.js
44
45
- run : yarn lint
45
46
46
47
checkPrecompiled :
Original file line number Diff line number Diff line change 430
430
{
431
431
"title" : " sharp-missing-in-production" ,
432
432
"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"
433
441
}
434
442
]
435
443
}
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