diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 12 | ||||
-rw-r--r-- | railties/lib/rails/commands/plugin/plugin_command.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/controller/controller_generator.rb | 6 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 4 |
6 files changed, 23 insertions, 12 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 0ba220104a..8a1a440fca 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,15 @@ +* Add Webpack support in new apps via the --webpack option, which will delegate to the rails/webpacker gem. + + To generate a new app that has Webpack dependencies configured and binstubs for webpack and webpack-watcher: + + rails new myapp --webpack + + To generate a new app that has Webpack + React configured and an example intalled: + + rails new myapp --webpack=react + + *DHH* + * Add Yarn support in new apps with a yarn binstub and vendor/package.json. Skippable via --skip-yarn option. *Liceth Ovalles*, *Guillermo Iguaran*, *DHH* diff --git a/railties/lib/rails/commands/plugin/plugin_command.rb b/railties/lib/rails/commands/plugin/plugin_command.rb index 16587ce067..b40ab006af 100644 --- a/railties/lib/rails/commands/plugin/plugin_command.rb +++ b/railties/lib/rails/commands/plugin/plugin_command.rb @@ -11,7 +11,7 @@ module Rails "#{executable} new [options]" end - class_option :rc, type: :boolean, default: File.join("~", ".railsrc"), + class_option :rc, type: :string, default: File.join("~", ".railsrc"), desc: "Initialize the plugin command with previous defaults. Uses .railsrc in your home directory by default." class_option :no_rc, desc: "Skip evaluating .railsrc." diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 576c36fc86..15cc070e35 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -33,7 +33,7 @@ module Rails class_option :javascript, type: :string, aliases: "-j", desc: "Preconfigure for selected JavaScript library" - class_option :webpack, type: :boolean, default: false, + class_option :webpack, type: :string, default: nil, desc: "Preconfigure for app-like JavaScript with Webpack" class_option :skip_yarn, type: :boolean, default: false, @@ -426,7 +426,10 @@ module Rails end def run_webpack - rails_command "webpacker:install" if options[:webpack] + if !(webpack = options[:webpack]).nil? + rails_command "webpacker:install" + rails_command "webpacker:install:#{webpack}" unless webpack == "webpack" + end end def generate_spring_binstubs diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 45f2fba5b9..70f63dc672 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -90,10 +90,6 @@ module Rails @class_path end - def namespaced_file_path - @namespaced_file_path ||= namespaced_class_path.join("/") - end - def namespaced_class_path @namespaced_class_path ||= [namespaced_path] + @class_path end diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index ced3c85c00..01214dc919 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -16,7 +16,7 @@ module Rails unless options[:skip_routes] actions.reverse_each do |action| # route prepends two spaces onto the front of the string that is passed, this corrects that. - route generate_routing_code(action)[2..-1] + route generate_routing_code(action) end end end @@ -40,7 +40,7 @@ module Rails # namespace :bar do namespace_ladder = regular_class_path.each_with_index.map do |ns, i| indent(" namespace :#{ns} do\n", i * 2) - end.join + end.join[2..-1] # Create route # get 'baz/index' @@ -54,7 +54,7 @@ module Rails end.join # Combine the 3 parts to generate complete route entry - namespace_ladder + route + end_ladder + "#{namespace_ladder}#{route}#{end_ladder}" end end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index cd09270df1..d80a45a83f 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -387,14 +387,14 @@ module ApplicationTests bin/rails generate model product name:string; bin/rails db:migrate db:schema:cache:dump` end - assert File.exist?(File.join(app_path, "db", "schema_cache.dump")) + assert File.exist?(File.join(app_path, "db", "schema_cache.yml")) end def test_rake_clear_schema_cache Dir.chdir(app_path) do `bin/rails db:schema:cache:dump db:schema:cache:clear` end - assert !File.exist?(File.join(app_path, "db", "schema_cache.dump")) + assert !File.exist?(File.join(app_path, "db", "schema_cache.yml")) end def test_copy_templates |