class Lono::New

Public Class Methods

cli_options() click to toggle source

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

# File lib/lono/new.rb, line 11
def self.cli_options
  [
    [:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"],
    [:demo, type: :boolean, default: false, desc: "Also generate demo blueprint"],
    [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
    [:git, type: :boolean, default: true, desc: "Git initialize the project"],
    [:type, default: "dsl", desc: "Blueprint type: dsl or erb"],
  ]
end

Public Instance Methods

bundle_install() click to toggle source
# File lib/lono/new.rb, line 57
def bundle_install
  return unless options[:bundle]

  puts "=> Installing dependencies with: bundle install"
  Bundler.with_unbundled_env do
    system("BUNDLE_IGNORE_CONFIG=1 bundle install")
  end
end
create_project() click to toggle source
# File lib/lono/new.rb, line 30
def create_project
  puts "=> Creating new project called #{project_name}."
  directory ".", "#{@cwd}/#{project_name}"
end
create_starter_blueprint() click to toggle source
# File lib/lono/new.rb, line 35
def create_starter_blueprint
  return unless @options[:demo]
  # https://github.com/erikhuda/thor/wiki/Invocations
  Lono::Blueprint::New.start(["demo", "--from-new", "--type", @options[:type], "--project-name", project_name])
end
git_commit() click to toggle source
# File lib/lono/new.rb, line 66
def git_commit
  run_git_commit
end
git_init() click to toggle source
# File lib/lono/new.rb, line 52
def git_init
  return if File.exist?(".git") # this is a clone repo
  run_git_init
end
make_executable() click to toggle source
# File lib/lono/new.rb, line 48
def make_executable
  chmod("exe", 0755 & ~File.umask, verbose: false) if File.exist?("exe")
end
set_cwd() click to toggle source

for specs

# File lib/lono/new.rb, line 26
def set_cwd
  @cwd = Dir.pwd
end
set_destination_root() click to toggle source

After this commands are executed with the newly created project

# File lib/lono/new.rb, line 42
def set_destination_root
  destination_root = "#{@cwd}/#{project_name}"
  self.destination_root = destination_root
  FileUtils.cd(self.destination_root)
end
welcome_message() click to toggle source
# File lib/lono/new.rb, line 70
    def welcome_message
      puts <<~EOL
        #{"="*64}
        Congrats 🎉 You have successfully created a lono project.  Check things out by going into the created infra folder.

            cd #{project_name}

        To create a new blueprint run:

            lono blueprint new demo

        To deploy the blueprint:

            lono cfn deploy my-demo --blueprint demo

        If you name the stack according to conventions, you can run:

            lono cfn deploy demo

        To list and create additional blueprints refer to https://lono.cloud/docs/core/blueprints

        More info: https://lono.cloud/
      EOL
    end