JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q67420F
  • License ISC

Package Exports

  • folder-tree-generator
  • folder-tree-generator/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (folder-tree-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Folder Tree Generator - FTG

Generate a folder tree structure using command line or code.

Npm package version

├── folder-tree-generator
│   ├── .editorconfig
│   ├── .gitignore
│   ├── .prettierrc.json
│   ├── README.md
│   ├── package-lock.json
│   ├── package.json
│   ├── src
│   │   ├── example
│   │   │   └── index.ts
│   │   ├── folder1
│   │   │   ├── folder2
│   │   │   ├── folder3
│   │   │   │   └── folder4
│   │   ├── index.ts
│   │   ├── terminal
│   │   │   └── 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)
  --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
│   │   ├── 📁 terminal
│   │   │   └── 📄 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)
--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

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
│   │   ├── terminal
│   │   │   └── 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
  • add ftg() options
    • sort ✅
    • folderOnly ✅
    • ignore (regex)
  • 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