From 876e92d5615f826a34a87c82aaabf92c0a9dbfb3 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 25 Aug 2024 10:59:05 -0300 Subject: [PATCH] update migration --- .../cli/src/migrate/migrations/v1/config.rs | 63 ++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/tooling/cli/src/migrate/migrations/v1/config.rs b/tooling/cli/src/migrate/migrations/v1/config.rs index af60d3d0263..a0baa9adb51 100644 --- a/tooling/cli/src/migrate/migrations/v1/config.rs +++ b/tooling/cli/src/migrate/migrations/v1/config.rs @@ -252,15 +252,39 @@ fn process_bundle(config: &mut Map, migrated: &MigratedConfig) { license_file = Some(license); } } + + // Windows if let Some(windows) = bundle_config.get_mut("windows") { - if let Some(wix) = windows.get_mut("wix").and_then(|v| v.as_object_mut()) { - if let Some(license_path) = wix.remove("license") { - license_file = Some(license_path); + if let Some(windows) = windows.as_object_mut() { + if let Some(wix) = windows.get_mut("wix").and_then(|v| v.as_object_mut()) { + if let Some(license_path) = wix.remove("license") { + license_file = Some(license_path); + } } - } - if let Some(nsis) = windows.get_mut("nsis").and_then(|v| v.as_object_mut()) { - if let Some(license_path) = nsis.remove("license") { - license_file = Some(license_path); + if let Some(nsis) = windows.get_mut("nsis").and_then(|v| v.as_object_mut()) { + if let Some(license_path) = nsis.remove("license") { + license_file = Some(license_path); + } + } + + if let Some((fixed_runtime_path, key)) = windows + .remove("webviewFixedRuntimePath") + .map(|v| (v, "webviewInstallMode")) + .or_else(|| { + windows + .remove("webview-fixed-runtime-path") + .map(|v| (v, "webview-install-mode")) + }) + { + if !fixed_runtime_path.is_null() { + windows.insert( + key.into(), + serde_json::json!({ + "type": "fixedRuntime", + "path": fixed_runtime_path + }), + ); + } } } } @@ -1083,4 +1107,29 @@ mod test { original["build"]["frontendDist"] ); } + + #[test] + fn migrate_webview_fixed_runtime_path() { + let original = serde_json::json!({ + "tauri": { + "bundle": { + "windows": { + "webviewFixedRuntimePath": "./path/to/runtime" + } + } + } + }); + + let migrated = migrate(&original); + + assert_eq!( + migrated["bundle"]["windows"]["webviewInstallMode"]["type"], + "fixedRuntime" + ); + + assert_eq!( + migrated["bundle"]["windows"]["webviewInstallMode"]["path"], + original["tauri"]["bundle"]["windows"]["webviewFixedRuntimePath"] + ); + } }