mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-21 10:17:42 +00:00
make update_api_docs.sh work for macOS
This commit is contained in:
@@ -1,17 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
SED_INPLACE=(-i)
|
||||||
|
EXTRA_SED_ARGS=()
|
||||||
|
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
SED_INPLACE=(-i "$1")
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
if sed --version >/dev/null 2>&1; then
|
||||||
|
SED_INPLACE=(-i)
|
||||||
|
else
|
||||||
|
SED_INPLACE=(-i '')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXTRA_SED_ARGS=("$@")
|
||||||
|
|
||||||
|
inplace_sed() {
|
||||||
|
sed "${SED_INPLACE[@]}" "${EXTRA_SED_ARGS[@]}" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/heads/main/templates/swagger/v1_json.tmpl
|
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/heads/main/templates/swagger/v1_json.tmpl
|
||||||
sed -i "$@" 's|"version": "{{.SwaggerAppVer}}"|"version": "dev"|' v1_json.tmpl
|
inplace_sed 's|"version": "{{.SwaggerAppVer}}"|"version": "dev"|' v1_json.tmpl
|
||||||
sed -i "$@" 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
|
inplace_sed 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
|
||||||
mv v1_json.tmpl static/swagger-latest.json
|
mv v1_json.tmpl static/swagger-latest.json
|
||||||
|
|
||||||
for ver in '1.25.1' '1.24.7' '1.23.8' '1.22.6'; do
|
for ver in '1.25.1' '1.24.7' '1.23.8' '1.22.6'; do
|
||||||
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v${ver}/templates/swagger/v1_json.tmpl
|
curl --silent --output v1_json.tmpl https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v${ver}/templates/swagger/v1_json.tmpl
|
||||||
sed -i "$@" "s|\"version\": \"{{.SwaggerAppVer}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
inplace_sed "s|\"version\": \"{{.SwaggerAppVer}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
||||||
sed -i "$@" 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
|
inplace_sed 's|"basePath": "{{.SwaggerAppSubUrl}}/api/v1"|"basePath": "https://gitea.com/api/v1"|' v1_json.tmpl
|
||||||
# for versions < 1.24
|
# for versions < 1.24
|
||||||
sed -i "$@" "s|\"version\": \"{{AppVer \| JSEscape}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
inplace_sed "s|\"version\": \"{{AppVer \| JSEscape}}\"|\"version\": \"${ver}\"|" v1_json.tmpl
|
||||||
sed -i "$@" 's\"basePath": "{{AppSubUrl | JSEscape}}/api/v1"\"basePath": "https://gitea.com/api/v1"\' v1_json.tmpl
|
inplace_sed "s#\"basePath\": \"{{AppSubUrl | JSEscape}}/api/v1\"#\"basePath\": \"https://gitea.com/api/v1\"#" v1_json.tmpl
|
||||||
minor=$(echo "$ver" | cut -d '.' -f 2)
|
minor=$(echo "$ver" | cut -d '.' -f 2)
|
||||||
mv v1_json.tmpl static/swagger-$minor.json
|
mv v1_json.tmpl static/swagger-$minor.json
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user