/
rails_app_bootstrap_devise_postgres.rb
88 lines (69 loc) · 2.68 KB
/
rails_app_bootstrap_devise_postgres.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# =============================================================================================================
# Template for generating a Rails application with user authentication, elastic search and Bourbon SASS support
# =============================================================================================================
#
# Usage:
# ------
#
# $ rails new appname --skip --skip-bundle --template "template_file_name.rb"
# =============================================================================================================
# ----- Add GEMS --------------------------------------------------------------------------------
gem 'haml-rails'
gem 'pry-rails'
gem 'pry-byebug'
gem 'puma'
gem 'devise'
gem 'bourbon'
gem 'neat'
gem 'bitters'
gem 'pg'
# ----- Remove GEMS -----------------------------------------------------------------------------
comment_lines 'Gemfile', /gem 'spring/
# ----- Initialize a Git Repository -----------------------------------------------------------
git :init
git add: "."
git commit: "-m 'Initial commit: Clean application'"
# ----- Install gems ------------------------------------------------------------------------------
puts
say_status "Rubygems", "Installing Rubygems...", :yellow
puts '-'*80, ''
run "bundle install"
# ----- Install Devise -----------------------------------------------------------------------------
puts
say_status "Installing Devise", :yellow
puts '-'*80, ''
run "rails generate devise:install"
puts
say_status "Installing Devise Views", :yellow
puts '-'*80, ''
run "rails generate devise:views"
puts
say_status "Create User Model", :yellow
puts '-'*80, ''
run "rails generate devise User"
puts
say_status "Migrating the Database", :yellow
puts '-'*80, ''
rake "db:migrate"
# ----- Print Git log -----------------------------------------------------------------------------
puts
say_status "Git", "Details about the application:", :yellow
puts '-'*80, ''
git tag: "basic"
git log: "--reverse --oneline"
# ----- Start the application ---------------------------------------------------------------------
unless ENV['RAILS_NO_SERVER_START']
require 'net/http'
if (begin; Net::HTTP.get(URI('http://localhost:3000')); rescue Errno::ECONNREFUSED; false; rescue Exception; true; end)
puts "\n"
say_status "ERROR", "Some other application is running on port 3000!\n", :red
puts '-'*80
port = ask("Please provide free port:", :bold)
else
port = '3000'
end
puts "", "="*80
say_status "DONE", "\e[1mStarting the application.\e[0m", :yellow
puts "="*80, ""
run "rails server --port=#{port}"
end