Skip to content

Commit fafc238

Browse files
authored
feat: add bundle > homepage option (#9977)
* feat: add `bundle > homepage` option If unspecified, it will fallback to `homepage` define in Cargo.toml closes #9949 * Update settings.rs
1 parent 40c0f44 commit fafc238

File tree

12 files changed

+67
-6
lines changed

12 files changed

+67
-6
lines changed

.changes/bundler-homepage-url.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-utils": "minor:feat"
3+
"tauri-bundler": "minor:feat"
4+
---
5+
6+
Add `bundle > homepage` option, if unset, it will fallback to `homepage` defined in `Cargo.toml`.
7+

core/tauri-config-schema/schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,13 @@
15321532
"null"
15331533
]
15341534
},
1535+
"homepage": {
1536+
"description": "A url to the home page of your application. If unset, will fallback to `homepage` defined in `Cargo.toml`.\n\nSupported bundle targets: `deb`, `rpm`, `nsis` and `msi`.",
1537+
"type": [
1538+
"string",
1539+
"null"
1540+
]
1541+
},
15351542
"icon": {
15361543
"description": "The app's icons",
15371544
"default": [],

core/tauri-utils/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,11 @@ pub struct BundleConfig {
10541054
/// The application's publisher. Defaults to the second element in the identifier string.
10551055
/// Currently maps to the Manufacturer property of the Windows Installer.
10561056
pub publisher: Option<String>,
1057+
/// A url to the home page of your application. If unset, will
1058+
/// fallback to `homepage` defined in `Cargo.toml`.
1059+
///
1060+
/// Supported bundle targets: `deb`, `rpm`, `nsis` and `msi`.
1061+
pub homepage: Option<String>,
10571062
/// The app's icons
10581063
#[serde(default)]
10591064
pub icon: Vec<String>,
@@ -2416,6 +2421,7 @@ mod build {
24162421
impl ToTokens for BundleConfig {
24172422
fn to_tokens(&self, tokens: &mut TokenStream) {
24182423
let publisher = quote!(None);
2424+
let homepage = quote!(None);
24192425
let icon = vec_lit(&self.icon, str_lit);
24202426
let active = self.active;
24212427
let targets = quote!(Default::default());
@@ -2439,6 +2445,7 @@ mod build {
24392445
::tauri::utils::config::BundleConfig,
24402446
active,
24412447
publisher,
2448+
homepage,
24422449
icon,
24432450
targets,
24442451
resources,
@@ -2756,6 +2763,7 @@ mod test {
27562763
active: false,
27572764
targets: Default::default(),
27582765
publisher: None,
2766+
homepage: None,
27592767
icon: Vec::new(),
27602768
resources: None,
27612769
copyright: None,

tooling/bundler/src/bundle/linux/debian.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ fn generate_control_file(
175175
writeln!(file, "Priority: optional")?;
176176
}
177177

178-
if !settings.homepage_url().is_empty() {
179-
writeln!(file, "Homepage: {}", settings.homepage_url())?;
178+
if let Some(homepage) = settings.homepage_url() {
179+
writeln!(file, "Homepage: {}", homepage)?;
180180
}
181+
181182
let dependencies = settings.deb().depends.as_ref().cloned().unwrap_or_default();
182183
if !dependencies.is_empty() {
183184
writeln!(file, "Depends: {}", dependencies.join(", "))?;

tooling/bundler/src/bundle/linux/rpm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
5252
.compression(rpm::CompressionWithLevel::Gzip(6));
5353

5454
if let Some(description) = settings.long_description() {
55-
builder = builder.description(description.trim())
55+
builder = builder.description(description);
56+
}
57+
58+
if let Some(homepage) = settings.homepage_url() {
59+
builder = builder.url(homepage);
5660
}
5761

5862
// Add requirements

tooling/bundler/src/bundle/settings.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ pub struct BundleSettings {
523523
/// The app's publisher. Defaults to the second element in the identifier string.
524524
/// Currently maps to the Manufacturer property of the Windows Installer.
525525
pub publisher: Option<String>,
526+
/// A url to the home page of your application. If None, will
527+
/// fallback to [PackageSettings::homepage].
528+
///
529+
/// Supported bundle targets: `deb`, `rpm`, `nsis` and `msi`
530+
pub homepage: Option<String>,
526531
/// the app's icon list.
527532
pub icon: Option<Vec<String>>,
528533
/// the app's resources to bundle.
@@ -893,7 +898,7 @@ impl Settings {
893898
self.bundle_settings.identifier.as_deref().unwrap_or("")
894899
}
895900

896-
/// Returns the bundle's identifier
901+
/// Returns the bundle's publisher
897902
pub fn publisher(&self) -> Option<&str> {
898903
self.bundle_settings.publisher.as_deref()
899904
}
@@ -999,8 +1004,12 @@ impl Settings {
9991004
}
10001005

10011006
/// Returns the package's homepage URL, defaulting to "" if not defined.
1002-
pub fn homepage_url(&self) -> &str {
1003-
self.package.homepage.as_deref().unwrap_or("")
1007+
pub fn homepage_url(&self) -> Option<&str> {
1008+
self
1009+
.bundle_settings
1010+
.homepage
1011+
.as_deref()
1012+
.or(self.package.homepage.as_deref())
10041013
}
10051014

10061015
/// Returns the app's category.

tooling/bundler/src/bundle/windows/msi/wix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ pub fn build_wix_app_installer(
518518
"long_description",
519519
to_json(settings.long_description().unwrap_or_default()),
520520
);
521+
data.insert("homepage", to_json(settings.homepage_url()));
521522
let bundle_id = settings.bundle_identifier();
522523
let manufacturer = settings
523524
.publisher()

tooling/bundler/src/bundle/windows/nsis.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ fn build_nsis_app_installer(
186186
data.insert("manufacturer", to_json(manufacturer));
187187
data.insert("product_name", to_json(settings.product_name()));
188188
data.insert("short_description", to_json(settings.short_description()));
189+
data.insert(
190+
"homepage",
191+
to_json(settings.homepage_url().unwrap_or_default()),
192+
);
189193
data.insert(
190194
"long_description",
191195
to_json(settings.long_description().unwrap_or_default()),

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ${StrLoc}
2828
!define VERSION "{{version}}"
2929
!define VERSIONWITHBUILD "{{version_with_build}}"
3030
!define SHORTDESCRIPTION "{{short_description}}"
31+
!define HOMEPAGE "{{homepage}}"
3132
!define INSTALLMODE "{{install_mode}}"
3233
!define LICENSE "{{license}}"
3334
!define INSTALLERICON "{{installer_icon}}"
@@ -579,6 +580,11 @@ Section Install
579580
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1"
580581
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1"
581582
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "${ESTIMATEDSIZE}"
583+
!if "${HOMEPAGE}" != ""
584+
WriteRegStr SHCTX "${UNINSTKEY}" "URLInfoAbout" "${HOMEPAGE}"
585+
WriteRegStr SHCTX "${UNINSTKEY}" "URLUpdateInfo" "${HOMEPAGE}"
586+
WriteRegStr SHCTX "${UNINSTKEY}" "HelpLink" "${HOMEPAGE}"
587+
!endif
582588

583589
; Create start menu shortcut
584590
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application

tooling/bundler/src/bundle/windows/templates/main.wxs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" /> <!-- Remove repair -->
5757
<SetProperty Id="ARPNOMODIFY" Value="1" After="InstallValidate" Sequence="execute"/>
5858

59+
{{#if homepage}}
60+
<Property Id="ARPURLINFOABOUT" Value="{{homepage}}"/>
61+
<Property Id="ARPHELPLINK" Value="{{homepage}}"/>
62+
<Property Id="ARPURLUPDATEINFO" Value="{{homepage}}"/>
63+
{{/if}}
64+
5965
<!-- initialize with previous InstallDir -->
6066
<Property Id="INSTALLDIR">
6167
<RegistrySearch Id="PrevInstallDirReg" Root="HKCU" Key="Software\\{{manufacturer}}\\{{product_name}}" Name="InstallDir" Type="raw"/>

0 commit comments

Comments
 (0)