chore: remove unstable log features & use qualified log::<macro> path (#9069)

* chore: remove unstable log features & use qualified `log::<macro>` path

* fmt

* fix build
This commit is contained in:
Amr Bashir 2024-03-04 21:22:07 +02:00 committed by GitHub
parent 46de49aaad
commit 9aa0d6e959
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 147 additions and 173 deletions

View File

@ -0,0 +1,5 @@
---
'tauri-utils': 'major:breaking'
---
Removed `debug_eprintln!` and `consume_unused_variable` macros.

1
Cargo.lock generated
View File

@ -3753,6 +3753,7 @@ dependencies = [
"gtk",
"http",
"jni",
"log",
"percent-encoding",
"raw-window-handle 0.6.0",
"softbuffer",

View File

@ -21,6 +21,7 @@ raw-window-handle = "0.6"
http = "0.2"
url = "2"
tracing = { version = "0.1", optional = true }
log = "0.4"
[target."cfg(windows)".dependencies]
webview2-com = "0.28"

View File

@ -59,7 +59,7 @@ use tao::{
};
#[cfg(target_os = "macos")]
use tauri_utils::TitleBarStyle;
use tauri_utils::{config::WindowConfig, debug_eprintln, Theme};
use tauri_utils::{config::WindowConfig, Theme};
use url::Url;
use wry::{
FileDropEvent as WryFileDropEvent, ProxyConfig, ProxyEndpoint, WebContext, WebView,
@ -2808,14 +2808,14 @@ fn handle_user_message<T: UserEvent>(
WebviewMessage::EvaluateScript(script, tx, span) => {
let _span = span.entered();
if let Err(e) = webview.evaluate_script(&script) {
debug_eprintln!("{}", e);
log::error!("{}", e);
}
tx.send(()).unwrap();
}
#[cfg(not(all(feature = "tracing", not(target_os = "android"))))]
WebviewMessage::EvaluateScript(script) => {
if let Err(e) = webview.evaluate_script(&script) {
debug_eprintln!("{}", e);
log::error!("{}", e);
}
}
WebviewMessage::Navigate(url) => webview.load_url(url.as_str()),
@ -2964,7 +2964,7 @@ fn handle_user_message<T: UserEvent>(
});
}
Err(e) => {
debug_eprintln!("{}", e);
log::error!("{}", e);
}
}
}
@ -2974,7 +2974,7 @@ fn handle_user_message<T: UserEvent>(
windows.0.borrow_mut().insert(window_id, webview);
}
Err(e) => {
debug_eprintln!("{}", e);
log::error!("{}", e);
}
},
Message::CreateRawWindow(window_id, handler, sender) => {

View File

@ -22,8 +22,6 @@ use std::{
use semver::Version;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use log::warn;
pub mod acl;
pub mod assets;
pub mod config;
@ -320,7 +318,7 @@ impl Default for Env {
.unwrap_or(true);
if !is_temp {
warn!("`APPDIR` or `APPIMAGE` environment variable found but this application was not detected as an AppImage; this might be a security issue.");
log::warn!("`APPDIR` or `APPIMAGE` environment variable found but this application was not detected as an AppImage; this might be a security issue.");
}
}
env
@ -388,34 +386,6 @@ pub enum Error {
NotAllowedToWalkDir(std::path::PathBuf),
}
/// Suppresses the unused-variable warnings of the given inputs.
///
/// This does not move any values. Instead, it just suppresses the warning by taking a
/// reference to the value.
#[macro_export]
macro_rules! consume_unused_variable {
($($arg:expr),*) => {
$(
let _ = &$arg;
)*
()
};
}
/// Prints to the standard error, with a newline.
///
/// Equivalent to the [`eprintln!`] macro, except that it's only effective for debug builds.
#[macro_export]
macro_rules! debug_eprintln {
() => ($crate::debug_eprintln!(""));
($($arg:tt)*) => {
#[cfg(debug_assertions)]
eprintln!($($arg)*);
#[cfg(not(debug_assertions))]
$crate::consume_unused_variable!($($arg)*);
};
}
/// Reconstructs a path from its components using the platform separator then converts it to String and removes UNC prefixes on Windows if it exists.
pub fn display_path<P: AsRef<Path>>(p: P) -> String {
dunce::simplified(&p.as_ref().components().collect::<PathBuf>())

View File

@ -73,6 +73,7 @@ ico = { version = "0.3.0", optional = true }
http-range = { version = "0.1.5", optional = true }
tracing = { version = "0.1", optional = true }
heck = "0.4"
log = "0.4"
[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
muda = { version = "0.11", default-features = false, features = [ "serde" ] }
@ -96,9 +97,6 @@ window-vibrancy = "0.5"
version = "0.52"
features = [ "Win32_Foundation" ]
[target."cfg(any(target_os = \"android\", target_os = \"ios\"))".dependencies]
log = "0.4"
[target."cfg(target_os = \"android\")".dependencies]
jni = "0.21"

View File

@ -40,7 +40,7 @@ use tauri_runtime::{
},
RuntimeInitArgs,
};
use tauri_utils::{debug_eprintln, PackageInfo};
use tauri_utils::PackageInfo;
use std::{
borrow::Cow,
@ -402,7 +402,7 @@ impl<R: Runtime> AppHandle<R> {
/// Exits the app by triggering [`RunEvent::ExitRequested`] and [`RunEvent::Exit`].
pub fn exit(&self, exit_code: i32) {
if let Err(e) = self.runtime_handle.request_exit(exit_code) {
debug_eprintln!("failed to exit: {}", e);
log::error!("failed to exit: {}", e);
self.cleanup_before_exit();
std::process::exit(exit_code);
}

View File

@ -13,7 +13,6 @@ use serde::Serialize;
use url::Url;
use tauri_macros::default_runtime;
use tauri_utils::debug_eprintln;
use tauri_utils::{
assets::{AssetKey, CspHash},
config::{Csp, CspDirectiveSources},
@ -67,7 +66,7 @@ fn set_csp<R: Runtime>(
acc.style.push(hash.into());
}
_csp_hash => {
debug_eprintln!("Unknown CspHash variant encountered: {:?}", _csp_hash);
log::debug!("Unknown CspHash variant encountered: {:?}", _csp_hash);
}
}
@ -362,14 +361,14 @@ impl<R: Runtime> AppManager<R> {
let asset_response = assets
.get(&path.as_str().into())
.or_else(|| {
debug_eprintln!("Asset `{path}` not found; fallback to {path}.html");
log::debug!("Asset `{path}` not found; fallback to {path}.html");
let fallback = format!("{}.html", path.as_str()).into();
let asset = assets.get(&fallback);
asset_path = fallback;
asset
})
.or_else(|| {
debug_eprintln!(
log::debug!(
"Asset `{}` not found; fallback to {}/index.html",
path,
path
@ -380,7 +379,7 @@ impl<R: Runtime> AppManager<R> {
asset
})
.or_else(|| {
debug_eprintln!("Asset `{}` not found; fallback to index.html", path);
log::debug!("Asset `{}` not found; fallback to index.html", path);
let fallback = AssetKey::from("index.html");
let asset = assets.get(&fallback);
asset_path = fallback;
@ -412,7 +411,7 @@ impl<R: Runtime> AppManager<R> {
})
}
Err(e) => {
debug_eprintln!("{:?}", e); // TODO log::error!
log::error!("{:?}", e);
Err(Box::new(e))
}
}

View File

@ -6,7 +6,6 @@ use crate::{path::SafePathBuf, scope, webview::UriSchemeProtocolHandler};
use http::{header::*, status::StatusCode, Request, Response};
use http_range::HttpRange;
use std::{borrow::Cow, io::SeekFrom};
use tauri_utils::debug_eprintln;
use tauri_utils::mime_type::MimeType;
use tokio::fs::File;
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
@ -40,12 +39,12 @@ fn get_response(
let mut resp = Response::builder().header("Access-Control-Allow-Origin", window_origin);
if let Err(e) = SafePathBuf::new(path.clone().into()) {
debug_eprintln!("asset protocol path \"{}\" is not valid: {}", path, e);
log::error!("asset protocol path \"{}\" is not valid: {}", path, e);
return resp.status(403).body(Vec::new().into()).map_err(Into::into);
}
if !scope.is_allowed(&path) {
debug_eprintln!("asset protocol not configured to allow the path: {}", path);
log::error!("asset protocol not configured to allow the path: {}", path);
return resp.status(403).body(Vec::new().into()).map_err(Into::into);
}

View File

@ -146,7 +146,7 @@ fn get_response<R: Runtime>(
.body(response.body.to_vec().into())?
}
Err(e) => {
tauri_utils::debug_eprintln!("Failed to request {}: {}", url.as_str(), e);
log::error!("Failed to request {}: {}", url.as_str(), e);
return Err(Box::new(e));
}
}

View File

@ -29,7 +29,7 @@ tar = "0.4.40"
walkdir = "2"
handlebars = "5.1"
tempfile = "3.10.1"
log = { version = "0.4.21", features = [ "kv_unstable" ] }
log = { version = "0.4.21", features = [ "kv" ] }
dirs-next = "2.0"
os_pipe = "1"
ureq = { version = "2.9.6", default-features = false, features = [ "socks-proxy" ] }

View File

@ -27,7 +27,6 @@ pub use self::{
};
#[cfg(target_os = "macos")]
use anyhow::Context;
use log::{info, warn};
pub use settings::{NsisSettings, WindowsSettings, WixLanguage, WixLanguageConfig, WixSettings};
use std::{fmt::Write, path::PathBuf};
@ -61,7 +60,7 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
.replace("darwin", "macos");
if target_os != std::env::consts::OS {
warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
log::warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
}
#[cfg(target_os = "windows")]
@ -78,7 +77,7 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
if !skip && windows::sign::verify(&path)? {
info!(
log::info!(
"sidecar at \"{}\" already signed. Skipping...",
path.display()
)
@ -135,13 +134,13 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
| PackageType::WindowsMsi
)
}) {
warn!("The updater bundle target exists but couldn't find any updater-enabled target, so the updater artifacts won't be generated. Please add one of these targets as well: app, appimage, msi, nsis");
log::warn!("The updater bundle target exists but couldn't find any updater-enabled target, so the updater artifacts won't be generated. Please add one of these targets as well: app, appimage, msi, nsis");
continue;
}
updater_bundle::bundle_project(&settings, &bundles)?
}
_ => {
warn!("ignoring {}", package_type.short_name());
log::warn!("ignoring {}", package_type.short_name());
continue;
}
};
@ -163,7 +162,7 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
.map(|b| b.bundle_paths)
{
for app_bundle_path in &app_bundle_paths {
info!(action = "Cleaning"; "{}", app_bundle_path.display());
log::info!(action = "Cleaning"; "{}", app_bundle_path.display());
match app_bundle_path.is_dir() {
true => std::fs::remove_dir_all(app_bundle_path),
false => std::fs::remove_file(app_bundle_path),
@ -201,7 +200,7 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
}
}
info!(action = "Finished"; "{} {} at:\n{}", bundles_wo_updater.len(), pluralised, printable_paths);
log::info!(action = "Finished"; "{} {} at:\n{}", bundles_wo_updater.len(), pluralised, printable_paths);
Ok(bundles)
} else {

View File

@ -3,8 +3,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use log::debug;
use std::{
ffi::OsStr,
fs::{self, File},
@ -173,14 +171,14 @@ impl CommandExt for Command {
self.stdout(os_pipe::dup_stdout()?);
self.stderr(os_pipe::dup_stderr()?);
let program = self.get_program().to_string_lossy().into_owned();
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
log::debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
self.status().map_err(Into::into)
}
fn output_ok(&mut self) -> crate::Result<Output> {
let program = self.get_program().to_string_lossy().into_owned();
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
log::debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
self.stdout(Stdio::piped());
self.stderr(Stdio::piped());
@ -198,7 +196,7 @@ impl CommandExt for Command {
match stdout.read_line(&mut line) {
Ok(0) => break,
Ok(_) => {
debug!(action = "stdout"; "{}", line.trim_end());
log::debug!(action = "stdout"; "{}", line.trim_end());
lines.extend(line.as_bytes().to_vec());
}
Err(_) => (),
@ -217,7 +215,7 @@ impl CommandExt for Command {
match stderr.read_line(&mut line) {
Ok(0) => break,
Ok(_) => {
debug!(action = "stderr"; "{}", line.trim_end());
log::debug!(action = "stderr"; "{}", line.trim_end());
lines.extend(line.as_bytes().to_vec());
}
Err(_) => (),

View File

@ -13,7 +13,6 @@ use super::{
use crate::Settings;
use anyhow::Context;
use handlebars::Handlebars;
use log::info;
use std::{
collections::BTreeMap,
fs::{remove_dir_all, write},
@ -95,7 +94,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
// create the shell script file in the target/ folder.
let sh_file = output_path.join("build_appimage.sh");
info!(action = "Bundling"; "{} ({})", appimage_filename, appimage_path.display());
log::info!(action = "Bundling"; "{} ({})", appimage_filename, appimage_path.display());
write(&sh_file, temp)?;

View File

@ -28,7 +28,6 @@ use crate::Settings;
use anyhow::Context;
use flate2::{write::GzEncoder, Compression};
use heck::AsKebabCase;
use log::info;
use tar::HeaderMode;
use walkdir::WalkDir;
@ -66,7 +65,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
}
let package_path = base_dir.join(&package_name);
info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
log::info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
let (data_dir, _) = generate_data(settings, &package_dir)
.with_context(|| "Failed to build data folders and files")?;

View File

@ -6,7 +6,6 @@
use crate::Settings;
use anyhow::Context;
use log::info;
use rpm::{self, signature::pgp, Dependency, FileMode, FileOptions};
use std::{
env,
@ -43,7 +42,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
fs::create_dir_all(&package_dir)?;
let package_path = base_dir.join(&package_name);
info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
log::info!(action = "Bundling"; "{} ({})", package_name, package_path.display());
let license = settings.license().unwrap_or_default();
let mut builder = rpm::PackageBuilder::new(name, version, &license, arch, summary)

View File

@ -30,7 +30,6 @@ use super::{
use crate::Settings;
use anyhow::Context;
use log::{info, warn};
use std::{
ffi::OsStr,
@ -60,7 +59,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
.join("bundle/macos")
.join(&app_product_name);
info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());
log::info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());
if app_bundle_path.exists() {
fs::remove_dir_all(&app_bundle_path)
@ -130,7 +129,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
if matches!(e, NotarizeAuthError::MissingTeamId) {
return Err(anyhow::anyhow!("{e}").into());
} else {
warn!("skipping app notarization, {}", e.to_string());
log::warn!("skipping app notarization, {}", e.to_string());
}
}
}

View File

@ -10,7 +10,6 @@ use crate::{
};
use anyhow::Context;
use log::info;
use std::{
env,
@ -70,7 +69,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
// create paths for script
let bundle_script_path = output_path.join("bundle_dmg.sh");
info!(action = "Bundling"; "{} ({})", dmg_name, dmg_path.display());
log::info!(action = "Bundling"; "{} ({})", dmg_name, dmg_path.display());
// write the scripts
write(
@ -175,7 +174,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
}
}
info!(action = "Running"; "bundle_dmg.sh");
log::info!(action = "Running"; "bundle_dmg.sh");
// execute the bundle script
bundle_dmg_cmd

View File

@ -17,7 +17,6 @@ use crate::{bundle::common, Settings};
use anyhow::Context;
use image::{self, codecs::png::PngDecoder, GenericImageView, ImageDecoder};
use log::{info, warn};
use std::{
collections::BTreeSet,
@ -30,7 +29,7 @@ use std::{
/// Bundles the project.
/// Returns a vector of PathBuf that shows where the .app was created.
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
warn!("iOS bundle support is still experimental.");
log::warn!("iOS bundle support is still experimental.");
let app_product_name = format!("{}.app", settings.product_name());
@ -39,7 +38,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
.join("bundle/ios")
.join(&app_product_name);
info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());
log::info!(action = "Bundling"; "{} ({})", app_product_name, app_bundle_path.display());
if app_bundle_path.exists() {
fs::remove_dir_all(&app_bundle_path)

View File

@ -14,7 +14,6 @@ use std::{
use crate::{bundle::common::CommandExt, Settings};
use anyhow::Context;
use log::info;
use serde::Deserialize;
const KEYCHAIN_ID: &str = "tauri-build.keychain";
@ -32,7 +31,7 @@ pub fn setup_keychain(
) -> crate::Result<()> {
// we delete any previous version of our keychain if present
delete_keychain();
info!("setup keychain from environment variables...");
log::info!("setup keychain from environment variables...");
let keychain_list_output = Command::new("security")
.args(["list-keychain", "-d", "user"])
@ -150,7 +149,7 @@ pub struct SignTarget {
}
pub fn sign(targets: Vec<SignTarget>, identity: &str, settings: &Settings) -> crate::Result<()> {
info!(action = "Signing"; "with identity \"{}\"", identity);
log::info!(action = "Signing"; "with identity \"{}\"", identity);
let setup_keychain = if let (Some(certificate_encoded), Some(certificate_password)) = (
var_os("APPLE_CERTIFICATE"),
@ -164,7 +163,7 @@ pub fn sign(targets: Vec<SignTarget>, identity: &str, settings: &Settings) -> cr
false
};
info!("Signing app bundle...");
log::info!("Signing app bundle...");
for target in targets {
try_sign(
@ -191,7 +190,7 @@ fn try_sign(
is_an_executable: bool,
tauri_keychain: bool,
) -> crate::Result<()> {
info!(action = "Signing"; "{}", path_to_sign.display());
log::info!(action = "Signing"; "{}", path_to_sign.display());
let mut args = vec!["--force", "-s", identity];
@ -201,7 +200,7 @@ fn try_sign(
}
if let Some(entitlements_path) = &settings.macos().entitlements {
info!("using entitlements file at {}", entitlements_path);
log::info!("using entitlements file at {}", entitlements_path);
args.push("--entitlements");
args.push(entitlements_path);
}
@ -283,7 +282,7 @@ pub fn notarize(
"json",
];
info!(action = "Notarizing"; "{}", app_bundle_path.display());
log::info!(action = "Notarizing"; "{}", app_bundle_path.display());
let output = Command::new("xcrun")
.args(notarize_args)

View File

@ -4,7 +4,6 @@
// SPDX-License-Identifier: MIT
use super::common::CommandExt;
use log::warn;
use std::process::Command;
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
@ -46,7 +45,7 @@ pub fn target_triple() -> Result<String, crate::Error> {
.target_arch
.expect("could not find `target_arch` when running `rustc --print cfg`."),
Err(err) => {
warn!(
log::warn!(
"failed to determine target arch using rustc, error: `{}`. The fallback is the architecture of the machine that compiled this crate.",
err,
);

View File

@ -24,7 +24,6 @@ use std::{
};
use anyhow::Context;
use log::info;
use zip::write::FileOptions;
// Build update
@ -78,7 +77,7 @@ fn bundle_update_macos(bundles: &[Bundle]) -> crate::Result<Vec<PathBuf>> {
create_tar(source_path, &osx_archived_path)
.with_context(|| "Failed to tar.gz update directory")?;
info!(action = "Bundling"; "{} ({})", osx_archived, display_path(&osx_archived_path));
log::info!(action = "Bundling"; "{} ({})", osx_archived, display_path(&osx_archived_path));
Ok(vec![osx_archived_path])
} else {
@ -113,7 +112,7 @@ fn bundle_update_linux(bundles: &[Bundle]) -> crate::Result<Vec<PathBuf>> {
create_tar(source_path, &appimage_archived_path)
.with_context(|| "Failed to tar.gz update directory")?;
info!(action = "Bundling"; "{} ({})", appimage_archived, display_path(&appimage_archived_path));
log::info!(action = "Bundling"; "{} ({})", appimage_archived, display_path(&appimage_archived_path));
Ok(vec![appimage_archived_path])
} else {
@ -197,7 +196,7 @@ fn bundle_update_windows(settings: &Settings, bundles: &[Bundle]) -> crate::Resu
});
let archived_path = archived_path.with_extension(format!("{}.zip", bundle_name));
info!(action = "Bundling"; "{}", display_path(&archived_path));
log::info!(action = "Bundling"; "{}", display_path(&archived_path));
// Create our gzip file
create_zip(&source_path, &archived_path).with_context(|| "Failed to zip update bundle")?;

View File

@ -6,7 +6,6 @@
mod wix;
use crate::Settings;
use log::warn;
use std::{self, path::PathBuf};
@ -35,7 +34,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
.iter()
.any(|p| !wix_path.join(p).exists())
{
warn!("WixTools directory is missing some files. Recreating it.");
log::warn!("WixTools directory is missing some files. Recreating it.");
std::fs::remove_dir_all(&wix_path)?;
wix::get_and_extract_wix(&wix_path)?;
}

View File

@ -17,7 +17,6 @@ use crate::bundle::{
};
use anyhow::{bail, Context};
use handlebars::{to_json, Handlebars};
use log::info;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{
@ -223,11 +222,11 @@ fn generate_guid(key: &[u8]) -> Uuid {
// Specifically goes and gets Wix and verifies the download via Sha256
pub fn get_and_extract_wix(path: &Path) -> crate::Result<()> {
info!("Verifying wix package");
log::info!("Verifying wix package");
let data = download_and_verify(WIX_URL, WIX_SHA256, HashAlgorithm::Sha256)?;
info!("extracting WIX");
log::info!("extracting WIX");
extract_zip(&data, path)
}
@ -331,7 +330,7 @@ fn run_candle(
let candle_exe = wix_toolset_path.join("candle.exe");
info!(action = "Running"; "candle for {:?}", wxs_file_path);
log::info!(action = "Running"; "candle for {:?}", wxs_file_path);
let mut cmd = Command::new(candle_exe);
for ext in extensions {
cmd.arg("-ext");
@ -400,7 +399,7 @@ pub fn build_wix_app_installer(
let app_version = convert_version(settings.version_string())?;
// target only supports x64.
info!("Target: {}", arch);
log::info!("Target: {}", arch);
let main_binary = settings
.binaries()
@ -789,7 +788,7 @@ pub fn build_wix_app_installer(
app_installer_output_path(settings, &language, settings.version_string(), updater)?;
create_dir_all(msi_path.parent().unwrap())?;
info!(action = "Running"; "light to produce {}", display_path(&msi_path));
log::info!(action = "Running"; "light to produce {}", display_path(&msi_path));
run_light(
wix_toolset_path,

View File

@ -19,7 +19,6 @@ use tauri_utils::display_path;
use anyhow::Context;
use handlebars::{to_json, Handlebars};
use log::{info, warn};
use tauri_utils::config::{NSISInstallerMode, NsisCompression, WebviewInstallMode};
use std::{
@ -79,7 +78,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
.iter()
.any(|p| !nsis_toolset_path.join(p).exists())
{
warn!("NSIS directory is missing some files. Recreating it.");
log::warn!("NSIS directory is missing some files. Recreating it.");
std::fs::remove_dir_all(&nsis_toolset_path)?;
get_and_extract_nsis(&nsis_toolset_path, &tauri_tools_path)?;
} else {
@ -91,7 +90,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
.collect::<Vec<_>>();
if !mismatched.is_empty() {
warn!("NSIS directory contains mis-hashed files. Redownloading them.");
log::warn!("NSIS directory contains mis-hashed files. Redownloading them.");
for (path, url, hash, hash_algorithim) in mismatched {
let data = download_and_verify(url, hash, *hash_algorithim)?;
write(nsis_toolset_path.join(path), data)?;
@ -104,12 +103,12 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
// Gets NSIS and verifies the download via Sha1
fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> crate::Result<()> {
info!("Verifying NSIS package");
log::info!("Verifying NSIS package");
#[cfg(target_os = "windows")]
{
let data = download_and_verify(NSIS_URL, NSIS_SHA1, HashAlgorithm::Sha1)?;
info!("extracting NSIS");
log::info!("extracting NSIS");
extract_zip(&data, _tauri_tools_path)?;
rename(_tauri_tools_path.join("nsis-3.08"), nsis_toolset_path)?;
}
@ -117,7 +116,7 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
let nsis_plugins = nsis_toolset_path.join("Plugins");
let data = download(NSIS_APPLICATIONID_URL)?;
info!("extracting NSIS ApplicationID plugin");
log::info!("extracting NSIS ApplicationID plugin");
extract_zip(&data, &nsis_plugins)?;
create_dir_all(nsis_plugins.join("x86-unicode"))?;
@ -181,10 +180,10 @@ fn build_nsis_app_installer(
}
};
info!("Target: {}", arch);
log::info!("Target: {}", arch);
#[cfg(not(target_os = "windows"))]
info!("Code signing is currently only supported on Windows hosts, skipping...");
log::info!("Code signing is currently only supported on Windows hosts, skipping...");
let output_path = settings.project_out_directory().join("nsis").join(arch);
if output_path.exists() {
@ -489,7 +488,7 @@ fn build_nsis_app_installer(
));
create_dir_all(nsis_installer_path.parent().unwrap())?;
info!(action = "Running"; "makensis.exe to produce {}", display_path(&nsis_installer_path));
log::info!(action = "Running"; "makensis.exe to produce {}", display_path(&nsis_installer_path));
#[cfg(target_os = "windows")]
let mut nsis_cmd = Command::new(_nsis_toolset_path.join("makensis.exe"));

View File

@ -7,7 +7,6 @@ use crate::{
bundle::{common::CommandExt, windows::util},
Settings,
};
use log::{debug, info};
use std::{
path::{Path, PathBuf},
process::Command,
@ -129,16 +128,16 @@ pub fn sign_command(path: &str, params: &SignParams) -> crate::Result<(Command,
pub fn sign<P: AsRef<Path>>(path: P, params: &SignParams) -> crate::Result<()> {
let path_str = path.as_ref().to_str().unwrap();
info!(action = "Signing"; "{} with identity \"{}\"", path_str, params.certificate_thumbprint);
log::info!(action = "Signing"; "{} with identity \"{}\"", path_str, params.certificate_thumbprint);
let (mut cmd, signtool) = sign_command(path_str, params)?;
debug!("Running signtool {:?}", signtool);
log::debug!("Running signtool {:?}", signtool);
// Execute SignTool command
let output = cmd.output_ok()?;
let stdout = String::from_utf8_lossy(output.stdout.as_slice()).into_owned();
info!("{:?}", stdout);
log::info!("{:?}", stdout);
Ok(())
}
@ -173,7 +172,7 @@ impl Settings {
pub fn try_sign(file_path: &std::path::PathBuf, settings: &Settings) -> crate::Result<()> {
if settings.can_sign() {
info!(action = "Signing"; "{}", tauri_utils::display_path(file_path));
log::info!(action = "Signing"; "{}", tauri_utils::display_path(file_path));
sign(file_path, &settings.sign_params())?;
}
Ok(())

View File

@ -8,7 +8,6 @@ use std::{
path::{Path, PathBuf},
};
use log::info;
use sha2::Digest;
use zip::ZipArchive;
@ -69,7 +68,7 @@ pub fn download_webview2_offline_installer(base_path: &Path, arch: &str) -> crat
}
pub fn download(url: &str) -> crate::Result<Vec<u8>> {
info!(action = "Downloading"; "{}", url);
log::info!(action = "Downloading"; "{}", url);
let agent = ureq::AgentBuilder::new().try_proxy_from_env(true).build();
let response = agent.get(url).call().map_err(Box::new)?;
@ -92,7 +91,7 @@ pub fn download_and_verify(
hash_algorithm: HashAlgorithm,
) -> crate::Result<Vec<u8>> {
let data = download(url)?;
info!("validating hash");
log::info!("validating hash");
verify_hash(&data, hash, hash_algorithm)?;
Ok(data)
}

16
tooling/cli/Cargo.lock generated
View File

@ -4785,7 +4785,7 @@ dependencies = [
"serde_json",
"sha1",
"sha2",
"strsim 0.10.0",
"strsim 0.11.0",
"tar",
"tauri-icns",
"tauri-utils 2.0.0-beta.6",
@ -4795,8 +4795,8 @@ dependencies = [
"ureq",
"uuid",
"walkdir",
"windows-sys 0.48.0",
"winreg 0.51.0",
"windows-sys 0.52.0",
"winreg 0.52.0",
"zip",
]
@ -5956,6 +5956,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "winreg"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "x25519-dalek"
version = "2.0.1"

View File

@ -1,13 +1,13 @@
[workspace]
members = [ "node" ]
members = ["node"]
[package]
name = "tauri-cli"
version = "2.0.0-beta.6"
authors = [ "Tauri Programme within The Commons Conservancy" ]
authors = ["Tauri Programme within The Commons Conservancy"]
edition = "2021"
rust-version = "1.70"
categories = [ "gui", "web-programming" ]
categories = ["gui", "web-programming"]
license = "Apache-2.0 OR MIT"
homepage = "https://tauri.app"
repository = "https://github.com/tauri-apps/tauri"
@ -20,7 +20,7 @@ include = [
"*.rs",
"tauri.gitignore",
"tauri-dev-watcher.gitignore",
"LICENSE*"
"LICENSE*",
]
[package.metadata.binstall]
@ -40,53 +40,63 @@ path = "src/main.rs"
[dependencies]
cargo-mobile2 = { version = "0.10.3", default-features = false }
jsonrpsee = { version = "0.22", features = [ "server" ] }
jsonrpsee = { version = "0.22", features = ["server"] }
jsonrpsee-core = "0.22"
jsonrpsee-client-transport = { version = "0.22", features = [ "ws" ] }
jsonrpsee-client-transport = { version = "0.22", features = ["ws"] }
jsonrpsee-ws-client = { version = "0.22", default-features = false }
thiserror = "1"
sublime_fuzzy = "0.7"
clap_complete = "4"
clap = { version = "4.5", features = [ "derive", "env" ] }
clap = { version = "4.5", features = ["derive", "env"] }
anyhow = "1.0"
tauri-bundler = { version = "2.0.1-beta.2", default-features = false, path = "../bundler" }
colored = "2.1"
serde = { version = "1.0", features = [ "derive" ] }
serde_json = { version = "1.0", features = [ "preserve_order" ] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
notify = "6.1"
notify-debouncer-mini = "0.4"
shared_child = "1.0"
duct = "0.13"
toml_edit = { version = "0.22", features = [ "serde" ] }
toml_edit = { version = "0.22", features = ["serde"] }
json-patch = "1.2"
tauri-utils = { version = "2.0.0-beta.6", path = "../../core/tauri-utils", features = [ "isolation", "schema", "config-json5", "config-toml" ] }
tauri-utils-v1 = { version = "1", package = "tauri-utils", features = [ "isolation", "schema", "config-json5", "config-toml" ] }
tauri-utils = { version = "2.0.0-beta.6", path = "../../core/tauri-utils", features = [
"isolation",
"schema",
"config-json5",
"config-toml",
] }
tauri-utils-v1 = { version = "1", package = "tauri-utils", features = [
"isolation",
"schema",
"config-json5",
"config-toml",
] }
toml = "0.8"
jsonschema = "0.17"
handlebars = "5.1"
include_dir = "0.7"
minisign = "=0.7.3"
base64 = "0.22.0"
ureq = { version = "2.9.6", default-features = false, features = [ "gzip" ] }
ureq = { version = "2.9.6", default-features = false, features = ["gzip"] }
os_info = "3"
semver = "1.0"
regex = "1.10.3"
unicode-width = "0.1"
zeroize = "1.7"
heck = { version = "0.4", features = [ "unicode" ] }
heck = { version = "0.4", features = ["unicode"] }
dialoguer = "0.11"
url = { version = "2.5", features = [ "serde" ] }
url = { version = "2.5", features = ["serde"] }
os_pipe = "1"
ignore = "0.4"
ctrlc = "3.4"
log = { version = "0.4.21", features = [ "kv_unstable", "kv_unstable_std" ] }
log = { version = "0.4.21", features = ["kv", "kv_std"] }
env_logger = "0.11.2"
icns = { package = "tauri-icns", version = "0.1" }
image = { version = "0.24", default-features = false, features = [ "ico" ] }
axum = { version = "0.7.4", features = [ "ws" ] }
image = { version = "0.24", default-features = false, features = ["ico"] }
axum = { version = "0.7.4", features = ["ws"] }
html5ever = "0.26"
kuchiki = { package = "kuchikiki", version = "0.8" }
tokio = { version = "1", features = [ "macros", "sync" ] }
tokio = { version = "1", features = ["macros", "sync"] }
common-path = "1"
serde-value = "0.7.0"
itertools = "0.12"
@ -97,7 +107,13 @@ dunce = "1"
glob = "0.3"
[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = [ "handleapi", "processenv", "winbase", "wincon", "winnt" ] }
winapi = { version = "0.3", features = [
"handleapi",
"processenv",
"winbase",
"wincon",
"winnt",
] }
cc = "1"
[target."cfg(unix)".dependencies]
@ -107,18 +123,18 @@ libc = "0.2"
plist = "1"
[features]
default = [ "rustls" ]
default = ["rustls"]
native-tls = [
"tauri-bundler/native-tls",
"cargo-mobile2/native-tls",
"ureq/native-tls"
"ureq/native-tls",
]
native-tls-vendored = [
"native-tls",
"tauri-bundler/native-tls-vendored",
"cargo-mobile2/openssl-vendored"
"cargo-mobile2/openssl-vendored",
]
rustls = [ "tauri-bundler/rustls", "cargo-mobile2/rustls", "ureq/tls" ]
rustls = ["tauri-bundler/rustls", "cargo-mobile2/rustls", "ureq/tls"]
[profile.release-size-optimized]
inherits = "release"

View File

@ -6,7 +6,6 @@ use crate::Result;
use anyhow::Context;
use clap::{Command, Parser};
use clap_complete::{generate, Shell};
use log::info;
use std::{fs::write, path::PathBuf};
@ -86,7 +85,7 @@ fn get_completions(shell: Shell, cmd: Command) -> Result<String> {
}
pub fn command(options: Options, cmd: Command) -> Result<()> {
info!("Generating completion file for {}...", options.shell);
log::info!("Generating completion file for {}...", options.shell);
let completions = get_completions(options.shell, cmd)?;
if let Some(output) = options.output {

View File

@ -16,7 +16,6 @@ use crate::{
use anyhow::{bail, Context};
use clap::{ArgAction, Parser};
use log::{error, info, warn};
use shared_child::SharedChild;
use tauri_utils::platform::Target;
@ -214,7 +213,7 @@ pub fn setup(
);
}
}
info!(action = "Running"; "BeforeDevCommand (`{}`)", before_dev);
log::info!(action = "Running"; "BeforeDevCommand (`{}`)", before_dev);
let mut env = command_env(true);
env.extend(interface.env());
@ -270,7 +269,7 @@ pub fn setup(
.wait()
.expect("failed to wait on \"beforeDevCommand\"");
if !(status.success() || KILL_BEFORE_DEV_FLAG.get().unwrap().load(Ordering::Relaxed)) {
error!("The \"beforeDevCommand\" terminated with a non-zero status code.");
log::error!("The \"beforeDevCommand\" terminated with a non-zero status code.");
exit(status.code().unwrap_or(1));
}
});
@ -401,11 +400,11 @@ pub fn setup(
}
if i % 3 == 1 {
warn!("Waiting for your frontend dev server to start on {url}...",);
log::warn!("Waiting for your frontend dev server to start on {url}...",);
}
i += 1;
if i == max_attempts {
error!("Could not connect to `{url}` after {}s. Please make sure that is the URL to your dev server.", i * sleep_interval.as_secs());
log::error!("Could not connect to `{url}` after {}s. Please make sure that is the URL to your dev server.", i * sleep_interval.as_secs());
exit(1);
}
std::thread::sleep(sleep_interval);

View File

@ -3,7 +3,6 @@
// SPDX-License-Identifier: MIT
use json_patch::merge;
use log::error;
use serde_json::Value as JsonValue;
pub use tauri_utils::{config::*, platform::Target};
@ -158,9 +157,9 @@ fn get_internal(
for error in errors {
let path = error.instance_path.clone().into_vec().join(" > ");
if path.is_empty() {
error!("`{}` error: {}", config_file_name, error);
log::error!("`{}` error: {}", config_file_name, error);
} else {
error!("`{}` error on `{}`: {}", config_file_name, path, error);
log::error!("`{}` error on `{}`: {}", config_file_name, path, error);
}
}
if !reload {

View File

@ -21,7 +21,6 @@ use anyhow::Context;
use clap::Parser;
use handlebars::{to_json, Handlebars};
use include_dir::{include_dir, Dir};
use log::warn;
const TEMPLATE_DIR: Dir<'_> = include_dir!("templates/app");
const TAURI_CONF_TEMPLATE: &str = include_str!("../templates/tauri.conf.json");
@ -155,7 +154,7 @@ pub fn command(mut options: Options) -> Result<()> {
let metadata = serde_json::from_str::<VersionMetadata>(include_str!("../metadata-v2.json"))?;
if template_target_path.exists() && !options.force {
warn!(
log::warn!(
"Tauri dir ({:?}) not empty. Run `init --force` to overwrite.",
template_target_path
);

View File

@ -18,7 +18,6 @@ use anyhow::Context;
use glob::glob;
use heck::ToKebabCase;
use ignore::gitignore::{Gitignore, GitignoreBuilder};
use log::{debug, error, info};
use notify::RecursiveMode;
use notify_debouncer_mini::new_debouncer;
use serde::{Deserialize, Deserializer};
@ -445,7 +444,7 @@ fn get_watch_folders() -> crate::Result<Vec<PathBuf>> {
}
Err(err) => {
// If this fails cargo itself should fail too. But we still try to keep going with the unexpanded path.
error!("Error watching {}: {}", p.display(), err.to_string());
log::error!("Error watching {}: {}", p.display(), err.to_string());
watch_folders.push(p);
}
};
@ -511,10 +510,10 @@ impl Rust {
.unwrap();
for path in watch_folders {
if !ignore_matcher.is_ignore(&path, true) {
info!("Watching {} for changes...", display_path(&path));
log::info!("Watching {} for changes...", display_path(&path));
lookup(&path, |file_type, p| {
if p != path {
debug!("Watching {} for changes...", display_path(&p));
log::debug!("Watching {} for changes...", display_path(&p));
let _ = watcher.watcher().watch(
&p,
if file_type.is_dir() {

View File

@ -9,7 +9,6 @@ use crate::helpers::{
use anyhow::Context;
use itertools::Itertools;
use log::info;
use toml_edit::{Array, Document, InlineTable, Item, TableLike, Value};
use std::{
@ -246,7 +245,7 @@ fn inject_features(
.and_then(|v| v.as_bool())
.unwrap_or_default()
{
info!("`{name}` dependency has workspace inheritance enabled. The features array won't be automatically rewritten. Expected features: [{}]", dependency.features.iter().join(", "));
log::info!("`{name}` dependency has workspace inheritance enabled. The features array won't be automatically rewritten. Expected features: [{}]", dependency.features.iter().join(", "));
} else {
let all_cli_managed_features = dependency.all_cli_managed_features.clone();
let is_managed_feature: Box<dyn Fn(&str) -> bool> =

View File

@ -32,7 +32,7 @@ mod signer;
use clap::{ArgAction, CommandFactory, FromArgMatches, Parser, Subcommand, ValueEnum};
use env_logger::fmt::style::{AnsiColor, Style};
use env_logger::Builder;
use log::{debug, log_enabled, Level};
use log::Level;
use serde::Deserialize;
use std::io::{BufReader, Write};
use std::process::{exit, Command, ExitStatus, Output, Stdio};
@ -222,7 +222,7 @@ where
)?;
}
if !is_command_output && log_enabled!(Level::Debug) {
if !is_command_output && log::log_enabled!(Level::Debug) {
let style = Style::new().fg_color(Some(AnsiColor::Black.into()));
write!(f, "[{style}{}{style:#}] ", record.target())?;
@ -289,14 +289,14 @@ impl CommandExt for Command {
self.stdout(os_pipe::dup_stdout()?);
self.stderr(os_pipe::dup_stderr()?);
let program = self.get_program().to_string_lossy().into_owned();
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
log::debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
self.status().map_err(Into::into)
}
fn output_ok(&mut self) -> crate::Result<Output> {
let program = self.get_program().to_string_lossy().into_owned();
debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
log::debug!(action = "Running"; "Command `{} {}`", program, self.get_args().map(|arg| arg.to_string_lossy()).fold(String::new(), |acc, arg| format!("{acc} {arg}")));
self.stdout(Stdio::piped());
self.stderr(Stdio::piped());
@ -314,7 +314,7 @@ impl CommandExt for Command {
match stdout.read_line(&mut line) {
Ok(0) => break,
Ok(_) => {
debug!(action = "stdout"; "{}", line.trim_end());
log::debug!(action = "stdout"; "{}", line.trim_end());
lines.extend(line.as_bytes().to_vec());
}
Err(_) => (),
@ -333,7 +333,7 @@ impl CommandExt for Command {
match stderr.read_line(&mut line) {
Ok(0) => break,
Ok(_) => {
debug!(action = "stderr"; "{}", line.trim_end());
log::debug!(action = "stderr"; "{}", line.trim_end());
lines.extend(line.as_bytes().to_vec());
}
Err(_) => (),

View File

@ -13,11 +13,9 @@ use clap::Parser;
use handlebars::{to_json, Handlebars};
use heck::{ToKebabCase, ToPascalCase, ToSnakeCase};
use include_dir::{include_dir, Dir};
use log::warn;
use std::{
collections::BTreeMap,
env::current_dir,
ffi::OsStr,
fs::{create_dir_all, remove_dir_all, File, OpenOptions},
path::{Component, Path, PathBuf},
};
@ -80,7 +78,7 @@ pub fn command(mut options: Options) -> Result<()> {
let template_target_path = PathBuf::from(options.directory);
let metadata = crates_metadata()?;
if std::fs::read_dir(&template_target_path)?.count() > 0 {
warn!("Plugin dir ({:?}) not empty.", template_target_path);
log::warn!("Plugin dir ({:?}) not empty.", template_target_path);
} else {
let (tauri_dep, tauri_example_dep, tauri_build_dep, tauri_plugin_dep) =
if let Some(tauri_path) = options.tauri_path {
@ -269,7 +267,7 @@ pub fn generate_android_out_file(
options.write(true);
#[cfg(unix)]
if path.file_name().unwrap() == OsStr::new("gradlew") {
if path.file_name().unwrap() == std::ffi::OsStr::new("gradlew") {
use std::os::unix::fs::OpenOptionsExt;
options.mode(0o755);
}