-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use app namespace for framework tasks #23439
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @kaspth (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
798e4cc
to
39f47bb
Compare
@@ -1,68 +1,66 @@ | |||
namespace :rails do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file, only the namespace and indentations are changed.
39f47bb
to
06e051e
Compare
I don't think we should change this right now. I think more of |
@kaspth should we change the namespace to |
@matthewd |
Yeah, app sounds good. We should still define the rails versions but enrich them with a deprecation prerequisite task. |
3ccfddb
to
80aaef1
Compare
@kaspth |
7d3c04b
to
cb3b482
Compare
@@ -1,3 +1,7 @@ | |||
* Use app namespace instead of rails namespace from the framework rake tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more info. Mention some of the tasks and that the rails:
namespace has been deprecated.
Also needs a rebase (and remember to keep your commits squashed). Thanks ❤️ |
d6435f5
to
4fa1ded
Compare
@kaspth |
Running this task with the rails task namespace is deprecated in favor of app. | ||
Please run e.g. bin/rails #{task.sub(/^rails:/, 'app:')} instead." | ||
MSG | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry wasn't clear enough.
Don't need to print deprecation warnings for every task in the namespace.
I meant we shouldn't use Rake.application.top_level_tasks.grep(/^rails:/)
. I didn't mean to remove the deprecation enrichment of the rails:
namespaced tasks, that part was correct before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should replace this with:
task :deprecated do |task|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Running #{task.name.sub('deprecated:', '')} with the rails: namespace is deprecated in favor of app.
Run e.g. bin/rails app:update instead."
MSG
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified the codes for the :rails namespace in my local environment.
namespace :rails do
task :deprecated do |task|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Running #{task.name.sub('deprecated:', '')} with the rails: namespace is deprecated in favor of app.
Run e.g. bin/rails app:update instead."
MSG
end
task :update => ['deprecated', 'app:update']
task :template => ['deprecated', 'app:template']
namespace :templates do
task :copy => ['deprecated', 'app:templates:copy']
end
namespace :update do
task :configs => ['deprecated', 'app:update:configs']
task :bin => ['deprecated', 'app:update:bin']
end
end
and ran the command.
$ rails rails:update 1 ↵
DEPRECATION WARNING: Running rails:deprecated with the rails: namespace is deprecated in favor of app. Run e.g. bin/rails app:update instead.". (called from block in execute at /Users/ryo/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-10.5.0/lib/rake/task.rb:238)
The message is incorrect because rails:deprecated
isn't the original task used by the actual command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code
Rake.application.top_level_tasks
returns only task names given in a command. (e.g. when rails rails:update
is given, only [rails:update]
is returned, not all tasks in the rails:
namespace.)
So, I think the below snippet is correct.
namespace :rails do
task :deprecated do |task|
Rake.application.top_level_tasks.grep(/^rails:/).each do |task|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Running #{task} with the rails: namespace is deprecated in favor of app.
Run e.g. bin/rails #{task.sub(/^rails:/, 'app:')} instead."
MSG
end
end
task :update => ['deprecated', 'app:update']
task :template => ['deprecated', 'app:template']
namespace :templates do
task :copy => ['deprecated', 'app:templates:copy']
end
namespace :update do
task :configs => ['deprecated', 'app:update:configs']
task :bin => ['deprecated', 'app:update:bin']
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I understand.
I removed Rake.application.top_level_tasks.grep(/^rails:/)
4fa1ded
to
5da0c51
Compare
Updated and rebased. I think it's better to use deprecated task names like below. namespace :rails do
%i(update template templates:copy update:configs update:bin).each do |task_name|
task "#{task_name}" do
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Running #{task_name} with the rails: namespace is deprecated in favor of app.
Run e.g. bin/rails app:#{task_name} instead."
MSG
Rake.application.invoke_task("app:#{task_name}")
end
end
end |
@kaspth |
5da0c51
to
237ff9e
Compare
237ff9e
to
9506907
Compare
Looks good and thanks for your patience! Can you rebase? If not, I will do it tonight 😄 |
Wait, what do you mean by "(And it doesn't deprecate all tasks with rails: namespace.)"? |
9506907
to
3bcaba0
Compare
@kaspth
I mean only tasks listed below are now deprecated. If someone add other tasks in the 'rails' namespace, %i(update template templates:copy update:configs update:bin) # in the rails namespace |
3bcaba0
to
5d16e7f
Compare
…amespace. (e.g. `rails:update` and `rails:template` tasks is renamed to `app:update` and `app:template`.)
5d16e7f
to
eaec958
Compare
Use app namespace for framework tasks
@ryohashimoto thanks! |
@kaspth Thanks a lot ! |
This guides were pointing to this command `rails app:update`, which I tried to run, but it didnt worked. I think the right command is `rails rails:update` instead. Also thats the name of the rake task. Also I removed the `Rake` word from the title, as we run it using `rails` bin now. cc @kaspth [skip ci]
Rake tasks `rails:update` or `rails:template` and so on were deprecated on Rails 5.0, and will be removed on Rails 5.1. So we should switch a task name. ref: * rails/rails#23439 * rails/rails@f778281
Rake tasks `rails:update` or `rails:template` and so on were deprecated on Rails 5.0, and will be removed on Rails 5.1. So we should switch a task name. ref: * rails/rails#23439 * rails/rails@f778281
Rake tasks `rails:update` or `rails:template` and so on were deprecated on Rails 5.0, and will be removed on Rails 5.1. So we should switch a task name. ref: * rails/rails#23439 * rails/rails@f778281
By introducing Rake proxy,
rake rails
commands becomerails rails
commands (rails rails:template
,rails rails:update
etc.) .For simplicity, I removed the
rails
namespace from the framework codes and docs. (and now we can userails template
,rails update
etc.)updated:
Not removing the rails namespace, use app namespace instead.
e.g.
rails rails:template
andrails rails:update
tasks should berails app:template
,rails app:update