pubspec_lock 3.0.2 copy "pubspec_lock: ^3.0.2" to clipboard
pubspec_lock: ^3.0.2 copied to clipboard

Dart library to access and manipulate content of pubpec.lock files

example/main.dart

import 'dart:io';

import 'package:pubspec_lock/pubspec_lock.dart';

// ignore_for_file: avoid_print

void main() {
  final file = File('pubspec.lock');
  final pubspecLock = file.readAsStringSync().loadPubspecLockFromYaml();
  print('Loaded pubspec.lock with '
      '${pubspecLock.packages.length} package dependencies:');

  final depsNotHostedByPubDev = [
    for (final package in pubspecLock.packages)
      if (!isHostedByPubDev(package)) package
  ];

  if (depsNotHostedByPubDev.isEmpty) {
    print('SUCCESS: All dependencies are hosted by pub-web.flutter-io.cn');
  } else {
    print('WARNING: Dependencies hosted outside of pub-web.flutter-io.cn:');
    depsNotHostedByPubDev.forEach(print);
  }
}

bool isHostedByPubDev(PackageDependency package) => package.iswitcho(
      hosted: (package) => package.url == 'https://pub-web.flutter-io.cn',
      otherwise: () => false,
    );
4
likes
120
pub points
70%
popularity

Publisher

verified publisherdart-borg.dev

Dart library to access and manipulate content of pubpec.lock files

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

functional_data, json2yaml, meta, sum_types, yaml

More

Packages that depend on pubspec_lock