require 'fileutils' require_relative 'file_manager' require_relative 'yaml_manager' class BrandResourcesManager def initialize(brand_key) @brand_key = brand_key end require 'fileutils' def update_ios Solara.logger.start_step("Update iOS resources") source = IOSFilePathManager.instance.brand_assets(@brand_key) destination = IOSFilePathManager.instance.assets_artifacts FileManager.delete_if_exists(destination) # Copy images and set the Content.json for each one add_to_asset_catalog # Copy all folders only in source to destination Dir.glob("#{source}/*").each do |item| if File.directory?(item) FileUtils.cp_r(item, destination) end end Solara.logger.end_step("Update iOS resources") end def add_to_asset_catalog source = IOSFilePathManager.instance.brand_assets(@brand_key) destination = IOSFilePathManager.instance.assets_artifacts asset_manager = XcodeAssetManager.new(destination) asset_manager.add(source) end def update_android Solara.logger.start_step("Update Android resources") FileManager.new.copy_files_recursively( FilePath.android_brand_res(@brand_key), FilePath.android_res_artifacts) assets_artifacts = File.join(FilePath.android_project_assets, 'artifacts') FileManager.delete_if_exists(assets_artifacts) FileManager.new.copy_files_recursively( FilePath.android_brand_assets(@brand_key), assets_artifacts) # Delete the original launcher icons to fix duplicate resources FileManager.new.delete_folders_by_prefix(FilePath.android_res, 'mipmap') Solara.logger.end_step("Update Android resources") end def update_flutter Solara.logger.start_step("Update Flutter resources") case SolaraSettingsManager.instance.platform when Platform::Flutter YamlManager.new(FilePath.pub_spec_yaml).add_to_nested_array( 'flutter', 'assets', 'assets/artifacts/') destination = FilePath.flutter_assets_artifacts FileManager.delete_if_exists(destination) FileManager.new.copy_files_recursively( FilePath.brand_flutter_assets(@brand_key), destination) else # Nothing end Solara.logger.end_step("Update Flutter resources") end end