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
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/envs'
5
+ require 'avm/files/appendable/resource_base'
6
+
7
+ module Avm
8
+ module Files
9
+ module Appendable
10
+ class TarOutputCommand < ::Avm::Files::Appendable::ResourceBase
11
+ attr_reader :command
12
+
13
+ def initialize(appender, command)
14
+ super(appender)
15
+ @command = command
16
+ end
17
+
18
+ def write_on(target_dir)
19
+ command.pipe(
20
+ ::EacRubyUtils::Envs.local.command('tar', '-xf', '-', '-C', target_dir)
21
+ ).execute!
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
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 TemplatizedDirectory < ::Avm::Files::Appendable::ResourceBase
10
+ attr_reader :source_path
11
+
12
+ def initialize(appender, source_path)
13
+ super(appender)
14
+ @source_path = source_path
15
+ end
16
+
17
+ def write_on(target_dir)
18
+ raise 'Variables source not set' if appender.variables_source.blank?
19
+
20
+ ::EacRubyUtils::Templates::Directory.new(source_path).apply(
21
+ appender.variables_source,
22
+ target_dir
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/files/appendable'
4
+
5
+ module Avm
6
+ module Files
7
+ class Appender
8
+ include ::Avm::Files::Appendable
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+ require 'avm/files/appendable'
5
+ require 'avm/patches/object/template'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module Files
10
+ class Deploy
11
+ include ::Avm::Files::Appendable
12
+ enable_simple_cache
13
+
14
+ attr_reader :build_dir, :target_env, :target_path
15
+
16
+ common_constructor :target_env, :target_path
17
+
18
+ def run
19
+ on_build_dir do
20
+ copy_content_to_build_dir
21
+ mkdir_target
22
+ clear_content
23
+ send_untar_package
24
+ set_target_permission
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def on_build_dir
31
+ @build_dir = ::Dir.mktmpdir
32
+ yield
33
+ ensure
34
+ ::FileUtils.rm_rf(@build_dir)
35
+ end
36
+
37
+ def copy_content_to_build_dir
38
+ write_appended_on(build_dir)
39
+ end
40
+
41
+ def mkdir_target
42
+ target_env.command('mkdir', '-p', target_path).execute!
43
+ end
44
+
45
+ def clear_content
46
+ target_env.command(
47
+ 'find', target_path, '-mindepth', '1', '-maxdepth', '1', '-exec', 'rm', '-rf', '{}', ';'
48
+ ).execute!
49
+ end
50
+
51
+ def send_untar_package
52
+ tar_build_command.pipe(untar_build_command).execute!
53
+ end
54
+
55
+ def set_target_permission
56
+ target_env.command('chmod', '755', target_path).execute!
57
+ end
58
+
59
+ def tar_build_command
60
+ source_env.command('tar', '-czO', '-C', build_dir, '.')
61
+ end
62
+
63
+ def untar_build_command
64
+ target_env.command('tar', '-xzf', '-', '-C', target_path)
65
+ end
66
+
67
+ def source_env
68
+ ::EacRubyUtils::Envs.local
69
+ end
70
+ end
71
+ end
72
+ end
@@ -10,7 +10,11 @@ module Avm
10
10
  require_sub __FILE__
11
11
  enable_simple_cache
12
12
  enable_console_speaker
13
- common_constructor :source_paths, :options
13
+ enable_listable
14
+ lists.add_symbol :option, :apply, :recursive, :verbose
15
+ common_constructor :source_paths, :options, default: [{}] do
16
+ options.assert_valid_keys(self.class.lists.option.values)
17
+ end
14
18
 
15
19
  FORMATS = %w[ruby php html python xml json generic_plain].freeze
16
20
 
@@ -27,7 +31,7 @@ module Avm
27
31
  infom "Applying #{@formats_files.count} format(s)... "
28
32
  @formats_files.each do |format, files|
29
33
  infom "Applying format #{format.name} (Files matched: #{files.count})..."
30
- next unless options.fetch(:apply)
34
+ next unless options[OPTION_APPLY]
31
35
 
32
36
  @result += format.apply(files)
33
37
  end
@@ -35,7 +39,7 @@ module Avm
35
39
 
36
40
  def traverser_check_file(file)
37
41
  format = find_format(file)
38
- infov file, format ? format.class : '-' if options.fetch(:verbose)
42
+ infov file, format ? format.class : '-' if options[OPTION_VERBOSE]
39
43
  return unless format
40
44
 
41
45
  @formats_files[format] ||= []
@@ -79,7 +83,7 @@ module Avm
79
83
  end
80
84
 
81
85
  def traverser_recursive
82
- options.fetch(:recursive)
86
+ options[OPTION_RECURSIVE]
83
87
  end
84
88
  end
85
89
  end
@@ -5,6 +5,7 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Git
7
7
  class AutoCommitPath
8
+ require_sub __FILE__, include_modules: true
8
9
  enable_console_speaker
9
10
  common_constructor :git, :path do
10
11
  self.path = path.to_pathname
@@ -31,10 +32,7 @@ module Avm
31
32
  end
32
33
 
33
34
  def class_name
34
- CLASS_NAME_PATTERNS.each do |pattern|
35
- pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
36
- end
37
- raise "No pattern matched \"#{relative_path}\""
35
+ ruby_class_name || relative_path.to_path
38
36
  end
39
37
 
40
38
  def commit_message
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ class AutoCommitPath
8
+ module Ruby
9
+ RUBY_CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
10
+
11
+ def ruby_class_name
12
+ RUBY_CLASS_NAME_PATTERNS.each do |pattern|
13
+ pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
14
+ end
15
+ nil
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,90 +2,37 @@
2
2
 
3
3
  require 'addressable'
4
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'avm/files/appendable'
6
+ require 'avm/files/deploy'
5
7
  require 'avm/patches/object/template'
6
8
 
7
9
  module Avm
8
10
  module Git
9
11
  class Commit
10
12
  class Deploy
11
- require_sub __FILE__, include_modules: true
13
+ include ::Avm::Files::Appendable
12
14
  enable_simple_cache
13
15
 
14
- attr_reader :build_dir, :commit, :target_env, :target_path, :variables_source
16
+ attr_reader :build_dir, :commit, :target_env, :target_path
15
17
 
16
18
  def initialize(commit, target_env, target_path)
17
19
  @commit = commit
18
20
  @target_env = target_env
19
21
  @target_path = target_path
20
- @variables_source = nil
21
- end
22
-
23
- def variables_source_set(source)
24
- @variables_source = source
25
- self
26
22
  end
27
23
 
28
24
  def run
29
- on_build_dir do
30
- copy_git_content
31
- copy_appended_content
32
- mkdir_target
33
- clear_content
34
- send_untar_package
35
- set_target_permission
36
- end
25
+ fd = ::Avm::Files::Deploy.new(target_env, target_path)
26
+ fd.append_tar_output_command(git_archive_command)
27
+ fd.appended.push(*appended)
28
+ fd.run
37
29
  end
38
30
 
39
31
  private
40
32
 
41
- def on_build_dir
42
- @build_dir = ::Dir.mktmpdir
43
- yield
44
- ensure
45
- ::FileUtils.rm_rf(@build_dir)
46
- end
47
-
48
- def copy_git_content
49
- git_archive_command.pipe(untar_git_archive_command).execute!
50
- end
51
-
52
- def mkdir_target
53
- target_env.command('mkdir', '-p', target_path).execute!
54
- end
55
-
56
- def clear_content
57
- target_env.command(
58
- 'find', target_path, '-mindepth', '1', '-maxdepth', '1', '-exec', 'rm', '-rf', '{}', ';'
59
- ).execute!
60
- end
61
-
62
- def send_untar_package
63
- tar_build_command.pipe(untar_build_command).execute!
64
- end
65
-
66
- def set_target_permission
67
- target_env.command('chmod', '755', target_path).execute!
68
- end
69
-
70
33
  def git_archive_command
71
34
  commit.git.command('archive', '--format=tar', commit.sha1)
72
35
  end
73
-
74
- def untar_git_archive_command
75
- source_env.command('tar', '-xf', '-', '-C', build_dir)
76
- end
77
-
78
- def tar_build_command
79
- source_env.command('tar', '-czO', '-C', build_dir, '.')
80
- end
81
-
82
- def untar_build_command
83
- target_env.command('tar', '-xzf', '-', '-C', target_path)
84
- end
85
-
86
- def source_env
87
- ::EacRubyUtils::Envs.local
88
- end
89
36
  end
90
37
  end
91
38
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/eac_rails_base1/runner_with/bundle'
3
4
  require 'avm/instances/entry_keys'
4
5
  require 'eac_cli/core_ext'
5
6
  require 'eac_ruby_utils/console/docopt_runner'
@@ -1,23 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/core_ext'
3
4
  require 'avm/eac_rails_base1/runner/code_runner'
4
- require 'eac_cli/default_runner'
5
5
 
6
6
  module Avm
7
7
  module Tools
8
8
  class Runner < ::EacRubyUtils::Console::DocoptRunner
9
9
  class EacRedmineBase0 < ::Avm::EacRailsBase1::Runner
10
- class ProjectRename < ::Avm::EacRailsBase1::Runner::CodeRunner
11
- include ::EacCli::DefaultRunner
12
-
13
- runner_definition do
10
+ class ProjectRename
11
+ runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle do
14
12
  pos_arg :from
15
13
  pos_arg :to
16
14
  end
17
15
 
18
16
  def run
19
- start_banner
20
- command.system!
17
+ bundle_run
21
18
  end
22
19
 
23
20
  def start_banner
@@ -25,16 +22,10 @@ module Avm
25
22
  infov 'To', to
26
23
  end
27
24
 
28
- def from
29
- options.fetch('<from>')
30
- end
31
-
32
- def to
33
- options.fetch('<to>')
34
- end
25
+ delegate :from, :to, to: :parsed
35
26
 
36
- def command
37
- context(:instance).bundle('exec', 'rails', 'runner', code)
27
+ def bundle_args
28
+ %w[exec rails runner] + [code]
38
29
  end
39
30
 
40
31
  def code
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/runner'
4
+ require 'avm/eac_writings_base0'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class EacWritingsBase0 < ::Avm::EacWebappBase0::Runner
11
+ require_sub __FILE__
12
+ end
13
+ end
14
+ end
15
+ end
@@ -32,8 +32,9 @@ module Avm
32
32
  end
33
33
 
34
34
  def formatter_options
35
- { apply: options.fetch('--apply'), recursive: !options.fetch('--no-recursive'),
36
- verbose: options.fetch('--verbose') }
35
+ { ::Avm::Files::Formatter::OPTION_APPLY => options.fetch('--apply'),
36
+ ::Avm::Files::Formatter::OPTION_RECURSIVE => !options.fetch('--no-recursive'),
37
+ ::Avm::Files::Formatter::OPTION_VERBOSE => options.fetch('--verbose') }
37
38
  end
38
39
 
39
40
  def git
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/git/auto_commit_path'
4
+ require 'avm/files/formatter'
4
5
  require 'eac_cli/default_runner'
5
6
 
6
7
  module Avm
@@ -13,12 +14,14 @@ module Avm
13
14
  runner_definition do
14
15
  desc 'Commit with message based in content commited.'
15
16
  bool_opt '-d', '--dirty', 'Select dirty files.'
17
+ bool_opt '-f', '--format', 'Format files before commit.'
16
18
  pos_arg 'paths', repeat: true, optional: true
17
19
  end
18
20
 
19
21
  def run
20
22
  clear_stage
21
23
  banner
24
+ format_files
22
25
  run_paths
23
26
  end
24
27
 
@@ -39,6 +42,14 @@ module Avm
39
42
  context(:git).dirty_files.map { |d| context(:git).root_path.join / d.path }
40
43
  end
41
44
 
45
+ def format_files
46
+ return unless options.fetch('--format')
47
+
48
+ infom 'Formating files...'
49
+ ::Avm::Files::Formatter.new(paths.map(&:path),
50
+ ::Avm::Files::Formatter::OPTION_APPLY => true).run
51
+ end
52
+
42
53
  def paths_uncached
43
54
  (options.fetch('<paths>')
44
55
  .map { |p| p.to_pathname.expand_path } + dirty_paths)
@@ -88,7 +88,7 @@ module Avm
88
88
  def deploy
89
89
  ::Avm::Git::Commit.new(git, reference_sha1)
90
90
  .deploy_to_url(target_url)
91
- .append_directories(appended_directories)
91
+ .append_templatized_directories(appended_directories)
92
92
  .variables_source_set(variables_source)
93
93
  .run
94
94
  end