From 22e0129a701cff25c74042090de392c80c53fb83 Mon Sep 17 00:00:00 2001 From: HushmKun Date: Tue, 18 Feb 2025 17:37:57 +0200 Subject: [PATCH] - Refactored the runserver_plus out of the runserver command. - Removed the remenants of `runserver_plus` from the docs & tests. --- README.md | 3 +- docs/usage.md | 5 +- .../management/commands/tailwind.py | 58 ++++--------------- tests/test_management_commands.py | 3 - 4 files changed, 14 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 97fd817..66a1614 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,7 @@ The goal of this library is to provided the simplest possible Tailwind integrati Enjoy! Checkout the detailed [installation guide](https://django-tailwind-cli.rtfd.io/latest/installation/) -if you want to activate browser reload or the `runserver_plus` management command known from -`django-extensions`. +if you want to activate browser reload. ## Features diff --git a/docs/usage.md b/docs/usage.md index ee7b0c1..65688af 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -45,9 +45,6 @@ Usage: manage.py tailwind runserver Run the development server with Tailwind CSS CLI in watch mode. - If django-extensions is installed along with this library, this command runs - the runserver_plus command from django-extensions. Otherwise it runs the - default runserver command. Arguments: [ADDRPORT] Optional port number, or ipaddr:port @@ -89,7 +86,7 @@ Options: ### watch -Run `python manage.py tailwind watch` to just start a tailwind watcher process if you prefer to start your debug server in a seperate shell or prefer a different solution than runserver or runserver_plus. +Run `python manage.py tailwind watch` to just start a tailwind watcher process if you prefer to start your debug server in a seperate shell or prefer a different solution than runserver. ## Use with Docker Compose diff --git a/src/django_tailwind_cli/management/commands/tailwind.py b/src/django_tailwind_cli/management/commands/tailwind.py index 8288c47..74e6f4e 100644 --- a/src/django_tailwind_cli/management/commands/tailwind.py +++ b/src/django_tailwind_cli/management/commands/tailwind.py @@ -7,6 +7,7 @@ from multiprocessing import Process from pathlib import Path from typing import Optional, Union +from warnings import warn import requests import typer @@ -184,37 +185,16 @@ def runserver( If django-extensions is installed along with this library, this command runs the runserver_plus command from django-extensions. Otherwise it runs the default runserver command. """ - if ( - importlib.util.find_spec("django_extensions") - and importlib.util.find_spec("werkzeug") - and not force_default_runserver - ): - server_command = "runserver_plus" - runserver_options = get_runserver_options( - addrport=addrport, - use_ipv6=use_ipv6, - no_threading=no_threading, - no_static=no_static, - no_reloader=no_reloader, - skip_checks=skip_checks, - pdb=pdb, - ipdb=ipdb, - pm=pm, - print_sql=print_sql, - print_sql_location=print_sql_location, - cert_file=cert_file, - key_file=key_file, - ) - else: - server_command = "runserver" - runserver_options = get_runserver_options( - addrport=addrport, - use_ipv6=use_ipv6, - no_threading=no_threading, - no_static=no_static, - no_reloader=no_reloader, - skip_checks=skip_checks, - ) + + + runserver_options = get_runserver_options( + addrport=addrport, + use_ipv6=use_ipv6, + no_threading=no_threading, + no_static=no_static, + no_reloader=no_reloader, + skip_checks=skip_checks, + ) watch_cmd = [sys.executable, "manage.py", "tailwind", "watch"] watch_process = Process( @@ -229,7 +209,7 @@ def runserver( debug_server_cmd = [ sys.executable, "manage.py", - server_command, + "runserver", ] + runserver_options debugserver_process = Process( @@ -361,20 +341,6 @@ def get_runserver_options( options.append("--noreload") if skip_checks: options.append("--skip-checks") - if pdb: - options.append("--pdb") - if ipdb: - options.append("--ipdb") - if pm: - options.append("--pm") - if print_sql: - options.append("--print-sql") - if print_sql_location: - options.append("--print-sql-location") - if cert_file: - options.append(f"--cert-file={cert_file}") - if key_file: - options.append(f"--key-file={key_file}") if addrport: options.append(addrport) diff --git a/tests/test_management_commands.py b/tests/test_management_commands.py index 673b006..84a1712 100644 --- a/tests/test_management_commands.py +++ b/tests/test_management_commands.py @@ -279,6 +279,3 @@ def test_runserver(): call_command("tailwind", "runserver") -def test_runserver_plus_without_django_extensions_installed(mocker: MockerFixture): - mocker.patch.dict(sys.modules, {"django_extensions": None, "werkzeug": None}) - call_command("tailwind", "runserver")