diff options
Diffstat (limited to 'railties/lib/rails')
13 files changed, 36 insertions, 33 deletions
diff --git a/railties/lib/rails/command.rb b/railties/lib/rails/command.rb index 9012ceb274..13f3b90b6d 100644 --- a/railties/lib/rails/command.rb +++ b/railties/lib/rails/command.rb @@ -15,6 +15,8 @@ module Rails include Behavior + HELP_MAPPINGS = %w(-h -? --help) + class << self def hidden_commands # :nodoc: @hidden_commands ||= [] @@ -27,7 +29,7 @@ module Rails # Receives a namespace, arguments and the behavior to invoke the command. def invoke(namespace, args = [], **config) namespace = namespace.to_s - namespace = "help" if namespace.blank? || Thor::HELP_MAPPINGS.include?(namespace) + namespace = "help" if namespace.blank? || HELP_MAPPINGS.include?(namespace) namespace = "version" if %w( -v --version ).include? namespace if command = find_by_namespace(namespace) diff --git a/railties/lib/rails/command/actions.rb b/railties/lib/rails/command/actions.rb index 31b656ec31..fb80e9d997 100644 --- a/railties/lib/rails/command/actions.rb +++ b/railties/lib/rails/command/actions.rb @@ -11,6 +11,11 @@ module Rails if defined?(ENGINE_PATH) def require_application_and_environment! require ENGINE_PATH + + if defined?(APP_PATH) + require APP_PATH + Rails.application.require_environment! + end end def load_tasks diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index 7ae190433a..1435792536 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -56,7 +56,7 @@ module Rails end def perform(command, args, config) # :nodoc: - command = nil if Thor::HELP_MAPPINGS.include?(args.first) + command = nil if Rails::Command::HELP_MAPPINGS.include?(args.first) dispatch(command, args.dup, nil, config) end diff --git a/railties/lib/rails/commands/help/USAGE b/railties/lib/rails/commands/help/USAGE index 348f41861f..c5f8ab72bb 100644 --- a/railties/lib/rails/commands/help/USAGE +++ b/railties/lib/rails/commands/help/USAGE @@ -1,16 +1,3 @@ -Usage: bin/rails COMMAND [args] [options] -<% if engine? %> -The common Rails commands available for engines are: - generate Generate new code (short-cut alias: "g") - destroy Undo code generated with "generate" (short-cut alias: "d") - test Run tests (short-cut alias: "t") - -All commands can be run with -h for more information. - -If you want to run any commands that need to be run in context -of the application, like `bin/rails server` or `bin/rails console`, -you should do it from the application's directory (typically test/dummy). -<% else %> The most common rails commands are: generate Generate new code (short-cut alias: "g") console Start the Rails console (short-cut alias: "c") @@ -18,10 +5,11 @@ The most common rails commands are: test Run tests (short-cut alias: "t") dbconsole Start a console for the database specified in config/database.yml (short-cut alias: "db") +<% unless engine? %> new Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app" +<% end %> All commands can be run with -h (or --help) for more information. -<% end %> In addition to those commands, there are: diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index 15c636103b..d58721f648 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -95,7 +95,7 @@ module Rails module Command class ServerCommand < Base # :nodoc: - DEFAULT_PID_PATH = File.expand_path("tmp/pids/server.pid").freeze + DEFAULT_PID_PATH = "tmp/pids/server.pid".freeze class_option :port, aliases: "-p", type: :numeric, desc: "Runs Rails on the specified port.", banner: :port, default: 3000 @@ -141,7 +141,7 @@ module Rails config: options[:config], environment: environment, daemonize: options[:daemon], - pid: options[:pid], + pid: pid, caching: options["dev-caching"], restart_cmd: restart_command } @@ -165,6 +165,10 @@ module Rails "bin/rails server #{@server} #{@original_options.join(" ")}" end + def pid + File.expand_path(options[:pid]) + end + def self.banner(*) "rails server [puma, thin etc] [options]" end diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb index a23ae44b0b..b9ef63243a 100644 --- a/railties/lib/rails/engine/commands.rb +++ b/railties/lib/rails/engine/commands.rb @@ -1,12 +1,7 @@ -require "rails/command" +unless defined?(APP_PATH) + if File.exist?(File.expand_path("test/dummy/config/application.rb", ENGINE_ROOT)) + APP_PATH = File.expand_path("test/dummy/config/application", ENGINE_ROOT) + end +end -aliases = { - "g" => "generate", - "d" => "destroy", - "t" => "test" -} - -command = ARGV.shift -command = aliases[command] || command - -Rails::Command.invoke command, ARGV +require "rails/commands" diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f1015b16d5..24d2fa1284 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -31,7 +31,7 @@ end <% if RUBY_ENGINE == 'ruby' -%> group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platform: :mri + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do diff --git a/railties/lib/rails/generators/rails/app/templates/config/cable.yml b/railties/lib/rails/generators/rails/app/templates/config/cable.yml index 0bbde6f74f..1da4913082 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/cable.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/cable.yml @@ -7,3 +7,4 @@ test: production: adapter: redis url: redis://localhost:6379/1 + channel_prefix: <%= app_name %>_production diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index c7cfa74bda..22604d4d9d 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -415,7 +415,6 @@ task default: :test require 'rake/testtask' Rake::TestTask.new(:test) do |t| - t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = false diff --git a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt index 56e7925c6b..c03d9953d4 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt @@ -3,6 +3,7 @@ ENGINE_ROOT = File.expand_path('../..', __FILE__) ENGINE_PATH = File.expand_path('../../lib/<%= namespaced_name -%>/engine', __FILE__) +APP_PATH = File.expand_path('../../<%= dummy_path -%>/config/application', __FILE__) # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb index 4cc1e2d0fd..cf97c22160 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -20,7 +20,6 @@ module Rails template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb") end - hook_for :template_engine, as: :scaffold do |template_engine| invoke template_engine unless options.api? end diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 3a48c4c496..e9088c44ce 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -13,7 +13,7 @@ # start with the tag optionally followed by a colon. Everything up to the end # of the line (or closing ERB comment tag) is considered to be their text. class SourceAnnotationExtractor - class Annotation < Struct.new(:line, :tag, :text) + Annotation = Struct.new(:line, :tag, :text) do def self.directories @@directories ||= %w(app config db lib test) + (ENV["SOURCE_ANNOTATION_DIRECTORIES"] || "").split(",") end diff --git a/railties/lib/rails/tasks/yarn.rake b/railties/lib/rails/tasks/yarn.rake new file mode 100644 index 0000000000..7c5e266e3e --- /dev/null +++ b/railties/lib/rails/tasks/yarn.rake @@ -0,0 +1,9 @@ +namespace :yarn do + desc "Install all JavaScript dependencies as specified via Yarn" + task :install do + system("./bin/yarn install") + end +end + +# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use. +Rake::Task["assets:precompile"].enhance [ "yarn:install" ] |