From 33f41885d5a13c7775df5973c90f1db18988cf31 Mon Sep 17 00:00:00 2001 From: Mark O'Sullivan Date: Wed, 19 Apr 2023 15:07:19 -0300 Subject: [PATCH] chore: v0.13.1 --- bin/generate.dart | 2 +- .../flutter_launcher_icons-development.yaml | 2 +- .../flutter_launcher_icons-integration.yaml | 2 +- .../flutter_launcher_icons-production.yaml | 2 +- lib/android.dart | 16 +++++----------- lib/ios.dart | 2 +- lib/macos/macos_icon_generator.dart | 6 +++--- lib/main.dart | 14 ++++++-------- test/all_tests.dart | 2 +- test/android_test.dart | 11 ++++------- test/config/test_pubspec.yaml | 2 +- ...r_icons_config_test.dart => config_test.dart} | 10 ++++------ test/main_test.dart | 7 ++++--- test/templates.dart | 12 ++++++------ 14 files changed, 39 insertions(+), 51 deletions(-) rename test/{flutter_launcher_icons_config_test.dart => config_test.dart} (98%) diff --git a/bin/generate.dart b/bin/generate.dart index 2e28c27cf0..7f52e5cec5 100644 --- a/bin/generate.dart +++ b/bin/generate.dart @@ -83,7 +83,7 @@ void _generateConfigFile(File configFile) { const _configFileTemplate = ''' # flutter pub run flutter_launcher_icons -flutter_icons: +flutter_launcher_icons: image_path: "assets/icon/icon.png" android: "launcher_icon" diff --git a/example/flavors/flutter_launcher_icons-development.yaml b/example/flavors/flutter_launcher_icons-development.yaml index e279676332..51b2bc301b 100644 --- a/example/flavors/flutter_launcher_icons-development.yaml +++ b/example/flavors/flutter_launcher_icons-development.yaml @@ -1,4 +1,4 @@ -flutter_icons: +flutter_launcher_icons: android: true ios: true image_path: "assets/launcher_icon/demo-icon-dev.png" diff --git a/example/flavors/flutter_launcher_icons-integration.yaml b/example/flavors/flutter_launcher_icons-integration.yaml index fe0ab76687..6532eeaa03 100644 --- a/example/flavors/flutter_launcher_icons-integration.yaml +++ b/example/flavors/flutter_launcher_icons-integration.yaml @@ -1,4 +1,4 @@ -flutter_icons: +flutter_launcher_icons: android: true ios: true image_path: "assets/launcher_icon/demo-icon-int.png" diff --git a/example/flavors/flutter_launcher_icons-production.yaml b/example/flavors/flutter_launcher_icons-production.yaml index be5ac8bca7..ceeefa0245 100644 --- a/example/flavors/flutter_launcher_icons-production.yaml +++ b/example/flavors/flutter_launcher_icons-production.yaml @@ -1,4 +1,4 @@ -flutter_icons: +flutter_launcher_icons: android: true ios: true image_path: "assets/launcher_icon/demo-icon.png" \ No newline at end of file diff --git a/lib/android.dart b/lib/android.dart index cd2d184e31..a94d7ae773 100644 --- a/lib/android.dart +++ b/lib/android.dart @@ -2,10 +2,10 @@ import 'dart:io'; +import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/constants.dart'; import 'package:flutter_launcher_icons/constants.dart' as constants; import 'package:flutter_launcher_icons/custom_exceptions.dart'; -import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/utils.dart' as utils; import 'package:flutter_launcher_icons/xml_templates.dart' as xml_template; import 'package:image/image.dart'; @@ -95,10 +95,8 @@ void createAdaptiveIcons( utils.printStatus('Creating adaptive icons Android'); // Retrieve the necessary Flutter Launcher Icons configuration from the pubspec.yaml file - final String? backgroundConfig = - config.adaptiveIconBackground; - final String? foregroundImagePath = - config.adaptiveIconForeground; + final String? backgroundConfig = config.adaptiveIconBackground; + final String? foregroundImagePath = config.adaptiveIconForeground; if (backgroundConfig == null || foregroundImagePath == null) { throw const InvalidConfigException(errorMissingImagePath); } @@ -161,9 +159,7 @@ void createAdaptiveIconMipmapXmlFile( ) { if (config.isCustomAndroidFile) { File( - constants.androidAdaptiveXmlFolder(flavor) + - config.android + - '.xml', + constants.androidAdaptiveXmlFolder(flavor) + config.android + '.xml', ).create(recursive: true).then((File adaptiveIcon) { adaptiveIcon.writeAsString(xml_template.icLauncherXml); }); @@ -205,9 +201,7 @@ void _createAdaptiveBackgrounds( // FILE LOCATED HERE: res/mipmap-anydpi/{icon-name-from-yaml-config}.xml if (config.isCustomAndroidFile) { File( - constants.androidAdaptiveXmlFolder(flavor) + - config.android + - '.xml', + constants.androidAdaptiveXmlFolder(flavor) + config.android + '.xml', ).create(recursive: true).then((File adaptiveIcon) { adaptiveIcon.writeAsString(xml_template.icLauncherDrawableBackgroundXml); }); diff --git a/lib/ios.dart b/lib/ios.dart index dc2689a09d..97ec682a60 100644 --- a/lib/ios.dart +++ b/lib/ios.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'dart:io'; +import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/constants.dart'; import 'package:flutter_launcher_icons/custom_exceptions.dart'; -import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/utils.dart'; import 'package:image/image.dart'; diff --git a/lib/macos/macos_icon_generator.dart b/lib/macos/macos_icon_generator.dart index 7e954224ae..8968250ab8 100644 --- a/lib/macos/macos_icon_generator.dart +++ b/lib/macos/macos_icon_generator.dart @@ -65,11 +65,11 @@ class MacOSIconGenerator extends IconGenerator { if (macOSConfig.imagePath == null && context.config.imagePath == null) { context.logger ..verbose({ - 'flutter_icons.macos.image_path': macOSConfig.imagePath, - 'flutter_icons.image_path': context.config.imagePath, + 'flutter_launcher_icons.macos.image_path': macOSConfig.imagePath, + 'flutter_launcher_icons.image_path': context.config.imagePath, }) ..error( - 'Missing image_path. Either provide "flutter_icons.macos.image_path" or "flutter_icons.image_path"', + 'Missing image_path. Either provide "flutter_launcher_icons.macos.image_path" or "flutter_launcher_icons.image_path"', ); return false; diff --git a/lib/main.dart b/lib/main.dart index dd6037b4f0..ef957ad565 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,14 +5,13 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:flutter_launcher_icons/abs/icon_generator.dart'; import 'package:flutter_launcher_icons/android.dart' as android_launcher_icons; +import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/constants.dart' as constants; import 'package:flutter_launcher_icons/constants.dart'; import 'package:flutter_launcher_icons/custom_exceptions.dart'; -import 'package:flutter_launcher_icons/config/config.dart'; import 'package:flutter_launcher_icons/ios.dart' as ios_launcher_icons; import 'package:flutter_launcher_icons/logger.dart'; import 'package:flutter_launcher_icons/macos/macos_icon_generator.dart'; -import 'package:flutter_launcher_icons/macos/macos_icon_template.dart'; import 'package:flutter_launcher_icons/web/web_icon_generator.dart'; import 'package:flutter_launcher_icons/windows/windows_icon_generator.dart'; import 'package:path/path.dart' as path; @@ -172,11 +171,10 @@ Config? loadConfigFileFromArgResults( ArgResults argResults, ) { final String prefixPath = argResults[prefixOption]; - final flutterLauncherIconsConfigs = - Config.loadConfigFromPath( - argResults[fileOption], - prefixPath, - ) ?? - Config.loadConfigFromPubSpec(prefixPath); + final flutterLauncherIconsConfigs = Config.loadConfigFromPath( + argResults[fileOption], + prefixPath, + ) ?? + Config.loadConfigFromPubSpec(prefixPath); return flutterLauncherIconsConfigs; } diff --git a/test/all_tests.dart b/test/all_tests.dart index 8867e8c645..ca1a98aaf8 100644 --- a/test/all_tests.dart +++ b/test/all_tests.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'abs/icon_generator_test.dart' as icon_generator_test; import 'android_test.dart' as android_test; -import 'flutter_launcher_icons_config_test.dart' as fli_config; +import 'config_test.dart' as fli_config; import 'macos/macos_icon_generator_test.dart' as macos_icons_gen_test; import 'macos/macos_icon_template_test.dart' as macos_template_test; import 'main_test.dart' as main_test; diff --git a/test/android_test.dart b/test/android_test.dart index 0d58810bac..c621998d0a 100644 --- a/test/android_test.dart +++ b/test/android_test.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:flutter_launcher_icons/android.dart' as android; -import 'package:flutter_launcher_icons/constants.dart'; import 'package:flutter_launcher_icons/config/config.dart'; +import 'package:flutter_launcher_icons/constants.dart'; import 'package:test/test.dart'; // unit tests for android.dart @@ -35,8 +35,7 @@ void main() { 'ios': true }; expect( - Config.fromJson(flutterIconsConfig) - .isCustomAndroidFile, + Config.fromJson(flutterIconsConfig).isCustomAndroidFile, isFalse, ); @@ -46,8 +45,7 @@ void main() { 'ios': true }; expect( - Config.fromJson(flutterIconsNewIconConfig) - .isCustomAndroidFile, + Config.fromJson(flutterIconsNewIconConfig).isCustomAndroidFile, isTrue, ); }); @@ -60,8 +58,7 @@ void main() { 'ios': true }; expect( - Config.fromJson(flutterIconsNewIconConfig) - .getImagePathAndroid(), + Config.fromJson(flutterIconsNewIconConfig).getImagePathAndroid(), equals('assets/images/icon-android.png'), ); }); diff --git a/test/config/test_pubspec.yaml b/test/config/test_pubspec.yaml index 7ae8605c59..54c988689a 100644 --- a/test/config/test_pubspec.yaml +++ b/test/config/test_pubspec.yaml @@ -3,7 +3,7 @@ dev_dependencies: flutter_launcher_icons: path: ../../ -flutter_icons: +flutter_launcher_icons: image_path: "assets/images/icon-710x599.png" android: true # can specify file name here e.g. "ic_launcher" ios: true # can specify file name here e.g. "My-Launcher-Icon" diff --git a/test/flutter_launcher_icons_config_test.dart b/test/config_test.dart similarity index 98% rename from test/flutter_launcher_icons_config_test.dart rename to test/config_test.dart index e008ee322b..acd8b1f8b8 100644 --- a/test/flutter_launcher_icons_config_test.dart +++ b/test/config_test.dart @@ -1,5 +1,5 @@ -import 'package:flutter_launcher_icons/custom_exceptions.dart'; import 'package:flutter_launcher_icons/config/config.dart'; +import 'package:flutter_launcher_icons/custom_exceptions.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; @@ -7,7 +7,7 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import './templates.dart' as templates; void main() { - group('FlutterLauncherIconsConfig', () { + group('Config', () { late String prefixPath; setUpAll(() { prefixPath = path.join(d.sandbox, 'fli_test'); @@ -98,8 +98,7 @@ void main() { group('#loadConfigFromTestPubSpec', () { test('should return valid configs', () { const String path = 'test/config/test_pubspec.yaml'; - final configs = - Config.loadConfigFromPath(path, '.'); + final configs = Config.loadConfigFromPath(path, '.'); expect(configs, isNotNull); const String imagePath = 'assets/images/icon-710x599.png'; expect(configs!.imagePath, equals(imagePath)); @@ -132,8 +131,7 @@ void main() { ]).create(); }); test('should return valid configs', () { - final configs = - Config.loadConfigFromPubSpec(prefixPath); + final configs = Config.loadConfigFromPubSpec(prefixPath); expect(configs, isNotNull); // android configs expect(configs!.android, isTrue); diff --git a/test/main_test.dart b/test/main_test.dart index 7db253fd6c..f7f811fbf3 100644 --- a/test/main_test.dart +++ b/test/main_test.dart @@ -54,10 +54,11 @@ void main() { tearDown(() { Directory.current = currentDirectory; }); + test('default', () async { await setCurrentDirectory('default'); await File('flutter_launcher_icons.yaml').writeAsString(''' -flutter_icons: +flutter_launcher_icons: android: true ios: false '''); @@ -70,7 +71,7 @@ flutter_icons: test('default_use_pubspec', () async { await setCurrentDirectory('pubspec_only'); await File('pubspec.yaml').writeAsString(''' -flutter_icons: +flutter_launcher_icons: android: true ios: false '''); @@ -88,7 +89,7 @@ flutter_icons: test('custom', () async { await setCurrentDirectory('custom'); await File('custom.yaml').writeAsString(''' -flutter_icons: +flutter_launcher_icons: android: true ios: true '''); diff --git a/test/templates.dart b/test/templates.dart index 655e5b621b..aa1537a168 100644 --- a/test/templates.dart +++ b/test/templates.dart @@ -1,5 +1,5 @@ const fliConfigTemplate = r''' -flutter_icons: +flutter_launcher_icons: android: true ios: true image_path: "assets/images/icon-128x128.png" @@ -28,7 +28,7 @@ flutter_icons: const flavorFLIConfigTemplate = fliConfigTemplate; const fliWebConfig = r''' -flutter_icons: +flutter_launcher_icons: web: generate: true image_path: "app_icon.png" # filepath @@ -39,7 +39,7 @@ flutter_icons: '''; const fliWindowsConfig = r''' -flutter_icons: +flutter_launcher_icons: windows: generate: true image_path: "app_icon.png" @@ -47,7 +47,7 @@ flutter_icons: '''; const invalidfliConfigTemplate = r''' -# flutter_icons +# flutter_launcher_icons android: true ios: true image_path: "assets/images/icon-128x128.png" @@ -103,7 +103,7 @@ flutter: - asset: fonts/TrajanPro_Bold.ttf weight: 700 -flutter_icons: +flutter_launcher_icons: android: true ios: true image_path: "assets/images/icon-128x128.png" @@ -167,7 +167,7 @@ flutter: - asset: fonts/TrajanPro_Bold.ttf weight: 700 -flutter_icons: +flutter_launcher_icons: android: true invalid_indented_key_key ios: true