fix: fixed warn info
This commit is contained in:
1 parent
5e710f6693
commit
d18a93f129
11 files changed
+43
-44
No files matched your search
+11
-13
@@ -3,7 +3,7 @@ use crate::{
|
|||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
io::{Read, Write},
|
io::Write,
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
use wasm_bindgen_cli_support::Bindgen;
|
use wasm_bindgen_cli_support::Bindgen;
|
||||||
@@ -29,14 +29,15 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
let t_start = std::time::Instant::now();
|
let t_start = std::time::Instant::now();
|
||||||
|
|
||||||
// [1] Build the .wasm module
|
// [1] Build the .wasm module
|
||||||
log::info!("Running build commands...");
|
log::info!("🚅 Running build commands...");
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new("cargo");
|
||||||
cmd.current_dir(&crate_dir)
|
cmd.current_dir(&crate_dir)
|
||||||
.arg("build")
|
.arg("build")
|
||||||
.arg("--target")
|
.arg("--target")
|
||||||
.arg("wasm32-unknown-unknown")
|
.arg("wasm32-unknown-unknown")
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::inherit())
|
||||||
.stderr(std::process::Stdio::piped());
|
.stderr(std::process::Stdio::inherit())
|
||||||
|
;
|
||||||
|
|
||||||
if config.release {
|
if config.release {
|
||||||
cmd.arg("--release");
|
cmd.arg("--release");
|
||||||
@@ -48,16 +49,13 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
ExecutableType::Example(name) => cmd.arg("--example").arg(name),
|
ExecutableType::Example(name) => cmd.arg("--example").arg(name),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut child = cmd.spawn()?;
|
let output = cmd.output()?;
|
||||||
|
|
||||||
let output = child.wait()?;
|
if output.status.success() {
|
||||||
|
std::io::stdout().write_all(&output.stdout).unwrap();
|
||||||
if output.success() {
|
|
||||||
log::info!("Build complete!");
|
|
||||||
} else {
|
} else {
|
||||||
log::error!("Build failed!");
|
log::error!("Build failed!");
|
||||||
let mut reason = String::new();
|
let reason = String::from_utf8_lossy(&output.stderr).to_string();
|
||||||
child.stderr.unwrap().read_to_string(&mut reason)?;
|
|
||||||
return Err(Error::BuildFailed(reason));
|
return Err(Error::BuildFailed(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,8 +96,8 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
|
|
||||||
// [5] Generate the html file with the module name
|
// [5] Generate the html file with the module name
|
||||||
// TODO: support names via options
|
// TODO: support names via options
|
||||||
log::info!("Writing to '{:#?}' directory...", out_dir);
|
|
||||||
|
|
||||||
|
// log::info!("Writing to '{:#?}' directory...", out_dir);
|
||||||
let copy_options = fs_extra::dir::CopyOptions::new();
|
let copy_options = fs_extra::dir::CopyOptions::new();
|
||||||
if static_dir.is_dir() {
|
if static_dir.is_dir() {
|
||||||
match fs_extra::dir::copy(static_dir, out_dir, ©_options) {
|
match fs_extra::dir::copy(static_dir, out_dir, ©_options) {
|
||||||
@@ -111,7 +109,7 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let t_end = std::time::Instant::now();
|
let t_end = std::time::Instant::now();
|
||||||
log::info!("Done in {}ms! 🎉", (t_end - t_start).as_millis());
|
log::info!("🏁 Done in {}ms!", (t_end - t_start).as_millis());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use crate::cfg::ConfigOptsBuild;
|
use crate::cfg::ConfigOptsBuild;
|
||||||
use anyhow::Result;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
/// Build the Rust WASM app and all of its assets.
|
/// Build the Rust WASM app and all of its assets.
|
||||||
@@ -18,7 +16,7 @@ impl Build {
|
|||||||
// change the relase state.
|
// change the relase state.
|
||||||
crate_config.with_release(self.build.release);
|
crate_config.with_release(self.build.release);
|
||||||
|
|
||||||
crate::builder::build(&crate_config);
|
crate::builder::build(&crate_config)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-4
@@ -1,11 +1,8 @@
|
|||||||
use anyhow::Result;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// Config options for the build system.
|
/// Config options for the build system.
|
||||||
#[derive(Clone, Debug, Default, Deserialize, StructOpt)]
|
#[derive(Clone, Debug, Default, Deserialize, StructOpt)]
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
use crate::cfg::ConfigOptsBuild;
|
|
||||||
use anyhow::Result;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
/// Build the Rust WASM app and all of its assets.
|
/// Build the Rust WASM app and all of its assets.
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use anyhow::{Context, Result};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
pub mod build;
|
pub mod build;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use crate::{cfg::ConfigOptsServe, server};
|
use crate::{cfg::ConfigOptsServe, server};
|
||||||
use anyhow::Result;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pub fn convert_html_to_component(html: &str) -> Result<ComponentRenderer> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct ComponentRenderer {
|
pub struct ComponentRenderer {
|
||||||
dom: Dom,
|
dom: Dom,
|
||||||
icon_index: usize,
|
icon_index: usize,
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use std::{io::Write, path::PathBuf, process::Command};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CrateConfig {
|
pub struct CrateConfig {
|
||||||
|
|||||||
+3
-3
@@ -8,11 +8,11 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
match args.action {
|
match args.action {
|
||||||
Commands::Translate(opts) => {
|
Commands::Translate(opts) => {
|
||||||
opts.translate();
|
opts.translate()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands::Build(opts) => {
|
Commands::Build(opts) => {
|
||||||
opts.build();
|
opts.build()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commands::Clean(_) => {
|
// Commands::Clean(_) => {
|
||||||
@@ -23,7 +23,7 @@ async fn main() -> Result<()> {
|
|||||||
// //
|
// //
|
||||||
// }
|
// }
|
||||||
Commands::Serve(opts) => {
|
Commands::Serve(opts) => {
|
||||||
opts.serve().await;
|
opts.serve().await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -1,6 +1,6 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
extract::{
|
extract::{
|
||||||
ws::{Message, WebSocket},
|
ws::Message,
|
||||||
Extension, TypedHeader, WebSocketUpgrade,
|
Extension, TypedHeader, WebSocketUpgrade,
|
||||||
},
|
},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
@@ -19,11 +19,11 @@ struct WsRelodState {
|
|||||||
update: bool,
|
update: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WsRelodState { fn change(&mut self) { self.update = !self.update } }
|
impl WsRelodState { fn change(&mut self) { self.update = !self.update; } }
|
||||||
|
|
||||||
pub async fn startup(config: CrateConfig) -> anyhow::Result<()> {
|
pub async fn startup(config: CrateConfig) -> anyhow::Result<()> {
|
||||||
|
|
||||||
log::info!("Starting development server 🚀");
|
log::info!("🚀 Starting development server...");
|
||||||
|
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
|
||||||
@@ -40,8 +40,9 @@ pub async fn startup(config: CrateConfig) -> anyhow::Result<()> {
|
|||||||
match v {
|
match v {
|
||||||
DebouncedEvent::Create(_) | DebouncedEvent::Write(_) |
|
DebouncedEvent::Create(_) | DebouncedEvent::Write(_) |
|
||||||
DebouncedEvent::Remove(_) | DebouncedEvent::Rename(_, _) => {
|
DebouncedEvent::Remove(_) | DebouncedEvent::Rename(_, _) => {
|
||||||
builder::build(&watcher_conf).unwrap();
|
if let Ok(_) = builder::build(&watcher_conf) {
|
||||||
watcher_ws_state.lock().unwrap().change();
|
watcher_ws_state.lock().unwrap().change();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-8
@@ -14,15 +14,26 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const socket = new WebSocket("ws://localhost:8080/ws");
|
(function () {
|
||||||
|
var protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
||||||
socket.addEventListener("message", function (event) {
|
var url = protocol + "//" + window.location.host + "/ws";
|
||||||
console.log(event);
|
var poll_interval = 2000;
|
||||||
if (event.data === "reload") {
|
var reload_upon_connect = () => {
|
||||||
window.location.reload();
|
window.setTimeout(() => {
|
||||||
}
|
var ws = new WebSocket(url);
|
||||||
});
|
ws.onopen = () => window.location.reload();
|
||||||
|
ws.onclose = reload_upon_connect;
|
||||||
|
}, poll_interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
var ws = new WebSocket(url);
|
||||||
|
ws.onmessage = (ev) => {
|
||||||
|
if (ev.data == "reload") {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ws.onclose = reload_upon_connect;
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user