mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(bundler): validate version before bundling with WiX (#4429)
This commit is contained in:
committed by
GitHub
parent
e0e5f77243
commit
672174b822
5
.changes/validate-wix-version.md
Normal file
5
.changes/validate-wix-version.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-bundler": patch
|
||||
---
|
||||
|
||||
Validate app version before bundling WiX.
|
||||
@@ -47,6 +47,7 @@ sha2 = "0.10"
|
||||
hex = "0.4"
|
||||
glob = "0.3"
|
||||
zip = "0.6"
|
||||
semver = "1"
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
icns = "0.3"
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::bundle::{
|
||||
path_utils::{copy_file, FileOpts},
|
||||
settings::Settings,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use anyhow::{bail, Context};
|
||||
use handlebars::{to_json, Handlebars};
|
||||
use log::info;
|
||||
use regex::Regex;
|
||||
@@ -348,6 +348,24 @@ fn run_light(
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
fn validate_version(version: &str) -> anyhow::Result<()> {
|
||||
let version = semver::Version::parse(version).context("invalid app version")?;
|
||||
if version.major > 255 {
|
||||
bail!("app version major number cannot be greater than 255");
|
||||
}
|
||||
if version.minor > 255 {
|
||||
bail!("app version minor number cannot be greater than 255");
|
||||
}
|
||||
if version.patch > 65535 {
|
||||
bail!("app version patch number cannot be greater than 65535");
|
||||
}
|
||||
if !(version.pre.is_empty() && version.build.is_empty()) {
|
||||
bail!("app version cannot have build metadata or pre-release identifier");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Entry point for bundling and creating the MSI installer. For now the only supported platform is Windows x64.
|
||||
pub fn build_wix_app_installer(
|
||||
settings: &Settings,
|
||||
@@ -364,6 +382,8 @@ pub fn build_wix_app_installer(
|
||||
}
|
||||
};
|
||||
|
||||
validate_version(settings.version_string())?;
|
||||
|
||||
// target only supports x64.
|
||||
info!("Target: {}", arch);
|
||||
|
||||
|
||||
@@ -113,4 +113,4 @@ pub enum Error {
|
||||
}
|
||||
|
||||
/// Convenient type alias of Result type.
|
||||
pub type Result<T> = anyhow::Result<T, Error>;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
1
tooling/cli/Cargo.lock
generated
1
tooling/cli/Cargo.lock
generated
@@ -2737,6 +2737,7 @@ dependencies = [
|
||||
"md5",
|
||||
"plist",
|
||||
"regex",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
||||
Reference in New Issue
Block a user