avm-tools 0.79.0 → 0.83.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/unit.rb +8 -3
  3. data/lib/avm/eac_rails_base0/apache_host.rb +2 -9
  4. data/lib/avm/eac_rails_base1/apache_host.rb +17 -0
  5. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  6. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  7. data/lib/avm/eac_redmine_base0/apache_host.rb +10 -0
  8. data/lib/avm/eac_redmine_base0/data_unit.rb +29 -1
  9. data/lib/avm/eac_writings_base1.rb +9 -0
  10. data/lib/avm/eac_writings_base1/build.rb +45 -0
  11. data/lib/avm/eac_writings_base1/build/file.rb +28 -0
  12. data/lib/avm/eac_writings_base1/project.rb +13 -0
  13. data/lib/avm/executables.rb +1 -1
  14. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  15. data/lib/avm/tools/runner/local_project/eac_writings_base1.rb +32 -0
  16. data/lib/avm/tools/runner/local_project/eac_writings_base1/build.rb +48 -0
  17. data/lib/avm/tools/version.rb +1 -1
  18. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  19. data/vendor/eac_cli/lib/eac_cli/parser.rb +6 -4
  20. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -0
  21. data/vendor/eac_cli/lib/eac_cli/runner.rb +10 -2
  22. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  23. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +17 -0
  24. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -1
  25. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  26. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +6 -3
  27. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  28. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -1
  29. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  30. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  31. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  32. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  33. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  34. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  35. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  36. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
  37. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  38. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  39. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  40. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  41. metadata +18 -4
  42. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  43. 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: eec96ee906113345d8ef2b32945ccf9140141b63cdeaccb7b2f351762f338e82
4
- data.tar.gz: 8f25aaa99149329fc034c040f45609b8eb078b2c547ab88d99c89dfd2b607135
3
+ metadata.gz: d469de0c152bb7c3b2f23bf083a10d66bed14ee4963cd6a6502ac8ef545145c9
4
+ data.tar.gz: 04a3077630a42a18df2a82ab7cf2874aa7f16b133d3ab99d899dc34e3231a571
5
5
  SHA512:
6
- metadata.gz: 1790d224e7b049c1aca352e2d4859ae9d48d80df3664aa2741654a56c70491e065380936e1d62f542b449aaf8de3e7e5d609985da830ebef6a24e4e392a75f99
7
- data.tar.gz: 4e658ff31fcb8044695f44a20a8f0777eda5eb580ddaad93d7e63f1ecfb4676e3f284e8e8578a0c3d2db1b978f0a3754ec3c0709fbb7e80c50a903c718dd408b
6
+ metadata.gz: a82ad8c06b90942d34e09e4c388a7b5335561026b5f4b63c62c1a623daca8c99ae10410caa70207e63cb3487b11c1aa84adab5a1a206e8c00cd5448a1c5ea4f3
7
+ data.tar.gz: 932ce1dad2c115a3a04998b4bed1697e179f257beba3f35af343f02f51274cbe8d25ace9f2ca9667289da18561dbcff9ab40dbe87fd04ebaaaac740efd601336
@@ -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 #{action}_command
19
- fail "Abstract method. Override in #{singleton_class}."
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
- load_command.execute!(input_file: data_path)
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)
@@ -1,17 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/eac_webapp_base0/apache_host'
3
+ require 'avm/eac_rails_base1/apache_host'
4
4
 
5
5
  module Avm
6
6
  module EacRailsBase0
7
- class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
8
- def document_root
9
- "#{instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)}/public"
10
- end
11
-
12
- def extra_content
13
- 'PassengerEnabled On'
14
- end
7
+ class ApacheHost < ::Avm::EacRailsBase1::ApacheHost
15
8
  end
16
9
  end
17
10
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/apache_host'
4
+
5
+ module Avm
6
+ module EacRailsBase1
7
+ class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
8
+ def document_root
9
+ "#{instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)}/public"
10
+ end
11
+
12
+ def extra_content
13
+ 'PassengerEnabled On'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/apache_host'
4
+
5
+ module Avm
6
+ module EacRedmineBase0
7
+ class ApacheHost < ::Avm::EacRailsBase1::ApacheHost
8
+ end
9
+ end
10
+ 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
- uri = ::Addressable::URI.parse(instance.read_entry('web.url')) + '/backup/export'
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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacWritingsBase1
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/fs/clearable_directory'
5
+
6
+ module Avm
7
+ module EacWritingsBase1
8
+ class Build
9
+ require_sub __FILE__
10
+ enable_console_speaker
11
+ enable_simple_cache
12
+ enable_listable
13
+ lists.add_symbol :option, :target_directory
14
+ common_constructor :project, :options, default: [{}] do
15
+ self.options = options.symbolize_keys
16
+ end
17
+
18
+ def run
19
+ infov 'Files to build', source_files.count
20
+ target_directory.clear
21
+ source_files.each(&:run)
22
+ end
23
+
24
+ def default_target_directory
25
+ project.root.join('build')
26
+ end
27
+
28
+ def target_directory
29
+ ::EacRubyUtils::Fs::ClearableDirectory.new(
30
+ options[OPTION_TARGET_DIRECTORY].if_present(default_target_directory)
31
+ )
32
+ end
33
+
34
+ def source_files_uncached
35
+ r = []
36
+ project.root.children.each do |child|
37
+ next unless child.extname == '.asc'
38
+
39
+ r << ::Avm::EacWritingsBase1::Build::File.new(self, child.basename)
40
+ end
41
+ r
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/executables'
4
+
5
+ module Avm
6
+ module EacWritingsBase1
7
+ class Build
8
+ class File
9
+ enable_console_speaker
10
+ common_constructor :build, :subpath
11
+
12
+ def run
13
+ infov 'Building', subpath
14
+ target_path.parent.mkpath
15
+ ::Avm::Executables.asciidoc.command('--out-file', target_path, source_path).system!
16
+ end
17
+
18
+ def source_path
19
+ build.project.root.join(subpath)
20
+ end
21
+
22
+ def target_path
23
+ build.target_directory.join(subpath).basename_sub('.*') { |b| "#{b}.html" }
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacWritingsBase1
7
+ class Project
8
+ common_constructor :root do
9
+ self.root = root.to_pathname
10
+ end
11
+ end
12
+ end
13
+ end
@@ -14,7 +14,7 @@ module Avm
14
14
 
15
15
  private
16
16
 
17
- %w[docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
17
+ %w[asciidoc docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
18
18
  define_method(program.underscore + '_uncached') do
19
19
  env.executable(program, '--version')
20
20
  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
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class EacWritingsBase1
11
+ require_sub __FILE__
12
+
13
+ runner_with :help, :subcommands do
14
+ desc 'EacWritingsBase0 utitilies for local projects.'
15
+ subcommands
16
+ end
17
+
18
+ def project_banner
19
+ infov 'Project', project.name
20
+ infov 'Path', project.root
21
+ end
22
+
23
+ private
24
+
25
+ def project_uncached
26
+ ::Avm::EacWritingsBase0::Project.new(runner_context.call(:instance_path))
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_writings_base1/build'
4
+ require 'avm/eac_writings_base1/project'
5
+ require 'eac_cli/core_ext'
6
+ require 'eac_ruby_utils/console/docopt_runner'
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
12
+ class EacWritingsBase1
13
+ class Build
14
+ runner_with :help do
15
+ desc 'Build the project'
16
+ arg_opt '-d', '--target-dir', 'Directory to build'
17
+ end
18
+
19
+ def run
20
+ start_banner
21
+ build.run
22
+ end
23
+
24
+ private
25
+
26
+ def build_uncached
27
+ ::Avm::EacWritingsBase1::Build.new(runner_context.call(:project),
28
+ target_directory: parsed.target_dir)
29
+ end
30
+
31
+ def default_target_directory
32
+ runner_context.call(:project).root.join('build')
33
+ end
34
+
35
+ def start_banner
36
+ runner_context.call(:project_banner)
37
+ infov 'Target directory', build.target_directory
38
+ end
39
+ #
40
+ # def target_directory_uncached
41
+ # .if_present(default_target_directory).to_pathname
42
+ # end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end