Skip to content

Commit 8ca0ae0

Browse files
authored
Add support for 'ignored_advisories' field (dart-archive/pubspec_parse#118)
1 parent cfa97ea commit 8ca0ae0

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

pkgs/pubspec_parse/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 1.2.4-wip
22

33
- Require Dart 3.0
4+
- Added support for `ignored_advisories` field.
45

56
## 1.2.3
67

pkgs/pubspec_parse/lib/src/pubspec.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class Pubspec {
4747
/// Optional field to list the topics that this packages belongs to.
4848
final List<String>? topics;
4949

50+
/// Optional field to list advisories to be ignored by the client.
51+
final List<String>? ignoredAdvisories;
52+
5053
/// Optional field for specifying included screenshot files.
5154
@JsonKey(fromJson: parseScreenshots)
5255
final List<Screenshot>? screenshots;
@@ -110,6 +113,7 @@ class Pubspec {
110113
this.issueTracker,
111114
this.funding,
112115
this.topics,
116+
this.ignoredAdvisories,
113117
this.screenshots,
114118
this.documentation,
115119
this.description,

pkgs/pubspec_parse/lib/src/pubspec.g.dart

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/pubspec_parse/test/parse_test.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void main() {
5252
'https://patreon.com/example',
5353
],
5454
'topics': ['widget', 'button'],
55+
'ignored_advisories': ['111', '222'],
5556
'screenshots': [
5657
{'description': 'my screenshot', 'path': 'path/to/screenshot'},
5758
],
@@ -79,6 +80,9 @@ void main() {
7980
expect(value.topics, hasLength(2));
8081
expect(value.topics!.first, 'widget');
8182
expect(value.topics!.last, 'button');
83+
expect(value.ignoredAdvisories, hasLength(2));
84+
expect(value.ignoredAdvisories!.first, '111');
85+
expect(value.ignoredAdvisories!.last, '222');
8286
expect(value.screenshots, hasLength(1));
8387
expect(value.screenshots!.first.description, 'my screenshot');
8488
expect(value.screenshots!.first.path, 'path/to/screenshot');
@@ -425,6 +429,43 @@ line 6, column 13: Unsupported value for "funding". Illegal scheme character at
425429
});
426430
});
427431

432+
group('ignored_advisories', () {
433+
test('not a list', () {
434+
expectParseThrowsContaining(
435+
{
436+
...defaultPubspec,
437+
'ignored_advisories': 1,
438+
},
439+
"Unsupported value for \"ignored_advisories\". type 'int' is not a subtype of type 'List<dynamic>?'",
440+
skipTryPub: true,
441+
);
442+
});
443+
444+
test('not a string', () {
445+
expectParseThrowsContaining(
446+
{
447+
...defaultPubspec,
448+
'ignored_advisories': [1],
449+
},
450+
"Unsupported value for \"ignored_advisories\". type 'int' is not a subtype of type 'String'",
451+
skipTryPub: true,
452+
);
453+
});
454+
455+
test('invalid data - lenient', () async {
456+
final value = await parse(
457+
{
458+
...defaultPubspec,
459+
'ignored_advisories': [1],
460+
},
461+
skipTryPub: true,
462+
lenient: true,
463+
);
464+
expect(value.name, 'sample');
465+
expect(value.ignoredAdvisories, isNull);
466+
});
467+
});
468+
428469
group('screenshots', () {
429470
test('one screenshot', () async {
430471
final value = await parse({

0 commit comments

Comments
 (0)