fix(cli): map --profile dev to debug folder when finding executable (#8776)

This commit is contained in:
Amr Bashir 2024-02-05 16:12:08 +02:00 committed by GitHub
parent cc3d8e7731
commit b0f27814b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 69 deletions

View File

@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---
Fix `fail to rename app` when using `--profile dev`.

View File

@ -23,8 +23,6 @@ use std::{
path::{Path, PathBuf},
};
use flate2::{write::GzEncoder, Compression};
use anyhow::Context;
use log::info;
use zip::write::FileOptions;
@ -236,6 +234,8 @@ pub fn create_zip(src_file: &Path, dst_file: &Path) -> crate::Result<PathBuf> {
#[cfg(not(target_os = "windows"))]
fn create_tar(src_dir: &Path, dest_path: &Path) -> crate::Result<PathBuf> {
use flate2::{write::GzEncoder, Compression};
let dest_file = common::create_file(dest_path)?;
let gzip_encoder = GzEncoder::new(dest_file, Compression::default());

74
tooling/cli/Cargo.lock generated
View File

@ -17,12 +17,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler32"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "aead"
version = "0.5.2"
@ -533,15 +527,6 @@ version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "core2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505"
dependencies = [
"memchr",
]
[[package]]
name = "cpufeatures"
version = "0.2.11"
@ -711,12 +696,6 @@ dependencies = [
"syn 2.0.39",
]
[[package]]
name = "dary_heap"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca"
[[package]]
name = "data-encoding"
version = "2.5.0"
@ -1193,15 +1172,6 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.14.3"
@ -1647,30 +1617,6 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libflate"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7d5654ae1795afc7ff76f4365c2c8791b0feb18e8996a96adad8ffd7c3b2bf"
dependencies = [
"adler32",
"core2",
"crc32fast",
"dary_heap",
"libflate_lz77",
]
[[package]]
name = "libflate_lz77"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be5f52fb8c451576ec6b79d3f4deb327398bc05bbdbd99021a6e77a4c855d524"
dependencies = [
"core2",
"hashbrown 0.13.2",
"rle-decode-fast",
]
[[package]]
name = "libloading"
version = "0.8.1"
@ -2745,12 +2691,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "rle-decode-fast"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
[[package]]
name = "rpassword"
version = "7.3.1"
@ -3212,6 +3152,17 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "socks"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b"
dependencies = [
"byteorder",
"libc",
"winapi",
]
[[package]]
name = "spin"
version = "0.9.8"
@ -3401,12 +3352,12 @@ dependencies = [
"ar",
"dirs-next",
"dunce",
"flate2",
"glob",
"handlebars",
"heck",
"hex",
"image",
"libflate",
"log",
"md5",
"native-tls",
@ -3921,6 +3872,7 @@ dependencies = [
"once_cell",
"rustls",
"rustls-webpki",
"socks",
"url",
"webpki-roots",
]

View File

@ -692,7 +692,7 @@ impl AppSettings for RustAppSettings {
.expect("Cargo manifest must have the `package.name` field");
let out_dir = self
.out_dir(options.target.clone(), get_profile(options))
.out_dir(options.target.clone(), get_profile_dir(options).to_string())
.with_context(|| "failed to get project out directory")?;
let binary_extension: String = if self.target_triple.contains("windows") {
@ -986,13 +986,20 @@ pub fn get_workspace_dir() -> crate::Result<PathBuf> {
)
}
pub fn get_profile(options: &Options) -> String {
pub fn get_profile(options: &Options) -> &str {
options
.args
.iter()
.position(|a| a == "--profile")
.map(|i| options.args[i + 1].clone())
.unwrap_or_else(|| if options.debug { "debug" } else { "release" }.into())
.map(|i| options.args[i + 1].as_str())
.unwrap_or_else(|| if options.debug { "debug" } else { "release" })
}
pub fn get_profile_dir(options: &Options) -> &str {
match get_profile(options) {
"dev" => "debug",
profile => profile,
}
}
#[allow(unused_variables)]

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use super::{get_profile, AppSettings, DevChild, ExitReason, Options, RustAppSettings, Target};
use super::{get_profile_dir, AppSettings, DevChild, ExitReason, Options, RustAppSettings, Target};
use crate::CommandExt;
use tauri_utils::display_path;
@ -125,7 +125,7 @@ pub fn build(
options.target.replace(triple.into());
let triple_out_dir = app_settings
.out_dir(Some(triple.into()), get_profile(&options))
.out_dir(Some(triple.into()), get_profile_dir(&options).to_string())
.with_context(|| format!("failed to get {triple} out dir"))?;
build_production_app(options, available_targets, config_features.clone())