Sha256: bb98c2acaf3a9d320042315472274afff08a990e00e602479510aa8cbdfd3666

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 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 initialize(brand_key, brand_name, clone_brand_key: nil)
        @brand_key = brand_key
        @brand_name = brand_name
        @clone_brand_key = clone_brand_key
    end

    def onboard
        if @clone_brand_key.nil? || @clone_brand_key.empty?
            generate_brand_template
        else
            clone_brand
        end
        add_to_brands_list
    end

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

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

        template_dir = FilePath.template_brands
        target_dir = File.join(FilePath.solara, 'brands', @brand_key)
        config_file = FilePath.template_config

        generator = ProjectTemplateGenerator.new(template_dir, target_dir, config_file)
        generator.create_project
    end

    def clone_brand
        Solara.logger.debug("Cloning #{@clone_brand_key} to #{@brand_key}")
        source = FilePath.brand(@clone_brand_key)
        destination = File.join(FilePath.solara, 'brands', @brand_key)
        FolderCopier.new(source, destination).copy
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solara-0.2.0 solara/lib/core/brands/brand_onboarder.rb
solara-0.1.0 solara/lib/core/brands/brand_onboarder.rb