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

feat: sort entries by references before add #913

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

Cyberxon
Copy link
Contributor

In order to avoid errors when creating entries using the contentful-merge cli, we introduced a sort on the Add task where we make sure we order the Add changeset in a way that the referenced entries come before the entries they are referenced in.

@Cyberxon Cyberxon marked this pull request as ready for review August 12, 2024 13:48
@Cyberxon Cyberxon requested a review from a team as a code owner August 12, 2024 13:48
@Cyberxon Cyberxon requested a review from marcolink August 12, 2024 13:48
Copy link
Member

@marcolink marcolink left a comment

Choose a reason for hiding this comment

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

Looking good 👏
Maybe we should mention in code or the PR description that this logic is "inspired" by the import CLI.

src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
Copy link

@screamcha screamcha left a comment

Choose a reason for hiding this comment

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

In general I prefer using native JS methods, especially if it's straightforward, because of the following reasons:

  • it improves code readability - it's safer to assume that more people are familiar with native JS methods than methods from 3rd party lib
  • it reduces dependency on the 3rd party lib
  • in most of the cases it doesn't bring any value as the language provides decent alternatives
    I'd ask you to refrain from such methods as map, filter, get etc. from lodash where they don't bring more to the table compared to the native methods.
    I will be happy to discuss it further, there's a high chance I'm missing something so feel free to let me know :)

src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
src/engine/utils/sort-entries-by-reference.ts Outdated Show resolved Hide resolved
@Cyberxon Cyberxon requested a review from screamcha August 14, 2024 11:41
Copy link

@screamcha screamcha left a comment

Choose a reason for hiding this comment

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

🥇

@Cyberxon Cyberxon merged commit 5f72256 into main Aug 14, 2024
9 checks passed
@Cyberxon Cyberxon deleted the feat/sort-entries-by-reference branch August 14, 2024 11:57
@contentful-automation
Copy link

🎉 This PR is included in version 2.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants