Class: Recipes::FrontEnd
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Recipes::FrontEnd
- Defined in:
- lib/potassium/recipes/front_end.rb
Instance Method Summary collapse
Instance Method Details
#ask ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/potassium/recipes/front_end.rb', line 2 def ask frameworks = { vue: "Vue", angular: "Angular 2", none: "None" } framework = answer(:front_end) do frameworks.keys[ Ask.list("Which front-end framework are you going to use?", frameworks.values) ] end set :front_end, framework.to_sym end |
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/potassium/recipes/front_end.rb', line 17 def create return if [:none, :None].include? get(:front_end).to_sym gather_gem 'webpacker', github: 'rails/webpacker' after(:gem_install) do value = get(:front_end) run "rails webpacker:install" run "rails webpacker:install:#{value}" if value if value == :vue application_js_file = "app/javascript/packs/application.js" FileUtils.move "app/javascript/packs/hello_vue.js", application_js_file gsub_file application_js_file, %r{\/\/.*\n}, "" js_pack_tag = "\n <%= javascript_pack_tag 'application' %>\n" layout_file = "app/views/layouts/application.html.erb" insert_into_file layout_file, js_pack_tag, after: "<%= csrf_meta_tags %>" end end end |
#install ⇒ Object
39 40 41 42 |
# File 'lib/potassium/recipes/front_end.rb', line 39 def install ask create end |
#installed? ⇒ Boolean
44 45 46 47 48 49 |
# File 'lib/potassium/recipes/front_end.rb', line 44 def installed? package_file = 'package.json' return false unless file_exist?(package_file) package_content = read_file(package_file) package_content.include?("\"@angular/core\"") || package_content.include?("\"vue\"") end |