Let's say I develop the 4 packages. My workspace looks like this:
- ios_transmogrify > depends on core_transmogrify
- android_transmogrify > depends on core_transmogrify
- core_transmogrify > depends on core_tools
- core_tools
In the pubspect.yaml
of each project repo, they each point to the released version (or remote git) of their dependencies. For example, in ios_transmogrify, we could see:
dependencies:
core_transmogrify: ^1.1.0
Now, I want to edit files in all 4 packages and see the change during dev in the running program.
My step:
I Git clone all 4 packages ( or their monorepo)
For each projects, I manually edit their pubspec.yaml
to point to the local path.
package_name: <release_version>
package_name: path: ../the/local/path
I repeat this process manually 4 times for each project.
I run the project and I start editing the files.
When I am done editing, I want to push the change.
pubspec.yaml
again to point to their remote repositories)That is so manual, prone to human error. And this repeats on every commit followed by a Git push.
I explored every options I know.
I used a custom bash script like setup_locally.sh
and prepare_for_push.sh
. This is tedious and will work only for one project.
If I have new project called yet_another_transmogrify
that depends on core_tools
, I will have to create the two bash files for that new projects.
I also tried git hooks, but this must be manually set for each project workspace. The setup is not stored remotely in the repo itself.
I even tried Github actions to modify the pubspect.yaml remotely when it is pushed. But this is expensive, and again, needs to be setup on every project.
It will be so great if we can override specific pubspec.yaml
dependencies with another file, let's say pubspect.local.yaml
. If the package is in the local.yaml file, it will behave like dependency_override
. The advantage here is that pubspect.local.yaml
is not checked in Git and pubspec.yaml
remain untouched.
I understand that this feature require the dart compiler to be smart enough to do this override.
My question applies for NodeJS, Python, and other langugages. So if there is a tool that is language agnostic, it will be even better.
"It will be so great if we can override specific pubspec.yaml dependencies with another file,"
You mean like dart.dev/tools/pub/dependencies#dependency-overrides which has been in place for years now?
Melos (in the pub) can help you manage those files as well.