Skip to content

Commit

Permalink
Solara
Browse files Browse the repository at this point in the history
  • Loading branch information
IdeaS0ft committed Sep 15, 2024
1 parent 929c5ba commit 08dc187
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
10 changes: 5 additions & 5 deletions solara/lib/core/brands/brand_switcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def switch

GradleSwitcher.new(@brand_key).switch
AndroidManifestSwitcher.new.switch(config)
AndroidStringsSwitcher.new.switch(config)
AndroidStringsSwitcher.new.switch
@theme_switcher.switch(Language::Kotlin)
@brand_config_switcher.switch(Language::Kotlin)
@resource_manager.update_android
Expand All @@ -101,10 +101,10 @@ def switch
private

def update_xcode_project
Solara.logger.start_step("Update Xcode project")
Solara.logger.start_step("Switch Xcode project")
project_path = FilePath.xcode_project
XcodeProjectSwitcher.new(project_path, @brand_key).switch
Solara.logger.end_step("Update Xcode project")
Solara.logger.end_step("Switch Xcode project")
end
end

Expand All @@ -131,7 +131,7 @@ def initialize(platform)
end

def create_dirs
Solara.logger.start_step("Create artifacts directories")
Solara.logger.start_step("Switch artifacts directories")
directories = case @platform
when Platform::Flutter
[FilePath::flutter_artifacts, FilePath::android_artifacts, FilePath.ios_artifacts]
Expand All @@ -143,7 +143,7 @@ def create_dirs
raise ArgumentError, "Invalid platform: #{@platform}"
end
DirectoryCreator.create_directories(directories, delete_if_exists: true)
Solara.logger.end_step("Create artifacts directories")
Solara.logger.end_step("Switch artifacts directories")
end
end

Expand Down
12 changes: 6 additions & 6 deletions solara/lib/core/scripts/brand_resources_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(brand_key)
require 'fileutils'

def update_ios
Solara.logger.start_step("Update iOS resources")
Solara.logger.start_step("Switch iOS resources")
source = FilePath.ios_brand_assets(@brand_key)
destination = FilePath.ios_assets_artifacts
FileManager.delete_if_exists(destination)
Expand All @@ -25,7 +25,7 @@ def update_ios
end
end

Solara.logger.end_step("Update iOS resources")
Solara.logger.end_step("Switch iOS resources")
end

def add_to_asset_catalog
Expand All @@ -36,7 +36,7 @@ def add_to_asset_catalog
end

def update_android
Solara.logger.start_step("Update Android resources")
Solara.logger.start_step("Switch Android resources")
FileManager.new.copy_files_recursively(
FilePath.android_brand_res(@brand_key),
FilePath.android_res_artifacts)
Expand All @@ -50,11 +50,11 @@ def update_android

# 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")
Solara.logger.end_step("Switch Android resources")
end

def update_flutter
Solara.logger.start_step("Update Flutter resources")
Solara.logger.start_step("Switch Flutter resources")
case SolaraSettingsManager.instance.platform
when Platform::Flutter
YamlManager.new(FilePath.pub_spec_yaml).add_to_nested_array(
Expand All @@ -72,6 +72,6 @@ def update_flutter
# Nothing
end

Solara.logger.end_step("Update Flutter resources")
Solara.logger.end_step("Switch Flutter resources")
end
end
4 changes: 2 additions & 2 deletions solara/lib/core/scripts/gitignore_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize(gitignore_path = '.gitignore')
end

def self.ignore
Solara.logger.start_step("Ignoring unneeded files and folders from Git")
Solara.logger.start_step("Exclude Brand-Generated Files and Folders from Git")
GitignoreManager.new(FilePath.project_root)
.add_items([
"# Generated by Solara. Ignore redundant brand specific changes.",
Expand All @@ -15,7 +15,7 @@ def self.ignore
"solara/.solara/aliases/",
"solara/.solara/solara_settings.json",
])
Solara.logger.end_step("Ignoring unneeded files and folders from Git")
Solara.logger.end_step("Exclude Brand-Generated Files and Folders from Git")
end

def add_items(items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@ class AndroidStringsSwitcher
def initialize
end

def switch(config)
Solara.logger.start_step("Generate #{FilePath.artifacts_dir_name}/strings.xml")
def switch
Solara.logger.start_step("Switch strings.xml")
strings_file = FilePath.android_artifacts_strings

# Create the file if it doesn't exist
unless File.exist?(strings_file)
FileUtils.mkdir_p(File.dirname(strings_file))
end

strings_content = generate_strings_xml_content(config)
File.write(strings_file, strings_content)
Solara.logger.debug("Updated #{strings_file} with name: \"#{config['brandName']}\"")

remove_app_name_from_strings
Solara.logger.end_step("Generate #{FilePath.artifacts_dir_name}/strings.xml")
Solara.logger.end_step("Switch strings.xml")
end

# It's important to delete app_name to avoid duplicate resources
def remove_app_name_from_strings
file_path = FilePath.android_strings
manager = StringsXmlManager.new(file_path)
manager.delete_app_name
Solara.logger.debug("Removed app_name from #{file_path} to avoid duplicates with #{FilePath.android_artifacts_strings}.")
end

private
Expand Down
4 changes: 2 additions & 2 deletions solara/lib/core/scripts/platform/android/gradle_switcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def initialize(brand_key)
end

def switch
Solara.logger.start_step("Update app/build.gradle")
Solara.logger.start_step("Switch app/build.gradle")
gradle_file = FilePath.android_app_gradle
gradle_content = File.read(gradle_file)

update_gradle(gradle_file, gradle_content)
add_source_sets(gradle_file)
update_keystore_config(gradle_file)
Solara.logger.end_step("Update app/build.gradle")
Solara.logger.end_step("Switch app/build.gradle")
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name"></string>
</resources>

0 comments on commit 08dc187

Please sign in to comment.