geordi 4.1.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af11b387f28e87fc2cb89172b1ea8fdcd87dc4bc62697c18ba4a7cc8ddada28
4
- data.tar.gz: c0612fe6e8f266a3b5e5a467018b5f6e484224944057ddd323c9162a0b64d858
3
+ metadata.gz: 4359df61d9901b0d3091ef950530212fb9ba92847425d136a42c4668d6745462
4
+ data.tar.gz: c6cf00413126337330997068a59f097f226cdc41f9feb97d8523996d77ceeba5
5
5
  SHA512:
6
- metadata.gz: e96089335890efaf9e8ea9a0cabea1c4a6447e363513f61fa2e2fe55f43637ca24906fd3732fd3eb0b5adb752bd2a752a263a0be772bedba1b7115e69425b5d2
7
- data.tar.gz: bad860e3b8a14d06970351213fda638e2b853dfbf107ea6b6f4e018cd2ecdbb767848a2ebdec34757f3c5a9d47e8a2a3181ac40c729b1b3a9cbb26e62aaf1613
6
+ metadata.gz: 6a2b44bbe812e2a20bd2002ee64f3925108203f188d88e7da0f590cf2b7d2f4e01c744525c778cce47f6e1990ec44b2df65a95adaaa15cb4a6e2d3a8167ceddb
7
+ data.tar.gz: 0f6441323fc798aba02f8d6947a803504e9bb11d3714001e1840959a90cf3763e590f45e112d94b6494996f78101bd73e5a7fb62440359c9c9b402dd1b9bc2a9
@@ -0,0 +1,48 @@
1
+ name: Tests
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ branches:
8
+ - master
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-18.04
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ include:
16
+ - ruby: 2.2.10
17
+ gemfile: Gemfile
18
+ - ruby: 2.3.8
19
+ gemfile: Gemfile
20
+ - ruby: 2.4.10
21
+ gemfile: Gemfile
22
+ - ruby: 2.5.8
23
+ gemfile: Gemfile
24
+ - ruby: 2.6.6
25
+ gemfile: Gemfile
26
+ - ruby: 2.7.2
27
+ gemfile: Gemfile
28
+ env:
29
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - name: Install ruby
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: "${{ matrix.ruby }}"
36
+ - name: Install vncserver
37
+ run: |
38
+ sudo apt-get update
39
+ sudo apt-get install -y tightvncserver
40
+ # Fake required password for vncserver
41
+ mkdir ~/.vnc && touch ~/.vnc/passwd && chmod 700 ~/.vnc/passwd
42
+ - name: Bundle
43
+ run: |
44
+ gem install bundler:1.17.3
45
+ bundle install --no-deployment
46
+ - name: Run tests
47
+ run: bundle exec rake
48
+
@@ -1 +1 @@
1
- 2.5
1
+ 2.5.8
@@ -5,8 +5,44 @@ All notable changes to this project will be documented in this file.
5
5
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## Unreleased
8
+
9
+ ### Compatible changes
10
+
11
+ ### Breaking changes
12
+
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
+
8
24
  ### Compatible changes
25
+ * Switch to tightvncserver to be compatible with Ubuntu 20.04. vnc4server is still supported.
26
+
27
+
28
+ ## 5.0.0 2020-11-25
29
+
9
30
  ### Breaking changes
31
+ * Remove support for Ruby 2.0 and 2.1
32
+
33
+
34
+ ## 4.2.0 2020-10-02
35
+
36
+ ### Compatible changes
37
+ * Add `auto_update_chromedriver` as global setting option to automatically update chromedriver before cucumber
38
+ tests, if Chrome and chromedriver versions don't match.
39
+ * Dump command: Add support for multiple databases (#103 by @kajatiger)
40
+ * Add Ruby 2.7 to list of supported Ruby versions
41
+ * Fix #115: `geordi cucumber --modified` command, that corrupted filenames like:
42
+ ```
43
+ No such file or directory tures/pages.feature
44
+ ```
45
+ * Avoid writing an instance of HighLine::String to Geordi config files (closes #114)
10
46
 
11
47
 
12
48
  ## 4.1.1 2020-08-28
@@ -105,6 +141,9 @@ Don't know how to build task 'db:migrate parallel:prepare'
105
141
  ### Breaking changes
106
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.
107
143
 
144
+ ## 2.12.3
145
+
146
+ * Add `geordi docker` command with support for opening a shell for dockerized dev environments.
108
147
 
109
148
  ## 2.11.0 2020-05-04
110
149
 
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source 'http://rubygems.org'
3
3
  # Specify your gem's dependencies in geordi.gemspec
4
4
  gemspec
5
5
 
6
- gem 'aruba'
6
+ gem 'aruba', '< 1' # Drops support for Ruby 2.2-
7
+ gem 'rake', '< 13' # Drops support for Ruby 2.1
7
8
  gem 'rspec-mocks'
8
9
  gem 'highline'
9
10
  gem 'parallel_tests'
@@ -1,76 +1,93 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (4.1.1)
4
+ geordi (5.2.0)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- addressable (2.3.8)
11
- aruba (0.6.2)
12
- childprocess (>= 0.3.6)
13
- cucumber (>= 1.1.1)
14
- rspec-expectations (>= 2.7.0)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ aruba (0.14.14)
13
+ childprocess (>= 0.6.3, < 4.0.0)
14
+ contracts (~> 0.9)
15
+ cucumber (>= 1.3.19)
16
+ ffi (~> 1.9)
17
+ rspec-expectations (>= 2.99)
18
+ thor (>= 0.19, < 2.0)
15
19
  axiom-types (0.1.1)
16
20
  descendants_tracker (~> 0.0.4)
17
21
  ice_nine (~> 0.11.0)
18
22
  thread_safe (~> 0.3, >= 0.3.1)
19
- builder (3.2.3)
23
+ backports (3.18.2)
24
+ builder (3.2.4)
20
25
  childprocess (1.0.1)
21
26
  rake (< 13.0)
22
- coderay (1.1.2)
27
+ coderay (1.1.3)
23
28
  coercible (1.0.0)
24
29
  descendants_tracker (~> 0.0.1)
25
- cucumber (1.3.20)
30
+ contracts (0.16.0)
31
+ cucumber (3.2.0)
26
32
  builder (>= 2.1.2)
27
- diff-lcs (>= 1.1.3)
28
- gherkin (~> 2.12)
33
+ cucumber-core (~> 3.2.0)
34
+ cucumber-expressions (~> 6.0.1)
35
+ cucumber-wire (~> 0.0.1)
36
+ diff-lcs (~> 1.3)
37
+ gherkin (~> 5.1.0)
29
38
  multi_json (>= 1.7.5, < 2.0)
30
39
  multi_test (>= 0.1.2)
40
+ cucumber-core (3.2.1)
41
+ backports (>= 3.8.0)
42
+ cucumber-tag_expressions (~> 1.1.0)
43
+ gherkin (~> 5.0)
44
+ cucumber-expressions (6.0.1)
45
+ cucumber-tag_expressions (1.1.1)
46
+ cucumber-wire (0.0.1)
31
47
  declarative (0.0.10)
32
48
  declarative-option (0.1.0)
33
49
  descendants_tracker (0.0.4)
34
50
  thread_safe (~> 0.3, >= 0.3.1)
35
- diff-lcs (1.2.5)
51
+ diff-lcs (1.4.4)
36
52
  equalizer (0.0.11)
37
- excon (0.73.0)
53
+ excon (0.78.0)
38
54
  faraday (0.17.3)
39
55
  multipart-post (>= 1.2, < 3)
40
56
  faraday_middleware (0.14.0)
41
57
  faraday (>= 0.7.4, < 1.0)
42
- gherkin (2.12.2)
43
- multi_json (~> 1.3)
44
- highline (1.6.21)
58
+ ffi (1.12.2)
59
+ gherkin (5.1.0)
60
+ highline (2.0.3)
45
61
  ice_nine (0.11.2)
46
62
  launchy (2.4.3)
47
63
  addressable (~> 2.3)
48
64
  method_source (1.0.0)
49
- mimemagic (0.3.4)
50
- multi_json (1.13.1)
65
+ mimemagic (0.3.5)
66
+ multi_json (1.15.0)
51
67
  multi_test (0.1.2)
52
68
  multipart-post (2.1.1)
53
- parallel (0.5.16)
54
- parallel_tests (0.6.18)
69
+ parallel (1.19.2)
70
+ parallel_tests (2.32.0)
55
71
  parallel
56
72
  pry (0.13.1)
57
73
  coderay (~> 1.1)
58
74
  method_source (~> 1.0)
59
- rake (10.5.0)
75
+ public_suffix (3.1.1)
76
+ rake (12.3.3)
60
77
  representable (3.0.4)
61
78
  declarative (< 0.1.0)
62
79
  declarative-option (< 0.2.0)
63
80
  uber (< 0.2.0)
64
- rspec-expectations (3.4.0)
81
+ rspec-expectations (3.10.0)
65
82
  diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.4.0)
67
- rspec-mocks (3.4.1)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-mocks (3.10.0)
68
85
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.4.0)
70
- rspec-support (3.4.1)
86
+ rspec-support (~> 3.10.0)
87
+ rspec-support (3.10.0)
71
88
  thor (1.0.1)
72
89
  thread_safe (0.3.6)
73
- tracker_api (1.10.0)
90
+ tracker_api (1.11.0)
74
91
  addressable
75
92
  equalizer
76
93
  excon
@@ -91,12 +108,13 @@ PLATFORMS
91
108
  ruby
92
109
 
93
110
  DEPENDENCIES
94
- aruba
111
+ aruba (< 1)
95
112
  geordi!
96
113
  highline
97
114
  launchy
98
115
  parallel_tests
99
116
  pry
117
+ rake (< 13)
100
118
  rspec-mocks
101
119
  tracker_api
102
120
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Geordi [![Build Status](https://travis-ci.org/makandra/geordi.svg?branch=master)](https://travis-ci.org/makandra/geordi)
1
+ Geordi [![Tests](https://github.com/makandra/geordi/workflows/Tests/badge.svg)](https://github.com/makandra/geordi/actions)
2
2
  ======
3
3
 
4
4
  Geordi is a collection of command line tools we use in our daily work with
@@ -39,6 +39,13 @@ Example: `geordi chromedriver_update`
39
39
  This command will find and install the matching chromedriver for the currently
40
40
  installed Chrome.
41
41
 
42
+ Setting `auto_update_chromedriver` to `true` in your global Geordi config file
43
+ (`~/.config/geordi/global.yml`), will automatically update chromedriver before
44
+ cucumber tests, in case Chrome and chromedriver versions don't match
45
+
46
+ **Options**
47
+ - `[--quiet-if-matching], [--no-quiet-if-matching]`: Suppress notification if chromedriver and chrome versions match
48
+
42
49
 
43
50
  ### `geordi clean`
44
51
  Remove unneeded files from the current directory.
@@ -150,6 +157,24 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
150
157
  - `-c, [--current-branch], [--no-current-branch]`: Set DEPLOY_BRANCH to the current branch during deploy
151
158
 
152
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
+
153
178
  ### `geordi drop-databases`
154
179
  Interactively delete local databases.
155
180
 
@@ -184,8 +209,15 @@ specified target's database and downloads it to `tmp/`.
184
209
  `geordi dump staging -l` (with a Capistrano deploy target and the `--load`
185
210
  option) sources the dump into the development database after downloading it.
186
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
+
187
218
  **Options**
188
219
  - `-l, [--load=[DUMP_FILE]]`: Load a dump
220
+ - `-d, [--database=NAME]`: Database name, if there are multiple databases
189
221
 
190
222
 
191
223
  ### `geordi firefox COMMAND`
@@ -369,7 +401,9 @@ Stores a timestamped database dump for the given Rails environment in `~/dumps`:
369
401
 
370
402
  dumple development
371
403
 
372
- See http://makandracards.com/makandra/1008-dump-your-database-with-dumple
404
+ **Options**
405
+ - `-i`: Print disk usage of `~/dumps`
406
+ - `--compress`: After dumping, run gzip to compress the dump in place
373
407
 
374
408
 
375
409
  launchy_browser
@@ -407,7 +441,7 @@ To try Geordi locally, call it like this:
407
441
 
408
442
  # -I means "add the following directory to load path"
409
443
  ruby -Ilib exe/geordi
410
-
444
+
411
445
  # From another directory
412
446
  ruby -I ../geordi/lib ../geordi/exe/geordi
413
447
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ desc 'Default: Run all tests'
5
5
  task default: :features
6
6
 
7
7
  task :features do
8
- system 'bundle exec cucumber'
8
+ exec 'bundle exec cucumber'
9
9
  end
10
10
 
11
11
  task :readme do
data/exe/dumple CHANGED
@@ -45,9 +45,13 @@ begin
45
45
  end
46
46
 
47
47
  config = YAML::load(ERB.new(File.read(config_path)).result)
48
+ environment, database = ARGV.reject{ |arg| arg[0].chr == '-' }
49
+ environment ||= 'production'
50
+ config = config[environment] or raise "No #{environment} database found.\nUsage: dumple ENVIRONMENT [DATABASE]"
48
51
 
49
- environment = ARGV.reject{ |arg| arg[0].chr == '-' }.first || 'production'
50
- config = config[environment] or raise "No #{environment} database found.\nUsage: dumple ENVIRONMENT"
52
+ if database
53
+ config = config[database] or raise %(Unknown #{environment} database "#{database}")
54
+ end
51
55
 
52
56
  dump_dir = "#{ENV['HOME']}/dumps"
53
57
  unless File.directory?(dump_dir)
@@ -61,7 +65,8 @@ begin
61
65
  dump_path = "#{dump_dir}/#{config['database']}_#{Time.now.strftime("%Y%m%d_%H%M%S")}.dump"
62
66
  end
63
67
 
64
- puts "> Dumping database for \"#{environment}\" environment ..."
68
+ given_database = database ? %(#{database} ) : ""
69
+ puts "> Dumping #{given_database}database for \"#{environment}\" environment ..."
65
70
 
66
71
  host = config['host']
67
72
  port = config['port']
@@ -90,7 +95,7 @@ begin
90
95
  command << " --port=#{port}" if port
91
96
  command
92
97
  else
93
- raise "Adapter \"#{config['adapter']} is not supported"
98
+ raise "Adapter \"#{config['adapter']}\" is not supported"
94
99
  end
95
100
  success = system(dump_command)
96
101
  success or raise "Creating the dump failed"
data/exe/geordi CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
3
5
  require 'geordi/util'
4
6
 
5
7
  Geordi::Util.installing_missing_gems do
@@ -5,19 +5,19 @@ require 'geordi/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'geordi'
7
7
  spec.version = Geordi::VERSION
8
- spec.required_ruby_version = '>= 2.0.0'
8
+ spec.required_ruby_version = '>= 2.2.0'
9
9
  spec.authors = ['Henning Koch']
10
10
  spec.email = ['henning.koch@makandra.de']
11
11
 
12
12
  spec.summary = 'Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.'
13
13
  spec.description = 'Collection of command line tools we use in our daily work with Ruby, Rails and Linux at makandra.'
14
- spec.homepage = 'http://makandra.com'
14
+ spec.homepage = 'https://makandra.com'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  # Specify which files should be added to the gem when it is released.
18
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
19
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
21
21
  end
22
22
  spec.bindir = 'exe'
23
23
  spec.executables = spec.files.grep(%r(^exe/)) { |f| File.basename(f) }
@@ -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
- * Binary `geordi` installed
30
- * Geordi 4.0.0 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
@@ -5,12 +5,12 @@ require 'tempfile'
5
5
  module Geordi
6
6
  class ChromedriverUpdater
7
7
 
8
- def run
8
+ def run(options)
9
9
  chrome_version = determine_chrome_version
10
10
  chromedriver_version = determine_chromedriver_version
11
11
 
12
12
  if skip_update?(chrome_version, chromedriver_version)
13
- Interaction.warn("No update required, you are using for both executables the same version #{chrome_version}!")
13
+ Interaction.note("No update required, you are using for both executables the same version #{chrome_version}!") unless options[:quiet_if_matching]
14
14
  else
15
15
  chromedriver_zip = download_chromedriver(chrome_version)
16
16
  unzip(chromedriver_zip, File.expand_path('~/bin'))
@@ -23,26 +23,24 @@ def _setup_vnc
23
23
  Interaction.success 'It appears you already have a VNC server installed. Good job!'
24
24
  else
25
25
  puts 'Please run:'
26
- Interaction.note_cmd 'sudo apt-get install vnc4server'
26
+ Interaction.note_cmd 'sudo apt-get install tightvncserver'
27
+ puts 'In case this package is not available, you may try vnc4server instead.'
27
28
  Interaction.prompt 'Continue ...'
28
29
 
29
30
  puts
31
+
30
32
  Interaction.note 'We will now set a password for your VNC server.'
31
33
  puts Util.strip_heredoc <<-TEXT
32
- When running our cucumber script, you will not actually need this
33
- password, and there is no security risk. However, if you start a vncserver
34
- without our cucumber script, a user with your password can connect to
35
- your machine.
34
+ When running our cucumber script, this password will be used while also
35
+ restricting access to the local machine. However, if you start a vncserver
36
+ without our cucumber script, keep in mind that a user with this password
37
+ can connect to your machine.
36
38
 
37
39
  TEXT
38
40
  puts 'Please run:'
39
- Interaction.note_cmd 'vncserver :20'
41
+ Interaction.note_cmd 'vncpasswd'
40
42
  Interaction.warn 'Enter a secure password!'
41
43
  Interaction.prompt 'Continue ...'
42
-
43
- puts 'Now stop the server again. Please run:'
44
- Interaction.note_cmd 'vncserver -kill :20'
45
- Interaction.prompt 'Continue ...'
46
44
  end
47
45
 
48
46
  Interaction.announce 'Setup VNC viewer'
@@ -4,10 +4,17 @@ Example: `geordi chromedriver_update`
4
4
 
5
5
  This command will find and install the matching chromedriver for the currently
6
6
  installed Chrome.
7
+
8
+ Setting `auto_update_chromedriver` to `true` in your global Geordi config file
9
+ (`~/.config/geordi/global.yml`), will automatically update chromedriver before
10
+ cucumber tests, in case Chrome and chromedriver versions don't match
7
11
  LONGDESC
8
12
 
13
+ option :quiet_if_matching, type: :boolean, default: false,
14
+ desc: 'Suppress notification if chromedriver and chrome versions match'
15
+
9
16
  def chromedriver_update
10
17
  require 'geordi/chromedriver_updater'
11
18
 
12
- ChromedriverUpdater.new.run
19
+ ChromedriverUpdater.new.run(options)
13
20
  end
@@ -9,10 +9,6 @@ stored in `~/.config/geordi/global.yml`.
9
9
  LONGDESC
10
10
 
11
11
  def commit(*git_args)
12
- raise <<-TEXT if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
13
- Unsupported Ruby Version #{RUBY_VERSION}. `geordi commit` requires Ruby 2.1+.
14
- TEXT
15
-
16
12
  require 'geordi/gitpt'
17
13
  Gitpt.new.run(git_args)
18
14
  end
@@ -7,7 +7,7 @@ def create_database_yml
7
7
  Interaction.announce 'Creating ' + real_yml
8
8
 
9
9
  sample = File.read(sample_yml)
10
- adapter = sample.match(/adapter: (\w+)\n/).captures.first
10
+ adapter = sample.match(/adapter: (\w+)/).captures.first
11
11
 
12
12
  print "Please enter your #{adapter} password: "
13
13
  db_password = STDIN.gets.strip
@@ -37,7 +37,7 @@ def cucumber(*args)
37
37
  if args.empty?
38
38
  # This is not testable as there is no way to stub `git` :(
39
39
  if options.modified?
40
- modified_features = `git status --short`.split($INPUT_RECORD_SEPARATOR).map do |line|
40
+ modified_features = `git status --short`.split("\n").map do |line|
41
41
  indicators = line.slice!(0..2) # Remove leading indicators
42
42
  line if line.include?('.feature') && !indicators.include?('D')
43
43
  end.compact
@@ -45,7 +45,7 @@ def cucumber(*args)
45
45
  end
46
46
 
47
47
  if options.containing
48
- matching_features = `grep -lri '#{options.containing}' --include=*.feature features/`.split($INPUT_RECORD_SEPARATOR)
48
+ matching_features = `grep -lri '#{options.containing}' --include=*.feature features/`.split("\n")
49
49
  args = matching_features.uniq
50
50
  end
51
51
  end
@@ -53,8 +53,13 @@ def cucumber(*args)
53
53
  if File.directory?('features')
54
54
  require 'geordi/cucumber'
55
55
 
56
+ settings = Geordi::Settings.new
57
+
56
58
  invoke_geordi 'bundle_install'
57
59
  invoke_geordi 'yarn_install'
60
+ if settings.auto_update_chromedriver
61
+ invoke_geordi 'chromedriver_update', quiet_if_matching: true
62
+ end
58
63
 
59
64
  cmd_opts, files = args.partition { |f| f.start_with? '-' }
60
65
  cmd_opts << '--format' << 'pretty' << '--backtrace' if options.debug
@@ -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,21 @@ specified target's database and downloads it to `tmp/`.
10
10
 
11
11
  `geordi dump staging -l` (with a Capistrano deploy target and the `--load`
12
12
  option) sources the dump into the development database after downloading it.
13
+
14
+ If you are using multiple databases per environment, pass the database name like this:
15
+
16
+ geordi dump -d primary
17
+
18
+ Loading a dump into one of multiple local databases is not supported yet.
13
19
  DESC
14
20
 
15
21
  option :load, aliases: '-l', type: :string, desc: 'Load a dump', banner: '[DUMP_FILE]'
22
+ option :database, aliases: '-d', type: :string, desc: 'Database name, if there are multiple databases', banner: 'NAME'
16
23
 
17
24
  def dump(target = nil, *_args)
18
25
  require 'geordi/dump_loader'
19
26
  require 'geordi/remote'
27
+ database = options[:database] ? "#{options[:database]} " : ''
20
28
 
21
29
  if target.nil?
22
30
  if options.load
@@ -33,12 +41,14 @@ def dump(target = nil, *_args)
33
41
 
34
42
  else
35
43
  Interaction.announce 'Dumping the development database'
36
- Util.run!('dumple development')
37
- Interaction.success 'Successfully dumped the development database.'
44
+ Util.run!("dumple development #{database}")
45
+ Interaction.success "Successfully dumped the #{database}development database."
38
46
  end
39
47
 
40
48
  else
41
- Interaction.announce 'Dumping the database of ' + target
49
+ database_label = options[:database] ? " (#{database}database)" : ""
50
+
51
+ Interaction.announce "Dumping the database of #{target}#{database_label}"
42
52
  dump_path = Geordi::Remote.new(target).dump(options)
43
53
 
44
54
  if options.load
@@ -47,7 +57,7 @@ def dump(target = nil, *_args)
47
57
  Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
48
58
  loader.load
49
59
 
50
- Interaction.success "Your #{loader.config['database']} database has now the data of #{target}."
60
+ Interaction.success "Your #{loader.config['database']} database has now the data of #{target}#{database_label}."
51
61
  end
52
62
  end
53
63
  end
@@ -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
- invoke_geordi 'migrate'
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
- Interaction.success 'Successfully updated the project.'
28
+ Interaction.success 'Successfully updated the project.'
19
29
 
20
- invoke_geordi 'dump', options.dump, load: true if options.dump
21
- invoke_geordi 'tests' if options.test
30
+ invoke_geordi 'dump', options.dump, load: true if options.dump
31
+ invoke_geordi 'tests' if options.test
32
+ end
22
33
  end
@@ -11,8 +11,10 @@ module Geordi
11
11
  class Cucumber
12
12
 
13
13
  VNC_DISPLAY = ':17'.freeze
14
- VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024".freeze
15
- VNC_VIEWER_COMMAND = "vncviewer #{VNC_DISPLAY}".freeze
14
+ VNC_PASSWORD_FILE = File.absolute_path('~/.vnc/passwd').freeze # default for "vncpasswd"
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
16
18
  VNC_ENV_VARIABLES = %w[DISPLAY BROWSER LAUNCHY_BROWSER].freeze
17
19
 
18
20
  def run(files, cucumber_options, options = {})
@@ -30,10 +32,10 @@ module Geordi
30
32
  system command # Util.run! would reset the Firefox PATH
31
33
  end
32
34
 
33
- def launch_vnc_viewer
35
+ def launch_vnc_viewer(source = VNC_DISPLAY)
34
36
  fork do
35
37
  error = capture_stderr do
36
- system(VNC_VIEWER_COMMAND)
38
+ system("#{VNC_VIEWER_COMMAND} #{source}")
37
39
  end
38
40
  unless $?.success?
39
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
@@ -31,9 +31,10 @@ module Geordi
31
31
  end
32
32
 
33
33
  def dump(options = {})
34
+ database = options[:database] ? " #{options[:database]}" : ''
34
35
  # Generate dump on the server
35
36
  shell options.merge({
36
- remote_command: "dumple #{@config.env} --for_download",
37
+ remote_command: "dumple #{@config.env}#{database} --for_download",
37
38
  })
38
39
 
39
40
  destination_directory = File.join(@config.root, 'tmp')
@@ -45,7 +46,7 @@ module Geordi
45
46
  server = @config.primary_server
46
47
  Util.run!("scp -C #{@config.user(server)}@#{server}:#{REMOTE_DUMP_PATH} #{destination_path}")
47
48
 
48
- Interaction.success "Dumped the #{@stage} database to #{relative_destination}."
49
+ Interaction.success "Dumped the#{database} #{@stage} database to #{relative_destination}."
49
50
 
50
51
  destination_path
51
52
  end
@@ -8,7 +8,7 @@ module Geordi
8
8
  GLOBAL_SETTINGS_FILE_NAME = Util.testing? ? './tmp/global_settings.yml'.freeze : File.join(ENV['HOME'], '.config/geordi/global.yml').freeze
9
9
  LOCAL_SETTINGS_FILE_NAME = Util.testing? ? './tmp/local_settings.yml'.freeze : './.geordi.yml'.freeze
10
10
 
11
- ALLOWED_GLOBAL_SETTINGS = %w[ pivotal_tracker_api_key ].freeze
11
+ ALLOWED_GLOBAL_SETTINGS = %w[ pivotal_tracker_api_key auto_update_chromedriver ].freeze
12
12
  ALLOWED_LOCAL_SETTINGS = %w[ use_vnc pivotal_tracker_project_ids ].freeze
13
13
 
14
14
  def initialize
@@ -25,6 +25,15 @@ module Geordi
25
25
  save_global_settings
26
26
  end
27
27
 
28
+ def auto_update_chromedriver
29
+ @global_settings["auto_update_chromedriver"] || false
30
+ end
31
+
32
+ def auto_update_chromedriver=(value)
33
+ @global_settings['auto_update_chromedriver'] = value
34
+ save_global_settings
35
+ end
36
+
28
37
  # Local settings
29
38
  # They should not be changed by geordi to avoid unexpected diffs, therefore
30
39
  # there are no setters for these settings
@@ -129,7 +138,7 @@ module Geordi
129
138
  def inquire_pt_api_key
130
139
  Geordi::Interaction.warn 'Your settings are missing or invalid.'
131
140
  Geordi::Interaction.warn "Please configure your Pivotal Tracker access."
132
- token = Geordi::Interaction.prompt 'Your API key:'
141
+ token = Geordi::Interaction.prompt('Your API key:').to_s # Just be sure
133
142
  self.pivotal_tracker_api_key = token
134
143
  puts
135
144
 
@@ -43,13 +43,14 @@ module Geordi
43
43
  if command.is_a?(Array)
44
44
  real_command, *arguments = *command
45
45
  command = [real_command.split(' '), arguments].flatten
46
- printable_command = command.join(', ')
46
+ show_command = command
47
47
  else
48
- printable_command = command
48
+ show_command = [command]
49
49
  end
50
50
 
51
51
  if show_cmd
52
- Interaction.note_cmd printable_command
52
+ # Join with spaces for better readability and copy-pasting
53
+ Interaction.note_cmd show_command.join(' ')
53
54
  end
54
55
 
55
56
  if confirm
@@ -57,12 +58,13 @@ module Geordi
57
58
  end
58
59
 
59
60
  if testing?
60
- puts "Util.run! #{printable_command}"
61
+ # Join with commas for precise argument distinction
62
+ puts "Util.run! #{show_command.join(', ')}"
61
63
  else
62
64
  # Remove Geordi's Bundler environment when running commands.
63
65
  success = if !defined?(Bundler)
64
66
  system(*command)
65
- elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.1.2')
67
+ elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.17.3')
66
68
  Bundler.with_original_env do
67
69
  system(*command)
68
70
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '4.1.1'.freeze
2
+ VERSION = '5.2.0'.freeze
3
3
  end
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: 4.1.1
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-08-28 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -36,9 +36,9 @@ executables:
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
+ - ".github/workflows/test.yml"
39
40
  - ".gitignore"
40
41
  - ".ruby-version"
41
- - ".travis.yml"
42
42
  - CHANGELOG.md
43
43
  - Gemfile
44
44
  - Gemfile.lock
@@ -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
@@ -97,13 +99,11 @@ files:
97
99
  - lib/geordi/settings.rb
98
100
  - lib/geordi/util.rb
99
101
  - lib/geordi/version.rb
100
- homepage: http://makandra.com
102
+ homepage: https://makandra.com
101
103
  licenses:
102
104
  - MIT
103
105
  metadata: {}
104
- post_install_message: |
105
- * Binary `geordi` installed
106
- * Geordi 4.0.0 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
@@ -111,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: 2.0.0
114
+ version: 2.2.0
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.0.8
121
+ rubygems_version: 3.1.4
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Collection of command line tools we use in our daily work with Ruby, Rails
@@ -1,23 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - '2.0.0'
5
- - '2.1.10'
6
- - '2.2.10'
7
- - '2.3.8'
8
- - '2.4.10'
9
- - '2.5.8'
10
- - '2.6.6'
11
-
12
- gemfile:
13
- - 'Gemfile'
14
-
15
- dist: trusty
16
-
17
- install:
18
- - gem install bundler:1.17.3
19
- # Replace default Travis CI bundler script with a version that doesn't
20
- # explode when lockfile doesn't match recently bumped version
21
- - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
22
-
23
- script: bundle exec rake