diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 9fc45f7..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test - -on: - push: - schedule: - - cron: "0 0 * * *" - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.7, 3.8, 3.9] - 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 - - 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fffa4ff..b7137c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,17 +13,14 @@ 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 npm@8.19.3 - name: Use Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: @@ -31,4 +28,4 @@ jobs: - name: Create Repo From Template run: | pip install nox - nox -s test + nox -t test diff --git a/.gitignore b/.gitignore index e1d0cfd..ac5b0c3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ __pycache__ # --- content generated by tests --- test-repo -idom +reactpy diff --git a/LICENSE b/LICENSE index 026d7cd..2b52c7e 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 673ba6c..39b81fc 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: diff --git a/cookiecutter.json b/cookiecutter.json index 3e1b96b..76b2376 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -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" } diff --git a/noxfile.py b/noxfile.py index 29f522a..0c6ca82 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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 @@ -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"): @@ -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) diff --git a/test-config.yaml b/test-config.yaml index 8baa18e..9c0a0e2 100644 --- a/test-config.yaml +++ b/test-config.yaml @@ -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" diff --git a/{{cookiecutter.repository_name}}/js/package-lock.json b/{{cookiecutter.repository_name}}/js/package-lock.json index 0b6a40a..63d6602 100644 --- a/{{cookiecutter.repository_name}}/js/package-lock.json +++ b/{{cookiecutter.repository_name}}/js/package-lock.json @@ -7,7 +7,7 @@ "name": "{{ cookiecutter.npm_package_name }}", "dependencies": { "htm": "^3.0.4", - "idom-client-react": "^0.8.5", + "reactpy-client-react": "^0.8.5", "react": "^17.0.1", "react-dom": "^17.0.1" }, @@ -100,9 +100,9 @@ "resolved": "https://registry.npmjs.org/htm/-/htm-3.1.0.tgz", "integrity": "sha512-L0s3Sid5r6YwrEvkig14SK3Emmc+kIjlfLhEGn2Vy3bk21JyDEes4MoDsbJk6luaPp8bugErnxPz86ZuAw6e5Q==" }, - "node_modules/idom-client-react": { + "node_modules/reactpy-client-react": { "version": "0.8.5", - "resolved": "https://registry.npmjs.org/idom-client-react/-/idom-client-react-0.8.5.tgz", + "resolved": "https://registry.npmjs.org/reactpy-client-react/-/reactpy-client-react-0.8.5.tgz", "integrity": "sha512-/S/J+BPGnQ4YrXWBD0mT0IqigDHrXglTX91qDyIjg6aoQwcprJ8ms9WFwdXcx0/QY85s08+/FP4FnF8lcqwx9w==", "dependencies": { "fast-json-patch": "^3.0.0-1", @@ -380,9 +380,9 @@ "resolved": "https://registry.npmjs.org/htm/-/htm-3.1.0.tgz", "integrity": "sha512-L0s3Sid5r6YwrEvkig14SK3Emmc+kIjlfLhEGn2Vy3bk21JyDEes4MoDsbJk6luaPp8bugErnxPz86ZuAw6e5Q==" }, - "idom-client-react": { + "reactpy-client-react": { "version": "0.8.5", - "resolved": "https://registry.npmjs.org/idom-client-react/-/idom-client-react-0.8.5.tgz", + "resolved": "https://registry.npmjs.org/reactpy-client-react/-/reactpy-client-react-0.8.5.tgz", "integrity": "sha512-/S/J+BPGnQ4YrXWBD0mT0IqigDHrXglTX91qDyIjg6aoQwcprJ8ms9WFwdXcx0/QY85s08+/FP4FnF8lcqwx9w==", "requires": { "fast-json-patch": "^3.0.0-1", diff --git a/{{cookiecutter.repository_name}}/requirements.txt b/{{cookiecutter.repository_name}}/requirements.txt index 7c94c3c..d7a23a1 100644 --- a/{{cookiecutter.repository_name}}/requirements.txt +++ b/{{cookiecutter.repository_name}}/requirements.txt @@ -1,4 +1,4 @@ twine pytest pytest-asyncio -idom[testing,starlette] +reactpy[testing,starlette] diff --git a/{{cookiecutter.repository_name}}/setup.py b/{{cookiecutter.repository_name}}/setup.py index 483a746..511ab28 100644 --- a/{{cookiecutter.repository_name}}/setup.py +++ b/{{cookiecutter.repository_name}}/setup.py @@ -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": [ diff --git a/{{cookiecutter.repository_name}}/tests/conftest.py b/{{cookiecutter.repository_name}}/tests/conftest.py index feab373..8e3fb45 100644 --- a/{{cookiecutter.repository_name}}/tests/conftest.py +++ b/{{cookiecutter.repository_name}}/tests/conftest.py @@ -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: diff --git a/{{cookiecutter.repository_name}}/tests/test_example.py b/{{cookiecutter.repository_name}}/tests/test_example.py index ab986d5..ad1ff50 100644 --- a/{{cookiecutter.repository_name}}/tests/test_example.py +++ b/{{cookiecutter.repository_name}}/tests/test_example.py @@ -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( diff --git a/{{cookiecutter.repository_name}}/{{cookiecutter.python_package_name}}/example.py b/{{cookiecutter.repository_name}}/{{cookiecutter.python_package_name}}/example.py index 2a01f0b..2318b2b 100644 --- a/{{cookiecutter.repository_name}}/{{cookiecutter.python_package_name}}/example.py +++ b/{{cookiecutter.repository_name}}/{{cookiecutter.python_package_name}}/example.py @@ -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(