UNPKG

fsmap-cli

Version:

๐Ÿ“ CLI to visualize and export the file structure of any folder or GitHub repo

174 lines (122 loc) โ€ข 4.13 kB
# ๐Ÿ—‚๏ธ 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)