### 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/*" ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Example: Package filters in scripts (new syntax) Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Demonstrates the new camel-cased package filter syntax for script configurations. Use 'dirExists' instead of 'dir-exists'. ```yaml scripts: test: exec: dart test packageFilters: dirExists: test ``` -------------------------------- ### Example: Package filters in scripts (old syntax) Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Illustrates the previous kebab-cased package filter syntax for script configurations, which has been replaced by camel case. ```yaml scripts: test: exec: dart test select-package: dir-exists: test ``` -------------------------------- ### Include Root as Package Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Enable `useRootAsPackage` to treat the repository root as a package for workspace operations. This is useful for legacy projects or single-package setups. ```yaml melos: useRootAsPackage: true categories: app: - "." packages: - "packages/**" ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure pubGetArgs for Bootstrap Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Pass additional arguments to `pub get` during `melos bootstrap`. Useful for custom flags like `--no-precompile`. ```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 ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### 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. ``` -------------------------------- ### 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 ``` -------------------------------- ### 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/*" ``` -------------------------------- ### Create Workspace Root pubspec.yaml Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx If a workspace root pubspec.yaml does not exist, create one to specify the Melos version for the workspace. This ensures consistent Melos usage across the project. ```yaml name: my_project_workspace environment: sdk: '>=3.0.0 <4.0.0' ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure Pre and Post Hooks for Bootstrap Command Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Define pre and post execution scripts for the 'bootstrap' command. These hooks run before and after the main command. ```yaml command: bootstrap: hooks: pre: echo `bootstrap command is running...` post: echo `bootstrap command is done` ``` -------------------------------- ### 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 # ... ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Extended Script Configuration Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Configures a script with a name, description, execution command, and environment variables. ```yaml scripts: hello: name: hey description: Greet the world run: echo '$GREETING World' env: GREETING: 'Hey' ``` -------------------------------- ### Control Fetch Tags for Versioning Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify whether to fetch tags from the `origin` remote before versioning. Defaults to `true`. ```yaml melos: command: version: fetchTags: false ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure Package pubspec.yaml for Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Ensure individual package pubspec.yaml files include 'resolution: workspace' to be recognized within the Dart pub workspace. ```yaml name: my_package environment: sdk: ^3.9.0 resolution: workspace ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure Aggregate Changelogs Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure aggregate changelogs to document changes across multiple packages. Specify the path, description, and package filters for each aggregate changelog. ```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_* ``` -------------------------------- ### Sequential Command Execution Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Connects multiple commands with '&&' to ensure sequential execution and stop if any command fails. ```yaml scripts: prepare: melos bootstrap && melos run build ``` -------------------------------- ### 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 ``` -------------------------------- ### Basic Script Definition Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Defines a simple script with a name and the command to execute. ```yaml melos: scripts: hello: echo 'Hello World' ``` -------------------------------- ### 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 ``` -------------------------------- ### Inheriting Standard I/O Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Configures a script to inherit Melos's stdin, stdout, and stderr for interactive commands. ```yaml scripts: attach: run: tmux attach -t my_session stdio: inherit ``` -------------------------------- ### 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 ``` -------------------------------- ### Migrate from --since to --diff flag Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Replace the --since flag with --diff for more flexible commit range specification. ```bash melos run --diff ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 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 ``` -------------------------------- ### 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 Root pubspec.yaml for Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Update your root pubspec.yaml to include workspace configuration and Melos dependency. This replaces the melos.yaml file and integrates with Dart's pub workspaces. ```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) ``` -------------------------------- ### 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 ``` -------------------------------- ### 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" ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure SDK Path Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Set the path to the Dart/Flutter SDK. Relative paths are resolved from the root `pubspec.yaml`. Use 'auto' to use the system-wide SDK. ```yaml melos: sdkPath: .fvm/flutter_sdk ``` -------------------------------- ### 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" ``` -------------------------------- ### Executing Script in Multiple Packages (Basic) Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Executes a command in multiple packages using the default melos exec options. ```yaml scripts: hello: exec: echo 'Hello $(dirname $PWD)' ``` -------------------------------- ### 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 Changelog Format Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure the format of the generated CHANGELOG.md, including whether to include the date and group entries by type. `includeDate` defaults to `false`. ```yaml melos: command: version: changelogFormat: includeDate: true groupByType: true ``` -------------------------------- ### Configure dependency overrides for bootstrapping Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify paths or glob patterns for local packages to be linked as 'dependency_overrides' in the workspace's pubspec_overrides.yaml during 'melos bootstrap'. ```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 ``` -------------------------------- ### Enable useRootAsPackage in Melos 7.x.x Source: https://github.com/invertase/melos/blob/main/docs/guides/migrations.mdx Add 'useRootAsPackage: true' to your root pubspec.yaml to maintain the behavior of including the repository root as a package in workspace operations. ```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/**" ``` -------------------------------- ### 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 : ``` -------------------------------- ### Defining Script Steps Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Combines multiple commands or scripts into a single script definition for complex workflows. ```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 . ``` -------------------------------- ### Executing Script in Multiple Packages (with Options) Source: https://github.com/invertase/melos/blob/main/docs/configuration/scripts.mdx Executes a command in multiple packages with specified melos exec options like concurrency. ```yaml scripts: hello: run: echo 'Hello $(dirname $PWD)' exec: concurrency: 1 ``` -------------------------------- ### 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 ``` -------------------------------- ### Discover Nested Workspaces Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Enable `discoverNestedWorkspaces` to recursively find packages within nested workspace roots. This ensures consistency with `dart pub workspace list`. ```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. ``` -------------------------------- ### Configure custom run arguments for IntelliJ Flutter apps Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify additional run arguments for Flutter apps, allowing for multiple configurations with custom names and arguments. A 'default: true' entry replaces the default configuration. ```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" ``` -------------------------------- ### 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 ``` -------------------------------- ### 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" # ... ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Define Repository URL Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Specify the git repository URL for your Melos workspace. This is required if the repository field is not defined at the top level of `pubspec.yaml` or if it's not a simple URL. ```yaml melos: repository: https://github.com/invertase/melos ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 ``` -------------------------------- ### Configure Version Command Message Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Customize the commit message template for `melos version`. Supports mustache syntax for variables like `new_package_versions`. ```yaml command: version: message: | chore: cut package releases 🎉 {new_package_versions} ``` -------------------------------- ### Control Workspace Changelog Generation Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Determine whether to generate a CHANGELOG.md at the workspace root when running `melos version`. Defaults to `true`. ```yaml melos: command: version: workspaceChangelog: false ``` -------------------------------- ### 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" ``` -------------------------------- ### 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" } ] } ``` -------------------------------- ### 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 ``` -------------------------------- ### Define Self-Hosted Repository Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure Melos to use a self-hosted Git instance by specifying the type, origin, owner, and name of the repository. ```yaml melos: repository: type: gitlab origin: https://gitlab.example.dev owner: invertase name: melos ``` -------------------------------- ### 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 Pub Timeouts and Retries Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Customize how Melos interacts with pub registries, including setting request timeouts and configuring retry behavior with delay factors and maximum attempts. ```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 ``` -------------------------------- ### 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 ``` -------------------------------- ### 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 IntelliJ script execution in terminal Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Determine if Melos scripts should execute within a terminal window when using IntelliJ IDE integration. Defaults to 'true'. ```yaml melos: ide: intellij: executeInTerminal: false ``` -------------------------------- ### 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 ." ``` -------------------------------- ### Configure Changelog Commit Bodies Source: https://github.com/invertase/melos/blob/main/docs/configuration/overview.mdx Configure whether to include commit bodies in the changelog and if only breaking changes should be included. `onlyBreaking` defaults to `true`. ```yaml melos: command: version: changelogCommitBodies: include: true onlyBreaking: false ```