benawad / destiny

Prettier for File Structures
MIT License
3.53k stars 80 forks source link

Module with its leaf dependencies in same folder #163

Open Vakrim opened 3 years ago

Vakrim commented 3 years ago

I'm working on fork with slightly modified version of fractal representation and I'm wonder if you would like to include it in destiny behind option flag. Main difference is that each file is in the same folder with dependencies.

Example

Orignal version

❯ destiny tests/fixtures/shared-with-dependencies
INFO: Generating tree for: tests/fixtures/shared-with-dependencies
shared-with-dependencies
├──index
│  ├──ParticipantSetup
│  │  ├──ParticipantSetupForm
│  │  │  ├──ConfigForm
│  │  │  │  ├──RadioBoxGroup
│  │  │  │  │  └──RadioBoxGroup.scss
│  │  │  │  ├──ConfigForm.module.scss
│  │  │  │  └──RadioBoxGroup.js
│  │  │  ├──ConfigForm.js
│  │  │  └──ParticipantSetupForm.scss
│  │  ├──ParticipantSetup.scss
│  │  └──ParticipantSetupForm.js
│  ├──shared
│  │  ├──Area
│  │  │  ├──Area.config.js
│  │  │  └──Area.module.scss
│  │  ├──CheckboxWithLabel
│  │  │  └──CheckboxWithLabel.scss
│  │  ├──Area.js
│  │  └──CheckboxWithLabel.js
│  ├──SomeOtherResource
│  │  └──SomeOtherResource.module.scss
│  ├──ParticipantSetup.js
│  └──SomeOtherResource.js
└──index.js

My version

❯ destiny --nest-main-modules tests/fixtures/shared-with-dependencies
INFO: Generating tree for: tests/fixtures/shared-with-dependencies
shared-with-dependencies
├──ParticipantSetup
│  ├──ParticipantSetupForm
│  │  ├──ConfigForm
│  │  │  ├──RadioBoxGroup
│  │  │  │  ├──RadioBoxGroup.js
│  │  │  │  └──RadioBoxGroup.scss
│  │  │  ├──ConfigForm.js
│  │  │  └──ConfigForm.module.scss
│  │  ├──ParticipantSetupForm.js
│  │  └──ParticipantSetupForm.scss
│  ├──ParticipantSetup.js
│  └──ParticipantSetup.scss
├──shared
│  ├──Area
│  │  ├──Area.js
│  │  ├──Area.config.js
│  │  └──Area.module.scss
│  └──CheckboxWithLabel
│     ├──CheckboxWithLabel.js
│     └──CheckboxWithLabel.scss
├──SomeOtherResource
│  ├──SomeOtherResource.js
│  └──SomeOtherResource.module.scss
└──index.js

It feels more natural to me that each subtree is contained in one folder and there is no need for "index" folder. But I guess it's matter of personal taste, so I'll leave it for discussion for now

AnatoleLucet commented 3 years ago

Hey, by what I can see, this structure looks like what @benawad proposed in #151. Feel free to open a PR so we can look it up!