Clean Command
Supports all Melos filtering flags.
This command cleans the current workspace and all its packages of temporary pub & generated Melos IDE files.
melos clean
These files include;
{packageRoot}/.packages
{packageRoot}/.flutter-plugins
{packageRoot}/.flutter-plugins-dependencies
{packageRoot}/.dart_tool/package_config.json
{packageRoot}/.dart_tool/package_config_subset
{packageRoot}/.dart_tool/version
{workspaceRoot}/.idea/runConfigurations/melos_*.xml
This can be useful to give your workspace a 'fresh start', e.g.;
melos clean
melos bootstrap
Combining with filters
Clean supports all package filtering options, therefore if you wanted to you could clean only a specific subset of your packages, for example:
# Only clean Flutter packages or apps.
melos clean --flutter
Adding a postclean lifecycle script
Melos supports various command lifecycle hooks that can be defined in your
melos.yaml
.
For example, if you needed to cleanup any generated files, e.g. from a build
runner, automatically after melos clean
is ran, you can add a post
hook
script.
# melos.yaml
# ...
command:
clean:
hooks:
post: rm packages/foo/lib/src/generated_file.g.dart
# ...
Another common use case is to run flutter clean
in all Flutter packages;
# melos.yaml
# ...
command:
clean:
hooks:
# Runs "flutter clean" in all Flutter packages (`--flutter`)
# with a concurrency of 3 at a time (`--concurrency=3`).
post: melos exec --flutter --concurrency=3 -- "flutter clean"
# ...