-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.sh
executable file
·46 lines (35 loc) · 1.13 KB
/
cli.sh
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
#!/usr/bin/env bash
set -euo pipefail
THIS_DIR="$(dirname "$(realpath "$0")")"
build_npm() {
deno run -A --check "$THIS_DIR"/scripts/build-npm.ts "$@"
}
publish_npm() {
npm publish ./dist
}
gen_types() {
local SPEC_URL=${1:-"https://raw.githubusercontent.com/kubernetes/kubernetes/v1.29.1/api/openapi-spec/swagger.json"}
echo "// deno-lint-ignore-file no-empty-interface" > "$THIS_DIR"/src/openapi.ts
echo "// Generated from ${SPEC_URL}" >> "$THIS_DIR"/src/openapi.ts
openapi-ts-gen <(curl -sf "${SPEC_URL}") "$THIS_DIR"/scripts/openapi-ts-formatter.mjs >> "$THIS_DIR"/src/openapi.ts
echo "// Generated from ${SPEC_URL}" > "$THIS_DIR"/src/legacy-types.ts
deno run -A --check "$THIS_DIR"/scripts/generate-legacy-types.ts "${SPEC_URL}" >> "$THIS_DIR"/src/legacy-types.ts
"$0" auto_fmt
}
code_quality() {
echo "Checking for unformatted TypeScript sources"
deno fmt --check
echo "Linting all TypeScript sources"
deno lint
}
auto_fmt() {
echo "Auto-formatting TypeScript sources"
deno fmt
}
update_cache() {
echo "Updating cache"
rm -f ./deno.lock
deno cache ./src/**.ts ./scripts/**.ts
echo "All good!"
}
"$@"