Skip to content
Prettier for File Structures
TypeScript JavaScript
Branch: develop
Clone or download


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create Apr 25, 2020
.yarn/releases init Feb 11, 2020
assets name Feb 16, 2020
src refactor: rename vars && cleaner loop in invertGraph May 23, 2020
tests fix: #128 May 21, 2020
.babelrc.js chore: consistently use process.env.NODE_ENV Feb 18, 2020
.editorconfig chore: add .editorconfig Feb 19, 2020
.eslintignore chore: lint test files Mar 8, 2020
.eslintrc.js chore: enable type checking lint rules Mar 8, 2020
.gitignore upload coverage to codecov Feb 27, 2020
.huskyrc.json chore: run check script on push Feb 21, 2020
.lintstagedrc.json fix: use rc files Feb 15, 2020
.npmignore ignore assets Feb 14, 2020
.prettierignore chore: lint test files Mar 8, 2020
.prettierrc.json fix configs Feb 15, 2020
.releaserc.json fix: add semantic release config Feb 20, 2020
.yarnrc.yml init Feb 11, 2020 chore(release): 0.7.0 [skip ci] May 23, 2020
LICENSE Create LICENSE Feb 15, 2020 docs: fix broken images on npm readme May 23, 2020
codecov.yml chore: add codecov config Feb 27, 2020
jest.config.js feat: Add CLI flag to rename single files Mar 4, 2020
jsconfig.json fix: extend linting Feb 26, 2020
package.json chore(release): 0.7.0 [skip ci] May 23, 2020
rollup.config.js fix: replace NODE_ENV with "production" on build Feb 18, 2020
tsconfig.json chore: typescript improvements (#59) Feb 21, 2020
yarn.lock chore(deps): bump acorn from 6.4.0 to 6.4.1 Mar 26, 2020


example transformation

Prettier for File Structures

npm version contributions welcome ci workflow Join the chat at file structure: destiny


What does this do?

  1. Scans a folder for all the files in it
  2. Creates a directed graph based on how the JavaScript/TypeScript files import each other example directed graph
  3. Creates a fractal representation of the graph (following similar rules outlined here:
  4. Moves existing files into the fractal structure
  5. Fixes imports
  6. Removes all empty folders
  7. Prints files that are "unused" (not imported by anyone and doesn't import anything)

The end result is a "prettified" file structure.


  • This is a work in progress and 100% has bugs of some kind in it
  • BEFORE running this tool on your codebase, make sure you have committed to git or made a backup (I don't expect the tool to destroy your work (although it's possible), but just in case you don't like the results)
  • Snapshot tests don't format correctly
  • Only works on JavaScript/TypeScript codebases (although this concept could probably be extended to any language)

How to run it

$ destiny --help
destiny - Prettier for file structures.


  destiny [option...] [path]

  The path argument can consist of either a file path or a glob.


  -V, --version              Output version number
  -h, --help                 Output usage information
  -w, --write                Restructure and edit folders and files
  -S, --avoid-single-file    Flag to indicate if single files in folders should be avoided
  --debug [?output file]     Print debugging info

Dry run which will output what the resulting file structure will look like:

npx destiny "src/**/*.*"

This will actually move files around and fix imports:

npx destiny -w "src/**/*.*"


You can find the full documentation at this url.

This tool might be useless

It might be better to just name your folders.

Why did you name it destiny?

The name could be "Destiny" maybe. Like the file was meant to be there.


Pull requests are welcome :)


file structure: destiny

[![file structure: destiny](](
You can’t perform that action at this time.