Эх сурвалжийг харах

feat(cli) Make `tauri migrate` update $schema in tauri.conf.json (#11414)

* Make `tauri migrate` update $schema in tauri.conf.json

* add change file

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Czxck001 9 сар өмнө
parent
commit
e0d1307d3f

+ 6 - 0
.changes/migrate-schema.md

@@ -0,0 +1,6 @@
+---
+"@tauri-apps/cli": patch:enhance
+"tauri-cli": patch:enhance
+---
+
+Migrate the `$schema` Tauri configuration to the v2 format.

+ 13 - 0
crates/tauri-cli/src/migrate/migrations/v1/config.rs

@@ -684,6 +684,15 @@ mod test {
     let mut migrated = original.clone();
     super::migrate_config(&mut migrated).expect("failed to migrate config");
 
+    if original.get("$schema").is_some() {
+      if let Some(map) = migrated.as_object_mut() {
+        map.insert(
+          "$schema".to_string(),
+          serde_json::Value::String("https://schema.tauri.app/config/2".to_string()),
+        );
+      }
+    }
+
     if original
       .get("tauri")
       .and_then(|v| v.get("bundle"))
@@ -708,6 +717,7 @@ mod test {
   #[test]
   fn migrate_full() {
     let original = serde_json::json!({
+      "$schema": "../node_modules/@tauri-apps/cli/schema.json",
       "build": {
         "distDir": "../dist",
         "devPath": "http://localhost:1240",
@@ -798,6 +808,9 @@ mod test {
 
     let migrated = migrate(&original);
 
+    // $schema
+    assert_eq!(migrated["$schema"], "https://schema.tauri.app/config/2");
+
     // plugins > updater
     assert_eq!(
       migrated["plugins"]["updater"]["endpoints"],