avm-tools 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +3 -3
- data/lib/avm/tools/runner/launcher.rb +12 -0
- data/lib/avm/tools/version.rb +1 -1
- data/lib/eac_launcher.rb +17 -0
- data/lib/eac_launcher/context.rb +81 -0
- data/lib/eac_launcher/context/instance_discovery.rb +54 -0
- data/lib/eac_launcher/context/instance_manager.rb +94 -0
- data/lib/eac_launcher/context/settings.rb +51 -0
- data/lib/eac_launcher/git.rb +7 -0
- data/lib/eac_launcher/git/base.rb +94 -0
- data/lib/eac_launcher/git/base/_remotes.rb +36 -0
- data/lib/eac_launcher/git/base/subrepo.rb +42 -0
- data/lib/eac_launcher/git/base/underlying.rb +49 -0
- data/lib/eac_launcher/git/error.rb +11 -0
- data/lib/eac_launcher/git/mirror_update.rb +36 -0
- data/lib/eac_launcher/git/publish_base.rb +118 -0
- data/lib/eac_launcher/git/remote.rb +53 -0
- data/lib/eac_launcher/git/sub_warp_base.rb +30 -0
- data/lib/eac_launcher/git/warp_base.rb +54 -0
- data/lib/eac_launcher/instances.rb +6 -0
- data/lib/eac_launcher/instances/base.rb +91 -0
- data/lib/eac_launcher/instances/base/cache.rb +41 -0
- data/lib/eac_launcher/instances/error.rb +8 -0
- data/lib/eac_launcher/instances/runner_helper.rb +42 -0
- data/lib/eac_launcher/instances/settings.rb +23 -0
- data/lib/eac_launcher/paths.rb +4 -0
- data/lib/eac_launcher/paths/logical.rb +80 -0
- data/lib/eac_launcher/paths/real.rb +42 -0
- data/lib/eac_launcher/project.rb +16 -0
- data/lib/eac_launcher/publish.rb +4 -0
- data/lib/eac_launcher/publish/base.rb +45 -0
- data/lib/eac_launcher/publish/check_result.rb +65 -0
- data/lib/eac_launcher/ruby.rb +3 -0
- data/lib/eac_launcher/ruby/gem.rb +4 -0
- data/lib/eac_launcher/ruby/gem/build.rb +123 -0
- data/lib/eac_launcher/ruby/gem/specification.rb +61 -0
- data/lib/eac_launcher/runner.rb +21 -0
- data/lib/eac_launcher/runner/instances.rb +41 -0
- data/lib/eac_launcher/runner/projects.rb +46 -0
- data/lib/eac_launcher/runner/publish.rb +59 -0
- data/lib/eac_launcher/stereotype.rb +52 -0
- data/lib/eac_launcher/stereotypes.rb +14 -0
- data/lib/eac_launcher/stereotypes/git.rb +21 -0
- data/lib/eac_launcher/stereotypes/git/publish.rb +13 -0
- data/lib/eac_launcher/stereotypes/git/warp.rb +25 -0
- data/lib/eac_launcher/stereotypes/git_subrepo.rb +30 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +12 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +85 -0
- data/lib/eac_launcher/stereotypes/git_subtree.rb +47 -0
- data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +10 -0
- data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +27 -0
- data/lib/eac_launcher/stereotypes/rails.rb +21 -0
- data/lib/eac_launcher/stereotypes/redmine_plugin.rb +21 -0
- data/lib/eac_launcher/stereotypes/ruby_gem.rb +27 -0
- data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +127 -0
- data/lib/eac_launcher/vendor.rb +3 -0
- data/lib/eac_launcher/vendor/github.rb +18 -0
- data/lib/eac_launcher/version.rb +5 -0
- metadata +101 -5
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'eac_ruby_utils/console/speaker'
|
5
|
+
require 'eac_ruby_utils/envs'
|
6
|
+
require 'eac_launcher/ruby/gem/specification'
|
7
|
+
|
8
|
+
module EacLauncher
|
9
|
+
module Ruby
|
10
|
+
module Gem
|
11
|
+
class Build
|
12
|
+
include ::EacRubyUtils::Console::Speaker
|
13
|
+
|
14
|
+
def initialize(original_gem_root)
|
15
|
+
@original_gem_root = original_gem_root
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_file
|
19
|
+
return nil unless @gem_root
|
20
|
+
|
21
|
+
@gem_root.find_files_with_extension('.gem').first
|
22
|
+
end
|
23
|
+
|
24
|
+
def builded?
|
25
|
+
output_file.present? && ::File.exist?(output_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
def build
|
29
|
+
return if builded?
|
30
|
+
|
31
|
+
copy_gem_files
|
32
|
+
build_gem
|
33
|
+
check_gem_empty_size
|
34
|
+
check_gem_version
|
35
|
+
end
|
36
|
+
|
37
|
+
def close
|
38
|
+
::FileUtils.remove_entry(@gem_root) if @gem_root && ::File.directory?(@gem_root)
|
39
|
+
@gem_root = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def copy_gem_files
|
45
|
+
@gem_root = ::EacLauncher::Paths::Real.new(::Dir.mktmpdir)
|
46
|
+
FileUtils.cp_r "#{@original_gem_root}/.", @gem_root
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_gem
|
50
|
+
info("Building gemspec #{gemspec_file}...")
|
51
|
+
clear_gems
|
52
|
+
Dir.chdir @gem_root do
|
53
|
+
isolated_build_gem
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def isolated_build_gem
|
58
|
+
on_clean_ruby do
|
59
|
+
EacRubyUtils::Envs.local.command('gem', 'build', gemspec_file).execute!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_gem_empty_size
|
64
|
+
Dir.mktmpdir do |dir|
|
65
|
+
Dir.chdir dir do
|
66
|
+
EacRubyUtils::Envs.local.command('gem', 'unpack', gem).system
|
67
|
+
gs = File.join(dir, File.basename(gem, '.gem'))
|
68
|
+
if (Dir.entries(gs) - %w[. ..]).empty?
|
69
|
+
raise "\"#{dir}\" (Unpacked from #{gem}) has no source code"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def clear_gems
|
76
|
+
@gem_root.find_files_with_extension('.gem').each do |f|
|
77
|
+
FileUtils.rm_rf(f)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def gemspec_file
|
82
|
+
@gem_root.find_file_with_extension('.gemspec')
|
83
|
+
end
|
84
|
+
|
85
|
+
def gem
|
86
|
+
@gem_root.find_file_with_extension('.gem')
|
87
|
+
end
|
88
|
+
|
89
|
+
def check_gem_version
|
90
|
+
spec = ::EacLauncher::Ruby::Gem::Specification.new(gemspec_file)
|
91
|
+
return if ::File.basename(output_file, '.gem') == spec.full_name
|
92
|
+
|
93
|
+
raise("Builded gem is not the same version of gemspec (#{spec}, #{output_file})")
|
94
|
+
end
|
95
|
+
|
96
|
+
def bundle_dependencies
|
97
|
+
gemfile = @gem_root.subpath('Gemfile')
|
98
|
+
return unless ::File.exist?(gemfile)
|
99
|
+
|
100
|
+
Dir.chdir(@gem_root) do
|
101
|
+
EacRubyUtils::Envs.local.command('bundle', 'install').execute!
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def on_clean_ruby
|
106
|
+
on_clear_envvars('BUNDLE', 'RUBY') { yield }
|
107
|
+
end
|
108
|
+
|
109
|
+
def on_clear_envvars(*start_with_vars)
|
110
|
+
old_values = envvars_starting_with(start_with_vars)
|
111
|
+
old_values.each_key { |k| ENV.delete(k) }
|
112
|
+
yield
|
113
|
+
ensure
|
114
|
+
old_values&.each { |k, v| ENV[k] = v }
|
115
|
+
end
|
116
|
+
|
117
|
+
def envvars_starting_with(start_with_vars)
|
118
|
+
ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Ruby
|
7
|
+
module Gem
|
8
|
+
class Specification
|
9
|
+
class << self
|
10
|
+
def parse_version_file(file)
|
11
|
+
s = ::File.read(file)
|
12
|
+
m = /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.match(s)
|
13
|
+
m ? m[1] : nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :gemspec_file
|
18
|
+
|
19
|
+
def initialize(gemspec_file)
|
20
|
+
@gemspec_file = gemspec_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def version
|
24
|
+
v = self.class.parse_version_file(version_file)
|
25
|
+
return v if v.present?
|
26
|
+
|
27
|
+
raise "Version not found on file \"#{version_file}\""
|
28
|
+
end
|
29
|
+
|
30
|
+
def name
|
31
|
+
::File.basename(gemspec_file).gsub(/\.gemspec\z/, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
def full_name
|
35
|
+
"#{name}-#{version}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
full_name
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def gem_root
|
45
|
+
::File.dirname(gemspec_file)
|
46
|
+
end
|
47
|
+
|
48
|
+
def version_file
|
49
|
+
f = ::File.join(gem_root, 'lib', *namespace_parts, 'version.rb')
|
50
|
+
return f if ::File.exist?(f)
|
51
|
+
|
52
|
+
raise "Version file \"#{f}\" does not exist"
|
53
|
+
end
|
54
|
+
|
55
|
+
def namespace_parts
|
56
|
+
name.split('-')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
4
|
+
require 'eac_launcher/runner/instances'
|
5
|
+
require 'eac_launcher/runner/projects'
|
6
|
+
require 'eac_launcher/runner/publish'
|
7
|
+
|
8
|
+
module EacLauncher
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
DOC = <<~DOCOPT
|
11
|
+
Utilities to deploy applications and libraries.
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
__PROGRAM__ [options] __SUBCOMMANDS__
|
15
|
+
__PROGRAM__ -h | --help
|
16
|
+
|
17
|
+
Options:
|
18
|
+
-h --help Show this screen.
|
19
|
+
DOCOPT
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/instances/runner_helper'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
7
|
+
class Instances < ::EacLauncher::Instances::RunnerHelper
|
8
|
+
DOC = <<~DOCOPT
|
9
|
+
Mostra informações sobre instâncias.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
__PROGRAM__ [options] [<instance_path>...]
|
13
|
+
__PROGRAM__ -h | --help
|
14
|
+
|
15
|
+
Options:
|
16
|
+
-h --help Show this screen.
|
17
|
+
--all Get all instances.
|
18
|
+
--recache Rewrite instances cache.
|
19
|
+
|
20
|
+
DOCOPT
|
21
|
+
|
22
|
+
def run
|
23
|
+
::EacLauncher::Context.current.recache = options['--recache']
|
24
|
+
instances.each { |i| show_instance(i) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def show_instance(instance)
|
30
|
+
puts instance_label(instance)
|
31
|
+
infov(' * Parent', (instance.parent ? instance_label(instance.parent) : '-'))
|
32
|
+
infov(' * Git current revision', instance.options.git_current_revision)
|
33
|
+
infov(' * Git publish remote', instance.options.git_publish_remote)
|
34
|
+
end
|
35
|
+
|
36
|
+
def instance_path
|
37
|
+
options['<instance_path>']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/context'
|
4
|
+
require 'eac_launcher/instances/runner_helper'
|
5
|
+
|
6
|
+
module EacLauncher
|
7
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
8
|
+
class Projects < ::EacLauncher::Instances::RunnerHelper
|
9
|
+
DOC = <<~DOCOPT
|
10
|
+
Shows available projects.
|
11
|
+
|
12
|
+
Usage:
|
13
|
+
__PROGRAM__ [options]
|
14
|
+
__PROGRAM__ -h | --help
|
15
|
+
|
16
|
+
Options:
|
17
|
+
-h --help Show this screen.
|
18
|
+
-i --instances Show instances.
|
19
|
+
--recache Rewrite instances cache.
|
20
|
+
|
21
|
+
DOCOPT
|
22
|
+
|
23
|
+
def run
|
24
|
+
::EacLauncher::Context.current.recache = options['--recache']
|
25
|
+
::EacLauncher::Context.current.projects.each do |p|
|
26
|
+
show_project(p)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def show_project(project)
|
33
|
+
puts project_label(project)
|
34
|
+
return unless options['--instances']
|
35
|
+
|
36
|
+
project.instances.each do |i|
|
37
|
+
puts " * #{instance_label(i)}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def project_label(project)
|
42
|
+
project.to_s.cyan.to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacLauncher
|
4
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
5
|
+
class Publish < ::EacLauncher::Instances::RunnerHelper
|
6
|
+
DOC = <<~DOCOPT
|
7
|
+
Publica projetos ou instâncias.
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
__PROGRAM__ [options] [<instance_path>...]
|
11
|
+
__PROGRAM__ -h | --help
|
12
|
+
|
13
|
+
Options:
|
14
|
+
-h --help Show this screen.
|
15
|
+
--new Publish projects not published before.
|
16
|
+
-s --stereotype=<st> Publish only for stereotype <stereotype>.
|
17
|
+
--all Publish all instances.
|
18
|
+
-d --dry-run "Dry run" publishing.
|
19
|
+
--pending Publish only pending.
|
20
|
+
--recache Rewrite instances cache.
|
21
|
+
--run Confirm publishing.
|
22
|
+
|
23
|
+
DOCOPT
|
24
|
+
|
25
|
+
def run
|
26
|
+
::EacLauncher::Context.current.recache = options['--recache']
|
27
|
+
build_publish_options
|
28
|
+
instances.each do |i|
|
29
|
+
next unless i.options.publishable?
|
30
|
+
|
31
|
+
i.send(instance_method)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def dry_run?
|
38
|
+
options.fetch('--dry-run')
|
39
|
+
end
|
40
|
+
|
41
|
+
def instance_method
|
42
|
+
run? || dry_run? ? 'publish_run' : 'publish_check'
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_publish_options
|
46
|
+
::EacLauncher::Context.current.publish_options = publish_options
|
47
|
+
end
|
48
|
+
|
49
|
+
def publish_options
|
50
|
+
{ new: options.fetch('--new'), stereotype: options.fetch('--stereotype'),
|
51
|
+
confirm: run? }
|
52
|
+
end
|
53
|
+
|
54
|
+
def run?
|
55
|
+
options.fetch('--run') && !dry_run?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Stereotype
|
7
|
+
class << self
|
8
|
+
attr_reader :stereotypes
|
9
|
+
|
10
|
+
def included(base)
|
11
|
+
@stereotypes ||= []
|
12
|
+
@stereotypes << base
|
13
|
+
base.extend(ClassMethods)
|
14
|
+
end
|
15
|
+
|
16
|
+
def git_stereotypes
|
17
|
+
stereotypes.select { |c| c.name.demodulize.downcase.match('git') }
|
18
|
+
end
|
19
|
+
|
20
|
+
def nogit_stereotypes
|
21
|
+
stereotypes - git_stereotypes
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def stereotype_name
|
27
|
+
name.gsub(/^.*::/, '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def stereotype_name_in_color
|
31
|
+
stereotype_name.send(color)
|
32
|
+
end
|
33
|
+
|
34
|
+
def publish_class
|
35
|
+
sub_class('Publish')
|
36
|
+
end
|
37
|
+
|
38
|
+
def warp_class
|
39
|
+
sub_class('Warp')
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def sub_class(sub_class_name)
|
45
|
+
klass = const_get(sub_class_name)
|
46
|
+
klass.is_a?(Class) ? klass : nil
|
47
|
+
rescue NameError
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/stereotypes/git'
|
4
|
+
require 'eac_launcher/stereotypes/git_subrepo'
|
5
|
+
require 'eac_launcher/stereotypes/git_subtree'
|
6
|
+
require 'eac_launcher/stereotypes/rails'
|
7
|
+
require 'eac_launcher/stereotypes/redmine_plugin'
|
8
|
+
require 'eac_launcher/stereotypes/ruby_gem'
|
9
|
+
require 'eac_launcher/stereotypes/git/publish'
|
10
|
+
require 'eac_launcher/stereotypes/git/warp'
|
11
|
+
require 'eac_launcher/stereotypes/git_subrepo/publish'
|
12
|
+
require 'eac_launcher/stereotypes/git_subrepo/warp'
|
13
|
+
require 'eac_launcher/stereotypes/git_subtree/publish'
|
14
|
+
require 'eac_launcher/stereotypes/git_subtree/warp'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_launcher/stereotype'
|
4
|
+
|
5
|
+
module EacLauncher
|
6
|
+
module Stereotypes
|
7
|
+
class Git
|
8
|
+
include EacLauncher::Stereotype
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def match?(path)
|
12
|
+
File.directory?(path.real.subpath('.git'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def color
|
16
|
+
:white
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|