geordi 4.1.0 → 4.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e69ce9156f933f0ae381e109b7359fe4da6243036028093ab9ce0f79408bfaad
4
- data.tar.gz: d6d16d8a1aca0fecc4669aa0b28251c508574f7d4d5ba3fae5d82d92385894fd
3
+ metadata.gz: 2af11b387f28e87fc2cb89172b1ea8fdcd87dc4bc62697c18ba4a7cc8ddada28
4
+ data.tar.gz: c0612fe6e8f266a3b5e5a467018b5f6e484224944057ddd323c9162a0b64d858
5
5
  SHA512:
6
- metadata.gz: 8d514a744b90c1d637a91db63ca3c58a36262e3493844a268eea48c920779f98ead441eeff42a9d544e0b0feb6baeb0d9314906531c1b9c3955bbb0758b2e316
7
- data.tar.gz: c75477cfb8ffb09895f1b6214ef762218e85b831adb4348ea58ed4cae6dd70a213feb7e2df3dc0740a97b0e70394be4878abeff57fb4aefd47a50eed7af5f10d
6
+ metadata.gz: e96089335890efaf9e8ea9a0cabea1c4a6447e363513f61fa2e2fe55f43637ca24906fd3732fd3eb0b5adb752bd2a752a263a0be772bedba1b7115e69425b5d2
7
+ data.tar.gz: bad860e3b8a14d06970351213fda638e2b853dfbf107ea6b6f4e018cd2ecdbb767848a2ebdec34757f3c5a9d47e8a2a3181ac40c729b1b3a9cbb26e62aaf1613
@@ -9,6 +9,32 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
9
9
  ### Breaking changes
10
10
 
11
11
 
12
+ ## 4.1.1 2020-08-28
13
+ ### Compatible changes
14
+
15
+ * Fixed: System calls are not executed properly if no bin stub is present. This resulted in errors like:
16
+
17
+ ```
18
+ % geordi rspec
19
+
20
+ # Running specs
21
+ > All specs at once (using parallel_tests)
22
+
23
+ x Specs failed.
24
+ ```
25
+
26
+ or
27
+
28
+ ```
29
+ % geordi migrate
30
+
31
+ # Migrating
32
+ > Development and parallel test databases
33
+
34
+ x Something went wrong.
35
+ ```
36
+
37
+
12
38
  ## 4.1.0 2020-08-18
13
39
 
14
40
  ### Compatible changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (4.1.0)
4
+ geordi (4.1.1)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
@@ -21,7 +21,7 @@ option :opt, type: :boolean, aliases: '-o', banner: 'VALUE_NAME', desc: 'If set,
21
21
 
22
22
  def example
23
23
  # Invoke other commands like this:
24
- invoke_cmd 'other_command', 'argument', an: 'option'
24
+ invoke_geordi 'other_command', 'argument', an: 'option'
25
25
 
26
26
  Interaction.fail 'Option missing' unless options.opt?
27
27
 
@@ -18,7 +18,7 @@ module Geordi
18
18
  private
19
19
 
20
20
  # fix weird implementation of #invoke
21
- def invoke_cmd(name, *args)
21
+ def invoke_geordi(name, *args)
22
22
  options = args.last.is_a?(Hash) ? args.pop : {}
23
23
  invoke(name, args, options)
24
24
  end
@@ -2,6 +2,6 @@ desc 'bundle-install', 'Run bundle install if required', hide: true
2
2
  def bundle_install
3
3
  if File.exist?('Gemfile') && !system('bundle check > /dev/null 2>&1')
4
4
  Interaction.announce 'Bundling'
5
- Util.system! 'bundle install'
5
+ Util.run!('bundle install')
6
6
  end
7
7
  end
@@ -17,6 +17,6 @@ def capistrano(*args)
17
17
  command = "bundle exec cap #{stage} " + args.join(' ')
18
18
  Interaction.note_cmd command
19
19
 
20
- Util.system!(command, fail_message: 'Capistrano failed. Have a look!')
20
+ Util.run!(command, fail_message: 'Capistrano failed. Have a look!')
21
21
  end
22
22
  end
@@ -14,14 +14,15 @@ option :select_server, type: :string, aliases: '-s', banner: '[SERVER_NUMBER]',
14
14
 
15
15
  def console(target = 'development', *_args)
16
16
  require 'geordi/remote'
17
- invoke_cmd 'bundle_install'
17
+ invoke_geordi 'bundle_install'
18
18
 
19
19
  if target == 'development'
20
- invoke_cmd 'yarn_install'
20
+ invoke_geordi 'yarn_install'
21
21
 
22
22
  Interaction.announce 'Opening a local Rails console'
23
23
 
24
- Util.system! Util.console_command(target)
24
+ command = Util.console_command(target)
25
+ Util.run!(command)
25
26
  else
26
27
  Interaction.announce 'Opening a Rails console on ' + target
27
28
 
@@ -1,16 +1,17 @@
1
1
  desc 'create-databases', 'Create all databases', hide: true
2
2
  def create_databases
3
- invoke_cmd 'create_database_yml'
4
- invoke_cmd 'bundle_install'
3
+ invoke_geordi 'create_database_yml'
4
+ invoke_geordi 'bundle_install'
5
5
 
6
6
  Interaction.announce 'Creating databases'
7
7
 
8
8
  if File.exist?('config/database.yml')
9
- command = Util.binstub 'rake'
10
- command << ' db:create:all'
11
- command << ' parallel:create' if Util.file_containing?('Gemfile', /parallel_tests/)
9
+ command = []
10
+ command << Util.binstub_or_fallback('rake')
11
+ command << 'db:create:all'
12
+ command << 'parallel:create' if Util.file_containing?('Gemfile', /parallel_tests/)
12
13
 
13
- Util.system! command
14
+ Util.run!(command)
14
15
  else
15
16
  puts 'config/database.yml does not exist. Nothing to do.'
16
17
  end
@@ -53,8 +53,8 @@ def cucumber(*args)
53
53
  if File.directory?('features')
54
54
  require 'geordi/cucumber'
55
55
 
56
- invoke_cmd 'bundle_install'
57
- invoke_cmd 'yarn_install'
56
+ invoke_geordi 'bundle_install'
57
+ invoke_geordi 'yarn_install'
58
58
 
59
59
  cmd_opts, files = args.partition { |f| f.start_with? '-' }
60
60
  cmd_opts << '--format' << 'pretty' << '--backtrace' if options.debug
@@ -66,7 +66,7 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
66
66
  push_needed = false if Util.testing? # Hard to test
67
67
 
68
68
  Interaction.announce "Checking whether your #{source_branch} branch is ready" ############
69
- Util.system! "git checkout #{source_branch}"
69
+ Util.run!("git checkout #{source_branch}")
70
70
  if (`git status -s | wc -l`.strip != '0') && !Util.testing?
71
71
  Interaction.warn "Your #{source_branch} branch holds uncommitted changes."
72
72
  Interaction.prompt('Continue anyway?', 'n', /y|yes/) || raise('Cancelled.')
@@ -76,14 +76,14 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
76
76
 
77
77
  if merge_needed
78
78
  Interaction.announce "Checking what's in your #{target_branch} branch right now" #######
79
- Util.system! "git checkout #{target_branch} && git pull"
79
+ Util.run!("git checkout #{target_branch} && git pull")
80
80
  end
81
81
 
82
82
  Interaction.announce 'You are about to:' #################################################
83
83
  Interaction.note "Merge branch #{source_branch} into #{target_branch}" if merge_needed
84
84
  if push_needed
85
85
  Interaction.note 'Push these commits:' if push_needed
86
- Util.system! "git --no-pager log origin/#{target_branch}..#{source_branch} --oneline"
86
+ Util.run!("git --no-pager log origin/#{target_branch}..#{source_branch} --oneline")
87
87
  end
88
88
  Interaction.note "Deploy to #{target_stage}"
89
89
  Interaction.note "From current branch #{source_branch}" if options.current_branch
@@ -94,7 +94,7 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
94
94
  git_call << "git merge #{source_branch}" if merge_needed
95
95
  git_call << 'git push' if push_needed
96
96
 
97
- invoke_cmd 'bundle_install'
97
+ invoke_geordi 'bundle_install'
98
98
 
99
99
  capistrano_call = "cap #{target_stage} deploy"
100
100
  capistrano_call << ':migrations' unless Util.gem_major_version('capistrano') == 3 || options.no_migrations
@@ -102,14 +102,14 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
102
102
  capistrano_call = "DEPLOY_BRANCH=#{source_branch} #{capistrano_call}" if options.current_branch
103
103
 
104
104
  if git_call.any?
105
- Util.system! git_call.join(' && '), show_cmd: true
105
+ Util.run!(git_call.join(' && '), show_cmd: true)
106
106
  end
107
107
 
108
- Util.system! capistrano_call, show_cmd: true
108
+ Util.run!(capistrano_call, show_cmd: true)
109
109
 
110
110
  Interaction.success 'Deployment complete.'
111
111
  else
112
- Util.system! "git checkout #{source_branch}"
112
+ Util.run!("git checkout #{source_branch}")
113
113
  Interaction.fail 'Deployment cancelled.'
114
114
  end
115
115
  end
@@ -33,7 +33,7 @@ def dump(target = nil, *_args)
33
33
 
34
34
  else
35
35
  Interaction.announce 'Dumping the development database'
36
- Util.system! 'dumple development'
36
+ Util.run!('dumple development')
37
37
  Interaction.success 'Successfully dumped the development database.'
38
38
  end
39
39
 
@@ -25,7 +25,7 @@ def firefox(*command)
25
25
 
26
26
  puts
27
27
  Interaction.note_cmd command.join(' ')
28
- system *command # Util.system! would reset the Firefox PATH
28
+ system *command # Util.run! would reset the Firefox PATH
29
29
  end
30
30
  end
31
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! Util.binstub('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,14 +10,16 @@ Example: `geordi rake db:migrate`
10
10
  LONGDESC
11
11
 
12
12
  def rake(*args)
13
- invoke_cmd 'bundle_install'
13
+ invoke_geordi 'bundle_install'
14
14
 
15
15
  %w[development test cucumber].each do |env| # update long_desc when changing this
16
16
  if File.exist? "config/environments/#{env}.rb"
17
- call = [Util.binstub('rake')] + args + ["RAILS_ENV=#{env}"]
18
- Interaction.note_cmd call.join(' ')
17
+ command = []
18
+ command << Util.binstub_or_fallback('rake')
19
+ command += args
20
+ command << "RAILS_ENV=#{env}"
19
21
 
20
- Util.system! *call
22
+ Util.run!(command, show_cmd: true)
21
23
  end
22
24
  end
23
25
  end
@@ -7,14 +7,14 @@ LONGDESC
7
7
 
8
8
  def rspec(*files)
9
9
  if File.exist?('spec/spec_helper.rb')
10
- invoke_cmd 'bundle_install'
11
- invoke_cmd 'yarn_install'
10
+ invoke_geordi 'bundle_install'
11
+ invoke_geordi 'yarn_install'
12
12
 
13
13
  Interaction.announce 'Running specs'
14
14
 
15
15
  if Util.file_containing?('Gemfile', /parallel_tests/) && files.empty?
16
16
  Interaction.note 'All specs at once (using parallel_tests)'
17
- Util.system! Util.binstub('rake'), 'parallel:spec', fail_message: 'Specs failed.'
17
+ Util.run!([Util.binstub_or_fallback('rake'), 'parallel:spec'], fail_message: 'Specs failed.')
18
18
 
19
19
  else
20
20
  # tell which specs will be run
@@ -28,13 +28,13 @@ def rspec(*files)
28
28
  command = if File.exist?('script/spec')
29
29
  ['bundle exec spec -c'] # RSpec 1
30
30
  else
31
- [Util.binstub('rspec')]
31
+ [Util.binstub_or_fallback('rspec')]
32
32
  end
33
33
  command << '-r rspec_spinner -f RspecSpinner::Bar' if Util.file_containing?('Gemfile', /rspec_spinner/)
34
34
  command << files.join(' ')
35
35
 
36
36
  puts
37
- Util.system! command.join(' '), fail_message: 'Specs failed.'
37
+ Util.run!(command.join(' '), fail_message: 'Specs failed.')
38
38
  end
39
39
  else
40
40
  Interaction.note 'RSpec not employed.'
@@ -35,8 +35,8 @@ def security_update(step = 'prepare')
35
35
  Interaction.note 'About to checkout production and pull.'
36
36
  Interaction.prompt('Continue?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
37
37
 
38
- Util.system! 'git checkout production', show_cmd: true
39
- Util.system! 'git pull', show_cmd: true
38
+ Util.run!('git checkout production', show_cmd: true)
39
+ Util.run!('git pull', show_cmd: true)
40
40
 
41
41
  Interaction.success 'Successfully prepared for security update'
42
42
  puts
@@ -47,7 +47,7 @@ def security_update(step = 'prepare')
47
47
  when 'f', 'finish'
48
48
  # ensure everything is committed
49
49
  if Util.testing?
50
- puts 'Util.system! git status --porcelain'
50
+ puts 'Util.run! git status --porcelain'
51
51
  else
52
52
  `git status --porcelain`.empty? || Interaction.fail('Please commit your changes before finishing the update.')
53
53
  end
@@ -59,11 +59,11 @@ def security_update(step = 'prepare')
59
59
  Interaction.note 'About to: push production, checkout & pull master, merge production, push master.'
60
60
  Interaction.prompt('Continue?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
61
61
 
62
- Util.system! 'git push', show_cmd: true
63
- Util.system! 'git checkout master', show_cmd: true
64
- Util.system! 'git pull', show_cmd: true
65
- Util.system! 'git merge production', show_cmd: true
66
- 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)
67
67
 
68
68
  Interaction.announce 'Deployment'
69
69
  deploy = (Util.gem_major_version('capistrano') == 3) ? 'deploy' : 'deploy:migrations'
@@ -76,7 +76,7 @@ def security_update(step = 'prepare')
76
76
  Interaction.prompt('Deploy staging now?', 'y', /y|yes/) || Interaction.fail('Cancelled.')
77
77
 
78
78
  Interaction.announce 'Deploy staging'
79
- Util.system! "bundle exec cap staging #{deploy}", show_cmd: true
79
+ Util.run! "bundle exec cap staging #{deploy}", show_cmd: true
80
80
 
81
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.')
82
82
  else
@@ -96,7 +96,7 @@ def security_update(step = 'prepare')
96
96
 
97
97
  deploy_targets_without_staging.each do |target|
98
98
  Interaction.announce "Deploy #{target}"
99
- Util.system! "bundle exec cap #{target} #{deploy}", show_cmd: true
99
+ Util.run!("bundle exec cap #{target} #{deploy}", show_cmd: true)
100
100
  end
101
101
 
102
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!')
@@ -6,8 +6,8 @@ option :public, aliases: '-P', type: :boolean,
6
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'
@@ -19,14 +19,14 @@ def setup
19
19
  Interaction.announce 'Running bin/setup'
20
20
  Interaction.note "Geordi's own setup routine is skipped"
21
21
 
22
- Util.system! 'bin/setup'
22
+ Util.run!('bin/setup')
23
23
  else
24
- invoke_cmd 'create_databases'
25
- invoke_cmd 'migrate'
24
+ invoke_geordi 'create_databases'
25
+ invoke_geordi 'migrate'
26
26
  end
27
27
 
28
28
  Interaction.success 'Successfully set up the project.'
29
29
 
30
- invoke_cmd 'dump', options.dump, load: true if options.dump
31
- invoke_cmd 'tests' if options.test
30
+ invoke_geordi 'dump', options.dump, load: true if options.dump
31
+ invoke_geordi 'tests' if options.test
32
32
  end
@@ -15,7 +15,7 @@ option :select_server, type: :string, aliases: '-s', banner: '[SERVER_NUMBER]',
15
15
  def shelll(target, *_args)
16
16
  require 'geordi/remote'
17
17
 
18
- invoke_cmd 'bundle_install'
18
+ invoke_geordi 'bundle_install'
19
19
 
20
20
  Interaction.announce 'Opening a shell on ' + target
21
21
  Geordi::Remote.new(target).shell(options)
@@ -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! Util.binstub('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
@@ -11,12 +11,12 @@ option :test, type: :boolean, aliases: '-t', desc: 'After updating, run tests'
11
11
 
12
12
  def update
13
13
  Interaction.announce 'Updating repository'
14
- Util.system! 'git pull', show_cmd: true
14
+ Util.run!('git pull', show_cmd: true)
15
15
 
16
- invoke_cmd 'migrate'
16
+ invoke_geordi 'migrate'
17
17
 
18
18
  Interaction.success 'Successfully updated the project.'
19
19
 
20
- invoke_cmd 'dump', options.dump, load: true if options.dump
21
- invoke_cmd 'tests' if options.test
20
+ invoke_geordi 'dump', options.dump, load: true if options.dump
21
+ invoke_geordi 'tests' if options.test
22
22
  end
@@ -10,7 +10,7 @@ option :setup, type: :boolean, desc: 'Guide through the setup of VNC'
10
10
 
11
11
  def vnc
12
12
  if options.setup
13
- invoke_cmd :_setup_vnc
13
+ invoke_geordi :_setup_vnc
14
14
  else
15
15
  require 'geordi/cucumber'
16
16
  Geordi::Cucumber.new.launch_vnc_viewer
@@ -1,11 +1,11 @@
1
1
  desc 'with-rake', 'Run tests with `rake`', hide: true
2
2
  def with_rake
3
3
  if Util.file_containing?('Rakefile', /^task.+default.+(spec|test|feature)/)
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 tests with `rake`'
8
- Util.system! Util.binstub('rake')
8
+ Util.run!(Util.binstub_or_fallback('rake'))
9
9
  else
10
10
  Interaction.note '`rake` does not run tests.'
11
11
  :did_not_perform
@@ -3,6 +3,6 @@ desc 'yarn-install', 'Runs yarn install if required', hide: true
3
3
  def yarn_install
4
4
  if File.exist?('package.json') && !system('yarn check --integrity > /dev/null 2>&1')
5
5
  Interaction.announce 'Yarn install'
6
- Util.system! 'yarn install'
6
+ Util.run!('yarn install')
7
7
  end
8
8
  end
@@ -27,7 +27,7 @@ module Geordi
27
27
  Interaction.note_cmd(command) if options[:verbose]
28
28
 
29
29
  puts # Make newline
30
- system command # Util.system! would reset the Firefox PATH
30
+ system command # Util.run! would reset the Firefox PATH
31
31
  end
32
32
 
33
33
  def launch_vnc_viewer
@@ -74,7 +74,7 @@ module Geordi
74
74
  unless argv.include?('--format') || argv.include?('-f')
75
75
  format_args = spinner_available? ? ['--format', 'CucumberSpinner::CuriousProgressBarFormatter'] : ['--format', 'progress']
76
76
  end
77
- [use_firefox_for_selenium, Util.binstub('cucumber'), format_args, escape_shell_args(argv)].flatten.compact.join(' ')
77
+ [use_firefox_for_selenium, Util.binstub_or_fallback('cucumber'), format_args, escape_shell_args(argv)].flatten.compact.join(' ')
78
78
  end
79
79
 
80
80
  def parallel_execution_command
@@ -57,7 +57,7 @@ module Geordi
57
57
  Interaction.note 'Source file: ' + dump_file
58
58
 
59
59
  source_command = send("#{config['adapter']}_command")
60
- Util.system! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
60
+ Util.run! source_command, fail_message: "An error occured loading #{File.basename(dump_file)}"
61
61
  end
62
62
 
63
63
  end
@@ -89,7 +89,7 @@ No staged changes. Will create an empty commit.
89
89
  extra = highline.ask("\nAdd an optional message").strip
90
90
  message << ' - ' << extra if extra != ''
91
91
 
92
- Geordi::Util.system! 'git', 'commit', '--allow-empty', '-m', message, *git_args
92
+ Geordi::Util.run!(['git', 'commit', '--allow-empty', '-m', message, *git_args])
93
93
  end
94
94
 
95
95
  def bold(string)
@@ -24,7 +24,7 @@ module Geordi
24
24
  end
25
25
 
26
26
  # Like `note`, but pink. Use to print (bash) commands.
27
- # Also see Util.system!
27
+ # Also see Util.run!
28
28
  def note_cmd(text)
29
29
  message = "> #{text}"
30
30
  puts "\e[35m#{message}\e[0m" # pink
@@ -43,7 +43,7 @@ module Geordi
43
43
 
44
44
  Interaction.note "Downloading remote dump to #{relative_destination} ..."
45
45
  server = @config.primary_server
46
- Util.system! "scp -C #{@config.user(server)}@#{server}:#{REMOTE_DUMP_PATH} #{destination_path}"
46
+ Util.run!("scp -C #{@config.user(server)}@#{server}:#{REMOTE_DUMP_PATH} #{destination_path}")
47
47
 
48
48
  Interaction.success "Dumped the #{@stage} database to #{relative_destination}."
49
49
 
@@ -74,7 +74,7 @@ module Geordi
74
74
  remote_command << " -c '#{options[:remote_command]}'" if options[:remote_command]
75
75
 
76
76
  Interaction.note 'Connecting to ' + server.to_s
77
- Util.system! 'ssh', "#{@config.user(server)}@#{server}", '-t', remote_command
77
+ Util.run!(['ssh', "#{@config.user(server)}@#{server}", '-t', remote_command])
78
78
  end
79
79
 
80
80
  end
@@ -21,7 +21,7 @@ module Geordi
21
21
  # install missing gem
22
22
  Interaction.warn 'Probably missing gem: ' + gem_name
23
23
  Interaction.prompt('Install it now?', 'y', /y|yes/) || Interaction.fail('Missing Gems.')
24
- system! install_command, show_cmd: true
24
+ Util.run!(install_command, show_cmd: true)
25
25
 
26
26
  # retry
27
27
  Gem.clear_paths
@@ -33,50 +33,60 @@ module Geordi
33
33
  # Run a command with a clean environment.
34
34
  # Print an error message and exit if the command fails.
35
35
  #
36
- # @option show_cmd: Whether to print the command
37
- # @option confirm: Whether to ask for confirmation before running it
38
- # @option fail_message: The text to print on command failure
39
- def system!(*commands)
40
- options = commands.last.is_a?(Hash) ? commands.pop : {}
41
- Interaction.note_cmd commands.join(' ') if options[:show_cmd]
42
-
43
- if options[:confirm]
36
+ # show_cmd: Whether to print the command
37
+ # confirm: Whether to ask for confirmation before running it
38
+ # fail_message: The text to print on command failure
39
+ def run!(command, show_cmd: false, confirm: false, fail_message: 'Something went wrong.')
40
+ # Disable shell features for arrays https://stackoverflow.com/questions/13338147/ruby-system-method-arguments
41
+ # Conversion: ['ls *', 'some arg'] => ['ls', '*', 'some arg']
42
+ # If you need shell features, you need to pass in a String instead of an array.
43
+ if command.is_a?(Array)
44
+ real_command, *arguments = *command
45
+ command = [real_command.split(' '), arguments].flatten
46
+ printable_command = command.join(', ')
47
+ else
48
+ printable_command = command
49
+ end
50
+
51
+ if show_cmd
52
+ Interaction.note_cmd printable_command
53
+ end
54
+
55
+ if confirm
44
56
  Interaction.prompt('Run this now?', 'n', /y|yes/) or Interaction.fail('Cancelled.')
45
57
  end
46
58
 
47
59
  if testing?
48
- puts "Util.system! #{commands.join ', '}"
60
+ puts "Util.run! #{printable_command}"
49
61
  else
50
62
  # Remove Geordi's Bundler environment when running commands.
51
63
  success = if !defined?(Bundler)
52
- system(*commands)
64
+ system(*command)
53
65
  elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.1.2')
54
66
  Bundler.with_original_env do
55
- system(*commands)
67
+ system(*command)
56
68
  end
57
69
  else
58
- Bundler.clean_system(*commands)
70
+ Bundler.clean_system(*command)
59
71
  end
60
72
 
61
- success || Interaction.fail(options[:fail_message] || 'Something went wrong.')
73
+ success || Interaction.fail(fail_message)
62
74
  end
63
75
  end
64
76
 
65
- def binstub(executable, *arguments)
77
+ def binstub_or_fallback(executable)
66
78
  binstub_file = "bin/#{executable}"
67
79
 
68
- command = File.exists?(binstub_file) ? [binstub_file] : ['bundle exec', executable]
69
- command.push(*arguments)
70
- command.join(' ')
80
+ File.exists?(binstub_file) ? binstub_file : "bundle exec #{executable}"
71
81
  end
72
82
 
73
83
  def console_command(environment)
74
84
  if gem_major_version('rails') == 2
75
85
  'script/console ' + environment
76
86
  elsif gem_major_version('rails') == 3
77
- binstub 'rails', 'console', environment
87
+ "#{binstub_or_fallback('rails')} console #{environment}"
78
88
  else
79
- binstub 'rails', 'console -e', environment
89
+ "#{binstub_or_fallback('rails')} console -e #{environment}"
80
90
  end
81
91
  end
82
92
 
@@ -84,7 +94,7 @@ module Geordi
84
94
  if gem_major_version('rails') == 2
85
95
  'script/server ""'
86
96
  else
87
- binstub 'rails', 'server'
97
+ "#{binstub_or_fallback('rails')} server"
88
98
  end
89
99
  end
90
100
 
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '4.1.0'.freeze
2
+ VERSION = '4.1.1'.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.0
4
+ version: 4.1.1
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-18 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.1.4
121
+ rubygems_version: 3.0.8
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