feat(cli): migrate tauri-build version (#8529)

* feat(cli): migrate tauri-build version

This changes the migrate command to also migrate the tauri-build dependency to v2, previously it only updated the tauri dependency.

* lint
This commit is contained in:
Lucas Fernandes Nogueira 2024-01-02 15:24:50 -03:00 committed by GitHub
parent 29ced5ceec
commit 0ec28c39f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-cli": patch:feat
"@tauri-apps/cli": patch:feat
---
Include tauri-build on the migration script.

View File

@ -13,7 +13,7 @@ use std::{
use crate::helpers::config::Config;
use tauri_bundler::bundle::{PackageType, Settings, SettingsBuilder};
pub use rust::{manifest, MobileOptions, Options, Rust as AppInterface};
pub use rust::{MobileOptions, Options, Rust as AppInterface};
pub trait DevProcess {
fn kill(&self) -> std::io::Result<()>;

View File

@ -37,6 +37,8 @@ pub fn migrate(tauri_dir: &Path) -> Result<()> {
}
fn migrate_manifest(manifest: &mut Document) -> Result<()> {
let version = dependency_version();
let dependencies = manifest
.as_table_mut()
.entry("dependencies")
@ -44,8 +46,16 @@ fn migrate_manifest(manifest: &mut Document) -> Result<()> {
.as_table_mut()
.expect("manifest dependencies isn't a table");
let version = dependency_version();
migrate_dependency(dependencies, "tauri", version, &features_to_remove());
migrate_dependency(dependencies, "tauri", &version, &features_to_remove());
let build_dependencies = manifest
.as_table_mut()
.entry("build-dependencies")
.or_insert(Item::Table(Table::new()))
.as_table_mut()
.expect("manifest build-dependencies isn't a table");
migrate_dependency(build_dependencies, "tauri-build", &version, &[]);
let lib = manifest
.as_table_mut()
@ -116,7 +126,7 @@ fn dependency_version() -> String {
}
}
fn migrate_dependency(dependencies: &mut Table, name: &str, version: String, remove: &[&str]) {
fn migrate_dependency(dependencies: &mut Table, name: &str, version: &str, remove: &[&str]) {
let item = dependencies.entry(name).or_insert(Item::None);
// do not rewrite if dependency uses workspace inheritance
@ -138,7 +148,7 @@ fn migrate_dependency(dependencies: &mut Table, name: &str, version: String, rem
}
}
fn migrate_dependency_table<D: TableLike>(dep: &mut D, version: String, remove: &[&str]) {
fn migrate_dependency_table<D: TableLike>(dep: &mut D, version: &str, remove: &[&str]) {
*dep.entry("version").or_insert(Item::None) = Item::Value(version.into());
let manifest_features = dep.entry("features").or_insert(Item::None);
if let Some(features_array) = manifest_features.as_array_mut() {