Skip to content

Commit

Permalink
Switch to Pub API (#152)
Browse files Browse the repository at this point in the history
* Switch to Pub API

* Rev version
  • Loading branch information
mosuem authored Aug 29, 2023
1 parent f777da7 commit 65817bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.25

- Switch to pub.dev API in `package:firehose`.

## 0.3.24

- Fix [#137](https://github.com/dart-lang/ecosystem/issues/137).
Expand Down
10 changes: 6 additions & 4 deletions pkgs/firehose/lib/src/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ class Pub {

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

var json = jsonDecode(response.body) as Map;
var versions = json['versions'] as List;
return versions.contains(version);
var json = jsonDecode(response.body) as Map<String, dynamic>;
return (json['versions'] as List)
.map((versionObject) =>
(versionObject as Map<String, dynamic>)['version'])
.contains(version);
}

void close() {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.3.24
version: 0.3.25
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down

0 comments on commit 65817bf

Please sign in to comment.