This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Assetfile
157 lines (120 loc) · 3.18 KB
/
Assetfile
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
require "rake-pipeline-web-filters"
require "json"
require "uglifier"
class EmberProductionFilter < Rake::Pipeline::Filter
def generate_output(inputs, output)
inputs.each do |input|
result = File.read(input.fullpath)
result.gsub!(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, "")
output.write result
end
end
end
class EmberLicenseFilter < Rake::Pipeline::Filter
def license
@license ||= File.read("generators/license.js")
end
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
output.write "#{license}\n\n#{file}"
end
end
end
class JSHintRC < Rake::Pipeline::Filter
def jshintrc
@jshintrc ||= File.read(".jshintrc")
end
def generate_output(inputs, output)
inputs.each do |input|
file = File.read(input.fullpath)
output.write "var JSHINTRC = #{jshintrc};\n\n#{file}"
end
end
end
distros = {
:full => %w(ember-touch)
}
output "dist"
input "packages" do
output "tests"
match "*/tests/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id.sub!('/tests', '/~tests')
id
}
concat "ember-touch-tests.js"
end
match "ember-touch-tests.js" do
filter JSHintRC
end
end
input "packages" do
match "ember-touch/lib/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "ember-touch-spade.js"
end
end
input "packages" do
match "ember/lib/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
'ember'
}
concat do |input|
package = input.dup.sub!('/lib/main.js', '')
"#{package}-spade.js"
end
end
end
input "packages" do
match "ember/lib/**/*.js" do
minispade :rewrite_requires => true, :string => true, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!('/lib/', '/')
id.sub!(/\.js$/, '')
id.sub!(/\/main$/, '')
id
}
concat "ember-spade.js"
end
end
input "packages" do
match "*/lib/**/main.js" do
neuter(
:additional_dependencies => proc { |input|
Dir.glob(File.join(File.dirname(input.fullpath),'**','*.js'))
},
:path_transform => proc { |path, input|
package, path = path.split('/', 2)
current_package = input.path.split('/', 2)[0]
current_package == package && path ? File.join(package, "lib", "#{path}.js") : nil
},
:closure_wrap => true
) do |filename|
File.join("modules/", filename.gsub('/lib/main.js', '.js'))
end
end
end
distros.each do |name, modules|
name = "ember-touch"
input "dist/modules" do
module_paths = modules.map{|m| "#{m}.js" }
match "{#{module_paths.join(',')}}" do
concat(module_paths){ ["#{name}.js"] }
end
match "#{name}.js" do
filter EmberProductionFilter
filter EmberLicenseFilter
end
end
end
# vim: filetype=ruby