class Vara::Cli

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/vara/cli.rb, line 6
def self.exit_on_failure?
  true
end

Public Instance Methods

build_metadata(product_dir) click to toggle source
# File lib/vara/cli.rb, line 15
def build_metadata(product_dir)
  require 'vara/prerelease_versioner'
  require 'vara/static_versioner'
  require 'vara/product_metadata_processor'
  versioner = Vara::PrereleaseVersioner.new(File.expand_path(product_dir), options.fetch('cycle'))
  versioner.override_prerelease_version!('') if options['final']
  if options['version'] && !options['version'].empty?
    versioner = Vara::StaticVersioner.new(File.expand_path(product_dir), options.fetch('version'))
  end
  metadata_path = Vara::ProductMetadataProcessor.new(
    File.expand_path(product_dir),
    versioner,
    external_release_paths: options.fetch('external_releases', '').split(',')
  ).process
  say("#{metadata_path} has been created")
  metadata_path
end
build_migrations(product_dir) click to toggle source
# File lib/vara/cli.rb, line 37
def build_migrations(product_dir)
  require 'vara/prerelease_versioner'
  require 'vara/static_versioner'
  require 'vara/content_migrations_processor'
  versioner = Vara::PrereleaseVersioner.new(File.expand_path(product_dir), options.fetch('cycle'))
  versioner.override_prerelease_version!('') if options['final']
  if options['version'] && !options['version'].empty?
    versioner = Vara::StaticVersioner.new(File.expand_path(product_dir), options.fetch('version'))
  end
  content_migrations_path = Vara::ContentMigrationsProcessor.new(File.expand_path(product_dir), versioner).process
  say("#{content_migrations_path} has been created") unless content_migrations_path.nil?
  content_migrations_path
end
build_pivotal(product_dir) click to toggle source
# File lib/vara/cli.rb, line 81
def build_pivotal(product_dir)
  metadata_path = build_metadata(product_dir)
  build_migrations(product_dir)
  lint(metadata_path)
  download_artifacts(metadata_path) unless options[:exclude_releases]
  zip_pivotal(product_dir)
end
download_artifacts(product_metadata) click to toggle source
# File lib/vara/cli.rb, line 59
def download_artifacts(product_metadata)
  require 'vara/product_resource_downloader'
  product_resource_downloader = Vara::ProductResourceDownloader.build(File.expand_path(product_metadata))
  product_resource_downloader.download
end
lint(product_metadata) click to toggle source
# File lib/vara/cli.rb, line 52
def lint(product_metadata)
  require 'vara/linter'
  linter = Vara::Linter.build(File.expand_path(product_metadata))
  linter.lint!
end
update_product_version(pivotal_file_path, version) click to toggle source
# File lib/vara/cli.rb, line 90
def update_product_version(pivotal_file_path, version)
  require 'vara/content_migrations_processor'
  require 'vara/product'
  require 'vara/static_versioner'
  pivotal_file_path = File.expand_path(pivotal_file_path)
  Dir.mktmpdir do |temp_dir|
    FileUtils.cd(temp_dir) do
      `unzip #{pivotal_file_path} -d .`
      output_dir = File.dirname(pivotal_file_path)

      versioner = Vara::StaticVersioner.new(temp_dir, version)
      Vara::ContentMigrationsProcessor.new(temp_dir, versioner).update_product_version_migrations

      product = Vara::Product.new(temp_dir)
      product.update_product_version(version)
      product.build
      product.paths.each do |path|
        FileUtils.mv(path, output_dir)
      end
    end
  end
end
zip_pivotal(product_dir) click to toggle source
# File lib/vara/cli.rb, line 66
def zip_pivotal(product_dir)
  require 'vara/product'
  product = Vara::Product.new(File.expand_path(product_dir), options)
  product.build
  say("file #{product.path} has been created")
  say("file #{product.bom_path} has been created")
  say("file #{product.md5_path} has been created")
end