Skip to content

Commit bda8304

Browse files
fix(cli): error out when migrating from v2 alpha (#13833)
1 parent fb9d9c7 commit bda8304

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

.changes/migrate-alpha-error.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tauri-apps/cli": patch:bug
3+
"tauri-cli": patch:bug
4+
---
5+
6+
Fail with an error when trying to migrate from v2 alpha

.changes/v2-beta-to-stable.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tauri-apps/cli": patch:bug
3+
"tauri-cli": patch:bug
4+
---
5+
6+
Use v2 stable instead of v2-rc when migrating from v2-beta

crates/tauri-cli/src/migrate/migrations/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// SPDX-License-Identifier: MIT
44

55
pub mod v1;
6-
pub mod v2_rc;
6+
pub mod v2_beta;

crates/tauri-cli/src/migrate/migrations/v2_rc.rs renamed to crates/tauri-cli/src/migrate/migrations/v2_beta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn migrate_npm_dependencies(frontend_dir: &Path) -> Result<()> {
7272
.unwrap_or_default()
7373
.unwrap_or_default();
7474
if version.starts_with('1') {
75-
install_deps.push(format!("{pkg}@^2.0.0-rc.0"));
75+
install_deps.push(format!("{pkg}@^2.0.0"));
7676
}
7777
}
7878

@@ -111,7 +111,7 @@ fn migrate_permissions(tauri_dir: &Path) -> Result<()> {
111111
}
112112

113113
fn migrate_manifest(manifest: &mut DocumentMut) -> Result<()> {
114-
let version = "2.0.0-rc.0";
114+
let version = "2.0.0";
115115

116116
let dependencies = manifest
117117
.as_table_mut()

crates/tauri-cli/src/migrate/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313

1414
use std::{fs::read_to_string, str::FromStr};
1515

16-
use anyhow::Context;
16+
use anyhow::{bail, Context};
1717

1818
mod migrations;
1919

@@ -47,9 +47,22 @@ pub fn command() -> Result<()> {
4747
migrations::v1::run().context("failed to migrate from v1")?;
4848
} else if tauri_version.major == 2 {
4949
if let Some((pre, _number)) = tauri_version.pre.as_str().split_once('.') {
50-
if pre == "beta" {
51-
migrations::v2_rc::run().context("failed to migrate from v2 beta to rc")?;
50+
match pre {
51+
"beta" => {
52+
migrations::v2_beta::run().context("failed to migrate from v2 beta")?;
53+
}
54+
"alpha" => {
55+
bail!(
56+
"Migrating from v2 alpha ({tauri_version}) to v2 stable is not supported yet, \
57+
if your project started early, try downgrading to v1 and then try again"
58+
)
59+
}
60+
_ => {
61+
bail!("Migrating from {tauri_version} to v2 stable is not supported yet")
62+
}
5263
}
64+
} else {
65+
log::info!("Nothing to do, the tauri version is already at v2 stable");
5366
}
5467
}
5568

0 commit comments

Comments
 (0)