geordi 2.5.0 → 2.6.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/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/geordi/chromedriver_updater.rb +95 -0
- data/lib/geordi/commands/chromedriver_update.rb +22 -0
- data/lib/geordi/commands/delete_dumps.rb +1 -1
- data/lib/geordi/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c2c675109e049fa2e448060119880d0e9efbb42275747e4e7ddce0c205872d3
|
4
|
+
data.tar.gz: 55a314c7beee03d00fdd7499585929df02acf2ed2c3dccafba40e46470182627
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66fc72c66158d5a6c6ed25e9ab41d3c6537fe479fd4d59f3ec61df338963ef139b15ed43d0deb59fe6423b109e0f050a86baa9e5a7b60bf8cfccfecf330450f4
|
7
|
+
data.tar.gz: 8ad6e9b7fd187d4e3668d84c5493b4bb7c6179b6d785ad9217f3e7d8dae3dbd0a700f795cd43d59d816e9379fde6ce972010c626f2bbc9307ecaf2e241cdc8b8
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,14 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
11
11
|
### Breaking changes
|
12
12
|
|
13
13
|
|
14
|
+
## 2.6.0 2019-11-04
|
15
|
+
|
16
|
+
### Compatible changes
|
17
|
+
|
18
|
+
- Added [#73](https://github.com/makandra/geordi/issues/73): New command `chromdriver-update` allows you to update your
|
19
|
+
chromedriver to the newest matching version.
|
20
|
+
|
21
|
+
|
14
22
|
## 2.5.0 2019-10-25
|
15
23
|
|
16
24
|
### Compatible changes
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,15 @@ Run a capistrano command on all deploy targets.
|
|
34
34
|
Example: `geordi capistrano deploy`
|
35
35
|
|
36
36
|
|
37
|
+
### `geordi chromedriver-update`
|
38
|
+
|
39
|
+
Update the chromedriver.
|
40
|
+
|
41
|
+
Example: `geordi chromedriver_update`
|
42
|
+
|
43
|
+
This command will find and install the matching chromedriver for the currently installed Chrome.
|
44
|
+
|
45
|
+
|
37
46
|
### `geordi clean`
|
38
47
|
|
39
48
|
Remove unneeded files from the current directory.
|
@@ -79,7 +88,7 @@ or `-d`.
|
|
79
88
|
e.g. `--format pretty`.
|
80
89
|
|
81
90
|
|
82
|
-
### `geordi
|
91
|
+
### `geordi delete-dumps [DIRECTORY]`
|
83
92
|
|
84
93
|
Delete database dump files (*.dump).
|
85
94
|
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'net/http'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module Geordi
|
6
|
+
class ChromedriverUpdater
|
7
|
+
include Geordi::Interaction
|
8
|
+
|
9
|
+
def run
|
10
|
+
chrome_version = determine_chrome_version
|
11
|
+
chromedriver_version = determine_chromedriver_version
|
12
|
+
|
13
|
+
if skip_update?(chrome_version, chromedriver_version)
|
14
|
+
warn("No update required, you are using for both executables the same version #{chrome_version}!")
|
15
|
+
else
|
16
|
+
chromedriver_zip = download_chromedriver(chrome_version)
|
17
|
+
unzip(chromedriver_zip, File.expand_path('~/bin'))
|
18
|
+
|
19
|
+
chromedriver_zip.unlink
|
20
|
+
|
21
|
+
# We need to determine the version again, as it could be nil in case no chromedriver was installed before
|
22
|
+
note "Chromedriver updated to version #{determine_chromedriver_version}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def determine_chrome_version
|
29
|
+
stdout_str, _error_str, status = Open3.capture3('google-chrome', '--version')
|
30
|
+
chrome_version = if !stdout_str.nil?
|
31
|
+
stdout_str[/\AGoogle Chrome (\d+)/, 1]
|
32
|
+
end
|
33
|
+
|
34
|
+
if !status.success? || chrome_version.nil?
|
35
|
+
fail('Could not determine the current Google Chrome version')
|
36
|
+
else
|
37
|
+
chrome_version.to_i
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def determine_chromedriver_version
|
42
|
+
return unless Open3.capture2('which chromedriver')[1].success?
|
43
|
+
|
44
|
+
stdout_str, _error_str, status = Open3.capture3('chromedriver', '-v')
|
45
|
+
chromedriver_version = if !stdout_str.nil?
|
46
|
+
stdout_str[/\AChromeDriver (\d+)/, 1]
|
47
|
+
end
|
48
|
+
|
49
|
+
if !status.success? || chromedriver_version.nil?
|
50
|
+
fail('Could not determine the current chromedriver version')
|
51
|
+
else
|
52
|
+
chromedriver_version.to_i
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def skip_update?(chrome_version, chromedriver_version)
|
57
|
+
chrome_version == chromedriver_version
|
58
|
+
end
|
59
|
+
|
60
|
+
def download_chromedriver(chrome_version)
|
61
|
+
latest_version = latest_version(chrome_version)
|
62
|
+
|
63
|
+
uri = URI("https://chromedriver.storage.googleapis.com/#{latest_version}/chromedriver_linux64.zip")
|
64
|
+
response = Net::HTTP.get_response(uri)
|
65
|
+
|
66
|
+
if response.is_a?(Net::HTTPSuccess)
|
67
|
+
file = Tempfile.new(['chromedriver', '.zip'])
|
68
|
+
file.write(response.body)
|
69
|
+
|
70
|
+
file
|
71
|
+
else
|
72
|
+
fail("Could not download chromedriver version #{latest_version}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def latest_version(chrome_version)
|
77
|
+
uri = URI("https://chromedriver.storage.googleapis.com/LATEST_RELEASE_#{chrome_version}")
|
78
|
+
response = Net::HTTP.get_response(uri)
|
79
|
+
|
80
|
+
if response.is_a?(Net::HTTPSuccess)
|
81
|
+
response.body.to_s
|
82
|
+
else
|
83
|
+
fail("Could not find the latest version for Google Chrome version #{chrome_version}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def unzip(zip, output_dir)
|
88
|
+
_stdout_str, _error_str, status = Open3.capture3('unzip', '-d', output_dir, '-o', zip.path)
|
89
|
+
|
90
|
+
unless status.success?
|
91
|
+
fail("Could not unzip #{zip.path}")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
desc 'chromedriver-update', 'Update the chromedriver'
|
2
|
+
|
3
|
+
long_desc <<-LONGDESC
|
4
|
+
Example: `geordi chromedriver_update`
|
5
|
+
|
6
|
+
This command will find and install the matching chromedriver for the currently installed Chrome.
|
7
|
+
LONGDESC
|
8
|
+
|
9
|
+
def chromedriver_update
|
10
|
+
require 'geordi/chromedriver_updater'
|
11
|
+
|
12
|
+
# Ruby 1.9.3 introduces #capture3 in open3
|
13
|
+
supported_ruby_version = '1.9.2'
|
14
|
+
|
15
|
+
# We do not want to backport this command to Ruby 1.8.7, a user can just use a newer Ruby version to run it. For all
|
16
|
+
# other commands it still is necessary to have a proper Ruby 1.8.7 support.
|
17
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(supported_ruby_version)
|
18
|
+
raise("Unsupported ruby version #{RUBY_VERSION}, please use at least #{supported_ruby_version} to run this command!")
|
19
|
+
end
|
20
|
+
|
21
|
+
ChromedriverUpdater.new.run
|
22
|
+
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: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -92,11 +92,13 @@ files:
|
|
92
92
|
- lib/geordi.rb
|
93
93
|
- lib/geordi/COMMAND_TEMPLATE
|
94
94
|
- lib/geordi/capistrano_config.rb
|
95
|
+
- lib/geordi/chromedriver_updater.rb
|
95
96
|
- lib/geordi/cli.rb
|
96
97
|
- lib/geordi/commands/_setup_vnc.rb
|
97
98
|
- lib/geordi/commands/apache_site.rb
|
98
99
|
- lib/geordi/commands/bundle_install.rb
|
99
100
|
- lib/geordi/commands/capistrano.rb
|
101
|
+
- lib/geordi/commands/chromedriver_update.rb
|
100
102
|
- lib/geordi/commands/clean.rb
|
101
103
|
- lib/geordi/commands/commit.rb
|
102
104
|
- lib/geordi/commands/console.rb
|