mikededo / dartBarrelFileGenerator

VSCode extension that generates barrel files for Dart projects
MIT License
25 stars 9 forks source link

Add option to name the barrel file #16

Closed Luckey-Elijah closed 2 years ago

Luckey-Elijah commented 2 years ago

By default the extension just uses the name of the parent folder to name the barrel file. Could you add an option to have an optional name for the file?

 lib
├──  commands
│  ├── add.dart
│  ├── commands.dart
│  ├── complete.dart
│  ├── remove.dart
│  └── show.dart
└── lib.dart // generated as lib.dart

lib.dart is the generated file, but I would like to name it as todo.dart with the same command: GDBF: Current and Nested Folders

mikededo commented 2 years ago

Hello @Luckey-Elijah, thanks for posting an issue 😄

That's something I had planned, but since I had no requests, I thought it was something not needed. By default, the name of barrel files are the same as the folder, yet I understand the need of wanting a different name.

So, if you would like such feature, I will add it as something new in the next version 💯

What I have thought to implement would be: when any option is run, ask for the file name. This may be a little hard to deal with, if the user does not really mind. Therefore, I would add an option that would disable this behaviour anytime (a setting like the ones to skip .g.dart and .freezed.dart files).

What are your thoughts about it?

PS: I'm currently finishing my degree while working part-time. Currently my time is a bit limited but I may have more time this holidays. If I feel like next version may take too long, I will implement a version of such feature before next 😉

Luckey-Elijah commented 2 years ago

Thanks, for asking! Possibly with the excluding files and names prompts features add a config in settings.json like:

{
  "dart-barrel-file-generator.promptName": true, // defaults to false
  "dart-barrel-file-generator.exclude": [
    "*.g.dart",
    "*.freezed.dart",
  ],
}

So there isn't any unexpected behavior from the current behavior.

mikededo commented 2 years ago

That's definetely the way to go. I will keep you updated and try to provide such feature asap 🙌🏼

Luckey-Elijah commented 2 years ago

Hi, @mikededo is there any update on this? Thanks 😄

mikededo commented 2 years ago

Hello! I'm afraid not. As I said before, I wanted it for the v2, yet since I'm pretty busy I can't spend as much time I want. I will try to add it as soon as possible, instead of waiting for version two. Give me a few days and I will let you know 😉

Sorry for the wait...

Luckey-Elijah commented 2 years ago

No problem! I just want to follow on it's progress. Thanks, again. I appreciate it!

mikededo commented 2 years ago

Hello @Luckey-Elijah 😄!

I'm pretty busy due to uni and it is hard for me to find time for the extension. I afraid to tell you that not until January I will have time for it. It's about a week, but as soon as I have time I will dig into it.

I'm sorry 😞

Luckey-Elijah commented 2 years ago

No worries! Thank you for the clarity.

mikededo commented 2 years ago

Hello once again!

I have been thinking about how to implement the feature and I believe such feat is only useful when creating a barrel file for a folder, rather than when it creates it for the children.

@Luckey-Elijah, have you found any case in which you wanted to propagate the name of the barrel file to the nested folders? 🤔

mikededo commented 2 years ago

Alright! I have made the pull request but I am mergin the code now 😉.

The new version will be released this afternoon. I would really appreciate if you could give me some feedback. Feel free to reopen this issue or create a new one if needed.

Thanks for your collaboration ❤️

Luckey-Elijah commented 2 years ago

Excellent! I will keep an eye for the update, thank you very much!

Regarding:

have you found any case in which you wanted to propagate the name of the barrel file to the nested folders?

No, I don't think so.

mikededo commented 2 years ago

Alright, then for now the option will only work for nested folders. On the next version I will add an option to the menu which will allow you to create a barrel file with the name given. Then, the settings option it will be possible to keep the settings as false, but to get prompted when needed.

DFelten commented 2 years ago

@mikededo Could you maybe add the possibility to change the default name? I would like to call the barrel file for example index.dart in each folder. Currently a file is overridden if it's name is the same as the folder. So index.dart is a good default for us.

mikededo commented 2 years ago

@DFelten Thanks for commenting in the issue. As this issue has already been closed, could you please open a new issue so we can discuss it there? Seems like a feature that would definetely add some value 💪🏼

DFelten commented 2 years ago

Thanks for the fast response. The issue is created here https://github.com/mikededo/dartBarrelFileGenerator/issues/54