Class: Suspenders::AppGenerator

Inherits:
Rails::Generators::AppGenerator
  • Object
show all
Defined in:
lib/voyage/generators/app_generator.rb,
lib/suspenders/generators/app_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accept_defaultsObject



20
21
22
# File 'lib/voyage/generators/app_generator.rb', line 20

def self.accept_defaults
  Suspenders::AppBuilder.new.accept_defaults
end


236
237
238
# File 'lib/suspenders/generators/app_generator.rb', line 236

def self.banner
  "suspenders #{arguments.map(&:usage).join(' ')} [options]"
end

.preflight_checkObject



10
11
12
13
14
15
16
17
18
# File 'lib/voyage/generators/app_generator.rb', line 10

def self.preflight_check
  puts '"bundle install" will be run for the current ruby version and gemset. Press enter to continue...'
  prompt = STDIN.gets.chomp

  unless prompt.empty?
    puts "Skipping install. Please create a ruby gemset first!"
    exit 1
  end
end

.startObject



3
4
5
6
7
8
# File 'lib/voyage/generators/app_generator.rb', line 3

def self.start
  preflight_check
  accept_defaults

  super
end

Instance Method Details

#actually_setup_springObject



183
184
185
186
# File 'lib/voyage/generators/app_generator.rb', line 183

def actually_setup_spring
  say "Springifying binstubs"
  build :setup_spring
end

#add_api_foundationObject



155
156
157
# File 'lib/voyage/generators/app_generator.rb', line 155

def add_api_foundation
  build :add_api_foundation
end

#add_app_css_fileObject



103
104
105
# File 'lib/voyage/generators/app_generator.rb', line 103

def add_app_css_file
  build :add_app_css_file
end

#add_auto_annotate_models_rake_taskObject



131
132
133
# File 'lib/voyage/generators/app_generator.rb', line 131

def add_auto_annotate_models_rake_task
  build :add_auto_annotate_models_rake_task
end

#add_faviconObject



139
140
141
# File 'lib/voyage/generators/app_generator.rb', line 139

def add_favicon
  build :add_favicon
end

#add_high_voltage_static_pagesObject



91
92
93
# File 'lib/voyage/generators/app_generator.rb', line 91

def add_high_voltage_static_pages
  build :add_high_voltage_static_pages
end

#add_rubocop_configObject



127
128
129
# File 'lib/voyage/generators/app_generator.rb', line 127

def add_rubocop_config
  build :add_rubocop_config
end

#add_specsObject



147
148
149
# File 'lib/voyage/generators/app_generator.rb', line 147

def add_specs
  build :add_specs
end

#add_to_gitignoreObject



179
180
181
# File 'lib/voyage/generators/app_generator.rb', line 179

def add_to_gitignore
  build :add_to_gitignore
end

#bon_voyageObject



193
194
195
196
# File 'lib/voyage/generators/app_generator.rb', line 193

def bon_voyage
  say 'Congratulations! You just pulled our suspenders, Headway style!'
  say honeybadger_outro
end

#configure_appObject



134
135
136
137
138
139
140
141
142
143
# File 'lib/suspenders/generators/app_generator.rb', line 134

def configure_app
  say 'Configuring app'
  build :configure_action_mailer
  build :configure_active_job
  build :configure_time_formats
  build :setup_default_rake_task
  build :replace_default_puma_configuration
  build :set_up_forego
  build :setup_rack_mini_profiler
end

#configure_rvm_prepend_bin_to_pathObject



163
164
165
# File 'lib/voyage/generators/app_generator.rb', line 163

def configure_rvm_prepend_bin_to_path
  build :configure_rvm_prepend_bin_to_path
end

#copy_env_to_exampleObject



175
176
177
# File 'lib/voyage/generators/app_generator.rb', line 175

def copy_env_to_example
  build :copy_env_to_example
end

#copy_miscellaneous_filesObject



207
208
209
210
# File 'lib/suspenders/generators/app_generator.rb', line 207

def copy_miscellaneous_files
  say 'Copying miscellaneous support files'
  build :copy_miscellaneous_files
end

#create_github_repoObject



173
174
175
176
177
178
# File 'lib/suspenders/generators/app_generator.rb', line 173

def create_github_repo
  if !options[:skip_git] && options[:github]
    say 'Creating Github repo'
    build :create_github_repo, options[:github]
  end
end

#create_heroku_appsObject



160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/suspenders/generators/app_generator.rb', line 160

def create_heroku_apps
  if options[:heroku]
    say "Creating Heroku apps"
    build :create_heroku_apps, options[:heroku_flags]
    build :set_heroku_remotes
    build :set_heroku_rails_secrets
    build :set_heroku_application_host
    build :set_heroku_backup_schedule
    build :create_heroku_pipeline
    build :configure_automatic_deployment
  end
end

#create_local_heroku_setupObject



153
154
155
156
157
158
# File 'lib/suspenders/generators/app_generator.rb', line 153

def create_local_heroku_setup
  say "Creating local Heroku setup"
  build :create_review_apps_setup_script
  build :create_deploy_script
  build :create_heroku_application_manifest_file
end

#create_suspenders_viewsObject



125
126
127
128
129
130
131
132
# File 'lib/suspenders/generators/app_generator.rb', line 125

def create_suspenders_views
  say 'Creating suspenders views'
  build :create_partials_directory
  build :create_shared_flashes
  build :create_shared_javascripts
  build :create_shared_css_overrides
  build :create_application_layout
end

#customize_application_jsObject



75
76
77
# File 'lib/voyage/generators/app_generator.rb', line 75

def customize_application_js
  build :customize_application_js
end

#customize_application_mailerObject



143
144
145
# File 'lib/voyage/generators/app_generator.rb', line 143

def customize_application_mailer
  build :customize_application_mailer
end

#customize_error_pagesObject



212
213
214
215
# File 'lib/suspenders/generators/app_generator.rb', line 212

def customize_error_pages
  say 'Customizing the 500/404/422 pages'
  build :customize_error_pages
end

#customize_gemfileObject



62
63
64
65
66
67
# File 'lib/suspenders/generators/app_generator.rb', line 62

def customize_gemfile
  build :replace_gemfile, options[:path]
  build :set_ruby_to_version_being_used
  bundle_command 'install'
  build :configure_simple_form
end

#downgrade_neat_1_8_so_refills_media_mixin_worksObject



95
96
97
# File 'lib/voyage/generators/app_generator.rb', line 95

def downgrade_neat_1_8_so_refills_media_mixin_works
  build :downgrade_neat_1_8_so_refills_media_mixin_works
end

#finish_templateObject



24
25
26
27
28
29
30
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
# File 'lib/voyage/generators/app_generator.rb', line 24

def finish_template
  invoke :suspenders_customization
  invoke :update_gemset_in_gemfile
  invoke :use_slim
  invoke :install_devise
  invoke :customize_application_js
  invoke :require_files_in_lib
  invoke :generate_ruby_version_and_gemset
  invoke :generate_data_migrations
  invoke :add_high_voltage_static_pages
  invoke :downgrade_neat_1_8_so_refills_media_mixin_works # this should be temporary until they get refills re-written to take advantage of Neat 2.0
  invoke :generate_refills
  invoke :add_app_css_file
  invoke :update_flashes_css_file
  invoke :update_application_css_file
  invoke :overwrite_application_layout
  invoke :generate_test_environment
  invoke :update_test_environment
  invoke :add_rubocop_config
  invoke :add_auto_annotate_models_rake_task
  invoke :update_delayed_job_migration_rails_5_1_specify_4_2
  invoke :add_favicon
  invoke :customize_application_mailer
  invoke :add_specs


  # Do these last
  invoke :add_api_foundation
  invoke :rake_db_setup
  invoke :configure_rvm_prepend_bin_to_path
  invoke :run_rubocop_auto_correct
  invoke :copy_env_to_example
  invoke :add_to_gitignore
  invoke :spin_up_webpacker
  invoke :actually_setup_spring
  invoke :bon_voyage
  super
end

#generate_data_migrationsObject



87
88
89
# File 'lib/voyage/generators/app_generator.rb', line 87

def generate_data_migrations
  build :generate_data_migrations
end

#generate_defaultObject



225
226
227
228
229
# File 'lib/suspenders/generators/app_generator.rb', line 225

def generate_default
  run("spring stop")
  generate("suspenders:static")
  generate("suspenders:stylesheet_base")
end

#generate_refillsObject



99
100
101
# File 'lib/voyage/generators/app_generator.rb', line 99

def generate_refills
  build :generate_refills
end

#generate_ruby_version_and_gemsetObject



83
84
85
# File 'lib/voyage/generators/app_generator.rb', line 83

def generate_ruby_version_and_gemset
  build :generate_ruby_version_and_gemset
end

#generate_test_environmentObject



119
120
121
# File 'lib/voyage/generators/app_generator.rb', line 119

def generate_test_environment
  build :generate_test_environment
end

#init_gitObject



203
204
205
# File 'lib/suspenders/generators/app_generator.rb', line 203

def init_git
  build :init_git
end

#install_deviseObject



71
72
73
# File 'lib/voyage/generators/app_generator.rb', line 71

def install_devise
  build :install_devise
end

#outroObject



188
189
190
191
# File 'lib/voyage/generators/app_generator.rb', line 188

def outro
  # need this to be nothing so it doesn't output any text when
  # :suspenders_customization runs and it invokes this method
end

#overwrite_application_layoutObject



115
116
117
# File 'lib/voyage/generators/app_generator.rb', line 115

def overwrite_application_layout
  build :overwrite_application_layout
end

#rake_db_setupObject



159
160
161
# File 'lib/voyage/generators/app_generator.rb', line 159

def rake_db_setup
  build :rake_db_setup
end

#remove_config_comment_linesObject



217
218
219
# File 'lib/suspenders/generators/app_generator.rb', line 217

def remove_config_comment_lines
  build :remove_config_comment_lines
end

#remove_routes_comment_linesObject



221
222
223
# File 'lib/suspenders/generators/app_generator.rb', line 221

def remove_routes_comment_lines
  build :remove_routes_comment_lines
end

#require_files_in_libObject



79
80
81
# File 'lib/voyage/generators/app_generator.rb', line 79

def require_files_in_lib
  build :require_files_in_lib
end

#run_rubocop_auto_correctObject



171
172
173
# File 'lib/voyage/generators/app_generator.rb', line 171

def run_rubocop_auto_correct
  build :run_rubocop_auto_correct
end

#setup_bundler_auditObject



193
194
195
196
# File 'lib/suspenders/generators/app_generator.rb', line 193

def setup_bundler_audit
  say "Setting up bundler-audit"
  build :setup_bundler_audit
end

#setup_databaseObject



69
70
71
72
73
74
75
76
77
# File 'lib/suspenders/generators/app_generator.rb', line 69

def setup_database
  say 'Setting up database'

  if 'postgresql' == options[:database]
    build :use_postgres_config_template
  end

  build :create_database
end

#setup_default_directoriesObject



189
190
191
# File 'lib/suspenders/generators/app_generator.rb', line 189

def setup_default_directories
  build :setup_default_directories
end

#setup_development_environmentObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/suspenders/generators/app_generator.rb', line 79

def setup_development_environment
  say 'Setting up the development environment'
  build :raise_on_missing_assets_in_test
  build :raise_on_delivery_errors
  build :remove_turbolinks
  build :set_test_delivery_method
  build :add_bullet_gem_configuration
  build :raise_on_unpermitted_parameters
  build :provide_setup_script
  build :provide_dev_prime_task
  build :configure_generators
  build :configure_i18n_for_missing_translations
  build :configure_quiet_assets
end

#setup_dotfilesObject



185
186
187
# File 'lib/suspenders/generators/app_generator.rb', line 185

def setup_dotfiles
  build :copy_dotfiles
end

#setup_gitObject



145
146
147
148
149
150
151
# File 'lib/suspenders/generators/app_generator.rb', line 145

def setup_git
  if !options[:skip_git]
    say "Initializing git"
    invoke :setup_default_directories
    invoke :init_git
  end
end

#setup_production_environmentObject



111
112
113
114
115
116
117
118
# File 'lib/suspenders/generators/app_generator.rb', line 111

def setup_production_environment
  say 'Setting up the production environment'
  build :configure_smtp
  build :configure_rack_timeout
  build :enable_rack_canonical_host
  build :enable_rack_deflater
  build :setup_asset_host
end

#setup_secret_tokenObject



120
121
122
123
# File 'lib/suspenders/generators/app_generator.rb', line 120

def setup_secret_token
  say 'Moving secret token out of version control'
  build :setup_secret_token
end

#setup_segmentObject



180
181
182
183
# File 'lib/suspenders/generators/app_generator.rb', line 180

def setup_segment
  say 'Setting up Segment'
  build :setup_segment
end

#setup_springObject



167
168
169
# File 'lib/voyage/generators/app_generator.rb', line 167

def setup_spring
  # do nothing so we can run generators after suspenders_customization runs
end

#setup_test_environmentObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/suspenders/generators/app_generator.rb', line 94

def setup_test_environment
  say 'Setting up the test environment'
  build :set_up_factory_girl_for_rspec
  build :generate_factories_file
  build :set_up_hound
  build :generate_rspec
  build :configure_rspec
  build :configure_background_jobs_for_rspec
  build :enable_database_cleaner
  build :provide_shoulda_matchers_config
  build :configure_spec_support_features
  build :configure_ci
  build :configure_i18n_for_test_environment
  build :configure_action_mailer_in_specs
  build :configure_capybara_webkit
end

#spin_up_webpackerObject



151
152
153
# File 'lib/voyage/generators/app_generator.rb', line 151

def spin_up_webpacker
  build :spin_up_webpacker
end

#suspenders_customizationObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/suspenders/generators/app_generator.rb', line 37

def suspenders_customization
  invoke :customize_gemfile
  invoke :setup_development_environment
  invoke :setup_test_environment
  invoke :setup_production_environment
  invoke :setup_secret_token
  invoke :create_suspenders_views
  invoke :configure_app
  invoke :copy_miscellaneous_files
  invoke :customize_error_pages
  invoke :remove_config_comment_lines
  invoke :remove_routes_comment_lines
  invoke :setup_dotfiles
  invoke :setup_git
  invoke :setup_database
  invoke :create_local_heroku_setup
  invoke :create_heroku_apps
  invoke :create_github_repo
  invoke :setup_segment
  invoke :setup_bundler_audit
  invoke :setup_spring
  invoke :generate_default
  invoke :outro
end

#update_application_css_fileObject



111
112
113
# File 'lib/voyage/generators/app_generator.rb', line 111

def update_application_css_file
  build :update_application_css_file
end

#update_delayed_job_migration_rails_5_1_specify_4_2Object



135
136
137
# File 'lib/voyage/generators/app_generator.rb', line 135

def update_delayed_job_migration_rails_5_1_specify_4_2
  build :update_delayed_job_migration_rails_5_1_specify_4_2
end

#update_flashes_css_fileObject



107
108
109
# File 'lib/voyage/generators/app_generator.rb', line 107

def update_flashes_css_file
  build :update_flashes_css_file
end

#update_gemset_in_gemfileObject



63
64
65
# File 'lib/voyage/generators/app_generator.rb', line 63

def update_gemset_in_gemfile
  build :update_gemset_in_gemfile
end

#update_test_environmentObject



123
124
125
# File 'lib/voyage/generators/app_generator.rb', line 123

def update_test_environment
  build :update_test_environment
end

#use_slimObject



67
68
69
# File 'lib/voyage/generators/app_generator.rb', line 67

def use_slim
  build :use_slim
end