invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.19k stars 207 forks source link

Feature: allow versioning private packages #44

Closed ajbarry closed 3 years ago

ajbarry commented 3 years ago

Melos appears to be just what I was looking for to help with the release process for a couple of flutter apps that have a shared (private) package. I have been looking through the docs, examples, issues etc but I am unable to figure out if our current use-case is supported. Here is a melos.yaml config that I am hoping is supported but I can't seem to use the melos version command to bump and generate the app changelogs as I hoped:

name: MyMonoRepo
packages:
  - app_common/**  # shared common package (publish_to: none)
  - admin_app/**   # flutter admin app, depends on app_common (publish_to: none)
  - user_app/**    # flutter end-user app, depends on app_common (publish_to: none)
environment:
  sdk: ">=2.7.0 <3.0.0"
  flutter: ">=1.24.0-0.0.pre <1.25.0"

The result of my command line session yields:

❯ melos list --all --scope="user_app"
user_app

❯ melos version --scope="user_app"
melos version
   └> /Users/me/workspace/mymonorepo

No packages were found that required versioning.
Hint: try running "melos list" with the same filtering options to see a list of packages that were included.

I have tried all combinations I can think of using --all, --private, --no-published etc.

Is this a matter of misconfiguration, filesystem layout or something just not supported at this time?

Salakar commented 3 years ago

for a couple of flutter apps that have a shared (private) package

This is definitely supported and a common use case that melos supports as you described.

However, versioning works for pub.dev only and skips private packages (I imagine your apps have publish_to: none on their pubspec.yaml files). Not sure what your use case here for versioning private apps but I guess we could make a change to allow the version bump to still occur for private packages. This is where it gets excluded so you should be able to test it out easily locally by removing these lines: https://github.com/invertase/melos/blob/master/packages/melos/lib/src/command/version.dart#L122-L124 (though we'd probably need to put this behind a flag so as not to be a breaking change).

Everything else apart from versioning should all be working though, with your shared package correctly interlinked across your apps in Dart.

QuirijnGB commented 3 years ago

I have a similar use case, multiple customer facing apps that depend on common packages. Ideally you'd be able to bump and version a specific app for release

Salakar commented 3 years ago

I have a similar use case, multiple customer facing apps that depend on common packages. Ideally you'd be able to bump and version a specific app for release

If we can get that line I mentioned above changed to not skip private packages then if you change the common package, and run melos version - melos will bump all packages (or in your case apps) that depend on the common package

QuirijnGB commented 3 years ago

I just tried that and it doesnt seem to find anything: No packages were found that required versioning. Aside from the Conventional Commits is there anything else that needs to be done to make it work?

Salakar commented 3 years ago

Ah ye forgot, there's multiple places where private packages are filtered out, will need to remove that one I mentioned previously and also this one: https://github.com/invertase/melos/blob/master/packages/melos/lib/src/command/version.dart#L184-L186 - should be fine after that.

kansson commented 3 years ago

Any update on this? Can the package be used to version a private package?

Salakar commented 3 years ago

Any update on this? Can the package be used to version a private package?

The changes I mentioned above would need doing through a PR which would allow this. It's been low priority for me and was hoping someone would help out and contribute a PR for this, otherwise it may be while until I get to it. PRs are reviewed and shipped fairly quickly.

kansson commented 3 years ago

Any update on this? Can the package be used to version a private package?

The changes I mentioned above would need doing through a PR which would allow this. It's been low priority for me and was hoping someone would help out and contribute a PR for this, otherwise it may be while until I get to it. PRs are reviewed and shipped fairly quickly.

Happy to contribute with a PR for this.

Salakar commented 3 years ago

Any update on this? Can the package be used to version a private package?

The changes I mentioned above would need doing through a PR which would allow this. It's been low priority for me and was hoping someone would help out and contribute a PR for this, otherwise it may be while until I get to it. PRs are reviewed and shipped fairly quickly.

Happy to contribute with a PR for this.

Yes please

Salakar commented 3 years ago

This is now available in 0.4.7 as --all - thanks @essarn for the PR (#67).