Class: GitDeploy::Generator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/git_deploy/generator.rb

Constant Summary collapse

TEMPLATES =
%w[rails-passenger rails-puma php-composer generic].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/git_deploy/generator.rb', line 10

def self.source_root
  File.expand_path('../templates', __FILE__)
end

Instance Method Details

#copy_main_hookObject



24
25
26
# File 'lib/git_deploy/generator.rb', line 24

def copy_main_hook
  copy_hook 'after_push.sh', 'deploy/after_push'
end

#copy_restart_callbacksObject



32
33
34
35
36
# File 'lib/git_deploy/generator.rb', line 32

def copy_restart_callbacks
  source = Dir[File.join(template_dir, 'before_restart.*')].first
  abort "Error: No before_restart script in template #{options[:template].inspect}" unless source
  copy_hook File.basename(source), 'deploy/before_restart'
end

#copy_restart_hookObject



28
29
30
# File 'lib/git_deploy/generator.rb', line 28

def copy_restart_hook
  copy_hook 'restart.sh', 'deploy/restart'
end

#verify_deploy_targetObject



14
15
16
17
18
19
20
21
22
# File 'lib/git_deploy/generator.rb', line 14

def verify_deploy_target
  if File.exist?('deploy') && !File.directory?('deploy')
    abort "Error: './deploy' exists but is a file. Remove or rename it before running init."
  end

  if File.directory?('deploy') && !Dir.empty?('deploy')
    say "Warning: deploy/ already exists and is not empty. Existing files will not be overwritten.", :yellow
  end
end