-
Notifications
You must be signed in to change notification settings - Fork 21
chore(tooling): generation script for all language and clients APIC-221 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
24e312e
ba35760
959ac8b
a8066d5
493594a
93b1434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Break on non-zero code | ||
set -e | ||
|
||
LANGUAGE=$1 | ||
CLIENT=$2 | ||
|
||
LANGUAGES=(javascript) | ||
CLIENTS=(search recommend personalization) | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" | ||
# Move to the root (easier to locate other scripts) | ||
cd ${DIR}/.. | ||
|
||
generate_client() { | ||
local lang=$1 | ||
local client=$2 | ||
echo "Generating code for ${lang}-${client}" | ||
yarn openapi-generator-cli generate --generator-key "${lang}-${client}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we maybe silence the output of the command? I wonder if it's possible to do it only if it succeed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You want to silence the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly wondering if we can silent unless it fails 🤔 |
||
|
||
# run the post generation script if it exists (linting and additional files) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need to mention this part in our contribution guide |
||
local postgen="./scripts/post-gen/${lang}.sh" | ||
if [[ -f "$postgen" ]]; then | ||
$postgen $client | ||
fi | ||
} | ||
|
||
if [[ $LANGUAGE == "all" ]]; then | ||
LANGUAGE=("${LANGUAGES[@]}") | ||
elif [[ " ${LANGUAGES[*]} " =~ " ${LANGUAGE} " ]]; then | ||
LANGUAGE=($LANGUAGE) | ||
else | ||
echo "Unknown language ${LANGUAGE}" | ||
exit 1 | ||
fi | ||
|
||
if [[ $CLIENT == "all" ]]; then | ||
CLIENT=("${CLIENTS[@]}") | ||
elif [[ " ${CLIENTS[*]} " =~ " ${CLIENT} " ]]; then | ||
CLIENT=($CLIENT) | ||
else | ||
echo "Unknown client ${CLIENT}" | ||
exit 1 | ||
fi | ||
|
||
for lang in "${LANGUAGE[@]}"; do | ||
for client in "${CLIENT[@]}"; do | ||
generate_client $lang $client | ||
done | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
client=$1 | ||
|
||
export CLIENT=$(cat openapitools.json | yarn json "generator-cli.generators.javascript-${client}.output" | sed 's/#{cwd}\///g') | ||
mkdir -p $CLIENT/utils | ||
cp -R clients/algoliasearch-client-javascript/utils/ $CLIENT/utils | ||
|
||
yarn lint:client:fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier is a formatter hence the
format
instead oflint
but I don't have a strong opinion