class Aemninja::Application

Constants

CONFIG_PATH
ENVIRONMENTS_PATH
ENVIRONMENT_CONFIG_FILE_LOCAL
ENVIRONMENT_CONFIG_FILE_PRODUCTION
ENVIRONMENT_CONFIG_FILE_STAGING
ROOT_PATH

Public Instance Methods

deploy!(package, environment='local') click to toggle source
# File lib/aemninja.rb, line 111
def deploy!(package, environment='local')

  # Read Environment from Config File
  #host = "localhost:4503"
  #user = "admin"
  #password = "admin"


  # Do It
  if File.exists?(package)
     if File.file?(package)
      #puts 'deploy package ' + package +  ' to ' + environment

      package_without_path = Aemninja::Helpers::remove_path_from package
      stripped_pkg = Aemninja::Helpers::remove_path_and_version_from package

      puts "--------------------------------------------------------"
      puts "Deployment to \'#{environment}\' environment"
      puts "--------------------------------------------------------"
      puts
      puts "Configuration: .aemninja/config/environments/#{environment}.rb"
      puts

      require "./.aemninja/config/environments/#{environment}.rb"

      Aemninja.configuration.instances.each do |key, array|
        host = array[:host]
        user = array[:user]
        password = array[:password]

        puts
        puts key.to_s + " [" + host + "]"

        # puts "host: " + host
        # puts "user: " + user
        # puts "password: " + password

        installed_package_name = Aem::is_package_installed? host, user, password, stripped_pkg

        if installed_package_name != nil
          print  "  uninstall " + installed_package_name + " from " + host
          rc = Aem::uninstall host, user, password, installed_package_name
          if rc == true
            puts "   OK"
          else
            puts "   FAILED"
          end

          print "  delete " + installed_package_name + " from " + host
          rc = Aem::delete host, user, password, installed_package_name
          if rc == true
            puts "   OK"
          else
            puts "   FAILED"
          end

        else
          puts "  Package " + package_without_path + " not found on " + host + ". Skipping uninstall."
        end

        print "  install " + package + " to " + host
        rc = Aem::install host, user, password, package
        if rc == true
            puts "   OK"
          else
            puts "   FAILED"
          end
      end



     else
       Aemninja::Errors::not_a_file(package)
     end
  else
    Aemninja::Errors::does_not_exist(package)
  end

exit 0
end
init!() click to toggle source
# File lib/aemninja.rb, line 43
def init!
  if File.directory? ROOT_PATH
    Aemninja::Errors::already_initialized(ROOT_PATH)
  end

  Aemninja::Helpers::create_directory ROOT_PATH
  Aemninja::Helpers::create_directory CONFIG_PATH
  Aemninja::Helpers::create_directory ENVIRONMENTS_PATH

  Aemninja::Helpers::create_file ENVIRONMENT_CONFIG_FILE_LOCAL
  open(ENVIRONMENT_CONFIG_FILE_LOCAL, 'w') do |f|
    f.puts 'Aemninja.configure do |config|'
    f.puts '  config.instances = {'
    f.puts '    author: { host: "localhost:4502", user: "admin", password: "admin"},'
    f.puts '    publish: { host: "localhost:4503", user: "admin", password: "admin"}'
    f.puts '  }'
    f.puts 'end'
  end


  Aemninja::Helpers::create_file ENVIRONMENT_CONFIG_FILE_STAGING
  open(ENVIRONMENT_CONFIG_FILE_STAGING, 'w') do |f|
    f.puts 'Aemninja.configure do |config|'
    f.puts '  config.instances = {'
    f.puts '    author: { host: "localhost:4502", user: "admin", password: "admin"},'
    f.puts '    publish: { host: "localhost:4503", user: "admin", password: "admin"}'
    f.puts '  }'
    f.puts 'end'
  end

  Aemninja::Helpers::create_file ENVIRONMENT_CONFIG_FILE_PRODUCTION
  open(ENVIRONMENT_CONFIG_FILE_PRODUCTION, 'w') do |f|
    f.puts 'Aemninja.configure do |config|'
    f.puts '  config.instances = {'
    f.puts '    author: { host: "localhost:4502", user: "admin", password: "admin"},'
    f.puts '    publish: { host: "localhost:4503", user: "admin", password: "admin"}'
    f.puts '  }'
    f.puts 'end'
  end

  exit 0

end
list!(environment='local') click to toggle source
# File lib/aemninja.rb, line 87
def list!(environment='local')
  puts "--------------------------------------------------------"
  puts "Deployment to \'#{environment}\' environment"
  puts "--------------------------------------------------------"
  puts
  puts "Configuration: .aemninja/config/environments/#{environment}.rb"
  puts

  require "./.aemninja/config/environments/#{environment}.rb"

  Aemninja.configuration.instances.each do |key, array|
    host = array[:host]
    user = array[:user]
    password = array[:password]

    puts
    puts key.to_s + " [" + host + "]"

    Aem::list host, user, password

  end
end
no_valid_command() click to toggle source
# File lib/aemninja.rb, line 192
def no_valid_command
  Aemninja::Usage.commands
end