Class: Vara::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/vara/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/vara/cli.rb', line 5

def self.exit_on_failure?
  true
end

Instance Method Details

#build_metadata(product_dir) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vara/cli.rb', line 14

def (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
   = Vara::ProductMetadataProcessor.new(
    File.expand_path(product_dir),
    versioner,
    external_release_paths: options.fetch('external_releases', '').split(',')
  ).process
  say("#{} has been created")
  
end

#build_migrations(product_dir) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vara/cli.rb', line 36

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) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/vara/cli.rb', line 80

def build_pivotal(product_dir)
   = (product_dir)
  build_migrations(product_dir)
  lint()
  download_artifacts() unless options[:exclude_releases]
  zip_pivotal(product_dir)
end

#download_artifacts(product_metadata) ⇒ Object



58
59
60
61
62
# File 'lib/vara/cli.rb', line 58

def download_artifacts()
  require 'vara/product_resource_downloader'
  product_resource_downloader = Vara::ProductResourceDownloader.build(File.expand_path())
  product_resource_downloader.download
end

#lint(product_metadata) ⇒ Object



51
52
53
54
55
# File 'lib/vara/cli.rb', line 51

def lint()
  require 'vara/linter'
  linter = Vara::Linter.build(File.expand_path())
  linter.lint!
end

#update_product_version(pivotal_file_path, version) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/vara/cli.rb', line 89

def update_product_version(pivotal_file_path, version)
  require 'vara/product'
  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)
      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) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/vara/cli.rb', line 65

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