fromPubspec static method
Implementation
static DependencyGraph fromPubspec() {
final pubspecFile = File('pubspec.yaml');
if (!pubspecFile.existsSync()) {
throw Exception('pubspec.yaml not found in the current directory.');
}
final pubspecContent = pubspecFile.readAsStringSync();
final pubspecYaml = loadYaml(pubspecContent);
final graph = DependencyGraph();
final dependencies = pubspecYaml['dependencies'] as YamlMap;
dependencies.forEach((package, value) {
// For simplicity, we'll just use a placeholder for dependencies
// You can extend this logic to include transitive dependencies as needed
graph.addDependency(package, []); // Add actual dependencies if available
});
return graph;
}