From db7d92e4f0837515f1b04ea7741d362479058135 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Fri, 27 Oct 2023 10:26:09 -0500 Subject: [PATCH 1/2] Temporarily allow modification of a BuildOutput's dependencies --- pkgs/native_assets_cli/CHANGELOG.md | 7 +++++++ .../native_assets_cli/lib/src/model/build_output.dart | 6 ++++-- .../native_assets_cli/lib/src/model/dependencies.dart | 7 ++++++- pkgs/native_assets_cli/pubspec.yaml | 2 +- .../test/model/build_output_test.dart | 11 +++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pkgs/native_assets_cli/CHANGELOG.md b/pkgs/native_assets_cli/CHANGELOG.md index 27462e51a..9147bd4fd 100644 --- a/pkgs/native_assets_cli/CHANGELOG.md +++ b/pkgs/native_assets_cli/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.3.2 + +- Fixed an issue where `Depenendencies.dependencies` could not be + modified when expected to. + **Note:** Avoid modifying `Dependencies.dependencies` directly, + the property will likely return an `Iterable` in a future release. + ## 0.3.1 - Added `Target.androidRiscv64`. diff --git a/pkgs/native_assets_cli/lib/src/model/build_output.dart b/pkgs/native_assets_cli/lib/src/model/build_output.dart index 20dc0c6eb..6f88407cc 100644 --- a/pkgs/native_assets_cli/lib/src/model/build_output.dart +++ b/pkgs/native_assets_cli/lib/src/model/build_output.dart @@ -33,8 +33,10 @@ class BuildOutput { Metadata? metadata, }) : timestamp = (timestamp ?? DateTime.now()).roundDownToSeconds(), assets = assets ?? [], - dependencies = dependencies ?? const Dependencies([]), - metadata = metadata ?? const Metadata({}); + // ignore: prefer_const_constructors + dependencies = dependencies ?? Dependencies([]), + // ignore: prefer_const_constructors + metadata = metadata ?? Metadata({}); static const _assetsKey = 'assets'; static const _dependenciesKey = 'dependencies'; diff --git a/pkgs/native_assets_cli/lib/src/model/dependencies.dart b/pkgs/native_assets_cli/lib/src/model/dependencies.dart index 4db792a69..d648b73f4 100644 --- a/pkgs/native_assets_cli/lib/src/model/dependencies.dart +++ b/pkgs/native_assets_cli/lib/src/model/dependencies.dart @@ -10,6 +10,10 @@ import '../utils/uri.dart'; import '../utils/yaml.dart'; class Dependencies { + /// The dependencies a build relied on. + /// + /// NOTE: Do not modify this list. In a future release, + /// the [dependencies] property will likely return an [Iterable]. final List dependencies; const Dependencies(this.dependencies); @@ -19,7 +23,8 @@ class Dependencies { if (yaml is YamlList) { return Dependencies.fromYaml(yaml); } - return const Dependencies([]); + // ignore: prefer_const_constructors + return Dependencies([]); } factory Dependencies.fromYaml(YamlList? yamlList) => Dependencies([ diff --git a/pkgs/native_assets_cli/pubspec.yaml b/pkgs/native_assets_cli/pubspec.yaml index 47149e533..1c944d73a 100644 --- a/pkgs/native_assets_cli/pubspec.yaml +++ b/pkgs/native_assets_cli/pubspec.yaml @@ -2,7 +2,7 @@ name: native_assets_cli description: >- A library that contains the argument and file formats for implementing a native assets CLI. -version: 0.3.1 +version: 0.3.2 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_cli topics: diff --git a/pkgs/native_assets_cli/test/model/build_output_test.dart b/pkgs/native_assets_cli/test/model/build_output_test.dart index ef23bb872..2955450f9 100644 --- a/pkgs/native_assets_cli/test/model/build_output_test.dart +++ b/pkgs/native_assets_cli/test/model/build_output_test.dart @@ -159,4 +159,15 @@ version: ${BuildOutput.version}'''), throwsFormatException, ); }); + + test('BuildOutput dependencies can be modified', () { + // TODO(https://github.com/dart-lang/native/issues/168): + // Remove once dependencies are made immutable. + final buildOutput = BuildOutput(); + expect( + () => buildOutput.dependencies.dependencies + .add(Uri.file('path/to/file.ext')), + returnsNormally, + ); + }); } From ab90f30f771df2b8f3389f4191f5d97c19f033cb Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Fri, 27 Oct 2023 13:52:56 -0500 Subject: [PATCH 2/2] Update comments and notes --- pkgs/native_assets_cli/CHANGELOG.md | 2 -- pkgs/native_assets_cli/lib/src/model/dependencies.dart | 3 --- pkgs/native_assets_cli/test/model/build_output_test.dart | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pkgs/native_assets_cli/CHANGELOG.md b/pkgs/native_assets_cli/CHANGELOG.md index 9147bd4fd..0159aabd4 100644 --- a/pkgs/native_assets_cli/CHANGELOG.md +++ b/pkgs/native_assets_cli/CHANGELOG.md @@ -2,8 +2,6 @@ - Fixed an issue where `Depenendencies.dependencies` could not be modified when expected to. - **Note:** Avoid modifying `Dependencies.dependencies` directly, - the property will likely return an `Iterable` in a future release. ## 0.3.1 diff --git a/pkgs/native_assets_cli/lib/src/model/dependencies.dart b/pkgs/native_assets_cli/lib/src/model/dependencies.dart index d648b73f4..9ecc2cb91 100644 --- a/pkgs/native_assets_cli/lib/src/model/dependencies.dart +++ b/pkgs/native_assets_cli/lib/src/model/dependencies.dart @@ -11,9 +11,6 @@ import '../utils/yaml.dart'; class Dependencies { /// The dependencies a build relied on. - /// - /// NOTE: Do not modify this list. In a future release, - /// the [dependencies] property will likely return an [Iterable]. final List dependencies; const Dependencies(this.dependencies); diff --git a/pkgs/native_assets_cli/test/model/build_output_test.dart b/pkgs/native_assets_cli/test/model/build_output_test.dart index 2955450f9..0dc0bad27 100644 --- a/pkgs/native_assets_cli/test/model/build_output_test.dart +++ b/pkgs/native_assets_cli/test/model/build_output_test.dart @@ -161,7 +161,7 @@ version: ${BuildOutput.version}'''), }); test('BuildOutput dependencies can be modified', () { - // TODO(https://github.com/dart-lang/native/issues/168): + // TODO(https://github.com/dart-lang/native/issues/25): // Remove once dependencies are made immutable. final buildOutput = BuildOutput(); expect(