2022-07-31 21:46:27 +02:00
|
|
|
import 'package:github/github.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:injectable/injectable.dart';
|
2022-08-08 00:40:31 +02:00
|
|
|
import 'package:timeago/timeago.dart';
|
2022-07-31 21:46:27 +02:00
|
|
|
|
2022-08-06 14:13:28 +02:00
|
|
|
@lazySingleton
|
2022-07-31 21:46:27 +02:00
|
|
|
class GithubAPI {
|
|
|
|
var github = GitHub();
|
|
|
|
|
2022-08-02 09:55:01 +02:00
|
|
|
Future<String?> latestRelease(String org, repoName) async {
|
2022-08-07 01:37:12 +02:00
|
|
|
var latestRelease = await github.repositories.getLatestRelease(
|
|
|
|
RepositorySlug(org, repoName),
|
|
|
|
);
|
2022-08-06 15:04:18 +02:00
|
|
|
var dlurl = latestRelease.assets
|
|
|
|
?.firstWhere((asset) =>
|
|
|
|
asset.name != null &&
|
2022-08-07 00:01:05 +02:00
|
|
|
(asset.name!.endsWith('.dex') || asset.name!.endsWith('.apk')) &&
|
2022-08-06 15:04:18 +02:00
|
|
|
!asset.name!.contains('-sources') &&
|
|
|
|
!asset.name!.contains('-javadoc'))
|
|
|
|
.browserDownloadUrl;
|
2022-08-02 09:55:01 +02:00
|
|
|
return dlurl;
|
2022-07-31 21:46:27 +02:00
|
|
|
}
|
2022-08-01 20:06:27 +02:00
|
|
|
|
2022-08-08 00:40:31 +02:00
|
|
|
Future<String> latestCommitTime(String org, repoName) async {
|
2022-08-07 01:37:12 +02:00
|
|
|
var repo = await github.repositories.getRepository(
|
|
|
|
RepositorySlug(org, repoName),
|
2022-08-01 20:06:27 +02:00
|
|
|
);
|
2022-08-08 00:40:31 +02:00
|
|
|
return format(repo.pushedAt!);
|
2022-08-01 20:12:38 +02:00
|
|
|
}
|
2022-07-31 21:46:27 +02:00
|
|
|
}
|