Class: Terraspace::CLI::New::Project
- Inherits:
-
Sequence
- Object
- Thor::Group
- Sequence
- Terraspace::CLI::New::Project
show all
- Defined in:
- lib/terraspace/cli/new/project.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Sequence
base_options, component_options
Class Method Details
.project_options ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/terraspace/cli/new/project.rb', line 3
def self.project_options
[
[:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"],
[:config, type: :boolean, default: true, desc: "Whether or not to generate config files."],
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
[:test_structure, type: :boolean, desc: "Create project bootstrap test structure."]
]
end
|
Instance Method Details
#bundle_install ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/terraspace/cli/new/project.rb', line 61
def bundle_install
return if @options[:bundle] == false
puts "=> Installing dependencies with: bundle install"
Bundler.with_unbundled_env do
system("BUNDLE_IGNORE_CONFIG=1 bundle install", chdir: name)
end
end
|
#create_base ⇒ Object
19
20
21
22
|
# File 'lib/terraspace/cli/new/project.rb', line 19
def create_base
plugin_template_source("base", "project")
directory ".", "#{name}"
end
|
#create_project ⇒ Object
Will generate config folder from
1. terraspace code lang templates or
2. example lang templates from provider gems
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/terraspace/cli/new/project.rb', line 29
def create_project
plugin_template_source(@options[:lang], "project")
options = @options[:config] == false ? {exclude_pattern: "config" } : {}
directory ".", "#{name}", options
if @options[:config] == false
empty_directory("#{name}/config")
end
end
|
#create_starter_module ⇒ Object
46
47
48
49
|
# File 'lib/terraspace/cli/new/project.rb', line 46
def create_starter_module
return unless @options[:examples]
Module.start(component_args("example", name))
end
|
#create_starter_stack ⇒ Object
51
52
53
54
|
# File 'lib/terraspace/cli/new/project.rb', line 51
def create_starter_stack
return unless @options[:examples]
Stack.start(component_args("demo", name))
end
|
#create_test ⇒ Object
56
57
58
59
|
# File 'lib/terraspace/cli/new/project.rb', line 56
def create_test
return if @options[:test_structure] == false
Test::Bootstrap.start(["--dir", name])
end
|
#creating_messaging ⇒ Object
15
16
17
|
# File 'lib/terraspace/cli/new/project.rb', line 15
def creating_messaging
puts "=> Creating new project called #{name}."
end
|
#empty_dirs ⇒ Object
40
41
42
43
44
|
# File 'lib/terraspace/cli/new/project.rb', line 40
def empty_dirs
return if @options[:examples]
empty_directory("#{name}/app/modules")
empty_directory("#{name}/app/stacks")
end
|
#welcome_message_examples ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/terraspace/cli/new/project.rb', line 69
def welcome_message_examples
return unless options[:examples]
puts <<~EOL
#{"="*64}
Congrats! You have successfully created a terraspace project.
Check out the created files. Adjust to the examples and then deploy with:
cd #{name}
terraspace up demo -y # to deploy
terraspace down demo -y # to destroy
More info: https://terraspace.cloud/
EOL
end
|
#welcome_message_no_examples ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/terraspace/cli/new/project.rb', line 84
def welcome_message_no_examples
return if options[:examples]
puts <<~EOL
#{"="*64}
Congrats! You have successfully created a terraspace project.
Check out the created files.
cd #{name}
You can create starter modules and stacks with their generators:
terraspace new module example
terraspace new stack demo
Add your code to them, and deploy when you are ready:
terraspace up demo -y # to deploy
Destroy with:
terraspace down demo -y # to destroy
More info: https://terraspace.cloud/
EOL
end
|