Fix compiler errors
This commit is contained in:
1 parent
b6c6dd6532
commit
ce628e1197
13 files changed
+101
-64
No files matched your search
@@ -1,16 +1,15 @@
|
||||
use super::*;
|
||||
|
||||
|
||||
/// Build the Rust WASM app and all of its assets.
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[structopt(name = "build")]
|
||||
#[clap(name = "build")]
|
||||
pub struct Build {
|
||||
#[structopt(flatten)]
|
||||
#[clap(flatten)]
|
||||
pub build: ConfigOptsBuild,
|
||||
}
|
||||
|
||||
impl Build {
|
||||
pub fn build(self) -> anyhow::Result<()> {
|
||||
pub fn build(self) -> Result<()> {
|
||||
let mut crate_config = crate::CrateConfig::new()?;
|
||||
|
||||
// change the release state.
|
||||
@@ -28,7 +27,7 @@ impl Build {
|
||||
crate::builder::build_desktop(&crate_config)?;
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!("Unsoppurt platform target."));
|
||||
return custom_error!("Unsoppurt platform target.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -4,40 +4,40 @@ use super::*;
|
||||
#[derive(Clone, Debug, Default, Deserialize, Parser)]
|
||||
pub struct ConfigOptsBuild {
|
||||
/// The index HTML file to drive the bundling process [default: index.html]
|
||||
#[structopt(parse(from_os_str))]
|
||||
#[clap(parse(from_os_str))]
|
||||
pub target: Option<PathBuf>,
|
||||
|
||||
/// Build in release mode [default: false]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
#[serde(default)]
|
||||
pub release: bool,
|
||||
|
||||
/// Build a example [default: ""]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
pub example: Option<String>,
|
||||
|
||||
/// Build platform: support Web & Desktop [default: "web"]
|
||||
#[structopt(long, default_value = "web")]
|
||||
#[clap(long, default_value = "web")]
|
||||
pub platform: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Parser)]
|
||||
pub struct ConfigOptsServe {
|
||||
/// The index HTML file to drive the bundling process [default: index.html]
|
||||
#[structopt(parse(from_os_str))]
|
||||
#[clap(parse(from_os_str))]
|
||||
pub target: Option<PathBuf>,
|
||||
|
||||
/// Build a example [default: ""]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
pub example: Option<String>,
|
||||
|
||||
/// Build in release mode [default: false]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
#[serde(default)]
|
||||
pub release: bool,
|
||||
|
||||
/// Build platform: support Web & Desktop [default: "web"]
|
||||
#[structopt(long, default_value = "web")]
|
||||
#[clap(long, default_value = "web")]
|
||||
pub platform: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@ use super::*;
|
||||
|
||||
/// Build the Rust WASM app and all of its assets.
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[structopt(name = "clean")]
|
||||
#[clap(name = "clean")]
|
||||
pub struct Clean {}
|
||||
|
||||
impl Clean {
|
||||
pub fn clean(self) -> anyhow::Result<()> {
|
||||
pub fn clean(self) -> Result<()> {
|
||||
let crate_config = crate::CrateConfig::new()?;
|
||||
|
||||
let output = Command::new("cargo")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use super::*;
|
||||
|
||||
|
||||
/// Build the Rust WASM app and all of its assets.
|
||||
#[derive(Clone, Debug, Deserialize, Parser)]
|
||||
#[structopt(name = "config")]
|
||||
#[derive(Clone, Debug, Deserialize, Subcommand)]
|
||||
#[clap(name = "config")]
|
||||
pub enum Config {
|
||||
/// Init `Dioxus.toml` for project/folder.
|
||||
Init {
|
||||
@@ -10,14 +11,14 @@ pub enum Config {
|
||||
name: String,
|
||||
|
||||
/// Cover old config
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
#[serde(default)]
|
||||
force: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn config(self) -> anyhow::Result<()> {
|
||||
pub fn config(self) -> Result<()> {
|
||||
let crate_root = crate::cargo::crate_root()?;
|
||||
match self {
|
||||
Config::Init { name, force } => {
|
||||
|
||||
+8
-12
@@ -1,15 +1,16 @@
|
||||
use super::*;
|
||||
use crate::custom_error;
|
||||
|
||||
/// Build the Rust WASM app and all of its assets.
|
||||
#[derive(Clone, Debug, Default, Deserialize, StructOpt)]
|
||||
#[structopt(name = "create")]
|
||||
#[derive(Clone, Debug, Default, Deserialize, Parser)]
|
||||
#[clap(name = "create")]
|
||||
pub struct Create {
|
||||
/// Init project name
|
||||
#[structopt(default_value = ".")]
|
||||
#[clap(default_value = ".")]
|
||||
name: String,
|
||||
|
||||
/// Template path
|
||||
#[structopt(default_value = "gh:dioxuslabs/dioxus-template", long)]
|
||||
#[clap(default_value = "gh:dioxuslabs/dioxus-template", long)]
|
||||
template: String,
|
||||
}
|
||||
|
||||
@@ -23,10 +24,7 @@ impl Create {
|
||||
let project_path = PathBuf::from(&self.name);
|
||||
|
||||
if project_path.join("Dioxus.toml").is_file() || project_path.join("Cargo.toml").is_file() {
|
||||
return Err(Error::Other(anyhow::anyhow!(
|
||||
"🧨 Folder '{}' is initialized.",
|
||||
&self.name
|
||||
)));
|
||||
return custom_error!("🧨 Folder '{}' is initialized.", &self.name);
|
||||
}
|
||||
|
||||
log::info!("🔧 Start to create a new project '{}'.", self.name);
|
||||
@@ -47,9 +45,7 @@ impl Create {
|
||||
.stderr(Stdio::inherit())
|
||||
.output()?;
|
||||
if !install_output.status.success() {
|
||||
return Err(Error::Other(anyhow::anyhow!(
|
||||
"Try to install cargo-generate failed."
|
||||
)));
|
||||
return custom_error!("Try to install cargo-generate failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +59,7 @@ impl Create {
|
||||
.output()?;
|
||||
|
||||
if !generate_output.status.success() {
|
||||
return Err(Error::Other(anyhow::anyhow!("Generate project failed.")));
|
||||
return custom_error!("Generate project failed.");
|
||||
}
|
||||
|
||||
let mut dioxus_file = File::open(project_path.join("Dioxus.toml"))?;
|
||||
|
||||
+17
-16
@@ -6,31 +6,31 @@ pub mod create;
|
||||
pub mod serve;
|
||||
pub mod translate;
|
||||
|
||||
use std::{io::Write, path::PathBuf};
|
||||
use crate::custom_error;
|
||||
use crate::{cfg::ConfigOptsBuild, gen_page};
|
||||
use clap::{Parser};
|
||||
use crate::{cfg::ConfigOptsServe, server, CrateConfig};
|
||||
use crate::{error::Result, Error};
|
||||
use clap::Parser;
|
||||
use html_parser::Dom;
|
||||
use html_parser::Element;
|
||||
use html_parser::Node;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::process::exit;
|
||||
use std::{
|
||||
fs::remove_dir_all,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
use std::{fs::File};
|
||||
use std::{
|
||||
io::{Read},
|
||||
};
|
||||
use regex::Regex;
|
||||
use crate::{error::Result, Error};
|
||||
use crate::{cfg::ConfigOptsServe, server, CrateConfig};
|
||||
use html_parser::Dom;
|
||||
use html_parser::Element;
|
||||
use html_parser::Node;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::process::exit;
|
||||
use std::{io::Write, path::PathBuf};
|
||||
use clap::{Subcommand};
|
||||
|
||||
/// Build, bundle, & ship your Dioxus app.
|
||||
///
|
||||
///
|
||||
#[derive(Parser, Debug)]
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "dioxus")]
|
||||
pub struct Cli {
|
||||
#[clap(subcommand)]
|
||||
@@ -42,7 +42,7 @@ pub struct Cli {
|
||||
//
|
||||
// // note: dioxus is still roughly compatible with trunk
|
||||
// /// Path to the Trunk config file [default: Trunk.toml]
|
||||
// #[structopt(long, parse(from_os_str), env = "TRUNK_CONFIG")]
|
||||
// #[clap(long, parse(from_os_str), env = "TRUNK_CONFIG")]
|
||||
// pub config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
@@ -59,5 +59,6 @@ pub enum Commands {
|
||||
/// Clean output artifacts.
|
||||
Clean(clean::Clean),
|
||||
/// Dioxus config file controls.
|
||||
#[clap(subcommand)]
|
||||
Config(config::Config),
|
||||
}
|
||||
@@ -2,14 +2,14 @@ use super::*;
|
||||
|
||||
/// Run the WASM project on dev-server
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[structopt(name = "serve")]
|
||||
#[clap(name = "serve")]
|
||||
pub struct Serve {
|
||||
#[structopt(flatten)]
|
||||
#[clap(flatten)]
|
||||
pub serve: ConfigOptsServe,
|
||||
}
|
||||
|
||||
impl Serve {
|
||||
pub async fn serve(self) -> anyhow::Result<()> {
|
||||
pub async fn serve(self) -> Result<()> {
|
||||
let mut crate_config = crate::CrateConfig::new()?;
|
||||
|
||||
// change the relase state.
|
||||
@@ -49,7 +49,7 @@ impl Serve {
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!("Unsoppurt platform target."));
|
||||
return custom_error!("Unsoppurt platform target.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ impl Serve {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn regen_dev_page(crate_config: &CrateConfig) -> anyhow::Result<()> {
|
||||
pub fn regen_dev_page(crate_config: &CrateConfig) -> Result<()> {
|
||||
let serve_html = gen_page(&crate_config.dioxus_config, true);
|
||||
|
||||
let mut file = std::fs::File::create(
|
||||
|
||||
@@ -2,24 +2,24 @@ use super::*;
|
||||
|
||||
/// Build the Rust WASM app and all of its assets.
|
||||
#[derive(Clone, Debug, Parser)]
|
||||
#[structopt(name = "translate")]
|
||||
#[clap(name = "translate")]
|
||||
pub struct Translate {
|
||||
/// Activate debug mode
|
||||
// short and long flags (-d, --debug) will be deduced from the field's name
|
||||
#[structopt(short, long)]
|
||||
#[clap(short, long)]
|
||||
pub component: bool,
|
||||
|
||||
/// Input file
|
||||
#[structopt(short, long)]
|
||||
#[clap(short, long)]
|
||||
pub file: Option<String>,
|
||||
|
||||
/// Output file, stdout if not present
|
||||
#[structopt(parse(from_os_str))]
|
||||
#[clap(parse(from_os_str))]
|
||||
pub output: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Translate {
|
||||
pub fn translate(self) -> anyhow::Result<()> {
|
||||
pub fn translate(self) -> Result<()> {
|
||||
let Translate {
|
||||
component,
|
||||
output,
|
||||
|
||||
Reference in new issue
Block a user