@@ -39,7 +39,7 @@ public static function command(CLI $cli): void
3939 protected static function confirmMigration (CLI $ cli ): void
4040 {
4141 $ cli ->br ();
42- $ cli ->confirmToContinue (' 💡 Migrating your folder setup can lead to a broken site. Make sure to backup your current installation. If you have modified your index.php you might need to adjust the new index.php after the migration. Do you want to continue? ' );
42+ $ cli ->confirmToContinue (" 💡 Migrating your folder setup can lead to a broken site. \n\n Make sure to backup your current installation. If you have modified your index.php you might need to adjust the new index.php after the migration.\n\n Do you want to continue?" );
4343 $ cli ->br ();
4444 }
4545
@@ -55,8 +55,8 @@ protected static function makeIndexPHP(CLI $cli, string $publicDir)
5555 protected static function makePublicDir (CLI $ cli , string $ publicDir ): void
5656 {
5757 if (is_dir ($ publicDir ) === true ) {
58- $ cli ->confirmToContinue ('The public folder exists. Do you still want to continue? ' );
59- return ;
58+ $ cli ->confirmToContinue ('⚠️ The public folder exists. Do you still want to continue? ' );
59+ $ cli -> br () ;
6060 }
6161
6262 Dir::make ($ publicDir );
@@ -67,6 +67,7 @@ protected static function makePublicDir(CLI $cli, string $publicDir): void
6767 protected static function movableDirs (string $ dir ): array
6868 {
6969 return [
70+ $ dir . '/.well-known ' ,
7071 $ dir . '/assets ' ,
7172 $ dir . '/media ' ,
7273 ];
@@ -76,6 +77,11 @@ protected static function movableFiles(string $dir): array
7677 {
7778 return [
7879 $ dir . '/.htaccess ' ,
80+ $ dir . '/favicon.ico ' ,
81+ $ dir . '/favicon.png ' ,
82+ $ dir . '/favicon.svg ' ,
83+ $ dir . '/favicon.gif ' ,
84+ $ dir . '/robots.txt ' ,
7985 ];
8086 }
8187
@@ -87,8 +93,21 @@ protected static function moveDirs(CLI $cli, string $destination, array $dirs):
8793 }
8894
8995 $ dirname = basename ($ dir );
96+ $ target = $ destination . '/ ' . $ dirname ;
97+
98+ // avoid overwriting directories that should not be overwritten
99+ if (is_dir ($ target ) === true ) {
100+ $ input = $ cli ->confirm ('⚠️ The directory ' . $ dirname . ' exists. Do you want to overwrite it? ' );
101+ $ cli ->br ();
102+
103+ if ($ input ->confirmed () === false ) {
104+ continue ;
105+ }
106+ }
107+
108+ Dir::remove ($ target );
90109
91- if (Dir::move ($ dir , $ destination . ' / ' . $ dirname ) === true ) {
110+ if (Dir::move ($ dir , $ target ) === true ) {
92111 $ cli ->out ('✅ The ' . $ dirname . ' directory has been moved ' );
93112 } else {
94113 $ cli ->out ('🚨 The ' . $ dirname . ' directory could not be moved ' );
@@ -104,6 +123,19 @@ protected static function moveFiles(CLI $cli, string $destination, array $files)
104123 }
105124
106125 $ filename = basename ($ file );
126+ $ target = $ destination . '/ ' . $ filename ;
127+
128+ // avoid overwriting directories that should not be overwritten
129+ if (is_dir ($ target ) === true ) {
130+ $ input = $ cli ->confirm ('⚠️ The file ' . $ filename . ' exists. Do you want to overwrite it? ' );
131+ $ cli ->br ();
132+
133+ if ($ input ->confirmed () === false ) {
134+ continue ;
135+ }
136+ }
137+
138+ F::remove ($ target );
107139
108140 if (F::move ($ file , $ destination . '/ ' . $ filename ) === true ) {
109141 $ cli ->out ('✅ The ' . $ filename . ' file has been moved ' );
0 commit comments