geordi 3.0.0 → 3.0.1
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 +7 -0
- data/Gemfile.lock +1 -1
- data/lib/geordi/COMMAND_TEMPLATE +2 -3
- data/lib/geordi/chromedriver_updater.rb +7 -8
- data/lib/geordi/cli.rb +0 -1
- data/lib/geordi/commands/_setup_vnc.rb +22 -22
- data/lib/geordi/commands/bundle_install.rb +1 -1
- data/lib/geordi/commands/capistrano.rb +4 -4
- data/lib/geordi/commands/clean.rb +6 -5
- data/lib/geordi/commands/console.rb +2 -2
- data/lib/geordi/commands/create_database_yml.rb +2 -2
- data/lib/geordi/commands/create_databases.rb +1 -1
- data/lib/geordi/commands/cucumber.rb +8 -8
- data/lib/geordi/commands/delete_dumps.rb +5 -5
- data/lib/geordi/commands/deploy.rb +18 -18
- data/lib/geordi/commands/drop_databases.rb +3 -3
- data/lib/geordi/commands/dump.rb +8 -8
- data/lib/geordi/commands/firefox.rb +2 -2
- data/lib/geordi/commands/migrate.rb +3 -3
- data/lib/geordi/commands/png_optimize.rb +5 -5
- data/lib/geordi/commands/rake.rb +1 -1
- data/lib/geordi/commands/remove_executable_flags.rb +2 -2
- data/lib/geordi/commands/rspec.rb +5 -5
- data/lib/geordi/commands/security_update.rb +17 -17
- data/lib/geordi/commands/server.rb +2 -2
- data/lib/geordi/commands/setup.rb +3 -3
- data/lib/geordi/commands/shell.rb +1 -1
- data/lib/geordi/commands/tests.rb +1 -1
- data/lib/geordi/commands/unit.rb +2 -2
- data/lib/geordi/commands/update.rb +2 -2
- data/lib/geordi/commands/with_rake.rb +2 -2
- data/lib/geordi/commands/yarn_install.rb +1 -1
- data/lib/geordi/cucumber.rb +14 -15
- data/lib/geordi/db_cleaner.rb +21 -22
- data/lib/geordi/dump_loader.rb +2 -3
- data/lib/geordi/firefox_for_selenium.rb +17 -19
- data/lib/geordi/gitpt.rb +2 -3
- data/lib/geordi/interaction.rb +2 -6
- data/lib/geordi/remote.rb +3 -4
- data/lib/geordi/util.rb +13 -8
- data/lib/geordi/version.rb +1 -1
- metadata +3 -3
@@ -11,19 +11,19 @@ def rspec(*files)
|
|
11
11
|
invoke_cmd 'bundle_install'
|
12
12
|
invoke_cmd 'yarn_install'
|
13
13
|
|
14
|
-
announce 'Running specs'
|
14
|
+
Interaction.announce 'Running specs'
|
15
15
|
|
16
16
|
if Util.file_containing?('Gemfile', /parallel_tests/) && files.empty?
|
17
|
-
note 'All specs at once (using parallel_tests)'
|
17
|
+
Interaction.note 'All specs at once (using parallel_tests)'
|
18
18
|
Util.system! 'bundle exec rake parallel:spec', fail_message: 'Specs failed.'
|
19
19
|
|
20
20
|
else
|
21
21
|
# tell which specs will be run
|
22
22
|
if files.empty?
|
23
23
|
files << 'spec/'
|
24
|
-
note 'All specs in spec/'
|
24
|
+
Interaction.note 'All specs in spec/'
|
25
25
|
else
|
26
|
-
note 'Only: ' + files.join(', ')
|
26
|
+
Interaction.note 'Only: ' + files.join(', ')
|
27
27
|
end
|
28
28
|
|
29
29
|
command = ['bundle exec']
|
@@ -41,6 +41,6 @@ def rspec(*files)
|
|
41
41
|
Util.system! command.join(' '), fail_message: 'Specs failed.'
|
42
42
|
end
|
43
43
|
else
|
44
|
-
note 'RSpec not employed.'
|
44
|
+
Interaction.note 'RSpec not employed.'
|
45
45
|
end
|
46
46
|
end
|
@@ -11,30 +11,30 @@ LONGDESC
|
|
11
11
|
def security_update(step = 'prepare')
|
12
12
|
case step
|
13
13
|
when 'prepare'
|
14
|
-
announce 'Preparing for security update'
|
15
|
-
warn 'Please read https://makandracards.com/makandra/1587 before applying security updates!'
|
16
|
-
note 'About to checkout production and pull'
|
17
|
-
prompt('Continue?', 'y', /y|yes/) ||
|
14
|
+
Interaction.announce 'Preparing for security update'
|
15
|
+
Interaction.warn 'Please read https://makandracards.com/makandra/1587 before applying security updates!'
|
16
|
+
Interaction.note 'About to checkout production and pull'
|
17
|
+
Interaction.prompt('Continue?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
|
18
18
|
|
19
19
|
Util.system! 'git checkout production', show_cmd: true
|
20
20
|
Util.system! 'git pull', show_cmd: true
|
21
21
|
|
22
|
-
success 'Successfully prepared for security update'
|
22
|
+
Interaction.success 'Successfully prepared for security update'
|
23
23
|
puts
|
24
|
-
note 'Please apply the security update now and commit your changes.'
|
25
|
-
note 'When you are done, run `geordi security-update finish`.'
|
24
|
+
Interaction.note 'Please apply the security update now and commit your changes.'
|
25
|
+
Interaction.note 'When you are done, run `geordi security-update finish`.'
|
26
26
|
|
27
27
|
|
28
28
|
when 'f', 'finish'
|
29
29
|
# ensure everything is committed
|
30
|
-
`git status --porcelain`.empty? ||
|
30
|
+
`git status --porcelain`.empty? || Interaction.fail('Please commit your changes before finishing the update.')
|
31
31
|
|
32
|
-
announce 'Finishing security update'
|
33
|
-
note 'Working directory clean.'
|
34
|
-
prompt('Have you successfully run all tests?', 'n', /y|yes/) ||
|
32
|
+
Interaction.announce 'Finishing security update'
|
33
|
+
Interaction.note 'Working directory clean.'
|
34
|
+
Interaction.prompt('Have you successfully run all tests?', 'n', /y|yes/) || Interaction.fail('Please run tests first.')
|
35
35
|
|
36
|
-
note 'About to: push production, checkout & pull master, merge production, push master'
|
37
|
-
prompt('Continue?', 'n', /y|yes/) ||
|
36
|
+
Interaction.note 'About to: push production, checkout & pull master, merge production, push master'
|
37
|
+
Interaction.prompt('Continue?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
38
38
|
|
39
39
|
Util.system! 'git push', show_cmd: true
|
40
40
|
Util.system! 'git checkout master', show_cmd: true
|
@@ -42,13 +42,13 @@ def security_update(step = 'prepare')
|
|
42
42
|
Util.system! 'git merge production', show_cmd: true
|
43
43
|
Util.system! 'git push', show_cmd: true
|
44
44
|
|
45
|
-
announce 'Deploying all targets'
|
45
|
+
Interaction.announce 'Deploying all targets'
|
46
46
|
deploy = (Util.gem_major_version('capistrano') == 3) ? 'deploy' : 'deploy:migrations'
|
47
47
|
invoke_cmd 'capistrano', deploy
|
48
48
|
|
49
|
-
success 'Successfully pushed and deployed security update'
|
49
|
+
Interaction.success 'Successfully pushed and deployed security update'
|
50
50
|
puts
|
51
|
-
note 'Now send an email to customer and project lead, informing them about the update.'
|
52
|
-
note 'Do not forget to make a joblog on a security budget, if available.'
|
51
|
+
Interaction.note 'Now send an email to customer and project lead, informing them about the update.'
|
52
|
+
Interaction.note 'Do not forget to make a joblog on a security budget, if available.'
|
53
53
|
end
|
54
54
|
end
|
@@ -10,9 +10,9 @@ def server(port = nil)
|
|
10
10
|
invoke_cmd 'yarn_install'
|
11
11
|
require 'geordi/util'
|
12
12
|
|
13
|
-
announce 'Booting a development server'
|
13
|
+
Interaction.announce 'Booting a development server'
|
14
14
|
port ||= options.port
|
15
|
-
note "URL: http://#{File.basename(Dir.pwd)}.vcap.me:#{port}"
|
15
|
+
Interaction.note "URL: http://#{File.basename(Dir.pwd)}.vcap.me:#{port}"
|
16
16
|
puts
|
17
17
|
|
18
18
|
command = Util.server_command
|
@@ -25,8 +25,8 @@ option :test, type: :boolean, aliases: '-t', desc: 'After setup, run tests'
|
|
25
25
|
|
26
26
|
def setup
|
27
27
|
if File.exist? 'bin/setup'
|
28
|
-
announce 'Running bin/setup'
|
29
|
-
note "Geordi's own setup routine is skipped"
|
28
|
+
Interaction.announce 'Running bin/setup'
|
29
|
+
Interaction.note "Geordi's own setup routine is skipped"
|
30
30
|
|
31
31
|
Util.system! 'bin/setup'
|
32
32
|
else
|
@@ -34,7 +34,7 @@ def setup
|
|
34
34
|
invoke_cmd 'migrate'
|
35
35
|
end
|
36
36
|
|
37
|
-
success 'Successfully set up the project.'
|
37
|
+
Interaction.success 'Successfully set up the project.'
|
38
38
|
|
39
39
|
invoke_cmd 'dump', options.dump, load: true if options.dump
|
40
40
|
invoke_cmd 'tests' if options.test
|
@@ -14,6 +14,6 @@ option :select_server, default: false, type: :boolean, aliases: '-s'
|
|
14
14
|
def shelll(target, *_args)
|
15
15
|
require 'geordi/remote'
|
16
16
|
|
17
|
-
announce 'Opening a shell on ' + target
|
17
|
+
Interaction.announce 'Opening a shell on ' + target
|
18
18
|
Geordi::Remote.new(target).shell(options)
|
19
19
|
end
|
data/lib/geordi/commands/unit.rb
CHANGED
@@ -4,9 +4,9 @@ def unit
|
|
4
4
|
invoke_cmd 'bundle_install'
|
5
5
|
invoke_cmd 'yarn_install'
|
6
6
|
|
7
|
-
announce 'Running Test::Unit'
|
7
|
+
Interaction.announce 'Running Test::Unit'
|
8
8
|
Util.system! 'bundle exec rake test'
|
9
9
|
else
|
10
|
-
note 'Test::Unit not employed.'
|
10
|
+
Interaction.note 'Test::Unit not employed.'
|
11
11
|
end
|
12
12
|
end
|
@@ -21,12 +21,12 @@ option :dump, type: :string, aliases: '-d', banner: 'TARGET',
|
|
21
21
|
option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
|
22
22
|
|
23
23
|
def update
|
24
|
-
announce 'Updating repository'
|
24
|
+
Interaction.announce 'Updating repository'
|
25
25
|
Util.system! 'git pull', show_cmd: true
|
26
26
|
|
27
27
|
invoke_cmd 'migrate'
|
28
28
|
|
29
|
-
success 'Successfully updated the project.'
|
29
|
+
Interaction.success 'Successfully updated the project.'
|
30
30
|
|
31
31
|
invoke_cmd 'dump', options.dump, load: true if options.dump
|
32
32
|
invoke_cmd 'tests' if options.test
|
@@ -4,10 +4,10 @@ def with_rake
|
|
4
4
|
invoke_cmd 'bundle_install'
|
5
5
|
invoke_cmd 'yarn_install'
|
6
6
|
|
7
|
-
announce 'Running tests with `rake`'
|
7
|
+
Interaction.announce 'Running tests with `rake`'
|
8
8
|
Util.system! 'rake'
|
9
9
|
else
|
10
|
-
note '`rake` does not run tests.'
|
10
|
+
Interaction.note '`rake` does not run tests.'
|
11
11
|
:did_not_perform
|
12
12
|
end
|
13
13
|
end
|
@@ -2,7 +2,7 @@ desc 'yarn-install', 'Runs yarn install if required', hide: true
|
|
2
2
|
|
3
3
|
def yarn_install
|
4
4
|
if File.exist?('package.json') && !system('yarn check --integrity > /dev/null 2>&1')
|
5
|
-
announce 'Yarn install'
|
5
|
+
Interaction.announce 'Yarn install'
|
6
6
|
Util.system! 'yarn install'
|
7
7
|
end
|
8
8
|
end
|
data/lib/geordi/cucumber.rb
CHANGED
@@ -8,7 +8,6 @@ require File.expand_path('firefox_for_selenium', __dir__)
|
|
8
8
|
|
9
9
|
module Geordi
|
10
10
|
class Cucumber
|
11
|
-
include Geordi::Interaction
|
12
11
|
|
13
12
|
VNC_DISPLAY = ':17'.freeze
|
14
13
|
VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024".freeze
|
@@ -23,7 +22,7 @@ module Geordi
|
|
23
22
|
setup_vnc
|
24
23
|
|
25
24
|
command = use_parallel_tests?(options) ? parallel_execution_command : serial_execution_command
|
26
|
-
note_cmd(command) if options[:verbose]
|
25
|
+
Interaction.note_cmd(command) if options[:verbose]
|
27
26
|
|
28
27
|
puts # Make newline
|
29
28
|
system command # Util.system! would reset the Firefox PATH
|
@@ -34,11 +33,11 @@ module Geordi
|
|
34
33
|
error = capture_stderr do
|
35
34
|
system(VNC_VIEWER_COMMAND)
|
36
35
|
end
|
37
|
-
unless
|
38
|
-
if
|
39
|
-
|
36
|
+
unless $?.success?
|
37
|
+
if $?.exitstatus == 127
|
38
|
+
Interaction.fail 'VNC viewer not found. Install it with `geordi vnc --setup`.'
|
40
39
|
else
|
41
|
-
note 'VNC viewer could not be opened:'
|
40
|
+
Interaction.note 'VNC viewer could not be opened:'
|
42
41
|
puts error
|
43
42
|
puts
|
44
43
|
end
|
@@ -60,7 +59,7 @@ module Geordi
|
|
60
59
|
ENV['BROWSER'] = ENV['LAUNCHY_BROWSER'] = File.expand_path('../../bin/launchy_browser', __dir__)
|
61
60
|
ENV['DISPLAY'] = VNC_DISPLAY
|
62
61
|
|
63
|
-
note 'Run `geordi vnc` to view the Selenium test browsers'
|
62
|
+
Interaction.note 'Run `geordi vnc` to view the Selenium test browsers'
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
@@ -77,7 +76,7 @@ module Geordi
|
|
77
76
|
end
|
78
77
|
|
79
78
|
def parallel_execution_command
|
80
|
-
note 'Using parallel_tests'
|
79
|
+
Interaction.note 'Using parallel_tests'
|
81
80
|
self.argv = argv - command_line_features
|
82
81
|
|
83
82
|
type_arg = Util.gem_version('parallel_tests') > Gem::Version.new('0.7.0') ? 'cucumber' : 'features'
|
@@ -115,15 +114,15 @@ module Geordi
|
|
115
114
|
|
116
115
|
def show_features_to_run
|
117
116
|
if command_line_options.include? '@solo'
|
118
|
-
note 'All features tagged with @solo'
|
117
|
+
Interaction.note 'All features tagged with @solo'
|
119
118
|
elsif command_line_options.include? 'rerun'
|
120
|
-
note 'Rerunning failed scenarios'
|
119
|
+
Interaction.note 'Rerunning failed scenarios'
|
121
120
|
elsif features_to_run.empty?
|
122
|
-
note 'All features in features/'
|
121
|
+
Interaction.note 'All features in features/'
|
123
122
|
else
|
124
123
|
notification = 'Only: ' + features_to_run.join(', ')
|
125
124
|
notification << ' (from rerun.txt)' if (features_to_run == rerun_txt_features) && (features_to_run != command_line_features)
|
126
|
-
note notification
|
125
|
+
Interaction.note notification
|
127
126
|
end
|
128
127
|
end
|
129
128
|
|
@@ -173,7 +172,7 @@ module Geordi
|
|
173
172
|
def consolidate_rerun_txt_files
|
174
173
|
parallel_rerun_files = Dir.glob('parallel_rerun*.txt')
|
175
174
|
unless parallel_rerun_files.empty?
|
176
|
-
note 'Consolidating parallel_rerun.txt files ...'
|
175
|
+
Interaction.note 'Consolidating parallel_rerun.txt files ...'
|
177
176
|
|
178
177
|
rerun_content = []
|
179
178
|
parallel_rerun_files.each do |filename|
|
@@ -218,10 +217,10 @@ module Geordi
|
|
218
217
|
98 # was already running after all
|
219
218
|
true
|
220
219
|
when 127 # not installed
|
221
|
-
warn 'Could not launch VNC server. Install it with `geordi vnc --setup`.'
|
220
|
+
Interaction.warn 'Could not launch VNC server. Install it with `geordi vnc --setup`.'
|
222
221
|
false
|
223
222
|
else
|
224
|
-
warn 'Starting VNC failed:'
|
223
|
+
Interaction.warn 'Starting VNC failed:'
|
225
224
|
puts error
|
226
225
|
puts
|
227
226
|
false
|
data/lib/geordi/db_cleaner.rb
CHANGED
@@ -4,14 +4,13 @@ require 'tempfile'
|
|
4
4
|
|
5
5
|
module Geordi
|
6
6
|
class DBCleaner
|
7
|
-
include Geordi::Interaction
|
8
7
|
|
9
8
|
def initialize(extra_flags)
|
10
9
|
puts 'Please enter your sudo password if asked, for db operations as system users'
|
11
10
|
puts "We're going to run `sudo -u postgres psql` for PostgreSQL"
|
12
11
|
puts ' and `sudo mysql` for MariaDB (which uses PAM auth)'
|
13
12
|
`sudo true`
|
14
|
-
|
13
|
+
Interaction.fail 'sudo access is required for database operations as database users' if $? != 0
|
15
14
|
@derivative_dbname = /_(test\d*|development|cucumber)$/
|
16
15
|
base_directory = ENV['XDG_CONFIG_HOME']
|
17
16
|
base_directory = Dir.home.to_s if base_directory.nil?
|
@@ -66,7 +65,7 @@ HEREDOC
|
|
66
65
|
tmpfile_content.push(['keep', db_name]) unless db_name.empty?
|
67
66
|
end
|
68
67
|
if warn_manual_whitelist
|
69
|
-
warn <<-ERROR_MSG.gsub(/^\s*/, '')
|
68
|
+
Interaction.warn <<-ERROR_MSG.gsub(/^\s*/, '')
|
70
69
|
Your whitelist #{whitelist} seems to have been generated manually.
|
71
70
|
In that case, make sure to use only one database name per line and omit the 'keep' prefix."
|
72
71
|
|
@@ -88,10 +87,10 @@ HEREDOC
|
|
88
87
|
lines.each do |line|
|
89
88
|
next if line.start_with?('#')
|
90
89
|
unless line.split.length == 2
|
91
|
-
|
90
|
+
Interaction.fail "Invalid edit to whitelist file: \`#{line}\` - Syntax is: ^[keep|drop] dbname$"
|
92
91
|
end
|
93
92
|
unless %w[keep drop k d].include? line.split.first
|
94
|
-
|
93
|
+
Interaction.fail "Invalid edit to whitelist file: \`#{line}\` - must start with either drop or keep."
|
95
94
|
end
|
96
95
|
db_status, db_name = line.split
|
97
96
|
if db_status == 'keep'
|
@@ -108,7 +107,7 @@ HEREDOC
|
|
108
107
|
unless extra_flags.nil?
|
109
108
|
if extra_flags.include? 'port'
|
110
109
|
port = Integer(extra_flags.split('=')[1].split[0])
|
111
|
-
|
110
|
+
Interaction.fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
112
111
|
end
|
113
112
|
cmd << " #{extra_flags}"
|
114
113
|
end
|
@@ -121,15 +120,15 @@ HEREDOC
|
|
121
120
|
cmd << " #{extra_flags}" unless extra_flags.nil?
|
122
121
|
unless File.exist? File.join(Dir.home, '.my.cnf')
|
123
122
|
puts "Please enter your MySQL/MariaDB password for account 'root'."
|
124
|
-
warn "You should create a ~/.my.cnf file instead, or you'll need to enter your MySQL root password for each db."
|
125
|
-
warn 'See https://makandracards.com/makandra/50813-store-mysql-passwords-for-development for more information.'
|
123
|
+
Interaction.warn "You should create a ~/.my.cnf file instead, or you'll need to enter your MySQL root password for each db."
|
124
|
+
Interaction.warn 'See https://makandracards.com/makandra/50813-store-mysql-passwords-for-development for more information.'
|
126
125
|
cmd << ' -p' # need to ask for password now
|
127
126
|
end
|
128
127
|
Open3.popen3("#{cmd} -e 'QUIT'") do |_stdin_2, _stdout_2, _stderr_2, thread_2|
|
129
|
-
|
128
|
+
Interaction.fail 'Could not connect to MySQL/MariaDB' unless thread_2.value.exitstatus == 0
|
130
129
|
end
|
131
130
|
elsif mysql_error == '2013' # connection to port or socket failed
|
132
|
-
|
131
|
+
Interaction.fail 'MySQL/MariaDB connection failed, is this the correct port?'
|
133
132
|
end
|
134
133
|
end
|
135
134
|
cmd
|
@@ -141,10 +140,10 @@ HEREDOC
|
|
141
140
|
unless extra_flags.nil?
|
142
141
|
begin
|
143
142
|
port = Integer(extra_flags.split('=')[1])
|
144
|
-
|
143
|
+
Interaction.fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
145
144
|
rescue ArgumentError
|
146
145
|
socket = extra_flags.split('=')[1]
|
147
|
-
|
146
|
+
Interaction.fail "Socket #{socket} does not exist" unless File.exist? socket
|
148
147
|
end
|
149
148
|
cmd << " #{extra_flags}"
|
150
149
|
end
|
@@ -172,7 +171,7 @@ HEREDOC
|
|
172
171
|
end
|
173
172
|
|
174
173
|
def clean_mysql
|
175
|
-
announce 'Checking for MySQL databases'
|
174
|
+
Interaction.announce 'Checking for MySQL databases'
|
176
175
|
database_list = list_all_dbs('mysql')
|
177
176
|
# confirm_deletion includes option for whitelist editing
|
178
177
|
deletable_dbs = confirm_deletion('mysql', database_list)
|
@@ -181,19 +180,19 @@ HEREDOC
|
|
181
180
|
if @mysql_command.include? '-p'
|
182
181
|
puts "Please enter your MySQL/MariaDB account 'root' for: DROP DATABASE #{db}"
|
183
182
|
else
|
184
|
-
note "Dropping MySQL/MariaDB database #{db}"
|
183
|
+
Interaction.note "Dropping MySQL/MariaDB database #{db}"
|
185
184
|
end
|
186
185
|
`#{@mysql_command} -e 'DROP DATABASE \`#{db}\`;'`
|
187
186
|
end
|
188
187
|
end
|
189
188
|
|
190
189
|
def clean_postgres
|
191
|
-
announce 'Checking for Postgres databases'
|
190
|
+
Interaction.announce 'Checking for Postgres databases'
|
192
191
|
database_list = list_all_dbs('postgres')
|
193
192
|
deletable_dbs = confirm_deletion('postgres', database_list)
|
194
193
|
return if deletable_dbs.nil?
|
195
194
|
deletable_dbs.each do |db|
|
196
|
-
note "Dropping PostgreSQL database `#{db}`."
|
195
|
+
Interaction.note "Dropping PostgreSQL database `#{db}`."
|
197
196
|
`#{@postgres_command} -c 'DROP DATABASE "#{db}";'`
|
198
197
|
end
|
199
198
|
end
|
@@ -207,27 +206,27 @@ HEREDOC
|
|
207
206
|
until %w[y n].include? proceed
|
208
207
|
deletable_dbs = filter_whitelisted(dbtype, database_list)
|
209
208
|
if deletable_dbs.empty?
|
210
|
-
note "No #{dbtype} databases found that were not whitelisted"
|
211
|
-
if prompt('Edit the whitelist? [y]es or [n]o') == 'y'
|
209
|
+
Interaction.note "No #{dbtype} databases found that were not whitelisted"
|
210
|
+
if Interaction.prompt('Edit the whitelist? [y]es or [n]o') == 'y'
|
212
211
|
proceed = 'e'
|
213
212
|
else
|
214
213
|
return []
|
215
214
|
end
|
216
215
|
end
|
217
216
|
if proceed.empty?
|
218
|
-
note "The following #{dbtype} databases are not whitelisted and could be deleted:"
|
217
|
+
Interaction.note "The following #{dbtype} databases are not whitelisted and could be deleted:"
|
219
218
|
deletable_dbs.sort.each do |db|
|
220
219
|
puts db
|
221
220
|
end
|
222
|
-
note "Those #{dbtype} databases are not whitelisted and could be deleted."
|
223
|
-
proceed = prompt('Proceed? [y]es, [n]o or [e]dit whitelist')
|
221
|
+
Interaction.note "Those #{dbtype} databases are not whitelisted and could be deleted."
|
222
|
+
proceed = Interaction.prompt('Proceed? [y]es, [n]o or [e]dit whitelist')
|
224
223
|
end
|
225
224
|
case proceed
|
226
225
|
when 'e'
|
227
226
|
proceed = '' # reset user selection
|
228
227
|
edit_whitelist dbtype
|
229
228
|
when 'n'
|
230
|
-
success 'Not deleting anything'
|
229
|
+
Interaction.success 'Not deleting anything'
|
231
230
|
return []
|
232
231
|
when 'y'
|
233
232
|
return deletable_dbs
|
data/lib/geordi/dump_loader.rb
CHANGED
@@ -5,7 +5,6 @@ require 'geordi/util'
|
|
5
5
|
|
6
6
|
module Geordi
|
7
7
|
class DumpLoader
|
8
|
-
include Geordi::Interaction
|
9
8
|
|
10
9
|
def initialize(file)
|
11
10
|
@dump_file = file
|
@@ -47,13 +46,13 @@ module Geordi
|
|
47
46
|
available_dumps = Dir.glob(dumps_glob).sort
|
48
47
|
|
49
48
|
HighLine.new.choose(*available_dumps) do |menu|
|
50
|
-
menu.hidden('') {
|
49
|
+
menu.hidden('') { Interaction.fail 'Abort.' }
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
54
|
def load
|
56
|
-
note 'Source file: ' + dump_file
|
55
|
+
Interaction.note 'Source file: ' + dump_file
|
57
56
|
|
58
57
|
source_command = send("#{config['adapter']}_command")
|
59
58
|
Util.system! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
|
@@ -4,7 +4,6 @@ require File.expand_path('interaction', __dir__)
|
|
4
4
|
|
5
5
|
module Geordi
|
6
6
|
module FirefoxForSelenium
|
7
|
-
extend Geordi::Interaction
|
8
7
|
|
9
8
|
FIREFOX_FOR_SELENIUM_BASE_PATH = Pathname.new('~/bin/firefoxes').expand_path
|
10
9
|
FIREFOX_FOR_SELENIUM_PROFILE_NAME = 'firefox-for-selenium'.freeze
|
@@ -19,14 +18,14 @@ module Geordi
|
|
19
18
|
|
20
19
|
if version && (version != 'system')
|
21
20
|
unless FirefoxForSelenium.binary(version).exist?
|
22
|
-
warn "Firefox #{version} not found"
|
21
|
+
Interaction.warn "Firefox #{version} not found"
|
23
22
|
|
24
|
-
note strip_heredoc(<<-INSTRUCTIONS)
|
23
|
+
Interaction.note Util.strip_heredoc(<<-INSTRUCTIONS)
|
25
24
|
Install it with
|
26
25
|
geordi firefox --setup #{version}
|
27
26
|
INSTRUCTIONS
|
28
27
|
|
29
|
-
prompt('Run tests anyway?', 'n', /y|yes/) ||
|
28
|
+
Interaction.prompt('Run tests anyway?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
30
29
|
end
|
31
30
|
|
32
31
|
path(version)
|
@@ -46,13 +45,12 @@ module Geordi
|
|
46
45
|
|
47
46
|
if path
|
48
47
|
ENV['PATH'] = "#{path}:#{ENV['PATH']}"
|
49
|
-
note 'Firefox for Selenium set up'
|
48
|
+
Interaction.note 'Firefox for Selenium set up'
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
|
54
53
|
class Installer
|
55
|
-
include Geordi::Interaction
|
56
54
|
|
57
55
|
def initialize(version)
|
58
56
|
@version = version
|
@@ -98,7 +96,7 @@ module Geordi
|
|
98
96
|
def say_hello
|
99
97
|
execute_command('clear')
|
100
98
|
|
101
|
-
puts strip_heredoc(<<-HELLO)
|
99
|
+
puts Util.strip_heredoc(<<-HELLO)
|
102
100
|
Whenever Firefox updates, Selenium breaks. This is annoying. This
|
103
101
|
script will help you create an unchanging version of Firefox for your
|
104
102
|
Selenium tests.
|
@@ -117,31 +115,31 @@ module Geordi
|
|
117
115
|
- It will live in #{path}
|
118
116
|
HELLO
|
119
117
|
|
120
|
-
prompt "Press ENTER when you're ready to begin."
|
118
|
+
Interaction.prompt "Press ENTER when you're ready to begin."
|
121
119
|
end
|
122
120
|
|
123
121
|
def check_if_run_before
|
124
122
|
if original_binary.exist?
|
125
|
-
note 'This version seems to be already installed.'
|
126
|
-
prompt 'Press ENTER to continue anyway or press CTRL+C to abort.'
|
123
|
+
Interaction.note 'This version seems to be already installed.'
|
124
|
+
Interaction.prompt 'Press ENTER to continue anyway or press CTRL+C to abort.'
|
127
125
|
end
|
128
126
|
end
|
129
127
|
|
130
128
|
def download_firefox
|
131
129
|
path.mkpath
|
132
130
|
|
133
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
131
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
134
132
|
Please download an old version of Firefox from: #{download_url}
|
135
133
|
Unpack it with: tar xjf firefox-#{@version}.tar.bz2 -C #{path} --strip-components=1
|
136
134
|
Now #{path.join('firefox')} should be the firefox binary, not a directory.
|
137
135
|
INSTRUCTION
|
138
|
-
prompt 'Continue?'
|
136
|
+
Interaction.prompt 'Continue?'
|
139
137
|
|
140
138
|
File.file?(binary) || raise("Could not find #{binary}")
|
141
139
|
end
|
142
140
|
|
143
141
|
def create_separate_profile
|
144
|
-
note "Creating a separate profile named '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}' so your own profile will be safe..."
|
142
|
+
Interaction.note "Creating a separate profile named '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}' so your own profile will be safe..."
|
145
143
|
# don't use the patched firefox binary for this, we don't want to give
|
146
144
|
# a -p option here
|
147
145
|
execute_command("PATH=#{path}:$PATH firefox -no-remote -CreateProfile #{FIREFOX_FOR_SELENIUM_PROFILE_NAME}")
|
@@ -149,11 +147,11 @@ module Geordi
|
|
149
147
|
end
|
150
148
|
|
151
149
|
def patch_old_firefox
|
152
|
-
note "Patching #{binary} so it uses the new profile and never re-uses windows from other Firefoxes..."
|
150
|
+
Interaction.note "Patching #{binary} so it uses the new profile and never re-uses windows from other Firefoxes..."
|
153
151
|
execute_command("mv #{binary} #{original_binary}")
|
154
152
|
execute_command("mv #{binary}-bin #{original_binary}-bin")
|
155
153
|
patched_binary = Tempfile.new('firefox')
|
156
|
-
patched_binary.write strip_heredoc(<<-PATCH)
|
154
|
+
patched_binary.write Util.strip_heredoc(<<-PATCH)
|
157
155
|
#!/usr/bin/env ruby
|
158
156
|
exec('#{original_binary}', '-no-remote', '-P', '#{FIREFOX_FOR_SELENIUM_PROFILE_NAME}', *ARGV)
|
159
157
|
PATCH
|
@@ -164,7 +162,7 @@ module Geordi
|
|
164
162
|
end
|
165
163
|
|
166
164
|
def configure_old_firefox
|
167
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
165
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
168
166
|
You will now have to do some manual configuration.
|
169
167
|
|
170
168
|
This script will open the patched copy of Firefox when you press ENTER.
|
@@ -178,15 +176,15 @@ module Geordi
|
|
178
176
|
Firefox profile
|
179
177
|
INSTRUCTION
|
180
178
|
|
181
|
-
prompt 'Will open the patched copy of Firefox now'
|
179
|
+
Interaction.prompt 'Will open the patched copy of Firefox now'
|
182
180
|
run_firefox_for_selenium
|
183
181
|
end
|
184
182
|
|
185
183
|
def kkthxbb
|
186
|
-
success "Congratulations, you're done!"
|
184
|
+
Interaction.success "Congratulations, you're done!"
|
187
185
|
|
188
186
|
puts
|
189
|
-
puts strip_heredoc(<<-INSTRUCTION)
|
187
|
+
puts Util.strip_heredoc(<<-INSTRUCTION)
|
190
188
|
Your patched copy of Firefox will be used when you run Cucumber using
|
191
189
|
the cucumber script that comes with the geordi gem. If you cannot use
|
192
190
|
`geordi cucumber`, but still need the test browser set up, you can use:
|
data/lib/geordi/gitpt.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class Gitpt
|
2
|
-
include Geordi::Interaction
|
3
2
|
require 'yaml'
|
4
3
|
require 'highline'
|
5
4
|
require 'tracker_api'
|
@@ -13,7 +12,7 @@ class Gitpt
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def run(git_args)
|
16
|
-
warn <<-WARNING unless Geordi::Util.staged_changes?
|
15
|
+
Geordi::Interaction.warn <<-WARNING unless Geordi::Util.staged_changes?
|
17
16
|
No staged changes. Will create an empty commit.
|
18
17
|
WARNING
|
19
18
|
|
@@ -67,7 +66,7 @@ No staged changes. Will create an empty commit.
|
|
67
66
|
if project_ids && (project_ids.size > 0)
|
68
67
|
project_ids
|
69
68
|
else
|
70
|
-
warn "Sorry, I could not find a project ID in #{file_path} :("
|
69
|
+
Geordi::Interaction.warn "Sorry, I could not find a project ID in #{file_path} :("
|
71
70
|
puts
|
72
71
|
|
73
72
|
puts "Please put at least one Pivotal Tracker project id into #{file_path} in this directory."
|
data/lib/geordi/interaction.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module Geordi
|
4
4
|
module Interaction
|
5
5
|
|
6
|
+
module_function
|
7
|
+
|
6
8
|
# Start your command by `announce`-ing what you're about to do
|
7
9
|
def announce(text)
|
8
10
|
message = "\n# #{text}"
|
@@ -42,12 +44,6 @@ module Geordi
|
|
42
44
|
puts "\e[32m#{message}\e[0m" # green
|
43
45
|
end
|
44
46
|
|
45
|
-
def strip_heredoc(string)
|
46
|
-
leading_whitespace = (string.match(/\A( +)[^ ]+/) || [])[1]
|
47
|
-
string.gsub! /^#{leading_whitespace}/, '' if leading_whitespace
|
48
|
-
string
|
49
|
-
end
|
50
|
-
|
51
47
|
# Returns the user's input.
|
52
48
|
# If agreement_regex is given, returns whether the input matches the regex.
|
53
49
|
def prompt(text, default = nil, agreement_regex = nil)
|