lib/ember_cli/app.rb in ember-cli-rails-0.5.8 vs lib/ember_cli/app.rb in ember-cli-rails-0.6.0

- old
+ new

@@ -1,7 +1,7 @@ require "ember_cli/shell" -require "ember_cli/sprockets" +require "ember_cli/html_page" require "ember_cli/build_monitor" module EmberCli class App attr_reader :name, :options, :paths @@ -31,11 +31,10 @@ def compile @compiled ||= begin prepare @shell.compile @build.check! - copy_index_html_file true end end def build @@ -46,64 +45,59 @@ end @build.wait! end + def index_html(head:, body:) + if index_file.exist? + html = HtmlPage.new( + head: head, + body: body, + content: index_file.read, + ) + + html.render + else + @build.check! + + raise BuildError.new <<-MSG + EmberCLI failed to generate an `index.html` file. + MSG + end + end + def install_dependencies @shell.install end def test prepare @shell.test end - def sprockets - EmberCli::Sprockets.new(self) - end + private + delegate :development?, :test?, to: :env + def index_file - if production? - paths.applications.join("#{name}.html") - else - paths.dist.join("index.html") - end + paths.index_file end - private - - delegate :development?, :production?, :test?, to: :env - def env EmberCli.env end def build_and_watch prepare @shell.build_and_watch - copy_index_html_file end def prepare @prepared ||= begin @build.reset - symlink_to_assets_root true end - end - - def copy_index_html_file - if production? - FileUtils.cp(paths.app_assets.join("index.html"), index_file) - end - end - - def symlink_to_assets_root - paths.app_assets.make_symlink paths.dist - rescue Errno::EEXIST - # Sometimes happens when starting multiple Unicorn workers. - # Ignoring... end def excluded_ember_deps Array.wrap(options[:exclude_ember_deps]).join(?,) end