npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

folder-tree-generator

v1.1.7

Published

Generate a folder tree structure using command line or code.

Downloads

38

Readme

Folder Tree Generator - FTG

Generate a folder tree structure using command line or code.

NPM version NPM downloads Open issues Open prs

├── folder-tree-generator
│   ├── .editorconfig
│   ├── .gitignore
│   ├── .prettierrc.json
│   ├── README.md
│   ├── package-lock.json
│   ├── package.json
│   ├── src
│   │   ├── example
│   │   │   └── index.ts
│   │   ├── folder1
│   │   │   ├── folder2
│   │   │   ├── folder3
│   │   │   │   └── folder4
│   │   ├── index.ts
│   │   ├── bin
│   │   │   └── index.ts
│   │   ├── utils
│   │   │   ├── drawTreeFromJsonDir.ts
│   │   │   ├── ftg.ts
│   │   │   ├── index.ts
│   │   │   ├── parseDirToJson.ts
│   │   │   └── sortFolder.ts
│   └── tsconfig.json

CLI Usage

Install globally

npm i folder-tree-generator -g

Run FTG

$ ftg [options]

Help options

$ ftg --help

Usage: dist [options]

Options:
  -V, --version          output the version number
  -d, --directory [dir]  Directory path. (default: "[current path]")
  -f, --folder-only      Draw folders only.
  -s, --sort             Sort alphabetically and put folders first and then files.
  -c, --comments         Show "Empty folder" comment (--folder-only must be false)
  -e, --export [path]    Set the folder path to export "ftg_tree_[date].txt" or just -e or --export for the default export to the current path
  -i, --ignore [regex]   Regex list to ignore folders and/or files (separated by commas) - eg: "example($|/.*),index.ts"
  --emojis               Show emojis - folder: 📁 - File: 📄
  -h, --help             display help for command

NPX

npx folder-tree-generator [options]

Code Usage

npm i folder-tree-generator
import { ftg, FtgOptions } from 'folder-tree-generator'

// get current path
const path = process.cwd()

// ftg options
const options: FtgOptions = { sort: true, emojis: true }

console.log('👇👇 Tree with options:', options)


const tree = ftg(path, options)
console.log(tree)

// OUTPUT

👇👇 Tree with options: { sort: true, emojis: true }
├── 📁 folder-tree-generator
│   ├── 📁 src
│   │   ├── 📁 example
│   │   │   └── 📄 index.ts
│   │   ├── 📁 bin
│   │   │   └── 📄 index.ts
│   │   ├── 📁 utils
│   │   │   ├── 📄 drawTreeFromJsonDir.ts
│   │   │   ├── 📄 ftg.ts
│   │   │   ├── 📄 index.ts
│   │   │   ├── 📄 parseDirToJson.ts
│   │   │   └── 📄 sortFolder.ts
│   │   └── 📄 index.ts
│   ├── 📄 .editorconfig
│   ├── 📄 .gitignore
│   ├── 📄 .prettierrc.json
│   ├── 📄 README.md
│   ├── 📄 package-lock.json
│   ├── 📄 package.json
│   └── 📄 tsconfig.json

Options

| Terminal | Code | Type | Default | Description | | -------------------- | ------------------- | ------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | -d -directory [dir] | Path is a parameter | string | Terminal: currentFolder - Code: path is required param | Folder Path | | -f, --folders-only | folderOnly | boolean | false | generate tree only with folders (ignore files) | | -s, --sort | sort | boolean | false | Sort alphabetically and put folders first and then files. | | -c, --comments | comments | boolean | false | Show "Empty folder" comment (--folder-only must be false) | | -e, --export [path] | [Not Available] | string | false | Set the folder path to export "ftg_tree_[date].txt" or just -e or --export for the default export to the current path | | -i, --ignore [regex] | ignore | string | false | Regex list to ignore folders and/or files (separated by commas) - eg: "example($|/.*),index.ts" | | --emojis | emojis | boolean | false | Show emojis - folder: 📁 - File: 📄 |

Ignore files/folders

By default ftg ignore the following files and folders

  • .vscode
  • .DS_Store
  • .git
  • node_modules
  • dist
  • coverage
  • .husky

Regex to ignore (-i, --ignore)

Example

Ignore all index.ts files and folders named "/example"

ftg -i 'example($|/.*),index.ts'

Output

├── folder-tree-generator
│   ├── .editorconfig
│   ├── .prettierrc.json
│   ├── .versionrc
│   ├── CHANGELOG.md
│   ├── LICENSE
│   ├── README.md
│   ├── package-lock.json
│   ├── package.json
│   ├── src
│   │   ├── bin
│   │   ├── utils
│   │   │   ├── drawTreeFromJsonDir.ts
│   │   │   ├── ftg.ts
│   │   │   ├── parseDirToJson.ts
│   │   │   └── sortFolder.ts
│   └── tsconfig.json

Comments

If files and folders are included and the comments option is also added, empty folders will show the comment "# Empty folder"

├── folder-tree-generator
│   ├── .editorconfig
│   ├── .gitignore
│   ├── .prettierrc.json
│   ├── README.md
│   ├── package-lock.json
│   ├── package.json
│   ├── src
│   │   ├── example
│   │   │   └── index.ts
│   │   ├── folder1
│   │   │   ├── folder2 # Empty folder
│   │   │   ├── folder3
│   │   │   │   └── folder4 # Empty folder
│   │   ├── index.ts
│   │   ├── bin
│   │   │   └── index.ts
│   │   ├── utils
│   │   │   ├── drawTreeFromJsonDir.ts
│   │   │   ├── ftg.ts
│   │   │   ├── index.ts
│   │   │   ├── parseDirToJson.ts
│   │   │   └── sortFolder.ts
│   └── tsconfig.json

TODO

  • Unit testing jest
  • Add command flags
    • --sort ✅
    • --folder-only ✅
    • --ignore (regex[]) ✅
    • --export ✅
    • --size (include file/folder size)
  • add ftg() options
    • sort ✅
    • folderOnly ✅
    • ignore (regex[]) ✅
    • size (include file/folder size)
  • Add comment "# Empty folder" (if you are including files but the folder is empty literally) ✅
  • Interactive terminal
  • Show available version in terminal ✅
  • Show emojis ✅
  • CHANGELOG.md ✅