From 3075d0c0ab823fbf3f52e9dfa33edd4be70f4679 Mon Sep 17 00:00:00 2001 From: Alexey Poimtsev <25312+alec-c4@users.noreply.github.com> Date: Fri, 15 Jan 2021 22:23:15 +0300 Subject: 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 --- plugins/rails/README.md | 111 +++++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 43 deletions(-) (limited to 'plugins/rails/README.md') diff --git a/plugins/rails/README.md b/plugins/rails/README.md index efdb8f8ba..0a6c68c75 100644 --- a/plugins/rails/README.md +++ b/plugins/rails/README.md @@ -12,47 +12,46 @@ plugins=(... rails) ### Rails aliases -| Alias | Command | Description | -|-------|----------------------------|----------------------------------------------------| -| `rc` | `rails console` | Interact with your Rails app from the CLI | -| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data | -| `rd` | `rails destroy` | Undo a generate operation | -| `rdb` | `rails dbconsole` | Interact with your db from the console | -| `rgen`| `rails generate` | Generate boilerplate code | -| `rgm` | `rails generate migration` | Generate a db migration | -| `rp` | `rails plugin` | Run a Rails plugin command | -| `rr` | `rails routes` | List all defined routes | -| `rrg` | `rails routes \| grep` | List and filter the defined routes | -| `ru` | `rails runner` | Run Ruby code in the context of Rails | -| `rs` | `rails server` | Launch a web server | -| `rsd` | `rails server --debugger` | Launch a web server with debugger | -| `rsp` | `rails server --port` | Launch a web server and specify the listening port | - -### Rake aliases - -| Alias | Command | Description | -|---------|---------------------------------|--------------------------------------------------------| -| `rdm` | `rake db:migrate` | Run pending db migrations | -| `rdms` | `rake db:migrate:status` | Show current db migration status | -| `rdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database | -| `rdr` | `rake db:rollback` | Roll back the last migration | -| `rdc` | `rake db:create` | Create the database | -| `rds` | `rake db:seed` | Seed the database | -| `rdd` | `rake db:drop` | Delete the database | -| `rdrs` | `rake db:reset` | Delete the database and set it up again | -| `rdtc` | `rake db:test:clone` | Clone the database into the test database | -| `rdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database | -| `rdsl` | `rake db:schema:load` | Load the database schema | -| `rlc` | `rake log:clear` | Clear Rails logs | -| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments | -| `rt` | `rake test` | Run Rails tests | -| `rmd` | `rake middleware` | Interact with Rails middlewares | -| `rsts` | `rake stats` | Print code statistics | +| Alias | Command | Description | +| ------- | -------------------------------- | ------------------------------------------------------ | +| `rc` | `rails console` | Interact with your Rails app from the CLI | +| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data | +| `rd` | `rails destroy` | Undo a generate operation | +| `rdb` | `rails dbconsole` | Interact with your db from the console | +| `rdc` | `rails db:create` | Create the database | +| `rdd` | `rails db:drop` | Delete the database | +| `rdm` | `rails db:migrate` | Run pending db migrations | +| `rdmd` | `rails db:migrate:down` | Undo specific db migration | +| `rdmr` | `rails db:migrate:redo` | Redo specific db migration | +| `rdms` | `rails db:migrate:status` | Show current db migration status | +| `rdmtc` | `rails db:migrate db:test:clone` | Run pending migrations and clone db into test database | +| `rdmu` | `rails db:migrate:up` | Run specific db migration | +| `rdr` | `rails db:rollback` | Roll back the last migration | +| `rdrs` | `rails db:reset` | Delete the database and set it up again | +| `rds` | `rails db:seed` | Seed the database | +| `rdsl` | `rails db:schema:load` | Load the database schema | +| `rdtc` | `rails db:test:clone` | Clone the database into the test database | +| `rdtp` | `rails db:test:prepare` | Duplicate the db schema into your test database | +| `rgen` | `rails generate` | Generate boilerplate code | +| `rgm` | `rails generate migration` | Generate a db migration | +| `rlc` | `rails log:clear` | Clear Rails logs | +| `rmd` | `rails middleware` | Interact with Rails middlewares | +| `rn` | `rails notes` | Search for notes (`FIXME`, `TODO`) in code comments | +| `rp` | `rails plugin` | Run a Rails plugin command | +| `rr` | `rails routes` | List all defined routes | +| `rrg` | `rails routes \| grep` | List and filter the defined routes | +| `rs` | `rails server` | Launch a web server | +| `rsb` | `rails server --bind` | Launch a web server binding it to a specific IP | +| `rsd` | `rails server --debugger` | Launch a web server with debugger | +| `rsp` | `rails server --port` | Launch a web server and specify the listening port | +| `rsts` | `rails stats` | Print code statistics | +| `rt` | `rails test` | Run Rails tests | +| `ru` | `rails runner` | Run Ruby code in the context of Rails | ### Utility aliases | Alias | Command | Description | -|-----------|-------------------------------|------------------------------------------------| +| --------- | ----------------------------- | ---------------------------------------------- | | `devlog` | `tail -f log/development.log` | Show and follow changes to the development log | | `prodlog` | `tail -f log/production.log` | Show and follow changes to the production log | | `testlog` | `tail -f log/test.log` | Show and follow changes to the test log | @@ -60,7 +59,7 @@ plugins=(... rails) ### Environment settings | Alias | Command | Description | -|-------|-------------------------|---------------------------------| +| ----- | ----------------------- | ------------------------------- | | `RED` | `RAILS_ENV=development` | Sets `RAILS_ENV` to development | | `REP` | `RAILS_ENV=production` | Sets `RAILS_ENV` to production | | `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test | @@ -68,15 +67,41 @@ plugins=(... rails) These are global aliases. Use in combination with a command or just run them separately. For example: `REP rake db:migrate` will migrate the production db. +### Legacy rake aliases + +The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the +prefix `rk` for backwards compatibility. + +[1]: https://guides.rubyonrails.org/v5.2/command_line.html#bin-rails + +| Alias | Command | Description | +| -------- | ------------------------------- | ------------------------------------------------------ | +| `rkdc` | `rake db:create` | Create the database | +| `rkdd` | `rake db:drop` | Delete the database | +| `rkdm` | `rake db:migrate` | Run pending db migrations | +| `rkdms` | `rake db:migrate:status` | Show current db migration status | +| `rkdmtc` | `rake db:migrate db:test:clone` | Run pending migrations and clone db into test database | +| `rkdr` | `rake db:rollback` | Roll back the last migration | +| `rkdrs` | `rake db:reset` | Delete the database and set it up again | +| `rkds` | `rake db:seed` | Seed the database | +| `rkdsl` | `rake db:schema:load` | Load the database schema | +| `rkdtc` | `rake db:test:clone` | Clone the database into the test database | +| `rkdtp` | `rake db:test:prepare` | Duplicate the db schema into your test database | +| `rklc` | `rake log:clear` | Clear Rails logs | +| `rkmd` | `rake middleware` | Interact with Rails middlewares | +| `rkn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments | +| `rksts` | `rake stats` | Print code statistics | +| `rkt` | `rake test` | Run Rails tests | + ### Legacy stuff | Alias | Command | -|---------|------------------------------------| -| `sstat` | `thin --stats "/thin/stats" start` | -| `sg` | `ruby script/generate` | +| ------- | ---------------------------------- | +| `sc` | `ruby script/console` | | `sd` | `ruby script/destroy` | +| `sd` | `ruby script/server --debugger` | +| `sg` | `ruby script/generate` | | `sp` | `ruby script/plugin` | | `sr` | `ruby script/runner` | | `ssp` | `ruby script/spec` | -| `sc` | `ruby script/console` | -| `sd` | `ruby script/server --debugger` | +| `sstat` | `thin --stats "/thin/stats" start` | -- cgit v1.2.3-70-g09d2 From 47d313c90409f63ee6b06c65f2372bbf847c106b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 7 Mar 2022 15:20:03 +0100 Subject: chore(rails): fix comments and docs --- plugins/rails/README.md | 11 ++++++++--- plugins/rails/rails.plugin.zsh | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'plugins/rails/README.md') diff --git a/plugins/rails/README.md b/plugins/rails/README.md index 0a6c68c75..3eee12fbd 100644 --- a/plugins/rails/README.md +++ b/plugins/rails/README.md @@ -1,6 +1,7 @@ # Rails -This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables. +This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and +[Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables. To use it, add `rails` to the plugins array in your zshrc file: @@ -67,7 +68,9 @@ plugins=(... rails) These are global aliases. Use in combination with a command or just run them separately. For example: `REP rake db:migrate` will migrate the production db. -### Legacy rake aliases +## Legacy + +### Rake aliases The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the prefix `rk` for backwards compatibility. @@ -93,7 +96,7 @@ prefix `rk` for backwards compatibility. | `rksts` | `rake stats` | Print code statistics | | `rkt` | `rake test` | Run Rails tests | -### Legacy stuff +### Other | Alias | Command | | ------- | ---------------------------------- | @@ -105,3 +108,5 @@ prefix `rk` for backwards compatibility. | `sr` | `ruby script/runner` | | `ssp` | `ruby script/spec` | | `sstat` | `thin --stats "/thin/stats" start` | + +- `remote_console `: runs `ruby script/console production` on a remote server. diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index f2b0f8293..e724bffc4 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -1,3 +1,4 @@ +# rails command wrapper function _rails_command () { if [ -e "bin/stubs/rails" ]; then bin/stubs/rails $@ @@ -12,28 +13,31 @@ function _rails_command () { fi } +alias rails='_rails_command' +compdef _rails_command=rails + +# rake command wrapper function _rake_command () { if [ -e "bin/stubs/rake" ]; then bin/stubs/rake $@ elif [ -e "bin/rake" ]; then bin/rake $@ - elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then + elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then bundle exec rake $@ else command rake $@ fi } -alias rails='_rails_command' -compdef _rails_command=rails - alias rake='_rake_command' compdef _rake_command=rake +# Log aliases alias devlog='tail -f log/development.log' alias prodlog='tail -f log/production.log' alias testlog='tail -f log/test.log' +# Environment settings alias -g RED='RAILS_ENV=development' alias -g REP='RAILS_ENV=production' alias -g RET='RAILS_ENV=test' -- cgit v1.2.3-70-g09d2 From 98ed582e6a143517d8c1ac229a4da8e4246217f1 Mon Sep 17 00:00:00 2001 From: romanch Date: Fri, 15 Jan 2021 09:33:48 +0530 Subject: feat(rails): add `fmns` alias for `foreman start` (#9600) Closes #9600 --- plugins/rails/README.md | 6 ++++++ plugins/rails/rails.plugin.zsh | 2 ++ 2 files changed, 8 insertions(+) (limited to 'plugins/rails/README.md') diff --git a/plugins/rails/README.md b/plugins/rails/README.md index 3eee12fbd..fa66750f0 100644 --- a/plugins/rails/README.md +++ b/plugins/rails/README.md @@ -49,6 +49,12 @@ plugins=(... rails) | `rt` | `rails test` | Run Rails tests | | `ru` | `rails runner` | Run Ruby code in the context of Rails | +### Foreman + +| Alias | Command | Description | +| ------ | --------------- | ----------------------------------------- | +| `fmns` | `foreman start` | Interact with your Rails app from the CLI | + ### Utility aliases | Alias | Command | Description | diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index e724bffc4..b11cbb5c7 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -77,6 +77,8 @@ alias rsts='rails stats' alias rt='rails test' alias ru='rails runner' +# Foreman aliases +alias fmns='foreman start' # Rake aliases alias rkdc='rake db:create' -- cgit v1.2.3-70-g09d2