From 6d379a68a275a197b685cbae6609f7748a2ae14e Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Tue, 7 Jan 2025 18:01:16 +0100 Subject: [PATCH] fix: Only run pub get in workspace root --- docs/commands/bootstrap.mdx | 6 ++--- .../melos/lib/src/commands/bootstrap.dart | 25 +------------------ .../melos/test/commands/bootstrap_test.dart | 18 ++++++------- 3 files changed, 11 insertions(+), 38 deletions(-) diff --git a/docs/commands/bootstrap.mdx b/docs/commands/bootstrap.mdx index 4883128e..596f0765 100644 --- a/docs/commands/bootstrap.mdx +++ b/docs/commands/bootstrap.mdx @@ -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 diff --git a/packages/melos/lib/src/commands/bootstrap.dart b/packages/melos/lib/src/commands/bootstrap.dart index fe891e69..40a3d572 100644 --- a/packages/melos/lib/src/commands/bootstrap.dart +++ b/packages/melos/lib/src/commands/bootstrap.dart @@ -60,7 +60,7 @@ mixin _BootstrapMixin on _CleanMixin { } logger.log( - 'Running "$pubCommandForLogging" in workspace packages...', + 'Running "$pubCommandForLogging" in workspace...', ); await _runPubGetForWorkspace( @@ -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(); } @visibleForTesting @@ -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, diff --git a/packages/melos/test/commands/bootstrap_test.dart b/packages/melos/test/commands/bootstrap_test.dart index ac0e7d2e..c9dc31d0 100644 --- a/packages/melos/test/commands/bootstrap_test.dart +++ b/packages/melos/test/commands/bootstrap_test.dart @@ -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... @@ -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. @@ -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... @@ -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... @@ -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... @@ -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... @@ -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...