Class: UcbRailsCli::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/ucb_rails_cli/cli.rb

Constant Summary collapse

MASTER_KEY_PATH =
File.expand_path("~/.ucb_rails_master_key")
INSTALL_RAILS =

error messages

"Unable to find rails - please make sure you've installed Rails 5.1 or greater"
VERIFY_KEY =
"Unable to find the master key for encrypted credentials\n" +
"in #{MASTER_KEY_PATH} or the RAILS_MASTER_KEY environment variable.\n" +
"Please set the master key in one of these two places before proceeding."
GEMFILE_ERROR =
"Unable to add new gems to Gemfile - check the console output for more info"
LAYOUT_FILES =
"Unable to copy view templates - check the console output for more info"
HELPER_FILES =
"Unable to copy helpers - check the console output for more info"
ASSETS =
"Unable to copy app assets - check the console output for more info"
ROUTES =
"Unable to copy routes file - check the console output for more info"
MIGRATIONS =
"Unable to copy migrations from ucb_rails_user gem - check the console output for more info"
CONTROLLERS =
"Unable to copy controllers - check the console output for more info"
CONFIG_FILES =
"Unable to copy config files - check the console output for more info"
RSPEC =
"Unable to install RSpec - check the console output for more info"

Instance Method Summary collapse

Instance Method Details

#new(app_name) ⇒ Object



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
# File 'lib/ucb_rails_cli/cli.rb', line 31

def new(app_name)
  puts "Generating #{app_name}..."

  verify_rails or exit_with_error(INSTALL_RAILS)

  verify_master_key or exit_with_error(VERIFY_KEY)

  create_rails_app(app_name) or exit_with_error

  add_to_gemfile(app_name) or exit_with_error(GEMFILE_ERROR)

  add_layout_files(app_name) or exit_with_error(LAYOUT_FILES)

  add_helpers(app_name) or exit_with_error(HELPER_FILES)

  add_assets(app_name) or exit_with_error(ASSETS)

  add_routes(app_name) or exit_with_error(ROUTES)

  add_controllers(app_name) or exit_with_error(CONTROLLERS)

  add_config_files(app_name) or exit_with_error(CONFIG_FILES)

  install_migrations(app_name) or exit_with_error(MIGRATIONS)

  setup_rspec(app_name) or exit_with_error(RSPEC)

  puts <<-END

********************************************************************
Finished! Your new app is in ./#{app_name}

From here, you should set up the database:

  cd #{app_name}
  bin/rails db:create
  bin/rails db:migrate

then start the server as usual:

  bin/rails server

then access the homepage at http://localhost:3000. You should be able
to login with your usual UCB credentials.

Enjoy!

  END
end

#versionObject



25
26
27
# File 'lib/ucb_rails_cli/cli.rb', line 25

def version
  say "ucb_rails_cli #{UcbRailsCli::VERSION}"
end