-
Notifications
You must be signed in to change notification settings - Fork 17
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: add clean models to preGen #271
Conversation
✅ Deploy Preview for api-clients-automation canceled. 🔨 Explore the source changes: eb79948 🔍 Inspect the deploy log: https://app.netlify.com/sites/api-clients-automation/deploys/623899b5d1e860000910f9d5 |
✗ The generated branch has been deleted. If the PR has been merged, you can check the generated code on the |
70d6d57
to
9f7e31f
Compare
scripts/generate.ts
Outdated
let modelPath = ''; | ||
switch (language) { | ||
case 'javascript': | ||
modelPath = 'model'; |
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.
I first used workspace commands but went back to rm -rf
to avoid impacting the package.json
of the generated client.
scripts/generate.ts
Outdated
modelPath = 'model'; | ||
break; | ||
case 'java': | ||
modelPath = `algoliasearch-core/com/algolia/model/${client}`; |
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.
what if we move these to clients.config.json
?
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.
Good idea!! done here: abd3048#diff-64a51f57427aace9dbccb385845d777dc94715dfa53fbac8e1651edfa3674bceR1
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.
Will save lots of ugly unused models !
scripts/generate.ts
Outdated
return; | ||
} | ||
|
||
if (modelPath) { |
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.
small refacto, you could create a function removeExistingModels
to return early and avoid this if
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.
Do you mean having an early if for php
? Since we are actually re-adding models I thought it was not necessary to extract the logic, but lmk if this is not what you meant
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.
Actually it make sense coupled with Eunjae's suggestion, I'll do it!
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.
…ients-automation into chore/clean-models-pregen
scripts/generate.ts
Outdated
|
||
await run( | ||
`rm -rf ${toAbsolutePath( | ||
path.resolve(output, `/${baseModelFolder}`, clientModel) |
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.
path.resolve(output, `/${baseModelFolder}`, clientModel) | |
path.resolve(output, `${baseModelFolder}`, clientModel) |
You have to remove the leading \
otherwise it's interpreted as root path, and ignores the param before it.
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.
TIL!!! Good to know (and weird behavior), but at least it's much cleaner
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.
resolve
is the glue of pieces for path, like /
for mac and linux, and \
for windows. So you don't need any :)
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.
Thanks both!!
🧭 What and Why
🎟 JIRA Ticket: -
Changes included:
Because doing it manually is really annoying.
As models are not deleted before a new gen, this PR adds a cleaning step to the
preGen
script.🧪 Test
CI :D