Class: Lono::Blueprint
- Includes:
- Helper
- Defined in:
- lib/lono/blueprint/info.rb,
lib/lono/blueprint.rb,
lib/lono/blueprint/find.rb,
lib/lono/blueprint/list.rb,
lib/lono/blueprint/root.rb,
lib/lono/blueprint/helper.rb
Overview
Small wrapper class to keep blueprint name and path. Found this to be a little cleaner than using a hash.
Defined Under Namespace
Modules: Helper, Root Classes: Find, Info, List
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #create_app_folder ⇒ Object
- #create_empty_directories ⇒ Object
- #create_project ⇒ Object
- #create_starter_configs ⇒ Object
-
#set_cwd ⇒ Object
for specs.
-
#set_destination_root ⇒ Object
After this commands are executed with the newly created project.
- #tree ⇒ Object
- #welcome_message ⇒ Object
Methods included from Helper
Class Method Details
.cli_options ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/lono/blueprint.rb', line 12 def self. [ [:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"], [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], [:from_new, type: :boolean, desc: "Called from `lono new` command."], [:project_name, default: '', desc: "Only used with from_new internally"], [:type, default: "dsl", desc: "Blueprint type: dsl or erb"], ] end |
.source_root ⇒ Object
7 8 9 10 |
# File 'lib/lono/blueprint.rb', line 7 def self.source_root templates = File.("../templates", File.dirname(__FILE__)) "#{templates}/blueprint" end |
Instance Method Details
#bundle_install ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/lono/blueprint.rb', line 75 def bundle_install return if [:from_new] return unless [:bundle] puts "=> Installing dependencies with: bundle install" Bundler.with_clean_env do system("BUNDLE_IGNORE_CONFIG=1 bundle install") end end |
#create_app_folder ⇒ Object
50 51 52 |
# File 'lib/lono/blueprint.rb', line 50 def create_app_folder directory "../blueprint_types/#{@options[:type]}", "#{@cwd}/#{blueprint_name}" end |
#create_empty_directories ⇒ Object
54 55 56 57 58 |
# File 'lib/lono/blueprint.rb', line 54 def create_empty_directories # Note: Not using Lono::Core::Config::PATHS.keys to create all of them because # think it is more common to not have all the folders. Instead create them explicitly. empty_directory "#{@cwd}/#{blueprint_name}/app/templates" end |
#create_project ⇒ Object
45 46 47 48 |
# File 'lib/lono/blueprint.rb', line 45 def create_project puts "=> Creating new blueprint called #{blueprint_name}." directory ".", "#{@cwd}/#{blueprint_name}" end |
#create_starter_configs ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/lono/blueprint.rb', line 60 def create_starter_configs if [:from_new] # lono new command directory "../blueprint_configs", [:project_name] else # lono blueprint command directory "../blueprint_configs", "." end end |
#set_cwd ⇒ Object
for specs
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/lono/blueprint.rb', line 27 def set_cwd @cwd = ENV['TEST'] ? File.dirname(Lono.root) : "#{Dir.pwd}/blueprints" if [:from_new] # At this point @cwd will have the project_name from `lono new` # Yup, it's confusing. Here's an example to explain: # # lono new my-infra - sets @cwd = my-infra # # Then within the new Thor::Group this is called # # Lono::Blueprint.start(["ec2", "--from-new"]) # # So @cwd = my-infra/blueprints @cwd = "#{[:project_name]}/blueprints" end end |
#set_destination_root ⇒ Object
After this commands are executed with the newly created project
69 70 71 72 73 |
# File 'lib/lono/blueprint.rb', line 69 def set_destination_root destination_root = "#{@cwd}/#{blueprint_name}" self.destination_root = destination_root FileUtils.cd(self.destination_root) end |
#tree ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/lono/blueprint.rb', line 100 def tree return if [:from_new] tree_installed = system("type tree > /dev/null") return unless tree_installed structure = `tree .` puts <<~EOL Here's the structure of your blueprint: #{structure} EOL end |
#welcome_message ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/lono/blueprint.rb', line 85 def return if [:from_new] puts <<~EOL #{"="*64} Congrats 🎉 You have successfully created a lono blueprint. Cd into your blueprint and check things out. cd #{blueprint_name} More info: https://lono.cloud/docs/core/blueprints EOL end |