|
| 1 | +# Next Commerce Theme Kit |
| 2 | + |
| 3 | +CLI tool (`ntk`) for building and maintaining storefront themes on the Next Commerce platform. Supports Sass processing via `libsass`. |
| 4 | + |
| 5 | +## Project Structure |
| 6 | + |
| 7 | +``` |
| 8 | +ntk/ |
| 9 | + __main__.py # Entry point |
| 10 | + command.py # All CLI commands (watch, push, pull, checkout, init, list, sass) |
| 11 | + conf.py # Config loading and constants |
| 12 | + decorator.py # @parser_config decorator for command validation |
| 13 | + gateway.py # API client for Next Commerce store |
| 14 | + utils.py # Helpers (get_template_name, progress_bar) |
| 15 | +tests/ |
| 16 | + test_command.py |
| 17 | + test_gateway.py |
| 18 | + test_config.py |
| 19 | + test_installer.py |
| 20 | +``` |
| 21 | + |
| 22 | +## Development Setup |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +- Python 3.10 or higher — check with `python --version` |
| 27 | +- `pip` — usually included with Python |
| 28 | +- On macOS, Python can be installed via [Homebrew](https://brew.sh): `brew install python` |
| 29 | +- On Windows, use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) (recommended) or the [Windows App Store](https://apps.microsoft.com/store/detail/python-310/9PJPW5LDXLZ5) |
| 30 | + |
| 31 | +### First-time Setup |
| 32 | + |
| 33 | +```bash |
| 34 | +# Clone the repo |
| 35 | +git clone https://github.com/29next/theme-kit.git |
| 36 | +cd theme-kit |
| 37 | + |
| 38 | +# Create and activate a virtual environment |
| 39 | +python -m venv venv |
| 40 | +source venv/bin/activate # macOS/Linux |
| 41 | +# venv\Scripts\activate # Windows |
| 42 | + |
| 43 | +# Install the package with test dependencies |
| 44 | +pip install -e ".[test]" |
| 45 | +``` |
| 46 | + |
| 47 | +### Installing the CLI Globally (for end users) |
| 48 | + |
| 49 | +```bash |
| 50 | +pip install next-theme-kit |
| 51 | + |
| 52 | +# Or with pipx (recommended — keeps it isolated) |
| 53 | +pipx install next-theme-kit |
| 54 | +``` |
| 55 | + |
| 56 | +## Running Tests |
| 57 | + |
| 58 | +```bash |
| 59 | +pytest tests/ -v |
| 60 | +pytest --cov=ntk --cov-report xml |
| 61 | +``` |
| 62 | + |
| 63 | +## Key Dependencies |
| 64 | + |
| 65 | +- `watchfiles` — file watching for `ntk watch` (replaced deprecated `watchgod`) |
| 66 | +- `libsass` — Sass/SCSS processing |
| 67 | +- `PyYAML` — config.yml parsing |
| 68 | +- `requests` — HTTP client for store API |
| 69 | + |
| 70 | +## Python Support |
| 71 | + |
| 72 | +Requires Python >= 3.10. Tested against 3.10, 3.11, 3.12, 3.13, 3.14 via tox and GitHub Actions. |
| 73 | + |
| 74 | +## Important Conventions |
| 75 | + |
| 76 | +- Use `asyncio.run()` for async entry points — not `get_event_loop()` (broke in Python 3.12+) |
| 77 | +- `watchfiles.Change` is an `IntEnum` — use `event_type.name.title()` for human-readable log output, not `str(event_type)` |
| 78 | +- `watchfiles` internal logging is suppressed via `logging.getLogger('watchfiles').setLevel(logging.WARNING)` |
| 79 | +- Test dependencies are declared as `extras_require={"test": ...}` in `setup.py` |
0 commit comments