geordi 2.11.0 → 3.1.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/.ruby-version +1 -1
- data/.travis.yml +8 -2
- data/CHANGELOG.md +40 -0
- data/Gemfile +2 -5
- data/Gemfile.lock +50 -3
- data/README.md +34 -7
- data/Rakefile +6 -10
- data/{bin → exe}/b +0 -0
- data/{bin → exe}/cap-all +0 -0
- data/{bin → exe}/console-for +0 -0
- data/{bin → exe}/cuc +0 -0
- data/{bin → exe}/cuc-show +0 -0
- data/{bin → exe}/cuc-vnc-setup +0 -0
- data/{bin → exe}/deploy-to-production +0 -0
- data/{bin → exe}/dump-for +0 -0
- data/{bin → exe}/dumple +0 -0
- data/{bin → exe}/geordi +0 -0
- data/{bin → exe}/gitpt +0 -0
- data/{bin → exe}/launchy_browser +0 -0
- data/{bin → exe}/load-dump +0 -0
- data/{bin → exe}/migrate-all +0 -0
- data/{bin → exe}/rs +0 -0
- data/{bin → exe}/run_tests +0 -0
- data/{bin → exe}/shell-for +0 -0
- data/{bin → exe}/tests +0 -0
- data/geordi.gemspec +23 -20
- data/lib/geordi/COMMAND_TEMPLATE +4 -6
- data/lib/geordi/capistrano_config.rb +7 -7
- data/lib/geordi/chromedriver_updater.rb +9 -10
- data/lib/geordi/cli.rb +1 -7
- data/lib/geordi/commands/_setup_vnc.rb +23 -23
- data/lib/geordi/commands/apache_site.rb +3 -3
- data/lib/geordi/commands/bundle_install.rb +3 -3
- data/lib/geordi/commands/capistrano.rb +5 -6
- data/lib/geordi/commands/chromedriver_update.rb +0 -9
- data/lib/geordi/commands/clean.rb +5 -6
- data/lib/geordi/commands/commit.rb +0 -1
- data/lib/geordi/commands/console.rb +4 -4
- data/lib/geordi/commands/create_database_yml.rb +4 -4
- data/lib/geordi/commands/create_databases.rb +3 -3
- data/lib/geordi/commands/cucumber.rb +25 -25
- data/lib/geordi/commands/delete_dumps.rb +12 -12
- data/lib/geordi/commands/deploy.rb +27 -28
- data/lib/geordi/commands/drop_databases.rb +13 -15
- data/lib/geordi/commands/dump.rb +12 -13
- data/lib/geordi/commands/eurest.rb +2 -2
- data/lib/geordi/commands/firefox.rb +4 -4
- data/lib/geordi/commands/migrate.rb +3 -3
- data/lib/geordi/commands/png_optimize.rb +15 -14
- data/lib/geordi/commands/rake.rb +3 -3
- data/lib/geordi/commands/remove_executable_flags.rb +3 -3
- data/lib/geordi/commands/rspec.rb +11 -11
- data/lib/geordi/commands/security_update.rb +84 -27
- data/lib/geordi/commands/server.rb +6 -6
- data/lib/geordi/commands/setup.rb +8 -8
- data/lib/geordi/commands/shell.rb +3 -3
- data/lib/geordi/commands/tests.rb +1 -1
- data/lib/geordi/commands/unit.rb +3 -3
- data/lib/geordi/commands/update.rb +7 -7
- data/lib/geordi/commands/vnc.rb +1 -1
- data/lib/geordi/commands/with_rake.rb +3 -3
- data/lib/geordi/commands/yarn_install.rb +3 -3
- data/lib/geordi/cucumber.rb +35 -36
- data/lib/geordi/db_cleaner.rb +40 -41
- data/lib/geordi/dump_loader.rb +6 -5
- data/lib/geordi/firefox_for_selenium.rb +26 -29
- data/lib/geordi/gitpt.rb +14 -15
- data/lib/geordi/interaction.rb +2 -6
- data/lib/geordi/remote.rb +9 -10
- data/lib/geordi/util.rb +26 -27
- data/lib/geordi/version.rb +1 -1
- metadata +25 -37
- data/features/commit.feature +0 -17
- data/features/console.feature +0 -7
- data/features/cucumber.feature +0 -261
- data/features/deploy.feature +0 -66
- data/features/dump.feature +0 -34
- data/features/firefox.feature +0 -44
- data/features/server.feature +0 -31
- data/features/setup.feature +0 -11
- data/features/shell.feature +0 -78
- data/features/support/env.rb +0 -8
- data/features/support/step_definitions/aruba_backport_steps.rb +0 -5
- data/features/support/step_definitions/miscellaneous_steps.rb +0 -11
data/lib/geordi/db_cleaner.rb
CHANGED
@@ -4,17 +4,16 @@ 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
|
-
fail 'sudo access is required for database operations as database users' if $? != 0
|
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
|
-
base_directory =
|
16
|
+
base_directory = Dir.home.to_s if base_directory.nil?
|
18
17
|
@whitelist_directory = File.join(base_directory, '.config', 'geordi', 'whitelists')
|
19
18
|
FileUtils.mkdir_p(@whitelist_directory) unless File.directory? @whitelist_directory
|
20
19
|
@mysql_command = decide_mysql_command(extra_flags['mysql'])
|
@@ -23,11 +22,11 @@ module Geordi
|
|
23
22
|
|
24
23
|
def edit_whitelist(dbtype)
|
25
24
|
whitelist = whitelist_fname(dbtype)
|
26
|
-
if File.exist? whitelist
|
27
|
-
|
25
|
+
whitelisted_dbs = if File.exist? whitelist
|
26
|
+
Geordi::Util.stripped_lines(File.read(whitelist))\
|
28
27
|
.delete_if { |l| l.start_with? '#' }
|
29
28
|
else
|
30
|
-
|
29
|
+
[]
|
31
30
|
end
|
32
31
|
all_dbs = list_all_dbs(dbtype)
|
33
32
|
tmp = Tempfile.open("geordi_whitelist_#{dbtype}")
|
@@ -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
|
|
@@ -82,16 +81,16 @@ HEREDOC
|
|
82
81
|
texteditor = Geordi::Util.decide_texteditor
|
83
82
|
system("#{texteditor} #{tmp.path}")
|
84
83
|
File.open(tmp.path, 'r') do |wl_edited|
|
85
|
-
whitelisted_dbs =
|
84
|
+
whitelisted_dbs = []
|
86
85
|
whitelist_storage = File.open(whitelist, 'w')
|
87
86
|
lines = Geordi::Util.stripped_lines(wl_edited.read)
|
88
87
|
lines.each do |line|
|
89
88
|
next if line.start_with?('#')
|
90
89
|
unless line.split.length == 2
|
91
|
-
fail "Invalid edit to whitelist file: \`#{line}\` - Syntax is: ^[keep|drop] dbname$"
|
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
|
-
fail "Invalid edit to whitelist file: \`#{line}\` - must start with either drop or keep."
|
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'
|
@@ -107,32 +106,32 @@ HEREDOC
|
|
107
106
|
cmd = 'sudo mysql'
|
108
107
|
unless extra_flags.nil?
|
109
108
|
if extra_flags.include? 'port'
|
110
|
-
port = Integer(extra_flags.split('=')[1].split
|
111
|
-
fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
109
|
+
port = Integer(extra_flags.split('=')[1].split[0])
|
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
|
115
|
-
Open3.popen3("#{cmd} -e 'QUIT'") do |
|
114
|
+
Open3.popen3("#{cmd} -e 'QUIT'") do |_stdin, _stdout, stderr, thread|
|
116
115
|
break if thread.value.exitstatus == 0
|
117
116
|
# sudo mysql was not successful, switching to mysql-internal user management
|
118
117
|
mysql_error = stderr.read.lines[0].chomp.strip.split[1]
|
119
|
-
if %w[1045 1698].include? mysql_error
|
118
|
+
if %w[1045 1698].include? mysql_error # authentication failed
|
120
119
|
cmd = 'mysql -uroot'
|
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
|
126
|
-
cmd << ' -p'
|
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.'
|
125
|
+
cmd << ' -p' # need to ask for password now
|
127
126
|
end
|
128
|
-
Open3.popen3("#{cmd} -e 'QUIT'") do |
|
129
|
-
fail 'Could not connect to MySQL/MariaDB' unless
|
127
|
+
Open3.popen3("#{cmd} -e 'QUIT'") do |_stdin_2, _stdout_2, _stderr_2, thread_2|
|
128
|
+
Interaction.fail 'Could not connect to MySQL/MariaDB' unless thread_2.value.exitstatus == 0
|
130
129
|
end
|
131
|
-
elsif mysql_error == '2013'
|
132
|
-
fail 'MySQL/MariaDB connection failed, is this the correct port?'
|
130
|
+
elsif mysql_error == '2013' # connection to port or socket failed
|
131
|
+
Interaction.fail 'MySQL/MariaDB connection failed, is this the correct port?'
|
133
132
|
end
|
134
133
|
end
|
135
|
-
|
134
|
+
cmd
|
136
135
|
end
|
137
136
|
private :decide_mysql_command
|
138
137
|
|
@@ -141,22 +140,22 @@ HEREDOC
|
|
141
140
|
unless extra_flags.nil?
|
142
141
|
begin
|
143
142
|
port = Integer(extra_flags.split('=')[1])
|
144
|
-
fail "Port #{port} is not open" unless Geordi::Util.is_port_open? port
|
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
|
-
fail "Socket #{socket} does not exist" unless File.exist? socket
|
146
|
+
Interaction.fail "Socket #{socket} does not exist" unless File.exist? socket
|
148
147
|
end
|
149
148
|
cmd << " #{extra_flags}"
|
150
149
|
end
|
151
|
-
|
150
|
+
cmd
|
152
151
|
end
|
153
152
|
private :decide_postgres_command
|
154
153
|
|
155
154
|
def list_all_dbs(dbtype)
|
156
155
|
if dbtype == 'postgres'
|
157
|
-
|
156
|
+
list_all_postgres_dbs
|
158
157
|
else
|
159
|
-
|
158
|
+
list_all_mysql_dbs
|
160
159
|
end
|
161
160
|
end
|
162
161
|
|
@@ -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
|
-
proceed = ''
|
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
|
@@ -245,10 +244,10 @@ HEREDOC
|
|
245
244
|
end
|
246
245
|
|
247
246
|
def is_whitelisted?(dbtype, database_name)
|
248
|
-
if File.exist? whitelist_fname(dbtype)
|
249
|
-
|
247
|
+
whitelist_content = if File.exist? whitelist_fname(dbtype)
|
248
|
+
Geordi::Util.stripped_lines(File.open(whitelist_fname(dbtype), 'r').read)
|
250
249
|
else
|
251
|
-
|
250
|
+
[]
|
252
251
|
end
|
253
252
|
# Allow explicit whitelisting of derivative databases like projectname_test2
|
254
253
|
if whitelist_content.include? database_name
|
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
|
@@ -14,7 +13,9 @@ module Geordi
|
|
14
13
|
def development_database_config
|
15
14
|
require 'yaml'
|
16
15
|
|
17
|
-
|
16
|
+
evaluated_config_file = ERB.new(File.read('config/database.yml')).result
|
17
|
+
# Allow aliases and a special set of classes like symbols and time objects
|
18
|
+
@config ||= YAML.safe_load(evaluated_config_file, [Symbol, Time], [], true)
|
18
19
|
@config['development']
|
19
20
|
end
|
20
21
|
alias_method :config, :development_database_config
|
@@ -47,16 +48,16 @@ module Geordi
|
|
47
48
|
available_dumps = Dir.glob(dumps_glob).sort
|
48
49
|
|
49
50
|
HighLine.new.choose(*available_dumps) do |menu|
|
50
|
-
menu.hidden('') { fail 'Abort.' }
|
51
|
+
menu.hidden('') { Interaction.fail 'Abort.' }
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
56
|
def load
|
56
|
-
note 'Source file: ' + dump_file
|
57
|
+
Interaction.note 'Source file: ' + dump_file
|
57
58
|
|
58
59
|
source_command = send("#{config['adapter']}_command")
|
59
|
-
Util.system! source_command, :
|
60
|
+
Util.system! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
|
60
61
|
end
|
61
62
|
|
62
63
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'tempfile'
|
3
|
-
require File.expand_path('
|
3
|
+
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
|
-
FIREFOX_FOR_SELENIUM_PROFILE_NAME = 'firefox-for-selenium'
|
9
|
+
FIREFOX_FOR_SELENIUM_PROFILE_NAME = 'firefox-for-selenium'.freeze
|
11
10
|
FIREFOX_VERSION_FILE = Pathname.new('.firefox-version')
|
12
11
|
|
13
12
|
def self.install(version)
|
@@ -17,16 +16,16 @@ module Geordi
|
|
17
16
|
def self.path_from_config
|
18
17
|
version = FIREFOX_VERSION_FILE.exist? && File.read(FIREFOX_VERSION_FILE).strip
|
19
18
|
|
20
|
-
if version
|
19
|
+
if version && (version != 'system')
|
21
20
|
unless FirefoxForSelenium.binary(version).exist?
|
22
|
-
warn "Firefox #{
|
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
|
-
geordi firefox --setup #{
|
25
|
+
geordi firefox --setup #{version}
|
27
26
|
INSTRUCTIONS
|
28
27
|
|
29
|
-
prompt
|
28
|
+
Interaction.prompt('Run tests anyway?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
30
29
|
end
|
31
30
|
|
32
31
|
path(version)
|
@@ -37,7 +36,7 @@ module Geordi
|
|
37
36
|
FIREFOX_FOR_SELENIUM_BASE_PATH.join(version)
|
38
37
|
end
|
39
38
|
|
40
|
-
def self.binary(version, name =
|
39
|
+
def self.binary(version, name = 'firefox')
|
41
40
|
path(version).join(name)
|
42
41
|
end
|
43
42
|
|
@@ -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
|
@@ -72,7 +70,7 @@ module Geordi
|
|
72
70
|
private
|
73
71
|
|
74
72
|
def execute_command(cmd)
|
75
|
-
system(cmd)
|
73
|
+
system(cmd) || raise("Error while executing command: #{cmd}")
|
76
74
|
end
|
77
75
|
|
78
76
|
def run_firefox_for_selenium(args = '')
|
@@ -92,13 +90,13 @@ module Geordi
|
|
92
90
|
end
|
93
91
|
|
94
92
|
def original_binary
|
95
|
-
FirefoxForSelenium.binary(@version,
|
93
|
+
FirefoxForSelenium.binary(@version, 'firefox-original')
|
96
94
|
end
|
97
95
|
|
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
|
-
File.file?(binary)
|
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,14 +147,14 @@ 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
|
160
158
|
patched_binary.close
|
161
159
|
execute_command("mv #{patched_binary.path} #{binary}")
|
162
160
|
execute_command("chmod +x #{binary}")
|
@@ -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:
|
@@ -200,4 +198,3 @@ module Geordi
|
|
200
198
|
end
|
201
199
|
end
|
202
200
|
end
|
203
|
-
|
data/lib/geordi/gitpt.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
class Gitpt
|
2
|
-
include Geordi::Interaction
|
3
2
|
require 'yaml'
|
4
3
|
require 'highline'
|
5
4
|
require 'tracker_api'
|
6
5
|
|
7
|
-
SETTINGS_FILE_NAME = '.gitpt'
|
8
|
-
PROJECT_IDS_FILE_NAME = '.pt_project_id'
|
6
|
+
SETTINGS_FILE_NAME = '.gitpt'.freeze
|
7
|
+
PROJECT_IDS_FILE_NAME = '.pt_project_id'.freeze
|
9
8
|
|
10
9
|
def initialize
|
11
10
|
self.highline = HighLine.new
|
@@ -13,7 +12,7 @@ class Gitpt
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def run(git_args)
|
16
|
-
warn <<-WARNING
|
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
|
|
@@ -30,16 +29,16 @@ No staged changes. Will create an empty commit.
|
|
30
29
|
def read_settings
|
31
30
|
file_path = File.join(ENV['HOME'], SETTINGS_FILE_NAME)
|
32
31
|
|
33
|
-
unless File.
|
32
|
+
unless File.exist?(file_path)
|
34
33
|
highline.say HighLine::RESET
|
35
34
|
highline.say "Welcome to #{bold 'gitpt'}.\n\n"
|
36
35
|
|
37
36
|
highline.say highlight('Your settings are missing or invalid.')
|
38
37
|
highline.say "Please configure your Pivotal Tracker access.\n\n"
|
39
|
-
token = highline.ask bold(
|
38
|
+
token = highline.ask bold('Your API key:') + ' '
|
40
39
|
highline.say "\n"
|
41
40
|
|
42
|
-
settings = { :
|
41
|
+
settings = { token: token }
|
43
42
|
File.open(file_path, 'w') do |file|
|
44
43
|
file.write settings.to_yaml
|
45
44
|
end
|
@@ -49,7 +48,7 @@ No staged changes. Will create an empty commit.
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def build_client(settings)
|
52
|
-
TrackerApi::Client.new(:
|
51
|
+
TrackerApi::Client.new(token: settings.fetch(:token))
|
53
52
|
end
|
54
53
|
|
55
54
|
def load_projects
|
@@ -60,14 +59,14 @@ No staged changes. Will create an empty commit.
|
|
60
59
|
def read_project_ids
|
61
60
|
file_path = PROJECT_IDS_FILE_NAME
|
62
61
|
|
63
|
-
if File.
|
62
|
+
if File.exist?(file_path)
|
64
63
|
project_ids = File.read('.pt_project_id').split(/[\s]+/).map(&:to_i)
|
65
64
|
end
|
66
65
|
|
67
|
-
if project_ids
|
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."
|
@@ -79,19 +78,19 @@ No staged changes. Will create an empty commit.
|
|
79
78
|
def applicable_stories
|
80
79
|
projects = load_projects
|
81
80
|
projects.collect do |project|
|
82
|
-
project.stories(:
|
81
|
+
project.stories(filter: 'state:started,finished,rejected')
|
83
82
|
end.flatten
|
84
83
|
end
|
85
84
|
|
86
85
|
def choose_story
|
87
86
|
if Geordi::Util.testing?
|
88
|
-
return OpenStruct.new(:
|
87
|
+
return OpenStruct.new(id: 12, name: 'Test Story')
|
89
88
|
end
|
90
89
|
|
91
90
|
loading_message = 'Connecting to Pivotal Tracker ...'
|
92
91
|
print(loading_message)
|
93
92
|
stories = applicable_stories
|
94
|
-
reset_loading_message = "\r#{
|
93
|
+
reset_loading_message = "\r#{' ' * (loading_message.length + stories.length)}\r"
|
95
94
|
|
96
95
|
highline.choose do |menu|
|
97
96
|
menu.header = 'Choose a story'
|
@@ -126,7 +125,7 @@ No staged changes. Will create an empty commit.
|
|
126
125
|
|
127
126
|
def create_commit(message, *git_args)
|
128
127
|
extra = highline.ask("\nAdd an optional message").strip
|
129
|
-
message << ' - ' << extra if
|
128
|
+
message << ' - ' << extra if extra != ''
|
130
129
|
|
131
130
|
Geordi::Util.system! 'git', 'commit', '--allow-empty', '-m', message, *git_args
|
132
131
|
end
|