This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
133 lines (120 loc) · 2.98 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Utility class that calls forward to WebBlocks rake
require 'pathname'
class WebBlocks
attr_accessor :path
attr_accessor :local
def initialize(path)
@path = path
@local = Local.new Pathname.new(__FILE__).parent, Pathname.new(__FILE__).parent.parent
end
def rake(command = '')
Dir.chdir @path do
sh "rake #{command} -- --config=#{Pathname.new(__FILE__).parent}/Rakefile-config.rb"
end
end
class Local
def initialize src_dir, build_dir
@src_dir = src_dir
@build_dir = build_dir
end
def log_task name
log "Executing task: #{name}"
end
def log message
puts "[Local] #{message}"
end
def move from, to
FileUtils.mkdir_p File.dirname "#{@build_dir}/#{to}"
FileUtils.copy "#{@src_dir}/#{from}", "#{@build_dir}/#{to}"
end
def move_sub from, to
Dir.foreach("#{@src_dir}/#{from}") do |item|
next if item == '.' or item == '..'
FileUtils.mkdir_p "#{@build_dir}/#{to}"
FileUtils.copy "#{@src_dir}/#{from}/#{item}", "#{@build_dir}/#{to}"
end
end
def remove path
FileUtils.rm_rf "#{@build_dir}/#{path}"
end
def build_fonts
log "Executing task: build_fonts"
move_sub "font", "font"
end
def build_all
build_fonts
end
def clean
clean_fonts
end
def clean_fonts
log "Executing task: clean_fonts"
remove "font"
end
end
end
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Set path to WebBlocks
webblocks_path = Pathname.new(__FILE__).realpath.parent + "_blocks"
blocks = WebBlocks.new webblocks_path
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Define the valid Rake tasks that will be call-forwarded
include Rake::DSL
task :default => [:_init] do
blocks.rake
blocks.local.build_fonts
end
task :init => [:_init] do
blocks.rake 'init'
end
task :build => [:_init] do
blocks.rake 'build'
end
task :build_all => [:_init] do
blocks.rake 'build_all'
blocks.local.build_all
end
task :build_css => [:_init] do
blocks.rake 'build_css'
end
task :build_fonts => [:_init] do
blocks.local.build_fonts
end
task :build_img => [:_init] do
blocks.rake 'build_img'
end
task :build_js => [:_init] do
blocks.rake 'build_js'
end
task :clean => [:_init] do
blocks.rake 'clean'
blocks.local.clean
end
task :clean_packages => [:_init] do
blocks.rake 'clean_packages'
end
task :clean_all => [:_init] do
blocks.rake 'clean_all'
blocks.local.clean_fonts
end
task :reset_packages => [:_init] do
blocks.rake 'reset_packages'
end
task :reset => [:_init] do
blocks.rake 'reset'
end
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Specialized task that pre-initializes
task :_init do
IO.popen "git rev-parse --show-toplevel" do |io|
Dir.chdir io.gets.strip do
sh "git submodule init"
sh "git submodule update"
end
end
Dir.chdir webblocks_path do
sh "bundle"
sh "npm install"
end
end