fix: upgrade crates & fixed repeat build error

This commit is contained in:
YuKun Liu 2024-01-28 11:51:02 -08:00
parent 20241d8f20
commit a0508861bc
3 changed files with 164 additions and 141 deletions

128
Cargo.lock generated
View file

@ -625,7 +625,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41e7771d4ab6635cbd685ce8db215b29c78a468098126de77c57f3b2e6eb3757" checksum = "41e7771d4ab6635cbd685ce8db215b29c78a468098126de77c57f3b2e6eb3757"
dependencies = [ dependencies = [
"dirs 5.0.1", "dirs",
"git2", "git2",
"terminal-prompt", "terminal-prompt",
] ]
@ -1111,7 +1111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0" checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"proc-macro-crate 2.0.1", "proc-macro-crate 2.0.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.48", "syn 2.0.48",
@ -1286,9 +1286,9 @@ dependencies = [
[[package]] [[package]]
name = "cargo-generate" name = "cargo-generate"
version = "0.18.5" version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a2885ae054e000b117515ab33e91c10eca90c2788a7baec1b97ada1f1f51e57" checksum = "92c1b6f44358912a9538fa3b6ac8d3aa3f585444f9dc32f12ed85d1545a9df9f"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"auth-git2", "auth-git2",
@ -1320,7 +1320,7 @@ dependencies = [
"serde", "serde",
"tempfile", "tempfile",
"thiserror", "thiserror",
"toml 0.8.2", "toml 0.8.8",
"walkdir", "walkdir",
] ]
@ -1386,6 +1386,20 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "cargo_metadata"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror",
]
[[package]] [[package]]
name = "cargo_toml" name = "cargo_toml"
version = "0.16.3" version = "0.16.3"
@ -1393,7 +1407,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3f9629bc6c4388ea699781dc988c2b99766d7679b151c81990b4fa1208fafd3" checksum = "e3f9629bc6c4388ea699781dc988c2b99766d7679b151c81990b4fa1208fafd3"
dependencies = [ dependencies = [
"serde", "serde",
"toml 0.8.2", "toml 0.8.8",
]
[[package]]
name = "cargo_toml"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "802b755090e39835a4b0440fb0bbee0df7495a8b337f63db21e616f7821c7e8c"
dependencies = [
"serde",
"toml 0.8.8",
] ]
[[package]] [[package]]
@ -2459,8 +2483,8 @@ dependencies = [
"axum 0.5.17", "axum 0.5.17",
"axum-server", "axum-server",
"cargo-generate", "cargo-generate",
"cargo_metadata 0.15.4", "cargo_metadata 0.18.1",
"cargo_toml", "cargo_toml 0.18.0",
"chrono", "chrono",
"clap 4.4.15", "clap 4.4.15",
"colored 2.1.0", "colored 2.1.0",
@ -2472,7 +2496,7 @@ dependencies = [
"dioxus-hot-reload", "dioxus-hot-reload",
"dioxus-html", "dioxus-html",
"dioxus-rsx", "dioxus-rsx",
"dirs 4.0.0", "dirs",
"fern", "fern",
"flate2", "flate2",
"fs_extra", "fs_extra",
@ -2502,8 +2526,8 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"tokio", "tokio",
"toml 0.5.11", "toml 0.8.8",
"toml_edit 0.19.15", "toml_edit 0.21.0",
"tower", "tower",
"tower-http 0.2.5", "tower-http 0.2.5",
"walkdir", "walkdir",
@ -2515,7 +2539,7 @@ dependencies = [
name = "dioxus-cli-config" name = "dioxus-cli-config"
version = "0.4.1" version = "0.4.1"
dependencies = [ dependencies = [
"cargo_toml", "cargo_toml 0.16.3",
"clap 4.4.15", "clap 4.4.15",
"once_cell", "once_cell",
"serde", "serde",
@ -3055,22 +3079,13 @@ dependencies = [
"syn 2.0.48", "syn 2.0.48",
] ]
[[package]]
name = "dirs"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
dependencies = [
"dirs-sys 0.3.7",
]
[[package]] [[package]]
name = "dirs" name = "dirs"
version = "5.0.1" version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
dependencies = [ dependencies = [
"dirs-sys 0.4.1", "dirs-sys",
] ]
[[package]] [[package]]
@ -3083,17 +3098,6 @@ dependencies = [
"dirs-sys-next", "dirs-sys-next",
] ]
[[package]]
name = "dirs-sys"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]] [[package]]
name = "dirs-sys" name = "dirs-sys"
version = "0.4.1" version = "0.4.1"
@ -3562,7 +3566,7 @@ dependencies = [
"atomic 0.6.0", "atomic 0.6.0",
"pear", "pear",
"serde", "serde",
"toml 0.8.2", "toml 0.8.8",
"uncased", "uncased",
"version_check", "version_check",
] ]
@ -4142,9 +4146,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-config" name = "gix-config"
version = "0.31.0" version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cae98c6b4c66c09379bc35274b172587d6b0ac369a416c39128ad8c6454f9bb" checksum = "0341471d55d8676e98b88e121d7065dfa4c9c5acea4b6d6ecdd2846e85cce0c3"
dependencies = [ dependencies = [
"bstr 1.9.0", "bstr 1.9.0",
"gix-config-value", "gix-config-value",
@ -4244,9 +4248,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-object" name = "gix-object"
version = "0.38.0" version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740f2a44267f58770a1cb3a3d01d14e67b089c7136c48d4bddbb3cfd2bf86a51" checksum = "febf79c5825720c1c63fe974c7bbe695d0cb54aabad73f45671c60ce0e501e33"
dependencies = [ dependencies = [
"bstr 1.9.0", "bstr 1.9.0",
"btoi", "btoi",
@ -4276,9 +4280,9 @@ dependencies = [
[[package]] [[package]]
name = "gix-ref" name = "gix-ref"
version = "0.38.0" version = "0.39.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ec2f6d07ac88d2fb8007ee3fa3e801856fb9d82e7366ec0ca332eb2c9d74a52" checksum = "3b2069adc212cf7f3317ef55f6444abd06c50f28479dbbac5a86acf3b05cbbfe"
dependencies = [ dependencies = [
"gix-actor", "gix-actor",
"gix-date", "gix-date",
@ -4375,7 +4379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.4.1",
"proc-macro-crate 2.0.1", "proc-macro-crate 2.0.0",
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -5081,7 +5085,7 @@ dependencies = [
"httpdate", "httpdate",
"itoa 1.0.10", "itoa 1.0.10",
"pin-project-lite", "pin-project-lite",
"socket2 0.4.10", "socket2 0.5.5",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
@ -6147,7 +6151,7 @@ dependencies = [
"anyhow", "anyhow",
"cargo-lock 9.0.0", "cargo-lock 9.0.0",
"cargo_metadata 0.17.0", "cargo_metadata 0.17.0",
"cargo_toml", "cargo_toml 0.16.3",
"image", "image",
"imagequant", "imagequant",
"lightningcss", "lightningcss",
@ -6274,9 +6278,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]] [[package]]
name = "memmap2" name = "memmap2"
version = "0.7.1" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -6900,9 +6904,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]] [[package]]
name = "open" name = "open"
version = "4.2.0" version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a083c0c7e5e4a8ec4176346cf61f67ac674e8bfb059d9226e1c54a96b377c12" checksum = "90878fb664448b54c4e592455ad02831e23a3f7e157374a8b95654731aac7349"
dependencies = [ dependencies = [
"is-wsl", "is-wsl",
"libc", "libc",
@ -7776,11 +7780,10 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "2.0.1" version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [ dependencies = [
"toml_datetime",
"toml_edit 0.20.2", "toml_edit 0.20.2",
] ]
@ -8950,7 +8953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fa50756ef995d410bb1968b403a1eca169b54c3c0eb4be4bcb1da8c7591cb7d" checksum = "5fa50756ef995d410bb1968b403a1eca169b54c3c0eb4be4bcb1da8c7591cb7d"
dependencies = [ dependencies = [
"cruet", "cruet",
"proc-macro-crate 2.0.1", "proc-macro-crate 2.0.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex", "regex",
@ -10127,7 +10130,7 @@ dependencies = [
"cfg-expr 0.15.6", "cfg-expr 0.15.6",
"heck 0.4.1", "heck 0.4.1",
"pkg-config", "pkg-config",
"toml 0.8.2", "toml 0.8.8",
"version-compare", "version-compare",
] ]
@ -10616,22 +10619,22 @@ dependencies = [
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.8.2" version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
dependencies = [ dependencies = [
"indexmap 2.1.0", "indexmap 2.1.0",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"toml_edit 0.20.2", "toml_edit 0.21.0",
] ]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.3" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -10654,6 +10657,17 @@ name = "toml_edit"
version = "0.20.2" version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
dependencies = [
"indexmap 2.1.0",
"toml_datetime",
"winnow",
]
[[package]]
name = "toml_edit"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
dependencies = [ dependencies = [
"indexmap 2.1.0", "indexmap 2.1.0",
"serde", "serde",

View file

@ -21,13 +21,13 @@ log = "0.4.14"
fern = { version = "0.6.0", features = ["colored"] } fern = { version = "0.6.0", features = ["colored"] }
serde = { version = "1.0.136", features = ["derive"] } serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79" serde_json = "1.0.79"
toml = "0.5.8" toml = "0.8.8"
fs_extra = "1.2.0" fs_extra = "1.2.0"
cargo_toml = "0.16.0" cargo_toml = "0.18.0"
futures = "0.3.21" futures = "0.3.21"
notify = { version = "5.0.0-pre.16", features = ["serde"] } notify = { version = "5.0.0-pre.16", features = ["serde"] }
html_parser = { workspace = true } html_parser = { workspace = true }
cargo_metadata = "0.15.0" cargo_metadata = "0.18.1"
tokio = { version = "1.16.1", features = ["fs", "sync", "rt", "macros"] } tokio = { version = "1.16.1", features = ["fs", "sync", "rt", "macros"] }
atty = "0.2.14" atty = "0.2.14"
chrono = "0.4.19" chrono = "0.4.19"
@ -45,7 +45,7 @@ headers = "0.3.7"
walkdir = "2" walkdir = "2"
# tools download # tools download
dirs = "4.0.0" dirs = "5.0.1"
reqwest = { version = "0.11", features = [ reqwest = { version = "0.11", features = [
"rustls-tls", "rustls-tls",
"stream", "stream",
@ -68,9 +68,9 @@ mlua = { version = "0.8.1", features = [
"macros", "macros",
], optional = true } ], optional = true }
ctrlc = "3.2.3" ctrlc = "3.2.3"
open = "4.1.0" open = "5.0.1"
cargo-generate = "0.18" cargo-generate = "0.19.0"
toml_edit = "0.19.11" toml_edit = "0.21.0"
# bundling # bundling
tauri-bundler = { version = "=1.4.*", features = ["native-tls-vendored"] } tauri-bundler = { version = "=1.4.*", features = ["native-tls-vendored"] }

View file

@ -31,93 +31,102 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
let mut watcher = notify::recommended_watcher(move |info: notify::Result<notify::Event>| { let mut watcher = notify::recommended_watcher(move |info: notify::Result<notify::Event>| {
let config = watcher_config.clone(); let config = watcher_config.clone();
if let Ok(e) = info { if let Ok(e) = info {
if chrono::Local::now().timestamp() > last_update_time { match e.kind {
let mut needs_full_rebuild; notify::EventKind::Create(_) | notify::EventKind::Remove(_) | notify::EventKind::Modify(_) => {
if let Some(hot_reload) = &hot_reload {
// find changes to the rsx in the file
let mut rsx_file_map = hot_reload.file_map.lock().unwrap();
let mut messages: Vec<Template<'static>> = Vec::new();
// In hot reload mode, we only need to rebuild if non-rsx code is changed if chrono::Local::now().timestamp() > last_update_time {
needs_full_rebuild = false; let mut needs_full_rebuild;
if let Some(hot_reload) = &hot_reload {
// find changes to the rsx in the file
let mut rsx_file_map = hot_reload.file_map.lock().unwrap();
let mut messages: Vec<Template<'static>> = Vec::new();
for path in &e.paths { // In hot reload mode, we only need to rebuild if non-rsx code is changed
// if this is not a rust file, rebuild the whole project needs_full_rebuild = false;
if path.extension().and_then(|p| p.to_str()) != Some("rs") {
for path in &e.paths {
// if this is not a rust file, rebuild the whole project
if path.extension().and_then(|p| p.to_str()) != Some("rs") {
needs_full_rebuild = true;
break;
}
// Workaround for notify and vscode-like editor:
// when edit & save a file in vscode, there will be two notifications,
// the first one is a file with empty content.
// filter the empty file notification to avoid false rebuild during hot-reload
if let Ok(metadata) = fs::metadata(path) {
if metadata.len() == 0 {
continue;
}
}
match rsx_file_map.update_rsx(path, &config.crate_dir) {
Ok(UpdateResult::UpdatedRsx(msgs)) => {
messages.extend(msgs);
needs_full_rebuild = false;
}
Ok(UpdateResult::NeedsRebuild) => {
needs_full_rebuild = true;
}
Err(err) => {
log::error!("{}", err);
}
}
}
if needs_full_rebuild {
// Reset the file map to the new state of the project
let FileMapBuildResult {
map: new_file_map,
errors,
} = FileMap::<HtmlCtx>::create(config.crate_dir.clone()).unwrap();
for err in errors {
log::error!("{}", err);
}
*rsx_file_map = new_file_map;
} else {
for msg in messages {
let _ = hot_reload.messages.send(msg);
}
}
} else {
needs_full_rebuild = true; needs_full_rebuild = true;
break;
} }
// Workaround for notify and vscode-like editor: if needs_full_rebuild {
// when edit & save a file in vscode, there will be two notifications, match build_with() {
// the first one is a file with empty content. Ok(res) => {
// filter the empty file notification to avoid false rebuild during hot-reload last_update_time = chrono::Local::now().timestamp();
if let Ok(metadata) = fs::metadata(path) {
if metadata.len() == 0 {
continue;
}
}
match rsx_file_map.update_rsx(path, &config.crate_dir) { #[allow(clippy::redundant_clone)]
Ok(UpdateResult::UpdatedRsx(msgs)) => { print_console_info(
messages.extend(msgs); &config,
needs_full_rebuild = false; PrettierOptions {
} changed: e.paths.clone(),
Ok(UpdateResult::NeedsRebuild) => { warnings: res.warnings,
needs_full_rebuild = true; elapsed_time: res.elapsed_time,
} },
Err(err) => { web_info.clone(),
log::error!("{}", err); );
}
}
}
if needs_full_rebuild { #[cfg(feature = "plugin")]
// Reset the file map to the new state of the project let _ = PluginManager::on_serve_rebuild(
let FileMapBuildResult { chrono::Local::now().timestamp(),
map: new_file_map, e.paths,
errors, );
} = FileMap::<HtmlCtx>::create(config.crate_dir.clone()).unwrap(); }
Err(e) => {
for err in errors { last_update_time = chrono::Local::now().timestamp();
log::error!("{}", err); log::error!("{:?}", e);
}
*rsx_file_map = new_file_map;
} else {
for msg in messages {
let _ = hot_reload.messages.send(msg);
}
}
} else {
needs_full_rebuild = true;
}
if needs_full_rebuild {
match build_with() {
Ok(res) => {
last_update_time = chrono::Local::now().timestamp();
#[allow(clippy::redundant_clone)]
print_console_info(
&config,
PrettierOptions {
changed: e.paths.clone(),
warnings: res.warnings,
elapsed_time: res.elapsed_time,
}, },
web_info.clone(), }
);
#[cfg(feature = "plugin")]
let _ = PluginManager::on_serve_rebuild(
chrono::Local::now().timestamp(),
e.paths,
);
} }
Err(e) => log::error!("{}", e),
} }
} },
_ => {},
} }
} }
}) })