(Programming Language β Node.js / TypeScript)
A simple yet powerful CLI tool that generates a clean, GitHub-style project directory tree and automatically injects it into your README.md. Designed for developers who want to keep their documentation clean, consistent, and always up to date.
- Auto-Update README: Intelligently finds
andtags in yourREADME.mdand updates the content between them. - Smart Configuration: Set your defaults (like
depth,ignore, etc.) using a.treerc.jsonfile. - Flexible Ignore System: Ignore files and folders using a
.treeignorefile that supports glob patterns (just like.gitignore). - Watch Mode: Run
make-tree --watchto automatically update your tree every time you add or remove a file. - Custom Output: Print to the terminal (default), update your
README.md(--update), or save to any file (--output). - Full ESM/CJS Support: Built with modern TypeScript and compiled to both ES Module and CommonJS formats.
You can install this tool globally to use it in any of your projects:
npm install -g tree-md-generator(Note: The name in your package.json is tree-md-generator, which will be the package name on NPM).
Once installed, you can run the make-tree command from any project directory.
make-tree [options]| Option | Alias | Description |
|---|---|---|
--depth <n> |
-d |
Limits the tree's scan depth (e.g., 2). |
--ignore <patterns> |
-i |
A comma-separated list of glob patterns to ignore (e.g., "dist,*.log"). |
--update |
-u |
Automatically updates the README.md file between tags. |
--output <file> |
-o |
Saves the tree output to a specific file (e.g., tree.txt). |
--root <name> |
-r |
Adds a custom root name to the top line of the tree (e.g., "."). |
--watch |
-w |
Stays running and watches for file changes, updating automatically. |
--version |
-v |
Displays the tool's version. |
--help |
-h |
Displays the help message. |
You can configure make-tree using two special files in your project's root directory.
This file works exactly like a .gitignore. Use it to list all files or folders you do not want to show in the tree.
Create a file named .treeignore in your project root.
.treeignore Template:
# Comments are ignored
# Ignore common folders
node_modules
dist
.git
.vscode
.next
logs
# Ignore specific files
.env
package-lock.json
# Ignore using glob patterns (minimatch)
*.log
*.tmp
The tool also ignores some common folders by default, like .git and node_modules, but adding them here is good practice.
This file is very useful for saving your default CLI options. Instead of typing make-tree --depth 2 --update every time, you can save it here.
Create a file named .treerc.json in your project root.
.treerc.json Template:
{
"depth": 2,
"root": "my-project",
"ignore": ["docs", ".github", "*.md"],
"update": true,
"watch": false
}The tool merges settings in the following order of priority (number 1 always wins):
- CLI Options (e.g.,
make-tree --depth 3) - Options in
.treerc.json(e.g.,"depth": 2) - Program Defaults
Example: If your
.treerc.jsonhas"depth": 2, but you runmake-tree --depth 4, thendepth 4will be used. If you just runmake-tree, thendepth 2will be used.
Just run the base command. This will print the tree to your console.
make-treeAdd these tags to your README.md file:
`<!-- TREE:START -->`
`<!-- TREE:END -->`Then, run the command with the --update flag:
make-tree --updateThe tool will find the tags and automatically update the content between them.
You want to always update the README with a depth of 2 and ignore the docs folder.
Your .treerc.json file:
{
"depth": 2,
"update": true,
"ignore": ["docs"]
}Now, you only need to run:
make-tree...and the tool will automatically run as if you had typed make-tree --depth 2 --update --ignore "docs".
You want to create a TREE.txt file with a depth of 1.
make-tree --output TREE.txt --depth 1You are actively developing and want your README.md to always be up-to-date.
(Assuming your .treerc.json already contains "update": true).
make-tree --watchπ Watching for file changes... (Press Ctrl+C to stop)
Now, every time you add, delete, or rename a file, your README.md will be updated automatically.
For detailed information on project management, security, and conduct, please refer to the following documents:
- Code of Conduct β CODE_OF_CONDUCT.md
- Security Guidelines β SECURITY.md
- Version Control Policy β VERSION_CONTROL.md
- Changelog β CHANGELOG.md
Please refer to the Version Control Policy for detailed instructions on contributing: VERSION_CONTROL.md.
This project is licensed under the MIT License β see the LICENSE file for details.