hem 1.0.1.beta6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +32 -45
  3. data/Hemfile +4 -2
  4. data/README.md +4 -0
  5. data/bin/hem +5 -6
  6. data/hem.gemspec +15 -15
  7. data/lib/hem.rb +47 -45
  8. data/lib/hem/asset_applicators/files.rb +1 -1
  9. data/lib/hem/cli.rb +36 -29
  10. data/lib/hem/error_handlers/debug.rb +1 -1
  11. data/lib/hem/error_handlers/friendly.rb +3 -3
  12. data/lib/hem/errors.rb +23 -12
  13. data/lib/hem/help_formatter.rb +12 -3
  14. data/lib/hem/helper/argument_parser.rb +30 -0
  15. data/lib/hem/helper/command.rb +2 -1
  16. data/lib/hem/helper/file_locator.rb +34 -7
  17. data/lib/hem/helper/shell.rb +0 -1
  18. data/lib/hem/helper/vm_command.rb +2 -2
  19. data/lib/hem/lib/host_check/vagrant.rb +2 -3
  20. data/lib/hem/lib/s3/sync.rb +2 -2
  21. data/lib/hem/lib/seed/project.rb +10 -13
  22. data/lib/hem/lib/seed/replacer.rb +9 -31
  23. data/lib/hem/lib/seed/template.rb +21 -0
  24. data/lib/hem/lib/vm/inspector.rb +1 -1
  25. data/lib/hem/patches/deepstruct.rb +4 -0
  26. data/lib/hem/patches/rake.rb +42 -11
  27. data/lib/hem/plugins.rb +129 -0
  28. data/lib/hem/setup.rb +6 -0
  29. data/lib/hem/tasks.rb +15 -0
  30. data/lib/hem/tasks/deps.rb +13 -14
  31. data/lib/hem/tasks/exec.rb +4 -2
  32. data/lib/hem/tasks/magento.rb +13 -275
  33. data/lib/hem/tasks/mysql.rb +16 -0
  34. data/lib/hem/tasks/ops.rb +2 -1
  35. data/lib/hem/tasks/plugin.rb +16 -0
  36. data/lib/hem/tasks/redis.rb +26 -0
  37. data/lib/hem/tasks/seed.rb +4 -2
  38. data/lib/hem/tasks/self.rb +7 -6
  39. data/lib/hem/tasks/tools.rb +1 -1
  40. data/lib/hem/tasks/vm.rb +8 -16
  41. data/lib/hem/util.rb +6 -16
  42. data/lib/hem/version.rb +12 -1
  43. data/lib/hobo/tasks/magento.rb +2 -1
  44. data/spec/hem/cli_spec.rb +1 -0
  45. data/spec/hem/helpers/argument_parser_spec.rb +57 -0
  46. data/spec/hem/lib/seed/project_spec.rb +1 -0
  47. data/spec/hem/lib/seed/replacer_spec.rb +12 -13
  48. data/spec/hem/lib/seed/seed_spec.rb +1 -0
  49. metadata +50 -42
  50. data/lib/hem/lib/github/api.rb +0 -48
  51. data/lib/hem/lib/github/client.rb +0 -52
  52. data/lib/hem/tasks/pr.rb +0 -45
@@ -13,11 +13,8 @@ module Rake
13
13
  old_task = Rake.application.instance_variable_get('@tasks').delete(task_name)
14
14
 
15
15
  Hem::Metadata.to_store task_name
16
- task task_name => old_task.prerequisites do
16
+ task task_name => old_task.prerequisites | new_tasks do
17
17
  new_task.call unless new_task.nil?
18
- new_tasks.each do |t|
19
- Rake::Task[t].invoke
20
- end
21
18
  old_task.invoke
22
19
  end
23
20
  end
@@ -25,13 +22,13 @@ module Rake
25
22
  def after(task_name, new_tasks = nil, &new_task)
26
23
  task_name = task_name.to_s
27
24
  new_tasks = [new_tasks].flatten.compact
28
- old_task = Rake.application.instance_variable_get('@tasks').delete(task_name)
29
25
 
30
- Hem::Metadata.to_store task_name
31
- task task_name => old_task.prerequisites do
32
- old_task.invoke
33
- new_tasks.each do |t|
34
- Rake::Task[t].invoke
26
+ task = Rake::Task[task_name]
27
+ task.enhance do
28
+ new_tasks.each do |post_task|
29
+ post = Rake.application.lookup(post_task, task.scope)
30
+ raise ArgumentError, "Task #{post_task.inspect} not found" unless post
31
+ post.invoke
35
32
  end
36
33
  new_task.call unless new_task.nil?
37
34
  end
@@ -48,6 +45,25 @@ module Rake
48
45
  Rake::Task[task].invoke(*args, &block)
49
46
  end
50
47
 
48
+ def argument name, options = {}
49
+ opts = {
50
+ optional: false,
51
+ as: String,
52
+ }.merge(options)
53
+ Hem::Metadata.store[:arg_list] ||= {}
54
+
55
+ if Hem::Metadata.store[:arg_list].length > 0
56
+ last_arg = Hem::Metadata.store[:arg_list].values.last
57
+ if last_arg[:optional] && !opts[:optional]
58
+ raise 'Cannot have mandatory arguments after optional arguments'
59
+ elsif last_arg[:as] == Array
60
+ raise 'Cannot add any arguments after an array argument'
61
+ end
62
+ end
63
+
64
+ Hem::Metadata.store[:arg_list][name] = opts
65
+ end
66
+
51
67
  def hidden value = true
52
68
  Hem::Metadata.store[:hidden] = value
53
69
  end
@@ -59,11 +75,20 @@ module Rake
59
75
  def task *args, &block
60
76
  name = args[0].is_a?(Hash) ? args[0].keys.first.to_s : args[0]
61
77
  scoped_name = Rake.application.current_scope.path_with_task_name(name).to_s
78
+ Hem::Metadata.store[:arg_list] ||= {}
62
79
 
63
- [:opts, :desc, :long_desc, :hidden, :project_only].each do |meta|
80
+ args[1..-1].each do |name|
81
+ argument name, optional: true
82
+ end if args.length > 1
83
+
84
+ [:opts, :desc, :long_desc, :hidden, :project_only, :arg_list].each do |meta|
64
85
  Hem::Metadata.add scoped_name, meta
65
86
  end
66
87
 
88
+ if Hem::Metadata.store[:arg_list]
89
+ args = [args[0], *Hem::Metadata.store[:arg_list].keys]
90
+ end
91
+
67
92
  Hem::Metadata.reset_store
68
93
 
69
94
  Hem::Logging.logger.debug("Added metadata to #{scoped_name} -- #{Hem::Metadata.metadata[scoped_name]}")
@@ -94,6 +119,12 @@ module Rake
94
119
 
95
120
  _old_namespace(name, &block)
96
121
  end
122
+
123
+ def plugins setup = true, &block
124
+ Hem.plugins.define &block if block_given?
125
+ Hem.plugins.setup if setup
126
+ Hem.plugins
127
+ end
97
128
  end
98
129
  end
99
130
 
@@ -0,0 +1,129 @@
1
+ module Hem
2
+ class << self
3
+ attr_accessor :plugins
4
+ end
5
+
6
+ class Plugins
7
+
8
+ def initialize(path, gemfile, lockfile = nil)
9
+ @is_setup = false
10
+ @gemfile = gemfile
11
+ if lockfile.nil?
12
+ @lockfile = "#{gemfile}.lock"
13
+ else
14
+ @lockfile = lockfile
15
+ end
16
+
17
+ @old_root = Bundler.method(:root)
18
+ def Bundler.root(path = nil)
19
+ @root = Pathname.new(path) if path
20
+ @root
21
+ end
22
+
23
+ # ensure Bundler doesn't get it's settings from the project
24
+ def Bundler.settings
25
+ return @settings if defined?(@settings)
26
+ @settings = Bundler::Settings.new
27
+ end
28
+
29
+ # ensure Bundler doesn't use a project's cache
30
+ def Bundler.app_cache
31
+ Bundler.rubygems.gem_cache.first
32
+ end
33
+
34
+ Bundler.root path
35
+ @builder = Class.new(Bundler::Dsl) do
36
+ define_method(:gemfile_root) do
37
+ Bundler.root
38
+ end
39
+ end.new
40
+ @definition = nil
41
+ end
42
+
43
+ def setup
44
+ raise Hem::PluginsAlreadySetupError if @is_setup
45
+ @is_setup = true
46
+ install unless check
47
+ require
48
+ end
49
+
50
+ def setup?
51
+ @is_setup
52
+ end
53
+
54
+ def define(&block)
55
+ raise Hem::PluginsAlreadySetupError if @is_setup
56
+ @builder.instance_eval &block
57
+
58
+ self
59
+ end
60
+
61
+ def check
62
+ return false unless File.exist?(File.join(Bundler.root, @lockfile))
63
+ begin
64
+ missing_specs = definition.missing_specs.any?
65
+ rescue Bundler::GemNotFound, Bundler::VersionConflict, Bundler::GitError
66
+ missing_specs = true
67
+ end
68
+ return !missing_specs
69
+ end
70
+
71
+ def install(options = {})
72
+ return self if definition.dependencies.empty?
73
+
74
+ opts = options.dup
75
+ opts[:system] = true
76
+ ui = opts.delete(:ui) { Bundler::UI::Shell.new }
77
+
78
+ Bundler.ui = ui
79
+ begin
80
+ ENV["BUNDLE_GEMFILE"] = File.join(Bundler.root, @gemfile)
81
+ Bundler::Installer.install(Bundler.root, definition, opts)
82
+ ENV.delete("BUNDLE_GEMFILE")
83
+ Bundler::Installer.post_install_messages.each do |name, message|
84
+ Hem.ui.info "Post-install message from #{name}:\n#{message}"
85
+ end
86
+ rescue Bundler::GemNotFound => e
87
+ raise e, e.message.sub('Gemfile', 'Hemfile'), e.backtrace
88
+ rescue Bundler::GitError => e
89
+ raise e, e.message.sub('bundle install', 'hem plugin install'), e.backtrace
90
+ end
91
+
92
+ self
93
+ end
94
+
95
+ def update(unlock = true, options = {})
96
+ opts = options.dup
97
+ opts['update'] = true
98
+ definition(unlock)
99
+ install(opts)
100
+ end
101
+
102
+ def require
103
+ runtime = Bundler::Runtime.new(nil, definition)
104
+ def runtime.clean_load_path(*); end
105
+ def runtime.setup_environment(*); end;
106
+ def runtime.lock(*); end;
107
+
108
+ runtime.setup
109
+ definition.lock(File.join(Bundler.root, @lockfile), :preserve_bundled_with => true) unless @lockfile === false
110
+
111
+ runtime.require
112
+
113
+ self
114
+ end
115
+
116
+ private
117
+
118
+ def definition(unlock = nil)
119
+ @definition = nil if unlock
120
+ return @definition unless @definition.nil?
121
+
122
+ unlock = {} if unlock.nil?
123
+ @definition = @builder.to_definition(@lockfile, unlock)
124
+ @definition.validate_ruby!
125
+
126
+ @definition
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ require_relative 'version'
3
+ require_relative 'plugins'
4
+
5
+ $:.push File.expand_path(File.join("..", ".."), __FILE__)
6
+ require 'hem'
@@ -0,0 +1,15 @@
1
+ require_relative 'tasks/assets'
2
+ require_relative 'tasks/config'
3
+ require_relative 'tasks/deps'
4
+ require_relative 'tasks/exec'
5
+ require_relative 'tasks/mysql'
6
+ require_relative 'tasks/ops'
7
+ require_relative 'tasks/plugin'
8
+ require_relative 'tasks/redis'
9
+ require_relative 'tasks/seed'
10
+ require_relative 'tasks/self'
11
+ require_relative 'tasks/shell_init'
12
+ require_relative 'tasks/system'
13
+ require_relative 'tasks/system/completions'
14
+ require_relative 'tasks/tools'
15
+ require_relative 'tasks/vm'
@@ -4,7 +4,7 @@ namespace :deps do
4
4
 
5
5
  desc "Install Gem dependencies"
6
6
  task :gems do
7
- locate "*Gemfile" do
7
+ locate "Gemfile" do
8
8
  required = shell("bundle check", :exit_status => true) != 0
9
9
  if required
10
10
  Hem.ui.title "Installing Gem dependencies"
@@ -46,7 +46,7 @@ namespace :deps do
46
46
  end
47
47
 
48
48
  if !complete
49
- run_command *args
49
+ run *args
50
50
  end
51
51
 
52
52
  Hem.ui.success "Composer dependencies installed"
@@ -57,10 +57,9 @@ namespace :deps do
57
57
  end
58
58
 
59
59
  desc "Install vagrant plugins"
60
- task :vagrant_plugins => [ "deps:gems" ] do
61
- require 'semantic'
62
- plugins = shell "vagrant plugin list", :capture => true
63
- locate "*Vagrantfile" do
60
+ task :vagrant_plugins do
61
+ raw_plugins = shell "vagrant plugin list", :capture => true
62
+ locate "Vagrantfile" do
64
63
  to_install = {}
65
64
  File.read("Vagrantfile").split("\n").each do |line|
66
65
  if line.match(/#\s*(?:Hem|Hobo)\.(vagrant_plugin.*)/)
@@ -73,18 +72,18 @@ namespace :deps do
73
72
  end
74
73
 
75
74
  plugins = Hash[
76
- plugins.scan(/^([^\s]+)\s+\(([^,\)]+)(?:,[^\)]+)?\)$/).map do |plugin, version|
77
- [plugin, Semantic::Version.new(version)]
75
+ raw_plugins.scan(/^([^\s]+)\s+\(([^,\)]+)(?:,[^\)]+)?\)$/).map do |plugin, version|
76
+ [plugin, version]
78
77
  end
79
78
  ]
80
79
 
81
80
  to_install.each do |plugin, constraint|
82
- next if plugins.has_key?(plugin) && (constraint.nil? || plugins[plugin].satisfies(constraint))
83
- Hem.ui.title "Installing vagrant plugin: #{plugin}#{constraint && " #{constraint}"}"
81
+ next if plugins.has_key?(plugin) && (constraint.nil? || constraint.match?(plugin, plugins[plugin]))
82
+ Hem.ui.title "Installing vagrant plugin: #{plugin}#{constraint.nil? ? '' : " #{constraint.requirement.to_s}"}"
84
83
  args = ["vagrant", "plugin", "install", plugin]
85
84
  if constraint
86
85
  args << '--plugin-version'
87
- args << constraint
86
+ args << constraint.requirement.to_s
88
87
  end
89
88
  shell *args, :realtime => true, :indent => 2
90
89
  Hem.ui.separator
@@ -94,7 +93,7 @@ namespace :deps do
94
93
 
95
94
  desc "Install chef dependencies"
96
95
  task :chef => [ "deps:gems" ] do
97
- locate "*Cheffile" do
96
+ locate "Cheffile" do
98
97
  Hem.ui.title "Installing chef dependencies via librarian"
99
98
  bundle_shell "librarian-chef", "install", "--verbose", :realtime => true, :indent => 2 do |line|
100
99
  line =~ /Installing.*</ ? line.strip + "\n" : nil
@@ -102,9 +101,9 @@ namespace :deps do
102
101
  Hem.ui.separator
103
102
  end
104
103
 
105
- locate "*Berksfile" do
104
+ locate "Berksfile" do
106
105
  Hem.ui.title "Installing chef dependencies via berkshelf"
107
- executor = (shell("bash -c 'which berks'", :capture => true).strip =~ /chefdk/) ?
106
+ executor = (shell("bundle show berkshelf", exit_status: true) > 0) ?
108
107
  lambda { |*args| shell *args } :
109
108
  lambda { |*args| bundle_shell *args }
110
109
 
@@ -1,3 +1,5 @@
1
- task 'exec' do
2
- exec(*$HEM_ARGV)
1
+ argument :command
2
+ argument 'args', optional: true, default: {}, as: Array
3
+ task 'exec' do |task, args|
4
+ exec [args[:command], args[:command]], *args[:args]
3
5
  end
@@ -1,281 +1,19 @@
1
- namespace :tools do
2
- desc "Fetches the n98-magerun utility"
3
- task :n98magerun do
4
- FileUtils.mkdir_p "bin"
5
- run_command '"wget" --no-check-certificate "https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar" -O bin/n98-magerun.phar'
6
- FileUtils.chmod 0755, "bin/n98-magerun.phar"
7
- end
1
+ unless defined? HOBO_TASKS_MAGENTO_DEPRECATION
2
+ Hem.ui.warning "require 'hem/tasks/magento' in #{Hem.project_dsl_file} is deprecated, and will be removed in a future release."
8
3
  end
9
4
 
10
- desc "Magento related tasks"
11
- namespace :magento do
5
+ Hem.ui.warning <<-eos
6
+ Please replace with:
12
7
 
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 Hem::UserError.new "Could not find app/Mage.php in the git repository, this command should only be run for Magento projects"
20
- end
8
+ Hem.require_version '~> 1.1'
21
9
 
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 Hem::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 Hem.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 = run_command(*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 Hem::Error.new "Invalid Magento edition '#{magento_edition}' was found when calling Mage::getEdition(), skipping patches"
56
- end
57
-
58
- Hem.project_config[:magento_edition] = magento_edition
59
- config_dirty = true
60
- end
61
-
62
- if Hem.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 = run_command(*args, :capture => true)
68
- end
69
-
70
- version_regex = /^\d+(\.\d+){3}$/
71
-
72
- unless version_regex.match(magento_version)
73
- raise Hem::Error.new "Invalid Magento version '#{magento_version}' was found when calling Mage::getVersion(), skipping patches"
74
- end
75
-
76
- Hem.project_config[:magento_version] = magento_version
77
- config_dirty = true
78
- end
79
-
80
- if config_dirty
81
- Hem::Config::File.save(Hem.project_config_file, Hem.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 = run_command(tools_command, :exit_status => true)
99
- end
100
-
101
- if status != 0
102
- raise Hem::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 = Hem.project_config
114
-
115
- sync = Hem::Lib::S3::Sync.new(Hem.aws_credentials)
116
-
117
- patches_path = "#{Hem.project_path}/tools/patches"
118
- incoming_path = "#{patches_path}/incoming"
119
-
120
- Hem.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
- Hem.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
- Hem.ui.success("#{patch_files.length} new patches found")
134
-
135
- Hem.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
- Hem.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
- Hem.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 = Hem::Config::File.load(yaml_file)
162
- end
163
-
164
- Hem.ui.info(metadata['description']) unless metadata['description'].nil?
165
-
166
- patch_options = %w( yes never skip )
167
- answer = Hem.ui.ask_choice('Do you want to apply this patch?', patch_options)
168
-
169
- if answer == 'skip'
170
- next
171
- end
172
-
173
- if answer == 'never'
174
- File.delete file
175
- File.write("#{patches_path}/#{base_filename}.skip", '')
176
-
177
- shell "git add '#{patches_path}/#{base_filename}.skip'"
178
- shell "git commit -m 'Add a skip file for patch #{filename}'"
179
- next
180
- end
181
-
182
- if /\.sh$/.match(file)
183
- File.rename file, "#{magento_path}/#{filename}"
184
- file = "#{magento_path}/#{filename}"
185
- if use_vm
186
- run_command "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
187
- else
188
- shell "cd #{magento_path} && sh #{filename}", :realtime => true, :indent => 2
189
- end
190
- else
191
- shell "git apply --directory #{magento_path} #{file}"
192
- end
193
- File.rename file, "#{patches_path}/#{filename}"
194
- shell "git add #{magento_path}"
195
- shell "git add #{patches_path}/#{filename}"
196
-
197
- if File.exist?(yaml_file)
198
- yaml_filename = File.basename(yaml_file)
199
- File.rename yaml_file, "#{patches_path}/#{yaml_filename}"
200
- shell "git add #{patches_path}/#{yaml_filename}"
201
- end
202
- shell "git commit -m #{metadata['commit_message'].shellescape}"
203
-
204
- Hem.ui.separator
205
- end
206
-
207
- Hem.ui.success("Finished applying #{patch_files.length} patches")
208
- end
209
- end
210
-
211
- desc "Setup script tasks"
212
- namespace :'setup-scripts' do
213
- desc "Run magento setup scripts"
214
- task :run => ['tools:n98magerun'] do
215
- Hem.ui.success "Running setup scripts"
216
- run_command("bin/n98-magerun.phar cache:clean config", :realtime => true, :indent => 2)
217
- run_command("bin/n98-magerun.phar sys:setup:incremental -n", :realtime => true, :indent => 2)
218
- Hem.ui.separator
219
- end
220
- end
221
-
222
- desc "Cache tasks"
223
- namespace :cache do
224
- desc "Clear cache"
225
- task :clear => ['tools:n98magerun'] do
226
- Hem.ui.success "Clearing magento cache"
227
- run_command("bin/n98-magerun.phar cache:flush", :realtime => true, :indent => 2)
228
- Hem.ui.separator
229
- end
230
- end
231
-
232
- desc "Configuration related tasks"
233
- namespace :config do
234
- desc "Configure magento base URLs"
235
- task :'configure-urls' => ['tools:n98magerun'] do
236
- Hem.ui.success "Configuring magento base urls"
237
- domain = Hem.project_config.hostname
238
- run_command("bin/n98-magerun.phar config:set web/unsecure/base_url 'http://#{domain}/'", :realtime => true, :indent => 2)
239
- run_command("bin/n98-magerun.phar config:set web/secure/base_url 'https://#{domain}/'", :realtime => true, :indent => 2)
240
- Hem.ui.separator
241
- end
242
-
243
- desc "Enable magento errors"
244
- task :'enable-errors' do
245
- error_config = File.join(Hem.project_path, 'public/errors/local.xml')
246
-
247
- FileUtils.cp(
248
- error_config + ".sample",
249
- error_config
250
- ) unless File.exists? error_config
251
- end
252
-
253
- desc "Create admin user"
254
- task :'create-admin-user' do
255
- initialized = run_command("bin/n98-magerun.phar admin:user:list | grep admin", :exit_status => true) == 0
256
- unless initialized
257
- Hem.ui.success "Creating admin user"
258
- run_command("bin/n98-magerun.phar admin:user:create admin '' admin admin admin", :realtime => true, :indent => 2)
259
- Hem.ui.separator
260
- end
261
- end
262
-
263
- desc "Enable rewrites"
264
- task :'enable-rewrites' do
265
- Hem.ui.success "Enabling rewrites"
266
- run_command("bin/n98-magerun.phar config:set web/seo/use_rewrites 1", :realtime => true, :indent => 2)
267
- Hem.ui.separator
268
- end
269
- end
10
+ plugins do
11
+ source 'https://rubygems.org'
12
+ gem 'hem-tasks-magento1', '~> 1.0'
13
+ end
14
+ eos
270
15
 
271
- desc "Initializes magento specifics on the virtual machine after a fresh build"
272
- task :'initialize-vm' => [
273
- 'magento:config:enable-errors',
274
- 'tools:n98magerun',
275
- 'magento:setup-scripts:run',
276
- 'magento:config:configure-urls',
277
- 'magento:config:create-admin-user',
278
- 'magento:config:enable-rewrites',
279
- 'magento:cache:clear'
280
- ]
16
+ plugins do
17
+ source 'https://rubygems.org'
18
+ gem 'hem-tasks-magento1', '~> 1.0'
281
19
  end