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

feat: improve very good create output #131

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions lib/src/commands/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CreateCommand extends Command<int> {
DirectoryGeneratorTarget(outputDirectory, _logger),
vars: {'project_name': projectName},
);
generateDone('Bootstrapping complete');
generateDone('Generated $fileCount file(s)');

final isFlutterInstalled = await Flutter.installed();
if (isFlutterInstalled) {
Expand All @@ -84,7 +84,7 @@ class CreateCommand extends Command<int> {
installDependenciesDone();
}

_logSummary(fileCount);
_logSummary();

unawaited(_analytics.sendEvent(
'create',
Expand All @@ -96,13 +96,8 @@ class CreateCommand extends Command<int> {
return ExitCode.success.code;
}

void _logSummary(int fileCount) {
void _logSummary() {
_logger
..info(
'${lightGreen.wrap('✓')} '
'Generated $fileCount file(s):',
)
..flush(_logger.success)
..info('\n')
..alert('Created a Very Good App! 🦄')
..info('\n')
Expand Down
17 changes: 10 additions & 7 deletions test/src/commands/create_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:args/args.dart';
import 'package:io/ansi.dart';
import 'package:io/io.dart';
import 'package:mason/mason.dart';
import 'package:mocktail/mocktail.dart';
Expand All @@ -21,6 +20,7 @@ class FakeDirectoryGeneratorTarget extends Fake

void main() {
group('Create', () {
late List<String> progressLogs;
late Analytics analytics;
late Logger logger;
late VeryGoodCommandRunner commandRunner;
Expand All @@ -30,6 +30,7 @@ void main() {
});

setUp(() {
progressLogs = <String>[];
analytics = MockAnalytics();
when(() => analytics.firstRun).thenReturn(false);
when(() => analytics.enabled).thenReturn(false);
Expand All @@ -41,7 +42,11 @@ void main() {
).thenAnswer((_) => Future.value());

logger = MockLogger();
when(() => logger.progress(any())).thenReturn(([_]) {});
when(() => logger.progress(any())).thenReturn(
([_]) {
if (_ != null) progressLogs.add(_);
},
);
commandRunner = VeryGoodCommandRunner(
analytics: analytics,
logger: logger,
Expand Down Expand Up @@ -107,12 +112,10 @@ void main() {
final result = await command.run();
expect(result, equals(ExitCode.success.code));
verify(() => logger.progress('Bootstrapping')).called(1);
expect(progressLogs, equals(['Generated 62 file(s)']));
verify(
() => logger.info(
'${lightGreen.wrap('✓')} '
'Generated 62 file(s):',
),
);
() => logger.progress('Running "flutter packages get" in .tmp'),
).called(1);
verify(() => logger.alert('Created a Very Good App! 🦄')).called(1);
verify(
() => generator.generate(
Expand Down