avm-tools 0.77.0 → 0.82.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/data/unit.rb +8 -3
- data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
- data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
- data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
- data/lib/avm/patches/class/i18n.rb +31 -0
- data/lib/avm/patches/object/i18n.rb +2 -10
- data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
- data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
- data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
- data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
- data/lib/avm/tools/version.rb +1 -1
- data/vendor/eac_cli/eac_cli.gemspec +1 -1
- data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
- data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +15 -0
- 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 +1 -1
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -3
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
- 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 +0 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +5 -4
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
- 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/struct.rb +7 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
- 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/struct_spec.rb +12 -1
- metadata +14 -4
- data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
- data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 168c054cba584a1c2d268e08f1c89d38768fab0c72696b69480db37b0392b605
|
4
|
+
data.tar.gz: 43eea0c69bbdf91f0cc7e30a9cf631461ae3023028c6b8191b5631ea5f5c562b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95bc36c2b16d6b625d4400a98e89a05f53a478cc2e78378e917de85ef0ba0833216c48104f7ad5aab779ecc462bbd972444580cf4a244b1c700949dcbfd460c6
|
7
|
+
data.tar.gz: 884b8fa7d13e6d590b61c71fa512986ba37d22630c55ea7bad36fecb475f9a5a2c2249535e9b28b3366215f32ae117a57ebb30b13a92d2e0526c2b620d90671e
|
data/lib/avm/data/unit.rb
CHANGED
@@ -12,11 +12,12 @@ module Avm
|
|
12
12
|
enable_console_speaker
|
13
13
|
|
14
14
|
%w[dump load].each do |action|
|
15
|
+
method_name = "#{action}_command"
|
15
16
|
class_eval <<~CODE, __FILE__, __LINE__ + 1
|
16
17
|
# Should be overrided.
|
17
18
|
# @return [EacRubyUtils::Envs::Command]
|
18
|
-
def #{
|
19
|
-
fail "
|
19
|
+
def #{method_name}
|
20
|
+
fail "\\"#{method_name}\\" is a abstract method. Override in #{singleton_class}."
|
20
21
|
end
|
21
22
|
CODE
|
22
23
|
|
@@ -69,7 +70,7 @@ module Avm
|
|
69
70
|
def load(data_path)
|
70
71
|
run_callbacks :load do
|
71
72
|
infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
|
72
|
-
|
73
|
+
do_load(data_path)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -79,6 +80,10 @@ module Avm
|
|
79
80
|
dump_command.execute!(output_file: data_path)
|
80
81
|
end
|
81
82
|
|
83
|
+
def do_load(data_path)
|
84
|
+
load_command.execute!(input_file: data_path)
|
85
|
+
end
|
86
|
+
|
82
87
|
private
|
83
88
|
|
84
89
|
def unit_on_directory_path(directory, identifier)
|
@@ -8,8 +8,7 @@ module Avm
|
|
8
8
|
module EacRailsBase1
|
9
9
|
class Runner < ::Avm::EacWebappBase0::Runner
|
10
10
|
class CodeRunner
|
11
|
-
runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle
|
12
|
-
runner_definition do
|
11
|
+
runner_with :help, ::Avm::EacRailsBase1::RunnerWith::Bundle do
|
13
12
|
desc 'Runs a Ruby code with "rails runner".'
|
14
13
|
pos_arg :code
|
15
14
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/eac_rails_base1/runner_with/bundle'
|
4
|
+
require 'avm/instances/entry_keys'
|
5
|
+
require 'eac_cli/core_ext'
|
6
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
7
|
+
require 'shellwords'
|
8
|
+
|
9
|
+
module Avm
|
10
|
+
module EacRailsBase1
|
11
|
+
class Runner < ::Avm::EacWebappBase0::Runner
|
12
|
+
class RailsServer
|
13
|
+
DEFAULT_RAILS_ENVIRONMENT = 'development'
|
14
|
+
runner_with :help, ::Avm::EacRailsBase1::RunnerWith::Bundle do
|
15
|
+
desc 'Run the embbeded Rails web server.'
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
infov 'Environment', rails_environment
|
20
|
+
infov 'Bundle args', ::Shellwords.join(bundle_args)
|
21
|
+
infov 'Result', bundle_command.system
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def bundle_args
|
27
|
+
['exec', 'rails', 'server', '--port',
|
28
|
+
runner_context.call(:instance).read_entry(::Avm::Instances::EntryKeys::WEB_PORT)]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'avm/data/instance/unit'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'curb'
|
5
6
|
require 'open-uri'
|
6
7
|
|
7
8
|
module Avm
|
@@ -17,8 +18,35 @@ module Avm
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
def do_load(data_path)
|
22
|
+
do_load_by_web(data_path) || do_load_by_rake(data_path) || raise('Failed to load')
|
23
|
+
end
|
24
|
+
|
25
|
+
def do_load_by_web(data_path)
|
26
|
+
c = Curl::Easy.new(import_url)
|
27
|
+
c.multipart_form_post = true
|
28
|
+
c.http_post(Curl::PostField.file('redmine_with_git_tableless_load[path]', data_path))
|
29
|
+
c.perform
|
30
|
+
true
|
31
|
+
rescue Curl::Err::ConnectionFailedError
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
def do_load_by_rake(data_path)
|
36
|
+
instance.bundle('exec', 'rake', "redmine_with_git:load:all[#{data_path}]").system
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
20
40
|
def export_url
|
21
|
-
|
41
|
+
url('/backup/export')
|
42
|
+
end
|
43
|
+
|
44
|
+
def import_url
|
45
|
+
url('/backup/import.json')
|
46
|
+
end
|
47
|
+
|
48
|
+
def url(path)
|
49
|
+
uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + path
|
22
50
|
uri.query_values = { key: instance.read_entry('admin.api_key') }
|
23
51
|
uri.to_s
|
24
52
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/patches/i18n'
|
4
|
+
|
5
|
+
class Class
|
6
|
+
TRANSLATE_LOCALE_KEY = :__locale
|
7
|
+
|
8
|
+
def translate(entry_suffix, values = {})
|
9
|
+
on_i18n_locale(values.delete(TRANSLATE_LOCALE_KEY)) do
|
10
|
+
::I18n.translate(translate_entry_full(entry_suffix), values)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def translate_entry_full(entry_suffix)
|
15
|
+
"#{translate_entry_self_prefix}.#{entry_suffix}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def translate_entry_self_prefix
|
19
|
+
name.underscore.gsub('/', '.')
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_i18n_locale(locale)
|
23
|
+
old_locale = ::I18n.locale
|
24
|
+
begin
|
25
|
+
::I18n.locale = locale
|
26
|
+
yield
|
27
|
+
ensure
|
28
|
+
::I18n.locale = old_locale
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,17 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/patches/i18n'
|
3
|
+
require 'avm/patches/class/i18n'
|
4
4
|
|
5
5
|
class Object
|
6
6
|
def translate(entry_suffix, values = {})
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def translate_entry_full(entry_suffix)
|
11
|
-
"#{translate_entry_self_prefix}.#{entry_suffix}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def translate_entry_self_prefix
|
15
|
-
self.class.name.underscore.gsub('/', '.')
|
7
|
+
self.class.translate(entry_suffix, values)
|
16
8
|
end
|
17
9
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/patches/class/i18n'
|
4
5
|
|
5
6
|
module Avm
|
6
7
|
module Projects
|
7
8
|
module Stereotypes
|
8
9
|
class RubyGem
|
9
10
|
class Update
|
11
|
+
TRANSLATE_CLASS = self
|
12
|
+
|
10
13
|
enable_console_speaker
|
11
14
|
common_constructor :instance
|
12
15
|
|
@@ -46,7 +49,7 @@ module Avm
|
|
46
49
|
end
|
47
50
|
|
48
51
|
def gemfile_lock_commit_message
|
49
|
-
|
52
|
+
TRANSLATE_CLASS.translate(__method__, __locale: instance.locale)
|
50
53
|
end
|
51
54
|
|
52
55
|
def gemfile_lock_changed?
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_git/local'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Git < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class Subrepo < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Clone
|
13
|
+
runner_with :help do
|
14
|
+
desc 'Clone git-subrepo repositories.'
|
15
|
+
arg_opt '-b', '--branch', 'Branch.'
|
16
|
+
arg_opt '-d', '--parent-dir', 'Target path\'s parent directory.'
|
17
|
+
pos_arg :url
|
18
|
+
pos_arg :target_path, optional: true
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
start_banner
|
23
|
+
clean
|
24
|
+
clone
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def start_banner
|
30
|
+
infov 'URL', url
|
31
|
+
infov 'Subpath', target_path
|
32
|
+
infov 'Branch', branch
|
33
|
+
end
|
34
|
+
|
35
|
+
def clean
|
36
|
+
infom 'Cleaning...'
|
37
|
+
git.command('subrepo', 'clean', '--all', '--force').system!
|
38
|
+
end
|
39
|
+
|
40
|
+
def clone
|
41
|
+
infom 'Cloning...'
|
42
|
+
infov 'Clone arguments', clone_args
|
43
|
+
git.command(*clone_args).system!
|
44
|
+
end
|
45
|
+
|
46
|
+
delegate :branch, :url, to: :parsed
|
47
|
+
|
48
|
+
def git_uncached
|
49
|
+
::EacGit::Local.new('.')
|
50
|
+
end
|
51
|
+
|
52
|
+
def clone_args
|
53
|
+
['subrepo'] + branch.if_present([]) { |v| ['--branch', v] } +
|
54
|
+
if ::File.exist?(target_path)
|
55
|
+
['init', target_path, '--remote', url]
|
56
|
+
else
|
57
|
+
['clone', url, target_path, '--message', clone_message, '--force']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def clone_message
|
62
|
+
"Subrepo \"#{target_path}\" (#{url})."
|
63
|
+
end
|
64
|
+
|
65
|
+
def repos_name_from_url
|
66
|
+
%r{/([^/]+)\z}.if_match(url, false) { |m| m[1].gsub(/\.git\z/, '') }
|
67
|
+
end
|
68
|
+
|
69
|
+
def target_path
|
70
|
+
parsed.target_path || target_path_from_parent_dir ||
|
71
|
+
fatal_error('No target path specified')
|
72
|
+
end
|
73
|
+
|
74
|
+
def target_path_from_parent_dir
|
75
|
+
return nil unless parsed.parent_dir && repos_name_from_url
|
76
|
+
|
77
|
+
::File.join(parsed.parent_dir, repos_name_from_url)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'eac_git/local'
|
5
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class Git < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class Subrepo < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
class Fix
|
13
|
+
runner_with :help do
|
14
|
+
desc 'Fix git-subrepos\' parent property.'
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
loop do
|
19
|
+
break if fix
|
20
|
+
|
21
|
+
amend_each
|
22
|
+
rebase_fixup
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def amend_each
|
29
|
+
infov 'Dirty files', local_repos.dirty_files.count
|
30
|
+
local_repos.dirty_files.each do |file|
|
31
|
+
infov ' * Ammending', file.path
|
32
|
+
::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file.path).run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def fix
|
37
|
+
infom 'Checking/fixing...'
|
38
|
+
c = new_check(true)
|
39
|
+
c.show_result
|
40
|
+
!c.result.error?
|
41
|
+
end
|
42
|
+
|
43
|
+
def new_check(fix_parent = false)
|
44
|
+
r = ::Avm::Git::SubrepoChecks.new(local_repos).add_all_subrepos
|
45
|
+
r.fix_parent = fix_parent
|
46
|
+
r
|
47
|
+
end
|
48
|
+
|
49
|
+
def local_repos_uncached
|
50
|
+
::EacGit::Local.new(runner_context.call(:git))
|
51
|
+
end
|
52
|
+
|
53
|
+
def rebase_fixup
|
54
|
+
local_repos.command('rebase', '-i', 'origin/master', '--autosquash').envvar(
|
55
|
+
'GIT_SEQUENCE_EDITOR', 'true'
|
56
|
+
).or(
|
57
|
+
local_repos.command('rebase', '--continue').envvar('GIT_SEQUENCE_EDITOR', 'true')
|
58
|
+
).system!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/avm/tools/version.rb
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.files = Dir['{lib}/**/*', 'Gemfile']
|
14
14
|
|
15
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
15
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.55'
|
16
16
|
|
17
17
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
|
18
18
|
end
|
@@ -12,12 +12,14 @@ module EacCli
|
|
12
12
|
|
13
13
|
def parsed_uncached
|
14
14
|
raise 'Definition has no alternatives' if alternatives.empty?
|
15
|
+
raise first_error unless alternatives.select(&:success?).any?
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
17
|
+
alternatives_parsed(true).merge(alternatives_parsed(false))
|
18
|
+
end
|
19
19
|
|
20
|
-
|
20
|
+
def alternatives_parsed(error)
|
21
|
+
alternatives.select { |a| error == a.error? }.map(&:parsed).reverse
|
22
|
+
.inject(::EacRubyUtils::Struct.new) { |a, e| a.merge(e) }
|
21
23
|
end
|
22
24
|
|
23
25
|
def alternatives_uncached
|
@@ -44,6 +44,8 @@ module EacCli
|
|
44
44
|
extend AfterClassMethods
|
45
45
|
include InstanceMethods
|
46
46
|
::EacCli::Docopt::RunnerExtension.check(self)
|
47
|
+
include ActiveSupport::Callbacks
|
48
|
+
define_callbacks :run
|
47
49
|
end
|
48
50
|
|
49
51
|
module AfterClassMethods
|
@@ -55,8 +57,7 @@ module EacCli
|
|
55
57
|
|
56
58
|
def run(*runner_context_args)
|
57
59
|
r = create(*runner_context_args)
|
58
|
-
r.
|
59
|
-
r.run
|
60
|
+
r.run_run
|
60
61
|
r
|
61
62
|
end
|
62
63
|
|
@@ -72,6 +73,13 @@ module EacCli
|
|
72
73
|
end
|
73
74
|
|
74
75
|
module InstanceMethods
|
76
|
+
def run_run
|
77
|
+
parsed
|
78
|
+
run_callbacks(:run) { run }
|
79
|
+
rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
|
80
|
+
# Do nothing
|
81
|
+
end
|
82
|
+
|
75
83
|
def runner_context
|
76
84
|
return @runner_context if @runner_context
|
77
85
|
|