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

conditional files / code generation. #100

Open
vaukalak opened this issue May 19, 2022 · 3 comments
Open

conditional files / code generation. #100

vaukalak opened this issue May 19, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@vaukalak
Copy link

suppose I have the following folder structure:

- FTName/
--- index.ts
--- [FTName].tsx
--- [FTName].tests.tsx
--- hooks.tsx

However, not all files need hooks.ts files and hence import in the [FTName].tsx. In theory, the work-around would be to create 2 templates. But in this case, I'll need to create a separate template for any specific scenario (suppose we'll have some optional files like utils, styles, and so on).

@Huuums
Copy link
Owner

Huuums commented May 19, 2022

Interesting suggestion.

So how could we go about it?

First idea I have is something like an extra option in the settings

optionalFiles: ["hooks.tsx"]

and for the files in this array we ask before actually creating the file? seems kinda intrusive and possibly annoying to work with.

What do you think?

@aguscha333
Copy link

Optional files could have a bit of a different structure:

optionalFiles: [
{ fileName: "hooks.tsx", "defaultValue": "false"},
{ fileName: "[FTName].stories.tsx", "defaultValue": "true"}
]

If optional files are included, if the defaultValues are what you need then it is just one more "enter" key press not much friction to be annoyed at. If you need to edit it and select or deselect some of the optionals you won't be annoyed because you are taking advantage of the functionality.
If you don't need optional files at all then this step would be ommited and that's it.

@Huuums
Copy link
Owner

Huuums commented Oct 26, 2022

I really like that approach.

Thanks alot. Will try to put this in when I have some free time.

@Huuums Huuums added the enhancement New feature or request label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants