Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only run pub get in workspace root #822

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading