avm-tools 0.74.1 → 0.77.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_rails_base1/runner/bundle.rb +2 -2
  3. data/lib/avm/eac_rails_base1/runner/code_runner.rb +3 -3
  4. data/lib/avm/eac_webapp_base0/deploy.rb +17 -40
  5. data/lib/avm/eac_webapp_base0/deploy/build.rb +48 -0
  6. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +13 -0
  7. data/lib/avm/eac_webapp_base0/deploy/version.rb +4 -0
  8. data/lib/avm/eac_webapp_base0/deploy/write_on_target.rb +18 -0
  9. data/lib/avm/eac_webapp_base0/runner/deploy.rb +1 -0
  10. data/lib/avm/eac_writings_base0/apache_host.rb +17 -0
  11. data/lib/avm/eac_writings_base0/deploy.rb +36 -0
  12. data/lib/avm/eac_writings_base0/instance.rb +11 -0
  13. data/lib/avm/files/appendable.rb +55 -0
  14. data/lib/avm/files/appendable/file_content.rb +24 -0
  15. data/lib/avm/files/appendable/plain_directory.rb +25 -0
  16. data/lib/avm/files/appendable/resource_base.rb +13 -0
  17. data/lib/avm/files/appendable/tar_output_command.rb +26 -0
  18. data/lib/avm/files/appendable/templatized_directory.rb +28 -0
  19. data/lib/avm/files/appender.rb +11 -0
  20. data/lib/avm/files/deploy.rb +72 -0
  21. data/lib/avm/files/formatter.rb +8 -4
  22. data/lib/avm/git/auto_commit_path.rb +2 -4
  23. data/lib/avm/git/auto_commit_path/ruby.rb +20 -0
  24. data/lib/avm/git/commit/deploy.rb +8 -61
  25. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +1 -0
  26. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +7 -16
  27. data/lib/avm/tools/runner/eac_writings_base0.rb +15 -0
  28. data/lib/avm/tools/runner/files/format.rb +3 -2
  29. data/lib/avm/tools/runner/git/auto_commit.rb +11 -0
  30. data/lib/avm/tools/runner/git/deploy.rb +1 -1
  31. data/lib/avm/tools/version.rb +1 -1
  32. data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
  33. data/template/avm/{stereotypes/eac_ubuntu_base0 → eac_ubuntu_base0}/docker_image/Dockerfile +0 -0
  34. data/template/avm/{stereotypes/eac_wordpress_base0 → eac_wordpress_base0}/deploy/wp-config.php.template +0 -0
  35. data/template/avm/eac_writings_base0/deploy/index.html.template +9 -0
  36. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  37. data/vendor/eac_cli/lib/eac_cli/definition.rb +49 -22
  38. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  39. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
  40. data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb} +20 -49
  41. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
  42. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  43. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  44. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +1 -0
  45. data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
  46. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
  47. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  48. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  49. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  50. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  51. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
  52. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
  53. data/vendor/eac_cli/lib/eac_cli/runner.rb +6 -2
  54. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
  55. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +96 -0
  56. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  57. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  58. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +35 -0
  59. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  60. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +57 -40
  61. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +57 -0
  62. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
  63. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
  64. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +59 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +7 -107
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  69. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +46 -0
  70. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  71. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
  72. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
  73. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
  74. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
  75. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  77. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  78. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
  79. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
  80. metadata +45 -12
  81. data/lib/avm/git/commit/deploy/appended.rb +0 -37
  82. data/lib/avm/git/commit/deploy/appended/base.rb +0 -17
  83. data/lib/avm/git/commit/deploy/appended/directory.rb +0 -32
  84. data/lib/avm/git/commit/deploy/appended/file_content.rb +0 -28
  85. data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +0 -14
  86. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -21
  87. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86b1ee08028ac161c73a2069542d961e11585fd4eee8673307cb5f3912e0c215
4
- data.tar.gz: 438fccaf469c7843762e381a853514ff60fb466bc202e628188eb8a512982129
3
+ metadata.gz: 3345f4afdd4f7bb8cb968848675bc6b1d5c91e5833b17e90c43a01eae82a95c3
4
+ data.tar.gz: 5e032e2b459e3c1fe3bf5c42e054d89491736c8e181b17a988a079068728b526
5
5
  SHA512:
6
- metadata.gz: adfbd30ba8bac66dbb87a165d1839a1163b0679f582e326ae888fc6f773d9eeaa67d8b7047d9a0f2ec16cf98dd815ddccf2097c2003743a9fee5b7a49e67a769
7
- data.tar.gz: deca6800842fd5dcebc5748ea4b4fa0909ff3e6bb7c927c5506d01b6f14af7588d2527f0c8c6636c11783b866dadbb65d8c59715198648eac7a9964ae2fec4a4
6
+ metadata.gz: eccb5df2cf88efda09388fdcbf6a363ad32d49772980b57a58865d5b322c49848cfbaacbd572d4c7c9f9fa2af486ee5efb32b6632b91ead052546e76aa3be51d
7
+ data.tar.gz: a28d9a27d6c22363d021dad5c1bee61cff8785139c9f69cf131762a6702f988d478ae15880845eb6294941b99e0e391496f4298e99864455543ebad80f8e8866
@@ -8,7 +8,7 @@ require 'shellwords'
8
8
  module Avm
9
9
  module EacRailsBase1
10
10
  class Runner < ::Avm::EacWebappBase0::Runner
11
- class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
+ class Bundle
12
12
  runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle
13
13
  runner_definition do
14
14
  desc 'Runs "bundle ...".'
@@ -20,7 +20,7 @@ module Avm
20
20
  end
21
21
 
22
22
  def bundle_args
23
- options.fetch('<bundle-args>').reject { |arg| arg == '--' }
23
+ parsed.bundle_args.reject { |arg| arg == '--' }
24
24
  end
25
25
  end
26
26
  end
@@ -7,7 +7,7 @@ require 'eac_ruby_utils/console/docopt_runner'
7
7
  module Avm
8
8
  module EacRailsBase1
9
9
  class Runner < ::Avm::EacWebappBase0::Runner
10
- class CodeRunner < ::EacRubyUtils::Console::DocoptRunner
10
+ class CodeRunner
11
11
  runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle
12
12
  runner_definition do
13
13
  desc 'Runs a Ruby code with "rails runner".'
@@ -15,12 +15,12 @@ module Avm
15
15
  end
16
16
 
17
17
  def run
18
- infov 'Environment', context(:instance).host_env
18
+ infov 'Environment', runner_context.call(:instance).host_env
19
19
  bundle_run
20
20
  end
21
21
 
22
22
  def bundle_args
23
- %w[exec rails runner] + [options.fetch('<code>')]
23
+ %w[exec rails runner] + [parsed.code]
24
24
  end
25
25
  end
26
26
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/callbacks'
4
- require 'delegate'
5
- require 'eac_ruby_utils/core_ext'
6
- require 'eac_launcher/git/base'
7
4
  require 'avm/git'
8
5
  require 'avm/patches/object/template'
6
+ require 'eac_ruby_utils/core_ext'
7
+ require 'eac_launcher/git/base'
9
8
  require 'net/http'
10
9
 
11
10
  module Avm
@@ -18,34 +17,20 @@ module Avm
18
17
 
19
18
  enable_console_speaker
20
19
  enable_simple_cache
20
+ common_constructor :instance, :options, default: [{}]
21
21
 
22
- JOBS = %w[git_deploy setup_files_units assert_instance_branch request_test].freeze
22
+ JOBS = %w[create_build_dir build_content append_instance_content write_on_target
23
+ setup_files_units assert_instance_branch request_test].freeze
23
24
  define_callbacks(*JOBS)
24
25
 
25
- attr_reader :instance, :options
26
-
27
- def initialize(instance, options = {})
28
- @instance = instance
29
- @options = options
30
- end
31
-
32
- def build_git_commit
33
- ::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
34
- instance.host_env,
35
- instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
36
- ).variables_source_set(instance)
37
- end
38
-
39
26
  def run
40
27
  start_banner
41
- JOBS.each do |job|
42
- run_callbacks job do
43
- send(job)
44
- end
45
- end
28
+ run_jobs
46
29
  ::Avm::Result.success('Deployed')
47
30
  rescue ::Avm::Result::Error => e
48
31
  e.to_result
32
+ ensure
33
+ remove_build_dir
49
34
  end
50
35
 
51
36
  def start_banner
@@ -57,15 +42,6 @@ module Avm
57
42
  infov 'Appended directories', appended_directories
58
43
  end
59
44
 
60
- def git_deploy
61
- infom 'Deploying source code and appended content...'
62
- build_git_commit
63
- .append_directory(template.path)
64
- .append_directories(appended_directories)
65
- .append_file_content(VERSION_TARGET_PATH, version)
66
- .run
67
- end
68
-
69
45
  def setup_files_units
70
46
  instance.class.const_get('FILES_UNITS').each do |data_key, fs_path_subpath|
71
47
  FileUnit.new(self, data_key, fs_path_subpath).run
@@ -85,17 +61,18 @@ module Avm
85
61
  fatal_error "Request to #{uri} failed" unless response.code.to_i == 200
86
62
  end
87
63
 
88
- def git_uncached
89
- ::EacLauncher::Git::Base.new(git_repository_path)
64
+ def variables_source
65
+ instance
90
66
  end
91
67
 
92
- def git_fetch_uncached
93
- infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
94
- git.fetch(git_remote_name)
95
- end
68
+ private
96
69
 
97
- def git_repository_path
98
- instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
70
+ def run_jobs
71
+ JOBS.each do |job|
72
+ run_callbacks job do
73
+ send(job)
74
+ end
75
+ end
99
76
  end
100
77
  end
101
78
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/files/appender'
4
+ require 'avm/files/deploy'
5
+ require 'eac_ruby_utils/envs'
6
+ require 'eac_ruby_utils/fs/temp'
7
+
8
+ module Avm
9
+ module EacWebappBase0
10
+ class Deploy
11
+ module Build
12
+ private
13
+
14
+ attr_accessor :build_dir
15
+
16
+ def append_instance_content
17
+ ::Avm::Files::Appender
18
+ .new
19
+ .variables_source_set(variables_source)
20
+ .append_templatized_directory(template.path)
21
+ .append_templatized_directories(appended_directories)
22
+ .append_file_content(version_target_path, version)
23
+ .write_appended_on(build_dir)
24
+ end
25
+
26
+ def build_dir_env
27
+ ::EacRubyUtils::Envs.local
28
+ end
29
+
30
+ def create_build_dir
31
+ self.build_dir = ::EacRubyUtils::Fs::Temp.directory
32
+ end
33
+
34
+ def remove_build_dir
35
+ build_dir&.remove
36
+ end
37
+
38
+ def build_content
39
+ infom 'Writing Git source code...'
40
+ ::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
41
+ build_dir_env,
42
+ build_dir
43
+ ).variables_source_set(variables_source).run
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -12,6 +12,11 @@ module Avm
12
12
  raise ::Avm::Result::Error, "No commit SHA1 found for \"#{git_reference_found}\""
13
13
  end
14
14
 
15
+ def git_fetch_uncached
16
+ infom "Fetching remote \"#{git_remote_name}\" from \"#{git_repository_path}\"..."
17
+ git.fetch(git_remote_name)
18
+ end
19
+
15
20
  def git_reference
16
21
  options[:reference] || DEFAULT_REFERENCE
17
22
  end
@@ -32,6 +37,14 @@ module Avm
32
37
  ::Avm::Git::DEFAULT_REMOTE_NAME
33
38
  end
34
39
 
40
+ def git_repository_path
41
+ instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
42
+ end
43
+
44
+ def git_uncached
45
+ ::EacLauncher::Git::Base.new(git_repository_path)
46
+ end
47
+
35
48
  def instance_branch
36
49
  remote_branch(instance.id)
37
50
  end
@@ -14,6 +14,10 @@ module Avm
14
14
  git_remote_hashs.select { |_name, sha1| sha1 == commit_sha1 }.keys
15
15
  .map { |ref| ref.gsub(%r{\Arefs/}, '') }.reject { |ref| ref == 'HEAD' }
16
16
  end
17
+
18
+ def version_target_path
19
+ VERSION_TARGET_PATH
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacWebappBase0
7
+ class Deploy
8
+ module WriteOnTarget
9
+ def write_on_target
10
+ ::Avm::Files::Deploy.new(
11
+ instance.host_env,
12
+ instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
13
+ ).append_plain_directory(build_dir).run
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/runner'
3
4
  require 'avm/path_string'
4
5
  require 'eac_ruby_utils/console/docopt_runner'
5
6
  require 'eac_ruby_utils/console/speaker'
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/apache_host'
4
+
5
+ module Avm
6
+ module EacWritingsBase0
7
+ class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
8
+ def document_root
9
+ instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
10
+ end
11
+
12
+ def extra_content
13
+ ''
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/deploy'
4
+ require 'avm/eac_writings_base0/project'
5
+ require 'avm/eac_writings_base0/project_build'
6
+
7
+ module Avm
8
+ module EacWritingsBase0
9
+ class Deploy < ::Avm::EacWebappBase0::Deploy
10
+ def build_content
11
+ ::Avm::EacWritingsBase0::ProjectBuild.new(project, output_file:
12
+ build_dir.join(pdf_path))
13
+ end
14
+
15
+ def title
16
+ instance.id.humanize
17
+ end
18
+
19
+ def pdf_path
20
+ "#{instance.id.underscore}.pdf"
21
+ end
22
+
23
+ def variables_source
24
+ self
25
+ end
26
+
27
+ private
28
+
29
+ def project_uncached
30
+ ::Avm::EacWritingsBase0::Project.new(
31
+ instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/instance'
4
+
5
+ module Avm
6
+ module EacWritingsBase0
7
+ class Instance < ::Avm::EacWebappBase0::Instance
8
+ FILES_UNITS = {}.freeze
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Files
7
+ module Appendable
8
+ require_sub __FILE__
9
+
10
+ attr_reader :variables_source
11
+
12
+ def appended
13
+ @appended ||= []
14
+ end
15
+
16
+ def append_templatized_directories(directories)
17
+ directories.each { |directory| append_templatized_directory(directory) }
18
+ self
19
+ end
20
+
21
+ def append_plain_directory(directory)
22
+ appended << ::Avm::Files::Appendable::PlainDirectory.new(self, directory)
23
+ self
24
+ end
25
+
26
+ def append_tar_output_command(tar_command)
27
+ appended << ::Avm::Files::Appendable::TarOutputCommand.new(self, tar_command)
28
+ self
29
+ end
30
+
31
+ def append_templatized_directory(directory)
32
+ appended << ::Avm::Files::Appendable::TemplatizedDirectory.new(self, directory)
33
+ self
34
+ end
35
+
36
+ def append_file_content(target_path, content)
37
+ appended << ::Avm::Files::Appendable::FileContent
38
+ .new(self, target_path, content)
39
+ self
40
+ end
41
+
42
+ def variables_source_set(source)
43
+ @variables_source = source
44
+ self
45
+ end
46
+
47
+ def write_appended_on(target_dir)
48
+ target_dir = target_dir.to_pathname
49
+ raise "\"#{target_dir}\" is not a directory" unless target_dir.directory?
50
+
51
+ appended.each { |append| append.write_on(target_dir) }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/files/appendable/resource_base'
5
+
6
+ module Avm
7
+ module Files
8
+ module Appendable
9
+ class FileContent < ::Avm::Files::Appendable::ResourceBase
10
+ attr_reader :target_path, :content
11
+
12
+ def initialize(deploy, target_path, content)
13
+ super(deploy)
14
+ @target_path = target_path
15
+ @content = content
16
+ end
17
+
18
+ def write_on(target_dir)
19
+ target_dir.join(target_path).write(content)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/files/appendable/resource_base'
5
+
6
+ module Avm
7
+ module Files
8
+ module Appendable
9
+ class PlainDirectory < ::Avm::Files::Appendable::ResourceBase
10
+ attr_reader :source_path
11
+
12
+ def initialize(appender, source_path)
13
+ super(appender)
14
+ @source_path = source_path.to_pathname
15
+ end
16
+
17
+ def write_on(target_dir)
18
+ raise "\"#{source_path}\" is not a directory" unless source_path.directory?
19
+
20
+ ::FileUtils.cp_r("#{source_path}/.", target_dir.to_path)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Files
7
+ module Appendable
8
+ class ResourceBase
9
+ common_constructor :appender
10
+ end
11
+ end
12
+ end
13
+ end