geordi 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/Gemfile.lock +1 -1
- data/README.md +26 -9
- data/exe/geordi +2 -0
- data/geordi.gemspec +2 -4
- data/lib/geordi/commands/docker.rb +44 -0
- data/lib/geordi/commands/update.rb +15 -4
- data/lib/geordi/cucumber.rb +5 -4
- data/lib/geordi/docker.rb +116 -0
- data/lib/geordi/util.rb +1 -1
- data/lib/geordi/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4359df61d9901b0d3091ef950530212fb9ba92847425d136a42c4668d6745462
|
4
|
+
data.tar.gz: c6cf00413126337330997068a59f097f226cdc41f9feb97d8523996d77ceeba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2b44bbe812e2a20bd2002ee64f3925108203f188d88e7da0f590cf2b7d2f4e01c744525c778cce47f6e1990ec44b2df65a95adaaa15cb4a6e2d3a8167ceddb
|
7
|
+
data.tar.gz: 0f6441323fc798aba02f8d6947a803504e9bb11d3714001e1840959a90cf3763e590f45e112d94b6494996f78101bd73e5a7fb62440359c9c9b402dd1b9bc2a9
|
data/CHANGELOG.md
CHANGED
@@ -7,11 +7,24 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
9
|
### Compatible changes
|
10
|
-
* Switch to tightvncserver to be compatible with Ubuntu 20.04. vnc4server is still supported.
|
11
10
|
|
12
11
|
### Breaking changes
|
13
12
|
|
14
13
|
|
14
|
+
## 5.2.0 2020-12-14
|
15
|
+
|
16
|
+
### Compatible changes
|
17
|
+
|
18
|
+
* Geordi update will exit with a warning when Ruby version changes during pull.
|
19
|
+
* Add `geordi docker` command with support for opening a shell for dockerized dev environments.
|
20
|
+
|
21
|
+
|
22
|
+
## 5.1.0 2020-12-04
|
23
|
+
|
24
|
+
### Compatible changes
|
25
|
+
* Switch to tightvncserver to be compatible with Ubuntu 20.04. vnc4server is still supported.
|
26
|
+
|
27
|
+
|
15
28
|
## 5.0.0 2020-11-25
|
16
29
|
|
17
30
|
### Breaking changes
|
@@ -128,6 +141,9 @@ Don't know how to build task 'db:migrate parallel:prepare'
|
|
128
141
|
### Breaking changes
|
129
142
|
- Remove support for Ruby 1.8.7 and Ruby 1.9.3. Bug fixes might still be backported to 2.x, but we will not add any features to 2.x anymore. Please consider to upgrade the Ruby version of your project.
|
130
143
|
|
144
|
+
## 2.12.3
|
145
|
+
|
146
|
+
* Add `geordi docker` command with support for opening a shell for dockerized dev environments.
|
131
147
|
|
132
148
|
## 2.11.0 2020-05-04
|
133
149
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -157,6 +157,24 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
|
|
157
157
|
- `-c, [--current-branch], [--no-current-branch]`: Set DEPLOY_BRANCH to the current branch during deploy
|
158
158
|
|
159
159
|
|
160
|
+
### `geordi docker`
|
161
|
+
Manage docker containers for the current project.
|
162
|
+
|
163
|
+
Manage docker containers to run your project dockerized.
|
164
|
+
|
165
|
+
It expects a `docker-compose.yml` file that specifies all services, and a service
|
166
|
+
named "main" that opens a shell for the project.
|
167
|
+
|
168
|
+
There are three subcommands:
|
169
|
+
|
170
|
+
- `geordi docker setup`
|
171
|
+
Fetches all docker containers.
|
172
|
+
- `geordi docker shell`
|
173
|
+
Runs the docker service named 'main'.
|
174
|
+
- `geordi docker vnc`
|
175
|
+
Opens a VNC viewer to connect to the VNC server in the container.
|
176
|
+
|
177
|
+
|
160
178
|
### `geordi drop-databases`
|
161
179
|
Interactively delete local databases.
|
162
180
|
|
@@ -176,18 +194,10 @@ offer to edit the whitelist instead.
|
|
176
194
|
- `[--postgres=PORT_OR_SOCKET]`: Use Postgres port or socket
|
177
195
|
- `[--mysql=PORT_OR_SOCKET]`: Use MySQL/MariaDB port or socket
|
178
196
|
|
197
|
+
|
179
198
|
### `geordi dump [TARGET]`
|
180
199
|
Handle (remote) database dumps.
|
181
200
|
|
182
|
-
If you are using multiple databases per environment, pass the database name like this:
|
183
|
-
|
184
|
-
geordi dump -d primary
|
185
|
-
|
186
|
-
Loading a dump into one of multiple local databases is not supported yet.
|
187
|
-
|
188
|
-
When called with the `--load` option, sources the specified dump into the
|
189
|
-
development database.
|
190
|
-
|
191
201
|
`geordi dump` (without arguments) dumps the development database with `dumple`.
|
192
202
|
|
193
203
|
`geordi dump -l tmp/staging.dump` (with the `--load` option) sources the
|
@@ -199,8 +209,15 @@ specified target's database and downloads it to `tmp/`.
|
|
199
209
|
`geordi dump staging -l` (with a Capistrano deploy target and the `--load`
|
200
210
|
option) sources the dump into the development database after downloading it.
|
201
211
|
|
212
|
+
If you are using multiple databases per environment, pass the database name like this:
|
213
|
+
|
214
|
+
geordi dump -d primary
|
215
|
+
|
216
|
+
Loading a dump into one of multiple local databases is not supported yet.
|
217
|
+
|
202
218
|
**Options**
|
203
219
|
- `-l, [--load=[DUMP_FILE]]`: Load a dump
|
220
|
+
- `-d, [--database=NAME]`: Database name, if there are multiple databases
|
204
221
|
|
205
222
|
|
206
223
|
### `geordi firefox COMMAND`
|
data/exe/geordi
CHANGED
data/geordi.gemspec
CHANGED
@@ -25,8 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_runtime_dependency 'thor', '~> 1'
|
27
27
|
|
28
|
-
spec.post_install_message = <<-ATTENTION
|
29
|
-
|
30
|
-
* Geordi 4 has removed its deprecated executables. If you want to invoke these commands like before, you may create aliases on your machine. For the alias mapping, please refer to https://github.com/makandra/geordi/commit/68fa92acb146ebde3acb92d7b9556bd4eaa2b4ff
|
31
|
-
ATTENTION
|
28
|
+
#spec.post_install_message = <<-ATTENTION
|
29
|
+
#ATTENTION
|
32
30
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class DockerCLI < Thor
|
2
|
+
desc 'setup', 'Setup docker and fetch required docker-container for the current project.'
|
3
|
+
def setup
|
4
|
+
docker.setup
|
5
|
+
end
|
6
|
+
|
7
|
+
desc 'shell', 'Open a shell in the main docker container for the current project.'
|
8
|
+
option :secondary, default: false, type: :boolean
|
9
|
+
map 'shell' => '_shell'
|
10
|
+
def _shell
|
11
|
+
docker.shell(:secondary => options[:secondary])
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'vnc', 'Open a vnc viewer connecting to the docker container.'
|
15
|
+
def vnc
|
16
|
+
docker.vnc
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def docker
|
22
|
+
require 'geordi/docker'
|
23
|
+
Geordi::Docker.new
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'docker', 'Manage docker containers for the current project.'
|
28
|
+
long_desc <<-LONGDESC
|
29
|
+
Manage docker containers to run your project dockerized.
|
30
|
+
|
31
|
+
It expects a `docker-compose.yml` file that specifies all services, and a service
|
32
|
+
named "main" that opens a shell for the project.
|
33
|
+
|
34
|
+
There are three subcommands:
|
35
|
+
|
36
|
+
- `geordi docker setup`
|
37
|
+
Fetches all docker containers.
|
38
|
+
- `geordi docker shell`
|
39
|
+
Runs the docker service named 'main'.
|
40
|
+
- `geordi docker vnc`
|
41
|
+
Opens a VNC viewer to connect to the VNC server in the container.
|
42
|
+
|
43
|
+
LONGDESC
|
44
|
+
subcommand 'docker', DockerCLI
|
@@ -10,13 +10,24 @@ option :dump, type: :string, aliases: '-d', banner: 'TARGET',
|
|
10
10
|
option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
|
11
11
|
|
12
12
|
def update
|
13
|
+
old_ruby_version = File.read('.ruby-version').chomp
|
14
|
+
|
13
15
|
Interaction.announce 'Updating repository'
|
14
16
|
Util.run!('git pull', show_cmd: true)
|
15
17
|
|
16
|
-
|
18
|
+
ruby_version = File.read('.ruby-version').chomp
|
19
|
+
ruby_version_changed = !ruby_version.empty? && (ruby_version != old_ruby_version)
|
20
|
+
|
21
|
+
if ruby_version_changed
|
22
|
+
puts
|
23
|
+
Interaction.warn 'Ruby version changed during git pull. Please run again to use the new version.'
|
24
|
+
exit(1)
|
25
|
+
else
|
26
|
+
invoke_geordi 'migrate'
|
17
27
|
|
18
|
-
|
28
|
+
Interaction.success 'Successfully updated the project.'
|
19
29
|
|
20
|
-
|
21
|
-
|
30
|
+
invoke_geordi 'dump', options.dump, load: true if options.dump
|
31
|
+
invoke_geordi 'tests' if options.test
|
32
|
+
end
|
22
33
|
end
|
data/lib/geordi/cucumber.rb
CHANGED
@@ -12,8 +12,9 @@ module Geordi
|
|
12
12
|
|
13
13
|
VNC_DISPLAY = ':17'.freeze
|
14
14
|
VNC_PASSWORD_FILE = File.absolute_path('~/.vnc/passwd').freeze # default for "vncpasswd"
|
15
|
-
|
16
|
-
|
15
|
+
VNC_SERVER_DEFAULT_OPTIONS = "-localhost -nolisten tcp -geometry 1280x1024 -rfbauth #{VNC_PASSWORD_FILE}".freeze
|
16
|
+
VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} #{ENV.fetch('GEORDI_VNC_OPTIONS', VNC_SERVER_DEFAULT_OPTIONS)}".freeze
|
17
|
+
VNC_VIEWER_COMMAND = "vncviewer -passwd #{VNC_PASSWORD_FILE}".freeze
|
17
18
|
VNC_ENV_VARIABLES = %w[DISPLAY BROWSER LAUNCHY_BROWSER].freeze
|
18
19
|
|
19
20
|
def run(files, cucumber_options, options = {})
|
@@ -31,10 +32,10 @@ module Geordi
|
|
31
32
|
system command # Util.run! would reset the Firefox PATH
|
32
33
|
end
|
33
34
|
|
34
|
-
def launch_vnc_viewer
|
35
|
+
def launch_vnc_viewer(source = VNC_DISPLAY)
|
35
36
|
fork do
|
36
37
|
error = capture_stderr do
|
37
|
-
system(VNC_VIEWER_COMMAND)
|
38
|
+
system("#{VNC_VIEWER_COMMAND} #{source}")
|
38
39
|
end
|
39
40
|
unless $?.success?
|
40
41
|
if $?.exitstatus == 127
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'geordi/interaction'
|
2
|
+
require 'geordi/cucumber'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Geordi
|
6
|
+
class Docker
|
7
|
+
DOCKER_COMPOSE_FILE = 'docker-compose.yml'.freeze
|
8
|
+
|
9
|
+
include Interaction
|
10
|
+
|
11
|
+
def setup
|
12
|
+
check_installation_and_config
|
13
|
+
announce('Fetching containers...')
|
14
|
+
if execute(:system, 'docker-compose', 'pull')
|
15
|
+
success('Fetch successful.')
|
16
|
+
else
|
17
|
+
fail('Fetch failed.')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def shell(options = {})
|
22
|
+
check_installation_and_config
|
23
|
+
if options[:secondary]
|
24
|
+
attach_to_running_shell
|
25
|
+
else
|
26
|
+
run_shell
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def vnc
|
31
|
+
Cucumber.new.launch_vnc_viewer('::5967')
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def attach_to_running_shell
|
37
|
+
running_containers = execute(:`, 'docker-compose ps').split("\n")
|
38
|
+
if (main_container_line = running_containers.grep(/_main_run/).first)
|
39
|
+
container_name = main_container_line.split(' ').first
|
40
|
+
execute(:exec, 'docker', 'exec', '-it', container_name, 'bash')
|
41
|
+
else
|
42
|
+
fail('Could not find a running shell. Start without --secondary first.')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def run_shell
|
47
|
+
command = [:system, 'docker-compose', 'run', '--service-ports']
|
48
|
+
command += ssh_agent_forward
|
49
|
+
command += ['main']
|
50
|
+
execute(*command)
|
51
|
+
execute(:system, 'docker-compose', 'stop')
|
52
|
+
end
|
53
|
+
|
54
|
+
def execute(kind, *args)
|
55
|
+
if ENV['GEORDI_TESTING']
|
56
|
+
puts "Stubbed run #{args.join(' ')}"
|
57
|
+
if kind == :`
|
58
|
+
mock_parse(*args)
|
59
|
+
else
|
60
|
+
mock_run(*args)
|
61
|
+
end
|
62
|
+
else
|
63
|
+
send(kind, *args)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def mock_run(*args)
|
68
|
+
# exists just to be stubbed in tests
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def mock_parse(*args)
|
73
|
+
# exists just to be stubbed in tests
|
74
|
+
'command output'
|
75
|
+
end
|
76
|
+
|
77
|
+
def check_installation_and_config
|
78
|
+
unless command_exists?('docker')
|
79
|
+
fail('You need to install docker first with `sudo apt install docker`. After installation please log out and back in to your system once.')
|
80
|
+
end
|
81
|
+
|
82
|
+
unless command_exists?('docker-compose')
|
83
|
+
fail('You need to install docker-compose first with `sudo apt install docker-compose`.')
|
84
|
+
end
|
85
|
+
|
86
|
+
unless docker_compose_config && (services = docker_compose_config['services']) && services.key?('main')
|
87
|
+
fail('Your project does not seem to be properly set up. Expected to find a docker-compose.yml which defines a service named "main".')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def command_exists?(command)
|
92
|
+
execute(:system, "which #{command} > /dev/null")
|
93
|
+
end
|
94
|
+
|
95
|
+
def docker_compose_config
|
96
|
+
@docker_compose_config ||= if File.exists?(DOCKER_COMPOSE_FILE)
|
97
|
+
if YAML.respond_to?(:safe_load)
|
98
|
+
YAML.safe_load(File.read(DOCKER_COMPOSE_FILE))
|
99
|
+
else
|
100
|
+
YAML.load(File.read(DOCKER_COMPOSE_FILE))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
rescue
|
104
|
+
false
|
105
|
+
end
|
106
|
+
|
107
|
+
def ssh_agent_forward
|
108
|
+
if (auth_sock = ENV['SSH_AUTH_SOCK'])
|
109
|
+
dirname = File.dirname(auth_sock)
|
110
|
+
['-v', "#{dirname}:#{dirname}", '-e', "SSH_AUTH_SOCK=#{auth_sock}"]
|
111
|
+
else
|
112
|
+
[]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/geordi/util.rb
CHANGED
@@ -64,7 +64,7 @@ module Geordi
|
|
64
64
|
# Remove Geordi's Bundler environment when running commands.
|
65
65
|
success = if !defined?(Bundler)
|
66
66
|
system(*command)
|
67
|
-
elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('
|
67
|
+
elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.17.3')
|
68
68
|
Bundler.with_original_env do
|
69
69
|
system(*command)
|
70
70
|
end
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/geordi/commands/cucumber.rb
|
69
69
|
- lib/geordi/commands/delete_dumps.rb
|
70
70
|
- lib/geordi/commands/deploy.rb
|
71
|
+
- lib/geordi/commands/docker.rb
|
71
72
|
- lib/geordi/commands/drop_databases.rb
|
72
73
|
- lib/geordi/commands/dump.rb
|
73
74
|
- lib/geordi/commands/firefox.rb
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- lib/geordi/commands/yarn_install.rb
|
90
91
|
- lib/geordi/cucumber.rb
|
91
92
|
- lib/geordi/db_cleaner.rb
|
93
|
+
- lib/geordi/docker.rb
|
92
94
|
- lib/geordi/dump_loader.rb
|
93
95
|
- lib/geordi/firefox_for_selenium.rb
|
94
96
|
- lib/geordi/gitpt.rb
|
@@ -101,9 +103,7 @@ homepage: https://makandra.com
|
|
101
103
|
licenses:
|
102
104
|
- MIT
|
103
105
|
metadata: {}
|
104
|
-
post_install_message:
|
105
|
-
* Binary `geordi` installed
|
106
|
-
* Geordi 4 has removed its deprecated executables. If you want to invoke these commands like before, you may create aliases on your machine. For the alias mapping, please refer to https://github.com/makandra/geordi/commit/68fa92acb146ebde3acb92d7b9556bd4eaa2b4ff
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|