getAllProjects function
Implementation
List<ProjectInfo> getAllProjects({Directory? baseDir}) {
final List<ProjectInfo> projects = [];
final root = baseDir ?? Directory.current;
try {
// 1. Check current directory
final rootInfo = parsePubspec(root);
if (rootInfo != null) projects.add(rootInfo);
// 2. Check subdirectories (up to 2 levels for monorepos)
for (final entity in root.listSync()) {
if (entity is Directory) {
final info = parsePubspec(entity);
if (info != null) {
projects.add(info);
} else {
// Check one level deeper (e.g. packages/my_package)
try {
for (final sub in entity.listSync()) {
if (sub is Directory) {
final subInfo = parsePubspec(sub);
if (subInfo != null) projects.add(subInfo);
}
}
} catch (_) {}
}
}
}
} catch (_) {}
return projects;
}