Skip to main content

Generate file structures from text tree files and scaffold React/Next.js projects

Project description

gentf

Generate file structures from text tree files - A CLI tool that creates directory structures and scaffolds framework projects from simple text-based tree definitions.

Features

  • 📁 Simple Structure Generation: Create file and folder structures from text tree files
  • ⚛️ React Scaffolding: Scaffold React projects with Vite or Create React App
  • 🚀 Next.js Scaffolding: Scaffold Next.js projects with multiple variants (TypeScript, Turbopack, Pages Router, App Router)
  • 🔄 Smart Unwrapping: Automatically unwraps matching top-level directories to avoid nested structures
  • 🔀 Intelligent Merging: Merges your custom structure with scaffolded framework files

Installation

pip install gentf

Quick Start

Basic Usage

Generate a file structure in the current directory:

gentf structure.txt

Generate in a specific output directory:

gentf structure.txt -o path/to/output

Framework Scaffolding

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

Tree File Format

Create a text file describing your directory structure using indentation or box-drawing characters:

project-root/
├── src/
│   ├── components/
│   │   └── Button.tsx
│   ├── pages/
│   │   └── Home.tsx
│   └── App.tsx
├── public/
│   └── favicon.ico
├── package.json
└── README.md

Or use simple indentation:

project-root/
    src/
        components/
            Button.tsx
        pages/
            Home.tsx
        App.tsx
    public/
        favicon.ico
    package.json
    README.md

How It Works

  1. Project Name: Automatically derived from your tree file name (e.g., myapp.txtmyapp)
  2. Unwrapping: If your tree file has a top-level directory matching the project name, it's automatically unwrapped to prevent nested structures
  3. Framework Scaffolding: When using --type, the framework project is scaffolded first, then your tree structure is applied
  4. Smart Merging: Your custom files are merged with scaffolded framework files

Examples

Simple Structure

# Create structure.txt with your tree definition
gentf structure.txt

React Project with Custom Structure

# Scaffold React + Vite, then apply your tree structure
gentf myapp.txt --type react --variant vite -o ./projects

Next.js TypeScript Project

# Scaffold Next.js with TypeScript, then apply your tree structure
gentf myapp.txt --type next --variant ts

Help

Get detailed help and see all available options:

gentf --help

Requirements

  • Python 3.8+
  • Node.js and npm (for framework scaffolding)

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

Setup

# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate  # On macOS/Linux

# Install in editable mode
pip install -e .

# Install development dependencies
pip install build twine pytest

Local Development

# Run tests
pytest tests/

# Test CLI
gentf --help

# Build package locally (for testing)
python -m build

See DEVELOPMENT.md for more details.

Releasing

The project uses GitHub Actions for automatic PyPI publishing. To release a new version:

  1. Update version in pyproject.toml
  2. Run the release script:
    ./release.sh 0.1.1
    

Or manually:

git tag v0.1.1
git push origin v0.1.1

The workflow will automatically build, test, and publish to PyPI.

Author

shayan (tomohmmdali@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gentf-0.1.3.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gentf-0.1.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file gentf-0.1.3.tar.gz.

File metadata

  • Download URL: gentf-0.1.3.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for gentf-0.1.3.tar.gz
Algorithm Hash digest
SHA256 638c5948b3d14599eef0bfb9a00da515de1c53292c8f10b49803995a7b009cec
MD5 e781d78a0f325ee9136e4a62fdfde1af
BLAKE2b-256 c08657a19f4debfd282534e5f3cb474da101376287e92bb596c74d76d9823a1e

See more details on using hashes here.

File details

Details for the file gentf-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: gentf-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for gentf-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9825fbf90f0ea43bd0a0d1f2770a612cf78d93daa852e81f18aa552ca44aa854
MD5 8a325e4cbe20e012c3a827913433e8b7
BLAKE2b-256 061304119d5518ef8d3be86022e7089d54f1a8548d8e612914141810743c098a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page