Skip to content

Commit

Permalink
Merge pull request #4 from gree/fix/bootstrap-command-for-getting-sta…
Browse files Browse the repository at this point in the history
…rted-in-core

fix: Correct the documentation and output of the bootstrap command in patapata_core
  • Loading branch information
toshiaki-satsuma authored Mar 29, 2024
2 parents a08140e + ec35e2f commit 61490b5
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/patapata_core/README.md
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions packages/patapata_core/bin/bootstrap.dart
Original file line number Diff line number Diff line change
@@ -126,6 +126,10 @@ void main(List<String> 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.');
}

0 comments on commit 61490b5

Please sign in to comment.