From c6badcd94f96893e13be3f3dcff9c866780d99cb Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 31 May 2018 14:00:40 -0700 Subject: [PATCH 001/152] Initial commit --- pkgs/pubspec_parse/.gitignore | 4 ++ pkgs/pubspec_parse/README.md | 5 ++ pkgs/pubspec_parse/analysis_options.yaml | 76 ++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 pkgs/pubspec_parse/.gitignore create mode 100644 pkgs/pubspec_parse/README.md create mode 100644 pkgs/pubspec_parse/analysis_options.yaml diff --git a/pkgs/pubspec_parse/.gitignore b/pkgs/pubspec_parse/.gitignore new file mode 100644 index 000000000..ec8eae3f1 --- /dev/null +++ b/pkgs/pubspec_parse/.gitignore @@ -0,0 +1,4 @@ +# Don’t commit the following directories created by pub. +.dart_tool/ +.packages +pubspec.lock diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md new file mode 100644 index 000000000..b355cef76 --- /dev/null +++ b/pkgs/pubspec_parse/README.md @@ -0,0 +1,5 @@ +## Features and bugs + +Please file feature requests and bugs at the [issue tracker]. + +[issue tracker]: https://github.com/dart-lang/pubspec_parse/issues diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml new file mode 100644 index 000000000..8521d7b7d --- /dev/null +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -0,0 +1,76 @@ +analyzer: + strong-mode: + implicit-casts: false + errors: + dead_code: error + override_on_non_overriding_method: error + unused_element: error + unused_import: error + unused_local_variable: error +linter: + rules: + - annotate_overrides + - avoid_empty_else + - avoid_function_literals_in_foreach_calls + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_renaming_method_parameters + - avoid_return_types_on_setters + - avoid_returning_null + - avoid_types_as_parameter_names + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_types + - cancel_subscriptions + #- cascade_invocations + - comment_references + - constant_identifier_names + - control_flow_in_finally + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + - invariant_booleans + - iterable_contains_unrelated_type + - library_names + - library_prefixes + - list_remove_unrelated_type + - no_adjacent_strings_in_list + - no_duplicate_case_values + - non_constant_identifier_names + - omit_local_variable_types + - only_throw_errors + - overridden_fields + #- package_api_docs + - package_names + - package_prefixed_library_names + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_contains + - prefer_final_fields + - prefer_initializing_formals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_single_quotes + - prefer_typing_uninitialized_variables + - recursive_getters + - slash_for_doc_comments + - super_goes_last + - test_types_in_equals + - test_types_in_equals + - throw_in_finally + - type_init_formals + - unawaited_futures + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_null_aware_assignments + - unnecessary_statements + - unnecessary_this + - unrelated_type_equality_checks + - valid_regexps From 541969ec35ad2e3f86bb0bda260723d9a8801a4d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 09:22:24 -0700 Subject: [PATCH 002/152] Add initial package implementation (dart-lang/pubspec_parse#3) - Pubspec class - Dependency classes - top-level parsePubspec function --- pkgs/pubspec_parse/.travis.yml | 18 +++ pkgs/pubspec_parse/CHANGELOG.md | 4 + pkgs/pubspec_parse/build.yaml | 17 +++ pkgs/pubspec_parse/dart_test.yaml | 3 + pkgs/pubspec_parse/lib/pubspec_parse.dart | 14 ++ pkgs/pubspec_parse/lib/src/dependency.dart | 144 ++++++++++++++++++ pkgs/pubspec_parse/lib/src/errors.dart | 87 +++++++++++ pkgs/pubspec_parse/lib/src/functions.dart | 34 +++++ pkgs/pubspec_parse/lib/src/pubspec.dart | 103 +++++++++++++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 38 +++++ pkgs/pubspec_parse/pubspec.yaml | 20 +++ pkgs/pubspec_parse/test/dependency_test.dart | 128 ++++++++++++++++ .../pubspec_parse/test/ensure_build_test.dart | 63 ++++++++ pkgs/pubspec_parse/test/parse_test.dart | 95 ++++++++++++ pkgs/pubspec_parse/test/test_utils.dart | 74 +++++++++ 15 files changed, 842 insertions(+) create mode 100644 pkgs/pubspec_parse/.travis.yml create mode 100644 pkgs/pubspec_parse/CHANGELOG.md create mode 100644 pkgs/pubspec_parse/build.yaml create mode 100644 pkgs/pubspec_parse/dart_test.yaml create mode 100644 pkgs/pubspec_parse/lib/pubspec_parse.dart create mode 100644 pkgs/pubspec_parse/lib/src/dependency.dart create mode 100644 pkgs/pubspec_parse/lib/src/errors.dart create mode 100644 pkgs/pubspec_parse/lib/src/functions.dart create mode 100644 pkgs/pubspec_parse/lib/src/pubspec.dart create mode 100644 pkgs/pubspec_parse/lib/src/pubspec.g.dart create mode 100644 pkgs/pubspec_parse/pubspec.yaml create mode 100644 pkgs/pubspec_parse/test/dependency_test.dart create mode 100644 pkgs/pubspec_parse/test/ensure_build_test.dart create mode 100644 pkgs/pubspec_parse/test/parse_test.dart create mode 100644 pkgs/pubspec_parse/test/test_utils.dart diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml new file mode 100644 index 000000000..ea5469401 --- /dev/null +++ b/pkgs/pubspec_parse/.travis.yml @@ -0,0 +1,18 @@ +language: dart + +dart: + - dev + +dart_task: + - test: -x presubmit-only + - test: --run-skipped -t presubmit-only + - dartfmt + - dartanalyzer: --fatal-infos --fatal-warnings . + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md new file mode 100644 index 000000000..39d51431c --- /dev/null +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -0,0 +1,4 @@ +## 0.1.0 + +- Initial release including the `Pubspec` class and a top-level `parsePubspec` + function. diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml new file mode 100644 index 000000000..ec706e421 --- /dev/null +++ b/pkgs/pubspec_parse/build.yaml @@ -0,0 +1,17 @@ +# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config +# To update generated code, run `pub run build_runner build` +targets: + $default: + builders: + json_serializable: + generate_for: + - lib/src/pubspec.dart + options: + any_map: true + checked: true + header: |+ + // Copyright (c) 2018, 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. + + // GENERATED CODE - DO NOT MODIFY BY HAND diff --git a/pkgs/pubspec_parse/dart_test.yaml b/pkgs/pubspec_parse/dart_test.yaml new file mode 100644 index 000000000..1d7ac69cc --- /dev/null +++ b/pkgs/pubspec_parse/dart_test.yaml @@ -0,0 +1,3 @@ +tags: + presubmit-only: + skip: "Should only be run during presubmit" diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart new file mode 100644 index 000000000..3339982b1 --- /dev/null +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2018, 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. + +export 'src/dependency.dart' + show + Dependency, + HostedDependency, + GitDependency, + SdkDependency, + PathDependency; +export 'src/errors.dart' show ParsedYamlException; +export 'src/functions.dart' show parsePubspec; +export 'src/pubspec.dart' show Pubspec; diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart new file mode 100644 index 000000000..8c9ab15b5 --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -0,0 +1,144 @@ +// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; +import 'package:pub_semver/pub_semver.dart'; + +abstract class Dependency { + Dependency._(); + + /// Returns `null` if the data could not be parsed. + factory Dependency.fromJson(dynamic data) { + if (data == null) { + return new HostedDependency(VersionConstraint.any); + } else if (data is String) { + return new HostedDependency(new VersionConstraint.parse(data)); + } else if (data is Map) { + try { + return new Dependency._fromMap(data); + } on ArgumentError catch (e) { + throw new CheckedFromJsonException( + data, e.name, 'Dependency', e.message.toString()); + } + } + + return null; + } + + factory Dependency._fromMap(Map data) { + if (data.entries.isEmpty) { + // TODO: provide list of supported keys? + throw new CheckedFromJsonException( + data, null, 'Dependency', 'Must provide at least one key.'); + } + + if (data.containsKey('sdk')) { + return new SdkDependency.fromData(data); + } + + if (data.entries.length > 1) { + throw new CheckedFromJsonException( + data, + data.keys.skip(1).first as String, + 'Dependency', + 'Expected only one key.'); + } + + var entry = data.entries.single; + var key = entry.key as String; + + if (entry.value == null) { + throw new CheckedFromJsonException( + data, key, 'Dependency', 'Cannot be null.'); + } + + switch (key) { + case 'path': + return new PathDependency.fromData(entry.value); + case 'git': + return new GitDependency.fromData(entry.value); + } + + return null; + } + + String get _info; + + @override + String toString() => '$runtimeType: $_info'; +} + +class SdkDependency extends Dependency { + final String name; + final VersionConstraint version; + + SdkDependency(this.name, {this.version}) : super._(); + + factory SdkDependency.fromData(Map data) { + VersionConstraint version; + if (data.containsKey('version')) { + version = new VersionConstraint.parse(data['version'] as String); + } + return new SdkDependency(data['sdk'] as String, version: version); + } + + @override + String get _info => name; +} + +class GitDependency extends Dependency { + final Uri url; + final String ref; + final String path; + + GitDependency(this.url, this.ref, this.path) : super._(); + + factory GitDependency.fromData(Object data) { + String url; + String path; + String ref; + + if (data is String) { + url = data; + } else if (data is Map) { + url = data['url'] as String; + path = data['path'] as String; + ref = data['ref'] as String; + } else { + throw new ArgumentError.value(data, 'git', 'Must be a String or a Map.'); + } + + // TODO: validate `url` is a valid URI + return new GitDependency(Uri.parse(url), ref, path); + } + + @override + String get _info => 'url@$url'; +} + +class PathDependency extends Dependency { + final String path; + + PathDependency(this.path) : super._(); + + factory PathDependency.fromData(Object data) { + if (data is String) { + return new PathDependency(data); + } + throw new ArgumentError.value(data, 'path', 'Must be a String.'); + } + + @override + String get _info => 'path@$path'; +} + +// TODO: support explicit host? +class HostedDependency extends Dependency { + final VersionConstraint constraint; + + HostedDependency(this.constraint) : super._(); + + @override + String get _info => constraint.toString(); +} diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart new file mode 100644 index 000000000..9b1489cf4 --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -0,0 +1,87 @@ +// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; +import 'package:yaml/yaml.dart'; + +ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => + new ParsedYamlException._(message, yamlNode); + +ParsedYamlException parsedYamlExceptionFromError( + CheckedFromJsonException error, StackTrace stack) { + var innerError = error.innerError; + if (innerError is BadKeyException) { + var map = innerError.map; + if (map is YamlMap) { + var key = map.nodes.keys.singleWhere((key) { + return (key as YamlScalar).value == innerError.key; + }, orElse: () => null); + + if (key is YamlScalar) { + return new ParsedYamlException._(innerError.message, key, + innerError: error, innerStack: stack); + } + } + } else if (innerError is ParsedYamlException) { + return innerError; + } + + var yamlMap = error.map as YamlMap; + var yamlNode = yamlMap.nodes[error.key]; + + String message; + if (yamlNode == null) { + assert(error.message != null); + message = error.message; + yamlNode = yamlMap; + } else { + if (error.message == null) { + message = 'Unsupported value for `${error.key}`.'; + } else { + message = error.message.toString(); + } + } + + return new ParsedYamlException._(message, yamlNode, + innerError: error, innerStack: stack); +} + +/// Thrown when parsing a YAML document fails. +class ParsedYamlException implements Exception { + /// Describes the nature of the parse failure. + final String message; + + /// The [YamlNode] that corresponds to the exception. + final YamlNode yamlNode; + + /// If this exception was thrown as a result of another error, + /// contains the source error object. + final Object innerError; + + /// If this exception was thrown as a result of another error, + /// contains the corresponding [StackTrace]. + final StackTrace innerStack; + + ParsedYamlException._(this.message, this.yamlNode, + {this.innerError, this.innerStack}); + + /// Returns [message] formatted with source information provided by + /// [yamlNode]. + String get formatMessage => yamlNode.span.message(message); + + @override + String toString() => message; +} + +/// Package-private class representing an invalid key. +/// +/// Used instead of [CheckedFromJsonException] when highlighting a bad [key] +/// is desired, instead of the associated value. +class BadKeyException implements Exception { + final Map map; + final String key; + final String message; + + BadKeyException(this.map, this.key, this.message); +} diff --git a/pkgs/pubspec_parse/lib/src/functions.dart b/pkgs/pubspec_parse/lib/src/functions.dart new file mode 100644 index 000000000..84ef35cc0 --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/functions.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; +import 'package:yaml/yaml.dart'; + +import 'errors.dart'; +import 'pubspec.dart'; + +/// If [sourceUrl] is passed, it's used as the URL from which the YAML +/// originated for error reporting. It can be a [String], a [Uri], or `null`. +Pubspec parsePubspec(String yaml, {sourceUrl}) { + var item = loadYaml(yaml, sourceUrl: sourceUrl); + + if (item == null) { + throw new ArgumentError.notNull('yaml'); + } + + if (item is! YamlMap) { + if (item is YamlNode) { + throw parsedYamlException('Does not represent a YAML map.', item); + } + + throw new ArgumentError.value( + yaml, 'yaml', 'Does not represent a YAML map.'); + } + + try { + return new Pubspec.fromJson(item as YamlMap); + } on CheckedFromJsonException catch (error, stack) { + throw parsedYamlExceptionFromError(error, stack); + } +} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart new file mode 100644 index 000000000..6a5c3a6ad --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -0,0 +1,103 @@ +// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; +import 'package:pub_semver/pub_semver.dart'; + +import 'dependency.dart'; +import 'errors.dart'; + +part 'pubspec.g.dart'; + +@JsonSerializable(createToJson: false) +class Pubspec { + final String name; + final String homepage; + final String documentation; + final String description; + final String author; + final List authors; + + @JsonKey(fromJson: _environmentMap) + final Map environment; + + List get allAuthors { + var values = []; + if (author != null) { + values.add(author); + } + values.addAll(authors); + return values; + } + + @JsonKey(fromJson: _versionFromString) + final Version version; + + @JsonKey(fromJson: _getDeps, nullable: false) + final Map dependencies; + + @JsonKey(name: 'dev_dependencies', fromJson: _getDeps, nullable: false) + final Map devDependencies; + + @JsonKey(name: 'dependency_overrides', fromJson: _getDeps, nullable: false) + final Map dependencyOverrides; + + Pubspec( + this.name, { + this.version, + this.author, + this.environment, + List authors, + this.homepage, + this.documentation, + this.description, + Map dependencies, + Map devDependencies, + Map dependencyOverrides, + }) : this.authors = authors ?? const [], + this.dependencies = dependencies ?? const {}, + this.devDependencies = devDependencies ?? const {}, + this.dependencyOverrides = dependencyOverrides ?? const {} { + if (name == null || name.isEmpty) { + throw new ArgumentError.value(name, 'name', '"name" cannot be empty.'); + } + } + + factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); +} + +// TODO: maybe move this to `dependencies.dart`? +Map _getDeps(Map source) => + source?.map((k, v) { + var key = k as String; + var value = new Dependency.fromJson(v); + if (value == null) { + throw new CheckedFromJsonException( + source, key, 'Pubspec', 'Not a valid dependency value.'); + } + return new MapEntry(key, value); + }) ?? + {}; + +Version _versionFromString(String input) => new Version.parse(input); + +Map _environmentMap(Map source) => + source.map((key, value) { + if (key == 'dart') { + // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 + // 'dart' is not allowed as a key! + throw new BadKeyException( + source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); + } + + VersionConstraint constraint; + try { + constraint = new VersionConstraint.parse(value as String); + } on FormatException catch (e) { + throw new CheckedFromJsonException( + source, key as String, 'Pubspec', e.message); + } + + return new MapEntry(key as String, constraint); + }); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart new file mode 100644 index 000000000..b98d76654 --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2018, 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. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pubspec.dart'; + +// ************************************************************************** +// Generator: JsonSerializableGenerator +// ************************************************************************** + +Pubspec _$PubspecFromJson(Map json) => $checkedNew( + 'Pubspec', + json, + () => new Pubspec($checkedConvert(json, 'name', (v) => v as String), + version: $checkedConvert(json, 'version', + (v) => v == null ? null : _versionFromString(v as String)), + author: $checkedConvert(json, 'author', (v) => v as String), + environment: $checkedConvert(json, 'environment', + (v) => v == null ? null : _environmentMap(v as Map)), + authors: $checkedConvert(json, 'authors', + (v) => (v as List)?.map((e) => e as String)?.toList()), + homepage: $checkedConvert(json, 'homepage', (v) => v as String), + documentation: + $checkedConvert(json, 'documentation', (v) => v as String), + description: + $checkedConvert(json, 'description', (v) => v as String), + dependencies: $checkedConvert( + json, 'dependencies', (v) => _getDeps(v as Map)), + devDependencies: $checkedConvert( + json, 'dev_dependencies', (v) => _getDeps(v as Map)), + dependencyOverrides: $checkedConvert( + json, 'dependency_overrides', (v) => _getDeps(v as Map))), + fieldKeyMap: const { + 'devDependencies': 'dev_dependencies', + 'dependencyOverrides': 'dependency_overrides' + }); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml new file mode 100644 index 000000000..ae1a617a0 --- /dev/null +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -0,0 +1,20 @@ +name: pubspec_parse +description: >- + Simple package for parsing pubspec.yaml files with a type-safe API and rich + error reporting. +version: 0.1.0-dev +homepage: https://github.com/dart-lang/pubspec_parse +author: Dart Team + +environment: + sdk: '>=2.0.0-dev.54 <2.0.0' + +dependencies: + json_annotation: ^0.2.6 + pub_semver: ^1.3.2 + yaml: ^2.1.12 + +dev_dependencies: + build_runner: ^0.8.0 + json_serializable: ^0.5.5 + test: ^0.12.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart new file mode 100644 index 000000000..21c621dbf --- /dev/null +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -0,0 +1,128 @@ +// Copyright (c) 2018, 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:pubspec_parse/pubspec_parse.dart'; +import 'package:test/test.dart'; + +import 'test_utils.dart'; + +void main() { + test('HostedDepedency', () { + var dep = _dependency('^1.0.0'); + expect(dep.constraint.toString(), '^1.0.0'); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + + test('SdkDependency without version', () { + var dep = _dependency({'sdk': 'flutter'}); + expect(dep.name, 'flutter'); + expect(dep.version, isNull); + expect(dep.toString(), 'SdkDependency: flutter'); + }); + + test('SdkDependency with version', () { + var dep = _dependency( + {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}); + expect(dep.name, 'flutter'); + expect(dep.version.toString(), '>=1.2.3 <2.0.0'); + expect(dep.toString(), 'SdkDependency: flutter'); + }); + + test('GitDependency', () { + var dep = _dependency({'git': 'bob'}); + expect(dep.url.toString(), 'bob'); + expect(dep.toString(), 'GitDependency: url@bob'); + }); + + test('HostedDepedency', () { + var dep = _dependency('^1.0.0'); + expect(dep.constraint.toString(), '^1.0.0'); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + + test('PathDependency', () { + var dep = _dependency({'path': '../path'}); + expect(dep.path, '../path'); + expect(dep.toString(), 'PathDependency: path@../path'); + }); + + group('errors', () { + test('List', () { + _expectThrows([], r''' +line 4, column 10: Not a valid dependency value. + "dep": [] + ^^'''); + }); + + test('int', () { + _expectThrows(42, r''' +line 4, column 10: Not a valid dependency value. + "dep": 42 + ^^^'''); + }); + + test('empty map', () { + _expectThrows({}, r''' +line 4, column 10: Must provide at least one key. + "dep": {} + ^^'''); + }); + + test('map with too many keys', () { + _expectThrows({'path': 'a', 'git': 'b'}, r''' +line 5, column 12: Expected only one key. + "path": "a", + ^^^'''); + }); + + test('git - null content', () { + _expectThrows({'git': null}, r''' +line 5, column 11: Cannot be null. + "git": null + ^^^^^'''); + }); + + test('git - int content', () { + _expectThrows({'git': 42}, r''' +line 5, column 11: Must be a String or a Map. + "git": 42 + ^^^'''); + }); + + test('path - null content', () { + _expectThrows({'path': null}, r''' +line 5, column 12: Cannot be null. + "path": null + ^^^^^'''); + }); + + test('path - int content', () { + _expectThrows({'path': 42}, r''' +line 5, column 12: Must be a String. + "path": 42 + ^^^'''); + }); + }); +} + +void _expectThrows(Object content, String expectedError) { + expectParseThrows({ + 'name': 'sample', + 'dependencies': {'dep': content} + }, expectedError); +} + +T _dependency(Object content) { + var value = parse({ + 'name': 'sample', + 'dependencies': {'dep': content} + }); + expect(value.name, 'sample'); + expect(value.dependencies, hasLength(1)); + + var entry = value.dependencies.entries.single; + expect(entry.key, 'dep'); + + return entry.value as T; +} diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart new file mode 100644 index 000000000..2842c5a06 --- /dev/null +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -0,0 +1,63 @@ +// Copyright (c) 2018, 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. + +@TestOn('vm') +@Tags(const ['presubmit-only']) + +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +void main() { + // TODO(kevmoo): replace with a common utility + // https://github.com/dart-lang/build/issues/716 + test('ensure local build succeeds with no changes', () { + var pkgRoot = _runProc('git', ['rev-parse', '--show-toplevel']); + var currentDir = Directory.current.resolveSymbolicLinksSync(); + + if (!p.equals(p.join(pkgRoot), currentDir)) { + throw new StateError('Expected the git root ($pkgRoot) ' + 'to match the current directory ($currentDir).'); + } + + // 1 - get a list of modified `.g.dart` files - should be empty + expect(_changedGeneratedFiles(), isEmpty); + + // 2 - run build - should be no output, since nothing should change + var result = _runProc('pub', + ['run', 'build_runner', 'build', '--delete-conflicting-outputs']); + + print(result); + expect(result, + contains(new RegExp(r'\[INFO\] Succeeded after \S+ with \d+ outputs'))); + + // 3 - get a list of modified `.g.dart` files - should still be empty + expect(_changedGeneratedFiles(), isEmpty); + }); +} + +final _whitespace = new RegExp(r'\s'); + +Set _changedGeneratedFiles() { + var output = _runProc('git', ['status', '--porcelain']); + + return LineSplitter + .split(output) + .map((line) => line.split(_whitespace).last) + .where((path) => path.endsWith('.dart')) + .toSet(); +} + +String _runProc(String proc, List args) { + var result = Process.runSync(proc, args); + + if (result.exitCode != 0) { + throw new ProcessException( + proc, args, result.stderr as String, result.exitCode); + } + + return (result.stdout as String).trim(); +} diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart new file mode 100644 index 000000000..7a4af7625 --- /dev/null +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -0,0 +1,95 @@ +// Copyright (c) 2018, 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:test/test.dart'; + +import 'test_utils.dart'; + +void main() { + test('trival', () { + var value = parse({'name': 'sample'}); + expect(value.name, 'sample'); + expect(value.authors, isEmpty); + expect(value.dependencies, isEmpty); + }); + + test('one author', () { + var value = parse({'name': 'sample', 'author': 'name@example.com'}); + expect(value.allAuthors, ['name@example.com']); + }); + + test('one author, via authors', () { + var value = parse({ + 'name': 'sample', + 'authors': ['name@example.com'] + }); + expect(value.authors, ['name@example.com']); + }); + + test('many authors', () { + var value = parse({ + 'name': 'sample', + 'authors': ['name@example.com', 'name2@example.com'] + }); + expect(value.authors, ['name@example.com', 'name2@example.com']); + }); + + test('author and authors', () { + var value = parse({ + 'name': 'sample', + 'author': 'name@example.com', + 'authors': ['name2@example.com'] + }); + expect(value.allAuthors, ['name@example.com', 'name2@example.com']); + }); + + group('invalid', () { + test('null', () { + expect(() => parse(null), throwsArgumentError); + }); + test('empty string', () { + expect(() => parse(''), throwsArgumentError); + }); + test('array', () { + expectParseThrows([], r''' +line 1, column 1: Does not represent a YAML map. +[] +^^'''); + }); + + test('missing name', () { + expectParseThrows({}, r''' +line 1, column 1: "name" cannot be empty. +{} +^^'''); + }); + + test('"dart" is an invalid environment key', () { + expectParseThrows({ + 'name': 'sample', + 'environment': {'dart': 'cool'} + }, r''' +line 4, column 3: Use "sdk" to for Dart SDK constraints. + "dart": "cool" + ^^^^^^'''); + }); + + test('invalid version', () { + expectParseThrows({'name': 'sample', 'version': 'invalid'}, r''' +line 3, column 13: Unsupported value for `version`. + "version": "invalid" + ^^^^^^^^^'''); + }); + + test('invalid environment value', () { + expectParseThrows({ + 'name': 'sample', + 'environment': {'sdk': 'silly'} + }, r''' +line 4, column 10: Could not parse version "silly". Unknown text at "silly". + "sdk": "silly" + ^^^^^^^'''); + }); + }); +} diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart new file mode 100644 index 000000000..69102bf08 --- /dev/null +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -0,0 +1,74 @@ +// Copyright (c) 2018, 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 'dart:convert'; + +import 'package:json_annotation/json_annotation.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:stack_trace/stack_trace.dart'; +import 'package:test/test.dart'; + +String _encodeJson(Object input) => + const JsonEncoder.withIndent(' ').convert(input); + +Matcher _throwsParsedYamlException(String prettyValue) => throwsA(allOf( + const isInstanceOf(), + new FeatureMatcher('formatMessage', (e) { + var message = e.formatMessage; + printOnFailure("Actual error format:\nr'''\n$message'''"); + _printDebugParsedYamlException(e); + return message; + }, prettyValue))); + +void _printDebugParsedYamlException(ParsedYamlException e) { + var innerError = e.innerError; + var innerStack = e.innerStack; + + if (e.innerError is CheckedFromJsonException) { + var cfje = e.innerError as CheckedFromJsonException; + if (cfje.innerError != null) { + innerError = cfje.innerError; + innerStack = cfje.innerStack; + } + } + + if (innerError != null) { + var items = [innerError]; + if (innerStack != null) { + items.add(Trace.format(innerStack, terse: true)); + } + + var content = + LineSplitter.split(items.join('\n')).map((e) => ' $e').join('\n'); + + printOnFailure('Inner error details:\n$content'); + } +} + +Pubspec parse(Object content, {bool quietOnError: false}) { + quietOnError ??= false; + try { + return parsePubspec(_encodeJson(content)); + } on ParsedYamlException catch (e) { + if (!quietOnError) { + _printDebugParsedYamlException(e); + } + rethrow; + } +} + +void expectParseThrows(Object content, String expectedError) => expect( + () => parse(content, quietOnError: true), + _throwsParsedYamlException(expectedError)); + +// TODO(kevmoo) add this to pkg/matcher – is nice! +class FeatureMatcher extends CustomMatcher { + final dynamic Function(T value) _feature; + + FeatureMatcher(String name, this._feature, matcher) + : super('`$name`', '`$name`', matcher); + + @override + featureValueOf(covariant T actual) => _feature(actual); +} From 0736e275fa1735a4e8c9bc201aac6ac54f2e068a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 09:53:25 -0700 Subject: [PATCH 003/152] Handle author and authors in a more sane way There is at least one published package with both author & authors set https://pub.dartlang.org/packages/crclib/versions/1.0.0 So we do normalization if both are set, eliminating duplicates and providing reasonable values from both author and authors properties Fixes https://github.com/dart-lang/pubspec_parse/issues/2 --- pkgs/pubspec_parse/lib/src/pubspec.dart | 42 +++++++++----- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 4 +- pkgs/pubspec_parse/test/parse_test.dart | 67 +++++++++++++++-------- 3 files changed, 76 insertions(+), 37 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 6a5c3a6ad..90efa1cb9 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -16,21 +16,24 @@ class Pubspec { final String homepage; final String documentation; final String description; - final String author; + + /// If there is exactly 1 value in [authors], returns it. + /// + /// If there are 0 or more than 1, returns `null`. + @Deprecated( + 'Here for completeness, but not recommended. Use `authors` instead.') + String get author { + if (authors.length == 1) { + return authors.single; + } + return null; + } + final List authors; @JsonKey(fromJson: _environmentMap) final Map environment; - List get allAuthors { - var values = []; - if (author != null) { - values.add(author); - } - values.addAll(authors); - return values; - } - @JsonKey(fromJson: _versionFromString) final Version version; @@ -43,19 +46,21 @@ class Pubspec { @JsonKey(name: 'dependency_overrides', fromJson: _getDeps, nullable: false) final Map dependencyOverrides; + /// If [author] and [authors] are both provided, their values are combined + /// with duplicates eliminated. Pubspec( this.name, { this.version, - this.author, - this.environment, + String author, List authors, + this.environment, this.homepage, this.documentation, this.description, Map dependencies, Map devDependencies, Map dependencyOverrides, - }) : this.authors = authors ?? const [], + }) : this.authors = _normalizeAuthors(author, authors), this.dependencies = dependencies ?? const {}, this.devDependencies = devDependencies ?? const {}, this.dependencyOverrides = dependencyOverrides ?? const {} { @@ -65,6 +70,17 @@ class Pubspec { } factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); + + static List _normalizeAuthors(String author, List authors) { + var value = new Set(); + if (author != null) { + value.add(author); + } + if (authors != null) { + value.addAll(authors); + } + return value.toList(); + } } // TODO: maybe move this to `dependencies.dart`? diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index b98d76654..4f040fffc 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -17,10 +17,10 @@ Pubspec _$PubspecFromJson(Map json) => $checkedNew( version: $checkedConvert(json, 'version', (v) => v == null ? null : _versionFromString(v as String)), author: $checkedConvert(json, 'author', (v) => v as String), - environment: $checkedConvert(json, 'environment', - (v) => v == null ? null : _environmentMap(v as Map)), authors: $checkedConvert(json, 'authors', (v) => (v as List)?.map((e) => e as String)?.toList()), + environment: $checkedConvert(json, 'environment', + (v) => v == null ? null : _environmentMap(v as Map)), homepage: $checkedConvert(json, 'homepage', (v) => v as String), documentation: $checkedConvert(json, 'documentation', (v) => v as String), diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 7a4af7625..bfe20f0a9 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -10,38 +10,61 @@ void main() { test('trival', () { var value = parse({'name': 'sample'}); expect(value.name, 'sample'); + // ignore: deprecated_member_use + expect(value.author, isNull); expect(value.authors, isEmpty); expect(value.dependencies, isEmpty); }); - test('one author', () { - var value = parse({'name': 'sample', 'author': 'name@example.com'}); - expect(value.allAuthors, ['name@example.com']); - }); + group('author, authors', () { + test('one author', () { + var value = parse({'name': 'sample', 'author': 'name@example.com'}); + // ignore: deprecated_member_use + expect(value.author, 'name@example.com'); + expect(value.authors, ['name@example.com']); + }); - test('one author, via authors', () { - var value = parse({ - 'name': 'sample', - 'authors': ['name@example.com'] + test('one author, via authors', () { + var value = parse({ + 'name': 'sample', + 'authors': ['name@example.com'] + }); + // ignore: deprecated_member_use + expect(value.author, 'name@example.com'); + expect(value.authors, ['name@example.com']); + }); + + test('many authors', () { + var value = parse({ + 'name': 'sample', + 'authors': ['name@example.com', 'name2@example.com'] + }); + // ignore: deprecated_member_use + expect(value.author, isNull); + expect(value.authors, ['name@example.com', 'name2@example.com']); }); - expect(value.authors, ['name@example.com']); - }); - test('many authors', () { - var value = parse({ - 'name': 'sample', - 'authors': ['name@example.com', 'name2@example.com'] + test('author and authors', () { + var value = parse({ + 'name': 'sample', + 'author': 'name@example.com', + 'authors': ['name2@example.com'] + }); + // ignore: deprecated_member_use + expect(value.author, isNull); + expect(value.authors, ['name@example.com', 'name2@example.com']); }); - expect(value.authors, ['name@example.com', 'name2@example.com']); - }); - test('author and authors', () { - var value = parse({ - 'name': 'sample', - 'author': 'name@example.com', - 'authors': ['name2@example.com'] + test('duplicate author values', () { + var value = parse({ + 'name': 'sample', + 'author': 'name@example.com', + 'authors': ['name@example.com', 'name@example.com'] + }); + // ignore: deprecated_member_use + expect(value.author, 'name@example.com'); + expect(value.authors, ['name@example.com']); }); - expect(value.allAuthors, ['name@example.com', 'name2@example.com']); }); group('invalid', () { From c136a5ad38a35f66477e7c410bfce9035eb80d29 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 10:01:08 -0700 Subject: [PATCH 004/152] Test all trivial fields --- pkgs/pubspec_parse/lib/src/pubspec.dart | 11 ++++----- pkgs/pubspec_parse/test/parse_test.dart | 30 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 90efa1cb9..06d358a47 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -13,9 +13,12 @@ part 'pubspec.g.dart'; @JsonSerializable(createToJson: false) class Pubspec { final String name; - final String homepage; - final String documentation; + + @JsonKey(fromJson: _versionFromString) + final Version version; + final String description; + final String homepage; /// If there is exactly 1 value in [authors], returns it. /// @@ -30,13 +33,11 @@ class Pubspec { } final List authors; + final String documentation; @JsonKey(fromJson: _environmentMap) final Map environment; - @JsonKey(fromJson: _versionFromString) - final Version version; - @JsonKey(fromJson: _getDeps, nullable: false) final Map dependencies; diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index bfe20f0a9..d163e5a39 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -7,13 +7,41 @@ import 'package:test/test.dart'; import 'test_utils.dart'; void main() { - test('trival', () { + test('minimal set values', () { var value = parse({'name': 'sample'}); expect(value.name, 'sample'); + expect(value.version, isNull); + expect(value.description, isNull); + expect(value.homepage, isNull); // ignore: deprecated_member_use expect(value.author, isNull); expect(value.authors, isEmpty); + expect(value.documentation, isNull); expect(value.dependencies, isEmpty); + expect(value.devDependencies, isEmpty); + expect(value.dependencyOverrides, isEmpty); + }); + + test('all fields set', () { + var value = parse({ + 'name': 'sample', + 'version': '1.2.3', + 'author': 'name@example.com', + 'description': 'description', + 'homepage': 'homepage', + 'documentation': 'documentation' + }); + expect(value.name, 'sample'); + expect(value.version.toString(), '1.2.3'); + expect(value.description, 'description'); + expect(value.homepage, 'homepage'); + // ignore: deprecated_member_use + expect(value.author, 'name@example.com'); + expect(value.authors, ['name@example.com']); + expect(value.documentation, 'documentation'); + expect(value.dependencies, isEmpty); + expect(value.devDependencies, isEmpty); + expect(value.dependencyOverrides, isEmpty); }); group('author, authors', () { From 21f602ab29333157a6a96c67929f95128eacd1f7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 10:10:11 -0700 Subject: [PATCH 005/152] Move _getDeps to dependencies.dart - renamed to parseDeps Removed public Dependency.fromJson ctor --- pkgs/pubspec_parse/lib/src/dependency.dart | 99 ++++++++++++---------- pkgs/pubspec_parse/lib/src/pubspec.dart | 19 +---- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 6 +- 3 files changed, 60 insertions(+), 64 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 8c9ab15b5..935325004 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -5,64 +5,73 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; -abstract class Dependency { - Dependency._(); - - /// Returns `null` if the data could not be parsed. - factory Dependency.fromJson(dynamic data) { - if (data == null) { - return new HostedDependency(VersionConstraint.any); - } else if (data is String) { - return new HostedDependency(new VersionConstraint.parse(data)); - } else if (data is Map) { - try { - return new Dependency._fromMap(data); - } on ArgumentError catch (e) { +Map parseDeps(Map source) => + source?.map((k, v) { + var key = k as String; + var value = _fromJson(v); + if (value == null) { throw new CheckedFromJsonException( - data, e.name, 'Dependency', e.message.toString()); + source, key, 'Pubspec', 'Not a valid dependency value.'); } + return new MapEntry(key, value); + }) ?? + {}; + +/// Returns `null` if the data could not be parsed. +Dependency _fromJson(dynamic data) { + if (data == null) { + return new HostedDependency(VersionConstraint.any); + } else if (data is String) { + return new HostedDependency(new VersionConstraint.parse(data)); + } else if (data is Map) { + try { + return _fromMap(data); + } on ArgumentError catch (e) { + throw new CheckedFromJsonException( + data, e.name, 'Dependency', e.message.toString()); } - - return null; } - factory Dependency._fromMap(Map data) { - if (data.entries.isEmpty) { - // TODO: provide list of supported keys? - throw new CheckedFromJsonException( - data, null, 'Dependency', 'Must provide at least one key.'); - } + return null; +} - if (data.containsKey('sdk')) { - return new SdkDependency.fromData(data); - } +Dependency _fromMap(Map data) { + if (data.entries.isEmpty) { +// TODO: provide list of supported keys? + throw new CheckedFromJsonException( + data, null, 'Dependency', 'Must provide at least one key.'); + } - if (data.entries.length > 1) { - throw new CheckedFromJsonException( - data, - data.keys.skip(1).first as String, - 'Dependency', - 'Expected only one key.'); - } + if (data.containsKey('sdk')) { + return new SdkDependency.fromData(data); + } - var entry = data.entries.single; - var key = entry.key as String; + if (data.entries.length > 1) { + throw new CheckedFromJsonException(data, data.keys.skip(1).first as String, + 'Dependency', 'Expected only one key.'); + } - if (entry.value == null) { - throw new CheckedFromJsonException( - data, key, 'Dependency', 'Cannot be null.'); - } + var entry = data.entries.single; + var key = entry.key as String; - switch (key) { - case 'path': - return new PathDependency.fromData(entry.value); - case 'git': - return new GitDependency.fromData(entry.value); - } + if (entry.value == null) { + throw new CheckedFromJsonException( + data, key, 'Dependency', 'Cannot be null.'); + } - return null; + switch (key) { + case 'path': + return new PathDependency.fromData(entry.value); + case 'git': + return new GitDependency.fromData(entry.value); } + return null; +} + +abstract class Dependency { + Dependency._(); + String get _info; @override diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 06d358a47..3c9c045d4 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -38,13 +38,13 @@ class Pubspec { @JsonKey(fromJson: _environmentMap) final Map environment; - @JsonKey(fromJson: _getDeps, nullable: false) + @JsonKey(fromJson: parseDeps, nullable: false) final Map dependencies; - @JsonKey(name: 'dev_dependencies', fromJson: _getDeps, nullable: false) + @JsonKey(name: 'dev_dependencies', fromJson: parseDeps, nullable: false) final Map devDependencies; - @JsonKey(name: 'dependency_overrides', fromJson: _getDeps, nullable: false) + @JsonKey(name: 'dependency_overrides', fromJson: parseDeps, nullable: false) final Map dependencyOverrides; /// If [author] and [authors] are both provided, their values are combined @@ -84,19 +84,6 @@ class Pubspec { } } -// TODO: maybe move this to `dependencies.dart`? -Map _getDeps(Map source) => - source?.map((k, v) { - var key = k as String; - var value = new Dependency.fromJson(v); - if (value == null) { - throw new CheckedFromJsonException( - source, key, 'Pubspec', 'Not a valid dependency value.'); - } - return new MapEntry(key, value); - }) ?? - {}; - Version _versionFromString(String input) => new Version.parse(input); Map _environmentMap(Map source) => diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 4f040fffc..c32db09ff 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -27,11 +27,11 @@ Pubspec _$PubspecFromJson(Map json) => $checkedNew( description: $checkedConvert(json, 'description', (v) => v as String), dependencies: $checkedConvert( - json, 'dependencies', (v) => _getDeps(v as Map)), + json, 'dependencies', (v) => parseDeps(v as Map)), devDependencies: $checkedConvert( - json, 'dev_dependencies', (v) => _getDeps(v as Map)), + json, 'dev_dependencies', (v) => parseDeps(v as Map)), dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => _getDeps(v as Map))), + json, 'dependency_overrides', (v) => parseDeps(v as Map))), fieldKeyMap: const { 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' From ad586155548f05942812c4ca0da09faf22440fdd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 10:43:36 -0700 Subject: [PATCH 006/152] Improve handling of git dependencies and improve associated tests --- pkgs/pubspec_parse/build.yaml | 1 + pkgs/pubspec_parse/lib/src/dependency.dart | 38 +++++++++++------ pkgs/pubspec_parse/lib/src/dependency.g.dart | 20 +++++++++ pkgs/pubspec_parse/lib/src/errors.dart | 16 +++---- pkgs/pubspec_parse/test/dependency_test.dart | 45 ++++++++++++++++++-- 5 files changed, 94 insertions(+), 26 deletions(-) create mode 100644 pkgs/pubspec_parse/lib/src/dependency.g.dart diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index ec706e421..930aad181 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -6,6 +6,7 @@ targets: json_serializable: generate_for: - lib/src/pubspec.dart + - lib/src/dependency.dart options: any_map: true checked: true diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 935325004..526023984 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -4,6 +4,9 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/src/errors.dart'; + +part 'dependency.g.dart'; Map parseDeps(Map source) => source?.map((k, v) { @@ -96,36 +99,43 @@ class SdkDependency extends Dependency { String get _info => name; } +@JsonSerializable(createToJson: false) class GitDependency extends Dependency { + @JsonKey(fromJson: _parseUri) final Uri url; final String ref; final String path; - GitDependency(this.url, this.ref, this.path) : super._(); + GitDependency(this.url, this.ref, this.path) : super._() { + if (url == null) { + throw new ArgumentError.value(url, 'url', '"url" cannot be null.'); + } + } factory GitDependency.fromData(Object data) { - String url; - String path; - String ref; - if (data is String) { - url = data; - } else if (data is Map) { - url = data['url'] as String; - path = data['path'] as String; - ref = data['ref'] as String; - } else { - throw new ArgumentError.value(data, 'git', 'Must be a String or a Map.'); + data = {'url': data}; } - // TODO: validate `url` is a valid URI - return new GitDependency(Uri.parse(url), ref, path); + if (data is Map) { + // TODO: Need JsonKey.required + // https://github.com/dart-lang/json_serializable/issues/216 + if (!data.containsKey('url')) { + throw new BadKeyException(data, 'url', '"url" is required.'); + } + + return _$GitDependencyFromJson(data); + } + + throw new ArgumentError.value(data, 'git', 'Must be a String or a Map.'); } @override String get _info => 'url@$url'; } +Uri _parseUri(String value) => Uri.parse(value); + class PathDependency extends Dependency { final String path; diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart new file mode 100644 index 000000000..cdb06bbc9 --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2018, 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. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'dependency.dart'; + +// ************************************************************************** +// Generator: JsonSerializableGenerator +// ************************************************************************** + +GitDependency _$GitDependencyFromJson(Map json) => $checkedNew( + 'GitDependency', + json, + () => new GitDependency( + $checkedConvert( + json, 'url', (v) => v == null ? null : _parseUri(v as String)), + $checkedConvert(json, 'ref', (v) => v as String), + $checkedConvert(json, 'path', (v) => v as String))); diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index 9b1489cf4..288553c4a 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -14,14 +14,14 @@ ParsedYamlException parsedYamlExceptionFromError( if (innerError is BadKeyException) { var map = innerError.map; if (map is YamlMap) { - var key = map.nodes.keys.singleWhere((key) { - return (key as YamlScalar).value == innerError.key; - }, orElse: () => null); - - if (key is YamlScalar) { - return new ParsedYamlException._(innerError.message, key, - innerError: error, innerStack: stack); - } + // if the associated key exists, use that as the error node, + // otherwise use the map itself + var node = map.nodes.keys.cast().singleWhere((key) { + return key.value == innerError.key; + }, orElse: () => map); + + return new ParsedYamlException._(innerError.message, node, + innerError: error, innerStack: stack); } } else if (innerError is ParsedYamlException) { return innerError; diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 21c621dbf..8ede482cc 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -29,10 +29,22 @@ void main() { expect(dep.toString(), 'SdkDependency: flutter'); }); - test('GitDependency', () { - var dep = _dependency({'git': 'bob'}); - expect(dep.url.toString(), 'bob'); - expect(dep.toString(), 'GitDependency: url@bob'); + test('GitDependency - string', () { + var dep = _dependency({'git': 'url'}); + expect(dep.url.toString(), 'url'); + expect(dep.path, isNull); + expect(dep.ref, isNull); + expect(dep.toString(), 'GitDependency: url@url'); + }); + + test('GitDependency - map', () { + var dep = _dependency({ + 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'} + }); + expect(dep.url.toString(), 'url'); + expect(dep.path, 'path'); + expect(dep.ref, 'ref'); + expect(dep.toString(), 'GitDependency: url@url'); }); test('HostedDepedency', () { @@ -90,6 +102,31 @@ line 5, column 11: Must be a String or a Map. ^^^'''); }); + test('git - empty map', () { + _expectThrows({'git': {}}, r''' +line 5, column 11: "url" is required. + "git": {} + ^^'''); + }); + + test('git - null url', () { + _expectThrows({ + 'git': {'url': null} + }, r''' +line 6, column 12: "url" cannot be null. + "url": null + ^^^^^'''); + }); + + test('git - int url', () { + _expectThrows({ + 'git': {'url': 42} + }, r''' +line 6, column 12: Unsupported value for `url`. + "url": 42 + ^^^'''); + }); + test('path - null content', () { _expectThrows({'path': null}, r''' line 5, column 12: Cannot be null. From d6238b948178f1a8ec3c074e8b4886682d612dca Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 11:21:05 -0700 Subject: [PATCH 007/152] Migrate Hosted and Sdk dependency to use generated fromJson Handle HostedDependency with explicit version field --- pkgs/pubspec_parse/lib/src/dependency.dart | 62 +++++++++++++------- pkgs/pubspec_parse/lib/src/dependency.g.dart | 14 +++++ pkgs/pubspec_parse/lib/src/pubspec.dart | 3 + pkgs/pubspec_parse/test/dependency_test.dart | 26 ++++---- 4 files changed, 74 insertions(+), 31 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 526023984..8488fe157 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -22,11 +22,14 @@ Map parseDeps(Map source) => /// Returns `null` if the data could not be parsed. Dependency _fromJson(dynamic data) { - if (data == null) { - return new HostedDependency(VersionConstraint.any); - } else if (data is String) { - return new HostedDependency(new VersionConstraint.parse(data)); - } else if (data is Map) { + var value = + SdkDependency.tryFromData(data) ?? HostedDependency.tryFromData(data); + + if (value != null) { + return value; + } + + if (data is Map) { try { return _fromMap(data); } on ArgumentError catch (e) { @@ -45,10 +48,6 @@ Dependency _fromMap(Map data) { data, null, 'Dependency', 'Must provide at least one key.'); } - if (data.containsKey('sdk')) { - return new SdkDependency.fromData(data); - } - if (data.entries.length > 1) { throw new CheckedFromJsonException(data, data.keys.skip(1).first as String, 'Dependency', 'Expected only one key.'); @@ -81,22 +80,23 @@ abstract class Dependency { String toString() => '$runtimeType: $_info'; } +@JsonSerializable(createToJson: false) class SdkDependency extends Dependency { - final String name; + final String sdk; + @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; - SdkDependency(this.name, {this.version}) : super._(); + SdkDependency(this.sdk, {this.version}) : super._(); - factory SdkDependency.fromData(Map data) { - VersionConstraint version; - if (data.containsKey('version')) { - version = new VersionConstraint.parse(data['version'] as String); + static SdkDependency tryFromData(Object data) { + if (data is Map && data.containsKey('sdk')) { + return _$SdkDependencyFromJson(data); } - return new SdkDependency(data['sdk'] as String, version: version); + return null; } @override - String get _info => name; + String get _info => sdk; } @JsonSerializable(createToJson: false) @@ -152,12 +152,32 @@ class PathDependency extends Dependency { String get _info => 'path@$path'; } -// TODO: support explicit host? +@JsonSerializable(createToJson: false) class HostedDependency extends Dependency { - final VersionConstraint constraint; + // TODO: support explicit host + + @JsonKey(fromJson: _constraintFromString) + final VersionConstraint version; + + HostedDependency({VersionConstraint version}) + : this.version = version ?? VersionConstraint.any, + super._(); + + static HostedDependency tryFromData(Object data) { + if (data == null || data is String) { + data = {'version': data}; + } - HostedDependency(this.constraint) : super._(); + if (data is Map && data.containsKey('version')) { + return _$HostedDependencyFromJson(data); + } + + return null; + } @override - String get _info => constraint.toString(); + String get _info => version.toString(); } + +VersionConstraint _constraintFromString(String input) => + new VersionConstraint.parse(input); diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index cdb06bbc9..7a7d427cd 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -10,6 +10,13 @@ part of 'dependency.dart'; // Generator: JsonSerializableGenerator // ************************************************************************** +SdkDependency _$SdkDependencyFromJson(Map json) => $checkedNew( + 'SdkDependency', + json, + () => new SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), + version: $checkedConvert(json, 'version', + (v) => v == null ? null : _constraintFromString(v as String)))); + GitDependency _$GitDependencyFromJson(Map json) => $checkedNew( 'GitDependency', json, @@ -18,3 +25,10 @@ GitDependency _$GitDependencyFromJson(Map json) => $checkedNew( json, 'url', (v) => v == null ? null : _parseUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), $checkedConvert(json, 'path', (v) => v as String))); + +HostedDependency _$HostedDependencyFromJson(Map json) => $checkedNew( + 'HostedDependency', + json, + () => new HostedDependency( + version: $checkedConvert(json, 'version', + (v) => v == null ? null : _constraintFromString(v as String)))); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 3c9c045d4..163f3f9bf 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -12,6 +12,9 @@ part 'pubspec.g.dart'; @JsonSerializable(createToJson: false) class Pubspec { + // TODO: executables + // TODO: publish_to + final String name; @JsonKey(fromJson: _versionFromString) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 8ede482cc..5c86721f4 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -8,15 +8,27 @@ import 'package:test/test.dart'; import 'test_utils.dart'; void main() { - test('HostedDepedency', () { + test('HostedDepedency - null', () { + var dep = _dependency(null); + expect(dep.version.toString(), 'any'); + expect(dep.toString(), 'HostedDependency: any'); + }); + + test('HostedDepedency - string', () { var dep = _dependency('^1.0.0'); - expect(dep.constraint.toString(), '^1.0.0'); + expect(dep.version.toString(), '^1.0.0'); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + + test('HostedDepedency - map', () { + var dep = _dependency({'version': '^1.0.0'}); + expect(dep.version.toString(), '^1.0.0'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); test('SdkDependency without version', () { var dep = _dependency({'sdk': 'flutter'}); - expect(dep.name, 'flutter'); + expect(dep.sdk, 'flutter'); expect(dep.version, isNull); expect(dep.toString(), 'SdkDependency: flutter'); }); @@ -24,7 +36,7 @@ void main() { test('SdkDependency with version', () { var dep = _dependency( {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}); - expect(dep.name, 'flutter'); + expect(dep.sdk, 'flutter'); expect(dep.version.toString(), '>=1.2.3 <2.0.0'); expect(dep.toString(), 'SdkDependency: flutter'); }); @@ -47,12 +59,6 @@ void main() { expect(dep.toString(), 'GitDependency: url@url'); }); - test('HostedDepedency', () { - var dep = _dependency('^1.0.0'); - expect(dep.constraint.toString(), '^1.0.0'); - expect(dep.toString(), 'HostedDependency: ^1.0.0'); - }); - test('PathDependency', () { var dep = _dependency({'path': '../path'}); expect(dep.path, '../path'); From 7ed87bcaf20190c604b1a45ad1341f7397df3baf Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 12:02:50 -0700 Subject: [PATCH 008/152] Update to latest json_serializable --- pkgs/pubspec_parse/lib/src/dependency.g.dart | 37 ++++++++------ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 52 ++++++++++---------- pkgs/pubspec_parse/pubspec.yaml | 4 +- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 7a7d427cd..794200bb9 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -10,25 +10,32 @@ part of 'dependency.dart'; // Generator: JsonSerializableGenerator // ************************************************************************** -SdkDependency _$SdkDependencyFromJson(Map json) => $checkedNew( - 'SdkDependency', - json, - () => new SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), +SdkDependency _$SdkDependencyFromJson(Map json) { + return $checkedNew('SdkDependency', json, () { + var val = new SdkDependency( + $checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert(json, 'version', - (v) => v == null ? null : _constraintFromString(v as String)))); + (v) => v == null ? null : _constraintFromString(v as String))); + return val; + }); +} -GitDependency _$GitDependencyFromJson(Map json) => $checkedNew( - 'GitDependency', - json, - () => new GitDependency( +GitDependency _$GitDependencyFromJson(Map json) { + return $checkedNew('GitDependency', json, () { + var val = new GitDependency( $checkedConvert( json, 'url', (v) => v == null ? null : _parseUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), - $checkedConvert(json, 'path', (v) => v as String))); + $checkedConvert(json, 'path', (v) => v as String)); + return val; + }); +} -HostedDependency _$HostedDependencyFromJson(Map json) => $checkedNew( - 'HostedDependency', - json, - () => new HostedDependency( +HostedDependency _$HostedDependencyFromJson(Map json) { + return $checkedNew('HostedDependency', json, () { + var val = new HostedDependency( version: $checkedConvert(json, 'version', - (v) => v == null ? null : _constraintFromString(v as String)))); + (v) => v == null ? null : _constraintFromString(v as String))); + return val; + }); +} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index c32db09ff..f585b847d 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -10,29 +10,29 @@ part of 'pubspec.dart'; // Generator: JsonSerializableGenerator // ************************************************************************** -Pubspec _$PubspecFromJson(Map json) => $checkedNew( - 'Pubspec', - json, - () => new Pubspec($checkedConvert(json, 'name', (v) => v as String), - version: $checkedConvert(json, 'version', - (v) => v == null ? null : _versionFromString(v as String)), - author: $checkedConvert(json, 'author', (v) => v as String), - authors: $checkedConvert(json, 'authors', - (v) => (v as List)?.map((e) => e as String)?.toList()), - environment: $checkedConvert(json, 'environment', - (v) => v == null ? null : _environmentMap(v as Map)), - homepage: $checkedConvert(json, 'homepage', (v) => v as String), - documentation: - $checkedConvert(json, 'documentation', (v) => v as String), - description: - $checkedConvert(json, 'description', (v) => v as String), - dependencies: $checkedConvert( - json, 'dependencies', (v) => parseDeps(v as Map)), - devDependencies: $checkedConvert( - json, 'dev_dependencies', (v) => parseDeps(v as Map)), - dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => parseDeps(v as Map))), - fieldKeyMap: const { - 'devDependencies': 'dev_dependencies', - 'dependencyOverrides': 'dependency_overrides' - }); +Pubspec _$PubspecFromJson(Map json) { + return $checkedNew('Pubspec', json, () { + var val = new Pubspec($checkedConvert(json, 'name', (v) => v as String), + version: $checkedConvert(json, 'version', + (v) => v == null ? null : _versionFromString(v as String)), + author: $checkedConvert(json, 'author', (v) => v as String), + authors: $checkedConvert(json, 'authors', + (v) => (v as List)?.map((e) => e as String)?.toList()), + environment: $checkedConvert(json, 'environment', + (v) => v == null ? null : _environmentMap(v as Map)), + homepage: $checkedConvert(json, 'homepage', (v) => v as String), + documentation: + $checkedConvert(json, 'documentation', (v) => v as String), + description: $checkedConvert(json, 'description', (v) => v as String), + dependencies: + $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map)), + devDependencies: $checkedConvert( + json, 'dev_dependencies', (v) => parseDeps(v as Map)), + dependencyOverrides: $checkedConvert( + json, 'dependency_overrides', (v) => parseDeps(v as Map))); + return val; + }, fieldKeyMap: const { + 'devDependencies': 'dev_dependencies', + 'dependencyOverrides': 'dependency_overrides' + }); +} diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index ae1a617a0..260681769 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -10,11 +10,11 @@ environment: sdk: '>=2.0.0-dev.54 <2.0.0' dependencies: - json_annotation: ^0.2.6 + json_annotation: ^0.2.7 pub_semver: ^1.3.2 yaml: ^2.1.12 dev_dependencies: build_runner: ^0.8.0 - json_serializable: ^0.5.5 + json_serializable: ^0.5.6 test: ^0.12.0 From 783c4ba45f9745a3ff085b889e8f1cf8b567ef6d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 14:24:33 -0700 Subject: [PATCH 009/152] Replace paresPubspec top-level function with Pubspec.parse ctor --- pkgs/pubspec_parse/lib/pubspec_parse.dart | 1 - pkgs/pubspec_parse/lib/src/functions.dart | 34 ----------------------- pkgs/pubspec_parse/lib/src/pubspec.dart | 24 ++++++++++++++++ pkgs/pubspec_parse/test/test_utils.dart | 2 +- 4 files changed, 25 insertions(+), 36 deletions(-) delete mode 100644 pkgs/pubspec_parse/lib/src/functions.dart diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart index 3339982b1..99886c44a 100644 --- a/pkgs/pubspec_parse/lib/pubspec_parse.dart +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -10,5 +10,4 @@ export 'src/dependency.dart' SdkDependency, PathDependency; export 'src/errors.dart' show ParsedYamlException; -export 'src/functions.dart' show parsePubspec; export 'src/pubspec.dart' show Pubspec; diff --git a/pkgs/pubspec_parse/lib/src/functions.dart b/pkgs/pubspec_parse/lib/src/functions.dart deleted file mode 100644 index 84ef35cc0..000000000 --- a/pkgs/pubspec_parse/lib/src/functions.dart +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; -import 'package:yaml/yaml.dart'; - -import 'errors.dart'; -import 'pubspec.dart'; - -/// If [sourceUrl] is passed, it's used as the URL from which the YAML -/// originated for error reporting. It can be a [String], a [Uri], or `null`. -Pubspec parsePubspec(String yaml, {sourceUrl}) { - var item = loadYaml(yaml, sourceUrl: sourceUrl); - - if (item == null) { - throw new ArgumentError.notNull('yaml'); - } - - if (item is! YamlMap) { - if (item is YamlNode) { - throw parsedYamlException('Does not represent a YAML map.', item); - } - - throw new ArgumentError.value( - yaml, 'yaml', 'Does not represent a YAML map.'); - } - - try { - return new Pubspec.fromJson(item as YamlMap); - } on CheckedFromJsonException catch (error, stack) { - throw parsedYamlExceptionFromError(error, stack); - } -} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 163f3f9bf..b57859670 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -4,6 +4,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; +import 'package:yaml/yaml.dart'; import 'dependency.dart'; import 'errors.dart'; @@ -75,6 +76,29 @@ class Pubspec { factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); + factory Pubspec.parse(String yaml, {sourceUrl}) { + var item = loadYaml(yaml, sourceUrl: sourceUrl); + + if (item == null) { + throw new ArgumentError.notNull('yaml'); + } + + if (item is! YamlMap) { + if (item is YamlNode) { + throw parsedYamlException('Does not represent a YAML map.', item); + } + + throw new ArgumentError.value( + yaml, 'yaml', 'Does not represent a YAML map.'); + } + + try { + return new Pubspec.fromJson(item as YamlMap); + } on CheckedFromJsonException catch (error, stack) { + throw parsedYamlExceptionFromError(error, stack); + } + } + static List _normalizeAuthors(String author, List authors) { var value = new Set(); if (author != null) { diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 69102bf08..0924b4138 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -49,7 +49,7 @@ void _printDebugParsedYamlException(ParsedYamlException e) { Pubspec parse(Object content, {bool quietOnError: false}) { quietOnError ??= false; try { - return parsePubspec(_encodeJson(content)); + return new Pubspec.parse(_encodeJson(content)); } on ParsedYamlException catch (e) { if (!quietOnError) { _printDebugParsedYamlException(e); From c12540fe5b34a4744e20dca2d4dc0cf4db8ba372 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 14:25:48 -0700 Subject: [PATCH 010/152] Pubspec: Rename formatMessage to formattedMessage --- pkgs/pubspec_parse/lib/src/errors.dart | 2 +- pkgs/pubspec_parse/test/test_utils.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index 288553c4a..528e44ac3 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -68,7 +68,7 @@ class ParsedYamlException implements Exception { /// Returns [message] formatted with source information provided by /// [yamlNode]. - String get formatMessage => yamlNode.span.message(message); + String get formattedMessage => yamlNode.span.message(message); @override String toString() => message; diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 0924b4138..65000afb4 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -14,8 +14,8 @@ String _encodeJson(Object input) => Matcher _throwsParsedYamlException(String prettyValue) => throwsA(allOf( const isInstanceOf(), - new FeatureMatcher('formatMessage', (e) { - var message = e.formatMessage; + new FeatureMatcher('formattedMessage', (e) { + var message = e.formattedMessage; printOnFailure("Actual error format:\nr'''\n$message'''"); _printDebugParsedYamlException(e); return message; From 42621e353f94cbc22f568f10da7d6c52451b3d9a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 14:42:50 -0700 Subject: [PATCH 011/152] Organize dependency tests around their type Easier to scan through --- pkgs/pubspec_parse/test/dependency_test.dart | 133 ++++++++++--------- 1 file changed, 73 insertions(+), 60 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 5c86721f4..b8544d8ad 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -8,6 +8,43 @@ import 'package:test/test.dart'; import 'test_utils.dart'; void main() { + group('hosted', _hostedDependency); + group('git', _gitDependency); + group('sdk', _sdkDependency); + group('path', _pathDependency); + + group('errors', () { + test('List', () { + _expectThrows([], r''' +line 4, column 10: Not a valid dependency value. + "dep": [] + ^^'''); + }); + + test('int', () { + _expectThrows(42, r''' +line 4, column 10: Not a valid dependency value. + "dep": 42 + ^^^'''); + }); + + test('empty map', () { + _expectThrows({}, r''' +line 4, column 10: Must provide at least one key. + "dep": {} + ^^'''); + }); + + test('map with too many keys', () { + _expectThrows({'path': 'a', 'git': 'b'}, r''' +line 5, column 12: Expected only one key. + "path": "a", + ^^^'''); + }); + }); +} + +void _hostedDependency() { test('HostedDepedency - null', () { var dep = _dependency(null); expect(dep.version.toString(), 'any'); @@ -25,7 +62,9 @@ void main() { expect(dep.version.toString(), '^1.0.0'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); +} +void _sdkDependency() { test('SdkDependency without version', () { var dep = _dependency({'sdk': 'flutter'}); expect(dep.sdk, 'flutter'); @@ -40,7 +79,9 @@ void main() { expect(dep.version.toString(), '>=1.2.3 <2.0.0'); expect(dep.toString(), 'SdkDependency: flutter'); }); +} +void _gitDependency() { test('GitDependency - string', () { var dep = _dependency({'git': 'url'}); expect(dep.url.toString(), 'url'); @@ -59,93 +100,65 @@ void main() { expect(dep.toString(), 'GitDependency: url@url'); }); - test('PathDependency', () { - var dep = _dependency({'path': '../path'}); - expect(dep.path, '../path'); - expect(dep.toString(), 'PathDependency: path@../path'); - }); - - group('errors', () { - test('List', () { - _expectThrows([], r''' -line 4, column 10: Not a valid dependency value. - "dep": [] - ^^'''); - }); - - test('int', () { - _expectThrows(42, r''' -line 4, column 10: Not a valid dependency value. - "dep": 42 - ^^^'''); - }); - - test('empty map', () { - _expectThrows({}, r''' -line 4, column 10: Must provide at least one key. - "dep": {} - ^^'''); - }); - - test('map with too many keys', () { - _expectThrows({'path': 'a', 'git': 'b'}, r''' -line 5, column 12: Expected only one key. - "path": "a", - ^^^'''); - }); - - test('git - null content', () { - _expectThrows({'git': null}, r''' + test('git - null content', () { + _expectThrows({'git': null}, r''' line 5, column 11: Cannot be null. "git": null ^^^^^'''); - }); + }); - test('git - int content', () { - _expectThrows({'git': 42}, r''' + test('git - int content', () { + _expectThrows({'git': 42}, r''' line 5, column 11: Must be a String or a Map. "git": 42 ^^^'''); - }); + }); - test('git - empty map', () { - _expectThrows({'git': {}}, r''' + test('git - empty map', () { + _expectThrows({'git': {}}, r''' line 5, column 11: "url" is required. "git": {} ^^'''); - }); + }); - test('git - null url', () { - _expectThrows({ - 'git': {'url': null} - }, r''' + test('git - null url', () { + _expectThrows({ + 'git': {'url': null} + }, r''' line 6, column 12: "url" cannot be null. "url": null ^^^^^'''); - }); + }); - test('git - int url', () { - _expectThrows({ - 'git': {'url': 42} - }, r''' + test('git - int url', () { + _expectThrows({ + 'git': {'url': 42} + }, r''' line 6, column 12: Unsupported value for `url`. "url": 42 ^^^'''); - }); + }); +} - test('path - null content', () { - _expectThrows({'path': null}, r''' +void _pathDependency() { + test('PathDependency', () { + var dep = _dependency({'path': '../path'}); + expect(dep.path, '../path'); + expect(dep.toString(), 'PathDependency: path@../path'); + }); + + test('path - null content', () { + _expectThrows({'path': null}, r''' line 5, column 12: Cannot be null. "path": null ^^^^^'''); - }); + }); - test('path - int content', () { - _expectThrows({'path': 42}, r''' + test('path - int content', () { + _expectThrows({'path': 42}, r''' line 5, column 12: Must be a String. "path": 42 ^^^'''); - }); }); } From e50261c0896fc06d09a429e95fc62447c30d1283 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 14:55:16 -0700 Subject: [PATCH 012/152] HostedDependency: support host data --- pkgs/pubspec_parse/lib/src/dependency.dart | 25 +++++++++++++++++--- pkgs/pubspec_parse/lib/src/dependency.g.dart | 13 +++++++++- pkgs/pubspec_parse/test/dependency_test.dart | 14 +++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 8488fe157..a66c9c41f 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -154,12 +154,12 @@ class PathDependency extends Dependency { @JsonSerializable(createToJson: false) class HostedDependency extends Dependency { - // TODO: support explicit host - @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; - HostedDependency({VersionConstraint version}) + final HostedDetails hosted; + + HostedDependency({VersionConstraint version, this.hosted}) : this.version = version ?? VersionConstraint.any, super._(); @@ -179,5 +179,24 @@ class HostedDependency extends Dependency { String get _info => version.toString(); } +@JsonSerializable(createToJson: false, nullable: false) +class HostedDetails { + final String name; + + @JsonKey(fromJson: _parseUri) + final Uri url; + + HostedDetails(this.name, this.url) { + if (name == null) { + throw new ArgumentError.value(name, 'name', '"name" cannot be null'); + } + if (url == null) { + throw new ArgumentError.value(url, 'url', '"url" cannot be null'); + } + } + + factory HostedDetails.fromJson(Map json) => _$HostedDetailsFromJson(json); +} + VersionConstraint _constraintFromString(String input) => new VersionConstraint.parse(input); diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 794200bb9..f3dc23d2e 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -35,7 +35,18 @@ HostedDependency _$HostedDependencyFromJson(Map json) { return $checkedNew('HostedDependency', json, () { var val = new HostedDependency( version: $checkedConvert(json, 'version', - (v) => v == null ? null : _constraintFromString(v as String))); + (v) => v == null ? null : _constraintFromString(v as String)), + hosted: $checkedConvert(json, 'hosted', + (v) => v == null ? null : new HostedDetails.fromJson(v as Map))); + return val; + }); +} + +HostedDetails _$HostedDetailsFromJson(Map json) { + return $checkedNew('HostedDetails', json, () { + var val = new HostedDetails( + $checkedConvert(json, 'name', (v) => v as String), + $checkedConvert(json, 'url', (v) => _parseUri(v as String))); return val; }); } diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index b8544d8ad..9a42a64c6 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -48,18 +48,32 @@ void _hostedDependency() { test('HostedDepedency - null', () { var dep = _dependency(null); expect(dep.version.toString(), 'any'); + expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); test('HostedDepedency - string', () { var dep = _dependency('^1.0.0'); expect(dep.version.toString(), '^1.0.0'); + expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); test('HostedDepedency - map', () { var dep = _dependency({'version': '^1.0.0'}); expect(dep.version.toString(), '^1.0.0'); + expect(dep.hosted, isNull); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + + test('HostedDepedency - map', () { + var dep = _dependency({ + 'version': '^1.0.0', + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} + }); + expect(dep.version.toString(), '^1.0.0'); + expect(dep.hosted.name, 'hosted_name'); + expect(dep.hosted.url.toString(), 'hosted_url'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); } From 16e4e6778f45af88b3cdb3c535681c6e30fd2f89 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 1 Jun 2018 14:57:34 -0700 Subject: [PATCH 013/152] Remove non-useful doc comment --- pkgs/pubspec_parse/lib/src/errors.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index 528e44ac3..dbdc94763 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -52,7 +52,6 @@ class ParsedYamlException implements Exception { /// Describes the nature of the parse failure. final String message; - /// The [YamlNode] that corresponds to the exception. final YamlNode yamlNode; /// If this exception was thrown as a result of another error, From d4800de90f45bc2fd56cbe46cc83db91bef86268 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Jun 2018 11:08:41 -0700 Subject: [PATCH 014/152] Pubspec.environment: never null, better validation for bad values --- pkgs/pubspec_parse/lib/src/pubspec.dart | 24 ++++++++++++-------- pkgs/pubspec_parse/test/parse_test.dart | 30 +++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index b57859670..169e719d7 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -58,7 +58,7 @@ class Pubspec { this.version, String author, List authors, - this.environment, + Map environment, this.homepage, this.documentation, this.description, @@ -66,6 +66,7 @@ class Pubspec { Map devDependencies, Map dependencyOverrides, }) : this.authors = _normalizeAuthors(author, authors), + this.environment = environment ?? const {}, this.dependencies = dependencies ?? const {}, this.devDependencies = devDependencies ?? const {}, this.dependencyOverrides = dependencyOverrides ?? const {} { @@ -114,7 +115,8 @@ class Pubspec { Version _versionFromString(String input) => new Version.parse(input); Map _environmentMap(Map source) => - source.map((key, value) { + source.map((k, value) { + var key = k as String; if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! @@ -122,13 +124,17 @@ Map _environmentMap(Map source) => source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); } - VersionConstraint constraint; - try { - constraint = new VersionConstraint.parse(value as String); - } on FormatException catch (e) { - throw new CheckedFromJsonException( - source, key as String, 'Pubspec', e.message); + if (value is String) { + VersionConstraint constraint; + try { + constraint = new VersionConstraint.parse(value); + } on FormatException catch (e) { + throw new CheckedFromJsonException(source, key, 'Pubspec', e.message); + } + + return new MapEntry(key, constraint); } - return new MapEntry(key as String, constraint); + throw new CheckedFromJsonException( + source, key, 'VersionConstraint', '`$value` is not a String.'); }); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index d163e5a39..1d7fcd8d5 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -2,6 +2,7 @@ // 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:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -16,6 +17,7 @@ void main() { // ignore: deprecated_member_use expect(value.author, isNull); expect(value.authors, isEmpty); + expect(value.environment, isEmpty); expect(value.documentation, isNull); expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); @@ -23,21 +25,25 @@ void main() { }); test('all fields set', () { + var constraint = new Version.parse('1.2.3'); var value = parse({ 'name': 'sample', - 'version': '1.2.3', + 'version': constraint.toString(), 'author': 'name@example.com', + 'environment': {'sdk': '1.2.3'}, 'description': 'description', 'homepage': 'homepage', 'documentation': 'documentation' }); expect(value.name, 'sample'); - expect(value.version.toString(), '1.2.3'); + expect(value.version, constraint); expect(value.description, 'description'); expect(value.homepage, 'homepage'); // ignore: deprecated_member_use expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); + expect(value.environment, hasLength(1)); + expect(value.environment, containsPair('sdk', constraint)); expect(value.documentation, 'documentation'); expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); @@ -126,6 +132,26 @@ line 4, column 3: Use "sdk" to for Dart SDK constraints. ^^^^^^'''); }); + test('environment values cannot be null', () { + expectParseThrows({ + 'name': 'sample', + 'environment': {'sdk': null} + }, r''' +line 4, column 10: `null` is not a String. + "sdk": null + ^^^^^'''); + }); + + test('environment values cannot be int', () { + expectParseThrows({ + 'name': 'sample', + 'environment': {'sdk': 42} + }, r''' +line 4, column 10: `42` is not a String. + "sdk": 42 + ^^^'''); + }); + test('invalid version', () { expectParseThrows({'name': 'sample', 'version': 'invalid'}, r''' line 3, column 13: Unsupported value for `version`. From dc34706c1e1e1a0b22847860a3b7d230899f107f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Jun 2018 10:43:26 -0700 Subject: [PATCH 015/152] Prepare for v0.1.0 release --- pkgs/pubspec_parse/CHANGELOG.md | 3 +-- pkgs/pubspec_parse/README.md | 8 ++++++++ pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 39d51431c..951a5a3f1 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,4 +1,3 @@ ## 0.1.0 -- Initial release including the `Pubspec` class and a top-level `parsePubspec` - function. +- Initial release. diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index b355cef76..a95459c6f 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,3 +1,11 @@ +[![Build Status](https://travis-ci.org/dart-lang/pubspec_parse.svg?branch=master)](https://travis-ci.org/dart-lang/pubspec_parse) + +Supports parsing `pubspec.yaml` files with robust error reporting and support +for most of the documented features. + +Read more about the +[pubspec format](https://www.dartlang.org/tools/pub/pubspec). + ## Features and bugs Please file feature requests and bugs at the [issue tracker]. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 260681769..e8942bfad 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.0-dev +version: 0.1.0 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team From aefc0e516e2b329202263dd8f0fda7811817c627 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Jun 2018 11:20:02 -0700 Subject: [PATCH 016/152] Add LICENSE file and missing stack_trace dependency --- pkgs/pubspec_parse/LICENSE | 26 ++++++++++++++++++++++++++ pkgs/pubspec_parse/pubspec.yaml | 1 + 2 files changed, 27 insertions(+) create mode 100644 pkgs/pubspec_parse/LICENSE diff --git a/pkgs/pubspec_parse/LICENSE b/pkgs/pubspec_parse/LICENSE new file mode 100644 index 000000000..c4dc9ba3c --- /dev/null +++ b/pkgs/pubspec_parse/LICENSE @@ -0,0 +1,26 @@ +Copyright 2018, the Dart project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index e8942bfad..526c7516b 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,4 +17,5 @@ dependencies: dev_dependencies: build_runner: ^0.8.0 json_serializable: ^0.5.6 + stack_trace: ^1.9.2 test: ^0.12.0 From 94bdc3e17962faddd5eb362eafdeae5fd5ee27ce Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Jun 2018 11:21:27 -0700 Subject: [PATCH 017/152] add missing dev_dependency on pkg:path --- pkgs/pubspec_parse/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 526c7516b..4579c9b22 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,5 +17,6 @@ dependencies: dev_dependencies: build_runner: ^0.8.0 json_serializable: ^0.5.6 + path: ^1.5.1 stack_trace: ^1.9.2 test: ^0.12.0 From 15e7dd1692421dc4cd01575a66eff9e11096a154 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 8 Jun 2018 09:59:09 -0700 Subject: [PATCH 018/152] Fix name collision with error type in latest `package:json_annotation` Update checks in GitDependency to use new features --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/lib/src/dependency.dart | 15 ++------------- pkgs/pubspec_parse/lib/src/dependency.g.dart | 2 ++ pkgs/pubspec_parse/lib/src/errors.dart | 6 +++--- pkgs/pubspec_parse/lib/src/pubspec.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 6 +++--- pkgs/pubspec_parse/test/dependency_test.dart | 4 ++-- 7 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 951a5a3f1..4fc410a8a 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1 + +- Fixed name collision with error type in latest `package:json_annotation`. + ## 0.1.0 - Initial release. diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index a66c9c41f..dd66d93e4 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -4,7 +4,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; -import 'package:pubspec_parse/src/errors.dart'; part 'dependency.g.dart'; @@ -101,16 +100,12 @@ class SdkDependency extends Dependency { @JsonSerializable(createToJson: false) class GitDependency extends Dependency { - @JsonKey(fromJson: _parseUri) + @JsonKey(fromJson: _parseUri, required: true, disallowNullValue: true) final Uri url; final String ref; final String path; - GitDependency(this.url, this.ref, this.path) : super._() { - if (url == null) { - throw new ArgumentError.value(url, 'url', '"url" cannot be null.'); - } - } + GitDependency(this.url, this.ref, this.path) : super._(); factory GitDependency.fromData(Object data) { if (data is String) { @@ -118,12 +113,6 @@ class GitDependency extends Dependency { } if (data is Map) { - // TODO: Need JsonKey.required - // https://github.com/dart-lang/json_serializable/issues/216 - if (!data.containsKey('url')) { - throw new BadKeyException(data, 'url', '"url" is required.'); - } - return _$GitDependencyFromJson(data); } diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index f3dc23d2e..620bde71b 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -22,6 +22,8 @@ SdkDependency _$SdkDependencyFromJson(Map json) { GitDependency _$GitDependencyFromJson(Map json) { return $checkedNew('GitDependency', json, () { + $checkKeys(json, + requiredKeys: const ['url'], disallowNullValues: const ['url']); var val = new GitDependency( $checkedConvert( json, 'url', (v) => v == null ? null : _parseUri(v as String)), diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index dbdc94763..c9643b885 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -11,7 +11,7 @@ ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => ParsedYamlException parsedYamlExceptionFromError( CheckedFromJsonException error, StackTrace stack) { var innerError = error.innerError; - if (innerError is BadKeyException) { + if (innerError is InvalidKeyException) { var map = innerError.map; if (map is YamlMap) { // if the associated key exists, use that as the error node, @@ -77,10 +77,10 @@ class ParsedYamlException implements Exception { /// /// Used instead of [CheckedFromJsonException] when highlighting a bad [key] /// is desired, instead of the associated value. -class BadKeyException implements Exception { +class InvalidKeyException implements Exception { final Map map; final String key; final String message; - BadKeyException(this.map, this.key, this.message); + InvalidKeyException(this.map, this.key, this.message); } diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 169e719d7..7cc1ee13b 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -120,7 +120,7 @@ Map _environmentMap(Map source) => if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! - throw new BadKeyException( + throw new InvalidKeyException( source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); } diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 4579c9b22..6814fb654 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.0 +version: 0.1.1-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team @@ -10,13 +10,13 @@ environment: sdk: '>=2.0.0-dev.54 <2.0.0' dependencies: - json_annotation: ^0.2.7 + json_annotation: ^0.2.8 pub_semver: ^1.3.2 yaml: ^2.1.12 dev_dependencies: build_runner: ^0.8.0 - json_serializable: ^0.5.6 + json_serializable: ^0.5.7 path: ^1.5.1 stack_trace: ^1.9.2 test: ^0.12.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 9a42a64c6..527b310cd 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -130,7 +130,7 @@ line 5, column 11: Must be a String or a Map. test('git - empty map', () { _expectThrows({'git': {}}, r''' -line 5, column 11: "url" is required. +line 5, column 11: Required keys are missing: url. "git": {} ^^'''); }); @@ -139,7 +139,7 @@ line 5, column 11: "url" is required. _expectThrows({ 'git': {'url': null} }, r''' -line 6, column 12: "url" cannot be null. +line 6, column 12: These keys had `null` values, which is not allowed: [url] "url": null ^^^^^'''); }); From de2f9e48bff8b416011c1cbb51084a9284d332fd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 8 Jun 2018 11:28:27 -0700 Subject: [PATCH 019/152] Improve parsing of hosted dependencies Use new features from json_serializable Allow `host: String` With the map syntax, require a name, but not a url --- pkgs/pubspec_parse/CHANGELOG.md | 1 + pkgs/pubspec_parse/lib/src/dependency.dart | 51 +++++++++++---- pkgs/pubspec_parse/lib/src/dependency.g.dart | 12 +++- pkgs/pubspec_parse/test/dependency_test.dart | 68 ++++++++++++++++++-- 4 files changed, 114 insertions(+), 18 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 4fc410a8a..c0c94c9e4 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.1.1 - Fixed name collision with error type in latest `package:json_annotation`. +- Improved parsing of hosted dependencies. ## 0.1.0 diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index dd66d93e4..1498740ab 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -4,13 +4,34 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; +import 'package:yaml/yaml.dart'; part 'dependency.g.dart'; Map parseDeps(Map source) => source?.map((k, v) { var key = k as String; - var value = _fromJson(v); + Dependency value; + try { + value = _fromJson(v); + } on CheckedFromJsonException catch (e) { + if (e.map is! YamlMap) { + // This is likely a "synthetic" map created from a String value + // Use `source` to throw this exception with an actual YamlMap and + // extract the associated error information. + + var message = e.message; + var innerError = e.innerError; + // json_annotation should handle FormatException... + // https://github.com/dart-lang/json_serializable/issues/233 + if (innerError is FormatException) { + message = innerError.message; + } + throw new CheckedFromJsonException(source, key, e.className, message); + } + rethrow; + } + if (value == null) { throw new CheckedFromJsonException( source, key, 'Pubspec', 'Not a valid dependency value.'); @@ -141,11 +162,12 @@ class PathDependency extends Dependency { String get _info => 'path@$path'; } -@JsonSerializable(createToJson: false) +@JsonSerializable(createToJson: false, disallowUnrecognizedKeys: true) class HostedDependency extends Dependency { @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; + @JsonKey(disallowNullValue: true) final HostedDetails hosted; HostedDependency({VersionConstraint version, this.hosted}) @@ -157,7 +179,8 @@ class HostedDependency extends Dependency { data = {'version': data}; } - if (data is Map && data.containsKey('version')) { + if (data is Map && + (data.containsKey('version') || data.containsKey('hosted'))) { return _$HostedDependencyFromJson(data); } @@ -168,23 +191,27 @@ class HostedDependency extends Dependency { String get _info => version.toString(); } -@JsonSerializable(createToJson: false, nullable: false) +@JsonSerializable(createToJson: false, disallowUnrecognizedKeys: true) class HostedDetails { + @JsonKey(required: true, disallowNullValue: true) final String name; - @JsonKey(fromJson: _parseUri) + @JsonKey(fromJson: _parseUri, disallowNullValue: true) final Uri url; - HostedDetails(this.name, this.url) { - if (name == null) { - throw new ArgumentError.value(name, 'name', '"name" cannot be null'); + HostedDetails(this.name, this.url); + + factory HostedDetails.fromJson(Object data) { + if (data is String) { + data = {'name': data}; } - if (url == null) { - throw new ArgumentError.value(url, 'url', '"url" cannot be null'); + + if (data is Map) { + return _$HostedDetailsFromJson(data); } - } - factory HostedDetails.fromJson(Map json) => _$HostedDetailsFromJson(json); + throw new ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); + } } VersionConstraint _constraintFromString(String input) => diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 620bde71b..6133cb454 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -35,20 +35,28 @@ GitDependency _$GitDependencyFromJson(Map json) { HostedDependency _$HostedDependencyFromJson(Map json) { return $checkedNew('HostedDependency', json, () { + $checkKeys(json, + allowedKeys: const ['version', 'hosted'], + disallowNullValues: const ['hosted']); var val = new HostedDependency( version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String)), hosted: $checkedConvert(json, 'hosted', - (v) => v == null ? null : new HostedDetails.fromJson(v as Map))); + (v) => v == null ? null : new HostedDetails.fromJson(v))); return val; }); } HostedDetails _$HostedDetailsFromJson(Map json) { return $checkedNew('HostedDetails', json, () { + $checkKeys(json, + allowedKeys: const ['name', 'url'], + requiredKeys: const ['name'], + disallowNullValues: const ['name', 'url']); var val = new HostedDetails( $checkedConvert(json, 'name', (v) => v as String), - $checkedConvert(json, 'url', (v) => _parseUri(v as String))); + $checkedConvert( + json, 'url', (v) => v == null ? null : _parseUri(v as String))); return val; }); } diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 527b310cd..f9fd369d1 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -45,28 +46,35 @@ line 5, column 12: Expected only one key. } void _hostedDependency() { - test('HostedDepedency - null', () { + test('null', () { var dep = _dependency(null); expect(dep.version.toString(), 'any'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); - test('HostedDepedency - string', () { + test('string version', () { var dep = _dependency('^1.0.0'); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); - test('HostedDepedency - map', () { + test('bad string version', () { + _expectThrows('not a version', r''' +line 4, column 10: Could not parse version "not a version". Unknown text at "not a version". + "dep": "not a version" + ^^^^^^^^^^^^^^^'''); + }); + + test('map w/ just version', () { var dep = _dependency({'version': '^1.0.0'}); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); - test('HostedDepedency - map', () { + test('map w/ version and hosted as Map', () { var dep = _dependency({ 'version': '^1.0.0', 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} @@ -76,6 +84,58 @@ void _hostedDependency() { expect(dep.hosted.url.toString(), 'hosted_url'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); + + test('map w/ bad version value', () { + _expectThrows({ + 'version': 'not a version', + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} + }, r''' +line 5, column 15: Unsupported value for `version`. + "version": "not a version", + ^^^^^^^^^^^^^^^'''); + }); + + test('map w/ unsupported keys', () { + _expectThrows({ + 'version': '^1.0.0', + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, + 'not_supported': null + }, r''' +line 4, column 10: Unrecognized keys: [not_supported]; supported keys: [version, hosted] + "dep": { + ^^'''); + }); + + test('map w/ version and hosted as String', () { + var dep = _dependency( + {'version': '^1.0.0', 'hosted': 'hosted_name'}); + expect(dep.version.toString(), '^1.0.0'); + expect(dep.hosted.name, 'hosted_name'); + expect(dep.hosted.url, isNull); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + + test('map w/ hosted as String', () { + var dep = _dependency({'hosted': 'hosted_name'}); + expect(dep.version, VersionConstraint.any); + expect(dep.hosted.name, 'hosted_name'); + expect(dep.hosted.url, isNull); + expect(dep.toString(), 'HostedDependency: any'); + }); + + test('map w/ null hosted should error', () { + _expectThrows({'hosted': null}, r''' +line 5, column 14: These keys had `null` values, which is not allowed: [hosted] + "hosted": null + ^^^^^'''); + }); + + test('map w/ null version is fine', () { + var dep = _dependency({'version': null}); + expect(dep.version, VersionConstraint.any); + expect(dep.hosted, isNull); + expect(dep.toString(), 'HostedDependency: any'); + }); } void _sdkDependency() { From 408e4d4b5c7261618690880084c8f16b970da627 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 8 Jun 2018 11:28:49 -0700 Subject: [PATCH 020/152] Prepare to release v0.1.1 --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 6814fb654..8d305ef82 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.1-dev +version: 0.1.1 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team From 3439cf13d68aa256d31a762b0874309f4b8510f5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 8 Jun 2018 15:44:39 -0700 Subject: [PATCH 021/152] Improve parsing logic to better align with what is supported by pub (dart-lang/pubspec_parse#9) * Allow environment constraint values to be null * Treat dependencies with empty map values like they are empty. * Use an SDK constraint in tests that is compatible with the supported SDK * Update tests to verify behavior of pub client * Failing test cases should cause pub to report a parse error * Successful test cases should be parsed successfully by pub, even if pub get ends up failing for another reason --- pkgs/pubspec_parse/CHANGELOG.md | 2 +- pkgs/pubspec_parse/lib/src/dependency.dart | 16 ++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 12 ++- pkgs/pubspec_parse/pubspec.yaml | 2 + pkgs/pubspec_parse/test/dependency_test.dart | 13 ++- pkgs/pubspec_parse/test/parse_test.dart | 31 +++---- pkgs/pubspec_parse/test/pub_utils.dart | 95 ++++++++++++++++++++ pkgs/pubspec_parse/test/test_utils.dart | 29 +++++- 8 files changed, 160 insertions(+), 40 deletions(-) create mode 100644 pkgs/pubspec_parse/test/pub_utils.dart diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index c0c94c9e4..720f0e723 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.1.1 - Fixed name collision with error type in latest `package:json_annotation`. -- Improved parsing of hosted dependencies. +- Improved parsing of hosted dependencies and environment constraints. ## 0.1.0 diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 1498740ab..c4f7b26ec 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -62,12 +62,7 @@ Dependency _fromJson(dynamic data) { } Dependency _fromMap(Map data) { - if (data.entries.isEmpty) { -// TODO: provide list of supported keys? - throw new CheckedFromJsonException( - data, null, 'Dependency', 'Must provide at least one key.'); - } - + assert(data.entries.isNotEmpty); if (data.entries.length > 1) { throw new CheckedFromJsonException(data, data.keys.skip(1).first as String, 'Dependency', 'Expected only one key.'); @@ -179,9 +174,12 @@ class HostedDependency extends Dependency { data = {'version': data}; } - if (data is Map && - (data.containsKey('version') || data.containsKey('hosted'))) { - return _$HostedDependencyFromJson(data); + if (data is Map) { + if (data.isEmpty || + data.containsKey('version') || + data.containsKey('hosted')) { + return _$HostedDependencyFromJson(data); + } } return null; diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 7cc1ee13b..a5cba623e 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -124,8 +124,10 @@ Map _environmentMap(Map source) => source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); } - if (value is String) { - VersionConstraint constraint; + VersionConstraint constraint; + if (value == null) { + constraint = null; + } else if (value is String) { try { constraint = new VersionConstraint.parse(value); } on FormatException catch (e) { @@ -133,8 +135,10 @@ Map _environmentMap(Map source) => } return new MapEntry(key, constraint); + } else { + throw new CheckedFromJsonException( + source, key, 'VersionConstraint', '`$value` is not a String.'); } - throw new CheckedFromJsonException( - source, key, 'VersionConstraint', '`$value` is not a String.'); + return new MapEntry(key, constraint); }); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 8d305ef82..0bf1220b9 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -20,3 +20,5 @@ dev_dependencies: path: ^1.5.1 stack_trace: ^1.9.2 test: ^0.12.0 + test_descriptor: ^1.0.3 + test_process: ^1.0.2 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index f9fd369d1..658e13275 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -29,13 +29,6 @@ line 4, column 10: Not a valid dependency value. ^^^'''); }); - test('empty map', () { - _expectThrows({}, r''' -line 4, column 10: Must provide at least one key. - "dep": {} - ^^'''); - }); - test('map with too many keys', () { _expectThrows({'path': 'a', 'git': 'b'}, r''' line 5, column 12: Expected only one key. @@ -53,6 +46,12 @@ void _hostedDependency() { expect(dep.toString(), 'HostedDependency: any'); }); + test('empty map', () { + var dep = _dependency({}); + expect(dep.hosted, isNull); + expect(dep.toString(), 'HostedDependency: any'); + }); + test('string version', () { var dep = _dependency('^1.0.0'); expect(dep.version.toString(), '^1.0.0'); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 1d7fcd8d5..00a0de97a 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -25,31 +25,42 @@ void main() { }); test('all fields set', () { - var constraint = new Version.parse('1.2.3'); + var version = new Version.parse('1.2.3'); + var sdkConstraint = new VersionConstraint.parse('>=2.0.0-dev.54 <2.0.0'); var value = parse({ 'name': 'sample', - 'version': constraint.toString(), + 'version': version.toString(), 'author': 'name@example.com', - 'environment': {'sdk': '1.2.3'}, + 'environment': {'sdk': sdkConstraint.toString()}, 'description': 'description', 'homepage': 'homepage', 'documentation': 'documentation' }); expect(value.name, 'sample'); - expect(value.version, constraint); + expect(value.version, version); expect(value.description, 'description'); expect(value.homepage, 'homepage'); // ignore: deprecated_member_use expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); expect(value.environment, hasLength(1)); - expect(value.environment, containsPair('sdk', constraint)); + expect(value.environment, containsPair('sdk', sdkConstraint)); expect(value.documentation, 'documentation'); expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); expect(value.dependencyOverrides, isEmpty); }); + test('environment values can be null', () { + var value = parse({ + 'name': 'sample', + 'environment': {'sdk': null} + }); + expect(value.name, 'sample'); + expect(value.environment, hasLength(1)); + expect(value.environment, containsPair('sdk', isNull)); + }); + group('author, authors', () { test('one author', () { var value = parse({'name': 'sample', 'author': 'name@example.com'}); @@ -132,16 +143,6 @@ line 4, column 3: Use "sdk" to for Dart SDK constraints. ^^^^^^'''); }); - test('environment values cannot be null', () { - expectParseThrows({ - 'name': 'sample', - 'environment': {'sdk': null} - }, r''' -line 4, column 10: `null` is not a String. - "sdk": null - ^^^^^'''); - }); - test('environment values cannot be int', () { expectParseThrows({ 'name': 'sample', diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart new file mode 100644 index 000000000..984bb49ae --- /dev/null +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -0,0 +1,95 @@ +// Copyright (c) 2018, 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 'dart:async'; +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; +import 'package:test_process/test_process.dart'; + +Future tryPub(String content) async { + await d.file('pubspec.yaml', content).create(); + + var proc = await TestProcess.start(_pubPath, ['get', '--offline'], + workingDirectory: d.sandbox); + + var result = await ProcResult.fromTestProcess(proc); + + printOnFailure([ + '-----BEGIN pub output-----', + result.toString().trim(), + '-----END pub output-----', + ].join('\n')); + + if (result.exitCode == 0) { + var lockContent = + new File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); + + printOnFailure([ + '-----BEGIN pubspec.lock-----', + lockContent.trim(), + '-----END pubspec.lock-----', + ].join('\n')); + } + + return result; +} + +class ProcResult { + final int exitCode; + final List lines; + + bool get cleanParse => exitCode == 0 || exitCode == 66 || exitCode == 69; + + ProcResult(this.exitCode, this.lines); + + static Future fromTestProcess(TestProcess proc) async { + var items = []; + + var values = await Future.wait([ + proc.exitCode, + proc + .stdoutStream() + .forEach((line) => items.add(new ProcLine(false, line))), + proc + .stderrStream() + .forEach((line) => items.add(new ProcLine(true, line))), + ]); + + return new ProcResult(values[0] as int, items); + } + + @override + String toString() { + var buffer = new StringBuffer('Exit code: $exitCode'); + for (var line in lines) { + buffer.write('\n$line'); + } + return buffer.toString(); + } +} + +class ProcLine { + final bool isError; + final String line; + + ProcLine(this.isError, this.line); + + @override + String toString() => '${isError ? 'err' : 'out'} $line'; +} + +/// The path to the root directory of the SDK. +final String _sdkDir = (() { + // The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is + // "/path/to/sdk". + var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable)); + assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version'))); + return aboveExecutable; +})(); + +final String _pubPath = + p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub'); diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 65000afb4..7180292ff 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -2,6 +2,7 @@ // 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 'dart:cli'; import 'dart:convert'; import 'package:json_annotation/json_annotation.dart'; @@ -9,6 +10,8 @@ import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:stack_trace/stack_trace.dart'; import 'package:test/test.dart'; +import 'pub_utils.dart'; + String _encodeJson(Object input) => const JsonEncoder.withIndent(' ').convert(input); @@ -48,11 +51,29 @@ void _printDebugParsedYamlException(ParsedYamlException e) { Pubspec parse(Object content, {bool quietOnError: false}) { quietOnError ??= false; + + var encoded = _encodeJson(content); + + var pubResult = waitFor(tryPub(encoded)); + try { - return new Pubspec.parse(_encodeJson(content)); - } on ParsedYamlException catch (e) { - if (!quietOnError) { - _printDebugParsedYamlException(e); + var value = new Pubspec.parse(encoded); + + addTearDown(() { + expect(pubResult.cleanParse, isTrue, + reason: + 'On success, parsing from the pub client should also succeed.'); + }); + return value; + } catch (e) { + addTearDown(() { + expect(pubResult.cleanParse, isFalse, + reason: 'On failure, parsing from the pub client should also fail.'); + }); + if (e is ParsedYamlException) { + if (!quietOnError) { + _printDebugParsedYamlException(e); + } } rethrow; } From 9ad0a964e1ad06062b0040dfa9177923693b32bd Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 12 Jun 2018 10:41:23 -0700 Subject: [PATCH 022/152] misc: enable a few more lints (dart-lang/pubspec_parse#10) --- pkgs/pubspec_parse/analysis_options.yaml | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/test_utils.dart | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 8521d7b7d..84a5b8d5e 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -9,6 +9,7 @@ analyzer: unused_local_variable: error linter: rules: + - always_declare_return_types - annotate_overrides - avoid_empty_else - avoid_function_literals_in_foreach_calls @@ -37,6 +38,7 @@ linter: - library_names - library_prefixes - list_remove_unrelated_type + - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values - non_constant_identifier_names @@ -51,6 +53,7 @@ linter: - prefer_conditional_assignment - prefer_const_constructors - prefer_contains + - prefer_equal_for_default_values - prefer_final_fields - prefer_initializing_formals - prefer_interpolation_to_compose_strings @@ -73,4 +76,5 @@ linter: - unnecessary_statements - unnecessary_this - unrelated_type_equality_checks + - use_rethrow_when_possible - valid_regexps diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 0bf1220b9..e6dbc4c40 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.1 +version: 0.1.2-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 7180292ff..808d7c5e2 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -49,7 +49,7 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } } -Pubspec parse(Object content, {bool quietOnError: false}) { +Pubspec parse(Object content, {bool quietOnError = false}) { quietOnError ??= false; var encoded = _encodeJson(content); @@ -91,5 +91,5 @@ class FeatureMatcher extends CustomMatcher { : super('`$name`', '`$name`', matcher); @override - featureValueOf(covariant T actual) => _feature(actual); + Object featureValueOf(covariant T actual) => _feature(actual); } From b89abe3ec35d8aa1d12d3c1d07ecba26c795a95e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 12 Jun 2018 11:04:01 -0700 Subject: [PATCH 023/152] Remove dupe test_types_in_equals (dart-lang/pubspec_parse#11) --- pkgs/pubspec_parse/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 84a5b8d5e..8cd2a0f6d 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -65,7 +65,6 @@ linter: - slash_for_doc_comments - super_goes_last - test_types_in_equals - - test_types_in_equals - throw_in_finally - type_init_formals - unawaited_futures From afcb6224619a36cf2307b9101fc557ccee13b2f8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 15 Jun 2018 13:57:52 -0700 Subject: [PATCH 024/152] fix: update generated output for latest source_gen (dart-lang/pubspec_parse#12) Also updated test code to use new TypeMatcher --- pkgs/pubspec_parse/lib/src/dependency.g.dart | 2 +- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/test_utils.dart | 18 +++--------------- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 6133cb454..ed384a994 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -7,7 +7,7 @@ part of 'dependency.dart'; // ************************************************************************** -// Generator: JsonSerializableGenerator +// JsonSerializableGenerator // ************************************************************************** SdkDependency _$SdkDependencyFromJson(Map json) { diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index f585b847d..921b7e435 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -7,7 +7,7 @@ part of 'pubspec.dart'; // ************************************************************************** -// Generator: JsonSerializableGenerator +// JsonSerializableGenerator // ************************************************************************** Pubspec _$PubspecFromJson(Map json) { diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index e6dbc4c40..78dba00e9 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -19,6 +19,6 @@ dev_dependencies: json_serializable: ^0.5.7 path: ^1.5.1 stack_trace: ^1.9.2 - test: ^0.12.0 + test: ^0.12.42 test_descriptor: ^1.0.3 test_process: ^1.0.2 diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 808d7c5e2..37cd3e96b 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -15,14 +15,13 @@ import 'pub_utils.dart'; String _encodeJson(Object input) => const JsonEncoder.withIndent(' ').convert(input); -Matcher _throwsParsedYamlException(String prettyValue) => throwsA(allOf( - const isInstanceOf(), - new FeatureMatcher('formattedMessage', (e) { +Matcher _throwsParsedYamlException(String prettyValue) => + throwsA(const TypeMatcher().having((e) { var message = e.formattedMessage; printOnFailure("Actual error format:\nr'''\n$message'''"); _printDebugParsedYamlException(e); return message; - }, prettyValue))); + }, 'formattedMessage', prettyValue)); void _printDebugParsedYamlException(ParsedYamlException e) { var innerError = e.innerError; @@ -82,14 +81,3 @@ Pubspec parse(Object content, {bool quietOnError = false}) { void expectParseThrows(Object content, String expectedError) => expect( () => parse(content, quietOnError: true), _throwsParsedYamlException(expectedError)); - -// TODO(kevmoo) add this to pkg/matcher – is nice! -class FeatureMatcher extends CustomMatcher { - final dynamic Function(T value) _feature; - - FeatureMatcher(String name, this._feature, matcher) - : super('`$name`', '`$name`', matcher); - - @override - Object featureValueOf(covariant T actual) => _feature(actual); -} From 62162ccf747b5c0b5beef4c3ffd86368ea687953 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 19 Jun 2018 17:03:26 -0700 Subject: [PATCH 025/152] fix(Dependency) ignore extra `version` key with path and git deps (dart-lang/pubspec_parse#14) Streamline the handling of all dependencies Improve errors when unsupported keys are provided in dependencies Better handling (and testing) for invalid `sdk:` values Handle scp-like URIs for git dependencies - See https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a Fixes https://github.com/dart-lang/pubspec_parse/issues/13 Prepare for release --- pkgs/pubspec_parse/CHANGELOG.md | 8 ++ pkgs/pubspec_parse/lib/src/dependency.dart | 137 +++++++++++-------- pkgs/pubspec_parse/lib/src/dependency.g.dart | 6 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/dependency_test.dart | 87 ++++++++++-- pkgs/pubspec_parse/test/git_uri_test.dart | 25 ++++ 6 files changed, 188 insertions(+), 77 deletions(-) create mode 100644 pkgs/pubspec_parse/test/git_uri_test.dart diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 720f0e723..30551e713 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.1.2 + +- Allow superfluous `version` keys with `git` and `path` dependencies. +- Improve errors when unsupported keys are provided in dependencies. +- Provide better errors with invalid `sdk` dependency values. +- Support "scp-like syntax" for Git SSH URIs in the form + `[user@]host.xz:path/to/repo.git/`. + ## 0.1.1 - Fixed name collision with error type in latest `package:json_annotation`. diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index c4f7b26ec..07d08b57b 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -6,6 +6,8 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; +import 'errors.dart'; + part 'dependency.g.dart'; Map parseDeps(Map source) => @@ -40,49 +42,55 @@ Map parseDeps(Map source) => }) ?? {}; +const _sourceKeys = const ['sdk', 'git', 'path', 'hosted']; + /// Returns `null` if the data could not be parsed. Dependency _fromJson(dynamic data) { - var value = - SdkDependency.tryFromData(data) ?? HostedDependency.tryFromData(data); - - if (value != null) { - return value; + if (data is String || data == null) { + return _$HostedDependencyFromJson({'version': data}); } if (data is Map) { - try { - return _fromMap(data); - } on ArgumentError catch (e) { - throw new CheckedFromJsonException( - data, e.name, 'Dependency', e.message.toString()); - } - } - - return null; -} - -Dependency _fromMap(Map data) { - assert(data.entries.isNotEmpty); - if (data.entries.length > 1) { - throw new CheckedFromJsonException(data, data.keys.skip(1).first as String, - 'Dependency', 'Expected only one key.'); - } - - var entry = data.entries.single; - var key = entry.key as String; + var matchedKeys = + data.keys.cast().where((key) => key != 'version').toList(); + + if (data.isEmpty || (matchedKeys.isEmpty && data.containsKey('version'))) { + return _$HostedDependencyFromJson(data); + } else { + var weirdKey = matchedKeys.firstWhere((k) => !_sourceKeys.contains(k), + orElse: () => null); + + if (weirdKey != null) { + throw new InvalidKeyException( + data, weirdKey, 'Unsupported dependency key.'); + } + if (matchedKeys.length > 1) { + throw new CheckedFromJsonException(data, matchedKeys[1], 'Dependency', + 'A dependency may only have one source.'); + } - if (entry.value == null) { - throw new CheckedFromJsonException( - data, key, 'Dependency', 'Cannot be null.'); - } + var key = matchedKeys.single; - switch (key) { - case 'path': - return new PathDependency.fromData(entry.value); - case 'git': - return new GitDependency.fromData(entry.value); + try { + switch (key) { + case 'git': + return new GitDependency.fromData(data[key]); + case 'path': + return new PathDependency.fromData(data[key]); + case 'sdk': + return _$SdkDependencyFromJson(data); + case 'hosted': + return _$HostedDependencyFromJson(data); + } + throw new StateError('There is a bug in pubspec_parse.'); + } on ArgumentError catch (e) { + throw new CheckedFromJsonException( + data, e.name, 'Dependency', e.message.toString()); + } + } } + // Not a String or a Map – return null so parent logic can throw proper error return null; } @@ -97,26 +105,20 @@ abstract class Dependency { @JsonSerializable(createToJson: false) class SdkDependency extends Dependency { + @JsonKey(nullable: false, disallowNullValue: true, required: true) final String sdk; @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; SdkDependency(this.sdk, {this.version}) : super._(); - static SdkDependency tryFromData(Object data) { - if (data is Map && data.containsKey('sdk')) { - return _$SdkDependencyFromJson(data); - } - return null; - } - @override String get _info => sdk; } @JsonSerializable(createToJson: false) class GitDependency extends Dependency { - @JsonKey(fromJson: _parseUri, required: true, disallowNullValue: true) + @JsonKey(fromJson: parseGitUri, required: true, disallowNullValue: true) final Uri url; final String ref; final String path; @@ -139,7 +141,38 @@ class GitDependency extends Dependency { String get _info => 'url@$url'; } -Uri _parseUri(String value) => Uri.parse(value); +Uri parseGitUri(String value) => _tryParseScpUri(value) ?? Uri.parse(value); + +/// Supports URIs like `[user@]host.xz:path/to/repo.git/` +/// See https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a +Uri _tryParseScpUri(String value) { + var colonIndex = value.indexOf(':'); + + if (colonIndex < 0) { + return null; + } else if (colonIndex == value.indexOf('://')) { + // If the first colon is part of a scheme, it's not an scp-like URI + return null; + } + var slashIndex = value.indexOf('/'); + + if (slashIndex >= 0 && slashIndex < colonIndex) { + // Per docs: This syntax is only recognized if there are no slashes before + // the first colon. This helps differentiate a local path that contains a + // colon. For example the local path foo:bar could be specified as an + // absolute path or ./foo:bar to avoid being misinterpreted as an ssh url. + return null; + } + + var atIndex = value.indexOf('@'); + if (colonIndex > atIndex) { + var user = atIndex >= 0 ? value.substring(0, atIndex) : null; + var host = value.substring(atIndex + 1, colonIndex); + var path = value.substring(colonIndex + 1); + return new Uri(scheme: 'ssh', userInfo: user, host: host, path: path); + } + return null; +} class PathDependency extends Dependency { final String path; @@ -169,22 +202,6 @@ class HostedDependency extends Dependency { : this.version = version ?? VersionConstraint.any, super._(); - static HostedDependency tryFromData(Object data) { - if (data == null || data is String) { - data = {'version': data}; - } - - if (data is Map) { - if (data.isEmpty || - data.containsKey('version') || - data.containsKey('hosted')) { - return _$HostedDependencyFromJson(data); - } - } - - return null; - } - @override String get _info => version.toString(); } @@ -194,7 +211,7 @@ class HostedDetails { @JsonKey(required: true, disallowNullValue: true) final String name; - @JsonKey(fromJson: _parseUri, disallowNullValue: true) + @JsonKey(fromJson: parseGitUri, disallowNullValue: true) final Uri url; HostedDetails(this.name, this.url); diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index ed384a994..e4bca581e 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -12,6 +12,8 @@ part of 'dependency.dart'; SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { + $checkKeys(json, + requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); var val = new SdkDependency( $checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert(json, 'version', @@ -26,7 +28,7 @@ GitDependency _$GitDependencyFromJson(Map json) { requiredKeys: const ['url'], disallowNullValues: const ['url']); var val = new GitDependency( $checkedConvert( - json, 'url', (v) => v == null ? null : _parseUri(v as String)), + json, 'url', (v) => v == null ? null : parseGitUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), $checkedConvert(json, 'path', (v) => v as String)); return val; @@ -56,7 +58,7 @@ HostedDetails _$HostedDetailsFromJson(Map json) { var val = new HostedDetails( $checkedConvert(json, 'name', (v) => v as String), $checkedConvert( - json, 'url', (v) => v == null ? null : _parseUri(v as String))); + json, 'url', (v) => v == null ? null : parseGitUri(v as String))); return val; }); } diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 78dba00e9..e21906084 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.2-dev +version: 0.1.2 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 658e13275..def243d10 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -31,10 +31,17 @@ line 4, column 10: Not a valid dependency value. test('map with too many keys', () { _expectThrows({'path': 'a', 'git': 'b'}, r''' -line 5, column 12: Expected only one key. +line 5, column 12: A dependency may only have one source. "path": "a", ^^^'''); }); + + test('map with unsupported keys', () { + _expectThrows({'bob': 'a', 'jones': 'b'}, r''' +line 6, column 4: Unsupported dependency key. + "jones": "b" + ^^^^^^^'''); + }); }); } @@ -94,15 +101,15 @@ line 5, column 15: Unsupported value for `version`. ^^^^^^^^^^^^^^^'''); }); - test('map w/ unsupported keys', () { + test('map w/ extra keys should fail', () { _expectThrows({ 'version': '^1.0.0', 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, 'not_supported': null }, r''' -line 4, column 10: Unrecognized keys: [not_supported]; supported keys: [version, hosted] - "dep": { - ^^'''); +line 10, column 4: Unsupported dependency key. + "not_supported": null + ^^^^^^^^^^^^^^^'''); }); test('map w/ version and hosted as String', () { @@ -138,24 +145,38 @@ line 5, column 14: These keys had `null` values, which is not allowed: [hosted] } void _sdkDependency() { - test('SdkDependency without version', () { + test('without version', () { var dep = _dependency({'sdk': 'flutter'}); expect(dep.sdk, 'flutter'); expect(dep.version, isNull); expect(dep.toString(), 'SdkDependency: flutter'); }); - test('SdkDependency with version', () { + test('with version', () { var dep = _dependency( {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}); expect(dep.sdk, 'flutter'); expect(dep.version.toString(), '>=1.2.3 <2.0.0'); expect(dep.toString(), 'SdkDependency: flutter'); }); + + test('null content', () { + _expectThrows({'sdk': null}, r''' +line 5, column 11: These keys had `null` values, which is not allowed: [sdk] + "sdk": null + ^^^^^'''); + }); + + test('number content', () { + _expectThrows({'sdk': 42}, r''' +line 5, column 11: Unsupported value for `sdk`. + "sdk": 42 + ^^^'''); + }); } void _gitDependency() { - test('GitDependency - string', () { + test('string', () { var dep = _dependency({'git': 'url'}); expect(dep.url.toString(), 'url'); expect(dep.path, isNull); @@ -163,7 +184,31 @@ void _gitDependency() { expect(dep.toString(), 'GitDependency: url@url'); }); - test('GitDependency - map', () { + test('string with version key is ignored', () { + // Regression test for https://github.com/dart-lang/pubspec_parse/issues/13 + var dep = _dependency({'git': 'url', 'version': '^1.2.3'}); + expect(dep.url.toString(), 'url'); + expect(dep.path, isNull); + expect(dep.ref, isNull); + expect(dep.toString(), 'GitDependency: url@url'); + }); + + test('string with user@ URL', () { + var dep = _dependency({'git': 'git@localhost:dep.git'}); + expect(dep.url.toString(), 'ssh://git@localhost/dep.git'); + expect(dep.path, isNull); + expect(dep.ref, isNull); + expect(dep.toString(), 'GitDependency: url@ssh://git@localhost/dep.git'); + }); + + test('string with random extra key fails', () { + _expectThrows({'git': 'url', 'bob': '^1.2.3'}, r''' +line 6, column 4: Unsupported dependency key. + "bob": "^1.2.3" + ^^^^^'''); + }); + + test('map', () { var dep = _dependency({ 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'} }); @@ -175,7 +220,7 @@ void _gitDependency() { test('git - null content', () { _expectThrows({'git': null}, r''' -line 5, column 11: Cannot be null. +line 5, column 11: Must be a String or a Map. "git": null ^^^^^'''); }); @@ -214,20 +259,34 @@ line 6, column 12: Unsupported value for `url`. } void _pathDependency() { - test('PathDependency', () { + test('valid', () { var dep = _dependency({'path': '../path'}); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); }); - test('path - null content', () { + test('valid with version key is ignored', () { + var dep = + _dependency({'path': '../path', 'version': '^1.2.3'}); + expect(dep.path, '../path'); + expect(dep.toString(), 'PathDependency: path@../path'); + }); + + test('valid with random extra key fails', () { + _expectThrows({'path': '../path', 'bob': '^1.2.3'}, r''' +line 6, column 4: Unsupported dependency key. + "bob": "^1.2.3" + ^^^^^'''); + }); + + test('null content', () { _expectThrows({'path': null}, r''' -line 5, column 12: Cannot be null. +line 5, column 12: Must be a String. "path": null ^^^^^'''); }); - test('path - int content', () { + test('int content', () { _expectThrows({'path': 42}, r''' line 5, column 12: Must be a String. "path": 42 diff --git a/pkgs/pubspec_parse/test/git_uri_test.dart b/pkgs/pubspec_parse/test/git_uri_test.dart new file mode 100644 index 000000000..a1cfdf9cb --- /dev/null +++ b/pkgs/pubspec_parse/test/git_uri_test.dart @@ -0,0 +1,25 @@ +import 'package:test/test.dart'; + +import 'package:pubspec_parse/src/dependency.dart'; + +void main() { + for (var item in { + 'git@github.com:google/grinder.dart.git': + 'ssh://git@github.com/google/grinder.dart.git', + 'host.xz:path/to/repo.git/': 'ssh://host.xz/path/to/repo.git/', + 'http:path/to/repo.git/': 'ssh://http/path/to/repo.git/', + 'file:path/to/repo.git/': 'ssh://file/path/to/repo.git/', + './foo:bar': 'foo%3Abar', + '/path/to/repo.git/': '/path/to/repo.git/', + 'file:///path/to/repo.git/': 'file:///path/to/repo.git/', + }.entries) { + test(item.key, () { + var uri = parseGitUri(item.key); + + printOnFailure( + [uri.scheme, uri.userInfo, uri.host, uri.port, uri.path].join('\n')); + + expect(uri, Uri.parse(item.value)); + }); + } +} From e0e79c8cee4044d67a5f415c41c3b84b950ad38b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 21 Jun 2018 14:54:41 -0700 Subject: [PATCH 026/152] test: update error tests for latest pkg:json_serializable (dart-lang/pubspec_parse#15) --- pkgs/pubspec_parse/pubspec.yaml | 6 +++--- pkgs/pubspec_parse/test/dependency_test.dart | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index e21906084..ae60a284e 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.2 +version: 0.1.3-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team @@ -10,13 +10,13 @@ environment: sdk: '>=2.0.0-dev.54 <2.0.0' dependencies: - json_annotation: ^0.2.8 + json_annotation: ^0.2.9 pub_semver: ^1.3.2 yaml: ^2.1.12 dev_dependencies: build_runner: ^0.8.0 - json_serializable: ^0.5.7 + json_serializable: ^0.5.8 path: ^1.5.1 stack_trace: ^1.9.2 test: ^0.12.42 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index def243d10..2a8b49132 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -96,7 +96,7 @@ line 4, column 10: Could not parse version "not a version". Unknown text at "not 'version': 'not a version', 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} }, r''' -line 5, column 15: Unsupported value for `version`. +line 5, column 15: Could not parse version "not a version". Unknown text at "not a version". "version": "not a version", ^^^^^^^^^^^^^^^'''); }); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 00a0de97a..b3db0b0e9 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -153,9 +153,9 @@ line 4, column 10: `42` is not a String. ^^^'''); }); - test('invalid version', () { + test('version', () { expectParseThrows({'name': 'sample', 'version': 'invalid'}, r''' -line 3, column 13: Unsupported value for `version`. +line 3, column 13: Could not parse "invalid". "version": "invalid" ^^^^^^^^^'''); }); From 472a9fe13f11f92c099e8ee5a2f87e74425caea2 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 22 Jun 2018 09:44:24 -0700 Subject: [PATCH 027/152] misc: require a minimum of build_runner 0.9.0, update pkg:test dep --- pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index ae60a284e..2ec796f9b 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -15,10 +15,10 @@ dependencies: yaml: ^2.1.12 dev_dependencies: - build_runner: ^0.8.0 + build_runner: ^0.9.0 json_serializable: ^0.5.8 path: ^1.5.1 stack_trace: ^1.9.2 - test: ^0.12.42 + test: ^1.0.0 test_descriptor: ^1.0.3 test_process: ^1.0.2 From c4eb5c0784fc391119887559757a1790f882edd7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 27 Jun 2018 17:36:13 -0700 Subject: [PATCH 028/152] update dartfmt --- pkgs/pubspec_parse/test/ensure_build_test.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index 2842c5a06..854dd2493 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -44,8 +44,7 @@ final _whitespace = new RegExp(r'\s'); Set _changedGeneratedFiles() { var output = _runProc('git', ['status', '--porcelain']); - return LineSplitter - .split(output) + return LineSplitter.split(output) .map((line) => line.split(_whitespace).last) .where((path) => path.endsWith('.dart')) .toSet(); From 54df806f2e00fcf07c8f385fc0903eee35335949 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 23 Jul 2018 08:26:24 -0700 Subject: [PATCH 029/152] misc: support the Dart 2 stable release (dart-lang/pubspec_parse#18) --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 30551e713..2447adb30 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2+1 + +- Support the Dart 2 stable release. + ## 0.1.2 - Allow superfluous `version` keys with `git` and `path` dependencies. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 2ec796f9b..eaedffbc1 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,12 +2,12 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.3-dev +version: 0.1.2+1 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team environment: - sdk: '>=2.0.0-dev.54 <2.0.0' + sdk: '>=2.0.0-dev.54 <3.0.0' dependencies: json_annotation: ^0.2.9 From 8697c47de770762195ab9165c9af074180d89312 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 24 Jul 2018 16:03:42 -0700 Subject: [PATCH 030/152] misc: support v1 json_annotation Verified that v1 changes don't affect runtime behavior --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 2447adb30..d114b8c36 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2+2 + +- Support `package:json_annotation` v1. + ## 0.1.2+1 - Support the Dart 2 stable release. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index eaedffbc1..17ff7d323 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.2+1 +version: 0.1.2+2 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team @@ -10,7 +10,7 @@ environment: sdk: '>=2.0.0-dev.54 <3.0.0' dependencies: - json_annotation: ^0.2.9 + json_annotation: '>=0.2.9 <2.0.0' pub_semver: ^1.3.2 yaml: ^2.1.12 From d797569a99947570bb8b6abe65a81adb3711894e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 9 Aug 2018 14:40:12 -0700 Subject: [PATCH 031/152] misc: upgraded to json_serializable v1 (dart-lang/pubspec_parse#20) - Updated generated output - Use latest build_runner - Update test to pass with Dart 2 stable - Test on the stable SDK, too --- pkgs/pubspec_parse/.travis.yml | 1 + pkgs/pubspec_parse/build.yaml | 6 ---- pkgs/pubspec_parse/lib/src/dependency.g.dart | 30 +++++++------------- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 8 ++---- pkgs/pubspec_parse/pubspec.yaml | 7 +++-- pkgs/pubspec_parse/test/parse_test.dart | 2 +- 6 files changed, 19 insertions(+), 35 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index ea5469401..8c6a4b8c3 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -2,6 +2,7 @@ language: dart dart: - dev + - stable dart_task: - test: -x presubmit-only diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 930aad181..69bcb1f43 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -10,9 +10,3 @@ targets: options: any_map: true checked: true - header: |+ - // Copyright (c) 2018, 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. - - // GENERATED CODE - DO NOT MODIFY BY HAND diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index e4bca581e..cba3364b2 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -1,7 +1,3 @@ -// Copyright (c) 2018, 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. - // GENERATED CODE - DO NOT MODIFY BY HAND part of 'dependency.dart'; @@ -12,10 +8,8 @@ part of 'dependency.dart'; SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { - $checkKeys(json, - requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); - var val = new SdkDependency( - $checkedConvert(json, 'sdk', (v) => v as String), + $checkKeys(json, requiredKeys: ['sdk'], disallowNullValues: ['sdk']); + var val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String))); return val; @@ -24,9 +18,8 @@ SdkDependency _$SdkDependencyFromJson(Map json) { GitDependency _$GitDependencyFromJson(Map json) { return $checkedNew('GitDependency', json, () { - $checkKeys(json, - requiredKeys: const ['url'], disallowNullValues: const ['url']); - var val = new GitDependency( + $checkKeys(json, requiredKeys: ['url'], disallowNullValues: ['url']); + var val = GitDependency( $checkedConvert( json, 'url', (v) => v == null ? null : parseGitUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), @@ -38,13 +31,12 @@ GitDependency _$GitDependencyFromJson(Map json) { HostedDependency _$HostedDependencyFromJson(Map json) { return $checkedNew('HostedDependency', json, () { $checkKeys(json, - allowedKeys: const ['version', 'hosted'], - disallowNullValues: const ['hosted']); - var val = new HostedDependency( + allowedKeys: ['version', 'hosted'], disallowNullValues: ['hosted']); + var val = HostedDependency( version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String)), hosted: $checkedConvert(json, 'hosted', - (v) => v == null ? null : new HostedDetails.fromJson(v))); + (v) => v == null ? null : HostedDetails.fromJson(v))); return val; }); } @@ -52,10 +44,10 @@ HostedDependency _$HostedDependencyFromJson(Map json) { HostedDetails _$HostedDetailsFromJson(Map json) { return $checkedNew('HostedDetails', json, () { $checkKeys(json, - allowedKeys: const ['name', 'url'], - requiredKeys: const ['name'], - disallowNullValues: const ['name', 'url']); - var val = new HostedDetails( + allowedKeys: ['name', 'url'], + requiredKeys: ['name'], + disallowNullValues: ['name', 'url']); + var val = HostedDetails( $checkedConvert(json, 'name', (v) => v as String), $checkedConvert( json, 'url', (v) => v == null ? null : parseGitUri(v as String))); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 921b7e435..dfb0bcf12 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -1,7 +1,3 @@ -// Copyright (c) 2018, 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. - // GENERATED CODE - DO NOT MODIFY BY HAND part of 'pubspec.dart'; @@ -12,7 +8,7 @@ part of 'pubspec.dart'; Pubspec _$PubspecFromJson(Map json) { return $checkedNew('Pubspec', json, () { - var val = new Pubspec($checkedConvert(json, 'name', (v) => v as String), + var val = Pubspec($checkedConvert(json, 'name', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _versionFromString(v as String)), author: $checkedConvert(json, 'author', (v) => v as String), @@ -31,7 +27,7 @@ Pubspec _$PubspecFromJson(Map json) { dependencyOverrides: $checkedConvert( json, 'dependency_overrides', (v) => parseDeps(v as Map))); return val; - }, fieldKeyMap: const { + }, fieldKeyMap: { 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' }); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 17ff7d323..490a6b254 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.2+2 +version: 0.1.3-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team @@ -10,13 +10,14 @@ environment: sdk: '>=2.0.0-dev.54 <3.0.0' dependencies: + # Verified that no new features since 0.2.9 are used - be careful! json_annotation: '>=0.2.9 <2.0.0' pub_semver: ^1.3.2 yaml: ^2.1.12 dev_dependencies: - build_runner: ^0.9.0 - json_serializable: ^0.5.8 + build_runner: ^0.10.0 + json_serializable: ^1.0.0 path: ^1.5.1 stack_trace: ^1.9.2 test: ^1.0.0 diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index b3db0b0e9..71c0a58ed 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -26,7 +26,7 @@ void main() { test('all fields set', () { var version = new Version.parse('1.2.3'); - var sdkConstraint = new VersionConstraint.parse('>=2.0.0-dev.54 <2.0.0'); + var sdkConstraint = new VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); var value = parse({ 'name': 'sample', 'version': version.toString(), From fcf673efd9c1f769ae79a5ea04ebe9215cee403a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 30 Aug 2018 15:44:27 -0700 Subject: [PATCH 032/152] Regenerate files with json_serializable v1.2.1 (dart-lang/pubspec_parse#22) --- pkgs/pubspec_parse/lib/src/dependency.g.dart | 15 +++++++++------ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index cba3364b2..7aee20614 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -8,7 +8,8 @@ part of 'dependency.dart'; SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { - $checkKeys(json, requiredKeys: ['sdk'], disallowNullValues: ['sdk']); + $checkKeys(json, + requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); var val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String))); @@ -18,7 +19,8 @@ SdkDependency _$SdkDependencyFromJson(Map json) { GitDependency _$GitDependencyFromJson(Map json) { return $checkedNew('GitDependency', json, () { - $checkKeys(json, requiredKeys: ['url'], disallowNullValues: ['url']); + $checkKeys(json, + requiredKeys: const ['url'], disallowNullValues: const ['url']); var val = GitDependency( $checkedConvert( json, 'url', (v) => v == null ? null : parseGitUri(v as String)), @@ -31,7 +33,8 @@ GitDependency _$GitDependencyFromJson(Map json) { HostedDependency _$HostedDependencyFromJson(Map json) { return $checkedNew('HostedDependency', json, () { $checkKeys(json, - allowedKeys: ['version', 'hosted'], disallowNullValues: ['hosted']); + allowedKeys: const ['version', 'hosted'], + disallowNullValues: const ['hosted']); var val = HostedDependency( version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String)), @@ -44,9 +47,9 @@ HostedDependency _$HostedDependencyFromJson(Map json) { HostedDetails _$HostedDetailsFromJson(Map json) { return $checkedNew('HostedDetails', json, () { $checkKeys(json, - allowedKeys: ['name', 'url'], - requiredKeys: ['name'], - disallowNullValues: ['name', 'url']); + allowedKeys: const ['name', 'url'], + requiredKeys: const ['name'], + disallowNullValues: const ['name', 'url']); var val = HostedDetails( $checkedConvert(json, 'name', (v) => v as String), $checkedConvert( diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index dfb0bcf12..7ac66f708 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -27,7 +27,7 @@ Pubspec _$PubspecFromJson(Map json) { dependencyOverrides: $checkedConvert( json, 'dependency_overrides', (v) => parseDeps(v as Map))); return val; - }, fieldKeyMap: { + }, fieldKeyMap: const { 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' }); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 490a6b254..2db643df0 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: build_runner: ^0.10.0 - json_serializable: ^1.0.0 + json_serializable: ^1.2.1 path: ^1.5.1 stack_trace: ^1.9.2 test: ^1.0.0 From 7bd71140bd08005151926d7efc5b3d6daadd271b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 4 Sep 2018 15:14:31 -0700 Subject: [PATCH 033/152] Use pkg:pedantic lints (dart-lang/pubspec_parse#23) --- pkgs/pubspec_parse/analysis_options.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 8cd2a0f6d..918f5deed 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -15,6 +15,7 @@ linter: - avoid_function_literals_in_foreach_calls - avoid_init_to_null - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports - avoid_renaming_method_parameters - avoid_return_types_on_setters - avoid_returning_null From b07fdbfb10a6cd24484582bf27c3c6328f5aee01 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 24 Sep 2018 11:01:58 -0700 Subject: [PATCH 034/152] Migrate to pkg:build_verify for generated file checks (dart-lang/pubspec_parse#24) Part of https://github.com/kevmoo/build_verify/issues/1 --- pkgs/pubspec_parse/pubspec.yaml | 1 + .../pubspec_parse/test/ensure_build_test.dart | 54 +------------------ 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 2db643df0..4178027d1 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: dev_dependencies: build_runner: ^0.10.0 + build_verify: ^1.0.0 json_serializable: ^1.2.1 path: ^1.5.1 stack_trace: ^1.9.2 diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index 854dd2493..ac67c9ff6 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -4,59 +4,9 @@ @TestOn('vm') @Tags(const ['presubmit-only']) - -import 'dart:convert'; -import 'dart:io'; - -import 'package:path/path.dart' as p; +import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; void main() { - // TODO(kevmoo): replace with a common utility - // https://github.com/dart-lang/build/issues/716 - test('ensure local build succeeds with no changes', () { - var pkgRoot = _runProc('git', ['rev-parse', '--show-toplevel']); - var currentDir = Directory.current.resolveSymbolicLinksSync(); - - if (!p.equals(p.join(pkgRoot), currentDir)) { - throw new StateError('Expected the git root ($pkgRoot) ' - 'to match the current directory ($currentDir).'); - } - - // 1 - get a list of modified `.g.dart` files - should be empty - expect(_changedGeneratedFiles(), isEmpty); - - // 2 - run build - should be no output, since nothing should change - var result = _runProc('pub', - ['run', 'build_runner', 'build', '--delete-conflicting-outputs']); - - print(result); - expect(result, - contains(new RegExp(r'\[INFO\] Succeeded after \S+ with \d+ outputs'))); - - // 3 - get a list of modified `.g.dart` files - should still be empty - expect(_changedGeneratedFiles(), isEmpty); - }); -} - -final _whitespace = new RegExp(r'\s'); - -Set _changedGeneratedFiles() { - var output = _runProc('git', ['status', '--porcelain']); - - return LineSplitter.split(output) - .map((line) => line.split(_whitespace).last) - .where((path) => path.endsWith('.dart')) - .toSet(); -} - -String _runProc(String proc, List args) { - var result = Process.runSync(proc, args); - - if (result.exitCode != 0) { - throw new ProcessException( - proc, args, result.stderr as String, result.exitCode); - } - - return (result.stdout as String).trim(); + test('ensure_build', expectBuildClean); } From cfa6618e75cdc739ed3fd4f81e41f1aeb9d88023 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 8 Oct 2018 13:35:02 -0700 Subject: [PATCH 035/152] support latest pkg:build_runner --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 4178027d1..5dcb3dc81 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: yaml: ^2.1.12 dev_dependencies: - build_runner: ^0.10.0 + build_runner: ^1.0.0 build_verify: ^1.0.0 json_serializable: ^1.2.1 path: ^1.5.1 From 5c8a6e4dbe6dd2403b5c88e4f9612cc5a5c48d13 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 8 Oct 2018 13:56:38 -0700 Subject: [PATCH 036/152] Avoid running pub w/ user@ git URL on travis Causes a travis-specific failure, it seems --- pkgs/pubspec_parse/test/dependency_test.dart | 13 ++++++-- pkgs/pubspec_parse/test/test_utils.dart | 33 +++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 2a8b49132..3bc890aef 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -2,6 +2,8 @@ // 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 'dart:io'; + import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; @@ -194,7 +196,12 @@ void _gitDependency() { }); test('string with user@ URL', () { - var dep = _dependency({'git': 'git@localhost:dep.git'}); + var skipTryParse = Platform.environment.containsKey('TRAVIS'); + if (skipTryParse) { + print('FYI: not validating git@ URI on travis due to failure'); + } + var dep = _dependency({'git': 'git@localhost:dep.git'}, + skipTryPub: skipTryParse); expect(dep.url.toString(), 'ssh://git@localhost/dep.git'); expect(dep.path, isNull); expect(dep.ref, isNull); @@ -301,11 +308,11 @@ void _expectThrows(Object content, String expectedError) { }, expectedError); } -T _dependency(Object content) { +T _dependency(Object content, {bool skipTryPub = false}) { var value = parse({ 'name': 'sample', 'dependencies': {'dep': content} - }); + }, skipTryPub: skipTryPub); expect(value.name, 'sample'); expect(value.dependencies, hasLength(1)); diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 37cd3e96b..48efdf698 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -48,27 +48,38 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } } -Pubspec parse(Object content, {bool quietOnError = false}) { +Pubspec parse(Object content, + {bool quietOnError = false, bool skipTryPub = false}) { quietOnError ??= false; + skipTryPub ??= false; var encoded = _encodeJson(content); - var pubResult = waitFor(tryPub(encoded)); + ProcResult pubResult; + if (!skipTryPub) { + pubResult = waitFor(tryPub(encoded)); + expect(pubResult, isNotNull); + } try { var value = new Pubspec.parse(encoded); - addTearDown(() { - expect(pubResult.cleanParse, isTrue, - reason: - 'On success, parsing from the pub client should also succeed.'); - }); + if (pubResult != null) { + addTearDown(() { + expect(pubResult.cleanParse, isTrue, + reason: + 'On success, parsing from the pub client should also succeed.'); + }); + } return value; } catch (e) { - addTearDown(() { - expect(pubResult.cleanParse, isFalse, - reason: 'On failure, parsing from the pub client should also fail.'); - }); + if (pubResult != null) { + addTearDown(() { + expect(pubResult.cleanParse, isFalse, + reason: + 'On failure, parsing from the pub client should also fail.'); + }); + } if (e is ParsedYamlException) { if (!quietOnError) { _printDebugParsedYamlException(e); From dc93cbd146040704230ebe6592f0ae6a50442ca9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 11 Oct 2018 15:50:20 -0700 Subject: [PATCH 037/152] fix unnecessary_this lint for latest SDK (dart-lang/pubspec_parse#26) --- pkgs/pubspec_parse/lib/src/dependency.dart | 2 +- pkgs/pubspec_parse/lib/src/pubspec.dart | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 07d08b57b..3839e54e8 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -199,7 +199,7 @@ class HostedDependency extends Dependency { final HostedDetails hosted; HostedDependency({VersionConstraint version, this.hosted}) - : this.version = version ?? VersionConstraint.any, + : version = version ?? VersionConstraint.any, super._(); @override diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index a5cba623e..59ee5858b 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -65,11 +65,11 @@ class Pubspec { Map dependencies, Map devDependencies, Map dependencyOverrides, - }) : this.authors = _normalizeAuthors(author, authors), - this.environment = environment ?? const {}, - this.dependencies = dependencies ?? const {}, - this.devDependencies = devDependencies ?? const {}, - this.dependencyOverrides = dependencyOverrides ?? const {} { + }) : authors = _normalizeAuthors(author, authors), + environment = environment ?? const {}, + dependencies = dependencies ?? const {}, + devDependencies = devDependencies ?? const {}, + dependencyOverrides = dependencyOverrides ?? const {} { if (name == null || name.isEmpty) { throw new ArgumentError.value(name, 'name', '"name" cannot be empty.'); } From 09f9ce49ed57908634f11772809e5584f4b55f7b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 23 Oct 2018 14:34:04 -0700 Subject: [PATCH 038/152] Support the latest release of pkg:json_annotation (dart-lang/pubspec_parse#28) --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index d114b8c36..26de02e08 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2+3 + +- Support the latest version of `package:json_annotation`. + ## 0.1.2+2 - Support `package:json_annotation` v1. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 5dcb3dc81..871ae6ea9 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,16 +2,16 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.3-dev +version: 0.1.2+3 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team environment: - sdk: '>=2.0.0-dev.54 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dependencies: - # Verified that no new features since 0.2.9 are used - be careful! - json_annotation: '>=0.2.9 <2.0.0' + # Verified that no new features since 1.0.0 are used - be careful! + json_annotation: '>=1.0.0 <3.0.0' pub_semver: ^1.3.2 yaml: ^2.1.12 From cdd1d2e49912371ff2c37086a549cbf4398ea735 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 10 Dec 2018 10:38:34 -0800 Subject: [PATCH 039/152] Add pkg:pedantic lints --- pkgs/pubspec_parse/analysis_options.yaml | 1 + pkgs/pubspec_parse/pubspec.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 918f5deed..9602469e0 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -1,3 +1,4 @@ +include: package:pedantic/analysis_options.yaml analyzer: strong-mode: implicit-casts: false diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 871ae6ea9..842c4d700 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -20,6 +20,7 @@ dev_dependencies: build_verify: ^1.0.0 json_serializable: ^1.2.1 path: ^1.5.1 + pedantic: ^1.4.0 stack_trace: ^1.9.2 test: ^1.0.0 test_descriptor: ^1.0.3 From 788a07258d7a6318803710a7cea4d6fe77d31e27 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 10 Dec 2018 10:40:19 -0800 Subject: [PATCH 040/152] Update json_serializable version --- pkgs/pubspec_parse/lib/src/dependency.g.dart | 8 ++++---- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 7aee20614..243a5b3d1 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -10,7 +10,7 @@ SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { $checkKeys(json, requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); - var val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), + final val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String))); return val; @@ -21,7 +21,7 @@ GitDependency _$GitDependencyFromJson(Map json) { return $checkedNew('GitDependency', json, () { $checkKeys(json, requiredKeys: const ['url'], disallowNullValues: const ['url']); - var val = GitDependency( + final val = GitDependency( $checkedConvert( json, 'url', (v) => v == null ? null : parseGitUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), @@ -35,7 +35,7 @@ HostedDependency _$HostedDependencyFromJson(Map json) { $checkKeys(json, allowedKeys: const ['version', 'hosted'], disallowNullValues: const ['hosted']); - var val = HostedDependency( + final val = HostedDependency( version: $checkedConvert(json, 'version', (v) => v == null ? null : _constraintFromString(v as String)), hosted: $checkedConvert(json, 'hosted', @@ -50,7 +50,7 @@ HostedDetails _$HostedDetailsFromJson(Map json) { allowedKeys: const ['name', 'url'], requiredKeys: const ['name'], disallowNullValues: const ['name', 'url']); - var val = HostedDetails( + final val = HostedDetails( $checkedConvert(json, 'name', (v) => v as String), $checkedConvert( json, 'url', (v) => v == null ? null : parseGitUri(v as String))); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 7ac66f708..08ad5460f 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -8,7 +8,7 @@ part of 'pubspec.dart'; Pubspec _$PubspecFromJson(Map json) { return $checkedNew('Pubspec', json, () { - var val = Pubspec($checkedConvert(json, 'name', (v) => v as String), + final val = Pubspec($checkedConvert(json, 'name', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _versionFromString(v as String)), author: $checkedConvert(json, 'author', (v) => v as String), diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 842c4d700..390e60147 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: dev_dependencies: build_runner: ^1.0.0 build_verify: ^1.0.0 - json_serializable: ^1.2.1 + json_serializable: ^2.0.0 path: ^1.5.1 pedantic: ^1.4.0 stack_trace: ^1.9.2 From eaae4fc04db0c7347d616a8adf37f740c7f7cf33 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 18 Dec 2018 10:57:30 -0800 Subject: [PATCH 041/152] Remove unnecessary const, new --- pkgs/pubspec_parse/analysis_options.yaml | 2 ++ pkgs/pubspec_parse/lib/src/dependency.dart | 32 +++++++++---------- pkgs/pubspec_parse/lib/src/errors.dart | 6 ++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 25 +++++++-------- .../pubspec_parse/test/ensure_build_test.dart | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 4 +-- pkgs/pubspec_parse/test/pub_utils.dart | 14 +++----- pkgs/pubspec_parse/test/test_utils.dart | 2 +- 8 files changed, 42 insertions(+), 45 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 9602469e0..ed170c1aa 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -71,8 +71,10 @@ linter: - type_init_formals - unawaited_futures - unnecessary_brace_in_string_interps + - unnecessary_const - unnecessary_getters_setters - unnecessary_lambdas + - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_statements - unnecessary_this diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 3839e54e8..0fb761c9e 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -29,20 +29,20 @@ Map parseDeps(Map source) => if (innerError is FormatException) { message = innerError.message; } - throw new CheckedFromJsonException(source, key, e.className, message); + throw CheckedFromJsonException(source, key, e.className, message); } rethrow; } if (value == null) { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( source, key, 'Pubspec', 'Not a valid dependency value.'); } - return new MapEntry(key, value); + return MapEntry(key, value); }) ?? {}; -const _sourceKeys = const ['sdk', 'git', 'path', 'hosted']; +const _sourceKeys = ['sdk', 'git', 'path', 'hosted']; /// Returns `null` if the data could not be parsed. Dependency _fromJson(dynamic data) { @@ -61,11 +61,11 @@ Dependency _fromJson(dynamic data) { orElse: () => null); if (weirdKey != null) { - throw new InvalidKeyException( + throw InvalidKeyException( data, weirdKey, 'Unsupported dependency key.'); } if (matchedKeys.length > 1) { - throw new CheckedFromJsonException(data, matchedKeys[1], 'Dependency', + throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', 'A dependency may only have one source.'); } @@ -74,17 +74,17 @@ Dependency _fromJson(dynamic data) { try { switch (key) { case 'git': - return new GitDependency.fromData(data[key]); + return GitDependency.fromData(data[key]); case 'path': - return new PathDependency.fromData(data[key]); + return PathDependency.fromData(data[key]); case 'sdk': return _$SdkDependencyFromJson(data); case 'hosted': return _$HostedDependencyFromJson(data); } - throw new StateError('There is a bug in pubspec_parse.'); + throw StateError('There is a bug in pubspec_parse.'); } on ArgumentError catch (e) { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( data, e.name, 'Dependency', e.message.toString()); } } @@ -134,7 +134,7 @@ class GitDependency extends Dependency { return _$GitDependencyFromJson(data); } - throw new ArgumentError.value(data, 'git', 'Must be a String or a Map.'); + throw ArgumentError.value(data, 'git', 'Must be a String or a Map.'); } @override @@ -169,7 +169,7 @@ Uri _tryParseScpUri(String value) { var user = atIndex >= 0 ? value.substring(0, atIndex) : null; var host = value.substring(atIndex + 1, colonIndex); var path = value.substring(colonIndex + 1); - return new Uri(scheme: 'ssh', userInfo: user, host: host, path: path); + return Uri(scheme: 'ssh', userInfo: user, host: host, path: path); } return null; } @@ -181,9 +181,9 @@ class PathDependency extends Dependency { factory PathDependency.fromData(Object data) { if (data is String) { - return new PathDependency(data); + return PathDependency(data); } - throw new ArgumentError.value(data, 'path', 'Must be a String.'); + throw ArgumentError.value(data, 'path', 'Must be a String.'); } @override @@ -225,9 +225,9 @@ class HostedDetails { return _$HostedDetailsFromJson(data); } - throw new ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); + throw ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); } } VersionConstraint _constraintFromString(String input) => - new VersionConstraint.parse(input); + VersionConstraint.parse(input); diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index c9643b885..637c5a80b 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -6,7 +6,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:yaml/yaml.dart'; ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => - new ParsedYamlException._(message, yamlNode); + ParsedYamlException._(message, yamlNode); ParsedYamlException parsedYamlExceptionFromError( CheckedFromJsonException error, StackTrace stack) { @@ -20,7 +20,7 @@ ParsedYamlException parsedYamlExceptionFromError( return key.value == innerError.key; }, orElse: () => map); - return new ParsedYamlException._(innerError.message, node, + return ParsedYamlException._(innerError.message, node, innerError: error, innerStack: stack); } } else if (innerError is ParsedYamlException) { @@ -43,7 +43,7 @@ ParsedYamlException parsedYamlExceptionFromError( } } - return new ParsedYamlException._(message, yamlNode, + return ParsedYamlException._(message, yamlNode, innerError: error, innerStack: stack); } diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 59ee5858b..a8ef2fe85 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -71,7 +71,7 @@ class Pubspec { devDependencies = devDependencies ?? const {}, dependencyOverrides = dependencyOverrides ?? const {} { if (name == null || name.isEmpty) { - throw new ArgumentError.value(name, 'name', '"name" cannot be empty.'); + throw ArgumentError.value(name, 'name', '"name" cannot be empty.'); } } @@ -81,7 +81,7 @@ class Pubspec { var item = loadYaml(yaml, sourceUrl: sourceUrl); if (item == null) { - throw new ArgumentError.notNull('yaml'); + throw ArgumentError.notNull('yaml'); } if (item is! YamlMap) { @@ -89,19 +89,18 @@ class Pubspec { throw parsedYamlException('Does not represent a YAML map.', item); } - throw new ArgumentError.value( - yaml, 'yaml', 'Does not represent a YAML map.'); + throw ArgumentError.value(yaml, 'yaml', 'Does not represent a YAML map.'); } try { - return new Pubspec.fromJson(item as YamlMap); + return Pubspec.fromJson(item as YamlMap); } on CheckedFromJsonException catch (error, stack) { throw parsedYamlExceptionFromError(error, stack); } } static List _normalizeAuthors(String author, List authors) { - var value = new Set(); + var value = Set(); if (author != null) { value.add(author); } @@ -112,7 +111,7 @@ class Pubspec { } } -Version _versionFromString(String input) => new Version.parse(input); +Version _versionFromString(String input) => Version.parse(input); Map _environmentMap(Map source) => source.map((k, value) { @@ -120,7 +119,7 @@ Map _environmentMap(Map source) => if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! - throw new InvalidKeyException( + throw InvalidKeyException( source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); } @@ -129,16 +128,16 @@ Map _environmentMap(Map source) => constraint = null; } else if (value is String) { try { - constraint = new VersionConstraint.parse(value); + constraint = VersionConstraint.parse(value); } on FormatException catch (e) { - throw new CheckedFromJsonException(source, key, 'Pubspec', e.message); + throw CheckedFromJsonException(source, key, 'Pubspec', e.message); } - return new MapEntry(key, constraint); + return MapEntry(key, constraint); } else { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( source, key, 'VersionConstraint', '`$value` is not a String.'); } - return new MapEntry(key, constraint); + return MapEntry(key, constraint); }); diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index ac67c9ff6..d64fa4f66 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Tags(const ['presubmit-only']) +@Tags(['presubmit-only']) import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 71c0a58ed..3ed73a509 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -25,8 +25,8 @@ void main() { }); test('all fields set', () { - var version = new Version.parse('1.2.3'); - var sdkConstraint = new VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); + var version = Version.parse('1.2.3'); + var sdkConstraint = VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); var value = parse({ 'name': 'sample', 'version': version.toString(), diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index 984bb49ae..f9e2f0cda 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -26,7 +26,7 @@ Future tryPub(String content) async { if (result.exitCode == 0) { var lockContent = - new File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); + File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); printOnFailure([ '-----BEGIN pubspec.lock-----', @@ -51,20 +51,16 @@ class ProcResult { var values = await Future.wait([ proc.exitCode, - proc - .stdoutStream() - .forEach((line) => items.add(new ProcLine(false, line))), - proc - .stderrStream() - .forEach((line) => items.add(new ProcLine(true, line))), + proc.stdoutStream().forEach((line) => items.add(ProcLine(false, line))), + proc.stderrStream().forEach((line) => items.add(ProcLine(true, line))), ]); - return new ProcResult(values[0] as int, items); + return ProcResult(values[0] as int, items); } @override String toString() { - var buffer = new StringBuffer('Exit code: $exitCode'); + var buffer = StringBuffer('Exit code: $exitCode'); for (var line in lines) { buffer.write('\n$line'); } diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 48efdf698..d5254db83 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -62,7 +62,7 @@ Pubspec parse(Object content, } try { - var value = new Pubspec.parse(encoded); + var value = Pubspec.parse(encoded); if (pubResult != null) { addTearDown(() { From fe0b7c323ed773cf0d244ed3fcf42950f552a316 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 18 Dec 2018 11:03:13 -0800 Subject: [PATCH 042/152] Enable and fix a number of lints --- pkgs/pubspec_parse/analysis_options.yaml | 10 ++++- pkgs/pubspec_parse/lib/src/dependency.dart | 22 +++++------ pkgs/pubspec_parse/lib/src/errors.dart | 8 ++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 6 +-- pkgs/pubspec_parse/test/dependency_test.dart | 40 ++++++++++---------- pkgs/pubspec_parse/test/git_uri_test.dart | 5 +-- pkgs/pubspec_parse/test/parse_test.dart | 20 +++++----- pkgs/pubspec_parse/test/pub_utils.dart | 18 ++++----- pkgs/pubspec_parse/test/test_utils.dart | 12 +++--- 9 files changed, 73 insertions(+), 68 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index ed170c1aa..b95911604 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -20,12 +20,13 @@ linter: - avoid_renaming_method_parameters - avoid_return_types_on_setters - avoid_returning_null + - avoid_returning_null_for_future + - avoid_shadowing_type_parameters - avoid_types_as_parameter_names - avoid_unused_constructor_parameters - await_only_futures - camel_case_types - cancel_subscriptions - #- cascade_invocations - comment_references - constant_identifier_names - control_flow_in_finally @@ -44,10 +45,11 @@ linter: - no_adjacent_strings_in_list - no_duplicate_case_values - non_constant_identifier_names + - null_closures - omit_local_variable_types - only_throw_errors - overridden_fields - #- package_api_docs + - package_api_docs - package_names - package_prefixed_library_names - prefer_adjacent_string_concatenation @@ -57,6 +59,7 @@ linter: - prefer_contains - prefer_equal_for_default_values - prefer_final_fields + - prefer_final_locals - prefer_initializing_formals - prefer_interpolation_to_compose_strings - prefer_is_empty @@ -70,14 +73,17 @@ linter: - throw_in_finally - type_init_formals - unawaited_futures + - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const - unnecessary_getters_setters - unnecessary_lambdas - unnecessary_new - unnecessary_null_aware_assignments + - unnecessary_parenthesis - unnecessary_statements - unnecessary_this - unrelated_type_equality_checks + - use_function_type_syntax_for_parameters - use_rethrow_when_possible - valid_regexps diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 0fb761c9e..cba01dc43 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -12,7 +12,7 @@ part 'dependency.g.dart'; Map parseDeps(Map source) => source?.map((k, v) { - var key = k as String; + final key = k as String; Dependency value; try { value = _fromJson(v); @@ -23,7 +23,7 @@ Map parseDeps(Map source) => // extract the associated error information. var message = e.message; - var innerError = e.innerError; + final innerError = e.innerError; // json_annotation should handle FormatException... // https://github.com/dart-lang/json_serializable/issues/233 if (innerError is FormatException) { @@ -51,13 +51,13 @@ Dependency _fromJson(dynamic data) { } if (data is Map) { - var matchedKeys = + final matchedKeys = data.keys.cast().where((key) => key != 'version').toList(); if (data.isEmpty || (matchedKeys.isEmpty && data.containsKey('version'))) { return _$HostedDependencyFromJson(data); } else { - var weirdKey = matchedKeys.firstWhere((k) => !_sourceKeys.contains(k), + final weirdKey = matchedKeys.firstWhere((k) => !_sourceKeys.contains(k), orElse: () => null); if (weirdKey != null) { @@ -69,7 +69,7 @@ Dependency _fromJson(dynamic data) { 'A dependency may only have one source.'); } - var key = matchedKeys.single; + final key = matchedKeys.single; try { switch (key) { @@ -146,7 +146,7 @@ Uri parseGitUri(String value) => _tryParseScpUri(value) ?? Uri.parse(value); /// Supports URIs like `[user@]host.xz:path/to/repo.git/` /// See https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a Uri _tryParseScpUri(String value) { - var colonIndex = value.indexOf(':'); + final colonIndex = value.indexOf(':'); if (colonIndex < 0) { return null; @@ -154,7 +154,7 @@ Uri _tryParseScpUri(String value) { // If the first colon is part of a scheme, it's not an scp-like URI return null; } - var slashIndex = value.indexOf('/'); + final slashIndex = value.indexOf('/'); if (slashIndex >= 0 && slashIndex < colonIndex) { // Per docs: This syntax is only recognized if there are no slashes before @@ -164,11 +164,11 @@ Uri _tryParseScpUri(String value) { return null; } - var atIndex = value.indexOf('@'); + final atIndex = value.indexOf('@'); if (colonIndex > atIndex) { - var user = atIndex >= 0 ? value.substring(0, atIndex) : null; - var host = value.substring(atIndex + 1, colonIndex); - var path = value.substring(colonIndex + 1); + final user = atIndex >= 0 ? value.substring(0, atIndex) : null; + final host = value.substring(atIndex + 1, colonIndex); + final path = value.substring(colonIndex + 1); return Uri(scheme: 'ssh', userInfo: user, host: host, path: path); } return null; diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index 637c5a80b..aba69709b 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -10,13 +10,13 @@ ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => ParsedYamlException parsedYamlExceptionFromError( CheckedFromJsonException error, StackTrace stack) { - var innerError = error.innerError; + final innerError = error.innerError; if (innerError is InvalidKeyException) { - var map = innerError.map; + final map = innerError.map; if (map is YamlMap) { // if the associated key exists, use that as the error node, // otherwise use the map itself - var node = map.nodes.keys.cast().singleWhere((key) { + final node = map.nodes.keys.cast().singleWhere((key) { return key.value == innerError.key; }, orElse: () => map); @@ -27,7 +27,7 @@ ParsedYamlException parsedYamlExceptionFromError( return innerError; } - var yamlMap = error.map as YamlMap; + final yamlMap = error.map as YamlMap; var yamlNode = yamlMap.nodes[error.key]; String message; diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index a8ef2fe85..df712625f 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -78,7 +78,7 @@ class Pubspec { factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); factory Pubspec.parse(String yaml, {sourceUrl}) { - var item = loadYaml(yaml, sourceUrl: sourceUrl); + final item = loadYaml(yaml, sourceUrl: sourceUrl); if (item == null) { throw ArgumentError.notNull('yaml'); @@ -100,7 +100,7 @@ class Pubspec { } static List _normalizeAuthors(String author, List authors) { - var value = Set(); + final value = Set(); if (author != null) { value.add(author); } @@ -115,7 +115,7 @@ Version _versionFromString(String input) => Version.parse(input); Map _environmentMap(Map source) => source.map((k, value) { - var key = k as String; + final key = k as String; if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 3bc890aef..6c7d968fe 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -4,8 +4,8 @@ import 'dart:io'; -import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:test/test.dart'; import 'test_utils.dart'; @@ -49,20 +49,20 @@ line 6, column 4: Unsupported dependency key. void _hostedDependency() { test('null', () { - var dep = _dependency(null); + final dep = _dependency(null); expect(dep.version.toString(), 'any'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); test('empty map', () { - var dep = _dependency({}); + final dep = _dependency({}); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); test('string version', () { - var dep = _dependency('^1.0.0'); + final dep = _dependency('^1.0.0'); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); @@ -76,14 +76,14 @@ line 4, column 10: Could not parse version "not a version". Unknown text at "not }); test('map w/ just version', () { - var dep = _dependency({'version': '^1.0.0'}); + final dep = _dependency({'version': '^1.0.0'}); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); test('map w/ version and hosted as Map', () { - var dep = _dependency({ + final dep = _dependency({ 'version': '^1.0.0', 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} }); @@ -115,7 +115,7 @@ line 10, column 4: Unsupported dependency key. }); test('map w/ version and hosted as String', () { - var dep = _dependency( + final dep = _dependency( {'version': '^1.0.0', 'hosted': 'hosted_name'}); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted.name, 'hosted_name'); @@ -124,7 +124,7 @@ line 10, column 4: Unsupported dependency key. }); test('map w/ hosted as String', () { - var dep = _dependency({'hosted': 'hosted_name'}); + final dep = _dependency({'hosted': 'hosted_name'}); expect(dep.version, VersionConstraint.any); expect(dep.hosted.name, 'hosted_name'); expect(dep.hosted.url, isNull); @@ -139,7 +139,7 @@ line 5, column 14: These keys had `null` values, which is not allowed: [hosted] }); test('map w/ null version is fine', () { - var dep = _dependency({'version': null}); + final dep = _dependency({'version': null}); expect(dep.version, VersionConstraint.any); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); @@ -148,14 +148,14 @@ line 5, column 14: These keys had `null` values, which is not allowed: [hosted] void _sdkDependency() { test('without version', () { - var dep = _dependency({'sdk': 'flutter'}); + final dep = _dependency({'sdk': 'flutter'}); expect(dep.sdk, 'flutter'); expect(dep.version, isNull); expect(dep.toString(), 'SdkDependency: flutter'); }); test('with version', () { - var dep = _dependency( + final dep = _dependency( {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}); expect(dep.sdk, 'flutter'); expect(dep.version.toString(), '>=1.2.3 <2.0.0'); @@ -179,7 +179,7 @@ line 5, column 11: Unsupported value for `sdk`. void _gitDependency() { test('string', () { - var dep = _dependency({'git': 'url'}); + final dep = _dependency({'git': 'url'}); expect(dep.url.toString(), 'url'); expect(dep.path, isNull); expect(dep.ref, isNull); @@ -188,7 +188,7 @@ void _gitDependency() { test('string with version key is ignored', () { // Regression test for https://github.com/dart-lang/pubspec_parse/issues/13 - var dep = _dependency({'git': 'url', 'version': '^1.2.3'}); + final dep = _dependency({'git': 'url', 'version': '^1.2.3'}); expect(dep.url.toString(), 'url'); expect(dep.path, isNull); expect(dep.ref, isNull); @@ -196,11 +196,11 @@ void _gitDependency() { }); test('string with user@ URL', () { - var skipTryParse = Platform.environment.containsKey('TRAVIS'); + final skipTryParse = Platform.environment.containsKey('TRAVIS'); if (skipTryParse) { print('FYI: not validating git@ URI on travis due to failure'); } - var dep = _dependency({'git': 'git@localhost:dep.git'}, + final dep = _dependency({'git': 'git@localhost:dep.git'}, skipTryPub: skipTryParse); expect(dep.url.toString(), 'ssh://git@localhost/dep.git'); expect(dep.path, isNull); @@ -216,7 +216,7 @@ line 6, column 4: Unsupported dependency key. }); test('map', () { - var dep = _dependency({ + final dep = _dependency({ 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'} }); expect(dep.url.toString(), 'url'); @@ -267,13 +267,13 @@ line 6, column 12: Unsupported value for `url`. void _pathDependency() { test('valid', () { - var dep = _dependency({'path': '../path'}); + final dep = _dependency({'path': '../path'}); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); }); test('valid with version key is ignored', () { - var dep = + final dep = _dependency({'path': '../path', 'version': '^1.2.3'}); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); @@ -309,14 +309,14 @@ void _expectThrows(Object content, String expectedError) { } T _dependency(Object content, {bool skipTryPub = false}) { - var value = parse({ + final value = parse({ 'name': 'sample', 'dependencies': {'dep': content} }, skipTryPub: skipTryPub); expect(value.name, 'sample'); expect(value.dependencies, hasLength(1)); - var entry = value.dependencies.entries.single; + final entry = value.dependencies.entries.single; expect(entry.key, 'dep'); return entry.value as T; diff --git a/pkgs/pubspec_parse/test/git_uri_test.dart b/pkgs/pubspec_parse/test/git_uri_test.dart index a1cfdf9cb..36e55a84c 100644 --- a/pkgs/pubspec_parse/test/git_uri_test.dart +++ b/pkgs/pubspec_parse/test/git_uri_test.dart @@ -1,6 +1,5 @@ -import 'package:test/test.dart'; - import 'package:pubspec_parse/src/dependency.dart'; +import 'package:test/test.dart'; void main() { for (var item in { @@ -14,7 +13,7 @@ void main() { 'file:///path/to/repo.git/': 'file:///path/to/repo.git/', }.entries) { test(item.key, () { - var uri = parseGitUri(item.key); + final uri = parseGitUri(item.key); printOnFailure( [uri.scheme, uri.userInfo, uri.host, uri.port, uri.path].join('\n')); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 3ed73a509..df2475b88 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -9,7 +9,7 @@ import 'test_utils.dart'; void main() { test('minimal set values', () { - var value = parse({'name': 'sample'}); + final value = parse({'name': 'sample'}); expect(value.name, 'sample'); expect(value.version, isNull); expect(value.description, isNull); @@ -25,9 +25,9 @@ void main() { }); test('all fields set', () { - var version = Version.parse('1.2.3'); - var sdkConstraint = VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); - var value = parse({ + final version = Version.parse('1.2.3'); + final sdkConstraint = VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); + final value = parse({ 'name': 'sample', 'version': version.toString(), 'author': 'name@example.com', @@ -52,7 +52,7 @@ void main() { }); test('environment values can be null', () { - var value = parse({ + final value = parse({ 'name': 'sample', 'environment': {'sdk': null} }); @@ -63,14 +63,14 @@ void main() { group('author, authors', () { test('one author', () { - var value = parse({'name': 'sample', 'author': 'name@example.com'}); + final value = parse({'name': 'sample', 'author': 'name@example.com'}); // ignore: deprecated_member_use expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); test('one author, via authors', () { - var value = parse({ + final value = parse({ 'name': 'sample', 'authors': ['name@example.com'] }); @@ -80,7 +80,7 @@ void main() { }); test('many authors', () { - var value = parse({ + final value = parse({ 'name': 'sample', 'authors': ['name@example.com', 'name2@example.com'] }); @@ -90,7 +90,7 @@ void main() { }); test('author and authors', () { - var value = parse({ + final value = parse({ 'name': 'sample', 'author': 'name@example.com', 'authors': ['name2@example.com'] @@ -101,7 +101,7 @@ void main() { }); test('duplicate author values', () { - var value = parse({ + final value = parse({ 'name': 'sample', 'author': 'name@example.com', 'authors': ['name@example.com', 'name@example.com'] diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index f9e2f0cda..1ebb9c7ca 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -13,10 +13,10 @@ import 'package:test_process/test_process.dart'; Future tryPub(String content) async { await d.file('pubspec.yaml', content).create(); - var proc = await TestProcess.start(_pubPath, ['get', '--offline'], + final proc = await TestProcess.start(_pubPath, ['get', '--offline'], workingDirectory: d.sandbox); - var result = await ProcResult.fromTestProcess(proc); + final result = await ProcResult.fromTestProcess(proc); printOnFailure([ '-----BEGIN pub output-----', @@ -25,7 +25,7 @@ Future tryPub(String content) async { ].join('\n')); if (result.exitCode == 0) { - var lockContent = + final lockContent = File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); printOnFailure([ @@ -47,9 +47,9 @@ class ProcResult { ProcResult(this.exitCode, this.lines); static Future fromTestProcess(TestProcess proc) async { - var items = []; + final items = []; - var values = await Future.wait([ + final values = await Future.wait([ proc.exitCode, proc.stdoutStream().forEach((line) => items.add(ProcLine(false, line))), proc.stderrStream().forEach((line) => items.add(ProcLine(true, line))), @@ -60,7 +60,7 @@ class ProcResult { @override String toString() { - var buffer = StringBuffer('Exit code: $exitCode'); + final buffer = StringBuffer('Exit code: $exitCode'); for (var line in lines) { buffer.write('\n$line'); } @@ -79,13 +79,13 @@ class ProcLine { } /// The path to the root directory of the SDK. -final String _sdkDir = (() { +final String _sdkDir = () { // The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is // "/path/to/sdk". - var aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable)); + final aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable)); assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version'))); return aboveExecutable; -})(); +}(); final String _pubPath = p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub'); diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index d5254db83..9750bfa9b 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -17,7 +17,7 @@ String _encodeJson(Object input) => Matcher _throwsParsedYamlException(String prettyValue) => throwsA(const TypeMatcher().having((e) { - var message = e.formattedMessage; + final message = e.formattedMessage; printOnFailure("Actual error format:\nr'''\n$message'''"); _printDebugParsedYamlException(e); return message; @@ -28,7 +28,7 @@ void _printDebugParsedYamlException(ParsedYamlException e) { var innerStack = e.innerStack; if (e.innerError is CheckedFromJsonException) { - var cfje = e.innerError as CheckedFromJsonException; + final cfje = e.innerError as CheckedFromJsonException; if (cfje.innerError != null) { innerError = cfje.innerError; innerStack = cfje.innerStack; @@ -36,12 +36,12 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } if (innerError != null) { - var items = [innerError]; + final items = [innerError]; if (innerStack != null) { items.add(Trace.format(innerStack, terse: true)); } - var content = + final content = LineSplitter.split(items.join('\n')).map((e) => ' $e').join('\n'); printOnFailure('Inner error details:\n$content'); @@ -53,7 +53,7 @@ Pubspec parse(Object content, quietOnError ??= false; skipTryPub ??= false; - var encoded = _encodeJson(content); + final encoded = _encodeJson(content); ProcResult pubResult; if (!skipTryPub) { @@ -62,7 +62,7 @@ Pubspec parse(Object content, } try { - var value = Pubspec.parse(encoded); + final value = Pubspec.parse(encoded); if (pubResult != null) { addTearDown(() { From 9f42e729850e4ae42e352b13e2879a94e394d81f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 9 Oct 2018 17:52:09 -0700 Subject: [PATCH 043/152] Move json_serializable config to build.yaml --- pkgs/pubspec_parse/build.yaml | 1 + pkgs/pubspec_parse/lib/src/dependency.dart | 8 ++++---- pkgs/pubspec_parse/lib/src/pubspec.dart | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 69bcb1f43..90eeb90f6 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -10,3 +10,4 @@ targets: options: any_map: true checked: true + create_to_json: false diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index cba01dc43..d9b3db247 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -103,7 +103,7 @@ abstract class Dependency { String toString() => '$runtimeType: $_info'; } -@JsonSerializable(createToJson: false) +@JsonSerializable() class SdkDependency extends Dependency { @JsonKey(nullable: false, disallowNullValue: true, required: true) final String sdk; @@ -116,7 +116,7 @@ class SdkDependency extends Dependency { String get _info => sdk; } -@JsonSerializable(createToJson: false) +@JsonSerializable() class GitDependency extends Dependency { @JsonKey(fromJson: parseGitUri, required: true, disallowNullValue: true) final Uri url; @@ -190,7 +190,7 @@ class PathDependency extends Dependency { String get _info => 'path@$path'; } -@JsonSerializable(createToJson: false, disallowUnrecognizedKeys: true) +@JsonSerializable(disallowUnrecognizedKeys: true) class HostedDependency extends Dependency { @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; @@ -206,7 +206,7 @@ class HostedDependency extends Dependency { String get _info => version.toString(); } -@JsonSerializable(createToJson: false, disallowUnrecognizedKeys: true) +@JsonSerializable(disallowUnrecognizedKeys: true) class HostedDetails { @JsonKey(required: true, disallowNullValue: true) final String name; diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index df712625f..c7fec6b8a 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -11,7 +11,7 @@ import 'errors.dart'; part 'pubspec.g.dart'; -@JsonSerializable(createToJson: false) +@JsonSerializable() class Pubspec { // TODO: executables // TODO: publish_to From 4711ac71da70d85b477d3b65823e4f77833d8dac Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 18 Dec 2018 13:15:44 -0800 Subject: [PATCH 044/152] Centralize field rename logic in build.yaml --- pkgs/pubspec_parse/build.yaml | 1 + pkgs/pubspec_parse/lib/src/pubspec.dart | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 90eeb90f6..1525ab832 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -11,3 +11,4 @@ targets: any_map: true checked: true create_to_json: false + field_rename: snake diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index c7fec6b8a..dee92e036 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -45,10 +45,10 @@ class Pubspec { @JsonKey(fromJson: parseDeps, nullable: false) final Map dependencies; - @JsonKey(name: 'dev_dependencies', fromJson: parseDeps, nullable: false) + @JsonKey(fromJson: parseDeps, nullable: false) final Map devDependencies; - @JsonKey(name: 'dependency_overrides', fromJson: parseDeps, nullable: false) + @JsonKey(fromJson: parseDeps, nullable: false) final Map dependencyOverrides; /// If [author] and [authors] are both provided, their values are combined From 9afd4ee4cd600f9632ab51546fe430ccd2914127 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 22 Jun 2018 10:25:05 -0700 Subject: [PATCH 045/152] Add support for publish_to field Fixes https://github.com/dart-lang/pubspec_parse/issues/21 --- pkgs/pubspec_parse/CHANGELOG.md | 4 +++ pkgs/pubspec_parse/lib/src/pubspec.dart | 22 +++++++++++- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 ++ pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 44 +++++++++++++++++++++++ pkgs/pubspec_parse/test/test_utils.dart | 10 ++++-- 6 files changed, 79 insertions(+), 5 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 26de02e08..add9737b8 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3 + +- Add support for `publish_to` field. + ## 0.1.2+3 - Support the latest version of `package:json_annotation`. diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index dee92e036..27ebc640f 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -14,7 +14,6 @@ part 'pubspec.g.dart'; @JsonSerializable() class Pubspec { // TODO: executables - // TODO: publish_to final String name; @@ -24,6 +23,15 @@ class Pubspec { final String description; final String homepage; + /// Specifies where to publish this package. + /// + /// Accepted values: `null`, `'none'` or an `http` or `https` URL. + /// + /// If not specified, the pub client defaults to `https://pub.dartlang.org`. + /// + /// [More information](https://www.dartlang.org/tools/pub/pubspec#publish_to). + final String publishTo; + /// If there is exactly 1 value in [authors], returns it. /// /// If there are 0 or more than 1, returns `null`. @@ -56,6 +64,7 @@ class Pubspec { Pubspec( this.name, { this.version, + this.publishTo, String author, List authors, Map environment, @@ -73,6 +82,17 @@ class Pubspec { if (name == null || name.isEmpty) { throw ArgumentError.value(name, 'name', '"name" cannot be empty.'); } + + if (publishTo != null && publishTo != 'none') { + try { + final targetUri = Uri.parse(publishTo); + if (!(targetUri.isScheme('http') || targetUri.isScheme('https'))) { + throw const FormatException('must be an http or https URL.'); + } + } on FormatException catch (e) { + throw ArgumentError.value(publishTo, 'publishTo', e.message); + } + } } factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 08ad5460f..bf878c2c5 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -11,6 +11,7 @@ Pubspec _$PubspecFromJson(Map json) { final val = Pubspec($checkedConvert(json, 'name', (v) => v as String), version: $checkedConvert(json, 'version', (v) => v == null ? null : _versionFromString(v as String)), + publishTo: $checkedConvert(json, 'publish_to', (v) => v as String), author: $checkedConvert(json, 'author', (v) => v as String), authors: $checkedConvert(json, 'authors', (v) => (v as List)?.map((e) => e as String)?.toList()), @@ -28,6 +29,7 @@ Pubspec _$PubspecFromJson(Map json) { json, 'dependency_overrides', (v) => parseDeps(v as Map))); return val; }, fieldKeyMap: const { + 'publishTo': 'publish_to', 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' }); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 390e60147..fde8f8a76 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.2+3 +version: 0.1.3-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index df2475b88..23d2078de 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -12,6 +12,7 @@ void main() { final value = parse({'name': 'sample'}); expect(value.name, 'sample'); expect(value.version, isNull); + expect(value.publishTo, isNull); expect(value.description, isNull); expect(value.homepage, isNull); // ignore: deprecated_member_use @@ -30,6 +31,7 @@ void main() { final value = parse({ 'name': 'sample', 'version': version.toString(), + 'publish_to': 'none', 'author': 'name@example.com', 'environment': {'sdk': sdkConstraint.toString()}, 'description': 'description', @@ -38,6 +40,7 @@ void main() { }); expect(value.name, 'sample'); expect(value.version, version); + expect(value.publishTo, 'none'); expect(value.description, 'description'); expect(value.homepage, 'homepage'); // ignore: deprecated_member_use @@ -61,6 +64,47 @@ void main() { expect(value.environment, containsPair('sdk', isNull)); }); + group('publish_to', () { + for (var entry in { + 42: r''' +line 3, column 16: Unsupported value for `publish_to`. + "publish_to": 42 + ^^^''', + '##not a uri!': r''' +line 3, column 16: must be an http or https URL. + "publish_to": "##not a uri!" + ^^^^^^^^^^^^^^''', + '/cool/beans': r''' +line 3, column 16: must be an http or https URL. + "publish_to": "/cool/beans" + ^^^^^^^^^^^^^''', + 'file:///Users/kevmoo/': r''' +line 3, column 16: must be an http or https URL. + "publish_to": "file:///Users/kevmoo/" + ^^^^^^^^^^^^^^^^^^^^^^^''' + }.entries) { + test('cannot be `${entry.key}`', () { + expectParseThrows( + {'name': 'sample', 'publish_to': entry.key}, + entry.value, + skipTryPub: true, + ); + }); + } + + for (var entry in { + null: null, + 'http': 'http://example.com', + 'https': 'https://example.com', + 'none': 'none' + }.entries) { + test('can be ${entry.key}', () { + final value = parse({'name': 'sample', 'publish_to': entry.value}); + expect(value.publishTo, entry.value); + }); + } + }); + group('author, authors', () { test('one author', () { final value = parse({'name': 'sample', 'author': 'name@example.com'}); diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 9750bfa9b..491873f34 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -89,6 +89,10 @@ Pubspec parse(Object content, } } -void expectParseThrows(Object content, String expectedError) => expect( - () => parse(content, quietOnError: true), - _throwsParsedYamlException(expectedError)); +void expectParseThrows( + Object content, + String expectedError, { + bool skipTryPub = false, +}) => + expect(() => parse(content, quietOnError: true, skipTryPub: skipTryPub), + _throwsParsedYamlException(expectedError)); From 5c532003292fcef698e1d74ae35799a3022d170f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Thu, 20 Dec 2018 00:31:08 +0100 Subject: [PATCH 046/152] Support the proposed repository and issue_tracker URLs. (dart-lang/pubspec_parse#30) --- pkgs/pubspec_parse/CHANGELOG.md | 1 + pkgs/pubspec_parse/lib/src/pubspec.dart | 12 ++++++++++++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index add9737b8..066edeb19 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.1.3 - Add support for `publish_to` field. +- Support the proposed `repository` and `issue_tracker` URLs. ## 0.1.2+3 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 27ebc640f..8324e0774 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -21,6 +21,8 @@ class Pubspec { final Version version; final String description; + + /// This should be a URL pointing to the website for the package. final String homepage; /// Specifies where to publish this package. @@ -32,6 +34,14 @@ class Pubspec { /// [More information](https://www.dartlang.org/tools/pub/pubspec#publish_to). final String publishTo; + /// Optional field to specify the source code repository of the package. + /// Useful when a package has both a home page and a repository. + final Uri repository; + + /// Optional field to a web page where developers can report new issues or + /// view existing ones. + final Uri issueTracker; + /// If there is exactly 1 value in [authors], returns it. /// /// If there are 0 or more than 1, returns `null`. @@ -69,6 +79,8 @@ class Pubspec { List authors, Map environment, this.homepage, + this.repository, + this.issueTracker, this.documentation, this.description, Map dependencies, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index bf878c2c5..866438f06 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -18,6 +18,10 @@ Pubspec _$PubspecFromJson(Map json) { environment: $checkedConvert(json, 'environment', (v) => v == null ? null : _environmentMap(v as Map)), homepage: $checkedConvert(json, 'homepage', (v) => v as String), + repository: $checkedConvert(json, 'repository', + (v) => v == null ? null : Uri.parse(v as String)), + issueTracker: $checkedConvert(json, 'issue_tracker', + (v) => v == null ? null : Uri.parse(v as String)), documentation: $checkedConvert(json, 'documentation', (v) => v as String), description: $checkedConvert(json, 'description', (v) => v as String), @@ -30,6 +34,7 @@ Pubspec _$PubspecFromJson(Map json) { return val; }, fieldKeyMap: const { 'publishTo': 'publish_to', + 'issueTracker': 'issue_tracker', 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' }); From ad96ee26306f98308cf1f265d3df7697493d03b5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 20 Dec 2018 08:31:46 -0800 Subject: [PATCH 047/152] Add support for the optional `flutter` field --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 9 +++++++++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 4 +++- pkgs/pubspec_parse/test/parse_test.dart | 9 +++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 066edeb19..9df4aca1b 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.1.3 -- Add support for `publish_to` field. -- Support the proposed `repository` and `issue_tracker` URLs. +- Added support for `flutter`, `issue_tracker`, `publish_to`, and `repository` + fields. ## 0.1.2+3 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 8324e0774..b79839d38 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -69,6 +69,14 @@ class Pubspec { @JsonKey(fromJson: parseDeps, nullable: false) final Map dependencyOverrides; + /// Optional configuration specific to [Flutter](https://flutter.io/) + /// packages. + /// + /// May include + /// [assets](https://flutter.io/docs/development/ui/assets-and-images) + /// and other settings. + final Map flutter; + /// If [author] and [authors] are both provided, their values are combined /// with duplicates eliminated. Pubspec( @@ -86,6 +94,7 @@ class Pubspec { Map dependencies, Map devDependencies, Map dependencyOverrides, + this.flutter, }) : authors = _normalizeAuthors(author, authors), environment = environment ?? const {}, dependencies = dependencies ?? const {}, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 866438f06..b68e030fa 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -30,7 +30,9 @@ Pubspec _$PubspecFromJson(Map json) { devDependencies: $checkedConvert( json, 'dev_dependencies', (v) => parseDeps(v as Map)), dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => parseDeps(v as Map))); + json, 'dependency_overrides', (v) => parseDeps(v as Map)), + flutter: $checkedConvert(json, 'flutter', + (v) => (v as Map)?.map((k, e) => MapEntry(k as String, e)))); return val; }, fieldKeyMap: const { 'publishTo': 'publish_to', diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 23d2078de..281f11374 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -23,6 +23,7 @@ void main() { expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); expect(value.dependencyOverrides, isEmpty); + expect(value.flutter, isNull); }); test('all fields set', () { @@ -154,6 +155,14 @@ line 3, column 16: must be an http or https URL. expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); + + test('flutter', () { + final value = parse({ + 'name': 'sample', + 'flutter': {'key': 'value'}, + }); + expect(value.flutter, {'key': 'value'}); + }); }); group('invalid', () { From a073213309664977b4d917f28311512c8e6b5a86 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 20 Dec 2018 08:32:05 -0800 Subject: [PATCH 048/152] Prepare to release v0.1.3 --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index fde8f8a76..be7ada51c 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.3-dev +version: 0.1.3 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team From 189d9851e1120da333fdfb6252a5695218217243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Tue, 8 Jan 2019 16:35:08 +0100 Subject: [PATCH 049/152] Parsing option: lenient. (dart-lang/pubspec_parse#36) Fixes https://github.com/dart-lang/pubspec_parse/issues/35 --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++ pkgs/pubspec_parse/lib/src/pubspec.dart | 32 ++++++++- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 86 +++++++++++++++++++++++++ pkgs/pubspec_parse/test/test_utils.dart | 11 +++- 5 files changed, 128 insertions(+), 7 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 9df4aca1b..d43264920 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.4 + +- Added `lenient` named argument to `Pubspec.fromJson` to ignore format and type errors. + ## 0.1.3 - Added support for `flutter`, `issue_tracker`, `publish_to`, and `repository` diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index b79839d38..4052a7017 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -116,9 +116,35 @@ class Pubspec { } } - factory Pubspec.fromJson(Map json) => _$PubspecFromJson(json); + factory Pubspec.fromJson(Map json, {bool lenient = false}) { + lenient ??= false; + + if (lenient) { + while (json.isNotEmpty) { + // Attempting to remove top-level properties that cause parsing errors. + try { + return _$PubspecFromJson(json); + } on CheckedFromJsonException catch (e) { + if (e.map == json && json.containsKey(e.key)) { + json = Map.from(json); + json.remove(e.key); + continue; + } + rethrow; + } + } + } + + return _$PubspecFromJson(json); + } + + /// Parses source [yaml] into [Pubspec]. + /// + /// When [lenient] is set, top-level property-parsing or type cast errors are + /// ignored and `null` values are returned. + factory Pubspec.parse(String yaml, {sourceUrl, bool lenient = false}) { + lenient ??= false; - factory Pubspec.parse(String yaml, {sourceUrl}) { final item = loadYaml(yaml, sourceUrl: sourceUrl); if (item == null) { @@ -134,7 +160,7 @@ class Pubspec { } try { - return Pubspec.fromJson(item as YamlMap); + return Pubspec.fromJson(item as YamlMap, lenient: lenient); } on CheckedFromJsonException catch (error, stack) { throw parsedYamlExceptionFromError(error, stack); } diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index be7ada51c..0b48262e4 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.3 +version: 0.1.4 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 281f11374..ff3ade0a7 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -222,5 +222,91 @@ line 4, column 10: Could not parse version "silly". Unknown text at "silly". "sdk": "silly" ^^^^^^^'''); }); + + test('bad repository url', () { + expectParseThrows({ + 'name': 'foo', + 'repository': {'x': 'y'}, + }, r''' +line 3, column 16: Unsupported value for `repository`. + "repository": { + ^^''', skipTryPub: true); + }); + + test('bad issue_tracker url', () { + expectParseThrows({ + 'name': 'foo', + 'issue_tracker': {'x': 'y'}, + }, r''' +line 3, column 19: Unsupported value for `issue_tracker`. + "issue_tracker": { + ^^''', skipTryPub: true); + }); + }); + + group('lenient', () { + test('null', () { + expect(() => parse(null, lenient: true), throwsArgumentError); + }); + + test('empty string', () { + expect(() => parse('', lenient: true), throwsArgumentError); + }); + + test('name cannot be empty', () { + expect(() => parse({}, lenient: true), throwsException); + }); + + test('bad repository url', () { + final value = parse( + { + 'name': 'foo', + 'repository': {'x': 'y'}, + }, + lenient: true, + ); + expect(value.name, 'foo'); + expect(value.repository, isNull); + }); + + test('bad issue_tracker url', () { + final value = parse( + { + 'name': 'foo', + 'issue_tracker': {'x': 'y'}, + }, + lenient: true, + ); + expect(value.name, 'foo'); + expect(value.issueTracker, isNull); + }); + + test('multiple bad values', () { + final value = parse( + { + 'name': 'foo', + 'repository': {'x': 'y'}, + 'issue_tracker': {'x': 'y'}, + }, + lenient: true, + ); + expect(value.name, 'foo'); + expect(value.repository, isNull); + expect(value.issueTracker, isNull); + }); + + test('deep error throws with lenient', () { + expect( + () => parse({ + 'name': 'foo', + 'dependencies': { + 'foo': { + 'git': {'url': 1} + }, + }, + 'issue_tracker': {'x': 'y'}, + }, skipTryPub: true, lenient: true), + throwsException); + }); }); } diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 491873f34..7f8ae87ae 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -48,10 +48,15 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } } -Pubspec parse(Object content, - {bool quietOnError = false, bool skipTryPub = false}) { +Pubspec parse( + Object content, { + bool quietOnError = false, + bool skipTryPub = false, + bool lenient = false, +}) { quietOnError ??= false; skipTryPub ??= false; + lenient ??= false; final encoded = _encodeJson(content); @@ -62,7 +67,7 @@ Pubspec parse(Object content, } try { - final value = Pubspec.parse(encoded); + final value = Pubspec.parse(encoded, lenient: lenient); if (pubResult != null) { addTearDown(() { From d05aa18de781f3b90bbd0ef532aeee1ddb18ede6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Tue, 8 Jan 2019 16:41:57 +0100 Subject: [PATCH 050/152] Parse tests for repository and issue_tracker. (dart-lang/pubspec_parse#37) --- pkgs/pubspec_parse/test/parse_test.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index ff3ade0a7..e00f8b0b8 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -24,6 +24,8 @@ void main() { expect(value.devDependencies, isEmpty); expect(value.dependencyOverrides, isEmpty); expect(value.flutter, isNull); + expect(value.repository, isNull); + expect(value.issueTracker, isNull); }); test('all fields set', () { @@ -37,7 +39,9 @@ void main() { 'environment': {'sdk': sdkConstraint.toString()}, 'description': 'description', 'homepage': 'homepage', - 'documentation': 'documentation' + 'documentation': 'documentation', + 'repository': 'https://github.com/example/repo', + 'issue_tracker': 'https://github.com/example/repo/issues', }); expect(value.name, 'sample'); expect(value.version, version); @@ -53,6 +57,9 @@ void main() { expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); expect(value.dependencyOverrides, isEmpty); + expect(value.repository, Uri.parse('https://github.com/example/repo')); + expect(value.issueTracker, + Uri.parse('https://github.com/example/repo/issues')); }); test('environment values can be null', () { From b82a0ff0a8941de7b20932a10f907f53c387c730 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 17 Jan 2019 16:08:31 -0800 Subject: [PATCH 051/152] fix tests with latest source_span release (dart-lang/pubspec_parse#38) --- pkgs/pubspec_parse/test/dependency_test.dart | 134 +++++++++++++------ pkgs/pubspec_parse/test/parse_test.dart | 78 +++++++---- 2 files changed, 150 insertions(+), 62 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 6c7d968fe..11a43824d 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -20,29 +20,39 @@ void main() { test('List', () { _expectThrows([], r''' line 4, column 10: Not a valid dependency value. - "dep": [] - ^^'''); + ╷ +4 │ "dep": [] + │ ^^ + ╵'''); }); test('int', () { _expectThrows(42, r''' line 4, column 10: Not a valid dependency value. - "dep": 42 - ^^^'''); + ╷ +4 │ "dep": 42 + │ ┌──────────^ +5 │ │ } + │ └─^ + ╵'''); }); test('map with too many keys', () { _expectThrows({'path': 'a', 'git': 'b'}, r''' line 5, column 12: A dependency may only have one source. - "path": "a", - ^^^'''); + ╷ +5 │ "path": "a", + │ ^^^ + ╵'''); }); test('map with unsupported keys', () { _expectThrows({'bob': 'a', 'jones': 'b'}, r''' line 6, column 4: Unsupported dependency key. - "jones": "b" - ^^^^^^^'''); + ╷ +6 │ "jones": "b" + │ ^^^^^^^ + ╵'''); }); }); } @@ -71,8 +81,10 @@ void _hostedDependency() { test('bad string version', () { _expectThrows('not a version', r''' line 4, column 10: Could not parse version "not a version". Unknown text at "not a version". - "dep": "not a version" - ^^^^^^^^^^^^^^^'''); + ╷ +4 │ "dep": "not a version" + │ ^^^^^^^^^^^^^^^ + ╵'''); }); test('map w/ just version', () { @@ -99,8 +111,10 @@ line 4, column 10: Could not parse version "not a version". Unknown text at "not 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} }, r''' line 5, column 15: Could not parse version "not a version". Unknown text at "not a version". - "version": "not a version", - ^^^^^^^^^^^^^^^'''); + ╷ +5 │ "version": "not a version", + │ ^^^^^^^^^^^^^^^ + ╵'''); }); test('map w/ extra keys should fail', () { @@ -110,8 +124,10 @@ line 5, column 15: Could not parse version "not a version". Unknown text at "not 'not_supported': null }, r''' line 10, column 4: Unsupported dependency key. - "not_supported": null - ^^^^^^^^^^^^^^^'''); + ╷ +10│ "not_supported": null + │ ^^^^^^^^^^^^^^^ + ╵'''); }); test('map w/ version and hosted as String', () { @@ -134,8 +150,12 @@ line 10, column 4: Unsupported dependency key. test('map w/ null hosted should error', () { _expectThrows({'hosted': null}, r''' line 5, column 14: These keys had `null` values, which is not allowed: [hosted] - "hosted": null - ^^^^^'''); + ╷ +5 │ "hosted": null + │ ┌──────────────^ +6 │ │ } + │ └──^ + ╵'''); }); test('map w/ null version is fine', () { @@ -165,15 +185,23 @@ void _sdkDependency() { test('null content', () { _expectThrows({'sdk': null}, r''' line 5, column 11: These keys had `null` values, which is not allowed: [sdk] - "sdk": null - ^^^^^'''); + ╷ +5 │ "sdk": null + │ ┌───────────^ +6 │ │ } + │ └──^ + ╵'''); }); test('number content', () { _expectThrows({'sdk': 42}, r''' line 5, column 11: Unsupported value for `sdk`. - "sdk": 42 - ^^^'''); + ╷ +5 │ "sdk": 42 + │ ┌───────────^ +6 │ │ } + │ └──^ + ╵'''); }); } @@ -211,8 +239,10 @@ void _gitDependency() { test('string with random extra key fails', () { _expectThrows({'git': 'url', 'bob': '^1.2.3'}, r''' line 6, column 4: Unsupported dependency key. - "bob": "^1.2.3" - ^^^^^'''); + ╷ +6 │ "bob": "^1.2.3" + │ ^^^^^ + ╵'''); }); test('map', () { @@ -228,22 +258,32 @@ line 6, column 4: Unsupported dependency key. test('git - null content', () { _expectThrows({'git': null}, r''' line 5, column 11: Must be a String or a Map. - "git": null - ^^^^^'''); + ╷ +5 │ "git": null + │ ┌───────────^ +6 │ │ } + │ └──^ + ╵'''); }); test('git - int content', () { _expectThrows({'git': 42}, r''' line 5, column 11: Must be a String or a Map. - "git": 42 - ^^^'''); + ╷ +5 │ "git": 42 + │ ┌───────────^ +6 │ │ } + │ └──^ + ╵'''); }); test('git - empty map', () { _expectThrows({'git': {}}, r''' line 5, column 11: Required keys are missing: url. - "git": {} - ^^'''); + ╷ +5 │ "git": {} + │ ^^ + ╵'''); }); test('git - null url', () { @@ -251,8 +291,12 @@ line 5, column 11: Required keys are missing: url. 'git': {'url': null} }, r''' line 6, column 12: These keys had `null` values, which is not allowed: [url] - "url": null - ^^^^^'''); + ╷ +6 │ "url": null + │ ┌────────────^ +7 │ │ } + │ └───^ + ╵'''); }); test('git - int url', () { @@ -260,8 +304,12 @@ line 6, column 12: These keys had `null` values, which is not allowed: [url] 'git': {'url': 42} }, r''' line 6, column 12: Unsupported value for `url`. - "url": 42 - ^^^'''); + ╷ +6 │ "url": 42 + │ ┌────────────^ +7 │ │ } + │ └───^ + ╵'''); }); } @@ -282,22 +330,32 @@ void _pathDependency() { test('valid with random extra key fails', () { _expectThrows({'path': '../path', 'bob': '^1.2.3'}, r''' line 6, column 4: Unsupported dependency key. - "bob": "^1.2.3" - ^^^^^'''); + ╷ +6 │ "bob": "^1.2.3" + │ ^^^^^ + ╵'''); }); test('null content', () { _expectThrows({'path': null}, r''' line 5, column 12: Must be a String. - "path": null - ^^^^^'''); + ╷ +5 │ "path": null + │ ┌────────────^ +6 │ │ } + │ └──^ + ╵'''); }); test('int content', () { _expectThrows({'path': 42}, r''' line 5, column 12: Must be a String. - "path": 42 - ^^^'''); + ╷ +5 │ "path": 42 + │ ┌────────────^ +6 │ │ } + │ └──^ + ╵'''); }); } diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index e00f8b0b8..a943e6acf 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -76,20 +76,28 @@ void main() { for (var entry in { 42: r''' line 3, column 16: Unsupported value for `publish_to`. - "publish_to": 42 - ^^^''', + ╷ +3 │ "publish_to": 42 + │ ^^ + ╵''', '##not a uri!': r''' line 3, column 16: must be an http or https URL. - "publish_to": "##not a uri!" - ^^^^^^^^^^^^^^''', + ╷ +3 │ "publish_to": "##not a uri!" + │ ^^^^^^^^^^^^^^ + ╵''', '/cool/beans': r''' line 3, column 16: must be an http or https URL. - "publish_to": "/cool/beans" - ^^^^^^^^^^^^^''', + ╷ +3 │ "publish_to": "/cool/beans" + │ ^^^^^^^^^^^^^ + ╵''', 'file:///Users/kevmoo/': r''' line 3, column 16: must be an http or https URL. - "publish_to": "file:///Users/kevmoo/" - ^^^^^^^^^^^^^^^^^^^^^^^''' + ╷ +3 │ "publish_to": "file:///Users/kevmoo/" + │ ^^^^^^^^^^^^^^^^^^^^^^^ + ╵''' }.entries) { test('cannot be `${entry.key}`', () { expectParseThrows( @@ -182,15 +190,19 @@ line 3, column 16: must be an http or https URL. test('array', () { expectParseThrows([], r''' line 1, column 1: Does not represent a YAML map. -[] -^^'''); + ╷ +1 │ [] + │ ^^ + ╵'''); }); test('missing name', () { expectParseThrows({}, r''' line 1, column 1: "name" cannot be empty. -{} -^^'''); + ╷ +1 │ {} + │ ^^ + ╵'''); }); test('"dart" is an invalid environment key', () { @@ -199,8 +211,10 @@ line 1, column 1: "name" cannot be empty. 'environment': {'dart': 'cool'} }, r''' line 4, column 3: Use "sdk" to for Dart SDK constraints. - "dart": "cool" - ^^^^^^'''); + ╷ +4 │ "dart": "cool" + │ ^^^^^^ + ╵'''); }); test('environment values cannot be int', () { @@ -209,15 +223,21 @@ line 4, column 3: Use "sdk" to for Dart SDK constraints. 'environment': {'sdk': 42} }, r''' line 4, column 10: `42` is not a String. - "sdk": 42 - ^^^'''); + ╷ +4 │ "sdk": 42 + │ ┌──────────^ +5 │ │ } + │ └─^ + ╵'''); }); test('version', () { expectParseThrows({'name': 'sample', 'version': 'invalid'}, r''' line 3, column 13: Could not parse "invalid". - "version": "invalid" - ^^^^^^^^^'''); + ╷ +3 │ "version": "invalid" + │ ^^^^^^^^^ + ╵'''); }); test('invalid environment value', () { @@ -226,8 +246,10 @@ line 3, column 13: Could not parse "invalid". 'environment': {'sdk': 'silly'} }, r''' line 4, column 10: Could not parse version "silly". Unknown text at "silly". - "sdk": "silly" - ^^^^^^^'''); + ╷ +4 │ "sdk": "silly" + │ ^^^^^^^ + ╵'''); }); test('bad repository url', () { @@ -236,8 +258,12 @@ line 4, column 10: Could not parse version "silly". Unknown text at "silly". 'repository': {'x': 'y'}, }, r''' line 3, column 16: Unsupported value for `repository`. - "repository": { - ^^''', skipTryPub: true); + ╷ +3 │ "repository": { + │ ┌────────────────^ +4 │ │ "x": "y" +5 │ └ } + ╵''', skipTryPub: true); }); test('bad issue_tracker url', () { @@ -246,8 +272,12 @@ line 3, column 16: Unsupported value for `repository`. 'issue_tracker': {'x': 'y'}, }, r''' line 3, column 19: Unsupported value for `issue_tracker`. - "issue_tracker": { - ^^''', skipTryPub: true); + ╷ +3 │ "issue_tracker": { + │ ┌───────────────────^ +4 │ │ "x": "y" +5 │ └ } + ╵''', skipTryPub: true); }); }); From ff2e4d42e184a8fdfdc3997003da639cd1010510 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 24 Jan 2019 22:25:58 -0800 Subject: [PATCH 052/152] Update ignores for hint changes in latest dev SDK (dart-lang/pubspec_parse#39) --- pkgs/pubspec_parse/.travis.yml | 10 +++++++++- pkgs/pubspec_parse/test/parse_test.dart | 14 +++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index 8c6a4b8c3..3af3939c7 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -8,7 +8,15 @@ dart_task: - test: -x presubmit-only - test: --run-skipped -t presubmit-only - dartfmt - - dartanalyzer: --fatal-infos --fatal-warnings . + +matrix: + include: + - dart: dev + dart_task: + dartanalyzer: --fatal-infos --fatal-warnings . + - dart: stable + dart_task: + dartanalyzer: --fatal-warnings . # Only building master means that we don't run two builds for each pull request. branches: diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index a943e6acf..dc469a5b7 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -15,7 +15,7 @@ void main() { expect(value.publishTo, isNull); expect(value.description, isNull); expect(value.homepage, isNull); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, isEmpty); expect(value.environment, isEmpty); @@ -48,7 +48,7 @@ void main() { expect(value.publishTo, 'none'); expect(value.description, 'description'); expect(value.homepage, 'homepage'); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); expect(value.environment, hasLength(1)); @@ -124,7 +124,7 @@ line 3, column 16: must be an http or https URL. group('author, authors', () { test('one author', () { final value = parse({'name': 'sample', 'author': 'name@example.com'}); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); @@ -134,7 +134,7 @@ line 3, column 16: must be an http or https URL. 'name': 'sample', 'authors': ['name@example.com'] }); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); @@ -144,7 +144,7 @@ line 3, column 16: must be an http or https URL. 'name': 'sample', 'authors': ['name@example.com', 'name2@example.com'] }); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); }); @@ -155,7 +155,7 @@ line 3, column 16: must be an http or https URL. 'author': 'name@example.com', 'authors': ['name2@example.com'] }); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); }); @@ -166,7 +166,7 @@ line 3, column 16: must be an http or https URL. 'author': 'name@example.com', 'authors': ['name@example.com', 'name@example.com'] }); - // ignore: deprecated_member_use + // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); From e51f873513e10f4987f198d83dd2704874a14b0b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 27 Feb 2019 11:03:38 -0800 Subject: [PATCH 053/152] Disable prefer_collection_literals, because Dart 2.2 Set (dart-lang/pubspec_parse#40) Enable and fix a few more --- pkgs/pubspec_parse/analysis_options.yaml | 14 ++++++++++++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 3 +-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index b95911604..4f0a48b4d 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -12,6 +12,8 @@ linter: rules: - always_declare_return_types - annotate_overrides + - avoid_bool_literals_in_conditional_expressions + - avoid_classes_with_only_static_members - avoid_empty_else - avoid_function_literals_in_foreach_calls - avoid_init_to_null @@ -21,12 +23,16 @@ linter: - avoid_return_types_on_setters - avoid_returning_null - avoid_returning_null_for_future + - avoid_returning_null_for_void + - avoid_returning_this - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements - avoid_types_as_parameter_names - avoid_unused_constructor_parameters - await_only_futures - camel_case_types - cancel_subscriptions + - cascade_invocations - comment_references - constant_identifier_names - control_flow_in_finally @@ -34,10 +40,12 @@ linter: - empty_catches - empty_constructor_bodies - empty_statements + - file_names - hash_and_equals - implementation_imports - invariant_booleans - iterable_contains_unrelated_type + - join_return_with_assignment - library_names - library_prefixes - list_remove_unrelated_type @@ -53,7 +61,8 @@ linter: - package_names - package_prefixed_library_names - prefer_adjacent_string_concatenation - - prefer_collection_literals + # TODO: reenable this once we want to pin the SDK to >=2.2.0 + # - prefer_collection_literals - prefer_conditional_assignment - prefer_const_constructors - prefer_contains @@ -64,11 +73,11 @@ linter: - prefer_interpolation_to_compose_strings - prefer_is_empty - prefer_is_not_empty + - prefer_null_aware_operators - prefer_single_quotes - prefer_typing_uninitialized_variables - recursive_getters - slash_for_doc_comments - - super_goes_last - test_types_in_equals - throw_in_finally - type_init_formals @@ -87,3 +96,4 @@ linter: - use_function_type_syntax_for_parameters - use_rethrow_when_possible - valid_regexps + - void_checks diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 4052a7017..c05e8249c 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -126,8 +126,7 @@ class Pubspec { return _$PubspecFromJson(json); } on CheckedFromJsonException catch (e) { if (e.map == json && json.containsKey(e.key)) { - json = Map.from(json); - json.remove(e.key); + json = Map.from(json)..remove(e.key); continue; } rethrow; From a7e62266581033b0370193ce4575577c4b89e878 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 12 Mar 2019 13:47:24 -0700 Subject: [PATCH 054/152] update generated code --- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index b68e030fa..ba7e6ebf1 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -31,8 +31,12 @@ Pubspec _$PubspecFromJson(Map json) { json, 'dev_dependencies', (v) => parseDeps(v as Map)), dependencyOverrides: $checkedConvert( json, 'dependency_overrides', (v) => parseDeps(v as Map)), - flutter: $checkedConvert(json, 'flutter', - (v) => (v as Map)?.map((k, e) => MapEntry(k as String, e)))); + flutter: $checkedConvert( + json, + 'flutter', + (v) => (v as Map)?.map( + (k, e) => MapEntry(k as String, e), + ))); return val; }, fieldKeyMap: const { 'publishTo': 'publish_to', From 8ac2af02cae51b40aa092b52934ebda888acd1a0 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 13 Mar 2019 13:10:23 -0700 Subject: [PATCH 055/152] Test analysis on oldest supported SDK (dart-lang/pubspec_parse#41) --- pkgs/pubspec_parse/.travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index 3af3939c7..b82f2f3e5 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -2,7 +2,6 @@ language: dart dart: - dev - - stable dart_task: - test: -x presubmit-only @@ -14,7 +13,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: stable + - dart: 2.0.0 dart_task: dartanalyzer: --fatal-warnings . From d69e98b1d2d496601db1bda617ca96f741b8998f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 2 Apr 2019 14:35:11 -0700 Subject: [PATCH 056/152] Remove a work-around for a long-ago fixed issue (dart-lang/pubspec_parse#42) --- pkgs/pubspec_parse/lib/src/dependency.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index d9b3db247..52057eb43 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -21,15 +21,7 @@ Map parseDeps(Map source) => // This is likely a "synthetic" map created from a String value // Use `source` to throw this exception with an actual YamlMap and // extract the associated error information. - - var message = e.message; - final innerError = e.innerError; - // json_annotation should handle FormatException... - // https://github.com/dart-lang/json_serializable/issues/233 - if (innerError is FormatException) { - message = innerError.message; - } - throw CheckedFromJsonException(source, key, e.className, message); + throw CheckedFromJsonException(source, key, e.className, e.message); } rethrow; } From 9a15a6b5e1d864b69ac91377154f30c742e3fe0e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 26 Apr 2019 09:10:14 -0700 Subject: [PATCH 057/152] Update SDK constraint, enable/fix lints (dart-lang/pubspec_parse#43) --- pkgs/pubspec_parse/.travis.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/analysis_options.yaml | 4 ++-- pkgs/pubspec_parse/lib/src/pubspec.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index b82f2f3e5..536ccee72 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -13,7 +13,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.0.0 + - dart: 2.2.0 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index d43264920..1f62e3afd 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.5 + +- Update SDK requirement to `>=2.2.0 <3.0.0`. + ## 0.1.4 - Added `lenient` named argument to `Pubspec.fromJson` to ignore format and type errors. diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 4f0a48b4d..f983bb3b8 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -61,14 +61,14 @@ linter: - package_names - package_prefixed_library_names - prefer_adjacent_string_concatenation - # TODO: reenable this once we want to pin the SDK to >=2.2.0 - # - prefer_collection_literals + - prefer_collection_literals - prefer_conditional_assignment - prefer_const_constructors - prefer_contains - prefer_equal_for_default_values - prefer_final_fields - prefer_final_locals + - prefer_generic_function_type_aliases - prefer_initializing_formals - prefer_interpolation_to_compose_strings - prefer_is_empty diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index c05e8249c..3d542d7a9 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -166,7 +166,7 @@ class Pubspec { } static List _normalizeAuthors(String author, List authors) { - final value = Set(); + final value = {}; if (author != null) { value.add(author); } diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 0b48262e4..c1df008a9 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,12 +2,12 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.4 +version: 0.1.5-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.2.0 <3.0.0' dependencies: # Verified that no new features since 1.0.0 are used - be careful! From 6c137d32e7cbb53566b2d96d794951fe28e79647 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 26 Apr 2019 10:27:58 -0700 Subject: [PATCH 058/152] Remove custom Yaml error class --- pkgs/pubspec_parse/lib/src/dependency.dart | 5 +---- pkgs/pubspec_parse/lib/src/errors.dart | 18 +++--------------- pkgs/pubspec_parse/lib/src/pubspec.dart | 3 +-- pkgs/pubspec_parse/test/dependency_test.dart | 8 ++++---- pkgs/pubspec_parse/test/parse_test.dart | 2 +- 5 files changed, 10 insertions(+), 26 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 52057eb43..364e70361 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -6,8 +6,6 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; -import 'errors.dart'; - part 'dependency.g.dart'; Map parseDeps(Map source) => @@ -53,8 +51,7 @@ Dependency _fromJson(dynamic data) { orElse: () => null); if (weirdKey != null) { - throw InvalidKeyException( - data, weirdKey, 'Unsupported dependency key.'); + throw UnrecognizedKeysException([weirdKey], data, _sourceKeys); } if (matchedKeys.length > 1) { throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index aba69709b..6d2b38ce7 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart @@ -11,13 +11,13 @@ ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => ParsedYamlException parsedYamlExceptionFromError( CheckedFromJsonException error, StackTrace stack) { final innerError = error.innerError; - if (innerError is InvalidKeyException) { + if (innerError is UnrecognizedKeysException) { final map = innerError.map; if (map is YamlMap) { // if the associated key exists, use that as the error node, // otherwise use the map itself - final node = map.nodes.keys.cast().singleWhere((key) { - return key.value == innerError.key; + final node = map.nodes.keys.cast().firstWhere((key) { + return innerError.unrecognizedKeys.contains(key.value); }, orElse: () => map); return ParsedYamlException._(innerError.message, node, @@ -72,15 +72,3 @@ class ParsedYamlException implements Exception { @override String toString() => message; } - -/// Package-private class representing an invalid key. -/// -/// Used instead of [CheckedFromJsonException] when highlighting a bad [key] -/// is desired, instead of the associated value. -class InvalidKeyException implements Exception { - final Map map; - final String key; - final String message; - - InvalidKeyException(this.map, this.key, this.message); -} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 3d542d7a9..a8dacf68d 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -185,8 +185,7 @@ Map _environmentMap(Map source) => if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! - throw InvalidKeyException( - source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); + throw UnrecognizedKeysException(['dart'], source, ['sdk']); } VersionConstraint constraint; diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 11a43824d..9e9099731 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -48,7 +48,7 @@ line 5, column 12: A dependency may only have one source. test('map with unsupported keys', () { _expectThrows({'bob': 'a', 'jones': 'b'}, r''' -line 6, column 4: Unsupported dependency key. +line 6, column 4: Unrecognized keys: [jones]; supported keys: [sdk, git, path, hosted] ╷ 6 │ "jones": "b" │ ^^^^^^^ @@ -123,7 +123,7 @@ line 5, column 15: Could not parse version "not a version". Unknown text at "not 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, 'not_supported': null }, r''' -line 10, column 4: Unsupported dependency key. +line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git, path, hosted] ╷ 10│ "not_supported": null │ ^^^^^^^^^^^^^^^ @@ -238,7 +238,7 @@ void _gitDependency() { test('string with random extra key fails', () { _expectThrows({'git': 'url', 'bob': '^1.2.3'}, r''' -line 6, column 4: Unsupported dependency key. +line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ 6 │ "bob": "^1.2.3" │ ^^^^^ @@ -329,7 +329,7 @@ void _pathDependency() { test('valid with random extra key fails', () { _expectThrows({'path': '../path', 'bob': '^1.2.3'}, r''' -line 6, column 4: Unsupported dependency key. +line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ 6 │ "bob": "^1.2.3" │ ^^^^^ diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index dc469a5b7..3c79d87f2 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -210,7 +210,7 @@ line 1, column 1: "name" cannot be empty. 'name': 'sample', 'environment': {'dart': 'cool'} }, r''' -line 4, column 3: Use "sdk" to for Dart SDK constraints. +line 4, column 3: Unrecognized keys: [dart]; supported keys: [sdk] ╷ 4 │ "dart": "cool" │ ^^^^^^ From 7790dff1ab030803aa2613c7b13bf9275a97b650 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 26 Apr 2019 10:11:27 -0700 Subject: [PATCH 059/152] use pkg:checked_yaml --- pkgs/pubspec_parse/lib/pubspec_parse.dart | 1 - pkgs/pubspec_parse/lib/src/dependency.dart | 28 ++-- pkgs/pubspec_parse/lib/src/errors.dart | 74 --------- pkgs/pubspec_parse/lib/src/pubspec.dart | 35 ++-- pkgs/pubspec_parse/pubspec.yaml | 1 + pkgs/pubspec_parse/test/dependency_test.dart | 158 ++++++++++++------- pkgs/pubspec_parse/test/parse_test.dart | 125 +++++++++++---- pkgs/pubspec_parse/test/test_utils.dart | 20 ++- 8 files changed, 229 insertions(+), 213 deletions(-) delete mode 100644 pkgs/pubspec_parse/lib/src/errors.dart diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart index 99886c44a..132263a8a 100644 --- a/pkgs/pubspec_parse/lib/pubspec_parse.dart +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -9,5 +9,4 @@ export 'src/dependency.dart' GitDependency, SdkDependency, PathDependency; -export 'src/errors.dart' show ParsedYamlException; export 'src/pubspec.dart' show Pubspec; diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 364e70361..e2b07702d 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -47,20 +47,21 @@ Dependency _fromJson(dynamic data) { if (data.isEmpty || (matchedKeys.isEmpty && data.containsKey('version'))) { return _$HostedDependencyFromJson(data); } else { - final weirdKey = matchedKeys.firstWhere((k) => !_sourceKeys.contains(k), - orElse: () => null); + final firstUnrecognizedKey = matchedKeys + .firstWhere((k) => !_sourceKeys.contains(k), orElse: () => null); - if (weirdKey != null) { - throw UnrecognizedKeysException([weirdKey], data, _sourceKeys); - } - if (matchedKeys.length > 1) { - throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', - 'A dependency may only have one source.'); - } + return $checkedNew('Dependency', data, () { + if (firstUnrecognizedKey != null) { + throw UnrecognizedKeysException( + [firstUnrecognizedKey], data, _sourceKeys); + } + if (matchedKeys.length > 1) { + throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', + 'A dependency may only have one source.'); + } - final key = matchedKeys.single; + final key = matchedKeys.single; - try { switch (key) { case 'git': return GitDependency.fromData(data[key]); @@ -72,10 +73,7 @@ Dependency _fromJson(dynamic data) { return _$HostedDependencyFromJson(data); } throw StateError('There is a bug in pubspec_parse.'); - } on ArgumentError catch (e) { - throw CheckedFromJsonException( - data, e.name, 'Dependency', e.message.toString()); - } + }); } } diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart deleted file mode 100644 index 6d2b38ce7..000000000 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2018, 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:json_annotation/json_annotation.dart'; -import 'package:yaml/yaml.dart'; - -ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => - ParsedYamlException._(message, yamlNode); - -ParsedYamlException parsedYamlExceptionFromError( - CheckedFromJsonException error, StackTrace stack) { - final innerError = error.innerError; - if (innerError is UnrecognizedKeysException) { - final map = innerError.map; - if (map is YamlMap) { - // if the associated key exists, use that as the error node, - // otherwise use the map itself - final node = map.nodes.keys.cast().firstWhere((key) { - return innerError.unrecognizedKeys.contains(key.value); - }, orElse: () => map); - - return ParsedYamlException._(innerError.message, node, - innerError: error, innerStack: stack); - } - } else if (innerError is ParsedYamlException) { - return innerError; - } - - final yamlMap = error.map as YamlMap; - var yamlNode = yamlMap.nodes[error.key]; - - String message; - if (yamlNode == null) { - assert(error.message != null); - message = error.message; - yamlNode = yamlMap; - } else { - if (error.message == null) { - message = 'Unsupported value for `${error.key}`.'; - } else { - message = error.message.toString(); - } - } - - return ParsedYamlException._(message, yamlNode, - innerError: error, innerStack: stack); -} - -/// Thrown when parsing a YAML document fails. -class ParsedYamlException implements Exception { - /// Describes the nature of the parse failure. - final String message; - - final YamlNode yamlNode; - - /// If this exception was thrown as a result of another error, - /// contains the source error object. - final Object innerError; - - /// If this exception was thrown as a result of another error, - /// contains the corresponding [StackTrace]. - final StackTrace innerStack; - - ParsedYamlException._(this.message, this.yamlNode, - {this.innerError, this.innerStack}); - - /// Returns [message] formatted with source information provided by - /// [yamlNode]. - String get formattedMessage => yamlNode.span.message(message); - - @override - String toString() => message; -} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index a8dacf68d..d31e65773 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -4,10 +4,9 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; -import 'package:yaml/yaml.dart'; +import 'package:checked_yaml/checked_yaml.dart'; import 'dependency.dart'; -import 'errors.dart'; part 'pubspec.g.dart'; @@ -108,7 +107,7 @@ class Pubspec { try { final targetUri = Uri.parse(publishTo); if (!(targetUri.isScheme('http') || targetUri.isScheme('https'))) { - throw const FormatException('must be an http or https URL.'); + throw const FormatException('Must be an http or https URL.'); } } on FormatException catch (e) { throw ArgumentError.value(publishTo, 'publishTo', e.message); @@ -144,25 +143,9 @@ class Pubspec { factory Pubspec.parse(String yaml, {sourceUrl, bool lenient = false}) { lenient ??= false; - final item = loadYaml(yaml, sourceUrl: sourceUrl); - - if (item == null) { - throw ArgumentError.notNull('yaml'); - } - - if (item is! YamlMap) { - if (item is YamlNode) { - throw parsedYamlException('Does not represent a YAML map.', item); - } - - throw ArgumentError.value(yaml, 'yaml', 'Does not represent a YAML map.'); - } - - try { - return Pubspec.fromJson(item as YamlMap, lenient: lenient); - } on CheckedFromJsonException catch (error, stack) { - throw parsedYamlExceptionFromError(error, stack); - } + return checkedYamlDecode( + yaml, (map) => Pubspec.fromJson(map, lenient: lenient), + sourceUrl: sourceUrl); } static List _normalizeAuthors(String author, List authors) { @@ -185,7 +168,13 @@ Map _environmentMap(Map source) => if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! - throw UnrecognizedKeysException(['dart'], source, ['sdk']); + throw CheckedFromJsonException( + source, + 'dart', + 'VersionConstraint', + 'Use "sdk" to for Dart SDK constraints.', + badKey: true, + ); } VersionConstraint constraint; diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index c1df008a9..2ae7fb28f 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -10,6 +10,7 @@ environment: sdk: '>=2.2.0 <3.0.0' dependencies: + checked_yaml: ^1.0.0 # Verified that no new features since 1.0.0 are used - be careful! json_annotation: '>=1.0.0 <3.0.0' pub_semver: ^1.3.2 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 9e9099731..948010558 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -18,32 +18,41 @@ void main() { group('errors', () { test('List', () { - _expectThrows([], r''' -line 4, column 10: Not a valid dependency value. + _expectThrows( + [], + r''' +line 4, column 10: Unsupported value for "dep". Not a valid dependency value. ╷ 4 │ "dep": [] │ ^^ - ╵'''); + ╵''', + ); }); test('int', () { - _expectThrows(42, r''' -line 4, column 10: Not a valid dependency value. + _expectThrows( + 42, + r''' +line 4, column 10: Unsupported value for "dep". Not a valid dependency value. ╷ 4 │ "dep": 42 │ ┌──────────^ 5 │ │ } │ └─^ - ╵'''); + ╵''', + ); }); test('map with too many keys', () { - _expectThrows({'path': 'a', 'git': 'b'}, r''' -line 5, column 12: A dependency may only have one source. + _expectThrows( + {'path': 'a', 'git': 'b'}, + r''' +line 5, column 12: Unsupported value for "path". A dependency may only have one source. ╷ 5 │ "path": "a", │ ^^^ - ╵'''); + ╵''', + ); }); test('map with unsupported keys', () { @@ -79,12 +88,15 @@ void _hostedDependency() { }); test('bad string version', () { - _expectThrows('not a version', r''' -line 4, column 10: Could not parse version "not a version". Unknown text at "not a version". + _expectThrows( + 'not a version', + r''' +line 4, column 10: Unsupported value for "dep". Could not parse version "not a version". Unknown text at "not a version". ╷ 4 │ "dep": "not a version" │ ^^^^^^^^^^^^^^^ - ╵'''); + ╵''', + ); }); test('map w/ just version', () { @@ -106,15 +118,18 @@ line 4, column 10: Could not parse version "not a version". Unknown text at "not }); test('map w/ bad version value', () { - _expectThrows({ - 'version': 'not a version', - 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} - }, r''' -line 5, column 15: Could not parse version "not a version". Unknown text at "not a version". + _expectThrows( + { + 'version': 'not a version', + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} + }, + r''' +line 5, column 15: Unsupported value for "version". Could not parse version "not a version". Unknown text at "not a version". ╷ 5 │ "version": "not a version", │ ^^^^^^^^^^^^^^^ - ╵'''); + ╵''', + ); }); test('map w/ extra keys should fail', () { @@ -148,14 +163,15 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git }); test('map w/ null hosted should error', () { - _expectThrows({'hosted': null}, r''' -line 5, column 14: These keys had `null` values, which is not allowed: [hosted] + _expectThrows( + {'hosted': null}, + r''' +line 5, column 4: These keys had `null` values, which is not allowed: [hosted] ╷ -5 │ "hosted": null - │ ┌──────────────^ -6 │ │ } - │ └──^ - ╵'''); +5 │ "hosted": null + │ ^^^^^^^^ + ╵''', + ); }); test('map w/ null version is fine', () { @@ -183,25 +199,29 @@ void _sdkDependency() { }); test('null content', () { - _expectThrows({'sdk': null}, r''' -line 5, column 11: These keys had `null` values, which is not allowed: [sdk] + _expectThrows( + {'sdk': null}, + r''' +line 5, column 4: These keys had `null` values, which is not allowed: [sdk] ╷ -5 │ "sdk": null - │ ┌───────────^ -6 │ │ } - │ └──^ - ╵'''); +5 │ "sdk": null + │ ^^^^^ + ╵''', + ); }); test('number content', () { - _expectThrows({'sdk': 42}, r''' -line 5, column 11: Unsupported value for `sdk`. + _expectThrows( + {'sdk': 42}, + r''' +line 5, column 11: Unsupported value for "sdk". ╷ 5 │ "sdk": 42 │ ┌───────────^ 6 │ │ } │ └──^ - ╵'''); + ╵''', + ); }); } @@ -256,25 +276,31 @@ line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos }); test('git - null content', () { - _expectThrows({'git': null}, r''' -line 5, column 11: Must be a String or a Map. + _expectThrows( + {'git': null}, + r''' +line 5, column 11: Unsupported value for "git". Must be a String or a Map. ╷ 5 │ "git": null │ ┌───────────^ 6 │ │ } │ └──^ - ╵'''); + ╵''', + ); }); test('git - int content', () { - _expectThrows({'git': 42}, r''' -line 5, column 11: Must be a String or a Map. + _expectThrows( + {'git': 42}, + r''' +line 5, column 11: Unsupported value for "git". Must be a String or a Map. ╷ 5 │ "git": 42 │ ┌───────────^ 6 │ │ } │ └──^ - ╵'''); + ╵''', + ); }); test('git - empty map', () { @@ -287,29 +313,33 @@ line 5, column 11: Required keys are missing: url. }); test('git - null url', () { - _expectThrows({ - 'git': {'url': null} - }, r''' -line 6, column 12: These keys had `null` values, which is not allowed: [url] + _expectThrows( + { + 'git': {'url': null} + }, + r''' +line 6, column 5: These keys had `null` values, which is not allowed: [url] ╷ -6 │ "url": null - │ ┌────────────^ -7 │ │ } - │ └───^ - ╵'''); +6 │ "url": null + │ ^^^^^ + ╵''', + ); }); test('git - int url', () { - _expectThrows({ - 'git': {'url': 42} - }, r''' -line 6, column 12: Unsupported value for `url`. + _expectThrows( + { + 'git': {'url': 42} + }, + r''' +line 6, column 12: Unsupported value for "url". ╷ 6 │ "url": 42 │ ┌────────────^ 7 │ │ } │ └───^ - ╵'''); + ╵''', + ); }); } @@ -337,25 +367,31 @@ line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos }); test('null content', () { - _expectThrows({'path': null}, r''' -line 5, column 12: Must be a String. + _expectThrows( + {'path': null}, + r''' +line 5, column 12: Unsupported value for "path". Must be a String. ╷ 5 │ "path": null │ ┌────────────^ 6 │ │ } │ └──^ - ╵'''); + ╵''', + ); }); test('int content', () { - _expectThrows({'path': 42}, r''' -line 5, column 12: Must be a String. + _expectThrows( + {'path': 42}, + r''' +line 5, column 12: Unsupported value for "path". Must be a String. ╷ 5 │ "path": 42 │ ┌────────────^ 6 │ │ } │ └──^ - ╵'''); + ╵''', + ); }); } diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 3c79d87f2..ca822e7fa 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -75,29 +75,29 @@ void main() { group('publish_to', () { for (var entry in { 42: r''' -line 3, column 16: Unsupported value for `publish_to`. +line 3, column 16: Unsupported value for "publish_to". ╷ 3 │ "publish_to": 42 │ ^^ ╵''', '##not a uri!': r''' -line 3, column 16: must be an http or https URL. +line 3, column 16: Unsupported value for "publish_to". Must be an http or https URL. ╷ 3 │ "publish_to": "##not a uri!" │ ^^^^^^^^^^^^^^ ╵''', '/cool/beans': r''' -line 3, column 16: must be an http or https URL. +line 3, column 16: Unsupported value for "publish_to". Must be an http or https URL. ╷ 3 │ "publish_to": "/cool/beans" │ ^^^^^^^^^^^^^ ╵''', 'file:///Users/kevmoo/': r''' -line 3, column 16: must be an http or https URL. +line 3, column 16: Unsupported value for "publish_to". Must be an http or https URL. ╷ 3 │ "publish_to": "file:///Users/kevmoo/" │ ^^^^^^^^^^^^^^^^^^^^^^^ - ╵''' + ╵''', }.entries) { test('cannot be `${entry.key}`', () { expectParseThrows( @@ -182,14 +182,30 @@ line 3, column 16: must be an http or https URL. group('invalid', () { test('null', () { - expect(() => parse(null), throwsArgumentError); + expectParseThrows( + null, + r''' +line 1, column 1: Not a map + ╷ +1 │ null + │ ^^^^ + ╵''', + ); }); test('empty string', () { - expect(() => parse(''), throwsArgumentError); + expectParseThrows( + '', + r''' +line 1, column 1: Not a map + ╷ +1 │ "" + │ ^^ + ╵''', + ); }); test('array', () { expectParseThrows([], r''' -line 1, column 1: Does not represent a YAML map. +line 1, column 1: Not a map ╷ 1 │ [] │ ^^ @@ -210,7 +226,7 @@ line 1, column 1: "name" cannot be empty. 'name': 'sample', 'environment': {'dart': 'cool'} }, r''' -line 4, column 3: Unrecognized keys: [dart]; supported keys: [sdk] +line 4, column 3: Use "sdk" to for Dart SDK constraints. ╷ 4 │ "dart": "cool" │ ^^^^^^ @@ -218,26 +234,32 @@ line 4, column 3: Unrecognized keys: [dart]; supported keys: [sdk] }); test('environment values cannot be int', () { - expectParseThrows({ - 'name': 'sample', - 'environment': {'sdk': 42} - }, r''' -line 4, column 10: `42` is not a String. + expectParseThrows( + { + 'name': 'sample', + 'environment': {'sdk': 42} + }, + r''' +line 4, column 10: Unsupported value for "sdk". `42` is not a String. ╷ 4 │ "sdk": 42 │ ┌──────────^ 5 │ │ } │ └─^ - ╵'''); + ╵''', + ); }); test('version', () { - expectParseThrows({'name': 'sample', 'version': 'invalid'}, r''' -line 3, column 13: Could not parse "invalid". + expectParseThrows( + {'name': 'sample', 'version': 'invalid'}, + r''' +line 3, column 13: Unsupported value for "version". Could not parse "invalid". ╷ 3 │ "version": "invalid" │ ^^^^^^^^^ - ╵'''); + ╵''', + ); }); test('invalid environment value', () { @@ -245,7 +267,7 @@ line 3, column 13: Could not parse "invalid". 'name': 'sample', 'environment': {'sdk': 'silly'} }, r''' -line 4, column 10: Could not parse version "silly". Unknown text at "silly". +line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". Unknown text at "silly". ╷ 4 │ "sdk": "silly" │ ^^^^^^^ @@ -253,45 +275,80 @@ line 4, column 10: Could not parse version "silly". Unknown text at "silly". }); test('bad repository url', () { - expectParseThrows({ - 'name': 'foo', - 'repository': {'x': 'y'}, - }, r''' -line 3, column 16: Unsupported value for `repository`. + expectParseThrows( + { + 'name': 'foo', + 'repository': {'x': 'y'}, + }, + r''' +line 3, column 16: Unsupported value for "repository". ╷ 3 │ "repository": { │ ┌────────────────^ 4 │ │ "x": "y" 5 │ └ } - ╵''', skipTryPub: true); + ╵''', + skipTryPub: true, + ); }); test('bad issue_tracker url', () { - expectParseThrows({ - 'name': 'foo', - 'issue_tracker': {'x': 'y'}, - }, r''' -line 3, column 19: Unsupported value for `issue_tracker`. + expectParseThrows( + { + 'name': 'foo', + 'issue_tracker': {'x': 'y'}, + }, + r''' +line 3, column 19: Unsupported value for "issue_tracker". ╷ 3 │ "issue_tracker": { │ ┌───────────────────^ 4 │ │ "x": "y" 5 │ └ } - ╵''', skipTryPub: true); + ╵''', + skipTryPub: true, + ); }); }); group('lenient', () { test('null', () { - expect(() => parse(null, lenient: true), throwsArgumentError); + expectParseThrows( + null, + r''' +line 1, column 1: Not a map + ╷ +1 │ null + │ ^^^^ + ╵''', + lenient: true, + ); }); test('empty string', () { - expect(() => parse('', lenient: true), throwsArgumentError); + expectParseThrows( + '', + r''' +line 1, column 1: Not a map + ╷ +1 │ "" + │ ^^ + ╵''', + lenient: true, + ); }); test('name cannot be empty', () { - expect(() => parse({}, lenient: true), throwsException); + expectParseThrows( + {}, + r''' +line 1, column 1: "name" cannot be empty. + ╷ +1 │ {} + │ ^^ + ╵''', + lenient: true, + ); }); test('bad repository url', () { diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 7f8ae87ae..b61cdbd6a 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -5,6 +5,7 @@ import 'dart:cli'; import 'dart:convert'; +import 'package:checked_yaml/checked_yaml.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:stack_trace/stack_trace.dart'; @@ -25,10 +26,11 @@ Matcher _throwsParsedYamlException(String prettyValue) => void _printDebugParsedYamlException(ParsedYamlException e) { var innerError = e.innerError; - var innerStack = e.innerStack; + StackTrace innerStack; + + if (innerError is CheckedFromJsonException) { + final cfje = innerError as CheckedFromJsonException; - if (e.innerError is CheckedFromJsonException) { - final cfje = e.innerError as CheckedFromJsonException; if (cfje.innerError != null) { innerError = cfje.innerError; innerStack = cfje.innerStack; @@ -98,6 +100,14 @@ void expectParseThrows( Object content, String expectedError, { bool skipTryPub = false, + bool lenient = false, }) => - expect(() => parse(content, quietOnError: true, skipTryPub: skipTryPub), - _throwsParsedYamlException(expectedError)); + expect( + () => parse( + content, + lenient: lenient, + quietOnError: true, + skipTryPub: skipTryPub, + ), + _throwsParsedYamlException(expectedError), + ); From e4cc83d61f14c0fc9f85bfdb9ada3e227158e9e8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 10 May 2019 15:53:38 -0700 Subject: [PATCH 060/152] Work-around dart-lang/linterdart-lang/pubspec_parse#1393 Fix is in https://github.com/dart-lang/sdk/commit/dac5a56422 Need it to get into a shipped SDK --- pkgs/pubspec_parse/test/parse_test.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index ca822e7fa..75c3f83e8 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -2,6 +2,11 @@ // 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. +// TODO(kevmoo) Remove when github.com/dart-lang/sdk/commit/dac5a56422 lands +// in a shipped SDK. +// ignore_for_file: deprecated_member_use +library parse_test; + import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; From 38e75a22be4d0c3558fbc5a2e649b8150917879d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 10 May 2019 16:18:26 -0700 Subject: [PATCH 061/152] fix debugging tests --- pkgs/pubspec_parse/test/pub_utils.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index 1ebb9c7ca..17e8970f7 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -13,8 +13,13 @@ import 'package:test_process/test_process.dart'; Future tryPub(String content) async { await d.file('pubspec.yaml', content).create(); - final proc = await TestProcess.start(_pubPath, ['get', '--offline'], - workingDirectory: d.sandbox); + final proc = await TestProcess.start( + _pubPath, + ['get', '--offline'], + workingDirectory: d.sandbox, + // Don't pass current process VM options to child + environment: Map.from(Platform.environment)..remove('DART_VM_OPTIONS'), + ); final result = await ProcResult.fromTestProcess(proc); From 6315549d42a51be2df6134653e787b5a0a39ca7e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 10 May 2019 16:19:51 -0700 Subject: [PATCH 062/152] migrate to json_serializable v3 --- pkgs/pubspec_parse/lib/src/dependency.dart | 5 +++-- pkgs/pubspec_parse/lib/src/dependency.g.dart | 17 +++++++---------- pkgs/pubspec_parse/lib/src/pubspec.dart | 7 ++++--- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 8 ++++---- pkgs/pubspec_parse/pubspec.yaml | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index e2b07702d..2d4eda696 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -128,7 +128,8 @@ class GitDependency extends Dependency { String get _info => 'url@$url'; } -Uri parseGitUri(String value) => _tryParseScpUri(value) ?? Uri.parse(value); +Uri parseGitUri(String value) => + value == null ? null : _tryParseScpUri(value) ?? Uri.parse(value); /// Supports URIs like `[user@]host.xz:path/to/repo.git/` /// See https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a @@ -217,4 +218,4 @@ class HostedDetails { } VersionConstraint _constraintFromString(String input) => - VersionConstraint.parse(input); + input == null ? null : VersionConstraint.parse(input); diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 243a5b3d1..534c03a6b 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -11,8 +11,8 @@ SdkDependency _$SdkDependencyFromJson(Map json) { $checkKeys(json, requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); final val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), - version: $checkedConvert(json, 'version', - (v) => v == null ? null : _constraintFromString(v as String))); + version: $checkedConvert( + json, 'version', (v) => _constraintFromString(v as String))); return val; }); } @@ -22,8 +22,7 @@ GitDependency _$GitDependencyFromJson(Map json) { $checkKeys(json, requiredKeys: const ['url'], disallowNullValues: const ['url']); final val = GitDependency( - $checkedConvert( - json, 'url', (v) => v == null ? null : parseGitUri(v as String)), + $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), $checkedConvert(json, 'ref', (v) => v as String), $checkedConvert(json, 'path', (v) => v as String)); return val; @@ -36,8 +35,8 @@ HostedDependency _$HostedDependencyFromJson(Map json) { allowedKeys: const ['version', 'hosted'], disallowNullValues: const ['hosted']); final val = HostedDependency( - version: $checkedConvert(json, 'version', - (v) => v == null ? null : _constraintFromString(v as String)), + version: $checkedConvert( + json, 'version', (v) => _constraintFromString(v as String)), hosted: $checkedConvert(json, 'hosted', (v) => v == null ? null : HostedDetails.fromJson(v))); return val; @@ -50,10 +49,8 @@ HostedDetails _$HostedDetailsFromJson(Map json) { allowedKeys: const ['name', 'url'], requiredKeys: const ['name'], disallowNullValues: const ['name', 'url']); - final val = HostedDetails( - $checkedConvert(json, 'name', (v) => v as String), - $checkedConvert( - json, 'url', (v) => v == null ? null : parseGitUri(v as String))); + final val = HostedDetails($checkedConvert(json, 'name', (v) => v as String), + $checkedConvert(json, 'url', (v) => parseGitUri(v as String))); return val; }); } diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index d31e65773..735838907 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -2,9 +2,9 @@ // 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:checked_yaml/checked_yaml.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; -import 'package:checked_yaml/checked_yaml.dart'; import 'dependency.dart'; @@ -160,10 +160,11 @@ class Pubspec { } } -Version _versionFromString(String input) => Version.parse(input); +Version _versionFromString(String input) => + input == null ? null : Version.parse(input); Map _environmentMap(Map source) => - source.map((k, value) { + source?.map((k, value) { final key = k as String; if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index ba7e6ebf1..d3e18f744 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -9,14 +9,14 @@ part of 'pubspec.dart'; Pubspec _$PubspecFromJson(Map json) { return $checkedNew('Pubspec', json, () { final val = Pubspec($checkedConvert(json, 'name', (v) => v as String), - version: $checkedConvert(json, 'version', - (v) => v == null ? null : _versionFromString(v as String)), + version: $checkedConvert( + json, 'version', (v) => _versionFromString(v as String)), publishTo: $checkedConvert(json, 'publish_to', (v) => v as String), author: $checkedConvert(json, 'author', (v) => v as String), authors: $checkedConvert(json, 'authors', (v) => (v as List)?.map((e) => e as String)?.toList()), - environment: $checkedConvert(json, 'environment', - (v) => v == null ? null : _environmentMap(v as Map)), + environment: $checkedConvert( + json, 'environment', (v) => _environmentMap(v as Map)), homepage: $checkedConvert(json, 'homepage', (v) => v as String), repository: $checkedConvert(json, 'repository', (v) => v == null ? null : Uri.parse(v as String)), diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 2ae7fb28f..39e627cc2 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: build_runner: ^1.0.0 build_verify: ^1.0.0 - json_serializable: ^2.0.0 + json_serializable: ^3.0.0 path: ^1.5.1 pedantic: ^1.4.0 stack_trace: ^1.9.2 From 41ab62292d63c58913cd694f940975dca2a693ae Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 13 Jun 2019 16:22:23 -0700 Subject: [PATCH 063/152] dartfmt, only test dartfmt on dev (dart-lang/pubspec_parse#50) Run tests on 2.2.0 --- pkgs/pubspec_parse/.travis.yml | 5 ++++- pkgs/pubspec_parse/test/test_utils.dart | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index 536ccee72..ccb1cafa5 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -1,15 +1,18 @@ language: dart dart: + - 2.2.0 - dev dart_task: - test: -x presubmit-only - test: --run-skipped -t presubmit-only - - dartfmt matrix: include: + # Only validate formatting using the dev release + - dart: dev + dart_task: dartfmt - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index b61cdbd6a..00196bb11 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -104,10 +104,10 @@ void expectParseThrows( }) => expect( () => parse( - content, - lenient: lenient, - quietOnError: true, - skipTryPub: skipTryPub, - ), + content, + lenient: lenient, + quietOnError: true, + skipTryPub: skipTryPub, + ), _throwsParsedYamlException(expectedError), ); From 85941fc296cb287862ac659261eeb8ea27633189 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 26 Jul 2019 18:36:41 -0700 Subject: [PATCH 064/152] regenerate code (dart-lang/pubspec_parse#51) --- pkgs/pubspec_parse/lib/src/dependency.g.dart | 30 ++++++---- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 59 ++++++++++---------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 534c03a6b..4e137fad7 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -10,9 +10,11 @@ SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { $checkKeys(json, requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); - final val = SdkDependency($checkedConvert(json, 'sdk', (v) => v as String), - version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String))); + final val = SdkDependency( + $checkedConvert(json, 'sdk', (v) => v as String), + version: $checkedConvert( + json, 'version', (v) => _constraintFromString(v as String)), + ); return val; }); } @@ -22,9 +24,10 @@ GitDependency _$GitDependencyFromJson(Map json) { $checkKeys(json, requiredKeys: const ['url'], disallowNullValues: const ['url']); final val = GitDependency( - $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), - $checkedConvert(json, 'ref', (v) => v as String), - $checkedConvert(json, 'path', (v) => v as String)); + $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), + $checkedConvert(json, 'ref', (v) => v as String), + $checkedConvert(json, 'path', (v) => v as String), + ); return val; }); } @@ -35,10 +38,11 @@ HostedDependency _$HostedDependencyFromJson(Map json) { allowedKeys: const ['version', 'hosted'], disallowNullValues: const ['hosted']); final val = HostedDependency( - version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String)), - hosted: $checkedConvert(json, 'hosted', - (v) => v == null ? null : HostedDetails.fromJson(v))); + version: $checkedConvert( + json, 'version', (v) => _constraintFromString(v as String)), + hosted: $checkedConvert( + json, 'hosted', (v) => v == null ? null : HostedDetails.fromJson(v)), + ); return val; }); } @@ -49,8 +53,10 @@ HostedDetails _$HostedDetailsFromJson(Map json) { allowedKeys: const ['name', 'url'], requiredKeys: const ['name'], disallowNullValues: const ['name', 'url']); - final val = HostedDetails($checkedConvert(json, 'name', (v) => v as String), - $checkedConvert(json, 'url', (v) => parseGitUri(v as String))); + final val = HostedDetails( + $checkedConvert(json, 'name', (v) => v as String), + $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), + ); return val; }); } diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index d3e18f744..eb062b8fd 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -8,35 +8,36 @@ part of 'pubspec.dart'; Pubspec _$PubspecFromJson(Map json) { return $checkedNew('Pubspec', json, () { - final val = Pubspec($checkedConvert(json, 'name', (v) => v as String), - version: $checkedConvert( - json, 'version', (v) => _versionFromString(v as String)), - publishTo: $checkedConvert(json, 'publish_to', (v) => v as String), - author: $checkedConvert(json, 'author', (v) => v as String), - authors: $checkedConvert(json, 'authors', - (v) => (v as List)?.map((e) => e as String)?.toList()), - environment: $checkedConvert( - json, 'environment', (v) => _environmentMap(v as Map)), - homepage: $checkedConvert(json, 'homepage', (v) => v as String), - repository: $checkedConvert(json, 'repository', - (v) => v == null ? null : Uri.parse(v as String)), - issueTracker: $checkedConvert(json, 'issue_tracker', - (v) => v == null ? null : Uri.parse(v as String)), - documentation: - $checkedConvert(json, 'documentation', (v) => v as String), - description: $checkedConvert(json, 'description', (v) => v as String), - dependencies: - $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map)), - devDependencies: $checkedConvert( - json, 'dev_dependencies', (v) => parseDeps(v as Map)), - dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => parseDeps(v as Map)), - flutter: $checkedConvert( - json, - 'flutter', - (v) => (v as Map)?.map( - (k, e) => MapEntry(k as String, e), - ))); + final val = Pubspec( + $checkedConvert(json, 'name', (v) => v as String), + version: $checkedConvert( + json, 'version', (v) => _versionFromString(v as String)), + publishTo: $checkedConvert(json, 'publish_to', (v) => v as String), + author: $checkedConvert(json, 'author', (v) => v as String), + authors: $checkedConvert(json, 'authors', + (v) => (v as List)?.map((e) => e as String)?.toList()), + environment: $checkedConvert( + json, 'environment', (v) => _environmentMap(v as Map)), + homepage: $checkedConvert(json, 'homepage', (v) => v as String), + repository: $checkedConvert( + json, 'repository', (v) => v == null ? null : Uri.parse(v as String)), + issueTracker: $checkedConvert(json, 'issue_tracker', + (v) => v == null ? null : Uri.parse(v as String)), + documentation: $checkedConvert(json, 'documentation', (v) => v as String), + description: $checkedConvert(json, 'description', (v) => v as String), + dependencies: + $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map)), + devDependencies: + $checkedConvert(json, 'dev_dependencies', (v) => parseDeps(v as Map)), + dependencyOverrides: $checkedConvert( + json, 'dependency_overrides', (v) => parseDeps(v as Map)), + flutter: $checkedConvert( + json, + 'flutter', + (v) => (v as Map)?.map( + (k, e) => MapEntry(k as String, e), + )), + ); return val; }, fieldKeyMap: const { 'publishTo': 'publish_to', From b2e43593d01b965afade8081f40cfae2fe198a37 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 7 Aug 2019 17:16:47 -0700 Subject: [PATCH 065/152] Prepare for release (dart-lang/pubspec_parse#52) --- pkgs/pubspec_parse/CHANGELOG.md | 1 + pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 1f62e3afd..f2c254244 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.1.5 - Update SDK requirement to `>=2.2.0 <3.0.0`. +- Support the latest `package:json_annotation`. ## 0.1.4 diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 39e627cc2..fc54d1240 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.5-dev +version: 0.1.5 homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team @@ -12,7 +12,7 @@ environment: dependencies: checked_yaml: ^1.0.0 # Verified that no new features since 1.0.0 are used - be careful! - json_annotation: '>=1.0.0 <3.0.0' + json_annotation: '>=1.0.0 <4.0.0' pub_semver: ^1.3.2 yaml: ^2.1.12 From 3b0884964297a7c9845f7a0b64090e8ff857e964 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 24 Sep 2019 09:10:53 -0700 Subject: [PATCH 066/152] fix tests w/ latest pkg:yaml (dart-lang/pubspec_parse#53) --- pkgs/pubspec_parse/test/dependency_test.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 948010558..d3bf3ad70 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -47,20 +47,20 @@ line 4, column 10: Unsupported value for "dep". Not a valid dependency value. _expectThrows( {'path': 'a', 'git': 'b'}, r''' -line 5, column 12: Unsupported value for "path". A dependency may only have one source. +line 6, column 11: Unsupported value for "git". A dependency may only have one source. ╷ -5 │ "path": "a", - │ ^^^ +6 │ "git": "b" + │ ^^^ ╵''', ); }); test('map with unsupported keys', () { _expectThrows({'bob': 'a', 'jones': 'b'}, r''' -line 6, column 4: Unrecognized keys: [jones]; supported keys: [sdk, git, path, hosted] +line 5, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ -6 │ "jones": "b" - │ ^^^^^^^ +5 │ "bob": "a", + │ ^^^^^ ╵'''); }); }); From 10ef1f6b2eb0d880c3dbcce935b6325094659d53 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 16 Jan 2020 17:42:54 -0800 Subject: [PATCH 067/152] Fix test related to latest version of source_span (dart-lang/pubspec_parse#55) Bump min SDK to ensure tested SDKs support latest source_span Cleanup analysis_options.yaml --- pkgs/pubspec_parse/.travis.yml | 4 ++-- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/analysis_options.yaml | 8 ++------ pkgs/pubspec_parse/pubspec.yaml | 4 ++-- pkgs/pubspec_parse/test/dependency_test.dart | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index ccb1cafa5..66bff3db8 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -1,7 +1,7 @@ language: dart dart: - - 2.2.0 + - 2.6.0 - dev dart_task: @@ -16,7 +16,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.2.0 + - dart: 2.6.0 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index f2c254244..df5c0e827 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.6-dev + +- Update SDK requirement to `>=2.6.0 <3.0.0`. + ## 0.1.5 - Update SDK requirement to `>=2.2.0 <3.0.0`. diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index f983bb3b8..649460aea 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -1,13 +1,9 @@ include: package:pedantic/analysis_options.yaml + analyzer: strong-mode: implicit-casts: false - errors: - dead_code: error - override_on_non_overriding_method: error - unused_element: error - unused_import: error - unused_local_variable: error + linter: rules: - always_declare_return_types diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index fc54d1240..785630507 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,12 +2,12 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.5 +version: 0.1.6-dev homepage: https://github.com/dart-lang/pubspec_parse author: Dart Team environment: - sdk: '>=2.2.0 <3.0.0' + sdk: '>=2.6.0 <3.0.0' dependencies: checked_yaml: ^1.0.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index d3bf3ad70..35ac6b67c 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -139,10 +139,10 @@ line 5, column 15: Unsupported value for "version". Could not parse version "not 'not_supported': null }, r''' line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git, path, hosted] - ╷ -10│ "not_supported": null - │ ^^^^^^^^^^^^^^^ - ╵'''); + ╷ +10 │ "not_supported": null + │ ^^^^^^^^^^^^^^^ + ╵'''); }); test('map w/ version and hosted as String', () { From f07261f56eb001a7e9d82fe293b8ffd17a002d55 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 14 Feb 2020 09:27:43 -0800 Subject: [PATCH 068/152] Remove redundant pedantic lints --- pkgs/pubspec_parse/analysis_options.yaml | 37 ------------------------ 1 file changed, 37 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 649460aea..92e1bec21 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -6,24 +6,15 @@ analyzer: linter: rules: - - always_declare_return_types - - annotate_overrides - avoid_bool_literals_in_conditional_expressions - avoid_classes_with_only_static_members - - avoid_empty_else - avoid_function_literals_in_foreach_calls - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_relative_lib_imports - avoid_renaming_method_parameters - - avoid_return_types_on_setters - avoid_returning_null - avoid_returning_null_for_future - avoid_returning_null_for_void - avoid_returning_this - - avoid_shadowing_type_parameters - avoid_single_cascade_in_expression_statements - - avoid_types_as_parameter_names - avoid_unused_constructor_parameters - await_only_futures - camel_case_types @@ -33,8 +24,6 @@ linter: - constant_identifier_names - control_flow_in_finally - directives_ordering - - empty_catches - - empty_constructor_bodies - empty_statements - file_names - hash_and_equals @@ -42,54 +31,28 @@ linter: - invariant_booleans - iterable_contains_unrelated_type - join_return_with_assignment - - library_names - - library_prefixes - list_remove_unrelated_type - literal_only_boolean_expressions - no_adjacent_strings_in_list - - no_duplicate_case_values - non_constant_identifier_names - - null_closures - - omit_local_variable_types - only_throw_errors - overridden_fields - package_api_docs - package_names - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - prefer_const_constructors - - prefer_contains - - prefer_equal_for_default_values - - prefer_final_fields - prefer_final_locals - - prefer_generic_function_type_aliases - prefer_initializing_formals - prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - prefer_null_aware_operators - - prefer_single_quotes - prefer_typing_uninitialized_variables - - recursive_getters - - slash_for_doc_comments - test_types_in_equals - throw_in_finally - - type_init_formals - - unawaited_futures - unnecessary_await_in_return - unnecessary_brace_in_string_interps - - unnecessary_const - unnecessary_getters_setters - unnecessary_lambdas - - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_parenthesis - unnecessary_statements - - unnecessary_this - - unrelated_type_equality_checks - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - valid_regexps - void_checks From 7f9401085be8999350c9d0b87826e20e175809d1 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 14 Feb 2020 09:29:55 -0800 Subject: [PATCH 069/152] enable some useful lints --- pkgs/pubspec_parse/analysis_options.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 92e1bec21..581ed8a2f 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -7,8 +7,11 @@ analyzer: linter: rules: - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors - avoid_classes_with_only_static_members - avoid_function_literals_in_foreach_calls + - avoid_private_typedef_functions + - avoid_redundant_argument_values - avoid_renaming_method_parameters - avoid_returning_null - avoid_returning_null_for_future @@ -16,6 +19,7 @@ linter: - avoid_returning_this - avoid_single_cascade_in_expression_statements - avoid_unused_constructor_parameters + - avoid_void_async - await_only_futures - camel_case_types - cancel_subscriptions @@ -31,21 +35,34 @@ linter: - invariant_booleans - iterable_contains_unrelated_type - join_return_with_assignment + - lines_longer_than_80_chars - list_remove_unrelated_type - literal_only_boolean_expressions + - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list + - no_runtimeType_toString - non_constant_identifier_names - only_throw_errors - overridden_fields - package_api_docs - package_names - package_prefixed_library_names + - prefer_asserts_in_initializer_lists - prefer_const_constructors + - prefer_const_declarations + # Need to update json_serializable to generate an ignore for this lint + #- prefer_expression_function_bodies - prefer_final_locals + - prefer_function_declarations_over_variables - prefer_initializing_formals + - prefer_inlined_adds - prefer_interpolation_to_compose_strings + - prefer_is_not_operator - prefer_null_aware_operators + - prefer_relative_imports - prefer_typing_uninitialized_variables + - prefer_void_to_null + - sort_pub_dependencies - test_types_in_equals - throw_in_finally - unnecessary_await_in_return @@ -53,6 +70,8 @@ linter: - unnecessary_getters_setters - unnecessary_lambdas - unnecessary_null_aware_assignments + - unnecessary_overrides - unnecessary_parenthesis - unnecessary_statements + - unnecessary_string_interpolations - void_checks From 61232120b8a95e005343aa885a0cd621f879831e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 26 Feb 2020 08:50:15 -0800 Subject: [PATCH 070/152] Fix URLs throughout the package (dart-lang/pubspec_parse#58) --- pkgs/pubspec_parse/README.md | 10 ++-------- pkgs/pubspec_parse/build.yaml | 2 +- pkgs/pubspec_parse/lib/src/pubspec.dart | 4 +--- pkgs/pubspec_parse/pubspec.yaml | 1 - 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index a95459c6f..7287d5f4e 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,13 +1,7 @@ [![Build Status](https://travis-ci.org/dart-lang/pubspec_parse.svg?branch=master)](https://travis-ci.org/dart-lang/pubspec_parse) +[![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/pubspec_parse) Supports parsing `pubspec.yaml` files with robust error reporting and support for most of the documented features. -Read more about the -[pubspec format](https://www.dartlang.org/tools/pub/pubspec). - -## Features and bugs - -Please file feature requests and bugs at the [issue tracker]. - -[issue tracker]: https://github.com/dart-lang/pubspec_parse/issues +Read more about the [pubspec format](https://dart.dev/tools/pub/pubspec). diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 1525ab832..874c975da 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -1,4 +1,4 @@ -# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config +# Read about `build.yaml` at https://pub.dev/packages/build_config # To update generated code, run `pub run build_runner build` targets: $default: diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 735838907..e3dbac14f 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -28,9 +28,7 @@ class Pubspec { /// /// Accepted values: `null`, `'none'` or an `http` or `https` URL. /// - /// If not specified, the pub client defaults to `https://pub.dartlang.org`. - /// - /// [More information](https://www.dartlang.org/tools/pub/pubspec#publish_to). + /// [More information](https://dart.dev/tools/pub/pubspec#publish_to). final String publishTo; /// Optional field to specify the source code repository of the package. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 785630507..a148e7f69 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -4,7 +4,6 @@ description: >- error reporting. version: 0.1.6-dev homepage: https://github.com/dart-lang/pubspec_parse -author: Dart Team environment: sdk: '>=2.6.0 <3.0.0' From 1683d54e5ca4399df9919dc2b6eb2a4a338ac2b5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 26 Feb 2020 09:01:10 -0800 Subject: [PATCH 071/152] Enable and some lints (dart-lang/pubspec_parse#57) Ignored violations in generated code --- pkgs/pubspec_parse/analysis_options.yaml | 5 +++-- pkgs/pubspec_parse/build.yaml | 7 +++++++ pkgs/pubspec_parse/lib/src/dependency.g.dart | 2 ++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 ++ pkgs/pubspec_parse/pubspec.yaml | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 581ed8a2f..39be54abb 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -50,8 +50,7 @@ linter: - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_declarations - # Need to update json_serializable to generate an ignore for this lint - #- prefer_expression_function_bodies + - prefer_expression_function_bodies - prefer_final_locals - prefer_function_declarations_over_variables - prefer_initializing_formals @@ -62,6 +61,7 @@ linter: - prefer_relative_imports - prefer_typing_uninitialized_variables - prefer_void_to_null + - provide_deprecation_message - sort_pub_dependencies - test_types_in_equals - throw_in_finally @@ -74,4 +74,5 @@ linter: - unnecessary_parenthesis - unnecessary_statements - unnecessary_string_interpolations + - use_string_buffers - void_checks diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 874c975da..aa3ea69ec 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -12,3 +12,10 @@ targets: checked: true create_to_json: false field_rename: snake + + # The end-user of a builder which applies "source_gen|combining_builder" + # may configure the builder to ignore specific lints for their project + source_gen|combining_builder: + options: + ignore_for_file: + - prefer_expression_function_bodies diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 4e137fad7..37352b37f 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -1,5 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: prefer_expression_function_bodies + part of 'dependency.dart'; // ************************************************************************** diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index eb062b8fd..c29a221d3 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -1,5 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: prefer_expression_function_bodies + part of 'pubspec.dart'; // ************************************************************************** diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index a148e7f69..2940ce3f9 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -21,6 +21,8 @@ dev_dependencies: json_serializable: ^3.0.0 path: ^1.5.1 pedantic: ^1.4.0 + # Needed because we are configuring `combining_builder` + source_gen: ^0.9.5 stack_trace: ^1.9.2 test: ^1.0.0 test_descriptor: ^1.0.3 From ce1af790abbe55f3b7a5a050f6ab1091f22e6ccb Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 4 Jun 2020 17:27:16 -0700 Subject: [PATCH 072/152] remove redundant arg --- pkgs/pubspec_parse/test/test_utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 00196bb11..e51f19863 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -40,7 +40,7 @@ void _printDebugParsedYamlException(ParsedYamlException e) { if (innerError != null) { final items = [innerError]; if (innerStack != null) { - items.add(Trace.format(innerStack, terse: true)); + items.add(Trace.format(innerStack)); } final content = From 524268d390de78f82a396747f100321f35115be5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 6 Jul 2020 15:38:03 -0700 Subject: [PATCH 073/152] Bump min Dart SDK to 2.7 (dart-lang/pubspec_parse#59) Works-around issue with testing Dart 2.6 in CI and changes to pkg:analyzer --- pkgs/pubspec_parse/.travis.yml | 4 ++-- pkgs/pubspec_parse/CHANGELOG.md | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml index 66bff3db8..802491f97 100644 --- a/pkgs/pubspec_parse/.travis.yml +++ b/pkgs/pubspec_parse/.travis.yml @@ -1,7 +1,7 @@ language: dart dart: - - 2.6.0 + - 2.7.0 - dev dart_task: @@ -16,7 +16,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.6.0 + - dart: 2.7.0 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index df5c0e827..7e74a5575 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.1.6-dev -- Update SDK requirement to `>=2.6.0 <3.0.0`. +- Update SDK requirement to `>=2.7.0 <3.0.0`. ## 0.1.5 diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 2940ce3f9..09d2fb9b5 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -6,7 +6,7 @@ version: 0.1.6-dev homepage: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.6.0 <3.0.0' + sdk: '>=2.7.0 <3.0.0' dependencies: checked_yaml: ^1.0.0 From 91c37d91cf0ca83a1a778eb255cf35ab1bf7afd3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 24 Nov 2020 11:14:30 -0800 Subject: [PATCH 074/152] Fix tests for latest pub parsing rules for environment (dart-lang/pubspec_parse#60) Since https://github.com/dart-lang/pub/commit/656803e924eae5cf6574f5200232ef69ac3b4f92 (SDK-2.12.0-28.0.dev) pub requires an SDK constraint. Update tests so this requirement no longer causes failures. Also updated test expectations for latest `pkg:json_annotation` changes --- pkgs/pubspec_parse/test/dependency_test.dart | 6 +- pkgs/pubspec_parse/test/parse_test.dart | 66 ++++++++++++-------- pkgs/pubspec_parse/test/test_utils.dart | 5 ++ 3 files changed, 47 insertions(+), 30 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 35ac6b67c..0afbf3645 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -214,7 +214,7 @@ line 5, column 4: These keys had `null` values, which is not allowed: [sdk] _expectThrows( {'sdk': 42}, r''' -line 5, column 11: Unsupported value for "sdk". +line 5, column 11: Unsupported value for "sdk". type 'int' is not a subtype of type 'String' in type cast ╷ 5 │ "sdk": 42 │ ┌───────────^ @@ -332,7 +332,7 @@ line 6, column 5: These keys had `null` values, which is not allowed: [url] 'git': {'url': 42} }, r''' -line 6, column 12: Unsupported value for "url". +line 6, column 12: Unsupported value for "url". type 'int' is not a subtype of type 'String' in type cast ╷ 6 │ "url": 42 │ ┌────────────^ @@ -404,7 +404,7 @@ void _expectThrows(Object content, String expectedError) { T _dependency(Object content, {bool skipTryPub = false}) { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'dependencies': {'dep': content} }, skipTryPub: skipTryPub); expect(value.name, 'sample'); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 75c3f83e8..179d0d8d1 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -14,7 +14,7 @@ import 'test_utils.dart'; void main() { test('minimal set values', () { - final value = parse({'name': 'sample'}); + final value = parse(defaultPubspec); expect(value.name, 'sample'); expect(value.version, isNull); expect(value.publishTo, isNull); @@ -23,7 +23,10 @@ void main() { // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, isEmpty); - expect(value.environment, isEmpty); + expect( + value.environment, + {'sdk': VersionConstraint.parse('>=2.7.0 <3.0.0')}, + ); expect(value.documentation, isNull); expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); @@ -70,17 +73,20 @@ void main() { test('environment values can be null', () { final value = parse({ 'name': 'sample', - 'environment': {'sdk': null} + 'environment': { + 'sdk': '>=2.7.0 <3.0.0', + 'bob': null, + } }); expect(value.name, 'sample'); - expect(value.environment, hasLength(1)); - expect(value.environment, containsPair('sdk', isNull)); + expect(value.environment, hasLength(2)); + expect(value.environment, containsPair('bob', isNull)); }); group('publish_to', () { for (var entry in { 42: r''' -line 3, column 16: Unsupported value for "publish_to". +line 3, column 16: Unsupported value for "publish_to". type 'int' is not a subtype of type 'String' in type cast ╷ 3 │ "publish_to": 42 │ ^^ @@ -120,7 +126,10 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https 'none': 'none' }.entries) { test('can be ${entry.key}', () { - final value = parse({'name': 'sample', 'publish_to': entry.value}); + final value = parse({ + ...defaultPubspec, + 'publish_to': entry.value, + }); expect(value.publishTo, entry.value); }); } @@ -128,7 +137,10 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https group('author, authors', () { test('one author', () { - final value = parse({'name': 'sample', 'author': 'name@example.com'}); + final value = parse({ + ...defaultPubspec, + 'author': 'name@example.com', + }); // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); @@ -136,7 +148,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('one author, via authors', () { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'authors': ['name@example.com'] }); // ignore: deprecated_member_use_from_same_package @@ -146,7 +158,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('many authors', () { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'authors': ['name@example.com', 'name2@example.com'] }); // ignore: deprecated_member_use_from_same_package @@ -156,7 +168,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('author and authors', () { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'author': 'name@example.com', 'authors': ['name2@example.com'] }); @@ -167,7 +179,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('duplicate author values', () { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'author': 'name@example.com', 'authors': ['name@example.com', 'name@example.com'] }); @@ -178,7 +190,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('flutter', () { final value = parse({ - 'name': 'sample', + ...defaultPubspec, 'flutter': {'key': 'value'}, }); expect(value.flutter, {'key': 'value'}); @@ -282,16 +294,16 @@ line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". test('bad repository url', () { expectParseThrows( { - 'name': 'foo', + ...defaultPubspec, 'repository': {'x': 'y'}, }, r''' -line 3, column 16: Unsupported value for "repository". +line 6, column 16: Unsupported value for "repository". type 'YamlMap' is not a subtype of type 'String' in type cast ╷ -3 │ "repository": { +6 │ "repository": { │ ┌────────────────^ -4 │ │ "x": "y" -5 │ └ } +7 │ │ "x": "y" +8 │ └ } ╵''', skipTryPub: true, ); @@ -300,11 +312,11 @@ line 3, column 16: Unsupported value for "repository". test('bad issue_tracker url', () { expectParseThrows( { - 'name': 'foo', + 'name': 'sample', 'issue_tracker': {'x': 'y'}, }, r''' -line 3, column 19: Unsupported value for "issue_tracker". +line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not a subtype of type 'String' in type cast ╷ 3 │ "issue_tracker": { │ ┌───────────────────^ @@ -359,37 +371,37 @@ line 1, column 1: "name" cannot be empty. test('bad repository url', () { final value = parse( { - 'name': 'foo', + ...defaultPubspec, 'repository': {'x': 'y'}, }, lenient: true, ); - expect(value.name, 'foo'); + expect(value.name, 'sample'); expect(value.repository, isNull); }); test('bad issue_tracker url', () { final value = parse( { - 'name': 'foo', + ...defaultPubspec, 'issue_tracker': {'x': 'y'}, }, lenient: true, ); - expect(value.name, 'foo'); + expect(value.name, 'sample'); expect(value.issueTracker, isNull); }); test('multiple bad values', () { final value = parse( { - 'name': 'foo', + ...defaultPubspec, 'repository': {'x': 'y'}, 'issue_tracker': {'x': 'y'}, }, lenient: true, ); - expect(value.name, 'foo'); + expect(value.name, 'sample'); expect(value.repository, isNull); expect(value.issueTracker, isNull); }); @@ -397,7 +409,7 @@ line 1, column 1: "name" cannot be empty. test('deep error throws with lenient', () { expect( () => parse({ - 'name': 'foo', + 'name': 'sample', 'dependencies': { 'foo': { 'git': {'url': 1} diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index e51f19863..ac5abba06 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -13,6 +13,11 @@ import 'package:test/test.dart'; import 'pub_utils.dart'; +const defaultPubspec = { + 'name': 'sample', + 'environment': {'sdk': '>=2.7.0 <3.0.0'}, +}; + String _encodeJson(Object input) => const JsonEncoder.withIndent(' ').convert(input); From 6a5bbfcc76a1f72b5d88a67c4abaabfc83d0f9a3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 8 Dec 2020 13:05:52 -0800 Subject: [PATCH 075/152] Allow null-safe json_annotation (dart-lang/pubspec_parse#61) prepare to release v0.1.6 --- pkgs/pubspec_parse/CHANGELOG.md | 3 ++- pkgs/pubspec_parse/pubspec.yaml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 7e74a5575..f7a1a3ae3 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ -## 0.1.6-dev +## 0.1.6 - Update SDK requirement to `>=2.7.0 <3.0.0`. +- Allow `package:json_annotation` `v4.x`. ## 0.1.5 diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 09d2fb9b5..6e2a7e9cd 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,8 +2,8 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.6-dev -homepage: https://github.com/dart-lang/pubspec_parse +version: 0.1.6 +repository: https://github.com/dart-lang/pubspec_parse environment: sdk: '>=2.7.0 <3.0.0' @@ -11,7 +11,7 @@ environment: dependencies: checked_yaml: ^1.0.0 # Verified that no new features since 1.0.0 are used - be careful! - json_annotation: '>=1.0.0 <4.0.0' + json_annotation: '>=1.0.0 <5.0.0' pub_semver: ^1.3.2 yaml: ^2.1.12 From 2fcd77b6d0f84bc030e08de25ca537027cd64b1b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 8 Dec 2020 13:53:18 -0800 Subject: [PATCH 076/152] Allow null-safe pkg:yaml (dart-lang/pubspec_parse#62) Prepare to release v0.1.7 --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index f7a1a3ae3..26b1d3139 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.7 + +- Allow `package:yaml` `v3.x`. + ## 0.1.6 - Update SDK requirement to `>=2.7.0 <3.0.0`. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 6e2a7e9cd..5cda97668 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.6 +version: 0.1.7 repository: https://github.com/dart-lang/pubspec_parse environment: @@ -13,7 +13,7 @@ dependencies: # Verified that no new features since 1.0.0 are used - be careful! json_annotation: '>=1.0.0 <5.0.0' pub_semver: ^1.3.2 - yaml: ^2.1.12 + yaml: '>=2.1.12 <4.0.0' dev_dependencies: build_runner: ^1.0.0 From 190f93add7d7c8e9eaa74b7db983937a32b245b8 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Thu, 28 Jan 2021 16:23:09 +0100 Subject: [PATCH 077/152] Migrate to GitHub Actions (dart-lang/pubspec_parse#63) --- .../.github/workflows/test-package.yml | 85 +++++++++++++++++++ pkgs/pubspec_parse/.travis.yml | 29 ------- pkgs/pubspec_parse/README.md | 2 +- 3 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 pkgs/pubspec_parse/.github/workflows/test-package.yml delete mode 100644 pkgs/pubspec_parse/.travis.yml diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml new file mode 100644 index 000000000..fa37a1f87 --- /dev/null +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -0,0 +1,85 @@ +name: Dart CI + +on: + # Run on PRs and pushes to the default branch. + push: + branches: [ master ] + pull_request: + branches: [ master ] + schedule: + - cron: "0 0 * * 0" + +env: + PUB_ENVIRONMENT: bot.github + +jobs: + # Check code formatting and static analysis on a single OS (linux) + # against Dart dev. + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Analyze code + run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + + # Run tests on a matrix consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release channel: dev + test: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm --run-skipped + if: always() && steps.install.outcome == 'success' + + # Run tests on a matrix consisting of two dimensions: + # 1. OS: ubuntu-latest, (macos-latest, windows-latest) + # 2. release: 2.7.0 + test-legacy-sdk: + needs: analyze + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Add macos-latest and/or windows-latest if relevant for this package. + os: [ubuntu-latest] + sdk: [2.7.0] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: pub get + - name: Run VM tests + run: pub run test --platform vm --run-skipped + if: always() && steps.install.outcome == 'success' diff --git a/pkgs/pubspec_parse/.travis.yml b/pkgs/pubspec_parse/.travis.yml deleted file mode 100644 index 802491f97..000000000 --- a/pkgs/pubspec_parse/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: dart - -dart: - - 2.7.0 - - dev - -dart_task: - - test: -x presubmit-only - - test: --run-skipped -t presubmit-only - -matrix: - include: - # Only validate formatting using the dev release - - dart: dev - dart_task: dartfmt - - dart: dev - dart_task: - dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.7.0 - dart_task: - dartanalyzer: --fatal-warnings . - -# Only building master means that we don't run two builds for each pull request. -branches: - only: [master] - -cache: - directories: - - $HOME/.pub-cache diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index 7287d5f4e..ed00eed97 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/dart-lang/pubspec_parse.svg?branch=master)](https://travis-ci.org/dart-lang/pubspec_parse) +[![Build Status](https://github.com/dart-lang/pubspec_parse/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/pubspec_parse/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) [![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/pubspec_parse) Supports parsing `pubspec.yaml` files with robust error reporting and support From b3c03dbf27a89f389782e2fd6dab7d2dd813df54 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 8 Feb 2021 13:57:09 -0800 Subject: [PATCH 078/152] allow latest pkg:pub_semver (dart-lang/pubspec_parse#64) --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 26b1d3139..a07e48885 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.8 + +- Allow the latest `package:pub_semver`. + ## 0.1.7 - Allow `package:yaml` `v3.x`. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 5cda97668..dee30ecde 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.7 +version: 0.1.8 repository: https://github.com/dart-lang/pubspec_parse environment: @@ -12,7 +12,7 @@ dependencies: checked_yaml: ^1.0.0 # Verified that no new features since 1.0.0 are used - be careful! json_annotation: '>=1.0.0 <5.0.0' - pub_semver: ^1.3.2 + pub_semver: '>=1.3.2 <3.0.0' yaml: '>=2.1.12 <4.0.0' dev_dependencies: From b8f2892926fecbaa7185b899b0b936b2755c55be Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 2 Mar 2021 09:27:49 -0800 Subject: [PATCH 079/152] migrate to stable, null-safety (dart-lang/pubspec_parse#65) Co-authored-by: Jacob MacDonald --- .../.github/workflows/test-package.yml | 28 +----- pkgs/pubspec_parse/CHANGELOG.md | 6 ++ pkgs/pubspec_parse/build.yaml | 2 + pkgs/pubspec_parse/lib/src/dependency.dart | 53 ++++++----- pkgs/pubspec_parse/lib/src/dependency.g.dart | 24 ++--- pkgs/pubspec_parse/lib/src/pubspec.dart | 94 ++++++++++--------- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 29 +++--- pkgs/pubspec_parse/pubspec.yaml | 27 ++++-- pkgs/pubspec_parse/test/dependency_test.dart | 44 +++++---- .../pubspec_parse/test/ensure_build_test.dart | 2 + pkgs/pubspec_parse/test/parse_test.dart | 48 +++++++--- pkgs/pubspec_parse/test/test_utils.dart | 20 ++-- 12 files changed, 199 insertions(+), 178 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index fa37a1f87..d63264526 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -45,9 +45,9 @@ jobs: strategy: fail-fast: false matrix: - # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [dev] + # change beta to 2.12.0 when released! + sdk: [beta, dev] steps: - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v0.3 @@ -59,27 +59,3 @@ jobs: - name: Run VM tests run: dart test --platform vm --run-skipped if: always() && steps.install.outcome == 'success' - - # Run tests on a matrix consisting of two dimensions: - # 1. OS: ubuntu-latest, (macos-latest, windows-latest) - # 2. release: 2.7.0 - test-legacy-sdk: - needs: analyze - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - # Add macos-latest and/or windows-latest if relevant for this package. - os: [ubuntu-latest] - sdk: [2.7.0] - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 - with: - sdk: ${{ matrix.sdk }} - - id: install - name: Install dependencies - run: pub get - - name: Run VM tests - run: pub run test --platform vm --run-skipped - if: always() && steps.install.outcome == 'success' diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index a07e48885..97c410f74 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.0 + +- Migrate to null-safety. +- Pubspec: `author` and `authors` are both now deprecated. + See https://dart.dev/tools/pub/pubspec#authorauthors + ## 0.1.8 - Allow the latest `package:pub_semver`. diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index aa3ea69ec..3e642b8f1 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -18,4 +18,6 @@ targets: source_gen|combining_builder: options: ignore_for_file: + - deprecated_member_use_from_same_package + - lines_longer_than_80_chars - prefer_expression_function_bodies diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 2d4eda696..e4996c58e 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -2,16 +2,17 @@ // 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:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; part 'dependency.g.dart'; -Map parseDeps(Map source) => +Map parseDeps(Map? source) => source?.map((k, v) { final key = k as String; - Dependency value; + Dependency? value; try { value = _fromJson(v); } on CheckedFromJsonException catch (e) { @@ -19,7 +20,7 @@ Map parseDeps(Map source) => // This is likely a "synthetic" map created from a String value // Use `source` to throw this exception with an actual YamlMap and // extract the associated error information. - throw CheckedFromJsonException(source, key, e.className, e.message); + throw CheckedFromJsonException(source, key, e.className!, e.message); } rethrow; } @@ -35,7 +36,7 @@ Map parseDeps(Map source) => const _sourceKeys = ['sdk', 'git', 'path', 'hosted']; /// Returns `null` if the data could not be parsed. -Dependency _fromJson(dynamic data) { +Dependency? _fromJson(Object? data) { if (data is String || data == null) { return _$HostedDependencyFromJson({'version': data}); } @@ -47,8 +48,8 @@ Dependency _fromJson(dynamic data) { if (data.isEmpty || (matchedKeys.isEmpty && data.containsKey('version'))) { return _$HostedDependencyFromJson(data); } else { - final firstUnrecognizedKey = matchedKeys - .firstWhere((k) => !_sourceKeys.contains(k), orElse: () => null); + final firstUnrecognizedKey = + matchedKeys.firstWhereOrNull((k) => !_sourceKeys.contains(k)); return $checkedNew('Dependency', data, () { if (firstUnrecognizedKey != null) { @@ -92,12 +93,13 @@ abstract class Dependency { @JsonSerializable() class SdkDependency extends Dependency { - @JsonKey(nullable: false, disallowNullValue: true, required: true) final String sdk; @JsonKey(fromJson: _constraintFromString) final VersionConstraint version; - SdkDependency(this.sdk, {this.version}) : super._(); + SdkDependency(this.sdk, {VersionConstraint? version}) + : version = version ?? VersionConstraint.any, + super._(); @override String get _info => sdk; @@ -105,14 +107,14 @@ class SdkDependency extends Dependency { @JsonSerializable() class GitDependency extends Dependency { - @JsonKey(fromJson: parseGitUri, required: true, disallowNullValue: true) + @JsonKey(fromJson: parseGitUri) final Uri url; - final String ref; - final String path; + final String? ref; + final String? path; - GitDependency(this.url, this.ref, this.path) : super._(); + GitDependency(this.url, {this.ref, this.path}) : super._(); - factory GitDependency.fromData(Object data) { + factory GitDependency.fromData(Object? data) { if (data is String) { data = {'url': data}; } @@ -128,12 +130,14 @@ class GitDependency extends Dependency { String get _info => 'url@$url'; } -Uri parseGitUri(String value) => - value == null ? null : _tryParseScpUri(value) ?? Uri.parse(value); +Uri? parseGitUriOrNull(String? value) => + value == null ? null : parseGitUri(value); + +Uri parseGitUri(String value) => _tryParseScpUri(value) ?? Uri.parse(value); /// Supports URIs like `[user@]host.xz:path/to/repo.git/` /// See https://git-scm.com/docs/git-clone#_git_urls_a_id_urls_a -Uri _tryParseScpUri(String value) { +Uri? _tryParseScpUri(String value) { final colonIndex = value.indexOf(':'); if (colonIndex < 0) { @@ -167,7 +171,7 @@ class PathDependency extends Dependency { PathDependency(this.path) : super._(); - factory PathDependency.fromData(Object data) { + factory PathDependency.fromData(Object? data) { if (data is String) { return PathDependency(data); } @@ -184,9 +188,9 @@ class HostedDependency extends Dependency { final VersionConstraint version; @JsonKey(disallowNullValue: true) - final HostedDetails hosted; + final HostedDetails? hosted; - HostedDependency({VersionConstraint version, this.hosted}) + HostedDependency({VersionConstraint? version, this.hosted}) : version = version ?? VersionConstraint.any, super._(); @@ -196,15 +200,14 @@ class HostedDependency extends Dependency { @JsonSerializable(disallowUnrecognizedKeys: true) class HostedDetails { - @JsonKey(required: true, disallowNullValue: true) final String name; - @JsonKey(fromJson: parseGitUri, disallowNullValue: true) - final Uri url; + @JsonKey(fromJson: parseGitUriOrNull, disallowNullValue: true) + final Uri? url; HostedDetails(this.name, this.url); - factory HostedDetails.fromJson(Object data) { + factory HostedDetails.fromJson(Object? data) { if (data is String) { data = {'name': data}; } @@ -217,5 +220,5 @@ class HostedDetails { } } -VersionConstraint _constraintFromString(String input) => - input == null ? null : VersionConstraint.parse(input); +VersionConstraint _constraintFromString(String? input) => + input == null ? VersionConstraint.any : VersionConstraint.parse(input); diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 37352b37f..95b177993 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: prefer_expression_function_bodies +// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, prefer_expression_function_bodies part of 'dependency.dart'; @@ -10,12 +10,10 @@ part of 'dependency.dart'; SdkDependency _$SdkDependencyFromJson(Map json) { return $checkedNew('SdkDependency', json, () { - $checkKeys(json, - requiredKeys: const ['sdk'], disallowNullValues: const ['sdk']); final val = SdkDependency( $checkedConvert(json, 'sdk', (v) => v as String), version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String)), + json, 'version', (v) => _constraintFromString(v as String?)), ); return val; }); @@ -23,12 +21,10 @@ SdkDependency _$SdkDependencyFromJson(Map json) { GitDependency _$GitDependencyFromJson(Map json) { return $checkedNew('GitDependency', json, () { - $checkKeys(json, - requiredKeys: const ['url'], disallowNullValues: const ['url']); final val = GitDependency( $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), - $checkedConvert(json, 'ref', (v) => v as String), - $checkedConvert(json, 'path', (v) => v as String), + ref: $checkedConvert(json, 'ref', (v) => v as String?), + path: $checkedConvert(json, 'path', (v) => v as String?), ); return val; }); @@ -41,9 +37,9 @@ HostedDependency _$HostedDependencyFromJson(Map json) { disallowNullValues: const ['hosted']); final val = HostedDependency( version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String)), - hosted: $checkedConvert( - json, 'hosted', (v) => v == null ? null : HostedDetails.fromJson(v)), + json, 'version', (v) => _constraintFromString(v as String?)), + hosted: $checkedConvert(json, 'hosted', + (v) => v == null ? null : HostedDetails.fromJson(v as Object)), ); return val; }); @@ -52,12 +48,10 @@ HostedDependency _$HostedDependencyFromJson(Map json) { HostedDetails _$HostedDetailsFromJson(Map json) { return $checkedNew('HostedDetails', json, () { $checkKeys(json, - allowedKeys: const ['name', 'url'], - requiredKeys: const ['name'], - disallowNullValues: const ['name', 'url']); + allowedKeys: const ['name', 'url'], disallowNullValues: const ['url']); final val = HostedDetails( $checkedConvert(json, 'name', (v) => v as String), - $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), + $checkedConvert(json, 'url', (v) => parseGitUriOrNull(v as String?)), ); return val; }); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index e3dbac14f..b851486ec 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -17,53 +17,57 @@ class Pubspec { final String name; @JsonKey(fromJson: _versionFromString) - final Version version; + final Version? version; - final String description; + final String? description; /// This should be a URL pointing to the website for the package. - final String homepage; + final String? homepage; /// Specifies where to publish this package. /// /// Accepted values: `null`, `'none'` or an `http` or `https` URL. /// /// [More information](https://dart.dev/tools/pub/pubspec#publish_to). - final String publishTo; + final String? publishTo; /// Optional field to specify the source code repository of the package. /// Useful when a package has both a home page and a repository. - final Uri repository; + final Uri? repository; /// Optional field to a web page where developers can report new issues or /// view existing ones. - final Uri issueTracker; + final Uri? issueTracker; /// If there is exactly 1 value in [authors], returns it. /// /// If there are 0 or more than 1, returns `null`. @Deprecated( - 'Here for completeness, but not recommended. Use `authors` instead.') - String get author { + 'See https://dart.dev/tools/pub/pubspec#authorauthors', + ) + String? get author { if (authors.length == 1) { return authors.single; } return null; } + @Deprecated( + 'See https://dart.dev/tools/pub/pubspec#authorauthors', + ) final List authors; - final String documentation; + final String? documentation; @JsonKey(fromJson: _environmentMap) - final Map environment; + final Map? environment; - @JsonKey(fromJson: parseDeps, nullable: false) + @JsonKey(fromJson: parseDeps) final Map dependencies; - @JsonKey(fromJson: parseDeps, nullable: false) + @JsonKey(fromJson: parseDeps) final Map devDependencies; - @JsonKey(fromJson: parseDeps, nullable: false) + @JsonKey(fromJson: parseDeps) final Map dependencyOverrides; /// Optional configuration specific to [Flutter](https://flutter.io/) @@ -72,7 +76,7 @@ class Pubspec { /// May include /// [assets](https://flutter.io/docs/development/ui/assets-and-images) /// and other settings. - final Map flutter; + final Map? flutter; /// If [author] and [authors] are both provided, their values are combined /// with duplicates eliminated. @@ -80,30 +84,38 @@ class Pubspec { this.name, { this.version, this.publishTo, - String author, - List authors, - Map environment, + @Deprecated( + 'See https://dart.dev/tools/pub/pubspec#authorauthors', + ) + String? author, + @Deprecated( + 'See https://dart.dev/tools/pub/pubspec#authorauthors', + ) + List? authors, + Map? environment, this.homepage, this.repository, this.issueTracker, this.documentation, this.description, - Map dependencies, - Map devDependencies, - Map dependencyOverrides, + Map? dependencies, + Map? devDependencies, + Map? dependencyOverrides, this.flutter, - }) : authors = _normalizeAuthors(author, authors), + }) : + // ignore: deprecated_member_use_from_same_package + authors = _normalizeAuthors(author, authors), environment = environment ?? const {}, dependencies = dependencies ?? const {}, devDependencies = devDependencies ?? const {}, dependencyOverrides = dependencyOverrides ?? const {} { - if (name == null || name.isEmpty) { + if (name.isEmpty) { throw ArgumentError.value(name, 'name', '"name" cannot be empty.'); } if (publishTo != null && publishTo != 'none') { try { - final targetUri = Uri.parse(publishTo); + final targetUri = Uri.parse(publishTo!); if (!(targetUri.isScheme('http') || targetUri.isScheme('https'))) { throw const FormatException('Must be an http or https URL.'); } @@ -114,8 +126,6 @@ class Pubspec { } factory Pubspec.fromJson(Map json, {bool lenient = false}) { - lenient ??= false; - if (lenient) { while (json.isNotEmpty) { // Attempting to remove top-level properties that cause parsing errors. @@ -138,30 +148,26 @@ class Pubspec { /// /// When [lenient] is set, top-level property-parsing or type cast errors are /// ignored and `null` values are returned. - factory Pubspec.parse(String yaml, {sourceUrl, bool lenient = false}) { - lenient ??= false; - - return checkedYamlDecode( - yaml, (map) => Pubspec.fromJson(map, lenient: lenient), - sourceUrl: sourceUrl); - } - - static List _normalizeAuthors(String author, List authors) { - final value = {}; - if (author != null) { - value.add(author); - } - if (authors != null) { - value.addAll(authors); - } + factory Pubspec.parse(String yaml, {Uri? sourceUrl, bool lenient = false}) => + checkedYamlDecode( + yaml, + (map) => Pubspec.fromJson(map!, lenient: lenient), + sourceUrl: sourceUrl, + ); + + static List _normalizeAuthors(String? author, List? authors) { + final value = { + if (author != null) author, + ...?authors, + }; return value.toList(); } } -Version _versionFromString(String input) => +Version? _versionFromString(String? input) => input == null ? null : Version.parse(input); -Map _environmentMap(Map source) => +Map? _environmentMap(Map? source) => source?.map((k, value) { final key = k as String; if (key == 'dart') { @@ -176,7 +182,7 @@ Map _environmentMap(Map source) => ); } - VersionConstraint constraint; + VersionConstraint? constraint; if (value == null) { constraint = null; } else if (value is String) { diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index c29a221d3..72ed2a264 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: prefer_expression_function_bodies +// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, prefer_expression_function_bodies part of 'pubspec.dart'; @@ -13,30 +13,31 @@ Pubspec _$PubspecFromJson(Map json) { final val = Pubspec( $checkedConvert(json, 'name', (v) => v as String), version: $checkedConvert( - json, 'version', (v) => _versionFromString(v as String)), - publishTo: $checkedConvert(json, 'publish_to', (v) => v as String), - author: $checkedConvert(json, 'author', (v) => v as String), + json, 'version', (v) => _versionFromString(v as String?)), + publishTo: $checkedConvert(json, 'publish_to', (v) => v as String?), + author: $checkedConvert(json, 'author', (v) => v as String?), authors: $checkedConvert(json, 'authors', - (v) => (v as List)?.map((e) => e as String)?.toList()), + (v) => (v as List?)?.map((e) => e as String).toList()), environment: $checkedConvert( - json, 'environment', (v) => _environmentMap(v as Map)), - homepage: $checkedConvert(json, 'homepage', (v) => v as String), + json, 'environment', (v) => _environmentMap(v as Map?)), + homepage: $checkedConvert(json, 'homepage', (v) => v as String?), repository: $checkedConvert( json, 'repository', (v) => v == null ? null : Uri.parse(v as String)), issueTracker: $checkedConvert(json, 'issue_tracker', (v) => v == null ? null : Uri.parse(v as String)), - documentation: $checkedConvert(json, 'documentation', (v) => v as String), - description: $checkedConvert(json, 'description', (v) => v as String), + documentation: + $checkedConvert(json, 'documentation', (v) => v as String?), + description: $checkedConvert(json, 'description', (v) => v as String?), dependencies: - $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map)), - devDependencies: - $checkedConvert(json, 'dev_dependencies', (v) => parseDeps(v as Map)), + $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map?)), + devDependencies: $checkedConvert( + json, 'dev_dependencies', (v) => parseDeps(v as Map?)), dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => parseDeps(v as Map)), + json, 'dependency_overrides', (v) => parseDeps(v as Map?)), flutter: $checkedConvert( json, 'flutter', - (v) => (v as Map)?.map( + (v) => (v as Map?)?.map( (k, e) => MapEntry(k as String, e), )), ); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index dee30ecde..4179feadf 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,28 +2,35 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 0.1.8 +version: 1.0.0 repository: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.7.0 <3.0.0' + sdk: '>=2.12.0-0 <3.0.0' dependencies: - checked_yaml: ^1.0.0 - # Verified that no new features since 1.0.0 are used - be careful! - json_annotation: '>=1.0.0 <5.0.0' - pub_semver: '>=1.3.2 <3.0.0' - yaml: '>=2.1.12 <4.0.0' + checked_yaml: ^2.0.1 + collection: ^1.15.0 + json_annotation: ^4.0.0 + pub_semver: ^2.0.0 + yaml: ^3.0.0 dev_dependencies: build_runner: ^1.0.0 build_verify: ^1.0.0 - json_serializable: ^3.0.0 + json_serializable: ^4.0.2 path: ^1.5.1 pedantic: ^1.4.0 # Needed because we are configuring `combining_builder` source_gen: ^0.9.5 stack_trace: ^1.9.2 test: ^1.0.0 - test_descriptor: ^1.0.3 - test_process: ^1.0.2 + test_descriptor: ^2.0.0 + test_process: ^2.0.0 + +dependency_overrides: + # Need to update dependencies on these packages + build_config: 0.4.6 + build_runner: any + checked_yaml: ^2.0.1 + json_annotation: 4.0.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 0afbf3645..c6f2dc50b 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -112,8 +112,8 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} }); expect(dep.version.toString(), '^1.0.0'); - expect(dep.hosted.name, 'hosted_name'); - expect(dep.hosted.url.toString(), 'hosted_url'); + expect(dep.hosted!.name, 'hosted_name'); + expect(dep.hosted!.url.toString(), 'hosted_url'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); @@ -149,16 +149,16 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git final dep = _dependency( {'version': '^1.0.0', 'hosted': 'hosted_name'}); expect(dep.version.toString(), '^1.0.0'); - expect(dep.hosted.name, 'hosted_name'); - expect(dep.hosted.url, isNull); + expect(dep.hosted!.name, 'hosted_name'); + expect(dep.hosted!.url, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); test('map w/ hosted as String', () { final dep = _dependency({'hosted': 'hosted_name'}); expect(dep.version, VersionConstraint.any); - expect(dep.hosted.name, 'hosted_name'); - expect(dep.hosted.url, isNull); + expect(dep.hosted!.name, 'hosted_name'); + expect(dep.hosted!.url, isNull); expect(dep.toString(), 'HostedDependency: any'); }); @@ -186,7 +186,7 @@ void _sdkDependency() { test('without version', () { final dep = _dependency({'sdk': 'flutter'}); expect(dep.sdk, 'flutter'); - expect(dep.version, isNull); + expect(dep.version, VersionConstraint.any); expect(dep.toString(), 'SdkDependency: flutter'); }); @@ -202,10 +202,12 @@ void _sdkDependency() { _expectThrows( {'sdk': null}, r''' -line 5, column 4: These keys had `null` values, which is not allowed: [sdk] +line 5, column 11: Unsupported value for "sdk". type 'Null' is not a subtype of type 'String' in type cast ╷ -5 │ "sdk": null - │ ^^^^^ +5 │ "sdk": null + │ ┌───────────^ +6 │ │ } + │ └──^ ╵''', ); }); @@ -304,12 +306,15 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. }); test('git - empty map', () { - _expectThrows({'git': {}}, r''' -line 5, column 11: Required keys are missing: url. + _expectThrows( + {'git': {}}, + r''' +line 5, column 11: Missing key "url". type 'Null' is not a subtype of type 'String' in type cast ╷ 5 │ "git": {} │ ^^ - ╵'''); + ╵''', + ); }); test('git - null url', () { @@ -318,10 +323,12 @@ line 5, column 11: Required keys are missing: url. 'git': {'url': null} }, r''' -line 6, column 5: These keys had `null` values, which is not allowed: [url] +line 6, column 12: Unsupported value for "url". type 'Null' is not a subtype of type 'String' in type cast ╷ -6 │ "url": null - │ ^^^^^ +6 │ "url": null + │ ┌────────────^ +7 │ │ } + │ └───^ ╵''', ); }); @@ -402,7 +409,10 @@ void _expectThrows(Object content, String expectedError) { }, expectedError); } -T _dependency(Object content, {bool skipTryPub = false}) { +T _dependency( + Object? content, { + bool skipTryPub = false, +}) { final value = parse({ ...defaultPubspec, 'dependencies': {'dep': content} diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index d64fa4f66..a75d1bd32 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -2,6 +2,8 @@ // 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. +// @dart=2.9 + @TestOn('vm') @Tags(['presubmit-only']) import 'package:build_verify/build_verify.dart'; diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 179d0d8d1..52df370d0 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -2,9 +2,7 @@ // 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. -// TODO(kevmoo) Remove when github.com/dart-lang/sdk/commit/dac5a56422 lands -// in a shipped SDK. -// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package library parse_test; import 'package:pub_semver/pub_semver.dart'; @@ -20,7 +18,6 @@ void main() { expect(value.publishTo, isNull); expect(value.description, isNull); expect(value.homepage, isNull); - // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, isEmpty); expect( @@ -56,7 +53,6 @@ void main() { expect(value.publishTo, 'none'); expect(value.description, 'description'); expect(value.homepage, 'homepage'); - // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); expect(value.environment, hasLength(1)); @@ -86,7 +82,7 @@ void main() { group('publish_to', () { for (var entry in { 42: r''' -line 3, column 16: Unsupported value for "publish_to". type 'int' is not a subtype of type 'String' in type cast +line 3, column 16: Unsupported value for "publish_to". type 'int' is not a subtype of type 'String?' in type cast ╷ 3 │ "publish_to": 42 │ ^^ @@ -141,7 +137,6 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https ...defaultPubspec, 'author': 'name@example.com', }); - // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); @@ -151,7 +146,6 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https ...defaultPubspec, 'authors': ['name@example.com'] }); - // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); @@ -161,7 +155,6 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https ...defaultPubspec, 'authors': ['name@example.com', 'name2@example.com'] }); - // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); }); @@ -172,7 +165,6 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https 'author': 'name@example.com', 'authors': ['name2@example.com'] }); - // ignore: deprecated_member_use_from_same_package expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); }); @@ -183,7 +175,6 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https 'author': 'name@example.com', 'authors': ['name@example.com', 'name@example.com'] }); - // ignore: deprecated_member_use_from_same_package expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); }); @@ -230,12 +221,39 @@ line 1, column 1: Not a map }); test('missing name', () { - expectParseThrows({}, r''' -line 1, column 1: "name" cannot be empty. + expectParseThrows( + {}, + r''' +line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast ╷ 1 │ {} │ ^^ - ╵'''); + ╵''', + ); + }); + + test('null name value', () { + expectParseThrows( + {'name': null}, + r''' +line 2, column 10: Unsupported value for "name". type 'Null' is not a subtype of type 'String' in type cast + ╷ +2 │ "name": null + │ ^^^^ + ╵''', + ); + }); + + test('empty name value', () { + expectParseThrows( + {'name': ''}, + r''' +line 2, column 10: Unsupported value for "name". "name" cannot be empty. + ╷ +2 │ "name": "" + │ ^^ + ╵''', + ); }); test('"dart" is an invalid environment key', () { @@ -359,7 +377,7 @@ line 1, column 1: Not a map expectParseThrows( {}, r''' -line 1, column 1: "name" cannot be empty. +line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast ╷ 1 │ {} │ ^^ diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index ac5abba06..b66adba87 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -18,7 +18,7 @@ const defaultPubspec = { 'environment': {'sdk': '>=2.7.0 <3.0.0'}, }; -String _encodeJson(Object input) => +String _encodeJson(Object? input) => const JsonEncoder.withIndent(' ').convert(input); Matcher _throwsParsedYamlException(String prettyValue) => @@ -31,10 +31,10 @@ Matcher _throwsParsedYamlException(String prettyValue) => void _printDebugParsedYamlException(ParsedYamlException e) { var innerError = e.innerError; - StackTrace innerStack; + StackTrace? innerStack; if (innerError is CheckedFromJsonException) { - final cfje = innerError as CheckedFromJsonException; + final cfje = innerError; if (cfje.innerError != null) { innerError = cfje.innerError; @@ -56,18 +56,14 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } Pubspec parse( - Object content, { + Object? content, { bool quietOnError = false, bool skipTryPub = false, bool lenient = false, }) { - quietOnError ??= false; - skipTryPub ??= false; - lenient ??= false; - final encoded = _encodeJson(content); - ProcResult pubResult; + ProcResult? pubResult; if (!skipTryPub) { pubResult = waitFor(tryPub(encoded)); expect(pubResult, isNotNull); @@ -78,7 +74,7 @@ Pubspec parse( if (pubResult != null) { addTearDown(() { - expect(pubResult.cleanParse, isTrue, + expect(pubResult!.cleanParse, isTrue, reason: 'On success, parsing from the pub client should also succeed.'); }); @@ -87,7 +83,7 @@ Pubspec parse( } catch (e) { if (pubResult != null) { addTearDown(() { - expect(pubResult.cleanParse, isFalse, + expect(pubResult!.cleanParse, isFalse, reason: 'On failure, parsing from the pub client should also fail.'); }); @@ -102,7 +98,7 @@ Pubspec parse( } void expectParseThrows( - Object content, + Object? content, String expectedError, { bool skipTryPub = false, bool lenient = false, From ecb8daf34b3db050b66e999db9c8057a63749cb6 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 15 Mar 2021 15:54:09 -0700 Subject: [PATCH 080/152] Drop dependency_overrides, bump CI script and SDK constraint (dart-lang/pubspec_parse#66) --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 7 +++---- pkgs/pubspec_parse/CHANGELOG.md | 2 ++ pkgs/pubspec_parse/pubspec.yaml | 11 ++--------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index d63264526..df7aeb463 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install @@ -46,11 +46,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - # change beta to 2.12.0 when released! - sdk: [beta, dev] + sdk: [2.12.0, dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1.0 with: sdk: ${{ matrix.sdk }} - id: install diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 97c410f74..0c72a39d0 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.0.1-dev + ## 1.0.0 - Migrate to null-safety. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 4179feadf..bd9f678a8 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,11 +2,11 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.0.0 +version: 1.0.1-dev repository: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: checked_yaml: ^2.0.1 @@ -27,10 +27,3 @@ dev_dependencies: test: ^1.0.0 test_descriptor: ^2.0.0 test_process: ^2.0.0 - -dependency_overrides: - # Need to update dependencies on these packages - build_config: 0.4.6 - build_runner: any - checked_yaml: ^2.0.1 - json_annotation: 4.0.0 From f75f35190461adf932bd26fa48098bd148e96039 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 16 Mar 2021 10:17:31 -0700 Subject: [PATCH 081/152] latest build verify (dart-lang/pubspec_parse#67) --- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/ensure_build_test.dart | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index bd9f678a8..bd0342df3 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: build_runner: ^1.0.0 - build_verify: ^1.0.0 + build_verify: ^2.0.0 json_serializable: ^4.0.2 path: ^1.5.1 pedantic: ^1.4.0 diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index a75d1bd32..d64fa4f66 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -2,8 +2,6 @@ // 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. -// @dart=2.9 - @TestOn('vm') @Tags(['presubmit-only']) import 'package:build_verify/build_verify.dart'; From d1886def5cbc059bdcd58b7baae24d7746c57d32 Mon Sep 17 00:00:00 2001 From: Franklin Yow <58489007+franklinyow@users.noreply.github.com> Date: Fri, 2 Apr 2021 17:09:02 -0700 Subject: [PATCH 082/152] Update LICENSE (dart-lang/pubspec_parse#68) Changes to comply with internal review --- pkgs/pubspec_parse/LICENSE | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/LICENSE b/pkgs/pubspec_parse/LICENSE index c4dc9ba3c..9972f6e70 100644 --- a/pkgs/pubspec_parse/LICENSE +++ b/pkgs/pubspec_parse/LICENSE @@ -1,4 +1,5 @@ -Copyright 2018, the Dart project authors. All rights reserved. +Copyright 2018, the Dart project authors. + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -9,7 +10,7 @@ met: copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. From 32489a75ac8140d6f90365d59b989e1921684a27 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 12 Apr 2021 07:33:03 -0700 Subject: [PATCH 083/152] latest deps (dart-lang/pubspec_parse#69) --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index bd0342df3..469e0046f 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -22,7 +22,7 @@ dev_dependencies: path: ^1.5.1 pedantic: ^1.4.0 # Needed because we are configuring `combining_builder` - source_gen: ^0.9.5 + source_gen: ^1.0.0 stack_trace: ^1.9.2 test: ^1.0.0 test_descriptor: ^2.0.0 From 91048ca82672239a46dfbba4a8c9a06565c1dc7f Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 21 May 2021 16:27:13 -0700 Subject: [PATCH 084/152] bump build_runner dep dependency (dart-lang/pubspec_parse#70) --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 469e0046f..c5577b04d 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: yaml: ^3.0.0 dev_dependencies: - build_runner: ^1.0.0 + build_runner: ^2.0.3 build_verify: ^2.0.0 json_serializable: ^4.0.2 path: ^1.5.1 From fbe7e40c89119c69a010a51c6c5063d41def859e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 23 Jul 2021 11:22:41 -0700 Subject: [PATCH 085/152] Fix hosted uri test (dart-lang/pubspec_parse#71) --- pkgs/pubspec_parse/test/dependency_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index c6f2dc50b..9ccd61434 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -109,11 +109,11 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v test('map w/ version and hosted as Map', () { final dep = _dependency({ 'version': '^1.0.0', - 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} + 'hosted': {'name': 'hosted_name', 'url': 'https://hosted_url'} }); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted!.name, 'hosted_name'); - expect(dep.hosted!.url.toString(), 'hosted_url'); + expect(dep.hosted!.url.toString(), 'https://hosted_url'); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); From e58f0ca25b3bad89f7b28a3099cbd88e9bff3181 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 23 Jul 2021 12:26:50 -0700 Subject: [PATCH 086/152] Bump dependency on json_serializable (dart-lang/pubspec_parse#72) --- pkgs/pubspec_parse/build.yaml | 4 +- pkgs/pubspec_parse/lib/src/dependency.dart | 2 +- pkgs/pubspec_parse/lib/src/dependency.g.dart | 97 +++++++++++--------- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 83 ++++++++--------- pkgs/pubspec_parse/pubspec.yaml | 4 +- 5 files changed, 102 insertions(+), 88 deletions(-) diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index 3e642b8f1..ddec84e33 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -19,5 +19,5 @@ targets: options: ignore_for_file: - deprecated_member_use_from_same_package - - lines_longer_than_80_chars - - prefer_expression_function_bodies + # https://github.com/google/json_serializable.dart/issues/945 + - unnecessary_cast diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index e4996c58e..20e7eb642 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -207,7 +207,7 @@ class HostedDetails { HostedDetails(this.name, this.url); - factory HostedDetails.fromJson(Object? data) { + factory HostedDetails.fromJson(Object data) { if (data is String) { data = {'name': data}; } diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 95b177993..b91756320 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, prefer_expression_function_bodies +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_cast part of 'dependency.dart'; @@ -8,51 +8,64 @@ part of 'dependency.dart'; // JsonSerializableGenerator // ************************************************************************** -SdkDependency _$SdkDependencyFromJson(Map json) { - return $checkedNew('SdkDependency', json, () { - final val = SdkDependency( - $checkedConvert(json, 'sdk', (v) => v as String), - version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String?)), +SdkDependency _$SdkDependencyFromJson(Map json) => $checkedCreate( + 'SdkDependency', + json, + ($checkedConvert) { + final val = SdkDependency( + $checkedConvert('sdk', (v) => v as String), + version: $checkedConvert( + 'version', (v) => _constraintFromString(v as String?)), + ); + return val; + }, ); - return val; - }); -} -GitDependency _$GitDependencyFromJson(Map json) { - return $checkedNew('GitDependency', json, () { - final val = GitDependency( - $checkedConvert(json, 'url', (v) => parseGitUri(v as String)), - ref: $checkedConvert(json, 'ref', (v) => v as String?), - path: $checkedConvert(json, 'path', (v) => v as String?), +GitDependency _$GitDependencyFromJson(Map json) => $checkedCreate( + 'GitDependency', + json, + ($checkedConvert) { + final val = GitDependency( + $checkedConvert('url', (v) => parseGitUri(v as String)), + ref: $checkedConvert('ref', (v) => v as String?), + path: $checkedConvert('path', (v) => v as String?), + ); + return val; + }, ); - return val; - }); -} -HostedDependency _$HostedDependencyFromJson(Map json) { - return $checkedNew('HostedDependency', json, () { - $checkKeys(json, - allowedKeys: const ['version', 'hosted'], - disallowNullValues: const ['hosted']); - final val = HostedDependency( - version: $checkedConvert( - json, 'version', (v) => _constraintFromString(v as String?)), - hosted: $checkedConvert(json, 'hosted', - (v) => v == null ? null : HostedDetails.fromJson(v as Object)), +HostedDependency _$HostedDependencyFromJson(Map json) => $checkedCreate( + 'HostedDependency', + json, + ($checkedConvert) { + $checkKeys( + json, + allowedKeys: const ['version', 'hosted'], + disallowNullValues: const ['hosted'], + ); + final val = HostedDependency( + version: $checkedConvert( + 'version', (v) => _constraintFromString(v as String?)), + hosted: $checkedConvert('hosted', + (v) => v == null ? null : HostedDetails.fromJson(v as Object)), + ); + return val; + }, ); - return val; - }); -} -HostedDetails _$HostedDetailsFromJson(Map json) { - return $checkedNew('HostedDetails', json, () { - $checkKeys(json, - allowedKeys: const ['name', 'url'], disallowNullValues: const ['url']); - final val = HostedDetails( - $checkedConvert(json, 'name', (v) => v as String), - $checkedConvert(json, 'url', (v) => parseGitUriOrNull(v as String?)), +HostedDetails _$HostedDetailsFromJson(Map json) => $checkedCreate( + 'HostedDetails', + json, + ($checkedConvert) { + $checkKeys( + json, + allowedKeys: const ['name', 'url'], + disallowNullValues: const ['url'], + ); + final val = HostedDetails( + $checkedConvert('name', (v) => v as String), + $checkedConvert('url', (v) => parseGitUriOrNull(v as String?)), + ); + return val; + }, ); - return val; - }); -} diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 72ed2a264..0231c97fa 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, prefer_expression_function_bodies +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_cast part of 'pubspec.dart'; @@ -8,44 +8,45 @@ part of 'pubspec.dart'; // JsonSerializableGenerator // ************************************************************************** -Pubspec _$PubspecFromJson(Map json) { - return $checkedNew('Pubspec', json, () { - final val = Pubspec( - $checkedConvert(json, 'name', (v) => v as String), - version: $checkedConvert( - json, 'version', (v) => _versionFromString(v as String?)), - publishTo: $checkedConvert(json, 'publish_to', (v) => v as String?), - author: $checkedConvert(json, 'author', (v) => v as String?), - authors: $checkedConvert(json, 'authors', - (v) => (v as List?)?.map((e) => e as String).toList()), - environment: $checkedConvert( - json, 'environment', (v) => _environmentMap(v as Map?)), - homepage: $checkedConvert(json, 'homepage', (v) => v as String?), - repository: $checkedConvert( - json, 'repository', (v) => v == null ? null : Uri.parse(v as String)), - issueTracker: $checkedConvert(json, 'issue_tracker', - (v) => v == null ? null : Uri.parse(v as String)), - documentation: - $checkedConvert(json, 'documentation', (v) => v as String?), - description: $checkedConvert(json, 'description', (v) => v as String?), - dependencies: - $checkedConvert(json, 'dependencies', (v) => parseDeps(v as Map?)), - devDependencies: $checkedConvert( - json, 'dev_dependencies', (v) => parseDeps(v as Map?)), - dependencyOverrides: $checkedConvert( - json, 'dependency_overrides', (v) => parseDeps(v as Map?)), - flutter: $checkedConvert( - json, - 'flutter', - (v) => (v as Map?)?.map( - (k, e) => MapEntry(k as String, e), - )), +Pubspec _$PubspecFromJson(Map json) => $checkedCreate( + 'Pubspec', + json, + ($checkedConvert) { + final val = Pubspec( + $checkedConvert('name', (v) => v as String), + version: $checkedConvert( + 'version', (v) => _versionFromString(v as String?)), + publishTo: $checkedConvert('publish_to', (v) => v as String?), + author: $checkedConvert('author', (v) => v as String?), + authors: $checkedConvert('authors', + (v) => (v as List?)?.map((e) => e as String).toList()), + environment: + $checkedConvert('environment', (v) => _environmentMap(v as Map?)), + homepage: $checkedConvert('homepage', (v) => v as String?), + repository: $checkedConvert( + 'repository', (v) => v == null ? null : Uri.parse(v as String)), + issueTracker: $checkedConvert('issue_tracker', + (v) => v == null ? null : Uri.parse(v as String)), + documentation: $checkedConvert('documentation', (v) => v as String?), + description: $checkedConvert('description', (v) => v as String?), + dependencies: + $checkedConvert('dependencies', (v) => parseDeps(v as Map?)), + devDependencies: + $checkedConvert('dev_dependencies', (v) => parseDeps(v as Map?)), + dependencyOverrides: $checkedConvert( + 'dependency_overrides', (v) => parseDeps(v as Map?)), + flutter: $checkedConvert( + 'flutter', + (v) => (v as Map?)?.map( + (k, e) => MapEntry(k as String, e), + )), + ); + return val; + }, + fieldKeyMap: const { + 'publishTo': 'publish_to', + 'issueTracker': 'issue_tracker', + 'devDependencies': 'dev_dependencies', + 'dependencyOverrides': 'dependency_overrides' + }, ); - return val; - }, fieldKeyMap: const { - 'publishTo': 'publish_to', - 'issueTracker': 'issue_tracker', - 'devDependencies': 'dev_dependencies', - 'dependencyOverrides': 'dependency_overrides' - }); -} diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index c5577b04d..3ca66711e 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -11,14 +11,14 @@ environment: dependencies: checked_yaml: ^2.0.1 collection: ^1.15.0 - json_annotation: ^4.0.0 + json_annotation: ^4.1.0 pub_semver: ^2.0.0 yaml: ^3.0.0 dev_dependencies: build_runner: ^2.0.3 build_verify: ^2.0.0 - json_serializable: ^4.0.2 + json_serializable: ^5.0.0 path: ^1.5.1 pedantic: ^1.4.0 # Needed because we are configuring `combining_builder` From e6972ca2acd3eee4f382aeef710b80b825e74ceb Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 27 Aug 2021 12:23:43 -0700 Subject: [PATCH 087/152] Ignore deprecations --- pkgs/pubspec_parse/test/test_utils.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index b66adba87..132ef647d 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -2,6 +2,7 @@ // 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. +// ignore: deprecated_member_use import 'dart:cli'; import 'dart:convert'; @@ -65,6 +66,7 @@ Pubspec parse( ProcResult? pubResult; if (!skipTryPub) { + // ignore: deprecated_member_use pubResult = waitFor(tryPub(encoded)); expect(pubResult, isNotNull); } From 82dd9795f646b26355512dcc969f76dcf45205ac Mon Sep 17 00:00:00 2001 From: Evan Weible Date: Wed, 15 Sep 2021 08:59:24 -0600 Subject: [PATCH 088/152] Export the `HostedDetails` type (dart-lang/pubspec_parse#73) This type is used by the public `HostedDependency` type, so it too should be public. --- pkgs/pubspec_parse/CHANGELOG.md | 6 ++++-- pkgs/pubspec_parse/lib/pubspec_parse.dart | 1 + pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 0c72a39d0..98fbbbf35 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,4 +1,6 @@ -## 1.0.1-dev +## 1.1.0 + +- Export `HostedDetails` publicly. ## 1.0.0 @@ -26,7 +28,7 @@ ## 0.1.4 -- Added `lenient` named argument to `Pubspec.fromJson` to ignore format and type errors. +- Added `lenient` named argument to `Pubspec.fromJson` to ignore format and type errors. ## 0.1.3 diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart index 132263a8a..63c1e30e4 100644 --- a/pkgs/pubspec_parse/lib/pubspec_parse.dart +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -6,6 +6,7 @@ export 'src/dependency.dart' show Dependency, HostedDependency, + HostedDetails, GitDependency, SdkDependency, PathDependency; diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 3ca66711e..afaa952d7 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.0.1-dev +version: 1.1.0 repository: https://github.com/dart-lang/pubspec_parse environment: From 270c69a07458d0fecfdbab9c38826224ccc13882 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 15 Oct 2021 11:38:21 -0700 Subject: [PATCH 089/152] lints: migrate to pkg:lints, enable and fix two more lints --- pkgs/pubspec_parse/CHANGELOG.md | 2 + pkgs/pubspec_parse/analysis_options.yaml | 35 +--------- pkgs/pubspec_parse/build.yaml | 2 + pkgs/pubspec_parse/lib/src/dependency.dart | 19 ++++-- pkgs/pubspec_parse/lib/src/dependency.g.dart | 2 +- pkgs/pubspec_parse/lib/src/pubspec.dart | 6 +- pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 4 +- pkgs/pubspec_parse/test/dependency_test.dart | 70 +++++++++++++------- pkgs/pubspec_parse/test/git_uri_test.dart | 3 +- pkgs/pubspec_parse/test/parse_test.dart | 64 +++++++++++------- pkgs/pubspec_parse/test/pub_utils.dart | 24 ++++--- pkgs/pubspec_parse/test/test_utils.dart | 36 ++++++---- 13 files changed, 156 insertions(+), 113 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 98fbbbf35..9cc4b52f6 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.1.1-dev + ## 1.1.0 - Export `HostedDetails` publicly. diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 39be54abb..67e23cbf6 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml analyzer: strong-mode: @@ -9,70 +9,41 @@ linter: - avoid_bool_literals_in_conditional_expressions - avoid_catching_errors - avoid_classes_with_only_static_members - - avoid_function_literals_in_foreach_calls + - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_renaming_method_parameters - avoid_returning_null - avoid_returning_null_for_future - - avoid_returning_null_for_void - avoid_returning_this - - avoid_single_cascade_in_expression_statements - avoid_unused_constructor_parameters - avoid_void_async - - await_only_futures - - camel_case_types - cancel_subscriptions - cascade_invocations - comment_references - - constant_identifier_names - - control_flow_in_finally - directives_ordering - - empty_statements - - file_names - - hash_and_equals - - implementation_imports - invariant_booleans - - iterable_contains_unrelated_type - join_return_with_assignment - lines_longer_than_80_chars - - list_remove_unrelated_type - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - non_constant_identifier_names - only_throw_errors - - overridden_fields - package_api_docs - - package_names - - package_prefixed_library_names - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_function_declarations_over_variables - - prefer_initializing_formals - - prefer_inlined_adds - prefer_interpolation_to_compose_strings - - prefer_is_not_operator - - prefer_null_aware_operators - prefer_relative_imports - - prefer_typing_uninitialized_variables - - prefer_void_to_null - - provide_deprecation_message + - require_trailing_commas - sort_pub_dependencies - test_types_in_equals - throw_in_finally - unnecessary_await_in_return - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - unnecessary_lambdas - unnecessary_null_aware_assignments - - unnecessary_overrides - unnecessary_parenthesis - unnecessary_statements - - unnecessary_string_interpolations - use_string_buffers - - void_checks diff --git a/pkgs/pubspec_parse/build.yaml b/pkgs/pubspec_parse/build.yaml index ddec84e33..2003bc29e 100644 --- a/pkgs/pubspec_parse/build.yaml +++ b/pkgs/pubspec_parse/build.yaml @@ -19,5 +19,7 @@ targets: options: ignore_for_file: - deprecated_member_use_from_same_package + - lines_longer_than_80_chars + - require_trailing_commas # https://github.com/google/json_serializable.dart/issues/945 - unnecessary_cast diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 20e7eb642..f8d3ecdc3 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -27,7 +27,11 @@ Map parseDeps(Map? source) => if (value == null) { throw CheckedFromJsonException( - source, key, 'Pubspec', 'Not a valid dependency value.'); + source, + key, + 'Pubspec', + 'Not a valid dependency value.', + ); } return MapEntry(key, value); }) ?? @@ -54,11 +58,18 @@ Dependency? _fromJson(Object? data) { return $checkedNew('Dependency', data, () { if (firstUnrecognizedKey != null) { throw UnrecognizedKeysException( - [firstUnrecognizedKey], data, _sourceKeys); + [firstUnrecognizedKey], + data, + _sourceKeys, + ); } if (matchedKeys.length > 1) { - throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', - 'A dependency may only have one source.'); + throw CheckedFromJsonException( + data, + matchedKeys[1], + 'Dependency', + 'A dependency may only have one source.', + ); } final key = matchedKeys.single; diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index b91756320..4e9d399b8 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_cast +// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, require_trailing_commas, unnecessary_cast part of 'dependency.dart'; diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index b851486ec..8cc7b09c1 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -195,7 +195,11 @@ Map? _environmentMap(Map? source) => return MapEntry(key, constraint); } else { throw CheckedFromJsonException( - source, key, 'VersionConstraint', '`$value` is not a String.'); + source, + key, + 'VersionConstraint', + '`$value` is not a String.', + ); } return MapEntry(key, constraint); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 0231c97fa..cadd38e41 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_cast +// ignore_for_file: deprecated_member_use_from_same_package, lines_longer_than_80_chars, require_trailing_commas, unnecessary_cast part of 'pubspec.dart'; diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index afaa952d7..5e51c29ab 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.1.0 +version: 1.1.1-dev repository: https://github.com/dart-lang/pubspec_parse environment: @@ -19,8 +19,8 @@ dev_dependencies: build_runner: ^2.0.3 build_verify: ^2.0.0 json_serializable: ^5.0.0 + lints: ^1.0.0 path: ^1.5.1 - pedantic: ^1.4.0 # Needed because we are configuring `combining_builder` source_gen: ^1.0.0 stack_trace: ^1.9.2 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 9ccd61434..20053a87a 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -56,12 +56,15 @@ line 6, column 11: Unsupported value for "git". A dependency may only have one s }); test('map with unsupported keys', () { - _expectThrows({'bob': 'a', 'jones': 'b'}, r''' + _expectThrows( + {'bob': 'a', 'jones': 'b'}, + r''' line 5, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ 5 │ "bob": "a", │ ^^^^^ - ╵'''); + ╵''', + ); }); }); } @@ -133,21 +136,25 @@ line 5, column 15: Unsupported value for "version". Could not parse version "not }); test('map w/ extra keys should fail', () { - _expectThrows({ - 'version': '^1.0.0', - 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, - 'not_supported': null - }, r''' + _expectThrows( + { + 'version': '^1.0.0', + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, + 'not_supported': null + }, + r''' line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git, path, hosted] ╷ 10 │ "not_supported": null │ ^^^^^^^^^^^^^^^ - ╵'''); + ╵''', + ); }); test('map w/ version and hosted as String', () { final dep = _dependency( - {'version': '^1.0.0', 'hosted': 'hosted_name'}); + {'version': '^1.0.0', 'hosted': 'hosted_name'}, + ); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted!.name, 'hosted_name'); expect(dep.hosted!.url, isNull); @@ -192,7 +199,8 @@ void _sdkDependency() { test('with version', () { final dep = _dependency( - {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}); + {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}, + ); expect(dep.sdk, 'flutter'); expect(dep.version.toString(), '>=1.2.3 <2.0.0'); expect(dep.toString(), 'SdkDependency: flutter'); @@ -250,8 +258,10 @@ void _gitDependency() { if (skipTryParse) { print('FYI: not validating git@ URI on travis due to failure'); } - final dep = _dependency({'git': 'git@localhost:dep.git'}, - skipTryPub: skipTryParse); + final dep = _dependency( + {'git': 'git@localhost:dep.git'}, + skipTryPub: skipTryParse, + ); expect(dep.url.toString(), 'ssh://git@localhost/dep.git'); expect(dep.path, isNull); expect(dep.ref, isNull); @@ -259,12 +269,15 @@ void _gitDependency() { }); test('string with random extra key fails', () { - _expectThrows({'git': 'url', 'bob': '^1.2.3'}, r''' + _expectThrows( + {'git': 'url', 'bob': '^1.2.3'}, + r''' line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ 6 │ "bob": "^1.2.3" │ ^^^^^ - ╵'''); + ╵''', + ); }); test('map', () { @@ -365,12 +378,15 @@ void _pathDependency() { }); test('valid with random extra key fails', () { - _expectThrows({'path': '../path', 'bob': '^1.2.3'}, r''' + _expectThrows( + {'path': '../path', 'bob': '^1.2.3'}, + r''' line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hosted] ╷ 6 │ "bob": "^1.2.3" │ ^^^^^ - ╵'''); + ╵''', + ); }); test('null content', () { @@ -403,20 +419,26 @@ line 5, column 12: Unsupported value for "path". Must be a String. } void _expectThrows(Object content, String expectedError) { - expectParseThrows({ - 'name': 'sample', - 'dependencies': {'dep': content} - }, expectedError); + expectParseThrows( + { + 'name': 'sample', + 'dependencies': {'dep': content} + }, + expectedError, + ); } T _dependency( Object? content, { bool skipTryPub = false, }) { - final value = parse({ - ...defaultPubspec, - 'dependencies': {'dep': content} - }, skipTryPub: skipTryPub); + final value = parse( + { + ...defaultPubspec, + 'dependencies': {'dep': content} + }, + skipTryPub: skipTryPub, + ); expect(value.name, 'sample'); expect(value.dependencies, hasLength(1)); diff --git a/pkgs/pubspec_parse/test/git_uri_test.dart b/pkgs/pubspec_parse/test/git_uri_test.dart index 36e55a84c..be89ba8a0 100644 --- a/pkgs/pubspec_parse/test/git_uri_test.dart +++ b/pkgs/pubspec_parse/test/git_uri_test.dart @@ -16,7 +16,8 @@ void main() { final uri = parseGitUri(item.key); printOnFailure( - [uri.scheme, uri.userInfo, uri.host, uri.port, uri.path].join('\n')); + [uri.scheme, uri.userInfo, uri.host, uri.port, uri.path].join('\n'), + ); expect(uri, Uri.parse(item.value)); }); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 52df370d0..5f70de8ba 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -62,8 +62,10 @@ void main() { expect(value.devDependencies, isEmpty); expect(value.dependencyOverrides, isEmpty); expect(value.repository, Uri.parse('https://github.com/example/repo')); - expect(value.issueTracker, - Uri.parse('https://github.com/example/repo/issues')); + expect( + value.issueTracker, + Uri.parse('https://github.com/example/repo/issues'), + ); }); test('environment values can be null', () { @@ -212,12 +214,15 @@ line 1, column 1: Not a map ); }); test('array', () { - expectParseThrows([], r''' + expectParseThrows( + [], + r''' line 1, column 1: Not a map ╷ 1 │ [] │ ^^ - ╵'''); + ╵''', + ); }); test('missing name', () { @@ -257,15 +262,18 @@ line 2, column 10: Unsupported value for "name". "name" cannot be empty. }); test('"dart" is an invalid environment key', () { - expectParseThrows({ - 'name': 'sample', - 'environment': {'dart': 'cool'} - }, r''' + expectParseThrows( + { + 'name': 'sample', + 'environment': {'dart': 'cool'} + }, + r''' line 4, column 3: Use "sdk" to for Dart SDK constraints. ╷ 4 │ "dart": "cool" │ ^^^^^^ - ╵'''); + ╵''', + ); }); test('environment values cannot be int', () { @@ -298,15 +306,18 @@ line 3, column 13: Unsupported value for "version". Could not parse "invalid". }); test('invalid environment value', () { - expectParseThrows({ - 'name': 'sample', - 'environment': {'sdk': 'silly'} - }, r''' + expectParseThrows( + { + 'name': 'sample', + 'environment': {'sdk': 'silly'} + }, + r''' line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". Unknown text at "silly". ╷ 4 │ "sdk": "silly" │ ^^^^^^^ - ╵'''); + ╵''', + ); }); test('bad repository url', () { @@ -426,16 +437,21 @@ line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'Stri test('deep error throws with lenient', () { expect( - () => parse({ - 'name': 'sample', - 'dependencies': { - 'foo': { - 'git': {'url': 1} - }, - }, - 'issue_tracker': {'x': 'y'}, - }, skipTryPub: true, lenient: true), - throwsException); + () => parse( + { + 'name': 'sample', + 'dependencies': { + 'foo': { + 'git': {'url': 1} + }, + }, + 'issue_tracker': {'x': 'y'}, + }, + skipTryPub: true, + lenient: true, + ), + throwsException, + ); }); }); } diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index 17e8970f7..5871b1b9c 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -23,21 +23,25 @@ Future tryPub(String content) async { final result = await ProcResult.fromTestProcess(proc); - printOnFailure([ - '-----BEGIN pub output-----', - result.toString().trim(), - '-----END pub output-----', - ].join('\n')); + printOnFailure( + [ + '-----BEGIN pub output-----', + result.toString().trim(), + '-----END pub output-----', + ].join('\n'), + ); if (result.exitCode == 0) { final lockContent = File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); - printOnFailure([ - '-----BEGIN pubspec.lock-----', - lockContent.trim(), - '-----END pubspec.lock-----', - ].join('\n')); + printOnFailure( + [ + '-----BEGIN pubspec.lock-----', + lockContent.trim(), + '-----END pubspec.lock-----', + ].join('\n'), + ); } return result; diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 132ef647d..72d214242 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -22,13 +22,18 @@ const defaultPubspec = { String _encodeJson(Object? input) => const JsonEncoder.withIndent(' ').convert(input); -Matcher _throwsParsedYamlException(String prettyValue) => - throwsA(const TypeMatcher().having((e) { - final message = e.formattedMessage; - printOnFailure("Actual error format:\nr'''\n$message'''"); - _printDebugParsedYamlException(e); - return message; - }, 'formattedMessage', prettyValue)); +Matcher _throwsParsedYamlException(String prettyValue) => throwsA( + const TypeMatcher().having( + (e) { + final message = e.formattedMessage; + printOnFailure("Actual error format:\nr'''\n$message'''"); + _printDebugParsedYamlException(e); + return message; + }, + 'formattedMessage', + prettyValue, + ), + ); void _printDebugParsedYamlException(ParsedYamlException e) { var innerError = e.innerError; @@ -76,18 +81,23 @@ Pubspec parse( if (pubResult != null) { addTearDown(() { - expect(pubResult!.cleanParse, isTrue, - reason: - 'On success, parsing from the pub client should also succeed.'); + expect( + pubResult!.cleanParse, + isTrue, + reason: + 'On success, parsing from the pub client should also succeed.', + ); }); } return value; } catch (e) { if (pubResult != null) { addTearDown(() { - expect(pubResult!.cleanParse, isFalse, - reason: - 'On failure, parsing from the pub client should also fail.'); + expect( + pubResult!.cleanParse, + isFalse, + reason: 'On failure, parsing from the pub client should also fail.', + ); }); } if (e is ParsedYamlException) { From 920a12be7eb1c326a0b735e4e3e3d6cd68e6060d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 15 Oct 2021 11:45:22 -0700 Subject: [PATCH 090/152] Update to the latest pkg:json_serializable --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 2 ++ pkgs/pubspec_parse/pubspec.yaml | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index df7aeb463..a818a1b94 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.14.0, dev] steps: - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v1.0 diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 9cc4b52f6..2601ee4ed 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,5 +1,7 @@ ## 1.1.1-dev +- Require Dart SDK >= 2.14.0 + ## 1.1.0 - Export `HostedDetails` publicly. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 5e51c29ab..d19201e05 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -6,19 +6,19 @@ version: 1.1.1-dev repository: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.14.0 <3.0.0' dependencies: checked_yaml: ^2.0.1 collection: ^1.15.0 - json_annotation: ^4.1.0 + json_annotation: ^4.3.0 pub_semver: ^2.0.0 yaml: ^3.0.0 dev_dependencies: build_runner: ^2.0.3 build_verify: ^2.0.0 - json_serializable: ^5.0.0 + json_serializable: ^6.0.0 lints: ^1.0.0 path: ^1.5.1 # Needed because we are configuring `combining_builder` From 517e7d9703dd5b35559368188c62430cb4c8a7f5 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Thu, 4 Nov 2021 10:20:38 +0100 Subject: [PATCH 091/152] Match hosted shorthand syntax from Dart 2.15 (dart-lang/pubspec_parse#74) * Match hosted shorthand syntax from Dart 2.15 --- pkgs/pubspec_parse/CHANGELOG.md | 9 ++++++ pkgs/pubspec_parse/lib/src/dependency.dart | 28 ++++++++++++++---- pkgs/pubspec_parse/lib/src/dependency.g.dart | 3 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/dependency_test.dart | 30 ++++++++++++++++---- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 2601ee4ed..8f2d28897 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.2.0-dev + +- Update `HostedDetails` to reflect how `hosted` dependencies are parsed in + Dart 2.15: + - Add `HostedDetails.declaredName` as the (optional) `name` property in a + `hosted` block. + - `HostedDetails.name` now falls back to the name of the dependency if no + name is declared in the block. + ## 1.1.1-dev - Require Dart SDK >= 2.14.0 diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index f8d3ecdc3..8b59f7367 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -14,7 +14,7 @@ Map parseDeps(Map? source) => final key = k as String; Dependency? value; try { - value = _fromJson(v); + value = _fromJson(v, k); } on CheckedFromJsonException catch (e) { if (e.map is! YamlMap) { // This is likely a "synthetic" map created from a String value @@ -40,7 +40,7 @@ Map parseDeps(Map? source) => const _sourceKeys = ['sdk', 'git', 'path', 'hosted']; /// Returns `null` if the data could not be parsed. -Dependency? _fromJson(Object? data) { +Dependency? _fromJson(Object? data, String name) { if (data is String || data == null) { return _$HostedDependencyFromJson({'version': data}); } @@ -82,7 +82,9 @@ Dependency? _fromJson(Object? data) { case 'sdk': return _$SdkDependencyFromJson(data); case 'hosted': - return _$HostedDependencyFromJson(data); + final hosted = _$HostedDependencyFromJson(data); + hosted.hosted?._nameOfPackage = name; + return hosted; } throw StateError('There is a bug in pubspec_parse.'); }); @@ -211,16 +213,30 @@ class HostedDependency extends Dependency { @JsonSerializable(disallowUnrecognizedKeys: true) class HostedDetails { - final String name; + /// The name of the target dependency as declared in a `hosted` block. + /// + /// This may be null if no explicit name is present, for instance because the + /// hosted dependency was declared as a string (`hosted: pub.example.org`). + @JsonKey(name: 'name') + final String? declaredName; @JsonKey(fromJson: parseGitUriOrNull, disallowNullValue: true) final Uri? url; - HostedDetails(this.name, this.url); + @JsonKey(ignore: true) + String? _nameOfPackage; + + /// The name of this package on the package repository. + /// + /// If this hosted block has a [declaredName], that one will be used. + /// Otherwise, the name will be inferred from the surrounding package name. + String get name => declaredName ?? _nameOfPackage!; + + HostedDetails(this.declaredName, this.url); factory HostedDetails.fromJson(Object data) { if (data is String) { - data = {'name': data}; + data = {'url': data}; } if (data is Map) { diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 4e9d399b8..1a504f1fd 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -63,9 +63,10 @@ HostedDetails _$HostedDetailsFromJson(Map json) => $checkedCreate( disallowNullValues: const ['url'], ); final val = HostedDetails( - $checkedConvert('name', (v) => v as String), + $checkedConvert('name', (v) => v as String?), $checkedConvert('url', (v) => parseGitUriOrNull(v as String?)), ); return val; }, + fieldKeyMap: const {'declaredName': 'name'}, ); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index d19201e05..90ae1fef6 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.1.1-dev +version: 1.2.0-dev repository: https://github.com/dart-lang/pubspec_parse environment: diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 20053a87a..da7badcee 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -120,6 +120,21 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); + test('map /w hosted as a map without name', () { + final dep = _dependency( + { + 'version': '^1.0.0', + 'hosted': {'url': 'https://hosted_url'} + }, + skipTryPub: true, // todo: Unskip once pub supports this syntax + ); + expect(dep.version.toString(), '^1.0.0'); + expect(dep.hosted!.declaredName, isNull); + expect(dep.hosted!.name, 'dep'); + expect(dep.hosted!.url.toString(), 'https://hosted_url'); + expect(dep.toString(), 'HostedDependency: ^1.0.0'); + }); + test('map w/ bad version value', () { _expectThrows( { @@ -153,19 +168,22 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git test('map w/ version and hosted as String', () { final dep = _dependency( - {'version': '^1.0.0', 'hosted': 'hosted_name'}, + {'version': '^1.0.0', 'hosted': 'hosted_url'}, + skipTryPub: true, // todo: Unskip once put supports this ); expect(dep.version.toString(), '^1.0.0'); - expect(dep.hosted!.name, 'hosted_name'); - expect(dep.hosted!.url, isNull); + expect(dep.hosted!.declaredName, isNull); + expect(dep.hosted!.name, 'dep'); + expect(dep.hosted!.url, Uri.parse('hosted_url')); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); test('map w/ hosted as String', () { - final dep = _dependency({'hosted': 'hosted_name'}); + final dep = _dependency({'hosted': 'hosted_url'}); expect(dep.version, VersionConstraint.any); - expect(dep.hosted!.name, 'hosted_name'); - expect(dep.hosted!.url, isNull); + expect(dep.hosted!.declaredName, isNull); + expect(dep.hosted!.name, 'dep'); + expect(dep.hosted!.url, Uri.parse('hosted_url')); expect(dep.toString(), 'HostedDependency: any'); }); From 411e9462ce5cc12c67006589a9c801952e5b66d6 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Tue, 7 Dec 2021 13:07:49 +0100 Subject: [PATCH 092/152] Add support for 'screenshots' field (dart-lang/pubspec_parse#78) --- pkgs/pubspec_parse/CHANGELOG.md | 6 +- pkgs/pubspec_parse/lib/pubspec_parse.dart | 1 + pkgs/pubspec_parse/lib/src/pubspec.dart | 6 + pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 + pkgs/pubspec_parse/lib/src/screenshot.dart | 65 +++++++++ pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 161 +++++++++++++++++++++ 7 files changed, 238 insertions(+), 5 deletions(-) create mode 100644 pkgs/pubspec_parse/lib/src/screenshot.dart diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 8f2d28897..5f3d5d6ec 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,14 +1,12 @@ -## 1.2.0-dev +## 1.2.0 +- Added support for `screenshots` field. - Update `HostedDetails` to reflect how `hosted` dependencies are parsed in Dart 2.15: - Add `HostedDetails.declaredName` as the (optional) `name` property in a `hosted` block. - `HostedDetails.name` now falls back to the name of the dependency if no name is declared in the block. - -## 1.1.1-dev - - Require Dart SDK >= 2.14.0 ## 1.1.0 diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart index 63c1e30e4..7360d1ac9 100644 --- a/pkgs/pubspec_parse/lib/pubspec_parse.dart +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -11,3 +11,4 @@ export 'src/dependency.dart' SdkDependency, PathDependency; export 'src/pubspec.dart' show Pubspec; +export 'src/screenshot.dart' show Screenshot; diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 8cc7b09c1..82c78aa7c 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -7,6 +7,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pub_semver/pub_semver.dart'; import 'dependency.dart'; +import 'screenshot.dart'; part 'pubspec.g.dart'; @@ -39,6 +40,10 @@ class Pubspec { /// view existing ones. final Uri? issueTracker; + /// Optional field for specifying included screenshot files. + @JsonKey(fromJson: parseScreenshots) + final List? screenshots; + /// If there is exactly 1 value in [authors], returns it. /// /// If there are 0 or more than 1, returns `null`. @@ -96,6 +101,7 @@ class Pubspec { this.homepage, this.repository, this.issueTracker, + this.screenshots, this.documentation, this.description, Map? dependencies, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index cadd38e41..221cc8347 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -27,6 +27,8 @@ Pubspec _$PubspecFromJson(Map json) => $checkedCreate( 'repository', (v) => v == null ? null : Uri.parse(v as String)), issueTracker: $checkedConvert('issue_tracker', (v) => v == null ? null : Uri.parse(v as String)), + screenshots: $checkedConvert( + 'screenshots', (v) => parseScreenshots(v as List?)), documentation: $checkedConvert('documentation', (v) => v as String?), description: $checkedConvert('description', (v) => v as String?), dependencies: diff --git a/pkgs/pubspec_parse/lib/src/screenshot.dart b/pkgs/pubspec_parse/lib/src/screenshot.dart new file mode 100644 index 000000000..f5f0be2ea --- /dev/null +++ b/pkgs/pubspec_parse/lib/src/screenshot.dart @@ -0,0 +1,65 @@ +// Copyright (c) 2021, 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:json_annotation/json_annotation.dart'; + +@JsonSerializable() +class Screenshot { + final String description; + final String path; + + Screenshot(this.description, this.path); +} + +List parseScreenshots(List? input) { + final res = []; + if (input == null) { + return res; + } + + for (final e in input) { + if (e is! Map) continue; + + final description = e['description']; + if (description == null) { + throw CheckedFromJsonException( + e, + 'description', + 'Screenshot', + 'Missing required key `description`', + ); + } + + if (description is! String) { + throw CheckedFromJsonException( + e, + 'description', + 'Screenshot', + '`$description` is not a String', + ); + } + + final path = e['path']; + if (path == null) { + throw CheckedFromJsonException( + e, + 'path', + 'Screenshot', + 'Missing required key `path`', + ); + } + + if (path is! String) { + throw CheckedFromJsonException( + e, + 'path', + 'Screenshot', + '`$path` is not a String', + ); + } + + res.add(Screenshot(description, path)); + } + return res; +} diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 90ae1fef6..ae7a03f96 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.0-dev +version: 1.2.0 repository: https://github.com/dart-lang/pubspec_parse environment: diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 5f70de8ba..e8d24c624 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -31,6 +31,7 @@ void main() { expect(value.flutter, isNull); expect(value.repository, isNull); expect(value.issueTracker, isNull); + expect(value.screenshots, isEmpty); }); test('all fields set', () { @@ -47,6 +48,9 @@ void main() { 'documentation': 'documentation', 'repository': 'https://github.com/example/repo', 'issue_tracker': 'https://github.com/example/repo/issues', + 'screenshots': [ + {'description': 'my screenshot', 'path': 'path/to/screenshot'} + ], }); expect(value.name, 'sample'); expect(value.version, version); @@ -66,6 +70,9 @@ void main() { value.issueTracker, Uri.parse('https://github.com/example/repo/issues'), ); + expect(value.screenshots, hasLength(1)); + expect(value.screenshots!.first.description, 'my screenshot'); + expect(value.screenshots!.first.path, 'path/to/screenshot'); }); test('environment values can be null', () { @@ -357,6 +364,160 @@ line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not }); }); + group('screenshots', () { + test('one screenshot', () { + final value = parse({ + ...defaultPubspec, + 'screenshots': [ + {'description': 'my screenshot', 'path': 'path/to/screenshot'} + ], + }); + expect(value.screenshots, hasLength(1)); + expect(value.screenshots!.first.description, 'my screenshot'); + expect(value.screenshots!.first.path, 'path/to/screenshot'); + }); + + test('many screenshots', () { + final value = parse({ + ...defaultPubspec, + 'screenshots': [ + {'description': 'my screenshot', 'path': 'path/to/screenshot'}, + { + 'description': 'my second screenshot', + 'path': 'path/to/screenshot2' + }, + ], + }); + expect(value.screenshots, hasLength(2)); + expect(value.screenshots!.first.description, 'my screenshot'); + expect(value.screenshots!.first.path, 'path/to/screenshot'); + expect(value.screenshots!.last.description, 'my second screenshot'); + expect(value.screenshots!.last.path, 'path/to/screenshot2'); + }); + + test('one screenshot plus invalid entries', () { + final value = parse({ + ...defaultPubspec, + 'screenshots': [ + 42, + { + 'description': 'my screenshot', + 'path': 'path/to/screenshot', + 'extraKey': 'not important' + }, + 'not a screenshot', + ], + }); + expect(value.screenshots, hasLength(1)); + expect(value.screenshots!.first.description, 'my screenshot'); + expect(value.screenshots!.first.path, 'path/to/screenshot'); + }); + + test('invalid entries', () { + final value = parse({ + ...defaultPubspec, + 'screenshots': [ + 42, + 'not a screenshot', + ], + }); + expect(value.screenshots, isEmpty); + }); + + test('missing key `dessription', () { + expectParseThrows( + { + ...defaultPubspec, + 'screenshots': [ + {'path': 'my/path'}, + ], + }, + r''' +line 7, column 3: Missing key "description". Missing required key `description` + ╷ +7 │ ┌ { +8 │ │ "path": "my/path" +9 │ └ } + ╵''', + skipTryPub: true, + ); + }); + + test('missing key `path`', () { + expectParseThrows( + { + ...defaultPubspec, + 'screenshots': [ + {'description': 'my screenshot'}, + ], + }, + r''' +line 7, column 3: Missing key "path". Missing required key `path` + ╷ +7 │ ┌ { +8 │ │ "description": "my screenshot" +9 │ └ } + ╵''', + skipTryPub: true, + ); + }); + + test('Value of description not a String`', () { + expectParseThrows( + { + ...defaultPubspec, + 'screenshots': [ + {'description': 42}, + ], + }, + r''' +line 8, column 19: Unsupported value for "description". `42` is not a String + ╷ +8 │ "description": 42 + │ ┌───────────────────^ +9 │ │ } + │ └──^ + ╵''', + skipTryPub: true, + ); + }); + + test('Value of path not a String`', () { + expectParseThrows( + { + ...defaultPubspec, + 'screenshots': [ + { + 'description': '', + 'path': 42, + }, + ], + }, + r''' +line 9, column 12: Unsupported value for "path". `42` is not a String + ╷ +9 │ "path": 42 + │ ┌────────────^ +10 │ │ } + │ └──^ + ╵''', + skipTryPub: true, + ); + }); + + test('invalid screenshot - lenient', () { + final value = parse( + { + ...defaultPubspec, + 'screenshots': 'Invalid value', + }, + lenient: true, + ); + expect(value.name, 'sample'); + expect(value.screenshots, isEmpty); + }); + }); + group('lenient', () { test('null', () { expectParseThrows( From 0edf0946d2651627cb0a9b5328a34c93d3749081 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 12 Jan 2022 08:41:49 -0800 Subject: [PATCH 093/152] Support latest pkg:build_verify (dart-lang/pubspec_parse#79) --- pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/ensure_build_test.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index ae7a03f96..c2be3dc78 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.3 - build_verify: ^2.0.0 + build_verify: '>=2.0.0 <4.0.0' json_serializable: ^6.0.0 lints: ^1.0.0 path: ^1.5.1 diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index d64fa4f66..612b837e9 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -2,6 +2,7 @@ // 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. +@Timeout.factor(2) @TestOn('vm') @Tags(['presubmit-only']) import 'package:build_verify/build_verify.dart'; From a274a38b7eb49ee817434d64a7afe8115132f0fc Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 6 Feb 2022 15:31:30 -0800 Subject: [PATCH 094/152] Fix test due to recent pub change Support SDKs are new checked --- pkgs/pubspec_parse/test/parse_test.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index e8d24c624..397a728e9 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -76,13 +76,16 @@ void main() { }); test('environment values can be null', () { - final value = parse({ - 'name': 'sample', - 'environment': { - 'sdk': '>=2.7.0 <3.0.0', - 'bob': null, - } - }); + final value = parse( + { + 'name': 'sample', + 'environment': { + 'sdk': '>=2.7.0 <3.0.0', + 'bob': null, + } + }, + skipTryPub: true, + ); expect(value.name, 'sample'); expect(value.environment, hasLength(2)); expect(value.environment, containsPair('bob', isNull)); From 20b42094d4047025d7371446d21b34ed3e0a1541 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 6 Feb 2022 15:33:36 -0800 Subject: [PATCH 095/152] Update readme version link and bump version in changelog/pubspec --- pkgs/pubspec_parse/CHANGELOG.md | 2 ++ pkgs/pubspec_parse/README.md | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 5f3d5d6ec..6b5a04d22 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.2.1-dev + ## 1.2.0 - Added support for `screenshots` field. diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index ed00eed97..eca3610fd 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,5 +1,5 @@ [![Build Status](https://github.com/dart-lang/pubspec_parse/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/pubspec_parse/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) -[![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/pubspec_parse) +[![pub package](https://img.shields.io/pub/v/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse) Supports parsing `pubspec.yaml` files with robust error reporting and support for most of the documented features. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index c2be3dc78..3932fd90f 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.0 +version: 1.2.1-dev repository: https://github.com/dart-lang/pubspec_parse environment: From 539845c90add4e8c2ab446aa14e8224b8ae383fc Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 6 Feb 2022 15:37:29 -0800 Subject: [PATCH 096/152] Bump min version of json_annotation --- pkgs/pubspec_parse/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 3932fd90f..bb9636969 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: checked_yaml: ^2.0.1 collection: ^1.15.0 - json_annotation: ^4.3.0 + json_annotation: ^4.4.0 pub_semver: ^2.0.0 yaml: ^3.0.0 From 8aa107ec75c59c069bd1efc69f6155a9411cdc05 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 14 Feb 2022 12:06:52 -0800 Subject: [PATCH 097/152] fix pub usage in tests (dart-lang/pubspec_parse#81) --- pkgs/pubspec_parse/test/pub_utils.dart | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index 5871b1b9c..a60aa2a99 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -14,8 +14,8 @@ Future tryPub(String content) async { await d.file('pubspec.yaml', content).create(); final proc = await TestProcess.start( - _pubPath, - ['get', '--offline'], + Platform.resolvedExecutable, + ['pub', 'get', '--offline'], workingDirectory: d.sandbox, // Don't pass current process VM options to child environment: Map.from(Platform.environment)..remove('DART_VM_OPTIONS'), @@ -86,15 +86,3 @@ class ProcLine { @override String toString() => '${isError ? 'err' : 'out'} $line'; } - -/// The path to the root directory of the SDK. -final String _sdkDir = () { - // The Dart executable is in "/path/to/sdk/bin/dart", so two levels up is - // "/path/to/sdk". - final aboveExecutable = p.dirname(p.dirname(Platform.resolvedExecutable)); - assert(FileSystemEntity.isFileSync(p.join(aboveExecutable, 'version'))); - return aboveExecutable; -}(); - -final String _pubPath = - p.join(_sdkDir, 'bin', Platform.isWindows ? 'pub.bat' : 'pub'); From 622fee46fd6ace80c5e816591b9b22de693f0c86 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 1 Aug 2022 09:41:14 -0700 Subject: [PATCH 098/152] Drop invariant booleans (dart-lang/pubspec_parse#82) Move to "newer" language check in analysis options --- pkgs/pubspec_parse/analysis_options.yaml | 6 +++--- pkgs/pubspec_parse/test/dependency_test.dart | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 67e23cbf6..fdc60e0db 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -1,8 +1,9 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false + language: + strict-casts: true + strict-inference: true linter: rules: @@ -21,7 +22,6 @@ linter: - cascade_invocations - comment_references - directives_ordering - - invariant_booleans - join_return_with_assignment - lines_longer_than_80_chars - literal_only_boolean_expressions diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index da7badcee..8fb48e867 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -338,7 +338,7 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. test('git - empty map', () { _expectThrows( - {'git': {}}, + {'git': {}}, r''' line 5, column 11: Missing key "url". type 'Null' is not a subtype of type 'String' in type cast ╷ From 615f8bbe04ba761d936de07e75ac6cbade33e097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?= Date: Thu, 18 Aug 2022 15:20:46 +0200 Subject: [PATCH 099/152] Support the 'funding' field. (dart-lang/pubspec_parse#83) --- pkgs/pubspec_parse/CHANGELOG.md | 4 ++ pkgs/pubspec_parse/lib/src/pubspec.dart | 5 ++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 5 ++ pkgs/pubspec_parse/pubspec.yaml | 4 +- pkgs/pubspec_parse/test/parse_test.dart | 59 +++++++++++++++++++++++ 5 files changed, 75 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 6b5a04d22..069e81ceb 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,5 +1,9 @@ ## 1.2.1-dev +## 1.2.1 + +- Added support for `funding` field. + ## 1.2.0 - Added support for `screenshots` field. diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 82c78aa7c..9943da8a4 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -40,6 +40,10 @@ class Pubspec { /// view existing ones. final Uri? issueTracker; + /// Optional field to list the URLs where the package authors accept + /// support or funding. + final List? funding; + /// Optional field for specifying included screenshot files. @JsonKey(fromJson: parseScreenshots) final List? screenshots; @@ -101,6 +105,7 @@ class Pubspec { this.homepage, this.repository, this.issueTracker, + this.funding, this.screenshots, this.documentation, this.description, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 221cc8347..a1312a556 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -27,6 +27,11 @@ Pubspec _$PubspecFromJson(Map json) => $checkedCreate( 'repository', (v) => v == null ? null : Uri.parse(v as String)), issueTracker: $checkedConvert('issue_tracker', (v) => v == null ? null : Uri.parse(v as String)), + funding: $checkedConvert( + 'funding', + (v) => (v as List?) + ?.map((e) => Uri.parse(e as String)) + .toList()), screenshots: $checkedConvert( 'screenshots', (v) => parseScreenshots(v as List?)), documentation: $checkedConvert('documentation', (v) => v as String?), diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index bb9636969..23f15c160 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.1-dev +version: 1.2.1 repository: https://github.com/dart-lang/pubspec_parse environment: @@ -11,7 +11,7 @@ environment: dependencies: checked_yaml: ^2.0.1 collection: ^1.15.0 - json_annotation: ^4.4.0 + json_annotation: ^4.6.0 pub_semver: ^2.0.0 yaml: ^3.0.0 diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 397a728e9..a12d034fd 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -48,6 +48,9 @@ void main() { 'documentation': 'documentation', 'repository': 'https://github.com/example/repo', 'issue_tracker': 'https://github.com/example/repo/issues', + 'funding': [ + 'https://patreon.com/example', + ], 'screenshots': [ {'description': 'my screenshot', 'path': 'path/to/screenshot'} ], @@ -70,6 +73,8 @@ void main() { value.issueTracker, Uri.parse('https://github.com/example/repo/issues'), ); + expect(value.funding, hasLength(1)); + expect(value.funding!.single.toString(), 'https://patreon.com/example'); expect(value.screenshots, hasLength(1)); expect(value.screenshots!.first.description, 'my screenshot'); expect(value.screenshots!.first.path, 'path/to/screenshot'); @@ -367,6 +372,60 @@ line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not }); }); + group('funding', () { + test('not a list', () { + expectParseThrows( + { + ...defaultPubspec, + 'funding': 1, + }, + r''' +line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'List?' in type cast + ╷ +6 │ "funding": 1 + │ ^ + ╵''', + skipTryPub: true, + ); + }); + + test('not an uri', () { + expectParseThrows( + { + ...defaultPubspec, + 'funding': [1], + }, + r''' +line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'String' in type cast + ╷ +6 │ "funding": [ + │ ┌─────────────^ +7 │ │ 1 +8 │ └ ] + ╵''', + skipTryPub: true, + ); + }); + + test('not an uri', () { + expectParseThrows( + { + ...defaultPubspec, + 'funding': ['ht tps://example.com/'], + }, + r''' +line 6, column 13: Unsupported value for "funding". Illegal scheme character at offset 2. + ╷ +6 │ "funding": [ + │ ┌─────────────^ +7 │ │ "ht tps://example.com/" +8 │ └ ] + ╵''', + skipTryPub: true, + ); + }); + }); + group('screenshots', () { test('one screenshot', () { final value = parse({ From f7a9b1d31a07592936244f582911c4465f191230 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 9 Nov 2022 15:26:32 -0800 Subject: [PATCH 100/152] blast_repo fixes (dart-lang/pubspec_parse#85) Dependabot GitHub Action --- pkgs/pubspec_parse/.github/dependabot.yml | 9 +++++++++ pkgs/pubspec_parse/.github/workflows/test-package.yml | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 pkgs/pubspec_parse/.github/dependabot.yml diff --git a/pkgs/pubspec_parse/.github/dependabot.yml b/pkgs/pubspec_parse/.github/dependabot.yml new file mode 100644 index 000000000..1603cdd9e --- /dev/null +++ b/pkgs/pubspec_parse/.github/dependabot.yml @@ -0,0 +1,9 @@ +# Dependabot configuration file. +# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index a818a1b94..53753996a 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -48,8 +48,8 @@ jobs: os: [ubuntu-latest] sdk: [2.14.0, dev] steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install From da1376283ea31817d855805e275b2318568a8983 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 12 Dec 2022 14:14:19 -0800 Subject: [PATCH 101/152] fix the unit tests for Dart 3.0 (dart-lang/pubspec_parse#86) * fix the unit tests for Dart 3.0 * update the package version --- .../.github/workflows/test-package.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 5 +- pkgs/pubspec_parse/LICENSE | 2 +- pkgs/pubspec_parse/README.md | 7 +- pkgs/pubspec_parse/pubspec.yaml | 6 +- pkgs/pubspec_parse/test/dependency_test.dart | 63 +++++--------- pkgs/pubspec_parse/test/parse_test.dart | 86 +++++-------------- pkgs/pubspec_parse/test/test_utils.dart | 35 +++++++- 8 files changed, 90 insertions(+), 116 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 53753996a..c46df3002 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.14.0, dev] + sdk: [2.17.0, dev] steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 069e81ceb..117fd129e 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,4 +1,7 @@ -## 1.2.1-dev +## 1.2.2-dev + +- Update SDK requirement to `2.17.0`. +- Fix the unit tests for Dart 3.0.0. ## 1.2.1 diff --git a/pkgs/pubspec_parse/LICENSE b/pkgs/pubspec_parse/LICENSE index 9972f6e70..4d1ad40a1 100644 --- a/pkgs/pubspec_parse/LICENSE +++ b/pkgs/pubspec_parse/LICENSE @@ -1,4 +1,4 @@ -Copyright 2018, the Dart project authors. +Copyright 2018, the Dart project authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index eca3610fd..916742a63 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,7 +1,12 @@ -[![Build Status](https://github.com/dart-lang/pubspec_parse/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/pubspec_parse/actions?query=workflow%3A"Dart+CI"+branch%3Amaster) +[![Dart CI](https://github.com/dart-lang/pubspec_parse/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/pubspec_parse/actions/workflows/test-package.yml) [![pub package](https://img.shields.io/pub/v/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse) +[![package publisher](https://img.shields.io/pub/publisher/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse/publisher) + +## What's this? Supports parsing `pubspec.yaml` files with robust error reporting and support for most of the documented features. +## More information + Read more about the [pubspec format](https://dart.dev/tools/pub/pubspec). diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 23f15c160..03f61bd80 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,11 +2,11 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.1 +version: 1.2.2-dev repository: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.14.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: checked_yaml: ^2.0.1 @@ -19,7 +19,7 @@ dev_dependencies: build_runner: ^2.0.3 build_verify: '>=2.0.0 <4.0.0' json_serializable: ^6.0.0 - lints: ^1.0.0 + lints: ^2.0.0 path: ^1.5.1 # Needed because we are configuring `combining_builder` source_gen: ^1.0.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 8fb48e867..b366887a3 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -225,30 +225,16 @@ void _sdkDependency() { }); test('null content', () { - _expectThrows( + _expectThrowsContaining( {'sdk': null}, - r''' -line 5, column 11: Unsupported value for "sdk". type 'Null' is not a subtype of type 'String' in type cast - ╷ -5 │ "sdk": null - │ ┌───────────^ -6 │ │ } - │ └──^ - ╵''', + r"type 'Null' is not a subtype of type 'String'", ); }); test('number content', () { - _expectThrows( + _expectThrowsContaining( {'sdk': 42}, - r''' -line 5, column 11: Unsupported value for "sdk". type 'int' is not a subtype of type 'String' in type cast - ╷ -5 │ "sdk": 42 - │ ┌───────────^ -6 │ │ } - │ └──^ - ╵''', + r"type 'int' is not a subtype of type 'String'", ); }); } @@ -337,46 +323,27 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. }); test('git - empty map', () { - _expectThrows( + _expectThrowsContaining( {'git': {}}, - r''' -line 5, column 11: Missing key "url". type 'Null' is not a subtype of type 'String' in type cast - ╷ -5 │ "git": {} - │ ^^ - ╵''', + r"type 'Null' is not a subtype of type 'String'", ); }); test('git - null url', () { - _expectThrows( + _expectThrowsContaining( { 'git': {'url': null} }, - r''' -line 6, column 12: Unsupported value for "url". type 'Null' is not a subtype of type 'String' in type cast - ╷ -6 │ "url": null - │ ┌────────────^ -7 │ │ } - │ └───^ - ╵''', + r"type 'Null' is not a subtype of type 'String'", ); }); test('git - int url', () { - _expectThrows( + _expectThrowsContaining( { 'git': {'url': 42} }, - r''' -line 6, column 12: Unsupported value for "url". type 'int' is not a subtype of type 'String' in type cast - ╷ -6 │ "url": 42 - │ ┌────────────^ -7 │ │ } - │ └───^ - ╵''', + r"type 'int' is not a subtype of type 'String'", ); }); } @@ -446,6 +413,16 @@ void _expectThrows(Object content, String expectedError) { ); } +void _expectThrowsContaining(Object content, String errorText) { + expectParseThrowsContaining( + { + 'name': 'sample', + 'dependencies': {'dep': content} + }, + errorText, + ); +} + T _dependency( Object? content, { bool skipTryPub = false, diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index a12d034fd..f3b4679bb 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. // ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: lines_longer_than_80_chars + library parse_test; import 'package:pub_semver/pub_semver.dart'; @@ -22,7 +24,7 @@ void main() { expect(value.authors, isEmpty); expect( value.environment, - {'sdk': VersionConstraint.parse('>=2.7.0 <3.0.0')}, + {'sdk': VersionConstraint.parse('>=2.12.0 <3.0.0')}, ); expect(value.documentation, isNull); expect(value.dependencies, isEmpty); @@ -36,7 +38,7 @@ void main() { test('all fields set', () { final version = Version.parse('1.2.3'); - final sdkConstraint = VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); + final sdkConstraint = VersionConstraint.parse('>=2.12.0 <3.0.0'); final value = parse({ 'name': 'sample', 'version': version.toString(), @@ -85,7 +87,7 @@ void main() { { 'name': 'sample', 'environment': { - 'sdk': '>=2.7.0 <3.0.0', + 'sdk': '>=2.12.0 <3.0.0', 'bob': null, } }, @@ -98,12 +100,7 @@ void main() { group('publish_to', () { for (var entry in { - 42: r''' -line 3, column 16: Unsupported value for "publish_to". type 'int' is not a subtype of type 'String?' in type cast - ╷ -3 │ "publish_to": 42 - │ ^^ - ╵''', + 42: "Unsupported value for \"publish_to\". type 'int' is not a subtype of type 'String?'", '##not a uri!': r''' line 3, column 16: Unsupported value for "publish_to". Must be an http or https URL. ╷ @@ -124,7 +121,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https ╵''', }.entries) { test('cannot be `${entry.key}`', () { - expectParseThrows( + expectParseThrowsContaining( {'name': 'sample', 'publish_to': entry.key}, entry.value, skipTryPub: true, @@ -241,26 +238,16 @@ line 1, column 1: Not a map }); test('missing name', () { - expectParseThrows( + expectParseThrowsContaining( {}, - r''' -line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast - ╷ -1 │ {} - │ ^^ - ╵''', + "Missing key \"name\". type 'Null' is not a subtype of type 'String'", ); }); test('null name value', () { - expectParseThrows( + expectParseThrowsContaining( {'name': null}, - r''' -line 2, column 10: Unsupported value for "name". type 'Null' is not a subtype of type 'String' in type cast - ╷ -2 │ "name": null - │ ^^^^ - ╵''', + "Unsupported value for \"name\". type 'Null' is not a subtype of type 'String'", ); }); @@ -336,37 +323,23 @@ line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". }); test('bad repository url', () { - expectParseThrows( + expectParseThrowsContaining( { ...defaultPubspec, 'repository': {'x': 'y'}, }, - r''' -line 6, column 16: Unsupported value for "repository". type 'YamlMap' is not a subtype of type 'String' in type cast - ╷ -6 │ "repository": { - │ ┌────────────────^ -7 │ │ "x": "y" -8 │ └ } - ╵''', + "Unsupported value for \"repository\". type 'YamlMap' is not a subtype of type 'String'", skipTryPub: true, ); }); test('bad issue_tracker url', () { - expectParseThrows( + expectParseThrowsContaining( { 'name': 'sample', 'issue_tracker': {'x': 'y'}, }, - r''' -line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not a subtype of type 'String' in type cast - ╷ -3 │ "issue_tracker": { - │ ┌───────────────────^ -4 │ │ "x": "y" -5 │ └ } - ╵''', + "Unsupported value for \"issue_tracker\". type 'YamlMap' is not a subtype of type 'String'", skipTryPub: true, ); }); @@ -374,35 +347,23 @@ line 3, column 19: Unsupported value for "issue_tracker". type 'YamlMap' is not group('funding', () { test('not a list', () { - expectParseThrows( + expectParseThrowsContaining( { ...defaultPubspec, 'funding': 1, }, - r''' -line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'List?' in type cast - ╷ -6 │ "funding": 1 - │ ^ - ╵''', + "Unsupported value for \"funding\". type 'int' is not a subtype of type 'List?'", skipTryPub: true, ); }); test('not an uri', () { - expectParseThrows( + expectParseThrowsContaining( { ...defaultPubspec, 'funding': [1], }, - r''' -line 6, column 13: Unsupported value for "funding". type 'int' is not a subtype of type 'String' in type cast - ╷ -6 │ "funding": [ - │ ┌─────────────^ -7 │ │ 1 -8 │ └ ] - ╵''', + "Unsupported value for \"funding\". type 'int' is not a subtype of type 'String'", skipTryPub: true, ); }); @@ -608,14 +569,9 @@ line 1, column 1: Not a map }); test('name cannot be empty', () { - expectParseThrows( + expectParseThrowsContaining( {}, - r''' -line 1, column 1: Missing key "name". type 'Null' is not a subtype of type 'String' in type cast - ╷ -1 │ {} - │ ^^ - ╵''', + "Missing key \"name\". type 'Null' is not a subtype of type 'String'", lenient: true, ); }); diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 72d214242..b573851ad 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -16,7 +16,7 @@ import 'pub_utils.dart'; const defaultPubspec = { 'name': 'sample', - 'environment': {'sdk': '>=2.7.0 <3.0.0'}, + 'environment': {'sdk': '>=2.12.0 <3.0.0'}, }; String _encodeJson(Object? input) => @@ -124,3 +124,36 @@ void expectParseThrows( ), _throwsParsedYamlException(expectedError), ); + +void expectParseThrowsContaining( + Object? content, + String errorFragment, { + bool skipTryPub = false, + bool lenient = false, +}) { + expect( + () => parse( + content, + lenient: lenient, + quietOnError: true, + skipTryPub: skipTryPub, + ), + _throwsParsedYamlExceptionContaining(errorFragment), + ); +} + +// ignore: prefer_expression_function_bodies +Matcher _throwsParsedYamlExceptionContaining(String errorFragment) { + return throwsA( + const TypeMatcher().having( + (e) { + final message = e.formattedMessage; + printOnFailure("Actual error format:\nr'''\n$message'''"); + _printDebugParsedYamlException(e); + return message; + }, + 'formattedMessage', + contains(errorFragment), + ), + ); +} From 1b08a8b8b33b82150d5a80864394953c7b9aa827 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 13:04:20 -0800 Subject: [PATCH 102/152] Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/pubspec_parse#88) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index c46df3002..bdb6946a5 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From b071e9af2f524da9170318b72701baee799433ac Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 23 Jan 2023 10:14:08 -0800 Subject: [PATCH 103/152] Update usage of json_annotatoin, bump pkg:lints (dart-lang/pubspec_parse#89) --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 4 ++-- pkgs/pubspec_parse/analysis_options.yaml | 2 -- pkgs/pubspec_parse/lib/src/dependency.dart | 2 +- pkgs/pubspec_parse/pubspec.yaml | 6 +++--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index bdb6946a5..0dab9a92d 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [2.18.0, dev] steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 117fd129e..5cf26e02c 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,7 +1,7 @@ ## 1.2.2-dev -- Update SDK requirement to `2.17.0`. -- Fix the unit tests for Dart 3.0.0. +- Require Dart SDK >= 2.18.0 +- Required `json_annotation: ^4.8.0` ## 1.2.1 diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index fdc60e0db..cf5c91faf 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -35,7 +35,6 @@ linter: - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_interpolation_to_compose_strings - prefer_relative_imports - require_trailing_commas - sort_pub_dependencies @@ -43,7 +42,6 @@ linter: - throw_in_finally - unnecessary_await_in_return - unnecessary_lambdas - - unnecessary_null_aware_assignments - unnecessary_parenthesis - unnecessary_statements - use_string_buffers diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 8b59f7367..e345dfda8 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -223,7 +223,7 @@ class HostedDetails { @JsonKey(fromJson: parseGitUriOrNull, disallowNullValue: true) final Uri? url; - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) String? _nameOfPackage; /// The name of this package on the package repository. diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 03f61bd80..961404487 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -6,19 +6,19 @@ version: 1.2.2-dev repository: https://github.com/dart-lang/pubspec_parse environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: checked_yaml: ^2.0.1 collection: ^1.15.0 - json_annotation: ^4.6.0 + json_annotation: ^4.8.0 pub_semver: ^2.0.0 yaml: ^3.0.0 dev_dependencies: build_runner: ^2.0.3 build_verify: '>=2.0.0 <4.0.0' - json_serializable: ^6.0.0 + json_serializable: ^6.6.0 lints: ^2.0.0 path: ^1.5.1 # Needed because we are configuring `combining_builder` From 956b27e18770b47bd314480ea1e4c373bc5f1686 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 21:51:10 -0800 Subject: [PATCH 104/152] Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/pubspec_parse#91) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 0dab9a92d..b51b48ab0 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 88ae8bdf680579b170ed69a68c932e43995e1361 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 23:28:10 -0800 Subject: [PATCH 105/152] Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/pubspec_parse#90) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index b51b48ab0..e78b568f2 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From 91c11ce6b6a848a316ac79eec1cf581d1c58f981 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Tue, 28 Feb 2023 14:44:17 +0100 Subject: [PATCH 106/152] Add support for "topics" field (dart-lang/pubspec_parse#93) --- pkgs/pubspec_parse/CHANGELOG.md | 3 +- pkgs/pubspec_parse/lib/src/pubspec.dart | 4 +++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 2 ++ pkgs/pubspec_parse/pubspec.yaml | 2 +- pkgs/pubspec_parse/test/parse_test.dart | 40 +++++++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 5cf26e02c..023e2a13f 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,7 +1,8 @@ -## 1.2.2-dev +## 1.2.2 - Require Dart SDK >= 2.18.0 - Required `json_annotation: ^4.8.0` +- Added support for `topics` field. ## 1.2.1 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 9943da8a4..188af314b 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -44,6 +44,9 @@ class Pubspec { /// support or funding. final List? funding; + /// Optional field to list the topics that this packages belongs to. + final List? topics; + /// Optional field for specifying included screenshot files. @JsonKey(fromJson: parseScreenshots) final List? screenshots; @@ -106,6 +109,7 @@ class Pubspec { this.repository, this.issueTracker, this.funding, + this.topics, this.screenshots, this.documentation, this.description, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index a1312a556..622999437 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -32,6 +32,8 @@ Pubspec _$PubspecFromJson(Map json) => $checkedCreate( (v) => (v as List?) ?.map((e) => Uri.parse(e as String)) .toList()), + topics: $checkedConvert('topics', + (v) => (v as List?)?.map((e) => e as String).toList()), screenshots: $checkedConvert( 'screenshots', (v) => parseScreenshots(v as List?)), documentation: $checkedConvert('documentation', (v) => v as String?), diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 961404487..63742631f 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -2,7 +2,7 @@ name: pubspec_parse description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.2-dev +version: 1.2.2 repository: https://github.com/dart-lang/pubspec_parse environment: diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index f3b4679bb..e181ca6d6 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -53,6 +53,7 @@ void main() { 'funding': [ 'https://patreon.com/example', ], + 'topics': ['widget', 'button'], 'screenshots': [ {'description': 'my screenshot', 'path': 'path/to/screenshot'} ], @@ -77,6 +78,9 @@ void main() { ); expect(value.funding, hasLength(1)); expect(value.funding!.single.toString(), 'https://patreon.com/example'); + expect(value.topics, hasLength(2)); + expect(value.topics!.first, 'widget'); + expect(value.topics!.last, 'button'); expect(value.screenshots, hasLength(1)); expect(value.screenshots!.first.description, 'my screenshot'); expect(value.screenshots!.first.path, 'path/to/screenshot'); @@ -386,6 +390,42 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at ); }); }); + group('topics', () { + test('not a list', () { + expectParseThrowsContaining( + { + ...defaultPubspec, + 'topics': 1, + }, + "Unsupported value for \"topics\". type 'int' is not a subtype of type 'List?'", + skipTryPub: true, + ); + }); + + test('not a string', () { + expectParseThrowsContaining( + { + ...defaultPubspec, + 'topics': [1], + }, + "Unsupported value for \"topics\". type 'int' is not a subtype of type 'String'", + skipTryPub: true, + ); + }); + + test('invalid data - lenient', () { + final value = parse( + { + ...defaultPubspec, + 'topics': [1], + }, + skipTryPub: true, + lenient: true, + ); + expect(value.name, 'sample'); + expect(value.topics, isNull); + }); + }); group('screenshots', () { test('one screenshot', () { From e61a97e236e19bdcea1e2e99a0fe9dcf65a5db7d Mon Sep 17 00:00:00 2001 From: Ricardo Amador <32242716+ricardoamador@users.noreply.github.com> Date: Tue, 4 Apr 2023 19:07:13 -0700 Subject: [PATCH 107/152] Updating to point to the config. (dart-lang/pubspec_parse#96) --- pkgs/pubspec_parse/.github/autosubmit.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 pkgs/pubspec_parse/.github/autosubmit.yml diff --git a/pkgs/pubspec_parse/.github/autosubmit.yml b/pkgs/pubspec_parse/.github/autosubmit.yml new file mode 100644 index 000000000..a9daaa91a --- /dev/null +++ b/pkgs/pubspec_parse/.github/autosubmit.yml @@ -0,0 +1,6 @@ +# Copyright 2023 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This file will be added to flutter's internal repository. +config_path: 'autosubmit/dart-lang/autosubmit.yml' From 6195b78d4bd3a437d432f8358bdcba7d86333fb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 12:35:08 -0700 Subject: [PATCH 108/152] Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/pubspec_parse#94) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index e78b568f2..ee1bbbf7a 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From adcd711141602fb7a1d35c9ca09ecc6926062b0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 02:34:39 +0000 Subject: [PATCH 109/152] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/pubspec_parse#95) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.5.1-dev

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use inline classes.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

v0.4

  • Removed previously deprecated input channel. Use the sdk input instead.
  • Added support for specifying the CPU architecture.

v0.3

  • Added support for installing SDKs from the main channel.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.4.0&new-version=1.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index ee1bbbf7a..cafe8ed33 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From 17a78c3e72a0a619bf08940c2bae08bddbd88051 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 26 Apr 2023 11:09:28 -0700 Subject: [PATCH 110/152] Update dependabot.yml (dart-lang/pubspec_parse#97) --- pkgs/pubspec_parse/.github/dependabot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/pubspec_parse/.github/dependabot.yml b/pkgs/pubspec_parse/.github/dependabot.yml index 1603cdd9e..cf1a70501 100644 --- a/pkgs/pubspec_parse/.github/dependabot.yml +++ b/pkgs/pubspec_parse/.github/dependabot.yml @@ -7,3 +7,5 @@ updates: directory: "/" schedule: interval: "monthly" + labels: + - "autosubmit" From ead89bcaa5d798e1cafc07fb5303222c7bc21b5a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Wed, 26 Apr 2023 11:16:06 -0700 Subject: [PATCH 111/152] Revert "Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/pubspec_parse#95)" (dart-lang/pubspec_parse#99) This reverts commit adcd711141602fb7a1d35c9ca09ecc6926062b0a. --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index cafe8ed33..ee1bbbf7a 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From be0701fef5a2ed3ff3dd58d142c93de92d08de5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:23:08 -0700 Subject: [PATCH 112/152] Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/pubspec_parse#98) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index ee1bbbf7a..a099cebce 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [2.18.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 6789ce31ca88aa65cd737e94ad3234124edd5eac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:41:53 -0700 Subject: [PATCH 113/152] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/pubspec_parse#100) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index a099cebce..44a40de01 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From bbf6de3a7920d71acd8078367b4998ef8e1cabd4 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 27 Apr 2023 11:54:11 -0700 Subject: [PATCH 114/152] Revert "Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/pubspec_parse#100)" (dart-lang/pubspec_parse#101) This reverts commit 6789ce31ca88aa65cd737e94ad3234124edd5eac. --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 44a40de01..a099cebce 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From 03fe5ff46c2eba7f0585e0337674cd9f55cd28e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 19:04:20 +0000 Subject: [PATCH 115/152] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/pubspec_parse#102) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.5.1-dev

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use inline classes.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

v0.4

  • Removed previously deprecated input channel. Use the sdk input instead.
  • Added support for specifying the CPU architecture.

v0.3

  • Added support for installing SDKs from the main channel.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.4.0&new-version=1.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index a099cebce..44a40de01 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [2.18.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From 5a13b29cc241112a6eaf4f75e0c61877b92553a7 Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Thu, 4 May 2023 14:33:13 +0200 Subject: [PATCH 116/152] Prepare release with topics. (dart-lang/pubspec_parse#103) --- pkgs/pubspec_parse/CHANGELOG.md | 3 +++ pkgs/pubspec_parse/pubspec.yaml | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 023e2a13f..9ed3837aa 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.2.3 +- Added topics to `pubspec.yaml`. + ## 1.2.2 - Require Dart SDK >= 2.18.0 diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 63742631f..a2b189db5 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,9 +1,11 @@ name: pubspec_parse +version: 1.2.3 description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -version: 1.2.2 repository: https://github.com/dart-lang/pubspec_parse +topics: +- dart-pub environment: sdk: '>=2.18.0 <3.0.0' From 283ae18b2f882f758f4d864aef8e6a83cc422462 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 9 May 2023 16:37:45 -0700 Subject: [PATCH 117/152] Delete autosubmit.yml (dart-lang/pubspec_parse#104) --- pkgs/pubspec_parse/.github/autosubmit.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 pkgs/pubspec_parse/.github/autosubmit.yml diff --git a/pkgs/pubspec_parse/.github/autosubmit.yml b/pkgs/pubspec_parse/.github/autosubmit.yml deleted file mode 100644 index a9daaa91a..000000000 --- a/pkgs/pubspec_parse/.github/autosubmit.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2023 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# This file will be added to flutter's internal repository. -config_path: 'autosubmit/dart-lang/autosubmit.yml' From 544b07a58d2bfb022ceaf96d5006f019647f4872 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 21 May 2023 19:57:34 -0700 Subject: [PATCH 118/152] Update formatting (dart-lang/pubspec_parse#105) --- pkgs/pubspec_parse/lib/src/pubspec.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 188af314b..3eb73cc3f 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -99,11 +99,11 @@ class Pubspec { @Deprecated( 'See https://dart.dev/tools/pub/pubspec#authorauthors', ) - String? author, + String? author, @Deprecated( 'See https://dart.dev/tools/pub/pubspec#authorauthors', ) - List? authors, + List? authors, Map? environment, this.homepage, this.repository, From ce15656712d2b333bdfaad2793b564f9ce61ea73 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 12 Jun 2023 08:50:44 -0700 Subject: [PATCH 119/152] Require Dart 3, update lints (dart-lang/pubspec_parse#106) --- .../.github/workflows/test-package.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 5 +++++ pkgs/pubspec_parse/analysis_options.yaml | 14 ++----------- pkgs/pubspec_parse/lib/pubspec_parse.dart | 6 +++--- pkgs/pubspec_parse/lib/src/dependency.dart | 21 +++++++------------ pkgs/pubspec_parse/pubspec.yaml | 6 +++--- .../pubspec_parse/test/ensure_build_test.dart | 2 ++ pkgs/pubspec_parse/test/parse_test.dart | 2 -- 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 44a40de01..eac88d582 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [2.18.0, dev] + sdk: [3.0.0, dev] steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 9ed3837aa..7444f4f82 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,4 +1,9 @@ +## 1.2.4-wip + +- Require Dart 3.0 + ## 1.2.3 + - Added topics to `pubspec.yaml`. ## 1.2.2 diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index cf5c91faf..af77edcae 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -1,4 +1,5 @@ -include: package:lints/recommended.yaml +# https://dart.dev/guides/language/analysis-options +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -8,9 +9,7 @@ analyzer: linter: rules: - avoid_bool_literals_in_conditional_expressions - - avoid_catching_errors - avoid_classes_with_only_static_members - - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_redundant_argument_values - avoid_returning_null @@ -21,27 +20,18 @@ linter: - cancel_subscriptions - cascade_invocations - comment_references - - directives_ordering - join_return_with_assignment - - lines_longer_than_80_chars - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - only_throw_errors - package_api_docs - - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - prefer_relative_imports - require_trailing_commas - - sort_pub_dependencies - test_types_in_equals - - throw_in_finally - unnecessary_await_in_return - - unnecessary_lambdas - - unnecessary_parenthesis - - unnecessary_statements - use_string_buffers diff --git a/pkgs/pubspec_parse/lib/pubspec_parse.dart b/pkgs/pubspec_parse/lib/pubspec_parse.dart index 7360d1ac9..b5c12e414 100644 --- a/pkgs/pubspec_parse/lib/pubspec_parse.dart +++ b/pkgs/pubspec_parse/lib/pubspec_parse.dart @@ -5,10 +5,10 @@ export 'src/dependency.dart' show Dependency, + GitDependency, HostedDependency, HostedDetails, - GitDependency, - SdkDependency, - PathDependency; + PathDependency, + SdkDependency; export 'src/pubspec.dart' show Pubspec; export 'src/screenshot.dart' show Screenshot; diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index e345dfda8..95bbc8ea7 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -74,19 +74,14 @@ Dependency? _fromJson(Object? data, String name) { final key = matchedKeys.single; - switch (key) { - case 'git': - return GitDependency.fromData(data[key]); - case 'path': - return PathDependency.fromData(data[key]); - case 'sdk': - return _$SdkDependencyFromJson(data); - case 'hosted': - final hosted = _$HostedDependencyFromJson(data); - hosted.hosted?._nameOfPackage = name; - return hosted; - } - throw StateError('There is a bug in pubspec_parse.'); + return switch (key) { + 'git' => GitDependency.fromData(data[key]), + 'path' => PathDependency.fromData(data[key]), + 'sdk' => _$SdkDependencyFromJson(data), + 'hosted' => _$HostedDependencyFromJson(data) + ..hosted?._nameOfPackage = name, + _ => throw StateError('There is a bug in pubspec_parse.'), + }; }); } } diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index a2b189db5..9c3b89a0f 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.2.3 +version: 1.2.4-wip description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. @@ -8,7 +8,7 @@ topics: - dart-pub environment: - sdk: '>=2.18.0 <3.0.0' + sdk: ^3.0.0 dependencies: checked_yaml: ^2.0.1 @@ -20,8 +20,8 @@ dependencies: dev_dependencies: build_runner: ^2.0.3 build_verify: '>=2.0.0 <4.0.0' + dart_flutter_team_lints: ^1.0.0 json_serializable: ^6.6.0 - lints: ^2.0.0 path: ^1.5.1 # Needed because we are configuring `combining_builder` source_gen: ^1.0.0 diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index 612b837e9..689f6fe66 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -5,6 +5,8 @@ @Timeout.factor(2) @TestOn('vm') @Tags(['presubmit-only']) +library; + import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index e181ca6d6..f4d6476aa 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -5,8 +5,6 @@ // ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: lines_longer_than_80_chars -library parse_test; - import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; From 3fba72ccfb7d6b01759699d1ef5b3060b930497f Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Sat, 1 Jul 2023 16:24:02 -0700 Subject: [PATCH 120/152] update formatting for recent lints (dart-lang/pubspec_parse#108) --- pkgs/pubspec_parse/test/dependency_test.dart | 20 +++++++------- pkgs/pubspec_parse/test/parse_test.dart | 28 ++++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index b366887a3..71b148cb6 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -112,7 +112,7 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v test('map w/ version and hosted as Map', () { final dep = _dependency({ 'version': '^1.0.0', - 'hosted': {'name': 'hosted_name', 'url': 'https://hosted_url'} + 'hosted': {'name': 'hosted_name', 'url': 'https://hosted_url'}, }); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted!.name, 'hosted_name'); @@ -124,7 +124,7 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v final dep = _dependency( { 'version': '^1.0.0', - 'hosted': {'url': 'https://hosted_url'} + 'hosted': {'url': 'https://hosted_url'}, }, skipTryPub: true, // todo: Unskip once pub supports this syntax ); @@ -139,7 +139,7 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v _expectThrows( { 'version': 'not a version', - 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'} + 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, }, r''' line 5, column 15: Unsupported value for "version". Could not parse version "not a version". Unknown text at "not a version". @@ -155,7 +155,7 @@ line 5, column 15: Unsupported value for "version". Could not parse version "not { 'version': '^1.0.0', 'hosted': {'name': 'hosted_name', 'url': 'hosted_url'}, - 'not_supported': null + 'not_supported': null, }, r''' line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git, path, hosted] @@ -286,7 +286,7 @@ line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos test('map', () { final dep = _dependency({ - 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'} + 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'}, }); expect(dep.url.toString(), 'url'); expect(dep.path, 'path'); @@ -332,7 +332,7 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. test('git - null url', () { _expectThrowsContaining( { - 'git': {'url': null} + 'git': {'url': null}, }, r"type 'Null' is not a subtype of type 'String'", ); @@ -341,7 +341,7 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. test('git - int url', () { _expectThrowsContaining( { - 'git': {'url': 42} + 'git': {'url': 42}, }, r"type 'int' is not a subtype of type 'String'", ); @@ -407,7 +407,7 @@ void _expectThrows(Object content, String expectedError) { expectParseThrows( { 'name': 'sample', - 'dependencies': {'dep': content} + 'dependencies': {'dep': content}, }, expectedError, ); @@ -417,7 +417,7 @@ void _expectThrowsContaining(Object content, String errorText) { expectParseThrowsContaining( { 'name': 'sample', - 'dependencies': {'dep': content} + 'dependencies': {'dep': content}, }, errorText, ); @@ -430,7 +430,7 @@ T _dependency( final value = parse( { ...defaultPubspec, - 'dependencies': {'dep': content} + 'dependencies': {'dep': content}, }, skipTryPub: skipTryPub, ); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index f4d6476aa..99199c7b4 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -53,7 +53,7 @@ void main() { ], 'topics': ['widget', 'button'], 'screenshots': [ - {'description': 'my screenshot', 'path': 'path/to/screenshot'} + {'description': 'my screenshot', 'path': 'path/to/screenshot'}, ], }); expect(value.name, 'sample'); @@ -91,7 +91,7 @@ void main() { 'environment': { 'sdk': '>=2.12.0 <3.0.0', 'bob': null, - } + }, }, skipTryPub: true, ); @@ -135,7 +135,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https null: null, 'http': 'http://example.com', 'https': 'https://example.com', - 'none': 'none' + 'none': 'none', }.entries) { test('can be ${entry.key}', () { final value = parse({ @@ -160,7 +160,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('one author, via authors', () { final value = parse({ ...defaultPubspec, - 'authors': ['name@example.com'] + 'authors': ['name@example.com'], }); expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); @@ -169,7 +169,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https test('many authors', () { final value = parse({ ...defaultPubspec, - 'authors': ['name@example.com', 'name2@example.com'] + 'authors': ['name@example.com', 'name2@example.com'], }); expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); @@ -179,7 +179,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https final value = parse({ ...defaultPubspec, 'author': 'name@example.com', - 'authors': ['name2@example.com'] + 'authors': ['name2@example.com'], }); expect(value.author, isNull); expect(value.authors, ['name@example.com', 'name2@example.com']); @@ -189,7 +189,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https final value = parse({ ...defaultPubspec, 'author': 'name@example.com', - 'authors': ['name@example.com', 'name@example.com'] + 'authors': ['name@example.com', 'name@example.com'], }); expect(value.author, 'name@example.com'); expect(value.authors, ['name@example.com']); @@ -269,7 +269,7 @@ line 2, column 10: Unsupported value for "name". "name" cannot be empty. expectParseThrows( { 'name': 'sample', - 'environment': {'dart': 'cool'} + 'environment': {'dart': 'cool'}, }, r''' line 4, column 3: Use "sdk" to for Dart SDK constraints. @@ -284,7 +284,7 @@ line 4, column 3: Use "sdk" to for Dart SDK constraints. expectParseThrows( { 'name': 'sample', - 'environment': {'sdk': 42} + 'environment': {'sdk': 42}, }, r''' line 4, column 10: Unsupported value for "sdk". `42` is not a String. @@ -313,7 +313,7 @@ line 3, column 13: Unsupported value for "version". Could not parse "invalid". expectParseThrows( { 'name': 'sample', - 'environment': {'sdk': 'silly'} + 'environment': {'sdk': 'silly'}, }, r''' line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". Unknown text at "silly". @@ -430,7 +430,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at final value = parse({ ...defaultPubspec, 'screenshots': [ - {'description': 'my screenshot', 'path': 'path/to/screenshot'} + {'description': 'my screenshot', 'path': 'path/to/screenshot'}, ], }); expect(value.screenshots, hasLength(1)); @@ -445,7 +445,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at {'description': 'my screenshot', 'path': 'path/to/screenshot'}, { 'description': 'my second screenshot', - 'path': 'path/to/screenshot2' + 'path': 'path/to/screenshot2', }, ], }); @@ -464,7 +464,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at { 'description': 'my screenshot', 'path': 'path/to/screenshot', - 'extraKey': 'not important' + 'extraKey': 'not important', }, 'not a screenshot', ], @@ -659,7 +659,7 @@ line 1, column 1: Not a map 'name': 'sample', 'dependencies': { 'foo': { - 'git': {'url': 1} + 'git': {'url': 1}, }, }, 'issue_tracker': {'x': 'y'}, From 6c28bdfd1e86a327cc878935b74fd28fa7b5a16c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 23:31:55 +0000 Subject: [PATCH 121/152] Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/pubspec_parse#107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index eac88d582..0f9e7fa73 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 8a100758911707fe1bd667d467508df1d0c28d8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 05:23:22 +0000 Subject: [PATCH 122/152] Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/pubspec_parse#110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 0f9e7fa73..bcc9e7139 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From d96d7cec8117858c7e024a426f4ab4d559852b67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:08:29 -0700 Subject: [PATCH 123/152] Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/pubspec_parse#111) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/f43a0e5ff2bd294095638e18286ca9a3d1956744...8ade135a41bc03ea155e62e844d188df1ea18608) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index bcc9e7139..db9e1e5e6 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 83007bec00a641ec7f2902b9b5348cb444f25d6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:41:20 -0700 Subject: [PATCH 124/152] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/pubspec_parse#112) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/d6a63dab3335f427404425de0fbfed4686d93c4f...8a4b97ea2017cc079571daec46542f76189836b1) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index db9e1e5e6..ee3178486 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From b4b92a4eefe7c2dbd4f96723dec73f9815d0e9d3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 3 Oct 2023 13:32:31 -0700 Subject: [PATCH 125/152] Drop usage of waitFor (dart-lang/pubspec_parse#114) --- pkgs/pubspec_parse/test/dependency_test.dart | 78 ++++++++++---------- pkgs/pubspec_parse/test/parse_test.dart | 76 +++++++++---------- pkgs/pubspec_parse/test/test_utils.dart | 8 +- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index 71b148cb6..f1e4f5776 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -70,21 +70,21 @@ line 5, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos } void _hostedDependency() { - test('null', () { - final dep = _dependency(null); + test('null', () async { + final dep = await _dependency(null); expect(dep.version.toString(), 'any'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); - test('empty map', () { - final dep = _dependency({}); + test('empty map', () async { + final dep = await _dependency({}); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); }); - test('string version', () { - final dep = _dependency('^1.0.0'); + test('string version', () async { + final dep = await _dependency('^1.0.0'); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); @@ -102,15 +102,15 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v ); }); - test('map w/ just version', () { - final dep = _dependency({'version': '^1.0.0'}); + test('map w/ just version', () async { + final dep = await _dependency({'version': '^1.0.0'}); expect(dep.version.toString(), '^1.0.0'); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); - test('map w/ version and hosted as Map', () { - final dep = _dependency({ + test('map w/ version and hosted as Map', () async { + final dep = await _dependency({ 'version': '^1.0.0', 'hosted': {'name': 'hosted_name', 'url': 'https://hosted_url'}, }); @@ -120,8 +120,8 @@ line 4, column 10: Unsupported value for "dep". Could not parse version "not a v expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); - test('map /w hosted as a map without name', () { - final dep = _dependency( + test('map /w hosted as a map without name', () async { + final dep = await _dependency( { 'version': '^1.0.0', 'hosted': {'url': 'https://hosted_url'}, @@ -166,8 +166,8 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git ); }); - test('map w/ version and hosted as String', () { - final dep = _dependency( + test('map w/ version and hosted as String', () async { + final dep = await _dependency( {'version': '^1.0.0', 'hosted': 'hosted_url'}, skipTryPub: true, // todo: Unskip once put supports this ); @@ -178,8 +178,8 @@ line 10, column 4: Unrecognized keys: [not_supported]; supported keys: [sdk, git expect(dep.toString(), 'HostedDependency: ^1.0.0'); }); - test('map w/ hosted as String', () { - final dep = _dependency({'hosted': 'hosted_url'}); + test('map w/ hosted as String', () async { + final dep = await _dependency({'hosted': 'hosted_url'}); expect(dep.version, VersionConstraint.any); expect(dep.hosted!.declaredName, isNull); expect(dep.hosted!.name, 'dep'); @@ -199,8 +199,8 @@ line 5, column 4: These keys had `null` values, which is not allowed: [hosted] ); }); - test('map w/ null version is fine', () { - final dep = _dependency({'version': null}); + test('map w/ null version is fine', () async { + final dep = await _dependency({'version': null}); expect(dep.version, VersionConstraint.any); expect(dep.hosted, isNull); expect(dep.toString(), 'HostedDependency: any'); @@ -208,15 +208,15 @@ line 5, column 4: These keys had `null` values, which is not allowed: [hosted] } void _sdkDependency() { - test('without version', () { - final dep = _dependency({'sdk': 'flutter'}); + test('without version', () async { + final dep = await _dependency({'sdk': 'flutter'}); expect(dep.sdk, 'flutter'); expect(dep.version, VersionConstraint.any); expect(dep.toString(), 'SdkDependency: flutter'); }); - test('with version', () { - final dep = _dependency( + test('with version', () async { + final dep = await _dependency( {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}, ); expect(dep.sdk, 'flutter'); @@ -240,29 +240,30 @@ void _sdkDependency() { } void _gitDependency() { - test('string', () { - final dep = _dependency({'git': 'url'}); + test('string', () async { + final dep = await _dependency({'git': 'url'}); expect(dep.url.toString(), 'url'); expect(dep.path, isNull); expect(dep.ref, isNull); expect(dep.toString(), 'GitDependency: url@url'); }); - test('string with version key is ignored', () { + test('string with version key is ignored', () async { // Regression test for https://github.com/dart-lang/pubspec_parse/issues/13 - final dep = _dependency({'git': 'url', 'version': '^1.2.3'}); + final dep = + await _dependency({'git': 'url', 'version': '^1.2.3'}); expect(dep.url.toString(), 'url'); expect(dep.path, isNull); expect(dep.ref, isNull); expect(dep.toString(), 'GitDependency: url@url'); }); - test('string with user@ URL', () { + test('string with user@ URL', () async { final skipTryParse = Platform.environment.containsKey('TRAVIS'); if (skipTryParse) { print('FYI: not validating git@ URI on travis due to failure'); } - final dep = _dependency( + final dep = await _dependency( {'git': 'git@localhost:dep.git'}, skipTryPub: skipTryParse, ); @@ -284,8 +285,8 @@ line 6, column 4: Unrecognized keys: [bob]; supported keys: [sdk, git, path, hos ); }); - test('map', () { - final dep = _dependency({ + test('map', () async { + final dep = await _dependency({ 'git': {'url': 'url', 'path': 'path', 'ref': 'ref'}, }); expect(dep.url.toString(), 'url'); @@ -349,15 +350,16 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. } void _pathDependency() { - test('valid', () { - final dep = _dependency({'path': '../path'}); + test('valid', () async { + final dep = await _dependency({'path': '../path'}); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); }); - test('valid with version key is ignored', () { - final dep = - _dependency({'path': '../path', 'version': '^1.2.3'}); + test('valid with version key is ignored', () async { + final dep = await _dependency( + {'path': '../path', 'version': '^1.2.3'}, + ); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); }); @@ -423,11 +425,11 @@ void _expectThrowsContaining(Object content, String errorText) { ); } -T _dependency( +Future _dependency( Object? content, { bool skipTryPub = false, -}) { - final value = parse( +}) async { + final value = await parse( { ...defaultPubspec, 'dependencies': {'dep': content}, diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 99199c7b4..31042f1cb 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -11,8 +11,8 @@ import 'package:test/test.dart'; import 'test_utils.dart'; void main() { - test('minimal set values', () { - final value = parse(defaultPubspec); + test('minimal set values', () async { + final value = await parse(defaultPubspec); expect(value.name, 'sample'); expect(value.version, isNull); expect(value.publishTo, isNull); @@ -34,10 +34,10 @@ void main() { expect(value.screenshots, isEmpty); }); - test('all fields set', () { + test('all fields set', () async { final version = Version.parse('1.2.3'); final sdkConstraint = VersionConstraint.parse('>=2.12.0 <3.0.0'); - final value = parse({ + final value = await parse({ 'name': 'sample', 'version': version.toString(), 'publish_to': 'none', @@ -84,8 +84,8 @@ void main() { expect(value.screenshots!.first.path, 'path/to/screenshot'); }); - test('environment values can be null', () { - final value = parse( + test('environment values can be null', () async { + final value = await parse( { 'name': 'sample', 'environment': { @@ -137,8 +137,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https 'https': 'https://example.com', 'none': 'none', }.entries) { - test('can be ${entry.key}', () { - final value = parse({ + test('can be ${entry.key}', () async { + final value = await parse({ ...defaultPubspec, 'publish_to': entry.value, }); @@ -148,8 +148,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https }); group('author, authors', () { - test('one author', () { - final value = parse({ + test('one author', () async { + final value = await parse({ ...defaultPubspec, 'author': 'name@example.com', }); @@ -157,8 +157,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expect(value.authors, ['name@example.com']); }); - test('one author, via authors', () { - final value = parse({ + test('one author, via authors', () async { + final value = await parse({ ...defaultPubspec, 'authors': ['name@example.com'], }); @@ -166,8 +166,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expect(value.authors, ['name@example.com']); }); - test('many authors', () { - final value = parse({ + test('many authors', () async { + final value = await parse({ ...defaultPubspec, 'authors': ['name@example.com', 'name2@example.com'], }); @@ -175,8 +175,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expect(value.authors, ['name@example.com', 'name2@example.com']); }); - test('author and authors', () { - final value = parse({ + test('author and authors', () async { + final value = await parse({ ...defaultPubspec, 'author': 'name@example.com', 'authors': ['name2@example.com'], @@ -185,8 +185,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expect(value.authors, ['name@example.com', 'name2@example.com']); }); - test('duplicate author values', () { - final value = parse({ + test('duplicate author values', () async { + final value = await parse({ ...defaultPubspec, 'author': 'name@example.com', 'authors': ['name@example.com', 'name@example.com'], @@ -195,8 +195,8 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expect(value.authors, ['name@example.com']); }); - test('flutter', () { - final value = parse({ + test('flutter', () async { + final value = await parse({ ...defaultPubspec, 'flutter': {'key': 'value'}, }); @@ -411,8 +411,8 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at ); }); - test('invalid data - lenient', () { - final value = parse( + test('invalid data - lenient', () async { + final value = await parse( { ...defaultPubspec, 'topics': [1], @@ -426,8 +426,8 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at }); group('screenshots', () { - test('one screenshot', () { - final value = parse({ + test('one screenshot', () async { + final value = await parse({ ...defaultPubspec, 'screenshots': [ {'description': 'my screenshot', 'path': 'path/to/screenshot'}, @@ -438,8 +438,8 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at expect(value.screenshots!.first.path, 'path/to/screenshot'); }); - test('many screenshots', () { - final value = parse({ + test('many screenshots', () async { + final value = await parse({ ...defaultPubspec, 'screenshots': [ {'description': 'my screenshot', 'path': 'path/to/screenshot'}, @@ -456,8 +456,8 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at expect(value.screenshots!.last.path, 'path/to/screenshot2'); }); - test('one screenshot plus invalid entries', () { - final value = parse({ + test('one screenshot plus invalid entries', () async { + final value = await parse({ ...defaultPubspec, 'screenshots': [ 42, @@ -474,8 +474,8 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at expect(value.screenshots!.first.path, 'path/to/screenshot'); }); - test('invalid entries', () { - final value = parse({ + test('invalid entries', () async { + final value = await parse({ ...defaultPubspec, 'screenshots': [ 42, @@ -566,8 +566,8 @@ line 9, column 12: Unsupported value for "path". `42` is not a String ); }); - test('invalid screenshot - lenient', () { - final value = parse( + test('invalid screenshot - lenient', () async { + final value = await parse( { ...defaultPubspec, 'screenshots': 'Invalid value', @@ -614,8 +614,8 @@ line 1, column 1: Not a map ); }); - test('bad repository url', () { - final value = parse( + test('bad repository url', () async { + final value = await parse( { ...defaultPubspec, 'repository': {'x': 'y'}, @@ -626,8 +626,8 @@ line 1, column 1: Not a map expect(value.repository, isNull); }); - test('bad issue_tracker url', () { - final value = parse( + test('bad issue_tracker url', () async { + final value = await parse( { ...defaultPubspec, 'issue_tracker': {'x': 'y'}, @@ -638,8 +638,8 @@ line 1, column 1: Not a map expect(value.issueTracker, isNull); }); - test('multiple bad values', () { - final value = parse( + test('multiple bad values', () async { + final value = await parse( { ...defaultPubspec, 'repository': {'x': 'y'}, diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index b573851ad..cc46522b7 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -2,8 +2,6 @@ // 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. -// ignore: deprecated_member_use -import 'dart:cli'; import 'dart:convert'; import 'package:checked_yaml/checked_yaml.dart'; @@ -61,18 +59,18 @@ void _printDebugParsedYamlException(ParsedYamlException e) { } } -Pubspec parse( +Future parse( Object? content, { bool quietOnError = false, bool skipTryPub = false, bool lenient = false, -}) { +}) async { final encoded = _encodeJson(content); ProcResult? pubResult; if (!skipTryPub) { // ignore: deprecated_member_use - pubResult = waitFor(tryPub(encoded)); + pubResult = await tryPub(encoded); expect(pubResult, isNotNull); } From 059282e85f74857c5cb893bfaaf57c8a28d15364 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 3 Oct 2023 17:29:49 -0700 Subject: [PATCH 126/152] Update lints (dart-lang/pubspec_parse#113) --- pkgs/pubspec_parse/analysis_options.yaml | 4 ---- pkgs/pubspec_parse/pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index af77edcae..7da0e8962 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -19,19 +19,15 @@ linter: - avoid_void_async - cancel_subscriptions - cascade_invocations - - comment_references - join_return_with_assignment - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - package_api_docs - - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_relative_imports - require_trailing_commas - - test_types_in_equals - unnecessary_await_in_return - use_string_buffers diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 9c3b89a0f..4f8eabc9a 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.3 build_verify: '>=2.0.0 <4.0.0' - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 json_serializable: ^6.6.0 path: ^1.5.1 # Needed because we are configuring `combining_builder` From a58e2f58ccc8984ef73752588b94384bcfb4c5bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 05:41:36 +0000 Subject: [PATCH 127/152] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/pubspec_parse#116) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index ee3178486..d1b8e0de0 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From a8d2a7f0938d1cd0120bac000035726fbc1586ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:25:03 +0000 Subject: [PATCH 128/152] Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/pubspec_parse#117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index d1b8e0de0..36ed6216e 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} From cfa97eaaba2fafc09a6fe1b7b1b9bf6361583802 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 30 Nov 2023 11:42:23 +0100 Subject: [PATCH 129/152] Remove outdated lints (dart-lang/pubspec_parse#119) --- pkgs/pubspec_parse/analysis_options.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 7da0e8962..c20999920 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -12,8 +12,6 @@ linter: - avoid_classes_with_only_static_members - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_returning_null - - avoid_returning_null_for_future - avoid_returning_this - avoid_unused_constructor_parameters - avoid_void_async From 8ca0ae06958a703598b5c9d9effc425621c16165 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Thu, 30 Nov 2023 11:45:09 +0100 Subject: [PATCH 130/152] Add support for 'ignored_advisories' field (dart-lang/pubspec_parse#118) --- pkgs/pubspec_parse/CHANGELOG.md | 1 + pkgs/pubspec_parse/lib/src/pubspec.dart | 4 +++ pkgs/pubspec_parse/lib/src/pubspec.g.dart | 3 ++ pkgs/pubspec_parse/test/parse_test.dart | 41 +++++++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 7444f4f82..87dd5cae8 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.2.4-wip - Require Dart 3.0 +- Added support for `ignored_advisories` field. ## 1.2.3 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 3eb73cc3f..f6934eef3 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -47,6 +47,9 @@ class Pubspec { /// Optional field to list the topics that this packages belongs to. final List? topics; + /// Optional field to list advisories to be ignored by the client. + final List? ignoredAdvisories; + /// Optional field for specifying included screenshot files. @JsonKey(fromJson: parseScreenshots) final List? screenshots; @@ -110,6 +113,7 @@ class Pubspec { this.issueTracker, this.funding, this.topics, + this.ignoredAdvisories, this.screenshots, this.documentation, this.description, diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 622999437..fc285718d 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -34,6 +34,8 @@ Pubspec _$PubspecFromJson(Map json) => $checkedCreate( .toList()), topics: $checkedConvert('topics', (v) => (v as List?)?.map((e) => e as String).toList()), + ignoredAdvisories: $checkedConvert('ignored_advisories', + (v) => (v as List?)?.map((e) => e as String).toList()), screenshots: $checkedConvert( 'screenshots', (v) => parseScreenshots(v as List?)), documentation: $checkedConvert('documentation', (v) => v as String?), @@ -55,6 +57,7 @@ Pubspec _$PubspecFromJson(Map json) => $checkedCreate( fieldKeyMap: const { 'publishTo': 'publish_to', 'issueTracker': 'issue_tracker', + 'ignoredAdvisories': 'ignored_advisories', 'devDependencies': 'dev_dependencies', 'dependencyOverrides': 'dependency_overrides' }, diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 31042f1cb..6251f41fb 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -52,6 +52,7 @@ void main() { 'https://patreon.com/example', ], 'topics': ['widget', 'button'], + 'ignored_advisories': ['111', '222'], 'screenshots': [ {'description': 'my screenshot', 'path': 'path/to/screenshot'}, ], @@ -79,6 +80,9 @@ void main() { expect(value.topics, hasLength(2)); expect(value.topics!.first, 'widget'); expect(value.topics!.last, 'button'); + expect(value.ignoredAdvisories, hasLength(2)); + expect(value.ignoredAdvisories!.first, '111'); + expect(value.ignoredAdvisories!.last, '222'); expect(value.screenshots, hasLength(1)); expect(value.screenshots!.first.description, 'my screenshot'); expect(value.screenshots!.first.path, 'path/to/screenshot'); @@ -425,6 +429,43 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at }); }); + group('ignored_advisories', () { + test('not a list', () { + expectParseThrowsContaining( + { + ...defaultPubspec, + 'ignored_advisories': 1, + }, + "Unsupported value for \"ignored_advisories\". type 'int' is not a subtype of type 'List?'", + skipTryPub: true, + ); + }); + + test('not a string', () { + expectParseThrowsContaining( + { + ...defaultPubspec, + 'ignored_advisories': [1], + }, + "Unsupported value for \"ignored_advisories\". type 'int' is not a subtype of type 'String'", + skipTryPub: true, + ); + }); + + test('invalid data - lenient', () async { + final value = await parse( + { + ...defaultPubspec, + 'ignored_advisories': [1], + }, + skipTryPub: true, + lenient: true, + ); + expect(value.name, 'sample'); + expect(value.ignoredAdvisories, isNull); + }); + }); + group('screenshots', () { test('one screenshot', () async { final value = await parse({ From 95bd915e9e9991dc7e982d12b4238c6cc25010d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 05:25:50 +0000 Subject: [PATCH 131/152] Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/pubspec_parse#120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.0 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.0&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 36ed6216e..e2b6fb688 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install From f625a17d724c3b7131d1fc885b9c84e97478e63c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 05:06:46 +0000 Subject: [PATCH 132/152] Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/pubspec_parse#122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
Release notes

Sourced from actions/checkout's releases.

v4.1.2

We are investigating the following issue with this release and have rolled-back the v4 tag to point to v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.1...v4.1.2

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.1&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index e2b6fb688..4604052b0 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From b89f34e4d95593a40474e60b29b628608f42be8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 05:24:07 +0000 Subject: [PATCH 133/152] Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/pubspec_parse#123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.4

  • Rebuild JS code to include changes from v1.6.3

v1.6.3

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.2&new-version=1.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 4604052b0..5c3041ba7 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [3.0.0, dev] steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install From 30351163004ad88c6c6eeb2279ac28d295782fc8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:17:55 +0000 Subject: [PATCH 134/152] Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/pubspec_parse#124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.4.
Release notes

Sourced from actions/checkout's releases.

v4.1.4

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.3...v4.1.4

v4.1.3

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.2...v4.1.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.2&new-version=4.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 5c3041ba7..b43c40ef3 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From 135088e411acfe8546eca153c02d7f1c3bb8b386 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 9 May 2024 13:46:58 -0700 Subject: [PATCH 135/152] blast_repo fixes (dart-lang/pubspec_parse#125) dependabot --- pkgs/pubspec_parse/.github/dependabot.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/.github/dependabot.yml b/pkgs/pubspec_parse/.github/dependabot.yml index cf1a70501..cde02ad6a 100644 --- a/pkgs/pubspec_parse/.github/dependabot.yml +++ b/pkgs/pubspec_parse/.github/dependabot.yml @@ -3,9 +3,13 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly labels: - - "autosubmit" + - autosubmit + groups: + github-actions: + patterns: + - "*" From 7c2edadbdc44e080b0d29155b29b8e5606bd6a7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 20:51:26 +0000 Subject: [PATCH 136/152] Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group (dart-lang/pubspec_parse#126) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.4 to 4.1.5
Release notes

Sourced from actions/checkout's releases.

v4.1.5

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.4...v4.1.5

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.4&new-version=4.1.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index b43c40ef3..b3f887735 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From aa020355b05f196b344ca733ede43a1a6790e2e1 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 28 May 2024 12:35:20 -0700 Subject: [PATCH 137/152] blast_repo fixes (dart-lang/pubspec_parse#128) auto-publish --- .../.github/workflows/publish.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pkgs/pubspec_parse/.github/workflows/publish.yaml diff --git a/pkgs/pubspec_parse/.github/workflows/publish.yaml b/pkgs/pubspec_parse/.github/workflows/publish.yaml new file mode 100644 index 000000000..27157a046 --- /dev/null +++ b/pkgs/pubspec_parse/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +# A CI configuration to auto-publish pub packages. + +name: Publish + +on: + pull_request: + branches: [ master ] + push: + tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] + +jobs: + publish: + if: ${{ github.repository_owner == 'dart-lang' }} + uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note From 091ed91aa80400e4bfa367202c81f0fefb53c924 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 28 May 2024 14:59:50 -0700 Subject: [PATCH 138/152] Add structural equality for dependencies (dart-lang/pubspec_parse#127) * Add structural equality for dependencies * Apply suggestions from code review Co-authored-by: Devon Carew --------- Co-authored-by: Devon Carew --- pkgs/pubspec_parse/CHANGELOG.md | 3 +- pkgs/pubspec_parse/lib/src/dependency.dart | 40 ++++++++++++++++++++++ pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 87dd5cae8..d14b82e40 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,7 +1,8 @@ -## 1.2.4-wip +## 1.3.0 - Require Dart 3.0 - Added support for `ignored_advisories` field. +- Added structural equality for `Dependency` subclasses and `HostedDetails`. ## 1.2.3 diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 95bbc8ea7..acce59843 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -111,6 +111,13 @@ class SdkDependency extends Dependency { @override String get _info => sdk; + + @override + bool operator ==(Object other) => + other is SdkDependency && other.sdk == sdk && other.version == version; + + @override + int get hashCode => Object.hash(sdk, version); } @JsonSerializable() @@ -136,6 +143,16 @@ class GitDependency extends Dependency { @override String get _info => 'url@$url'; + + @override + bool operator ==(Object other) => + other is GitDependency && + other.url == url && + other.ref == ref && + other.path == path; + + @override + int get hashCode => Object.hash(url, ref, path); } Uri? parseGitUriOrNull(String? value) => @@ -188,6 +205,13 @@ class PathDependency extends Dependency { @override String get _info => 'path@$path'; + + @override + bool operator ==(Object other) => + other is PathDependency && other.path == path; + + @override + int get hashCode => path.hashCode; } @JsonSerializable(disallowUnrecognizedKeys: true) @@ -204,6 +228,15 @@ class HostedDependency extends Dependency { @override String get _info => version.toString(); + + @override + bool operator ==(Object other) => + other is HostedDependency && + other.version == version && + other.hosted == hosted; + + @override + int get hashCode => Object.hash(version, hosted); } @JsonSerializable(disallowUnrecognizedKeys: true) @@ -240,6 +273,13 @@ class HostedDetails { throw ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); } + + @override + bool operator ==(Object other) => + other is HostedDetails && other.name == name && other.url == url; + + @override + int get hashCode => Object.hash(name, url); } VersionConstraint _constraintFromString(String? input) => diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 4f8eabc9a..9ca992dae 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.2.4-wip +version: 1.3.0 description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. From 94f1f40aed1fc9baf2fb5f462c53f2ece8ac1459 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 05:38:22 +0000 Subject: [PATCH 139/152] Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group (dart-lang/pubspec_parse#129) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.5 to 4.1.6
Release notes

Sourced from actions/checkout's releases.

v4.1.6

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.5...v4.1.6

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.5&new-version=4.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index b3f887735..e55f44e2d 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.0.0, dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From df5584740aaa8b5346cd7bdc9ee4a83ad5783d0a Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 4 Jun 2024 09:09:30 -0700 Subject: [PATCH 140/152] Latest lints, bump min SDK to 3.2 (dart-lang/pubspec_parse#131) --- .../.github/workflows/test-package.yml | 2 +- pkgs/pubspec_parse/CHANGELOG.md | 4 ++++ pkgs/pubspec_parse/pubspec.yaml | 18 +++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index e55f44e2d..da26a738c 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [3.0.0, dev] + sdk: [3.2, dev] steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index d14b82e40..aa99cbb5c 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.1-wip + +- Require Dart 3.2 + ## 1.3.0 - Require Dart 3.0 diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 9ca992dae..00cf12ce6 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.3.0 +version: 1.3.1-wip description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. @@ -8,7 +8,7 @@ topics: - dart-pub environment: - sdk: ^3.0.0 + sdk: ^3.2.0 dependencies: checked_yaml: ^2.0.1 @@ -18,14 +18,14 @@ dependencies: yaml: ^3.0.0 dev_dependencies: - build_runner: ^2.0.3 - build_verify: '>=2.0.0 <4.0.0' - dart_flutter_team_lints: ^2.0.0 + build_runner: ^2.2.1 + build_verify: ^3.0.0 + dart_flutter_team_lints: ^3.0.0 json_serializable: ^6.6.0 - path: ^1.5.1 + path: ^1.8.0 # Needed because we are configuring `combining_builder` - source_gen: ^1.0.0 - stack_trace: ^1.9.2 - test: ^1.0.0 + source_gen: ^1.2.3 + stack_trace: ^1.10.0 + test: ^1.21.6 test_descriptor: ^2.0.0 test_process: ^2.0.0 From c363290cc2104ad71d1567a8bf48918861b0fd31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 05:05:17 +0000 Subject: [PATCH 141/152] Bump the github-actions group with 2 updates (dart-lang/pubspec_parse#133) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `actions/checkout` from 4.1.6 to 4.1.7
Release notes

Sourced from actions/checkout's releases.

v4.1.7

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.6...v4.1.7

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

... (truncated)

Commits

Updates `dart-lang/setup-dart` from 1.6.4 to 1.6.5
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.5

dart-lang/pubspec_parse#118: dart-lang/setup-dartdart-lang/pubspec_parse#118

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.5

dart-lang/pubspec_parse#118: dart-lang/setup-dartdart-lang/pubspec_parse#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

... (truncated)

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index da26a738c..1bd25f969 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,8 +22,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install @@ -48,8 +48,8 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install From b9c5b3b4affba1bd6cb2e5c6c72b03eb1744f162 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 05:50:53 +0000 Subject: [PATCH 142/152] Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (dart-lang/pubspec_parse#135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.7 to 4.2.0
Release notes

Sourced from actions/checkout's releases.

v4.2.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.7...v4.2.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.7&new-version=4.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 1bd25f969..756cf5c84 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 770c3713a27b82578cb8472d186c19a20851e89b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 28 Oct 2024 14:51:08 -0700 Subject: [PATCH 143/152] blast_repo fixes (dart-lang/pubspec_parse#138) drop-lint --- pkgs/pubspec_parse/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index c20999920..93eeebff2 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml @@ -22,7 +22,6 @@ linter: - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - package_api_docs - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals From fba7c1f6d2c17ac83c32be11a5bb58b8cab6626c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 05:11:08 +0000 Subject: [PATCH 144/152] Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group (dart-lang/pubspec_parse#139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.2.0 to 4.2.2
Release notes

Sourced from actions/checkout's releases.

v4.2.2

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.2.1...v4.2.2

v4.2.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.2.0...v4.2.1

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.2

v4.2.1

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.2.0&new-version=4.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 756cf5c84..16fb962ec 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -48,7 +48,7 @@ jobs: os: [ubuntu-latest] sdk: [3.2, dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From bc0d37022765730f8eb3f4677b8e60db9126c49e Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Tue, 19 Nov 2024 18:52:20 +0100 Subject: [PATCH 145/152] chore: Remove deprecated package_api_docs rule (dart-lang/pubspec_parse#141) * chore: Remove deprecated package_api_docs rule * chore: Add changelog entry --- pkgs/pubspec_parse/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index aa99cbb5c..91613ccf6 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.3.1-wip - Require Dart 3.2 +- Remove deprecated package_api_docs rule ## 1.3.0 From c3fa9594c431be80054059a2f4bcaf832b410f71 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:17:22 +0000 Subject: [PATCH 146/152] Bump dart-lang/setup-dart in the github-actions group (dart-lang/pubspec_parse#142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `dart-lang/setup-dart` from 1.6.5 to 1.7.0
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.7.0

What's Changed

  • Install a Flutter SDK in the publish workflow allowing for publication of flutter packages.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.7.0

v1.6.5

dart-lang/pubspec_parse#118: dart-lang/setup-dartdart-lang/pubspec_parse#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.5&new-version=1.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/pubspec_parse/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/pkgs/pubspec_parse/.github/workflows/test-package.yml index 16fb962ec..922d6c28e 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/pkgs/pubspec_parse/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install @@ -49,7 +49,7 @@ jobs: sdk: [3.2, dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install From a7ddf356ad32bd36742108d300e12484772e3fb3 Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Tue, 10 Dec 2024 19:12:35 +0100 Subject: [PATCH 147/152] fix: Pubspec.environment can never be null (dart-lang/pubspec_parse#137) * fix: Pubspec.environment can never be null * chore: Add changelog entry * fix: _environmentMap to return empty map when input is null --- pkgs/pubspec_parse/CHANGELOG.md | 1 + pkgs/pubspec_parse/lib/src/pubspec.dart | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 91613ccf6..2768cdebd 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.3.1-wip - Require Dart 3.2 +- Set `Pubspec.environment` to non-nullable. - Remove deprecated package_api_docs rule ## 1.3.0 diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index f6934eef3..1317a2309 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -74,7 +74,7 @@ class Pubspec { final String? documentation; @JsonKey(fromJson: _environmentMap) - final Map? environment; + final Map environment; @JsonKey(fromJson: parseDeps) final Map dependencies; @@ -186,7 +186,7 @@ class Pubspec { Version? _versionFromString(String? input) => input == null ? null : Version.parse(input); -Map? _environmentMap(Map? source) => +Map _environmentMap(Map? source) => source?.map((k, value) { final key = k as String; if (key == 'dart') { @@ -222,4 +222,5 @@ Map? _environmentMap(Map? source) => } return MapEntry(key, constraint); - }); + }) ?? + {}; From a0c9f10e0b767de9eea199c4aa1b0f02da58a6c4 Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Wed, 11 Dec 2024 16:33:23 +0100 Subject: [PATCH 148/152] refactor!: Seal the Dependency class (dart-lang/pubspec_parse#140) * fix: Don't use runtimeType for toString --- pkgs/pubspec_parse/CHANGELOG.md | 3 +- pkgs/pubspec_parse/lib/src/dependency.dart | 43 +++++++++------------- pkgs/pubspec_parse/pubspec.yaml | 2 +- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 2768cdebd..251d4cc47 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,6 +1,7 @@ -## 1.3.1-wip +## 1.4.0-wip - Require Dart 3.2 +- Seal the `Dependency` class. - Set `Pubspec.environment` to non-nullable. - Remove deprecated package_api_docs rule diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index acce59843..24c65eac1 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -90,14 +90,7 @@ Dependency? _fromJson(Object? data, String name) { return null; } -abstract class Dependency { - Dependency._(); - - String get _info; - - @override - String toString() => '$runtimeType: $_info'; -} +sealed class Dependency {} @JsonSerializable() class SdkDependency extends Dependency { @@ -106,11 +99,7 @@ class SdkDependency extends Dependency { final VersionConstraint version; SdkDependency(this.sdk, {VersionConstraint? version}) - : version = version ?? VersionConstraint.any, - super._(); - - @override - String get _info => sdk; + : version = version ?? VersionConstraint.any; @override bool operator ==(Object other) => @@ -118,6 +107,9 @@ class SdkDependency extends Dependency { @override int get hashCode => Object.hash(sdk, version); + + @override + String toString() => 'SdkDependency: $sdk'; } @JsonSerializable() @@ -127,7 +119,7 @@ class GitDependency extends Dependency { final String? ref; final String? path; - GitDependency(this.url, {this.ref, this.path}) : super._(); + GitDependency(this.url, {this.ref, this.path}); factory GitDependency.fromData(Object? data) { if (data is String) { @@ -141,9 +133,6 @@ class GitDependency extends Dependency { throw ArgumentError.value(data, 'git', 'Must be a String or a Map.'); } - @override - String get _info => 'url@$url'; - @override bool operator ==(Object other) => other is GitDependency && @@ -153,6 +142,9 @@ class GitDependency extends Dependency { @override int get hashCode => Object.hash(url, ref, path); + + @override + String toString() => 'GitDependency: url@$url'; } Uri? parseGitUriOrNull(String? value) => @@ -194,7 +186,7 @@ Uri? _tryParseScpUri(String value) { class PathDependency extends Dependency { final String path; - PathDependency(this.path) : super._(); + PathDependency(this.path); factory PathDependency.fromData(Object? data) { if (data is String) { @@ -203,15 +195,15 @@ class PathDependency extends Dependency { throw ArgumentError.value(data, 'path', 'Must be a String.'); } - @override - String get _info => 'path@$path'; - @override bool operator ==(Object other) => other is PathDependency && other.path == path; @override int get hashCode => path.hashCode; + + @override + String toString() => 'PathDependency: path@$path'; } @JsonSerializable(disallowUnrecognizedKeys: true) @@ -223,11 +215,7 @@ class HostedDependency extends Dependency { final HostedDetails? hosted; HostedDependency({VersionConstraint? version, this.hosted}) - : version = version ?? VersionConstraint.any, - super._(); - - @override - String get _info => version.toString(); + : version = version ?? VersionConstraint.any; @override bool operator ==(Object other) => @@ -237,6 +225,9 @@ class HostedDependency extends Dependency { @override int get hashCode => Object.hash(version, hosted); + + @override + String toString() => 'HostedDependency: $version'; } @JsonSerializable(disallowUnrecognizedKeys: true) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 00cf12ce6..bcdaa31ff 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.3.1-wip +version: 1.4.0-wip description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. From 4a260a86fdde74aff242db4cfa064a33795b30d3 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 20 Dec 2024 13:58:31 +0100 Subject: [PATCH 149/152] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/pubspec_parse.md | 5 +++++ pkgs/pubspec_parse/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/pubspec_parse.md diff --git a/.github/ISSUE_TEMPLATE/pubspec_parse.md b/.github/ISSUE_TEMPLATE/pubspec_parse.md new file mode 100644 index 000000000..2d6588102 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/pubspec_parse.md @@ -0,0 +1,5 @@ +--- +name: "package:pubspec_parse" +about: "Create a bug or file a feature request against package:pubspec_parse." +labels: "package:pubspec_parse" +--- \ No newline at end of file diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index bcdaa31ff..cb29d02d5 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -3,7 +3,7 @@ version: 1.4.0-wip description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -repository: https://github.com/dart-lang/pubspec_parse +repository: https://github.com/dart-lang/tools/tree/main/pkgs/pubspec_parse topics: - dart-pub From 9a9a7e510a01c0bd2c21493085773c86548df7c8 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 20 Dec 2024 14:02:11 +0100 Subject: [PATCH 150/152] Moving fixes --- .github/labeler.yml | 4 ++++ .../workflows/pubspec_parse.yaml | 17 ++++++++++++++--- README.md | 1 + pkgs/pubspec_parse/.github/dependabot.yml | 15 --------------- .../.github/workflows/publish.yaml | 17 ----------------- pkgs/pubspec_parse/CHANGELOG.md | 3 ++- pkgs/pubspec_parse/README.md | 2 +- pkgs/pubspec_parse/pubspec.yaml | 2 +- 8 files changed, 23 insertions(+), 38 deletions(-) rename pkgs/pubspec_parse/.github/workflows/test-package.yml => .github/workflows/pubspec_parse.yaml (83%) delete mode 100644 pkgs/pubspec_parse/.github/dependabot.yml delete mode 100644 pkgs/pubspec_parse/.github/workflows/publish.yaml diff --git a/.github/labeler.yml b/.github/labeler.yml index bfef3164e..3ab79c051 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -92,6 +92,10 @@ - changed-files: - any-glob-to-any-file: 'pkgs/pub_semver/**' +'package:pubspec_parse': + - changed-files: + - any-glob-to-any-file: 'pkgs/pubspec_parse/**' + 'package:source_map_stack_trace': - changed-files: - any-glob-to-any-file: 'pkgs/source_map_stack_trace/**' diff --git a/pkgs/pubspec_parse/.github/workflows/test-package.yml b/.github/workflows/pubspec_parse.yaml similarity index 83% rename from pkgs/pubspec_parse/.github/workflows/test-package.yml rename to .github/workflows/pubspec_parse.yaml index 922d6c28e..ebe705912 100644 --- a/pkgs/pubspec_parse/.github/workflows/test-package.yml +++ b/.github/workflows/pubspec_parse.yaml @@ -1,17 +1,28 @@ -name: Dart CI +name: package:pubspec_parse on: # Run on PRs and pushes to the default branch. push: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/pubspec_parse.yaml' + - 'pkgs/pubspec_parse/**' pull_request: - branches: [ master ] + branches: [ main ] + paths: + - '.github/workflows/pubspec_parse.yaml' + - 'pkgs/pubspec_parse/**' schedule: - cron: "0 0 * * 0" env: PUB_ENVIRONMENT: bot.github + +defaults: + run: + working-directory: pkgs/pubspec_parse/ + jobs: # Check code formatting and static analysis on a single OS (linux) # against Dart dev. diff --git a/README.md b/README.md index d1a1d0416..0201aa284 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ don't naturally belong to other topic monorepos (like | [package_config](pkgs/package_config/) | Support for reading and writing Dart Package Configuration files. | [![package issues](https://img.shields.io/badge/package:package_config-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apackage_config) | [![pub package](https://img.shields.io/pub/v/package_config.svg)](https://pub.dev/packages/package_config) | | [pool](pkgs/pool/) | Manage a finite pool of resources. Useful for controlling concurrent file system or network requests. | [![package issues](https://img.shields.io/badge/package:pool-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apool) | [![pub package](https://img.shields.io/pub/v/pool.svg)](https://pub.dev/packages/pool) | | [pub_semver](pkgs/pub_semver/) | Versions and version constraints implementing pub's versioning policy. This is very similar to vanilla semver, with a few corner cases. | [![package issues](https://img.shields.io/badge/package:pub_semver-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apub_semver) | [![pub package](https://img.shields.io/pub/v/pub_semver.svg)](https://pub.dev/packages/pub_semver) | +| [pubspec_parse](pkgs/pubspec_parse/) | Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. | [![package issues](https://img.shields.io/badge/package:pubspec_parse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apubspec_parse) | [![pub package](https://img.shields.io/pub/v/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse) | | [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![package issues](https://img.shields.io/badge/package:source_map_stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_map_stack_trace) | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) | | [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) | | [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) | diff --git a/pkgs/pubspec_parse/.github/dependabot.yml b/pkgs/pubspec_parse/.github/dependabot.yml deleted file mode 100644 index cde02ad6a..000000000 --- a/pkgs/pubspec_parse/.github/dependabot.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Dependabot configuration file. -# See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates -version: 2 - -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit - groups: - github-actions: - patterns: - - "*" diff --git a/pkgs/pubspec_parse/.github/workflows/publish.yaml b/pkgs/pubspec_parse/.github/workflows/publish.yaml deleted file mode 100644 index 27157a046..000000000 --- a/pkgs/pubspec_parse/.github/workflows/publish.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# A CI configuration to auto-publish pub packages. - -name: Publish - -on: - pull_request: - branches: [ master ] - push: - tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ] - -jobs: - publish: - if: ${{ github.repository_owner == 'dart-lang' }} - uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main - permissions: - id-token: write # Required for authentication using OIDC - pull-requests: write # Required for writing the pull request note diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 251d4cc47..a5f0f1a30 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,9 +1,10 @@ -## 1.4.0-wip +## 1.4.0 - Require Dart 3.2 - Seal the `Dependency` class. - Set `Pubspec.environment` to non-nullable. - Remove deprecated package_api_docs rule +- Move to `dart-lang/tools` monorepo. ## 1.3.0 diff --git a/pkgs/pubspec_parse/README.md b/pkgs/pubspec_parse/README.md index 916742a63..1d04aa486 100644 --- a/pkgs/pubspec_parse/README.md +++ b/pkgs/pubspec_parse/README.md @@ -1,4 +1,4 @@ -[![Dart CI](https://github.com/dart-lang/pubspec_parse/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/pubspec_parse/actions/workflows/test-package.yml) +[![Build Status](https://github.com/dart-lang/tools/actions/workflows/pubspec_parse.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/pubspec_parse.yaml) [![pub package](https://img.shields.io/pub/v/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse) [![package publisher](https://img.shields.io/pub/publisher/pubspec_parse.svg)](https://pub.dev/packages/pubspec_parse/publisher) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index cb29d02d5..9d1c8db76 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.4.0-wip +version: 1.4.0 description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. From b1e27824e429cebb6f80b052818fd9946ada424a Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 20 Dec 2024 14:04:53 +0100 Subject: [PATCH 151/152] Add newline --- pkgs/pubspec_parse/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 9d1c8db76..ad0c55e67 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -4,6 +4,7 @@ description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. repository: https://github.com/dart-lang/tools/tree/main/pkgs/pubspec_parse + topics: - dart-pub From 4ebcd8ed2107dcbe8069a12782d68bdd0eb68748 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 20 Dec 2024 14:09:57 +0100 Subject: [PATCH 152/152] Update test --- pkgs/pubspec_parse/test/ensure_build_test.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index 689f6fe66..0e4371c13 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart @@ -11,5 +11,8 @@ import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; void main() { - test('ensure_build', expectBuildClean); + test( + 'ensure_build', + () => expectBuildClean(packageRelativeDirectory: 'pkgs/pubspec_parse/'), + ); }