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: add clean models to preGen #271

Merged
merged 6 commits into from
Mar 21, 2022
Merged

Conversation

shortcuts
Copy link
Member

🧭 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

@shortcuts shortcuts requested a review from a team March 21, 2022 12:17
@shortcuts shortcuts self-assigned this Mar 21, 2022
@shortcuts shortcuts requested review from eunjae-lee and damcou and removed request for a team March 21, 2022 12:17
@netlify
Copy link

netlify bot commented Mar 21, 2022

✅ 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

@shortcuts
Copy link
Member Author

shortcuts commented Mar 21, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the generated/main branch.

@shortcuts shortcuts force-pushed the chore/clean-models-pregen branch from 70d6d57 to 9f7e31f Compare March 21, 2022 13:35
let modelPath = '';
switch (language) {
case 'javascript':
modelPath = 'model';
Copy link
Member Author

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.

@shortcuts shortcuts marked this pull request as ready for review March 21, 2022 14:17
modelPath = 'model';
break;
case 'java':
modelPath = `algoliasearch-core/com/algolia/model/${client}`;
Copy link
Contributor

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?

Copy link
Member Author

@shortcuts shortcuts Mar 21, 2022

Choose a reason for hiding this comment

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

millotp
millotp previously approved these changes Mar 21, 2022
Copy link
Collaborator

@millotp millotp left a 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 !

return;
}

if (modelPath) {
Copy link
Collaborator

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

Copy link
Member Author

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

Copy link
Member Author

@shortcuts shortcuts Mar 21, 2022

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!

Copy link
Member Author

Choose a reason for hiding this comment

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

scripts/pre-gen/setHostsOptions.ts Show resolved Hide resolved

await run(
`rm -rf ${toAbsolutePath(
path.resolve(output, `/${baseModelFolder}`, clientModel)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member Author

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

Copy link
Contributor

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks both!!

scripts/generate.ts Outdated Show resolved Hide resolved
@shortcuts shortcuts enabled auto-merge (squash) March 21, 2022 15:28
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.

3 participants