Skip to content

reactive-python/reactpy-js-component-template

Repository files navigation

ReactPy Package Cookiecutter

Test

A cookiecutter template for packaging Javascript components with ReactPy

About ReactPy

ReactPy is a framework for creating highly interactive web pages purely in Python. However, ReactPy also provides a way to natively interface with the Javascript ecosystem. This repository defines a basic template for creating packages wich distribute Javascript for use in ReactPy-based applications.

For more information about ReactPy refer to its documentation.

Usage

Install cookiecutter with pip:

pip install cookiecutter

Then use this repostory template as a cookiecutter to initalize a repository:

cookiecutter https://github.com/reactive-python/reactpy-react-component-cookiecutter.git

As the template is being constructed you will be prompted to fill out the following information:

Field Description
author_name your name or the name of your organization
author_email your email of the email of your organization
repository_name the name of your repository's root directory
repository_url the URL your repository can be found at
python_package_name the name of the "backend" Python package your Javascript components will be used in
npm_package_name the name of the "frontend" Javascript package used by your Python package
project_short_description a short summary used to describe both Python and Javascript packages

After this you should find a new directory named after the given repository_name.

Template Manifest

The template generates the following files:

├── {python_package_name}
│   ├── __init__.py
│   └── example.py
├── js
│   ├── src
│   │   ├── index.js
│   ├── package.json
│   ├── README.md
│   └── rollup.config.js
├── tests
│   ├── __init__.py
│   ├── conftest.py
│   └── test_example.py
├── .gitignore
├── MANIFEST.in
├── README.md
├── setup.cfg
└── setup.py

The key consituents of the generated repository are briefly described below:

File/Directory Contents
js/ a bare-bones Javascript component that is bundled with Rollup
{python_package_name}/ minimial code required to load the Javascript component
tests/ a basic selenium-based test suite for your component

Run the Tests

To run the tests for this repository you'll need the ChromeDriver in your PATH. Once that's done, simply pip install the requirements:

pip install -r requirements.txt

And run the test session with Nox:

nox -s test

To open the browser when the tests run:

nox -s test

About

A repository template for distributing custom React-based Javascript components in a Python package for IDOM.

Resources

License

Stars

Watchers

Forks