django-tailwind-cli 4.8.1__tar.gz → 4.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.github/dependabot.yml +4 -0
  2. django_tailwind_cli-4.8.3/.github/workflows/dependabot-auto-merge.yml +34 -0
  3. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.github/workflows/release.yml +9 -9
  4. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.github/workflows/test.yml +23 -10
  5. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.pre-commit-config.yaml +5 -5
  6. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/CHANGELOG.md +16 -0
  7. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/CONTRIBUTING.md +2 -2
  8. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/PKG-INFO +1 -1
  9. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/settings.md +2 -0
  10. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/usage.md +5 -3
  11. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/mise.toml +5 -7
  12. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_build.py +20 -13
  13. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_process.py +23 -2
  14. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_source_css.py +10 -5
  15. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/conftest.py +19 -0
  16. django_tailwind_cli-4.8.3/tests/helpers.py +106 -0
  17. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_integration.py +104 -1
  18. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_management_commands.py +43 -0
  19. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/uv.lock +11 -11
  20. django_tailwind_cli-4.8.1/tests/helpers.py +0 -46
  21. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.gitignore +0 -0
  22. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.mise/tasks/dev +0 -0
  23. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/.readthedocs.yml +0 -0
  24. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/CODE_OF_CONDUCT.md +0 -0
  25. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/LICENSE +0 -0
  26. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/README.md +0 -0
  27. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/base_template.md +0 -0
  28. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/changelog.md +0 -0
  29. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/conf.py +0 -0
  30. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/contributing.md +0 -0
  31. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/index.md +0 -0
  32. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/installation.md +0 -0
  33. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/requirements.txt +0 -0
  34. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/template_tags.md +0 -0
  35. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/whitenoise.md +0 -0
  36. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/docs/workflow.md +0 -0
  37. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/pyproject.toml +0 -0
  38. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/__init__.py +0 -0
  39. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/apps.py +0 -0
  40. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/checks.py +0 -0
  41. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/config.py +0 -0
  42. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/__init__.py +0 -0
  43. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/__init__.py +0 -0
  44. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_download.py +0 -0
  45. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_errors.py +0 -0
  46. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_group.py +0 -0
  47. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/_guides.py +0 -0
  48. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/management/commands/tailwind.py +0 -0
  49. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/py.typed +0 -0
  50. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/templates/tailwind_cli/base.html +0 -0
  51. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/templates/tailwind_cli/tailwind_css.html +0 -0
  52. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/templatetags/__init__.py +0 -0
  53. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/templatetags/tailwind_cli.py +0 -0
  54. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/utils/__init__.py +0 -0
  55. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/src/django_tailwind_cli/utils/http.py +0 -0
  56. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/.gitignore +0 -0
  57. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/__init__.py +0 -0
  58. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/assets/css/.gitkeep +0 -0
  59. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/assets/css/tailwind.css +0 -0
  60. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/settings.py +0 -0
  61. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/templates/tests/base.html +0 -0
  62. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/templates/tests/dummy.email +0 -0
  63. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_additional_commands.py +0 -0
  64. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_checks.py +0 -0
  65. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_config.py +0 -0
  66. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_error_scenarios.py +0 -0
  67. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_http.py +0 -0
  68. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tests/test_tailwind_css_tag.py +0 -0
  69. {django_tailwind_cli-4.8.1 → django_tailwind_cli-4.8.3}/tox.ini +0 -0
@@ -6,6 +6,10 @@ updates:
6
6
  interval: "weekly"
7
7
  cooldown:
8
8
  default-days: 7
9
+ groups:
10
+ github-actions:
11
+ patterns:
12
+ - "*"
9
13
 
10
14
  - package-ecosystem: "pip"
11
15
  directory: "/"
@@ -0,0 +1,34 @@
1
+ name: Dependabot auto-merge
2
+
3
+ # pull_request rather than pull_request_target: the job needs no secrets, and
4
+ # Dependabot pull requests honour the permissions block below.
5
+ on:
6
+ pull_request:
7
+
8
+ permissions: {}
9
+
10
+ jobs:
11
+ auto-merge:
12
+ name: Enable auto-merge
13
+ runs-on: ubuntu-latest
14
+ # The pull request author, not github.actor, which a re-run by anyone changes.
15
+ if: github.event.pull_request.user.login == 'dependabot[bot]'
16
+ permissions:
17
+ contents: write # gh pr merge needs it to merge into main
18
+ pull-requests: write # gh pr merge --auto enables auto-merge on the PR
19
+ steps:
20
+ - name: Fetch Dependabot metadata
21
+ id: metadata
22
+ uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
23
+
24
+ # Only action bumps below a major version. PR CI never runs release.yml,
25
+ # so a major bump of an action used there would pass unseen.
26
+ # The main ruleset holds the merge until the ci-ok check passes.
27
+ - name: Enable auto-merge for patch and minor action updates
28
+ if: >-
29
+ steps.metadata.outputs.package-ecosystem == 'github_actions' &&
30
+ steps.metadata.outputs.update-type != 'version-update:semver-major'
31
+ run: gh pr merge --auto --squash "$PR_URL"
32
+ env:
33
+ PR_URL: ${{ github.event.pull_request.html_url }}
34
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -25,7 +25,7 @@ jobs:
25
25
  with:
26
26
  persist-credentials: false
27
27
  - name: Set up Python
28
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
28
+ uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
29
29
  with:
30
30
  python-version: "3.x"
31
31
  - name: Install pypa/build
@@ -34,7 +34,7 @@ jobs:
34
34
  - name: Build a binary wheel and a source tarball
35
35
  run: python3 -m build
36
36
  - name: Store the distribution packages
37
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
37
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
38
38
  with:
39
39
  name: python-package-distributions
40
40
  path: dist/
@@ -58,7 +58,7 @@ jobs:
58
58
  cat release-notes.md
59
59
  - name: Upload release notes
60
60
  if: startsWith(github.ref, 'refs/tags/')
61
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
61
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
62
62
  with:
63
63
  name: release-notes
64
64
  path: release-notes.md
@@ -80,12 +80,12 @@ jobs:
80
80
  id-token: write # IMPORTANT: mandatory for trusted publishing
81
81
  steps:
82
82
  - name: Download all the dists
83
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
83
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
84
84
  with:
85
85
  name: python-package-distributions
86
86
  path: dist/
87
87
  - name: Publish distribution 📦 to PyPI
88
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1.14
88
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
89
89
 
90
90
  github-release:
91
91
  name: >-
@@ -101,12 +101,12 @@ jobs:
101
101
 
102
102
  steps:
103
103
  - name: Download all the dists
104
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
104
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
105
105
  with:
106
106
  name: python-package-distributions
107
107
  path: dist/
108
108
  - name: Download release notes
109
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
109
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
110
110
  with:
111
111
  name: release-notes
112
112
  - name: Sign the dists with Sigstore
@@ -154,12 +154,12 @@ jobs:
154
154
 
155
155
  steps:
156
156
  - name: Download all the dists
157
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
157
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
158
158
  with:
159
159
  name: python-package-distributions
160
160
  path: dist/
161
161
  - name: Publish distribution 📦 to TestPyPI
162
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1.14
162
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
163
163
  with:
164
164
  repository-url: https://test.pypi.org/legacy/
165
165
  skip-existing: true
@@ -18,10 +18,10 @@ jobs:
18
18
  name: Lint
19
19
  runs-on: ubuntu-latest
20
20
 
21
- # pre-commit pins its hook environments to 3.10 (default_language_version),
21
+ # pre-commit pins its hook environments to 3.13 (default_language_version),
22
22
  # and the linters only ever need one interpreter.
23
23
  env:
24
- MISE_PYTHON_VERSION: "3.10"
24
+ MISE_PYTHON_VERSION: "3.13"
25
25
  # tmux only exists for the optional `mise run dev` session, which CI never starts. Disabling
26
26
  # beats limiting install_args, because `mise run` would auto-install it again.
27
27
  MISE_DISABLE_TOOLS: tmux
@@ -32,7 +32,7 @@ jobs:
32
32
  persist-credentials: false
33
33
 
34
34
  - name: Set up mise
35
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
35
+ uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7
36
36
  with:
37
37
  install: true
38
38
  cache: true
@@ -61,11 +61,11 @@ jobs:
61
61
  # which is why the original pre-commit job was dropped back in 2022.
62
62
  # --locked, unlike `mise run bootstrap`: a uv.lock that has drifted from
63
63
  # pyproject.toml should fail the job, not be silently re-resolved into
64
- # something uv-secure then audits instead of the committed lock.
64
+ # something uv-audit then audits instead of the committed lock.
65
65
  - name: Install dependencies
66
66
  run: uv sync --all-extras --locked
67
67
 
68
- # uv-secure audits uv.lock against the published advisories, so a new one
68
+ # uv-audit checks uv.lock against the published advisories, so a new one
69
69
  # can turn an unrelated pull request red. That is deliberate: it is how we
70
70
  # hear about it. Fix the lock rather than skipping the hook.
71
71
  - name: Run pre-commit
@@ -79,7 +79,7 @@ jobs:
79
79
  python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
80
80
 
81
81
  # Job-scoped so every step resolves the same interpreter, not just the
82
- # install step. Prereleases are aliased in mise.toml, so "3.15" resolves.
82
+ # install step.
83
83
  env:
84
84
  MISE_PYTHON_VERSION: ${{ matrix.python-version }}
85
85
  # pre-commit too, unlike the lint job: this one never runs it.
@@ -91,7 +91,7 @@ jobs:
91
91
  persist-credentials: false
92
92
 
93
93
  - name: Set up mise
94
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
94
+ uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7
95
95
  with:
96
96
  install: true
97
97
  cache: true
@@ -126,7 +126,7 @@ jobs:
126
126
  persist-credentials: false
127
127
 
128
128
  - name: Set up mise
129
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
129
+ uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7
130
130
  with:
131
131
  install: true
132
132
  cache: true
@@ -162,7 +162,7 @@ jobs:
162
162
  persist-credentials: false
163
163
 
164
164
  - name: Set up mise
165
- uses: jdx/mise-action@c2a87611a18de5b3828c5652fe268e992400cb5c # v4.3.0
165
+ uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7
166
166
  with:
167
167
  install: true
168
168
  cache: true
@@ -190,4 +190,17 @@ jobs:
190
190
  with:
191
191
  persist-credentials: false
192
192
 
193
- - uses: zizmorcore/zizmor-action@70fb788f84895a7701f5643d103d587e460b5c99 # v0.6.3
193
+ - uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1
194
+
195
+ # The main ruleset requires this one check instead of every job, so a new
196
+ # matrix entry needs no ruleset change. always() is required: a job skipped
197
+ # after a failed dependency reports as passing to a required status check.
198
+ ci-ok:
199
+ name: ci-ok
200
+ if: always()
201
+ needs: [lint, build, coverage, docs, zizmor]
202
+ runs-on: ubuntu-latest
203
+ steps:
204
+ - name: Fail unless every job succeeded
205
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')
206
+ run: exit 1
@@ -1,5 +1,5 @@
1
1
  default_language_version:
2
- python: python3.10
2
+ python: python3.13
3
3
 
4
4
  repos:
5
5
  - repo: https://github.com/pre-commit/pre-commit-hooks
@@ -39,11 +39,11 @@ repos:
39
39
  - id: djade
40
40
  args: [--target-version, "4.2"]
41
41
 
42
- - repo: https://github.com/owenlamont/uv-secure
43
- rev: 0.17.1
42
+ - repo: https://github.com/astral-sh/uv-pre-commit
43
+ rev: 0.13.6
44
44
  hooks:
45
- - id: uv-secure
46
- exclude: ^docs/
45
+ - id: uv-audit
46
+ args: [--preview-features, audit-command]
47
47
 
48
48
  - repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
49
49
  rev: 1.39.0
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.8.3 (2026-11-18)
4
+
5
+ ### 🐛 Bug Fixes
6
+ - **`tailwind watch` keeps watching without a terminal.** The Tailwind 4 CLI stops `--watch` when its stdin closes. A parallel `mise run` task or a container without `tty: true` has no open stdin. There the watcher stopped after the first build. The CLI now reads stdin from a pipe that only the Python process holds. This also fixes `tailwind runserver`, which starts `tailwind watch`.
7
+ - **The Tailwind CLI exits with `tailwind watch` and `tailwind runserver`.** A SIGTERM or SIGINT sent to the command alone left the CLI running. Only Ctrl+C in a terminal, which signals the whole process group, stopped it. Now the CLI exits on both signals.
8
+ - **Generated source CSS uses UTF-8 on every platform.** External app paths containing non-ASCII characters no longer fail to write on Windows, and existing UTF-8 source files can be checked and backed up without decoding errors. Backups preserve the original bytes.
9
+
10
+ ## 4.8.2 (2026-10-27)
11
+
12
+ ### 🐛 Bug Fixes
13
+ - **`tailwind watch` with one stylesheet shows the watcher's output again.** It ran the CLI with its output captured, so rebuild messages and build errors never reached the terminal, and the captured text grew for as long as the watcher ran. Multiple stylesheets were not affected.
14
+
15
+ ### 🛠️ Developer Experience
16
+ - **Python 3.15 is tested against the final release** instead of 3.15.0rc1.
17
+ - **`uv audit` replaces `uv-secure`** in the lint hooks. The `uv-secure` project is archived. `uv audit` checks `uv.lock` but not the installed uv binary.
18
+
3
19
  ## 4.8.1 (2026-09-18)
4
20
 
5
21
  ### 🐛 Bug Fixes
@@ -55,14 +55,14 @@ mise run bootstrap
55
55
  ```bash
56
56
  mise run test # pytest with coverage on the default interpreter
57
57
  mise run test-all # the full Python/Django matrix via tox
58
- mise run lint # pre-commit: ruff, basedpyright, uv-secure, upgrade hooks
58
+ mise run lint # pre-commit: ruff, basedpyright, uv-audit, upgrade hooks
59
59
  ```
60
60
 
61
61
  `mise run test` and `mise run lint` both have to pass before a pull request is ready. `test-all`
62
62
  takes a while; CI runs the matrix on every pull request, so running it locally is optional unless
63
63
  you are touching something version-specific.
64
64
 
65
- One of the lint hooks, `uv-secure`, checks the lock file against published security advisories. If
65
+ One of the lint hooks, `uv-audit`, checks the lock file against published security advisories. If
66
66
  it fails on a dependency your change never touched, a new advisory appeared and the lock needs a
67
67
  bump — mention it in the pull request instead of working around it.
68
68
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: django-tailwind-cli
3
- Version: 4.8.1
3
+ Version: 4.8.3
4
4
  Summary: Django and Tailwind integration based on the prebuilt Tailwind CSS CLI.
5
5
  Project-URL: Home, https://django-tailwind-cli.rtfd.io/
6
6
  Project-URL: Documentation, https://django-tailwind-cli.rtfd.io/
@@ -79,6 +79,8 @@ This setting only affects the **auto-generated** default source CSS. If you set
79
79
 
80
80
  The list of external apps is re-evaluated whenever the source CSS is written. When combined with the `tailwind watch` auto-reloader, installing a new app or editing `INSTALLED_APPS` automatically regenerates the declarations and triggers a Tailwind rebuild.
81
81
 
82
+ Generated source CSS uses UTF-8 on every platform, including when external app paths contain non-ASCII characters.
83
+
82
84
  ### TAILWIND_CLI_USE_SYSTEM_BINARY
83
85
 
84
86
  **Default**: `False`
@@ -34,6 +34,8 @@ Run `python manage.py tailwind watch` to start a Tailwind watcher process on its
34
34
 
35
35
  By default the watch command runs under Django's own auto-reloader (the same one `runserver` uses). Whenever you change a Python file — including `settings.py` — the watcher restarts its Python process, regenerates the default source CSS file (picking up freshly added `INSTALLED_APPS`), and respawns the Tailwind CLI subprocess. This pairs nicely with [`TAILWIND_CLI_AUTO_SOURCE_EXTERNAL_APPS`](settings.md#tailwind_cli_auto_source_external_apps): adding an editable-installed app and updating `INSTALLED_APPS` is enough — no manual restart needed.
36
36
 
37
+ The watch command does not need a terminal or an open stdin. It runs as a parallel task under `mise run` or in a Docker container without `tty: true`. The Tailwind CLI stops watching when its stdin closes. The command therefore gives it a pipe that only the Python process holds. On SIGTERM or SIGINT to `tailwind watch` or `tailwind runserver`, the Tailwind CLI exits too. A SIGKILL to the command skips the cleanup of Django's auto-reloader, and its child process keeps running. With `--noreload`, the Tailwind CLI exits on SIGKILL too.
38
+
37
39
  Pass `--noreload` if you want a single-process watch loop (e.g. in CI or when debugging the watcher itself):
38
40
 
39
41
  ```bash
@@ -130,20 +132,20 @@ Run `python manage.py tailwind remove_cli` to remove the installed CLI binary. T
130
132
 
131
133
  ## Use with Docker Compose
132
134
 
133
- When used in the `watch` mode, the Tailwind CLI requires a TTY-enabled environment to function correctly. In a Docker Compose setup, ensure that the container executing the Tailwind style rebuild command (either `python manage.py tailwind runserver` or `python manage.py tailwind watch`, as noted above) is configured with the `tty: true` setting in your `docker-compose.yml`.
135
+ Both `python manage.py tailwind runserver` and `python manage.py tailwind watch` run in a container without further settings:
134
136
 
135
137
  ```yaml
136
138
  web:
137
139
  command: python manage.py tailwind runserver
138
- tty: true
139
140
 
140
141
  # or
141
142
 
142
143
  tailwind-sidecar:
143
144
  command: python manage.py tailwind watch
144
- tty: true
145
145
  ```
146
146
 
147
+ Versions before 4.8.3 need `tty: true` on that service. Without it the watcher stops right after the first build.
148
+
147
149
  ## Use with WhiteNoise
148
150
 
149
151
  [WhiteNoise](https://whitenoise.readthedocs.io/) works with the defaults of this library and needs no extra configuration. See [Use with WhiteNoise](whitenoise.md) for a sample configuration and the traps around `collectstatic`.
@@ -1,13 +1,11 @@
1
- # 3.15 is unreleased, so bare "3.15" does not resolve. Aliasing it here is the
2
- # single place to bump while CI and the tool list keep saying "3.15".
3
- [tool_alias.python.versions]
4
- "3.15" = "3.15.0rc1"
5
-
6
1
  [tools]
7
2
  # 3.13 is the active default; the rest are installed for the tox matrix.
8
3
  python = ["3.13", "3.10", "3.11", "3.12", "3.14", "3.15"]
9
- uv = "latest"
10
- pre-commit = "latest"
4
+ # Pinned because the CI mise cache key hashes this file, not resolved versions.
5
+ # With "latest", CI kept a cached old uv.
6
+ uv = "0.13.6"
7
+ # pre-commit 4.7 needs Python 3.11+, also for the hook environments it creates.
8
+ pre-commit = "4.7.0"
11
9
  # For `mise run dev`, which runs its own tmux server on a socket named after the project. Every client of
12
10
  # that socket needs this version — a hand-run `tmux -L tailwind-cli attach`, and the dev script itself: its
13
11
  # `has-session` check discards stderr, so a "protocol version mismatch" would surface as the far more
@@ -15,7 +15,7 @@ from django.core.management.base import CommandError
15
15
 
16
16
  from django_tailwind_cli.config import get_config
17
17
  from django_tailwind_cli.management.commands._download import ensure_cli_binary, ensure_default_gitignore
18
- from django_tailwind_cli.management.commands._process import MultiWatchProcessManager
18
+ from django_tailwind_cli.management.commands._process import MultiWatchProcessManager, watcher_stdin
19
19
  from django_tailwind_cli.management.commands._source_css import ensure_source_css
20
20
 
21
21
 
@@ -44,17 +44,21 @@ def run_watch_loop(*, verbose: bool = False) -> None:
44
44
  if verbose:
45
45
  click.secho("🔄 Starting file watcher...", fg="cyan")
46
46
 
47
- if len(config.css_entries) == 1:
48
- execute_tailwind_command(
49
- config.watch_cmd,
50
- success_message="Stopped watching for changes.",
51
- error_message="Failed to start in watch mode",
52
- capture_output=True,
53
- verbose=verbose,
54
- )
55
- else:
56
- manager = MultiWatchProcessManager()
57
- manager.start_watch_processes(config, verbose=verbose)
47
+ with watcher_stdin() as stdin:
48
+ if len(config.css_entries) == 1:
49
+ execute_tailwind_command(
50
+ config.watch_cmd,
51
+ success_message="Stopped watching for changes.",
52
+ error_message="Failed to start in watch mode",
53
+ # The watcher runs until Ctrl+C: its rebuilds and errors belong on the terminal, and a
54
+ # captured pipe would only grow for as long as it runs.
55
+ capture_output=False,
56
+ stdin=stdin,
57
+ verbose=verbose,
58
+ )
59
+ else:
60
+ manager = MultiWatchProcessManager()
61
+ manager.start_watch_processes(config, stdin=stdin, verbose=verbose)
58
62
 
59
63
 
60
64
  def setup_tailwind_environment(*, verbose: bool = False) -> None:
@@ -72,6 +76,7 @@ def execute_tailwind_command(
72
76
  success_message: str,
73
77
  error_message: str,
74
78
  capture_output: bool = True,
79
+ stdin: int | None = None,
75
80
  verbose: bool = False,
76
81
  ) -> bool:
77
82
  """Execute a Tailwind command with consistent error handling and optional verbose output.
@@ -81,6 +86,8 @@ def execute_tailwind_command(
81
86
  success_message: Message to display on success.
82
87
  error_message: Message prefix for errors.
83
88
  capture_output: Whether to capture subprocess output.
89
+ stdin: File descriptor for the command's stdin. Applies only with ``capture_output=False``,
90
+ the watch path. None inherits this process's stdin.
84
91
  verbose: Whether to show detailed execution information.
85
92
 
86
93
  Returns:
@@ -102,7 +109,7 @@ def execute_tailwind_command(
102
109
  click.secho("📤 Command output:", fg="blue")
103
110
  click.echo(result.stdout)
104
111
  else:
105
- subprocess.run(cmd, cwd=settings.BASE_DIR, check=True)
112
+ subprocess.run(cmd, cwd=settings.BASE_DIR, check=True, stdin=stdin)
106
113
 
107
114
  if verbose:
108
115
  end_time = time.time()
@@ -8,13 +8,15 @@ one place and the two entry points differ only in what they start and how they r
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
+ import os
11
12
  import re
12
13
  import signal
13
14
  import sys
14
15
  import subprocess
15
16
  import threading
16
17
  import time
17
- from collections.abc import Callable
18
+ from collections.abc import Callable, Iterator
19
+ from contextlib import contextmanager
18
20
  from types import FrameType
19
21
  from typing import IO
20
22
 
@@ -51,6 +53,23 @@ _BUN_NOISE = re.compile(
51
53
  _WATCH_SPAWN_STAGGER_S = 0.3
52
54
 
53
55
 
56
+ @contextmanager
57
+ def watcher_stdin() -> Iterator[int]:
58
+ """Yield the read end of a pipe whose write end only this process holds, as a watcher's stdin.
59
+
60
+ The Tailwind 4 CLI ends `--watch` when its stdin reaches EOF. An inherited stdin can be at EOF
61
+ from the start, for example in a parallel `mise run` task. This pipe reaches EOF only when its
62
+ write end closes. That happens on leaving this block or when this process dies, also by
63
+ SIGKILL. The CLI then stops watching, so it does not outlive this process.
64
+ """
65
+ read_fd, write_fd = os.pipe()
66
+ try:
67
+ yield read_fd
68
+ finally:
69
+ os.close(write_fd)
70
+ os.close(read_fd)
71
+
72
+
54
73
  def _is_bun_noise(line: str) -> bool:
55
74
  """Return True if the line looks like a Bun native-runtime crash trace."""
56
75
  return bool(_BUN_NOISE.match(line))
@@ -195,11 +214,12 @@ class MultiWatchProcessManager(_BaseProcessManager):
195
214
  def _exit_notice(self, index: int, returncode: int) -> str:
196
215
  return f"Watch process {index} exited with code {returncode}"
197
216
 
198
- def start_watch_processes(self, config: Config, *, verbose: bool = False) -> None:
217
+ def start_watch_processes(self, config: Config, *, stdin: int | None = None, verbose: bool = False) -> None:
199
218
  """Start watch processes for all CSS entries.
200
219
 
201
220
  Args:
202
221
  config: Configuration object with css_entries.
222
+ stdin: File descriptor for every watcher's stdin, see `watcher_stdin`. None inherits it.
203
223
  verbose: Whether to show detailed information.
204
224
  """
205
225
  # SIGINT propagates as KeyboardInterrupt via Python's default handler.
@@ -228,6 +248,7 @@ class MultiWatchProcessManager(_BaseProcessManager):
228
248
  watch_cmd,
229
249
  cwd=settings.BASE_DIR,
230
250
  text=True,
251
+ stdin=stdin,
231
252
  stderr=subprocess.PIPE,
232
253
  )
233
254
  self.processes.append(process)
@@ -36,7 +36,7 @@ def _should_recreate_file(file_path: Path, content: str) -> bool:
36
36
  return True
37
37
 
38
38
  try:
39
- current_content = file_path.read_text()
39
+ current_content = file_path.read_text(encoding="utf-8")
40
40
  if current_content != content:
41
41
  return True
42
42
  except (OSError, UnicodeDecodeError):
@@ -165,7 +165,7 @@ def _preserve_hand_edits(src_css: Path) -> None:
165
165
  managed directory, which carries its own ``.gitignore``.
166
166
  """
167
167
  backup = src_css.with_suffix(".css.bak")
168
- backup.write_text(src_css.read_text())
168
+ backup.write_bytes(src_css.read_bytes())
169
169
 
170
170
  click.secho(
171
171
  f"⚠️ '{src_css}' has hand edits that are about to be replaced.",
@@ -239,14 +239,19 @@ def _ensure_one_source_css(src_css: Path, content: str, *, manages_the_file: boo
239
239
  click.secho("⏭️ Source CSS file is up-to-date, no changes needed", fg="green")
240
240
  return False
241
241
 
242
- if manages_the_file and src_css.exists() and not _looks_auto_generated(src_css.read_text()):
243
- _preserve_hand_edits(src_css)
242
+ if manages_the_file and src_css.exists():
243
+ try:
244
+ generated = _looks_auto_generated(src_css.read_text(encoding="utf-8"))
245
+ except UnicodeDecodeError:
246
+ generated = False
247
+ if not generated:
248
+ _preserve_hand_edits(src_css)
244
249
 
245
250
  if verbose:
246
251
  click.secho("📝 Creating/updating source CSS file...", fg="cyan")
247
252
 
248
253
  src_css.parent.mkdir(parents=True, exist_ok=True)
249
- src_css.write_text(content)
254
+ src_css.write_text(content, encoding="utf-8")
250
255
 
251
256
  if verbose:
252
257
  click.secho(f"✅ Created directory: {src_css.parent}", fg="green")
@@ -1,6 +1,7 @@
1
1
  """Shared fixtures for the test suite."""
2
2
 
3
3
  import hashlib
4
+ import os
4
5
  import socket
5
6
  from collections.abc import Iterator
6
7
  from pathlib import Path
@@ -188,6 +189,24 @@ def no_writes_into_the_checkout() -> Iterator[None]:
188
189
  )
189
190
 
190
191
 
192
+ @pytest.fixture
193
+ def stdin_from_dev_null() -> Iterator[None]:
194
+ """Point file descriptor 0 at /dev/null, as a task runner without a terminal does.
195
+
196
+ pytest's default fd capture does the same. Under ``-s``, fd 0 is the terminal instead.
197
+ This fixture makes the test independent of the capture mode.
198
+ """
199
+ saved = os.dup(0)
200
+ devnull = os.open(os.devnull, os.O_RDONLY)
201
+ os.dup2(devnull, 0)
202
+ os.close(devnull)
203
+ try:
204
+ yield
205
+ finally:
206
+ os.dup2(saved, 0)
207
+ os.close(saved)
208
+
209
+
191
210
  @pytest.fixture
192
211
  def stub_subprocess_run(mocker: MockerFixture) -> MagicMock:
193
212
  """A `subprocess.run` that succeeds and says nothing.
@@ -0,0 +1,106 @@
1
+ """Helpers shared across test modules.
2
+
3
+ Plain functions live here rather than in ``conftest.py``: pytest loads that module itself, and
4
+ importing from it is a pytest anti-pattern. Fixtures still belong in ``conftest.py``.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import sys
10
+ from collections.abc import Callable
11
+ from pathlib import Path
12
+
13
+
14
+ def write_fake_cli(
15
+ url: str,
16
+ filepath: Path,
17
+ timeout: int = 30,
18
+ progress_callback: Callable[[int, int, float], None] | None = None,
19
+ *,
20
+ content: bytes = b"fake-cli-binary",
21
+ ) -> None:
22
+ """Stand-in for ``http.download_with_progress`` that just puts bytes at the target path.
23
+
24
+ The signature mirrors the real function because it is installed as a ``side_effect``, so it is
25
+ called with the production call's arguments. ``content`` is keyword-only, which keeps it clear
26
+ of that call.
27
+
28
+ No chmod: the caller does that itself right after the download returns
29
+ (``ensure_cli_binary``), so a stub that sets the mode only hides whether it does.
30
+
31
+ Args:
32
+ content: Bytes to write. Tests that assert on the file's content pass their own.
33
+ """
34
+ filepath.parent.mkdir(parents=True, exist_ok=True)
35
+ filepath.write_bytes(content)
36
+
37
+
38
+ def install_fake_cli(path: Path, *, content: bytes = b"fake-cli-binary") -> Path:
39
+ """Put an executable fake CLI binary at ``path``, as if it had already been installed.
40
+
41
+ Not the same function as ``write_fake_cli``, and the chmod is why — see its docstring above.
42
+ This one claims the binary is already there, so the executable bit is part of the claim.
43
+ """
44
+ path.parent.mkdir(parents=True, exist_ok=True)
45
+ path.write_bytes(content)
46
+ path.chmod(0o755)
47
+ return path
48
+
49
+
50
+ # Shared start of the fake CLIs below: answer `--help` with a version line, otherwise find `--output`.
51
+ _FAKE_CLI_PREAMBLE = """\
52
+ import os
53
+ import select
54
+ import sys
55
+
56
+ if "--watch" not in sys.argv:
57
+ print("tailwindcss v4.0.0")
58
+ sys.exit(0)
59
+ output_path = sys.argv[sys.argv.index("--output") + 1]
60
+ os.makedirs(os.path.dirname(output_path), exist_ok=True)
61
+ """
62
+
63
+ _STDIN_PROBE_TAIL = """\
64
+ ready, _, _ = select.select([sys.stdin], [], [], 0.1)
65
+ state = "eof" if ready and sys.stdin.buffer.read(1) == b"" else "open"
66
+ with open(output_path, "w") as output:
67
+ output.write(state)
68
+ """
69
+
70
+ _STDIN_WAIT_TAIL = """\
71
+ with open(output_path, "w") as output:
72
+ output.write(str(os.getpid()))
73
+ sys.stdin.buffer.read()
74
+ """
75
+
76
+
77
+ def _install_python_cli(path: Path, tail: str) -> Path:
78
+ """Put an executable fake CLI at ``path`` that runs the preamble plus ``tail`` with this interpreter.
79
+
80
+ A ``/bin/sh`` wrapper rather than a ``#!python`` shebang: the kernel rejects a shebang with
81
+ spaces in the interpreter path or one longer than its limit.
82
+ """
83
+ script_path = path.with_name(f"{path.name}.py")
84
+ script_path.parent.mkdir(parents=True, exist_ok=True)
85
+ script_path.write_text(_FAKE_CLI_PREAMBLE + tail)
86
+ wrapper = f'#!/bin/sh\nexec "{sys.executable}" -I -S "{script_path}" "$@"\n'
87
+ return install_fake_cli(path, content=wrapper.encode())
88
+
89
+
90
+ def install_stdin_probe_cli(path: Path) -> Path:
91
+ """Put an executable fake CLI at ``path`` that reports its stdin state when watching.
92
+
93
+ The Tailwind 4 CLI ends ``--watch`` once stdin reaches EOF. This fake writes ``eof`` or
94
+ ``open`` to its ``--output`` file instead, then exits so the watch command returns.
95
+ POSIX only: ``select()`` on a pipe is not available on Windows.
96
+ """
97
+ return _install_python_cli(path, _STDIN_PROBE_TAIL)
98
+
99
+
100
+ def install_stdin_wait_cli(path: Path) -> Path:
101
+ """Put an executable fake CLI at ``path`` that watches until its stdin reaches EOF.
102
+
103
+ It writes its PID to its ``--output`` file, then blocks on stdin, as the Tailwind 4 CLI does.
104
+ POSIX only.
105
+ """
106
+ return _install_python_cli(path, _STDIN_WAIT_TAIL)
@@ -9,7 +9,11 @@ import io
9
9
  import os
10
10
  import platform
11
11
  import signal
12
+ import subprocess
13
+ import sys
12
14
  import threading
15
+ import time
16
+ from collections.abc import Callable
13
17
  from pathlib import Path
14
18
  from unittest.mock import Mock, patch
15
19
 
@@ -34,7 +38,7 @@ from django_tailwind_cli.management.commands._source_css import (
34
38
  DEFAULT_SOURCE_CSS,
35
39
  )
36
40
  from django_tailwind_cli.management.commands.tailwind import run_watch_loop
37
- from tests.helpers import write_fake_cli
41
+ from tests.helpers import install_stdin_probe_cli, install_stdin_wait_cli, write_fake_cli
38
42
 
39
43
 
40
44
  def _clear_legacy_css_settings(settings: LazySettings) -> None:
@@ -345,6 +349,26 @@ class TestWatchModeIntegration:
345
349
  assert not worker.is_alive(), "run_watch_loop did not terminate within 5s"
346
350
  assert not errors, f"run_watch_loop crashed in worker thread: {errors[0]!r}"
347
351
 
352
+ @pytest.mark.skipif(sys.platform == "win32", reason="select() does not accept pipes on Windows")
353
+ @pytest.mark.usefixtures("stdin_from_dev_null")
354
+ @pytest.mark.parametrize("css_map", [None, [("admin.css", "admin.output.css"), ("web.css", "web.output.css")]])
355
+ def test_watcher_stdin_stays_open_without_terminal(
356
+ self, settings: LazySettings, tmp_project: Path, mocker: MockerFixture, css_map: list[tuple[str, str]] | None
357
+ ):
358
+ """The Tailwind 4 CLI ends `--watch` on stdin EOF, which happens at once under `mise run`."""
359
+ if css_map:
360
+ settings.TAILWIND_CLI_CSS_MAP = css_map
361
+ _clear_legacy_css_settings(settings)
362
+ for src, _ in css_map:
363
+ (tmp_project / src).write_text('@import "tailwindcss";')
364
+ mocker.patch("django_tailwind_cli.management.commands._process._WATCH_SPAWN_STAGGER_S", 0)
365
+ install_stdin_probe_cli(settings.TAILWIND_CLI_PATH)
366
+
367
+ run_watch_loop()
368
+
369
+ entries = get_config().css_entries
370
+ assert [entry.dist_css.read_text() for entry in entries] == ["open"] * len(entries)
371
+
348
372
  @pytest.mark.parametrize(
349
373
  "entry_count,expected_staggers",
350
374
  [(2, 1), (3, 2), (4, 3)],
@@ -402,6 +426,85 @@ class TestWatchModeIntegration:
402
426
  assert "Stopped watching for changes." in captured.out
403
427
 
404
428
 
429
+ # Runs `run_watch_loop` in its own process, so the test can SIGKILL it. argv: BASE_DIR, "single" or "multi".
430
+ # Starts from tests.settings, as the suite does, and points the project at BASE_DIR like `tmp_project`.
431
+ _WATCH_PROCESS_SCRIPT = """\
432
+ import sys
433
+ from pathlib import Path
434
+
435
+ import django
436
+ from django.conf import settings
437
+
438
+ base = Path(sys.argv[1])
439
+ settings.BASE_DIR = base
440
+ settings.STATICFILES_DIRS = (base / "assets",)
441
+ settings.TAILWIND_CLI_PATH = base / "tailwindcss"
442
+ settings.TAILWIND_CLI_VERSION = "4.0.0"
443
+ if sys.argv[2] == "multi":
444
+ settings.TAILWIND_CLI_CSS_MAP = [("admin.css", "admin.output.css"), ("web.css", "web.output.css")]
445
+ django.setup()
446
+
447
+ from django_tailwind_cli.management.commands._build import run_watch_loop
448
+
449
+ run_watch_loop()
450
+ """
451
+
452
+
453
+ def _wait_for(condition: Callable[[], bool], what: str, timeout: float = 10) -> None:
454
+ deadline = time.monotonic() + timeout
455
+ while not condition():
456
+ assert time.monotonic() < deadline, f"timed out waiting for {what}"
457
+ time.sleep(0.05)
458
+
459
+
460
+ def _is_running(pid: int) -> bool:
461
+ try:
462
+ os.kill(pid, 0)
463
+ except ProcessLookupError:
464
+ return False
465
+ return True
466
+
467
+
468
+ @pytest.mark.skipif(sys.platform == "win32", reason="POSIX signals and pipes")
469
+ @pytest.mark.timeout(30)
470
+ @pytest.mark.parametrize(
471
+ "mode,outputs",
472
+ [("single", ["css/tailwind.css"]), ("multi", ["admin.output.css", "web.output.css"])],
473
+ )
474
+ def test_watcher_exits_when_the_watch_process_is_killed(tmp_path: Path, mode: str, outputs: list[str]):
475
+ """A watcher must not outlive the Python process that started it, even after SIGKILL."""
476
+ install_stdin_wait_cli(tmp_path / "tailwindcss")
477
+ (tmp_path / "admin.css").write_text('@import "tailwindcss";')
478
+ (tmp_path / "web.css").write_text('@import "tailwindcss";')
479
+ pid_files = [tmp_path / "assets" / output for output in outputs]
480
+ # The test holds this stdin open, as a terminal does, so only the watch command can end the watcher.
481
+ terminal_read, terminal_write = os.pipe()
482
+ watch_process = subprocess.Popen(
483
+ [sys.executable, "-c", _WATCH_PROCESS_SCRIPT, str(tmp_path), mode],
484
+ cwd=Path(__file__).resolve().parent.parent,
485
+ env={**os.environ, "DJANGO_SETTINGS_MODULE": "tests.settings"},
486
+ stdin=terminal_read,
487
+ stdout=subprocess.DEVNULL,
488
+ stderr=subprocess.DEVNULL,
489
+ )
490
+ os.close(terminal_read)
491
+ cli_pids: list[int] = []
492
+ try:
493
+ _wait_for(lambda: all(f.exists() and f.read_text() for f in pid_files), "the watchers to start")
494
+ cli_pids = [int(f.read_text()) for f in pid_files]
495
+
496
+ watch_process.kill()
497
+ watch_process.wait()
498
+
499
+ _wait_for(lambda: not any(_is_running(pid) for pid in cli_pids), "the watchers to exit", timeout=5)
500
+ finally:
501
+ os.close(terminal_write)
502
+ watch_process.kill()
503
+ watch_process.wait()
504
+ for pid in filter(_is_running, cli_pids):
505
+ os.kill(pid, signal.SIGKILL)
506
+
507
+
405
508
  class TestProcessManagerIntegration:
406
509
  """Test ProcessManager for runserver integration."""
407
510
 
@@ -244,6 +244,14 @@ class TestSubprocessCommands:
244
244
  # Should call subprocess for watch mode
245
245
  assert self.mock_subprocess_run.call_count >= 1
246
246
 
247
+ @pytest.mark.timeout(5)
248
+ def test_watch_streams_output(self):
249
+ """A single watcher writes straight to the terminal; captured output would never be shown."""
250
+ call_command("tailwind", "watch")
251
+
252
+ self.mock_subprocess_run.assert_called_once()
253
+ assert not self.mock_subprocess_run.call_args.kwargs.get("capture_output")
254
+
247
255
  @pytest.mark.timeout(5)
248
256
  def test_watch_with_keyboard_interrupt(self, capsys: CaptureFixture[str]):
249
257
  """Test watch command handling of KeyboardInterrupt."""
@@ -702,6 +710,41 @@ pytestmark = [
702
710
  ]
703
711
 
704
712
 
713
+ class TestSourceCssEncoding:
714
+ @pytest.mark.parametrize("already_exists", [False, True])
715
+ def test_generated_unicode_source_is_written_once(self, tmp_path: Path, already_exists: bool):
716
+ from django_tailwind_cli.management.commands._source_css import _ensure_one_source_css
717
+
718
+ src_css = tmp_path / "source.css"
719
+ content = f'{DEFAULT_SOURCE_CSS}\n{AUTO_SOURCE_COMMENT}\n@source "/editable/\u0645\u0644\u0641\u0627\u062a";\n'
720
+ if already_exists:
721
+ src_css.write_bytes(content.encode("utf-8"))
722
+
723
+ assert _ensure_one_source_css(src_css, content, manages_the_file=True, verbose=False) is not already_exists
724
+ assert src_css.read_text(encoding="utf-8") == content
725
+ assert not _ensure_one_source_css(src_css, content, manages_the_file=True, verbose=False)
726
+ assert not src_css.with_suffix(".css.bak").exists()
727
+
728
+ @pytest.mark.parametrize(
729
+ "edited_bytes",
730
+ [
731
+ f'{DEFAULT_SOURCE_CSS}@source "../\u0645\u0644\u0641\u0627\u062a";\n'.encode(),
732
+ b'@import "tailwindcss";\n@source "../caf\xe9";\n',
733
+ ],
734
+ ids=["utf8", "legacy-encoding"],
735
+ )
736
+ def test_hand_edits_are_backed_up_without_changing_bytes(self, tmp_path: Path, edited_bytes: bytes):
737
+ from django_tailwind_cli.management.commands._source_css import _ensure_one_source_css
738
+
739
+ src_css = tmp_path / "source.css"
740
+ src_css.write_bytes(edited_bytes)
741
+
742
+ assert _ensure_one_source_css(src_css, DEFAULT_SOURCE_CSS, manages_the_file=True, verbose=False)
743
+
744
+ assert src_css.with_suffix(".css.bak").read_bytes() == edited_bytes
745
+ assert src_css.read_text(encoding="utf-8") == DEFAULT_SOURCE_CSS
746
+
747
+
705
748
  class TestSourceCssOverwriteWarning:
706
749
  """The managed source.css is overwritten; hand edits should not vanish silently."""
707
750
 
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 5
3
3
  requires-python = ">=3.10"
4
4
  resolution-markers = [
5
5
  "python_full_version >= '3.12'",
@@ -193,7 +193,7 @@ wheels = [
193
193
 
194
194
  [[package]]
195
195
  name = "django"
196
- version = "6.1"
196
+ version = "6.1.1"
197
197
  source = { registry = "https://pypi.org/simple" }
198
198
  resolution-markers = [
199
199
  "python_full_version >= '3.12'",
@@ -203,9 +203,9 @@ dependencies = [
203
203
  { name = "sqlparse" },
204
204
  { name = "tzdata", marker = "sys_platform == 'win32'" },
205
205
  ]
206
- sdist = { url = "https://files.pythonhosted.org/packages/e2/42/6cb20996733984c1f6661daeda3877990836c76c633c6c8879d39f7120eb/django-6.1.tar.gz", hash = "sha256:86a2aacd59b817e4d6ac2ebfe22356c58f66f7b24e503f71b7c2fead677ee48b", size = 11223034, upload-time = "2026-08-05T19:21:53.789Z" }
206
+ sdist = { url = "https://files.pythonhosted.org/packages/f8/d4/8314b5bdef20832f0ac6ae3b3e4d4924e4759fa3b4af27609dd747e7a6be/django-6.1.1.tar.gz", hash = "sha256:7ab93536d8e677aa14554c56426290c69480bf2ee68d7513d4a22f57d6bfeb84", size = 11284905, upload-time = "2026-09-02T17:20:45.621Z" }
207
207
  wheels = [
208
- { url = "https://files.pythonhosted.org/packages/91/9c/ce847620134cfab903e75690c498af73b46abbede2912ea89bd76d5c1e76/django-6.1-py3-none-any.whl", hash = "sha256:6c132cd980c9392b06807d4ca52d72530d631dc65a85d9dacede00a780cefbbe", size = 8417399, upload-time = "2026-08-05T19:21:47.285Z" },
208
+ { url = "https://files.pythonhosted.org/packages/8d/ca/c1040a4fd15754ede7df15fd72fc2e123045b473b253ab5f5284e11c651e/django-6.1.1-py3-none-any.whl", hash = "sha256:585fb82bf15053c42cf52e67c2f1b54a032dca384759315fd6678ab1870d1d72", size = 8419512, upload-time = "2026-09-02T17:20:39.153Z" },
209
209
  ]
210
210
 
211
211
  [[package]]
@@ -226,7 +226,7 @@ version = "4.1"
226
226
  source = { registry = "https://pypi.org/simple" }
227
227
  dependencies = [
228
228
  { name = "django", version = "5.2.17", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
229
- { name = "django", version = "6.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
229
+ { name = "django", version = "6.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
230
230
  ]
231
231
  sdist = { url = "https://files.pythonhosted.org/packages/6d/b3/ed0f54ed706ec0b54fd251cc0364a249c6cd6c6ec97f04dc34be5e929eac/django_extensions-4.1.tar.gz", hash = "sha256:7b70a4d28e9b840f44694e3f7feb54f55d495f8b3fa6c5c0e5e12bcb2aa3cdeb", size = 283078, upload-time = "2025-04-11T01:15:39.617Z" }
232
232
  wheels = [
@@ -262,7 +262,7 @@ resolution-markers = [
262
262
  ]
263
263
  dependencies = [
264
264
  { name = "django", version = "5.2.17", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
265
- { name = "django", version = "6.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
265
+ { name = "django", version = "6.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
266
266
  { name = "django-stubs-ext", version = "6.1.0", source = { registry = "https://pypi.org/simple" } },
267
267
  { name = "types-pyyaml" },
268
268
  { name = "typing-extensions" },
@@ -298,7 +298,7 @@ resolution-markers = [
298
298
  ]
299
299
  dependencies = [
300
300
  { name = "django", version = "5.2.17", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
301
- { name = "django", version = "6.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
301
+ { name = "django", version = "6.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
302
302
  { name = "typing-extensions" },
303
303
  ]
304
304
  sdist = { url = "https://files.pythonhosted.org/packages/e6/40/75dd6650c5fc345b9edaebe42085811096e31a502fdbe17a52ffb9640d03/django_stubs_ext-6.1.0.tar.gz", hash = "sha256:d5635a481f5bdf2e04d533a8b602d3b9a28f073deffc85b83048dd20032e4d20", size = 6848, upload-time = "2026-08-12T10:54:44.47Z" }
@@ -312,7 +312,7 @@ source = { editable = "." }
312
312
  dependencies = [
313
313
  { name = "click" },
314
314
  { name = "django", version = "5.2.17", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
315
- { name = "django", version = "6.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
315
+ { name = "django", version = "6.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
316
316
  { name = "django-click" },
317
317
  { name = "semver" },
318
318
  ]
@@ -718,12 +718,12 @@ wheels = [
718
718
 
719
719
  [[package]]
720
720
  name = "werkzeug"
721
- version = "3.1.8"
721
+ version = "3.1.9"
722
722
  source = { registry = "https://pypi.org/simple" }
723
723
  dependencies = [
724
724
  { name = "markupsafe" },
725
725
  ]
726
- sdist = { url = "https://files.pythonhosted.org/packages/dd/b2/381be8cfdee792dd117872481b6e378f85c957dd7c5bca38897b08f765fd/werkzeug-3.1.8.tar.gz", hash = "sha256:9bad61a4268dac112f1c5cd4630a56ede601b6ed420300677a869083d70a4c44", size = 875852, upload-time = "2026-04-02T18:49:14.268Z" }
726
+ sdist = { url = "https://files.pythonhosted.org/packages/a4/34/4dd12fc8bb7d61c91467ec3efe415ffa7d5456f799954b40c5bbaeae470e/werkzeug-3.1.9.tar.gz", hash = "sha256:55ca7c70a75689be937aa27f8ff4b018f06ff4838fc73045560bf0f5a1291060", size = 940188, upload-time = "2026-09-27T18:33:41.637Z" }
727
727
  wheels = [
728
- { url = "https://files.pythonhosted.org/packages/93/8c/2e650f2afeb7ee576912636c23ddb621c91ac6a98e66dc8d29c3c69446e1/werkzeug-3.1.8-py3-none-any.whl", hash = "sha256:63a77fb8892bf28ebc3178683445222aa500e48ebad5ec77b0ad80f8726b1f50", size = 226459, upload-time = "2026-04-02T18:49:12.72Z" },
728
+ { url = "https://files.pythonhosted.org/packages/a1/38/df03f564f43cec2684823f3cccae1a652ee7face1cbaa76fb223096e64d7/werkzeug-3.1.9-py3-none-any.whl", hash = "sha256:6392e50c78460ba618e5b21f08a71f59c99ce99cdc6cf6e3dd7e6ccca8754fab", size = 228700, upload-time = "2026-09-27T18:33:39.685Z" },
729
729
  ]
@@ -1,46 +0,0 @@
1
- """Helpers shared across test modules.
2
-
3
- Plain functions live here rather than in ``conftest.py``: pytest loads that module itself, and
4
- importing from it is a pytest anti-pattern. Fixtures still belong in ``conftest.py``.
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- from collections.abc import Callable
10
- from pathlib import Path
11
-
12
-
13
- def write_fake_cli(
14
- url: str,
15
- filepath: Path,
16
- timeout: int = 30,
17
- progress_callback: Callable[[int, int, float], None] | None = None,
18
- *,
19
- content: bytes = b"fake-cli-binary",
20
- ) -> None:
21
- """Stand-in for ``http.download_with_progress`` that just puts bytes at the target path.
22
-
23
- The signature mirrors the real function because it is installed as a ``side_effect``, so it is
24
- called with the production call's arguments. ``content`` is keyword-only, which keeps it clear
25
- of that call.
26
-
27
- No chmod: the caller does that itself right after the download returns
28
- (``ensure_cli_binary``), so a stub that sets the mode only hides whether it does.
29
-
30
- Args:
31
- content: Bytes to write. Tests that assert on the file's content pass their own.
32
- """
33
- filepath.parent.mkdir(parents=True, exist_ok=True)
34
- filepath.write_bytes(content)
35
-
36
-
37
- def install_fake_cli(path: Path, *, content: bytes = b"fake-cli-binary") -> Path:
38
- """Put an executable fake CLI binary at ``path``, as if it had already been installed.
39
-
40
- Not the same function as ``write_fake_cli``, and the chmod is why — see its docstring above.
41
- This one claims the binary is already there, so the executable bit is part of the claim.
42
- """
43
- path.parent.mkdir(parents=True, exist_ok=True)
44
- path.write_bytes(content)
45
- path.chmod(0o755)
46
- return path