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

[feature]: Add --no-test flag to stacked create commands #1097

Open
Ay0ubCheurfi opened this issue Apr 16, 2024 · 3 comments
Open

[feature]: Add --no-test flag to stacked create commands #1097

Ay0ubCheurfi opened this issue Apr 16, 2024 · 3 comments
Labels
new feature Requires planning and detailed comments of what will be done to build this

Comments

@Ay0ubCheurfi
Copy link

Is your feature request related to a problem? Please describe.

Currently, the Stacked CLI tools always generate corresponding test files when creating new views or services. If a developer doesn't intend to write tests immediately, this can lead to project setup errors. Here's an example of how I might configure stacked.json to customize paths, and would still encounter this issue:

{
    "bottom_sheets_path": "ui/bottom_sheets",
    "dialogs_path": "ui/dialogs",
    "line_length": 80,
    "locator_name": "locator",
    "prefer_web": false,
    "services_path": "services",
    "stacked_app_file_path": "app/app.dart",
    "v1": false,
    "views_path": "ui/views",
    "widgets_path": "ui/widgets/smart"
}

Error when creating a service:

stacked create service test
Created File: 'test/services/test_service_test.dart'
Created File: 'lib/services/test_service.dart'
Modification not applied. The file test/helpers/test_helpers.dart does not exist
The structure of your stacked application is invalid. The app.dart file should be located in lib/app/

I've implemented a temporary ( dumb ) workaround to address this issue (see the attached file):
modify_app_file.TXT

Describe the solution you would like

The introduction of a --no-test flag for the stacked create command would provide the following benefits:

  • Flexibility: Generate views and services without test files, allowing developers to introduce testing at their own pace.
  • Error Prevention: Avoid project setup errors due to missing test helper files when the developer doesn't plan to create tests immediately, especially in projects with customized directory structures.

Additional Context

No response

@FilledStacks
Copy link
Contributor

Good suggestion.

We've never imagined writing code without tests 🤯 haha.

Jokes aside, this is a good request. Will add it to our backlog.

I'm currently on paternity leave so we might not get to this soon.

Would be happy with a PR review and merge if you're up for some pure dart development 😄

@FilledStacks FilledStacks added the new feature Requires planning and detailed comments of what will be done to build this label Apr 25, 2024
@Ay0ubCheurfi
Copy link
Author

@FilledStacks thanks for the update! To make sure I can contribute effectively (if I get the time), could you provide a little more context about where this feature might fit in? Are there any specific design considerations in mind?

@FilledStacks
Copy link
Contributor

in the cli project you can look at the code for ViewCommand and ServiceCommand see how we implement the options there and then pass the option in.

Then when we write out the files you can check that option value and skip any file with _test in the name. I'd say that should be an okay implementation that will solve your issue.

In terms of design considerations, I don't think it needs any, it's a straight forward exclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Requires planning and detailed comments of what will be done to build this
Projects
None yet
Development

No branches or pull requests

2 participants