Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update copyright year in Windows Runner.rc #188

Merged
merged 10 commits into from
Aug 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions very_good_core/hooks/pre_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
1 change: 1 addition & 0 deletions very_good_core/hooks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ environment:
sdk: ^3.5.0

dependencies:
clock: ^1.1.1
equatable: ^2.0.5
mason: ^0.1.0-dev.52

Expand Down
62 changes: 34 additions & 28 deletions very_good_core/hooks/test/pre_gen_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:clock/clock.dart';
import 'package:mason/mason.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';
Expand All @@ -15,34 +16,39 @@ 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<String, dynamic>;

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',
},
),
);
// Fake the current year to ensure the test is deterministic.
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<String, dynamic>;

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',
},
),
);
});
});
});
}
Loading