loadAllMetadata method

Future<List<ReleaseMetadata>> loadAllMetadata(
  1. String projectPath
)

Loads all historical release manifests for projectPath ordered by timestamp descending.

Implementation

Future<List<ReleaseMetadata>> loadAllMetadata(String projectPath) async {
  final dirPath = getManifestDirectory(projectPath);
  final dir = Directory(dirPath);
  if (!await dir.exists()) return [];

  final files = dir
      .listSync()
      .whereType<File>()
      .where(
          (f) => f.path.endsWith('.json') && !f.path.endsWith('latest.json'))
      .toList();

  final results = <ReleaseMetadata>[];
  for (final file in files) {
    try {
      final content = file.readAsStringSync();
      final json = jsonDecode(content) as Map<String, dynamic>;
      results.add(ReleaseMetadata.fromJson(json));
    } catch (_) {}
  }

  results.sort((a, b) => b.timestamp.compareTo(a.timestamp));
  return results;
}