geordi 7.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +0 -4
- data/CHANGELOG.md +26 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +3 -3
- data/README.md +3 -22
- data/geordi.gemspec +1 -0
- data/lib/geordi/commands/branch.rb +3 -1
- data/lib/geordi/dump_loader.rb +8 -1
- data/lib/geordi/gitpt.rb +4 -6
- data/lib/geordi/version.rb +1 -1
- metadata +19 -7
- data/lib/geordi/commands/docker.rb +0 -52
- data/lib/geordi/docker.rb +0 -183
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1060f10e77e6173a1b8d63fd8c2d89579e5be0597a683f5358b01173e4c266de
|
4
|
+
data.tar.gz: 8a44e3cd313e779b84ae9ecfa0f92283f4dd3f45f7525ec0bc298b11a719c389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7793fda9e1494d3b1a2cf50dfa7b8c10ff61e8c7462596828fe6e44721f50dedbfe18ba2a2c2fb4e0b354500de9528f6e948e8716c9c1a31ceb42a49c8ea845
|
7
|
+
data.tar.gz: fedd7f3106bc5283b25b5f4e20fe1eda099d76c7e4b01483362cebde5cca516d559241d976ad51486a3bc71e11df5a3c21d14288c10805ad9af8307f48d7dab3
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,16 +3,41 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
|
6
7
|
## Unreleased
|
7
8
|
|
8
9
|
### Compatible changes
|
10
|
+
|
9
11
|
### Breaking changes
|
10
12
|
|
11
13
|
|
12
|
-
##
|
14
|
+
## 9.0.0 2021-12-02
|
15
|
+
|
16
|
+
### Breaking changes
|
17
|
+
* Remove the `geordi docker` command.
|
18
|
+
|
19
|
+
|
20
|
+
## 8.0.0 2021-11-08
|
13
21
|
|
14
22
|
### Breaking changes
|
23
|
+
* `geordi branch` now checks out new branches from the current branch instead of master. To check out from master, use `geordi branch -m`.
|
24
|
+
|
15
25
|
|
26
|
+
## 7.0.2 2021-10-06
|
27
|
+
|
28
|
+
### Compatible changes
|
29
|
+
* fix `YAML.safe_load` for `psych` >= 4
|
30
|
+
|
31
|
+
|
32
|
+
## 7.0.1 2021-08-13
|
33
|
+
|
34
|
+
### Compatible changes
|
35
|
+
* Fix missing `thor` dependency
|
36
|
+
|
37
|
+
|
38
|
+
## 7.0.0 2021-08-25
|
39
|
+
|
40
|
+
### Breaking changes
|
16
41
|
* Drop support for Ruby < 2.5.0
|
17
42
|
|
18
43
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
geordi (
|
4
|
+
geordi (9.0.0)
|
5
|
+
thor (~> 1)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
@@ -161,8 +162,7 @@ DEPENDENCIES
|
|
161
162
|
pry-byebug
|
162
163
|
rake (< 13)
|
163
164
|
rspec
|
164
|
-
thor (~> 1)
|
165
165
|
tracker_api
|
166
166
|
|
167
167
|
BUNDLED WITH
|
168
|
-
2.2.
|
168
|
+
2.2.27
|
data/README.md
CHANGED
@@ -33,6 +33,9 @@ Example: `geordi branch`
|
|
33
33
|
On the first execution we ask for your Pivotal Tracker API token. It will be
|
34
34
|
stored in `~/.config/geordi/global.yml`.
|
35
35
|
|
36
|
+
**Options**
|
37
|
+
- `-m, [--from-master], [--no-from-master]`: Branch from master instead of the current branch
|
38
|
+
|
36
39
|
|
37
40
|
### `geordi capistrano COMMAND`
|
38
41
|
Run a capistrano command on all deploy targets.
|
@@ -157,28 +160,6 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
|
|
157
160
|
- `-c, [--current-branch], [--no-current-branch]`: Set DEPLOY_BRANCH to the current branch during deploy
|
158
161
|
|
159
162
|
|
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
|
-
|
173
|
-
- `geordi docker shell`
|
174
|
-
Runs the docker service named 'main'.
|
175
|
-
Append `--secondary` to open a second shell in an already running container.
|
176
|
-
|
177
|
-
- `geordi docker vnc`
|
178
|
-
Opens a VNC viewer to connect to the VNC server in the container.
|
179
|
-
Append `--setup` to be guided through the setup of VNC viewer.
|
180
|
-
|
181
|
-
|
182
163
|
### `geordi drop-databases`
|
183
164
|
Interactively delete local databases.
|
184
165
|
|
data/geordi.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r(^exe/)) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
+
spec.add_runtime_dependency 'thor', '~> 1'
|
26
27
|
# Development dependencies are defined in the Gemfile (therefore no `spec.add_development_dependency` directives)
|
27
28
|
|
28
29
|
spec.post_install_message = <<-ATTENTION
|
@@ -6,7 +6,9 @@ On the first execution we ask for your Pivotal Tracker API token. It will be
|
|
6
6
|
stored in `~/.config/geordi/global.yml`.
|
7
7
|
LONGDESC
|
8
8
|
|
9
|
+
option :from_master, aliases: '-m', type: :boolean, desc: 'Branch from master instead of the current branch'
|
10
|
+
|
9
11
|
def branch
|
10
12
|
require 'geordi/gitpt'
|
11
|
-
Gitpt.new.run_branch
|
13
|
+
Gitpt.new.run_branch(from_master: options.from_master)
|
12
14
|
end
|
data/lib/geordi/dump_loader.rb
CHANGED
@@ -14,8 +14,15 @@ module Geordi
|
|
14
14
|
require 'yaml'
|
15
15
|
|
16
16
|
evaluated_config_file = ERB.new(File.read('config/database.yml')).result
|
17
|
+
|
17
18
|
# Allow aliases and a special set of classes like symbols and time objects
|
18
|
-
|
19
|
+
permitted_classes = [Symbol, Time]
|
20
|
+
@config ||= if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
|
21
|
+
YAML.safe_load(evaluated_config_file, permitted_classes: permitted_classes, aliases: true)
|
22
|
+
else
|
23
|
+
YAML.safe_load(evaluated_config_file, permitted_classes, [], true)
|
24
|
+
end
|
25
|
+
|
19
26
|
@config['development']
|
20
27
|
end
|
21
28
|
alias_method :config, :development_database_config
|
data/lib/geordi/gitpt.rb
CHANGED
@@ -26,7 +26,7 @@ module Geordi
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def run_branch
|
29
|
+
def run_branch(from_master: false)
|
30
30
|
story = choose_story || Interaction.fail('No story selected.')
|
31
31
|
|
32
32
|
normalized_story_name = normalize_string(story.name)
|
@@ -50,7 +50,7 @@ module Geordi
|
|
50
50
|
if branch_name.present?
|
51
51
|
checkout_branch branch_name, new_branch: false
|
52
52
|
else
|
53
|
-
checkout_branch new_branch_name, new_branch: true
|
53
|
+
checkout_branch new_branch_name, new_branch: true, from_master: from_master
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -103,8 +103,6 @@ module Geordi
|
|
103
103
|
menu.header = 'Choose a story'
|
104
104
|
|
105
105
|
stories.each do |story|
|
106
|
-
print '.' # Progress
|
107
|
-
|
108
106
|
state = story.current_state
|
109
107
|
owners = story.owners
|
110
108
|
owner_is_me = owners.collect(&:id).include?(my_id)
|
@@ -141,9 +139,9 @@ module Geordi
|
|
141
139
|
HighLine::BOLD + string + HighLine::RESET
|
142
140
|
end
|
143
141
|
|
144
|
-
def checkout_branch(name, new_branch: false)
|
142
|
+
def checkout_branch(name, new_branch: false, from_master: false)
|
145
143
|
if new_branch
|
146
|
-
Util.run! ['git', 'checkout', 'master']
|
144
|
+
Util.run! ['git', 'checkout', 'master'] if from_master
|
147
145
|
Util.run! ['git', 'checkout', '-b', name]
|
148
146
|
else
|
149
147
|
Util.run! ['git', 'checkout', name]
|
data/lib/geordi/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geordi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.0.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: 2021-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
13
27
|
description: Collection of command line tools we use in our daily work with Ruby,
|
14
28
|
Rails and Linux at makandra.
|
15
29
|
email:
|
@@ -53,7 +67,6 @@ files:
|
|
53
67
|
- lib/geordi/commands/cucumber.rb
|
54
68
|
- lib/geordi/commands/delete_dumps.rb
|
55
69
|
- lib/geordi/commands/deploy.rb
|
56
|
-
- lib/geordi/commands/docker.rb
|
57
70
|
- lib/geordi/commands/drop_databases.rb
|
58
71
|
- lib/geordi/commands/dump.rb
|
59
72
|
- lib/geordi/commands/migrate.rb
|
@@ -73,7 +86,6 @@ files:
|
|
73
86
|
- lib/geordi/commands/yarn_install.rb
|
74
87
|
- lib/geordi/cucumber.rb
|
75
88
|
- lib/geordi/db_cleaner.rb
|
76
|
-
- lib/geordi/docker.rb
|
77
89
|
- lib/geordi/dump_loader.rb
|
78
90
|
- lib/geordi/gitpt.rb
|
79
91
|
- lib/geordi/interaction.rb
|
@@ -88,7 +100,7 @@ metadata: {}
|
|
88
100
|
post_install_message: 'Support for sequential running of integration tests tagged
|
89
101
|
with @solo has been dropped.
|
90
102
|
|
91
|
-
|
103
|
+
'
|
92
104
|
rdoc_options: []
|
93
105
|
require_paths:
|
94
106
|
- lib
|
@@ -103,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
115
|
- !ruby/object:Gem::Version
|
104
116
|
version: '0'
|
105
117
|
requirements: []
|
106
|
-
rubygems_version: 3.2.
|
118
|
+
rubygems_version: 3.2.32
|
107
119
|
signing_key:
|
108
120
|
specification_version: 4
|
109
121
|
summary: Collection of command line tools we use in our daily work with Ruby, Rails
|
@@ -1,52 +0,0 @@
|
|
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
|
-
option :setup, default: false, type: :boolean, desc: 'Guide through the setup of VNC'
|
16
|
-
def vnc
|
17
|
-
if options.setup
|
18
|
-
docker.setup_vnc
|
19
|
-
else
|
20
|
-
docker.vnc
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def docker
|
27
|
-
require 'geordi/docker'
|
28
|
-
Geordi::Docker.new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'docker', 'Manage docker containers for the current project'
|
33
|
-
long_desc <<-LONGDESC
|
34
|
-
Manage docker containers to run your project dockerized.
|
35
|
-
|
36
|
-
It expects a `docker-compose.yml` file that specifies all services, and a service
|
37
|
-
named "main" that opens a shell for the project.
|
38
|
-
|
39
|
-
There are three subcommands:
|
40
|
-
|
41
|
-
- `geordi docker setup`
|
42
|
-
Fetches all docker containers.
|
43
|
-
|
44
|
-
- `geordi docker shell`
|
45
|
-
Runs the docker service named 'main'.
|
46
|
-
Append `--secondary` to open a second shell in an already running container.
|
47
|
-
|
48
|
-
- `geordi docker vnc`
|
49
|
-
Opens a VNC viewer to connect to the VNC server in the container.
|
50
|
-
Append `--setup` to be guided through the setup of VNC viewer.
|
51
|
-
LONGDESC
|
52
|
-
subcommand 'docker', DockerCLI
|
data/lib/geordi/docker.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'geordi/interaction'
|
2
|
-
require 'geordi/cucumber'
|
3
|
-
require 'yaml'
|
4
|
-
require 'open3'
|
5
|
-
|
6
|
-
module Geordi
|
7
|
-
class Docker
|
8
|
-
DOCKER_COMPOSE_FILE = 'docker-compose.yml'.freeze
|
9
|
-
|
10
|
-
include Interaction
|
11
|
-
|
12
|
-
def setup
|
13
|
-
check_installation_and_config
|
14
|
-
announce('Fetching containers...')
|
15
|
-
if execute(:system, 'docker-compose', 'pull')
|
16
|
-
success('Fetch successful.')
|
17
|
-
else
|
18
|
-
fail('Fetch failed.')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def shell(options = {})
|
23
|
-
check_installation_and_config
|
24
|
-
if options[:secondary]
|
25
|
-
attach_to_running_shell
|
26
|
-
else
|
27
|
-
run_shell
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def vnc
|
32
|
-
check_installation_and_config
|
33
|
-
launch_vnc_viewer('::5967')
|
34
|
-
end
|
35
|
-
|
36
|
-
def setup_vnc
|
37
|
-
`clear`
|
38
|
-
Interaction.note 'This script will help you install a VNC viewer.'
|
39
|
-
Interaction.note 'Please open a second shell to execute instructions.'
|
40
|
-
Interaction.prompt 'Continue ...'
|
41
|
-
|
42
|
-
Interaction.announce 'Setup VNC viewer'
|
43
|
-
vnc_viewer_installed = system('which vncviewer > /dev/null 2>&1')
|
44
|
-
if vnc_viewer_installed
|
45
|
-
Interaction.success 'It appears you already have a VNC viewer installed. Good job!'
|
46
|
-
else
|
47
|
-
puts 'Please run:'
|
48
|
-
Interaction.note_cmd 'sudo apt-get install xtightvncviewer'
|
49
|
-
Interaction.prompt 'Continue ...'
|
50
|
-
end
|
51
|
-
|
52
|
-
puts
|
53
|
-
puts <<~TEXT
|
54
|
-
Done. You can view the VNC window with `geordi docker vnc`.
|
55
|
-
TEXT
|
56
|
-
|
57
|
-
Interaction.success 'Happy cuking!'
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def launch_vnc_viewer(source)
|
63
|
-
fail('VNC viewer not found. Install it with `geordi docker vnc --setup`.') unless command_exists?('vncviewer')
|
64
|
-
|
65
|
-
fork do
|
66
|
-
error = capture_stderr do
|
67
|
-
system("vncviewer #{source}")
|
68
|
-
end
|
69
|
-
unless $?.success?
|
70
|
-
if $?.exitstatus == 127
|
71
|
-
fail('VNC viewer not found. Install it with `geordi docker vnc --setup`.')
|
72
|
-
else
|
73
|
-
fail("VNC viewer could not be opened: #{error}")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
exit 0
|
78
|
-
end
|
79
|
-
|
80
|
-
def attach_to_running_shell
|
81
|
-
# The command line output of docker-compose ps changes depending on the container name length, this is
|
82
|
-
# caused by the varying terminal length and results in the longer outputs, e.g the container name and id
|
83
|
-
# to be cut after x characters and the rest being placed in the line below.
|
84
|
-
|
85
|
-
stdout_str, _error_str = execute(:capture, {'COLUMNS' => '400'}, 'docker-compose ps')
|
86
|
-
running_containers = stdout_str.split("\n")
|
87
|
-
if (main_container_line = running_containers.grep(/_main_run/).first)
|
88
|
-
container_name = main_container_line.split(' ').first
|
89
|
-
execute(:exec, 'docker', 'exec', '-it', container_name, 'bash')
|
90
|
-
else
|
91
|
-
fail('Could not find a running shell. Start without --secondary first.')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def run_shell
|
96
|
-
command = [:system, 'docker-compose', 'run', '--service-ports']
|
97
|
-
command += ssh_agent_forward
|
98
|
-
command += ['main']
|
99
|
-
execute(*command)
|
100
|
-
execute(:system, 'docker-compose', 'stop')
|
101
|
-
end
|
102
|
-
|
103
|
-
def execute(kind, *args)
|
104
|
-
if ENV['GEORDI_TESTING']
|
105
|
-
puts "Stubbed run #{args.join(' ')}"
|
106
|
-
if kind == :` || kind == :capture
|
107
|
-
mock_parse(*args)
|
108
|
-
else
|
109
|
-
mock_run(*args)
|
110
|
-
end
|
111
|
-
else
|
112
|
-
if kind == :capture
|
113
|
-
Open3.capture2(*args)
|
114
|
-
else
|
115
|
-
send(kind, *args)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def mock_run(*args)
|
121
|
-
# exists just to be stubbed in tests
|
122
|
-
true
|
123
|
-
end
|
124
|
-
|
125
|
-
def mock_parse(*args)
|
126
|
-
# exists just to be stubbed in tests
|
127
|
-
'command output'
|
128
|
-
end
|
129
|
-
|
130
|
-
def check_installation_and_config
|
131
|
-
unless command_exists?('docker')
|
132
|
-
fail('You need to install docker first with `sudo apt install docker`. After installation please log out and back in to your system once.')
|
133
|
-
end
|
134
|
-
|
135
|
-
unless command_exists?('docker-compose')
|
136
|
-
fail('You need to install docker-compose first with `sudo apt install docker-compose`.')
|
137
|
-
end
|
138
|
-
|
139
|
-
unless docker_compose_config && (services = docker_compose_config['services']) && services.key?('main')
|
140
|
-
fail('Your project does not seem to be properly set up. Expected to find a docker-compose.yml which defines a service named "main".')
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def command_exists?(command)
|
145
|
-
execute(:system, "which #{command} > /dev/null")
|
146
|
-
end
|
147
|
-
|
148
|
-
def docker_compose_config
|
149
|
-
@docker_compose_config ||= if File.exists?(DOCKER_COMPOSE_FILE)
|
150
|
-
if YAML.respond_to?(:safe_load)
|
151
|
-
YAML.safe_load(File.read(DOCKER_COMPOSE_FILE))
|
152
|
-
else
|
153
|
-
YAML.load(File.read(DOCKER_COMPOSE_FILE))
|
154
|
-
end
|
155
|
-
end
|
156
|
-
rescue
|
157
|
-
false
|
158
|
-
end
|
159
|
-
|
160
|
-
def ssh_agent_forward
|
161
|
-
if (auth_sock = ENV['SSH_AUTH_SOCK'])
|
162
|
-
dirname = File.dirname(auth_sock)
|
163
|
-
['-v', "#{dirname}:#{dirname}", '-e', "SSH_AUTH_SOCK=#{auth_sock}"]
|
164
|
-
else
|
165
|
-
[]
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def capture_stderr
|
170
|
-
old_stderr = $stderr.dup
|
171
|
-
io = Tempfile.new('cuc')
|
172
|
-
$stderr.reopen(io)
|
173
|
-
yield
|
174
|
-
io.rewind
|
175
|
-
io.read
|
176
|
-
ensure
|
177
|
-
io.close
|
178
|
-
io.unlink
|
179
|
-
$stderr.reopen(old_stderr)
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
end
|