Skip to content

Commit 86e06bf

Browse files
authored
feat: add --no-test flag to skip test file generation in create commands (#63)
- Added --no-test flag to all create commands (view, service, bottom_sheet, dialog, widget) - Updated TemplateService to support noTest parameter and filter out test files - Added new constants: ksNoTest and kCommandHelpNoTest - When --no-test is provided, components are created without their test files - Maintains backward compatibility - default behavior unchanged - Fixed for-loop bug in CreateWidgetCommand (missing increment) - Updated all command help messages to include the new flag - Regenerated mock files to match new method signatures Usage examples: stacked create view my_view --no-test stacked create service my_service --no-test stacked create dialog my_dialog --no-test This allows developers to skip test file generation when they prefer to write tests manually or don't need them for certain components.
1 parent 644207d commit 86e06bf

14 files changed

Lines changed: 1029 additions & 336 deletions

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [Unreleased]
2+
3+
### Features
4+
5+
* **create commands:** Add --no-test flag to skip test file generation ([#XX](https://github.com/Stacked-Org/stacked/issues/1097))
6+
- Added --no-test flag to all create commands (view, service, bottom_sheet, dialog, widget)
7+
- When provided, no test files will be generated for the created components
8+
- Maintains backward compatibility with default behavior unchanged
9+
- Fixed for-loop bug in CreateWidgetCommand
10+
111
# [1.14.0](https://github.com/Stacked-Org/cli/compare/v1.13.4...v1.14.0) (2025-02-18)
212

313

lib/src/commands/create/create_bottom_sheet_command.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class CreateBottomSheetCommand extends Command with ProjectStructureValidator {
6262
..addOption(
6363
ksProjectPath,
6464
help: kCommandHelpProjectPath,
65+
)
66+
..addFlag(
67+
ksNoTest,
68+
defaultsTo: false,
69+
help: kCommandHelpNoTest,
6570
);
6671
}
6772

@@ -88,6 +93,7 @@ class CreateBottomSheetCommand extends Command with ProjectStructureValidator {
8893
excludeRoute: argResults![ksExcludeRoute],
8994
hasModel: argResults![ksModel],
9095
templateType: templateType,
96+
noTest: argResults![ksNoTest],
9197
);
9298

9399
await _analyticsService.createBottomSheetEvent(

lib/src/commands/create/create_dialog_command.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class CreateDialogCommand extends Command with ProjectStructureValidator {
6262
..addOption(
6363
ksProjectPath,
6464
help: kCommandHelpProjectPath,
65+
)
66+
..addFlag(
67+
ksNoTest,
68+
defaultsTo: false,
69+
help: kCommandHelpNoTest,
6570
);
6671
}
6772

@@ -88,6 +93,7 @@ class CreateDialogCommand extends Command with ProjectStructureValidator {
8893
excludeRoute: argResults![ksExcludeRoute],
8994
hasModel: argResults![ksModel],
9095
templateType: templateType,
96+
noTest: argResults![ksNoTest],
9197
);
9298

9399
await _analyticsService.createDialogEvent(

lib/src/commands/create/create_service_command.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class CreateServiceCommand extends Command with ProjectStructureValidator {
5757
..addOption(
5858
ksProjectPath,
5959
help: kCommandHelpProjectPath,
60+
)
61+
..addFlag(
62+
ksNoTest,
63+
defaultsTo: false,
64+
help: kCommandHelpNoTest,
6065
);
6166
}
6267

@@ -82,6 +87,7 @@ class CreateServiceCommand extends Command with ProjectStructureValidator {
8287
verbose: true,
8388
excludeRoute: argResults![ksExcludeDependency],
8489
templateType: templateType,
90+
noTest: argResults![ksNoTest],
8591
);
8692

8793
await _analyticsService.createServiceEvent(

lib/src/commands/create/create_view_command.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class CreateViewCommand extends Command with ProjectStructureValidator {
6262
..addOption(
6363
ksProjectPath,
6464
help: kCommandHelpProjectPath,
65+
)
66+
..addFlag(
67+
ksNoTest,
68+
defaultsTo: false,
69+
help: kCommandHelpNoTest,
6570
);
6671
}
6772

@@ -96,6 +101,7 @@ class CreateViewCommand extends Command with ProjectStructureValidator {
96101
excludeRoute: argResults![ksExcludeRoute],
97102
useBuilder: argResults![ksV1] ?? _configService.v1,
98103
templateType: templateType,
104+
noTest: argResults![ksNoTest],
99105
);
100106

101107
await _analyticsService.createViewEvent(

lib/src/commands/create/create_widget_command.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class CreateWidgetCommand extends Command with ProjectStructureValidator {
6161
..addOption(
6262
ksProjectPath,
6363
help: kCommandHelpProjectPath,
64+
)
65+
..addFlag(
66+
ksNoTest,
67+
defaultsTo: false,
68+
help: kCommandHelpNoTest,
6469
);
6570
}
6671

@@ -82,14 +87,15 @@ class CreateWidgetCommand extends Command with ProjectStructureValidator {
8287
workingDirectory: argResults![ksProjectPath]);
8388
await validateStructure(outputPath: argResults![ksProjectPath]);
8489

85-
for (var i = 0; i < widgetNames.length; i) {
90+
for (var i = 0; i < widgetNames.length; i++) {
8691
await _templateService.renderTemplate(
8792
templateName: name,
8893
name: widgetNames[i],
8994
outputPath: argResults![ksProjectPath],
9095
verbose: true,
9196
hasModel: argResults![ksModel],
9297
templateType: templateType,
98+
noTest: argResults![ksNoTest],
9399
);
94100

95101
await _analyticsService.createWidgetEvent(

lib/src/constants/command_constants.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const String ksAppDescription = 'description';
3636
const String ksAppOrganization = 'org';
3737
const String ksAppPlatforms = 'platforms';
3838
const String ksProjectPath = 'project-path';
39+
const String ksNoTest = 'no-test';
3940

4041
/// A list of strings that are used to run the run build_runner
4142
/// [build or watch] --delete-conflicting-outputs command.

lib/src/constants/message_constants.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,6 @@ Paths on Stacked config do not need to start with directory "lib" or "test" beca
106106
const String kCommandHelpProjectPath = '''
107107
When path is provided, it will be considered the project directory instead of the current directory.
108108
''';
109+
110+
const String kCommandHelpNoTest =
111+
'When provided, no test files will be generated for the created component.';

0 commit comments

Comments
 (0)