### Local Development Setup for Melos Source: https://github.com/invertase/melos/blob/main/CONTRIBUTING.md Commands to set up and activate a local development version of Melos. This includes installing Melos globally, bootstrapping the workspace, and activating the local version. ```bash # Install melos if it's not already installed: dart pub global activate melos # Bootstrap the workspace. melos bootstrap # Activate 'melos' from path: melos activate # Confirm you now using a local development version: melos --help ``` -------------------------------- ### Example Melos Initialization with Options Source: https://github.com/invertase/melos/blob/main/docs/commands/init.mdx Demonstrates a complete Melos workspace initialization, including specifying a custom directory and package glob patterns. ```bash melos init my_workspace \ --directory custom_dir \ --packages "modules/*" ``` -------------------------------- ### Run Melos Bootstrap Command Source: https://github.com/invertase/melos/blob/main/docs/commands/bootstrap.mdx Initializes the workspace and installs remaining package dependencies. Supports all Melos filtering flags. ```bash melos bootstrap # or melos bs ``` -------------------------------- ### Configure Package Filters Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Example of the updated packageFilters configuration syntax compared to the legacy select-package format. ```yaml scripts: test: exec: dart test packageFilters: dirExists: test ``` ```yaml scripts: test: exec: dart test select-package: dir-exists: test ``` -------------------------------- ### Install Melos Globally Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx Install Melos as a global package to make it accessible from anywhere on your system. This is a one-time setup step. ```bash dart pub global activate melos ``` -------------------------------- ### Bootstrap Melos Workspace Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx Run the 'melos bootstrap' command to install all package dependencies, sync shared dependencies, and execute any bootstrap lifecycle scripts. This command initializes your Melos workspace. ```bash melos bootstrap ``` -------------------------------- ### List Packages with Parsable Output Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--parsable` or `-p` flag to get output in a parsable format instead of a columnized view. Defaults to false. ```bash melos list --parsable ``` ```bash melos list -p ``` -------------------------------- ### Configure pubGetArgs in melos.yaml Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Pass additional arguments to the pub get command during the bootstrap process. ```yaml melos: command: bootstrap: pubGetArgs: - --no-precompile ``` -------------------------------- ### Root pubspec.yaml Configuration for Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/README.md This is an example of how your root pubspec.yaml file should look after migrating to Melos 7.x.x, incorporating pub workspaces and Melos configuration. ```yaml name: my_workspace publish_to: none environment: sdk: ^3.9.0 workspace: - packages/helper - packages/client_package - packages/server_package dev_dependencies: melos: ^7.0.0-dev.9 melos: # All of the content of your previous melos.yaml file # (Except for the packages and name) ``` -------------------------------- ### Example Git Dependency with Ref Source: https://github.com/invertase/melos/blob/main/docs/guides/automated-releases.mdx Illustrates how a git dependency with a specific 'ref' in pubspec.yaml looks. Melos can update this 'ref' automatically for git-hosted packages. ```yaml dependencies: internal_dep: git: url: git@github.com:org/repo.git path: packages/internal_dep ref: internal_dep-v0.0.1 ``` -------------------------------- ### Configure version command message template Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Defines the commit message template using mustache syntax. The default template is shown first, followed by a custom configuration example. ```text chore(release): publish packages {new_package_versions} ``` ```yaml command: version: message: | chore: cut package releases 🎉 {new_package_versions} ``` -------------------------------- ### Define dependency overrides in pubspec_overrides.yaml Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Example of how Melos manages dependency overrides with a marker comment to preserve user-defined entries. ```yaml # melos_managed_dependency_overrides: my_pkg dependency_overrides: my_pkg: path: ../external_project/packages/my_pkg ``` -------------------------------- ### Add Post-Clean Script in pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/commands/clean.mdx Define a `post` lifecycle hook in the root `pubspec.yaml` to execute a script after `melos clean` completes. This example shows removing a generated file. ```yaml # root pubspec.yaml # ... melos: command: clean: hooks: post: rm packages/foo/lib/src/generated_file.g.dart # ... ``` -------------------------------- ### Define a Melos Script in pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx Add a 'melos.scripts' section to your root pubspec.yaml to define custom scripts. This example shows how to configure a 'generate' script that runs 'build_runner' in dependent packages. ```yaml name: my_workspace ... melos: scripts: generate: run: melos exec -c 1 --depends-on build_runner -- dart run build_runner build ``` -------------------------------- ### Define Melos Workspace in pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx Configure your workspace by defining package paths in the root 'pubspec.yaml' file. This tells Melos which directories contain your packages. Supports globs starting from Dart v3.11.0. ```yaml name: my_project publish_to: none environment: sdk: ^3.9.0 workspace: - packages/helper - packages/client_package - packages/server_package ``` -------------------------------- ### Bootstrap Melos Workspace Source: https://github.com/invertase/melos/blob/main/docs/commands/init.mdx After initializing a Melos workspace, run this command to set up dependencies and prepare the monorepo for development. ```bash cd melos bootstrap ``` -------------------------------- ### Basic Melos Init Command Source: https://github.com/invertase/melos/blob/main/docs/commands/init.mdx Initializes a new Melos workspace. If no workspace name is provided, it prompts the user or defaults to the current directory name. ```bash melos init [workspace_name] ``` -------------------------------- ### Publish Packages to pub.dev (Actual Release) Source: https://github.com/invertase/melos/blob/main/docs/guides/automated-releases.mdx Execute this command with the --no-dry-run flag to release your versioned packages to pub.dev. ```sh melos publish --no-dry-run ``` -------------------------------- ### Run basic analysis Source: https://github.com/invertase/melos/blob/main/docs/commands/analyze.mdx Executes static analysis on all local packages in the workspace. ```bash melos analyze ``` -------------------------------- ### Version All Packages Including Private Ones Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Use the `--all` or `-a` flag to version private packages that are skipped by default. ```bash melos version --all ``` ```bash melos version -a ``` -------------------------------- ### List Packages as JSON Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--json` flag to display package information as a JSON array. Defaults to false. ```bash melos list --json ``` -------------------------------- ### Clean and Bootstrap Workspace Source: https://github.com/invertase/melos/blob/main/docs/commands/clean.mdx Perform a clean operation followed by a bootstrap to ensure a fresh workspace state. ```bash melos clean melos bootstrap ``` -------------------------------- ### Commit and Push Changes Source: https://github.com/invertase/melos/blob/main/CONTRIBUTING.md Instructions for creating a new branch, making changes, committing with clear messages, and pushing to your fork. Ensure commit messages follow a clear format. ```bash git checkout -b my-new-feature # Make your changes git commit -m 'docs: Add CONTRIBUTING.md' git push origin my-username.my-new-feature ``` -------------------------------- ### Configure exec script with options Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use an object structure to specify the command and additional execution options like concurrency. ```yaml scripts: hello: exec: command: echo 'Hello $(dirname $PWD)' concurrency: 1 ``` -------------------------------- ### Melos CLI Help Output Source: https://github.com/invertase/melos/blob/main/README.md Displays available global options and commands for the Melos CLI. Use `melos help ` for more details on specific commands. ```bash > melos --help A CLI tool for managing Dart & Flutter projects with multiple packages. Usage: melos [arguments] Global options: -h, --help Print this usage information. --verbose Enable verbose logging. --sdk-path Path to the Dart/Flutter SDK that should be used. This command line option has precedence over the `sdkPath` option in the root `pubspec.yaml` configuration file and the `MELOS_SDK_PATH` environment variable. To use the system-wide SDK, provide the special value "auto". Available commands: bootstrap Initialize the workspace, link local packages together and install remaining package dependencies. Supports all package filtering options. clean Clean this workspace and all packages. This deletes the temporary pub & ide files such as ".packages" & ".flutter-plugins". Supports all package filtering options. exec Execute an arbitrary command in each package. Supports all package filtering options. format Idiomatically format Dart source code. list List local packages in various output formats. Supports all package filtering options. publish Publish any unpublished packages or package versions in your repository to pub.dev. Dry run is on by default. run Run a script by name defined in the workspace pubspec.yaml config file. version Automatically version and generate changelogs based on the Conventional Commits specification. Supports all package filtering options. Run "melos help " for more information about a command. ``` -------------------------------- ### Configure root as a package Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Enable the root directory as a package to include it in workspace operations like scripts and filtering. ```yaml melos: useRootAsPackage: true categories: app: - "." packages: - "packages/**" ``` -------------------------------- ### Enable/Disable Release URL Generation Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Generate and print a link to a prefilled release creation page for each package using the `--release-url` (or `-r`) flag. The default is `false`. Use `--no-release-url` to disable. ```bash melos version --release-url ``` ```bash melos version -r ``` -------------------------------- ### Graduate Prerelease Versions to Stable Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Use the `--graduate` or `-g` flag to promote existing prerelease versions to stable versions. This flag cannot be combined with the `--prerelease` flag. ```bash melos version --graduate ``` ```bash melos version -g ``` -------------------------------- ### Create Workspace pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Define the workspace root pubspec.yaml to specify the Melos version. ```yaml name: my_project_workspace environment: sdk: '>=3.0.0 <4.0.0' ``` -------------------------------- ### Define Package Directories with Melos Init Source: https://github.com/invertase/melos/blob/main/docs/commands/init.mdx Specifies additional glob patterns for package directories to include in the workspace using the `--packages` option. This can be specified multiple times or with comma-separated values. ```bash melos init --packages "modules/*" --packages "libs/*" ``` -------------------------------- ### Configure simple exec script Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Define a basic command to run across packages using the exec key. ```yaml scripts: hello: exec: echo 'Hello $(dirname $PWD)' ``` -------------------------------- ### Configure Publish Server in melos.yaml Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Sets the package server URL workspace-wide in `melos.yaml` via the `pubServer` option. ```yaml command: publish: pubServer: https://pub.flutter-io.cn ``` -------------------------------- ### Define Pre and Post Publish Hooks Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Configures pre- and post-publish hook scripts in the root `pubspec.yaml` to run commands before and after publishing. ```yaml # root pubspec.yaml # ... melos: command: publish: hooks: pre: dart pub run build_runner build post: dart pub run build_runner clean # ... ``` -------------------------------- ### Define a complex workspace script Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use the extends syntax to provide a name, description, run command, and environment variables. ```yaml scripts: hello: name: hey description: Greet the world run: echo "$GREETING World" env: GREETING: 'Hey' ``` -------------------------------- ### Specify Workspace Directory with Melos Init Source: https://github.com/invertase/melos/blob/main/docs/commands/init.mdx Initializes a Melos workspace in a specific directory using the `--directory` option. If not provided, the user is prompted or it defaults to the workspace name or current directory. ```bash melos init my_workspace --directory custom_dir ``` -------------------------------- ### Define a simple workspace script Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use the simple syntax to define a script name and its corresponding command. ```yaml melos: scripts: hello: echo 'Hello World' ``` -------------------------------- ### Define sequential workflows with steps Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Combine multiple commands into a single script definition to execute them sequentially. ```yaml scripts: pre-commit: description: pre-commit git hook script steps: - echo 'hello world' - format --output none --set-exit-if-changed - dart test --fail-fast . ``` -------------------------------- ### Configure pub workspaces for Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Defines the structure for root and package-level pubspec.yaml files required for pub workspace integration. ```yaml name: my_workspace publish_to: none environment: sdk: ^3.9.0 workspace: - packages/helper - packages/client_package - packages/server_package dev_dependencies: melos: ^7.0.0 melos: # All of the content of your previous melos.yaml file # (Except for the packages and name) ``` ```yaml name: my_package environment: sdk: ^3.9.0 resolution: workspace ``` -------------------------------- ### List Package Dependencies for Cycles Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--cycles` flag to find and list cycles in the package dependencies within the workspace. ```bash melos list --cycles ``` -------------------------------- ### List Packages Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Basic command to list information about local packages in the workspace. Supports all Melos filtering flags. ```bash melos list ``` -------------------------------- ### Define self-hosted repository Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure a self-hosted instance by providing the type, origin, owner, and name. ```yaml melos: repository: type: gitlab origin: https://gitlab.example.dev owner: invertase name: melos ``` -------------------------------- ### Configure interactive script with stdio inheritance Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use inherit to connect a script directly to the terminal for interactive commands like tmux or vim. ```yaml scripts: attach: run: tmux attach -t my_session stdio: inherit ``` -------------------------------- ### List Package Dependency Graph in Graphviz DOT Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--gviz` flag to display the package dependency graph in the Graphviz DOT language. Defaults to false. ```bash melos list --gviz ``` -------------------------------- ### List all scripts Source: https://github.com/invertase/melos/blob/main/docs/commands/run.mdx Displays all scripts defined in the Melos workspace. Use `--json` to output the list in JSON format. ```bash melos run --list ``` ```bash melos run --list --json ``` -------------------------------- ### Toggle tag fetching Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Determines whether to fetch tags from the origin remote before versioning. ```yaml melos: command: version: fetchTags: false ``` -------------------------------- ### Enable root package usage in Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Configures the root directory as a package within the workspace using the useRootAsPackage option. ```yaml # pubspec.yaml name: my_workspace publish_to: none environment: sdk: ^3.9.0 workspace: - packages/helper - packages/client_package melos: useRootAsPackage: true categories: app: - "." packages: - "packages/**" ``` -------------------------------- ### List Package Dependency Graph as JSON Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--graph` flag to display the package dependency graph as a JSON-formatted adjacency list. Defaults to false. ```bash melos list --graph ``` -------------------------------- ### List Packages with Extended Information Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--long` or `-l` flag to display extended or verbose information about packages. Defaults to false. ```bash melos list --long ``` ```bash melos list -l ``` -------------------------------- ### Publish and Add Git Tags Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Publishes packages and adds any missing git tags for release. Tags are only created if `--no-dry-run` is also set. ```bash melos publish --no-dry-run --git-tag-version ``` -------------------------------- ### Version Packages as Prerelease Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Use the `--prerelease` or `-p` flag to version packages with changes as prereleases. This flag cannot be combined with the `--graduate` flag. ```bash melos version --prerelease ``` ```bash melos version -p ``` -------------------------------- ### List Package Dependency Graph in Mermaid Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--mermaid` flag to display the package dependency graph in Mermaid Diagram format. Defaults to false. ```bash melos list --mermaid ``` -------------------------------- ### Configure SDK path Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Set a custom path for the Dart or Flutter SDK, or use 'auto' for the system-wide SDK. ```yaml melos: sdkPath: .fvm/flutter_sdk ``` -------------------------------- ### Run Melos Format Command Source: https://github.com/invertase/melos/blob/main/docs/commands/format.mdx Execute the basic format command to format code in your Melos workspace. ```bash melos format ``` -------------------------------- ### Add Melos Dependency Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Add Melos as a development dependency to the workspace root. ```bash dart pub add melos --dev ``` -------------------------------- ### Run Melos Version Command Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Execute the basic `melos version` command to automatically version and generate changelogs for all packages. ```bash melos version ``` -------------------------------- ### Configure aggregate changelogs Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Sets up custom changelog files for specific package groups using package filters. ```yaml melos: command: version: changelogs: - path: FOO_CHANGELOG.md description: | All notable changes to foo packages will be documented in this file. packageFilters: scope: foo_* ``` -------------------------------- ### List scripts including private Source: https://github.com/invertase/melos/blob/main/docs/commands/run.mdx Ignores the private configuration on scripts, showing private scripts in prompts, listings, and allowing them to be executed directly. ```bash melos run --list --json ``` -------------------------------- ### Configure exec scripts for Melos 8.0.0 Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Updates the script configuration to use the 'command' key within 'exec', as 'run' and 'exec' are now mutually exclusive. ```yaml # Before (no longer supported) scripts: test: run: dart test --concurrency=1 exec: concurrency: 1 ``` ```yaml # After scripts: test: exec: command: dart test --concurrency=1 concurrency: 1 ``` ```yaml scripts: hello: exec: echo 'Hello $(dirname $PWD)' ``` -------------------------------- ### Manually Specify Package Versions Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx Use the `--manual-version` or `-V` flag to manually set specific versions for packages. Each argument must be in the format `:`. This flag cannot be combined with `--graduate` or `--prerelease`. ```bash melos version --manual-version=foo:patch ``` ```bash melos version --manual-version=foo:1.0.0 ``` ```bash melos version -V foo:1.0.0 ``` ```bash melos version --manual-version=foo:patch --manual-version=bar:major ``` ```bash melos version --manual-version=foo:1.0.0 --manual-version=bar:1.0.0 ``` ```bash melos version -V foo:1.0.0 -V bar:2.0.0 ``` -------------------------------- ### Configure Post Bootstrap Script in Melos Source: https://github.com/invertase/melos/blob/main/docs/commands/bootstrap.mdx Add a 'post' hook to the 'bootstrap' command in your root pubspec.yaml to run a script after 'melos bootstrap' completes. This ensures local project requirements, like generated files, are met. ```yaml melos: command: bootstrap: hooks: post: dart pub run build_runner build ``` -------------------------------- ### Configure changelog format Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Settings for date inclusion and grouping entries by commit type in the changelog. ```yaml melos: command: version: changelogFormat: includeDate: true groupByType: true ``` ```md ## 1.2.0 ### Features - added user authentication. - implemented dark mode support. ### Bug Fixes - corrected issue with API call. - resolved UI glitch on iOS. ``` -------------------------------- ### List Packages with Relative Paths Source: https://github.com/invertase/melos/blob/main/docs/commands/list.mdx Use the `--relative` or `-r` flag to show package paths relative to the workspace root. Defaults to false (full paths). ```bash melos list --relative ``` ```bash melos list -r ``` -------------------------------- ### Specify Prerelease Identifier Source: https://github.com/invertase/melos/blob/main/docs/commands/version.mdx When using the `--prerelease` flag, specify a custom prerelease identifier (e.g., 'beta') using the `--preid` option to control the prerelease version format. ```bash melos version --prerelease --preid=beta ``` -------------------------------- ### Chain multiple commands in a script Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use the && operator to execute multiple commands sequentially, stopping if a command fails. ```yaml scripts: prepare: melos bootstrap && melos run build ``` -------------------------------- ### Execute a Command with melos exec Source: https://github.com/invertase/melos/blob/main/docs/commands/exec.mdx Run a command in each package. For complex commands or multiple commands, pass them as a single string. ```bash melos exec # e.g. melos exec -- pub global run tuneup check ``` ```shell melos exec -- "melos bootstrap && melos run build" ``` -------------------------------- ### Enable nested workspace discovery Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure Melos to recursively discover packages within nested workspace roots defined by pubspec.yaml files. ```yaml melos: discoverNestedWorkspaces: true # Example workspace layout: # packages/ # base/ # ui/ # workspace root with workspace: ['core', 'components'] # pubspec.yaml # defines workspace: ['core', 'components'] # core/ # pubspec.yaml # components/ # pubspec.yaml # example/ # nested workspace with example # pubspec.yaml # defines workspace: ['example'] # example/ # pubspec.yaml workspace: - packages/** # discovers ui, core, components, example, etc. ``` -------------------------------- ### Run a script by name Source: https://github.com/invertase/melos/blob/main/docs/commands/run.mdx Execute a script defined in the workspace root `pubspec.yaml` config file. Supports all Melos filtering flags. ```bash melos run ``` -------------------------------- ### Filter by File Existence Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--file-exists` to include only packages that contain a specific file. This is useful for targeting packages that have certain files, like configuration or documentation. ```bash # Only bootstrap packages with an README.md file melos bootstrap --file-exists="README.md" ``` -------------------------------- ### Configure Single Package Project Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx For single-package projects, set 'useRootAsPackage: true' in the 'pubspec.yaml' to leverage Melos features like versioning and publishing. This treats the root directory as the main package. ```yaml name: my_single_package publish_to: none environment: sdk: ^3.9.0 dev_dependencies: melos: ^7.0.0 melos: useRootAsPackage: true ``` -------------------------------- ### Configure Melos command hooks Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Define pre and post execution scripts for specific Melos commands within the root pubspec.yaml file. ```yaml command: bootstrap: hooks: pre: echo `bootstrap command is running...` post: echo `bootstrap command is done` ``` -------------------------------- ### Configure dependencyOverridePaths in melos.yaml Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Use glob patterns to reference external local packages relative to the workspace root. ```yaml melos: command: bootstrap: dependencyOverridePaths: - '../external_project/packages/**' ``` -------------------------------- ### Publish Packages Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Publishes any unpublished packages or package versions in your repository to pub.dev. Dry run is enabled by default. ```bash melos publish ``` -------------------------------- ### Manually Version a Single Package Source: https://github.com/invertase/melos/blob/main/docs/guides/automated-releases.mdx Use this command to specify a version increment or exact version for a single package. ```sh melos version ``` -------------------------------- ### Manually Version Multiple Packages Source: https://github.com/invertase/melos/blob/main/docs/guides/automated-releases.mdx Use the --manual-version flag to specify version changes for multiple packages. This allows mixing automatic and manual versioning. ```sh melos version --manual-version : --manual-version : ``` ```sh melos version -V : -V : ``` -------------------------------- ### Run Melos Clean Source: https://github.com/invertase/melos/blob/main/docs/commands/clean.mdx Execute the clean command to remove temporary files from the workspace and all packages. ```bash melos clean ``` -------------------------------- ### Clone Melos Repository Source: https://github.com/invertase/melos/blob/main/CONTRIBUTING.md Clone the Melos repository to your local machine. Use the upstream remote to fetch from the main repository. ```bash git clone git@github.com:/melos.git git remote add upstream git@github.com:invertase/melos.git ``` -------------------------------- ### Define package categories Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Groups packages into categories using glob patterns within the root pubspec.yaml file. ```yaml melos: categories: examples: - packages/example* alpha: - packages/feature_a/* - packages/feature_b ``` -------------------------------- ### Configure pub registry timeouts and retries Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Defines request timeout and retry logic for pub registry interactions. Omit timeoutSeconds or set to 0 to disable request duration limits. ```yaml melos: pub: timeoutSeconds: 60 # optional per-request timeout; 0/omit = no timeout retry: delayFactorMillis: 200 # base delay; doubled each retry randomizationFactor: 0.25 maxDelaySeconds: 30 maxAttempts: 8 # includes the first attempt ``` -------------------------------- ### Publish to a Specific Package Server Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Specifies the URL of the package server to publish to. This overrides the per-package `publish_to` field in `pubspec.yaml`. ```bash melos publish --no-dry-run --server https://pub.flutter-io.cn ``` -------------------------------- ### Ignore pubspec_overrides.yaml Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Add the generated override files to your .gitignore. ```text pubspec_overrides.yaml ``` -------------------------------- ### Define custom run arguments for Flutter apps Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify additional run arguments per package to generate multiple distinct IntelliJ run configurations. ```yaml melos: ide: intellij: runArguments: my_app: - name: local args: "--flavor local --dart-define-from-file=local.json" - name: prod args: "--flavor prod --dart-define-from-file=prod.json" - default: true args: "--flavor dev" ``` -------------------------------- ### Run Flutter Clean via Melos Exec Hook Source: https://github.com/invertase/melos/blob/main/docs/commands/clean.mdx Configure a `post` hook in `melos.yaml` to execute `flutter clean` on all Flutter packages using `melos exec` with specified concurrency. ```yaml # 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" # ... ``` -------------------------------- ### Configure script name prefix Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Customize or remove the prefix applied to generated IntelliJ run configuration names. ```yaml melos: ide: intellij: scriptNamePrefix: "" ``` -------------------------------- ### Filter by Published Packages Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--published` to include only packages where the current local version is already published on pub.dev. Use `--no-published` to filter for packages that have not yet been published. ```bash melos bootstrap --published ``` -------------------------------- ### Configure Package Resolution Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx In each package's 'pubspec.yaml' file, add 'resolution: workspace' to enable workspace-aware dependency resolution. This is crucial for monorepos managed by Melos. ```yaml name: my_package resolution: workspace ... ``` -------------------------------- ### Configure Git Bash on Windows Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx If using Git Bash on Windows, this function ensures the 'melos' command can be called directly. It adds a wrapper to call 'melos.bat' with arguments. ```bash function melos() { melos.bat $@ } ``` -------------------------------- ### Configure Melos script as VS Code task Source: https://github.com/invertase/melos/blob/main/docs/ide-support.mdx Define a VS Code task to run a Melos script by specifying the task type as 'melos' and providing the script name and a label for the task in .vscode/tasks.json. ```json // .vscode/tasks.json { "version": "2.0.0", "tasks": [ { "type": "melos", "script": "test", "label": "melos: test" } ] } ``` -------------------------------- ### Include Transitive Dependencies Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--include-dependencies` to expand the filtered list of packages to also include their transitive dependencies, ignoring any other filters. This ensures all downstream dependencies are processed. ```bash melos list --scope=some_package --include-dependencies ``` -------------------------------- ### Set analysis concurrency Source: https://github.com/invertase/melos/blob/main/docs/commands/analyze.mdx Limits the number of packages analyzed simultaneously. ```bash # Set a 5 concurrency melos analyze -c 5 ``` -------------------------------- ### Run script skipping package selection Source: https://github.com/invertase/melos/blob/main/docs/commands/run.mdx Skips the prompt to select a package if defined in the script configuration. Filters defined in the script's "packageFilters" options will still be applied. ```bash melos run --no-select ``` -------------------------------- ### Filter by Code Changes (Diff) Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--diff` to filter packages based on changes between commits. Specify a single commit hash for comparison with HEAD, or use git shorthand like `origin/main...HEAD` for range comparisons. ```bash # Run `flutter build ios` on all packages that are different between current # branch and the specified commit hash. melos exec --diff= -- flutter build ios ``` ```bash # Run `flutter build ios` on all packages that are different between remote # `main` branch and HEAD. melos exec --diff=origin/main...HEAD -- flutter build ios ``` -------------------------------- ### Configure Release URL Generation Permanently Source: https://github.com/invertase/melos/blob/main/docs/guides/automated-releases.mdx Add 'releaseUrl: true' to your root pubspec.yaml under 'melos.command.version' to permanently enable release URL generation. ```yaml melos: command: version: releaseUrl: true ``` -------------------------------- ### Publish Packages with Dry Run Source: https://github.com/invertase/melos/blob/main/docs/commands/publish.mdx Flags whether to publish the packages as a dry run, which validates but does not publish. This is the default behavior. ```bash melos publish --dry-run ``` ```bash melos publish --no-dry-run ``` -------------------------------- ### Configure fatal info-level issues Source: https://github.com/invertase/melos/blob/main/docs/commands/analyze.mdx Controls whether info-level issues are treated as fatal errors during analysis. ```bash melos analyze --fatal-infos ``` ```bash melos analyze --no-fatal-infos ``` -------------------------------- ### Filter by Direct Dependencies Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--depends-on` to include only packages that directly depend on the specified dependencies. This option can be repeated to specify multiple dependencies. Use `--no-depends-on` to filter packages that do not depend on the given dependencies. ```bash melos exec --depends-on="flutter" --depends-on="firebase_core" -- flutter test ``` -------------------------------- ### Filter by Package Name Glob Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--scope` to include only packages whose names match the provided glob pattern. This option can be repeated to include multiple scopes. ```bash # Run `flutter build ios` on all packages with "example" in the package name melos exec --scope="*example*" -- flutter build ios ``` -------------------------------- ### Define repository URL Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify the git repository URL for the Melos workspace. ```yaml melos: repository: https://github.com/invertase/melos ``` -------------------------------- ### Filter by Directory Existence Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--dir-exists` to include only packages that contain a specific directory. This is useful for targeting packages with certain structural elements. ```bash # Only bootstrap packages with an example directory melos bootstrap --dir-exists="example" ``` -------------------------------- ### Exclude Private Packages Source: https://github.com/invertase/melos/blob/main/docs/filters.mdx Use `--no-private` to exclude packages marked as private (publish_to: none) from command execution. Private packages are included by default. ```bash melos bootstrap --no-private ``` -------------------------------- ### Configure melos.yaml schema in IntelliJ Source: https://github.com/invertase/melos/blob/main/docs/ide-support.mdx Enable autocompletion and validation for melos.yaml in IntelliJ by adding the Melos schema URL in JSON Schema Mappings. This requires Melos v6 or lower. ```json { "version": "2.0.0", "tasks": [ { "type": "melos", "script": "test", "label": "melos: test" } ] } ``` -------------------------------- ### Melos README Badge Source: https://github.com/invertase/melos/blob/main/docs/index.mdx Add this markdown to your project's README to display a badge indicating it is maintained with Melos. ```markdown [![melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos) ``` -------------------------------- ### Configure changelog commit bodies Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Settings for including commit bodies in the generated changelog. ```yaml melos: command: version: changelogCommitBodies: include: true onlyBreaking: false ``` -------------------------------- ### Configure Shared Dependencies in pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/commands/bootstrap.mdx Define shared dependency versions in the root `pubspec.yaml` to ensure consistency across packages. Melos will update package dependency versions to match these configurations during bootstrap. ```yaml # root pubspec.yaml ``` -------------------------------- ### Execute script with package filters Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Use packageFilters to restrict script execution to specific package types, such as Flutter packages. ```yaml scripts: hello_flutter: exec: echo 'Hello $(dirname $PWD)' packageFilters: flutter: true ``` -------------------------------- ### Add Melos as a Dev Dependency Source: https://github.com/invertase/melos/blob/main/docs/getting-started.mdx Add Melos as a development dependency to your workspace's root 'pubspec.yaml' file. This ensures consistent Melos version usage across the project and CI. ```bash dart pub add melos --dev ``` -------------------------------- ### Enable Fail Fast with melos exec --fail-fast Source: https://github.com/invertase/melos/blob/main/docs/commands/exec.mdx Stop executing the script in further packages if it fails in an individual package. Defaults to false. ```bash # Fail fast melos exec --fail-fast -- "dart analyze ." ``` -------------------------------- ### Configure fatal warnings Source: https://github.com/invertase/melos/blob/main/docs/commands/analyze.mdx Controls whether warnings are treated as fatal errors during analysis. ```bash melos analyze --fatal-warnings ``` ```bash melos analyze --no-fatal-warnings ``` -------------------------------- ### Control Concurrency with melos exec -c Source: https://github.com/invertase/melos/blob/main/docs/commands/exec.mdx Limit the number of packages that execute the command concurrently. Defaults to 5. ```bash # Set a 1 concurrency melos exec -c 1 -- "dart analyze ." ```