Merge pull request #115 from dart-lang/cleanup
Misc cleanup
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 898ebc4..c85ac50 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
-## 2.0.2-dev
+## 2.0.2
+
+- Update package description and README.
+- Change to package:lints for style checking.
+- Add an example.
## 2.0.1
diff --git a/README.md b/README.md
index ada1bd0..15ed4f6 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,13 @@
Support for working with **Package Configuration** files as described
in the Package Configuration v2 [design document](https://github.com/dart-lang/language/blob/master/accepted/future-releases/language-versioning/package-config-file-v2.md).
-The primary libraries are
+A Dart package configuration file is used to resolve Dart package names (e.g.
+`foobar`) to Dart files containing the source code for that package (e.g.
+`file:///Users/myuser/.pub-cache/hosted/pub.dartlang.org/foobar-1.1.0`). The
+standard package configuration file is `.dart_tool/package_config.json`, and is
+written by the Dart tool when the command `dart pub get` is run.
+
+The primary libraries of this package are
* `package_config.dart`:
Defines the `PackageConfig` class and other types needed to use
package configurations, and provides functions to find, read and
diff --git a/analysis_options.yaml b/analysis_options.yaml
index a0ba68d..278ec48 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -2,4 +2,4 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-include: package:pedantic/analysis_options.1.9.0.yaml
+include: package:lints/recommended.yaml
diff --git a/example/main.dart b/example/main.dart
new file mode 100644
index 0000000..42a5963
--- /dev/null
+++ b/example/main.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:package_config/package_config.dart';
+import 'dart:io' show Directory;
+
+void main() async {
+ var packageConfig = await findPackageConfig(Directory.current);
+ if (packageConfig == null) {
+ print('Failed to locate or read package config.');
+ } else {
+ print('This package depends on ${packageConfig.packages.length} packages:');
+ for (var package in packageConfig.packages) {
+ print('- ${package.name}');
+ }
+ }
+}
diff --git a/lib/package_config_types.dart b/lib/package_config_types.dart
index 482f82a..976009b 100644
--- a/lib/package_config_types.dart
+++ b/lib/package_config_types.dart
@@ -3,7 +3,13 @@
// BSD-style license that can be found in the LICENSE file.
/// A package configuration is a way to assign file paths to package URIs,
-/// and vice-versa,
+/// and vice-versa.
+///
+/// {@canonicalFor package_config.InvalidLanguageVersion}
+/// {@canonicalFor package_config.LanguageVersion}
+/// {@canonicalFor package_config.Package}
+/// {@canonicalFor package_config.PackageConfig}
+/// {@canonicalFor errors.PackageConfigError}
library package_config.package_config_types;
export 'src/package_config.dart'
diff --git a/lib/src/package_config_json.dart b/lib/src/package_config_json.dart
index 1998b66..fe185a2 100644
--- a/lib/src/package_config_json.dart
+++ b/lib/src/package_config_json.dart
@@ -35,7 +35,7 @@
PackageConfig parsePackageConfigBytes(
Uint8List bytes, Uri file, void Function(Object error) onError) {
// TODO(lrn): Make this simpler. Maybe parse directly from bytes.
- var jsonObject;
+ Object? jsonObject;
try {
jsonObject = _jsonUtf8Decoder.convert(bytes);
} on FormatException catch (e) {
@@ -47,7 +47,7 @@
PackageConfig parsePackageConfigString(
String source, Uri file, void Function(Object error) onError) {
- var jsonObject;
+ Object? jsonObject;
try {
jsonObject = jsonDecode(source);
} on FormatException catch (e) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 5cc9cc0..6f80473 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: package_config
-version: 2.0.2-dev
-description: Support for working with Package Configuration files.
+version: 2.0.2
+description: Support for reading and writing Dart Package Configuration files.
homepage: https://github.com/dart-lang/package_config
environment:
@@ -13,5 +13,5 @@
build_runner: ^2.0.0
build_test: ^2.1.2
build_web_compilers: ^3.0.0
- pedantic: ^1.10.0
+ lints: ^1.0.0
test: ^1.16.0
diff --git a/test/discovery_test.dart b/test/discovery_test.dart
index d2c3d83..4a1bba0 100644
--- a/test/discovery_test.dart
+++ b/test/discovery_test.dart
@@ -99,8 +99,7 @@
'.packages': packagesFile,
'subdir': {'script.dart': 'main(){}'}
}, (Directory directory) async {
- var config;
- config = await findPackageConfig(subdir(directory, 'subdir/'));
+ var config = (await findPackageConfig(subdir(directory, 'subdir/')))!;
expect(config.version, 1);
validatePackagesFile(config, directory);
});
diff --git a/test/discovery_uri_test.dart b/test/discovery_uri_test.dart
index 0a9b917..e487e47 100644
--- a/test/discovery_uri_test.dart
+++ b/test/discovery_uri_test.dart
@@ -98,9 +98,8 @@
'.packages': packagesFile,
'subdir': {'script.dart': 'main(){}'}
}, (directory, loader) async {
- var config;
- config = await findPackageConfigUri(directory.resolve('subdir/'),
- loader: loader);
+ var config = (await findPackageConfigUri(directory.resolve('subdir/'),
+ loader: loader))!;
expect(config.version, 1);
validatePackagesFile(config, directory);
});