Class: ZenPro::Commands::Generate
- Inherits:
-
Object
- Object
- ZenPro::Commands::Generate
- Defined in:
- lib/zen_pro/commands/generate.rb
Class Method Summary collapse
Instance Method Summary collapse
- #ask_app_name ⇒ Object
- #fetch_project_template_configurations(id) ⇒ Object
- #setup_complete_message(app_name) ⇒ Object
- #welcome_message ⇒ Object
Class Method Details
.run(project_template_id, options) ⇒ Object
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 |
# File 'lib/zen_pro/commands/generate.rb', line 8 def self.run(project_template_id, ) instance = new instance. app_name = instance.ask_app_name project_configurations = instance.fetch_project_template_configurations(project_template_id) = { project_template_id: project_template_id, app_name: app_name, project_configurations: project_configurations, ** } ZenPro::Commands::Create.run() # TODO: call class/method to save progress since rails app is now generated ZenPro::Commands::Configure.run() # TODO: API call to mark project as configured and store all configurations instance.(app_name) rescue StandardError => e prompt = TTY::Prompt.new prompt.error "\nOops, Zen encountered an error!" prompt.error "\n#{e.message}" end |
Instance Method Details
#ask_app_name ⇒ Object
41 42 43 44 45 46 |
# File 'lib/zen_pro/commands/generate.rb', line 41 def ask_app_name name = prompt.ask "\nWhat would you like to name your app? e.g. zero_config_rails or zero-config-rails" name.chomp end |
#fetch_project_template_configurations(id) ⇒ Object
48 49 50 51 52 |
# File 'lib/zen_pro/commands/generate.rb', line 48 def fetch_project_template_configurations(id) prompt.say "\nFetching your project's configurations from the server...\n\n" ZenPro::Api::ProjectTemplate.new.fetch_details(id) end |
#setup_complete_message(app_name) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/zen_pro/commands/generate.rb', line 54 def (app_name) prompt.say "\nššš" prompt.ok "Congratulations! Your app is fully configured.\n" prompt.say " 1. Run the rails server with `cd \#{app_name} && rails s`\n 2. You can access the app at http://localhost:3000\n BANNER\nend\n" |
#welcome_message ⇒ Object
35 36 37 38 39 |
# File 'lib/zen_pro/commands/generate.rb', line 35 def prompt.say " We will ask you few questions while all other options will automatically be added as per application configurations in the Web App.\n BANNER\nend\n" |