To install the mt command:
# pub global activate mt
Create a fork, and clone your fork to your workstation.
Then do pub get
to install the dependencies.
To execute the program, dart run bin/mt.dart
.
To install mt globally during development, you can use dart run bin/mt.dart install
.
The biggest reason to use monorepos for Dart projects is to share common custom packages between the programs also in the monorepo. You may wish to work on the packages at the same time as the projects that use them, then publish your packages to pub.dev.
There is an obvious need for a command line tool (or tools in the IDE) to work with monorepos. The mt tool is meant to make managing monorepos easy. For example, mt can (recursively) run pub get on any package directory.
Doing recursive pub get is only one pain point of working with monorepos and Dart.
mt is designed to work on the whole monorepo or any subdirectory/subtree of it, or individual files.
While mt features a rich set of commands and options/flags for those commands, you can create a mt.yaml file within each project/package directory of your monorepo to provide additional hints or directives to be honored by mt when it runs.
In a Dart program(s) monorepo, we may have a packages/ folder with some number of individual package directories. Each of those package directories will have its own pubspec.yaml, and we need to run pub get within.
To bump a package's version number, you need to edit CHANGELOG.md and add text for the new version, you need to edit the pubspec.yaml file to have the proper version number in it.
You also may need to update several other pubspec.yaml files within the monorepo to reference the package's new version number.
You can bump the pacakge's version number: major, minor, and or point values.
While working on/developing packages that you ultimately want to publish to pub.dev (pub publish), the pubspec.yaml files in your project and package directories might contain relative links to dependencies in your monorepo. But when published, you need to edit all those pubspec.yaml files and convert the relative path entries to version numbers.
The mt tool can recursively edit your pubspec.yaml files to convert to, or create, relative links or convert those links to package versions to be fetched from pub.dev.
When you bump a package's version number, you may want to pub publish it, too. And you then may need to update all the pubspec.yaml files that refer to it.
Your monorepo might contain a number of programs to be built as Docker containers and run via docker-compose.
The mt tool can automatically maintain your docker-compose.yml file by adding or removing service definitions.
As well, you can use mt to run any or all of the containers in production or development mode.
The mt command can be used to generate the directory structure for a new program or package within the monorepo.
The package directory needs to have a README.md, a CHANGELOG.md, a lib/ directory, a pubspec.yaml file, a mt.yaml file, a lib/package-name.dart file, etc.
Additionally, the files need to be added to git.
You can use mt to generate relative and/or pub.dev specific dependencies within all the pubspec.yaml files in the repo or subtree.
You can have mt automatically generate local dependencies by examining the import statements in the .dart files in your package/program directories.
At some point, you will want to prune any packages not used.
See https://pub.dev/documentation/pub_api_client/latest/
Dart SDK 2.x (developed with at least 2.13.4).
PRs welcome. Fork this repository, create a branch to do your work, and when ready, make a PR from your branch.
Modus Create is a digital product consultancy. We use a distributed team of the best talent in the world to offer a full suite of digital product design-build services; ranging from consumer facing apps, to digital migration, to agile development training, and business transformation.
This project is part of Modus Labs.
This project is MIT licensed.