diff options
author | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
commit | 8cf813ff033bbc98a7dd40db6ac11e2e35c7e997 (patch) | |
tree | a451059194cbd4ba90993ebdaced4749448ec4df /nginx/types.sh | |
download | asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.tar.gz asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.zip |
initial commit
Diffstat (limited to 'nginx/types.sh')
-rwxr-xr-x | nginx/types.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nginx/types.sh b/nginx/types.sh new file mode 100755 index 0000000..b670fdb --- /dev/null +++ b/nginx/types.sh @@ -0,0 +1,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 |