avm-tools 0.68.0 → 0.69.0

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