MCPcopy Index your code
hub / github.com/benawad/destiny

github.com/benawad/destiny @v0.7.1 sqlite

repository ↗ · DeepWiki ↗ · release v0.7.1 ↗
79 symbols 246 edges 110 files 0 documented · 0%
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)

Core symbols most depended-on inside this repo

buildGraph
called by 6
src/index/generateTrees/buildGraph.ts
findSharedParent
called by 6
src/index/generateTrees/shared/findSharedParent.ts
getFilePaths
called by 5
src/index/getFilePaths.ts
removeANSI
called by 5
src/shared/logger.ts
run
called by 3
src/index.ts
findImports
called by 3
src/index/shared/findImports.ts
extractParentDirectory
called by 3
src/index/shared/detect-lonely-files.ts
detectLonelyFiles
called by 3
src/index/shared/detect-lonely-files.ts

Shape

Function 79

Languages

TypeScript100%

Modules by API surface

src/index/generateTrees/printTree.ts10 symbols
src/shared/logger.ts8 symbols
src/index.ts6 symbols
src/index/getFilePaths.ts5 symbols
src/index/generateTrees/toFractalTree.ts5 symbols
tests/fixtures/cra/serviceWorker.js4 symbols
src/index/formatFileStructure/fixImports.ts4 symbols
src/index/shared/detect-lonely-files.ts3 symbols
tests/detect-lonely-files.test.ts2 symbols
src/index/shared/findImports.ts2 symbols
src/index/generateTrees/shared/isLinkedFile.ts2 symbols
src/index/generateTrees/findEntryPoints.ts2 symbols

Dependencies from manifests, versioned

@babel/cli7.8.4 · 1×
@babel/core7.8.4 · 1×
@babel/plugin-transform-runtime7.8.3 · 1×
@babel/preset-env7.8.4 · 1×
@babel/preset-typescript7.8.3 · 1×
@babel/runtime7.8.4 · 1×
@rollup/plugin-commonjs11.0.0 · 1×
@rollup/plugin-json4.0.0 · 1×
@rollup/plugin-node-resolve7.0.0 · 1×
@rollup/plugin-replace2.3.1 · 1×
@semantic-release/changelog5.0.0 · 1×
@semantic-release/git9.0.0 · 1×

For agents

$ claude mcp add destiny \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact