diff --git a/very_good_core/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc b/very_good_core/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc index 79b7cc2..cd8d793 100644 --- a/very_good_core/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc +++ b/very_good_core/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "{{project_name.snakeCase()}}" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "{{project_name.snakeCase()}}" "\0" - VALUE "LegalCopyright", "Copyright (C) 2022 {{windows_application_id}}. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) {{current_year}} {{windows_application_id}}. All rights reserved." "\0" VALUE "OriginalFilename", "{{project_name.snakeCase()}}.exe" "\0" VALUE "ProductName", "{{project_name.titleCase()}}" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/very_good_core/hooks/lib/src/models/very_good_core_configuration.dart b/very_good_core/hooks/lib/src/models/very_good_core_configuration.dart index fc24355..375a9b9 100644 --- a/very_good_core/hooks/lib/src/models/very_good_core_configuration.dart +++ b/very_good_core/hooks/lib/src/models/very_good_core_configuration.dart @@ -1,3 +1,4 @@ +import 'package:clock/clock.dart'; import 'package:equatable/equatable.dart'; import 'package:very_good_core_hooks/very_good_core_hooks.dart'; @@ -163,6 +164,11 @@ class VeryGoodCoreConfiguration extends Equatable { /// {@macro very_good_core_configuration_variables.description} final String description; + /// The current year. + /// + /// Usually used for copyright headers. + final String currentYear = clock.now().year.toString(); + /// {@macro windows_application_id} late final WindowsApplicationId windowsApplicationId; diff --git a/very_good_core/hooks/pre_gen.dart b/very_good_core/hooks/pre_gen.dart index 0667cd6..34249ea 100644 --- a/very_good_core/hooks/pre_gen.dart +++ b/very_good_core/hooks/pre_gen.dart @@ -41,5 +41,6 @@ void run(HookContext context) { 'ios_application_id': configuration.iOsApplicationId, 'macos_application_id': configuration.macOsApplicationId, 'windows_application_id': configuration.windowsApplicationId, + 'current_year': configuration.currentYear, }; } diff --git a/very_good_core/hooks/pubspec.yaml b/very_good_core/hooks/pubspec.yaml index 66f0641..cdb1252 100644 --- a/very_good_core/hooks/pubspec.yaml +++ b/very_good_core/hooks/pubspec.yaml @@ -4,6 +4,7 @@ environment: sdk: ^3.5.0 dependencies: + clock: ^1.1.1 equatable: ^2.0.5 mason: ^0.1.0-dev.52 diff --git a/very_good_core/hooks/test/pre_gen_test.dart b/very_good_core/hooks/test/pre_gen_test.dart index 3c49c97..2ee41c0 100644 --- a/very_good_core/hooks/test/pre_gen_test.dart +++ b/very_good_core/hooks/test/pre_gen_test.dart @@ -1,3 +1,4 @@ +import 'package:clock/clock.dart'; import 'package:mason/mason.dart'; import 'package:mocktail/mocktail.dart'; import 'package:test/test.dart'; @@ -15,34 +16,38 @@ void main() { }); test('populates variables', () { - final vars = { - 'project_name': 'my_app', - 'org_name': 'com.example', - 'application_id': 'app.id', - 'description': 'A new Flutter project.', - }; - when(() => context.vars).thenReturn(vars); - - pre_gen.run(context); - - final newVars = verify(() => context.vars = captureAny()).captured.last - as Map; - - expect( - newVars, - equals( - { - 'project_name': 'my_app', - 'org_name': 'com.example', - 'description': 'A new Flutter project.', - 'android_namespace': 'app.id', - 'android_application_id': 'app.id', - 'ios_application_id': 'app.id', - 'macos_application_id': 'app.id', - 'windows_application_id': 'app.id', - }, - ), - ); + final clock = Clock.fixed(DateTime(2020)); + withClock(clock, () { + final vars = { + 'project_name': 'my_app', + 'org_name': 'com.example', + 'application_id': 'app.id', + 'description': 'A new Flutter project.', + }; + when(() => context.vars).thenReturn(vars); + + pre_gen.run(context); + + final newVars = verify(() => context.vars = captureAny()).captured.last + as Map; + + expect( + newVars, + equals( + { + 'project_name': 'my_app', + 'org_name': 'com.example', + 'description': 'A new Flutter project.', + 'android_namespace': 'app.id', + 'android_application_id': 'app.id', + 'ios_application_id': 'app.id', + 'macos_application_id': 'app.id', + 'windows_application_id': 'app.id', + 'current_year': '2020', + }, + ), + ); + }); }); }); }