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

folder-tree-generator

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

folder-tree-generator

Generate a folder tree structure using command line or code.

latest
Source
npmnpm
Version
1.1.7
Version published
Weekly downloads
11
-80.36%
Maintainers
1
Weekly downloads
 
Created
Source

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

TerminalCodeTypeDefaultDescription
-d -directory [dir]Path is a parameterstringTerminal: currentFolder - Code: path is required paramFolder Path
-f, --folders-onlyfolderOnlybooleanfalsegenerate tree only with folders (ignore files)
-s, --sortsortbooleanfalseSort alphabetically and put folders first and then files.
-c, --commentscommentsbooleanfalseShow "Empty folder" comment (--folder-only must be false)
-e, --export [path][Not Available]stringfalseSet 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]ignorestringfalseRegex list to ignore folders and/or files (separated by commas) - eg: "example($|/.*),index.ts"
--emojisemojisbooleanfalseShow 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 ✅

Keywords

folder

FAQs

Package last updated on 04 Dec 2022

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