3075d0c0ab823fbf3f52e9dfa33edd4be70f4679

Author
Alexey Poimtsev <25312+alec-c4@users.noreply.github.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

feat(rails)!: run old rake aliases with `rails` (#9601)

BREAKING CHANGE: we've updated the aliases that run `rake` to use
`rails` instead because that's how they are run since Rails v5.
The old `rake` aliases can still be run by using the `rk` prefix
(e.g. the `rake test` alias has been changed from `rt` to `rkt`).

Closes #9601
Closes #9813
Fixes #10696

Co-authored-by: Vsevolod Voloshyn <seva.voloshin@gmail.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/rails/README.md b/plugins/rails/README.md
  2index efdb8f8babb66614cbb3dbb5c7e5a8abe2ba7e93..0a6c68c75ace723a2fb68720353b7847b5e82f8a 100644
  3--- a/plugins/rails/README.md
  4+++ b/plugins/rails/README.md
  5@@ -12,47 +12,46 @@ plugins=(... rails)
  6 
  7 ### Rails aliases
  8 
  9-| Alias | Command                    | Description                                        |
 10-|-------|----------------------------|----------------------------------------------------|
 11-| `rc`  | `rails console`            | Interact with your Rails app from the CLI          |
 12-| `rcs` | `rails console --sandbox`  | Test code in a sandbox, without changing any data  |
 13-| `rd`  | `rails destroy`            | Undo a generate operation                          |
 14-| `rdb` | `rails dbconsole`          | Interact with your db from the console             |
 15-| `rgen`| `rails generate`           | Generate boilerplate code                          |
 16-| `rgm` | `rails generate migration` | Generate a db migration                            |
 17-| `rp`  | `rails plugin`             | Run a Rails plugin command                         |
 18-| `rr`  | `rails routes`             | List all defined routes                            |
 19-| `rrg` | `rails routes \| grep`     | List and filter the defined routes                 |
 20-| `ru`  | `rails runner`             | Run Ruby code in the context of Rails              |
 21-| `rs`  | `rails server`             | Launch a web server                                |
 22-| `rsd` | `rails server --debugger`  | Launch a web server with debugger                  |
 23-| `rsp` | `rails server --port`      | Launch a web server and specify the listening port |
 24-
 25-### Rake aliases
 26-
 27-| Alias   | Command                         | Description                                            |
 28-|---------|---------------------------------|--------------------------------------------------------|
 29-| `rdm`   | `rake db:migrate`               | Run pending db migrations                              |
 30-| `rdms`  | `rake db:migrate:status`        | Show current db migration status                       |
 31-| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database |
 32-| `rdr`   | `rake db:rollback`              | Roll back the last migration                           |
 33-| `rdc`   | `rake db:create`                | Create the database                                    |
 34-| `rds`   | `rake db:seed`                  | Seed the database                                      |
 35-| `rdd`   | `rake db:drop`                  | Delete the database                                    |
 36-| `rdrs`  | `rake db:reset`                 | Delete the database and set it up again                |
 37-| `rdtc`  | `rake db:test:clone`            | Clone the database into the test database              |
 38-| `rdtp`  | `rake db:test:prepare`          | Duplicate the db schema into your test database        |
 39-| `rdsl`  | `rake db:schema:load`           | Load the database schema                               |
 40-| `rlc`   | `rake log:clear`                | Clear Rails logs                                       |
 41-| `rn`    | `rake notes`                    | Search for notes (`FIXME`, `TODO`) in code comments    |
 42-| `rt`    | `rake test`                     | Run Rails tests                                        |
 43-| `rmd`   | `rake middleware`               | Interact with Rails middlewares                        |
 44-| `rsts`  | `rake stats`                    | Print code statistics                                  |
 45+| Alias   | Command                          | Description                                            |
 46+| ------- | -------------------------------- | ------------------------------------------------------ |
 47+| `rc`    | `rails console`                  | Interact with your Rails app from the CLI              |
 48+| `rcs`   | `rails console --sandbox`        | Test code in a sandbox, without changing any data      |
 49+| `rd`    | `rails destroy`                  | Undo a generate operation                              |
 50+| `rdb`   | `rails dbconsole`                | Interact with your db from the console                 |
 51+| `rdc`   | `rails db:create`                | Create the database                                    |
 52+| `rdd`   | `rails db:drop`                  | Delete the database                                    |
 53+| `rdm`   | `rails db:migrate`               | Run pending db migrations                              |
 54+| `rdmd`  | `rails db:migrate:down`          | Undo specific db migration                             |
 55+| `rdmr`  | `rails db:migrate:redo`          | Redo specific db migration                             |
 56+| `rdms`  | `rails db:migrate:status`        | Show current db migration status                       |
 57+| `rdmtc` | `rails db:migrate db:test:clone` | Run pending migrations and clone db into test database |
 58+| `rdmu`  | `rails db:migrate:up`            | Run specific db migration                              |
 59+| `rdr`   | `rails db:rollback`              | Roll back the last migration                           |
 60+| `rdrs`  | `rails db:reset`                 | Delete the database and set it up again                |
 61+| `rds`   | `rails db:seed`                  | Seed the database                                      |
 62+| `rdsl`  | `rails db:schema:load`           | Load the database schema                               |
 63+| `rdtc`  | `rails db:test:clone`            | Clone the database into the test database              |
 64+| `rdtp`  | `rails db:test:prepare`          | Duplicate the db schema into your test database        |
 65+| `rgen`  | `rails generate`                 | Generate boilerplate code                              |
 66+| `rgm`   | `rails generate migration`       | Generate a db migration                                |
 67+| `rlc`   | `rails log:clear`                | Clear Rails logs                                       |
 68+| `rmd`   | `rails middleware`               | Interact with Rails middlewares                        |
 69+| `rn`    | `rails notes`                    | Search for notes (`FIXME`, `TODO`) in code comments    |
 70+| `rp`    | `rails plugin`                   | Run a Rails plugin command                             |
 71+| `rr`    | `rails routes`                   | List all defined routes                                |
 72+| `rrg`   | `rails routes \| grep`           | List and filter the defined routes                     |
 73+| `rs`    | `rails server`                   | Launch a web server                                    |
 74+| `rsb`   | `rails server --bind`            | Launch a web server binding it to a specific IP        |
 75+| `rsd`   | `rails server --debugger`        | Launch a web server with debugger                      |
 76+| `rsp`   | `rails server --port`            | Launch a web server and specify the listening port     |
 77+| `rsts`  | `rails stats`                    | Print code statistics                                  |
 78+| `rt`    | `rails test`                     | Run Rails tests                                        |
 79+| `ru`    | `rails runner`                   | Run Ruby code in the context of Rails                  |
 80 
 81 ### Utility aliases
 82 
 83 | Alias     | Command                       | Description                                    |
 84-|-----------|-------------------------------|------------------------------------------------|
 85+| --------- | ----------------------------- | ---------------------------------------------- |
 86 | `devlog`  | `tail -f log/development.log` | Show and follow changes to the development log |
 87 | `prodlog` | `tail -f log/production.log`  | Show and follow changes to the production log  |
 88 | `testlog` | `tail -f log/test.log`        | Show and follow changes to the test log        |
 89@@ -60,7 +59,7 @@ plugins=(... rails)
 90 ### Environment settings
 91 
 92 | Alias | Command                 | Description                     |
 93-|-------|-------------------------|---------------------------------|
 94+| ----- | ----------------------- | ------------------------------- |
 95 | `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development |
 96 | `REP` | `RAILS_ENV=production`  | Sets `RAILS_ENV` to production  |
 97 | `RET` | `RAILS_ENV=test`        | Sets `RAILS_ENV` to test        |
 98@@ -68,15 +67,41 @@ plugins=(... rails)
 99 These are global aliases. Use in combination with a command or just run them
100 separately. For example: `REP rake db:migrate` will migrate the production db.
101 
102+### Legacy rake aliases
103+
104+The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the
105diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
106index 29b413434b1131736c0becc027def7bbe9eef858..f2b0f8293d7db5cfcfd28ccdd11278db156d6c0d 100644
107--- a/plugins/rails/rails.plugin.zsh
108+++ b/plugins/rails/rails.plugin.zsh
109@@ -43,47 +43,67 @@ alias rc='rails console'
110 alias rcs='rails console --sandbox'
111 alias rd='rails destroy'
112 alias rdb='rails dbconsole'
113+alias rdc='rails db:create'
114+alias rdd='rails db:drop'
115+alias rdm='rails db:migrate'
116+alias rdmd='rails db:migrate:down'
117+alias rdmr='rails db:migrate:redo'
118+alias rdms='rails db:migrate:status'
119+alias rdmtc='rails db:migrate db:test:clone'
120+alias rdmu='rails db:migrate:up'
121+alias rdr='rails db:rollback'
122+alias rdrs='rails db:reset'
123+alias rds='rails db:seed'
124+alias rdsl='rails db:schema:load'
125+alias rdtc='rails db:test:clone'
126+alias rdtp='rails db:test:prepare'
127 alias rgen='rails generate'
128 alias rgm='rails generate migration'
129+alias rlc='rails log:clear'
130+alias rmd='rails middleware'
131+alias rn='rails notes'
132 alias rp='rails plugin'
133 alias rr='rails routes'
134 alias rrg='rails routes | grep'
135-alias ru='rails runner'
136 alias rs='rails server'
137+alias rsb='rails server --bind'
138 alias rsd='rails server --debugger'
139 alias rsp='rails server --port'
140-alias rsb='rails server --bind'
141+alias rsts='rails stats'
142+alias rt='rails test'
143+alias ru='rails runner'
144+
145 
146 # Rake aliases
147-alias rdm='rake db:migrate'
148-alias rdmr='rake db:migrate:redo'
149-alias rdmd='rake db:migrate:down'
150-alias rdms='rake db:migrate:status'
151-alias rdmu='rake db:migrate:up'
152-alias rdr='rake db:rollback'
153-alias rdc='rake db:create'
154-alias rds='rake db:seed'
155-alias rdd='rake db:drop'
156-alias rdrs='rake db:reset'
157-alias rdtc='rake db:test:clone'
158-alias rdtp='rake db:test:prepare'
159-alias rdmtc='rake db:migrate db:test:clone'
160-alias rdsl='rake db:schema:load'
161-alias rlc='rake log:clear'
162-alias rn='rake notes'
163-alias rt='rake test'
164-alias rmd='rake middleware'
165-alias rsts='rake stats'
166+alias rkdc='rake db:create'
167+alias rkdd='rake db:drop'
168+alias rkdm='rake db:migrate'
169+alias rkdmd='rake db:migrate:down'
170+alias rkdmr='rake db:migrate:redo'
171+alias rkdms='rake db:migrate:status'
172+alias rkdmtc='rake db:migrate db:test:clone'
173+alias rkdmu='rake db:migrate:up'
174+alias rkdr='rake db:rollback'
175+alias rkdrs='rake db:reset'
176+alias rkds='rake db:seed'
177+alias rkdsl='rake db:schema:load'
178+alias rkdtc='rake db:test:clone'
179+alias rkdtp='rake db:test:prepare'
180+alias rklc='rake log:clear'
181+alias rkmd='rake middleware'
182+alias rkn='rake notes'
183+alias rksts='rake stats'
184+alias rkt='rake test'
185 
186 # legacy stuff
187-alias sstat='thin --stats "/thin/stats" start'
188-alias sg='ruby script/generate'
189+alias sc='ruby script/console'
190 alias sd='ruby script/destroy'
191+alias sd='ruby script/server --debugger'
192+alias sg='ruby script/generate'
193 alias sp='ruby script/plugin'
194 alias sr='ruby script/runner'
195 alias ssp='ruby script/spec'
196-alias sc='ruby script/console'
197-alias sd='ruby script/server --debugger'
198+alias sstat='thin --stats "/thin/stats" start'
199 
200 function remote_console() {
201   /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"