Fix sed calls in mac (#7245)

This commit is contained in:
Diego Imbert
2025-11-27 18:08:53 +01:00
committed by GitHub
parent ab554241ce
commit b4e85cfe41

View File

@@ -1,31 +1,28 @@
#!/usr/bin/env bash
set -e
if [[ "$OSTYPE" == "darwin"* ]]; then
sed() {
gsed "$@"
}
fi
mkdir openapi || true
# cp ../backend/windmill-api/openapi.yaml openapi/openapi.yaml
LEGACY_WILDCARD="\$ref: \"..\/..\/openflow.openapi.yaml#\/components\/schemas\""
# We will need to use old syntax of openapi to maintain compatability with previous windmill-api versions.
# If we use new format, many models use another namespace, thus make it not fully compatible with old versions
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS version using perl
perl -0777 -pe "s/# -- INLINE START --\n.*?# -- INLINE END --\n/$LEGACY_WILDCARD\n/s" \
../backend/windmill-api/openapi.yaml > openapi/openapi.yaml
else
# Replace everything between markers with legacy wildcard
sed -z "
s/# -- INLINE START --\n.*# -- INLINE END --\n/$LEGACY_WILDCARD\n/g;
" ../backend/windmill-api/openapi.yaml > openapi/openapi.yaml
fi
# Replace everything between markers with legacy wildcard
sed -z "
s/# -- INLINE START --\n.*# -- INLINE END --\n/$LEGACY_WILDCARD\n/g;
" ../backend/windmill-api/openapi.yaml > openapi/openapi.yaml
npx @redocly/openapi-cli@latest bundle openapi/openapi.yaml > openapi-bundled.yaml
if [[ "$OSTYPE" == "darwin"* ]]; then
# sed -z is not supported on macOS, use perl instead
perl -0777 -pe 's/FlowModuleValue:/FlowModuleValue2:/g' openapi-bundled.yaml > openapi-decycled.yaml
else
sed -z 's/FlowModuleValue:/FlowModuleValue2:/' openapi-bundled.yaml > openapi-decycled.yaml
fi
sed -z 's/FlowModuleValue:/FlowModuleValue2:/' openapi-bundled.yaml > openapi-decycled.yaml
echo " FlowModuleValue: {}" >> openapi-decycled.yaml
npx @redocly/openapi-cli@latest bundle openapi-decycled.yaml --ext json -d > openapi-deref.json
@@ -41,18 +38,9 @@ rm openapi*
cp LICENSE windmill-api/
# Check if running on macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS version
sed -i '' '5 i\
license = "Apache-2.0"' windmill-api/pyproject.toml
sed -i '' 's/authors = \[\]/\nauthors = \["Ruben Fiszel <ruben@windmill.dev>"\]/g' windmill-api/pyproject.toml
else
# Linux version
sed -i '5 i license = "Apache-2.0"' windmill-api/pyproject.toml
sed -i '5 i license = "Apache-2.0"' windmill-api/pyproject.toml
sed -i 's/authors = \[\]/authors = \["Ruben Fiszel <ruben@windmill.dev>"\]/g' windmill-api/pyproject.toml
fi
sed -i 's/authors = \[\]/authors = \["Ruben Fiszel <ruben@windmill.dev>"\]/g' windmill-api/pyproject.toml
echo "# Autogenerated Windmill OpenApi Client" >> windmill-api/README.md.tmp
echo "This is the raw autogenerated api client. You are most likely more interested \