Compare commits
32 Commits
Author | SHA1 | Date |
---|---|---|
Florian Schwab | aa4a03bdf2 | |
Florian Schwab | 1fd05219ce | |
Florian Schwab | 9501f25ebe | |
Florian Schwab | c658715d28 | |
Florian Schwab | afccfdd379 | |
Florian Schwab | 2fecb87e89 | |
Florian Schwab | 42cd9edc96 | |
Florian Schwab | 92831fe312 | |
Florian Schwab | 663a7cd563 | |
Florian Schwab | cb1e30b515 | |
Florian Schwab | c26464291b | |
Florian Schwab | 11b0448c02 | |
Florian Schwab | 9d3ade7840 | |
Florian Schwab | a14cc3660c | |
Florian Schwab | 99743c0ac3 | |
Florian Schwab | 6a983cd78e | |
Florian Schwab | ccd2d0419c | |
Florian Schwab | 33ad883cde | |
Florian Schwab | fb9a04135a | |
Andrew Babichev | f05245707f | |
Florian Schwab | dab5836816 | |
Florian Schwab | cef3fa0f87 | |
Florian Schwab | 0ded7fe4ef | |
Florian Schwab | b9766d7a2d | |
Florian Schwab | 499761d84a | |
Hector Parra | 226f6dbed5 | |
Florian Schwab | b33da0ee23 | |
Florian Schwab | 4b1a0f7ba7 | |
Florian Schwab | 468750c240 | |
Florian Schwab | 77a45cf3eb | |
Florian Schwab | 5524c3a4e6 | |
Florian Schwab | 1b1bfa03a7 |
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,12 @@
|
|||
require:
|
||||
- rubocop-performance
|
||||
|
||||
AllCops:
|
||||
TargetRubyVersion: 2.4
|
||||
|
||||
Naming/FileName:
|
||||
Exclude:
|
||||
- 'lib/capistrano-rails-console.rb'
|
||||
|
||||
Metrics/LineLength:
|
||||
Max: 120
|
53
CHANGELOG.md
53
CHANGELOG.md
|
@ -1,37 +1,66 @@
|
|||
# Change Log
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 2.0.0 (2016-09-16)
|
||||
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
|
||||
### Fixed
|
||||
- revert unintentional change when the gem is required
|
||||
### Added
|
||||
- add support for `rails dbconsole`
|
||||
|
||||
## [2.0.0] - 2016-09-16
|
||||
### Changed
|
||||
- switched connection part to _sshkit-interactive_
|
||||
- allow setting rails environment separately deployment environment
|
||||
- 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
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in capistrano-rails-console.gemspec
|
||||
|
|
44
README.md
44
README.md
|
@ -1,13 +1,6 @@
|
|||
[![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 for capistrano.
|
||||
Remote rails console and dbconsole for capistrano.
|
||||
|
||||
|
||||
## Installation
|
||||
|
@ -15,7 +8,7 @@ Remote rails console for capistrano.
|
|||
Add this line to your application's Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'capistrano-rails-console'
|
||||
gem 'capistrano-rails-console', require: false
|
||||
```
|
||||
|
||||
And then execute:
|
||||
|
@ -29,38 +22,63 @@ 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
|
||||
require 'capistrano/rails/console'
|
||||
```
|
||||
|
||||
This will add a task `rails:console`:
|
||||
Run a remote rails console with:
|
||||
|
||||
$ cap production rails:console
|
||||
$ cap production rails:c
|
||||
|
||||
You can also start a sandbox session:
|
||||
|
||||
$ cap production rails:console sandbox=1
|
||||
|
||||
Or run a dbconsole:
|
||||
|
||||
$ cap production rails:dbconsole
|
||||
$ cap production rails:db
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
### Rails environment
|
||||
|
||||
```ruby
|
||||
set :console_env, :production
|
||||
set :console_env, :production # use different environment than deployment environment (rails_env)
|
||||
```
|
||||
|
||||
### User
|
||||
|
||||
```ruby
|
||||
set :console_user, :appuser
|
||||
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
|
||||
|
|
4
Rakefile
4
Rakefile
|
@ -1 +1,3 @@
|
|||
require "bundler/gem_tasks"
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bundler/gem_tasks'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
require 'capistrano/rails/console'
|
||||
# frozen_string_literal: true
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'sshkit/interactive'
|
||||
require 'capistrano/rails/console/version'
|
||||
require 'capistrano/rails/console/remote'
|
||||
|
||||
load File.expand_path('console/tasks.cap', __dir__)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
require 'sshkit/interactive'
|
||||
|
||||
load File.expand_path('../tasks/remote.cap', __FILE__)
|
|
@ -0,0 +1,47 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
namespace :load do
|
||||
task :defaults do
|
||||
# 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_role, :app
|
||||
set :console_shell, nil
|
||||
end
|
||||
end
|
||||
|
||||
namespace :rails do
|
||||
desc 'Interact with a remote rails console'
|
||||
task :console do
|
||||
args = []
|
||||
args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s')
|
||||
|
||||
run_interactively primary(fetch(:console_role)), shell: fetch(:console_shell) do
|
||||
within current_path do
|
||||
as user: fetch(:console_user) do
|
||||
execute(:rails, :console, '-e', fetch(:console_env), *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Interact with a remote rails dbconsole'
|
||||
task :dbconsole 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))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task c: :console
|
||||
task db: :dbconsole
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
namespace :load do
|
||||
task :defaults do
|
||||
# Add rails to rvm_map_bins
|
||||
set :rvm_map_bins, fetch(:rvm_map_bins, []).push(:rails)
|
||||
|
||||
# Default values
|
||||
set :console_env, -> { fetch(:rails_env, fetch(:stage, 'production')) }
|
||||
set :console_user, -> { fetch(:app_user, nil) }
|
||||
end
|
||||
end
|
||||
|
||||
namespace :rails do
|
||||
desc 'Interact with a remote rails console'
|
||||
task :console do
|
||||
args = []
|
||||
args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s')
|
||||
|
||||
run_interactively primary(:app) do
|
||||
within current_path do
|
||||
as user: fetch(:console_user) do
|
||||
execute(:rails, :console, fetch(:console_env), *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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.0.0'
|
||||
VERSION = '2.3.0'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue