Skip to content

Commit b072daa

Browse files
authored
refactor(core): move updater to a plugin (#6919)
1 parent 60cf9ed commit b072daa

File tree

42 files changed

+34
-6805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+34
-6805
lines changed

.changes/move-updater.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"api": patch
3+
"tauri": patch
4+
"tauri-utils": patch
5+
---
6+
7+
Moved the `updater` feature to its own plugin in the plugins-workspace repository.

.github/workflows/artifacts-updater.yml

Lines changed: 0 additions & 107 deletions
This file was deleted.

.scripts/update-lockfiles.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44
# SPDX-License-Identifier: MIT
55

6-
declare -a examples=("api" "sidecar" "updater" "resources" "tauri-dynamic-lib" "workspace")
6+
declare -a examples=("api" "sidecar" "resources" "tauri-dynamic-lib" "workspace")
77
declare -a tooling=("bench" "cli" "webdriver")
88

99
for example in "${examples[@]}"

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ members = [
1212

1313
# integration tests
1414
"core/tests/restart",
15-
"core/tests/app-updater",
1615
]
1716

1817
exclude = [
1918
# examples that can be compiled with the tauri CLI
2019
"examples/api/src-tauri",
21-
"examples/updater/src-tauri",
2220
"examples/resources/src-tauri",
2321
"examples/sidecar/src-tauri",
2422
"examples/web/core",

core/tauri-utils/src/config.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,22 +2206,14 @@ impl TauriConfig {
22062206
#[allow(dead_code)]
22072207
pub fn all_features() -> Vec<&'static str> {
22082208
let mut features = AllowlistConfig::all_features();
2209-
features.extend(vec![
2210-
"updater",
2211-
"system-tray",
2212-
"macos-private-api",
2213-
"isolation",
2214-
]);
2209+
features.extend(vec!["system-tray", "macos-private-api", "isolation"]);
22152210
features
22162211
}
22172212

22182213
/// Returns the enabled Cargo features.
22192214
#[allow(dead_code)]
22202215
pub fn features(&self) -> Vec<&str> {
22212216
let mut features = self.allowlist.to_features();
2222-
if self.updater.active {
2223-
features.push("updater");
2224-
}
22252217
if self.system_tray.is_some() {
22262218
features.push("system-tray");
22272219
}

core/tauri/Cargo.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ flate2 = "1.0"
6060
http = "0.2"
6161
dirs-next = "2.0"
6262
percent-encoding = "2.2"
63-
base64 = { version = "0.21", optional = true }
6463
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] }
6564
bytes = { version = "1", features = [ "serde" ] }
6665
raw-window-handle = "0.5"
67-
minisign-verify = { version = "0.2", optional = true }
68-
time = { version = "0.3", features = [ "parsing", "formatting" ], optional = true }
66+
time = { version = "0.3", optional = true }
6967
glob = "0.3"
7068
data-url = { version = "0.2", optional = true }
7169
serialize-to-javascript = "=0.1.1"
@@ -110,14 +108,12 @@ once_cell = "1"
110108
tauri-build = { path = "../tauri-build/", version = "2.0.0-alpha.1" }
111109

112110
[dev-dependencies]
113-
mockito = "0.31"
114111
proptest = "1.0.0"
115112
quickcheck = "1.0.3"
116113
quickcheck_macros = "1.0.0"
117114
serde = { version = "1.0", features = [ "derive" ] }
118115
serde_json = "1.0"
119116
tauri = { path = ".", default-features = false, features = [ "wry" ] }
120-
tokio-test = "0.4.2"
121117
tokio = { version = "1", features = [ "full" ] }
122118
cargo_toml = "0.11"
123119
winnow = "=0.4.1"
@@ -130,13 +126,7 @@ objc-exception = [ "tauri-runtime-wry/objc-exception" ]
130126
linux-protocol-headers = [ "tauri-runtime-wry/linux-headers", "webkit2gtk/v2_36" ]
131127
isolation = [ "tauri-utils/isolation", "tauri-macros/isolation" ]
132128
custom-protocol = [ "tauri-macros/custom-protocol" ]
133-
updater = [
134-
"minisign-verify",
135-
"time",
136-
"base64",
137-
"dialog-ask",
138-
"fs-extract-api"
139-
]
129+
updater = [ "time" ]
140130
fs-extract-api = [ "zip" ]
141131
native-tls = [ "reqwest/native-tls" ]
142132
native-tls-vendored = [ "reqwest/native-tls-vendored" ]

core/tauri/scripts/bundle.global.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri/src/app.rs

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ use crate::runtime::menu::{Menu, MenuId, MenuIdRef};
4545

4646
use crate::runtime::RuntimeHandle;
4747

48-
#[cfg(updater)]
49-
use crate::updater;
50-
5148
#[cfg(target_os = "macos")]
5249
use crate::ActivationPolicy;
5350

@@ -232,12 +229,6 @@ impl<R: Runtime> GlobalWindowEvent<R> {
232229
}
233230
}
234231

235-
#[cfg(updater)]
236-
#[derive(Debug, Clone, Default)]
237-
pub(crate) struct UpdaterSettings {
238-
pub(crate) target: Option<String>,
239-
}
240-
241232
/// The asset resolver is a helper to access the [`tauri_utils::assets::Assets`] interface.
242233
#[derive(Debug, Clone)]
243234
pub struct AssetResolver<R: Runtime> {
@@ -259,15 +250,11 @@ impl<R: Runtime> AssetResolver<R> {
259250
pub struct AppHandle<R: Runtime> {
260251
pub(crate) runtime_handle: R::Handle,
261252
pub(crate) manager: WindowManager<R>,
262-
/// The updater configuration.
263-
#[cfg(updater)]
264-
pub(crate) updater_settings: UpdaterSettings,
265253
}
266254

267255
impl<R: Runtime> AppHandle<R> {
268-
// currently only used on the updater
269-
#[allow(dead_code)]
270-
pub(crate) fn create_proxy(&self) -> R::EventLoopProxy {
256+
/// Creates a proxy to send events through the event loop.
257+
pub fn create_proxy(&self) -> R::EventLoopProxy {
271258
self.runtime_handle.create_proxy()
272259
}
273260
}
@@ -306,8 +293,6 @@ impl<R: Runtime> Clone for AppHandle<R> {
306293
Self {
307294
runtime_handle: self.runtime_handle.clone(),
308295
manager: self.manager.clone(),
309-
#[cfg(updater)]
310-
updater_settings: self.updater_settings.clone(),
311296
}
312297
}
313298
}
@@ -511,29 +496,6 @@ impl App<crate::Wry> {
511496
macro_rules! shared_app_impl {
512497
($app: ty) => {
513498
impl<R: Runtime> $app {
514-
#[cfg(updater)]
515-
#[cfg_attr(doc_cfg, doc(cfg(feature = "updater")))]
516-
/// Gets the updater builder to manually check if an update is available.
517-
///
518-
/// # Examples
519-
///
520-
/// ```no_run
521-
/// tauri::Builder::default()
522-
/// .setup(|app| {
523-
/// let handle = app.handle();
524-
/// tauri::async_runtime::spawn(async move {
525-
#[cfg_attr(
526-
feature = "updater",
527-
doc = r#" let response = handle.updater().check().await;"#
528-
)]
529-
/// });
530-
/// Ok(())
531-
/// });
532-
/// ```
533-
pub fn updater(&self) -> updater::UpdateBuilder<R> {
534-
updater::builder(self.app_handle())
535-
}
536-
537499
/// Gets a handle to the first system tray.
538500
///
539501
/// Prefer [`Self::tray_handle_by_id`] when multiple system trays are created.
@@ -788,21 +750,6 @@ impl<R: Runtime> App<R> {
788750
}
789751
}
790752

791-
#[cfg(updater)]
792-
impl<R: Runtime> App<R> {
793-
fn run_updater(&self) {
794-
// check if updater is active or not
795-
if self.manager.config().tauri.updater.active {
796-
// we only listen for `tauri://update`
797-
// once we receive the call, we check if an update is available or not
798-
// if there is a new update we emit `tauri://update-available` with details
799-
// this is the user responsibilities to display dialog and ask if user want to install
800-
// to install the update you need to invoke the Event `tauri://update-install`
801-
updater::listener(self.handle());
802-
}
803-
}
804-
}
805-
806753
/// Builds a Tauri application.
807754
///
808755
/// # Examples
@@ -866,10 +813,6 @@ pub struct Builder<R: Runtime> {
866813
#[cfg(all(desktop, feature = "system-tray"))]
867814
system_tray_event_listeners: Vec<SystemTrayEventListener<R>>,
868815

869-
/// The updater configuration.
870-
#[cfg(updater)]
871-
updater_settings: UpdaterSettings,
872-
873816
/// The device event filter.
874817
device_event_filter: DeviceEventFilter,
875818
}
@@ -898,8 +841,6 @@ impl<R: Runtime> Builder<R> {
898841
system_tray: None,
899842
#[cfg(all(desktop, feature = "system-tray"))]
900843
system_tray_event_listeners: Vec::new(),
901-
#[cfg(updater)]
902-
updater_settings: Default::default(),
903844
device_event_filter: Default::default(),
904845
}
905846
}
@@ -1307,42 +1248,6 @@ impl<R: Runtime> Builder<R> {
13071248
self
13081249
}
13091250

1310-
/// Sets the current platform's target name for the updater.
1311-
///
1312-
/// See [`UpdateBuilder::target`](crate::updater::UpdateBuilder#method.target) for more information.
1313-
///
1314-
/// # Examples
1315-
///
1316-
/// - Use a macOS Universal binary target name:
1317-
///
1318-
/// ```
1319-
/// let mut builder = tauri::Builder::default();
1320-
/// #[cfg(target_os = "macos")]
1321-
/// {
1322-
/// builder = builder.updater_target("darwin-universal");
1323-
/// }
1324-
/// ```
1325-
///
1326-
/// - Append debug information to the target:
1327-
///
1328-
/// ```
1329-
/// let kind = if cfg!(debug_assertions) { "debug" } else { "release" };
1330-
/// tauri::Builder::default()
1331-
/// .updater_target(format!("{}-{kind}", tauri::updater::target().unwrap()));
1332-
/// ```
1333-
///
1334-
/// - Use the platform's target triple:
1335-
///
1336-
/// ```
1337-
/// tauri::Builder::default()
1338-
/// .updater_target(tauri::utils::platform::target_triple().unwrap());
1339-
/// ```
1340-
#[cfg(updater)]
1341-
pub fn updater_target<T: Into<String>>(mut self, target: T) -> Self {
1342-
self.updater_settings.target.replace(target.into());
1343-
self
1344-
}
1345-
13461251
/// Change the device event filter mode.
13471252
///
13481253
/// Since the DeviceEvent capture can lead to high CPU usage for unfocused windows, [`tao`]
@@ -1431,8 +1336,6 @@ impl<R: Runtime> Builder<R> {
14311336
handle: AppHandle {
14321337
runtime_handle,
14331338
manager,
1434-
#[cfg(updater)]
1435-
updater_settings: self.updater_settings,
14361339
},
14371340
};
14381341

@@ -1550,8 +1453,6 @@ fn setup<R: Runtime>(app: &mut App<R>) -> crate::Result<()> {
15501453
(setup)(app).map_err(|e| crate::Error::Setup(e.into()))?;
15511454
}
15521455

1553-
#[cfg(updater)]
1554-
app.run_updater();
15551456
Ok(())
15561457
}
15571458

0 commit comments

Comments
 (0)