CLI Fixes & Tweaks (#2846)
Fixes scrolling on vscode using simple fix Adds scroll modifier, scroll at 5 lines per scroll while holding shift key. Adds error handling for manganis failure that still lets the build run. Revises TUI rendering code. Move TUI "info bars" to the bottom of the terminal. Revised logging system with tracing Working [c] clear keybind. This has been removed. Removal of [h] hide keybind text (it does nothing) Some opinionated cleanups and renames to make tui logic easier to understand. Rolling log file & maybe add some more "internal" logging. Closes CLI Rolling Log File #2764 Removes log tabs. Closes CLI: Color-code logs and get rid of tabs #2857 Combines info bars. Working and good text selection. Print launch URL in console. Handle log lines properly and add formatting. Move MessageSource to a more reasonable location. Add some background styling to powerline (info bar) - Tried this and it doesn't look the greatest. Log Filtering Final Cleaning & Changes - I could do this forever Test Linux --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
87c2f64f13
commit
8d68886310
22 files changed
+1302
-718
No files matched your search
@@ -1,11 +1,14 @@
|
||||
use std::future::{poll_fn, Future, IntoFuture};
|
||||
use std::task::Poll;
|
||||
|
||||
use crate::builder::{Stage, TargetPlatform, UpdateBuildProgress, UpdateStage};
|
||||
use crate::cli::serve::Serve;
|
||||
use crate::dioxus_crate::DioxusCrate;
|
||||
use crate::tracer::CLILogControl;
|
||||
use crate::Result;
|
||||
use crate::{
|
||||
builder::{Stage, TargetPlatform, UpdateBuildProgress, UpdateStage},
|
||||
TraceSrc,
|
||||
};
|
||||
use futures_util::FutureExt;
|
||||
use tokio::task::yield_now;
|
||||
|
||||
@@ -54,6 +57,8 @@ pub async fn serve_all(
|
||||
dioxus_crate: DioxusCrate,
|
||||
log_control: CLILogControl,
|
||||
) -> Result<()> {
|
||||
// Start the screen first so we collect build logs.
|
||||
let mut screen = Output::start(&serve, log_control).expect("Failed to open terminal logger");
|
||||
let mut builder = Builder::new(&dioxus_crate, &serve);
|
||||
|
||||
// Start the first build
|
||||
@@ -61,7 +66,6 @@ pub async fn serve_all(
|
||||
|
||||
let mut server = Server::start(&serve, &dioxus_crate);
|
||||
let mut watcher = Watcher::start(&serve, &dioxus_crate);
|
||||
let mut screen = Output::start(&serve, log_control).expect("Failed to open terminal logger");
|
||||
|
||||
let is_hot_reload = serve.server_arguments.hot_reload.unwrap_or(true);
|
||||
|
||||
@@ -81,15 +85,21 @@ pub async fn serve_all(
|
||||
}
|
||||
|
||||
let changed_files = watcher.dequeue_changed_files(&dioxus_crate);
|
||||
let changed = changed_files.first().cloned();
|
||||
|
||||
// if change is hotreloadable, hotreload it
|
||||
// and then send that update to all connected clients
|
||||
if let Some(hr) = watcher.attempt_hot_reload(&dioxus_crate, changed_files) {
|
||||
// Only send a hotreload message for templates and assets - otherwise we'll just get a full rebuild
|
||||
if hr.templates.is_empty() && hr.assets.is_empty() {
|
||||
if hr.templates.is_empty() && hr.assets.is_empty() && hr.unknown_files.is_empty() {
|
||||
continue
|
||||
}
|
||||
|
||||
if let Some(changed_path) = changed {
|
||||
let path_relative = changed_path.strip_prefix(dioxus_crate.crate_dir()).map(|p| p.display().to_string()).unwrap_or_else(|_| changed_path.display().to_string());
|
||||
tracing::info!(dx_src = ?TraceSrc::Dev, "Hotreloaded {}", path_relative);
|
||||
}
|
||||
|
||||
server.send_hotreload(hr).await;
|
||||
} else {
|
||||
// If the change is not binary patchable, rebuild the project
|
||||
@@ -129,7 +139,7 @@ pub async fn serve_all(
|
||||
match application {
|
||||
Ok(BuilderUpdate::Progress { platform, update }) => {
|
||||
let update_clone = update.clone();
|
||||
screen.new_build_logs(platform, update_clone);
|
||||
screen.new_build_progress(platform, update_clone);
|
||||
server.update_build_status(screen.build_progress.progress(), update.stage.to_string()).await;
|
||||
|
||||
match update {
|
||||
@@ -151,7 +161,7 @@ pub async fn serve_all(
|
||||
match child {
|
||||
Ok(Some(child_proc)) => builder.children.push((build_result.target_platform, child_proc)),
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to open build result: {e}");
|
||||
tracing::error!(dx_src = ?TraceSrc::Build, "Failed to open build result: {e}");
|
||||
break;
|
||||
},
|
||||
_ => {}
|
||||
@@ -176,11 +186,11 @@ pub async fn serve_all(
|
||||
break;
|
||||
}
|
||||
else {
|
||||
tracing::error!("Application exited with status: {status}");
|
||||
tracing::error!(dx_src = ?TraceSrc::Dev, "Application exited with status: {status}");
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
tracing::error!("Application exited with error: {e}");
|
||||
tracing::error!(dx_src = ?TraceSrc::Dev, "Application exited with error: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user