-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_package.sh
executable file
·48 lines (39 loc) · 1.5 KB
/
update_package.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
47
48
#!/bin/sh
generator_jar=${OPENAI_GENERATOR_PATH:-}
# check whether 'openapi-generator-cli' is available
if command -v openapi-generator-cli &> /dev/null; then
CMD=openapi-generator-cli
elif [ ! -z "${generator_jar}" ]; then
CMD="java -Dcolor -jar $generator_jar"
else
echo "openapi-generator-cli is not available!"
echo "Please install it or set OPENAI_GENERATOR_PATH to the path of the openapi-generator-cli.jar file."
exit 1
fi
api_spec=https://us-west-2.api.lamin.ai/openapi.json
pkg_name=laminr.api
pkg_ver=$(curl $api_spec | jq -r '.info.version')
echo "Generating R client package using OpenAI Generator..."
echo "Generator JAR: $generator_jar"
echo "API Spec: $api_spec"
echo "Package Name: $pkg_name"
echo "Package Version: $pkg_ver"
eval $CMD generate \
-g r \
--input-spec $api_spec \
--output . \
--package-name $pkg_name \
--additional-properties=packageName=$pkg_name,packageVersion=$pkg_ver,exceptionPackage=rlang
# remove docs/ because this documentation could be generated by pkgdown
rm -r docs/
# Hack to fix the auto-generated documentation so that checks pass
sed -i 's/\[\*\*AnyType\*\*\](AnyType\.md)/AnyType/g' docs/DefaultApi.md
sed -i 's/\\link{AnyType}/AnyType/g' R/default_api.R
sed -i 's#${module}.\${model}#module + "." + model#g' R/default_api.R
echo "Styling package..."
Rscript -e "styler::style_pkg(include_roxygen_examples = TRUE)"
echo "Documenting package..."
Rscript -e "devtools::document()"
echo
echo "NEXT STEPS:"
echo "Run 'quarto render README.qmd'"