avm-tools 0.58.1 → 0.62.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) 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/local_projects.rb +9 -0
  8. data/lib/avm/local_projects/instance.rb +35 -0
  9. data/lib/avm/local_projects/jobs/update.rb +29 -0
  10. data/lib/avm/projects.rb +9 -0
  11. data/lib/avm/projects/stereotype.rb +62 -0
  12. data/lib/avm/projects/stereotypes.rb +20 -0
  13. data/lib/avm/projects/stereotypes/git.rb +25 -0
  14. data/lib/avm/projects/stereotypes/git/local_project_mixin.rb +19 -0
  15. data/lib/avm/projects/stereotypes/git/publish.rb +15 -0
  16. data/lib/avm/projects/stereotypes/git/warp.rb +27 -0
  17. data/lib/avm/projects/stereotypes/git_subrepo.rb +34 -0
  18. data/lib/avm/projects/stereotypes/git_subrepo/publish.rb +14 -0
  19. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +87 -0
  20. data/lib/avm/projects/stereotypes/git_subtree.rb +51 -0
  21. data/lib/avm/projects/stereotypes/git_subtree/publish.rb +12 -0
  22. data/lib/avm/projects/stereotypes/git_subtree/warp.rb +29 -0
  23. data/lib/avm/projects/stereotypes/rails_application.rb +23 -0
  24. data/lib/avm/projects/stereotypes/redmine_plugin.rb +23 -0
  25. data/lib/avm/projects/stereotypes/ruby_gem.rb +30 -0
  26. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +19 -0
  27. data/lib/avm/projects/stereotypes/ruby_gem/publish.rb +129 -0
  28. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +59 -0
  29. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +3 -1
  30. data/lib/avm/sync.rb +94 -0
  31. data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
  32. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
  33. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
  34. data/lib/avm/tools/runner/git/issue.rb +43 -4
  35. data/lib/avm/tools/runner/launcher.rb +10 -2
  36. data/lib/avm/tools/runner/launcher/instances.rb +45 -0
  37. data/lib/avm/tools/runner/launcher/projects.rb +50 -0
  38. data/lib/avm/tools/runner/launcher/publish.rb +65 -0
  39. data/lib/avm/tools/runner/local_project.rb +32 -0
  40. data/lib/avm/tools/runner/local_project/info.rb +25 -0
  41. data/lib/avm/tools/runner/local_project/update.rb +26 -0
  42. data/lib/avm/tools/version.rb +1 -1
  43. data/lib/eac_launcher.rb +1 -2
  44. data/lib/eac_launcher/context/instance_manager.rb +1 -0
  45. data/lib/eac_launcher/git/base/dirty_files.rb +5 -14
  46. data/lib/eac_launcher/git/publish_base.rb +1 -0
  47. data/lib/eac_launcher/git/sub_warp_base.rb +1 -1
  48. data/lib/eac_launcher/git/warp_base.rb +2 -2
  49. data/lib/eac_launcher/instances/base.rb +2 -2
  50. data/lib/eac_launcher/instances/runner_helper.rb +1 -1
  51. data/lib/eac_launcher/paths/logical.rb +2 -2
  52. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/install.sh.template +0 -0
  53. data/template/avm/{stereotypes/eac_redmine_base0 → eac_redmine_base0}/deploy/config/secrets.yml +0 -0
  54. data/vendor/eac_git/lib/eac_git/local.rb +1 -1
  55. data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +38 -0
  56. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  57. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  58. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +2 -0
  59. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +2 -0
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +2 -0
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +8 -8
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  64. metadata +41 -27
  65. data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
  66. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
  67. data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
  68. data/lib/eac_launcher/runner.rb +0 -21
  69. data/lib/eac_launcher/runner/instances.rb +0 -41
  70. data/lib/eac_launcher/runner/projects.rb +0 -46
  71. data/lib/eac_launcher/runner/publish.rb +0 -59
  72. data/lib/eac_launcher/stereotype.rb +0 -52
  73. data/lib/eac_launcher/stereotypes.rb +0 -14
  74. data/lib/eac_launcher/stereotypes/git.rb +0 -21
  75. data/lib/eac_launcher/stereotypes/git/publish.rb +0 -13
  76. data/lib/eac_launcher/stereotypes/git/warp.rb +0 -25
  77. data/lib/eac_launcher/stereotypes/git_subrepo.rb +0 -30
  78. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +0 -12
  79. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +0 -85
  80. data/lib/eac_launcher/stereotypes/git_subtree.rb +0 -47
  81. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +0 -10
  82. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +0 -27
  83. data/lib/eac_launcher/stereotypes/rails.rb +0 -21
  84. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +0 -21
  85. data/lib/eac_launcher/stereotypes/ruby_gem.rb +0 -27
  86. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +0 -127
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_git/local'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class Git
10
+ module LocalProjectMixin
11
+ # @return [EacGit::Local]
12
+ def git_repo
13
+ @git_repo ||= ::EacGit::Local.new(path)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/publish_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class Git
9
+ class Publish < ::EacLauncher::Git::PublishBase
10
+ PUBLISH_GIT_REMOTE_NAME = 'publish'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/warp_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class Git
9
+ class Warp < ::EacLauncher::Git::WarpBase
10
+ private
11
+
12
+ def current_ref
13
+ 'HEAD'
14
+ end
15
+
16
+ def source_instance
17
+ instance
18
+ end
19
+
20
+ def source_remote_name
21
+ ::Avm::Projects::Stereotypes::Git::Publish::PUBLISH_GIT_REMOTE_NAME
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/error'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'avm/projects/stereotype'
6
+
7
+ module Avm
8
+ module Projects
9
+ module Stereotypes
10
+ class GitSubrepo
11
+ require_sub __FILE__
12
+ include Avm::Projects::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ File.exist?(path.real.subpath('.gitrepo')) && subrepo_url(path.real) != 'none'
17
+ end
18
+
19
+ def color
20
+ :light_cyan
21
+ end
22
+
23
+ def subrepo_url(path)
24
+ File.read(path.subpath('.gitrepo')).each_line do |l|
25
+ m = /remote\s*=\s(.+)/.match(l)
26
+ return m[1] if m
27
+ end
28
+ raise ::EacLauncher::Git::Error.new(path, '"remote = ... " not found')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/git/publish_base'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class GitSubrepo
9
+ class Publish < ::EacLauncher::Git::PublishBase
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+ require 'eac_launcher/git/sub_warp_base'
5
+ require 'eac_launcher/instances/error'
6
+ require 'eac_launcher/paths/real'
7
+ require 'eac_launcher/vendor/github'
8
+
9
+ module Avm
10
+ module Projects
11
+ module Stereotypes
12
+ class GitSubrepo
13
+ class Warp < ::EacLauncher::Paths::Real
14
+ include ::EacLauncher::Git::SubWarpBase
15
+ include ::EacRubyUtils::SimpleCache
16
+
17
+ attr_reader :instance
18
+
19
+ def initialize(instance)
20
+ @instance = instance
21
+ check_parent
22
+ init_aux
23
+ push_to_aux
24
+ reset
25
+ assert_target_remote
26
+ super(warped_git)
27
+ end
28
+
29
+ private
30
+
31
+ def check_parent
32
+ return if parent_git_warped.rev_parse(subrepo_parent_hash) &&
33
+ parent_git_warped.descendant?('HEAD', subrepo_parent_hash)
34
+
35
+ raise EacLauncher::Instances::Error, "Subrepo parent hash \"#{subrepo_parent_hash}\""\
36
+ " not found in \"#{parent_git_warped}\""
37
+ end
38
+
39
+ def subrepo_parent_hash
40
+ data = parent_git_warped.subrepo_status(to_parent_git_path)
41
+ h = data['Pull Parent']
42
+ return h if h.present?
43
+
44
+ raise EacLauncher::Instances::Error, "Subrepo parent hash is blank: #{data}"
45
+ end
46
+
47
+ def init_aux
48
+ ::EacLauncher::Git::Base.new(aux_path).init_bare
49
+ end
50
+
51
+ def parent_git_warped_uncached
52
+ ::EacLauncher::Git::Base.new(parent_instance.warped)
53
+ end
54
+
55
+ def aux_path
56
+ instance.cache_path('subrepo_aux_git_repository')
57
+ end
58
+
59
+ def warped_git_uncached
60
+ ::EacLauncher::Git::Base.new(instance.cache_path('git_repository'))
61
+ end
62
+
63
+ def push_to_aux
64
+ parent_git_warped.execute!('subrepo', 'branch', to_parent_git_path, '-fF')
65
+ h = parent_git_warped.rev_parse("subrepo/#{to_parent_git_path}", true)
66
+ parent_git_warped.execute!('push', aux_path, "#{h}:refs/heads/master", '--force')
67
+ end
68
+
69
+ def reset
70
+ ::EacLauncher::Git::MirrorUpdate.new(warped_git, aux_path, 'master')
71
+ end
72
+
73
+ def assert_target_remote
74
+ warped_git.assert_remote_url(::EacLauncher::Git::WarpBase::TARGET_REMOTE,
75
+ target_remote_url)
76
+ end
77
+
78
+ def target_remote_url
79
+ ::EacLauncher::Vendor::Github.to_ssh_url(
80
+ parent_git_warped.subrepo_remote_url(to_parent_git_path)
81
+ )
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'avm/projects/stereotypes/git'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Projects
9
+ module Stereotypes
10
+ class GitSubtree
11
+ require_sub __FILE__
12
+ include Avm::Projects::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ return false if other_git_stereotype?(path)
17
+ return false unless other_nogit_stereotype?(path)
18
+
19
+ parent = parent_git(path.parent_path)
20
+ return false unless parent
21
+
22
+ ::Git.open(parent.real).remote(path.real.basename).url ? true : false
23
+ end
24
+
25
+ def color
26
+ :green
27
+ end
28
+
29
+ def parent_git(parent_path)
30
+ return nil unless parent_path
31
+
32
+ if ::Avm::Projects::Stereotypes::Git.match?(parent_path)
33
+ parent_path
34
+ else
35
+ parent_git(parent_path.parent_path)
36
+ end
37
+ end
38
+
39
+ def other_git_stereotype?(path)
40
+ ::Avm::Projects::Stereotypes::Git.match?(path) ||
41
+ ::Avm::Projects::Stereotypes::GitSubrepo.match?(path)
42
+ end
43
+
44
+ def other_nogit_stereotype?(path)
45
+ Avm::Projects::Stereotype.nogit_stereotypes.any? { |s| s.match?(path) }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Projects
5
+ module Stereotypes
6
+ class GitSubtree
7
+ class Publish < ::EacLauncher::Git::PublishBase
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Projects
5
+ module Stereotypes
6
+ class GitSubtree
7
+ class Warp < ::EacLauncher::Git::WarpBase
8
+ include ::EacLauncher::Git::SubWarpBase
9
+
10
+ private
11
+
12
+ def current_ref
13
+ instance.cache_key("git_subtree.parent.#{cache_git.git.object('HEAD').sha}") do
14
+ cache_git.subtree_split(to_parent_git_path)
15
+ end
16
+ end
17
+
18
+ def source_instance
19
+ parent_instance
20
+ end
21
+
22
+ def source_remote_name
23
+ instance.project_name
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class RailsApplication
9
+ include Avm::Projects::Stereotype
10
+
11
+ class << self
12
+ def match?(path)
13
+ File.exist?(path.real.subpath('config.ru')) && path.real.basename != 'dummy'
14
+ end
15
+
16
+ def color
17
+ :magenta
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class RedminePlugin
9
+ include Avm::Projects::Stereotype
10
+
11
+ class << self
12
+ def match?(path)
13
+ File.exist?(path.real.subpath('init.rb'))
14
+ end
15
+
16
+ def color
17
+ :light_magenta
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'eac_launcher/ruby/gem/specification'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Projects
9
+ module Stereotypes
10
+ class RubyGem
11
+ require_sub __FILE__
12
+ include Avm::Projects::Stereotype
13
+
14
+ class << self
15
+ def match?(path)
16
+ Dir.glob(File.join(path.real, '*.gemspec')).any?
17
+ end
18
+
19
+ def color
20
+ :red
21
+ end
22
+
23
+ def load_gemspec(gemspec_file)
24
+ ::EacLauncher::Ruby::Gem::Specification.new(gemspec_file)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
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 Projects
8
+ module Stereotypes
9
+ class RubyGem
10
+ module LocalProjectMixin
11
+ # @return [EacRubyGemsUtils::Gem]
12
+ def ruby_gem
13
+ @ruby_gem ||= ::EacRubyGemsUtils::Gem.new(path)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'curb'
4
+ require 'json'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'rubygems'
7
+ require 'eac_ruby_utils/console/speaker'
8
+ require 'eac_launcher/publish/base'
9
+ require 'eac_launcher/publish/check_result'
10
+ require 'eac_launcher/ruby/gem'
11
+
12
+ module Avm
13
+ module Projects
14
+ module Stereotypes
15
+ class RubyGem
16
+ class Publish < ::EacLauncher::Publish::Base
17
+ include ::EacRubyUtils::SimpleCache
18
+ include ::EacRubyUtils::Console::Speaker
19
+
20
+ protected
21
+
22
+ def internal_check
23
+ gem_published? ? internal_check_gem_published : internal_check_gem_unpublished
24
+ end
25
+
26
+ private
27
+
28
+ def internal_check_gem_published
29
+ if version_published?
30
+ outdated_version? ? outdated_version_check_result : version_published_check_result
31
+ else
32
+ version_unpublished_check_result
33
+ end
34
+ end
35
+
36
+ def internal_check_gem_unpublished
37
+ if new_gem_allowed?
38
+ version_unpublished_check_result
39
+ else
40
+ new_gem_disallowed_check_result
41
+ end
42
+ end
43
+
44
+ def new_gem_disallowed_check_result
45
+ ::EacLauncher::Publish::CheckResult.blocked(
46
+ "#{gem_spec.full_name} does not exist in RubyGems"
47
+ )
48
+ end
49
+
50
+ def version_published_check_result
51
+ ::EacLauncher::Publish::CheckResult.updated("#{gem_spec.full_name} already pushed")
52
+ end
53
+
54
+ def outdated_version_check_result
55
+ ::EacLauncher::Publish::CheckResult.outdated(
56
+ "#{gem_spec.full_name} is outdated (Max: #{gem_version_max})"
57
+ )
58
+ end
59
+
60
+ def version_unpublished_check_result
61
+ ::EacLauncher::Publish::CheckResult.pending("#{gem_spec.full_name} not found " \
62
+ 'in RubyGems')
63
+ end
64
+
65
+ def source_uncached
66
+ instance.warped
67
+ end
68
+
69
+ def gem_spec_uncached
70
+ ::Avm::Projects::Stereotypes::RubyGem.load_gemspec(gemspec)
71
+ end
72
+
73
+ def gem_build_uncached
74
+ ::EacLauncher::Ruby::Gem::Build.new(source)
75
+ end
76
+
77
+ def publish
78
+ gem_build.build
79
+ push_gem
80
+ ensure
81
+ gem_build.close
82
+ end
83
+
84
+ def new_gem_allowed?
85
+ ::EacLauncher::Context.current.publish_options[:new]
86
+ end
87
+
88
+ def gem_published?
89
+ gem_versions.any?
90
+ end
91
+
92
+ def version_published?
93
+ gem_versions.any? { |v| v['number'] == gem_spec.version }
94
+ end
95
+
96
+ def outdated_version?
97
+ gem_version_max.present? && ::Gem::Version.new(gem_spec.version) < gem_version_max
98
+ end
99
+
100
+ def gem_versions_uncached
101
+ http = Curl.get("https://rubygems.org/api/v1/versions/#{gem_spec.name}.json")
102
+ return JSON.parse!(http.body_str) if /\A2/ =~ http.status
103
+ return [] if /\A4/ =~ http.status
104
+
105
+ raise "#{http} code error: #{http.status}"
106
+ end
107
+
108
+ def gem_version_max_uncached
109
+ gem_versions.map { |v| ::Gem::Version.new(v['number']) }.max
110
+ end
111
+
112
+ def push_gem
113
+ info("Pushing gem #{gem_spec}...")
114
+ command = ['gem', 'push', gem_build.output_file]
115
+ unless ::EacLauncher::Context.current.publish_options[:confirm]
116
+ command = %w[echo] + command + %w[(Dry-run)]
117
+ end
118
+ EacRubyUtils::Envs.local.command(command).system
119
+ info('Pushed!')
120
+ end
121
+
122
+ def gemspec_uncached
123
+ source.find_file_with_extension('.gemspec')
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end