From 79c18f6997a328336bcc97f1dd439f3917cbb672 Mon Sep 17 00:00:00 2001 From: Antoniobox Date: Wed, 28 Aug 2024 16:18:04 +0200 Subject: [PATCH 1/5] feat: update copyright year in Windows Runner.rc --- .../{{project_name.snakeCase()}}/windows/runner/Runner.rc | 2 +- very_good_flame_game/hooks/pre_gen.dart | 2 ++ very_good_flame_game/hooks/pubspec.yaml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/very_good_flame_game/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc b/very_good_flame_game/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc index 79b7cc2..cd8d793 100644 --- a/very_good_flame_game/__brick__/{{project_name.snakeCase()}}/windows/runner/Runner.rc +++ b/very_good_flame_game/__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_flame_game/hooks/pre_gen.dart b/very_good_flame_game/hooks/pre_gen.dart index 4e155ee..d4e3103 100644 --- a/very_good_flame_game/hooks/pre_gen.dart +++ b/very_good_flame_game/hooks/pre_gen.dart @@ -1,3 +1,4 @@ +import 'package:clock/clock.dart'; import 'package:mason/mason.dart'; import 'package:very_good_flame_game_hooks/very_good_core_hooks.dart'; @@ -42,5 +43,6 @@ void run(HookContext context) { 'ios_application_id': configuration.iOsApplicationId, 'macos_application_id': configuration.macOsApplicationId, 'windows_application_id': configuration.windowsApplicationId, + 'current_year': clock.now().year, }; } diff --git a/very_good_flame_game/hooks/pubspec.yaml b/very_good_flame_game/hooks/pubspec.yaml index c128468..494076d 100644 --- a/very_good_flame_game/hooks/pubspec.yaml +++ b/very_good_flame_game/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 very_good_core_hooks: From 9545994b2128250968db30ebe7135534f37b4ab3 Mon Sep 17 00:00:00 2001 From: Antoniobox Date: Wed, 28 Aug 2024 16:23:15 +0200 Subject: [PATCH 2/5] feat: add current_year for pre_gen_test --- .../hooks/test/pre_gen_test.dart | 62 ++++++++++--------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/very_good_flame_game/hooks/test/pre_gen_test.dart b/very_good_flame_game/hooks/test/pre_gen_test.dart index 80fc38c..c63b0d2 100644 --- a/very_good_flame_game/hooks/test/pre_gen_test.dart +++ b/very_good_flame_game/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'; @@ -14,35 +15,40 @@ void main() { context = _MockHookContext(); }); + final clock = Clock.fixed(DateTime(2020)); test('populates variables', () { - final vars = { - 'project_name': 'my_game', - 'org_name': 'com.example', - 'application_id': 'app.id', - 'description': 'A new Flame 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_game', - 'org_name': 'com.example', - 'description': 'A new Flame 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', - }, - ), - ); + withClock(clock, () { + final vars = { + 'project_name': 'my_game', + 'org_name': 'com.example', + 'application_id': 'app.id', + 'description': 'A new Flame project.', + 'current_year': clock.now().year, + }; + 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_game', + 'org_name': 'com.example', + 'description': 'A new Flame 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': clock.now().year, + }, + ), + ); + }); }); }); } From 25e94b0c4f66f90aae0bfdb13bcf8454538eda40 Mon Sep 17 00:00:00 2001 From: Antoniobox Date: Wed, 28 Aug 2024 17:36:26 +0200 Subject: [PATCH 3/5] test: use clock inside test to control the current time --- very_good_flame_game/hooks/test/pre_gen_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/very_good_flame_game/hooks/test/pre_gen_test.dart b/very_good_flame_game/hooks/test/pre_gen_test.dart index c63b0d2..64adbb7 100644 --- a/very_good_flame_game/hooks/test/pre_gen_test.dart +++ b/very_good_flame_game/hooks/test/pre_gen_test.dart @@ -15,8 +15,8 @@ void main() { context = _MockHookContext(); }); - final clock = Clock.fixed(DateTime(2020)); test('populates variables', () { + final clock = Clock.fixed(DateTime(2020)); withClock(clock, () { final vars = { 'project_name': 'my_game', From 21f1dc61249f6d8b01b97a35456b4c5f2657afe9 Mon Sep 17 00:00:00 2001 From: Antoniobox Date: Wed, 28 Aug 2024 18:58:16 +0200 Subject: [PATCH 4/5] feat: remove current_year from vars --- very_good_flame_game/hooks/test/pre_gen_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/very_good_flame_game/hooks/test/pre_gen_test.dart b/very_good_flame_game/hooks/test/pre_gen_test.dart index 64adbb7..97e4c14 100644 --- a/very_good_flame_game/hooks/test/pre_gen_test.dart +++ b/very_good_flame_game/hooks/test/pre_gen_test.dart @@ -23,7 +23,6 @@ void main() { 'org_name': 'com.example', 'application_id': 'app.id', 'description': 'A new Flame project.', - 'current_year': clock.now().year, }; when(() => context.vars).thenReturn(vars); From e81ef018a664d69dd6e0c18165c024dee6556e0b Mon Sep 17 00:00:00 2001 From: Alejandro Santiago Date: Thu, 29 Aug 2024 14:20:31 +0100 Subject: [PATCH 5/5] feat: use current_year as String --- very_good_flame_game/hooks/pre_gen.dart | 2 +- very_good_flame_game/hooks/test/pre_gen_test.dart | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/very_good_flame_game/hooks/pre_gen.dart b/very_good_flame_game/hooks/pre_gen.dart index d4e3103..8d02d04 100644 --- a/very_good_flame_game/hooks/pre_gen.dart +++ b/very_good_flame_game/hooks/pre_gen.dart @@ -43,6 +43,6 @@ void run(HookContext context) { 'ios_application_id': configuration.iOsApplicationId, 'macos_application_id': configuration.macOsApplicationId, 'windows_application_id': configuration.windowsApplicationId, - 'current_year': clock.now().year, + 'current_year': clock.now().year.toString(), }; } diff --git a/very_good_flame_game/hooks/test/pre_gen_test.dart b/very_good_flame_game/hooks/test/pre_gen_test.dart index 97e4c14..67531de 100644 --- a/very_good_flame_game/hooks/test/pre_gen_test.dart +++ b/very_good_flame_game/hooks/test/pre_gen_test.dart @@ -16,8 +16,7 @@ void main() { }); test('populates variables', () { - final clock = Clock.fixed(DateTime(2020)); - withClock(clock, () { + withClock(Clock.fixed(DateTime(2020)), () { final vars = { 'project_name': 'my_game', 'org_name': 'com.example', @@ -43,7 +42,7 @@ void main() { 'ios_application_id': 'app.id', 'macos_application_id': 'app.id', 'windows_application_id': 'app.id', - 'current_year': clock.now().year, + 'current_year': '2020', }, ), );