avm-tools 0.58.0 → 0.62.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) 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/sync.rb +94 -0
  30. data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
  31. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
  32. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
  33. data/lib/avm/tools/runner/git/issue.rb +43 -4
  34. data/lib/avm/tools/runner/launcher.rb +10 -2
  35. data/lib/avm/tools/runner/launcher/instances.rb +45 -0
  36. data/lib/avm/tools/runner/launcher/projects.rb +50 -0
  37. data/lib/avm/tools/runner/launcher/publish.rb +65 -0
  38. data/lib/avm/tools/runner/local_project.rb +32 -0
  39. data/lib/avm/tools/runner/local_project/info.rb +25 -0
  40. data/lib/avm/tools/runner/local_project/update.rb +26 -0
  41. data/lib/avm/tools/version.rb +1 -1
  42. data/lib/eac_launcher.rb +1 -2
  43. data/lib/eac_launcher/context/instance_manager.rb +1 -0
  44. data/lib/eac_launcher/git/base/dirty_files.rb +5 -14
  45. data/lib/eac_launcher/git/publish_base.rb +1 -0
  46. data/lib/eac_launcher/git/sub_warp_base.rb +1 -1
  47. data/lib/eac_launcher/git/warp_base.rb +2 -2
  48. data/lib/eac_launcher/instances/base.rb +2 -2
  49. data/lib/eac_launcher/instances/runner_helper.rb +1 -1
  50. data/lib/eac_launcher/paths/logical.rb +2 -2
  51. data/vendor/eac_git/lib/eac_git/local.rb +1 -1
  52. data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +38 -0
  53. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  54. data/vendor/eac_git/vendor/git-subrepo/lib/git-subrepo.d/bash+.bash +1 -1
  55. data/vendor/eac_ruby_gems_utils/LICENCE +16 -674
  56. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +10 -2
  57. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +2 -1
  58. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  59. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +10 -18
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +8 -8
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  69. metadata +52 -28
  70. data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
  71. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
  72. data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
  73. data/lib/eac_launcher/runner.rb +0 -21
  74. data/lib/eac_launcher/runner/instances.rb +0 -41
  75. data/lib/eac_launcher/runner/projects.rb +0 -46
  76. data/lib/eac_launcher/runner/publish.rb +0 -59
  77. data/lib/eac_launcher/stereotype.rb +0 -52
  78. data/lib/eac_launcher/stereotypes.rb +0 -14
  79. data/lib/eac_launcher/stereotypes/git.rb +0 -21
  80. data/lib/eac_launcher/stereotypes/git/publish.rb +0 -13
  81. data/lib/eac_launcher/stereotypes/git/warp.rb +0 -25
  82. data/lib/eac_launcher/stereotypes/git_subrepo.rb +0 -30
  83. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +0 -12
  84. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +0 -85
  85. data/lib/eac_launcher/stereotypes/git_subtree.rb +0 -47
  86. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +0 -10
  87. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +0 -27
  88. data/lib/eac_launcher/stereotypes/rails.rb +0 -21
  89. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +0 -21
  90. data/lib/eac_launcher/stereotypes/ruby_gem.rb +0 -27
  91. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +0 -127
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea1f70fc2f9b43dd584ccf4519299ccf687b44ac69f0984a996ba26dc8255964
4
- data.tar.gz: 4fdec7c63f7ec4f48f4e44fff60f5a901119a919e4f4884a90df9a436bae4368
3
+ metadata.gz: 37ce02b35f53298066d48205ff8442084a1d702baecb901c91ba3dffe5d2cd0d
4
+ data.tar.gz: f4bf6b545744791267fdbdc0eb47f4dc1f0d6b5c1ebef912dd1cbaa8c06b6bfe
5
5
  SHA512:
6
- metadata.gz: 620de198f99a3acb3d798f73af83cb85d48f428d1d012a3c99cf5a7ac0a4688c5ec51a927c9fe955e1605f6298f1dd05b1422e57f96220ee6f7cfe666ad229d5
7
- data.tar.gz: a5ac202f489c02e73a8c4d0ca00102fbc35a687d8b180798d5538f4c2abe875388da0992ea4b4462cd38d25596697205dc0120b1c0f19ac2b50b7aa5d434cbbb
6
+ metadata.gz: a2c271e9d1e95373e7957b55d26b3ffc87b227e1fe4a4d90d94b686e16d4bbf90e40e9be639ab4ea2063698aa42d5e43284472e5e271e3d8e55d4a68acc2e5e3
7
+ data.tar.gz: 58d5924ed8c0e329292240d866b7c567bd1eec97f1774d4ef8573fa4d77b09477a07aa6c90e4ae99806f235af4892d752653667d5d9de7dc3806dee507d2a774
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/fs_cache'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ class CachedDownload
8
+ attr_reader :url, :fs_cache
9
+
10
+ def initialize(url, parent_fs_cache = nil)
11
+ @url = url
12
+ @fs_cache = (parent_fs_cache || ::Avm.fs_cache).child(url.parameterize)
13
+ end
14
+
15
+ def assert
16
+ download unless fs_cache.cached?
17
+ end
18
+
19
+ def download
20
+ ::EacRubyUtils::Fs::Temp.on_file do |temp|
21
+ download_to(temp)
22
+ fs_cache.content_path.to_pathname.dirname.mkpath
23
+ ::FileUtils.mv(temp.to_path, fs_cache.content_path)
24
+ end
25
+ end
26
+
27
+ def path
28
+ @path ||= fs_cache.content_path.to_pathname
29
+ end
30
+
31
+ private
32
+
33
+ def download_to(local_file)
34
+ ::URI.parse(url).open do |remote|
35
+ local_file.open('wb') { |handle| handle.write(remote.read) }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_redmine_base0/core_update'
4
+ require 'avm/cached_download'
5
+ require 'avm/sync'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module EacRedmineBase0
10
+ class CoreUpdate
11
+ enable_console_speaker
12
+ enable_simple_cache
13
+ common_constructor :instance, :version, :url
14
+
15
+ GITIGNORE_ADD = %w[/public/assets/**/* /config/install.sh /log/**/*].freeze
16
+ GITIGNORE_DEL = %w[/Gemfile.lock /plugins/* /public/themes/*].freeze
17
+ TARGET_KEEP = %w[/Gemfile.lock].freeze
18
+
19
+ def run
20
+ ::EacRubyUtils::Fs::Temp.on_directory do |dir|
21
+ @tempdir = dir
22
+ assert_source_package
23
+ extract_package_to_tempdir
24
+ sync_content
25
+ change_git_ignore
26
+ validate_empty_dir
27
+ end
28
+ git_commit
29
+ success 'Done!'
30
+ end
31
+
32
+ def assert_source_package
33
+ infom 'Asserting source package...'
34
+ source_package.assert
35
+ infov 'Package cache path', source_package.path
36
+ infov 'Package size', source_package.path.size
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :tempdir
42
+
43
+ def change_git_ignore
44
+ file = target_path.join('.gitignore')
45
+ file.write(
46
+ (file.read.each_line.map(&:strip).reject { |line| GITIGNORE_DEL.include?(line) } +
47
+ ['', '#eac_redmine_base0'] + GITIGNORE_ADD).map { |line| "#{line}\n" }.join
48
+ )
49
+ end
50
+
51
+ def extract_package_to_tempdir
52
+ infom "Extracting package to tempdir #{tempdir}..."
53
+ ::EacRubyUtils::Envs.local.command(
54
+ 'tar', '-xf', source_package.path.to_path, '-C', tempdir.to_path,
55
+ '--strip-components', '1'
56
+ ).execute!
57
+ end
58
+
59
+ def git_commit
60
+ if git_repo.dirty?
61
+ infom 'Git commiting...'
62
+ git_repo.command('add', '--', target_path).execute!
63
+ git_repo.command('commit', '-m', git_commit_message, '--', target_path).execute!
64
+ else
65
+ infom 'Nothing to commit'
66
+ end
67
+ end
68
+
69
+ def git_commit_message
70
+ "Core: update to #{version}."
71
+ end
72
+
73
+ def git_repo_uncached
74
+ ::EacGit::Local.new(target_path)
75
+ end
76
+
77
+ def sync_content
78
+ ::Avm::Sync.new(source_path, target_path)
79
+ .add_exclude('/*').add_includes(*target_files_to_remove).move_mode(true).run
80
+ end
81
+
82
+ def source_package_uncached
83
+ ::Avm::CachedDownload.new(url, ::Avm.fs_cache.child('eac_redmine_base0', 'core_update'))
84
+ end
85
+
86
+ def validate_empty_dir
87
+ if source_path.children.empty?
88
+ infom 'No content left in source directory'
89
+ else
90
+ fatal_error 'Found entries in source directory: ' +
91
+ source_path.children.map { |c| c.basename.to_path }.join(', ')
92
+ end
93
+ end
94
+
95
+ def source_path_uncached
96
+ ::Pathname.new(tempdir.to_path)
97
+ end
98
+
99
+ def target_files_to_remove
100
+ git_repo.command('ls-files').execute!
101
+ .each_line.map { |v| "/#{v.strip}" }
102
+ .without(*TARGET_KEEP)
103
+ end
104
+
105
+ def target_path_uncached
106
+ instance.read_entry('fs_path').to_pathname
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/data/instance/unit'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'open-uri'
6
+
7
+ module Avm
8
+ module EacRedmineBase0
9
+ class DataUnit < ::Avm::Data::Instance::Unit
10
+ common_constructor :instance
11
+
12
+ EXTENSION = '.tar'
13
+
14
+ def do_dump(data_path)
15
+ ::File.open(data_path, 'wb') do |file|
16
+ file << URI.parse(export_url).read
17
+ end
18
+ end
19
+
20
+ def export_url
21
+ uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + '/backup/export'
22
+ uri.query_values = { key: instance.read_entry('admin.api_key') }
23
+ uri.to_s
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/stereotypes/eac_webapp_base0/deploy'
4
+ require 'eac_ruby_utils/ruby'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ class Deploy < ::Avm::Stereotypes::EacWebappBase0::Deploy
9
+ set_callback :assert_instance_branch, :after, :run_installer
10
+
11
+ def run_installer
12
+ infom 'Running installer'
13
+ ::EacRubyUtils::Ruby.on_clean_environment do
14
+ installer_command.system!
15
+ end
16
+ end
17
+
18
+ def installer_command
19
+ instance.host_env.command(installer_path, install_task)
20
+ end
21
+
22
+ def installer_path
23
+ ::File.join(instance.read_entry(:fs_path), 'plugins', 'redmine_installer', 'installer',
24
+ 'run.sh')
25
+ end
26
+
27
+ def install_task
28
+ if instance.read_entry_optional('web.path').present?
29
+ 'redmine_as_apache_path'
30
+ else
31
+ 'redmine_as_apache_base'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_redmine_base0/data_unit'
4
+ require 'avm/stereotypes/eac_ubuntu_base0/docker_image'
5
+ require 'avm/stereotypes/eac_webapp_base0/instance'
6
+ require 'avm/stereotypes/rails/instance'
7
+
8
+ module Avm
9
+ module EacRedmineBase0
10
+ class Instance < ::Avm::Stereotypes::EacWebappBase0::Instance
11
+ include ::Avm::Stereotypes::Rails::Instance
12
+
13
+ FILES_UNITS = { files: 'files' }.freeze
14
+
15
+ def docker_image_class
16
+ ::Avm::Stereotypes::EacUbuntuBase0::DockerImage
17
+ end
18
+
19
+ def docker_run_arguments
20
+ [
21
+ '--volume', "#{read_entry(:fs_path)}:/home/myuser/eac_redmine_base0",
22
+ '--publish', "#{read_entry(:ssh_port)}:22",
23
+ '--publish', "#{read_entry(:http_port)}:80",
24
+ '--publish', "#{read_entry(:https_port)}:443"
25
+ ]
26
+ end
27
+
28
+ def data_package
29
+ @data_package ||= ::Avm::Data::Instance::Package.new(
30
+ self,
31
+ units: {
32
+ all: ::Avm::EacRedmineBase0::DataUnit.new(self)
33
+ }
34
+ )
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module LocalProjects
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/paths/real'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'avm/projects/stereotypes'
6
+
7
+ module Avm
8
+ module LocalProjects
9
+ class Instance
10
+ enable_simple_cache
11
+ common_constructor :path do
12
+ self.path = path.to_pathname
13
+ source_stereotypes_mixins
14
+ end
15
+
16
+ # Backward compatibility with [EacLauncher::Paths::Logical].
17
+ # @return [EacLauncher::Paths::Real].
18
+ def real
19
+ ::EacLauncher::Paths::Real.new(path.to_path)
20
+ end
21
+
22
+ private
23
+
24
+ def stereotypes_uncached
25
+ ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
26
+ end
27
+
28
+ def source_stereotypes_mixins
29
+ stereotypes.each do |s|
30
+ s.local_project_mixin_module.if_present { |v| extend(v) }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module LocalProjects
7
+ module Jobs
8
+ class Update
9
+ enable_console_speaker
10
+ common_constructor :instance
11
+
12
+ def run
13
+ instance.stereotypes.each { |stereotype| run_stereotype(stereotype) }
14
+ end
15
+
16
+ private
17
+
18
+ def run_stereotype(stereotype)
19
+ if stereotype.update_class.present?
20
+ puts stereotype.label + ': update class found. Running...'
21
+ stereotype.update_class.new(instance).run
22
+ else
23
+ puts stereotype.label + ': update class not found'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Projects
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+ require 'colorized_string'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotype
9
+ class << self
10
+ attr_reader :stereotypes
11
+
12
+ def included(base)
13
+ @stereotypes ||= []
14
+ @stereotypes << base
15
+ base.extend(ClassMethods)
16
+ end
17
+
18
+ def git_stereotypes
19
+ stereotypes.select { |c| c.name.demodulize.downcase.match('git') }
20
+ end
21
+
22
+ def nogit_stereotypes
23
+ stereotypes - git_stereotypes
24
+ end
25
+ end
26
+
27
+ module ClassMethods
28
+ def label
29
+ ::ColorizedString.new(stereotype_name).send(color)
30
+ end
31
+
32
+ def stereotype_name
33
+ name.demodulize
34
+ end
35
+
36
+ {
37
+ local_project_mixin: ::Module,
38
+ publish: ::Class,
39
+ update: ::Class,
40
+ warp: ::Class
41
+ }.each do |name, is_a|
42
+ define_method "#{name}_#{is_a.name.underscore}" do
43
+ sub_constant(name.to_s.camelcase, is_a)
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def sub_constant(constant_name, is_a)
50
+ constant = const_get(constant_name)
51
+ unless is_a.if_present(true) { |v| constant.is_a?(v) }
52
+ raise("#{constant} is not a #{is_a}")
53
+ end
54
+
55
+ constant
56
+ rescue NameError
57
+ nil
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ require_sub __FILE__, base: nil
10
+
11
+ class << self
12
+ def list
13
+ @list ||= constants.map { |c| const_get(c) }
14
+ .select { |c| c.included_modules.include?(Avm::Projects::Stereotype) }
15
+ .freeze
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/projects/stereotype'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class Git
10
+ require_sub __FILE__
11
+ include Avm::Projects::Stereotype
12
+
13
+ class << self
14
+ def match?(path)
15
+ File.directory?(path.real.subpath('.git'))
16
+ end
17
+
18
+ def color
19
+ :white
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end