Skip to content

Commit dbe955c

Browse files
Merge branch 'main' into feat/very_good_config/create
2 parents 55670d9 + c2dc91b commit dbe955c

18 files changed

Lines changed: 337 additions & 7 deletions

lib/src/commands/create/commands/app_ui_package.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_app_ui_package_command}
55
/// A [CreateSubCommand] for creating App UI packages.
66
/// {@endtemplate}
7-
class CreateAppUiPackage extends CreateSubCommand with Publishable {
7+
class CreateAppUiPackage extends CreateSubCommand with Publishable, Workspace {
88
/// {@macro very_good_create_app_ui_package_command}
99
CreateAppUiPackage({
1010
required super.logger,

lib/src/commands/create/commands/create_subcommand.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ typedef MasonGeneratorFromBundle = Future<MasonGenerator> Function(MasonBundle);
4343
///
4444
/// For sub commands that receive a publishable flag, sub classes must mix with
4545
/// [Publishable].
46+
///
47+
/// For sub commands that receive a workspace flag, sub classes must mix with
48+
/// [Workspace].
4649
abstract class CreateSubCommand extends Command<int> {
4750
/// {@macro create_subcommand}
4851
CreateSubCommand({
@@ -100,6 +103,16 @@ abstract class CreateSubCommand extends Command<int> {
100103
help: 'Whether the generated project is intended to be published.',
101104
);
102105
}
106+
107+
if (this is Workspace) {
108+
argParser.addFlag(
109+
'workspace',
110+
aliases: ['ws'],
111+
help:
112+
'Whether the generated project should resolve its dependencies '
113+
'from a parent Pub workspace.',
114+
);
115+
}
103116
}
104117

105118
/// The logger user to notify the user of the command's progress.
@@ -262,6 +275,7 @@ abstract class CreateSubCommand extends Command<int> {
262275
///
263276
/// For subcommands that mix with [OrgName], it includes 'org_name'.
264277
/// For subcommands that mix with [Publishable], it includes 'publishable'.
278+
/// For subcommands that mix with [Workspace], it includes 'workspace'.
265279
@mustCallSuper
266280
Map<String, dynamic> getTemplateVars() {
267281
final projectName = this.projectName;
@@ -272,6 +286,7 @@ abstract class CreateSubCommand extends Command<int> {
272286
'description': projectDescription,
273287
if (this is OrgName) 'org_name': (this as OrgName).orgName,
274288
if (this is Publishable) 'publishable': (this as Publishable).publishable,
289+
if (this is Workspace) 'workspace': (this as Workspace).workspace,
275290
};
276291
}
277292
}
@@ -359,3 +374,12 @@ mixin Publishable on CreateSubCommand {
359374
fallbackValue: false,
360375
);
361376
}
377+
378+
/// Mixin for [CreateSubCommand] subclasses that receives the workspace flag.
379+
///
380+
/// Takes care of parsing it from [argResults] and pass it
381+
/// to the brick generator.
382+
mixin Workspace on CreateSubCommand {
383+
/// Gets the workspace flag.
384+
bool get workspace => argResults['workspace'] as bool? ?? false;
385+
}

lib/src/commands/create/commands/dart_cli.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_dart_cli_command}
55
/// A [CreateSubCommand] for creating Dart command line interfaces.
66
/// {@endtemplate}
7-
class CreateDartCLI extends CreateSubCommand with Publishable {
7+
class CreateDartCLI extends CreateSubCommand with Publishable, Workspace {
88
/// {@macro very_good_create_dart_cli_command}
99
CreateDartCLI({
1010
required super.logger,

lib/src/commands/create/commands/dart_package.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_dart_package_command}
55
/// A [CreateSubCommand] for creating Dart packages.
66
/// {@endtemplate}
7-
class CreateDartPackage extends CreateSubCommand with Publishable {
7+
class CreateDartPackage extends CreateSubCommand with Publishable, Workspace {
88
/// {@macro very_good_create_dart_package_command}
99
CreateDartPackage({
1010
required super.logger,

lib/src/commands/create/commands/flame_game.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_flame_game_command}
55
/// A [CreateSubCommand] for creating Flame games.
66
/// {@endtemplate}
7-
class CreateFlameGame extends CreateSubCommand with OrgName, Publishable {
7+
class CreateFlameGame extends CreateSubCommand
8+
with OrgName, Publishable, Workspace {
89
/// {@macro very_good_create_flame_game_command}
910
CreateFlameGame({
1011
required super.logger,

lib/src/commands/create/commands/flutter_app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
55
/// A [CreateSubCommand] for creating Flutter apps.
66
/// {@endtemplate}
77
class CreateFlutterApp extends CreateSubCommand
8-
with OrgName, MultiTemplates, Publishable {
8+
with OrgName, MultiTemplates, Publishable, Workspace {
99
/// {@macro very_good_create_flutter_app_command}
1010
CreateFlutterApp({
1111
required super.logger,

lib/src/commands/create/commands/flutter_package.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_flutter_package_command}
55
/// A [CreateSubCommand] for creating Flutter packages.
66
/// {@endtemplate}
7-
class CreateFlutterPackage extends CreateSubCommand with Publishable {
7+
class CreateFlutterPackage extends CreateSubCommand
8+
with Publishable, Workspace {
89
/// {@macro very_good_create_flutter_package_command}
910
CreateFlutterPackage({
1011
required super.logger,

lib/src/commands/create/commands/flutter_plugin.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import 'package:very_good_cli/src/commands/create/templates/templates.dart';
44
/// {@template very_good_create_flutter_plugin_command}
55
/// A [CreateSubCommand] for creating Flutter plugins.
66
/// {@endtemplate}
7-
class CreateFlutterPlugin extends CreateSubCommand with Publishable, OrgName {
7+
class CreateFlutterPlugin extends CreateSubCommand
8+
with Publishable, OrgName, Workspace {
89
/// {@macro very_good_create_flutter_plugin_command}
910
CreateFlutterPlugin({
1011
required super.logger,

lib/src/mcp/mcp_server.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ Only available for subcommands: flutter_plugin with all values) and flame_game (
138138
'publishable': BooleanSchema(
139139
description: '''
140140
Whether package is intended for publishing (flutter_package, dart_package only)''',
141+
),
142+
'workspace': BooleanSchema(
143+
description: '''
144+
Whether the generated project should resolve its dependencies from a parent Pub workspace.''',
141145
),
142146
'executable-name': StringSchema(
143147
description: '''
@@ -348,6 +352,11 @@ Only one value can be selected.
348352
if (args['publishable'] == true) {
349353
cliArgs.add('--publishable');
350354
}
355+
if (args['workspace'] == true) {
356+
cliArgs.add('--workspace');
357+
} else if (args['workspace'] == false) {
358+
cliArgs.add('--no-workspace');
359+
}
351360
if (args['executable-name'] != null) {
352361
cliArgs.addAll(['--executable-name', args['executable-name']! as String]);
353362
}

test/src/commands/create/commands/app_ui_package_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Usage: very_good create app_ui_package <project-name> [arguments]
3434
--description The description for this new project.
3535
(defaults to "A Very Good Project created by Very Good CLI.")
3636
--publishable Whether the generated project is intended to be published.
37+
--[no-]workspace Whether the generated project should resolve its dependencies from a parent Pub workspace.
3738
3839
Run "very_good help" to see global options.''',
3940
];
@@ -74,6 +75,7 @@ void main() {
7475
);
7576
expect(command.logger, equals(logger));
7677
expect(command, isA<Publishable>());
78+
expect(command, isA<Workspace>());
7779
});
7880
});
7981

@@ -185,6 +187,7 @@ void main() {
185187
'project_name': 'my_app_ui',
186188
'description': '',
187189
'publishable': false,
190+
'workspace': false,
188191
},
189192
onVarsChanged: any(named: 'onVarsChanged'),
190193
),
@@ -196,6 +199,7 @@ void main() {
196199
'project_name': 'my_app_ui',
197200
'description': '',
198201
'publishable': false,
202+
'workspace': false,
199203
},
200204
logger: logger,
201205
),

0 commit comments

Comments
 (0)