diff --git a/.github/workflows/html.yaml b/.github/workflows/html.yaml index afbaad4e5..e2702b1d1 100644 --- a/.github/workflows/html.yaml +++ b/.github/workflows/html.yaml @@ -45,7 +45,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [3.2, stable, dev] + sdk: [3.6, stable, dev] steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c diff --git a/.github/workflows/pubspec_parse.yaml b/.github/workflows/pubspec_parse.yaml index 9388669d9..a5dea386c 100644 --- a/.github/workflows/pubspec_parse.yaml +++ b/.github/workflows/pubspec_parse.yaml @@ -54,7 +54,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - sdk: [3.6, dev] + sdk: [3.8, dev] steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c diff --git a/pkgs/graphs/pubspec.yaml b/pkgs/graphs/pubspec.yaml index e25ee85de..d3779b5a8 100644 --- a/pkgs/graphs/pubspec.yaml +++ b/pkgs/graphs/pubspec.yaml @@ -15,6 +15,6 @@ dev_dependencies: test: ^1.21.6 # For examples - analyzer: '>=5.2.0 <8.0.0' + analyzer: '>=5.2.0 <9.0.0' path: ^1.8.0 pool: ^1.5.0 diff --git a/pkgs/html/CHANGELOG.md b/pkgs/html/CHANGELOG.md index c0e48769e..17cbb8466 100644 --- a/pkgs/html/CHANGELOG.md +++ b/pkgs/html/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.15.7-wip + +- Require Dart `3.6` + ## 0.15.6 - Performance improvements. diff --git a/pkgs/html/pubspec.yaml b/pkgs/html/pubspec.yaml index 75327df30..c2ce3c370 100644 --- a/pkgs/html/pubspec.yaml +++ b/pkgs/html/pubspec.yaml @@ -1,5 +1,5 @@ name: html -version: 0.15.6 +version: 0.15.7-wip description: APIs for parsing and manipulating HTML content outside the browser. repository: https://github.com/dart-lang/tools/tree/main/pkgs/html issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ahtml @@ -9,7 +9,7 @@ topics: - web environment: - sdk: ^3.2.0 + sdk: ^3.6.0 dependencies: csslib: ^1.0.0 @@ -17,6 +17,6 @@ dependencies: dev_dependencies: dart_flutter_team_lints: ^3.0.0 - dart_style: ^2.3.6 + dart_style: ^3.0.0 path: ^1.8.0 test: ^1.16.6 diff --git a/pkgs/html/tool/generate_trie.dart b/pkgs/html/tool/generate_trie.dart index e7fc99619..9042830e0 100644 --- a/pkgs/html/tool/generate_trie.dart +++ b/pkgs/html/tool/generate_trie.dart @@ -17,7 +17,9 @@ void main() { '''// AUTO GENERATED by 'tool/generate_trie.dart'. DO NOT EDIT!\n''' 'const entitiesTrieRoot = $root;' .replaceAll('{}', '{}'); - final formatted = DartFormatter().format(source); + final formatted = DartFormatter( + languageVersion: DartFormatter.latestShortStyleLanguageVersion) + .format(source); final htmlDir = File(Platform.script.path).parent.parent; File(join(htmlDir.path, 'lib', 'src', 'trie.dart')) .writeAsStringSync(formatted); diff --git a/pkgs/process/pubspec.yaml b/pkgs/process/pubspec.yaml index 32a977708..064e9411b 100644 --- a/pkgs/process/pubspec.yaml +++ b/pkgs/process/pubspec.yaml @@ -16,5 +16,5 @@ dependencies: platform: '^3.0.0' dev_dependencies: - lints: ^5.0.0 + lints: ^6.0.0 test: ^1.16.8 diff --git a/pkgs/pubspec_parse/CHANGELOG.md b/pkgs/pubspec_parse/CHANGELOG.md index 5aeb49802..31b30456b 100644 --- a/pkgs/pubspec_parse/CHANGELOG.md +++ b/pkgs/pubspec_parse/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.5.1-wip + +- Require Dart 3.8 + ## 1.5.0 - Added fields to `Pubspec`: `executables`, `resolution`, `workspace`. diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 24c65eac1..ff052fa64 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart @@ -46,14 +46,17 @@ Dependency? _fromJson(Object? data, String name) { } if (data is Map) { - final matchedKeys = - data.keys.cast().where((key) => key != 'version').toList(); + final matchedKeys = data.keys + .cast() + .where((key) => key != 'version') + .toList(); if (data.isEmpty || (matchedKeys.isEmpty && data.containsKey('version'))) { return _$HostedDependencyFromJson(data); } else { - final firstUnrecognizedKey = - matchedKeys.firstWhereOrNull((k) => !_sourceKeys.contains(k)); + final firstUnrecognizedKey = matchedKeys.firstWhereOrNull( + (k) => !_sourceKeys.contains(k), + ); return $checkedNew('Dependency', data, () { if (firstUnrecognizedKey != null) { @@ -78,8 +81,9 @@ Dependency? _fromJson(Object? data, String name) { 'git' => GitDependency.fromData(data[key]), 'path' => PathDependency.fromData(data[key]), 'sdk' => _$SdkDependencyFromJson(data), - 'hosted' => _$HostedDependencyFromJson(data) - ..hosted?._nameOfPackage = name, + 'hosted' => _$HostedDependencyFromJson( + data, + )..hosted?._nameOfPackage = name, _ => throw StateError('There is a bug in pubspec_parse.'), }; }); @@ -99,7 +103,7 @@ class SdkDependency extends Dependency { final VersionConstraint version; SdkDependency(this.sdk, {VersionConstraint? version}) - : version = version ?? VersionConstraint.any; + : version = version ?? VersionConstraint.any; @override bool operator ==(Object other) => @@ -215,7 +219,7 @@ class HostedDependency extends Dependency { final HostedDetails? hosted; HostedDependency({VersionConstraint? version, this.hosted}) - : version = version ?? VersionConstraint.any; + : version = version ?? VersionConstraint.any; @override bool operator ==(Object other) => diff --git a/pkgs/pubspec_parse/lib/src/dependency.g.dart b/pkgs/pubspec_parse/lib/src/dependency.g.dart index 1a504f1fd..8300ebee9 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.g.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.g.dart @@ -8,65 +8,58 @@ part of 'dependency.dart'; // JsonSerializableGenerator // ************************************************************************** -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; - }, - ); +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; + }); -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; - }, - ); +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; + }); -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; - }, - ); +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; + }); -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; - }, - fieldKeyMap: const {'declaredName': 'name'}, - ); +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; + }, fieldKeyMap: const {'declaredName': 'name'}); diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index eb779089a..01327f4a3 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart @@ -57,9 +57,7 @@ class Pubspec { /// If there is exactly 1 value in [authors], returns it. /// /// If there are 0 or more than 1, returns `null`. - @Deprecated( - 'See https://dart.dev/tools/pub/pubspec#authorauthors', - ) + @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') String? get author { if (authors.length == 1) { return authors.single; @@ -67,9 +65,7 @@ class Pubspec { return null; } - @Deprecated( - 'See https://dart.dev/tools/pub/pubspec#authorauthors', - ) + @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') final List authors; final String? documentation; @@ -109,13 +105,9 @@ class Pubspec { this.name, { this.version, this.publishTo, - @Deprecated( - 'See https://dart.dev/tools/pub/pubspec#authorauthors', - ) + @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') String? author, - @Deprecated( - 'See https://dart.dev/tools/pub/pubspec#authorauthors', - ) + @Deprecated('See https://dart.dev/tools/pub/pubspec#authorauthors') List? authors, Map? environment, this.homepage, @@ -134,14 +126,16 @@ class Pubspec { Map? dependencyOverrides, this.flutter, Map? executables, - }) : - // ignore: deprecated_member_use_from_same_package - authors = _normalizeAuthors(author, authors), - environment = environment ?? const {}, - dependencies = dependencies ?? const {}, - devDependencies = devDependencies ?? const {}, - executables = executables ?? const {}, - dependencyOverrides = dependencyOverrides ?? const {} { + }) : authors // ignore: deprecated_member_use_from_same_package + = _normalizeAuthors( + author, + authors, + ), + environment = environment ?? const {}, + dependencies = dependencies ?? const {}, + devDependencies = devDependencies ?? const {}, + executables = executables ?? const {}, + dependencyOverrides = dependencyOverrides ?? const {} { if (name.isEmpty) { throw ArgumentError.value(name, 'name', '"name" cannot be empty.'); } @@ -189,10 +183,7 @@ class Pubspec { ); static List _normalizeAuthors(String? author, List? authors) { - final value = { - if (author != null) author, - ...?authors, - }; + final value = {if (author != null) author, ...?authors}; return value.toList(); } } diff --git a/pkgs/pubspec_parse/lib/src/pubspec.g.dart b/pkgs/pubspec_parse/lib/src/pubspec.g.dart index 58e015a5e..fa2222567 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.g.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.g.dart @@ -9,61 +9,86 @@ part of 'pubspec.dart'; // ************************************************************************** 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)), - funding: $checkedConvert( - 'funding', - (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()), - 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?), - description: $checkedConvert('description', (v) => v as String?), - workspace: $checkedConvert('workspace', - (v) => (v as List?)?.map((e) => e as String).toList()), - resolution: $checkedConvert('resolution', (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), - )), - executables: - $checkedConvert('executables', (v) => _executablesMap(v as Map?)), - ); - return val; - }, - fieldKeyMap: const { - 'publishTo': 'publish_to', - 'issueTracker': 'issue_tracker', - 'ignoredAdvisories': 'ignored_advisories', - 'devDependencies': 'dev_dependencies', - 'dependencyOverrides': 'dependency_overrides' - }, + '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), + ), + funding: $checkedConvert( + 'funding', + (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(), + ), + 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?), + description: $checkedConvert('description', (v) => v as String?), + workspace: $checkedConvert( + 'workspace', + (v) => (v as List?)?.map((e) => e as String).toList(), + ), + resolution: $checkedConvert('resolution', (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)), + ), + executables: $checkedConvert( + 'executables', + (v) => _executablesMap(v as Map?), + ), ); + return val; + }, + fieldKeyMap: const { + 'publishTo': 'publish_to', + 'issueTracker': 'issue_tracker', + 'ignoredAdvisories': 'ignored_advisories', + 'devDependencies': 'dev_dependencies', + 'dependencyOverrides': 'dependency_overrides', + }, +); diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml index 90741efff..0769ddf55 100644 --- a/pkgs/pubspec_parse/pubspec.yaml +++ b/pkgs/pubspec_parse/pubspec.yaml @@ -1,5 +1,5 @@ name: pubspec_parse -version: 1.5.0 +version: 1.5.1-wip description: >- Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. @@ -10,24 +10,24 @@ topics: - dart-pub environment: - sdk: ^3.6.0 + sdk: ^3.8.0 dependencies: checked_yaml: ^2.0.1 collection: ^1.19.0 json_annotation: ^4.9.0 pub_semver: ^2.1.4 - yaml: ^3.0.0 + yaml: ^3.1.2 dev_dependencies: - build_runner: ^2.4.6 + build_runner: ^2.6.0 build_verify: ^3.0.0 dart_flutter_team_lints: ^3.0.0 - json_serializable: ^6.9.1 + json_serializable: ^6.11.1 path: ^1.9.0 # Needed because we are configuring `combining_builder` - source_gen: ^2.0.0 + source_gen: ^4.0.0 stack_trace: ^1.10.0 - test: ^1.24.4 + test: ^1.25.9 test_descriptor: ^2.0.0 test_process: ^2.0.0 diff --git a/pkgs/pubspec_parse/test/dependency_test.dart b/pkgs/pubspec_parse/test/dependency_test.dart index f1e4f5776..8d4353fe8 100644 --- a/pkgs/pubspec_parse/test/dependency_test.dart +++ b/pkgs/pubspec_parse/test/dependency_test.dart @@ -18,29 +18,23 @@ void main() { group('errors', () { test('List', () { - _expectThrows( - [], - r''' + _expectThrows([], r''' line 4, column 10: Unsupported value for "dep". Not a valid dependency value. ╷ 4 │ "dep": [] │ ^^ - ╵''', - ); + ╵'''); }); test('int', () { - _expectThrows( - 42, - r''' + _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', () { @@ -91,15 +85,12 @@ void _hostedDependency() { }); test('bad string version', () { - _expectThrows( - 'not a version', - r''' + _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', () async { @@ -216,26 +207,25 @@ void _sdkDependency() { }); test('with version', () async { - final dep = await _dependency( - {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}, - ); + final dep = await _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', () { - _expectThrowsContaining( - {'sdk': null}, - r"type 'Null' is not a subtype of type 'String'", - ); + _expectThrowsContaining({ + 'sdk': null, + }, r"type 'Null' is not a subtype of type 'String'"); }); test('number content', () { - _expectThrowsContaining( - {'sdk': 42}, - r"type 'int' is not a subtype of type 'String'", - ); + _expectThrowsContaining({ + 'sdk': 42, + }, r"type 'int' is not a subtype of type 'String'"); }); } @@ -250,8 +240,10 @@ void _gitDependency() { test('string with version key is ignored', () async { // Regression test for https://github.com/dart-lang/pubspec_parse/issues/13 - final dep = - await _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); @@ -263,10 +255,9 @@ void _gitDependency() { if (skipTryParse) { print('FYI: not validating git@ URI on travis due to failure'); } - final dep = await _dependency( - {'git': 'git@localhost:dep.git'}, - skipTryPub: skipTryParse, - ); + final dep = await _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); @@ -324,28 +315,21 @@ line 5, column 11: Unsupported value for "git". Must be a String or a Map. }); test('git - empty map', () { - _expectThrowsContaining( - {'git': {}}, - r"type 'Null' is not a subtype of type 'String'", - ); + _expectThrowsContaining({ + 'git': {}, + }, r"type 'Null' is not a subtype of type 'String'"); }); test('git - null url', () { - _expectThrowsContaining( - { - 'git': {'url': null}, - }, - r"type 'Null' is not a subtype of type 'String'", - ); + _expectThrowsContaining({ + 'git': {'url': null}, + }, r"type 'Null' is not a subtype of type 'String'"); }); test('git - int url', () { - _expectThrowsContaining( - { - 'git': {'url': 42}, - }, - r"type 'int' is not a subtype of type 'String'", - ); + _expectThrowsContaining({ + 'git': {'url': 42}, + }, r"type 'int' is not a subtype of type 'String'"); }); } @@ -357,9 +341,10 @@ void _pathDependency() { }); test('valid with version key is ignored', () async { - final dep = await _dependency( - {'path': '../path', 'version': '^1.2.3'}, - ); + final dep = await _dependency({ + 'path': '../path', + 'version': '^1.2.3', + }); expect(dep.path, '../path'); expect(dep.toString(), 'PathDependency: path@../path'); }); @@ -406,36 +391,27 @@ 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); } void _expectThrowsContaining(Object content, String errorText) { - expectParseThrowsContaining( - { - 'name': 'sample', - 'dependencies': {'dep': content}, - }, - errorText, - ); + expectParseThrowsContaining({ + 'name': 'sample', + 'dependencies': {'dep': content}, + }, errorText); } Future _dependency( Object? content, { bool skipTryPub = false, }) async { - final value = await parse( - { - ...defaultPubspec, - 'dependencies': {'dep': content}, - }, - skipTryPub: skipTryPub, - ); + final value = await parse({ + ...defaultPubspec, + 'dependencies': {'dep': content}, + }, skipTryPub: skipTryPub); expect(value.name, 'sample'); expect(value.dependencies, hasLength(1)); diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index e0698af16..f700b4efa 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart @@ -20,10 +20,9 @@ void main() { expect(value.homepage, isNull); expect(value.author, isNull); expect(value.authors, isEmpty); - expect( - value.environment, - {'sdk': VersionConstraint.parse('>=2.12.0 <3.0.0')}, - ); + expect(value.environment, { + 'sdk': VersionConstraint.parse('>=2.12.0 <3.0.0'), + }); expect(value.documentation, isNull); expect(value.dependencies, isEmpty); expect(value.devDependencies, isEmpty); @@ -40,38 +39,30 @@ void main() { test('all fields set', () async { final version = Version.parse('1.2.3'); final sdkConstraint = VersionConstraint.parse('>=3.6.0 <4.0.0'); - final value = await parse( - { - 'name': 'sample', - 'version': version.toString(), - 'publish_to': 'none', - 'author': 'name@example.com', - 'environment': {'sdk': sdkConstraint.toString()}, - 'description': 'description', - 'homepage': 'homepage', - 'documentation': 'documentation', - 'repository': 'https://github.com/example/repo', - 'issue_tracker': 'https://github.com/example/repo/issues', - 'funding': [ - 'https://patreon.com/example', - ], - 'topics': ['widget', 'button'], - 'ignored_advisories': ['111', '222'], - 'screenshots': [ - {'description': 'my screenshot', 'path': 'path/to/screenshot'}, - ], - 'workspace': [ - 'pkg1', - 'pkg2', - ], - 'resolution': 'workspace', - 'executables': { - 'my_script': 'bin/my_script.dart', - 'my_script2': 'bin/my_script2.dart', - }, + final value = await parse({ + 'name': 'sample', + 'version': version.toString(), + 'publish_to': 'none', + 'author': 'name@example.com', + 'environment': {'sdk': sdkConstraint.toString()}, + 'description': 'description', + 'homepage': 'homepage', + 'documentation': 'documentation', + 'repository': 'https://github.com/example/repo', + 'issue_tracker': 'https://github.com/example/repo/issues', + 'funding': ['https://patreon.com/example'], + 'topics': ['widget', 'button'], + 'ignored_advisories': ['111', '222'], + 'screenshots': [ + {'description': 'my screenshot', 'path': 'path/to/screenshot'}, + ], + 'workspace': ['pkg1', 'pkg2'], + 'resolution': 'workspace', + 'executables': { + 'my_script': 'bin/my_script.dart', + 'my_script2': 'bin/my_script2.dart', }, - skipTryPub: true, - ); + }, skipTryPub: true); expect(value.name, 'sample'); expect(value.version, version); expect(value.publishTo, 'none'); @@ -113,16 +104,10 @@ void main() { }); test('environment values can be null', () async { - final value = await parse( - { - 'name': 'sample', - 'environment': { - 'sdk': '>=2.12.0 <3.0.0', - 'bob': null, - }, - }, - skipTryPub: true, - ); + final value = await parse({ + 'name': 'sample', + 'environment': {'sdk': '>=2.12.0 <3.0.0', 'bob': null}, + }, skipTryPub: true); expect(value.name, 'sample'); expect(value.environment, hasLength(2)); expect(value.environment, containsPair('bob', isNull)); @@ -262,9 +247,7 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https expectParseThrowsContaining( { ...defaultPubspec, - 'executables': { - 'script': 32, - }, + 'executables': {'script': 32}, }, 'Unsupported value for "script". `32` is not a String.', skipTryPub: true, @@ -272,13 +255,10 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https }); test('invalid executable - lenient', () async { - final value = await parse( - { - ...defaultPubspec, - 'executables': 'Invalid value', - }, - lenient: true, - ); + final value = await parse({ + ...defaultPubspec, + 'executables': 'Invalid value', + }, lenient: true); expect(value.name, 'sample'); expect(value.executables, isEmpty); }); @@ -286,37 +266,28 @@ line 3, column 16: Unsupported value for "publish_to". Must be an http or https group('invalid', () { test('null', () { - expectParseThrows( - null, - r''' + expectParseThrows(null, r''' line 1, column 1: Not a map ╷ 1 │ null │ ^^^^ - ╵''', - ); + ╵'''); }); test('empty string', () { - expectParseThrows( - '', - r''' + expectParseThrows('', r''' line 1, column 1: Not a map ╷ 1 │ "" │ ^^ - ╵''', - ); + ╵'''); }); test('array', () { - expectParseThrows( - [], - r''' + expectParseThrows([], r''' line 1, column 1: Not a map ╷ 1 │ [] │ ^^ - ╵''', - ); + ╵'''); }); test('missing name', () { @@ -430,10 +401,7 @@ line 4, column 10: Unsupported value for "sdk". Could not parse version "silly". group('funding', () { test('not a list', () { expectParseThrowsContaining( - { - ...defaultPubspec, - 'funding': 1, - }, + {...defaultPubspec, 'funding': 1}, "Unsupported value for \"funding\". type 'int' is not a subtype of type 'List?'", skipTryPub: true, ); @@ -471,10 +439,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at group('topics', () { test('not a list', () { expectParseThrowsContaining( - { - ...defaultPubspec, - 'topics': 1, - }, + {...defaultPubspec, 'topics': 1}, "Unsupported value for \"topics\". type 'int' is not a subtype of type 'List?'", skipTryPub: true, ); @@ -508,10 +473,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at group('ignored_advisories', () { test('not a list', () { expectParseThrowsContaining( - { - ...defaultPubspec, - 'ignored_advisories': 1, - }, + {...defaultPubspec, 'ignored_advisories': 1}, "Unsupported value for \"ignored_advisories\". type 'int' is not a subtype of type 'List?'", skipTryPub: true, ); @@ -594,10 +556,7 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at test('invalid entries', () async { final value = await parse({ ...defaultPubspec, - 'screenshots': [ - 42, - 'not a screenshot', - ], + 'screenshots': [42, 'not a screenshot'], }); expect(value.screenshots, isEmpty); }); @@ -665,10 +624,7 @@ line 8, column 19: Unsupported value for "description". `42` is not a String { ...defaultPubspec, 'screenshots': [ - { - 'description': '', - 'path': 42, - }, + {'description': '', 'path': 42}, ], }, r''' @@ -684,13 +640,10 @@ line 9, column 12: Unsupported value for "path". `42` is not a String }); test('invalid screenshot - lenient', () async { - final value = await parse( - { - ...defaultPubspec, - 'screenshots': 'Invalid value', - }, - lenient: true, - ); + final value = await parse({ + ...defaultPubspec, + 'screenshots': 'Invalid value', + }, lenient: true); expect(value.name, 'sample'); expect(value.screenshots, isEmpty); }); @@ -698,29 +651,21 @@ line 9, column 12: Unsupported value for "path". `42` is not a String group('lenient', () { test('null', () { - expectParseThrows( - null, - r''' + expectParseThrows(null, r''' line 1, column 1: Not a map ╷ 1 │ null │ ^^^^ - ╵''', - lenient: true, - ); + ╵''', lenient: true); }); test('empty string', () { - expectParseThrows( - '', - r''' + expectParseThrows('', r''' line 1, column 1: Not a map ╷ 1 │ "" │ ^^ - ╵''', - lenient: true, - ); + ╵''', lenient: true); }); test('name cannot be empty', () { @@ -732,38 +677,29 @@ line 1, column 1: Not a map }); test('bad repository url', () async { - final value = await parse( - { - ...defaultPubspec, - 'repository': {'x': 'y'}, - }, - lenient: true, - ); + final value = await parse({ + ...defaultPubspec, + 'repository': {'x': 'y'}, + }, lenient: true); expect(value.name, 'sample'); expect(value.repository, isNull); }); test('bad issue_tracker url', () async { - final value = await parse( - { - ...defaultPubspec, - 'issue_tracker': {'x': 'y'}, - }, - lenient: true, - ); + final value = await parse({ + ...defaultPubspec, + 'issue_tracker': {'x': 'y'}, + }, lenient: true); expect(value.name, 'sample'); expect(value.issueTracker, isNull); }); test('multiple bad values', () async { - final value = await parse( - { - ...defaultPubspec, - 'repository': {'x': 'y'}, - 'issue_tracker': {'x': 'y'}, - }, - lenient: true, - ); + final value = await parse({ + ...defaultPubspec, + 'repository': {'x': 'y'}, + 'issue_tracker': {'x': 'y'}, + }, lenient: true); expect(value.name, 'sample'); expect(value.repository, isNull); expect(value.issueTracker, isNull); @@ -792,10 +728,7 @@ line 1, column 1: Not a map group('workspaces', () { test('workspace key must be a list', () { expectParseThrowsContaining( - { - ...defaultPubspec, - 'workspace': 42, - }, + {...defaultPubspec, 'workspace': 42}, 'Unsupported value for "workspace". type \'int\' is not a subtype of type \'List?\' in type cast', skipTryPub: true, ); diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index a60aa2a99..3660f5ec5 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart @@ -32,8 +32,9 @@ Future tryPub(String content) async { ); if (result.exitCode == 0) { - final lockContent = - File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); + final lockContent = File( + p.join(d.sandbox, 'pubspec.lock'), + ).readAsStringSync(); printOnFailure( [ diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index cc46522b7..e04c41088 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart @@ -21,17 +21,17 @@ 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, - ), - ); + 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; @@ -52,8 +52,9 @@ void _printDebugParsedYamlException(ParsedYamlException e) { items.add(Trace.format(innerStack)); } - final content = - LineSplitter.split(items.join('\n')).map((e) => ' $e').join('\n'); + final content = LineSplitter.split( + items.join('\n'), + ).map((e) => ' $e').join('\n'); printOnFailure('Inner error details:\n$content'); } @@ -112,16 +113,15 @@ void expectParseThrows( String expectedError, { bool skipTryPub = false, bool lenient = false, -}) => - expect( - () => parse( - content, - lenient: lenient, - quietOnError: true, - skipTryPub: skipTryPub, - ), - _throwsParsedYamlException(expectedError), - ); +}) => expect( + () => parse( + content, + lenient: lenient, + quietOnError: true, + skipTryPub: skipTryPub, + ), + _throwsParsedYamlException(expectedError), +); void expectParseThrowsContaining( Object? content,