scaffdir
Version:
Generate folders and files from a simple tree
91 lines (63 loc) โข 2.33 kB
Markdown
# scaffdir
๐ **scaffdir** is a command-line tool that generates folders and files from a simple text-based tree structure. It's perfect for scaffolding project directories or quickly mocking up file structures.
## โจ Features
- ๐ Create nested folders and files from a `.txt` file
- ๐ก Supports dry-run mode to preview what will be created
- ๐ฌ Friendly output with emoji and color (uses `chalk`)
- ๐ง Smart parsing of indentation-based tree structures
- ๐ Easily installable as a global CLI tool
## ๐ Installation
You can install `scaffdir` globally using npm:
```bash
npm install -g scaffdir
```
## ๐ ๏ธ Usage
The tool accepts the following flags
- ๐ `-f --file <file>` (Required) Path to the input file describing the folder/file tree structure.
- ๐ `-o --output <dir>` Output directory where structure should be created (defaults to current dir)
- ๐งช `-d, --dry-run` Show what would be created without making any changes on disk.
- `-V, --version` Display the current version
- `-h, --help` Show help message
Use the flags together like below:
```bash
scaffdir -f <structure.txt> [-o <output-directory>] [--dry-run]
```
## ๐ Example Input File
Here's an example of what the input text file might look like
```bash
my-app/
index.html
src/
main.js
utils.js
styles/
main.css
README.md
```
Use 2 spaces for indentation. Folder names should end with a `/`
## โ
Example Usage
### ๐งช Dry Run
```bash
scaffdir -f structure.txt --dry-run
```
### Output
```bash
๐ Reading structure from: structure.txt...
๐ Output directory: /your/current/dir
๐ Would create folder: /your/current/dir/my-app
๐ Would create file: /your/current/dir/my-app/index.html
๐ Would create folder: /your/current/dir/my-app/src
๐ Would create file: /your/current/dir/my-app/src/main.js
๐ Would create file: /your/current/dir/my-app/src/utils.js
๐ Would create folder: /your/current/dir/my-app/styles
๐ Would create file: /your/current/dir/my-app/styles/main.css
๐ Would create file: /your/current/dir/my-app/README.md
```
## ๐ Create Structure
```bash
scaffdir -f structure.txt -o ./generated-project
```
## ๐ License
MIT License ยฉ Damain Gabriel