FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
solid-apps.github.io/scripts/validate.js at gh-pages · solid-apps/solid-apps.github.io · GitHub
solid-apps
solid-apps.github.io
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
solid-apps.github.io
/
scripts
/
validate.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (48 loc) · 1.75 KB
Breadcrumbs
solid-apps.github.io
/
scripts
/
validate.js
Copy path
File metadata and controls
58 lines (48 loc) · 1.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
import
fs
from
"node:fs"
;
import
path
from
"node:path"
;
import
url
from
"node:url"
;
import
Ajv
from
"ajv/dist/2020.js"
;
import
addFormats
from
"ajv-formats"
;
const
ROOT
=
path
.
resolve
(
path
.
dirname
(
url
.
fileURLToPath
(
import
.
meta
.
url
)
)
,
".."
)
;
const
RESERVED
=
new
Set
(
[
"schema"
,
"scripts"
,
"node_modules"
,
".github"
,
".git"
,
".claude"
,
"assets"
,
"vendor"
,
"spec"
,
"demo"
,
"template"
,
"preact"
]
)
;
const
isAppDir
=
(
name
)
=>
{
if
(
RESERVED
.
has
(
name
)
)
return
false
;
if
(
name
.
startsWith
(
"."
)
)
return
false
;
if
(
!
/
^
[
A
-
Z
a
-
z
0
-
9
]
[
A
-
Z
a
-
z
0
-
9
_
-
]
*
$
/
.
test
(
name
)
)
return
false
;
return
fs
.
existsSync
(
path
.
join
(
ROOT
,
name
,
"app.json"
)
)
;
}
;
const
META
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
join
(
ROOT
,
"schema"
,
"app.schema.json"
)
,
"utf8"
)
)
;
const
ajv
=
new
Ajv
(
{
strict
:
false
,
allErrors
:
true
}
)
;
addFormats
(
ajv
)
;
const
validateMeta
=
ajv
.
compile
(
META
)
;
const
names
=
fs
.
readdirSync
(
ROOT
,
{
withFileTypes
:
true
}
)
.
filter
(
d
=>
d
.
isDirectory
(
)
)
.
map
(
d
=>
d
.
name
)
.
filter
(
isAppDir
)
.
sort
(
)
;
let
ok
=
0
;
let
failed
=
0
;
for
(
const
name
of
names
)
{
const
filePath
=
path
.
join
(
ROOT
,
name
,
"app.json"
)
;
let
manifest
;
try
{
manifest
=
JSON
.
parse
(
fs
.
readFileSync
(
filePath
,
"utf8"
)
)
;
}
catch
(
e
)
{
console
.
error
(
`[validate]
${
name
}
: malformed JSON —
${
e
.
message
}
`
)
;
failed
++
;
continue
;
}
if
(
!
validateMeta
(
manifest
)
)
{
console
.
error
(
`[validate]
${
name
}
: failed manifest schema:`
,
validateMeta
.
errors
)
;
failed
++
;
continue
;
}
const
entryPath
=
path
.
join
(
ROOT
,
name
,
manifest
.
entry
)
;
if
(
!
fs
.
existsSync
(
entryPath
)
)
{
console
.
error
(
`[validate]
${
name
}
: entry "
${
manifest
.
entry
}
" not found at
${
entryPath
}
`
)
;
failed
++
;
continue
;
}
ok
++
;
}
console
.
log
(
`[validate]
${
ok
}
ok,
${
failed
}
failed`
)
;
if
(
failed
>
0
)
process
.
exit
(
1
)
;
Back
|
FazBrowse Home
|
New Git URL