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)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#build_metadata(product_dir) ⇒ Object



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

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



37
38
39
40
41
42
43
44
45
46
47
48
49
# 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) ⇒ Object



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

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



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

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



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

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

#update_product_version(pivotal_file_path, version) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# 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) ⇒ Object



66
67
68
69
70
71
72
73
# 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