fix(build): do not rewrite unchanged schema (#8757)

* fix(build): do not rewrite unchanged schema

* typo
This commit is contained in:
Lucas Fernandes Nogueira 2024-02-04 08:45:59 -03:00 committed by GitHub
parent b43c423165
commit 0f2789cd67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 17 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-build": patch:bug
---
Do not rewrite capability JSON schema if it did not change.

View File

@ -4,8 +4,7 @@
use std::{
collections::{BTreeMap, BTreeSet},
fs::{copy, create_dir_all, read_to_string, File},
io::{BufWriter, Write},
fs::{copy, create_dir_all, read_to_string, write},
path::PathBuf,
};
@ -181,20 +180,21 @@ pub fn generate_schema(
create_dir_all(&out_dir).context("unable to create schema output directory")?;
let schema_path = out_dir.join(format!("{target}-{CAPABILITIES_SCHEMA_FILE_NAME}"));
let mut schema_file = BufWriter::new(File::create(&schema_path)?);
write!(schema_file, "{schema_str}")?;
if schema_str != read_to_string(&schema_path).unwrap_or_default() {
write(&schema_path, "{schema_str}")?;
copy(
schema_path,
out_dir.join(format!(
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
if target.is_desktop() {
"desktop"
} else {
"mobile"
}
)),
)?;
copy(
schema_path,
out_dir.join(format!(
"{}-{CAPABILITIES_SCHEMA_FILE_NAME}",
if target.is_desktop() {
"desktop"
} else {
"mobile"
}
)),
)?;
}
Ok(())
}

View File

@ -56,7 +56,7 @@ pub struct Capability {
pub description: String,
/// Execution context of the capability.
///
/// At runtime, Tauri filters the IPC command together with the context to determine wheter it is allowed or not and its scope.
/// At runtime, Tauri filters the IPC command together with the context to determine whether it is allowed or not and its scope.
#[serde(default)]
pub context: CapabilityContext,
/// List of windows that uses this capability. Can be a glob pattern.

View File

@ -3677,7 +3677,7 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae"
[[package]]
name = "tauri"
version = "2.0.0-beta.0"
version = "2.0.0-beta.1"
dependencies = [
"anyhow",
"bytes",