Skip to content

Commit fafd4c6

Browse files
committed
First commit.
0 parents  commit fafd4c6

125 files changed

Lines changed: 24968 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.py]
4+
indent_style = space
5+
indent_size = 4
6+
7+
[*.{html,css,js}]
8+
indent_style = space
9+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- uses: astral-sh/setup-uv@v7
16+
with:
17+
version: "latest"
18+
19+
- uses: oven-sh/setup-bun@v2
20+
21+
- uses: extractions/setup-just@v3
22+
23+
- name: Install dependencies
24+
run: |
25+
uv sync --extra testing
26+
bun install --frozen-lockfile
27+
28+
- name: Pre-commit (all files)
29+
run: just pre-commit --all-files
30+
31+
- name: Lint (check-only)
32+
run: just lint --no-fix
33+
34+
- name: Install Playwright Chromium + system deps (E2E)
35+
run: uv run playwright install --with-deps chromium
36+
37+
- name: Run all tests
38+
run: just test-all
39+
40+
- name: Verify package builds
41+
run: just build
42+
43+
- name: Upload dist (workflow artifact)
44+
uses: actions/upload-artifact@v6
45+
with:
46+
name: dist-${{ github.run_id }}
47+
path: dist/
48+
49+
- name: Upload Playwright / pytest artifacts on failure
50+
if: failure()
51+
uses: actions/upload-artifact@v6
52+
with:
53+
name: e2e-failures-${{ github.run_id }}
54+
path: test-results/
55+
if-no-files-found: ignore
56+
57+
tox:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v6
61+
- uses: astral-sh/setup-uv@v7
62+
with:
63+
version: "latest"
64+
- uses: oven-sh/setup-bun@v2
65+
- uses: extractions/setup-just@v3
66+
- name: Install dependencies
67+
run: |
68+
uv sync --extra testing
69+
bun install --frozen-lockfile
70+
- name: Tox (multi Django/Wagtail)
71+
run: just tox

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
# Uncomment when PyPI Trusted Publishing is configured (pypi.org → Publishing → Add pending publisher).
11+
# id-token: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- uses: astral-sh/setup-uv@v7
20+
with:
21+
version: "latest"
22+
23+
- name: Build sdist and wheel
24+
run: uv build
25+
26+
- name: Upload dist to GitHub Release
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
files: dist/*
30+
31+
- name: Upload dist as workflow artifact
32+
uses: actions/upload-artifact@v6
33+
with:
34+
name: dist-${{ github.ref_name }}
35+
path: dist/
36+
37+
# --- PyPI: uncomment after Trusted Publisher matches this workflow ---
38+
# - name: Publish to PyPI
39+
# uses: pypa/gh-action-pypi-publish@release/v1
40+
#
41+
# TestPyPI:
42+
# with:
43+
# repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.DS_Store
2+
3+
4+
# Python-generated files
5+
__pycache__/
6+
*.py[oc]
7+
build/
8+
dist/
9+
wheels/
10+
*.egg-info
11+
12+
# Virtual environments
13+
.venv
14+
15+
# Code editors
16+
.cursor/
17+
.vscode/
18+
19+
# Node.js
20+
node_modules/
21+
22+
# Local dev server artefacts
23+
testapp/db.sqlite3
24+
testproject/testapp/db.sqlite3
25+
testapp/staticfiles/
26+
27+
# Wagtail media (MEDIA_ROOT = testproject/media/). Renditions and documents are
28+
# regenerated; ignore everything in original_images/ except fixture files named in
29+
# tests/e2e/fixtures/test_data.json (add a ! line when the fixture references a new original).
30+
testproject/media/images/
31+
testproject/media/documents/
32+
testproject/media/original_images/*
33+
!testproject/media/original_images/7-800x600.png
34+
!testproject/media/original_images/avatar.png
35+
# Stray media if something ran with the wrong cwd (MEDIA_ROOT should be testproject/media/)
36+
/images/
37+
/original_images/

.oxfmtrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": [],
4+
"tabWidth": 2,
5+
"useTabs": false
6+
}

.pre-commit-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# https://pre-commit.com
2+
# Keep `ruff-pre-commit` rev aligned with `ruff` in [project.optional-dependencies] testing.
3+
repos:
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.15.6
6+
hooks:
7+
- id: ruff-format
8+
files: ^(src/|tests/backend/|tests/e2e/|testproject/).+\.(py|pyi)$
9+
10+
- repo: local
11+
hooks:
12+
- id: djlint-reformat
13+
name: djlint (reformat)
14+
language: system
15+
entry: uv run djlint --reformat
16+
files: ^(src/wagtail_inspect/templates/|testproject/).+\.html$
17+
- id: oxfmt
18+
name: oxfmt
19+
language: system
20+
entry: bunx oxfmt
21+
files: ^(src/wagtail_inspect/static/.+\.(js|css)|tests/frontend/.+\.js)$
22+
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.15.6
25+
hooks:
26+
- id: ruff
27+
args: [--fix]
28+
files: ^(src/|tests/backend/|tests/e2e/|testproject/).+\.(py|pyi)$
29+
30+
- repo: local
31+
hooks:
32+
- id: djlint-lint
33+
name: djlint (lint)
34+
language: system
35+
entry: uv run djlint --lint
36+
files: ^(src/wagtail_inspect/templates/|testproject/).+\.html$
37+
- id: oxlint
38+
name: oxlint
39+
language: system
40+
entry: bunx oxlint --fix
41+
files: ^(src/wagtail_inspect/static/.+\.(js|css)|tests/frontend/.+\.js)$

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.0] - 2025-03-26
11+
12+
### Added
13+
14+
- Initial release: block inspection for the Wagtail CMS preview panel.
15+
- Crosshairs control in the editor preview panel and **Inspect blocks** in the userbar on standalone preview pages.
16+
- Preview-only DOM attributes (`data-block-id`, `data-block-type`, `data-block-label`) and admin JSON API for the block map.
17+
- Support for Django 4.2+ and Wagtail 5, 6, and 7 (Python 3.12+).
18+
19+
[Unreleased]: https://github.com/lincolnloop/wagtail-inspect/compare/v0.1.0...HEAD
20+
[0.1.0]: https://github.com/lincolnloop/wagtail-inspect/releases/tag/v0.1.0

Justfile

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# List available recipes
2+
default:
3+
@just --list
4+
5+
# Roots passed to Ruff (Python only)
6+
py_roots := "src tests/backend tests/e2e testproject"
7+
# Roots passed to djlint (HTML templates)
8+
template_roots := "src/wagtail_inspect/templates testproject"
9+
10+
# ---------------------------------------------------------------------------
11+
# Setup
12+
# ---------------------------------------------------------------------------
13+
14+
# Install all dependencies (Python + JavaScript)
15+
install:
16+
uv sync --extra testing
17+
bun install
18+
19+
# Register pre-commit hooks (run once per clone)
20+
pre-commit-install:
21+
uv run pre-commit install
22+
23+
# Run pre-commit on staged files (default) or pass e.g. `--all-files`
24+
pre-commit *args:
25+
uv run pre-commit run {{args}}
26+
27+
# Install Playwright browsers (run once after install)
28+
install-browsers:
29+
uv run playwright install chromium
30+
31+
# ---------------------------------------------------------------------------
32+
# Testing
33+
# ---------------------------------------------------------------------------
34+
35+
# Run backend and frontend tests
36+
test *args:
37+
#!/usr/bin/env bash
38+
pytest_extra=""
39+
bun_extra=""
40+
if echo " {{ args }} " | grep -qw -- "-x"; then
41+
pytest_extra="-x"
42+
bun_extra="--bail"
43+
fi
44+
just test-backend $pytest_extra & just test-frontend $bun_extra
45+
wait
46+
47+
# Run all tests (including E2E)
48+
test-all *args:
49+
#!/usr/bin/env bash
50+
pytest_extra=""
51+
bun_extra=""
52+
if echo " {{ args }} " | grep -qw -- "-x"; then
53+
pytest_extra="-x"
54+
bun_extra="--bail"
55+
fi
56+
just test-backend $pytest_extra & just test-frontend $bun_extra & just test-e2e $pytest_extra
57+
wait
58+
59+
# Run Python/Django tests
60+
test-backend *args:
61+
uv run pytest tests/backend {{ args }}
62+
63+
# Run JavaScript tests with Bun
64+
test-frontend *args:
65+
bun test tests/frontend {{ args }}
66+
67+
# Run JavaScript tests in watch mode
68+
test-frontend-watch:
69+
bun test --watch tests/frontend
70+
71+
# Run E2E tests with Playwright (headless, artifacts captured on failure)
72+
test-e2e *args:
73+
uv run pytest tests/e2e --ds=tests.e2e.settings \
74+
--screenshot=only-on-failure --video=retain-on-failure {{ args }}
75+
76+
# Run E2E tests in headed mode for interactive debugging
77+
test-e2e-headed *args:
78+
uv run pytest tests/e2e --ds=tests.e2e.settings --headed {{ args }}
79+
80+
# Run backend tests against all supported Django/Wagtail version combinations
81+
tox *args:
82+
uvx --with tox-uv tox {{ args }}
83+
84+
# Run backend tests against a single tox environment (e.g. just tox-env py312-django51-wagtail7)
85+
tox-env env *args:
86+
uvx --with tox-uv tox -e {{ env }} {{ args }}
87+
88+
# Run Python tests with coverage report
89+
coverage:
90+
uv run coverage run -m pytest tests/backend -n auto
91+
uv run coverage report
92+
93+
# Ruff, djlint, oxlint (scoped paths). Pass Ruff flags after the recipe name, e.g. `just lint --no-fix` (CI) or `just lint --fix`.
94+
lint *args:
95+
uv run ruff check {{ py_roots }} {{ args }}
96+
uv run djlint {{ template_roots }} --lint
97+
bun run lint:check
98+
99+
# Apply Ruff and oxlint autofixes (same paths as `lint`).
100+
lint-fix *args:
101+
uv run ruff check {{ py_roots }} --fix {{ args }}
102+
uv run djlint {{ template_roots }} --lint
103+
bun run lint
104+
105+
format *args: # Ruff format, djlint reformat, oxfmt (scoped paths)
106+
uv run ruff format {{ py_roots }} {{ args }}
107+
uv run djlint {{ template_roots }} --reformat
108+
bun run format
109+
110+
# ---------------------------------------------------------------------------
111+
# Development
112+
# ---------------------------------------------------------------------------
113+
114+
# Migrate and run the dev server; set LOAD_E2E_FIXTURE=1 to load tests/e2e/fixtures/test_data.json first (skipped if missing or empty)
115+
run:
116+
#!/usr/bin/env bash
117+
set -euo pipefail
118+
uv run python testproject/manage.py migrate
119+
fixture="tests/e2e/fixtures/test_data.json"
120+
if [[ "${LOAD_E2E_FIXTURE:-}" == "1" ]] && [[ -f "$fixture" ]]; then
121+
if uv run python -c "import json, pathlib, sys; d=json.loads(pathlib.Path('$fixture').read_text()); sys.exit(0 if d else 1)"; then
122+
# Wagtail migrate leaves default pages (e.g. path 00010001); fixture pages
123+
# use the same tree paths → UNIQUE on wagtailcore_page.path without a flush.
124+
uv run python testproject/manage.py flush --no-input
125+
uv run python testproject/manage.py loaddata "$fixture"
126+
fi
127+
fi
128+
uv run python testproject/manage.py runserver
129+
130+
# Same as `just run` with LOAD_E2E_FIXTURE=1 (loads test_data.json when non-empty)
131+
run-with-fixture:
132+
#!/usr/bin/env bash
133+
set -euo pipefail
134+
export LOAD_E2E_FIXTURE=1
135+
just run
136+
137+
# Export local Wagtail DB to tests/e2e/fixtures/test_data.json (for E2E tests)
138+
dump-fixture:
139+
uv run python testproject/manage.py dump_test_fixture
140+
141+
# Load E2E fixture into the local dev database (testproject/testapp/db.sqlite3)
142+
load-fixture:
143+
uv run python testproject/manage.py flush --no-input
144+
uv run python testproject/manage.py loaddata tests/e2e/fixtures/test_data.json
145+
146+
# ---------------------------------------------------------------------------
147+
# Build
148+
# ---------------------------------------------------------------------------
149+
150+
# Build the distributable wheel and sdist
151+
build:
152+
uv build
153+
154+
# Remove build artefacts
155+
clean:
156+
rm -rf dist/ build/ *.egg-info src/*.egg-info

0 commit comments

Comments
 (0)