Ver código fonte

fixed cargo create bug

mgbvox 2 anos atrás
pai
commit
e38092fc44
4 arquivos alterados com 5 adições e 15 exclusões
  1. 2 2
      src/cli/create/mod.rs
  2. 1 1
      src/config.rs
  3. 2 2
      src/main.rs
  4. 0 10
      tests/main.rs

+ 2 - 2
src/cli/create/mod.rs

@@ -17,7 +17,7 @@ pub struct Create {
 impl Create {
     pub fn create(self) -> Result<()> {
         if Self::name_valid_check(self.name.clone()) {
-            return custom_error!("❗Unsupported project name.");
+            return custom_error!("❗Unsupported project name: '{}'.", &self.name);
         }
 
         let project_path = PathBuf::from(&self.name);
@@ -26,7 +26,7 @@ impl Create {
             return custom_error!("🧨 Folder '{}' is initialized.", &self.name);
         }
 
-        log::info!("🔧 Start to create a new project '{}'.", self.name);
+        log::info!("🔧 Start: Creating new project '{}'.", self.name);
 
         let output = Command::new("cargo")
             .arg("generate")

+ 1 - 1
src/config.rs

@@ -18,7 +18,7 @@ fn default_plugin() -> toml::Value {
 
 impl DioxusConfig {
     pub fn load() -> crate::error::Result<Option<DioxusConfig>> {
-        let crate_dir = crate::cargo::crate_root()?;
+        let Ok(crate_dir) = crate::cargo::crate_root() else { return Ok(None); };
 
         // we support either `Dioxus.toml` or `Cargo.toml`
         let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {

+ 2 - 2
src/main.rs

@@ -10,9 +10,9 @@ async fn main() -> anyhow::Result<()> {
     set_up_logging();
 
     let dioxus_config = DioxusConfig::load()
-        .map_err(|e| anyhow!("Failed to load `dioxus.toml` because: {e}"))?
+        .map_err(|e| anyhow!("Failed to load `Dioxus.toml` because: {e}"))?
         .unwrap_or_else(|| {
-            log::warn!("Your `dioxus.toml` could not be found. Using the default config. To set up this crate with dioxus, use `dioxus init`.");
+            log::warn!("You appear to be creating a Dioxus project from scratch; we will use the default config");
             DioxusConfig::default()
         });
 

+ 0 - 10
tests/main.rs

@@ -7,14 +7,4 @@ use std::process::Command; // Run programs
 #[test]
 fn ready() {
     println!("Compiled successfully!")
-}
-
-#[test]
-fn test_create() -> Result<(), Box<dyn Error>> {
-    let mut cmd = Command::cargo_bin("dioxus")?;
-    cmd.arg("create").arg("scratch");
-    cmd.assert()
-        .failure();
-
-    Ok(())
 }