136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/antoinette/cli/commands.rb', line 136
def call(elm_files:, **)
out = Antoinette::CLI.output
elm_app_names = elm_files.map { |path| File.basename(path, ".elm") }
config_path = Rails.root.join("config", "antoinette.json")
config = JSON.parse(File.read(config_path))
filtered_bundles = config["bundles"].select do |bundle|
(bundle["elm_apps"] & elm_app_names).any?
end
if filtered_bundles.empty?
out.puts "No bundles found containing: #{elm_app_names.join(", ")}"
exit
end
elm_path = config["elm_path"] || "elm"
compiler = Antoinette::CompileElm.new(elm_path: elm_path)
concatenator = Antoinette::ConcatBundle.new
injector = Antoinette::InjectScriptTag.new
filtered_bundles.each do |bundle|
out.puts "Updating bundle: #{bundle["name"]}"
elm_js = compiler.compile(bundle["elm_apps"])
concatenator.concatenate(
bundle_name: bundle["name"],
elm_js: elm_js
)
bundle["templates"].each do |template_path|
injector.inject(template_path: template_path, bundle_name: bundle["name"])
end
out.puts " Compiled Elm apps: #{bundle["elm_apps"].join(", ")}"
out.puts " Injected script tags into #{bundle["templates"].length} template(s)"
end
out.puts "Update complete!"
end
|