inspect.rs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2019-2024 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. use anyhow::Result;
  5. use clap::{Parser, Subcommand};
  6. use crate::interface::{AppInterface, AppSettings, Interface};
  7. #[derive(Debug, Parser)]
  8. #[clap(about = "Manage or create permissions for your app or plugin")]
  9. pub struct Cli {
  10. #[clap(subcommand)]
  11. command: Commands,
  12. }
  13. #[derive(Subcommand, Debug)]
  14. enum Commands {
  15. /// Print the default Upgrade Code used by MSI installer derived from productName.
  16. WixUpgradeCode,
  17. }
  18. pub fn command(cli: Cli) -> Result<()> {
  19. match cli.command {
  20. Commands::WixUpgradeCode => wix_upgrade_code(),
  21. }
  22. }
  23. // NOTE: if this is ever changed, make sure to also update Wix upgrade code generation in tauri-bundler
  24. fn wix_upgrade_code() -> Result<()> {
  25. crate::helpers::app_paths::resolve();
  26. let target = tauri_utils::platform::Target::Windows;
  27. let config = crate::helpers::config::get(target, None)?;
  28. let interface = AppInterface::new(config.lock().unwrap().as_ref().unwrap(), None)?;
  29. let product_name = interface.app_settings().get_package_settings().product_name;
  30. let upgrade_code = uuid::Uuid::new_v5(
  31. &uuid::Uuid::NAMESPACE_DNS,
  32. format!("{product_name}.exe.app.x64").as_bytes(),
  33. )
  34. .to_string();
  35. log::info!("Default WiX Upgrade Code, derived from {product_name}: {upgrade_code}");
  36. if let Some(code) = config.lock().unwrap().as_ref().and_then(|c| {
  37. c.bundle
  38. .windows
  39. .wix
  40. .as_ref()
  41. .and_then(|wix| wix.upgrade_code)
  42. }) {
  43. log::info!("Application Upgrade Code override: {code}");
  44. }
  45. Ok(())
  46. }