mirror of https://github.com/rails/rails
Remove deprecated `server` argument from the rails server command
This commit is contained in:
parent
6204651412
commit
5a7028a1a5
|
@ -39,6 +39,8 @@ Please refer to the [Changelog][railties] for detailed changes.
|
||||||
|
|
||||||
* Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` environment variable support from `rails notes`.
|
* Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` environment variable support from `rails notes`.
|
||||||
|
|
||||||
|
* Remove deprecated `server` argument from the rails server command.
|
||||||
|
|
||||||
### Deprecations
|
### Deprecations
|
||||||
|
|
||||||
### Notable changes
|
### Notable changes
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
* Remove deprecated `server` argument from the rails server command.
|
||||||
|
|
||||||
|
*Rafael Mendonça França*
|
||||||
|
|
||||||
* Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` environment variable support from `rails notes`.
|
* Remove deprecated `SOURCE_ANNOTATION_DIRECTORIES` environment variable support from `rails notes`.
|
||||||
|
|
||||||
*Rafael Mendonça França*
|
*Rafael Mendonça França*
|
||||||
|
|
|
@ -102,8 +102,6 @@ module Rails
|
||||||
DEFAULT_PORT = 3000
|
DEFAULT_PORT = 3000
|
||||||
DEFAULT_PIDFILE = "tmp/pids/server.pid"
|
DEFAULT_PIDFILE = "tmp/pids/server.pid"
|
||||||
|
|
||||||
argument :using, optional: true
|
|
||||||
|
|
||||||
class_option :port, aliases: "-p", type: :numeric,
|
class_option :port, aliases: "-p", type: :numeric,
|
||||||
desc: "Runs Rails on the specified port - defaults to 3000.", banner: :port
|
desc: "Runs Rails on the specified port - defaults to 3000.", banner: :port
|
||||||
class_option :binding, aliases: "-b", type: :string,
|
class_option :binding, aliases: "-b", type: :string,
|
||||||
|
@ -128,7 +126,6 @@ module Rails
|
||||||
super
|
super
|
||||||
|
|
||||||
@original_options = local_options - %w( --restart )
|
@original_options = local_options - %w( --restart )
|
||||||
deprecate_positional_rack_server_and_rewrite_to_option(@original_options)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
@ -147,7 +144,7 @@ module Rails
|
||||||
after_stop_callback = -> { say "Exiting" unless options[:daemon] }
|
after_stop_callback = -> { say "Exiting" unless options[:daemon] }
|
||||||
server.start(after_stop_callback)
|
server.start(after_stop_callback)
|
||||||
else
|
else
|
||||||
say rack_server_suggestion(using)
|
say rack_server_suggestion(options[:using])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -156,7 +153,7 @@ module Rails
|
||||||
def server_options
|
def server_options
|
||||||
{
|
{
|
||||||
user_supplied_options: user_supplied_options,
|
user_supplied_options: user_supplied_options,
|
||||||
server: using,
|
server: options[:using],
|
||||||
log_stdout: log_to_stdout?,
|
log_stdout: log_to_stdout?,
|
||||||
Port: port,
|
Port: port,
|
||||||
Host: host,
|
Host: host,
|
||||||
|
@ -266,22 +263,6 @@ module Rails
|
||||||
FileUtils.rm_f(pid) if options[:restart]
|
FileUtils.rm_f(pid) if options[:restart]
|
||||||
end
|
end
|
||||||
|
|
||||||
def deprecate_positional_rack_server_and_rewrite_to_option(original_options)
|
|
||||||
if using
|
|
||||||
ActiveSupport::Deprecation.warn(<<~MSG.squish)
|
|
||||||
Passing the Rack server name as a regular argument is deprecated
|
|
||||||
and will be removed in the next Rails version. Please, use the -u
|
|
||||||
option instead.
|
|
||||||
MSG
|
|
||||||
|
|
||||||
original_options.concat [ "-u", using ]
|
|
||||||
else
|
|
||||||
# Use positional internally to get around Thor's immutable options.
|
|
||||||
# TODO: Replace `using` occurrences with `options[:using]` after deprecation removal.
|
|
||||||
@using = options[:using]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def rack_server_suggestion(server)
|
def rack_server_suggestion(server)
|
||||||
if server.in?(RACK_SERVERS)
|
if server.in?(RACK_SERVERS)
|
||||||
<<~MSG
|
<<~MSG
|
||||||
|
|
|
@ -44,10 +44,6 @@ class Rails::Command::ServerCommandTest < ActiveSupport::TestCase
|
||||||
assert_no_match(/Maybe you meant/, output)
|
assert_no_match(/Maybe you meant/, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_using_positional_argument_deprecation
|
|
||||||
assert_match(/DEPRECATION WARNING/, run_command("tin"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_using_known_server_that_isnt_in_the_gemfile
|
def test_using_known_server_that_isnt_in_the_gemfile
|
||||||
assert_match(/Could not load server "unicorn". Maybe you need to the add it to the Gemfile/, run_command("-u", "unicorn"))
|
assert_match(/Could not load server "unicorn". Maybe you need to the add it to the Gemfile/, run_command("-u", "unicorn"))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue