Class: Suspenders::AppGenerator

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ AppGenerator

Returns a new instance of AppGenerator.



36
37
38
39
40
41
42
# File 'lib/suspenders/generators/app_generator.rb', line 36

def initialize(*args)
  super

  if options[:webpack] && `which yarn`.empty?
    raise Rails::Generators::Error, 'ERROR: yarn is required in order to use webpack'
  end
end

Instance Method Details

#configure_appObject



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

def configure_app
  say 'Configuring app'
  build :configure_action_mailer
  build :configure_active_job
  build :configure_time_formats
  build :configure_simple_form
  build :fix_i18n_deprecation_warning
  build :setup_default_rake_task
  build :configure_puma
  build :setup_foreman
  build :configure_airbrake
  build :configure_lib_directory
end

#copy_miscellaneous_filesObject



263
264
265
266
# File 'lib/suspenders/generators/app_generator.rb', line 263

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

#copy_project_markdown_filesObject



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

def copy_project_markdown_files
  build :readme
  build :pull_request_template
end

#create_github_repoObject



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

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



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

def create_heroku_apps
  unless options[:skip_heroku]
    say "Creating Heroku apps"
    build :create_heroku_apps, options[:heroku_flags]
    build :set_heroku_serve_static_files
    build :set_heroku_rails_secrets
  end
end

#create_suspenders_viewsObject



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

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

#customize_error_pagesObject



268
269
270
271
# File 'lib/suspenders/generators/app_generator.rb', line 268

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

#customize_gemfileObject



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/suspenders/generators/app_generator.rb', line 84

def customize_gemfile
  build :replace_gemfile
  build :set_ruby_to_version_being_used
  build :add_webpacker if options[:webpack]

  unless options[:skip_heroku]
    build :setup_heroku_specific_gems
  end

  bundle_command 'install'

  build :version_gems_in_gemfile
end

#finish_templateObject



44
45
46
47
# File 'lib/suspenders/generators/app_generator.rb', line 44

def finish_template
  invoke :suspenders_customization
  super
end

#init_gitObject



259
260
261
# File 'lib/suspenders/generators/app_generator.rb', line 259

def init_git
  build :init_git
end

#initial_commit_and_branchingObject



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

def initial_commit_and_branching
  if !options[:skip_git]
    say 'Creating initial commit and branches'
    build :create_initial_commit
    build :setup_deployment_environment_branches
  end
end

#outroObject



288
289
290
291
# File 'lib/suspenders/generators/app_generator.rb', line 288

def outro
  say 'Congratulations! You just pulled our suspenders.'
  say 'Remember to update the README with specifics for your project.'
end

#push_to_originObject



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

def push_to_origin
  if !options[:skip_git] && options[:origin]
    say 'Pushing to origin remote'
    build :setup_and_push_to_origin_remote, options[:origin]
  end
end

#remove_routes_comment_linesObject



273
274
275
# File 'lib/suspenders/generators/app_generator.rb', line 273

def remove_routes_comment_lines
  build :remove_routes_comment_lines
end

#run_autofixesObject



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

def run_autofixes
  say 'Running rubocop and i18n autofixes'
  build :run_autofixes
end

#run_setupObject



277
278
279
280
281
282
283
284
285
286
# File 'lib/suspenders/generators/app_generator.rb', line 277

def run_setup
  build :copy_env_example
  if options[:webpack]
    build :inject_webpacker_into_setup
    build :run_bin_setup
    build :run_webpacker_install
  else
    build :run_bin_setup
  end
end

#setup_bundler_auditObject



249
250
251
252
# File 'lib/suspenders/generators/app_generator.rb', line 249

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

#setup_css_frameworkObject



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/suspenders/generators/app_generator.rb', line 184

def setup_css_framework
  if options[:css_framework]
    say "Installing #{options[:css_framework]}"
    case options[:css_framework]
    when 'bourbon_n_friends' then build :install_bourbon_n_friends
    when 'bootstrap' then build :install_bootstrap
    when 'foundation' then build :install_foundation
    else say "Unrecognized Css Framework"
    end
  end
end

#setup_databaseObject



98
99
100
101
102
103
104
105
106
# File 'lib/suspenders/generators/app_generator.rb', line 98

def setup_database
  say 'Setting up database'

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

  build :create_database
end

#setup_development_environmentObject



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

def setup_development_environment
  say 'Setting up the development environment'
  build :raise_on_delivery_errors
  build :set_test_delivery_method
  build :raise_on_unpermitted_parameters
  build :provide_setup_script
  build :configure_generators
  build :configure_i18n_for_missing_translations
  build :configure_rubocop
  build :configure_quiet_assets
end

#setup_gitObject



196
197
198
199
200
201
202
# File 'lib/suspenders/generators/app_generator.rb', line 196

def setup_git
  if !options[:skip_git]
    say 'Initializing git'
    invoke :setup_gitignore
    invoke :init_git
  end
end

#setup_gitignoreObject



245
246
247
# File 'lib/suspenders/generators/app_generator.rb', line 245

def setup_gitignore
  build :gitignore_files
end

#setup_javascriptsObject



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

def setup_javascripts
  say 'Set up javascript'
  build :setup_javascripts
  build :inject_webpacker_into_layout if options[:webpack]
end

#setup_production_environmentObject



131
132
133
134
135
136
137
138
139
# File 'lib/suspenders/generators/app_generator.rb', line 131

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

#setup_secret_tokenObject



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

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

#setup_segmentObject



240
241
242
243
# File 'lib/suspenders/generators/app_generator.rb', line 240

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

#setup_springObject



254
255
256
257
# File 'lib/suspenders/generators/app_generator.rb', line 254

def setup_spring
  say "Springifying binstubs"
  build :setup_spring
end

#setup_staging_environmentObject



141
142
143
144
# File 'lib/suspenders/generators/app_generator.rb', line 141

def setup_staging_environment
  say 'Setting up the staging environment'
  build :setup_staging_environment
end

#setup_stylesheetsObject



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

def setup_stylesheets
  say 'Set up stylesheets'
  build :setup_stylesheets
end

#setup_test_environmentObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/suspenders/generators/app_generator.rb', line 120

def setup_test_environment
  say 'Setting up the test environment'
  build :generate_rspec
  build :configure_rspec
  build :enable_database_cleaner
  build :configure_spec_support_features
  build :configure_i18n_for_test_environment
  build :configure_i18n_tasks
  build :configure_action_mailer_in_specs
end

#suspenders_customizationObject



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
# File 'lib/suspenders/generators/app_generator.rb', line 49

def suspenders_customization
  invoke :copy_project_markdown_files
  invoke :customize_gemfile
  invoke :setup_development_environment
  invoke :setup_test_environment
  invoke :setup_production_environment
  invoke :setup_staging_environment
  invoke :setup_secret_token
  invoke :create_suspenders_views
  invoke :configure_app
  invoke :setup_stylesheets
  invoke :setup_javascripts
  invoke :copy_miscellaneous_files
  invoke :customize_error_pages
  invoke :remove_routes_comment_lines
  invoke :setup_git
  invoke :setup_database
  invoke :create_heroku_apps
  invoke :create_github_repo
  invoke :setup_segment
  invoke :setup_bundler_audit
  invoke :setup_spring
  invoke :run_setup
  invoke :run_autofixes
  invoke :initial_commit_and_branching
  invoke :push_to_origin
  invoke :setup_css_framework
  invoke :outro
end