Sha256: df7d5ee022b3346a36d323e7acd9196fcfdd8821500b80ff8cf6d3586af0eb8a

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

require 'thor'

require_relative '../interface/berkshelf'
require_relative '../patch/thor-actions'

module Builderator
  module Tasks
    ##
    # Wrap Berkshelf commands
    ##
    class Berkshelf < Thor
      include Thor::Actions

      def self.exit_on_failure?
        true
      end

      desc 'configure', 'Write a Berksfile into the project workspace'
      def configure
        Interface.berkshelf.write
      end

      desc 'vendor', 'Vendor a cookbook release and its dependencies'
      def vendor
        invoke :configure, [], options
        empty_directory Interface.berkshelf.vendor

        command = "#{Interface.berkshelf.command} vendor #{Interface.berkshelf.vendor} "
        command << "-c #{Interface.berkshelf.berkshelf_config} "
        command << "-b #{Interface.berkshelf.source}"

        inside Interface.berkshelf.directory do
          remove_file Interface.berkshelf.lockfile
          run command
        end
      end

      desc 'upload', 'Upload the local cookbook source and its dependencies to the Chef server'
      def upload
        vendor

        command = "#{Interface.berkshelf.command} upload "
        command << "-c #{Interface.berkshelf.berkshelf_config} "
        command << "-b #{Interface.berkshelf.source}"

        run command
      end

      desc 'uncache', 'Delete the Berkshelf cache'
      def uncache
        remove_dir File.join(ENV['HOME'], '.berkshelf/cookbooks')
      end

      desc 'clean', 'Remove a local vendor directory'
      def clean
        remove_dir Interface.berkshelf.vendor
        remove_file Interface.berkshelf.source
        remove_file Interface.berkshelf.lockfile
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
builderator-1.0.1 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.12 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.11 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.10 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.9 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.8 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.7 lib/builderator/tasks/berkshelf.rb
builderator-1.0.0.pre.rc.6 lib/builderator/tasks/berkshelf.rb