fix(cli): error out when migrating from v2 alpha (#13833)

This commit is contained in:
Tony
2025-07-16 22:06:17 +08:00
committed by GitHub
parent fb9d9c7fd1
commit bda8304107
5 changed files with 31 additions and 6 deletions

View File

@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:bug
"tauri-cli": patch:bug
---
Fail with an error when trying to migrate from v2 alpha

View File

@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:bug
"tauri-cli": patch:bug
---
Use v2 stable instead of v2-rc when migrating from v2-beta

View File

@@ -3,4 +3,4 @@
// SPDX-License-Identifier: MIT
pub mod v1;
pub mod v2_rc;
pub mod v2_beta;

View File

@@ -72,7 +72,7 @@ fn migrate_npm_dependencies(frontend_dir: &Path) -> Result<()> {
.unwrap_or_default()
.unwrap_or_default();
if version.starts_with('1') {
install_deps.push(format!("{pkg}@^2.0.0-rc.0"));
install_deps.push(format!("{pkg}@^2.0.0"));
}
}
@@ -111,7 +111,7 @@ fn migrate_permissions(tauri_dir: &Path) -> Result<()> {
}
fn migrate_manifest(manifest: &mut DocumentMut) -> Result<()> {
let version = "2.0.0-rc.0";
let version = "2.0.0";
let dependencies = manifest
.as_table_mut()

View File

@@ -13,7 +13,7 @@ use crate::{
use std::{fs::read_to_string, str::FromStr};
use anyhow::Context;
use anyhow::{bail, Context};
mod migrations;
@@ -47,9 +47,22 @@ pub fn command() -> Result<()> {
migrations::v1::run().context("failed to migrate from v1")?;
} else if tauri_version.major == 2 {
if let Some((pre, _number)) = tauri_version.pre.as_str().split_once('.') {
if pre == "beta" {
migrations::v2_rc::run().context("failed to migrate from v2 beta to rc")?;
match pre {
"beta" => {
migrations::v2_beta::run().context("failed to migrate from v2 beta")?;
}
"alpha" => {
bail!(
"Migrating from v2 alpha ({tauri_version}) to v2 stable is not supported yet, \
if your project started early, try downgrading to v1 and then try again"
)
}
_ => {
bail!("Migrating from {tauri_version} to v2 stable is not supported yet")
}
}
} else {
log::info!("Nothing to do, the tauri version is already at v2 stable");
}
}