Skip to content

rename to reactpy #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/test.yaml

This file was deleted.

13 changes: 5 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- uses: nanasess/setup-chromedriver@master
- uses: actions/setup-node@v2-beta
with:
node-version: "12"
- name: Install latest NPM
run: |
npm install -g npm@latest
npm --version
node-version: "14"
- name: install NPM version
run: npm install -g [email protected]
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Create Repo From Template
run: |
pip install nox
nox -s test
nox -t test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ __pycache__

# --- content generated by tests ---
test-repo
idom
reactpy
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 idom-team
Copyright (c) 2020 reactive-python

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# IDOM Package Cookiecutter
# ReactPy Package Cookiecutter

![Test](https://github.com/idom-team/idom-package-cookiecutter/workflows/Test/badge.svg?branch=main)
![Test](https://github.com/reactive-python/reactpy-package-cookiecutter/workflows/Test/badge.svg?branch=main)

A [`cookiecutter`](https://cookiecutter.readthedocs.io/en/1.7.2/README.html) template for packaging Javascript components with IDOM
A [`cookiecutter`](https://cookiecutter.readthedocs.io/en/1.7.2/README.html) template for packaging Javascript components with ReactPy

# About IDOM
# About ReactPy

IDOM is a framework for creating highly interactive web pages purely in Python. However,
IDOM also provides a way to natively interface with the Javascript ecosystem. This
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 IDOM-based applications.
use in ReactPy-based applications.

For more information about IDOM refer to its [documentation](https://idom-docs.herokuapp.com/docs/index.html).
For more information about ReactPy refer to its [documentation](https://reactpy-docs.herokuapp.com/docs/index.html).

# Usage

Expand All @@ -24,7 +24,7 @@ pip install cookiecutter
Then use this repostory template as a cookiecutter to initalize a repository:

```bash
cookiecutter https://github.com/idom-team/idom-react-component-cookiecutter.git
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:
Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"repository_url": "",
"python_package_name": "",
"npm_package_name": "",
"project_short_description": "A custom component library for IDOM"
"project_short_description": "A custom component library for ReactPy"
}
67 changes: 19 additions & 48 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from contextlib import contextmanager
from functools import wraps
from pathlib import Path
from shutil import rmtree
from tempfile import TemporaryDirectory
from typing import Callable

from nox import Session, session
Expand All @@ -14,63 +11,25 @@
SessionFunc = Callable[[Session], None]


def build_test_repo(install: bool = True) -> Callable[[SessionFunc], SessionFunc]:
"""Build a test repo from test-config.yaml before a session"""

def decorator(session_func: SessionFunc) -> SessionFunc:
@wraps(session_func)
def wrapper(session: Session) -> None:
_build_test_repo(session, install)
return session_func(session)

return wrapper

return decorator


def install_latest_idom(session_func: SessionFunc) -> SessionFunc:
# install the latest version of IDOM by pulling it from the main repo

@wraps(session_func)
def wrapper(session: Session) -> None:
try:
session.run(
"git", "clone", "https://github.com/idom-team/idom.git", external=True
)
session.install("./idom[testing,starlette]")
session_func(session)
finally:
idom_dir = HERE / "idom"
if idom_dir.exists():
rmtree(idom_dir)

return wrapper


@session
def test(session: Session) -> None:
session.notify("test_suite", posargs=session.posargs)
session.notify("test_style")


@session
@build_test_repo()
@install_latest_idom
@session(tags=["test"])
def test_suite(session: Session) -> None:
build_test_repo(session)
install_latest_reactpy(session)
session.chdir("test-repo")
session.run("playwright", "install", "chromium")
session.run("pytest", "tests", "--import-mode=importlib", *session.posargs)


@session
@build_test_repo(install=False)
@session(tags=["test"])
def test_style(session: Session) -> None:
build_test_repo(session, install=False)
session.install("black", "flake8")
session.run("black", "--check", "test-repo", *list(map(str, HERE.glob("*.py"))))
session.run("flake8", "test-repo")


def _build_test_repo(session: Session, install: bool) -> None:
def build_test_repo(session: Session, install: bool = True) -> None:
"""Build a test repo from test-config.yaml"""
# Need to remove node_modules so cookiecutter doesn't think since the cookiecutter
# will try to format those files if present
for path in TEMPLATE_DIR.rglob("node_modules"):
Expand All @@ -91,3 +50,15 @@ def _build_test_repo(session: Session, install: bool) -> None:
session.install(".")
session.install("-r", "requirements.txt")
session.chdir("..")


def install_latest_reactpy(session: Session) -> SessionFunc:
# install the latest version of ReactPy by pulling it from the main repo
try:
session.install(
"reactpy[testing,starlette] @ git+https://github.com/reactive-python/reactpy"
)
finally:
reactpy_dir = HERE / "reactpy"
if reactpy_dir.exists():
rmtree(reactpy_dir)
2 changes: 1 addition & 1 deletion test-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ default_context:
repository_url: "https://test.com"
python_package_name: "testpypkg"
npm_package_name: "testjspkg"
project_short_description: "A custom component library for IDOM"
project_short_description: "A custom component library for ReactPy"
10 changes: 5 additions & 5 deletions {{cookiecutter.repository_name}}/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion {{cookiecutter.repository_name}}/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
twine
pytest
pytest-asyncio
idom[testing,starlette]
reactpy[testing,starlette]
4 changes: 2 additions & 2 deletions {{cookiecutter.repository_name}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
package = {
"name": name,
"python_requires": ">=3.7",
"install_requires": ["idom>=0.39.0"],
"install_requires": ["reactpy>=0.39.0"],
"packages": find_packages(exclude=["tests*"]),
"description": "{{ cookiecutter.project_short_description }}",
"author": "{{ cookiecutter.author_name }}",
"author_email": "{{ cookiecutter.author_email }}",
"url": "{{ cookiecutter.repository_url }}",
"platforms": "Linux, Mac OS X, Windows",
"keywords": ["idom", "components"],
"keywords": ["reactpy", "components"],
"include_package_data": True,
"zip_safe": False,
"classifiers": [
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.repository_name}}/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from playwright.async_api import async_playwright
from idom.testing import DisplayFixture, BackendFixture
from reactpy.testing import DisplayFixture, BackendFixture


def pytest_addoption(parser) -> None:
Expand Down
6 changes: 3 additions & 3 deletions {{cookiecutter.repository_name}}/tests/test_example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import idom
from idom.testing import poll
import reactpy
from reactpy.testing import poll

from {{ cookiecutter.python_package_name }}.example import ExampleCounter


async def test_example_counter(display):
count = idom.Ref(0)
count = reactpy.Ref(0)

await display.show(
lambda: ExampleCounter(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from idom.web.module import export, module_from_file
from reactpy.web.module import export, module_from_file


_js_module = module_from_file(
Expand Down