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,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module EacCli
7
+ module Docopt
8
+ class DocBuilder
9
+ class Alternative
10
+ common_constructor :alternative
11
+
12
+ def to_s
13
+ (
14
+ [::EacRubyUtils::Console::DocoptRunner::PROGRAM_MACRO] +
15
+ alternative.options_argument?.if_present([]) { |_v| ['[options]'] } +
16
+ options +
17
+ positionals
18
+ ).join(::EacCli::Docopt::DocBuilder::SEP)
19
+ end
20
+
21
+ def options
22
+ alternative.options.select(&:show_on_usage?).map do |option|
23
+ ::EacCli::Docopt::DocBuilder.option_long(option)
24
+ end
25
+ end
26
+
27
+ def option_argument(option)
28
+ b = option.long
29
+ b += '=<value>' if option.argument?
30
+ b
31
+ end
32
+
33
+ def positionals
34
+ alternative.positional.map { |p| positional(p) }
35
+ end
36
+
37
+ def positional(positional)
38
+ if positional.subcommand?
39
+ ::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
40
+ else
41
+ r = "<#{positional.name}>"
42
+ r += '...' if positional.repeat?
43
+ r = "[#{r}]" if positional.optional?
44
+ r
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/docopt/doc_builder'
4
+ require 'eac_cli/runner'
4
5
  require 'eac_ruby_utils/console/docopt_runner'
5
6
 
6
7
  module EacCli
@@ -5,10 +5,28 @@ require 'eac_ruby_utils/core_ext'
5
5
  module EacCli
6
6
  class Parser
7
7
  require_sub __FILE__
8
- common_constructor :definition
8
+ enable_simple_cache
9
+ common_constructor :definition, :argv
9
10
 
10
- def parse(argv)
11
- ::EacCli::Parser::ParseResult.new(definition, argv).result
11
+ private
12
+
13
+ def parsed_uncached
14
+ raise 'Definition has no alternatives' if alternatives.empty?
15
+
16
+ alternatives.each do |alt_parser|
17
+ return alt_parser.parsed unless alt_parser.error?
18
+ end
19
+
20
+ raise first_error
21
+ end
22
+
23
+ def alternatives_uncached
24
+ definition.alternatives
25
+ .map { |alternative| ::EacCli::Parser::Alternative.new(alternative, argv) }
26
+ end
27
+
28
+ def first_error_uncached
29
+ alternatives.lazy.select(&:error?).map(&:error).first
12
30
  end
13
31
  end
14
32
  end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/parser/collector'
4
+ require 'eac_cli/parser/error'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacCli
8
+ class Parser
9
+ class Alternative
10
+ require_sub __FILE__, include_modules: true
11
+ enable_listable
12
+ lists.add_symbol :phase, :any, :option_argument, :positional
13
+ attr_reader :error
14
+
15
+ common_constructor :alternative, :argv do
16
+ alternative.assert_argument(::EacCli::Definition::Alternative, :alternative)
17
+ self.phase = PHASE_ANY
18
+ collect
19
+ end
20
+
21
+ def error?
22
+ error.present?
23
+ end
24
+
25
+ def parsed
26
+ @parsed ||= collector.to_data.freeze
27
+ end
28
+
29
+ private
30
+
31
+ attr_accessor :phase
32
+
33
+ def any_collect_argv_value
34
+ if argv_current_option?
35
+ option_collect_argv_value
36
+ else
37
+ positional_collect_argv_value
38
+ end
39
+ end
40
+
41
+ def collector
42
+ @collector ||= ::EacCli::Parser::Collector.new(alternative)
43
+ end
44
+
45
+ def collect
46
+ loop do
47
+ break unless argv_pending?
48
+
49
+ collect_argv_value
50
+ end
51
+ validate
52
+ rescue ::EacCli::Parser::Error => e
53
+ @error = e
54
+ end
55
+
56
+ def collect_argv_value
57
+ send("#{phase}_collect_argv_value")
58
+ argv_enum.next
59
+ end
60
+
61
+ def collect_option_argv_value
62
+ alternative.options.each do |option|
63
+ end
64
+
65
+ raise ::EacCli::Parser::Error.new(
66
+ alternative, argv, "Invalid option: #{argv_enum.current}"
67
+ )
68
+ end
69
+
70
+ def raise_error(message)
71
+ raise ::EacCli::Parser::Error.new(alternative, argv, message)
72
+ end
73
+
74
+ def validate
75
+ (alternative.options + alternative.positional).each do |option|
76
+ validate_option(option)
77
+ end
78
+ end
79
+
80
+ def validate_option(option)
81
+ return unless option.required?
82
+ return if collector.supplied?(option)
83
+
84
+ raise_error("Required option/positional #{option} not supplied")
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module Argv
7
+ def argv_enum
8
+ @argv_enum ||= argv.each
9
+ end
10
+
11
+ def argv_pending?
12
+ argv_enum.ongoing?
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module DoubleDash
7
+ DOUBLE_DASH = '--'
8
+
9
+ private
10
+
11
+ attr_accessor :double_dash
12
+
13
+ def argv_current_double_dash?
14
+ argv_enum.peek == DOUBLE_DASH && !double_dash
15
+ end
16
+
17
+ def double_dash_collect_argv_value
18
+ self.phase = PHASE_POSITIONAL
19
+ self.double_dash = true
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module Options
7
+ DOUBLE_DASH = '--'
8
+
9
+ private
10
+
11
+ attr_accessor :argument_option, :double_dash
12
+
13
+ def argument_option_collect_argv(option)
14
+ self.argument_option = option
15
+ self.phase = PHASE_OPTION_ARGUMENT
16
+ end
17
+
18
+ def argv_current_option?
19
+ phase == PHASE_ANY && argv_enum.peek.start_with?('-')
20
+ end
21
+
22
+ def argv_current_double_dash?
23
+ argv_enum.peek == DOUBLE_DASH && !double_dash
24
+ end
25
+
26
+ def boolean_option_collect_argv(option)
27
+ collector.collect(option, true)
28
+ end
29
+
30
+ def option_argument_collect_argv_value
31
+ collector.collect(argument_option, argv_enum.peek)
32
+ self.argument_option = nil
33
+ self.phase = PHASE_ANY
34
+ end
35
+
36
+ def option_collect_argv_value
37
+ return double_dash_collect_argv_value if argv_current_double_dash?
38
+
39
+ alternative.options.any? do |option|
40
+ next false unless [option.short, option.long].include?(argv_enum.peek)
41
+
42
+ if option.argument?
43
+ argument_option_collect_argv(option)
44
+ else
45
+ boolean_option_collect_argv(option)
46
+ end
47
+
48
+ true
49
+ end || raise_argv_current_invalid_option
50
+ end
51
+
52
+ def raise_argv_current_invalid_option
53
+ raise_error "Invalid option: \"#{argv_enum.peek}\""
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ class Parser
5
+ class Alternative
6
+ module Positionals
7
+ private
8
+
9
+ def positional_collect_argv_value
10
+ positional_check
11
+ collector.collect(positional_enum.peek, argv_enum.peek)
12
+ positional_next
13
+ end
14
+
15
+ def positional_enum
16
+ @positional_enum ||= alternative.positional.each
17
+ end
18
+
19
+ def positional_check
20
+ raise_error("Invalid positional: #{argv_enum.peek}") if positional_enum.stopped?
21
+ end
22
+
23
+ def positional_next
24
+ self.phase = PHASE_POSITIONAL if positional_enum.peek.subcommand?
25
+ positional_enum.next unless positional_enum.peek.repeat?
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -31,6 +31,10 @@ module EacCli
31
31
  end
32
32
  end
33
33
 
34
+ def supplied?(option)
35
+ data[option].present?
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def data
@@ -5,13 +5,14 @@ require 'eac_cli/runner'
5
5
  require 'eac_cli/runner_with'
6
6
 
7
7
  class Object
8
- def runner_with(*runners)
8
+ def runner_with(*runners, &block)
9
9
  include ::EacCli::Runner
10
10
  enable_simple_cache
11
11
  enable_console_speaker
12
12
  runners.each do |runner|
13
13
  include runner_with_to_module(runner)
14
14
  end
15
+ runner_definition(&block) if block
15
16
  end
16
17
 
17
18
  private
@@ -18,13 +18,17 @@ module EacCli
18
18
  end
19
19
  end
20
20
 
21
+ def runner?(object)
22
+ object.is_a?(::Class) && object.included_modules.include?(::EacCli::Runner)
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def alias_class_method(klass, from, to)
24
28
  sklass = klass.singleton_class
25
29
  return unless sklass.method_defined?(from)
26
30
 
27
- sklass.alias_method to, from
31
+ sklass.send(:alias_method, to, from)
28
32
  end
29
33
 
30
34
  def build_method_name(name, suffix)
@@ -80,7 +84,7 @@ module EacCli
80
84
  end
81
85
 
82
86
  def parsed
83
- @parsed ||= ::EacCli::Parser.new(self.class.runner_definition).parse(runner_context.argv)
87
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
84
88
  end
85
89
  end
86
90
  end
@@ -10,7 +10,7 @@ module EacCli
10
10
  include ::EacCli::Runner
11
11
 
12
12
  runner_definition.alt do
13
- options_arg false
13
+ options_argument false
14
14
  bool_opt '-h', '--help', 'Show help.', usage: true
15
15
  end
16
16
  end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module Subcommands
9
+ common_concern do
10
+ include ::EacCli::Runner
11
+ end
12
+
13
+ EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME = :extra_available_subcommands
14
+
15
+ def available_subcommands
16
+ @available_subcommands ||= available_subcommands_auto.merge(available_subcommands_extra)
17
+ end
18
+
19
+ def available_subcommands_auto
20
+ self.class.constants
21
+ .map { |name| [name.to_s.underscore.gsub('_', '-'), self.class.const_get(name)] }
22
+ .select { |c| ::EacCli::Runner.runner?(c[1]) }
23
+ .to_h.with_indifferent_access
24
+ end
25
+
26
+ def available_subcommands_extra
27
+ if respond_to?(EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME, true)
28
+ send(EXTRA_AVAILABLE_SUBCOMMANDS_METHOD_NAME)
29
+ else
30
+ {}
31
+ end
32
+ end
33
+
34
+ def method_missing(method_name, *arguments, &block)
35
+ return run_with_subcommand(*arguments, &block) if
36
+ run_with_subcommand_alias_run?(method_name)
37
+
38
+ super
39
+ end
40
+
41
+ def respond_to_missing?(method_name, include_private = false)
42
+ run_with_subcommand_alias_run?(method_name) || super
43
+ end
44
+
45
+ def run_with_subcommand
46
+ if subcommand_name
47
+ subcommand_runner.run
48
+ else
49
+ run_without_subcommand
50
+ end
51
+ end
52
+
53
+ def run_with_subcommand_alias_run?(method_name)
54
+ subcommands? && method_name.to_sym == :run
55
+ end
56
+
57
+ def run_without_subcommand
58
+ "Method #{__method__} should be overrided in #{self.class.name}"
59
+ end
60
+
61
+ def subcommands?
62
+ self.class.runner_definition.subcommands?
63
+ end
64
+
65
+ def subcommand_args
66
+ parsed.fetch(::EacCli::Definition::SUBCOMMAND_ARGS_ARG)
67
+ end
68
+
69
+ def subcommand_class
70
+ available_subcommands[subcommand_name].if_present { |v| return v }
71
+
72
+ raise(::EacCli::Parser::Error.new(
73
+ self.class.runner_definition, runner_context.argv,
74
+ "Subcommand \"#{subcommand_name}\" not found " \
75
+ "(Available: #{available_subcommands.keys}"
76
+ ))
77
+ end
78
+
79
+ def subcommand_name
80
+ parsed.fetch(::EacCli::Definition::SUBCOMMAND_NAME_ARG)
81
+ end
82
+
83
+ def subcommand_program
84
+ subcommand_name
85
+ end
86
+
87
+ def subcommand_runner
88
+ @subcommand_runner ||= subcommand_class.create(
89
+ argv: subcommand_args,
90
+ program_name: subcommand_program,
91
+ parent: self
92
+ )
93
+ end
94
+ end
95
+ end
96
+ end