fix: clean file

This commit is contained in:
mrxiaozhuox committed 2022-01-22 10:02:52 +08:00
1 parent d07fad470a
commit 281a075c6c
14 files changed
+35 -221

No files matched your search

+1 -1
View File
@@ -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"
-8
View File
@@ -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]
-8
View File
@@ -1,8 +0,0 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
+9 -5
View File
@@ -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, &copy_options) {
Ok(_) => {}
Err(_e) => {
log::warn!("Error copying dir");
if static_dir.is_dir() {
match fs_extra::dir::copy(static_dir, out_dir, &copy_options) {
Ok(_) => {}
Err(_e) => {
log::warn!("Error copying dir: {}", _e);
}
}
}
-4
View File
@@ -1,4 +0,0 @@
/*
todo: wasm splitting
*/
-1
View File
@@ -1 +0,0 @@
+13 -1
View File
@@ -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(())
}
}
-9
View File
@@ -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 {}
+2 -4
View File
@@ -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),
View File
Whitespace-only changes.
-164
View File
@@ -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<String>,
outdir: Option<String>,
release: bool,
hydrate: Option<String>,
template: Option<String>,
translate_file: Option<String>,
crate_config: Option<CrateConfig>,
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<Box<dyn Any>>,
}
impl TuiStudio {
fn use_hook<F: 'static>(&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::<F>().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<B: tui::backend::Backend>(&mut self, f: &mut tui::Frame<B>) {
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<B: tui::backend::Backend>(&mut self, f: &mut tui::Frame<B>) {
let options = [
"Bundle", "Develop",
//
];
}
}
-1
View File
@@ -1 +0,0 @@
+1 -9
View File
@@ -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;
+9 -6
View File
@@ -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(())