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.13k stars 201 forks source link

fix: bootstrap dependency override failing if package is not in pub.dev #660

Closed oravecz-jpmc closed 6 months ago

oravecz-jpmc commented 6 months ago

Is there an existing issue for this?

Version

5.1.0

Description

Melos throws an error if I attempt to override a package version specified as an override in my melos.yaml bootstrap config.

pubspec.yaml

dependencies:
  flutter_auth_web: any

melos.yaml

command:
  bootstrap:
    runPubGetInParallel: false

    dependencies:
      flutter_auth_web:
        git:
          url: ssh://git@bitbucketdc-cluster07-ssh.myorg.net/auth/flutter_auth_web.git
          ref: develop

Error

% melos bootstrap
Resolving dependencies... (1.5s)
Because main depends on flutter_auth_web any which doesn't exist (could not find package flutter_auth_web at https://mypub.aws.myorg.net), version solving failed.

Steps to reproduce

  1. Provide a repository override in melos.yaml for a package that does not exist in Pub
  2. run melos bootstrap

Expected behavior

I would expect the version override in melos.yaml to take priority over any settings in the packages in my monorepo.

Hopefully, I am understanding the documentation regarding bootstrap config and what a "shared version" is.

Screenshots

No response

Additional context and comments

We run a private repository, and this package is a work in progress. I have not yet published it to our internal Pub repository.

spydon commented 6 months ago

Is this your root pubspec (where only the melos dependency should be)? Can you post your full pubspec and melos file.

oravecz-jpmc commented 6 months ago

I can see how a root pubspec might only include melos.yaml if I was building a library, but this is a UX project with different app features organized in a monorepo manner.

Even running melos clean fails with the same error

spydon commented 6 months ago

I can see how a root pubspec might only include melos.yaml if I was building a library, but this is a UX project with different app features organized in a monorepo manner.

I think you might have misunderstood me, you still need a root pubspec, but you shouldn't have any package/app in the root of your monorepo where the workspace is defined. You can read about the recommended structure here: https://melos.invertase.dev/getting-started#recommended-directory-structure

oravecz-jpmc commented 6 months ago

That goes a bit beyond a recommended structure. :) You mean it is a required structure, or more succinctly, if you use Melos, you cannot have a root pubspec.yaml with dependencies other than melos, and thus you cannot have the typical Flutter structure where a lib folder contains your main UX code.

I'll try that structure and see how it works for me.

spydon commented 6 months ago

if you use Melos, you cannot have a root pubspec.yaml with dependencies other than melos,

Yes, that is correct, and monorepos in general are not recommended to have projects in the root of the repository.

... and thus you cannot have the typical Flutter structure where a lib folder contains your main UX code.

Of course you can, but since it is a monorepo it should live within the project that it belongs to (and no project should live in the root, since that is where the monorepo workspace is defined), for example if you have an app named your_app it could look like this:

my_project/
├── apps/
│    └─ your_app/
|        ├─ pubspec.yaml
|        └─ lib/
├── melos.yaml
├── pubspec.yaml
└── README.md

The recommended Flutter structure is per app/package/plugin, not per repository.

spydon commented 6 months ago

@oravecz-jpmc if that didn't solve your issue, feel free to just write in here and I'll re-open it :)