avm-tools 0.63.0 → 0.66.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 855b0d8610e334378c5f061444ae6c414739fa383b9d09d64229ef8014feba53
4
- data.tar.gz: '09008022bebd8de5a6c3104406c7b5f415f94b1c0f2d84700e92a2b29d4fa530'
3
+ metadata.gz: 5fadfbad4ae6f17cae7e5137761710e454d858b08f56b0f666956d7f84c9787b
4
+ data.tar.gz: 30bceb50691d6c31bd34980c0985f4a689d16075f01ffba2495441d67913e312
5
5
  SHA512:
6
- metadata.gz: c4f2e3cb91702b6b93963c1478c38498c0774617538b75a8401ce96b00b505156aeb5d6554c595d5837c678a6f245b86352a57f86056c6599a40f5fbefae3cd7
7
- data.tar.gz: a577468f0221af04fb6fc08a5f6ada465dc9e64228b4be577ac0b6cbdaed4cd995108ca0f88f713226cadacf4152b1243b18986f3d9212d20742b75a84e651ff
6
+ metadata.gz: 5c88f25a0c0a7ae293d3c7b40f8708cfcdbfe92ace54a85c0b028751b75a044aa0c9ad437d16b3d47e0895bee0338119c6ea18cbf1328124dab7189f28852353
7
+ data.tar.gz: eab8e705b2d927f0d196117592a5273ce01f3f55e67e2074691500e44164eed3df86e50e69ece788f77c01fc4b06f39f3aeb670f389ab992c7d539ebc1206eca
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/files/rotate'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'minitar'
5
6
 
@@ -80,6 +80,7 @@ module Avm
80
80
 
81
81
  def publish?(stereotype)
82
82
  return false unless stereotype.publish_class
83
+ return false unless options.stereotype_publishable?(stereotype)
83
84
 
84
85
  filter = ::EacLauncher::Context.current.publish_options[:stereotype]
85
86
  filter.blank? ? true : filter == stereotype.name.demodulize
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Launcher
7
+ module Instances
8
+ class Settings
9
+ DEFAULT_CURRENT_REVISION = 'origin/master'
10
+ DEFAULT_PUBLISH_REMOTE = 'publish'
11
+ PUBLISHABLE_KEY = :publishable
12
+
13
+ common_constructor :data do
14
+ self.data = (data.is_a?(Hash) ? data : {}).with_indifferent_access
15
+ end
16
+
17
+ def git_current_revision
18
+ data[__method__] || DEFAULT_CURRENT_REVISION
19
+ end
20
+
21
+ def git_publish_remote
22
+ data[__method__] || DEFAULT_PUBLISH_REMOTE
23
+ end
24
+
25
+ def publishable?
26
+ !!publishable_value
27
+ end
28
+
29
+ def stereotype_publishable?(stereotype)
30
+ return publishable? unless publishable_value.is_a?(::Hash)
31
+
32
+ parse_publishable_value(publishable_value[stereotype.stereotype_name], true)
33
+ end
34
+
35
+ private
36
+
37
+ def publishable_value
38
+ parse_publishable_value(data[PUBLISHABLE_KEY], false)
39
+ end
40
+
41
+ def parse_publishable_value(value, hash_to_true)
42
+ return value.with_indifferent_access if !hash_to_true && value.is_a?(::Hash)
43
+ return true if value.nil? || value == true
44
+ return false if value == false
45
+
46
+ !!value
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/configuration'
3
4
  require 'eac_launcher/paths/real'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
  require 'avm/projects/stereotypes'
@@ -13,6 +14,8 @@ module Avm
13
14
  source_stereotypes_mixins
14
15
  end
15
16
 
17
+ delegate :to_s, to: :path
18
+
16
19
  # Backward compatibility with [EacLauncher::Paths::Logical].
17
20
  # @return [EacLauncher::Paths::Real].
18
21
  def real
@@ -21,6 +24,11 @@ module Avm
21
24
 
22
25
  private
23
26
 
27
+ # @return [Avm::Instances::Configuration]
28
+ def configuration_uncached
29
+ ::Avm::Instances::Configuration.find_in_path(path)
30
+ end
31
+
24
32
  def stereotypes_uncached
25
33
  ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
26
34
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/self'
3
4
  require 'eac_ruby_utils/patches/object/template'
4
5
 
5
- ::EacRubyUtils::Templates::Searcher.default.included_paths << ::File.expand_path(
6
- ('../' * 4) + 'template', __dir__
7
- )
6
+ ::EacRubyUtils::Templates::Searcher.default.included_paths <<
7
+ ::Avm::Self.root.join('template').to_path
@@ -47,14 +47,14 @@ module Avm
47
47
  private
48
48
 
49
49
  def sub_constant(constant_name, is_a)
50
+ return nil unless const_defined?(constant_name)
51
+
50
52
  constant = const_get(constant_name)
51
53
  unless is_a.if_present(true) { |v| constant.is_a?(v) }
52
54
  raise("#{constant} is not a #{is_a}")
53
55
  end
54
56
 
55
57
  constant
56
- rescue NameError
57
- nil
58
58
  end
59
59
  end
60
60
  end
@@ -10,12 +10,16 @@ module Avm
10
10
 
11
11
  class << self
12
12
  def application
13
- @application ||= ::EacRubyBase0::Application.new(::File.expand_path('../..', __dir__))
13
+ @application ||= ::EacRubyBase0::Application.new(root.to_path)
14
14
  end
15
15
 
16
16
  def instance
17
17
  @instance ||= ::Avm::Self::Instance.by_id('avm-tools_self')
18
18
  end
19
+
20
+ def root
21
+ ::Pathname.new('../..').expand_path(__dir__)
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -17,6 +17,11 @@ module Avm
17
17
  subcommands
18
18
  end
19
19
 
20
+ def instance_banner
21
+ infov 'Instance', instance
22
+ infov 'Stereotypes', instance.stereotypes.map(&:label).join(', ')
23
+ end
24
+
20
25
  private
21
26
 
22
27
  def instance_uncached
@@ -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
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Test < ::EacRubyUtils::Console::DocoptRunner
11
+ include ::EacCli::DefaultRunner
12
+
13
+ runner_definition do
14
+ desc 'Test local project.'
15
+ end
16
+
17
+ def run
18
+ context(:instance_banner)
19
+ infov 'Test command', test_command
20
+ if test_command.present?
21
+ test_command.system!
22
+ else
23
+ fatal_error 'No test command found'
24
+ end
25
+ end
26
+
27
+ def test_command
28
+ context(:instance).configuration.if_present(&:any_test_command)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.63.0'
5
+ VERSION = '0.66.0'
6
6
  end
7
7
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/launcher/instances/settings'
3
4
  require 'eac_ruby_utils/simple_cache'
4
5
  require 'yaml'
5
- require 'eac_launcher/instances/settings'
6
6
 
7
7
  module EacLauncher
8
8
  class Context
@@ -18,7 +18,7 @@ module EacLauncher
18
18
  end
19
19
 
20
20
  def instance_settings(instance)
21
- ::EacLauncher::Instances::Settings.new(value(['Instances', instance.name]))
21
+ ::Avm::Launcher::Instances::Settings.new(value(['Instances', instance.name]))
22
22
  end
23
23
 
24
24
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -373,6 +373,7 @@ files:
373
373
  - lib/avm/launcher/errors/non_project.rb
374
374
  - lib/avm/launcher/instances/base.rb
375
375
  - lib/avm/launcher/instances/base/cache.rb
376
+ - lib/avm/launcher/instances/settings.rb
376
377
  - lib/avm/local_projects.rb
377
378
  - lib/avm/local_projects/instance.rb
378
379
  - lib/avm/local_projects/jobs/update.rb
@@ -488,6 +489,10 @@ files:
488
489
  - lib/avm/tools/runner/launcher/publish.rb
489
490
  - lib/avm/tools/runner/local_project.rb
490
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
495
+ - lib/avm/tools/runner/local_project/test.rb
491
496
  - lib/avm/tools/runner/local_project/update.rb
492
497
  - lib/avm/tools/runner/ruby.rb
493
498
  - lib/avm/tools/runner/ruby/gems.rb
@@ -516,7 +521,6 @@ files:
516
521
  - lib/eac_launcher/instances.rb
517
522
  - lib/eac_launcher/instances/error.rb
518
523
  - lib/eac_launcher/instances/runner_helper.rb
519
- - lib/eac_launcher/instances/settings.rb
520
524
  - lib/eac_launcher/paths.rb
521
525
  - lib/eac_launcher/paths/logical.rb
522
526
  - lib/eac_launcher/paths/real.rb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacLauncher
4
- module Instances
5
- class Settings
6
- def initialize(data)
7
- @data = ActiveSupport::HashWithIndifferentAccess.new(data.is_a?(Hash) ? data : {})
8
- end
9
-
10
- def git_current_revision
11
- @data[__method__] || 'origin/master'
12
- end
13
-
14
- def git_publish_remote
15
- @data[__method__] || 'publish'
16
- end
17
-
18
- def publishable?
19
- @data.key?(:publishable) ? @data[:publishable] : true
20
- end
21
- end
22
- end
23
- end