Procházet zdrojové kódy

refactor(cli): remove mobile assets folder symlink

Lucas Nogueira před 3 roky
rodič
revize
349895b296

+ 12 - 3
tooling/cli/src/mobile/android/project.rs

@@ -9,12 +9,13 @@ use cargo_mobile::{
     config::{Config, Metadata},
     target::Target,
   },
+  config::app::DEFAULT_ASSET_DIR,
   os,
   target::TargetTrait as _,
   util::{
     self,
     cli::{Report, TextWrapper},
-    ln, prefix_path,
+    prefix_path,
   },
 };
 use handlebars::Handlebars;
@@ -150,8 +151,16 @@ pub fn gen(
       cause
     )
   })?;
-  os::ln::force_symlink_relative(config.app().asset_dir(), dest, ln::TargetStyle::Directory)
-    .map_err(|_| anyhow::anyhow!("failed to symlink asset directory"))?;
+
+  let asset_dir = dest.join(DEFAULT_ASSET_DIR);
+  if !asset_dir.is_dir() {
+    fs::create_dir_all(&asset_dir).map_err(|cause| {
+      anyhow::anyhow!(
+        "failed to create asset dir {path}: {cause}",
+        path = asset_dir.display()
+      )
+    })?;
+  }
 
   Ok(())
 }

+ 1 - 11
tooling/cli/src/mobile/init.rs

@@ -19,7 +19,7 @@ use cargo_mobile::{
 };
 use handlebars::{Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderError};
 
-use std::{env::current_dir, fs, path::PathBuf};
+use std::{env::current_dir, path::PathBuf};
 
 pub fn command(target: Target, ci: bool, reinstall_deps: bool) -> Result<()> {
   let wrapper = TextWrapper::with_splitter(textwrap::termwidth(), textwrap::NoHyphenation);
@@ -71,16 +71,6 @@ pub fn exec(
 
   let app = get_app(tauri_config_);
 
-  let asset_dir = app.asset_dir();
-  if !asset_dir.is_dir() {
-    fs::create_dir_all(&asset_dir).map_err(|cause| {
-      anyhow::anyhow!(
-        "failed to create asset dir {path}: {cause}",
-        path = asset_dir.display()
-      )
-    })?;
-  }
-
   let (handlebars, mut map) = handlebars(&app);
 
   let mut args = std::env::args_os();

+ 11 - 3
tooling/cli/src/mobile/ios/project.rs

@@ -11,8 +11,9 @@ use cargo_mobile::{
     target::Target,
   },
   bossy,
+  config::app::DEFAULT_ASSET_DIR,
   target::TargetTrait as _,
-  util::{self, cli::TextWrapper, ln},
+  util::{self, cli::TextWrapper},
 };
 use handlebars::Handlebars;
 use include_dir::{include_dir, Dir};
@@ -140,8 +141,15 @@ pub fn gen(
   )
   .with_context(|| "failed to process template")?;
 
-  ln::force_symlink_relative(config.app().asset_dir(), &dest, ln::TargetStyle::Directory)
-    .map_err(|_| anyhow::anyhow!("failed to symlink asset directory"))?;
+  let asset_dir = dest.join(DEFAULT_ASSET_DIR);
+  if !asset_dir.is_dir() {
+    create_dir_all(&asset_dir).map_err(|cause| {
+      anyhow::anyhow!(
+        "failed to create asset dir {path}: {cause}",
+        path = asset_dir.display()
+      )
+    })?;
+  }
 
   // Create all asset catalog directories if they don't already exist
   for dir in asset_catalogs {