Class: Ironclad::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ironclad/install_generator.rb

Overview

Installs Ironclad: asks which environments you manage, writes a config/ironclad.yml to fill in and a bin/ironclad binstub, then asks about optional integrations.

Instance Method Summary collapse

Instance Method Details

#create_binstubObject



17
18
19
20
# File 'lib/generators/ironclad/install_generator.rb', line 17

def create_binstub
  copy_file 'binstub', 'bin/ironclad'
  chmod 'bin/ironclad', 0o755
end

#create_configObject



13
14
15
# File 'lib/generators/ironclad/install_generator.rb', line 13

def create_config
  create_file 'config/ironclad.yml', config_contents
end

#create_vscode_taskObject



22
23
24
25
26
# File 'lib/generators/ironclad/install_generator.rb', line 22

def create_vscode_task
  return unless yes?("Add a VS Code 'Edit Credentials' task? (y/N)")

  template 'tasks.json', '.vscode/tasks.json'
end

#setup_capistranoObject



28
29
30
31
32
33
34
# File 'lib/generators/ironclad/install_generator.rb', line 28

def setup_capistrano
  return unless File.exist?(File.join(destination_root, 'Capfile'))
  return unless yes?('Wire Ironclad into your Capfile for deploys? (y/N)')

  inject_into_file 'Capfile', "require 'ironclad/capistrano'\n",
                   after: %r{^require ['"]capistrano/setup['"].*\n}
end

#show_post_installObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/ironclad/install_generator.rb', line 36

def show_post_install
  say <<~MESSAGE

    Ironclad installed. Edit config/ironclad.yml and fill in your
    1Password references. In CI / on servers, set RAILS_MASTER_KEY from a
    secret instead.

    Print a key:      bin/ironclad [env]
    Edit credentials: bin/ironclad edit [env]
  MESSAGE
end