avm-tools 0.75.0 → 0.78.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/eac_rails_base1/runner/bundle.rb +2 -2
- data/lib/avm/eac_rails_base1/runner/code_runner.rb +3 -3
- data/lib/avm/eac_webapp_base0/deploy/build.rb +1 -1
- data/lib/avm/eac_webapp_base0/runner/deploy.rb +1 -0
- data/lib/avm/files/formatter.rb +8 -4
- data/lib/avm/git/auto_commit_path.rb +2 -4
- data/lib/avm/git/auto_commit_path/ruby.rb +20 -0
- data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +7 -16
- data/lib/avm/tools/runner/files/format.rb +3 -2
- data/lib/avm/tools/runner/git/auto_commit.rb +11 -0
- data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/definition.rb +49 -22
- data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +17 -1
- data/vendor/eac_cli/lib/eac_cli/{parser/options_collection.rb → definition/help_formatter.rb} +20 -49
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +21 -4
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +1 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +21 -3
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +88 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
- data/vendor/eac_cli/lib/eac_cli/runner.rb +6 -2
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +96 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +35 -0
- data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +57 -40
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +57 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +7 -107
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +46 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/current.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/enumerator/stopped.rb +14 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb +26 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/stopped_spec.rb +32 -0
- metadata +31 -6
- data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +0 -14
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -21
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -49
@@ -61,6 +61,8 @@ module EacRubyUtils
|
|
61
61
|
setup_class_attr_readers(klass)
|
62
62
|
setup_class_attr_writers(klass)
|
63
63
|
setup_class_initialize(klass)
|
64
|
+
|
65
|
+
klass
|
64
66
|
end
|
65
67
|
|
66
68
|
def setup_class_attr_readers(klass)
|
@@ -79,9 +81,14 @@ module EacRubyUtils
|
|
79
81
|
klass.define_callbacks :initialize
|
80
82
|
klass.send(:define_method, :initialize) do |*args|
|
81
83
|
Initialize.new(common_constructor, args, self).run
|
84
|
+
super(*SuperArgs.new(common_constructor, args, self).result)
|
82
85
|
end
|
83
86
|
end
|
84
87
|
|
88
|
+
def super_args
|
89
|
+
options[:super_args]
|
90
|
+
end
|
91
|
+
|
85
92
|
class Initialize
|
86
93
|
attr_reader :common_constructor, :args, :object
|
87
94
|
|
@@ -129,5 +136,51 @@ module EacRubyUtils
|
|
129
136
|
" (given #{args.count}, expected #{common_constructor.args_count})"
|
130
137
|
end
|
131
138
|
end
|
139
|
+
|
140
|
+
class SuperArgs
|
141
|
+
attr_reader :common_constructor, :args, :object
|
142
|
+
|
143
|
+
def initialize(common_constructor, args, object)
|
144
|
+
@common_constructor = common_constructor
|
145
|
+
@args = args
|
146
|
+
@object = object
|
147
|
+
end
|
148
|
+
|
149
|
+
def auto_result
|
150
|
+
r = []
|
151
|
+
sub_args.each do |name, value|
|
152
|
+
i = super_arg_index(name)
|
153
|
+
r[i] = value if i
|
154
|
+
end
|
155
|
+
r
|
156
|
+
end
|
157
|
+
|
158
|
+
def result
|
159
|
+
result_from_options || auto_result
|
160
|
+
end
|
161
|
+
|
162
|
+
def result_from_options
|
163
|
+
return unless common_constructor.super_args
|
164
|
+
|
165
|
+
object.instance_exec(&common_constructor.super_args)
|
166
|
+
end
|
167
|
+
|
168
|
+
def sub_args
|
169
|
+
common_constructor.args.each_with_index.map do |name, index|
|
170
|
+
[name, args[index]]
|
171
|
+
end.to_h
|
172
|
+
end
|
173
|
+
|
174
|
+
def super_arg_index(name)
|
175
|
+
super_method.parameters.each_with_index do |arg, index|
|
176
|
+
return index if arg[1] == name
|
177
|
+
end
|
178
|
+
nil
|
179
|
+
end
|
180
|
+
|
181
|
+
def super_method
|
182
|
+
object.class.superclass ? object.class.superclass.instance_method(:initialize) : nil
|
183
|
+
end
|
184
|
+
end
|
132
185
|
end
|
133
186
|
end
|
@@ -1,31 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/common_constructor'
|
4
3
|
require 'eac_ruby_utils/configs'
|
5
|
-
require 'eac_ruby_utils/
|
6
|
-
require 'eac_ruby_utils/options_consumer'
|
7
|
-
require 'eac_ruby_utils/patches/object/asserts'
|
8
|
-
require 'eac_ruby_utils/simple_cache'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
9
5
|
|
10
6
|
module EacRubyUtils
|
11
7
|
module Console
|
12
8
|
class Configs
|
13
|
-
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_console_speaker
|
14
11
|
|
15
12
|
class << self
|
16
13
|
def entry_key_to_envvar_name(entry_key)
|
17
|
-
|
18
|
-
entry_key
|
19
|
-
else
|
20
|
-
::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
|
21
|
-
end
|
22
|
-
path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
|
23
|
-
.gsub(/_{2,}/, '_').upcase
|
14
|
+
::EacRubyUtils::Console::Configs::EntryReader.entry_key_to_envvar_name(entry_key)
|
24
15
|
end
|
25
16
|
end
|
26
17
|
|
27
|
-
STORE_PASSWORDS_KEY = 'core.store_passwords'
|
28
|
-
|
29
18
|
attr_reader :configs
|
30
19
|
|
31
20
|
def initialize(configs_key, options = {})
|
@@ -34,104 +23,15 @@ module EacRubyUtils
|
|
34
23
|
end
|
35
24
|
|
36
25
|
def read_password(entry_key, options = {})
|
37
|
-
|
38
|
-
if store_passwords?
|
39
|
-
read_entry(entry_key, options)
|
40
|
-
else
|
41
|
-
looped_entry_value_from_input(entry_key, options)
|
42
|
-
end
|
26
|
+
::EacRubyUtils::Console::Configs::PasswordEntryReader.new(self, entry_key, options).read
|
43
27
|
end
|
44
28
|
|
45
29
|
def read_entry(entry_key, options = {})
|
46
|
-
|
47
|
-
unless options[:noenv]
|
48
|
-
envvar_value = envvar_read_entry(entry_key)
|
49
|
-
return envvar_value if envvar_value.present?
|
50
|
-
end
|
51
|
-
stored_value = configs.read_entry(entry_key)
|
52
|
-
return stored_value if stored_value
|
53
|
-
return read_entry_from_console(entry_key, options) unless options[:noinput]
|
54
|
-
|
55
|
-
raise "No value found for entry \"#{entry_key}\"" if options[:required]
|
30
|
+
::EacRubyUtils::Console::Configs::EntryReader.new(self, entry_key, options).read
|
56
31
|
end
|
57
32
|
|
58
33
|
def store_passwords?
|
59
|
-
|
60
|
-
STORE_PASSWORDS_KEY,
|
61
|
-
before_input: -> { store_password_banner },
|
62
|
-
validator: ->(entry_value) { %w[yes no].include?(entry_value) }
|
63
|
-
) == 'yes'
|
64
|
-
end
|
65
|
-
|
66
|
-
protected
|
67
|
-
|
68
|
-
def envvar_read_entry(entry_key)
|
69
|
-
env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
|
70
|
-
return nil unless ENV.key?(env_entry_key)
|
71
|
-
|
72
|
-
ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
73
|
-
end
|
74
|
-
|
75
|
-
def read_entry_from_console(entry_key, options)
|
76
|
-
options[:before_input].call if options[:before_input].present?
|
77
|
-
entry_value = looped_entry_value_from_input(entry_key, options)
|
78
|
-
configs.write_entry(entry_key, entry_value)
|
79
|
-
entry_value
|
80
|
-
end
|
81
|
-
|
82
|
-
def store_password_banner
|
83
|
-
infom 'Do you wanna to store passwords?'
|
84
|
-
infom "Warning: the passwords will be store in clear text in \"#{configs.storage_path}\""
|
85
|
-
infom 'Enter "yes" or "no"'
|
86
|
-
end
|
87
|
-
|
88
|
-
def looped_entry_value_from_input(entry_key, options)
|
89
|
-
loop do
|
90
|
-
entry_value = entry_value_from_input(entry_key, options)
|
91
|
-
next if entry_value.blank?
|
92
|
-
next if options[:validator] && !options[:validator].call(entry_value)
|
93
|
-
|
94
|
-
return entry_value
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def entry_value_from_input(entry_key, options)
|
99
|
-
entry_value = request_input("Value for entry \"#{entry_key}\"",
|
100
|
-
options.request_input_options)
|
101
|
-
warn('Entered value is blank') if entry_value.blank?
|
102
|
-
entry_value
|
103
|
-
end
|
104
|
-
|
105
|
-
class ReadEntryOptions
|
106
|
-
include ::EacRubyUtils::SimpleCache
|
107
|
-
::EacRubyUtils::CommonConstructor.new(:options).setup_class(self)
|
108
|
-
|
109
|
-
DEFAULT_VALUES = {
|
110
|
-
before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
|
111
|
-
required: true, validator: nil
|
112
|
-
}.freeze
|
113
|
-
|
114
|
-
def [](key)
|
115
|
-
values.fetch(key.to_sym)
|
116
|
-
end
|
117
|
-
|
118
|
-
def request_input_options
|
119
|
-
values.slice(:bool, :list, :noecho)
|
120
|
-
end
|
121
|
-
|
122
|
-
private
|
123
|
-
|
124
|
-
def values_uncached
|
125
|
-
consumer = ::EacRubyUtils::OptionsConsumer.new(options)
|
126
|
-
r = {}
|
127
|
-
DEFAULT_VALUES.each do |key, default_value|
|
128
|
-
value = consumer.consume(key)
|
129
|
-
value = default_value if value.nil?
|
130
|
-
r[key] = value
|
131
|
-
end
|
132
|
-
consumer.validate
|
133
|
-
r
|
134
|
-
end
|
34
|
+
::EacRubyUtils::Console::Configs::StorePasswordsEntryReader.new(self) == 'yes'
|
135
35
|
end
|
136
36
|
end
|
137
37
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/read_entry_options'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Console
|
8
|
+
class Configs
|
9
|
+
class EntryReader
|
10
|
+
enable_console_speaker
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def entry_key_to_envvar_name(entry_key)
|
14
|
+
path = if entry_key.is_a?(::Array)
|
15
|
+
entry_key
|
16
|
+
else
|
17
|
+
::EacRubyUtils::PathsHash.parse_entry_key(entry_key)
|
18
|
+
end
|
19
|
+
path.join('_').gsub(/[^a-z0-9_]/i, '').gsub(/\A_+/, '').gsub(/_+\z/, '')
|
20
|
+
.gsub(/_{2,}/, '_').upcase
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
common_constructor :console_configs, :entry_key, :options do
|
25
|
+
self.options = ::EacRubyUtils::Console::Configs::ReadEntryOptions.new(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def read
|
29
|
+
%w[envvars storage console].each do |suffix|
|
30
|
+
value = send("read_from_#{suffix}")
|
31
|
+
return value if value.present?
|
32
|
+
end
|
33
|
+
return nil unless options[:required]
|
34
|
+
|
35
|
+
raise "No value found for entry \"#{entry_key}\""
|
36
|
+
end
|
37
|
+
|
38
|
+
def read_from_storage
|
39
|
+
console_configs.configs.read_entry(entry_key)
|
40
|
+
end
|
41
|
+
|
42
|
+
def read_from_envvars
|
43
|
+
return if options[:noenv]
|
44
|
+
|
45
|
+
env_entry_key = self.class.entry_key_to_envvar_name(entry_key)
|
46
|
+
return unless ENV.key?(env_entry_key)
|
47
|
+
|
48
|
+
ENV.fetch(env_entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
49
|
+
end
|
50
|
+
|
51
|
+
def read_from_console
|
52
|
+
return if options[:noinput]
|
53
|
+
|
54
|
+
options[:before_input].if_present(&:call)
|
55
|
+
entry_value = looped_entry_value_from_input
|
56
|
+
console_configs.configs.write_entry(entry_key, entry_value) if options[:store]
|
57
|
+
entry_value
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def looped_entry_value_from_input
|
63
|
+
loop do
|
64
|
+
entry_value = entry_value_from_input(entry_key, options)
|
65
|
+
next if entry_value.blank?
|
66
|
+
next if options[:validator] && !options[:validator].call(entry_value)
|
67
|
+
|
68
|
+
return entry_value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def entry_value_from_input(entry_key, options)
|
73
|
+
entry_value = request_input("Value for entry \"#{entry_key}\"",
|
74
|
+
options.request_input_options)
|
75
|
+
warn('Entered value is blank') if entry_value.blank?
|
76
|
+
entry_value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/entry_reader'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class PasswordEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
|
9
|
+
ENTRY_KEY = 'core.store_passwords'
|
10
|
+
|
11
|
+
def initialize(console_configs, entry_key, options = {})
|
12
|
+
super(console_configs, entry_key, options.merge(noecho: true,
|
13
|
+
store: console_configs.store_passwords?))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class ReadEntryOptions
|
9
|
+
enable_simple_cache
|
10
|
+
common_constructor :options do
|
11
|
+
self.options = options.to_h.symbolize_keys
|
12
|
+
.assert_valid_keys(DEFAULT_VALUES.keys).freeze
|
13
|
+
end
|
14
|
+
|
15
|
+
DEFAULT_VALUES = {
|
16
|
+
before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
|
17
|
+
required: true, store: true, validator: nil
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
delegate :to_h, to: :options
|
21
|
+
|
22
|
+
def [](key)
|
23
|
+
values.fetch(key.to_sym)
|
24
|
+
end
|
25
|
+
|
26
|
+
def request_input_options
|
27
|
+
values.slice(:bool, :list, :noecho)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def values_uncached
|
33
|
+
consumer = options.to_options_consumer
|
34
|
+
r = {}
|
35
|
+
DEFAULT_VALUES.each do |key, default_value|
|
36
|
+
value = consumer.consume(key)
|
37
|
+
value = default_value if value.nil?
|
38
|
+
r[key] = value
|
39
|
+
end
|
40
|
+
consumer.validate
|
41
|
+
r
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/configs/entry_reader'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Console
|
7
|
+
class Configs
|
8
|
+
class StorePasswordsEntryReader < ::EacRubyUtils::Console::Configs::EntryReader
|
9
|
+
ENTRY_KEY = 'core.store_passwords'
|
10
|
+
|
11
|
+
def initialize(console_configs)
|
12
|
+
super(console_configs, ENTRY_KEY,
|
13
|
+
before_input: -> { banner },
|
14
|
+
validator: ->(entry_value) { %w[yes no].include?(entry_value) }
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def banner
|
19
|
+
infom 'Do you wanna to store passwords?'
|
20
|
+
infom 'Warning: the passwords will be store in clear text in ' \
|
21
|
+
"\"#{console_configs.configs.storage_path}\""
|
22
|
+
infom 'Enter "yes" or "no"'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|