Class: Wellcar::Commands::New
- Inherits:
-
Base
- Object
- Base
- Wellcar::Commands::New
show all
- Defined in:
- lib/wellcar/commands/new.rb
Instance Attribute Summary
Attributes inherited from Base
#app_name, #domain_name, #github_account, #ruby_version, #use_bundler_2
Instance Method Summary
collapse
Methods inherited from Base
#build_development_environment, #clean_docker, #core_docker_templates, #create_directories, #create_wellcar_folder, #write_files
Constructor Details
#initialize(app_name, github_account, domain_name) ⇒ New
Returns a new instance of New.
4
5
6
7
8
9
10
|
# File 'lib/wellcar/commands/new.rb', line 4
def initialize(app_name, github_account, domain_name)
self.app_name = app_name
self.domain_name = domain_name
self.github_account = github_account
self.ruby_version = "2.6.6"
self.use_bundler_2 = true
end
|
Instance Method Details
#call(options, args) ⇒ Object
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
89
90
91
92
93
94
95
|
# File 'lib/wellcar/commands/new.rb', line 57
def call(options, args)
try_full_nuke options[:full_nuke]
within_app_folder do
create_wellcar_folder
create_directories
write_files
clean_docker
perform_setup
tidy_up_setup
build_development_environment
end
puts <<-FINISHED
Your new Rails application "#{app_name}" has been created with Docker!
Don't forget to commit everything to git.
You can use wellcar to interact with the Docker containers and the Rails application as you develop your app.
Run `wellcar` for help with commands.
FINISHED
end
|
41
42
43
44
45
46
47
|
# File 'lib/wellcar/commands/new.rb', line 41
def perform_setup
exit 16 unless system "docker-compose up --build new_rails"
exit 32 unless system "docker-compose up --build bundle"
exit 64 unless system "docker-compose up --build install_webpacker"
puts "Rails app created; initializing for Docker\n"
end
|
#try_full_nuke(nuke) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/wellcar/commands/new.rb', line 21
def try_full_nuke(nuke)
if nuke && Dir.exists?(app_name)
puts "*** Destroying the existing folder #{app_name} ***"
FileUtils.rm_rf app_name
elsif Dir.exists? app_name
puts "Cannot overwrite existing folder #{Dir.pwd}/#{app_name}"
exit 1
end
end
|
#within_app_folder(&block) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/wellcar/commands/new.rb', line 31
def within_app_folder(&block)
raise NotImplemented if block.nil?
Dir.mkdir app_name
Dir.chdir(app_name) do
yield
end
end
|