Class: Forger::New
Class Method Summary collapse
-
.cli_options ⇒ Object
Ugly, but when the class_option is only defined in the Thor::Group class it doesnt show up with cli-template new help :( If anyone knows how to fix this let me know. Also options from the cli can be pass through to here.
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #configure_network_settings ⇒ Object
- #create_project ⇒ Object
- #git_init ⇒ Object
- #make_executable ⇒ Object
- #user_message ⇒ Object
Methods inherited from Sequence
Class Method Details
.cli_options ⇒ Object
Ugly, but when the class_option is only defined in the Thor::Group class it doesnt show up with cli-template new help :( If anyone knows how to fix this let me know. Also options from the cli can be pass through to here
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/forger/new.rb', line 9 def self. [ [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], [:git, type: :boolean, default: true, desc: "Git initialize the project"], [:iam, desc: "iam_instance_profile to use in the profiles/default.yml"], [:key_name, desc: "key name to use with launched instance in profiles/default.yml"], [:security_group, desc: "Security group to use. For config/variables/development.rb network settings."], [:subnet, desc: "Subnet to use. For config/variables/development.rb network settings."], [:vpc_id, desc: "Vpc id. For config/variables/development.rb network settings. Will use default sg and subnet"], ] end |
Instance Method Details
#bundle_install ⇒ Object
44 45 46 47 48 |
# File 'lib/forger/new.rb', line 44 def bundle_install Bundler.with_clean_env do system("BUNDLE_IGNORE_CONFIG=1 bundle install") end end |
#configure_network_settings ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/forger/new.rb', line 25 def configure_network_settings return if ENV['TEST'] network = Network.new(@options[:vpc_id]) # used for default settings @subnet = @options[:subnet] || network.subnet_ids.first @security_group = @options[:security_group] || network.security_group_id end |
#create_project ⇒ Object
33 34 35 36 37 38 |
# File 'lib/forger/new.rb', line 33 def create_project copy_project destination_root = "#{Dir.pwd}/#{project_name}" self.destination_root = destination_root FileUtils.cd("#{Dir.pwd}/#{project_name}") end |
#git_init ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/forger/new.rb', line 50 def git_init return if ![:git] return unless git_installed? return if File.exist?(".git") # this is a clone repo run("git init") run("git add .") run("git commit -m 'first commit'") end |
#make_executable ⇒ Object
40 41 42 |
# File 'lib/forger/new.rb', line 40 def make_executable chmod("exe", 0755 & ~File.umask, verbose: false) if File.exist?("exe") end |
#user_message ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/forger/new.rb', line 60 def puts <<-EOL #{"="*64} Congrats 🎉 You have successfully generated a starter forger project. Test the CLI: cd #{project_name} forger create box --noop # dry-run to see the tmp/user-data.txt script forger create box # live-run forger create box --ssh EOL end |