fetchPubspecUris method

  1. @override
Future<List<Uri>> fetchPubspecUris()
override

Fetches URIs of all file.yaml files available in the GitLab group.

Implementation

@override
Future<List<Uri>> fetchPubspecUris() async {
  final List<Uri> pubspecUris = [];
  List<String> erroredProjects = [];

  print('Fetching projects from group $groupId...');
  await _loopOverPages(
    (page) async {
      print('Processing page $page of projects...');
      return await dio.get<List<dynamic>>(
        '/groups/$groupId/projects',
        queryParameters: {
          'include_subgroups': true,
          'per_page': 100,
          'page': page,
        },
      );
    },
    (project) async {
      try {
        await processProject(project, pubspecUris, pubspecUris.length);
      } catch (e) {
        print('Error processing project: $e');
        erroredProjects.add(project['id'].toString());
      }
    },
  );

  // Write errored projects to a file
  File('errors.txt').writeAsStringSync(erroredProjects.join('\n'));
  return pubspecUris;
}