mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-10-26 09:58:16 +03:00
chore: fix clippy warnings
This commit is contained in:
parent
a02c6c4c81
commit
015020760a
@ -18,7 +18,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
crate_dir.join("../../tooling/cli/schema.json"),
|
||||
] {
|
||||
let mut schema_file = BufWriter::new(File::create(&file)?);
|
||||
write!(schema_file, "{}", schema_str)?;
|
||||
write!(schema_file, "{schema_str}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -86,7 +86,7 @@ impl CodegenContext {
|
||||
pub fn build(self) -> PathBuf {
|
||||
match self.try_build() {
|
||||
Ok(out) => out,
|
||||
Err(error) => panic!("Error found during Codegen::build: {}", error),
|
||||
Err(error) => panic!("Error found during Codegen::build: {error}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ impl CodegenContext {
|
||||
)
|
||||
})?;
|
||||
|
||||
writeln!(file, "{}", code).with_context(|| {
|
||||
writeln!(file, "{code}").with_context(|| {
|
||||
format!(
|
||||
"Unable to write tokenstream to out file during tauri-build {}",
|
||||
out.display()
|
||||
|
@ -35,8 +35,8 @@ fn copy_file(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn copy_binaries<'a>(
|
||||
binaries: ResourcePaths<'a>,
|
||||
fn copy_binaries(
|
||||
binaries: ResourcePaths,
|
||||
target_triple: &str,
|
||||
path: &Path,
|
||||
package_name: Option<&String>,
|
||||
@ -48,7 +48,7 @@ fn copy_binaries<'a>(
|
||||
.file_name()
|
||||
.expect("failed to extract external binary filename")
|
||||
.to_string_lossy()
|
||||
.replace(&format!("-{}", target_triple), "");
|
||||
.replace(&format!("-{target_triple}"), "");
|
||||
|
||||
if package_name.map_or(false, |n| n == &file_name) {
|
||||
return Err(anyhow::anyhow!(
|
||||
@ -90,7 +90,7 @@ fn has_feature(feature: &str) -> bool {
|
||||
// `alias` must be a snake case string.
|
||||
fn cfg_alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +227,8 @@ impl Attributes {
|
||||
/// This is typically desirable when running inside a build script; see [`try_build`] for no panics.
|
||||
pub fn build() {
|
||||
if let Err(error) = try_build(Attributes::default()) {
|
||||
let error = format!("{:#}", error);
|
||||
println!("{}", error);
|
||||
let error = format!("{error:#}");
|
||||
println!("{error}");
|
||||
if error.starts_with("unknown field") {
|
||||
print!("found an unknown configuration field. This usually means that you are using a CLI version that is newer than `tauri-build` and is incompatible. ");
|
||||
println!(
|
||||
|
@ -141,7 +141,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
} else if target.contains("apple-ios") {
|
||||
Target::Ios
|
||||
} else {
|
||||
panic!("unknown codegen target {}", target);
|
||||
panic!("unknown codegen target {target}");
|
||||
}
|
||||
} else if cfg!(target_os = "linux") {
|
||||
Target::Linux
|
||||
@ -371,8 +371,7 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
|
||||
let dir = config_parent.join(dir);
|
||||
if !dir.exists() {
|
||||
panic!(
|
||||
"The isolation application path is set to `{:?}` but it does not exist",
|
||||
dir
|
||||
"The isolation application path is set to `{dir:?}` but it does not exist"
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -343,14 +343,14 @@ impl EmbeddedAssets {
|
||||
|
||||
let mut hex = String::with_capacity(2 * bytes.len());
|
||||
for b in bytes {
|
||||
write!(hex, "{:02x}", b).map_err(EmbeddedAssetsError::Hex)?;
|
||||
write!(hex, "{b:02x}").map_err(EmbeddedAssetsError::Hex)?;
|
||||
}
|
||||
hex
|
||||
};
|
||||
|
||||
// use the content hash to determine filename, keep extensions that exist
|
||||
let out_path = if let Some(ext) = path.extension().and_then(|e| e.to_str()) {
|
||||
out_dir.join(format!("{}.{}", hash, ext))
|
||||
out_dir.join(format!("{hash}.{ext}"))
|
||||
} else {
|
||||
out_dir.join(hash)
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub enum WindowUrl {
|
||||
impl fmt::Display for WindowUrl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::External(url) => write!(f, "{}", url),
|
||||
Self::External(url) => write!(f, "{url}"),
|
||||
Self::App(path) => write!(f, "{}", path.display()),
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ impl<'de> Deserialize<'de> for BundleType {
|
||||
"app" => Ok(Self::App),
|
||||
"dmg" => Ok(Self::Dmg),
|
||||
"updater" => Ok(Self::Updater),
|
||||
_ => Err(DeError::custom(format!("unknown bundle target '{}'", s))),
|
||||
_ => Err(DeError::custom(format!("unknown bundle target '{s}'"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,7 +223,7 @@ impl<'de> Deserialize<'de> for BundleTarget {
|
||||
|
||||
match BundleTargetInner::deserialize(deserializer)? {
|
||||
BundleTargetInner::All(s) if s.to_lowercase() == "all" => Ok(Self::All),
|
||||
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {}", t))),
|
||||
BundleTargetInner::All(t) => Err(DeError::custom(format!("invalid bundle type {t}"))),
|
||||
BundleTargetInner::List(l) => Ok(Self::List(l)),
|
||||
BundleTargetInner::One(t) => Ok(Self::One(t)),
|
||||
}
|
||||
@ -994,7 +994,7 @@ impl CspDirectiveSources {
|
||||
/// Whether the given source is configured on this directive or not.
|
||||
pub fn contains(&self, source: &str) -> bool {
|
||||
match self {
|
||||
Self::Inline(s) => s.contains(&format!("{} ", source)) || s.contains(&format!(" {}", source)),
|
||||
Self::Inline(s) => s.contains(&format!("{source} ")) || s.contains(&format!(" {source}")),
|
||||
Self::List(l) => l.contains(&source.into()),
|
||||
}
|
||||
}
|
||||
@ -1060,7 +1060,7 @@ impl From<Csp> for HashMap<String, CspDirectiveSources> {
|
||||
impl Display for Csp {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Policy(s) => write!(f, "{}", s),
|
||||
Self::Policy(s) => write!(f, "{s}"),
|
||||
Self::DirectiveMap(m) => {
|
||||
let len = m.len();
|
||||
let mut i = 0;
|
||||
@ -2365,8 +2365,7 @@ impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
|
||||
"quiet" => Ok(Self::Quiet),
|
||||
"passive" => Ok(Self::Passive),
|
||||
_ => Err(DeError::custom(format!(
|
||||
"unknown update install mode '{}'",
|
||||
s
|
||||
"unknown update install mode '{s}'"
|
||||
))),
|
||||
}
|
||||
}
|
||||
@ -2510,7 +2509,7 @@ pub enum AppUrl {
|
||||
impl std::fmt::Display for AppUrl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Url(url) => write!(f, "{}", url),
|
||||
Self::Url(url) => write!(f, "{url}"),
|
||||
Self::Files(files) => write!(f, "{}", serde_json::to_string(files).unwrap()),
|
||||
}
|
||||
}
|
||||
@ -2649,9 +2648,9 @@ impl<'d> serde::Deserialize<'d> for PackageVersion {
|
||||
let path = PathBuf::from(value);
|
||||
if path.exists() {
|
||||
let json_str = read_to_string(&path)
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
|
||||
let package_json: serde_json::Value = serde_json::from_str(&json_str)
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {}", e)))?;
|
||||
.map_err(|e| DeError::custom(format!("failed to read version JSON file: {e}")))?;
|
||||
if let Some(obj) = package_json.as_object() {
|
||||
let version = obj
|
||||
.get("version")
|
||||
|
@ -37,7 +37,7 @@ fn serialize_node_ref_internal<S: Serializer>(
|
||||
traversal_scope: TraversalScope,
|
||||
) -> crate::Result<()> {
|
||||
match (traversal_scope, node.data()) {
|
||||
(ref scope, &NodeData::Element(ref element)) => {
|
||||
(ref scope, NodeData::Element(element)) => {
|
||||
if *scope == TraversalScope::IncludeNode {
|
||||
let attrs = element.attributes.borrow();
|
||||
|
||||
@ -82,16 +82,16 @@ fn serialize_node_ref_internal<S: Serializer>(
|
||||
|
||||
(TraversalScope::ChildrenOnly(_), _) => Ok(()),
|
||||
|
||||
(TraversalScope::IncludeNode, &NodeData::Doctype(ref doctype)) => {
|
||||
(TraversalScope::IncludeNode, NodeData::Doctype(doctype)) => {
|
||||
serializer.write_doctype(&doctype.name).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, &NodeData::Text(ref text)) => {
|
||||
(TraversalScope::IncludeNode, NodeData::Text(text)) => {
|
||||
serializer.write_text(&text.borrow()).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, &NodeData::Comment(ref text)) => {
|
||||
(TraversalScope::IncludeNode, NodeData::Comment(text)) => {
|
||||
serializer.write_comment(&text.borrow()).map_err(Into::into)
|
||||
}
|
||||
(TraversalScope::IncludeNode, &NodeData::ProcessingInstruction(ref contents)) => {
|
||||
(TraversalScope::IncludeNode, NodeData::ProcessingInstruction(contents)) => {
|
||||
let contents = contents.borrow();
|
||||
serializer
|
||||
.write_processing_instruction(&contents.0, &contents.1)
|
||||
|
@ -39,7 +39,7 @@ impl std::fmt::Display for MimeType {
|
||||
MimeType::Svg => "image/svg+xml",
|
||||
MimeType::Mp4 => "video/mp4",
|
||||
};
|
||||
write!(f, "{}", mime)
|
||||
write!(f, "{mime}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,10 +133,10 @@ pub fn target_triple() -> crate::Result<String> {
|
||||
return Err(crate::Error::Environment);
|
||||
};
|
||||
|
||||
format!("{}-{}", os, env)
|
||||
format!("{os}-{env}")
|
||||
};
|
||||
|
||||
Ok(format!("{}-{}", arch, os))
|
||||
Ok(format!("{arch}-{os}"))
|
||||
}
|
||||
|
||||
/// Computes the resource directory of the current environment.
|
||||
@ -157,8 +157,8 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
|
||||
let exe_dir = exe.parent().expect("failed to get exe directory");
|
||||
let curr_dir = exe_dir.display().to_string();
|
||||
|
||||
if curr_dir.ends_with(format!("{S}target{S}debug", S = MAIN_SEPARATOR).as_str())
|
||||
|| curr_dir.ends_with(format!("{S}target{S}release", S = MAIN_SEPARATOR).as_str())
|
||||
if curr_dir.ends_with(format!("{MAIN_SEPARATOR}target{MAIN_SEPARATOR}debug").as_str())
|
||||
|| curr_dir.ends_with(format!("{MAIN_SEPARATOR}target{MAIN_SEPARATOR}release").as_str())
|
||||
|| cfg!(target_os = "windows")
|
||||
{
|
||||
// running from the out dir or windows
|
||||
|
@ -31,7 +31,7 @@ fn has_feature(feature: &str) -> bool {
|
||||
// `alias` must be a snake case string.
|
||||
fn alias(alias: &str, has_feature: bool) {
|
||||
if has_feature {
|
||||
println!("cargo:rustc-cfg={}", alias);
|
||||
println!("cargo:rustc-cfg={alias}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,8 +137,8 @@ fn main() {
|
||||
let checked_features_out_path =
|
||||
Path::new(&std::env::var("OUT_DIR").unwrap()).join("checked_features");
|
||||
std::fs::write(
|
||||
&checked_features_out_path,
|
||||
&CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","),
|
||||
checked_features_out_path,
|
||||
CHECKED_FEATURES.get().unwrap().lock().unwrap().join(","),
|
||||
)
|
||||
.expect("failed to write checked_features file");
|
||||
}
|
||||
@ -153,14 +153,14 @@ fn main() {
|
||||
//
|
||||
// Note that both `module` and `apis` strings must be written in kebab case.
|
||||
fn alias_module(module: &str, apis: &[&str], api_all: bool) {
|
||||
let all_feature_name = format!("{}-all", module);
|
||||
let all_feature_name = format!("{module}-all");
|
||||
let all = has_feature(&all_feature_name) || api_all;
|
||||
alias(&all_feature_name.to_snake_case(), all);
|
||||
|
||||
let mut any = all;
|
||||
|
||||
for api in apis {
|
||||
let has = has_feature(&format!("{}-{}", module, api)) || all;
|
||||
let has = has_feature(&format!("{module}-{api}")) || all;
|
||||
alias(
|
||||
&format!("{}_{}", AsSnakeCase(module), AsSnakeCase(api)),
|
||||
has,
|
||||
|
@ -226,7 +226,7 @@ mod test {
|
||||
fn check_test_dir() {
|
||||
// create a callback closure that takes in a TempDir type and prints it.
|
||||
let callback = |td: &tempfile::TempDir| {
|
||||
println!("{:?}", td);
|
||||
println!("{td:?}");
|
||||
};
|
||||
|
||||
// execute the with_temp_dir function on the callback
|
||||
|
@ -150,7 +150,7 @@ impl<'a, R: std::fmt::Debug + Read + Seek> std::fmt::Debug for Extract<'a, R> {
|
||||
impl<'a, R: Read + Seek> Extract<'a, R> {
|
||||
/// Create archive from reader.
|
||||
pub fn from_cursor(mut reader: R, archive_format: ArchiveFormat) -> Extract<'a, R> {
|
||||
if reader.seek(io::SeekFrom::Start(0)).is_err() {
|
||||
if reader.rewind().is_err() {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("Could not seek to start of the file");
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ impl TryFrom<FilePart> for Vec<u8> {
|
||||
type Error = crate::api::Error;
|
||||
fn try_from(file: FilePart) -> crate::api::Result<Self> {
|
||||
let bytes = match file {
|
||||
FilePart::Path(path) => std::fs::read(&path)?,
|
||||
FilePart::Path(path) => std::fs::read(path)?,
|
||||
FilePart::Contents(bytes) => bytes,
|
||||
};
|
||||
Ok(bytes)
|
||||
@ -441,8 +441,7 @@ impl<'de> Deserialize<'de> for HeaderMap {
|
||||
headers.insert(key, value);
|
||||
} else {
|
||||
return Err(serde::de::Error::custom(format!(
|
||||
"invalid header `{}` `{}`",
|
||||
key, value
|
||||
"invalid header `{key}` `{value}`"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
@ -242,22 +242,22 @@ mod test {
|
||||
}
|
||||
|
||||
let raw_str = "T".repeat(MIN_JSON_PARSE_LEN);
|
||||
assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{}\"", raw_str));
|
||||
assert_eq!(serialize_js(&raw_str).unwrap(), format!("\"{raw_str}\""));
|
||||
|
||||
assert_eq!(
|
||||
serialize_js(&JsonObj {
|
||||
value: raw_str.clone()
|
||||
})
|
||||
.unwrap(),
|
||||
format!("JSON.parse('{{\"value\":\"{}\"}}')", raw_str)
|
||||
format!("JSON.parse('{{\"value\":\"{raw_str}\"}}')")
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serialize_js(&JsonObj {
|
||||
value: format!("\"{}\"", raw_str)
|
||||
value: format!("\"{raw_str}\"")
|
||||
})
|
||||
.unwrap(),
|
||||
format!("JSON.parse('{{\"value\":\"\\\\\"{}\\\\\"\"}}')", raw_str)
|
||||
format!("JSON.parse('{{\"value\":\"\\\\\"{raw_str}\\\\\"\"}}')")
|
||||
);
|
||||
|
||||
let dangerous_json = RawValue::from_string(
|
||||
|
@ -112,5 +112,5 @@ pub fn open<P: AsRef<str>>(
|
||||
) -> crate::api::Result<()> {
|
||||
scope
|
||||
.open(path.as_ref(), with)
|
||||
.map_err(|err| crate::api::Error::Shell(format!("failed to open: {}", err)))
|
||||
.map_err(|err| crate::api::Error::Shell(format!("failed to open: {err}")))
|
||||
}
|
||||
|
@ -1290,8 +1290,7 @@ impl<R: Runtime> Builder<R> {
|
||||
let type_name = std::any::type_name::<T>();
|
||||
assert!(
|
||||
self.state.set(state),
|
||||
"state for type '{}' is already being managed",
|
||||
type_name
|
||||
"state for type '{type_name}' is already being managed"
|
||||
);
|
||||
self
|
||||
}
|
||||
|
@ -238,8 +238,7 @@ pub(crate) fn handle<R: Runtime>(
|
||||
if let Some(unknown_variant_name) = s.next() {
|
||||
if unknown_variant_name == module {
|
||||
return resolver.reject(format!(
|
||||
"The `{}` module is not enabled. You must enable one of its APIs in the allowlist.",
|
||||
module
|
||||
"The `{module}` module is not enabled. You must enable one of its APIs in the allowlist."
|
||||
));
|
||||
} else if module == "Window" {
|
||||
return resolver.reject(window::into_allowlist_error(unknown_variant_name).to_string());
|
||||
|
@ -138,7 +138,7 @@ impl Cmd {
|
||||
serde_json::to_string(&p)
|
||||
.map_err(|e| {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("{}", e);
|
||||
eprintln!("{e}");
|
||||
e
|
||||
})
|
||||
.ok()
|
||||
|
@ -135,7 +135,7 @@ impl Cmd {
|
||||
Ok(cmd) => cmd,
|
||||
Err(e) => {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("{}", e);
|
||||
eprintln!("{e}");
|
||||
return Err(crate::Error::ProgramNotAllowed(PathBuf::from(program)).into_anyhow());
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,7 @@ impl Cmd {
|
||||
if let Some(encoding) = crate::api::process::Encoding::for_label(encoding.as_bytes()) {
|
||||
command = command.encoding(encoding);
|
||||
} else {
|
||||
return Err(anyhow::anyhow!(format!("unknown encoding {}", encoding)));
|
||||
return Err(anyhow::anyhow!(format!("unknown encoding {encoding}")));
|
||||
}
|
||||
}
|
||||
let (mut rx, child) = command.spawn()?;
|
||||
|
@ -232,7 +232,7 @@ mod test {
|
||||
|
||||
// dummy event handler function
|
||||
fn event_fn(s: Event) {
|
||||
println!("{:?}", s);
|
||||
println!("{s:?}");
|
||||
}
|
||||
|
||||
proptest! {
|
||||
@ -304,18 +304,15 @@ pub fn unlisten_js(listeners_object_name: String, event_name: String, event_id:
|
||||
format!(
|
||||
"
|
||||
(function () {{
|
||||
const listeners = (window['{listeners}'] || {{}})['{event_name}']
|
||||
const listeners = (window['{listeners_object_name}'] || {{}})['{event_name}']
|
||||
if (listeners) {{
|
||||
const index = window['{listeners}']['{event_name}'].findIndex(e => e.id === {event_id})
|
||||
const index = window['{listeners_object_name}']['{event_name}'].findIndex(e => e.id === {event_id})
|
||||
if (index > -1) {{
|
||||
window['{listeners}']['{event_name}'].splice(index, 1)
|
||||
window['{listeners_object_name}']['{event_name}'].splice(index, 1)
|
||||
}}
|
||||
}}
|
||||
}})()
|
||||
",
|
||||
listeners = listeners_object_name,
|
||||
event_name = event_name,
|
||||
event_id = event_id,
|
||||
)
|
||||
}
|
||||
|
||||
@ -353,7 +350,7 @@ pub fn listen_js(
|
||||
event_id = event_id,
|
||||
window_label = if let Some(l) = window_label {
|
||||
crate::runtime::window::assert_label_is_valid(&l);
|
||||
format!("'{}'", l)
|
||||
format!("'{l}'")
|
||||
} else {
|
||||
"null".to_owned()
|
||||
},
|
||||
|
@ -99,7 +99,7 @@ impl InvokeError {
|
||||
/// Create an [`InvokeError`] as a string of the [`anyhow::Error`] message.
|
||||
#[inline(always)]
|
||||
pub fn from_anyhow(error: anyhow::Error) -> Self {
|
||||
Self(JsonValue::String(format!("{:#}", error)))
|
||||
Self(JsonValue::String(format!("{error:#}")))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,8 +440,7 @@ impl TryFrom<Icon> for runtime::Icon {
|
||||
})
|
||||
}
|
||||
_ => panic!(
|
||||
"image `{}` extension not supported; please file a Tauri feature request. `png` or `ico` icons are supported with the `icon-png` and `icon-ico` feature flags",
|
||||
extension
|
||||
"image `{extension}` extension not supported; please file a Tauri feature request. `png` or `ico` icons are supported with the `icon-png` and `icon-ico` feature flags"
|
||||
),
|
||||
}
|
||||
}
|
||||
@ -845,8 +844,8 @@ mod tests {
|
||||
let lib_code = read_to_string(manifest_dir.join("src/lib.rs")).expect("failed to read lib.rs");
|
||||
|
||||
for f in get_manifest().features.keys() {
|
||||
if !(f.starts_with("__") || f == "default" || lib_code.contains(&format!("*{}**", f))) {
|
||||
panic!("Feature {} is not documented", f);
|
||||
if !(f.starts_with("__") || f == "default" || lib_code.contains(&format!("*{f}**"))) {
|
||||
panic!("Feature {f} is not documented");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -858,8 +857,7 @@ mod tests {
|
||||
for checked_feature in checked_features {
|
||||
if !manifest.features.iter().any(|(f, _)| f == checked_feature) {
|
||||
panic!(
|
||||
"Feature {} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml",
|
||||
checked_feature
|
||||
"Feature {checked_feature} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -895,24 +893,20 @@ mod tests {
|
||||
let module = module_all_feature.replace("-all", "");
|
||||
assert!(
|
||||
checked_features.contains(&module_all_feature.as_str()),
|
||||
"`{}` is not aliased",
|
||||
module
|
||||
"`{module}` is not aliased"
|
||||
);
|
||||
|
||||
let module_prefix = format!("{}-", module);
|
||||
let module_prefix = format!("{module}-");
|
||||
// we assume that module features are the ones that start with `<module>-`
|
||||
// though it's not 100% accurate, we have an allowed list to fix it
|
||||
let module_features = manifest
|
||||
.features
|
||||
.iter()
|
||||
.map(|(f, _)| f)
|
||||
.features.keys()
|
||||
.filter(|f| f.starts_with(&module_prefix));
|
||||
for module_feature in module_features {
|
||||
assert!(
|
||||
allowed.contains(&module_feature.as_str())
|
||||
|| checked_features.contains(&module_feature.as_str()),
|
||||
"`{}` is not aliased",
|
||||
module_feature
|
||||
"`{module_feature}` is not aliased"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -940,7 +934,7 @@ mod test_utils {
|
||||
fn check_spawn_task(task in "[a-z]+") {
|
||||
// create dummy task function
|
||||
let dummy_task = async move {
|
||||
format!("{}-run-dummy-task", task);
|
||||
format!("{task}-run-dummy-task");
|
||||
};
|
||||
// call spawn
|
||||
crate::async_runtime::spawn(dummy_task);
|
||||
|
@ -184,7 +184,7 @@ fn replace_csp_nonce(
|
||||
if !(nonces.is_empty() && hashes.is_empty()) {
|
||||
let nonce_sources = nonces
|
||||
.into_iter()
|
||||
.map(|n| format!("'nonce-{}'", n))
|
||||
.map(|n| format!("'nonce-{n}'"))
|
||||
.collect::<Vec<String>>();
|
||||
let sources = csp.entry(directive.into()).or_insert_with(Default::default);
|
||||
let self_source = "'self'".to_string();
|
||||
@ -487,7 +487,7 @@ impl<R: Runtime> WindowManager<R> {
|
||||
window_url.scheme(),
|
||||
window_url.host().unwrap(),
|
||||
if let Some(port) = window_url.port() {
|
||||
format!(":{}", port)
|
||||
format!(":{port}")
|
||||
} else {
|
||||
"".into()
|
||||
}
|
||||
@ -714,7 +714,7 @@ impl<R: Runtime> WindowManager<R> {
|
||||
{
|
||||
let assets = assets.clone();
|
||||
let schema_ = schema.clone();
|
||||
let url_base = format!("{}://localhost", schema_);
|
||||
let url_base = format!("{schema_}://localhost");
|
||||
let aes_gcm_key = *crypto_keys.aes_gcm().raw();
|
||||
|
||||
pending.register_uri_scheme_protocol(schema, move |request| {
|
||||
@ -813,7 +813,7 @@ impl<R: Runtime> WindowManager<R> {
|
||||
let asset_response = assets
|
||||
.get(&path.as_str().into())
|
||||
.or_else(|| {
|
||||
eprintln!("Asset `{}` not found; fallback to {}.html", path, path);
|
||||
eprintln!("Asset `{path}` not found; fallback to {path}.html");
|
||||
let fallback = format!("{}.html", path.as_str()).into();
|
||||
let asset = assets.get(&fallback);
|
||||
asset_path = fallback;
|
||||
@ -1408,8 +1408,7 @@ fn on_window_event<R: Runtime>(
|
||||
let windows = windows_map.values();
|
||||
for window in windows {
|
||||
window.eval(&format!(
|
||||
r#"(function () {{ const metadata = window.__TAURI_METADATA__; if (metadata != null) {{ metadata.__windows = window.__TAURI_METADATA__.__windows.filter(w => w.label !== "{}"); }} }})()"#,
|
||||
label
|
||||
r#"(function () {{ const metadata = window.__TAURI_METADATA__; if (metadata != null) {{ metadata.__windows = window.__TAURI_METADATA__.__windows.filter(w => w.label !== "{label}"); }} }})()"#
|
||||
))?;
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ pub(crate) struct PatternJavascript {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn format_real_schema(schema: &str) -> String {
|
||||
if cfg!(windows) {
|
||||
format!("https://{}.localhost", schema)
|
||||
format!("https://{schema}.localhost")
|
||||
} else {
|
||||
format!("{}://localhost", schema)
|
||||
format!("{schema}://localhost")
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ impl<R: Runtime> PluginStore<R> {
|
||||
.values()
|
||||
.filter_map(|p| p.initialization_script())
|
||||
.fold(String::new(), |acc, script| {
|
||||
format!("{}\n(function () {{ {} }})();", acc, script)
|
||||
format!("{acc}\n(function () {{ {script} }})();")
|
||||
})
|
||||
}
|
||||
|
||||
@ -588,7 +588,7 @@ impl<R: Runtime> PluginStore<R> {
|
||||
} else {
|
||||
invoke
|
||||
.resolver
|
||||
.reject(format!("plugin {} not found", target));
|
||||
.reject(format!("plugin {target} not found"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ impl Scope {
|
||||
.iter()
|
||||
.map(|url| {
|
||||
glob::Pattern::new(url.as_str())
|
||||
.unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{}`", url))
|
||||
.unwrap_or_else(|_| panic!("scoped URL is not a valid glob pattern: `{url}`"))
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ impl<'de> Deserialize<'de> for RemoteRelease {
|
||||
let pub_date = if let Some(date) = release.pub_date {
|
||||
Some(
|
||||
OffsetDateTime::parse(&date, &time::format_description::well_known::Rfc3339)
|
||||
.map_err(|e| DeError::custom(format!("invalid value for `pub_date`: {}", e)))?,
|
||||
.map_err(|e| DeError::custom(format!("invalid value for `pub_date`: {e}")))?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
@ -336,7 +336,7 @@ impl<R: Runtime> UpdateBuilder<R> {
|
||||
(target.clone(), target)
|
||||
} else {
|
||||
let target = get_updater_target().ok_or(Error::UnsupportedOs)?;
|
||||
(target.to_string(), format!("{}-{}", target, arch))
|
||||
(target.to_string(), format!("{target}-{arch}"))
|
||||
};
|
||||
|
||||
// Get the extract_path from the provided executable_path
|
||||
@ -1049,14 +1049,13 @@ mod test {
|
||||
format!(
|
||||
r#"
|
||||
{{
|
||||
"name": "v{}",
|
||||
"name": "v{version}",
|
||||
"notes": "This is the latest version! Once updated you shouldn't see this prompt.",
|
||||
"pub_date": "2020-06-25T14:14:19Z",
|
||||
"signature": "{}",
|
||||
"url": "{}"
|
||||
"signature": "{public_signature}",
|
||||
"url": "{download_url}"
|
||||
}}
|
||||
"#,
|
||||
version, public_signature, download_url
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
@ -1069,15 +1068,14 @@ mod test {
|
||||
format!(
|
||||
r#"
|
||||
{{
|
||||
"name": "v{}",
|
||||
"name": "v{version}",
|
||||
"notes": "This is the latest version! Once updated you shouldn't see this prompt.",
|
||||
"pub_date": "2020-06-25T14:14:19Z",
|
||||
"signature": "{}",
|
||||
"url": "{}",
|
||||
"with_elevated_task": {}
|
||||
"signature": "{public_signature}",
|
||||
"url": "{download_url}",
|
||||
"with_elevated_task": {with_elevated_task}
|
||||
}}
|
||||
"#,
|
||||
version, public_signature, download_url, with_elevated_task
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
@ -1515,7 +1513,7 @@ mod test {
|
||||
}"#;
|
||||
|
||||
fn missing_field_error(field: &str) -> String {
|
||||
format!("the `{}` field was not set on the updater response", field)
|
||||
format!("the `{field}` field was not set on the updater response")
|
||||
}
|
||||
|
||||
let test_cases = [
|
||||
@ -1547,7 +1545,7 @@ mod test {
|
||||
.target("test-target")
|
||||
.build());
|
||||
if let Err(e) = check_update {
|
||||
println!("ERROR: {}, expected: {}", e, error);
|
||||
println!("ERROR: {e}, expected: {error}");
|
||||
assert!(e.to_string().contains(&error));
|
||||
} else {
|
||||
panic!("unexpected Ok response");
|
||||
|
@ -109,7 +109,7 @@ pub const EVENT_STATUS_UPTODATE: &str = "UPTODATE";
|
||||
/// Gets the target string used on the updater.
|
||||
pub fn target() -> Option<String> {
|
||||
if let (Some(target), Some(arch)) = (core::get_updater_target(), core::get_updater_arch()) {
|
||||
Some(format!("{}-{}", target, arch))
|
||||
Some(format!("{target}-{arch}"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -565,7 +565,7 @@ async fn prompt_for_install<R: Runtime>(
|
||||
// something more conventional.
|
||||
let should_install = ask(
|
||||
parent_window,
|
||||
format!(r#"A new version of {} is available! "#, app_name),
|
||||
format!(r#"A new version of {app_name} is available! "#),
|
||||
format!(
|
||||
r#"{} {} is now available -- you have {}.
|
||||
|
||||
|
@ -15,13 +15,13 @@ fn main() {
|
||||
match handle.updater().check().await {
|
||||
Ok(update) => {
|
||||
if let Err(e) = update.download_and_install().await {
|
||||
println!("{}", e);
|
||||
println!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
std::process::exit(0);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}", e);
|
||||
println!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -55,12 +55,12 @@ fn get_cli_bin_path(cli_dir: &Path, debug: bool) -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
fn build_app(cli_bin_path: &Path, cwd: &Path, config: &Config, bundle_updater: bool) {
|
||||
let mut command = Command::new(&cli_bin_path);
|
||||
let mut command = Command::new(cli_bin_path);
|
||||
command
|
||||
.args(["build", "--debug", "--verbose"])
|
||||
.arg("--config")
|
||||
.arg(serde_json::to_string(config).unwrap())
|
||||
.current_dir(&cwd);
|
||||
.current_dir(cwd);
|
||||
|
||||
#[cfg(windows)]
|
||||
command.args(["--bundles", "msi"]);
|
||||
@ -88,8 +88,7 @@ fn build_app(cli_bin_path: &Path, cwd: &Path, config: &Config, bundle_updater: b
|
||||
#[cfg(target_os = "linux")]
|
||||
fn bundle_path(root_dir: &Path, version: &str) -> PathBuf {
|
||||
root_dir.join(format!(
|
||||
"target/debug/bundle/appimage/app-updater_{}_amd64.AppImage",
|
||||
version
|
||||
"target/debug/bundle/appimage/app-updater_{version}_amd64.AppImage"
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ fn main() {
|
||||
env.args.clear();
|
||||
tauri::api::process::restart(&env)
|
||||
}
|
||||
Some(invalid) => panic!("only argument `restart` is allowed, {} is invalid", invalid),
|
||||
Some(invalid) => panic!("only argument `restart` is allowed, {invalid} is invalid"),
|
||||
None => {}
|
||||
};
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fn symlink_runner(create_symlinks: impl Fn(&Path) -> io::Result<Symlink>) -> Res
|
||||
if cfg!(windows) {
|
||||
compiled_binary.set_extension("exe");
|
||||
}
|
||||
println!("{:?}", compiled_binary);
|
||||
println!("{compiled_binary:?}");
|
||||
|
||||
// set up all the temporary file paths
|
||||
let temp = tempfile::TempDir::new()?;
|
||||
|
@ -18,7 +18,7 @@ pub fn resolver(_argument: String) {}
|
||||
|
||||
#[command]
|
||||
pub fn simple_command(the_argument: String) {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
}
|
||||
|
||||
#[command]
|
||||
|
@ -37,12 +37,12 @@ fn window_label(window: Window) {
|
||||
|
||||
#[command]
|
||||
async fn async_simple_command(the_argument: String) {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
}
|
||||
|
||||
#[command(rename_all = "snake_case")]
|
||||
async fn async_simple_command_snake(the_argument: String) {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
}
|
||||
|
||||
#[command]
|
||||
@ -57,7 +57,7 @@ async fn async_stateful_command(
|
||||
|
||||
#[command(async)]
|
||||
fn future_simple_command(the_argument: String) -> impl std::future::Future<Output = ()> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(())
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ fn future_simple_command(the_argument: String) -> impl std::future::Future<Outpu
|
||||
fn future_simple_command_with_return(
|
||||
the_argument: String,
|
||||
) -> impl std::future::Future<Output = String> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(the_argument)
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ fn future_simple_command_with_return(
|
||||
fn future_simple_command_with_result(
|
||||
the_argument: String,
|
||||
) -> impl std::future::Future<Output = Result<String, ()>> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(Ok(the_argument))
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ fn force_async_with_result(the_argument: &str) -> Result<&str, MyError> {
|
||||
|
||||
#[command(async, rename_all = "snake_case")]
|
||||
fn future_simple_command_snake(the_argument: String) -> impl std::future::Future<Output = ()> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(())
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ fn future_simple_command_snake(the_argument: String) -> impl std::future::Future
|
||||
fn future_simple_command_with_return_snake(
|
||||
the_argument: String,
|
||||
) -> impl std::future::Future<Output = String> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(the_argument)
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ fn future_simple_command_with_return_snake(
|
||||
fn future_simple_command_with_result_snake(
|
||||
the_argument: String,
|
||||
) -> impl std::future::Future<Output = Result<String, ()>> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
std::future::ready(Ok(the_argument))
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ fn force_async_with_result_snake(the_argument: &str) -> Result<&str, MyError> {
|
||||
|
||||
#[command]
|
||||
fn simple_command_with_result(the_argument: String) -> Result<String, MyError> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
(!the_argument.is_empty())
|
||||
.then(|| the_argument)
|
||||
.ok_or(MyError::FooError)
|
||||
@ -148,7 +148,7 @@ fn stateful_command_with_result(
|
||||
|
||||
#[command(rename_all = "snake_case")]
|
||||
fn simple_command_with_result_snake(the_argument: String) -> Result<String, MyError> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
(!the_argument.is_empty())
|
||||
.then(|| the_argument)
|
||||
.ok_or(MyError::FooError)
|
||||
@ -167,7 +167,7 @@ fn stateful_command_with_result_snake(
|
||||
|
||||
#[command]
|
||||
async fn async_simple_command_with_result(the_argument: String) -> Result<String, MyError> {
|
||||
println!("{}", the_argument);
|
||||
println!("{the_argument}");
|
||||
Ok(the_argument)
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ struct Person<'a> {
|
||||
|
||||
#[command]
|
||||
fn command_arguments_struct(Person { name, age }: Person<'_>) {
|
||||
println!("received person struct with name: {} | age: {}", name, age)
|
||||
println!("received person struct with name: {name} | age: {age}")
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@ -203,7 +203,7 @@ struct InlinePerson<'a>(&'a str, u8);
|
||||
|
||||
#[command]
|
||||
fn command_arguments_tuple_struct(InlinePerson(name, age): InlinePerson<'_>) {
|
||||
println!("received person tuple with name: {} | age: {}", name, age)
|
||||
println!("received person tuple with name: {name} | age: {age}")
|
||||
}
|
||||
|
||||
#[command]
|
||||
|
@ -14,7 +14,7 @@ fn main() {
|
||||
.on_page_load(|window, _payload| {
|
||||
let label = window.label().to_string();
|
||||
window.listen("clicked".to_string(), move |_payload| {
|
||||
println!("got 'clicked' event on window '{}'", label);
|
||||
println!("got 'clicked' event on window '{label}'");
|
||||
});
|
||||
})
|
||||
.setup(|app| {
|
||||
|
@ -28,7 +28,7 @@ fn main() {
|
||||
.on_page_load(|window, _payload| {
|
||||
let label = window.label().to_string();
|
||||
window.listen("clicked".to_string(), move |_payload| {
|
||||
println!("got 'clicked' event on window '{}'", label);
|
||||
println!("got 'clicked' event on window '{label}'");
|
||||
});
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![create_child_window])
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
||||
if !video_file.exists() {
|
||||
// Downloading with curl this saves us from adding
|
||||
// a Rust HTTP client dependency.
|
||||
println!("Downloading {}", video_url);
|
||||
println!("Downloading {video_url}");
|
||||
let status = Command::new("curl")
|
||||
.arg("-L")
|
||||
.arg("-o")
|
||||
|
@ -117,7 +117,7 @@ pub fn generate_data(
|
||||
|
||||
for bin in settings.binaries() {
|
||||
let bin_path = settings.binary_path(bin);
|
||||
common::copy_file(&bin_path, &bin_dir.join(bin.name()))
|
||||
common::copy_file(&bin_path, bin_dir.join(bin.name()))
|
||||
.with_context(|| format!("Failed to copy binary from {:?}", bin_path))?;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,10 @@ where
|
||||
let mut work = true;
|
||||
|
||||
while work {
|
||||
#[allow(clippy::needless_borrow)]
|
||||
{
|
||||
result_copy = copy_file(&file, &path, &file_options);
|
||||
}
|
||||
match result_copy {
|
||||
Ok(val) => {
|
||||
result += val;
|
||||
|
@ -655,7 +655,7 @@ impl Settings {
|
||||
.to_string_lossy()
|
||||
.replace(&format!("-{}", self.target), ""),
|
||||
);
|
||||
common::copy_file(&src, &dest)?;
|
||||
common::copy_file(&src, dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -665,7 +665,7 @@ impl Settings {
|
||||
for src in self.resource_files() {
|
||||
let src = src?;
|
||||
let dest = path.join(tauri_utils::resources::resource_relpath(&src));
|
||||
common::copy_file(&src, &dest)?;
|
||||
common::copy_file(&src, dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
4
tooling/cli/Cargo.lock
generated
4
tooling/cli/Cargo.lock
generated
@ -3435,9 +3435,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -185,8 +185,7 @@ pub fn command(mut options: Options) -> Result<()> {
|
||||
}
|
||||
None => {
|
||||
return Err(anyhow::anyhow!(format!(
|
||||
"Unsupported bundle format: {}",
|
||||
name
|
||||
"Unsupported bundle format: {name}"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@ -349,7 +348,7 @@ fn run_hook(name: &str, hook: HookCommand, interface: &AppInterface, debug: bool
|
||||
.current_dir(cwd)
|
||||
.envs(env)
|
||||
.piped()
|
||||
.with_context(|| format!("failed to run `{}` with `sh -c`", script))?;
|
||||
.with_context(|| format!("failed to run `{script}` with `sh -c`"))?;
|
||||
|
||||
if !status.success() {
|
||||
bail!(
|
||||
@ -384,9 +383,9 @@ mod pkgconfig_utils {
|
||||
|
||||
pub fn get_appindicator_library_path() -> PathBuf {
|
||||
match get_library_path("ayatana-appindicator3-0.1") {
|
||||
Some(p) => format!("{}/libayatana-appindicator3.so.1", p).into(),
|
||||
Some(p) => format!("{p}/libayatana-appindicator3.so.1").into(),
|
||||
None => match get_library_path("appindicator3-0.1") {
|
||||
Some(p) => format!("{}/libappindicator3.so.1", p).into(),
|
||||
Some(p) => format!("{p}/libappindicator3.so.1").into(),
|
||||
None => panic!("Can't detect any appindicator library"),
|
||||
},
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ fn command_internal(mut options: Options) -> Result<()> {
|
||||
command.stderr(os_pipe::dup_stderr()?);
|
||||
|
||||
let child = SharedChild::spawn(&mut command)
|
||||
.unwrap_or_else(|_| panic!("failed to run `{}`", before_dev));
|
||||
.unwrap_or_else(|_| panic!("failed to run `{before_dev}`"));
|
||||
let child = Arc::new(child);
|
||||
let child_ = child.clone();
|
||||
|
||||
@ -239,8 +239,7 @@ fn command_internal(mut options: Options) -> Result<()> {
|
||||
options.config = Some(serde_json::to_string(&c).unwrap());
|
||||
} else {
|
||||
options.config = Some(format!(
|
||||
r#"{{ "build": {{ "devPath": "{}" }} }}"#,
|
||||
SERVER_URL
|
||||
r#"{{ "build": {{ "devPath": "{SERVER_URL}" }} }}"#
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ pub fn generate_key(password: Option<String>) -> crate::Result<KeyPair> {
|
||||
let pk_box_str = pk.to_box().unwrap().to_string();
|
||||
let sk_box_str = sk.to_box(None).unwrap().to_string();
|
||||
|
||||
let encoded_pk = encode(&pk_box_str);
|
||||
let encoded_sk = encode(&sk_box_str);
|
||||
let encoded_pk = encode(pk_box_str);
|
||||
let encoded_sk = encode(sk_box_str);
|
||||
|
||||
Ok(KeyPair {
|
||||
pk: encoded_pk,
|
||||
@ -46,7 +46,7 @@ pub fn generate_key(password: Option<String>) -> crate::Result<KeyPair> {
|
||||
|
||||
/// Transform a base64 String to readable string for the main signer
|
||||
pub fn decode_key(base64_key: String) -> crate::Result<String> {
|
||||
let decoded_str = &decode(&base64_key)?[..];
|
||||
let decoded_str = &decode(base64_key)?[..];
|
||||
Ok(String::from(str::from_utf8(decoded_str)?))
|
||||
}
|
||||
|
||||
@ -81,11 +81,11 @@ where
|
||||
}
|
||||
|
||||
let mut sk_writer = create_file(sk_path)?;
|
||||
write!(sk_writer, "{:}", key)?;
|
||||
write!(sk_writer, "{key:}")?;
|
||||
sk_writer.flush()?;
|
||||
|
||||
let mut pk_writer = create_file(pk_path)?;
|
||||
write!(pk_writer, "{:}", pubkey)?;
|
||||
write!(pk_writer, "{pubkey:}")?;
|
||||
pk_writer.flush()?;
|
||||
|
||||
Ok((fs::canonicalize(sk_path)?, fs::canonicalize(pk_path)?))
|
||||
@ -128,7 +128,7 @@ where
|
||||
Some("signature from tauri secret key"),
|
||||
)?;
|
||||
|
||||
let encoded_signature = encode(&signature_box.to_string());
|
||||
let encoded_signature = encode(signature_box.to_string());
|
||||
signature_box_writer.write_all(encoded_signature.as_bytes())?;
|
||||
signature_box_writer.flush()?;
|
||||
Ok((fs::canonicalize(&signature_path)?, signature_box))
|
||||
|
@ -76,7 +76,7 @@ fn appx(source: &DynamicImage, out_dir: &Path) -> Result<()> {
|
||||
resize_and_save_png(source, 50, &out_dir.join("StoreLogo.png"))?;
|
||||
|
||||
for size in [30, 44, 71, 89, 107, 142, 150, 284, 310] {
|
||||
let file_name = format!("Square{}x{}Logo.png", size, size);
|
||||
let file_name = format!("Square{size}x{size}Logo.png");
|
||||
log::info!(action = "Appx"; "Creating {}", file_name);
|
||||
|
||||
resize_and_save_png(source, size, &out_dir.join(&file_name))?;
|
||||
@ -108,7 +108,7 @@ fn icns(source: &DynamicImage, out_dir: &Path) -> Result<()> {
|
||||
&image,
|
||||
IconType::from_ostype(entry.ostype.parse().unwrap()).unwrap(),
|
||||
)
|
||||
.with_context(|| format!("Can't add {} to Icns Family", name))?;
|
||||
.with_context(|| format!("Can't add {name} to Icns Family"))?;
|
||||
}
|
||||
|
||||
let mut out_file = BufWriter::new(File::create(out_dir.join("icon.icns"))?);
|
||||
@ -159,7 +159,7 @@ fn png(source: &DynamicImage, out_dir: &Path) -> Result<()> {
|
||||
let file_name = match size {
|
||||
256 => "128x128@2x.png".to_string(),
|
||||
512 => "icon.png".to_string(),
|
||||
_ => format!("{}x{}.png", size, size),
|
||||
_ => format!("{size}x{size}.png"),
|
||||
};
|
||||
|
||||
log::info!(action = "PNG"; "Creating {}", file_name);
|
||||
|
@ -128,7 +128,7 @@ pub(crate) fn cli_upstream_version() -> Result<String> {
|
||||
}
|
||||
|
||||
fn crate_latest_version(name: &str) -> Option<String> {
|
||||
let url = format!("https://docs.rs/crate/{}/", name);
|
||||
let url = format!("https://docs.rs/crate/{name}/");
|
||||
match ureq::get(&url).call() {
|
||||
Ok(response) => match (response.status(), response.header("location")) {
|
||||
(302, Some(location)) => Some(location.replace(&url, "")),
|
||||
@ -431,7 +431,7 @@ fn crate_version(
|
||||
crate_lock_package.version.clone()
|
||||
};
|
||||
(
|
||||
format!("{} (no manifest)", version_string),
|
||||
format!("{version_string} (no manifest)"),
|
||||
vec![crate_lock_package.version.clone()],
|
||||
)
|
||||
}
|
||||
@ -450,21 +450,21 @@ fn crate_version(
|
||||
v
|
||||
} else if let Some(p) = p.path {
|
||||
let manifest_path = tauri_dir.join(&p).join("Cargo.toml");
|
||||
let v = match read_to_string(&manifest_path)
|
||||
let v = match read_to_string(manifest_path)
|
||||
.map_err(|_| ())
|
||||
.and_then(|m| toml::from_str::<CargoManifest>(&m).map_err(|_| ()))
|
||||
{
|
||||
Ok(manifest) => manifest.package.version,
|
||||
Err(_) => "unknown version".to_string(),
|
||||
};
|
||||
format!("path:{:?} [{}]", p, v)
|
||||
format!("path:{p:?} [{v}]")
|
||||
} else if let Some(g) = p.git {
|
||||
is_git = true;
|
||||
let mut v = format!("git:{}", g);
|
||||
let mut v = format!("git:{g}");
|
||||
if let Some(branch) = p.branch {
|
||||
let _ = write!(v, "&branch={}", branch);
|
||||
let _ = write!(v, "&branch={branch}");
|
||||
} else if let Some(rev) = p.rev {
|
||||
let _ = write!(v, "#{}", rev);
|
||||
let _ = write!(v, "#{rev}");
|
||||
}
|
||||
v
|
||||
} else {
|
||||
@ -505,7 +505,7 @@ fn crate_version(
|
||||
(Some(version), Some(target_version)) => {
|
||||
let target_version = semver::Version::parse(&target_version).unwrap();
|
||||
if version < target_version {
|
||||
Some(format!(" (outdated, latest: {})", target_version))
|
||||
Some(format!(" (outdated, latest: {target_version})"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -538,8 +538,7 @@ impl<T> MaybeWorkspace<T> {
|
||||
MaybeWorkspace::Defined(value) => Ok(value),
|
||||
MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: true }) => {
|
||||
get_ws_field().context(format!(
|
||||
"error inheriting `{}` from workspace root manifest's `workspace.package.{}`",
|
||||
label, label
|
||||
"error inheriting `{label}` from workspace root manifest's `workspace.package.{label}`"
|
||||
))
|
||||
}
|
||||
MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: false }) => Err(anyhow::anyhow!(
|
||||
@ -674,7 +673,7 @@ impl AppSettings for RustAppSettings {
|
||||
}
|
||||
.into();
|
||||
|
||||
Ok(out_dir.join(bin_name).with_extension(&binary_extension))
|
||||
Ok(out_dir.join(bin_name).with_extension(binary_extension))
|
||||
}
|
||||
|
||||
fn get_binaries(&self, config: &Config, target: &str) -> crate::Result<Vec<BundleBinary>> {
|
||||
|
@ -103,7 +103,7 @@ fn get_file_path(
|
||||
warn: bool,
|
||||
) -> Result<Option<PathBuf>> {
|
||||
let possible = dir.join(filename_without_extension);
|
||||
let possible_with_extension = dir.join(format!("{}.toml", filename_without_extension));
|
||||
let possible_with_extension = dir.join(format!("{filename_without_extension}.toml"));
|
||||
|
||||
if possible.exists() {
|
||||
if warn && possible_with_extension.exists() {
|
||||
|
@ -109,10 +109,10 @@ pub fn build(
|
||||
|
||||
let triple_out_dir = app_settings
|
||||
.out_dir(Some(triple.into()), options.debug)
|
||||
.with_context(|| format!("failed to get {} out dir", triple))?;
|
||||
.with_context(|| format!("failed to get {triple} out dir"))?;
|
||||
|
||||
build_production_app(options, available_targets, config_features.clone())
|
||||
.with_context(|| format!("failed to build {} binary", triple))?;
|
||||
.with_context(|| format!("failed to build {triple} binary"))?;
|
||||
|
||||
lipo_cmd.arg(triple_out_dir.join(bin_name));
|
||||
}
|
||||
@ -120,8 +120,7 @@ pub fn build(
|
||||
let lipo_status = lipo_cmd.output_ok()?.status;
|
||||
if !lipo_status.success() {
|
||||
return Err(anyhow::anyhow!(format!(
|
||||
"Result of `lipo` command was unsuccessful: {}. (Is `lipo` installed?)",
|
||||
lipo_status
|
||||
"Result of `lipo` command was unsuccessful: {lipo_status}. (Is `lipo` installed?)"
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
@ -288,7 +287,7 @@ fn build_command(
|
||||
args.push(target);
|
||||
}
|
||||
|
||||
let mut build_cmd = Command::new(&runner);
|
||||
let mut build_cmd = Command::new(runner);
|
||||
build_cmd.arg("build");
|
||||
build_cmd.args(args);
|
||||
|
||||
@ -341,7 +340,7 @@ fn rename_app(bin_path: &Path, product_name: Option<&str>) -> crate::Result<Path
|
||||
let product_path = bin_path
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join(&product_name)
|
||||
.join(product_name)
|
||||
.with_extension(bin_path.extension().unwrap_or_default());
|
||||
|
||||
rename(bin_path, &product_path).with_context(|| {
|
||||
|
@ -54,7 +54,7 @@ impl Manifest {
|
||||
let mut all_enabled_features: Vec<String> = self
|
||||
.tauri_features
|
||||
.iter()
|
||||
.map(|f| format!("tauri/{}", f))
|
||||
.map(|f| format!("tauri/{f}"))
|
||||
.collect();
|
||||
|
||||
let manifest_features = self.features();
|
||||
@ -86,7 +86,7 @@ fn read_manifest(manifest_path: &Path) -> crate::Result<Document> {
|
||||
let mut manifest_str = String::new();
|
||||
|
||||
let mut manifest_file = File::open(manifest_path)
|
||||
.with_context(|| format!("failed to open `{:?}` file", manifest_path))?;
|
||||
.with_context(|| format!("failed to open `{manifest_path:?}` file"))?;
|
||||
manifest_file.read_to_string(&mut manifest_str)?;
|
||||
|
||||
let manifest: Document = manifest_str
|
||||
|
@ -156,7 +156,7 @@ where
|
||||
.try_init();
|
||||
|
||||
if let Err(err) = init_res {
|
||||
eprintln!("Failed to attach logger: {}", err);
|
||||
eprintln!("Failed to attach logger: {err}");
|
||||
}
|
||||
|
||||
match cli.command {
|
||||
@ -204,14 +204,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)));
|
||||
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)));
|
||||
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());
|
||||
|
@ -56,7 +56,7 @@ impl Options {
|
||||
|
||||
pub fn command(mut options: Options) -> Result<()> {
|
||||
options.load();
|
||||
let template_target_path = PathBuf::from(options.directory).join(&format!(
|
||||
let template_target_path = PathBuf::from(options.directory).join(format!(
|
||||
"tauri-plugin-{}",
|
||||
AsKebabCase(&options.plugin_name)
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user