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

melos bootstrap should consider path when comparing two GitReferences #658

Open
1 task done
mateusfccp opened this issue Mar 12, 2024 · 6 comments · May be fixed by #659
Open
1 task done

melos bootstrap should consider path when comparing two GitReferences #658

mateusfccp opened this issue Mar 12, 2024 · 6 comments · May be fixed by #659
Labels
bug Something isn't working

Comments

@mateusfccp
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Version

4.1.0

Description

The _updateDependencies method in the bootstrap command checks if two DependencyReferences are equal to decide if it should update the dependencies of the modules:

https://github.com/invertase/melos/blob/ed826b39761039ba545d3ae7b18f491726d7ebe1/packages/melos/lib/src/commands/bootstrap.dart#L335C1-L362C1

However, the GitReference equals operator considers only the url and ref fields. As a consequence, if you change the path without changing the url or the ref in melos.yaml, the references are not going to be updated in the modules.

I actually lost some hours of work trying to understand why my references were not being updated.

Running melos clean before the bootstrap does not solves the problem.

Thus, Melos should consider the path field when the DependencyReference is a GitReference.

Steps to reproduce

In any Melos project that has at least one git dependency on melos.yaml:

  1. Run melos bootstrap
  2. Change the reference path to something else
  3. Run melos bootstrap again

Expected behavior

The modules references should be updated accordingly to the new path.

Screenshots

No response

Additional context and comments

Workaround: currently, you can workaround this by changing either the url or the ref to something different (it may not exist), run melos bootstrap, revert the changes and run melos bootstrap again.

@spydon
Copy link
Collaborator

spydon commented Mar 12, 2024

Good catch! Do you want to provide a PR for this?

@mateusfccp
Copy link
Author

mateusfccp commented Mar 12, 2024

I may open a PR fixing it tomorrow.

If j4qfrost/pubspec#9 is ever solved we may want to revert the code, but the repository seems to be abandoned (there are some open PRs that were never reviewed).

Maybe we should consider forking it or using pubspec2?

@spydon
Copy link
Collaborator

spydon commented Mar 12, 2024

Maybe we should consider forking it or using pubspec2?

We could ask the author if they would be willing to transfer the repository and the package to one of our pub publishers first, I can do that tomorrow.

@spydon
Copy link
Collaborator

spydon commented Mar 13, 2024

Maybe it is better to move to pubspec2, since it seems quite well maintained.
Could you open an issue/PR there and see if we could get that change in? If so we could start depending on that instead.

@mateusfccp
Copy link
Author

pubspec2 repository has no issues enabled. I'm going to try to contact @bsutton or @onepub-dev.

@mateusfccp
Copy link
Author

mateusfccp commented Mar 13, 2024

I've reached out to @bsutton and he said that he's working on a pubspec_manager, a package to supersede both pubspec and pubspec2.

Using pubspec_manager would require much more changes, as the API is completely different, and I don't know what are the plans of the Melos team. Thus, for now, I am going to provide a PR to fix this issue while still using pubspec and open another issue regarding the replacement of pubspec, as it has been abandoned.

@mateusfccp mateusfccp linked a pull request Mar 13, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants