From d91727acc79980f04d3b2f11c4edb26ad9f46d06 Mon Sep 17 00:00:00 2001 From: Hjort Date: Thu, 23 Nov 2023 16:00:40 +0100 Subject: [PATCH] Add button to showLicensePage + add script that checks dependency licenses --- assets/graphics/CCD.svg | 3 + lib/screens/home/screen.dart | 20 +++++++ pubspec.lock | 112 +++++++++++++++++++++++++++++++++++ pubspec.yaml | 3 + scripts/check_license.dart | 35 +++++++++++ scripts/license.yaml | 14 +++++ 6 files changed, 187 insertions(+) create mode 100644 assets/graphics/CCD.svg create mode 100644 scripts/check_license.dart create mode 100644 scripts/license.yaml diff --git a/assets/graphics/CCD.svg b/assets/graphics/CCD.svg new file mode 100644 index 0000000..d168d52 --- /dev/null +++ b/assets/graphics/CCD.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/screens/home/screen.dart b/lib/screens/home/screen.dart index 14bd6ec..bd43e17 100644 --- a/lib/screens/home/screen.dart +++ b/lib/screens/home/screen.dart @@ -5,6 +5,8 @@ import 'package:concordium_wallet/state/network.dart'; import 'package:concordium_wallet/state/terms_and_conditions.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:package_info_plus/package_info_plus.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({super.key}); @@ -79,6 +81,24 @@ class _HomeScreenState extends State { ], ), ), + ElevatedButton( + onPressed: () { + PackageInfo.fromPlatform().then((packageInfo) { + showAboutDialog( + context: context, + applicationName: packageInfo.appName, + applicationVersion: packageInfo.version, + applicationIcon: SvgPicture.asset( + 'assets/graphics/CCD.svg', + semanticsLabel: 'CCD Logo', + ), + ); + }); + + }, + child: const Text('Show About'), + ), + const SizedBox(height: 8), ElevatedButton( onPressed: () => context.read().testResetValidTime(), child: const Text('Reset update time of valid T&C'), diff --git a/pubspec.lock b/pubspec.lock index 03a8e77..b45e8f6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -33,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + barbecue: + dependency: transitive + description: + name: barbecue + sha256: e3a0afaf9005e466887d6c87411a2ddd8d72fc46db3caabf278ee600f1e2f92c + url: "https://pub.dev" + source: hosted + version: "0.4.0" bloc: dependency: transitive description: @@ -137,6 +145,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + url: "https://pub.dev" + source: hosted + version: "0.4.0" clock: dependency: transitive description: @@ -161,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" + colorize: + dependency: transitive + description: + name: colorize + sha256: "584746cd6ba1cba0633b6720f494fe6f9601c4170f0666c1579d2aa2a61071ba" + url: "https://pub.dev" + source: hosted + version: "3.0.0" convert: dependency: transitive description: @@ -185,6 +209,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + csslib: + dependency: transitive + description: + name: csslib + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" + url: "https://pub.dev" + source: hosted + version: "1.0.0" cupertino_icons: dependency: "direct main" description: @@ -304,6 +336,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" + html: + dependency: transitive + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" http: dependency: "direct main" description: @@ -360,6 +400,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.7.1" + license_checker: + dependency: "direct dev" + description: + name: license_checker + sha256: eea27638e42bc98fd91a6a8187eb57e5617e2c3c8b313a5d51b14bec7a8685e1 + url: "https://pub.dev" + source: hosted + version: "1.6.0" lints: dependency: transitive description: @@ -376,6 +424,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + markdown: + dependency: transitive + description: + name: markdown + sha256: acf35edccc0463a9d7384e437c015a3535772e09714cf60e07eeef3a15870dcd + url: "https://pub.dev" + source: hosted + version: "7.1.1" matcher: dependency: transitive description: @@ -440,6 +496,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017" + url: "https://pub.dev" + source: hosted + version: "4.2.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + pana: + dependency: transitive + description: + name: pana + sha256: "6f4372d5d2af5fe3fc6491c18f575601743bceb8433c7f179a6fffd162ee55f1" + url: "https://pub.dev" + source: hosted + version: "0.21.39" path: dependency: transitive description: @@ -536,6 +616,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.3" + retry: + dependency: transitive + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + safe_url_check: + dependency: transitive + description: + name: safe_url_check + sha256: b85685b48d74dcd9659e1f2228f900b9fb37cd3b4ba085ca4f593d06c00c36a6 + url: "https://pub.dev" + source: hosted + version: "1.1.1" shared_preferences: dependency: "direct main" description: @@ -701,6 +797,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + string_validator: + dependency: transitive + description: + name: string_validator + sha256: "50dd8ecf91db6a732f4a851eeae81ee12406eedc62d0da72f2d91a04a2d10dd8" + url: "https://pub.dev" + source: hosted + version: "0.3.0" + tar: + dependency: transitive + description: + name: tar + sha256: "451629b6ed9dd18be43688f4b42de34dd0ddd9e0a7da76a42b9e0b4ac7e9c68d" + url: "https://pub.dev" + source: hosted + version: "1.0.2" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dffe9e2..a4f40f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: shared_preferences: ^2.2.1 http: ^1.1.0 flutter_bloc: ^8.1.3 + package_info_plus: ^4.2.0 dev_dependencies: flutter_test: @@ -56,6 +57,7 @@ dev_dependencies: json_serializable: ^6.7.1 mocktail: ^1.0.1 bloc_test: ^9.1.5 + license_checker: ^1.6.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -100,3 +102,4 @@ flutter: # see https://flutter.dev/custom-fonts/#from-packages assets: - assets/graphics/ + diff --git a/scripts/check_license.dart b/scripts/check_license.dart new file mode 100644 index 0000000..4f290c7 --- /dev/null +++ b/scripts/check_license.dart @@ -0,0 +1,35 @@ +// ignore_for_file: avoid_print +import 'dart:io'; +import 'package:license_checker/src/config.dart'; +import 'package:license_checker/src/check_license.dart'; +import 'package:license_checker/src/dependency_checker.dart'; +import 'package:license_checker/src/package_checker.dart'; + +void main() async { + // Load the config file + Config config = Config.fromFile(File('./scripts/license.yaml')); + + // Get the package configuration from the current directory + PackageChecker packageConfig = await PackageChecker.fromCurrentDirectory(config: config); + + // Run the license check on all packages + List> lic = await checkAllPackageLicenses( + packageConfig: packageConfig, + showDirectDepsOnly: false, + filterApproved: true, + licenseDisplay: ({ + required String licenseName, + required String packageName, + required LicenseStatus licenseStatus, + }) => + '$packageName $licenseName ${licenseStatus.toString()}', + ); + + if (lic.isNotEmpty) { + print('Unapproved licenses used!'); + for (final x in lic) { + print(x.display); + } + throw "Unapproved licenses used!"; + } +} diff --git a/scripts/license.yaml b/scripts/license.yaml new file mode 100644 index 0000000..5e9f27a --- /dev/null +++ b/scripts/license.yaml @@ -0,0 +1,14 @@ +permittedLicenses: + - MIT + - BSD-3-Clause + +rejectedLicenses: + - GPL + - GPL-1 + - GPL-2 + - GPL-3 + +omitDisclaimer: + - flutter_test + - flutter_web_plugins +