django-tailwind-cli 2.6.0__tar.gz → 2.7.1__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 (15) hide show
  1. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/PKG-INFO +1 -1
  2. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/pyproject.toml +1 -1
  3. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/management/commands/tailwind.py +85 -7
  4. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/utils.py +29 -8
  5. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/LICENSE +0 -0
  6. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/README.md +0 -0
  7. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/__init__.py +0 -0
  8. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/apps.py +0 -0
  9. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/management/__init__.py +0 -0
  10. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/management/commands/__init__.py +0 -0
  11. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/py.typed +0 -0
  12. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/templates/tailwind_cli/base.html +0 -0
  13. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/templates/tailwind_cli/tailwind_css.html +0 -0
  14. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/templatetags/__init__.py +0 -0
  15. {django_tailwind_cli-2.6.0 → django_tailwind_cli-2.7.1}/src/django_tailwind_cli/templatetags/tailwind_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-tailwind-cli
3
- Version: 2.6.0
3
+ Version: 2.7.1
4
4
  Summary: Django and Tailwind integration based on the prebuilt Tailwind CSS CLI.
5
5
  Home-page: https://django-tailwind-cli.andrich.me/
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "django-tailwind-cli"
3
- version = "2.6.0"
3
+ version = "2.7.1"
4
4
  description = "Django and Tailwind integration based on the prebuilt Tailwind CSS CLI."
5
5
  authors = ["Oliver Andrich <oliver@andrich.me>"]
6
6
  readme = "README.md"
@@ -49,7 +49,30 @@ class Command(BaseCommand):
49
49
  "runserver",
50
50
  help="Start the Django development server and the Tailwind CLI in watch mode.",
51
51
  )
52
-
52
+ parser.add_argument(
53
+ "--ipv6",
54
+ "-6",
55
+ action="store_true",
56
+ dest="use_ipv6",
57
+ help="Tells Django to use an IPv6 address.",
58
+ )
59
+ parser.add_argument(
60
+ "--nothreading",
61
+ action="store_true",
62
+ dest="no_threading",
63
+ help="Tells Django to NOT use threading.",
64
+ )
65
+ parser.add_argument(
66
+ "--noreload",
67
+ action="store_true",
68
+ dest="no_reloader",
69
+ help="Tells Django to NOT use the auto-reloader.",
70
+ )
71
+ runserver_parser.add_argument(
72
+ "--skip-checks",
73
+ action="store_true",
74
+ help="Skip system checks.",
75
+ )
53
76
  runserver_parser.add_argument(
54
77
  "addrport", nargs="?", help="Optional port number, or ipaddr:port"
55
78
  )
@@ -61,11 +84,45 @@ class Command(BaseCommand):
61
84
  "Tailwind CLI in watch mode."
62
85
  ),
63
86
  )
64
-
65
87
  runserver_plus_parser.add_argument(
66
- "addrport", nargs="?", help="Optional port number, or ipaddr:port"
88
+ "--ipv6",
89
+ "-6",
90
+ action="store_true",
91
+ dest="use_ipv6",
92
+ help="Tells Django to use an IPv6 address.",
93
+ )
94
+ runserver_plus_parser.add_argument(
95
+ "--nothreading",
96
+ action="store_true",
97
+ dest="no_threading",
98
+ help="Do not run in multithreaded mode.",
99
+ )
100
+ runserver_plus_parser.add_argument(
101
+ "--noreload",
102
+ action="store_true",
103
+ dest="no_reloader",
104
+ help="Tells Django to NOT use the auto-reloader.",
105
+ )
106
+ runserver_plus_parser.add_argument(
107
+ "--pdb",
108
+ action="store_true",
109
+ help="Drop into pdb shell at the start of any view.",
110
+ )
111
+ runserver_plus_parser.add_argument(
112
+ "--ipdb",
113
+ action="store_true",
114
+ help="Drop into ipdb shell at the start of any view.",
115
+ )
116
+ runserver_plus_parser.add_argument(
117
+ "--pm",
118
+ action="store_true",
119
+ help="Drop into (i)pdb shell if an exception is raised in a view.",
120
+ )
121
+ runserver_plus_parser.add_argument(
122
+ "--print-sql",
123
+ action="store_true",
124
+ help="Print SQL queries as they're executed.",
67
125
  )
68
-
69
126
  runserver_plus_parser.add_argument(
70
127
  "--cert-file", help="Optional SSL certificate file to use for the development server."
71
128
  )
@@ -76,11 +133,13 @@ class Command(BaseCommand):
76
133
  runserver_plus_parser.add_argument(
77
134
  "--key-file", help="Optional SSL certificate file to use for the development server."
78
135
  )
79
-
80
136
  runserver_plus_parser.add_argument(
81
137
  "--reloader-interval",
82
138
  help="Optional SSL certificate file to use for the development server.",
83
139
  )
140
+ runserver_plus_parser.add_argument(
141
+ "addrport", nargs="?", help="Optional port number, or ipaddr:port"
142
+ )
84
143
 
85
144
  def handle(self, *_args: Any, **kwargs: Any) -> None:
86
145
  """Perform the command's actions."""
@@ -154,12 +213,31 @@ class Command(BaseCommand):
154
213
  if addrport := kwargs.get("addrport"):
155
214
  debugserver_cmd.append(addrport)
156
215
 
216
+ if kwargs.get("use_ipv6", False):
217
+ debugserver_cmd.append("--ipv6")
218
+ if kwargs.get("no_threading", False):
219
+ debugserver_cmd.append("--nothreading")
220
+ if kwargs.get("no_reloader", False):
221
+ debugserver_cmd.append("--noreload")
222
+ if kwargs.get("skip_checks", False):
223
+ debugserver_cmd.append("--skip-checks")
224
+
225
+ if kwargs.get("print_sql", False):
226
+ debugserver_cmd.append("--print-sql")
227
+ if kwargs.get("pdb", False):
228
+ debugserver_cmd.append("--pdb")
229
+ if kwargs.get("ipdb", False):
230
+ debugserver_cmd.append("--ipdb")
231
+ if kwargs.get("pm", False):
232
+ debugserver_cmd.append("--pm")
233
+
157
234
  if cert_file := kwargs.get("cert_file"):
158
235
  debugserver_cmd.append(f"--cert-file={cert_file}")
159
236
  elif cert := kwargs.get("cert"):
160
237
  debugserver_cmd.append(f"--cert-file={cert}")
161
238
  if key_file := kwargs.get("key_file"):
162
239
  debugserver_cmd.append(f"--key-file={key_file}")
240
+
163
241
  if reloader_interval := kwargs.get("reloader_interval"):
164
242
  debugserver_cmd.append(f"--reloader-interval={reloader_interval}")
165
243
 
@@ -240,9 +318,9 @@ class Command(BaseCommand):
240
318
 
241
319
  def _download_cli_if_not_exists(self) -> None:
242
320
  dest_file = self.config.get_full_cli_path()
243
- download_url = self.config.get_download_url()
244
321
 
245
- if not dest_file.exists():
322
+ if not dest_file.exists() and self.config.automatic_download:
323
+ download_url = self.config.get_download_url()
246
324
  self.stdout.write(self.style.ERROR("Tailwind CSS CLI not found."))
247
325
  self.stdout.write(
248
326
  self.style.WARNING(f"Downloading Tailwind CSS CLI from '{download_url}'")
@@ -5,6 +5,7 @@ This module contains utility functions to read the configuration, download the C
5
5
  the various paths.
6
6
  """
7
7
 
8
+ import os
8
9
  import platform
9
10
  from pathlib import Path
10
11
  from typing import Tuple, Union
@@ -20,8 +21,15 @@ class Config:
20
21
  return getattr(settings, "TAILWIND_CLI_VERSION", "3.3.5")
21
22
 
22
23
  @property
23
- def cli_path(self) -> Union[str, None]:
24
- return getattr(settings, "TAILWIND_CLI_PATH", "~/.local/bin/")
24
+ def cli_path(self) -> Union[Path, None]:
25
+ p = getattr(settings, "TAILWIND_CLI_PATH", "~/.local/bin/")
26
+ if p is None:
27
+ return p
28
+ return Path(p).expanduser()
29
+
30
+ @property
31
+ def automatic_download(self) -> bool:
32
+ return bool(getattr(settings, "TAILWIND_CLI_AUTOMATIC_DOWNLOAD", True))
25
33
 
26
34
  @property
27
35
  def src_css(self) -> Union[str, None]:
@@ -44,13 +52,13 @@ class Config:
44
52
  def get_system_and_machine(self) -> Tuple[str, str]:
45
53
  """Get the system and machine name."""
46
54
  system = platform.system().lower()
47
- if system == "darwin": # pragma: no cover
55
+ if system == "darwin":
48
56
  system = "macos"
49
57
 
50
58
  machine = platform.machine().lower()
51
- if machine == "x86_64": # pragma: no cover
59
+ if machine in ["x86_64", "amd64"]:
52
60
  machine = "x64"
53
- elif machine == "aarch64": # pragma: no cover
61
+ elif machine == "aarch64":
54
62
  machine = "arm64"
55
63
 
56
64
  return (system, machine)
@@ -58,19 +66,32 @@ class Config:
58
66
  def get_download_url(self) -> str:
59
67
  """Get the download url for the Tailwind CSS CLI."""
60
68
  system, machine = self.get_system_and_machine()
69
+ extension = ".exe" if system == "windows" else ""
61
70
  return (
62
71
  "https://github.com/tailwindlabs/tailwindcss/releases/download/"
63
- f"v{self.tailwind_version}/tailwindcss-{system}-{machine}"
72
+ f"v{self.tailwind_version}/tailwindcss-{system}-{machine}{extension}"
64
73
  )
65
74
 
66
75
  def get_full_cli_path(self) -> Path:
67
76
  """Get path to the Tailwind CSS CLI."""
77
+
78
+ # If Tailwind CSS CLI path points to an existing executable use is.
79
+ if (
80
+ self.cli_path
81
+ and self.cli_path.exists()
82
+ and self.cli_path.is_file()
83
+ and os.access(self.cli_path, os.X_OK)
84
+ ):
85
+ return self.cli_path
86
+
87
+ # Otherwise try to calculate the full cli path as usual.
68
88
  system, machine = self.get_system_and_machine()
69
- executable_name = f"tailwindcss-{system}-{machine}-{self.tailwind_version}"
89
+ extension = ".exe" if system == "windows" else ""
90
+ executable_name = f"tailwindcss-{system}-{machine}-{self.tailwind_version}{extension}"
70
91
  if self.cli_path is None:
71
92
  return Path(settings.BASE_DIR) / executable_name
72
93
  else:
73
- return Path(self.cli_path).expanduser() / executable_name
94
+ return self.cli_path / executable_name
74
95
 
75
96
  def get_full_src_css_path(self) -> Path:
76
97
  """Get path to the source css."""