class Bard::CLI::New
Attributes
Public Instance Methods
Source
# File lib/bard/cli/new.rb, line 6 def new project_name @project_name = project_name validate create_project push_to_github stage puts green("Project #{project_name} created!") puts "Please cd ../#{project_name}" end
Private Instance Methods
Source
# File lib/bard/cli/new.rb, line 28 def create_project run! <<~BASH env -i bash -lc ' export HOME=~ cd .. source ~/.rvm/scripts/rvm rvm use --create #{ruby_version}@#{project_name} gem list rails -i || gem install rails --no-document rails new #{project_name} --skip-git --skip-kamal --skip-test -m #{template_path} ' BASH end
Source
# File lib/bard/cli/new.rb, line 42 def push_to_github api = Bard::Github.new(project_name) api.create_repo run! <<~BASH cd ../#{project_name} git init -b master git add -A git commit -m"initial commit." git remote add origin git@github.com:botandrosedesign/#{project_name} git push -u origin master BASH api.add_master_key File.read("../#{project_name}/config/master.key") api.add_master_branch_protection api.patch(nil, allow_auto_merge: true) end
Source
# File lib/bard/cli/new.rb, line 58 def stage run! <<~BASH cd ../#{project_name} bard deploy --clone BASH end
Source
# File lib/bard/cli/new.rb, line 69 def template_path File.expand_path("new_rails_template.rb", __dir__) end
Source
# File lib/bard/cli/new.rb, line 20 def validate if project_name !~ /^[a-z][a-z0-9]*\Z/ puts red("!!! ") + "Invalid project name: #{yellow(project_name)}." puts "The first character must be a lowercase letter, and all following characters must be a lowercase letter or number." exit 1 end end