-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wear os template to the create command (#694)
* feat: add wear os template to the create command * wear template * default teamplte name to first template
- Loading branch information
1 parent
d22e66b
commit 40f71c1
Showing
10 changed files
with
866 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
lib/src/commands/create/templates/very_good_wear_app/very_good_wear_app.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'very_good_wear_app_bundle.dart'; | ||
export 'very_good_wear_app_template.dart'; |
704 changes: 704 additions & 0 deletions
704
lib/src/commands/create/templates/very_good_wear_app/very_good_wear_app_bundle.dart
Large diffs are not rendered by default.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
lib/src/commands/create/templates/very_good_wear_app/very_good_wear_app_template.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:mason/mason.dart'; | ||
import 'package:very_good_cli/src/commands/create/templates/templates.dart'; | ||
import 'package:very_good_cli/src/logger_extension.dart'; | ||
|
||
/// {@template wear_app_template} | ||
/// A template for Wear OS apps. | ||
/// {@endtemplate} | ||
class VeryGoodWearAppTemplate extends Template { | ||
/// {@macro wear_app_template} | ||
VeryGoodWearAppTemplate() | ||
: super( | ||
name: 'wear', | ||
bundle: veryGoodWearAppBundle, | ||
help: 'Generate a Very Good Flutter Wear OS application.', | ||
); | ||
|
||
@override | ||
Future<void> onGenerateComplete(Logger logger, Directory outputDir) async { | ||
await installFlutterPackages(logger, outputDir); | ||
await applyDartFixes(logger, outputDir); | ||
_logSummary(logger); | ||
} | ||
|
||
void _logSummary(Logger logger) { | ||
logger | ||
..info('\n') | ||
..created('Created a Very Good Wear OS app! ⌚️🦄') | ||
..info('\n'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:args/args.dart'; | ||
import 'package:mason/mason.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:test/test.dart'; | ||
import 'package:very_good_cli/src/commands/commands.dart'; | ||
import 'package:very_good_cli/src/logger_extension.dart'; | ||
|
||
class _MockArgResults extends Mock implements ArgResults {} | ||
|
||
Future<void> testMultiTemplateCommand({ | ||
required MultiTemplates multiTemplatesCommand, | ||
required String templateName, | ||
required Map<String, dynamic> mockArgs, | ||
required MasonGenerator generator, | ||
required Logger logger, | ||
required GeneratorHooks hooks, | ||
|
||
// expected | ||
required Map<String, dynamic> expectedVars, | ||
required String expectedLogSummary, | ||
}) async { | ||
final tempDir = Directory.systemTemp.createTempSync(); | ||
addTearDown(() => tempDir.deleteSync(recursive: true)); | ||
final argResults = _MockArgResults(); | ||
final command = multiTemplatesCommand..argResultOverrides = argResults; | ||
|
||
when(() => argResults['template'] as String?).thenReturn(templateName); | ||
when(() => argResults['output-directory'] as String?) | ||
.thenReturn(tempDir.path); | ||
|
||
for (final entry in mockArgs.entries) { | ||
when(() => argResults[entry.key]).thenReturn(entry.value); | ||
} | ||
|
||
when(() => argResults.rest).thenReturn(['my_app']); | ||
|
||
final result = await command.run(); | ||
|
||
expect(command.template.name, templateName); | ||
expect(result, equals(ExitCode.success.code)); | ||
|
||
verify(() => logger.progress('Bootstrapping')).called(1); | ||
verify( | ||
() => hooks.preGen( | ||
vars: expectedVars, | ||
onVarsChanged: any(named: 'onVarsChanged'), | ||
), | ||
); | ||
verify( | ||
() => generator.generate( | ||
any(), | ||
vars: expectedVars, | ||
logger: logger, | ||
), | ||
).called(1); | ||
verify(() => logger.created(expectedLogSummary)).called(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters