Sha256: 29a0b34bda5c9b4f604879d954154373b0d90a768633adbc60ae1a17c423f4d1

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

Dir[File.expand_path('scripts/*.rb', __dir__)].each { |file| require_relative file }
Dir[File.expand_path('../template/*.rb', __dir__)].each { |file| require_relative file }
Dir[File.expand_path('platform/android/*.rb', __dir__)].each { |file| require_relative file }
Dir[File.expand_path('platform/ios/*.rb', __dir__)].each { |file| require_relative file }
Dir[File.expand_path('platform/flutter/*.rb', __dir__)].each { |file| require_relative file }

class BrandOnboarder

    def onboard(brand_key, brand_name, clone_brand_key: nil)
        if clone_brand_key.nil? || clone_brand_key.strip.empty?
            generate_from_template(brand_key)
        else
            clone_brand(brand_key, clone_brand_key: clone_brand_key)
        end
        add_to_brands_list(brand_key, brand_name)
    end

    def sync_with_template(brand_key)
        generator = template_generator(brand_key)
        generator.sync_with_template
    end

    def clone_brand(brand_key, clone_brand_key:)
        Solara.logger.debug("Cloning #{clone_brand_key} to #{brand_key}")
        source = FilePath.brand(clone_brand_key)
        destination = FilePath.brand(brand_key)

        FileManager.delete_if_exists(destination)
        FolderCopier.new(source, destination).copy
    end

    def add_to_brands_list(brand_key, brand_name)
        BrandsManager.instance.add_brand(brand_name, brand_key)
    end

    def generate_from_template(brand_key)
        Solara.logger.debug("Onboarding #{brand_key} from template.")

        generator = template_generator(brand_key)
        generator.create_project
    end

    def template_generator(brand_key)
        template_dir = FilePath.template_brands
        target_dir = FilePath.brand(brand_key)
        config_file = FilePath.template_config

        ProjectTemplateGenerator.new(template_dir, target_dir, config_file)
    end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solara-0.7.4 solara/lib/core/brands/brand_onboarder.rb
solara-0.7.3 solara/lib/core/brands/brand_onboarder.rb
solara-0.7.2 solara/lib/core/brands/brand_onboarder.rb
solara-0.7.1 solara/lib/core/brands/brand_onboarder.rb
solara-0.7.0 solara/lib/core/brands/brand_onboarder.rb