avm-tools 0.68.0 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/instance/files_unit.rb +1 -1
  3. data/lib/avm/eac_rails_base0/apache_host.rb +17 -0
  4. data/lib/avm/eac_rails_base0/apache_path.rb +50 -0
  5. data/lib/avm/eac_rails_base0/deploy.rb +51 -0
  6. data/lib/avm/eac_rails_base0/instance.rb +14 -0
  7. data/lib/avm/eac_redmine_base0/deploy.rb +4 -4
  8. data/lib/avm/eac_redmine_base0/instance.rb +6 -5
  9. data/lib/avm/eac_ubuntu_base0/apache.rb +26 -0
  10. data/lib/avm/eac_ubuntu_base0/apache/resource.rb +59 -0
  11. data/lib/avm/eac_ubuntu_base0/docker_image.rb +14 -0
  12. data/lib/avm/eac_webapp_base0/apache_host.rb +103 -0
  13. data/lib/avm/eac_webapp_base0/deploy.rb +102 -0
  14. data/lib/avm/eac_webapp_base0/deploy/appended_directories.rb +25 -0
  15. data/lib/avm/eac_webapp_base0/deploy/file_unit.rb +42 -0
  16. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +49 -0
  17. data/lib/avm/eac_webapp_base0/deploy/version.rb +20 -0
  18. data/lib/avm/eac_webapp_base0/instance.rb +50 -0
  19. data/lib/avm/eac_webapp_base0/runner/apache_host.rb +39 -0
  20. data/lib/avm/eac_webapp_base0/runner/data.rb +25 -0
  21. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +69 -0
  22. data/lib/avm/eac_webapp_base0/runner/data/load.rb +66 -0
  23. data/lib/avm/eac_webapp_base0/runner/deploy.rb +59 -0
  24. data/lib/avm/git/issue/complete/_git_subrepos.rb +1 -0
  25. data/lib/avm/instances/base/auto_values/filesystem.rb +3 -1
  26. data/lib/avm/instances/entries.rb +5 -8
  27. data/lib/avm/instances/entry.rb +47 -0
  28. data/lib/avm/instances/entry_keys.rb +2 -0
  29. data/lib/avm/self/instance.rb +1 -1
  30. data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +3 -3
  31. data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +2 -2
  32. data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +2 -2
  33. data/lib/avm/tools/runner/eac_rails_base0.rb +9 -14
  34. data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +3 -26
  35. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +38 -0
  36. data/lib/avm/tools/runner/eac_rails_base0/data.rb +2 -2
  37. data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +3 -3
  38. data/lib/avm/tools/runner/eac_redmine_base0/data.rb +1 -1
  39. data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +2 -2
  40. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +2 -2
  41. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +1 -0
  42. data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +3 -25
  43. data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +2 -2
  44. data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +2 -2
  45. data/lib/avm/tools/runner/git/deploy.rb +3 -1
  46. data/lib/avm/tools/version.rb +1 -1
  47. data/template/avm/eac_rails_base0/apache_path/default.conf +13 -0
  48. data/template/avm/{stereotypes/eac_rails_base0 → eac_rails_base0}/deploy/config/database.yml.template +0 -0
  49. data/template/avm/{stereotypes/eac_webapp_base0 → eac_webapp_base0}/apache_host/no_ssl.conf +0 -0
  50. data/template/avm/self/docker_image/Dockerfile +1 -1
  51. data/vendor/eac_cli/Gemfile +5 -0
  52. data/vendor/eac_cli/eac_cli.gemspec +18 -0
  53. data/vendor/eac_cli/lib/eac_cli.rb +7 -0
  54. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
  55. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +14 -0
  56. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  57. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  58. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -0
  59. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  60. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +27 -0
  61. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +77 -0
  62. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
  63. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  64. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  65. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  66. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  67. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  68. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  69. data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
  70. data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
  71. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
  72. data/vendor/eac_cli/lib/eac_cli/runner.rb +87 -0
  73. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  74. data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
  75. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
  76. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
  77. data/vendor/eac_cli/lib/eac_cli/version.rb +5 -0
  78. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  79. data/vendor/eac_cli/spec/rubocop_spec.rb +7 -0
  80. data/vendor/eac_cli/spec/spec_helper.rb +100 -0
  81. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  82. data/vendor/eac_git/vendor/git-subrepo/lib/git-subrepo +9 -7
  83. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
  84. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +5 -1
  85. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  86. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +10 -0
  87. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +6 -5
  88. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +5 -34
  89. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +42 -0
  90. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
  91. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  92. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
  93. data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  99. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  100. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  102. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
  103. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
  104. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  105. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  106. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  107. metadata +66 -22
  108. data/lib/avm/instances/entries/entry_reader.rb +0 -45
  109. data/lib/avm/stereotypes/eac_rails_base0/apache_host.rb +0 -19
  110. data/lib/avm/stereotypes/eac_rails_base0/deploy.rb +0 -52
  111. data/lib/avm/stereotypes/eac_rails_base0/instance.rb +0 -16
  112. data/lib/avm/stereotypes/eac_ubuntu_base0/apache.rb +0 -27
  113. data/lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb +0 -61
  114. data/lib/avm/stereotypes/eac_ubuntu_base0/docker_image.rb +0 -16
  115. data/lib/avm/stereotypes/eac_webapp_base0/apache_host.rb +0 -97
  116. data/lib/avm/stereotypes/eac_webapp_base0/deploy.rb +0 -104
  117. data/lib/avm/stereotypes/eac_webapp_base0/deploy/appended_directories.rb +0 -27
  118. data/lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb +0 -43
  119. data/lib/avm/stereotypes/eac_webapp_base0/deploy/git_info.rb +0 -51
  120. data/lib/avm/stereotypes/eac_webapp_base0/deploy/version.rb +0 -22
  121. data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +0 -52
  122. data/lib/avm/stereotypes/eac_webapp_base0/runner/data.rb +0 -27
  123. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/dump.rb +0 -71
  124. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb +0 -68
  125. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +0 -61
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/path_string'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ class Deploy
8
+ module AppendedDirectories
9
+ APPENDED_DIRECTORIES_ENTRY_KEY = 'deploy.appended_directories'
10
+
11
+ def appended_directories
12
+ appended_directories_from_instance_entry + appended_directories_from_options
13
+ end
14
+
15
+ def appended_directories_from_instance_entry
16
+ ::Avm::PathString.paths(instance.read_entry_optional(APPENDED_DIRECTORIES_ENTRY_KEY))
17
+ end
18
+
19
+ def appended_directories_from_options
20
+ options[:appended_directories] || []
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module EacWebappBase0
5
+ class Deploy
6
+ class FileUnit < ::SimpleDelegator
7
+ attr_reader :data_key, :fs_path_subpath
8
+
9
+ def initialize(deploy, data_key, fs_path_subpath)
10
+ super(deploy)
11
+ @data_key = data_key
12
+ @fs_path_subpath = fs_path_subpath
13
+ end
14
+
15
+ def run
16
+ assert_source_directory
17
+ link_source_target
18
+ end
19
+
20
+ def assert_source_directory
21
+ infom "Asserting \"#{data_key}\" source directory..."
22
+ instance.host_env.command('mkdir', '-p', source_path).execute!
23
+ end
24
+
25
+ def source_path
26
+ ::File.join(instance.read_entry(:data_fs_path), data_key.to_s)
27
+ end
28
+
29
+ def target_path
30
+ ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH),
31
+ fs_path_subpath.to_s)
32
+ end
33
+
34
+ def link_source_target
35
+ infom "Linking \"#{data_key}\" directory..."
36
+ instance.host_env.command('rm', '-rf', target_path).execute!
37
+ instance.host_env.command('ln', '-s', source_path, target_path).execute!
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module EacWebappBase0
5
+ class Deploy
6
+ module GitInfo
7
+ def commit_sha1_uncached
8
+ git_fetch
9
+ r = git.rev_parse(git_reference_found)
10
+ return r if r
11
+
12
+ raise ::Avm::Result::Error, "No commit SHA1 found for \"#{git_reference_found}\""
13
+ end
14
+
15
+ def git_reference
16
+ options[:reference] || DEFAULT_REFERENCE
17
+ end
18
+
19
+ def git_reference_found_uncached
20
+ %w[git_reference instance_branch master_branch].map { |b| send(b) }.find(&:present?) ||
21
+ raise(
22
+ ::Avm::Result::Error,
23
+ 'No git reference found (Searched for option, instance and master)'
24
+ )
25
+ end
26
+
27
+ def git_remote_hashs_uncached
28
+ git.remote_hashs(git_remote_name)
29
+ end
30
+
31
+ def git_remote_name
32
+ ::Avm::Git::DEFAULT_REMOTE_NAME
33
+ end
34
+
35
+ def instance_branch
36
+ remote_branch(instance.id)
37
+ end
38
+
39
+ def remote_branch(name)
40
+ git_remote_hashs.key?("refs/heads/#{name}") ? "#{git_remote_name}/#{name}" : nil
41
+ end
42
+
43
+ def master_branch
44
+ remote_branch('master')
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module EacWebappBase0
5
+ class Deploy
6
+ module Version
7
+ VERSION_TARGET_PATH = 'VERSION'
8
+
9
+ def version
10
+ ([::Time.now, commit_sha1] + version_git_refs).join('|')
11
+ end
12
+
13
+ def version_git_refs
14
+ git_remote_hashs.select { |_name, sha1| sha1 == commit_sha1 }.keys
15
+ .map { |ref| ref.gsub(%r{\Arefs/}, '') }.reject { |ref| ref == 'HEAD' }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'avm/stereotypes/postgresql/instance_with'
5
+ require 'avm/data/instance/files_unit'
6
+ require 'avm/data/instance/package'
7
+ require 'avm/eac_webapp_base0/deploy/file_unit'
8
+
9
+ module Avm
10
+ module EacWebappBase0
11
+ class Instance < ::Avm::Instances::Base
12
+ include ::Avm::Stereotypes::Postgresql::InstanceWith
13
+
14
+ def stereotype_name
15
+ self.class.name.desconstantize.demodulize
16
+ end
17
+
18
+ def data_dump(argv = [])
19
+ run_subcommand(::Avm::Tools::Runner::EacWordpressBase0::Data::Dump, argv)
20
+ end
21
+
22
+ def data_dump_runner_class
23
+ "::Avm::Tools::Runner::#{stereotype_name}::Data::Dump".constantize
24
+ end
25
+
26
+ def run_subcommand(subcommand_class, argv)
27
+ parent = ::OpenStruct.new(instance: self)
28
+ subcommand_class.new(argv: argv, parent: parent).run
29
+ end
30
+
31
+ def data_package
32
+ @data_package ||= ::Avm::Data::Instance::Package.new(
33
+ self, units: { database: database_unit }.merge(files_units)
34
+ )
35
+ end
36
+
37
+ def database_unit
38
+ pg.data_unit
39
+ end
40
+
41
+ private
42
+
43
+ def files_units
44
+ self.class.const_get('FILES_UNITS').transform_values do |fs_path_subpath|
45
+ ::Avm::Data::Instance::FilesUnit.new(self, fs_path_subpath)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module Runner
9
+ class ApacheHost < ::EacRubyUtils::Console::DocoptRunner
10
+ include ::EacCli::DefaultRunner
11
+
12
+ stereotype_name = name.deconstantize.demodulize
13
+ runner_definition do
14
+ desc "Configure Apache virtual host for #{stereotype_name} instance."
15
+ bool_opt '-c', '--certbot', 'Install certbot.'
16
+ end
17
+
18
+ def run
19
+ options
20
+ result = stereotype_apache_host_class.new(context(:instance),
21
+ stereotype_apache_host_options).run
22
+ if result.error?
23
+ fatal_error result.to_s
24
+ else
25
+ infov 'Result', result.label
26
+ end
27
+ end
28
+
29
+ def stereotype_apache_host_class
30
+ "#{context(:instance).class.name.deconstantize}::ApacheHost".constantize
31
+ end
32
+
33
+ def stereotype_apache_host_options
34
+ { certbot: options.fetch('--certbot') }
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/require_sub'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module Runner
9
+ class Data < ::EacRubyUtils::Console::DocoptRunner
10
+ ::EacRubyUtils.require_sub(__FILE__)
11
+
12
+ DOC = <<~DOCOPT
13
+ Data utilities for EacRailsBase0 instances.
14
+
15
+ Usage:
16
+ __PROGRAM__ __SUBCOMMANDS__
17
+ __PROGRAM__ -h | --help
18
+
19
+ Options:
20
+ -h --help Show this screen.
21
+ DOCOPT
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/numeric/time'
4
+ require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_ruby_utils/simple_cache'
6
+ require 'avm/data/package/dump'
7
+
8
+ module Avm
9
+ module EacWebappBase0
10
+ module Runner
11
+ class Data < ::EacRubyUtils::Console::DocoptRunner
12
+ class Dump < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacRubyUtils::SimpleCache
14
+ include ::EacRubyUtils::Console::Speaker
15
+
16
+ DUMP_EXPIRE_TIME = 1.day
17
+ DEFAULT_DUMP_PATH_ENTRY_SUFFIX = 'data.default_dump_path'
18
+ NO_DUMP_MESSAGE = 'Dump "%s" already exist and rewrite options was no setted nor ' \
19
+ 'dump was expired.'
20
+
21
+ DOC = <<~DOCUMENT
22
+ Dump utility for EacRailsBase instance.
23
+
24
+ Usage:
25
+ __PROGRAM__ [options]
26
+
27
+ Options:
28
+ -h --help Show this screen.
29
+ --rewrite Forces dump overwrite.
30
+ --dump-path=<dump_path> Set DUMP_PATH variable.
31
+ DOCUMENT
32
+
33
+ def run
34
+ infov 'Instance to dump', "#{context(:instance)} (#{context(:instance).class})"
35
+ if package_dump.runnable?
36
+ package_dump.run
37
+ else
38
+ warn(package_dump.cannot_run_reason)
39
+ end
40
+ success("Dump path: \"#{dump_path}\"")
41
+ dump_path
42
+ end
43
+
44
+ private
45
+
46
+ def package_dump_uncached
47
+ context(:instance).data_package.dump(dump_path, existing: package_dump_existing)
48
+ end
49
+
50
+ def dump_path
51
+ options.fetch('--dump-path') || default_dump_path
52
+ end
53
+
54
+ def default_dump_path
55
+ context(:instance).read_entry(DEFAULT_DUMP_PATH_ENTRY_SUFFIX)
56
+ end
57
+
58
+ def package_dump_existing
59
+ if options.fetch('--rewrite')
60
+ ::Avm::Data::Package::Dump::EXISTING_ROTATE
61
+ else
62
+ ::Avm::Data::Package::Dump::EXISTING_ROTATE_EXPIRED
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/numeric/time'
4
+ require 'eac_ruby_utils/console/speaker'
5
+ require 'eac_ruby_utils/simple_cache'
6
+
7
+ module Avm
8
+ module EacWebappBase0
9
+ module Runner
10
+ class Data < ::EacRubyUtils::Console::DocoptRunner
11
+ class Load < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacRubyUtils::SimpleCache
13
+ include ::EacRubyUtils::Console::Speaker
14
+
15
+ DOC = <<~DOCUMENT
16
+ Load utility for EacRailsBase instance.
17
+
18
+ Usage:
19
+ __PROGRAM__ (<dump-path>|--source-instance=<source-instance>)
20
+ __PROGRAM__ -h | --help
21
+
22
+ Options:
23
+ -h --help Show this screen.
24
+ -S --source-instance=<source-instance> Informa a instância a ser extraída o dump.
25
+ DOCUMENT
26
+
27
+ def run
28
+ return ::Dev::Result.error("Dump \"#{dump_path}\" does not exist") unless
29
+ ::File.exist?(dump_path)
30
+
31
+ load_dump
32
+ success("Dump loaded from \"#{dump_path}\"")
33
+ end
34
+
35
+ def dump_path_uncached
36
+ return options.fetch('<dump-path>').to_s if options.fetch('<dump-path>').present?
37
+ return source_instance_dump_path if options.fetch('--source-instance').present?
38
+
39
+ raise "Dump path unknown (Options: #{options})"
40
+ end
41
+
42
+ def source_instance_dump_path
43
+ context(:instance).class.by_id(
44
+ options.fetch('--source-instance')
45
+ ).data_dump
46
+ end
47
+
48
+ def load_dump
49
+ info "Loading dump \"#{dump_path}\"..."
50
+ package_load.run
51
+ end
52
+
53
+ def dump_instance_method
54
+ :dump_database
55
+ end
56
+
57
+ private
58
+
59
+ def package_load_uncached
60
+ context(:instance).data_package.load(dump_path)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/path_string'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/console/speaker'
6
+
7
+ module Avm
8
+ module EacWebappBase0
9
+ module Runner
10
+ class Deploy < ::EacRubyUtils::Console::DocoptRunner
11
+ include ::EacRubyUtils::Console::Speaker
12
+
13
+ DOC = <<~DOCOPT
14
+ Deploy for %%STEREOTYPE_NAME%% instance.
15
+
16
+ Usage:
17
+ __PROGRAM__ [options]
18
+ __PROGRAM__ -h | --help
19
+
20
+ Options:
21
+ -h --help Show this screen.
22
+ -r --reference=<git-reference> Git reference to deploy.
23
+ -a --append-dirs=<append-dirs> Append directories to deploy (List separated by ":").
24
+ DOCOPT
25
+ def initialize(settings = {})
26
+ super settings.merge(doc: DOC.gsub('%%STEREOTYPE_NAME%%', stereotype_name))
27
+ end
28
+
29
+ def deploy_class
30
+ stereotype_module.const_get('Deploy')
31
+ end
32
+
33
+ def stereotype_module
34
+ ::Avm::Stereotypes.const_get(stereotype_name)
35
+ rescue ::NameError
36
+ ::Avm.const_get(stereotype_name)
37
+ end
38
+
39
+ def stereotype_name
40
+ self.class.name.deconstantize.demodulize
41
+ end
42
+
43
+ def run
44
+ result = deploy_class.new(context(:instance), deploy_options).run
45
+ if result.error?
46
+ fatal_error result.to_s
47
+ else
48
+ infov 'Result', result.label
49
+ end
50
+ end
51
+
52
+ def deploy_options
53
+ { reference: options.fetch('--reference'),
54
+ appended_directories: ::Avm::PathString.paths(options.fetch('--append-dirs')) }
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end