Generate file structures from text tree files and scaffold React/Next.js projects
Project description
gentf
Generate file structures from text tree files. A simple CLI tool that creates directory structures and scaffolds framework projects from plain text definitions.
What is gentf?
gentf reads a text file describing a directory structure and creates that structure on your filesystem. It can also scaffold React or Next.js projects and merge your custom file structure into them.
Instead of manually creating dozens of folders and files, write a simple text tree and let gentf do the work.
Installation
pip install gentf
Quick Start
Basic Usage
Create a text file describing your structure:
my-project/
├── src/
│ ├── components/
│ │ └── Button.tsx
│ └── App.tsx
├── public/
│ └── favicon.ico
└── package.json
Then generate it:
gentf my-project.txt
This creates the entire structure in your current directory. Use -o to specify a different output location:
gentf my-project.txt -o ./output
Framework Scaffolding
gentf can scaffold React or Next.js projects and then apply your custom structure to them.
React with Vite:
gentf project.txt --type react --variant vite
React with Create React App:
gentf project.txt --type react --variant cra
Next.js (App Router):
gentf project.txt --type next --variant default
Next.js with TypeScript:
gentf project.txt --type next --variant ts
Next.js with Turbopack:
gentf project.txt --type next --variant turbopack
Next.js Pages Router:
gentf project.txt --type next --variant pages
When you use framework scaffolding, gentf will:
- Create the framework project (React or Next.js)
- Apply your custom file structure from the tree file
- Merge everything together intelligently
Tree File Format
You can write your structure using box-drawing characters:
project-root/
├── src/
│ ├── components/
│ │ └── Button.tsx
│ └── pages/
│ └── Home.tsx
├── public/
│ └── favicon.ico
└── package.json
Or use simple indentation:
project-root/
src/
components/
Button.tsx
pages/
Home.tsx
public/
favicon.ico
package.json
Comments (lines starting with #) are automatically ignored, so you can add notes:
project/
├── src/
│ ├── components/ # Reusable UI components
│ └── utils/ # Helper functions
└── tests/ # Test files
How It Works
Project Name: The project name is automatically derived from your tree file name. If your file is myapp.txt, the project will be named myapp.
Smart Unwrapping: If your tree file has a top-level directory matching the project name, gentf automatically unwraps it to avoid creating nested structures. For example, if your tree file is myapp.txt and contains myapp/ at the top level, the contents go directly into the project root instead of creating myapp/myapp/.
Intelligent Merging: When scaffolding frameworks, your custom files are merged with the scaffolded project files. Existing files are preserved, and new files from your tree are added.
Examples
Simple Structure Generation
Create a structure.txt file:
my-app/
├── src/
│ └── index.js
├── public/
│ └── index.html
└── README.md
Generate it:
gentf structure.txt
React Project with Custom Structure
Create myapp.txt:
myapp/
├── src/
│ ├── components/
│ │ └── Header.tsx
│ └── hooks/
│ └── useAuth.ts
└── public/
└── logo.svg
Scaffold and apply:
gentf myapp.txt --type react --variant vite -o ./projects
This creates a React + Vite project in ./projects/myapp/ with your custom structure merged in.
Next.js TypeScript Project
gentf myapp.txt --type next --variant ts
Creates a Next.js TypeScript project with your custom file structure.
Requirements
- Python 3.8 or higher
- Node.js and npm (required for framework scaffolding)
Getting Help
View all available options and detailed help:
gentf --help
Development
For local development:
# Clone the repository
git clone https://github.com/yourusername/gentf
cd gentf
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in editable mode
pip install -e .
# Run tests
pytest tests/
See DEVELOPMENT.md for more details.
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gentf-0.1.4.tar.gz.
File metadata
- Download URL: gentf-0.1.4.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d0a1e1f1fbcbd711c3bfb4823002a1c1b5d0786bbec6a69e8bf58bf26c326c2
|
|
| MD5 |
ebc2d11000e8c1b9007eddebbf2e10c3
|
|
| BLAKE2b-256 |
bb2b4f9808dfd573a9ff9f47b572690323d2a865bd6ba4ad583f979c7d6bad0d
|
File details
Details for the file gentf-0.1.4-py3-none-any.whl.
File metadata
- Download URL: gentf-0.1.4-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ef94a6e723edd37f7b14050e6e6dbfa7be972bf42e70d4c7dfa6b1a9c92cca5
|
|
| MD5 |
c7459da05725dced0fb90117074aa30a
|
|
| BLAKE2b-256 |
0af86eccf555c2867e97126241c2b98a97fc610d388de7085fc9941b88304d0a
|