Skip to content

Commit 378cfdd

Browse files
committed
INIT
0 parents  commit 378cfdd

File tree

12 files changed

+1602
-0
lines changed

12 files changed

+1602
-0
lines changed

.gitignore

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/dist
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
.pnpm-debug.log*
11+
pnpm-lock.yaml
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
node_modules/
46+
jspm_packages/
47+
48+
# Snowpack dependency directory (https://snowpack.dev/)
49+
web_modules/
50+
51+
# TypeScript cache
52+
*.tsbuildinfo
53+
54+
# Optional npm cache directory
55+
.npm
56+
57+
# Optional eslint cache
58+
.eslintcache
59+
60+
# Optional stylelint cache
61+
.stylelintcache
62+
63+
# Microbundle cache
64+
.rpt2_cache/
65+
.rts2_cache_cjs/
66+
.rts2_cache_es/
67+
.rts2_cache_umd/
68+
69+
# Optional REPL history
70+
.node_repl_history
71+
72+
# Output of 'npm pack'
73+
*.tgz
74+
75+
# Yarn Integrity file
76+
.yarn-integrity
77+
78+
# dotenv environment variable files
79+
.env
80+
.env.development.local
81+
.env.test.local
82+
.env.production.local
83+
.env.local
84+
85+
# parcel-bundler cache (https://parceljs.org/)
86+
.cache
87+
.parcel-cache
88+
89+
# Next.js build output
90+
.next
91+
out
92+
93+
# Nuxt.js build / generate output
94+
.nuxt
95+
96+
# Gatsby files
97+
.cache/
98+
# Comment in the public line in if your project uses Gatsby and not Next.js
99+
# https://nextjs.org/blog/next-9-1#public-directory-support
100+
# public
101+
102+
# vuepress build output
103+
.vuepress/dist
104+
105+
# vuepress v2.x temp and cache directory
106+
.temp
107+
.cache
108+
109+
# Docusaurus cache and generated files
110+
.docusaurus
111+
112+
# Serverless directories
113+
.serverless/
114+
115+
# FuseBox cache
116+
.fusebox/
117+
118+
# DynamoDB Local files
119+
.dynamodb/
120+
121+
# TernJS port file
122+
.tern-port
123+
124+
# Stores VSCode versions used for testing VSCode extensions
125+
.vscode-test
126+
127+
# yarn v2
128+
.yarn/cache
129+
.yarn/unplugged
130+
.yarn/build-state.yml
131+
.yarn/install-state.gz
132+
.pnp.*
133+
134+
/temp

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 4,
4+
"singleQuote": true,
5+
"arrowParens": "avoid",
6+
"experimentalTernaries": true
7+
}

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "file-tree-cli",
3+
"version": "0.0.1",
4+
"description": "A powerful and flexible command-line tool for visualizing directory structures with advanced features and customization options.",
5+
"main": "dist/index.js",
6+
"bin": {
7+
"tree": "./dist/index.js",
8+
"file-tree": "./dist/index.js",
9+
"file-tree-cli": "./dist/index.js"
10+
},
11+
"scripts": {
12+
"build": "tsc",
13+
"start": "ts-node src/index.ts",
14+
"prepublishOnly": "npm run build",
15+
"dev": "ts-node src/index.ts",
16+
"clean": "rm -rf dist",
17+
"prebuild": "npm run clean",
18+
"format": "prettier --write \"src/**/*.ts\"",
19+
"format:check": "prettier --check \"src/**/*.ts\""
20+
},
21+
"license": "MIT",
22+
"private": false,
23+
"files": [
24+
"dist",
25+
"README.md"
26+
],
27+
"keywords": [
28+
"cli",
29+
"file-tree",
30+
"directory",
31+
"visualization",
32+
"tree",
33+
"filesystem"
34+
],
35+
"author": {
36+
"name": "Prateek Sing",
37+
"email": "[email protected]"
38+
},
39+
"repository": {
40+
"type": "git",
41+
"url": "git+https://github.com/devxprite/file-tree-cli.git"
42+
},
43+
"bugs": {
44+
"url": "https://github.com/devxprite/file-tree-cli/issues"
45+
},
46+
"homepage": "https://github.com/devxprite/file-tree-cli#readme",
47+
"engines": {
48+
"node": ">=12.0.0"
49+
},
50+
"dependencies": {
51+
"colorette": "^2.0.20",
52+
"commander": "^12.1.0"
53+
},
54+
"devDependencies": {
55+
"@types/node": "^22.10.2",
56+
"@typescript-eslint/eslint-plugin": "^6.0.0",
57+
"@typescript-eslint/parser": "^6.0.0",
58+
"eslint": "^8.0.0",
59+
"prettier": "^3.4.2",
60+
"ts-node": "^10.9.2",
61+
"typescript": "^5.7.2"
62+
}
63+
}

public/logo.svg

Lines changed: 27 additions & 0 deletions
Loading

readme.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<div align="center">
2+
<h2>File Tree CLI</h2>
3+
<!-- <img src="./public/logo.svg" alt="MoviesPrix" width="250" /> -->
4+
<p>A modern CLI tool for visualizing directory structures with advanced filtering and display options.</p>
5+
</div>
6+
7+
## Features
8+
9+
- 🎨 Colorized output (directories in blue, files in cyan)
10+
- 📏 Configurable directory traversal depth
11+
- 🔍 Multiple filtering options:
12+
- File extensions
13+
- Regular expression patterns
14+
- Hidden files
15+
- Directories/files only
16+
- 📊 File size display
17+
- 📅 Last modified dates
18+
- 🔄 Multiple sorting options
19+
- 💾 Save output to file
20+
- ⚡ Performance optimized
21+
22+
## Installation
23+
24+
```bash
25+
npm install -g file-tree-cli
26+
```
27+
28+
## Usage
29+
30+
```bash
31+
tree [options] [directory]
32+
```
33+
34+
If no directory is specified, the current directory will be used.
35+
36+
### Basic Examples
37+
38+
```bash
39+
# Display tree of current directory
40+
tree
41+
42+
# Display tree of specific directory
43+
tree /path/to/directory
44+
45+
# Show tree with file sizes
46+
tree -s
47+
48+
# Show only JavaScript and TypeScript files
49+
tree --ext js,ts
50+
51+
# Show files modified dates and sizes
52+
tree -s -m
53+
```
54+
55+
### Advanced Examples
56+
57+
```bash
58+
# Show only directories, sorted by name
59+
tree --dirs-only --sort name
60+
61+
# Show only JavaScript files and their sizes
62+
tree --ext js -s
63+
64+
# Show tree with custom depth and excluded directories
65+
tree -d 3 -e "dist,coverage"
66+
67+
# Show all files (including hidden) sorted by size
68+
tree -a --sort size
69+
70+
# Export tree to a file
71+
tree -o output.txt
72+
```
73+
74+
## Options
75+
76+
| Option | Description |
77+
| -------------------------- | ---------------------------------------------- |
78+
| `-d, --max-depth <number>` | Maximum depth to traverse |
79+
| `-a, --all` | Show hidden files |
80+
| `-e, --exclude <items>` | Comma-separated list of directories to exclude |
81+
| `-s, --show-size` | Show file sizes |
82+
| `-m, --modified` | Show last modified date |
83+
| `-f, --pattern <pattern>` | Filter items by regex pattern |
84+
| `--ext <extensions>` | Filter by file extensions (comma-separated) |
85+
| `--sort <type>` | Sort items by: name, size, or date |
86+
| `-r, --reverse` | Reverse sort order |
87+
| `--dirs-only` | Show only directories |
88+
| `--files-only` | Show only files |
89+
| `-o, --output <file>` | Save output to file |
90+
91+
## Output Format
92+
93+
The tool provides a structured view of your directory:
94+
95+
```
96+
Directory
97+
├── src
98+
│ ├── index.ts [2.5KB] 2024-01-15
99+
│ └── utils.ts [1.2KB] 2024-01-14
100+
└── package.json [0.8KB] 2024-01-10
101+
```
102+
103+
## Development
104+
105+
1. Clone the repository:
106+
```bash
107+
git clone https://github.com/devxprite/file-tree-cli.git
108+
```
109+
110+
2. Install dependencies:
111+
```bash
112+
npm install
113+
```
114+
115+
3. Build the project:
116+
```bash
117+
npm run build
118+
```
119+
120+
4. Link for local development:
121+
```bash
122+
npm link
123+
```
124+
125+
## Contributing
126+
127+
Contributions are welcome! Please feel free to submit a Pull Request.
128+
129+
## License
130+
131+
MIT

src/constants.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Config } from './types';
2+
3+
export const DEFAULT_CONFIG: Config = {
4+
maxDepth: Infinity,
5+
exclude: ['.git', 'node_modules'],
6+
showHidden: false,
7+
showSize: false,
8+
showLastModified: false,
9+
pattern: null,
10+
extensions: null,
11+
sort: 'name',
12+
reverse: false,
13+
onlyDirs: false,
14+
onlyFiles: false,
15+
};

0 commit comments

Comments
 (0)