hobo-inviqa 0.0.14 → 0.0.15
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/Gemfile.lock +8 -8
- data/Rakefile +27 -0
- data/lib/hobo/bundler.rb +8 -2
- data/lib/hobo/help_formatter.rb +6 -1
- data/lib/hobo/helper/file_locator.rb +6 -0
- data/lib/hobo/helper/shell.rb +14 -3
- data/lib/hobo/lib/s3/sync.rb +2 -0
- data/lib/hobo/lib/seed/seed.rb +25 -9
- data/lib/hobo/patches/slop.rb +20 -0
- data/lib/hobo/tasks/deps.rb +0 -1
- data/lib/hobo/tasks/magento.rb +191 -0
- data/lib/hobo/tasks/seed.rb +6 -0
- data/lib/hobo/ui.rb +33 -0
- data/lib/hobo/version.rb +1 -1
- data/spec/hobo/helpers/file_locator_spec.rb +1 -0
- data/spec/hobo/helpers/shell_spec.rb +2 -0
- data/spec/hobo/lib/s3/sync_spec.rb +1 -0
- data/spec/hobo/lib/seed/seed_spec.rb +35 -0
- data/spec/hobo/ui_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bc931dc97fa5ef07e062bde87cb5fe28b85899e
|
4
|
+
data.tar.gz: 937d3b8f1115bcf690d37045efca2b827acf291e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8044e55e9035be12728376ca8dcaca53adbb6af98d2f63e11c82bd148f7a18d16c8d47aca434a6db1aa8071ae2994c4ed940ac78416f268a87b5df3f7aa7983c
|
7
|
+
data.tar.gz: f2363c0b713e1e02ddfefbac09bc703d1c1cfa76fc168b14691773c9a942255ba957eb4e23665f3c9992e2bd5f2ee9de993498c06a62de37fd31fdd43fb9ece5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hobo-inviqa (0.0.
|
4
|
+
hobo-inviqa (0.0.15)
|
5
5
|
aws-sdk (~> 1.34.0)
|
6
6
|
bundler (>= 1.5.2)
|
7
7
|
deepstruct (~> 0.0.5)
|
@@ -25,19 +25,19 @@ GEM
|
|
25
25
|
blockenspiel (0.4.5)
|
26
26
|
coderay (1.1.0)
|
27
27
|
deepstruct (0.0.7)
|
28
|
-
hashie (3.
|
28
|
+
hashie (3.3.1)
|
29
29
|
highline (1.6.21)
|
30
30
|
json (1.8.1)
|
31
31
|
method_source (0.8.2)
|
32
32
|
mini_portile (0.6.0)
|
33
|
-
net-scp (1.1
|
33
|
+
net-scp (1.2.1)
|
34
34
|
net-ssh (>= 2.6.5)
|
35
|
-
net-ssh (2.
|
36
|
-
net-ssh-simple (1.6.
|
35
|
+
net-ssh (2.9.1)
|
36
|
+
net-ssh-simple (1.6.6)
|
37
37
|
blockenspiel (~> 0.4.3)
|
38
38
|
hashie (>= 1.1.0)
|
39
|
-
net-scp (~> 1.1
|
40
|
-
net-ssh (~> 2.
|
39
|
+
net-scp (~> 1.2.1)
|
40
|
+
net-ssh (~> 2.9.1)
|
41
41
|
nokogiri (1.6.3.1)
|
42
42
|
mini_portile (= 0.6.0)
|
43
43
|
pry (0.9.12.6)
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
semantic (1.3.0)
|
52
52
|
slop (3.4.7)
|
53
53
|
teerb (0.0.1)
|
54
|
-
uuidtools (2.1.
|
54
|
+
uuidtools (2.1.5)
|
55
55
|
|
56
56
|
PLATFORMS
|
57
57
|
ruby
|
data/Rakefile
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'semantic'
|
3
|
+
require_relative 'lib/hobo/version'
|
4
|
+
|
2
5
|
Bundler::GemHelper.install_tasks
|
3
6
|
|
4
7
|
ENV['HOBO_BUILD'] = '1'
|
@@ -12,6 +15,30 @@ task :install_dev_deps do
|
|
12
15
|
sh 'HOBO_ENV=dev bundle install'
|
13
16
|
end
|
14
17
|
|
18
|
+
namespace :version do
|
19
|
+
desc "Set version"
|
20
|
+
task :set, :version do |task, args|
|
21
|
+
sh "sed -i -e 's/#{Hobo::VERSION}/#{args[:version]}/' lib/hobo/version.rb"
|
22
|
+
sh "bundle install"
|
23
|
+
sh "git add Gemfile.lock lib/hobo/version.rb"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Bump version"
|
27
|
+
task :bump, :version do |task, args|
|
28
|
+
new_version = Semantic::Version.new args[:version]
|
29
|
+
old_version = Semantic::Version.new Hobo::VERSION
|
30
|
+
[ :major, :minor, :patch ].each do |k|
|
31
|
+
new_version.send "#{k.to_s}=", new_version.send(k) + old_version.send(k)
|
32
|
+
end
|
33
|
+
sh "sed -i -e 's/#{Hobo::VERSION}/#{new_version.to_s}/' lib/hobo/version.rb"
|
34
|
+
sh "bundle install"
|
35
|
+
sh "git add Gemfile.lock lib/hobo/version.rb"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :release do
|
40
|
+
end
|
41
|
+
|
15
42
|
namespace :test do
|
16
43
|
task :specs => [ 'install_dev_deps' ] do
|
17
44
|
sh 'HOBO_ENV=dev bundle exec rspec'
|
data/lib/hobo/bundler.rb
CHANGED
@@ -28,12 +28,12 @@ module Hobo
|
|
28
28
|
begin
|
29
29
|
bundler_install.run
|
30
30
|
Kernel.exec('hobo', *$HOBO_ARGV)
|
31
|
-
rescue Exception =>
|
31
|
+
rescue Exception => exception
|
32
32
|
puts
|
33
33
|
puts "Failed to install dependencies. Hobo can not proceed."
|
34
34
|
puts "Please see the error below:"
|
35
35
|
puts
|
36
|
-
|
36
|
+
raise
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -46,6 +46,12 @@ module Hobo
|
|
46
46
|
::Bundler.instance_variable_set('@load', nil)
|
47
47
|
::Bundler.definition true
|
48
48
|
|
49
|
+
# This is required as of 1.6.5 due to this commit:
|
50
|
+
# https://github.com/bundler/bundler/commit/4870340132878c30d49a5d5fc27257e2abe46e7e
|
51
|
+
::Bundler.class_eval do
|
52
|
+
@root = Pathname.new File.dirname(ENV['BUNDLE_GEMFILE'])
|
53
|
+
end
|
54
|
+
|
49
55
|
begin
|
50
56
|
::Bundler.setup(:default)
|
51
57
|
rescue ::Bundler::GemNotFound => exception
|
data/lib/hobo/help_formatter.rb
CHANGED
@@ -64,7 +64,12 @@ module Hobo
|
|
64
64
|
|
65
65
|
if opt.long
|
66
66
|
description += ". (Disable with --no-#{opt.long})" if opt.config[:invertable]
|
67
|
-
|
67
|
+
case opt.config[:as].to_s.downcase
|
68
|
+
when 'hash'
|
69
|
+
value = opt.config[:argument] ? "KEY#{opt.config[:key_delimiter]}VALUE" : ""
|
70
|
+
else
|
71
|
+
value = opt.config[:argument] ? "#{opt.long.upcase}" : ""
|
72
|
+
end
|
68
73
|
value = "[#{value}]" if opt.accepts_optional_argument?
|
69
74
|
value = "=#{value}" unless value.empty?
|
70
75
|
|
@@ -7,6 +7,7 @@ module Hobo
|
|
7
7
|
match = locate_git(pattern, &block)
|
8
8
|
end
|
9
9
|
|
10
|
+
return match unless block_given?
|
10
11
|
return true if match
|
11
12
|
|
12
13
|
Hobo.ui.warning opts[:missing] if opts[:missing]
|
@@ -22,6 +23,11 @@ module Hobo
|
|
22
23
|
found = false
|
23
24
|
paths.each do |path|
|
24
25
|
path.strip!
|
26
|
+
end
|
27
|
+
|
28
|
+
return paths unless block_given?
|
29
|
+
|
30
|
+
paths.each do |path|
|
25
31
|
Dir.chdir File.dirname(path) do
|
26
32
|
Hobo::Logging.logger.debug "helper.locator: Found #{path} for #{pattern}"
|
27
33
|
yield File.basename(path), path
|
data/lib/hobo/helper/shell.rb
CHANGED
@@ -37,6 +37,7 @@ module Hobo
|
|
37
37
|
opts = (args.size > 1 && args.last.is_a?(Hash)) ? args.pop : {}
|
38
38
|
opts = {
|
39
39
|
:capture => false,
|
40
|
+
:strip => true,
|
40
41
|
:indent => 0,
|
41
42
|
:realtime => false,
|
42
43
|
:env => {},
|
@@ -59,8 +60,13 @@ module Hobo
|
|
59
60
|
threads.push(::Thread.new do
|
60
61
|
chunk_line_iterator stream do |line|
|
61
62
|
line = ::Hobo.ui.color(line, :error) if key == :err
|
62
|
-
|
63
|
-
|
63
|
+
line_formatted = if opts[:strip]
|
64
|
+
line.strip
|
65
|
+
else
|
66
|
+
line
|
67
|
+
end
|
68
|
+
buffer.write("#{line_formatted}\n")
|
69
|
+
Hobo::Logging.logger.debug("helper.shell: #{line_formatted}")
|
64
70
|
line = yield line if block
|
65
71
|
print indent + line if opts[:realtime] && !line.nil?
|
66
72
|
end
|
@@ -78,7 +84,12 @@ module Hobo
|
|
78
84
|
|
79
85
|
raise ::Hobo::ExternalCommandError.new(args.join(" "), external.value.exitstatus, buffer) if external.value.exitstatus != 0 && !opts[:ignore_errors]
|
80
86
|
|
81
|
-
|
87
|
+
if opts[:capture]
|
88
|
+
return buffer.read unless opts[:strip]
|
89
|
+
return buffer.read.strip
|
90
|
+
else
|
91
|
+
return nil
|
92
|
+
end
|
82
93
|
end
|
83
94
|
end
|
84
95
|
end
|
data/lib/hobo/lib/s3/sync.rb
CHANGED
@@ -29,6 +29,7 @@ module Hobo
|
|
29
29
|
|
30
30
|
handle_s3_error do
|
31
31
|
opts = {
|
32
|
+
:delete => true,
|
32
33
|
:dry => false,
|
33
34
|
:progress => Hobo.method(:progress)
|
34
35
|
}.merge(opts)
|
@@ -68,6 +69,7 @@ module Hobo
|
|
68
69
|
|
69
70
|
opts[:progress].call(file, 0, size, :finish)
|
70
71
|
end
|
72
|
+
break unless opts[:delete]
|
71
73
|
|
72
74
|
delta[:remove].each do |file|
|
73
75
|
logger.debug("s3sync: Removing #{file}")
|
data/lib/hobo/lib/seed/seed.rb
CHANGED
@@ -9,33 +9,49 @@ module Hobo
|
|
9
9
|
@url = url
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def tags
|
13
|
+
tags = []
|
14
|
+
Dir.chdir @seed_path do
|
15
|
+
tag_output = Hobo::Helper.shell "git tag", :capture => true
|
16
|
+
tags = tag_output.split("\n")
|
17
|
+
end
|
18
|
+
tags
|
19
|
+
end
|
20
|
+
|
21
|
+
def export path, opts = {}
|
22
|
+
opts = {
|
23
|
+
:name => 'seed',
|
24
|
+
:ref => 'master'
|
25
|
+
}.merge(opts)
|
26
|
+
|
13
27
|
path = File.expand_path(path)
|
14
28
|
FileUtils.mkdir_p path
|
15
29
|
|
16
|
-
Hobo.ui.success "Exporting
|
30
|
+
Hobo.ui.success "Exporting #{opts[:name]} to #{path}"
|
17
31
|
|
18
32
|
tmp_path = Dir.mktmpdir("hobo-seed-export")
|
19
33
|
|
20
34
|
Dir.chdir @seed_path do
|
21
|
-
Hobo::Helper.shell "git clone . #{tmp_path}"
|
35
|
+
Hobo::Helper.shell "git clone --branch #{opts[:ref].shellescape} . #{tmp_path}"
|
22
36
|
end
|
23
37
|
|
24
38
|
Dir.chdir tmp_path do
|
39
|
+
Hobo::Helper.shell "git archive #{opts[:ref].shellescape} | tar -x -C #{path.shellescape}"
|
40
|
+
|
41
|
+
submodules = Hobo::Helper.shell "git submodule status", :capture => true, :strip => false
|
42
|
+
|
43
|
+
next if submodules.empty?
|
44
|
+
|
25
45
|
Hobo.ui.success "Cloning submodules"
|
26
46
|
Hobo::Helper.shell "git submodule update --init", :realtime => true, :indent => 2
|
27
47
|
|
28
|
-
Hobo.ui.success "Exporting seed"
|
29
|
-
Hobo::Helper.shell "git archive master | tar -x -C #{path.shellescape}"
|
30
|
-
|
31
48
|
# Export submodules
|
32
49
|
# git submodule foreach does not play nice on windows so we fake it here
|
33
|
-
submodules = Hobo::Helper.shell "git submodule status", :capture => true
|
34
50
|
submodules.split("\n").each do |line|
|
35
|
-
matches = line.match
|
51
|
+
matches = line.match /^[\s-][a-z0-9]+ (.+)/
|
36
52
|
next unless matches
|
37
53
|
submodule_path = matches[1]
|
38
|
-
Hobo.ui.success "Exporting '#{submodule_path}'
|
54
|
+
Hobo.ui.success "Exporting '#{submodule_path}' #{opts[:name]} submodule"
|
39
55
|
Hobo::Helper.shell "cd #{tmp_path}/#{submodule_path.shellescape} && git archive HEAD | tar -x -C #{path}/#{submodule_path.shellescape}"
|
40
56
|
end
|
41
57
|
end
|
data/lib/hobo/patches/slop.rb
CHANGED
@@ -46,4 +46,24 @@ class Slop
|
|
46
46
|
|
47
47
|
old_parse!(items, &block)
|
48
48
|
end
|
49
|
+
|
50
|
+
class Option
|
51
|
+
DEFAULT_OPTIONS[:key_delimiter] = '='
|
52
|
+
|
53
|
+
alias :old_value= :value=
|
54
|
+
def value=(new_value)
|
55
|
+
if config[:as].to_s.downcase == 'hash'
|
56
|
+
@value ||= {}
|
57
|
+
|
58
|
+
if new_value.respond_to?(:split)
|
59
|
+
new_array_hash = new_value.split(config[:delimiter], config[:limit]).map do |v|
|
60
|
+
v.split(config[:key_delimiter], 2)
|
61
|
+
end
|
62
|
+
@value.merge!(Hash[new_array_hash])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
self.old_value = new_value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
49
69
|
end
|
data/lib/hobo/tasks/deps.rb
CHANGED
data/lib/hobo/tasks/magento.rb
CHANGED
@@ -10,6 +10,197 @@ end
|
|
10
10
|
desc "Magento related tasks"
|
11
11
|
namespace :magento do
|
12
12
|
|
13
|
+
desc "Patch tasks"
|
14
|
+
namespace :patches do
|
15
|
+
def magento_path
|
16
|
+
unless @magento_path
|
17
|
+
files = locate('*app/Mage.php')
|
18
|
+
unless files.length > 0
|
19
|
+
raise Hobo::UserError.new "Could not find app/Mage.php in the git repository, this command should only be run for Magento projects"
|
20
|
+
end
|
21
|
+
|
22
|
+
/(?:(.*)\/)app\/Mage\.php/.match(files[0])
|
23
|
+
@magento_path = $1
|
24
|
+
end
|
25
|
+
@magento_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def detect_clean
|
29
|
+
status = shell('git status -z', :capture => true, :strip => false)
|
30
|
+
status.split("\u0000").each do |line|
|
31
|
+
match = line.match(/^([\s\S]{2})\s+(.*)$/)
|
32
|
+
next if match.nil?
|
33
|
+
|
34
|
+
if ![' ', '?'].include?($1[0]) || $2.start_with?(magento_path)
|
35
|
+
raise Hobo::UserError.new "Please remove all files from the git index, and stash all changes in '#{magento_path}' before continuing"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def detect_version
|
41
|
+
config_dirty = false
|
42
|
+
magento_version_file = "#{magento_path}/app/Mage.php"
|
43
|
+
|
44
|
+
if Hobo.project_config[:magento_edition].nil?
|
45
|
+
magento_edition = nil
|
46
|
+
if magento_version_file
|
47
|
+
args = [ "php -r \"require '#{magento_version_file}'; echo Mage::getEdition();\""]
|
48
|
+
|
49
|
+
magento_edition = vm_shell(*args, :capture => true).to_s.downcase
|
50
|
+
end
|
51
|
+
|
52
|
+
edition_options = ['community', 'enterprise', 'professional', 'go']
|
53
|
+
|
54
|
+
unless edition_options.include? magento_edition
|
55
|
+
raise Hobo::Error.new "Invalid Magento edition '#{magento_edition}' was found when calling Mage::getEdition(), skipping patches"
|
56
|
+
end
|
57
|
+
|
58
|
+
Hobo.project_config[:magento_edition] = magento_edition
|
59
|
+
config_dirty = true
|
60
|
+
end
|
61
|
+
|
62
|
+
if Hobo.project_config[:magento_version].nil?
|
63
|
+
magento_version = nil
|
64
|
+
if magento_version_file
|
65
|
+
args = [ "php -r \"require '#{magento_version_file}'; echo Mage::getVersion();\""]
|
66
|
+
|
67
|
+
magento_version = vm_shell(*args, :capture => true)
|
68
|
+
end
|
69
|
+
|
70
|
+
version_regex = /^\d+(\.\d+){3}$/
|
71
|
+
|
72
|
+
unless version_regex.match(magento_version)
|
73
|
+
raise Hobo::Error.new "Invalid Magento version '#{magento_version}' was found when calling Mage::getVersion(), skipping patches"
|
74
|
+
end
|
75
|
+
|
76
|
+
Hobo.project_config[:magento_version] = magento_version
|
77
|
+
config_dirty = true
|
78
|
+
end
|
79
|
+
|
80
|
+
if config_dirty
|
81
|
+
Hobo::Config::File.save(Hobo.project_config_file, Hobo.project_config)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def detect_tools
|
86
|
+
use_vm = shell("which which", :exit_status => true) != 0
|
87
|
+
|
88
|
+
tools = ['patch', 'sed']
|
89
|
+
tools_command = tools.map {|tool| "which #{tool}"}.join " && "
|
90
|
+
status = 0
|
91
|
+
|
92
|
+
unless use_vm
|
93
|
+
status = shell(tools_command, :exit_status => true)
|
94
|
+
use_vm = status != 0
|
95
|
+
end
|
96
|
+
|
97
|
+
if use_vm
|
98
|
+
status = vm_shell(tools_command, :exit_status => true)
|
99
|
+
end
|
100
|
+
|
101
|
+
if status != 0
|
102
|
+
raise Hobo::UserError.new "Please make sure '#{tools.join(',')}' is installed on your host or VM before continuing"
|
103
|
+
end
|
104
|
+
|
105
|
+
use_vm
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Apply patches to Magento"
|
109
|
+
task "apply" do
|
110
|
+
detect_clean
|
111
|
+
detect_version
|
112
|
+
|
113
|
+
config = Hobo.project_config
|
114
|
+
|
115
|
+
sync = Hobo::Lib::S3::Sync.new(Hobo.aws_credentials)
|
116
|
+
|
117
|
+
patches_path = "tools/patches"
|
118
|
+
incoming_path = "#{patches_path}/incoming"
|
119
|
+
|
120
|
+
Hobo.ui.success("Downloading Magento #{config[:magento_edition].capitalize} #{config[:magento_version]} patches")
|
121
|
+
changes = sync.sync(
|
122
|
+
"s3://inviqa-assets-magento/#{config[:magento_edition]}/patches/#{config[:magento_version]}/",
|
123
|
+
"#{incoming_path}/",
|
124
|
+
:delete => false
|
125
|
+
)
|
126
|
+
Hobo.ui.separator
|
127
|
+
|
128
|
+
use_vm = false
|
129
|
+
use_vm = detect_tools if Dir.glob("#{incoming_path}/*.sh").length > 0
|
130
|
+
|
131
|
+
patch_files = Dir.glob("#{incoming_path}/*.{sh,patch,diff}")
|
132
|
+
|
133
|
+
Hobo.ui.success("#{patch_files.length} new patches found")
|
134
|
+
|
135
|
+
Hobo.ui.separator
|
136
|
+
|
137
|
+
patch_files.each do |file|
|
138
|
+
filename = File.basename(file)
|
139
|
+
base_filename = File.basename(filename, File.extname(filename))
|
140
|
+
|
141
|
+
if File.exist?("#{patches_path}/#{filename}")
|
142
|
+
Hobo.ui.debug("Patch #{filename} has already been applied, so skipping it")
|
143
|
+
|
144
|
+
File.delete file
|
145
|
+
next
|
146
|
+
end
|
147
|
+
|
148
|
+
if File.exist?("#{patches_path}/#{base_filename}.skip")
|
149
|
+
File.delete file
|
150
|
+
next
|
151
|
+
end
|
152
|
+
|
153
|
+
Hobo.ui.success("Applying patch #{filename}")
|
154
|
+
|
155
|
+
yaml_file = File.join(File.dirname(file), base_filename + ".yaml")
|
156
|
+
|
157
|
+
metadata = {
|
158
|
+
'commit_message' => "Apply Magento patch #{filename}"
|
159
|
+
}
|
160
|
+
if File.exist?(yaml_file)
|
161
|
+
metadata = Hobo::Config::File.load(yaml_file)
|
162
|
+
end
|
163
|
+
|
164
|
+
Hobo.ui.info(metadata['description']) unless metadata['description'].nil?
|
165
|
+
|
166
|
+
if ['n','N','no'].include? Hobo.ui.ask('Do you want to apply this patch?')
|
167
|
+
File.delete file
|
168
|
+
File.write("#{patches_path}/#{base_filename}.skip", '')
|
169
|
+
|
170
|
+
shell "git add '#{patches_path}/#{base_filename}.skip'"
|
171
|
+
shell "git commit -m 'Add a skip file for patch #{filename}'"
|
172
|
+
next
|
173
|
+
end
|
174
|
+
|
175
|
+
if /\.sh$/.match(file)
|
176
|
+
File.rename file, "#{magento_path}/#{filename}"
|
177
|
+
file = "#{magento_path}/#{filename}"
|
178
|
+
if use_vm
|
179
|
+
vm_shell "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
|
180
|
+
else
|
181
|
+
shell "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
|
182
|
+
end
|
183
|
+
else
|
184
|
+
shell "git apply --directory #{magento_path} #{file}"
|
185
|
+
end
|
186
|
+
File.rename file, "#{patches_path}/#{filename}"
|
187
|
+
shell "git add #{magento_path}"
|
188
|
+
shell "git add #{patches_path}/#{filename}"
|
189
|
+
|
190
|
+
if File.exist?(yaml_file)
|
191
|
+
yaml_filename = File.basename(yaml_file)
|
192
|
+
File.rename yaml_file, "#{patches_path}/#{yaml_filename}"
|
193
|
+
shell "git add #{patches_path}/#{yaml_filename}"
|
194
|
+
end
|
195
|
+
shell "git commit -m #{metadata['commit_message'].shellescape}"
|
196
|
+
|
197
|
+
Hobo.ui.separator
|
198
|
+
end
|
199
|
+
|
200
|
+
Hobo.ui.success("Finished applying #{patch_files.length} patches")
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
13
204
|
desc "Setup script tasks"
|
14
205
|
namespace :'setup-scripts' do
|
15
206
|
desc "Run magento setup scripts"
|
data/lib/hobo/tasks/seed.rb
CHANGED
@@ -6,6 +6,7 @@ namespace :seed do
|
|
6
6
|
|
7
7
|
option '-g=', '--git-url=', 'Git repository for project'
|
8
8
|
option '-s=', '--seed=', 'Seed name or URL to use'
|
9
|
+
option '-d=', '--data=', 'Seed data to save to the project hobo configuration', :as => Hash
|
9
10
|
|
10
11
|
task :plant, [ :name ] do |t, args|
|
11
12
|
name = args[:name]
|
@@ -28,6 +29,11 @@ namespace :seed do
|
|
28
29
|
:url => Hobo::Lib::Seed::Seed.name_to_url(seed_name)
|
29
30
|
}
|
30
31
|
|
32
|
+
unless t.opts[:data].nil?
|
33
|
+
data = t.opts[:data].inject({}){|hash,(k,v)| hash[k.to_sym] = v; hash}
|
34
|
+
config.merge!(data)
|
35
|
+
end
|
36
|
+
|
31
37
|
seed = Hobo::Lib::Seed::Seed.new(
|
32
38
|
File.join(Hobo.seed_cache_path, config[:seed][:name]),
|
33
39
|
config[:seed][:url]
|
data/lib/hobo/ui.rb
CHANGED
@@ -71,6 +71,39 @@ module Hobo
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
def ask_choice question, choices, opts = {}
|
75
|
+
unless @interactive
|
76
|
+
raise Hobo::NonInteractiveError.new(question) if opts[:default].nil?
|
77
|
+
return opts[:default].to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
question = "#{question} [#{opts[:default]}]" if opts[:default]
|
81
|
+
question += ":"
|
82
|
+
info question
|
83
|
+
|
84
|
+
choice_map = {}
|
85
|
+
choices.to_enum.with_index(1) do |choice, index|
|
86
|
+
choice_map[index.to_s] = choice
|
87
|
+
info "#{index}] #{choice}"
|
88
|
+
end
|
89
|
+
|
90
|
+
begin
|
91
|
+
answer = @out.ask("? ") do |q|
|
92
|
+
q.validate = lambda do |a|
|
93
|
+
s = a.strip
|
94
|
+
s.empty? || (choice_map.keys + choices).include?(s)
|
95
|
+
end
|
96
|
+
q.readline
|
97
|
+
end
|
98
|
+
answer = answer.to_s
|
99
|
+
answer = choice_map[answer] if /^\d+$/.match(answer.strip)
|
100
|
+
answer.strip.empty? ? opts[:default].to_s : answer.strip
|
101
|
+
rescue EOFError
|
102
|
+
Hobo.ui.info ""
|
103
|
+
""
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
74
107
|
def section title
|
75
108
|
Hobo.ui.title title
|
76
109
|
yield
|
data/lib/hobo/version.rb
CHANGED
@@ -17,5 +17,7 @@ describe Hobo::Helper do
|
|
17
17
|
it "should throw Hobo::ExternalCommandError on non-zero exit code"
|
18
18
|
it "should colour stderr output with red"
|
19
19
|
it "should set ENV args for command if specified with :env"
|
20
|
+
it "should strip leading and trailing whitespace in captured output"
|
21
|
+
it "should preserve whitespace in captured output if :strip false"
|
20
22
|
end
|
21
23
|
end
|
@@ -11,6 +11,7 @@ describe Hobo::Lib::S3::Sync do
|
|
11
11
|
it "should add files that only exist in source"
|
12
12
|
it "should update files that have changed"
|
13
13
|
it "should remove files that do not exist in source"
|
14
|
+
it "should keep files that do not exist in source if :delete false"
|
14
15
|
it "should update progress as files are transferred"
|
15
16
|
end
|
16
17
|
end
|
@@ -26,6 +26,12 @@ describe Hobo::Lib::Seed::Seed do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def tag_repo path, tag
|
30
|
+
Dir.chdir path do
|
31
|
+
`git tag #{tag}`
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
29
35
|
describe "update", :integration do
|
30
36
|
it "should fetch the seed if it does not exist locally" do
|
31
37
|
# Create test repo as seed remote
|
@@ -75,6 +81,35 @@ describe Hobo::Lib::Seed::Seed do
|
|
75
81
|
end
|
76
82
|
|
77
83
|
it "should export seed submodules to the specified directory"
|
84
|
+
it "should export a specifified git :ref"
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "tags" do
|
88
|
+
it "should return no tags if the repository doesn't have any" do
|
89
|
+
# Create test repo as seed remote
|
90
|
+
remote_seed_path = File.join(tmp_dir, "seed_5")
|
91
|
+
create_test_repo remote_seed_path, "version_test"
|
92
|
+
|
93
|
+
# Update seed and export
|
94
|
+
seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_3', remote_seed_path
|
95
|
+
seed.update
|
96
|
+
|
97
|
+
seed.tags.should eq []
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should return a list of tags if there are any" do
|
101
|
+
# Create test repo as seed remote
|
102
|
+
remote_seed_path = File.join(tmp_dir, "seed_5")
|
103
|
+
create_test_repo remote_seed_path, "version_test"
|
104
|
+
tag_repo remote_seed_path, "1.2.3"
|
105
|
+
tag_repo remote_seed_path, "1.2.4"
|
106
|
+
|
107
|
+
# Update seed and export
|
108
|
+
seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_3', remote_seed_path
|
109
|
+
seed.update
|
110
|
+
|
111
|
+
seed.tags.should eq ['1.2.3', '1.2.4']
|
112
|
+
end
|
78
113
|
end
|
79
114
|
|
80
115
|
describe "version", :integration do
|
data/spec/hobo/ui_spec.rb
CHANGED
@@ -62,6 +62,42 @@ describe Hobo::Ui do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
describe "ask_choice" do
|
66
|
+
it "should return default if in non-interactive mode" do
|
67
|
+
ui = test_ui()
|
68
|
+
ui.interactive = false
|
69
|
+
ui.ask_choice("Question", ['default', 'non-default'], :default => "default").should match "default"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should raise error if no default provided in non-interactive mode" do
|
73
|
+
ui = test_ui(:answer => "Answer\n")
|
74
|
+
ui.interactive = false
|
75
|
+
expect { ui.ask_choice("Question", ['one', 'two']) }.to raise_exception(Hobo::NonInteractiveError)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should format prompt to include default if provided"
|
79
|
+
|
80
|
+
it "should give a choice prompt with each option in"
|
81
|
+
|
82
|
+
it "should convert a number choice to its value if given" do
|
83
|
+
test_ui(:answer => "2\n").ask_choice("Question", ['default', 'non-default'], :default => "default").should match "non-default"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should use default answer if given answer is empty" do
|
87
|
+
test_ui(:answer => "\n").ask_choice("Question", ['default', 'non-default'], :default => "default").should match "default"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should handle stdin EOF (Ctrl+d)" do
|
91
|
+
test_ui(:eof => true).ask_choice("Question", ['default', 'non-default']).should be_empty
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should always return an instance of String" do
|
95
|
+
test_ui(:answer => "Answer\n").ask_choice("Question", ['Answer']).should be_an_instance_of String
|
96
|
+
test_ui(:answer => "\n").ask_choice("Question", ['Answer'], :default => "").should be_an_instance_of String
|
97
|
+
test_ui(:answer => "\x04").ask_choice("Question", ['Answer']).should be_an_instance_of String
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
65
101
|
describe "color" do
|
66
102
|
it "should format message with ansi style" do
|
67
103
|
ui = test_ui
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobo-inviqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Simons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|