Skip to content

Commit

Permalink
Chore/update pubspec parse (#52)
Browse files Browse the repository at this point in the history
* Updated pubspec to pubspec_parse

* Cached response update

* Local cache response test
  • Loading branch information
leoafarias authored Oct 1, 2024
1 parent 7548368 commit 5549f6d
Show file tree
Hide file tree
Showing 13 changed files with 3,397 additions and 358 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.0

* Replaced deprecated `pubspec` to `pubspec_parse` package
* Extensions for Pubspec, repository, issueTracker, screenshots, and issueTracker are now properties and not methods, for consistency with `pubspec_parse`

## 2.7.1

* Fix result data class schema [#50](https:/leoafarias/pub_api_client/pull/50)
Expand All @@ -24,7 +29,7 @@

## 2.4.0

* Added the ability to search with any tags [32](https:/fluttertools/pub_api_client/pull/32) thanks @Rexios80
* Added the ability to search with any tags [#32](https:/fluttertools/pub_api_client/pull/32) thanks @Rexios80

## 2.3.0

Expand Down Expand Up @@ -177,4 +182,4 @@ Thank you [@Rexios80](https:/Rexios80) for all the great contributio

### Changed

* Initial version
* Initial version
1 change: 0 additions & 1 deletion lib/src/models/barrel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export 'package:pub_api_client/src/models/package_publisher_model.dart';
export 'package:pub_api_client/src/models/package_score_card.dart';
export 'package:pub_api_client/src/models/package_score_model.dart';
export 'package:pub_api_client/src/models/pub_package_model.dart';
export 'package:pub_api_client/src/models/pubspec_extensions.dart';
export 'package:pub_api_client/src/models/search_order.dart';
export 'package:pub_api_client/src/models/search_results_model.dart';
16 changes: 9 additions & 7 deletions lib/src/models/pub_package_model.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:dart_mappable/dart_mappable.dart';
import 'package:pubspec/pubspec.dart';
import 'package:pubspec_parse/pubspec_parse.dart';

part 'pub_package_model.mapper.dart';

/// Package Model
@MappableClass(includeCustomMappers: [PubspecMapper()])
@MappableClass(includeCustomMappers: [
PubspecMapper(),
])
class PubPackage with PubPackageMappable {
final String name;
final PackageVersion latest;
Expand All @@ -19,7 +21,7 @@ class PubPackage with PubPackageMappable {
String get description => latestPubspec.description ?? '';
String get url => 'https://pub.dev/packages/$name';
String get changelogUrl => '$url/changelog';
PubSpec get latestPubspec => latest.pubspec;
Pubspec get latestPubspec => latest.pubspec;

static const fromMap = PubPackageMapper.fromMap;
static const fromJson = PubPackageMapper.fromJson;
Expand All @@ -29,7 +31,7 @@ class PubPackage with PubPackageMappable {
@MappableClass(includeCustomMappers: [PubspecMapper()])
class PackageVersion with PackageVersionMappable {
final String version;
final PubSpec pubspec;
final Pubspec pubspec;
@MappableField(key: 'archive_url')
final String archiveUrl;
final DateTime published;
Expand All @@ -47,14 +49,14 @@ class PackageVersion with PackageVersionMappable {
static const fromJson = PackageVersionMapper.fromJson;
}

class PubspecMapper extends SimpleMapper<PubSpec> {
class PubspecMapper extends SimpleMapper<Pubspec> {
const PubspecMapper();

@override
// ignore: avoid-dynamic
PubSpec decode(dynamic value) => PubSpec.fromJson(value);
Pubspec decode(dynamic value) => Pubspec.fromJson(value, lenient: true);

@override
// ignore: avoid-dynamic
dynamic encode(PubSpec self) => self.toString();
dynamic encode(Pubspec self) => self.toString();
}
8 changes: 4 additions & 4 deletions lib/src/models/pub_package_model.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class PackageVersionMapper extends ClassMapperBase<PackageVersion> {
static String _$version(PackageVersion v) => v.version;
static const Field<PackageVersion, String> _f$version =
Field('version', _$version);
static PubSpec _$pubspec(PackageVersion v) => v.pubspec;
static const Field<PackageVersion, PubSpec> _f$pubspec =
static Pubspec _$pubspec(PackageVersion v) => v.pubspec;
static const Field<PackageVersion, Pubspec> _f$pubspec =
Field('pubspec', _$pubspec);
static String _$archiveUrl(PackageVersion v) => v.archiveUrl;
static const Field<PackageVersion, String> _f$archiveUrl =
Expand Down Expand Up @@ -246,7 +246,7 @@ abstract class PackageVersionCopyWith<$R, $In extends PackageVersion, $Out>
implements ClassCopyWith<$R, $In, $Out> {
$R call(
{String? version,
PubSpec? pubspec,
Pubspec? pubspec,
String? archiveUrl,
DateTime? published,
String? archiveSha256});
Expand All @@ -265,7 +265,7 @@ class _PackageVersionCopyWithImpl<$R, $Out>
@override
$R call(
{String? version,
PubSpec? pubspec,
Pubspec? pubspec,
String? archiveUrl,
DateTime? published,
String? archiveSha256}) =>
Expand Down
71 changes: 0 additions & 71 deletions lib/src/models/pubspec_extensions.dart

This file was deleted.

1 change: 1 addition & 0 deletions lib/src/pub_api_client_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class PubClient {
/// Returns the `PubPackage` information for [packageName]
Future<PubPackage> packageInfo(String packageName) async {
final data = await _fetch(endpoint.packageInfo(packageName));

return PubPackage.fromMap(data);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pub_api_client
description: An API Client for Pub to interact with public package information.
version: 2.7.1
version: 3.0.0
homepage: https:/leoafarias/pub_api_client

environment:
Expand All @@ -12,7 +12,7 @@ dependencies:
http: ^1.1.0
oauth2: ^2.0.2
path: ^1.8.3
pubspec: ^2.3.0
pubspec_parse: ^1.3.0

dev_dependencies:
build_runner: ^2.4.8
Expand Down
Loading

0 comments on commit 5549f6d

Please sign in to comment.