Merge pull request #58 from trevyn/fix-notify

Fix `notify` and make CI pass
This commit is contained in:
YuKun Liu authored and GitHub committed 2022-08-15 13:52:51 -07:00
commit bc1a81b84b
5 files changed
+235 -278

No files matched your search

Generated
+202 -249
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -25,7 +25,7 @@ toml = "0.5.8"
fs_extra = "1.2.0"
cargo_toml = "0.11.4"
futures = "0.3.21"
notify = { version = "5.0.0-pre.13", features = ["serde"] }
notify = { version = "5.0.0-pre.16", features = ["serde"] }
html_parser = "0.6.2"
binary-install = "0.0.2"
convert_case = "0.5.0"
+11 -8
View File
@@ -152,10 +152,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
if config.release == true {
args.push("-Oz");
}
binaryen.call(
"wasm-opt",
args,
)?;
binaryen.call("wasm-opt", args)?;
}
}
}
@@ -177,11 +174,11 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
let input_path = match sub.get("input") {
Some(val) => val.as_str().unwrap(),
None => "./public"
None => "./public",
};
let config_path = match sub.get("config") {
Some(val) => val.as_str().unwrap(),
None => "./src/tailwind.config.js"
None => "./src/tailwind.config.js",
};
let mut args = vec![
"-i",
@@ -189,7 +186,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
"-o",
"dist/tailwind.css",
"-c",
config_path
config_path,
];
if config.release == true {
@@ -459,7 +456,13 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
&style.to_str().unwrap(),
))
}
if config.application.tools.clone().unwrap_or_default().contains_key("tailwindcss") {
if config
.application
.tools
.clone()
.unwrap_or_default()
.contains_key("tailwindcss")
{
style_str.push_str("<link rel=\"stylesheet\" href=\"tailwind.css\">\n");
}
html = html.replace("{style_include}", &style_str);
+13 -6
View File
@@ -98,7 +98,8 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
.unwrap_or_else(|| vec![PathBuf::from("src")]);
let watcher_config = config.clone();
let mut watcher = RecommendedWatcher::new(move |evt: notify::Result<notify::Event>| {
let mut watcher = RecommendedWatcher::new(
move |evt: notify::Result<notify::Event>| {
let config = watcher_config.clone();
if chrono::Local::now().timestamp() > last_update_time {
// Give time for the change to take effect before reading the file
@@ -146,8 +147,9 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
if let Some(last) = lines.last_mut() {
// if there is only one line the start index of last line will be the start of the rsx!, not the start of the line
if start.line == end.line {
*last =
last.split_at(end.column - start.column).0;
*last = last
.split_at(end.column - start.column)
.0;
} else {
*last = last.split_at(end.column).0;
}
@@ -191,7 +193,9 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
}
last_update_time = chrono::Local::now().timestamp();
}
})
},
notify::Config::default(),
)
.unwrap();
for sub_path in allow_watch_path {
@@ -304,7 +308,8 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
.unwrap_or_else(|| vec![PathBuf::from("src")]);
let watcher_config = config.clone();
let mut watcher = RecommendedWatcher::new(move |info: notify::Result<notify::Event>| {
let mut watcher = RecommendedWatcher::new(
move |info: notify::Result<notify::Event>| {
let config = watcher_config.clone();
if info.is_ok() {
if chrono::Local::now().timestamp() > last_update_time {
@@ -325,7 +330,9 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
}
}
}
})
},
notify::Config::default(),
)
.unwrap();
for sub_path in allow_watch_path {
+8 -14
View File
@@ -1,8 +1,8 @@
use std::{
fs::{create_dir_all, File},
io::{Read, Write},
path::{Path, PathBuf},
process::Command,
io::{Read, Write}
};
use anyhow::Context;
@@ -121,15 +121,9 @@ impl Tool {
/// get tool version
pub fn tool_version(&self) -> &str {
match self {
Self::Binaryen => {
"version_105"
}
Self::Sass => {
"1.51.0"
}
Self::Tailwind => {
"v3.1.6"
}
Self::Binaryen => "version_105",
Self::Sass => "1.51.0",
Self::Tailwind => "v3.1.6",
}
}
@@ -154,7 +148,7 @@ impl Tool {
Self::Tailwind => {
let windows_extension = match self.target_platform() {
"windows" => ".exe",
_ => ""
_ => "",
};
format!(
"https://github.com/tailwindlabs/tailwindcss/releases/download/{version}/tailwindcss-{target}-x64{optional_ext}",
@@ -177,7 +171,7 @@ impl Tool {
"tar.gz"
}
}
Self::Tailwind => "bin"
Self::Tailwind => "bin",
}
}
@@ -218,7 +212,7 @@ impl Tool {
let dir_name = match self {
Self::Binaryen => format!("binaryen-{}", self.tool_version()),
Self::Sass => "dart-sass".to_string(),
Self::Tailwind => self.name().to_string()
Self::Tailwind => self.name().to_string(),
};
if self.extension() == "tar.gz" {
@@ -234,7 +228,7 @@ impl Tool {
} else if self.extension() == "bin" {
let bin_path = match self.target_platform() {
"windows" => tool_path.join(&dir_name).join(self.name()).join(".exe"),
_ => tool_path.join(&dir_name).join(self.name())
_ => tool_path.join(&dir_name).join(self.name()),
};
// Manualy creating tool directory because we directly download the binary via Github
std::fs::create_dir(tool_path.join(dir_name))?;