Skip to content
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

chore(tooling): generation script for all language and clients APIC-221 #32

Merged
merged 6 commits into from
Dec 9, 2021

Conversation

millotp
Copy link
Collaborator

@millotp millotp commented Dec 8, 2021

🧭 What and Why

🎟 JIRA Ticket: APIC-221

Generation script to ease tooling and not bloat the package.json.
Support multi-languages, multi-clients, and post-generation-script.

Changes included:

  • create generate.sh
  • remove all generation from the package.json, except generate
  • remove format:spec from the generation

🧪 Test

yarn generate

@millotp millotp self-assigned this Dec 8, 2021
@millotp millotp requested a review from shortcuts December 8, 2021 17:18
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niiiiiiiiiiiiiice

package.json Outdated
"generate:recommend": "yarn generate:js:recommend",
"generate:search": "yarn generate:js:search",
"generate": "yarn generate:js && yarn format:specs",
"generate": "./scripts/generate.sh ${1:-all} ${2:-all} && yarn format:specs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn format:specs could maybe be a post-gen/global.sh script or something? We might have other post gen script related to the specs etc. later.

It might also be a good thing to add a pre-gen like in the CI, to build and validate the specs before generating, wdyt?

package.json Outdated
"generate:recommend": "yarn generate:js:recommend",
"generate:search": "yarn generate:js:search",
"generate": "yarn generate:js && yarn format:specs",
"lint:specs:fix": "yarn prettier --write specs",
Copy link
Member

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 of lint but I don't have a strong opinion

local lang=$1
local client=$2
echo "Generating code for ${lang}-${client}"
yarn openapi-generator-cli generate --generator-key "${lang}-${client}"
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to silence the openapi-generator-cli part ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly wondering if we can silent unless it fails 🤔

echo "Generating code for ${lang}-${client}"
yarn openapi-generator-cli generate --generator-key "${lang}-${client}"

# run the post generation script if it exists (linting and additional files)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to mention this part in our contribution guide

@millotp millotp requested a review from shortcuts December 9, 2021 13:27
Copy link
Member

@shortcuts shortcuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants