Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli/migrate): migrate existing v1 plugins
closes #9400
- Loading branch information
Showing
6 changed files
with
95 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"tauri-cli": "patch:feat" | ||
"@tauri-apps/cli": "patch:feat" | ||
--- | ||
|
||
`tauri migrate` will migrate v1 plugins if detected. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
use std::{fs, path::Path}; | ||
|
||
use anyhow::Context; | ||
|
||
use crate::{ | ||
helpers::{cargo, npm::PackageManager}, | ||
Result, | ||
}; | ||
|
||
const PLUGINS: &[&str] = &[ | ||
"authenticator", | ||
"autostart", | ||
"fs-extra", | ||
"fs-watch", | ||
"localhost", | ||
"log", | ||
"persisted-scope", | ||
"positioner", | ||
"single-instance", | ||
"sql", | ||
"store", | ||
"stronghold", | ||
"upload", | ||
"websocket", | ||
"window-state", | ||
]; | ||
|
||
pub fn migrate(tauri_dir: &Path, app_dir: &Path) -> Result<()> { | ||
let manifest_path = tauri_dir.join("Cargo.toml"); | ||
let manifest = fs::read_to_string(manifest_path).context("failed to read Cargo.toml")?; | ||
|
||
let plugins_to_migrate = PLUGINS | ||
.iter() | ||
.filter(|p| manifest.contains(&format!("tauri-plugin-{p}"))); | ||
|
||
let cargo_deps = plugins_to_migrate | ||
.clone() | ||
.map(|p| format!("tauri-plugin-{p}@2.0.0-beta")) | ||
.collect::<Vec<_>>(); | ||
cargo::install(&cargo_deps, Some(tauri_dir))?; | ||
|
||
let npm_deps = plugins_to_migrate | ||
.map(|p| format!("@tauri-apps/plugin-{p}@>=2.0.0-beta.0")) | ||
.collect::<Vec<_>>(); | ||
let pm = PackageManager::from_project(app_dir) | ||
.into_iter() | ||
.next() | ||
.unwrap_or(PackageManager::Npm); | ||
pm.install(&npm_deps)?; | ||
|
||
Ok(()) | ||
} |