-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgenerate-json-schemas
More file actions
executable file
·38 lines (32 loc) · 1.23 KB
/
generate-json-schemas
File metadata and controls
executable file
·38 lines (32 loc) · 1.23 KB
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
#!/bin/bash
set -eu
cd "$(dirname "$0")/.."
# Generate the schemas to a temporary directory and then move them into their
# canonical positions at the end. This means we can wipe the src/json-schemas
# directory to ensure that it only contains correct generated files. But also
# works around the requirement that the schemas must exist during generation,
# because they are imported by the typescript, so we cannot compile it to
# generate the schemas unless all imported schemas files exist.
rm -rf json-schemas-tmp
mkdir json-schemas-tmp
generate_schema () {
npx ts-json-schema-generator \
--path $1 \
--type $2 \
--out json-schemas-tmp/$2.json \
--tsconfig tsconfig.json \
--additional-properties \
--no-type-check
}
generate_schema ./src/inputs.ts RepoArray
generate_schema ./src/inputs.ts Instructions
generate_schema ./src/codeql.ts Sarif
generate_schema ./src/codeql.ts BQRSInfo
generate_schema ./src/codeql.ts ResolvedQueries
generate_schema ./src/codeql.ts ResolvedDatabase
generate_schema ./src/codeql.ts QueryMetadata
generate_schema ./src/gh-api-client.ts RepoTask
generate_schema ./src/gh-api-client.ts Policy
rm -rf src/json-schemas/*
mv json-schemas-tmp/* src/json-schemas
rmdir json-schemas-tmp