@dandesdev/scaf
v1.0.2
Published
A cross-platform directory scaffold CLI tool
Downloads
174
Readme
scaf
A CLI tool that prints the scaffold of a project, I made it for myself because I needed powerful and easier ignore patterns in my windows 10 machine. Its node based, so cross-platform, and It can output to a txt or a json file, see examples bellow.
Installation
npm install -g @dandesdev/scafYou absolutely can use the package manager of your choice, it doesn't need to be npm, but you need node already installed.
Project Structure
The code is organized into focused modules in the lib/ folder:
parseArgs.js- Command-line argument parsinghelp.js- Help message displayignore.js- Gitignore/dockerignore file loadingfilter.js- File filtering logicsort.js- Sorting and stat retrievalformat.js- Output formatting for text and JSONstats.js- Statistics tracking and calculationscan.js- Directory tree building and streaming
The main entry point (bin/scaf.js) orchestrates these modules.
Usage
scaf [options]Options
| Flag | Short | Description | Default |
|------|-------|-------------|---------|
| --path | -p | Target directory | Current directory |
| --maxdepth | -md | Maximum folder depth | Infinite |
| --output | -o | Save to file (.txt or .json) | Print to console |
| --ignore | -i | Patterns to ignore | None |
| --typed-ignore | -ti | Enable typed ignore mode | Disabled |
| --only | -n | Show only matching patterns | All (filtered) |
| --dirs-only | -d | Show only directories | Disabled |
| --size | - | Show file sizes | Disabled |
| --show-hidden | -a | Show hidden files (dotfiles) | Disabled |
| --sort | - | Sort by: name, size, date | name |
| --stats | - | Show stats: console, include, all | None |
| --stats-only | - | Show detailed stats: strict, all | None |
| --gitignore | - | Load .gitignore patterns (true/false) | true |
| --dockerignore | - | Load .dockerignore patterns (true/false) | true |
| --buffered | -b | Use buffered mode for text output | Disabled |
| --quiet | -q | Suppress info messages | Disabled |
| --help | -h | Show help | - |
Ignore Patterns
Default Mode (-i)
Ignores items by exact name or extension:
scaf -i node_modules .git .env .lognode_modules→ ignores file or folder named "node_modules".log→ ignores all files ending in.log
Typed Mode (-ti + -i)
Makes patterns type-aware. Use trailing / for folders:
scaf -ti -i bin/ config *. .tmpbin/→ ignores only the folder "bin"config→ ignores files named "config" (any extension:config.js,config.json)*.→ ignores all files (shows only folders)*/→ ignores all folders (shows only root-level files).tmp→ still works as extension match
Examples
Basic tree
scafScan specific directory
scaf -p ./srcLimit depth
scaf -md 2Save to text file
scaf -o structure.txtSave to JSON
scaf -o tree.jsonIgnore common folders
scaf -i node_modules .git distIgnore only the bin folder
scaf -ti -i bin/Ignore all config files (any extension)
scaf -ti -i configShow only folders
scaf -ti -i *.Show only files (ignore all folders)
scaf -ti -i */Complex ignore
scaf -ti -i node_modules/ *.md .env configCombine options
scaf -p ./myapp -md 3 -ti -i node_modules/ dist/ *.log -o output.txtShow only TypeScript files
scaf -n .ts .tsxShow file sizes sorted by size
scaf --size --sort sizeGenerate statistics
scaf --stats
scaf --stats all -o report.txt
scaf --stats-only -o stats.jsonInclude hidden files
scaf -aNote!
scaf -i -ti src/will not ignore the folder "src", you must pass all the arguments of the flag "-i" right after it, the correct way would be:
scaf -ti -i src/Output Format
Text (default)
└── MyApp/
├── src/
│ ├── components/
│ │ └── Button.tsx
│ └── index.ts
└── package.jsonJSON
[
{
"name": "MyApp",
"type": "directory",
"children": [
{
"name": "src",
"type": "directory",
"children": [
{
"name": "components",
"type": "directory",
"children": [
{
"name": "Button.tsx",
"type": "file"
}
]
}
]
},
{
"name": "package.json",
"type": "file"
}
]
}
]
### License
MIT