Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

destiny

benawad27.4kMIT0.7.1

Prettier for file structures

auto, fractal, cli, file, prettier, structure

readme

Destiny

example transformation

Prettier for File Structures

npm version contributions welcome ci workflow Join the chat at https://gitter.im/destiny-dev/community file structure: destiny


Motivation: https://www.youtube.com/watch?v=rGYbrIf-y58

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: https://hackernoon.com/fractal-a-react-app-structure-for-infinite-scale-4dab943092af)
  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.

Disclaimer

  • 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.

USAGE

  destiny [option...] [path]

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

OPTIONS

  -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/**/*.*"

Documentation

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.

Contributing

Pull requests are welcome :)

Badge

file structure: destiny

[![file structure: destiny](https://img.shields.io/badge/file%20structure-destiny-7a49ff?style=flat)](https://github.com/benawad/destiny)

changelog

0.7.1 (2020-08-19)

Bug Fixes

0.7.0 (2020-05-23)

Bug Fixes

Features

  • debugger: log full data (09a78f4)

0.6.2 (2020-04-29)

Bug Fixes

0.6.1 (2020-04-25)

Reverts

  • Revert "chore(release): 0.6.0 [skip ci]" (9d2dbc1)

0.5.0 (2020-03-26)

Bug Fixes

  • Glob stays in the tree's root path - #88 (3795d40)

Features

0.4.0 (2020-03-04)

Bug Fixes

  • ensure path correctness (f22f07f), closes #81
  • extend linting (039cadf)
  • fix new linting issues (c19f2e5)
  • Fix time complexity when searching for common parent dir (ce9915e)
  • improve regex path matching (ff9b19b), closes #87
  • support paths in config via include (c049ceb)

Features

  • Add CLI flag to rename single files (2de9ff1)

0.3.1 (2020-02-26)

Bug Fixes

  • don't fail if can't find file and add json support (954e9db)
  • ensure unique edges (a50c40c)

0.3.0 (2020-02-24)

Bug Fixes

  • printTree: colorize tree (9fd4706)
  • add generateTrees module (e0366d6)
  • create restructure map (4090fdd)
  • use generateTrees and refactor formatFileStructure (fb48957)
  • printTree: add leaf resolver (514084a)
  • printTree: add proper sorting of files and directories (bc177c1)
  • printTree: position our leafs (1b5bca1)

Features

  • cli: only restructure with write option (65313bb)
  • printTree: print tree (ef01dae)
  • add support for sass (f70e96b)
  • remove detect-roots option (7812dc6)

0.2.1 (2020-02-20)

Bug Fixes

  • add semantic release config (9b1c635)