eac_launcher 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +14 -0
- data/README.rdoc +3 -0
- data/exe/eac_launcher_instance +33 -0
- data/exe/eac_launcher_projects +43 -0
- data/exe/eac_launcher_publish +49 -0
- data/lib/eac_launcher.rb +44 -0
- data/lib/eac_launcher/context.rb +63 -0
- data/lib/eac_launcher/context/settings.rb +36 -0
- data/lib/eac_launcher/git/base.rb +105 -0
- data/lib/eac_launcher/git/base/subrepo.rb +18 -0
- data/lib/eac_launcher/git/base/underlying.rb +38 -0
- data/lib/eac_launcher/git/mirror_update.rb +32 -0
- data/lib/eac_launcher/git/publish_base.rb +69 -0
- data/lib/eac_launcher/git/transpose_base.rb +48 -0
- data/lib/eac_launcher/instances/base.rb +110 -0
- data/lib/eac_launcher/instances/base/cache.rb +38 -0
- data/lib/eac_launcher/instances/runner_helper.rb +37 -0
- data/lib/eac_launcher/instances/settings.rb +17 -0
- data/lib/eac_launcher/path.rb +25 -0
- data/lib/eac_launcher/project.rb +14 -0
- data/lib/eac_launcher/publish/base.rb +12 -0
- data/lib/eac_launcher/publish/check_result.rb +42 -0
- data/lib/eac_launcher/stereotype.rb +44 -0
- data/lib/eac_launcher/stereotypes/git.rb +17 -0
- data/lib/eac_launcher/stereotypes/git/publish.rb +9 -0
- data/lib/eac_launcher/stereotypes/git/transpose.rb +21 -0
- data/lib/eac_launcher/stereotypes/git_subrepo.rb +25 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +8 -0
- data/lib/eac_launcher/stereotypes/git_subrepo/transpose.rb +87 -0
- data/lib/eac_launcher/stereotypes/git_subtree.rb +31 -0
- data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +8 -0
- data/lib/eac_launcher/stereotypes/git_subtree/transpose.rb +27 -0
- data/lib/eac_launcher/stereotypes/rails.rb +17 -0
- data/lib/eac_launcher/stereotypes/redmine_plugin.rb +17 -0
- data/lib/eac_launcher/stereotypes/ruby_gem.rb +21 -0
- data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +109 -0
- data/lib/eac_launcher/vendor/github.rb +13 -0
- data/lib/eac_launcher/version.rb +5 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ddd299ffda328fc28afcf975e6f4c5cf1044fc62
|
4
|
+
data.tar.gz: deb8b2a8a31144cfcc8a2c3603eac3b0f4fc7cc2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2365a2c18cc5d3d9b22748a32b41f65e76e85767848314f08bdea10f30d49f0c0e40c47caa49393d0f973360f2d7a5cc600b16dd944fecbee266d0dc3c16f7d2
|
7
|
+
data.tar.gz: 97e6e6f63eb094a7151f732aefb20cf35de0a92d1e23132b0308a52c230cbd09aa6d109107dfa56ad347e43cce896b1f73d0d0ff24c2fe2806986ceaffc5956a
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in users_support.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use a debugger
|
14
|
+
# gem 'byebug', group: [:development, :test]
|
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'eac_launcher'
|
7
|
+
|
8
|
+
class Runner < ::EacLauncher::Instances::RunnerHelper
|
9
|
+
DOC = <<DOCOPT.freeze
|
10
|
+
Mostra informações sobre instâncias.
|
11
|
+
|
12
|
+
Usage:
|
13
|
+
__PROGRAM__ [options] [<instance_path>...]
|
14
|
+
__PROGRAM__ -h | --help
|
15
|
+
|
16
|
+
Options:
|
17
|
+
-h --help Show this screen.
|
18
|
+
--all Get all instances.
|
19
|
+
|
20
|
+
DOCOPT
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def run
|
25
|
+
instances.each { |i| puts instance_label(i) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def instance_path
|
29
|
+
options['<instance_path>']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Runner.new
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'eac_launcher'
|
6
|
+
|
7
|
+
class Runner < ::EacLauncher::Instances::RunnerHelper
|
8
|
+
DOC = <<DOCOPT.freeze
|
9
|
+
Listas os projetos disponíveis.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
__PROGRAM__
|
13
|
+
__PROGRAM__ -i | --instances
|
14
|
+
__PROGRAM__ -h | --help
|
15
|
+
|
16
|
+
Options:
|
17
|
+
-h --help Show this screen.
|
18
|
+
-i --instances Show instances.
|
19
|
+
|
20
|
+
DOCOPT
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def run
|
25
|
+
::EacLauncher::Context.current.projects.each do |p|
|
26
|
+
show_project(p)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def show_project(p)
|
31
|
+
puts project_label(p)
|
32
|
+
return unless options['--instances']
|
33
|
+
p.instances.each do |i|
|
34
|
+
puts " * #{instance_label(i)}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def project_label(p)
|
39
|
+
p.to_s.cyan.to_s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Runner.new
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'eac_launcher'
|
6
|
+
|
7
|
+
class Runner < ::EacLauncher::Instances::RunnerHelper
|
8
|
+
DOC = <<DOCOPT.freeze
|
9
|
+
Publica projetos ou instâncias.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
__PROGRAM__ (check|dry-run|run) [options] [<instance_path>...]
|
13
|
+
__PROGRAM__ -h | --help
|
14
|
+
|
15
|
+
Options:
|
16
|
+
-h --help Show this screen.
|
17
|
+
--new Publish projects not published before.
|
18
|
+
-s --stereotype=<st> Publish only for stereotype <stereotype>.
|
19
|
+
--all Publish all instances.
|
20
|
+
|
21
|
+
DOCOPT
|
22
|
+
|
23
|
+
OPTIONS = {
|
24
|
+
new: '--new', confirm: 'run', stereotype: '--stereotype'
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def run
|
30
|
+
build_publish_options
|
31
|
+
instances.each do |i|
|
32
|
+
i.send(instance_method)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def instance_method
|
37
|
+
options['run'] || options['dry-run'] ? 'publish_run' : 'publish_check'
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_publish_options
|
41
|
+
::EacLauncher::Context.current.publish_options = publish_options
|
42
|
+
end
|
43
|
+
|
44
|
+
def publish_options
|
45
|
+
Hash[OPTIONS.map { |k, v| [k, options[v]] }]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Runner.new
|
data/lib/eac_launcher.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require('active_support')
|
4
|
+
require('active_support/core_ext')
|
5
|
+
require('colorize')
|
6
|
+
require('curb')
|
7
|
+
require('eac/simple_cache')
|
8
|
+
require('eac_ruby_utils')
|
9
|
+
require('git')
|
10
|
+
require('json')
|
11
|
+
require('rubygems')
|
12
|
+
require('shellwords')
|
13
|
+
require('yaml')
|
14
|
+
|
15
|
+
module EacLauncher
|
16
|
+
require 'eac_launcher/context'
|
17
|
+
require 'eac_launcher/path'
|
18
|
+
require 'eac_launcher/project'
|
19
|
+
require 'eac_launcher/stereotype'
|
20
|
+
require 'eac_launcher/context/settings'
|
21
|
+
require 'eac_launcher/git/base'
|
22
|
+
require 'eac_launcher/git/mirror_update'
|
23
|
+
require 'eac_launcher/git/publish_base'
|
24
|
+
require 'eac_launcher/git/transpose_base'
|
25
|
+
require 'eac_launcher/instances/base'
|
26
|
+
require 'eac_launcher/instances/runner_helper'
|
27
|
+
require 'eac_launcher/instances/settings'
|
28
|
+
require 'eac_launcher/publish/base'
|
29
|
+
require 'eac_launcher/publish/check_result'
|
30
|
+
require 'eac_launcher/stereotypes/git'
|
31
|
+
require 'eac_launcher/stereotypes/git_subrepo'
|
32
|
+
require 'eac_launcher/stereotypes/git_subtree'
|
33
|
+
require 'eac_launcher/stereotypes/rails'
|
34
|
+
require 'eac_launcher/stereotypes/redmine_plugin'
|
35
|
+
require 'eac_launcher/stereotypes/ruby_gem'
|
36
|
+
require 'eac_launcher/stereotypes/git/publish'
|
37
|
+
require 'eac_launcher/stereotypes/git/transpose'
|
38
|
+
require 'eac_launcher/stereotypes/git_subrepo/publish'
|
39
|
+
require 'eac_launcher/stereotypes/git_subrepo/transpose'
|
40
|
+
require 'eac_launcher/stereotypes/git_subtree/publish'
|
41
|
+
require 'eac_launcher/stereotypes/git_subtree/transpose'
|
42
|
+
require 'eac_launcher/stereotypes/ruby_gem/publish'
|
43
|
+
require 'eac_launcher/vendor/github'
|
44
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module EacLauncher
|
2
|
+
class Context
|
3
|
+
include ::Eac::SimpleCache
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def current
|
7
|
+
default
|
8
|
+
end
|
9
|
+
|
10
|
+
def default
|
11
|
+
@default ||= Context.new(
|
12
|
+
ENV['EAC_LAUNCHER_PROJECTS_ROOT'] || '.',
|
13
|
+
ENV['EAC_LAUNCHER_SETTINGS_FILE'] ||
|
14
|
+
::File.join(ENV['HOME'], '.config', 'eac_launcher', 'settings.yml')
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :root, :settings
|
20
|
+
attr_accessor :publish_options
|
21
|
+
|
22
|
+
def initialize(projects_root, settings_file)
|
23
|
+
@root = ::EacLauncher::Instances::Base.new(projects_root, nil)
|
24
|
+
@settings = ::EacLauncher::Context::Settings.new(settings_file)
|
25
|
+
@publish_options = { new: false, confirm: false, stereotype: nil }
|
26
|
+
end
|
27
|
+
|
28
|
+
def cache_root
|
29
|
+
File.join(ENV['HOME'], '.cache', 'cli-utils', 'dev')
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def projects_uncached
|
35
|
+
r = {}
|
36
|
+
instances.each do |i|
|
37
|
+
r[i.basename] ||= []
|
38
|
+
r[i.basename] << i
|
39
|
+
end
|
40
|
+
r.map { |name, instances| ::EacLauncher::Project.new(name, instances) }
|
41
|
+
.select { |p| include_project?(p) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def instances_uncached
|
45
|
+
instance_instances(root)
|
46
|
+
end
|
47
|
+
|
48
|
+
def instance_instances(i)
|
49
|
+
r = []
|
50
|
+
r << i if include_instance?(i)
|
51
|
+
r += i.children.flat_map { |c| instance_instances(c) }
|
52
|
+
r
|
53
|
+
end
|
54
|
+
|
55
|
+
def include_project?(p)
|
56
|
+
!@settings.excluded_projects.include?(p.name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def include_instance?(i)
|
60
|
+
i.project? && !@settings.excluded_projects.include?(i.project_name)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module EacLauncher
|
2
|
+
class Context
|
3
|
+
class Settings
|
4
|
+
include ::Eac::SimpleCache
|
5
|
+
|
6
|
+
def initialize(file)
|
7
|
+
@data = YAML.load_file(file)
|
8
|
+
end
|
9
|
+
|
10
|
+
def instance_settings(instance)
|
11
|
+
::EacLauncher::Instances::Settings.new(value(['Instances', instance.to_root_path]))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def excluded_projects_uncached
|
17
|
+
enum_value(%w[Projects Exclude])
|
18
|
+
end
|
19
|
+
|
20
|
+
def enum_value(path)
|
21
|
+
r = value(path)
|
22
|
+
r.is_a?(Enumerable) ? r : []
|
23
|
+
end
|
24
|
+
|
25
|
+
def value(path)
|
26
|
+
node_value(@data, path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def node_value(data, path)
|
30
|
+
return data if path.empty?
|
31
|
+
return nil unless data.is_a?(Hash)
|
32
|
+
node_value(data[path.first], path.drop(1))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative 'base/underlying'
|
2
|
+
require_relative 'base/subrepo'
|
3
|
+
|
4
|
+
module EacLauncher
|
5
|
+
module Git
|
6
|
+
class Base < ::EacLauncher::Path
|
7
|
+
include ::Eac::SimpleCache
|
8
|
+
include ::EacLauncher::Git::Base::Subrepo
|
9
|
+
include ::EacLauncher::Git::Base::Underlying
|
10
|
+
|
11
|
+
def init_bare
|
12
|
+
FileUtils.mkdir_p(self)
|
13
|
+
::EacRubyUtils::Envs.local.command('git', 'init', '--bare', self).execute! unless
|
14
|
+
File.exist?(subpath('.git'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def rev_parse(ref)
|
18
|
+
r = execute!('rev-parse', ref, exit_outputs: { 128 => nil, 32_768 => nil })
|
19
|
+
r.strip! if r.is_a?(String)
|
20
|
+
r = nil if r == ''
|
21
|
+
r
|
22
|
+
end
|
23
|
+
|
24
|
+
def remote_hashs(remote_name)
|
25
|
+
r = {}
|
26
|
+
execute!(['ls-remote', remote_name]).each_line do |line|
|
27
|
+
x = line.strip.split(/\s+/)
|
28
|
+
r[x[1]] = x[0]
|
29
|
+
end
|
30
|
+
r
|
31
|
+
end
|
32
|
+
|
33
|
+
def remote_exist?(remote_name)
|
34
|
+
git.remote(remote_name).url.present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def descendant?(descendant, ancestor)
|
38
|
+
base = merge_base(descendant, ancestor)
|
39
|
+
return false if base.blank?
|
40
|
+
revparse = execute!('rev-parse', '--verify', ancestor).strip
|
41
|
+
base == revparse
|
42
|
+
end
|
43
|
+
|
44
|
+
def merge_base(*commits)
|
45
|
+
refs = commits.dup
|
46
|
+
while refs.count > 1
|
47
|
+
refs[1] = merge_base_pair(refs[0], refs[1])
|
48
|
+
return nil if refs[1].blank?
|
49
|
+
refs.shift
|
50
|
+
end
|
51
|
+
refs.first
|
52
|
+
end
|
53
|
+
|
54
|
+
def subtree_split(prefix)
|
55
|
+
execute!('subtree', '-q', 'split', '-P', prefix).strip
|
56
|
+
end
|
57
|
+
|
58
|
+
def assert_remote_url(remote_name, url)
|
59
|
+
r = git.remote(remote_name)
|
60
|
+
if !r.url || r.url != url
|
61
|
+
r.remove if r.url
|
62
|
+
git.add_remote(remote_name, url)
|
63
|
+
end
|
64
|
+
r
|
65
|
+
end
|
66
|
+
|
67
|
+
def remote_branch_sha(remote_name, branch_name)
|
68
|
+
remote_hashs(remote_name)["refs/heads/#{branch_name}"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def push(remote_name, refspecs, options = {})
|
72
|
+
refspecs = [refspecs] unless refspecs.is_a?(Array)
|
73
|
+
args = ['push']
|
74
|
+
args << '--dry-run' if options[:dryrun]
|
75
|
+
args << '--force' if options[:force]
|
76
|
+
system!(args + [remote_name] + refspecs)
|
77
|
+
end
|
78
|
+
|
79
|
+
def push_all(remote_name)
|
80
|
+
system!('push', '--all', remote_name)
|
81
|
+
system!('push', '--tags', remote_name)
|
82
|
+
end
|
83
|
+
|
84
|
+
def fetch(remote_name, options = {})
|
85
|
+
args = ['fetch', '-p', remote_name]
|
86
|
+
args << '--tags' if options[:tags]
|
87
|
+
execute!(*args)
|
88
|
+
end
|
89
|
+
|
90
|
+
def current_branch
|
91
|
+
execute!(%w[symbolic-ref -q HEAD]).gsub(%r{\Arefs/heads/}, '').strip
|
92
|
+
end
|
93
|
+
|
94
|
+
def reset_hard(ref)
|
95
|
+
execute!('reset', '--hard', ref)
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def merge_base_pair(c1, c2)
|
101
|
+
execute!('merge-base', c1, c2, exit_outputs: { 256 => '' }).strip
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EacLauncher
|
2
|
+
module Git
|
3
|
+
class Base < ::EacLauncher::Path
|
4
|
+
module Subrepo
|
5
|
+
def subrepo_status(subrepo_path)
|
6
|
+
s = execute!('subrepo', 'status', subrepo_path.gsub(%r{\A/}, ''))
|
7
|
+
r = {}.with_indifferent_access
|
8
|
+
s.each_line do |l|
|
9
|
+
m = /\A([^\:]+)\:(.*)\z/.match(l.strip)
|
10
|
+
next unless m && m[2].present?
|
11
|
+
r[m[1].strip] = m[2].strip
|
12
|
+
end
|
13
|
+
r
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module EacLauncher
|
2
|
+
module Git
|
3
|
+
class Base < ::EacLauncher::Path
|
4
|
+
module Underlying
|
5
|
+
def execute!(*args)
|
6
|
+
args, options = build_args(args)
|
7
|
+
::EacRubyUtils::Envs.local.command(*args).execute!(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def system!(*args)
|
11
|
+
args, options = build_args(args)
|
12
|
+
::EacRubyUtils::Envs.local.command(*args).system!(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def build_args(args)
|
18
|
+
options = {}
|
19
|
+
if args.last.is_a?(Hash)
|
20
|
+
options = args.last
|
21
|
+
args.pop
|
22
|
+
end
|
23
|
+
args = args.first if args.first.is_a?(Array)
|
24
|
+
[['git', '-C', self, '--no-pager'] + args, options]
|
25
|
+
end
|
26
|
+
|
27
|
+
def git_uncached
|
28
|
+
FileUtils.mkdir_p(self)
|
29
|
+
if File.exist?(subpath('.git'))
|
30
|
+
::Git.open(self)
|
31
|
+
else
|
32
|
+
::Git.init(self)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|