New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

traverse-md

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

traverse-md

a command line tool to get the folder structure of your project for your readme file

latest
npmnpm
Version
1.1.1
Version published
Maintainers
0
Created
Source

traverse-md

traverse-md is a simple command-line tool that generates a markdown-compatible directory structure of a given folder and writes it to a README file. It’s perfect for documenting project structures or creating navigable outlines in README.md files.

Features

  • Outputs the directory and file structure in a markdown tree format
  • Automatically writes to README.md or updates the existing structure within the file
  • Customizable root directory path

Installation

You can use traverse-md directly with npx, or install it globally.

Using npx

npx traverse-md "path/to/directory"

Global Installation

Install traverse-md globally to use it without npx:

npm install -g traverse-md

Usage

Basic Command

To generate the structure of the current working directory, run:

npx traverse-md .

Or, if installed globally:

traverse-md .

This will create or update a README.md file in the specified directory with a structured outline of your project.

Specifying a Directory

Provide a specific path if you want to outline a different directory:

npx traverse-md path/to/your-directory

Interactive Mode

If you want to specify directories to ignore, run the command without arguments:

npx traverse-md

The tool will prompt you to enter:

The path of the directory to traverse.

  • A list of directories to ignore, separated by commas.
  • Ignored Directories By default, the following directories are ignored:
  • .git
  • .next
  • node_modules
  • vendor
  • Log files and temporary files

You can also add your own directories to ignore by passing them as a command line argument:

npx traverse-md . --ignore "dir1,dir2"

Example Output

Running traverse-md in a Next.js project might produce the following output in your README.md:

my-nextjs-app/
├── public/              # Static files (images, fonts, etc.)
│   └── favicon.ico
├── src/                 # Source folder
│   ├── app/             # App directory for Next.js 13+ App Router
│   │   ├── api/         # API routes
│   │   └── layout.tsx   # Global layout for the app
│   └── components/      # Reusable components
│       ├── Button.tsx
│       └── Header.tsx
│   └── hooks/           # Custom React hooks
│       └── useAuth.ts
├── .env                 # Environment variables
├── next.config.js       # Next.js configuration
├── package.json         # Package dependencies and scripts
├── tsconfig.json        # TypeScript configuration
└── README.md            # Project documentation

Customization

  • File Path: Run the command with npx traverse-md "path/to/directory" to specify which directory to structure.
  • Updating the README: If README.md exists, traverse-md will update the section containing the folder structure instead of appending a duplicate.

Configuration Options

traverse-md can be extended with future updates. The current implementation writes the folder structure in the README.md file automatically, ensuring a neat, collapsible section. Custom configurations can be added by modifying the codebase to accept parameters for output format or additional information (e.g., file sizes).

Contributing

I welcome contributions to enhance traverse-md! Here are ways to get involved:

  • Report issues: If you find bugs, report them on the GitHub issues page.
  • Submit PRs: Fork the repository and submit pull requests for improvements.
  • Feature requests: Let us know what features you'd like to see in future versions.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Directory Structure

└── .github └── workflows ├── npm-publish.yml ├── .gitignore ├── index.js ├── package-lock.json ├── package.json ├── README.md

End Directory Structure

Keywords

CLI

FAQs

Package last updated on 05 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts