Disclaimer: I made this

I spend a lot of time contributing to huge mono repos (flutter/packages, flutterfire, etc) and while some of them use melos to deal with the mess most of them don’t. To help deal with this, I made puby.

Melos can be useful, but it requires project-specific setup so it’s not good for repos that you don’t control (and don’t already have it set up). puby requires no setup, and you can run it literally anywhere. For example, if you keep all your dart/flutter projects in one directory you can execute commands in all of them at once by running puby in the root directory.

puby can do a lot, but here are the highlights:

Run any pub command

The first thing puby was made for is in its name: running pub commands. Run puby get, puby upgrade, etc to run those commands in all the projects in the current directory. Any extra arguments passed into puby will get passed to the commands puby runs. puby will automatically use the correct root command (dart/flutter) and even supports running with fvm if the project has it set up. puby combines the exit codes of the commands it runs, so it can be used to check for failures in CI.

puby link

puby link uses existing pubspec.lock files to catalog the dependencies required for all projects in the current directory, adds them to the pub cache, and then runs pub get --offline in all the projects in parallel. This can run up to five times faster than a regular pub get. This requires you to check in your pubspec.lock files to git, but the benefit is that when you switch branches a puby link will get you up to date in a few seconds.

puby clean

puby clean used to just be an alias for flutter clean, but since I added support for running commands in parallel for puby link it can now clean all projects in parallel as well. This is useful to clear out the cache of an entire monorepo, but it also has a much cooler use: cleaning up all of your local dart/flutter projects at once. Run puby clean in the directory containing all your local projects and you’ll be surprised how much disk space you can reclaim.

puby exec

Run any command in all projects

Convenience commands

puby comes with many conventience commands to make common tasks easier

command equivalent
puby gen [engine] pub run build_runner build --delete-conflicting-outputs
puby test [engine] test
puby mup [engine] pub upgrade --major-versions
puby reset puby clean && puby get

Outro

My team and I use puby every day. Please let me know what you think!

  • Rexios@lemm.eeOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    The regular commands are dart/flutter pub, so I thought it could be your “pub buddy” or something like that. I didn’t want to add more characters to the command than necessary just so people pronounce it correctly. In context I think it makes sense.