From 6a6ce6fd03884bf53aa8199af758056e4b2d1a81 Mon Sep 17 00:00:00 2001 From: Shaban Kamel Date: Fri, 20 Sep 2024 18:32:09 +0300 Subject: [PATCH] Solara --- solara/lib/core/brands/brand_onboarder.rb | 3 ++- solara/lib/core/brands/brands_manager.rb | 2 +- solara/lib/core/scripts/directory_creator.rb | 2 +- solara/lib/core/scripts/file_manager.rb | 6 ++++-- solara/lib/core/scripts/platform/ios/infoplist_switcher.rb | 2 +- solara/lib/solara_initializer.rb | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/solara/lib/core/brands/brand_onboarder.rb b/solara/lib/core/brands/brand_onboarder.rb index c6fd915..79b74fa 100644 --- a/solara/lib/core/brands/brand_onboarder.rb +++ b/solara/lib/core/brands/brand_onboarder.rb @@ -35,7 +35,8 @@ def clone_brand Solara.logger.debug("Cloning #{@clone_brand_key} to #{@brand_key}") source = FilePath.brand(@clone_brand_key) destination = FilePath.brand(@brand_key) - FileUtils.rm_rf(destination) if File.exist?(destination) + + FileManager.delete_if_exists(destination) FolderCopier.new(source, destination).copy end diff --git a/solara/lib/core/brands/brands_manager.rb b/solara/lib/core/brands/brands_manager.rb index 8555f16..7f5d2ab 100644 --- a/solara/lib/core/brands/brands_manager.rb +++ b/solara/lib/core/brands/brands_manager.rb @@ -109,7 +109,7 @@ def offboard(brand_key) if index brand_dir = FilePath.brand(brand_key) remove_brand(index) - FileUtils.rm_rf(brand_dir) + FileManager.delete_if_exists(brand_dir) save_brands_list Solara.logger.debug("Brand removed.") else diff --git a/solara/lib/core/scripts/directory_creator.rb b/solara/lib/core/scripts/directory_creator.rb index 7e5f0a1..36ae6fb 100644 --- a/solara/lib/core/scripts/directory_creator.rb +++ b/solara/lib/core/scripts/directory_creator.rb @@ -10,7 +10,7 @@ def self.create_directories(directories, delete_if_exists = false) def self.create_directory(dir, delete_if_exists) if Dir.exist?(dir) if delete_if_exists - FileUtils.rm_rf(dir) + FileManager.delete_if_exists(dir) Solara.logger.debug("🧹 Deleted directory: #{dir}") Dir.mkdir(dir) end diff --git a/solara/lib/core/scripts/file_manager.rb b/solara/lib/core/scripts/file_manager.rb index f14c0af..6b29298 100644 --- a/solara/lib/core/scripts/file_manager.rb +++ b/solara/lib/core/scripts/file_manager.rb @@ -24,12 +24,14 @@ def copy_files_recursively(source_dir, destination_dir) def delete_folders_by_prefix(directory, folder_prefix) # Get a list of all folders in the directory - folders = Dir.entries(directory).select { |entry| File.directory?(File.join(directory, entry)) && entry.start_with?(folder_prefix) } + folders = Dir.entries(directory).select { |entry| + File.directory?(File.join(directory, entry)) && entry.start_with?(folder_prefix) + } # Delete each folder folders.each do |folder| folder_path = File.join(directory, folder) - FileUtils.rm_rf(folder_path) + FileManager.delete_if_exists(folder_path) Solara.logger.debug("🧹 Deleted folder: #{folder_path}") end end diff --git a/solara/lib/core/scripts/platform/ios/infoplist_switcher.rb b/solara/lib/core/scripts/platform/ios/infoplist_switcher.rb index 3e5df3c..f7372cb 100644 --- a/solara/lib/core/scripts/platform/ios/infoplist_switcher.rb +++ b/solara/lib/core/scripts/platform/ios/infoplist_switcher.rb @@ -20,7 +20,7 @@ def copy_string_catalog # Remove from project before copying project_infoplist_string_catalog = FilePath.project_infoplist_string_catalog if File.exist?(project_infoplist_string_catalog) - FileUtils.rm_rf(project_infoplist_string_catalog) + FileManager.delete_if_exists(project_infoplist_string_catalog) Solara.logger.debug("Deleted #{project_infoplist_string_catalog} successfully.") end diff --git a/solara/lib/solara_initializer.rb b/solara/lib/solara_initializer.rb index 3e2df23..90f8515 100644 --- a/solara/lib/solara_initializer.rb +++ b/solara/lib/solara_initializer.rb @@ -37,7 +37,7 @@ def confirm_init_if_necessary Solara.logger.info("Solara initialization cancelled.") exit 1 end - FileUtils.rm_rf(brand_path) + FileManager.delete_if_exists(brand_path) end end