diff --git a/packages/fluttium_interfaces/lib/src/fluttium/action_location.dart b/packages/fluttium_interfaces/lib/src/fluttium/addon_location.dart similarity index 71% rename from packages/fluttium_interfaces/lib/src/fluttium/action_location.dart rename to packages/fluttium_interfaces/lib/src/fluttium/addon_location.dart index 6bcd2144..77bbceec 100644 --- a/packages/fluttium_interfaces/lib/src/fluttium/action_location.dart +++ b/packages/fluttium_interfaces/lib/src/fluttium/addon_location.dart @@ -1,12 +1,16 @@ import 'package:equatable/equatable.dart'; import 'package:fluttium_interfaces/src/fluttium/fluttium.dart'; -/// {@template action_location} /// The location of an action. +@Deprecated('use AddonLocation instead') +typedef ActionLocation = AddonLocation; + +/// {@template addon_location} +/// The location of an addon. /// {@endtemplate} -class ActionLocation extends Equatable { - /// {@macro action_location} - const ActionLocation({ +class AddonLocation extends Equatable { + /// {@macro addon_location} + const AddonLocation({ this.hosted, this.git, this.path, @@ -17,12 +21,12 @@ class ActionLocation extends Equatable { 'Only one of hosted, git, or path can be set.', ); - /// {@macro action_location} + /// {@macro addon_location} /// - /// Converts a json map to an [ActionLocation]. - factory ActionLocation.fromJson(dynamic data) { + /// Converts a json map to an [AddonLocation]. + factory AddonLocation.fromJson(dynamic data) { if (data is String) { - return ActionLocation( + return AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse(data), @@ -30,7 +34,7 @@ class ActionLocation extends Equatable { ); } else if (data is Map) { if (data.containsKey('hosted')) { - return ActionLocation( + return AddonLocation( hosted: HostedPath( url: data['hosted'] as String, version: VersionConstraint.parse(data['version'] as String), @@ -39,9 +43,9 @@ class ActionLocation extends Equatable { } else if (data.containsKey('git')) { final dynamic git = data['git']; if (git is String) { - return ActionLocation(git: GitPath(url: git)); + return AddonLocation(git: GitPath(url: git)); } else if (git is Map) { - return ActionLocation( + return AddonLocation( git: GitPath( url: git['url'] as String, ref: git['ref'] as String?, @@ -50,9 +54,9 @@ class ActionLocation extends Equatable { ); } } else if (data.containsKey('path')) { - return ActionLocation(path: data['path'] as String); + return AddonLocation(path: data['path'] as String); } - throw UnsupportedError('unknown action dependency setup: $data'); + throw UnsupportedError('unknown addon dependency setup: $data'); } else { throw ArgumentError.value( data, @@ -62,13 +66,13 @@ class ActionLocation extends Equatable { } } - /// The hosted path of the action. + /// The hosted path of the addon. final HostedPath? hosted; - /// The git path of the action. + /// The git path of the addon. final GitPath? git; - /// The path of the action. + /// The path of the addon. final String? path; @override @@ -76,7 +80,7 @@ class ActionLocation extends Equatable { } /// {@template hosted_path} -/// The hosted path of an action. +/// The hosted path of an addon. /// {@endtemplate} class HostedPath extends Equatable { /// {@macro hosted_path} @@ -88,7 +92,7 @@ class HostedPath extends Equatable { /// The hosted url. final String url; - /// The version constraint of the action. + /// The version constraint of the addon. final VersionConstraint version; @override @@ -96,7 +100,7 @@ class HostedPath extends Equatable { } /// {@template git_path} -/// The git path of an action. +/// The git path of an addon. /// {@endtemplate} class GitPath extends Equatable { /// {@macro git_path} @@ -112,7 +116,7 @@ class GitPath extends Equatable { /// The ref of the git repository. final String? ref; - /// The path where the action is located in the git repository. + /// The path where the addon is located in the git repository. final String? path; @override diff --git a/packages/fluttium_interfaces/lib/src/fluttium/fluttium.dart b/packages/fluttium_interfaces/lib/src/fluttium/fluttium.dart index df1a5b97..353037a8 100644 --- a/packages/fluttium_interfaces/lib/src/fluttium/fluttium.dart +++ b/packages/fluttium_interfaces/lib/src/fluttium/fluttium.dart @@ -4,7 +4,7 @@ library fluttium; export 'package:pub_semver/pub_semver.dart'; -export 'action_location.dart'; +export 'addon_location.dart'; export 'driver_configuration.dart'; export 'fluttium_environment.dart'; export 'fluttium_yaml.dart'; diff --git a/packages/fluttium_interfaces/lib/src/fluttium/fluttium_yaml.dart b/packages/fluttium_interfaces/lib/src/fluttium/fluttium_yaml.dart index f3a75666..fece6d26 100644 --- a/packages/fluttium_interfaces/lib/src/fluttium/fluttium_yaml.dart +++ b/packages/fluttium_interfaces/lib/src/fluttium/fluttium_yaml.dart @@ -12,7 +12,7 @@ class FluttiumYaml extends Equatable { /// {@macro fluttium_yaml} const FluttiumYaml({ required this.environment, - this.actions = const {}, + this.addons = const {}, this.driver = const DriverConfiguration(), }); @@ -28,10 +28,12 @@ class FluttiumYaml extends Equatable { environment: FluttiumEnvironment.fromJson( yaml['environment'] as Map? ?? {}, ), - actions: { - for (final entry - in (yaml['actions'] as Map? ?? {}).entries) - entry.key: ActionLocation.fromJson(entry.value) + addons: { + for (final entry in (yaml['addons'] as Map? ?? + yaml['actions'] as Map? ?? + {}) + .entries) + entry.key: AddonLocation.fromJson(entry.value) }, driver: DriverConfiguration.fromJson( yaml['driver'] as Map? ?? {}, @@ -45,21 +47,26 @@ class FluttiumYaml extends Equatable { /// The configuration for the driver. final DriverConfiguration driver; - /// The actions to install to run the flow. - final Map actions; + /// The addons to install to run the flow. + final Map addons; + + /// The addons to install to run the flow. + @Deprecated('use addons instead') + Map get actions => addons; @override - List get props => [environment, driver, actions]; + List get props => [environment, driver, addons]; /// Copy the configuration to a new instance with optional overrides. FluttiumYaml copyWith({ FluttiumEnvironment? environment, - Map? actions, + @Deprecated('use addons instead') Map? actions, + Map? addons, DriverConfiguration? driver, }) { return FluttiumYaml( environment: environment ?? this.environment, - actions: actions ?? this.actions, + addons: addons ?? this.addons, driver: driver ?? this.driver, ); } diff --git a/packages/fluttium_interfaces/test/src/fluttium/action_location_test.dart b/packages/fluttium_interfaces/test/src/fluttium/addon_location_test.dart similarity index 82% rename from packages/fluttium_interfaces/test/src/fluttium/action_location_test.dart rename to packages/fluttium_interfaces/test/src/fluttium/addon_location_test.dart index 0ca7da43..a39524b0 100644 --- a/packages/fluttium_interfaces/test/src/fluttium/action_location_test.dart +++ b/packages/fluttium_interfaces/test/src/fluttium/addon_location_test.dart @@ -4,9 +4,9 @@ import 'package:fluttium_interfaces/fluttium_interfaces.dart'; import 'package:test/test.dart'; void main() { - group('ActionLocation', () { + group('$AddonLocation', () { test('can be instantiated', () { - final location = ActionLocation( + final location = AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('1.0.0'), @@ -20,7 +20,7 @@ void main() { group('fromJson', () { test('creates hosted location when data is a string', () { - final location = ActionLocation.fromJson('1.0.0'); + final location = AddonLocation.fromJson('1.0.0'); expect(location.hosted, isNotNull); expect( @@ -32,7 +32,7 @@ void main() { }); test('creates hosted location when data is a hosted map', () { - final location = ActionLocation.fromJson(const { + final location = AddonLocation.fromJson(const { 'hosted': 'https://my.custom.pub', 'version': '1.0.0', }); @@ -48,22 +48,22 @@ void main() { }); test('creates git location when data is a git map with a string', () { - final location = ActionLocation.fromJson(const { - 'git': 'git@git.some.where/some/action.git', + final location = AddonLocation.fromJson(const { + 'git': 'git@git.some.where/some/addon.git', }); expect(location.hosted, isNull); expect(location.git, isNotNull); - expect(location.git!.url, equals('git@git.some.where/some/action.git')); + expect(location.git!.url, equals('git@git.some.where/some/addon.git')); expect(location.git!.ref, isNull); expect(location.git!.path, isNull); expect(location.path, isNull); }); test('creates git location when data is a git map', () { - final location = ActionLocation.fromJson(const { + final location = AddonLocation.fromJson(const { 'git': { - 'url': 'git@git.some.where/some/action.git', + 'url': 'git@git.some.where/some/addon.git', 'ref': 'main', 'path': 'some/path', } @@ -71,14 +71,14 @@ void main() { expect(location.hosted, isNull); expect(location.git, isNotNull); - expect(location.git!.url, equals('git@git.some.where/some/action.git')); + expect(location.git!.url, equals('git@git.some.where/some/addon.git')); expect(location.git!.ref, equals('main')); expect(location.git!.path, equals('some/path')); expect(location.path, isNull); }); test('creates path location when data is a path map', () { - final location = ActionLocation.fromJson(const { + final location = AddonLocation.fromJson(const { 'path': 'some/path', }); @@ -89,14 +89,14 @@ void main() { test('throws when data is not a string or map', () { expect( - () => ActionLocation.fromJson(1), + () => AddonLocation.fromJson(1), throwsA(isA()), ); }); test('throws when data is a map with unknown keys', () { expect( - () => ActionLocation.fromJson(const { + () => AddonLocation.fromJson(const { 'unknown': 'some/path', }), throwsA(isA()), @@ -105,14 +105,14 @@ void main() { }); test('equality', () { - final location = ActionLocation( + final location = AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('1.0.0'), ), ); - final otherLocation = ActionLocation( + final otherLocation = AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('1.0.0'), @@ -152,25 +152,25 @@ void main() { group('GitPath', () { test('can be instantiated', () { final path = GitPath( - url: 'git@git.some.where/some/action.git', + url: 'git@git.some.where/some/addon.git', ref: 'main', path: 'some/path', ); - expect(path.url, equals('git@git.some.where/some/action.git')); + expect(path.url, equals('git@git.some.where/some/addon.git')); expect(path.ref, equals('main')); expect(path.path, equals('some/path')); }); test('equality', () { final path = GitPath( - url: 'git@git.some.where/some/action.git', + url: 'git@git.some.where/some/addon.git', ref: 'main', path: 'some/path', ); final otherPath = GitPath( - url: 'git@git.some.where/some/action.git', + url: 'git@git.some.where/some/addon.git', ref: 'main', path: 'some/path', ); diff --git a/packages/fluttium_interfaces/test/src/fluttium/driver_configuration_test.dart b/packages/fluttium_interfaces/test/src/fluttium/driver_configuration_test.dart index 2228fbe5..4b7ebb3d 100644 --- a/packages/fluttium_interfaces/test/src/fluttium/driver_configuration_test.dart +++ b/packages/fluttium_interfaces/test/src/fluttium/driver_configuration_test.dart @@ -4,7 +4,7 @@ import 'package:fluttium_interfaces/fluttium_interfaces.dart'; import 'package:test/test.dart'; void main() { - group('DriverConfiguration', () { + group('$DriverConfiguration', () { test('can be instantiated', () { final driver = DriverConfiguration( target: 'lib/main_development.dart', diff --git a/packages/fluttium_interfaces/test/src/fluttium/fluttium_environment_test.dart b/packages/fluttium_interfaces/test/src/fluttium/fluttium_environment_test.dart index d8aebd72..86e63ca4 100644 --- a/packages/fluttium_interfaces/test/src/fluttium/fluttium_environment_test.dart +++ b/packages/fluttium_interfaces/test/src/fluttium/fluttium_environment_test.dart @@ -2,7 +2,7 @@ import 'package:fluttium_interfaces/fluttium_interfaces.dart'; import 'package:test/test.dart'; void main() { - group('FluttiumEnvironment', () { + group('$FluttiumEnvironment', () { test('can be instantiated', () { final environment = FluttiumEnvironment( fluttium: VersionConstraint.parse('>=0.1.0-dev.1 <0.1.0'), diff --git a/packages/fluttium_interfaces/test/src/fluttium/fluttium_yaml_test.dart b/packages/fluttium_interfaces/test/src/fluttium/fluttium_yaml_test.dart index 2108aa4a..9b758fd7 100644 --- a/packages/fluttium_interfaces/test/src/fluttium/fluttium_yaml_test.dart +++ b/packages/fluttium_interfaces/test/src/fluttium/fluttium_yaml_test.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; class _FakeEncoding extends Fake implements Encoding {} void main() { - group('FluttiumYaml', () { + group('$FluttiumYaml', () { setUpAll(() { registerFallbackValue(_FakeEncoding()); }); @@ -36,14 +36,118 @@ driver: - SOME_API_KEY=development deviceId: 1234 +addons: + custom_addon: ^0.1.0-dev.1 + some_other_addon: + path: ../some_other_addon + and_final_addon: + git: + url: https://github.com/wolfenrain/fluttium.git + path: addons/and_final_addon + ref: development +'''); + + expect( + config.environment, + equals( + FluttiumEnvironment( + fluttium: VersionConstraint.parse('>=0.1.0-dev.1 <0.1.0'), + ), + ), + ); + + expect( + config.driver, + equals( + DriverConfiguration( + target: 'lib/main_development.dart', + flavor: 'development', + dartDefines: const ['SOME_API_KEY=development'], + deviceId: '1234', + ), + ), + ); + + expect( + config.addons, + equals({ + 'custom_addon': AddonLocation( + hosted: HostedPath( + url: 'https://pub.dartlang.org', + version: VersionConstraint.parse('^0.1.0-dev.1'), + ), + ), + 'some_other_addon': AddonLocation( + path: '../some_other_addon', + ), + 'and_final_addon': AddonLocation( + git: GitPath( + url: 'https://github.com/wolfenrain/fluttium.git', + path: 'addons/and_final_addon', + ref: 'development', + ), + ), + }), + ); + }); + + test('can construct from a file without addons', () { + final config = FluttiumYaml.fromData(''' +environment: + fluttium: ">=0.1.0-dev.1 <0.1.0" + +driver: + mainEntry: lib/main_development.dart + flavor: development + dartDefines: + - SOME_API_KEY=development + deviceId: 1234 +'''); + + expect( + config.environment, + equals( + FluttiumEnvironment( + fluttium: VersionConstraint.parse('>=0.1.0-dev.1 <0.1.0'), + ), + ), + ); + + expect( + config.driver, + equals( + DriverConfiguration( + target: 'lib/main_development.dart', + flavor: 'development', + dartDefines: const ['SOME_API_KEY=development'], + deviceId: '1234', + ), + ), + ); + + expect(config.addons, isEmpty); + }); + + test('is backwards compatible', () { + final config = FluttiumYaml.fromData(''' +environment: + fluttium: ">=0.1.0-dev.1 <0.1.0" + +driver: + mainEntry: lib/main_development.dart + flavor: development + dartDefines: + - SOME_API_KEY=development + deviceId: 1234 + actions: - custom_action: ^0.1.0-dev.1 - some_other_action: - path: ../some_other_action - and_final_action: + custom_addon: ^0.1.0-dev.1 + some_other_addon: + path: ../some_other_addon + and_final_addon: git: url: https://github.com/wolfenrain/fluttium.git - path: actions/and_final_action + path: addons/and_final_addon ref: development '''); @@ -68,22 +172,25 @@ actions: ), ); + // ignore: deprecated_member_use_from_same_package + expect(config.actions, equals(config.addons)); + expect( - config.actions, + config.addons, equals({ - 'custom_action': ActionLocation( + 'custom_addon': AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('^0.1.0-dev.1'), ), ), - 'some_other_action': ActionLocation( - path: '../some_other_action', + 'some_other_addon': AddonLocation( + path: '../some_other_addon', ), - 'and_final_action': ActionLocation( + 'and_final_addon': AddonLocation( git: GitPath( url: 'https://github.com/wolfenrain/fluttium.git', - path: 'actions/and_final_action', + path: 'addons/and_final_addon', ref: 'development', ), ), @@ -112,14 +219,14 @@ actions: deviceId: '1234', ); - final actions = { - 'custom_action': ActionLocation( + final addons = { + 'custom_addon': AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('^0.1.0-dev.1'), ), ), - 'some_other_action': ActionLocation( + 'some_other_addon': AddonLocation( hosted: HostedPath( url: 'https://pub.dartlang.org', version: VersionConstraint.parse('1.2.3'), @@ -130,15 +237,15 @@ actions: final otherConfig = config.copyWith( environment: environment, driver: driver, - actions: actions, + addons: addons, ); expect(config.environment, isNot(equals(environment))); expect(config.driver, isNot(equals(driver))); - expect(config.actions, isNot(equals(actions))); + expect(config.addons, isNot(equals(addons))); expect(otherConfig.environment, equals(environment)); expect(otherConfig.driver, equals(driver)); - expect(otherConfig.actions, equals(actions)); + expect(otherConfig.addons, equals(addons)); }); test('equality', () {