parse method

List<Dependency> parse()

Implementation

List<Dependency> parse() {
  final file = File('$projectPath/pubspec.yaml');

  if (!file.existsSync()) {
    throw Exception('pubspec.yaml not found at: ${file.path}');
  }

  final content = file.readAsStringSync();
  final yaml = loadYaml(content);

  if (yaml is! YamlMap) {
    throw Exception('Invalid pubspec.yaml format.');
  }

  final dependencies = <Dependency>[];

  _parseDependencySection(
    yaml['dependencies'],
    DependencyType.direct,
    dependencies,
  );

  _parseDependencySection(
    yaml['dev_dependencies'],
    DependencyType.dev,
    dependencies,
  );

  return dependencies;
}