Skip to content

Commit 5549f6d

Browse files
authored
Chore/update pubspec parse (#52)
* Updated pubspec to pubspec_parse * Cached response update * Local cache response test
1 parent 7548368 commit 5549f6d

13 files changed

+3397
-358
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.0.0
2+
3+
* Replaced deprecated `pubspec` to `pubspec_parse` package
4+
* Extensions for Pubspec, repository, issueTracker, screenshots, and issueTracker are now properties and not methods, for consistency with `pubspec_parse`
5+
16
## 2.7.1
27

38
* Fix result data class schema [#50](https://github.com/leoafarias/pub_api_client/pull/50)
@@ -24,7 +29,7 @@
2429

2530
## 2.4.0
2631

27-
* Added the ability to search with any tags [32](https://github.com/fluttertools/pub_api_client/pull/32) thanks @Rexios80
32+
* Added the ability to search with any tags [#32](https://github.com/fluttertools/pub_api_client/pull/32) thanks @Rexios80
2833

2934
## 2.3.0
3035

@@ -177,4 +182,4 @@ Thank you [@Rexios80](https://github.com/Rexios80) for all the great contributio
177182

178183
### Changed
179184

180-
* Initial version
185+
* Initial version

lib/src/models/barrel.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ export 'package:pub_api_client/src/models/package_publisher_model.dart';
77
export 'package:pub_api_client/src/models/package_score_card.dart';
88
export 'package:pub_api_client/src/models/package_score_model.dart';
99
export 'package:pub_api_client/src/models/pub_package_model.dart';
10-
export 'package:pub_api_client/src/models/pubspec_extensions.dart';
1110
export 'package:pub_api_client/src/models/search_order.dart';
1211
export 'package:pub_api_client/src/models/search_results_model.dart';

lib/src/models/pub_package_model.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import 'package:dart_mappable/dart_mappable.dart';
2-
import 'package:pubspec/pubspec.dart';
2+
import 'package:pubspec_parse/pubspec_parse.dart';
33

44
part 'pub_package_model.mapper.dart';
55

66
/// Package Model
7-
@MappableClass(includeCustomMappers: [PubspecMapper()])
7+
@MappableClass(includeCustomMappers: [
8+
PubspecMapper(),
9+
])
810
class PubPackage with PubPackageMappable {
911
final String name;
1012
final PackageVersion latest;
@@ -19,7 +21,7 @@ class PubPackage with PubPackageMappable {
1921
String get description => latestPubspec.description ?? '';
2022
String get url => 'https://pub.dev/packages/$name';
2123
String get changelogUrl => '$url/changelog';
22-
PubSpec get latestPubspec => latest.pubspec;
24+
Pubspec get latestPubspec => latest.pubspec;
2325

2426
static const fromMap = PubPackageMapper.fromMap;
2527
static const fromJson = PubPackageMapper.fromJson;
@@ -29,7 +31,7 @@ class PubPackage with PubPackageMappable {
2931
@MappableClass(includeCustomMappers: [PubspecMapper()])
3032
class PackageVersion with PackageVersionMappable {
3133
final String version;
32-
final PubSpec pubspec;
34+
final Pubspec pubspec;
3335
@MappableField(key: 'archive_url')
3436
final String archiveUrl;
3537
final DateTime published;
@@ -47,14 +49,14 @@ class PackageVersion with PackageVersionMappable {
4749
static const fromJson = PackageVersionMapper.fromJson;
4850
}
4951

50-
class PubspecMapper extends SimpleMapper<PubSpec> {
52+
class PubspecMapper extends SimpleMapper<Pubspec> {
5153
const PubspecMapper();
5254

5355
@override
5456
// ignore: avoid-dynamic
55-
PubSpec decode(dynamic value) => PubSpec.fromJson(value);
57+
Pubspec decode(dynamic value) => Pubspec.fromJson(value, lenient: true);
5658

5759
@override
5860
// ignore: avoid-dynamic
59-
dynamic encode(PubSpec self) => self.toString();
61+
dynamic encode(Pubspec self) => self.toString();
6062
}

lib/src/models/pub_package_model.mapper.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ class PackageVersionMapper extends ClassMapperBase<PackageVersion> {
160160
static String _$version(PackageVersion v) => v.version;
161161
static const Field<PackageVersion, String> _f$version =
162162
Field('version', _$version);
163-
static PubSpec _$pubspec(PackageVersion v) => v.pubspec;
164-
static const Field<PackageVersion, PubSpec> _f$pubspec =
163+
static Pubspec _$pubspec(PackageVersion v) => v.pubspec;
164+
static const Field<PackageVersion, Pubspec> _f$pubspec =
165165
Field('pubspec', _$pubspec);
166166
static String _$archiveUrl(PackageVersion v) => v.archiveUrl;
167167
static const Field<PackageVersion, String> _f$archiveUrl =
@@ -246,7 +246,7 @@ abstract class PackageVersionCopyWith<$R, $In extends PackageVersion, $Out>
246246
implements ClassCopyWith<$R, $In, $Out> {
247247
$R call(
248248
{String? version,
249-
PubSpec? pubspec,
249+
Pubspec? pubspec,
250250
String? archiveUrl,
251251
DateTime? published,
252252
String? archiveSha256});
@@ -265,7 +265,7 @@ class _PackageVersionCopyWithImpl<$R, $Out>
265265
@override
266266
$R call(
267267
{String? version,
268-
PubSpec? pubspec,
268+
Pubspec? pubspec,
269269
String? archiveUrl,
270270
DateTime? published,
271271
String? archiveSha256}) =>

lib/src/models/pubspec_extensions.dart

Lines changed: 0 additions & 71 deletions
This file was deleted.

lib/src/pub_api_client_base.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class PubClient {
8989
/// Returns the `PubPackage` information for [packageName]
9090
Future<PubPackage> packageInfo(String packageName) async {
9191
final data = await _fetch(endpoint.packageInfo(packageName));
92+
9293
return PubPackage.fromMap(data);
9394
}
9495

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: pub_api_client
22
description: An API Client for Pub to interact with public package information.
3-
version: 2.7.1
3+
version: 3.0.0
44
homepage: https://github.com/leoafarias/pub_api_client
55

66
environment:
@@ -12,7 +12,7 @@ dependencies:
1212
http: ^1.1.0
1313
oauth2: ^2.0.2
1414
path: ^1.8.3
15-
pubspec: ^2.3.0
15+
pubspec_parse: ^1.3.0
1616

1717
dev_dependencies:
1818
build_runner: ^2.4.8

0 commit comments

Comments
 (0)