fsmap-cli
Version:
๐ CLI to visualize and export the file structure of any folder or GitHub repo
174 lines (122 loc) โข 4.13 kB
Markdown
# ๐๏ธ fsmap โ Visualize Folder Structures from Local or GitHub Repos
**fsmap** is a powerful CLI tool that scans any directory (local or remote GitHub repo) and visualizes its folder structure in a clean, tree-like format.
Supports output as text, markdown, JSON, and even integrates file size, modified dates, and Git status.
## ๐ฆ Features
- ๐ Visualize any local folder structure
- ๐ Fetch and display **GitHub repo structure** via `--repo`
- ๐งน Smart one-repo caching system (reuse if same repo, delete if not)
- ๐พ Show file sizes (`--show-size`)
- ๐ Show last modified dates (`--show-date`)
- ๐งโ๐ป Show Git status (`--show-git`)
- ๐ Output as: text (default), markdown, JSON, or HTML
- ๐ Save output to a file
- ๐ Works recursively with depth control
## ๐ ๏ธ Installation
(Global)
```bash
npm install -g fsmap-cli
```
(Local)
```bash
npm install -D fsmap-cli
```
## ๐ Usage
(Global)
```bash
fsmap [path] [options]
```
(Local)
```bash
npx fsmap [path] [options]
```
By default, it scans the **current directory (`.`)**.
### ๐ Scan a local folder
```bash
fsmap . --depth 2 --show-size --show-date
```
### ๐ Scan a remote GitHub repo
```bash
fsmap --repo user/repo
```
### ๐พ Export as markdown
```bash
fsmap . -o markdown > structure.md
```
### ๐ Save output to a file
```bash
fsmap . --output-format json --output-file structure.json
```
## ๐ Example Output (Text)
```bash
fsmap . --depth 1 --show-size --show-date
```
```
fsmap
โโโ dist (4.2 KB) [2025-05-23]
โโโ package.json (894 B) [2025-05-23]
โโโ src (7 files)
```
## ๐ง Available Options
| Option | Description |
|---------------------------|-----------------------------------------------------------|
| `-d, --depth <n>` | Limit recursion depth |
| `-e, --exclude <names>` | Comma-separated list of folders/files to exclude |
| `--show-size` | Display file sizes |
| `--show-date` | Display last modified date |
| `--show-hidden` | Include hidden files and folders |
| `--show-git` | Display Git status (`modified`, `untracked`, `ignored`) |
| `-o, --output-format` | Output format: `text` (default), `markdown`, `json` |
| `--output-file <path>` | Save the output to a file instead of printing to console |
| `--repo <user/repo>` | Clone and scan a GitHub repository |
| `--dry-run` | Show scan result without writing anything |
| `-v, --version` | Show version info |
| `-h, --help` | Show help info |
## ๐ง Repo Caching Behavior
- โ
If you scan the same repo again โ uses cached clone
- ๐ If you scan a different repo โ deletes old repo, clones fresh
- ๐ก Only **one repo** is ever cached at a time for performance and clarity
## โ๏ธ Config
Add a `fsmap.config.json` file in your project root to override the default options.
Example:
```js
{
"$schema": "https://raw.githubusercontent.com/SwasthK/fsmap/main/fsmap.schema.config.json",
"exclude": [
"node_modules",
".git",
"dist"
]
}
```
> **_NOTE:** Cli written options override the config rules.
## ๐ Plugin Support
Add a `fsmap.config.ts` file in your project root to transform or extend the file tree output.
Example:
```js
module.exports = {
ย ย transform(entry: FsMapEntry) {
ย ย ย ย if (entry.name.endsWith("git.ts")) {
ย ย ย ย ย ย entry.name = "๐งช " + entry.name;
ย ย ย ย }
ย ย ย ย return entry;
ย ย }
}
```
## ๐ค Contributing
Found a bug? Have a feature idea? PRs are welcome โ open an issue first!
## ๐ License
[MIT](./LICENSE)
## โจ Author
Made with โค๏ธ by [Swasthik](https://swasthk.vercel.app)