Compare commits

...

25 Commits

Author SHA1 Message Date
Florian Schwab aa4a03bdf2 remove allow_failure from dependency scanning 2019-09-03 12:03:05 +02:00
Florian Schwab 1fd05219ce * add missing rubocop-performance dependency to gemspec
* set targeted ruby version for rubocop to 2.4
2019-08-23 11:05:44 +02:00
Florian Schwab 9501f25ebe update changelog 2019-06-19 11:27:54 +02:00
Florian Schwab c658715d28 update ci 2019-06-19 11:27:48 +02:00
Florian Schwab afccfdd379 improve code style 2018-10-07 15:16:37 +02:00
Florian Schwab 2fecb87e89 add security scans to ci pipeline 2018-10-07 15:00:27 +02:00
Florian Schwab 42cd9edc96 update gitlab ci 2018-06-10 12:52:43 +02:00
Florian Schwab 92831fe312 fix gem file list 2018-06-09 18:48:45 +02:00
Florian Schwab 663a7cd563 fix rubocop warnings 2018-06-09 18:45:58 +02:00
Florian Schwab cb1e30b515 move to gitlab 2018-06-09 18:37:36 +02:00
Florian Schwab c26464291b prepare v2.3.0 release 2018-05-24 11:18:42 +02:00
Florian Schwab 11b0448c02 add alias for rails:console (fixes #36) 2018-05-24 11:16:56 +02:00
Florian Schwab 9d3ade7840 remove rails 5.2 deprecation for setting environment without '-e' 2018-02-11 10:05:55 +01:00
Florian Schwab a14cc3660c allow to set shell (refs #31) 2018-02-03 23:12:13 +01:00
Florian Schwab 99743c0ac3 fix copied headline in readme 2018-02-03 22:06:01 +01:00
Florian Schwab 6a983cd78e allow to set capistrano role (closes #33) 2018-02-03 21:30:35 +01:00
Florian Schwab ccd2d0419c * remove gemnasium batch due to service termination
* remove gitter link
2018-02-03 21:27:03 +01:00
Florian Schwab 33ad883cde prepare v2.2.1 release 2017-09-04 10:17:46 +02:00
Florian Schwab fb9a04135a Merge branch 'pr/32' 2017-09-04 10:15:01 +02:00
Andrew Babichev f05245707f Add rails:db alias to rails:dbconsole 2017-07-17 16:30:50 +03:00
Florian Schwab dab5836816 add information about #18 and #26 to readme 2016-10-26 21:23:12 +02:00
Florian Schwab cef3fa0f87 prepare 2.2.0 release 2016-10-25 10:29:47 +02:00
Florian Schwab 0ded7fe4ef add missing entry for PR#25 to changelog 2016-10-25 10:28:58 +02:00
Florian Schwab b9766d7a2d Merge pull request #25 from hector/master
Add compatibility with Rbenv and Chruby
2016-10-16 13:33:48 +02:00
Hector Parra 226f6dbed5 Add compatibility with Rbenv and Chruby 2016-09-29 00:15:58 +02:00
12 changed files with 152 additions and 59 deletions

20
.gitignore vendored
View File

@ -1,17 +1,3 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
/.bundle
/Gemfile.lock
/pkg

41
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,41 @@
stages:
- build
- codequality
- security
build:
stage: build
image: ruby:2.6
script:
- gem install bundler --no-document
- bundle update
artifacts:
paths:
- Gemfile.lock
rubocop:
stage: codequality
image: ruby:2.6
script:
- gem install rubocop rubocop-performance --no-document
- rubocop
dependency_scanning:
stage: security
dependencies:
- build
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
artifacts:
paths:
- gl-dependency-scanning-report.json

12
.rubocop.yml Normal file
View File

@ -0,0 +1,12 @@
require:
- rubocop-performance
AllCops:
TargetRubyVersion: 2.4
Naming/FileName:
Exclude:
- 'lib/capistrano-rails-console.rb'
Metrics/LineLength:
Max: 120

View File

@ -1,47 +1,66 @@
# Change Log
# Changelog
All notable changes to this project will be documented in this file.
## 2.1.1 (2016-10-04)
### Feature
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [2.3.0] - 2018-05-24
### Added
- remove rails 5.2 deprecation: _Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -e option instead._
- allow to set capistrano role to select server for remote console (#33)
- allow to set shell used on server (#31)
- [add rails:c alias to rails:console](https://gitlab.com/ydkn/capistrano-rails-console/issues/36)
## [2.2.1] - 2017-09-04
### Added
- [add rails:db alias to rails:dbconsole](https://gitlab.com/ydkn/capistrano-rails-console/merge_requests/32)
## [2.2.0] - 2016-10-25
### Added
- support for rbenv and chruby
## [2.1.1] - 2016-10-04
### Added
- use password from database.yml for dbconsole
## 2.1.0 (2016-09-23)
### Feature
- add support for `rails dbconsole`
## [2.1.0] - 2016-09-23
### Fixed
- revert unintentional change when the gem is required
### Added
- add support for `rails dbconsole`
## 2.0.0 (2016-09-16)
## [2.0.0] - 2016-09-16
### Changed
- switched connection part to _sshkit-interactive_
- allow setting rails environment separately from deployment environment
- allow setting user to run rails console separately from ssh user
## 1.0.2 (2015-12-06)
## [1.0.2] - 2015-12-06
### Fixed
- works with sshkit 1.8
## 1.0.1 (2015-11-12)
## [1.0.1] - 2015-11-12
### Fixed
- setting ssh hostname through `ssh_options`
- use login shell
### Feature
### Added
- log ssh command before it is being executed
## 1.0.0 (2015-08-01)
## [1.0.0] - 2015-08-01
### Fixed
- removed dependency on capistrano-rails gem setting propper rails_env
- setting ssh port through `ssh_options`
- setting ssh user through `ssh_options`
- require a minimum version of 3.1.0 for capistrano (sshkit compatibility)
### Feature
### Added
- support for ssh keys
## 0.5.2 (2015-04-02)
## [0.5.2] - 2015-04-02
### Fixed
- removed rails binary check due to different environments in sshkit and the ssh shellout
## 0.5.1 (2015-04-01)
## [0.5.1] - 2015-04-01
### Fixed
- missing ssh proxy options in console task

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in capistrano-rails-console.gemspec

View File

@ -1,10 +1,3 @@
[![Gem Version](https://img.shields.io/gem/v/capistrano-rails-console.svg)](https://rubygems.org/gems/capistrano-rails-console)
[![Dependencies](https://img.shields.io/gemnasium/ydkn/capistrano-rails-console.svg)](https://gemnasium.com/ydkn/capistrano-rails-console)
[![Code Climate](https://img.shields.io/codeclimate/github/ydkn/capistrano-rails-console.svg)](https://codeclimate.com/github/ydkn/capistrano-rails-console)
[![Join the chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ydkn/capistrano-rails-console)
# Capistrano::Rails::Console
Remote rails console and dbconsole for capistrano.
@ -29,6 +22,11 @@ Or install it yourself as:
## Usage
You should ensure there is a `rails` binstub in the `current/bin` directory on the server otherwise
this gem won't work (because rails itself won't work).
If you experience any problems please verify that manually running `rails console` on the server does work.
If it doesn't you are deploying your rails application wrong (check [#18](https://gitlab.com/ydkn/capistrano-rails-console/issues/18) or [#26](https://gitlab.com/ydkn/capistrano-rails-console/issues/26) for details)!
Require in `Capfile` to use the default task:
```ruby
@ -38,6 +36,7 @@ require 'capistrano/rails/console'
Run a remote rails console with:
$ cap production rails:console
$ cap production rails:c
You can also start a sandbox session:
@ -46,6 +45,8 @@ You can also start a sandbox session:
Or run a dbconsole:
$ cap production rails:dbconsole
$ cap production rails:db
## Options
@ -62,10 +63,22 @@ set :console_user, :appuser # run rails console as appuser through sudo
set :console_user, nil # explicitly disable switching user through sudo
```
### Role
```ruby
set :console_role, :app # start remote console on primary server for this role
```
### Shell
```ruby
set :console_shell, '/bin/bash' # select shell to be used on server in case you experience problems (see #31)
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ydkn/capistrano-rails-console.
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/ydkn/capistrano-rails-console.
## License

View File

@ -1 +1,3 @@
require "bundler/gem_tasks"
# frozen_string_literal: true
require 'bundler/gem_tasks'

View File

@ -1,5 +1,6 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'capistrano/rails/console/version'
@ -8,19 +9,21 @@ Gem::Specification.new do |spec|
spec.version = Capistrano::Rails::Console::VERSION
spec.authors = ['Florian Schwab']
spec.email = ['me@ydkn.de']
spec.description = %q{Remote rails console for capistrano}
spec.summary = %q{Remote rails console for capistrano}
spec.homepage = 'https://github.com/ydkn/capistrano-rails-console'
spec.description = 'Remote rails console for capistrano'
spec.summary = 'Remote rails console for capistrano'
spec.homepage = 'https://gitlab.com/ydkn/capistrano-rails-console'
spec.license = 'MIT'
spec.files = `git ls-files`.split($/)
spec.files = `git ls-files`.split("\n")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.add_dependency 'capistrano', '>= 3.5.0', '< 4.0.0'
spec.add_dependency 'sshkit-interactive', '~> 0.2.0'
spec.add_dependency 'sshkit-interactive', '~> 0.3.0'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-performance'
end

View File

@ -0,0 +1 @@
# frozen_string_literal: true

View File

@ -1,4 +1,6 @@
# frozen_string_literal: true
require 'sshkit/interactive'
require 'capistrano/rails/console/version'
load File.expand_path('../console/tasks.cap', __FILE__)
load File.expand_path('console/tasks.cap', __dir__)

View File

@ -1,24 +1,31 @@
# frozen_string_literal: true
namespace :load do
task :defaults do
# Add rails to rvm_map_bins
set :rvm_map_bins, fetch(:rvm_map_bins, []).push(:rails)
# Add rails to RVM, Rbenv and Chruby bins
%i[rvm_map_bins rbenv_map_bins chruby_map_bins].each do |bins_var|
bins = fetch(bins_var, [])
set bins_var, bins.push('rails') unless bins.include?('rails')
end
# Default values
set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) }
set :console_user, -> { fetch(:app_user, nil) }
set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) }
set :console_user, -> { fetch(:app_user, nil) }
set :console_role, :app
set :console_shell, nil
end
end
namespace :rails do
desc 'Interact with a remote rails console'
task :console do
args = []
args = []
args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s')
run_interactively primary(:app) do
run_interactively primary(fetch(:console_role)), shell: fetch(:console_shell) do
within current_path do
as user: fetch(:console_user) do
execute(:rails, :console, fetch(:console_env), *args)
execute(:rails, :console, '-e', fetch(:console_env), *args)
end
end
end
@ -26,7 +33,7 @@ namespace :rails do
desc 'Interact with a remote rails dbconsole'
task :dbconsole do
run_interactively primary(:app) do
run_interactively primary(fetch(:console_role)), shell: fetch(:console_shell) do
within current_path do
as user: fetch(:console_user) do
execute(:rails, :dbconsole, '-p', '-e', fetch(:console_env))
@ -34,4 +41,7 @@ namespace :rails do
end
end
end
task c: :console
task db: :dbconsole
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Capistrano
module Capistrano
# Rails
@ -5,7 +7,7 @@ module Capistrano
# Console
module Console
# Gem version
VERSION = '2.1.1'
VERSION = '2.3.0'
end
end
end