avm-tools 0.65.0 → 0.66.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b49415c22196804138f3b05422b6efeec1aa7d092d4ec282721b4a292b81cc26
4
- data.tar.gz: da7e1f8019ee6ea9694088a328f8c988143325f72fca48b99e082a8217616aca
3
+ metadata.gz: 5fadfbad4ae6f17cae7e5137761710e454d858b08f56b0f666956d7f84c9787b
4
+ data.tar.gz: 30bceb50691d6c31bd34980c0985f4a689d16075f01ffba2495441d67913e312
5
5
  SHA512:
6
- metadata.gz: 993126704ac357031cd9f050964aace90fedb10c29849b1de13a05b1cc4f8c222223f6d10604517d5a87c03bcf03d09337d517e067cad85af0aba9c39e001af2
7
- data.tar.gz: 40d27a357cf1ba0d5534289bebc3cbf2a529e4250cee92a8a6de80b623a5ba6b9d055c22f397e133e1f5fcc5ec26e57e9d307c07acc1e70721600a57a7930258
6
+ metadata.gz: 5c88f25a0c0a7ae293d3c7b40f8708cfcdbfe92ace54a85c0b028751b75a044aa0c9ad437d16b3d47e0895bee0338119c6ea18cbf1328124dab7189f28852353
7
+ data.tar.gz: eab8e705b2d927f0d196117592a5273ce01f3f55e67e2074691500e44164eed3df86e50e69ece788f77c01fc4b06f39f3aeb670f389ab992c7d539ebc1206eca
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'eac_cli/default_runner'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
12
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
13
+ require_sub __FILE__
14
+ include ::EacCli::DefaultRunner
15
+
16
+ runner_definition do
17
+ desc 'Ruby utitilies for local projects.'
18
+ subcommands
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
12
+ class Bundler < ::EacRubyUtils::Console::DocoptRunner
13
+ require_sub __FILE__
14
+ include ::EacCli::DefaultRunner
15
+
16
+ runner_definition do
17
+ desc 'Ruby\'s bundler utitilies for local projects.'
18
+ subcommands
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,138 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
11
+ class Bundler < ::EacRubyUtils::Console::DocoptRunner
12
+ class GemfileLock < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+
15
+ runner_definition do
16
+ desc 'Manipulage a "Gemfile.lock" file.'
17
+ bool_opt '-c', '--continue', 'Continue Git rebase/cherry-pick.'
18
+ bool_opt '-i', '--install', 'Run "bundle install".'
19
+ bool_opt '-u', '--update', 'Run "bundle update".'
20
+ bool_opt '-r', '--recursive', 'Run until Git rebase/cherry-pick is finished.'
21
+ bool_opt '-a', '--all', 'Same as "-ciru".'
22
+ end
23
+
24
+ def run
25
+ loop do
26
+ git_reset_checkout
27
+ bundle_update
28
+ bundle_install
29
+ git_continue
30
+ break if complete?
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def complete?
37
+ !option_or_all?('--recursive') || !conflict?
38
+ end
39
+
40
+ def rebasing?
41
+ instance.git_repo.root_path.join('.git', 'rebase-merge').exist?
42
+ end
43
+
44
+ def git_reset_checkout
45
+ return unless check_capability(__method__, :git_repo, nil)
46
+
47
+ infom 'Reseting...'
48
+ instance.git_repo.command('reset', gemfile_lock).system!
49
+ infom 'Checkouting...'
50
+ instance.git_repo.command('checkout', '--', gemfile_lock).system!
51
+ end
52
+
53
+ def bundle_install
54
+ return unless check_capability(__method__, :ruby_gem, '--install')
55
+
56
+ infom '"bundle install"...'
57
+ bundle_run('install')
58
+ end
59
+
60
+ def bundle_update
61
+ return unless check_capability(__method__, :ruby_gem, '--update')
62
+
63
+ infom '"bundle update"...'
64
+ bundle_run('update')
65
+ end
66
+
67
+ def git_continue
68
+ return unless check_capability(__method__, :git_repo, '--continue')
69
+
70
+ infom "Adding \"#{gemfile_lock}\"..."
71
+ instance.git_repo.command('add', gemfile_lock).execute!
72
+ if rebase_conflict?
73
+ git_continue_run('rebase')
74
+ elsif cherry_conflict?
75
+ git_continue_run('cherry-pick')
76
+ else
77
+ raise 'Unknown how to continue'
78
+ end
79
+ end
80
+
81
+ def git_continue_run(command)
82
+ infom "\"#{command}\" --continue..."
83
+ cmd = instance.git_repo.command(command, '--continue').envvar('GIT_EDITOR', 'true')
84
+ return unless !cmd.system && !conflict?
85
+
86
+ fatal_error "\"#{cmd}\" failed and there is no conflict"
87
+ end
88
+
89
+ def gemfile_lock
90
+ 'Gemfile.lock'
91
+ end
92
+
93
+ def git_uncached
94
+ ::EacGit::Local.new(git_path)
95
+ end
96
+
97
+ def bundle_run(*args)
98
+ instance.ruby_gem.bundle(*args).system!
99
+ end
100
+
101
+ def git_path
102
+ '.'
103
+ end
104
+
105
+ def conflict?
106
+ rebase_conflict? || cherry_conflict?
107
+ end
108
+
109
+ def rebase_conflict?
110
+ instance.git_repo.root_path.join('.git', 'REBASE_HEAD').exist?
111
+ end
112
+
113
+ def cherry_conflict?
114
+ instance.git_repo.root_path.join('.git', 'CHERRY_PICK_HEAD').exist?
115
+ end
116
+
117
+ def option_or_all?(option)
118
+ options.fetch(option) || options.fetch('--all')
119
+ end
120
+
121
+ def instance
122
+ context(:instance)
123
+ end
124
+
125
+ def check_capability(caller, capability, option)
126
+ return false unless option.blank? || option_or_all?(option)
127
+ return true if instance.respond_to?(capability)
128
+
129
+ warn "Cannot run #{caller}: instance has no capability \"#{capability}\""
130
+ false
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.65.0'
5
+ VERSION = '0.66.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -489,6 +489,9 @@ files:
489
489
  - lib/avm/tools/runner/launcher/publish.rb
490
490
  - lib/avm/tools/runner/local_project.rb
491
491
  - lib/avm/tools/runner/local_project/info.rb
492
+ - lib/avm/tools/runner/local_project/ruby.rb
493
+ - lib/avm/tools/runner/local_project/ruby/bundler.rb
494
+ - lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb
492
495
  - lib/avm/tools/runner/local_project/test.rb
493
496
  - lib/avm/tools/runner/local_project/update.rb
494
497
  - lib/avm/tools/runner/ruby.rb