aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/app_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r--railties/lib/rails/generators/app_base.rb58
1 files changed, 13 insertions, 45 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 8991c547ca..410e53b4c0 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -68,10 +68,7 @@ module Rails
class_option :skip_listen, type: :boolean, default: false,
desc: "Don't generate configuration that depends on the listen gem"
- class_option :skip_coffee, type: :boolean, default: false,
- desc: "Don't use CoffeeScript"
-
- class_option :skip_javascript, type: :boolean, aliases: "-J", default: false,
+ class_option :skip_javascript, type: :boolean, aliases: "-J", default: name == "plugin",
desc: "Skip JavaScript files"
class_option :skip_turbolinks, type: :boolean, default: false,
@@ -327,24 +324,17 @@ module Rails
def assets_gemfile_entry
return [] if options[:skip_sprockets]
- gems = []
- gems << GemfileEntry.version("sass-rails", "~> 5.0",
- "Use SCSS for stylesheets")
-
- if !options[:skip_javascript]
- gems << GemfileEntry.version("uglifier",
- ">= 1.3.0",
- "Use Uglifier as compressor for JavaScript assets")
- end
-
- gems
+ GemfileEntry.version("sass-rails", "~> 5.0", "Use SCSS for stylesheets")
end
def webpacker_gemfile_entry
- return [] unless options[:webpack]
+ return [] if options[:skip_javascript]
- comment = "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
- GemfileEntry.new "webpacker", nil, comment
+ if options.dev? || options.edge?
+ GemfileEntry.github "webpacker", "rails/webpacker", nil, "Use development version of Webpacker"
+ else
+ GemfileEntry.new "webpacker", nil, "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
+ end
end
def jbuilder_gemfile_entry
@@ -352,34 +342,12 @@ module Rails
GemfileEntry.new "jbuilder", "~> 2.5", comment, {}, options[:api]
end
- def coffee_gemfile_entry
- GemfileEntry.version "coffee-rails", "~> 4.2", "Use CoffeeScript for .coffee assets and views"
- end
-
def javascript_gemfile_entry
- if options[:skip_javascript] || options[:skip_sprockets]
+ if options[:skip_javascript] || options[:skip_turbolinks]
[]
else
- gems = [javascript_runtime_gemfile_entry]
- gems << coffee_gemfile_entry unless options[:skip_coffee]
-
- unless options[:skip_turbolinks]
- gems << GemfileEntry.version("turbolinks", "~> 5",
- "Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks")
- end
-
- gems
- end
- end
-
- def javascript_runtime_gemfile_entry
- comment = "See https://github.com/rails/execjs#readme for more supported runtimes"
- if defined?(JRUBY_VERSION)
- GemfileEntry.version "therubyrhino", nil, comment
- elsif RUBY_PLATFORM.match?(/mingw|mswin/)
- GemfileEntry.version "duktape", nil, comment
- else
- GemfileEntry.new "mini_racer", nil, comment, { platforms: :ruby }, true
+ [ GemfileEntry.version("turbolinks", "~> 5",
+ "Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks") ]
end
end
@@ -452,9 +420,9 @@ module Rails
end
def run_webpack
- if !(webpack = options[:webpack]).nil?
+ unless options[:skip_javascript]
rails_command "webpacker:install"
- rails_command "webpacker:install:#{webpack}" unless webpack == "webpack"
+ rails_command "webpacker:install:#{options[:webpack]}" if options[:webpack] && options[:webpack] != "webpack"
end
end