From 1045ef52bdc15c9acd1da380b282a05a2c276fcc Mon Sep 17 00:00:00 2001 From: "mahmut.taskiran" Date: Sat, 14 Dec 2024 19:51:09 +0400 Subject: [PATCH 1/4] fix: too many open files while creating a workspace --- packages/melos/lib/src/package.dart | 76 ++++++++++++++--------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/packages/melos/lib/src/package.dart b/packages/melos/lib/src/package.dart index 4f4a4b12..cab09679 100644 --- a/packages/melos/lib/src/package.dart +++ b/packages/melos/lib/src/package.dart @@ -531,15 +531,14 @@ class PackageMap { final packageMap = {}; - await Future.wait( - pubspecFiles.map((pubspecFile) async { - final pubspecDirPath = pubspecFile.parent.path; - final pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); - final name = pubspec.name; - - if (packageMap.containsKey(name)) { - throw MelosConfigException( - ''' + await Stream.fromIterable(pubspecFiles).parallel((pubspecFile) async { + final pubspecDirPath = pubspecFile.parent.path; + final pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + final name = pubspec.name; + + if (packageMap.containsKey(name)) { + throw MelosConfigException( + ''' Multiple packages with the name `$name` found in the workspace, which is unsupported. To fix this problem, consider renaming your packages to have a unique name. @@ -547,38 +546,37 @@ The packages that caused the problem are: - $name at ${printablePath(relativePath(pubspecDirPath, workspacePath))} - $name at ${printablePath(relativePath(packageMap[name]!.path, workspacePath))} ''', - ); - } + ); + } - final filteredCategories = []; - - categories.forEach((key, value) { - final isCategoryMatching = value.any( - (category) => category.matches( - relativePath(pubspecDirPath, workspacePath), - ), - ); - - if (isCategoryMatching) { - filteredCategories.add(key); - } - }); - - packageMap[name] = Package( - name: name, - path: pubspecDirPath, - pathRelativeToWorkspace: relativePath(pubspecDirPath, workspacePath), - version: pubspec.version ?? Version.none, - publishTo: pubspec.publishTo.let(Uri.parse), - packageMap: packageMap, - dependencies: pubspec.dependencies.keys.toList(), - devDependencies: pubspec.devDependencies.keys.toList(), - dependencyOverrides: pubspec.dependencyOverrides.keys.toList(), - pubspec: pubspec, - categories: filteredCategories, + final filteredCategories = []; + + categories.forEach((key, value) { + final isCategoryMatching = value.any( + (category) => category.matches( + relativePath(pubspecDirPath, workspacePath), + ), ); - }), - ); + + if (isCategoryMatching) { + filteredCategories.add(key); + } + }); + + packageMap[name] = Package( + name: name, + path: pubspecDirPath, + pathRelativeToWorkspace: relativePath(pubspecDirPath, workspacePath), + version: pubspec.version ?? Version.none, + publishTo: pubspec.publishTo.let(Uri.parse), + packageMap: packageMap, + dependencies: pubspec.dependencies.keys.toList(), + devDependencies: pubspec.devDependencies.keys.toList(), + dependencyOverrides: pubspec.dependencyOverrides.keys.toList(), + pubspec: pubspec, + categories: filteredCategories, + ); + }).drain(); return PackageMap(packageMap, logger); } From ff85492b496c85e4dfe26b7c85de0f9855414820 Mon Sep 17 00:00:00 2001 From: "mahmut.taskiran" Date: Tue, 17 Dec 2024 14:57:05 +0400 Subject: [PATCH 2/4] Triggering workflow From c80c8e82c80bb9283786f4f247da49860262893f Mon Sep 17 00:00:00 2001 From: "mahmut.taskiran" Date: Sat, 21 Dec 2024 19:27:05 +0400 Subject: [PATCH 3/4] added 'no dependencies would change in' case to the matcher --- packages/melos/test/matchers.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/melos/test/matchers.dart b/packages/melos/test/matchers.dart index 3f82ad09..71da52d9 100644 --- a/packages/melos/test/matchers.dart +++ b/packages/melos/test/matchers.dart @@ -24,6 +24,7 @@ Matcher ignoringDependencyMessages(String expected) { !line.startsWith('Got dependencies!') && // Removes lines like " pub_updater 0.4.0 (0.5.0 available)" !(line.startsWith(' ') && line.contains(' available)')) && + !line.startsWith('No dependencies would change in') && !line.contains( 'newer versions incompatible with dependency constraints', ) && From 762fdb8f8d21f2e8edd9ded03f5e253216e769ab Mon Sep 17 00:00:00 2001 From: "mahmut.taskiran" Date: Sat, 21 Dec 2024 19:33:44 +0400 Subject: [PATCH 4/4] 'Would change' case is added --- packages/melos/test/matchers.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/melos/test/matchers.dart b/packages/melos/test/matchers.dart index 71da52d9..195102c0 100644 --- a/packages/melos/test/matchers.dart +++ b/packages/melos/test/matchers.dart @@ -25,6 +25,7 @@ Matcher ignoringDependencyMessages(String expected) { // Removes lines like " pub_updater 0.4.0 (0.5.0 available)" !(line.startsWith(' ') && line.contains(' available)')) && !line.startsWith('No dependencies would change in') && + !line.startsWith('Would change') && !line.contains( 'newer versions incompatible with dependency constraints', ) &&