diff --git a/solara/lib/core/scripts/brand_resources_manager.rb b/solara/lib/core/scripts/brand_resources_manager.rb index ac560ac..1757f97 100644 --- a/solara/lib/core/scripts/brand_resources_manager.rb +++ b/solara/lib/core/scripts/brand_resources_manager.rb @@ -41,7 +41,7 @@ def update_android FilePath.android_brand_res(@brand_key), FilePath.android_res_artifacts) - assets_artifacts = File.join(FilePath.android_project_assets, 'artifacts') + assets_artifacts = File.join(FilePath.android_project_assets, FilePath.artifacts_dir_name) FileManager.delete_if_exists(assets_artifacts) FileManager.new.copy_files_recursively( @@ -60,7 +60,7 @@ def update_flutter YamlManager.new(FilePath.pub_spec_yaml).add_to_nested_array( 'flutter', 'assets', - 'assets/artifacts/') + "assets/#{FilePath.artifacts_dir_name}/") destination = FilePath.flutter_assets_artifacts FileManager.delete_if_exists(destination) diff --git a/solara/lib/core/scripts/file_path.rb b/solara/lib/core/scripts/file_path.rb index f2b9319..a39af97 100644 --- a/solara/lib/core/scripts/file_path.rb +++ b/solara/lib/core/scripts/file_path.rb @@ -6,6 +6,14 @@ def self.project_root SolaraSettingsManager.instance.project_root end + def self.artifacts_dir_name + 'solara_artifacts' + end + + def self.artifacts_dir_name_ios + 'SolaraArtifacts' + end + def self.root SolaraSettingsManager.instance.root end @@ -134,15 +142,15 @@ def self.generated_config(name, platform) end def self.flutter_artifacts - File.join(project_root, 'lib', 'artifacts') + File.join(project_root, 'lib', artifacts_dir_name) end def self.android_artifacts - File.join(android_project_root, 'artifacts') + File.join(android_project_root, artifacts_dir_name) end def self.android_main_artifacts - File.join(android_project_root, 'app', 'src', 'main', 'java', 'artifacts') + File.join(android_project_root, 'app', 'src', 'main', 'java', artifacts_dir_name) end def self.android_brand_config(brand_key) @@ -186,7 +194,7 @@ def self.android_res end def self.android_res_artifacts - File.join(android_project_root, 'app', 'src', 'main', 'artifacts') + File.join(android_project_root, 'app', 'src', 'main', artifacts_dir_name) end def self.android_artifacts_strings @@ -206,7 +214,7 @@ def self.brand_flutter_assets(brand_key) end def self.flutter_assets_artifacts - File.join(project_root, 'assets', 'artifacts') + File.join(project_root, 'assets', artifacts_dir_name) end def self.pub_spec_yaml @@ -366,9 +374,9 @@ def self.brand_xcconfig def self.ios_artifacts case SolaraSettingsManager.instance.platform when Platform::Flutter - return File.join(project_root, ios, 'Flutter', 'Artifacts') + return File.join(project_root, ios, 'Flutter', artifacts_dir_name_ios) when Platform::IOS - return File.join(xcode_project_directory, 'Artifacts') + return File.join(xcode_project_directory, artifacts_dir_name_ios) else raise ArgumentError, "Invalid platform: #{SolaraSettingsManager.instance.platform}" end @@ -381,7 +389,7 @@ def self.info_plist end def self.ios_assets_artifacts - File.join(File.dirname(ios_assets), 'Assets.xcassets', 'Artifacts') + File.join(File.dirname(ios_assets), 'Assets.xcassets', artifacts_dir_name_ios) end def self.ios_assets diff --git a/solara/lib/core/scripts/gitignore_manager.rb b/solara/lib/core/scripts/gitignore_manager.rb index 69b4a36..218ca17 100644 --- a/solara/lib/core/scripts/gitignore_manager.rb +++ b/solara/lib/core/scripts/gitignore_manager.rb @@ -9,8 +9,8 @@ def self.ignore GitignoreManager.new(FilePath.project_root) .add_items([ "# Generated by Solara. Ignore redundant brand specific changes.", - "**/artifacts/", - "**/Artifacts/", + "**/#{FilePath.artifacts_dir_name}/", + "**/#{FilePath.artifacts_dir_name_ios}/", "solara/brands/current_app.json", "solara/.solara/aliases/", "solara/.solara/solara_settings.json", diff --git a/solara/lib/core/scripts/interactive_file_system_validator.rb b/solara/lib/core/scripts/interactive_file_system_validator.rb index a64403a..cc71963 100644 --- a/solara/lib/core/scripts/interactive_file_system_validator.rb +++ b/solara/lib/core/scripts/interactive_file_system_validator.rb @@ -34,7 +34,11 @@ def validate(file_system) validate_required_item(item) end else - ignored = %w[solara/ Artifacts/ Pods/ build/] + ignored = [ + 'solara/', + "#{FilePath.artifacts_dir_name_ios}/", + 'Pods/', + 'build/'] root = File.join(@project_root, item_path) paths = if recursive diff --git a/solara/lib/core/scripts/platform/android/android_strings_switcher.rb b/solara/lib/core/scripts/platform/android/android_strings_switcher.rb index 8d81a46..73846c7 100644 --- a/solara/lib/core/scripts/platform/android/android_strings_switcher.rb +++ b/solara/lib/core/scripts/platform/android/android_strings_switcher.rb @@ -3,7 +3,7 @@ def initialize end def switch(config) - Solara.logger.start_step("Generate artifacts/strings.xml") + Solara.logger.start_step("Generate #{FilePath.artifacts_dir_name}/strings.xml") strings_file = FilePath.android_artifacts_strings # Create the file if it doesn't exist @@ -16,7 +16,7 @@ def switch(config) Solara.logger.debug("Updated #{strings_file} with name: \"#{config['brandName']}\"") remove_app_name_from_strings - Solara.logger.end_step("Generate artifacts/strings.xml") + Solara.logger.end_step("Generate #{FilePath.artifacts_dir_name}/strings.xml") end # It's important to delete app_name to avoid duplicate resources diff --git a/solara/lib/core/scripts/platform/android/gradle_switcher.rb b/solara/lib/core/scripts/platform/android/gradle_switcher.rb index 0e43c7c..e674331 100644 --- a/solara/lib/core/scripts/platform/android/gradle_switcher.rb +++ b/solara/lib/core/scripts/platform/android/gradle_switcher.rb @@ -1,3 +1,4 @@ +Dir[File.expand_path('../../*.rb', __dir__)].each { |file| require_relative file } require 'fileutils' require 'json' @@ -10,14 +11,14 @@ class GradleSwitcher KOTLIN_PROPERTIES_LOADER = <<-KOTLIN val brandProperties = Properties().apply { - load(FileInputStream(file("../artifacts/brand.properties"))) + load(FileInputStream(file("../#{FilePath.artifacts_dir_name}/brand.properties"))) } KOTLIN GROOVY_PROPERTIES_LOADER = <<-GROOVY project.ext { brandProperties = new Properties() - brandProperties.load(new FileInputStream(file("../artifacts/brand.properties"))) + brandProperties.load(new FileInputStream(file("../#{FilePath.artifacts_dir_name}/brand.properties"))) } GROOVY @@ -30,7 +31,7 @@ class GradleSwitcher KOTLIN_VERSION_CODE = 'versionCode = brandProperties.getProperty("versionCode").toInt()' GROOVY_VERSION_CODE = "versionCode = project.ext.brandProperties.getProperty('versionCode').toInteger()" - DEFAULT_SOURCE_SETS = %w[src/main/res src/main/artifacts] + DEFAULT_SOURCE_SETS = ['src/main/res', "src/main/#{FilePath.artifacts_dir_name}"] def initialize(brand_key) @brand_key = brand_key diff --git a/solara/lib/core/scripts/platform/ios/xcconfig_generator.rb b/solara/lib/core/scripts/platform/ios/xcconfig_generator.rb index 01f0190..83efe1e 100644 --- a/solara/lib/core/scripts/platform/ios/xcconfig_generator.rb +++ b/solara/lib/core/scripts/platform/ios/xcconfig_generator.rb @@ -18,7 +18,7 @@ def generate def generate_xcconfig_content content = <<~XCCONFIG - ASSETCATALOG_COMPILER_APPICON_NAME = Artifacts/AppIcon + ASSETCATALOG_COMPILER_APPICON_NAME = #{FilePath.artifacts_dir_name_ios}/AppIcon #{load_config.map { |key, value| "#{key.upcase} = #{value}" }.join("\n")} XCCONFIG diff --git a/solara/lib/core/scripts/platform/ios/xcode_project_switcher.rb b/solara/lib/core/scripts/platform/ios/xcode_project_switcher.rb index ae65158..fa5a181 100644 --- a/solara/lib/core/scripts/platform/ios/xcode_project_switcher.rb +++ b/solara/lib/core/scripts/platform/ios/xcode_project_switcher.rb @@ -78,7 +78,7 @@ def update_debug_and_release_xcconfig def create_xcconfigs_and_add_to_project(debug_xcconfig_path, release_xcconfig_path) FileManager.create_files_if_not_exist([debug_xcconfig_path, release_xcconfig_path]) - base_xcconfig_name = 'Artifacts/Brand.xcconfig' + base_xcconfig_name = "#{FilePath.artifacts_dir_name_ios}/Brand.xcconfig" case @platform when Platform::Flutter @@ -108,15 +108,17 @@ def set_base_xcconfigs(debug_xcconfig_path, release_xcconfig_path) end def add_artifacts_group + artifacts_dir_name = FilePath.artifacts_dir_name_ios + case @platform when Platform::Flutter flutter_group = @project.groups.find { |group| group.name == 'Flutter' } - artifacts_group = flutter_group.groups.find { |group| group.name == 'Artifacts' } - artifacts_group = flutter_group.new_group("Artifacts") if artifacts_group.nil? + artifacts_group = flutter_group.groups.find { |group| group.name == artifacts_dir_name } + artifacts_group = flutter_group.new_group(artifacts_dir_name) if artifacts_group.nil? add_files_to_group(artifacts_group, FilePath.ios_artifacts) when Platform::IOS - artifacts_group = @project.groups.find { |group| group.name == 'Artifacts' } - artifacts_group = @project.new_group("Artifacts") if artifacts_group.nil? + artifacts_group = @project.groups.find { |group| group.name == artifacts_dir_name } + artifacts_group = @project.new_group(artifacts_dir_name) if artifacts_group.nil? add_files_to_group(artifacts_group, FilePath.ios_artifacts) else raise ArgumentError, "Invalid platform: #{@platform}" diff --git a/solara/lib/core/scripts/strings_xml_manager.rb b/solara/lib/core/scripts/strings_xml_manager.rb index ae195f3..70d1da7 100644 --- a/solara/lib/core/scripts/strings_xml_manager.rb +++ b/solara/lib/core/scripts/strings_xml_manager.rb @@ -11,7 +11,7 @@ def delete_app_name app_name_element = @doc.elements['resources/string[@name="app_name"]'] app_name_element.remove if app_name_element save_changes - Solara.logger.debug("Removed app_name from #{@file_path} to avoid duplication with artifacts/strings.xml.") + Solara.logger.debug("Removed app_name from #{@file_path} to avoid duplication with #{FilePath.artifacts_dir_name}/strings.xml.") end private