Skip to content

Commit

Permalink
fix: Only run pub get in workspace root
Browse files Browse the repository at this point in the history
  • Loading branch information
spydon committed Jan 7, 2025
1 parent 8588592 commit 6d379a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 38 deletions.
6 changes: 3 additions & 3 deletions docs/commands/bootstrap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Bootstrapping has three primary functions:
After the [Pub Workspaces feature](https://dart.dev/tools/pub/workspaces) was
introduced in Dart 3.6.0, it is no longer strictly necessary to run `melos
bootstrap`, since all the packages are already linked together. However, there
are still some benefits to running `melos bootstrap`, because you need to run
`pub get` in each package to initialize the workspace, and `melos bootstrap`
will do that for you.
are still some benefits to running `melos bootstrap`, if you for example want
to set up shared dependencies or attaching your own setup scripts to the
bootstrap hooks.

### Benefits

Expand Down
25 changes: 1 addition & 24 deletions packages/melos/lib/src/commands/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mixin _BootstrapMixin on _CleanMixin {
}

logger.log(
'Running "$pubCommandForLogging" in workspace packages...',
'Running "$pubCommandForLogging" in workspace...',
);

await _runPubGetForWorkspace(
Expand Down Expand Up @@ -107,23 +107,6 @@ mixin _BootstrapMixin on _CleanMixin {
runOffline: runOffline,
enforceLockfile: enforceLockfile,
);

final filteredPackages = workspace.filteredPackages.values;
await Stream.fromIterable(filteredPackages).parallel(
(package) async {
await runPubGetForPackage(
workspace,
package,
noExample: noExample,
runOffline: runOffline,
enforceLockfile: enforceLockfile,
);

_logPackagePubGetSuccess(package);
},
parallelism:
workspace.config.commands.bootstrap.runPubGetInParallel ? null : 1,
).drain<void>();
}

@visibleForTesting
Expand Down Expand Up @@ -310,12 +293,6 @@ mixin _BootstrapMixin on _CleanMixin {
return dependenciesToUpdate.length;
}

void _logPackagePubGetSuccess(Package package) {
logger.child(packageNameStyle(package.name), prefix: '$checkLabel ').child(
packagePathStyle(printablePath(package.pathRelativeToWorkspace)),
);
}

void _logBootstrapException(
BootstrapException exception,
MelosWorkspace workspace,
Expand Down
18 changes: 7 additions & 11 deletions packages/melos/test/commands/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ void main() {
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get" in workspace packages...
✓ a
└> packages/a
Running "${pubExecArgs.join(' ')} get" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down Expand Up @@ -280,7 +278,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get" in workspace packages...
Running "${pubExecArgs.join(' ')} get" in workspace...
- workspace
└> .
e- └> Failed to run pub get.
Expand Down Expand Up @@ -331,7 +329,7 @@ e-Because a depends on package_that_does_not_exists any which doesn't exist (cou
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get --offline" in workspace packages...
Running "${pubExecArgs.join(' ')} get --offline" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down Expand Up @@ -391,7 +389,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get --enforce-lockfile" in workspace packages...
Running "${pubExecArgs.join(' ')} get --enforce-lockfile" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down Expand Up @@ -448,7 +446,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get" in workspace packages...
Running "${pubExecArgs.join(' ')} get" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down Expand Up @@ -499,7 +497,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "${pubExecArgs.join(' ')} get" in workspace packages...
Running "${pubExecArgs.join(' ')} get" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down Expand Up @@ -749,9 +747,7 @@ Generating IntelliJ IDE files...
melos bootstrap
└> ${workspaceDir.path}
Running "dart pub get --offline" in workspace packages...
✓ a
└> packages/a
Running "dart pub get --offline" in workspace...
> SUCCESS
Generating IntelliJ IDE files...
Expand Down

0 comments on commit 6d379a6

Please sign in to comment.