├── Rakefile ├── Gemfile ├── lib ├── ember-cli │ ├── version.rb │ ├── view_helpers.rb │ ├── middleware.rb │ ├── railtie.rb │ ├── configuration.rb │ ├── helpers.rb │ └── app.rb ├── generators │ └── ember-cli │ │ └── init │ │ ├── templates │ │ └── initializer.rb │ │ ├── USAGE │ │ └── init_generator.rb └── ember-cli-rails.rb ├── .gitignore ├── ember-cli-rails.gemspec ├── LICENSE.txt ├── CHANGELOG.md └── README.md /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | 5 | gem "pry" 6 | -------------------------------------------------------------------------------- /lib/ember-cli/version.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | VERSION = "0.0.15".freeze 3 | end 4 | -------------------------------------------------------------------------------- /lib/generators/ember-cli/init/templates/initializer.rb: -------------------------------------------------------------------------------- 1 | EmberCLI.configure do |c| 2 | c.app :frontend 3 | end 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | -------------------------------------------------------------------------------- /lib/generators/ember-cli/init/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Generates ember cli initializer. The initializer sets up where the EmberCli application will live (by default in app/frontend) 3 | 4 | Example: 5 | rails generate ember-cli:init 6 | 7 | This will create: 8 | config/initializers/ember.rb 9 | -------------------------------------------------------------------------------- /lib/generators/ember-cli/init/init_generator.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | class InitGenerator < Rails::Generators::Base 3 | source_root File.expand_path("../templates", __FILE__) 4 | 5 | namespace "ember-cli:init" 6 | 7 | def copy_initializer_file 8 | copy_file "initializer.rb", "config/initializers/ember.rb" 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/ember-cli/view_helpers.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | module ViewHelpers 3 | def include_ember_script_tags(app_name) 4 | app = EmberCLI.configuration.apps.fetch(app_name) 5 | javascript_include_tag *app.exposed_js_assets 6 | end 7 | 8 | def include_ember_stylesheet_tags(app_name) 9 | app = EmberCLI.configuration.apps.fetch(app_name) 10 | stylesheet_link_tag *app.exposed_css_assets 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/ember-cli/middleware.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | class Middleware 3 | def initialize(app) 4 | @app = app 5 | end 6 | 7 | def call(env) 8 | enable_ember_cli 9 | EmberCLI.wait! 10 | 11 | @app.call(env) 12 | end 13 | 14 | private 15 | 16 | def enable_ember_cli 17 | @enabled ||= begin 18 | if Rails.env.development? 19 | EmberCLI.run! 20 | else 21 | EmberCLI.compile! 22 | end 23 | 24 | true 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/ember-cli/railtie.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | class Railtie < Rails::Railtie 3 | initializer "ember-cli-rails.view_helpers" do 4 | ActionView::Base.send :include, ViewHelpers 5 | end 6 | 7 | initializer "ember-cli-rails.inflector" do 8 | ActiveSupport::Inflector.inflections :en do |inflect| 9 | inflect.acronym "CLI" 10 | end 11 | end 12 | 13 | initializer "ember-cli-rails.enable" do 14 | EmberCLI.enable! unless ENV["SKIP_EMBER"] 15 | end 16 | 17 | rake_tasks do 18 | require "sprockets/rails/task" 19 | Helpers.override_assets_precompile_task! 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /ember-cli-rails.gemspec: -------------------------------------------------------------------------------- 1 | require File.expand_path("../lib/ember-cli/version", __FILE__) 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = "ember-cli-rails" 5 | spec.version = EmberCLI::VERSION 6 | spec.authors = ["Pavel Pravosud", "Jonathan Jackson"] 7 | spec.email = ["pavel@pravosud.com", "jonathan.jackson1@me.com"] 8 | spec.summary = "Integration between Ember CLI and Rails" 9 | spec.homepage = "https://github.com/rwz/ember-cli-rails" 10 | spec.license = "MIT" 11 | spec.files = Dir["README.md", "CHANGELOG.md", "LICENSE.txt", "lib/**/*"] 12 | 13 | spec.required_ruby_version = ">= 1.9.3" 14 | 15 | spec.add_dependency "railties", "~> 4.0" 16 | spec.add_dependency "sprockets-rails", "~> 2.0" 17 | end 18 | -------------------------------------------------------------------------------- /lib/ember-cli/configuration.rb: -------------------------------------------------------------------------------- 1 | require "singleton" 2 | 3 | module EmberCLI 4 | class Configuration 5 | include Singleton 6 | 7 | def app(name, options={}) 8 | apps.store name, App.new(name, options) 9 | end 10 | 11 | def apps 12 | @apps ||= HashWithIndifferentAccess.new 13 | end 14 | 15 | def tee_path 16 | return @tee_path if defined?(@tee_path) 17 | @tee_path = Helpers.which("tee") 18 | end 19 | 20 | def ember_path 21 | @ember_path ||= Helpers.which("ember").tap do |path| 22 | fail "ember-cli executable could not be found" unless path 23 | end 24 | end 25 | 26 | def build_timeout 27 | @build_timeout ||= 5 28 | end 29 | 30 | attr_writer :ember_path, :build_timeout 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Pavel Pravosud 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/ember-cli/helpers.rb: -------------------------------------------------------------------------------- 1 | module EmberCLI 2 | module Helpers 3 | extend self 4 | 5 | def match_version?(version, requirement) 6 | version = Gem::Version.new(version) 7 | requirement = Gem::Requirement.new(requirement) 8 | requirement.satisfied_by?(version) 9 | end 10 | 11 | def which(cmd) 12 | exts = ENV.fetch("PATHEXT", ?;).split(?;, -1).uniq 13 | 14 | ENV.fetch("PATH").split(File::PATH_SEPARATOR).each do |path| 15 | exts.each do |ext| 16 | exe = File.join(path, "#{cmd}#{ext}") 17 | return exe if File.executable?(exe) && !File.directory?(exe) 18 | end 19 | end 20 | 21 | nil 22 | end 23 | 24 | def non_production? 25 | !Rails.env.production? && Rails.configuration.consider_all_requests_local 26 | end 27 | 28 | def override_assets_precompile_task! 29 | Rake.application.instance_eval do 30 | @tasks["assets:precompile:original"] = @tasks.delete("assets:precompile") 31 | Rake::Task.define_task "assets:precompile", [:assets, :precompile] => :environment do 32 | EmberCLI.compile! 33 | Rake::Task["assets:precompile:original"].execute 34 | end 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/ember-cli-rails.rb: -------------------------------------------------------------------------------- 1 | require "ember-cli/railtie" if defined?(Rails) 2 | 3 | module EmberCLI 4 | extend self 5 | 6 | autoload :App, "ember-cli/app" 7 | autoload :Configuration, "ember-cli/configuration" 8 | autoload :ViewHelpers, "ember-cli/view_helpers" 9 | autoload :Helpers, "ember-cli/helpers" 10 | autoload :Middleware, "ember-cli/middleware" 11 | 12 | def configure 13 | yield configuration 14 | end 15 | 16 | def configuration 17 | Configuration.instance 18 | end 19 | 20 | def prepare! 21 | @prepared ||= begin 22 | Rails.configuration.assets.paths << root.join("assets").to_s 23 | at_exit{ cleanup } 24 | true 25 | end 26 | end 27 | 28 | def enable! 29 | prepare! 30 | 31 | if Helpers.non_production? 32 | Rails.configuration.middleware.use Middleware 33 | end 34 | end 35 | 36 | def run! 37 | prepare! 38 | each_app &:run 39 | end 40 | 41 | def compile! 42 | prepare! 43 | each_app &:compile 44 | end 45 | 46 | def stop! 47 | each_app &:stop 48 | end 49 | 50 | def wait! 51 | each_app &:wait 52 | end 53 | 54 | def root 55 | @root ||= Rails.root.join("tmp", "ember-cli-#{uid}") 56 | end 57 | 58 | private 59 | 60 | def uid 61 | @uid ||= SecureRandom.uuid 62 | end 63 | 64 | def cleanup 65 | root.rmtree if root.exist? 66 | end 67 | 68 | def each_app 69 | configuration.apps.each{ |name, app| yield app } 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 0.0.15 2 | ------ 3 | 4 | * Fix NameError when addon version doesn't match. [#47](https://github.com/rwz/ember-cli-rails/pull/47) 5 | * Fix race condition in symlink creation when run multiple workers (again). [#22](https://github.com/rwz/ember-cli-rails/pull/22) 6 | 7 | 0.0.14 8 | ------ 9 | 10 | * Do not include jQuery into vendor.js when jquery-rails is available. [#32](https://github.com/rwz/ember-cli-rails/issues/32) 11 | 12 | 0.0.13 13 | ------ 14 | 15 | * Fix assets:precompile in production environment. [#38](https://github.com/rwz/ember-cli-rails/issues/38) 16 | 17 | 0.0.12 18 | ------ 19 | 20 | * Make sure ember-cli-dependency-checker is present. [#35](https://github.com/rwz/ember-cli-rails/issues/35) 21 | 22 | 0.0.11 23 | ------ 24 | 25 | * Fix locking feature by bumping addon version to 0.0.5. [#31](https://github.com/rwz/ember-cli-rails/issues/31) 26 | 27 | 0.0.10 28 | ------ 29 | 30 | * Add locking feature to prevent stale code. [#25](https://github.com/rwz/ember-cli-rails/pull/25) 31 | 32 | 0.0.9 33 | ----- 34 | 35 | * Fix a bug when path provided as a string, not pathname. [#24](https://github.com/rwz/ember-cli-rails/issues/24) 36 | 37 | 0.0.8 38 | ----- 39 | 40 | * Add support for including Ember stylesheet link tags. [#21](https://github.com/rwz/ember-cli-rails/pull/21) 41 | * Fix an error when the symlink already exists. [#22](https://github.com/rwz/ember-cli-rails/pull/22) 42 | 43 | 0.0.7 44 | ----- 45 | 46 | * Add sprockets-rails to dependency list. [commit](https://github.com/rwz/ember-cli-rails/commit/99a893030d6b754fe71363a396fd4515b93812b6) 47 | * Add a flag to skip ember-cli integration. [#17](https://github.com/rwz/ember-cli-rails/issues/17) 48 | 49 | 0.0.6 50 | ----- 51 | 52 | * Fix compiling assets in test environment. [#15](https://github.com/rwz/ember-cli-rails/pull/15) 53 | * Use only development/production Ember environments. [#16](https://github.com/rwz/ember-cli-rails/pull/16) 54 | * Make the gem compatible with ruby 1.9.3. [#20](https://github.com/rwz/ember-cli-rails/issues/20) 55 | 56 | 0.0.5 57 | ----- 58 | 59 | * Fix generator. [commit](https://github.com/rwz/ember-cli-rails/commit/c1bb10c6a2ec5b24d55fe69b6919fdd415fd1cdc) 60 | 61 | 0.0.4 62 | ----- 63 | 64 | * Add assets:precompile hook. [#11](https://github.com/rwz/ember-cli-rails/issues/11) 65 | 66 | 0.0.3 67 | ----- 68 | 69 | * Make gem Ruby 2.0 compatible. [#12](https://github.com/rwz/ember-cli-rails/issues/12) 70 | 71 | 0.0.2 72 | ----- 73 | 74 | * Do not assume ember-cli app name is equal to configured name. [#5](https://github.com/rwz/ember-cli-rails/issues/5) 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EmberCLI Rails 2 | 3 | EmberCLI Rails is an integration story between (surprise suprise) EmberCLI and 4 | Rails. It is designed to provide an easy way to organize your Rails backed 5 | EmberCLI application with a specific focus on upgradeability. Rails and Ember 6 | [slash EmberCLI] are maintained by different teams with different goals. As 7 | such, we believe that it is important to ensure smooth upgrading of both 8 | aspects of your application. 9 | 10 | A large contingent of Ember developers use Rails. And Rails is awesome. With 11 | the upcoming changes to Ember 2.0 and the Ember community's desire to unify 12 | around EmberCLI it is now more important than ever to ensure that Rails and 13 | EmberCLI can coexist and development still be fun! 14 | 15 | To this end we have created a minimum set of features (which we will outline 16 | below) to allow you keep your Rails workflow while minimizing the risk of 17 | upgrade pain with your Ember build tools. 18 | 19 | For example, end-to-end tests with frameworks like Cucumber should just work. 20 | You should still be able leverage the asset pipeline, and all the conveniences 21 | that Rails offers. And you should get all the new goodies like ES6 modules and 22 | EmberCLI addons too! Without further ado, let's get in there! 23 | 24 | ## Installation 25 | 26 | Firstly, you'll have to include the gem in your `Gemfile` and `bundle install` 27 | 28 | ```ruby 29 | gem "ember-cli-rails" 30 | ``` 31 | 32 | Then you'll want to configure your installation by adding an `ember.rb` 33 | initializer. There is a generator to guide you, run: 34 | 35 | ```shell 36 | rails generate ember-cli:init 37 | ``` 38 | 39 | This will generate an initializer that looks like the following: 40 | 41 | ```ruby 42 | EmberCLI.configure do |c| 43 | c.app :frontend 44 | end 45 | ``` 46 | 47 | ##### options 48 | 49 | - app - this represents the name of the ember cli application. The presumed 50 | path of which would be `Rails.root.join('app', )` 51 | 52 | - path - used if you need to override the default path (mentioned above). 53 | Example usage: 54 | 55 | ```ruby 56 | EmberCLI.configure do |c| 57 | c.app :frontend, path: "/path/to/your/ember-cli-app/on/disk" 58 | end 59 | ``` 60 | 61 | Once you've updated your initializer to taste, you need to install the 62 | [ember-cli-rails-addon](https://github.com/rondale-sc/ember-cli-rails-addon). 63 | 64 | For each of your EmberCLI applications install the addon with: 65 | 66 | ```sh 67 | npm install --save-dev ember-cli-rails-addon@0.0.7 68 | ``` 69 | 70 | And that's it! 71 | 72 | ### Multiple EmberCLI apps 73 | 74 | In the initializer you may specify multiple EmberCLI apps, each of which can be 75 | referenced with the view helper independently. You'd accomplish this like so: 76 | 77 | ```ruby 78 | EmberCLI.configure do |c| 79 | c.app :frontend 80 | c.app :admin_panel, path: "/somewhere/else" 81 | end 82 | ``` 83 | 84 | ## Usage 85 | 86 | You render your Ember CLI app by including the corresponding JS/CSS tags in whichever 87 | Rails view you'd like the Ember app to appear. 88 | 89 | For example, if you had the following Rails app 90 | 91 | ```rb 92 | # /config/routes.rb 93 | Rails.application.routes.draw do 94 | root 'application#index' 95 | end 96 | 97 | # /app/controllers/application_controller.rb 98 | class ApplicationController < ActionController::Base 99 | def index 100 | render :index 101 | end 102 | end 103 | ``` 104 | 105 | and if you had created an Ember app `:frontend` in your initializer, then you 106 | could render your app at the `/` route with the following view: 107 | 108 | ```erb 109 | 110 | <%= include_ember_script_tags :frontend %> 111 | <%= include_ember_stylesheet_tags :frontend %> 112 | ``` 113 | 114 | Your Ember application will now be served at the `/` route. 115 | 116 | ## Additional Information 117 | 118 | When running in the development environment, EmberCLI Rails runs `ember build` 119 | with the `--output-path` and `--watch` flags on. The `--watch` flag tells 120 | EmberCLI to watch for file system events and rebuild when an EmberCLI file is changed. 121 | The `--output-path` flag specifies where the distribution files will be put. 122 | EmberCLI Rails does some fancy stuff to get it into your asset path without 123 | polluting your git history. Note that for this to work, you must have 124 | `config.consider_all_requests_local = true` set in 125 | `config/environments/development.rb`, otherwise the middleware responsible for 126 | building Ember CLI will not be enabled. 127 | 128 | ## Contributing 129 | 130 | 1. Fork it (https://github.com/rwz/ember-cli-rails/fork) 131 | 2. Create your feature branch (`git checkout -b my-new-feature`) 132 | 3. Commit your changes (`git commit -am 'Add some feature'`) 133 | 4. Push to the branch (`git push origin my-new-feature`) 134 | 5. Create a new Pull Request 135 | -------------------------------------------------------------------------------- /lib/ember-cli/app.rb: -------------------------------------------------------------------------------- 1 | require "timeout" 2 | 3 | module EmberCLI 4 | class App 5 | ADDON_VERSION = "0.0.7" 6 | EMBER_CLI_VERSION = "~> 0.1.3" 7 | JQUERY_VERSIONS = ["~> 1.7", "~> 2.1"].freeze 8 | 9 | attr_reader :name, :options, :pid 10 | 11 | def initialize(name, options={}) 12 | @name, @options = name.to_s, options 13 | end 14 | 15 | def compile 16 | prepare 17 | silence_stream STDOUT do 18 | system(env_hash, command, chdir: app_path, err: :out) 19 | end 20 | end 21 | 22 | def run 23 | prepare 24 | @pid = spawn(env_hash, command(watch: true), chdir: app_path, err: :out) 25 | at_exit{ stop } 26 | end 27 | 28 | def stop 29 | Process.kill "INT", pid if pid 30 | @pid = nil 31 | end 32 | 33 | def exposed_js_assets 34 | %W[#{name}/vendor #{name}/#{ember_app_name}] 35 | end 36 | 37 | def exposed_css_assets 38 | %W[#{name}/vendor #{name}/#{ember_app_name}] 39 | end 40 | 41 | def wait 42 | Timeout.timeout(build_timeout) do 43 | sleep 0.1 while lockfile.exist? 44 | end 45 | rescue Timeout::Error 46 | suggested_timeout = build_timeout + 5 47 | 48 | warn <<-MSG.strip_heredoc 49 | ============================= WARNING! ============================= 50 | 51 | Seems like Ember #{name} application takes more than #{build_timeout} 52 | seconds to compile. 53 | 54 | To prevent race conditions consider adjusting build timeout 55 | configuration in your ember initializer: 56 | 57 | EmberCLI.configure do |config| 58 | config.build_timeout = #{suggested_timeout} # in seconds 59 | end 60 | 61 | Alternatively, you can set build timeout per application like this: 62 | 63 | EmberCLI.configure do |config| 64 | config.app :#{name}, build_timeout: #{suggested_timeout} 65 | end 66 | 67 | ============================= WARNING! ============================= 68 | MSG 69 | end 70 | 71 | private 72 | 73 | delegate :ember_path, to: :configuration 74 | delegate :match_version?, :non_production?, to: Helpers 75 | delegate :tee_path, to: :configuration 76 | delegate :configuration, to: :EmberCLI 77 | 78 | def build_timeout 79 | options.fetch(:build_timeout){ configuration.build_timeout } 80 | end 81 | 82 | def lockfile 83 | tmp_path.join("build.lock") 84 | end 85 | 86 | def prepare 87 | @prepared ||= begin 88 | check_addon! 89 | check_ember_cli_version! 90 | FileUtils.touch lockfile 91 | symlink_to_assets_root 92 | add_assets_to_precompile_list 93 | true 94 | end 95 | end 96 | 97 | def suppress_jquery? 98 | return false unless defined?(Jquery::Rails::JQUERY_VERSION) 99 | 100 | JQUERY_VERSIONS.any? do |requirement| 101 | match_version?(Jquery::Rails::JQUERY_VERSION, requirement) 102 | end 103 | end 104 | 105 | def check_ember_cli_version! 106 | version = dev_dependencies.fetch("ember-cli").split("-").first 107 | 108 | unless match_version?(version, EMBER_CLI_VERSION) 109 | fail <<-MSG.strip_heredoc 110 | EmberCLI Rails require ember-cli NPM package version to be 111 | #{EMBER_CLI_VERSION} to work properly. From within your EmberCLI directory 112 | please update your package.json accordingly and run: 113 | 114 | $ npm install 115 | 116 | MSG 117 | end 118 | end 119 | 120 | def check_addon! 121 | unless addon_present? 122 | fail <<-MSG.strip_heredoc 123 | EmberCLI Rails requires your Ember app to have an addon. 124 | 125 | From within your EmberCLI directory please run: 126 | 127 | $ npm install --save-dev ember-cli-rails-addon@#{ADDON_VERSION} 128 | 129 | in you Ember application root: #{app_path} 130 | MSG 131 | end 132 | end 133 | 134 | def symlink_to_assets_root 135 | assets_path.join(name).make_symlink dist_path.join("assets") 136 | rescue Errno::EEXIST 137 | # Sometimes happens when starting multiple Unicorn workers. 138 | # Ignoring... 139 | end 140 | 141 | def add_assets_to_precompile_list 142 | Rails.configuration.assets.precompile << /(?:\/|\A)#{name}\// 143 | end 144 | 145 | def command(options={}) 146 | watch = options[:watch] ? "--watch" : "" 147 | "#{ember_path} build #{watch} --environment #{environment} --output-path #{dist_path} #{log_pipe}" 148 | end 149 | 150 | def log_pipe 151 | "| #{tee_path} -a #{log_path}" if tee_path 152 | end 153 | 154 | def ember_app_name 155 | @ember_app_name ||= options.fetch(:name){ package_json.fetch(:name) } 156 | end 157 | 158 | def app_path 159 | @app_path ||= begin 160 | path = options.fetch(:path){ Rails.root.join("app", name) } 161 | Pathname.new(path) 162 | end 163 | end 164 | 165 | def tmp_path 166 | @tmp_path ||= begin 167 | path = app_path.join("tmp") 168 | path.mkdir unless path.exist? 169 | path 170 | end 171 | end 172 | 173 | def log_path 174 | Rails.root.join("log", "ember-#{name}.#{Rails.env}.log") 175 | end 176 | 177 | def dist_path 178 | @dist_path ||= EmberCLI.root.join("apps", name).tap(&:mkpath) 179 | end 180 | 181 | def assets_path 182 | @assets_path ||= EmberCLI.root.join("assets").tap(&:mkpath) 183 | end 184 | 185 | def environment 186 | non_production?? "development" : "production" 187 | end 188 | 189 | def package_json 190 | @package_json ||= JSON.parse(app_path.join("package.json").read).with_indifferent_access 191 | end 192 | 193 | def dev_dependencies 194 | package_json.fetch("devDependencies", {}) 195 | end 196 | 197 | def addon_present? 198 | dev_dependencies["ember-cli-rails-addon"] == ADDON_VERSION && 199 | app_path.join('node_modules', 'ember-cli-rails-addon', 'package.json').exist? 200 | end 201 | 202 | def env_hash 203 | ENV.clone.tap do |vars| 204 | vars.store "DISABLE_FINGERPRINTING", "true" 205 | vars.store "SUPPRESS_JQUERY", "true" if suppress_jquery? 206 | end 207 | end 208 | end 209 | end 210 | --------------------------------------------------------------------------------