Class: Terraspace::CLI::New::Project
- Defined in:
- lib/terraspace/cli/new/project.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #create_base ⇒ Object
-
#create_project ⇒ Object
Will generate config folder from.
- #create_starter_module ⇒ Object
- #create_starter_stack ⇒ Object
- #create_test ⇒ Object
- #creating_messaging ⇒ Object
- #empty_dirs ⇒ Object
- #welcome_message_examples ⇒ Object
- #welcome_message_no_examples ⇒ Object
Methods inherited from Sequence
base_options, component_options
Methods included from Util::Logging
Class Method Details
.project_options ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/terraspace/cli/new/project.rb', line 3 def self. [ [: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, aliases: %w[y], type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."], [:quiet, type: :boolean, desc: "Quiet output."], [:test_structure, type: :boolean, desc: "Create project bootstrap test structure."], ] end |
Instance Method Details
#bundle_install ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/terraspace/cli/new/project.rb', line 68 def bundle_install return if @options[:bundle] == false log "=> Installing dependencies with: bundle install" Bundler.with_unbundled_env do bundle = "BUNDLE_IGNORE_CONFIG=1 bundle install" bundle << " > /dev/null 2>&1" if @options[:quiet] system(bundle, chdir: name) end end |
#create_base ⇒ Object
26 27 28 29 |
# File 'lib/terraspace/cli/new/project.rb', line 26 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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/terraspace/cli/new/project.rb', line 36 def create_project plugin_template_source(@options[:lang], "project") # IE: plugin_template_source("hcl", "project") = @options[:config] == false ? {exclude_pattern: "config" } : {} directory ".", "#{name}", if @options[:config] == false empty_directory("#{name}/config") end end |
#create_starter_module ⇒ Object
53 54 55 56 |
# File 'lib/terraspace/cli/new/project.rb', line 53 def create_starter_module return unless @options[:examples] Module.start(component_args("example", name)) end |
#create_starter_stack ⇒ Object
58 59 60 61 |
# File 'lib/terraspace/cli/new/project.rb', line 58 def create_starter_stack return unless @options[:examples] Stack.start(component_args("demo", name)) end |
#create_test ⇒ Object
63 64 65 66 |
# File 'lib/terraspace/cli/new/project.rb', line 63 def create_test return unless @options[:test_structure] Test::Bootstrap.start(["--dir", name]) end |
#creating_messaging ⇒ Object
22 23 24 |
# File 'lib/terraspace/cli/new/project.rb', line 22 def creating_messaging log "=> Creating new project called #{name}." end |
#empty_dirs ⇒ Object
47 48 49 50 51 |
# File 'lib/terraspace/cli/new/project.rb', line 47 def empty_dirs return if @options[:examples] empty_directory("#{name}/app/modules") empty_directory("#{name}/app/stacks") end |
#welcome_message_examples ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/terraspace/cli/new/project.rb', line 78 def return unless [:examples] log <<~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
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/terraspace/cli/new/project.rb', line 93 def return if [:examples] log <<~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 |