Skip to content

Commit

Permalink
Support FreeBSD with bespoke upstream build
Browse files Browse the repository at this point in the history
  • Loading branch information
dch committed Dec 23, 2022
1 parent aa5ccfa commit 21b659e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v0.1.10 (2022-12-23)

* Provide FreeBSD-native tailwindcss binary for amd64 architecture

## v0.1.9 (2022-09-06)

* Use only TLS 1.2 on OTP versions less than 25.
Expand Down
15 changes: 14 additions & 1 deletion lib/tailwind.ex
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,24 @@ defmodule Tailwind do
run(profile, args)
end

@doc """
This could equally be amended to allow a custom fetch url viz
https://github.com/phoenixframework/tailwind/issues/59
"""
defp base_url do
case :os.type() do
{:unix, :freebsd} -> "https://people.freebsd.org/~dch/pub/tailwind/"
_ -> "https://github.com/tailwindlabs/tailwindcss/releases/download/"
end
end

@doc """
Installs tailwind with `configured_version/0`.
"""
def install do
version = configured_version()
name = "tailwindcss-#{target()}"
url = "https://github.com/tailwindlabs/tailwindcss/releases/download/v#{version}/#{name}"
url = base_url() <> "v#{version}/#{name}"
bin_path = bin_path()
tailwind_config_path = Path.expand("assets/tailwind.config.js")
binary = fetch_body!(url)
Expand Down Expand Up @@ -273,6 +284,7 @@ defmodule Tailwind do
end

# Available targets:
# tailwindcss-freebsd-x64
# tailwindcss-linux-arm64
# tailwindcss-linux-x64
# tailwindcss-macos-arm64
Expand All @@ -286,6 +298,7 @@ defmodule Tailwind do
{{:win32, _}, _arch, 64} -> "windows-x64.exe"
{{:unix, :darwin}, arch, 64} when arch in ~w(arm aarch64) -> "macos-arm64"
{{:unix, :darwin}, "x86_64", 64} -> "macos-x64"
{{:unix, :freebsd}, "amd64", 64} -> "freebsd-x64"
{{:unix, :linux}, "aarch64", 64} -> "linux-arm64"
{{:unix, _osname}, arch, 64} when arch in ~w(x86_64 amd64) -> "linux-x64"
{_os, _arch, _wordsize} -> raise "tailwind is not available for architecture: #{arch_str}"
Expand Down

0 comments on commit 21b659e

Please sign in to comment.