Skip to content

Commit

Permalink
Bumped default tailwind version to 3.4.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverandrich committed Mar 8, 2024
1 parent fa637ae commit a5a4d59
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 51 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Bumped default Tailwind CLI version to 3.4.1.

## 2.8.1

- [#83](https://github.com/oliverandrich/django-tailwind-cli/pull/83)
Expand Down
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hide:
The package can be configured by a few settings, which can be overwritten in the `settings.py` of your project.

`TAILWIND_CLI_VERSION`
: **Default**: `"3.4.0"`
: **Default**: `"3.4.1"`

This defines the version of the CLI and of Tailwind CSS you want to use in your project.

Expand Down
9 changes: 2 additions & 7 deletions src/django_tailwind_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Config:

@property
def tailwind_version(self) -> str:
return getattr(settings, "TAILWIND_CLI_VERSION", "3.4.0")
return getattr(settings, "TAILWIND_CLI_VERSION", "3.4.1")

@property
def cli_path(self) -> Union[Path, None]:
Expand Down Expand Up @@ -78,12 +78,7 @@ def get_full_cli_path(self) -> Path:
"""Get path to the Tailwind CSS CLI."""

# If Tailwind CSS CLI path points to an existing executable use is.
if (
self.cli_path
and self.cli_path.exists()
and self.cli_path.is_file()
and os.access(self.cli_path, os.X_OK)
):
if self.cli_path and self.cli_path.exists() and self.cli_path.is_file() and os.access(self.cli_path, os.X_OK):
return self.cli_path

# Otherwise try to calculate the full cli path as usual.
Expand Down
76 changes: 33 additions & 43 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ def configure_settings(settings):


def test_default_config(config):
assert "3.4.0" == config.tailwind_version
assert "3.4.1" == config.tailwind_version
assert Path("~/.local/bin/").expanduser() == config.cli_path
assert config.src_css is None
assert "css/tailwind.css" == config.dist_css
assert "tailwind.config.js" == config.config_file
assert "3.4.0" in config.get_download_url()
assert "3.4.0" in str(config.get_full_cli_path())
assert "3.4.1" in config.get_download_url()
assert "3.4.1" in str(config.get_full_cli_path())


def test_validate_settigns(config, settings):
settings.STATICFILES_DIRS = []
with pytest.raises(
ValueError, match="STATICFILES_DIRS is empty. Please add a path to your static files."
):
with pytest.raises(ValueError, match="STATICFILES_DIRS is empty. Please add a path to your static files."):
config.validate_settings()


Expand All @@ -32,9 +30,7 @@ def test_get_full_config_file_path(config):

def test_get_full_dist_css_path_without_staticfiles_dir_set(config, settings):
settings.STATICFILES_DIRS = None
with pytest.raises(
ValueError, match="STATICFILES_DIRS is empty. Please add a path to your static files."
):
with pytest.raises(ValueError, match="STATICFILES_DIRS is empty. Please add a path to your static files."):
config.get_full_dist_css_path()


Expand Down Expand Up @@ -82,48 +78,42 @@ def test_get_system_and_machine(config, mocker):
assert machine == "arm64"


def test_get_download_url(config, mocker):
@pytest.mark.parametrize(
"platform,machine,result",
[
("Windows", "x86_64", "tailwindcss-windows-x64.exe"),
("Windows", "amd64", "tailwindcss-windows-x64.exe"),
("Darwin", "aarch64", "tailwindcss-macos-arm64"),
("Darwin", "arm64", "tailwindcss-macos-arm64"),
],
)
def test_get_download_url(config, mocker, platform, machine, result):
platform_system = mocker.patch("platform.system")
platform_machine = mocker.patch("platform.machine")

platform_system.return_value = "Windows"
platform_machine.return_value = "x86_64"
assert config.get_download_url().endswith("tailwindcss-windows-x64.exe")

platform_system.return_value = "Windows"
platform_machine.return_value = "amd64"
assert config.get_download_url().endswith("tailwindcss-windows-x64.exe")

platform_system.return_value = "Darwin"
platform_machine.return_value = "aarch64"
assert config.get_download_url().endswith("tailwindcss-macos-arm64")

platform_system.return_value = "Darwin"
platform_machine.return_value = "arm64"
assert config.get_download_url().endswith("tailwindcss-macos-arm64")


def test_get_full_cli_path(config, mocker):
platform_system.return_value = platform
platform_machine.return_value = machine
assert config.get_download_url().endswith(result)


@pytest.mark.parametrize(
"platform,machine,result",
[
("Windows", "x86_64", "tailwindcss-windows-x64-3.4.1.exe"),
("Windows", "amd64", "tailwindcss-windows-x64-3.4.1.exe"),
("Darwin", "aarch64", "tailwindcss-macos-arm64-3.4.1"),
("Darwin", "arm64", "tailwindcss-macos-arm64-3.4.1"),
],
)
def test_get_full_cli_path(config, mocker, platform, machine, result):
assert "/.local/bin/tailwindcss-" in str(config.get_full_cli_path())

platform_system = mocker.patch("platform.system")
platform_machine = mocker.patch("platform.machine")

platform_system.return_value = "Windows"
platform_machine.return_value = "x86_64"
assert str(config.get_full_cli_path()).endswith("tailwindcss-windows-x64-3.4.0.exe")

platform_system.return_value = "Windows"
platform_machine.return_value = "amd64"
assert str(config.get_full_cli_path()).endswith("tailwindcss-windows-x64-3.4.0.exe")

platform_system.return_value = "Darwin"
platform_machine.return_value = "aarch64"
assert str(config.get_full_cli_path()).endswith("tailwindcss-macos-arm64-3.4.0")

platform_system.return_value = "Darwin"
platform_machine.return_value = "arm64"
assert str(config.get_full_cli_path()).endswith("tailwindcss-macos-arm64-3.4.0")
platform_system.return_value = platform
platform_machine.return_value = machine
assert str(config.get_full_cli_path()).endswith(result)


def test_get_full_cli_path_with_existing_executable(config, tmp_path, settings):
Expand Down

0 comments on commit a5a4d59

Please sign in to comment.