diff --git a/Cargo.toml b/Cargo.toml index 238cec2e2..3a8b061ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT/Apache-2.0" thiserror = "1.0.23" log = "0.4.13" fern = { version = "0.6.0", features = ["colored"] } -wasm-bindgen-cli-support = "0.2.78" +wasm-bindgen-cli-support = "0.2.79" anyhow = "1.0.38" serde = { version = "1.0.133", features = ["derive"] } serde_json = "1" diff --git a/packages/rsx-translate/Cargo.toml b/packages/rsx-translate/Cargo.toml deleted file mode 100644 index 2af83c634..000000000 --- a/packages/rsx-translate/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "rsx-translate" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/packages/rsx-translate/src/lib.rs b/packages/rsx-translate/src/lib.rs deleted file mode 100644 index 1b4a90c93..000000000 --- a/packages/rsx-translate/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} diff --git a/src/builder.rs b/src/builder.rs index b80c3dd36..b5bae9bf9 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -37,6 +37,7 @@ pub fn build(config: &CrateConfig) -> Result<()> { .arg("wasm32-unknown-unknown") .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()); + ; if config.release { cmd.arg("--release"); @@ -49,10 +50,11 @@ pub fn build(config: &CrateConfig) -> Result<()> { }; let mut child = cmd.spawn()?; + let output = child.wait()?; if output.success() { - log::info!("Build complete!"); + log::info!("Build complete! {:?}", reason); } else { log::error!("Build failed!"); let mut reason = String::new(); @@ -102,10 +104,12 @@ pub fn build(config: &CrateConfig) -> Result<()> { file.write_all(gen_page("./wasm/module.js").as_str().as_bytes())?; let copy_options = fs_extra::dir::CopyOptions::new(); - match fs_extra::dir::copy(static_dir, out_dir, ©_options) { - Ok(_) => {} - Err(_e) => { - log::warn!("Error copying dir"); + if static_dir.is_dir() { + match fs_extra::dir::copy(static_dir, out_dir, ©_options) { + Ok(_) => {} + Err(_e) => { + log::warn!("Error copying dir: {}", _e); + } } } diff --git a/src/buildsystem/assets.rs b/src/buildsystem/assets.rs deleted file mode 100644 index e35ac1005..000000000 --- a/src/buildsystem/assets.rs +++ /dev/null @@ -1,4 +0,0 @@ -/* - -todo: wasm splitting -*/ diff --git a/src/buildsystem/wasm.rs b/src/buildsystem/wasm.rs deleted file mode 100644 index 8b1378917..000000000 --- a/src/buildsystem/wasm.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 33a81a540..f4b69d5d7 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -11,4 +11,16 @@ pub struct Build { pub build: ConfigOptsBuild, } -pub async fn perform_build() {} +impl Build { + pub fn build(self) -> anyhow::Result<()> { + + let mut crate_config = crate::CrateConfig::new()?; + + // change the relase state. + crate_config.with_release(self.build.release); + + crate::builder::build(&crate_config); + + Ok(()) + } +} \ No newline at end of file diff --git a/src/cli/config/mod.rs b/src/cli/config/mod.rs deleted file mode 100644 index 616c9bc78..000000000 --- a/src/cli/config/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::cfg::ConfigOptsBuild; -use anyhow::Result; -use std::path::PathBuf; -use structopt::StructOpt; - -/// Build the Rust WASM app and all of its assets. -#[derive(Clone, Debug, StructOpt)] -#[structopt(name = "config")] -pub struct Config {} diff --git a/src/cli/mod.rs b/src/cli/mod.rs index fe118cbb7..fa3bd2c77 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -5,10 +5,8 @@ use structopt::StructOpt; pub mod build; pub mod cfg; pub mod clean; -pub mod config; pub mod serve; pub mod translate; -pub mod watch; /// Build, bundle, & ship your Dioxus app. /// @@ -32,11 +30,11 @@ pub struct Cli { #[derive(StructOpt)] pub enum Commands { // /// Build the Rust WASM app and all of its assets. - // Build(build::Build), + Build(build::Build), /// Translate some source file into Dioxus code. Translate(translate::Translate), // /// Build, watch & serve the Rust WASM app and all of its assets. - // Serve(serve::Serve), + Serve(serve::Serve), // /// Clean output artifacts. // Clean(clean::Clean), diff --git a/src/cli/serve/draw.rs b/src/cli/serve/draw.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cli/serve/studio.rs b/src/cli/serve/studio.rs deleted file mode 100644 index 60c330beb..000000000 --- a/src/cli/serve/studio.rs +++ /dev/null @@ -1,164 +0,0 @@ -//! It's better to store all the configuration in one spot - -use tui::{ - backend::{Backend, CrosstermBackend}, - layout::{Constraint, Direction, Layout, Rect}, - style::{Color, Modifier, Style}, - symbols, - text::{Span, Spans}, - widgets::canvas::{Canvas, Line, Map, MapResolution, Rectangle}, - widgets::{ - Axis, BarChart, Block, BorderType, Borders, Cell, Chart, Dataset, Gauge, LineGauge, List, - ListItem, Paragraph, Row, Sparkline, Table, Tabs, Wrap, - }, - Frame, Terminal, -}; - -use crate::*; -use std::{any::Any, io::Write, path::PathBuf, process::Command}; - -pub struct Cfg { - command: LaunchOptions, - headless: bool, - example: Option, - outdir: Option, - release: bool, - hydrate: Option, - template: Option, - translate_file: Option, - crate_config: Option, - should_quit: bool, -} - -pub async fn start(options: DevelopOptions) -> Result<()> { - let mut state = Cfg { - command: todo!(), - headless: todo!(), - example: todo!(), - outdir: todo!(), - release: todo!(), - hydrate: todo!(), - template: todo!(), - translate_file: todo!(), - crate_config: todo!(), - should_quit: false, - }; - - crossterm::terminal::enable_raw_mode()?; - - let backend = CrosstermBackend::new(std::io::stdout()); - let mut terminal = Terminal::new(backend).unwrap(); - - // Setup input handling - // let (tx, rx) = futures::channel::mpsc::unbounded(); - let tick_rate = std::time::Duration::from_millis(100); - - let mut prev_time = std::time::Instant::now(); - while !state.should_quit { - let next_time = prev_time + tick_rate; - let now = std::time::Instant::now(); - - let diff = next_time - std::time::Instant::now(); - } - - Ok(()) -} - -struct TuiStudio { - cfg: Cfg, - hook_idx: usize, - hooks: Vec>, -} -impl TuiStudio { - fn use_hook(&mut self, f: impl FnOnce() -> F) -> &mut F { - if self.hook_idx == self.hooks.len() { - self.hooks.push(Box::new(f())); - } - let idx = self.hook_idx; - self.hook_idx += 1; - let hook = self.hooks.get_mut(idx).unwrap(); - let r = hook.downcast_mut::().unwrap(); - r - } -} - -impl TuiStudio { - fn event_handler(&self, action: crossterm::event::Event) -> anyhow::Result<()> { - match action { - crossterm::event::Event::Key(_) => {} - crossterm::event::Event::Mouse(_) => {} - crossterm::event::Event::Resize(_, _) => {} - } - Ok(()) - } - - fn handle_key(&mut self, key: crossterm::event::KeyEvent) {} - - fn tick(&mut self) {} - - fn should_quit(&self) -> bool { - false - } - - fn render(&mut self, f: &mut tui::Frame) { - self.hook_idx = 0; - - // Wrapping block for a group - // Just draw the block and the group on the same area and build the group - // with at least a margin of 1 - let size = f.size(); - let block = Block::default() - .borders(Borders::ALL) - .title("Main block with round corners") - .border_type(BorderType::Rounded); - f.render_widget(block, size); - let chunks = Layout::default() - .direction(Direction::Vertical) - .margin(4) - .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) - .split(f.size()); - - let top_chunks = Layout::default() - .direction(Direction::Horizontal) - .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) - .split(chunks[0]); - let block = Block::default() - .title(vec![ - Span::styled("With", Style::default().fg(Color::Yellow)), - Span::from(" background"), - ]) - .style(Style::default().bg(Color::Green)); - f.render_widget(block, top_chunks[0]); - - let block = Block::default().title(Span::styled( - "Styled title", - Style::default() - .fg(Color::White) - .bg(Color::Red) - .add_modifier(Modifier::BOLD), - )); - f.render_widget(block, top_chunks[1]); - - let bottom_chunks = Layout::default() - .direction(Direction::Horizontal) - .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) - .split(chunks[1]); - let block = Block::default().title("With borders").borders(Borders::ALL); - f.render_widget(block, bottom_chunks[0]); - let block = Block::default() - .title("With styled borders and doubled borders") - .border_style(Style::default().fg(Color::Cyan)) - .borders(Borders::LEFT | Borders::RIGHT) - .border_type(BorderType::Double); - f.render_widget(block, bottom_chunks[1]); - } -} - -impl TuiStudio { - fn render_list(&mut self, f: &mut tui::Frame) { - let options = [ - "Bundle", "Develop", - // - ]; - } -} diff --git a/src/cli/watch/mod.rs b/src/cli/watch/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/src/cli/watch/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/lib.rs b/src/lib.rs index 4cc4f2d75..ea8393484 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,12 +16,4 @@ pub use error::*; pub mod logging; pub use logging::*; -pub mod watch; - -pub mod buildsystem { - pub mod wasm; - pub use wasm::*; - - pub mod assets; - pub use assets::*; -} +pub mod watch; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 798c492dc..2ec44eb97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,15 +3,18 @@ use structopt::StructOpt; #[tokio::main] async fn main() -> Result<()> { + let args = Cli::from_args(); set_up_logging(); match args.action { Commands::Translate(opts) => { opts.translate(); - } // Commands::Build(_) => { - // // - // } + } + + Commands::Build(opts) => { + opts.build(); + } // Commands::Clean(_) => { // // @@ -21,9 +24,9 @@ async fn main() -> Result<()> { // // // } - // Commands::Serve(_) => { - // // - // } + Commands::Serve(_) => { + // + } } Ok(())