From ec35e2fa6308589b6d296142e735aa5c1d2baa29 Mon Sep 17 00:00:00 2001 From: Toshiaki Satsuma Date: Wed, 27 Mar 2024 18:19:25 +0900 Subject: [PATCH] fix: patapata_core documentation, add widget_test.dart overwrite logic --- packages/patapata_core/README.md | 2 +- packages/patapata_core/bin/bootstrap.dart | 29 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/patapata_core/README.md b/packages/patapata_core/README.md index 174c928..ac8e4a9 100644 --- a/packages/patapata_core/README.md +++ b/packages/patapata_core/README.md @@ -91,7 +91,7 @@ To just get the standard Patapata experience and have an app up and running, exe flutter create my_app cd my_app flutter pub add patapata_core -dart run patapata_core:bootstrap +dart run patapata_core:bootstrap -f ``` Note that this will change the minimum Android SDK version to 21 and the minimum iOS version to 12.0. diff --git a/packages/patapata_core/bin/bootstrap.dart b/packages/patapata_core/bin/bootstrap.dart index a474147..ec4b288 100644 --- a/packages/patapata_core/bin/bootstrap.dart +++ b/packages/patapata_core/bin/bootstrap.dart @@ -126,6 +126,10 @@ void main(List arguments) { // Check if the l10n directory exists. // And if not, create it. _checkL10nFiles(tResults); + + // Check if a widget_test.dart file exists. + // And if not, create it with a empty code. + _checkWidgetTestFile(tResults); } catch (e) { switch (e) { case UsageException(): @@ -997,3 +1001,28 @@ errors: stdout.writeln('Done.'); } + +void _checkWidgetTestFile(ArgResults results) { + stdout.writeln('Checking widget_test.dart file...'); + + final tFile = File('test/widget_test.dart'); + final tFileExists = tFile.existsSync(); + + if (results['force'] == true || !tFileExists) { + stdout.writeln('Creating widget_test.dart file...'); + + if (!tFileExists) { + tFile.createSync(recursive: true); + } + + tFile.writeAsStringSync(DartFormatter().format(''' +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('empty', (WidgetTester tester) async {}); +} +''')); + } + + stdout.writeln('Done.'); +}