@@ -10,8 +10,22 @@ use anyhow::Context;
1010
1111use std:: { fs, path:: Path } ;
1212
13- const CORE_API_MODULES : & [ & str ] = & [ "dpi" , "event" , "path" , "core" , "window" , "mocks" ] ;
14- const JS_EXTENSIONS : & [ & str ] = & [ "js" , "jsx" , "ts" , "tsx" , "mjs" ] ;
13+ // (from, to)
14+ const RENAMED_MODULES : & [ ( & str , & str ) ] = & [ ( "tauri" , "core" ) , ( "window" , "webviewWindow" ) ] ;
15+ const PLUGINIFIED_MODULES : & [ & str ] = & [
16+ "cli" ,
17+ "clipboard" ,
18+ "dialog" ,
19+ "fs" ,
20+ "globalShortcut" ,
21+ "http" ,
22+ "notification" ,
23+ "os" ,
24+ "process" ,
25+ "shell" ,
26+ "updater" ,
27+ ] ;
28+ const JS_EXTENSIONS : & [ & str ] = & [ "js" , "mjs" , "jsx" , "ts" , "mts" , "tsx" ] ;
1529
1630/// Returns a list of paths that could not be migrated
1731pub fn migrate ( app_dir : & Path , tauri_dir : & Path ) -> Result < ( ) > {
@@ -39,23 +53,12 @@ pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
3953 let original = cap. get ( 0 ) . unwrap ( ) . as_bytes ( ) ;
4054 let original = String :: from_utf8_lossy ( original) . to_string ( ) ;
4155
42- if module == "tauri" {
43- let new = "@tauri-apps/api/core" . to_string ( ) ;
44- log:: info!( "Replacing `{original}` with `{new}` on {}" , path. display( ) ) ;
45- new
46- } else if module == "window" {
47- let new = "@tauri-apps/api/webviewWindow" . to_string ( ) ;
48- log:: info!( "Replacing `{original}` with `{new}` on {}" , path. display( ) ) ;
49- new
50- } else if CORE_API_MODULES . contains ( & module. as_str ( ) ) {
51- original
52- } else {
56+ let new = if let Some ( ( _, renamed_to) ) =
57+ RENAMED_MODULES . iter ( ) . find ( |( from, _to) | * from == module)
58+ {
59+ renamed_to. to_string ( )
60+ } else if PLUGINIFIED_MODULES . contains ( & module. as_str ( ) ) {
5361 let plugin = format ! ( "@tauri-apps/plugin-{module}" ) ;
54- log:: info!(
55- "Replacing `{original}` with `{plugin}` on {}" ,
56- path. display( )
57- ) ;
58-
5962 new_npm_packages. push ( plugin. clone ( ) ) ;
6063 new_cargo_packages. push ( format ! (
6164 "tauri-plugin-{}" ,
@@ -65,9 +68,13 @@ pub fn migrate(app_dir: &Path, tauri_dir: &Path) -> Result<()> {
6568 & module
6669 }
6770 ) ) ;
68-
6971 plugin
70- }
72+ } else {
73+ return original;
74+ } ;
75+
76+ log:: info!( "Replacing `{original}` with `{new}` on {}" , path. display( ) ) ;
77+ new
7178 } ) ;
7279
7380 if new_contents != js_contents {
0 commit comments