|
1 | 1 | # TreeEx |
2 | 2 |
|
3 | | -CLI tool that analyzes directory structure and outputs a JSON tree |
| 3 | +A CLI tool that analyzes directory structures and outputs them as JSON. Built with Bun and TypeScript. |
| 4 | + |
| 5 | +## Why TreeEx? |
| 6 | + |
| 7 | +Sometimes you just need a quick way to get a directory's structure as JSON - maybe for documentation, feeding into an LLM, or just understanding a codebase. TreeEx does exactly that, with sensible defaults and cross-platform support. |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +### From source |
| 12 | + |
| 13 | +Requirements: |
| 14 | +- Bun |
| 15 | +- Git |
| 16 | + |
| 17 | +```bash |
| 18 | +git clone https://github.com/pratikdev/treeex.git |
| 19 | +cd treeex |
| 20 | +bun install |
| 21 | +``` |
| 22 | + |
| 23 | +## Building |
| 24 | + |
| 25 | +```bash |
| 26 | +# Build for current platform |
| 27 | +bun run build |
| 28 | + |
| 29 | +# Check [package.json](./package.json) for more options |
| 30 | +``` |
| 31 | + |
| 32 | +This produces a standalone binary in the `build/` directory for your OS |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +```bash |
| 37 | +# cd into the build directory |
| 38 | +cd build |
| 39 | + |
| 40 | +# Analyze current directory (`/build` directory will be empty though) |
| 41 | +treeEx |
| 42 | + |
| 43 | +# Analyze a specific path |
| 44 | +treeEx ../src |
| 45 | + |
| 46 | +# Limit depth |
| 47 | +treeEx --depth 3 |
| 48 | + |
| 49 | +# Unlimited depth |
| 50 | +treeEx --depth inf |
| 51 | + |
| 52 | +# Ignore additional patterns |
| 53 | +treeEx -i "*.log" -i "*.tmp" |
| 54 | + |
| 55 | +# Include everything (disable default ignores) |
| 56 | +treeEx --no-default-ignore |
| 57 | +``` |
| 58 | + |
| 59 | +## Output Format |
| 60 | + |
| 61 | +TreeEx outputs a JSON tree structure: |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "name": "root", |
| 66 | + "type": "directory", |
| 67 | + "children": [ |
| 68 | + { |
| 69 | + "name": "src", |
| 70 | + "type": "directory", |
| 71 | + "children": [ |
| 72 | + { |
| 73 | + "name": "index.ts", |
| 74 | + "type": "file", |
| 75 | + "children": [] |
| 76 | + } |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "name": "package.json", |
| 81 | + "type": "file", |
| 82 | + "children": [] |
| 83 | + } |
| 84 | + ] |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +## Default Ignore Patterns |
| 89 | + |
| 90 | +By default, TreeEx ignores common noise directories and files: |
| 91 | + |
| 92 | +- `.git`, `.svn`, `.hg`, `.CVS` |
| 93 | +- `node_modules`, `vendor` |
| 94 | +- `build`, `dist`, `out` |
| 95 | +- `.vscode`, `.DS_Store` |
| 96 | + |
| 97 | +Use `--no-default-ignore` to include everything. |
| 98 | + |
| 99 | +## Options |
| 100 | + |
| 101 | +| Option | Description | |
| 102 | +|--------|-------------| |
| 103 | +| `-d, --depth <level>` | Maximum depth level (default: 20, use "inf" for unlimited) | |
| 104 | +| `-i, --ignore <pattern>` | Glob pattern to ignore (can be used multiple times) | |
| 105 | +| `--no-default-ignore` | Disable default ignore patterns | |
| 106 | +| `-v, --version` | Show version | |
| 107 | +| `-h, --help` | Show help | |
| 108 | + |
| 109 | +## License |
| 110 | + |
| 111 | +MIT |
0 commit comments