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.2.tar.gz (10.5 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.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gentf-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 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.2.tar.gz
Algorithm Hash digest
SHA256 433783670b48408b9fae56541e462d6bb873c05523861ff6ff03f475550a4a07
MD5 6cf7db0f5800850b789a51493181d2a4
BLAKE2b-256 2e4ab60726d77b4de60199c1967756577d6edb7f8fc9df1719885e1e41c9e641

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gentf-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 be70b126d7f762513555c934fa71b94534f4ca4f40210135ba5bd4f3f9cdf695
MD5 d008a1b94621d4558ad5e7abc1c4a917
BLAKE2b-256 e2f0085e438dbb0de0b05d9e7740adb17d51c0788b75d4f5e7797280c0629c10

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