geordi 3.2.0 → 4.2.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +5 -0
  4. data/CHANGELOG.md +69 -1
  5. data/Gemfile +2 -1
  6. data/Gemfile.lock +46 -28
  7. data/README.md +132 -140
  8. data/Rakefile +19 -9
  9. data/exe/dumple +19 -4
  10. data/geordi.gemspec +3 -2
  11. data/lib/geordi/COMMAND_TEMPLATE +4 -2
  12. data/lib/geordi/chromedriver_updater.rb +2 -2
  13. data/lib/geordi/cli.rb +1 -1
  14. data/lib/geordi/commands/bundle_install.rb +1 -1
  15. data/lib/geordi/commands/capistrano.rb +1 -1
  16. data/lib/geordi/commands/chromedriver_update.rb +10 -3
  17. data/lib/geordi/commands/commit.rb +0 -5
  18. data/lib/geordi/commands/console.rb +11 -13
  19. data/lib/geordi/commands/create_databases.rb +7 -5
  20. data/lib/geordi/commands/cucumber.rb +22 -19
  21. data/lib/geordi/commands/delete_dumps.rb +0 -1
  22. data/lib/geordi/commands/deploy.rb +17 -17
  23. data/lib/geordi/commands/drop_databases.rb +0 -6
  24. data/lib/geordi/commands/dump.rb +20 -18
  25. data/lib/geordi/commands/firefox.rb +3 -6
  26. data/lib/geordi/commands/migrate.rb +4 -4
  27. data/lib/geordi/commands/rake.rb +7 -3
  28. data/lib/geordi/commands/rspec.rb +8 -12
  29. data/lib/geordi/commands/security_update.rb +24 -25
  30. data/lib/geordi/commands/server.rb +4 -4
  31. data/lib/geordi/commands/setup.rb +7 -16
  32. data/lib/geordi/commands/shell.rb +7 -8
  33. data/lib/geordi/commands/tests.rb +4 -4
  34. data/lib/geordi/commands/unit.rb +3 -3
  35. data/lib/geordi/commands/update.rb +4 -15
  36. data/lib/geordi/commands/vnc.rb +2 -4
  37. data/lib/geordi/commands/with_rake.rb +3 -3
  38. data/lib/geordi/commands/yarn_install.rb +1 -1
  39. data/lib/geordi/cucumber.rb +3 -3
  40. data/lib/geordi/dump_loader.rb +1 -1
  41. data/lib/geordi/gitpt.rb +1 -1
  42. data/lib/geordi/interaction.rb +1 -1
  43. data/lib/geordi/remote.rb +5 -4
  44. data/lib/geordi/settings.rb +11 -2
  45. data/lib/geordi/util.rb +35 -17
  46. data/lib/geordi/version.rb +1 -1
  47. metadata +7 -34
  48. data/exe/cap-all +0 -4
  49. data/exe/console-for +0 -4
  50. data/exe/cuc +0 -4
  51. data/exe/cuc-show +0 -4
  52. data/exe/cuc-vnc-setup +0 -4
  53. data/exe/deploy-to-production +0 -4
  54. data/exe/dump-for +0 -8
  55. data/exe/gitpt +0 -4
  56. data/exe/load-dump +0 -4
  57. data/exe/migrate-all +0 -4
  58. data/exe/rs +0 -4
  59. data/exe/run_tests +0 -4
  60. data/exe/shell-for +0 -4
  61. data/exe/tests +0 -4
  62. data/lib/geordi/commands/eurest.rb +0 -4
@@ -7,12 +7,6 @@ and offer to delete them. Excluded are databases that are whitelisted. This come
7
7
  in handy when you're keeping your currently active projects in the whitelist files
8
8
  and perform regular housekeeping with Geordi.
9
9
 
10
- When called with `-P` or `-M` options, only handles Postgres resp. MySQL/MariaDB.
11
-
12
- When called with `--postgres <port or local socket>` or `--mysql <port or local socket>`,
13
- will instruct the underlying management commands to use those connection methods
14
- instead of the defaults. This is useful when running multiple installations.
15
-
16
10
  Geordi will ask for confirmation before actually dropping databases and will
17
11
  offer to edit the whitelist instead.
18
12
  LONGDESC
@@ -1,30 +1,30 @@
1
- desc 'dump [TARGET]', 'Handle dumps (see `geordi help dump` for details)'
1
+ desc 'dump [TARGET]', 'Handle (remote) database dumps'
2
2
  long_desc <<-DESC
3
- When called without arguments, dumps the development database with `dumple`.
3
+ `geordi dump` (without arguments) dumps the development database with `dumple`.
4
4
 
5
- geordi dump
5
+ `geordi dump -l tmp/staging.dump` (with the `--load` option) sources the
6
+ specified dump file into the development database.
6
7
 
7
- When called with the `--load` option, sources the specified dump into the
8
- development database.
8
+ `geordi dump staging` (with a Capistrano deploy target) remotely dumps the
9
+ specified target's database and downloads it to `tmp/`.
9
10
 
10
- geordi dump -l tmp/staging.dump
11
+ `geordi dump staging -l` (with a Capistrano deploy target and the `--load`
12
+ option) sources the dump into the development database after downloading it.
11
13
 
12
- When called with a capistrano deploy target (e.g. `staging`), remotely dumps
13
- the specified target's database and downloads it to `tmp/`.
14
+ If you are using multiple databases per environment, pass the database name like this:
14
15
 
15
- geordi dump staging
16
+ geordi dump -d primary
16
17
 
17
- When called with a capistrano deploy target and the `--load` option, sources the
18
- dump into the development database after downloading it.
19
-
20
- geordi dump staging -l
18
+ Loading a dump into one of multiple local databases is not supported yet.
21
19
  DESC
22
20
 
23
- option :load, aliases: ['-l'], type: :string, desc: 'Load a dump'
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'
24
23
 
25
24
  def dump(target = nil, *_args)
26
25
  require 'geordi/dump_loader'
27
26
  require 'geordi/remote'
27
+ database = options[:database] ? "#{options[:database]} " : ''
28
28
 
29
29
  if target.nil?
30
30
  if options.load
@@ -41,12 +41,14 @@ def dump(target = nil, *_args)
41
41
 
42
42
  else
43
43
  Interaction.announce 'Dumping the development database'
44
- Util.system! 'dumple development'
45
- Interaction.success 'Successfully dumped the development database.'
44
+ Util.run!("dumple development #{database}")
45
+ Interaction.success "Successfully dumped the #{database}development database."
46
46
  end
47
47
 
48
48
  else
49
- 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}"
50
52
  dump_path = Geordi::Remote.new(target).dump(options)
51
53
 
52
54
  if options.load
@@ -55,7 +57,7 @@ def dump(target = nil, *_args)
55
57
  Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
56
58
  loader.load
57
59
 
58
- 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}."
59
61
  end
60
62
  end
61
63
  end
@@ -3,11 +3,8 @@ long_desc <<-LONGDESC
3
3
  Example: `geordi firefox b cucumber` or `geordi firefox --setup 24.0`
4
4
 
5
5
  Useful when you need Firefox for Selenium or the VNC set up, but can't use the
6
- `geordi cucumber` command.
7
-
8
- *Install* a special Firefox by calling with `--setup <version>`.
9
-
10
- This command is aliased `chrome` for users running Selenium in Chrome.
6
+ `geordi cucumber` command. This command is aliased `chrome` for users running
7
+ Selenium in Chrome.
11
8
  LONGDESC
12
9
 
13
10
  option :setup, banner: 'FIREFOX_VERSION',
@@ -28,7 +25,7 @@ def firefox(*command)
28
25
 
29
26
  puts
30
27
  Interaction.note_cmd command.join(' ')
31
- system *command # Util.system! would reset the Firefox PATH
28
+ system *command # Util.run! would reset the Firefox PATH
32
29
  end
33
30
  end
34
31
 
@@ -8,8 +8,8 @@ with `db:migrate`.
8
8
  LONGDESC
9
9
 
10
10
  def migrate
11
- invoke_cmd 'bundle_install'
12
- invoke_cmd 'yarn_install'
11
+ invoke_geordi 'bundle_install'
12
+ invoke_geordi 'yarn_install'
13
13
  Interaction.announce 'Migrating'
14
14
 
15
15
  if File.directory?('db/migrate')
@@ -17,9 +17,9 @@ def migrate
17
17
  Interaction.note 'Development and parallel test databases'
18
18
  puts
19
19
 
20
- Util.system! 'bundle exec rake db:migrate parallel:prepare'
20
+ Util.run!([Util.binstub_or_fallback('rake'), 'db:migrate', 'parallel:prepare'])
21
21
  else
22
- invoke_cmd 'rake', 'db:migrate'
22
+ invoke_geordi 'rake', 'db:migrate'
23
23
  end
24
24
  else
25
25
  Interaction.note 'No migrations directory found.'
@@ -10,12 +10,16 @@ Example: `geordi rake db:migrate`
10
10
  LONGDESC
11
11
 
12
12
  def rake(*args)
13
+ invoke_geordi 'bundle_install'
14
+
13
15
  %w[development test cucumber].each do |env| # update long_desc when changing this
14
16
  if File.exist? "config/environments/#{env}.rb"
15
- call = %w[bundle exec rake] + args + ["RAILS_ENV=#{env}"]
16
- Interaction.note_cmd call.join(' ')
17
+ command = []
18
+ command << Util.binstub_or_fallback('rake')
19
+ command += args
20
+ command << "RAILS_ENV=#{env}"
17
21
 
18
- Util.system! *call
22
+ Util.run!(command, show_cmd: true)
19
23
  end
20
24
  end
21
25
  end
@@ -2,20 +2,19 @@ desc 'rspec [FILES]', 'Run RSpec'
2
2
  long_desc <<-LONGDESC
3
3
  Example: `geordi rspec spec/models/user_spec.rb:13`
4
4
 
5
- Runs RSpec as you want: with RSpec 1/2 detection, `bundle exec`, rspec_spinner
6
- detection, etc.
5
+ Runs RSpec with RSpec 1/2 support, parallel_tests detection and `bundle exec`.
7
6
  LONGDESC
8
7
 
9
8
  def rspec(*files)
10
9
  if File.exist?('spec/spec_helper.rb')
11
- invoke_cmd 'bundle_install'
12
- invoke_cmd 'yarn_install'
10
+ invoke_geordi 'bundle_install'
11
+ invoke_geordi 'yarn_install'
13
12
 
14
13
  Interaction.announce 'Running specs'
15
14
 
16
15
  if Util.file_containing?('Gemfile', /parallel_tests/) && files.empty?
17
16
  Interaction.note 'All specs at once (using parallel_tests)'
18
- Util.system! 'bundle exec rake parallel:spec', fail_message: 'Specs failed.'
17
+ Util.run!([Util.binstub_or_fallback('rake'), 'parallel:spec'], fail_message: 'Specs failed.')
19
18
 
20
19
  else
21
20
  # tell which specs will be run
@@ -26,19 +25,16 @@ def rspec(*files)
26
25
  Interaction.note 'Only: ' + files.join(', ')
27
26
  end
28
27
 
29
- command = ['bundle exec']
30
- command << if File.exist?('script/spec')
31
- 'spec -c' # RSpec 1
32
- elsif File.exist?('bin/rspec')
33
- 'bin/rspec'
28
+ command = if File.exist?('script/spec')
29
+ ['bundle exec spec -c'] # RSpec 1
34
30
  else
35
- 'rspec'
31
+ [Util.binstub_or_fallback('rspec')]
36
32
  end
37
33
  command << '-r rspec_spinner -f RspecSpinner::Bar' if Util.file_containing?('Gemfile', /rspec_spinner/)
38
34
  command << files.join(' ')
39
35
 
40
36
  puts
41
- Util.system! command.join(' '), fail_message: 'Specs failed.'
37
+ Util.run!(command.join(' '), fail_message: 'Specs failed.')
42
38
  end
43
39
  else
44
40
  Interaction.note 'RSpec not employed.'
@@ -1,31 +1,30 @@
1
1
  desc 'security-update [STEP]', 'Support for performing security updates'
2
2
  long_desc <<-LONGDESC
3
- Preparation for security update: `geordi security-update`
3
+ Preparation for security update: `geordi security-update`. Checks out production
4
+ and pulls.
4
5
 
5
- Checks out production and pulls.
6
+ After performing the update: `geordi security-update finish`. Switches branches,
7
+ pulls, pushes and deploys as required by our workflow.
6
8
 
7
- After performing the update: `geordi security-update finish`
9
+ This command tells what it will do before it does it. In detail:
8
10
 
9
- Switches branches, pulls, pushes and deploys as required by our workflow. Tells
10
- what it will do before it does it. In detail:
11
+ 1. Ask user if tests are green
11
12
 
12
- 1. Asks user, if tests are green
13
+ 2. Push production
13
14
 
14
- 2. Pushes production
15
+ 3. Check out master and pull
15
16
 
16
- 3. Checks out master and pulls
17
+ 4. Merge production and push in master
17
18
 
18
- 4. Merges production and pushes in master
19
+ 5. Deploy staging, if there is a staging environment
19
20
 
20
- 5. Deploys staging first, if there is a staging environment
21
+ 6. Ask user if deployment log is okay and staging application is still running
21
22
 
22
- 6. Asks user, if deployment log is okay and application is still running on staging
23
+ 7. Deploy other stages
23
24
 
24
- 7. Deploys other stages
25
+ 8. Ask user if deployment log is okay and application is still running on all stages
25
26
 
26
- 8. Asks user, if deployment log is okay and application is still running on all other stages
27
-
28
- 9. Informs user about the next steps
27
+ 9. Inform user about the next (manual) steps
29
28
  LONGDESC
30
29
 
31
30
  def security_update(step = 'prepare')
@@ -36,8 +35,8 @@ def security_update(step = 'prepare')
36
35
  Interaction.note 'About to checkout production and pull.'
37
36
  Interaction.prompt('Continue?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
38
37
 
39
- Util.system! 'git checkout production', show_cmd: true
40
- Util.system! 'git pull', show_cmd: true
38
+ Util.run!('git checkout production', show_cmd: true)
39
+ Util.run!('git pull', show_cmd: true)
41
40
 
42
41
  Interaction.success 'Successfully prepared for security update'
43
42
  puts
@@ -48,7 +47,7 @@ def security_update(step = 'prepare')
48
47
  when 'f', 'finish'
49
48
  # ensure everything is committed
50
49
  if Util.testing?
51
- puts 'Util.system! git status --porcelain'
50
+ puts 'Util.run! git status --porcelain'
52
51
  else
53
52
  `git status --porcelain`.empty? || Interaction.fail('Please commit your changes before finishing the update.')
54
53
  end
@@ -60,11 +59,11 @@ def security_update(step = 'prepare')
60
59
  Interaction.note 'About to: push production, checkout & pull master, merge production, push master.'
61
60
  Interaction.prompt('Continue?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
62
61
 
63
- Util.system! 'git push', show_cmd: true
64
- Util.system! 'git checkout master', show_cmd: true
65
- Util.system! 'git pull', show_cmd: true
66
- Util.system! 'git merge production', show_cmd: true
67
- Util.system! 'git push', show_cmd: true
62
+ Util.run!('git push', show_cmd: true)
63
+ Util.run!('git checkout master', show_cmd: true)
64
+ Util.run!('git pull', show_cmd: true)
65
+ Util.run!('git merge production', show_cmd: true)
66
+ Util.run!('git push', show_cmd: true)
68
67
 
69
68
  Interaction.announce 'Deployment'
70
69
  deploy = (Util.gem_major_version('capistrano') == 3) ? 'deploy' : 'deploy:migrations'
@@ -77,7 +76,7 @@ def security_update(step = 'prepare')
77
76
  Interaction.prompt('Deploy staging now?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
78
77
 
79
78
  Interaction.announce 'Deploy staging'
80
- Util.system! "bundle exec cap staging #{deploy}", show_cmd: true
79
+ Util.run! "bundle exec cap staging #{deploy}", show_cmd: true
81
80
 
82
81
  Interaction.prompt('Is the deployment log okay and the application is still running on staging?', 'y', /y|yes/) || Interaction.fail('Please fix the deployment issues on staging before you continue.')
83
82
  else
@@ -97,7 +96,7 @@ def security_update(step = 'prepare')
97
96
 
98
97
  deploy_targets_without_staging.each do |target|
99
98
  Interaction.announce "Deploy #{target}"
100
- Util.system! "bundle exec cap #{target} #{deploy}", show_cmd: true
99
+ Util.run!("bundle exec cap #{target} #{deploy}", show_cmd: true)
101
100
  end
102
101
 
103
102
  Interaction.prompt('Is the application still running on all other stages and the logs are okay?', 'y', /y|yes/) || Interaction.fail('Please fix the application immediately!')
@@ -3,11 +3,11 @@ desc 'server [PORT]', 'Start a development server'
3
3
  option :port, aliases: '-p', default: '3000',
4
4
  desc: 'Choose a port'
5
5
  option :public, aliases: '-P', type: :boolean,
6
- desc: 'Make the server accessible in the local network'
6
+ desc: 'Make the server accessible from the local network'
7
7
 
8
8
  def server(port = nil)
9
- invoke_cmd 'bundle_install'
10
- invoke_cmd 'yarn_install'
9
+ invoke_geordi 'bundle_install'
10
+ invoke_geordi 'yarn_install'
11
11
  require 'geordi/util'
12
12
 
13
13
  Interaction.announce 'Booting a development server'
@@ -18,7 +18,7 @@ def server(port = nil)
18
18
  command = Util.server_command
19
19
  command << ' -b 0.0.0.0' if options.public
20
20
  command << ' -p ' << port
21
- Util.system! command
21
+ Util.run!(command)
22
22
  end
23
23
 
24
24
  map 'devserver' => 'server'
@@ -6,17 +6,8 @@ Check out a repository and cd into its directory. Then let `setup` do the tiring
6
6
  work: run `bundle install`, create `database.yml`, create databases, migrate
7
7
  (all if applicable).
8
8
 
9
- If a local bin/setup file is found, Geordi skips these steps runs bin/setup
10
- for setup instead.
11
-
12
- After setting up, loads a remote database dump into the development db when
13
- called with the `--dump` option:
14
-
15
- geordi setup -d staging
16
-
17
- After setting up, runs all tests when called with the `--test` option:
18
-
19
- geordi setup -t
9
+ If a local bin/setup file is found, Geordi skips its routine and runs bin/setup
10
+ instead.
20
11
  LONGDESC
21
12
 
22
13
  option :dump, type: :string, aliases: '-d', banner: 'TARGET',
@@ -28,14 +19,14 @@ def setup
28
19
  Interaction.announce 'Running bin/setup'
29
20
  Interaction.note "Geordi's own setup routine is skipped"
30
21
 
31
- Util.system! 'bin/setup'
22
+ Util.run!('bin/setup')
32
23
  else
33
- invoke_cmd 'create_databases'
34
- invoke_cmd 'migrate'
24
+ invoke_geordi 'create_databases'
25
+ invoke_geordi 'migrate'
35
26
  end
36
27
 
37
28
  Interaction.success 'Successfully set up the project.'
38
29
 
39
- invoke_cmd 'dump', options.dump, load: true if options.dump
40
- invoke_cmd 'tests' if options.test
30
+ invoke_geordi 'dump', options.dump, load: true if options.dump
31
+ invoke_geordi 'tests' if options.test
41
32
  end
@@ -2,22 +2,21 @@ desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
2
2
  long_desc <<-LONGDESC
3
3
  Example: `geordi shell production`
4
4
 
5
- Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
6
-
7
- geordi shell production -s
8
-
9
- If you already know the number of the server you want to connect to, just pass it along:
10
-
11
- geordi shell production -s2
5
+ Selecting the server: `geordi shell staging -s` shows a menu with all available
6
+ servers. When passed a number, directly connects to the selected server.
12
7
  LONGDESC
13
8
 
14
- option :select_server, type: :string, aliases: '-s'
9
+ # This option is duplicated in console.rb
10
+ option :select_server, type: :string, aliases: '-s', banner: '[SERVER_NUMBER]',
11
+ desc: 'Select a server to connect to'
15
12
 
16
13
  # This method has a triple 'l' because :shell is a Thor reserved word. However,
17
14
  # it can still be called with `geordi shell` :)
18
15
  def shelll(target, *_args)
19
16
  require 'geordi/remote'
20
17
 
18
+ invoke_geordi 'bundle_install'
19
+
21
20
  Interaction.announce 'Opening a shell on ' + target
22
21
  Geordi::Remote.new(target).shell(options)
23
22
  end
@@ -1,13 +1,13 @@
1
1
  desc 'tests', 'Run all employed tests'
2
2
  def tests
3
- rake_result = invoke_cmd 'with_rake'
3
+ rake_result = invoke_geordi 'with_rake'
4
4
 
5
5
  # Since `rake` usually is configured to run all tests, only run them if `rake`
6
6
  # did not perform
7
7
  if rake_result == :did_not_perform
8
- invoke_cmd 'unit'
9
- invoke_cmd 'rspec'
10
- invoke_cmd 'cucumber'
8
+ invoke_geordi 'unit'
9
+ invoke_geordi 'rspec'
10
+ invoke_geordi 'cucumber'
11
11
  end
12
12
 
13
13
  Interaction.success 'Successfully ran tests.'
@@ -1,11 +1,11 @@
1
1
  desc 'unit', 'Run Test::Unit'
2
2
  def unit
3
3
  if File.exist?('test/test_helper.rb')
4
- invoke_cmd 'bundle_install'
5
- invoke_cmd 'yarn_install'
4
+ invoke_geordi 'bundle_install'
5
+ invoke_geordi 'yarn_install'
6
6
 
7
7
  Interaction.announce 'Running Test::Unit'
8
- Util.system! 'bundle exec rake test'
8
+ Util.run!([Util.binstub_or_fallback('rake'), 'test'])
9
9
  else
10
10
  Interaction.note 'Test::Unit not employed.'
11
11
  end
@@ -3,17 +3,6 @@ long_desc <<-LONGDESC
3
3
  Example: `geordi update`
4
4
 
5
5
  Performs: `git pull`, `bundle install` (if necessary) and migrates (if applicable).
6
-
7
- After updating, loads a dump into the development db when called with the
8
- `--dump` option:
9
-
10
- geordi update -d staging
11
-
12
- After updating, runs all tests when called with the `--test` option:
13
-
14
- geordi update -t
15
-
16
- See `geordi help update` for details.
17
6
  LONGDESC
18
7
 
19
8
  option :dump, type: :string, aliases: '-d', banner: 'TARGET',
@@ -22,12 +11,12 @@ option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
22
11
 
23
12
  def update
24
13
  Interaction.announce 'Updating repository'
25
- Util.system! 'git pull', show_cmd: true
14
+ Util.run!('git pull', show_cmd: true)
26
15
 
27
- invoke_cmd 'migrate'
16
+ invoke_geordi 'migrate'
28
17
 
29
18
  Interaction.success 'Successfully updated the project.'
30
19
 
31
- invoke_cmd 'dump', options.dump, load: true if options.dump
32
- invoke_cmd 'tests' if options.test
20
+ invoke_geordi 'dump', options.dump, load: true if options.dump
21
+ invoke_geordi 'tests' if options.test
33
22
  end