avm-tools 0.64.2 → 0.69.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) 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/instances/configuration/_locale.rb +16 -0
  20. data/lib/avm/local_projects/instance.rb +28 -1
  21. data/lib/avm/patches/i18n.rb +22 -0
  22. data/lib/avm/patches/object/i18n.rb +17 -0
  23. data/lib/avm/patches/object/template.rb +3 -3
  24. data/lib/avm/projects/stereotype.rb +3 -2
  25. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +2 -2
  26. data/lib/avm/projects/stereotypes/rails_application.rb +2 -0
  27. data/lib/avm/projects/stereotypes/rails_application/local_project_mixin.rb +18 -0
  28. data/lib/avm/projects/stereotypes/rails_application/update.rb +14 -0
  29. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +9 -0
  30. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +61 -0
  31. data/lib/avm/self.rb +5 -1
  32. data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +2 -2
  33. data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +2 -2
  34. data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +2 -2
  35. data/lib/avm/tools/runner/eac_rails_base0.rb +2 -2
  36. data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +3 -26
  37. data/lib/avm/tools/runner/eac_rails_base0/data.rb +2 -2
  38. data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +3 -3
  39. data/lib/avm/tools/runner/eac_redmine_base0/data.rb +1 -1
  40. data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +2 -2
  41. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +2 -2
  42. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +1 -0
  43. data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +3 -25
  44. data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +2 -2
  45. data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +2 -2
  46. data/lib/avm/tools/runner/local_project.rb +5 -0
  47. data/lib/avm/tools/runner/local_project/ruby.rb +24 -0
  48. data/lib/avm/tools/runner/local_project/ruby/bundler.rb +25 -0
  49. data/lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb +138 -0
  50. data/lib/avm/tools/runner/local_project/test.rb +34 -0
  51. data/lib/avm/tools/runner/local_project/update.rb +1 -2
  52. data/lib/avm/tools/runner/local_project/version_bump.rb +89 -0
  53. data/lib/avm/tools/version.rb +1 -1
  54. data/lib/avm/version.rb +45 -0
  55. data/lib/eac_launcher/git/sub_warp_base.rb +1 -1
  56. data/lib/eac_launcher/publish/base.rb +1 -1
  57. data/template/avm/{stereotypes/eac_rails_base0 → eac_rails_base0}/deploy/config/database.yml.template +0 -0
  58. data/template/avm/{stereotypes/eac_webapp_base0 → eac_webapp_base0}/apache_host/no_ssl.conf +0 -0
  59. data/vendor/eac_cli/Gemfile +5 -0
  60. data/vendor/eac_cli/eac_cli.gemspec +18 -0
  61. data/vendor/eac_cli/lib/eac_cli.rb +7 -0
  62. data/vendor/eac_cli/lib/eac_cli/default_runner.rb +22 -0
  63. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  64. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  65. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -0
  66. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  67. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +27 -0
  68. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +77 -0
  69. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
  70. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  71. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  72. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  73. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  74. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  75. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  76. data/vendor/eac_cli/lib/eac_cli/runner.rb +87 -0
  77. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  78. data/vendor/eac_cli/lib/eac_cli/version.rb +5 -0
  79. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  80. data/vendor/eac_cli/spec/rubocop_spec.rb +7 -0
  81. data/vendor/eac_cli/spec/spec_helper.rb +100 -0
  82. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +15 -1
  83. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +40 -0
  84. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +5 -34
  85. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +42 -0
  86. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
  87. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +47 -0
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  99. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  100. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  101. metadata +64 -19
  102. data/lib/avm/local_projects/jobs/update.rb +0 -29
  103. data/lib/avm/stereotypes/eac_rails_base0/apache_host.rb +0 -19
  104. data/lib/avm/stereotypes/eac_rails_base0/deploy.rb +0 -52
  105. data/lib/avm/stereotypes/eac_rails_base0/instance.rb +0 -16
  106. data/lib/avm/stereotypes/eac_webapp_base0/apache_host.rb +0 -97
  107. data/lib/avm/stereotypes/eac_webapp_base0/deploy.rb +0 -104
  108. data/lib/avm/stereotypes/eac_webapp_base0/deploy/appended_directories.rb +0 -27
  109. data/lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb +0 -43
  110. data/lib/avm/stereotypes/eac_webapp_base0/deploy/git_info.rb +0 -51
  111. data/lib/avm/stereotypes/eac_webapp_base0/deploy/version.rb +0 -22
  112. data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +0 -52
  113. data/lib/avm/stereotypes/eac_webapp_base0/runner/data.rb +0 -27
  114. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/dump.rb +0 -71
  115. data/lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb +0 -68
  116. data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +0 -61
@@ -1,29 +0,0 @@
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
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/stereotypes/eac_webapp_base0/apache_host'
4
-
5
- module Avm
6
- module Stereotypes
7
- module EacRailsBase0
8
- class ApacheHost < ::Avm::Stereotypes::EacWebappBase0::ApacheHost
9
- def document_root
10
- "#{instance.read_entry(:fs_path)}/public"
11
- end
12
-
13
- def extra_content
14
- 'PassengerEnabled On'
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/stereotypes/eac_webapp_base0/deploy'
4
-
5
- module Avm
6
- module Stereotypes
7
- module EacRailsBase0
8
- class Deploy < ::Avm::Stereotypes::EacWebappBase0::Deploy
9
- set_callback :assert_instance_branch, :after do
10
- bundle_install
11
- assert_database
12
- database_migrate
13
- compile_assets
14
- restart_tasks_scheduler
15
- touch_restart_file
16
- end
17
-
18
- def assert_database
19
- infom 'Asserting database...'
20
- instance.rake('db:create').system!
21
- end
22
-
23
- def bundle_install
24
- infom 'Running "bundle install"...'
25
- instance.bundle('install').system!
26
- end
27
-
28
- def compile_assets
29
- infom 'Compiling assets...'
30
- instance.rake('assets:clean', 'assets:precompile').system!
31
- end
32
-
33
- def database_migrate
34
- infom 'Running database migrations...'
35
- instance.rake('db:migrate').system!
36
- end
37
-
38
- def restart_tasks_scheduler
39
- infom 'Restarting Tasks Scheduler\'s daemon...'
40
- instance.bundle('exec', 'tasks_scheduler', 'restart').system!
41
- end
42
-
43
- def touch_restart_file
44
- infom 'Touching restart file...'
45
- instance.host_env.command(
46
- 'touch', ::File.join(instance.read_entry(:fs_path), 'tmp', 'restart.txt')
47
- ).system!
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/stereotypes/eac_webapp_base0/instance'
4
- require 'avm/stereotypes/rails/instance'
5
-
6
- module Avm
7
- module Stereotypes
8
- module EacRailsBase0
9
- class Instance < ::Avm::Stereotypes::EacWebappBase0::Instance
10
- include ::Avm::Stereotypes::Rails::Instance
11
-
12
- FILES_UNITS = { uploads: 'public/uploads' }.freeze
13
- end
14
- end
15
- end
16
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'avm/patches/object/template'
5
- require 'avm/stereotypes/eac_ubuntu_base0/apache'
6
- require 'avm/patches/object/template'
7
-
8
- module Avm
9
- module Stereotypes
10
- module EacWebappBase0
11
- class ApacheHost
12
- enable_console_speaker
13
- enable_simple_cache
14
- common_constructor :instance
15
-
16
- def run
17
- write_available_no_ssl_site
18
- enable_no_ssl_site
19
- remove_ssl_site
20
- reload_apache
21
- run_certbot
22
- enable_ssl_site
23
- reload_apache
24
- ::Avm::Result.success('Done')
25
- end
26
-
27
- def no_ssl_site_content
28
- ::Avm::Stereotypes::EacWebappBase0::ApacheHost.template.child('no_ssl.conf')
29
- .apply(EntriesReader.new(self, instance))
30
- end
31
-
32
- private
33
-
34
- def apache_uncached
35
- ::Avm::Stereotypes::EacUbuntuBase0::Apache.new(instance.host_env)
36
- end
37
-
38
- def enable_no_ssl_site
39
- infom 'Enabling no SSL site...'
40
- no_ssl_site.enable
41
- end
42
-
43
- def enable_ssl_site
44
- infom 'Enabling SSL site...'
45
- ssl_site.enable
46
- end
47
-
48
- def no_ssl_site_uncached
49
- apache.site(instance.id)
50
- end
51
-
52
- def reload_apache
53
- infom 'Reloading Apache...'
54
- apache.service('reload')
55
- end
56
-
57
- def remove_ssl_site
58
- infom 'Removing SSL site...'
59
- ssl_site.remove
60
- end
61
-
62
- def run_certbot
63
- infom 'Running Certbot...'
64
- instance.host_env.command(
65
- 'sudo', 'certbot', '--apache', '--domain', instance.read_entry('web.hostname'),
66
- '--redirect', '--non-interactive', '--agree-tos',
67
- '--email', instance.read_entry('admin.email')
68
- ).system!
69
- end
70
-
71
- def ssl_site_uncached
72
- apache.site(no_ssl_site.name + '-le-ssl')
73
- end
74
-
75
- def write_available_no_ssl_site
76
- infom 'Writing no SSL site conf...'
77
- no_ssl_site.write(no_ssl_site_content)
78
- end
79
-
80
- class EntriesReader
81
- common_constructor :job, :instance
82
-
83
- def read_entry(path, options = {})
84
- entry_from_job(path) || instance.read_entry(path, options)
85
- end
86
-
87
- private
88
-
89
- def entry_from_job(path)
90
- method = path.gsub('.', '_').underscore
91
- return job.send(method) if job.respond_to?(method, true)
92
- end
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/callbacks'
4
- require 'delegate'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'eac_launcher/git/base'
7
- require 'avm/git'
8
- require 'avm/patches/object/template'
9
- require 'net/http'
10
-
11
- module Avm
12
- module Stereotypes
13
- module EacWebappBase0
14
- class Deploy
15
- require_sub __FILE__, include_modules: true
16
- include ::ActiveSupport::Callbacks
17
-
18
- DEFAULT_REFERENCE = 'HEAD'
19
-
20
- enable_console_speaker
21
- enable_simple_cache
22
-
23
- JOBS = %w[git_deploy setup_files_units assert_instance_branch request_test].freeze
24
- define_callbacks(*JOBS)
25
-
26
- attr_reader :instance, :options
27
-
28
- def initialize(instance, options = {})
29
- @instance = instance
30
- @options = options
31
- end
32
-
33
- def build_git_commit
34
- ::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
35
- instance.host_env,
36
- instance.read_entry(:fs_path)
37
- ).variables_source_set(instance)
38
- end
39
-
40
- def run
41
- start_banner
42
- JOBS.each do |job|
43
- run_callbacks job do
44
- send(job)
45
- end
46
- end
47
- ::Avm::Result.success('Deployed')
48
- rescue ::Avm::Result::Error => e
49
- e.to_result
50
- end
51
-
52
- def start_banner
53
- infov 'Instance', instance
54
- infov 'Git reference (User)', git_reference.if_present('- BLANK -')
55
- infov 'Git remote name', git_remote_name
56
- infov 'Git reference (Found)', git_reference_found
57
- infov 'Git commit SHA1', commit_sha1
58
- infov 'Appended directories', appended_directories
59
- end
60
-
61
- def git_deploy
62
- infom 'Deploying source code and appended content...'
63
- build_git_commit
64
- .append_directory(template.path)
65
- .append_directories(appended_directories)
66
- .append_file_content(VERSION_TARGET_PATH, version)
67
- .run
68
- end
69
-
70
- def setup_files_units
71
- instance.class.const_get('FILES_UNITS').each do |data_key, fs_path_subpath|
72
- FileUnit.new(self, data_key, fs_path_subpath).run
73
- end
74
- end
75
-
76
- def assert_instance_branch
77
- infom 'Setting instance branch...'
78
- git.execute!('push', git_remote_name, "#{commit_sha1}:refs/heads/#{instance.id}", '-f')
79
- end
80
-
81
- def request_test
82
- infom 'Requesting web interface...'
83
- uri = URI(instance.read_entry('web.url'))
84
- response = ::Net::HTTP.get_response(uri)
85
- infov 'Response status', response.code
86
- fatal_error "Request to #{uri} failed" unless response.code.to_i == 200
87
- end
88
-
89
- def git_uncached
90
- ::EacLauncher::Git::Base.new(git_repository_path)
91
- end
92
-
93
- def git_fetch_uncached
94
- infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
95
- git.fetch(git_remote_name)
96
- end
97
-
98
- def git_repository_path
99
- instance.source_instance.read_entry(:fs_path)
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -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