Skip to content

Commit 65817bf

Browse files
authored
Switch to Pub API (#152)
* Switch to Pub API * Rev version
1 parent f777da7 commit 65817bf

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

pkgs/firehose/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.25
2+
3+
- Switch to pub.dev API in `package:firehose`.
4+
15
## 0.3.24
26

37
- Fix [#137](https://github.com/dart-lang/ecosystem/issues/137).

pkgs/firehose/lib/src/pub.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ class Pub {
1313

1414
Future<bool> hasPublishedVersion(String name, String version) async {
1515
var response =
16-
await httpClient.get(Uri.parse('https://pub.dev/packages/$name.json'));
16+
await httpClient.get(Uri.parse('https://pub.dev/api/packages/$name'));
1717
if (response.statusCode != 200) {
1818
return false;
1919
}
2020

21-
var json = jsonDecode(response.body) as Map;
22-
var versions = json['versions'] as List;
23-
return versions.contains(version);
21+
var json = jsonDecode(response.body) as Map<String, dynamic>;
22+
return (json['versions'] as List)
23+
.map((versionObject) =>
24+
(versionObject as Map<String, dynamic>)['version'])
25+
.contains(version);
2426
}
2527

2628
void close() {

pkgs/firehose/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: firehose
22
description: A tool to automate publishing of Pub packages from GitHub actions.
3-
version: 0.3.24
3+
version: 0.3.25
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

0 commit comments

Comments
 (0)