-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tailwind v4 support #428
Merged
Merged
Tailwind v4 support #428
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f3bb93b
Make tailwind v4 default and add support for musl for tailwind
SleeplessOne1917 afdff7c
Fix false assumption from last commit
SleeplessOne1917 1e3c899
Use tailwind v4 import
SleeplessOne1917 d3baddb
Use latest tailwindcss
SleeplessOne1917 8de8d31
Merge branch 'main' into tailwind-v4
SleeplessOne1917 663063d
Dep update
SleeplessOne1917 97d448f
Move where versions for exes are handled
SleeplessOne1917 0682f75
Do not autogenerate tailwind js config when using tailwind v4
SleeplessOne1917 3690ae0
Run cargo update
SleeplessOne1917 249200e
Merge branch 'main' into tailwind-v4
SleeplessOne1917 9f348d6
Merge branch 'main' into tailwind-v4
benwis 3f3e7cd
Merge branch 'main' into tailwind-v4
SleeplessOne1917 0f4631d
Merge branch 'tailwind-v4' of https://github.com/SleeplessOne1917/car…
SleeplessOne1917 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@import "tailwindcss"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::{borrow::Cow, env}; | ||
|
||
pub const ENV_VAR_LEPTOS_TAILWIND_VERSION: &str = "LEPTOS_TAILWIND_VERSION"; | ||
pub const ENV_VAR_LEPTOS_SASS_VERSION: &str = "LEPTOS_SASS_VERSION"; | ||
|
||
pub enum VersionConfig { | ||
Tailwind, | ||
Sass, | ||
} | ||
|
||
impl VersionConfig { | ||
pub fn version<'a>(&self) -> Cow<'a, str> { | ||
env::var(self.env_var_version_name()) | ||
.map(Cow::Owned) | ||
.unwrap_or_else(|_| self.default_version().into()) | ||
} | ||
|
||
pub fn default_version(&self) -> &'static str { | ||
match self { | ||
Self::Tailwind => "v4.0.6", | ||
Self::Sass => "1.83.4", | ||
} | ||
} | ||
|
||
pub fn env_var_version_name(&self) -> &'static str { | ||
match self { | ||
Self::Tailwind => ENV_VAR_LEPTOS_TAILWIND_VERSION, | ||
Self::Sass => ENV_VAR_LEPTOS_SASS_VERSION, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::{ | ||
config::VersionConfig, | ||
ext::{ | ||
anyhow::{bail, Context, Result}, | ||
Paint, | ||
|
@@ -7,6 +8,7 @@ use crate::{ | |
}; | ||
use bytes::Bytes; | ||
use std::{ | ||
borrow::Cow, | ||
fs::{self, File}, | ||
io::{Cursor, Write}, | ||
path::{Path, PathBuf}, | ||
|
@@ -40,9 +42,6 @@ lazy_static::lazy_static! { | |
static ref ON_STARTUP_DEBUG_ONCE: Once = Once::new(); | ||
} | ||
|
||
pub const ENV_VAR_LEPTOS_TAILWIND_VERSION: &str = "LEPTOS_TAILWIND_VERSION"; | ||
pub const ENV_VAR_LEPTOS_SASS_VERSION: &str = "LEPTOS_SASS_VERSION"; | ||
|
||
impl ExeMeta { | ||
#[allow(clippy::wrong_self_convention)] | ||
fn from_global_path(&self) -> Option<PathBuf> { | ||
|
@@ -260,7 +259,7 @@ impl Exe { | |
/// as it carries classifiers, etc, but strip non-ascii | ||
/// digits from the prefix. | ||
#[inline] | ||
fn sanitize_version_prefix<'a>(ver_string: &'a str) -> Result<&'a str> { | ||
fn sanitize_version_prefix(ver_string: &str) -> Result<&str> { | ||
if let [b'v', rest @ ..] = ver_string.as_bytes() { | ||
str::from_utf8(rest).dot() | ||
} else { | ||
|
@@ -304,11 +303,14 @@ impl Command for CommandTailwind { | |
fn name(&self) -> &'static str { | ||
"tailwindcss" | ||
} | ||
fn version(&self) -> Cow<'_, str> { | ||
VersionConfig::Tailwind.version() | ||
} | ||
fn default_version(&self) -> &'static str { | ||
"v3.4.0" | ||
VersionConfig::Tailwind.default_version() | ||
} | ||
fn env_var_version_name(&self) -> &'static str { | ||
ENV_VAR_LEPTOS_TAILWIND_VERSION | ||
VersionConfig::Tailwind.env_var_version_name() | ||
} | ||
fn github_owner(&self) -> &'static str { | ||
"tailwindlabs" | ||
|
@@ -319,6 +321,8 @@ impl Command for CommandTailwind { | |
|
||
/// Tool binary download url for the given OS and platform arch | ||
fn download_url(&self, target_os: &str, target_arch: &str, version: &str) -> Result<String> { | ||
let use_musl = is_linux_musl_env() && version.starts_with("v4"); | ||
|
||
match (target_os, target_arch) { | ||
("windows", "x86_64") => Ok(format!( | ||
"https://github.com/{}/{}/releases/download/{}/{}-windows-x64.exe", | ||
|
@@ -341,13 +345,27 @@ impl Command for CommandTailwind { | |
version, | ||
self.name() | ||
)), | ||
("linux", "x86_64") if use_musl => Ok(format!( | ||
"https://github.com/{}/{}/releases/download/{}/{}-linux-x64-musl", | ||
self.github_owner(), | ||
self.github_repo(), | ||
version, | ||
self.name() | ||
)), | ||
("linux", "x86_64") => Ok(format!( | ||
"https://github.com/{}/{}/releases/download/{}/{}-linux-x64", | ||
self.github_owner(), | ||
self.github_repo(), | ||
version, | ||
self.name() | ||
)), | ||
("linux", "aarch64") if use_musl => Ok(format!( | ||
"https://github.com/{}/{}/releases/download/{}/{}-linux-arm64-musl", | ||
self.github_owner(), | ||
self.github_repo(), | ||
version, | ||
self.name() | ||
)), | ||
("linux", "aarch64") => Ok(format!( | ||
"https://github.com/{}/{}/releases/download/{}/{}-linux-arm64", | ||
self.github_owner(), | ||
|
@@ -364,17 +382,16 @@ impl Command for CommandTailwind { | |
} | ||
} | ||
|
||
fn executable_name( | ||
&self, | ||
target_os: &str, | ||
target_arch: &str, | ||
_version: Option<&str>, | ||
) -> Result<String> { | ||
fn executable_name(&self, target_os: &str, target_arch: &str, version: &str) -> Result<String> { | ||
let use_musl = is_linux_musl_env() && version.starts_with("v4"); | ||
|
||
Ok(match (target_os, target_arch) { | ||
("windows", _) => format!("{}-windows-x64.exe", self.name()), | ||
("macos", "x86_64") => format!("{}-macos-x64", self.name()), | ||
("macos", "aarch64") => format!("{}-macos-arm64", self.name()), | ||
("linux", "x86_64") if use_musl => format!("{}-linux-x64-musl", self.name()), | ||
("linux", "x86_64") => format!("{}-linux-x64", self.name()), | ||
(_, _) if use_musl => format!("{}-linux-arm64-musl", self.name()), | ||
(_, _) => format!("{}-linux-arm64", self.name()), | ||
}) | ||
} | ||
|
@@ -383,17 +400,19 @@ impl Command for CommandTailwind { | |
"Try manually installing tailwindcss: https://tailwindcss.com/docs/installation".to_string() | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Command for CommandSass { | ||
fn name(&self) -> &'static str { | ||
"sass" | ||
} | ||
fn version(&self) -> Cow<'_, str> { | ||
VersionConfig::Sass.version() | ||
} | ||
fn default_version(&self) -> &'static str { | ||
"1.58.3" | ||
VersionConfig::Sass.default_version() | ||
} | ||
fn env_var_version_name(&self) -> &'static str { | ||
ENV_VAR_LEPTOS_SASS_VERSION | ||
VersionConfig::Sass.env_var_version_name() | ||
} | ||
fn github_owner(&self) -> &'static str { | ||
"dart-musl" | ||
|
@@ -450,7 +469,7 @@ impl Command for CommandSass { | |
&self, | ||
target_os: &str, | ||
_target_arch: &str, | ||
_version: Option<&str>, | ||
_version: &str, | ||
) -> Result<String> { | ||
Ok(match target_os { | ||
"windows" => "dart-sass/sass.bat".to_string(), | ||
|
@@ -462,25 +481,21 @@ impl Command for CommandSass { | |
"Try manually installing sass: https://sass-lang.com/install".to_string() | ||
} | ||
} | ||
|
||
#[async_trait] | ||
/// Template trait, implementors should only fill in | ||
/// the command-specific logic. Handles caching, latest | ||
/// version checking against the GitHub API and env var | ||
/// version override for a given command. | ||
#[async_trait] | ||
trait Command { | ||
fn name(&self) -> &'static str; | ||
fn version(&self) -> Cow<'_, str>; | ||
fn default_version(&self) -> &str; | ||
fn env_var_version_name(&self) -> &str; | ||
fn github_owner(&self) -> &str; | ||
fn github_repo(&self) -> &str; | ||
fn download_url(&self, target_os: &str, target_arch: &str, version: &str) -> Result<String>; | ||
fn executable_name( | ||
&self, | ||
target_os: &str, | ||
target_arch: &str, | ||
version: Option<&str>, | ||
) -> Result<String>; | ||
fn executable_name(&self, target_os: &str, target_arch: &str, version: &str) -> Result<String>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made |
||
#[allow(unused)] | ||
fn manual_install_instructions(&self) -> String { | ||
// default placeholder text, individual commands can override and customize | ||
|
@@ -504,7 +519,7 @@ trait Command { | |
async fn exe_meta(&self, target_os: &str, target_arch: &str) -> Result<ExeMeta> { | ||
let version = self.resolve_version().await; | ||
let url = self.download_url(target_os, target_arch, version.as_str())?; | ||
let exe = self.executable_name(target_os, target_arch, Some(version.as_str()))?; | ||
let exe = self.executable_name(target_os, target_arch, version.as_str())?; | ||
Ok(ExeMeta { | ||
name: self.name(), | ||
version, | ||
|
@@ -652,9 +667,7 @@ trait Command { | |
return self.default_version().into(); | ||
} | ||
|
||
let version = env::var(self.env_var_version_name()) | ||
.unwrap_or_else(|_| self.default_version().into()) | ||
.to_owned(); | ||
let version = self.version(); | ||
|
||
let latest = self.check_for_latest_version().await; | ||
|
||
|
@@ -685,7 +698,7 @@ trait Command { | |
), | ||
} | ||
|
||
version | ||
version.to_string() | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I should put in the effort to make the Tailwind version check more robust. I doubt they'll be coming out with a new major version any time soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might consider making it error if the version is greater than 4 and provide a useful error message