processProject method

Future<void> processProject(
  1. dynamic project,
  2. List<Uri> pubspecUris,
  3. int processedProjects
)

Implementation

Future<void> processProject(
    project, List<Uri> pubspecUris, int processedProjects) async {
  final projectId = project['id'];
  print('    Fetching file.yaml for project $projectId...');

  await _loopOverPages(
    (page) async => await dio.get<List<dynamic>>(
      '/projects/$projectId/repository/tree',
      queryParameters: {
        'recursive': true,
        'per_page': 100,
        'page': page,
      },
    ),
    (item) async {
      if (item['type'] == 'blob' &&
          (item['path'] as String).endsWith('file.yaml')) {
        if ((item['path'] as String).endsWith('example/file.yaml')) {
          print(
              '        EXCLUDE found file.yaml in project $projectId at: ${item['path']}');
          return;
        }
        print(
            '        Found file.yaml in project $projectId at: ${item['path']}');
        final filePath = Uri.encodeComponent(item['path'] as String);
        final fileUri = Uri.parse(
          '${dio.options.baseUrl}/projects/$projectId/repository/files/$filePath/raw',
        );
        pubspecUris.add(fileUri);
      }
    },
  );
}