forked from WiStudios/spree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
98 lines (83 loc) · 2.16 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require 'rake'
require 'rubygems/package_task'
require 'thor/group'
begin
require 'spree/testing_support/common_rake'
rescue LoadError
raise "Could not find spree/testing_support/common_rake. You need to run this command using Bundler."
end
SPREE_GEMS = %w(core api cli emails sample).freeze
task default: :test
desc "Runs all tests in all Spree engines"
task test: :test_app do
SPREE_GEMS.each do |gem_name|
Dir.chdir("#{File.dirname(__FILE__)}/#{gem_name}") do
sh 'rspec'
end
end
end
desc "Generates a dummy app for testing for every Spree engine"
task :test_app do
SPREE_GEMS.each do |gem_name|
Dir.chdir("#{File.dirname(__FILE__)}/#{gem_name}") do
sh 'rake test_app'
end
end
end
desc "clean the whole repository by removing all the generated files"
task :clean do
rm_f "Gemfile.lock"
rm_rf "sandbox"
rm_rf "pkg"
SPREE_GEMS.each do |gem_name|
rm_f "#{gem_name}/Gemfile.lock"
rm_rf "#{gem_name}/pkg"
rm_rf "#{gem_name}/spec/dummy"
end
end
namespace :gem do
def version
require 'spree/core/version'
Spree.version
end
def for_each_gem
SPREE_GEMS.each do |gem_name|
yield "pkg/spree_#{gem_name}-#{version}.gem"
end
yield "pkg/spree-#{version}.gem"
end
desc "Build all spree gems"
task :build do
pkgdir = File.expand_path("../pkg", __FILE__)
FileUtils.mkdir_p pkgdir
SPREE_GEMS.each do |gem_name|
Dir.chdir(gem_name) do
sh "gem build spree_#{gem_name}.gemspec"
mv "spree_#{gem_name}-#{version}.gem", pkgdir
end
end
sh "gem build spree.gemspec"
mv "spree-#{version}.gem", pkgdir
end
desc "Install all spree gems"
task install: :build do
for_each_gem do |gem_path|
Bundler.with_clean_env do
sh "gem install #{gem_path}"
end
end
end
desc "Release all gems to rubygems"
task release: :build do
sh "git tag -a -m \"Version #{version}\" v#{version}"
for_each_gem do |gem_path|
sh "gem push '#{gem_path}'"
end
end
end
desc "Creates a sandbox application for simulating the Spree code in a deployed Rails app"
task :sandbox do
Bundler.with_clean_env do
exec("bin/sandbox.sh")
end
end