mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
feat: beautify console
This commit is contained in:
parent
c86c39477f
commit
719e48c0a5
4 changed files with 48 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "dioxus-cli"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
authors = ["Jonathan Kelley"]
|
||||
edition = "2021"
|
||||
description = "CLI tool for developing, testing, and publishing Dioxus apps"
|
||||
|
@ -14,6 +14,7 @@ license = "MIT/Apache-2.0"
|
|||
clap = { version = "3.0.14", features = ["derive"] }
|
||||
thiserror = "1.0.30"
|
||||
wasm-bindgen-cli-support = "0.2.79"
|
||||
colored = "2.0.0"
|
||||
|
||||
# features
|
||||
log = "0.4.14"
|
||||
|
|
|
@ -27,7 +27,7 @@ use std::{
|
|||
|
||||
/// Build, bundle, & ship your Dioxus app.
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "dioxus")]
|
||||
#[clap(name = "dioxus", version)]
|
||||
pub struct Cli {
|
||||
#[clap(subcommand)]
|
||||
pub action: Commands,
|
||||
|
@ -35,10 +35,6 @@ pub struct Cli {
|
|||
/// Enable verbose logging.
|
||||
#[clap(short)]
|
||||
pub v: bool,
|
||||
// // note: dioxus is still roughly compatible with trunk
|
||||
// /// Path to the Trunk config file [default: Trunk.toml]
|
||||
// #[clap(long, parse(from_os_str), env = "TRUNK_CONFIG")]
|
||||
// pub config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
pub const DIOXUS_CLI_VERSION: &'static str = "0.1.5";
|
||||
|
||||
pub mod builder;
|
||||
pub mod server;
|
||||
pub mod tools;
|
||||
|
@ -19,4 +21,4 @@ pub use error::*;
|
|||
pub mod logging;
|
||||
pub use logging::*;
|
||||
|
||||
pub mod hot_reload;
|
||||
pub mod hot_reload;
|
|
@ -6,11 +6,12 @@ use axum::{
|
|||
routing::{get, get_service},
|
||||
Router,
|
||||
};
|
||||
use colored::Colorize;
|
||||
use dioxus::rsx_interpreter::SetRsxMessage;
|
||||
use notify::{RecommendedWatcher, Watcher};
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use std::{path::PathBuf, process::Command, sync::Arc};
|
||||
use tower::ServiceBuilder;
|
||||
use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody};
|
||||
|
||||
|
@ -180,7 +181,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||
}
|
||||
|
||||
// start serve dev-server at 0.0.0.0:8080
|
||||
log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port);
|
||||
print_console_info(port, &config);
|
||||
|
||||
let file_service_config = config.clone();
|
||||
let file_service = ServiceBuilder::new()
|
||||
|
@ -290,7 +291,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
|||
}
|
||||
|
||||
// start serve dev-server at 0.0.0.0
|
||||
log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port);
|
||||
print_console_info(port, &config);
|
||||
|
||||
let file_service_config = config.clone();
|
||||
let file_service = ServiceBuilder::new()
|
||||
|
@ -348,6 +349,44 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn print_console_info(port: u16, config: &CrateConfig) {
|
||||
print!(
|
||||
"{}",
|
||||
String::from_utf8_lossy(
|
||||
&Command::new(if cfg!(target_os = "windows") {
|
||||
"cls"
|
||||
} else {
|
||||
"clear"
|
||||
})
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout
|
||||
)
|
||||
);
|
||||
|
||||
let mut profile = if config.release { "Release" } else { "Debug" }.to_string();
|
||||
if config.custom_profile.is_some() {
|
||||
profile = config.custom_profile.as_ref().unwrap().to_string();
|
||||
}
|
||||
let hot_reload = if config.hot_reload { "RSX" } else { "Normal" };
|
||||
let workspace = config.workspace_dir.to_str().unwrap().to_string();
|
||||
|
||||
println!(
|
||||
"{} @ v{}\n",
|
||||
"Dioxus".bold().green(),
|
||||
crate::DIOXUS_CLI_VERSION
|
||||
);
|
||||
println!(
|
||||
"\t> Local: {}",
|
||||
format!("https://localhost:{}/", port).blue()
|
||||
);
|
||||
println!("\t> Profile: {}", profile.green());
|
||||
println!("\t> Hot Reload: {}", hot_reload.green());
|
||||
println!("\t> Workspace: {}", workspace.yellow());
|
||||
|
||||
println!("\n{}", "Server startup completed.".bold());
|
||||
}
|
||||
|
||||
async fn ws_handler(
|
||||
ws: WebSocketUpgrade,
|
||||
_: Option<TypedHeader<headers::UserAgent>>,
|
||||
|
|
Loading…
Add table
Reference in a new issue