bwu_pub_client 0.1.0+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 9

BWU PubClient

Easy access to pub.dartlang.org remote API from Dart.

Example

It's not the simplest example but one I needed. For a given package it prints which dependency has a dependency constraint (direct or transitive) that prevents updating to the latest version


library bwu_pub_client.example.check_dependencies;

import 'dart:async' show Future, Stream;
import 'dart:collection';
import 'package:bwu_pub_client/bwu_pub_client.dart';
import 'package:http/http.dart' as http;

const startPackageName = 'appengine';

/// Collect all dependencies (direct and transitive).
Map<String, PubPackage> allDependencies = <String, PubPackage>{};

main() async {
  final pubClient = new PubClient(new http.Client());
  Map<String, Set<String>> outdated =
      await findLimitingDependencies(pubClient, startPackageName);
  outdated.forEach((k, v) {
    print(
        '"${k}" (latest: ${allDependencies[k].latest.version
            }) doesn\'t support the latest version of:');
    v.forEach((e) {
      print(
          '    "${e}" (${allDependencies[e].latest.version}) - constraint: ${
              allDependencies[k].latest.pubspec.dependencies[e].versionConstraint}');
    });
  });
}

/// Collect all direct and transitive dependencies and let
/// `outdatedDependencies()` find which have constraints that limit updating to
/// the most recent version.
Future<Map<String, Set<String>>> findLimitingDependencies(
    PubClient pubClient, String packageName) async {
  /// Queue of packages to fetch info from pub.dartlang.org
  final queue = new Queue<String>();
  queue.add(packageName);

  while (queue.isNotEmpty) {
    /// Fetch data from pub.dartlang.org
    final PubPackage package = await pubClient.fetchPackage(queue.removeLast());
    allDependencies[package.name] = package;

    /// Queue transtitive dependencies to process
    final dependencies = package.latest.pubspec.dependencies;
    if (dependencies != null) {
      for (final p in dependencies.keys) {
        if (!allDependencies.containsKey(p) && !queue.contains(p)) {
          queue.add(p);
        }
      }
    }
  }
  return outdatedDependencies();
}

/// Find the dependencies where a dependency constraint prevents updating to
/// the most recent version.
Map<String, Set<String>> outdatedDependencies() {
  final result = <String, Set<String>>{};
  final depending = findDependingPackages();
  depending.forEach((k, v) {
    v.forEach((d) {
      final dep = allDependencies[d].latest.pubspec.dependencies[k];
      /// Check if latest version is supported (only hosted packages are
      /// supported currently because others would require to fetch version
      /// information from a path or Git reference.
      if (dep.kind == DependencyKind.hosted &&
          !dep.versionConstraint.allows(allDependencies[k].latest.version)) {
        if (result[d] == null) {
          result[d] = new Set<String>()..add(k);
        } else {
          result[d].add(k);
        }
      }
    });
  });
  return result;
}

/// Builds a map from each dependency to the packages which depend on this 
/// dependency (from the set of transitive dependencies of the 
/// `startPackageName`).
Map<String, List<String>> findDependingPackages() {
  final result = {};
  allDependencies.forEach((k, v) {
    final dependencies = findDependingOn(k);
    result[k] = dependencies;
  });
  return result;
}

/// Get the packages which depend on package [name].
List<String> findDependingOn(String name) {
  return allDependencies.keys
      .where((k) =>
          allDependencies[k].latest.pubspec.dependencies.containsKey(name))
      .toList();
}

prints for example

"gcloud" (latest: 0.2.0+1) doesn't support the latest version of:
    "googleapis_beta" (0.14.0) - constraint: >=0.10.0 <0.13.0
    "googleapis" (0.10.0) - constraint: >=0.2.0 <0.9.0
"appengine" (latest: 0.3.0) doesn't support the latest version of:
    "logging" (0.11.1) - constraint: >=0.9.3 <0.10.0

which shows that the package appengine has a constraint on logging which prevents to update to the latest logging version and that appengine also has a dependency on gcloud which isself has too narrow constraints for googleapis_beta and googleapis to update to the newest versions of these dependencies.

CHANGELOG

0.1.0+1

  • enable travis integration
  • use bwu_utils_dev default Grinder tasks

0.1.0

  • initial version

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  bwu_pub_client: "^0.1.0+1"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:bwu_pub_client/bwu_pub_client.dart';
        
Version Uploaded Documentation Archive
0.1.0+1 Jun 4, 2015 Go to the documentation of bwu_pub_client 0.1.0+1 Download bwu_pub_client 0.1.0+1 archive
0.1.0 Jun 1, 2015 Go to the documentation of bwu_pub_client 0.1.0 Download bwu_pub_client 0.1.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 14, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
31 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
9

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:bwu_pub_client/bwu_pub_client.dart.

Suggestions

  • Fix lib/src/pub_client.dart.

    Strong-mode analysis of lib/src/pub_client.dart failed with the following error:

    line: 186 col: 25
    The argument type 'List' can't be assigned to the parameter type 'Iterable<String>'.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use bwu_pub_client.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0
http ^0.11.2 0.11.3+16
logging ^0.11.1 0.11.3+1
pub_semver ^1.2.1 1.3.2
quiver ^0.21.4 0.21.4 0.28.0
Transitive dependencies
async 2.0.3 2.0.4
charcode 1.1.1
collection 1.14.5
http_parser 3.1.1
matcher 0.12.1+4
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
bwu_utils_dev ^0.1.0-dev.6
quiver_log ^1.0.3
stack_trace ^1.3.2 1.9.2
test ^0.12.2