@@ -7,48 +7,43 @@ description: Learn more about the `bootstrap` command in Melos.
77
88<Info >Supports all [ Melos filtering] ( /filters ) flags.</Info >
99
10- This command initializes the workspace, links local packages together and
11- installs remaining package dependencies.
10+ This command initializes the workspace and installs remaining package
11+ dependencies.
1212
1313``` bash
1414melos bootstrap
1515# or
1616melos bs
1717```
1818
19- Bootstrapping has two primary functions:
19+ Bootstrapping has three primary functions:
2020
21211 . Installing all package dependencies (internally using ` pub get ` ).
22- 2 . Locally linking any packages together via path dependency overrides _ without
23- having to edit your pubspec.yaml _ .
22+ 2 . Syncing shared dependencies between packages.
23+ 3 . Running any bootstrap lifecycle scripts .
2424
2525## Why is bootstrapping required?
2626
27- In normal projects, packages can be linked by providing a ` path ` within the
28- ` pubspec.yaml ` . This works for small projects however presents a problem at
29- scale. Packages cannot be published with a locally defined path, meaning once
30- you're ready to publish your packages you'll need to manually update all the
31- packages ` pubspec.yaml ` files with the versions. If your packages are also
32- tightly coupled (dependencies of each other), you'll also have to manually check
33- which versions should be updated. Even with a few of packages this can become a
34- long and error-prone task.
35-
36- Melos solves this problem by overriding local files which the Dart analyzer uses
37- to read packages from. If a local package exists (defined in the ` melos.yaml `
38- file) and a different local package has it listed as a dependency, it will be
39- linked regardless of whether a version has been specified.
27+ After the [ Pub Workspaces feature] ( https://dart.dev/tools/pub/workspaces ) was
28+ introduced in Dart 3.6.0, it is no longer strictly necessary to run `melos
29+ bootstrap`, since all the packages are already linked together. However, there
30+ are still some benefits to running ` melos bootstrap ` , because you need to run
31+ ` pub get ` in each package to initialize the workspace, and ` melos bootstrap `
32+ will do that for you.
4033
4134### Benefits
4235
43- - All local packages in the repository can be interlinked by Melos to point to
44- their local directories rather than 'remote' _ without pubspec.yaml
45- modifications_ .
36+ Why would I want to use a monorepo?
37+
38+ - All local packages in the repository can be interlinked to point to their
39+ local directories rather than 'remote' _ without pubspec.yaml modifications_ .
4640 - ** Example Scenario** : In a repository, package ` A ` depends on package ` B ` .
4741 Both packages ` A ` & ` B ` exist in the monorepo. However, if you ` pub get `
4842 inside package ` A ` , ` pub ` will retrieve package ` B ` from the pub.dev
49- registry as it's unaware of ` B ` existing locally. However, with Melos, it's
50- aware that package ` B ` exists locally too, so it will generate the various
51- pub files to point to a relative path in the local repository.
43+ registry as it's unaware of ` B ` existing locally. However, with Melos and
44+ pub workspaces, it's aware that package ` B ` exists locally too, so it will
45+ generate the various pub files to point to a relative path in the local
46+ repository.
5247 - If you wanted to use pub you could of course define a dependency override
5348 in the pubspec of package ` A ` that sets a path for package ` B ` but, then
5449 you'd have to do this manually every time and then manually remove it
@@ -86,20 +81,19 @@ melos bootstrap --diff="main"
8681
8782## Bootstrap flags
8883
89- - The ` --no-example ` flag is used to exclude flutter package's example's dependencies
90- (https://github.com/dart-lang/pub/pull/3856 )
84+ - The ` --no-example ` flag is used to exclude flutter package's example's
85+ dependencies (https://github.com/dart-lang/pub/pull/3856 )
9186 - This will run ` pub get ` with the ` --no-example ` flag.
9287- The ` --enforce-lockfile ` flag is used to enforce versions from ` .lock ` files.
9388 - Ensure .lock files exist, as failure may occur if they're not checked in.
94- - The ` --no-enforce-lockfile ` flag is used to disregard versions from ` .lock ` files if
95- ` enforce-lockfile ` is configured in the ` melos.yaml ` file.
96- - The ` --skip-linking ` flag is used to skip the local linking of workspace packages.
97- - The ` --offline ` flag is used to only resolve dependencies from the local cache by running
98- ` pub get ` with the ` --offline ` flag.
89+ - The ` --no-enforce-lockfile ` flag is used to disregard versions from ` .lock `
90+ files if ` enforce-lockfile ` is configured in the ` melos.yaml ` file.
91+ - The ` --offline ` flag is used to only resolve dependencies from the local
92+ cache by running ` pub get ` with the ` --offline ` flag.
9993
10094
101- In addition to the above flags, the ` melos bootstrap ` command supports a few different flags that
102- can be defined in your ` melos.yaml ` file.
95+ In addition to the above flags, the ` melos bootstrap ` command supports a few
96+ different configurations that can be defined in your ` melos.yaml ` file.
10397
10498
10599### Shared dependencies
0 commit comments