Sha256: 88a4849d9add5032fdef2cb4ccf5858f56d047859d5920de0cd763dd3d483a06

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

class BowerVendor::Setup < BowerVendor::Base
  def execute
    return if vendors.empty?

    create_bowerrc
    create_bower_json
  end

  def create_bower_json
    data = {
      name: 'autogenerated',
      dependencies: {
      },
      resolutions: {
      },
    }
    vendors.each do |vendor_key, vendor|
      version = vendor['version']&.to_s
      tag_version = version

      git = vendor['git']
      tag = vendor['tag']&.to_s
      if git
        tag_version = tag ? "#{git}##{tag}" : git
      end

      url = vendor['url']
      if url
        tag_version = url
      end

      data[:dependencies][vendor_key] = tag_version
      data[:resolutions][vendor_key] = version
    end

    target_file = "#{work_dir}/bower.json"
    File.write(target_file, JSON.pretty_generate(data))
    puts "Wrote: #{target_file}"
  end

  def create_bowerrc
    data = {
      directory: "bower_components"
    }

    FileUtils.mkdir_p(work_dir)

    target_file = "#{work_dir}/.bowerrc"
    File.write(target_file, JSON.pretty_generate(data))
    puts "Wrote: #{target_file}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bower_vendor-0.1.21 lib/bower_vendor/setup.rb
bower_vendor-0.1.20 lib/bower_vendor/setup.rb
bower_vendor-0.1.19 lib/bower_vendor/setup.rb
bower_vendor-0.1.4 lib/bower_vendor/setup.rb
bower_vendor-0.1.3 lib/bower_vendor/setup.rb