Skip to content
Draft
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
31 changes: 25 additions & 6 deletions lib/src/commands/create/commands/flutter_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ class CreateFlutterApp extends CreateSubCommand with OrgName, MultiTemplates {
required super.generatorFromBundle,
required super.generatorFromBrick,
}) {
argParser.addOption(
'application-id',
help:
'The bundle identifier on iOS or application id on Android. '
'(defaults to <org-name>.<project-name>)',
);
argParser
..addOption(
'application-id',
help:
'The bundle identifier on iOS or application id on Android. '
'(defaults to <org-name>.<project-name>)',
)
..addMultiOption(
'platforms',
help:
'The platforms supported by the app. By default, all platforms '
'are enabled. Example: --platforms=android,ios',
defaultsTo: ['android', 'ios', 'macos', 'web', 'windows'],
allowed: ['android', 'ios', 'macos', 'web', 'windows'],
allowedHelp: {
'android': 'The app supports the Android platform.',
'ios': 'The app supports the iOS platform.',
'macos': 'The app supports the macOS platform.',
'web': 'The app supports the Web platform.',
'windows': 'The app supports the Windows platform.',
},
);
}

@override
Expand All @@ -34,6 +50,9 @@ class CreateFlutterApp extends CreateSubCommand with OrgName, MultiTemplates {
vars['application_id'] = applicationId;
}

final platforms = argResults['platforms'] as List<String>;
vars['platforms'] = platforms;

return vars;
}

Expand Down
87 changes: 76 additions & 11 deletions test/src/commands/create/commands/flutter_app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ final expectedUsage = [
Generate a Very Good Flutter application.

Usage: very_good create flutter_app <project-name> [arguments]
-h, --help Print this usage information.
-o, --output-directory The desired output directory when creating a new project.
--description The description for this new project.
(defaults to "A Very Good Project created by Very Good CLI.")
-t, --template The template used to generate this new project.
-h, --help Print this usage information.
-o, --output-directory The desired output directory when creating a new project.
--description The description for this new project.
(defaults to "A Very Good Project created by Very Good CLI.")
-t, --template The template used to generate this new project.

[core] (default) Generate a Very Good Flutter application.
[core] (default) Generate a Very Good Flutter application.

--org-name The organization for this new project.
(defaults to "com.example.verygoodcore")
--application-id The bundle identifier on iOS or application id on Android. (defaults to <org-name>.<project-name>)
--org-name The organization for this new project.
(defaults to "com.example.verygoodcore")
--application-id The bundle identifier on iOS or application id on Android. (defaults to <org-name>.<project-name>)
--platforms The platforms supported by the app. By default, all platforms are enabled. Example: --platforms=android,ios

[android] (default) The app supports the Android platform.
[ios] (default) The app supports the iOS platform.
[macos] (default) The app supports the macOS platform.
[web] (default) The app supports the Web platform.
[windows] (default) The app supports the Windows platform.

Run "very_good help" to see global options.''',
];
Expand Down Expand Up @@ -169,12 +176,54 @@ void main() {
hooks: hooks,
generator: generator,
templateName: 'core',
mockArgs: {'application-id': 'xyz.app.my_app'},
mockArgs: {
'application-id': 'xyz.app.my_app',
'platforms': const [
'android',
'ios',
'macos',
'web',
'windows',
],
},
expectedVars: {
'project_name': 'my_app',
'description': '',
'org_name': 'com.example.verygoodcore',
'application_id': 'xyz.app.my_app',
'platforms': const [
'android',
'ios',
'macos',
'web',
'windows',
],
},
expectedLogSummary: 'Created a Very Good App! 🦄',
);
});

test('generates successfully with custom platforms', () async {
await testMultiTemplateCommand(
multiTemplatesCommand: CreateFlutterApp(
logger: logger,
generatorFromBundle: (_) async => throw Exception('oops'),
generatorFromBrick: (_) async => generator,
),
logger: logger,
hooks: hooks,
generator: generator,
templateName: 'core',
mockArgs: {
'application-id': 'xyz.app.my_app',
'platforms': const ['android', 'ios'],
},
expectedVars: {
'project_name': 'my_app',
'description': '',
'org_name': 'com.example.verygoodcore',
'application_id': 'xyz.app.my_app',
'platforms': const ['android', 'ios'],
},
expectedLogSummary: 'Created a Very Good App! 🦄',
);
Expand All @@ -195,12 +244,28 @@ void main() {
hooks: hooks,
generator: generator,
templateName: 'core',
mockArgs: {'application-id': 'xyz.app.my_app'},
mockArgs: {
'application-id': 'xyz.app.my_app',
'platforms': const [
'android',
'ios',
'macos',
'web',
'windows',
],
},
expectedVars: {
'project_name': 'my_app',
'description': '',
'org_name': 'com.example.verygoodcore',
'application_id': 'xyz.app.my_app',
'platforms': const [
'android',
'ios',
'macos',
'web',
'windows',
],
},
expectedLogSummary: 'Created a Very Good App! 🦄',
);
Expand Down
Loading