eac_tools 0.86.7 → 0.86.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -9
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm-eac_webapp_base0/Gemfile +8 -0
  5. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +25 -0
  6. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/executables.rb +26 -0
  7. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/css/file_apply.rb +48 -0
  8. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/css.rb +22 -0
  9. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/html.rb +43 -0
  10. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/javascript.rb +22 -0
  11. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/json.rb +25 -0
  12. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/provider.rb +24 -0
  13. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats/xml.rb +26 -0
  14. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/file_formats.rb +11 -0
  15. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_base.rb +33 -0
  16. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_host.rb +78 -0
  17. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_path.rb +42 -0
  18. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/apache.rb +44 -0
  19. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/install.rb +22 -0
  20. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base.rb +44 -0
  21. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/appended_directories.rb +27 -0
  22. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/build.rb +50 -0
  23. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/scm.rb +72 -0
  24. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb +53 -0
  25. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/version.rb +26 -0
  26. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/write_on_target.rb +20 -0
  27. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy.rb +73 -0
  28. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes/web_server.rb +37 -0
  29. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes.rb +13 -0
  30. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/apache_host.rb +36 -0
  31. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/apache_path.rb +40 -0
  32. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/data/load.rb +60 -0
  33. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners/deploy.rb +43 -0
  34. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/runners.rb +13 -0
  35. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/sources/base.rb +15 -0
  36. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/sources.rb +11 -0
  37. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +7 -0
  38. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0.rb +9 -0
  39. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec.rb +7 -0
  40. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec_files/css1.source.css +11 -0
  41. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/css_spec_files/css1.target.css +11 -0
  42. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec.rb +7 -0
  43. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.erb.source +8 -0
  44. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.erb.target +8 -0
  45. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.source +5 -0
  46. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/html_spec_files/html_code.html.target +5 -0
  47. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec.rb +7 -0
  48. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec_files/javascript_code1.js.source +29 -0
  49. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/javascript_spec_files/javascript_code1.js.target +21 -0
  50. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec.rb +7 -0
  51. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec_files/json_code.json.source +8 -0
  52. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/json_spec_files/json_code.json.target +7 -0
  53. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec.rb +7 -0
  54. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec_files/xml_code.xml.source +11 -0
  55. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/file_formats/xml_spec_files/xml_code.xml.target +9 -0
  56. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/instances/base_spec.rb +11 -0
  57. data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/sources/base_spec.rb +7 -0
  58. data/sub/avm-eac_webapp_base0/spec/rubocop_spec.rb +3 -0
  59. data/sub/avm-eac_webapp_base0/spec/spec_helper.rb +4 -0
  60. data/sub/avm-eac_webapp_base0/template/avm/eac_webapp_base0/instances/apache_host/no_ssl.conf +11 -0
  61. data/sub/avm-eac_webapp_base0/template/avm/eac_webapp_base0/instances/apache_path/default.conf +7 -0
  62. metadata +62 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d67c2a515fd0150abe443e603d3cd661157476bfbdc017f72e9e7fbcbbd0e893
4
- data.tar.gz: 7804925301bc2de9ad5897721b8c4a0f19ea028a28faa75b6d025ccdae39ee3d
3
+ metadata.gz: 3a651785bbad5b6e82261dd8b700b59444065b413a84e1761eaeb52b5f678e8b
4
+ data.tar.gz: a83ff785fb5a584a6d53a241df483c72d82f73331d0988ca7a46d28da1995342
5
5
  SHA512:
6
- metadata.gz: 7ca17b5749cc8815d455f8e382e8734eb55adedb239bf0607284b06227047cd71586cca3bf0fbea6e6783ef6ee57f0c91cfb804376258372a03eca1a165fdcae
7
- data.tar.gz: d168cc711313a7404b33c421a6e03dec8a2a4848c42674fdcfc8ab7d91b915a9de8fb700456fff0deb1f6d5872b4ea91d28928537807394f9995c7e4afbcebc1
6
+ metadata.gz: 421d195b6f42b45c6dde83b4357307aa3acc9332be4925fd89aef01fd9e65d4fda2abc52424bb45ae236da15326ca69b291458895274a6ecefa72efa9595916d
7
+ data.tar.gz: 7ab426184c8b950306561e5762219be50cb101eeef7a09edf422d72d9da0dbcaff488883c8dd17386231ae39b82c33f080783e315cc78c4302c64afa14efb5de
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.86.7)
4
+ eac_tools (0.86.8)
5
5
  avm (~> 0.86, >= 0.86.2)
6
6
  avm-eac_asciidoctor_base0 (~> 0.22)
7
7
  avm-eac_generic_base0 (~> 0.12, >= 0.12.2)
@@ -16,7 +16,7 @@ PATH
16
16
  avm-eac_redmine_base0 (~> 0.22)
17
17
  avm-eac_redmine_plugin_base0 (~> 0.4, >= 0.4.1)
18
18
  avm-eac_ruby_base1 (~> 0.33, >= 0.33.1)
19
- avm-eac_webapp_base0 (~> 0.18, >= 0.18.3)
19
+ avm-eac_webapp_base0 (~> 0.18, >= 0.18.4)
20
20
  avm-eac_wordpress_base0 (~> 0.3, >= 0.3.1)
21
21
  avm-git (~> 0.17)
22
22
  avm-tools (~> 0.161)
@@ -44,6 +44,18 @@ PATH
44
44
  eac_ruby_utils (~> 0.117, >= 0.117.1)
45
45
  eac_templates (~> 0.5)
46
46
 
47
+ PATH
48
+ remote: sub/avm-eac_webapp_base0
49
+ specs:
50
+ avm-eac_webapp_base0 (0.18.4)
51
+ avm (~> 0.86, >= 0.86.2)
52
+ avm-eac_generic_base0 (~> 0.12, >= 0.12.2)
53
+ avm-eac_postgresql_base0 (~> 0.5, >= 0.5.3)
54
+ avm-eac_ubuntu_base0 (~> 0.5)
55
+ avm-files (~> 0.7)
56
+ eac_ruby_utils (~> 0.121)
57
+ htmlbeautifier (~> 1.4, >= 1.4.3)
58
+
47
59
  PATH
48
60
  remote: sub/avm-eac_wordpress_base0
49
61
  specs:
@@ -136,13 +148,6 @@ GEM
136
148
  avm-eac_generic_base0 (~> 0.12, >= 0.12.1)
137
149
  eac_envs-http (~> 0.4, >= 0.4.1)
138
150
  eac_ruby_utils (~> 0.119, >= 0.119.2)
139
- avm-eac_webapp_base0 (0.18.3)
140
- avm (~> 0.84, >= 0.84.2)
141
- avm-eac_generic_base0 (~> 0.12, >= 0.12.2)
142
- avm-eac_postgresql_base0 (~> 0.5, >= 0.5.2)
143
- avm-eac_ubuntu_base0 (~> 0.5)
144
- avm-files (~> 0.6, >= 0.6.2)
145
- eac_ruby_utils (~> 0.120)
146
151
  avm-files (0.7.0)
147
152
  avm (~> 0.84, >= 0.84.2)
148
153
  eac_cli (~> 0.40)
@@ -236,6 +241,7 @@ GEM
236
241
  addressable (~> 2.8)
237
242
  rchardet (~> 1.8)
238
243
  hpricot (0.8.6)
244
+ htmlbeautifier (1.4.3)
239
245
  i18n (1.14.1)
240
246
  concurrent-ruby (~> 1.0)
241
247
  json (2.7.1)
@@ -333,6 +339,7 @@ DEPENDENCIES
333
339
  avm-eac_rails_base0!
334
340
  avm-eac_redmine_plugin_base0!
335
341
  avm-eac_ubuntu_base0!
342
+ avm-eac_webapp_base0!
336
343
  avm-eac_wordpress_base0!
337
344
  eac_ruby_gem_support (~> 0.10)
338
345
  eac_tools!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.86.7'
4
+ VERSION = '0.86.8'
5
5
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if File.exist?(local_gemfile)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'avm/eac_webapp_base0/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'avm-eac_webapp_base0'
9
+ s.version = Avm::EacWebappBase0::VERSION
10
+ s.authors = ['Put here the authors']
11
+ s.summary = 'Put here de description.'
12
+
13
+ s.files = Dir['{lib,template}/**/*']
14
+ s.required_ruby_version = '>= 2.7'
15
+
16
+ s.add_dependency 'avm', '~> 0.86', '>= 0.86.2'
17
+ s.add_dependency 'avm-eac_generic_base0', '~> 0.12', '>= 0.12.2'
18
+ s.add_dependency 'avm-eac_postgresql_base0', '~> 0.5', '>= 0.5.3'
19
+ s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.5'
20
+ s.add_dependency 'avm-files', '~> 0.7'
21
+ s.add_dependency 'eac_ruby_utils', '~> 0.121'
22
+ s.add_dependency 'htmlbeautifier', '~> 1.4', '>= 1.4.3'
23
+
24
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.10'
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/envs'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module Executables
9
+ class << self
10
+ enable_simple_cache
11
+
12
+ def env
13
+ ::EacRubyUtils::Envs.local
14
+ end
15
+
16
+ private
17
+
18
+ %w[cssbeautify-cli js-beautify tidy].each do |program|
19
+ define_method("#{program.underscore}_uncached") do
20
+ env.executable(program, '--version')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+ require 'avm/eac_webapp_base0/executables'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacWebappBase0
9
+ module FileFormats
10
+ class Css < ::Avm::EacGenericBase0::FileFormats::Base
11
+ class FileApply
12
+ EXECUTABLE_NAME = 'cssbeautify-cli'
13
+ EXECUTABLE_CHECK_ARGS = ['--version'].freeze
14
+ EXECUTABLE_STATIC_ARGS = ['--autosemicolon', '--indent', ' ', '--openbrace',
15
+ 'end-of-line', '--stdin'].freeze
16
+
17
+ common_constructor :file
18
+
19
+ def perform
20
+ on_temp_output_file do |_temp_file|
21
+ run_command
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ attr_accessor :output_file
28
+
29
+ def command
30
+ ::Avm::EacWebappBase0::Executables.cssbeautify_cli.command(*EXECUTABLE_STATIC_ARGS)
31
+ end
32
+
33
+ def on_temp_output_file
34
+ ::EacRubyUtils::Fs::Temp.on_file do |temp_output_file|
35
+ self.output_file = temp_output_file
36
+ yield
37
+ ::FileUtils.mv(temp_output_file.to_path, file)
38
+ end
39
+ end
40
+
41
+ def run_command
42
+ command.system!(input_file: file, output_file: output_file.to_path)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+ require 'eac_ruby_utils/envs'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module FileFormats
9
+ class Css < ::Avm::EacGenericBase0::FileFormats::Base
10
+ require_sub __FILE__
11
+
12
+ VALID_BASENAMES = %w[*.css *.scss].freeze
13
+ VALID_TYPES = [].freeze
14
+
15
+ def file_apply(file)
16
+ ::Avm::EacWebappBase0::FileFormats::Css::FileApply.new(file).perform
17
+ super(file)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+ require 'htmlbeautifier'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module FileFormats
9
+ class Html < ::Avm::EacGenericBase0::FileFormats::Base
10
+ VALID_BASENAMES = %w[*.html *.html.erb].freeze
11
+ VALID_TYPES = [].freeze
12
+
13
+ def file_apply(path)
14
+ input = ::File.read(path)
15
+ temppath = tempfile_path
16
+ ::File.open(temppath, 'w') do |output|
17
+ beautify path, input, output
18
+ end
19
+ ::FileUtils.mv(temppath, path)
20
+ super(path)
21
+ end
22
+
23
+ private
24
+
25
+ def beautify(name, input, output)
26
+ output.puts ::HtmlBeautifier.beautify(input, htmlbeautify_options)
27
+ rescue StandardError => e
28
+ raise "Error parsing #{name}: #{e}"
29
+ end
30
+
31
+ def htmlbeautify_options
32
+ @htmlbeautify_options ||= { indent: ' ' }
33
+ end
34
+
35
+ def tempfile_path
36
+ tempfile = ::Tempfile.new
37
+ tempfile.close
38
+ tempfile.path
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+ require 'avm/eac_webapp_base0/executables'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module FileFormats
9
+ class Javascript < ::Avm::EacGenericBase0::FileFormats::Base
10
+ VALID_BASENAMES = %w[*.js].freeze
11
+ VALID_TYPES = [].freeze
12
+
13
+ def internal_apply(files)
14
+ ::Avm::EacWebappBase0::Executables.js_beautify.command.append(
15
+ ['--indent-size=2', '--end-with-newline', '--replace', *files]
16
+ ).system!
17
+ super(files)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ module FileFormats
8
+ class Json < ::Avm::EacGenericBase0::FileFormats::Base
9
+ VALID_BASENAMES = %w[*.json].freeze
10
+ VALID_TYPES = [].freeze
11
+
12
+ def file_apply(file)
13
+ ::File.write(file, ::JSON.pretty_generate(::JSON.parse(::File.read(file))))
14
+ end
15
+
16
+ def json_file?(file)
17
+ ::JSON.parse(::File.read(file))
18
+ true
19
+ rescue JSON::ParserError
20
+ false
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/file_formats/css'
4
+ require 'avm/eac_webapp_base0/file_formats/html'
5
+ require 'avm/eac_webapp_base0/file_formats/javascript'
6
+ require 'avm/eac_webapp_base0/file_formats/json'
7
+ require 'avm/eac_webapp_base0/file_formats/xml'
8
+ require 'eac_ruby_utils/core_ext'
9
+
10
+ module Avm
11
+ module EacWebappBase0
12
+ module FileFormats
13
+ class Provider
14
+ ALL_NAMES = %w[css html javascript json xml].freeze
15
+
16
+ def all
17
+ @all ||= ALL_NAMES.map do |name|
18
+ ::Avm::EacWebappBase0::FileFormats.const_get(name.camelize)
19
+ end.freeze
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/file_formats/base'
4
+ require 'avm/eac_webapp_base0/executables'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module FileFormats
9
+ class Xml < ::Avm::EacGenericBase0::FileFormats::Base
10
+ VALID_BASENAMES = %w[*.svg *.xml].freeze
11
+ VALID_TYPES = ['image/svg+xml', 'xml'].freeze
12
+
13
+ def internal_apply(files)
14
+ format_command(files).system!
15
+ super(files)
16
+ end
17
+
18
+ def format_command(files)
19
+ ::Avm::EacWebappBase0::Executables.tidy.command.append(
20
+ %w[-xml -modify --indent auto --indent-spaces 2 --wrap 100] + files
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ module FileFormats
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/entries/jobs/base'
5
+ require 'avm/eac_ubuntu_base0/apache'
6
+ require 'eac_templates/core_ext'
7
+
8
+ module Avm
9
+ module EacWebappBase0
10
+ module Instances
11
+ class ApacheBase
12
+ # @return [String]
13
+ def document_root
14
+ instance.read_entry(::Avm::Instances::EntryKeys::INSTALL_PATH)
15
+ end
16
+
17
+ protected
18
+
19
+ def reload_apache
20
+ infom 'Reloading Apache...'
21
+ apache.service('reload')
22
+ end
23
+
24
+ private
25
+
26
+ # @return [Avm::EacUbuntuBase0::Apache]
27
+ def apache_uncached
28
+ instance.platform_instance.apache
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/entries/jobs/base'
5
+ require 'avm/eac_ubuntu_base0/apache'
6
+ require 'avm/eac_webapp_base0/instances/apache_base'
7
+ require 'eac_templates/core_ext'
8
+
9
+ module Avm
10
+ module EacWebappBase0
11
+ module Instances
12
+ class ApacheHost < ::Avm::EacWebappBase0::Instances::ApacheBase
13
+ APACHE_DIRECTORY_EXTRA_CONFIG_KEY = 'install.apache_directory_extra_config'
14
+ JOBS = %w[write_available_no_ssl_site enable_no_ssl_site remove_ssl_site reload_apache
15
+ run_certbot enable_ssl_site reload_apache].freeze
16
+ include ::Avm::Entries::Jobs::Base
17
+
18
+ def directory_extra_config
19
+ instance.entry(APACHE_DIRECTORY_EXTRA_CONFIG_KEY).optional_value
20
+ .if_present { |v| " #{v}\n" }
21
+ end
22
+
23
+ def no_ssl_site_content
24
+ ::Avm::EacWebappBase0::Instances::ApacheHost
25
+ .template.child('no_ssl.conf')
26
+ .apply(variables_source)
27
+ end
28
+
29
+ def ssl?
30
+ options[:certbot]
31
+ end
32
+
33
+ private
34
+
35
+ def enable_no_ssl_site
36
+ infom 'Enabling no SSL site...'
37
+ no_ssl_site.enable
38
+ end
39
+
40
+ def enable_ssl_site
41
+ return unless ssl?
42
+
43
+ infom 'Enabling SSL site...'
44
+ ssl_site.enable
45
+ end
46
+
47
+ def no_ssl_site_uncached
48
+ apache.site(instance.id)
49
+ end
50
+
51
+ def remove_ssl_site
52
+ infom 'Removing SSL site...'
53
+ ssl_site.remove
54
+ end
55
+
56
+ def run_certbot
57
+ return unless ssl?
58
+
59
+ infom 'Running Certbot...'
60
+ instance.host_env.command(
61
+ 'sudo', 'certbot', '--apache', '--domain', instance.read_entry('web.hostname'),
62
+ '--redirect', '--non-interactive', '--agree-tos',
63
+ '--email', instance.install_email
64
+ ).system!
65
+ end
66
+
67
+ def ssl_site_uncached
68
+ apache.site("#{no_ssl_site.name}-le-ssl")
69
+ end
70
+
71
+ def write_available_no_ssl_site
72
+ infom 'Writing no SSL site conf...'
73
+ no_ssl_site.write(no_ssl_site_content)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/entries/jobs/base'
4
+ require 'avm/eac_ubuntu_base0/apache'
5
+ require 'avm/eac_webapp_base0/instances/apache_base'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module EacWebappBase0
10
+ module Instances
11
+ class ApachePath < ::Avm::EacWebappBase0::Instances::ApacheBase
12
+ JOBS = %w[write_available_conf enable_conf reload_apache].freeze
13
+ include ::Avm::Entries::Jobs::Base
14
+
15
+ def content
16
+ ::Avm::EacWebappBase0::Instances::ApachePath.template.child('default.conf')
17
+ .apply(variables_source)
18
+ end
19
+
20
+ def extra_content
21
+ ''
22
+ end
23
+
24
+ private
25
+
26
+ def enable_conf
27
+ infom 'Enabling configuration...'
28
+ conf.enable
29
+ end
30
+
31
+ def conf_uncached
32
+ apache.conf(instance.id)
33
+ end
34
+
35
+ def write_available_conf
36
+ infom 'Writing available configuration...'
37
+ conf.write(content)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module EacWebappBase0
5
+ module Instances
6
+ class Base < ::Avm::Instances::Base
7
+ module Apache
8
+ common_concern
9
+
10
+ class_methods do
11
+ # @return [Class]
12
+ def apache_path_class
13
+ ancestors.lazy.map { |ancestor| apache_path_class_by_ancestor(ancestor) }
14
+ .find(&:present?) || raise("No apache patch class found for \"#{self}\"")
15
+ end
16
+
17
+ private
18
+
19
+ # @param ancestor [Module]
20
+ # @return [Class]
21
+ def apache_path_class_by_ancestor(ancestor)
22
+ "#{ancestor.name.deconstantize}::ApachePath".constantize
23
+ rescue ::NameError
24
+ nil
25
+ end
26
+ end
27
+
28
+ # @return [Class]
29
+ def apache_path_class
30
+ self.class.apache_path_class
31
+ end
32
+
33
+ # @return [Avm::EacUbuntuBase0::Apache::Resource, nil]
34
+ def apache_resource
35
+ %i[conf site]
36
+ .lazy
37
+ .map { |type| platform_instance.apache.send(type, install_apache_resource_name) }
38
+ .find(&:available?)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/entries/uri_builder'
4
+ require 'avm/instances/entry_keys'
5
+
6
+ module Avm
7
+ module EacWebappBase0
8
+ module Instances
9
+ class Base < ::Avm::Instances::Base
10
+ module Install
11
+ common_concern do
12
+ uri_components_entries_values 'install', %w[apache_resource_name]
13
+ end
14
+
15
+ def install_apache_resource_name_default_value
16
+ id
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/base'
4
+ require 'avm/eac_postgresql_base0/instance_with'
5
+ require 'avm/instances/data/files_unit'
6
+ require 'avm/instances/data/package'
7
+ require 'avm/eac_webapp_base0/instances/processes/web_server'
8
+ require 'avm/eac_webapp_base0/instances/runners'
9
+ require 'avm/eac_ubuntu_base0/instances/base'
10
+
11
+ module Avm
12
+ module EacWebappBase0
13
+ module Instances
14
+ class Base < ::Avm::Instances::Base
15
+ require_sub __FILE__, include_modules: true
16
+ include ::Avm::EacPostgresqlBase0::InstanceWith
17
+ enable_simple_cache
18
+
19
+ def run_subcommand(subcommand_class, argv)
20
+ subcommand_class.create(
21
+ argv: argv,
22
+ parent: ::Avm::Instances::Base::SubcommandParent.new(self)
23
+ ).run
24
+ end
25
+
26
+ def database_unit
27
+ pg_data_unit
28
+ end
29
+
30
+ # @return [Array<Avm::Instances::Process>]
31
+ def processes
32
+ super + [::Avm::EacWebappBase0::Instances::Processes::WebServer.new(self)]
33
+ end
34
+
35
+ private
36
+
37
+ # @return [Avm::EacUbuntuBase0::Instances::Base]
38
+ def platform_instance_uncached
39
+ ::Avm::EacUbuntuBase0::Instances::Base.by_id(id)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/path_string'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ module Instances
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[OPTION_APPENDED_DIRECTORIES] || []
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end