Skip to content

A cookiecutter template for creating ReactPy component packages, with optional JavaScript/TypeScript browser code support.

License

Notifications You must be signed in to change notification settings

stevej2608/cookiecutter-reactpy-package

Repository files navigation

Cookiecutter ReactPy Package Template

A cookiecutter template for creating ReactPy component packages, with optional JavaScript/TypeScript browser code support.

This project is currently pinned at ReactPy Beta V2.0.0b7

Features

  • Standardized project structure following ReactPy best practices
  • Optional JavaScript/TypeScript browser code with bun build system
  • Optional ReactPy themed docs
  • Pre-configured testing with pytest and playwright
  • Visual regression testing support
  • Type checking with pyright
  • VSCODE support
  • Hatch build system integration
  • MIT License by default

Requirements

  • Python 3.11+
  • cookiecutter
  • bun (if using browser code)

Usage

Create a new project

cookiecutter gh:stevej2608/cookiecutter-reactpy-package

You'll be prompted for:

  • project_name: Human-readable name (e.g., "My ReactPy Package")
  • project_slug: URL/package friendly name (auto-generated from project_name)
  • package_name: Python import name (auto-generated from project_slug)
  • project_short_description: Brief description of your package
  • author_name: Your name
  • author_email: Your email address
  • github_username: Your GitHub username
  • browser_code: JavaScript/TypeScript browser code option (none/js/ts)
  • has_docs: Whether to include ReactPy themed project docs folder & builder (no/yes)
  • keywords: Comma-separated keywords for PyPI
  • version: Initial version number

Project Structure

The generated project will have:

your-project/
├── pyproject.toml          # Project configuration
├── README.md               # Project documentation
├── LICENSE.md              # MIT License
├── CONTRIBUTING.md         # Contribution guidelines
├── .gitignore              # Git ignore rules
├── .vscode/                # VS Code configuration
│   ├── launch.json         # Debug configurations
│   ├── settings.json       # Editor settings
│   └── tasks.json          # Build tasks
├── src/
│   ├── js/                 # JavaScript/TypeScript source (if browser_code != none)
│   │   ├── package.json
│   │   ├── tsconfig.json   # (if browser_code == ts)
│   │   └── src/
│   │       └── index.tsx or index.jsx
│   └── your_package/       # Python package
│       └── __init__.py
├── tests/
│   ├── __init__.py
│   ├── conftest.py         # Pytest configuration
│   ├── test_component.py   # Example test
│   └── tooling/            # Test utilities
│       ├── __init__.py
│       ├── page_containers.py
│       ├── playwright_helpers.py
│       ├── pytest_playwright_visual.py
│       └── wait_stable.py
├── examples/               # Usage examples
│   ├── __init__.py
│   └── app_example.py
├── docs/                   # Documentation (if has_docs == yes)
│   ├── mkdocs.yml
│   └── src/
│       ├── index.md
│       └── about/
│           ├── contributing.md
│           └── license.md
└── utils/                  # Development utilities
    ├── __init__.py
    ├── app_runner.py       # Application runner helpers
    ├── logger.py           # Logging configuration
    └── types.py            # Type definitions

Development Workflow

After generating your project:

cd your-project

# Run tests
hatch test

# Build the package
hatch build

# Publish the package
hatch publish

License

This cookiecutter template is released under the MIT License.

About

A cookiecutter template for creating ReactPy component packages, with optional JavaScript/TypeScript browser code support.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published