blob: b670fdbee12395af18941012b40edad68600a3a6 (
plain) (
blame)
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
|
#!/bin/bash
set -e
# generates nginx.d.ts from the latest version of njs-types published on npm
test -d nginx/types && rm -r nginx/types
mkdir nginx/types
test -f nginx/nginx.d.ts && rm nginx/nginx.d.ts
doc=$(curl https://registry.npmjs.org/njs-types)
ver=$(echo "$doc" | jq -r '."dist-tags".latest')
echo "downloading $ver"
url=$(echo "$doc" | jq -r .versions.'"'"$ver"'"'.dist.tarball)
curl "$url" | tar xzC nginx/types --strip-components=1
echo concatenating
for file in nginx/types/*.d.ts nginx/types/**/*.d.ts; do
name="${file#nginx/types/}"
[ "$name" = "index.d.ts" ] && continue # index.d.ts is just references. lame!
{
echo -e "// $name\n"
sed 's|^/// <reference .*$||' "$file" # filter out xml references
echo
} >> nginx/nginx.d.ts
done
rm -r nginx/types
if command -v prettier >/dev/null; then
echo formatting
prettier --write nginx/nginx.d.ts
fi
|