avm-tools 0.61.0 → 0.62.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/cached_download.rb +39 -0
  3. data/lib/avm/eac_redmine_base0/core_update.rb +110 -0
  4. data/lib/avm/eac_redmine_base0/data_unit.rb +27 -0
  5. data/lib/avm/eac_redmine_base0/deploy.rb +36 -0
  6. data/lib/avm/eac_redmine_base0/instance.rb +38 -0
  7. data/lib/avm/instances/configuration.rb +11 -3
  8. data/lib/avm/instances/configuration/_tests.rb +1 -1
  9. data/lib/avm/launcher/context/instance_manager.rb +76 -0
  10. data/lib/avm/launcher/context/instance_manager/cached_instance.rb +37 -0
  11. data/lib/avm/launcher/context/instance_manager/cached_instances.rb +35 -0
  12. data/lib/avm/launcher/errors/base.rb +10 -0
  13. data/lib/avm/launcher/errors/non_project.rb +15 -0
  14. data/lib/avm/launcher/instances/base.rb +94 -0
  15. data/lib/avm/launcher/instances/base/cache.rb +43 -0
  16. data/lib/avm/patches/eac_ruby_gems_utils/gem.rb +28 -0
  17. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +5 -4
  18. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +1 -1
  19. data/lib/avm/ruby/rubocop/_gemfile.rb +2 -2
  20. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +3 -1
  21. data/lib/avm/sync.rb +94 -0
  22. data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
  23. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
  24. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
  25. data/lib/avm/tools/version.rb +1 -1
  26. data/lib/eac_launcher/context.rb +2 -2
  27. data/lib/eac_launcher/context/instance_discovery.rb +2 -2
  28. data/lib/eac_launcher/git/base/dirty_files.rb +1 -1
  29. data/lib/eac_launcher/git/sub_warp_base.rb +3 -2
  30. data/lib/eac_launcher/instances.rb +2 -2
  31. data/lib/eac_launcher/instances/error.rb +7 -3
  32. data/lib/eac_launcher/paths/logical.rb +2 -2
  33. data/lib/eac_launcher/publish/base.rb +2 -2
  34. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/install.sh.template +0 -0
  35. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/secrets.yml +0 -0
  36. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +1 -1
  37. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  38. metadata +20 -11
  39. data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
  40. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
  41. data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
  42. data/lib/eac_launcher/context/instance_manager.rb +0 -95
  43. data/lib/eac_launcher/instances/base.rb +0 -91
  44. data/lib/eac_launcher/instances/base/cache.rb +0 -41
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Errors
6
+ class Base < ::StandardError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/launcher/errors/base'
4
+
5
+ module Avm
6
+ module Launcher
7
+ module Errors
8
+ class NonProject < ::Avm::Launcher::Errors::Base
9
+ def initialize(path)
10
+ super("#{path} is not a project")
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base/cache'
4
+ require 'avm/launcher/errors/non_project'
5
+
6
+ module Avm
7
+ module Launcher
8
+ module Instances
9
+ module Base
10
+ class << self
11
+ def extend_object(object)
12
+ object.extend ::EacRubyUtils::SimpleCache
13
+ object.extend ::EacRubyUtils::Console::Speaker
14
+ object.extend ::Avm::Launcher::Instances::Base::Cache
15
+ super
16
+ end
17
+
18
+ def instanciate(path, parent)
19
+ unless path.is_a?(::Avm::Launcher::Instances::Base)
20
+ raise ::Avm::Launcher::Errors::NonProject, path unless path.project?
21
+
22
+ path.extend(::Avm::Launcher::Instances::Base)
23
+ path.parent = parent
24
+ end
25
+ path
26
+ end
27
+ end
28
+
29
+ attr_accessor :parent
30
+
31
+ def name
32
+ logical
33
+ end
34
+
35
+ def stereotype?(stereotype)
36
+ stereotypes.include?(stereotype)
37
+ end
38
+
39
+ def to_parent_path
40
+ return self unless @parent
41
+
42
+ logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
43
+ end
44
+
45
+ def project?
46
+ stereotypes.any?
47
+ end
48
+
49
+ def publish_run
50
+ stereotypes.each do |s|
51
+ next unless publish?(s)
52
+
53
+ infov(name, "publishing #{s.label}")
54
+ s.publish_class.new(self).run
55
+ end
56
+ end
57
+
58
+ def publish_check
59
+ stereotypes.each do |s|
60
+ next unless publish?(s)
61
+
62
+ puts "#{name.to_s.cyan}|#{s.label}|" \
63
+ "#{s.publish_class.new(self).check}"
64
+ end
65
+ end
66
+
67
+ def project_name
68
+ ::File.basename(logical)
69
+ end
70
+
71
+ def included?
72
+ !::EacLauncher::Context.current.settings.excluded_projects.include?(project_name)
73
+ end
74
+
75
+ def to_h
76
+ super.to_h.merge(parent: parent ? parent.logical : nil)
77
+ end
78
+
79
+ private
80
+
81
+ def publish?(stereotype)
82
+ return false unless stereotype.publish_class
83
+
84
+ filter = ::EacLauncher::Context.current.publish_options[:stereotype]
85
+ filter.blank? ? true : filter == stereotype.name.demodulize
86
+ end
87
+
88
+ def options_uncached
89
+ ::EacLauncher::Context.current.settings.instance_settings(self)
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Launcher
5
+ module Instances
6
+ module Base
7
+ module Cache
8
+ def cache_path(subpath)
9
+ File.join(cache_root, subpath)
10
+ end
11
+
12
+ def cache_key(key, &block)
13
+ v = cache_key_get(key)
14
+ return v if v.present? || block.nil?
15
+
16
+ v = yield
17
+ cache_key_write(key, v)
18
+ v
19
+ end
20
+
21
+ private
22
+
23
+ def cache_key_get(key)
24
+ File.file?(cache_key_path(key)) ? File.read(cache_key_path(key)) : nil
25
+ end
26
+
27
+ def cache_key_write(key, value)
28
+ FileUtils.mkdir_p(File.dirname(cache_key_path(key)))
29
+ File.write(cache_key_path(key), value)
30
+ end
31
+
32
+ def cache_key_path(key)
33
+ File.join(cache_root, 'keys', key.parameterize)
34
+ end
35
+
36
+ def cache_root
37
+ File.join(::EacLauncher::Context.current.cache_root, name.parameterize)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Patches
8
+ module EacRubyGemsUtils
9
+ module Gem
10
+ enable_simple_cache
11
+
12
+ private
13
+
14
+ def configuration_uncached
15
+ ::Avm::Instances::Configuration.find_in_path(root)
16
+ end
17
+
18
+ def gemfile_path_uncached
19
+ return super unless configuration.present? && configuration.rubocop_gemfile.present?
20
+
21
+ configuration.rubocop_gemfile
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ ::EacRubyGemsUtils::Gem.prepend(::Avm::Patches::EacRubyGemsUtils::Gem)
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/simple_cache'
4
4
  require 'eac_launcher/git/sub_warp_base'
5
- require 'eac_launcher/instances/error'
5
+ require 'avm/launcher/errors/base'
6
6
  require 'eac_launcher/paths/real'
7
7
  require 'eac_launcher/vendor/github'
8
8
 
@@ -32,8 +32,9 @@ module Avm
32
32
  return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
33
33
  parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
34
34
 
35
- raise EacLauncher::Instances::Error, "Subrepo parent hash \"#{subrepo_parent_hash}\""\
36
- " not found in \"#{parent_git_warped}\""
35
+ raise EacLauncher::Instances::Errors::Base,
36
+ "Subrepo parent hash \"#{subrepo_parent_hash}\"" \
37
+ " not found in \"#{parent_git_warped}\""
37
38
  end
38
39
 
39
40
  def subrepo_parent_hash
@@ -41,7 +42,7 @@ module Avm
41
42
  h = data['Pull Parent']
42
43
  return h if h.present?
43
44
 
44
- raise EacLauncher::Instances::Error, "Subrepo parent hash is blank: #{data}"
45
+ raise EacLauncher::Instances::Errors::Base, "Subrepo parent hash is blank: #{data}"
45
46
  end
46
47
 
47
48
  def init_aux
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gems_utils/gem'
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
 
6
6
  module Avm
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gems_utils/gem'
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
4
  require 'eac_ruby_utils/core_ext'
5
5
  require 'eac_ruby_utils/on_clean_ruby_environment'
6
6
 
@@ -14,7 +14,7 @@ module Avm
14
14
  end
15
15
 
16
16
  def rubocop_command_by_gemfile_path(path)
17
- ::EacRubyGemsUtils::Gem.new(path).bundle('exec', 'rubocop')
17
+ ::EacRubyGemsUtils::Gem.new(path).bundle('exec', 'rubocop').chdir_root
18
18
  end
19
19
 
20
20
  def rubocop_gemfile?
@@ -32,7 +32,9 @@ module Avm
32
32
  end
33
33
 
34
34
  def stereotype_module
35
- "Avm::Stereotypes::#{stereotype_name}".constantize
35
+ ::Avm::Stereotypes.const_get(stereotype_name)
36
+ rescue ::NameError
37
+ ::Avm.const_get(stereotype_name)
36
38
  end
37
39
 
38
40
  def stereotype_name
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ class Sync
7
+ attr_reader :excludes, :includes
8
+
9
+ common_constructor :source_path, :target_path do
10
+ self.source_path = source_path.to_pathname
11
+ self.target_path = target_path.to_pathname
12
+ @excludes = []
13
+ @includes = []
14
+ end
15
+
16
+ def run
17
+ clear_target
18
+ copy
19
+ end
20
+
21
+ def add_exclude(exclude)
22
+ excludes << exclude
23
+
24
+ self
25
+ end
26
+
27
+ def add_excludes(*excludes)
28
+ excludes.each { |exclude| add_exclude(exclude) }
29
+
30
+ self
31
+ end
32
+
33
+ def add_include(include)
34
+ includes << include
35
+
36
+ self
37
+ end
38
+
39
+ def add_includes(*includes)
40
+ includes.each { |include| add_include(include) }
41
+
42
+ self
43
+ end
44
+
45
+ def move_mode(value)
46
+ @move_mode = value
47
+
48
+ self
49
+ end
50
+
51
+ def move_mode?
52
+ @move_mode ? true : false
53
+ end
54
+
55
+ private
56
+
57
+ def clear_target
58
+ target_remove(target_path)
59
+ target_path.children.each { |tchild| target_remove(tchild) }
60
+ end
61
+
62
+ def copy
63
+ source_path.children.each do |schild|
64
+ ::FileUtils.cp_r(schild.to_path, target_path.to_path)
65
+ schild.rmtree if move_mode?
66
+ end
67
+ end
68
+
69
+ def source_to_target_path(source_path)
70
+ source_path.relative_path_from(self.source_path).expand_path(target_path)
71
+ end
72
+
73
+ def target_remove(tpath)
74
+ return if skip_target_path?(tpath)
75
+
76
+ if tpath.directory?
77
+ tpath.children.each { |tchild| target_remove(tchild) }
78
+ tpath.rmdir if tpath.children.empty?
79
+ elsif tpath.file?
80
+ tpath.unlink
81
+ end
82
+ end
83
+
84
+ def skip_target_path?(tpath)
85
+ skip_path?(tpath.relative_path_from(target_path))
86
+ end
87
+
88
+ def skip_path?(relpath)
89
+ relpath = relpath.expand_path('/')
90
+ excludes.any? { |exclude| relpath.fnmatch?(exclude) } &&
91
+ includes.none? { |include| relpath.fnmatch?(include) }
92
+ end
93
+ end
94
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/console/docopt_runner'
4
4
  require 'eac_ruby_utils/simple_cache'
5
- require 'avm/stereotypes/eac_redmine_base0/instance'
5
+ require 'avm/eac_redmine_base0/instance'
6
6
  require 'eac_ruby_utils/require_sub'
7
7
  ::EacRubyUtils.require_sub(__FILE__)
8
8
 
@@ -26,7 +26,7 @@ module Avm
26
26
  private
27
27
 
28
28
  def instance_uncached
29
- ::Avm::Stereotypes::EacRedmineBase0::Instance.by_id(options['<instance_id>'])
29
+ ::Avm::EacRedmineBase0::Instance.by_id(options['<instance_id>'])
30
30
  end
31
31
  end
32
32
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_redmine_base0/core_update'
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 EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
12
+ class CoreUpdate < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+
15
+ runner_definition do
16
+ arg_opt '-u', '--url', 'Core\'s package URL.'
17
+ arg_opt '-v', '--version', 'Core\'s version.'
18
+ desc 'Update instance\' core.'
19
+ end
20
+
21
+ def run
22
+ start_banner
23
+ validate
24
+ update
25
+ end
26
+
27
+ private
28
+
29
+ def start_banner
30
+ infov 'URL', url
31
+ infov 'Version', version
32
+ end
33
+
34
+ def update
35
+ ::Avm::EacRedmineBase0::CoreUpdate.new(context(:instance), version, url).run
36
+ end
37
+
38
+ def url
39
+ options.fetch('--url') || url_by_version
40
+ end
41
+
42
+ def url_by_version
43
+ options.fetch('--version').if_present do |v|
44
+ "https://www.redmine.org/releases/redmine-#{v}.tar.gz"
45
+ end
46
+ end
47
+
48
+ def validate
49
+ %w[url version].each do |attr|
50
+ fatal_error "\"#{attr}\" is blank. See avaiable options." if send(attr).blank?
51
+ end
52
+ end
53
+
54
+ def version
55
+ options.fetch('--version') || version_by_url
56
+ end
57
+
58
+ def version_by_url
59
+ options.fetch('--url').if_present do |v|
60
+ /(\d+.\d+.\d+)/.if_match(v, false) { |m| m[1] }
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/stereotypes/eac_redmine_base0/deploy'
3
+ require 'avm/eac_redmine_base0/deploy'
4
4
  require 'avm/stereotypes/eac_webapp_base0/runner/deploy'
5
5
 
6
6
  module Avm