소스 검색

feat(cli): use default macOS minimum system version when it is empty (#3658)

Lucas Fernandes Nogueira 3 년 전
부모
커밋
c81534ebd8

+ 6 - 0
.changes/cli-template-minimum-mac-system-version.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Remove `minimumSystemVersion: null` from the application template configuration.

+ 5 - 0
.changes/enhance-minimum-system-version-deserialization.md

@@ -0,0 +1,5 @@
+---
+"tauri-utils": patch
+---
+
+Use the default value for `MacConfig.minimumSystemVersion` if the value is set to an empty string.

+ 18 - 1
core/tauri-utils/src/config.rs

@@ -99,6 +99,17 @@ pub struct DebConfig {
   pub files: HashMap<PathBuf, PathBuf>,
 }
 
+fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
+where
+  D: Deserializer<'de>,
+{
+  let version = Option::<String>::deserialize(deserializer)?;
+  match version {
+    Some(v) if v.is_empty() => Ok(minimum_system_version()),
+    e => Ok(e),
+  }
+}
+
 /// Configuration for the macOS bundles.
 #[skip_serializing_none]
 #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
@@ -110,9 +121,15 @@ pub struct MacConfig {
   /// If a name is used, ".framework" must be omitted and it will look for standard install locations. You may also use a path to a specific framework.
   pub frameworks: Option<Vec<String>>,
   /// A version string indicating the minimum macOS X version that the bundled application supports. Defaults to `10.13`.
+  ///
   /// Setting it to `null` completely removes the `LSMinimumSystemVersion` field on the bundle's `Info.plist`
   /// and the `MACOSX_DEPLOYMENT_TARGET` environment variable.
-  #[serde(default = "minimum_system_version")]
+  ///
+  /// An empty string is considered an invalid value so the default value is used.
+  #[serde(
+    deserialize_with = "de_minimum_system_version",
+    default = "minimum_system_version"
+  )]
   pub minimum_system_version: Option<String>,
   /// Allows your application to communicate with the outside world.
   /// It should be a lowercase, without port and protocol domain name.

+ 0 - 1
examples/commands/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/helloworld/src-tauri/tauri.conf.json

@@ -29,7 +29,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/isolation/src-tauri/tauri.conf.json

@@ -40,7 +40,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": "",
         "signingIdentity": null,

+ 0 - 1
examples/navigation/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/resources/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/sidecar/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/state/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/streaming/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/tauri-dynamic-lib/src-tauri/tauri.conf.json

@@ -29,7 +29,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
examples/updater/src-tauri/tauri.conf.json

@@ -31,7 +31,6 @@
         "signingIdentity": null,
         "entitlements": "../entitlements.plist",
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       },

+ 0 - 1
tooling/bench/tests/cpu_intensive/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
tooling/bench/tests/files_transfer/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 0 - 1
tooling/bench/tests/helloworld/src-tauri/tauri.conf.json

@@ -30,7 +30,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }

+ 1 - 1
tooling/cli/schema.json

@@ -1145,7 +1145,7 @@
           ]
         },
         "minimumSystemVersion": {
-          "description": "A version string indicating the minimum macOS X version that the bundled application supports. Defaults to `10.13`. Setting it to `null` completely removes the `LSMinimumSystemVersion` field on the bundle's `Info.plist` and the `MACOSX_DEPLOYMENT_TARGET` environment variable.",
+          "description": "A version string indicating the minimum macOS X version that the bundled application supports. Defaults to `10.13`.\n\nSetting it to `null` completely removes the `LSMinimumSystemVersion` field on the bundle's `Info.plist` and the `MACOSX_DEPLOYMENT_TARGET` environment variable.\n\nAn empty string is considered an invalid value so the default value is used.",
           "default": "10.13",
           "type": [
             "string",

+ 0 - 1
tooling/cli/templates/app/src-tauri/tauri.conf.json

@@ -33,7 +33,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": "",
         "signingIdentity": null,

+ 0 - 1
tooling/cli/templates/plugin/backend/examples/vanilla/src-tauri/tauri.conf.json

@@ -31,7 +31,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": "",
         "signingIdentity": null,

+ 0 - 1
tooling/cli/templates/plugin/with-api/examples/svelte-app/src-tauri/tauri.conf.json

@@ -29,7 +29,6 @@
       },
       "macOS": {
         "frameworks": [],
-        "minimumSystemVersion": "",
         "useBootstrapper": false,
         "exceptionDomain": ""
       }