ember-cli-rails 0.0.18 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02bdcb704d9cf103835f4d33f06a395b154e6f83
4
- data.tar.gz: be0455d38e0af37abe4ce06880974c16fb2edbf5
3
+ metadata.gz: a08a5e8f40b04f129a52111debe85c7ba3d18020
4
+ data.tar.gz: 1ccad7df9c3612812095e776becf4cf87314e1d0
5
5
  SHA512:
6
- metadata.gz: b2f69ab85c0197d8581541bd4cd020f1e579ae34d40c27a5a16a8d5d9177cbb98550ac9687a712c917447cf3833deb15de3d9f25f479768b9f64be9c0204ed14
7
- data.tar.gz: 22c0988bc923d89e60fd9ee0252ccb230a277e3fb38d5b37e9999fbf49f0a8e0494819e7f7c8ea9353b5b2b5d0f59e501263bf7744fd81549f82f14182face3d
6
+ metadata.gz: 465c7fecc91622ee2c8cbf9b01b4f1012c3e411628d06fe5f5845eb146aa6df635051d90ce9d36158db3fac29bbd8de3693aa47c3fda58813d5c818229e41ee8
7
+ data.tar.gz: ea65b28b73265023bc0325a7c39de2e168fd71158f5dfdc471597e7fae6d6819e8fae90ccbb81ddf1b93247be2f47f86f638e960d98f3a95dd1c5ee13b39651d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.1.0
2
+ -----
3
+
4
+ * Expose rake task for `npm install` [#59](https://github.com/rwz/ember-cli-rails/pull/59)
5
+ * Detect and raise EmberCLI build errors [#23](https://github.com/rwz/ember-cli-rails/pull/23)
6
+
1
7
  0.0.18
2
8
  ------
3
9
 
data/README.md CHANGED
@@ -64,7 +64,7 @@ Once you've updated your initializer to taste, you need to install the
64
64
  For each of your EmberCLI applications install the addon with:
65
65
 
66
66
  ```sh
67
- npm install --save-dev ember-cli-rails-addon@0.0.8
67
+ npm install --save-dev ember-cli-rails-addon@0.0.9
68
68
  ```
69
69
 
70
70
  And that's it!
@@ -145,7 +145,7 @@ polluting your git history. Note that for this to work, you must have
145
145
  building Ember CLI will not be enabled.
146
146
 
147
147
 
148
- #### Ember Depdencies
148
+ #### Ember Dependencies
149
149
 
150
150
  Ember has several dependencies. Some of these dependencies might already be
151
151
  present in your asset list. For example jQuery is bundled in `jquery-rails` gem.
@@ -33,6 +33,11 @@ module EmberCLI
33
33
  end
34
34
  end
35
35
 
36
+ def install_dependencies!
37
+ prepare!
38
+ each_app &:install_dependencies
39
+ end
40
+
36
41
  def run!
37
42
  prepare!
38
43
  each_app &:run
data/lib/ember-cli/app.rb CHANGED
@@ -2,9 +2,11 @@ require "timeout"
2
2
 
3
3
  module EmberCLI
4
4
  class App
5
- ADDON_VERSION = "0.0.8"
5
+ ADDON_VERSION = "0.0.9"
6
6
  EMBER_CLI_VERSION = "~> 0.1.5"
7
7
 
8
+ class BuildError < StandardError; end
9
+
8
10
  attr_reader :name, :options, :pid
9
11
 
10
12
  def initialize(name, options={})
@@ -14,6 +16,11 @@ module EmberCLI
14
16
  def compile
15
17
  prepare
16
18
  silence_stream(STDOUT){ exec command }
19
+ check_for_build_error!
20
+ end
21
+
22
+ def install_dependencies
23
+ exec "#{npm_path} install"
17
24
  end
18
25
 
19
26
  def run
@@ -38,7 +45,7 @@ module EmberCLI
38
45
 
39
46
  def wait
40
47
  Timeout.timeout(build_timeout) do
41
- sleep 0.1 while lockfile.exist?
48
+ wait_for_build_complete_or_error
42
49
  end
43
50
  rescue Timeout::Error
44
51
  suggested_timeout = build_timeout + 5
@@ -78,7 +85,7 @@ module EmberCLI
78
85
  private
79
86
 
80
87
  delegate :match_version?, :non_production?, to: Helpers
81
- delegate :tee_path, to: :configuration
88
+ delegate :tee_path, :npm_path, to: :configuration
82
89
  delegate :configuration, to: :EmberCLI
83
90
 
84
91
  def build_timeout
@@ -89,10 +96,33 @@ module EmberCLI
89
96
  tmp_path.join("build.lock")
90
97
  end
91
98
 
99
+ def check_for_build_error!
100
+ raise_build_error! if build_error_file.exist?
101
+ end
102
+
103
+ def build_error_file
104
+ tmp_path.join("error.txt")
105
+ end
106
+
107
+ def reset_build_error!
108
+ build_error_file.delete if build_error?
109
+ end
110
+
111
+ def build_error?
112
+ build_error_file.exist?
113
+ end
114
+
115
+ def raise_build_error!
116
+ error = BuildError.new("EmberCLI app #{name.inspect} has failed to build")
117
+ error.set_backtrace build_error_file.read.split(?\n)
118
+ fail error
119
+ end
120
+
92
121
  def prepare
93
122
  @prepared ||= begin
94
123
  check_addon!
95
124
  check_ember_cli_version!
125
+ reset_build_error!
96
126
  FileUtils.touch lockfile
97
127
  symlink_to_assets_root
98
128
  add_assets_to_precompile_list
@@ -215,5 +245,13 @@ module EmberCLI
215
245
  Kernel.public_send(method_name, env_hash, cmd, err: :out)
216
246
  end
217
247
  end
248
+
249
+ def wait_for_build_complete_or_error
250
+ loop do
251
+ check_for_build_error!
252
+ break unless lockfile.exist?
253
+ sleep 0.1
254
+ end
255
+ end
218
256
  end
219
257
  end
@@ -17,6 +17,10 @@ module EmberCLI
17
17
  @tee_path = Helpers.which("tee")
18
18
  end
19
19
 
20
+ def npm_path
21
+ @npm_path ||= Helpers.which("npm")
22
+ end
23
+
20
24
  def build_timeout
21
25
  @build_timeout ||= 5
22
26
  end
@@ -28,7 +28,7 @@ module EmberCLI
28
28
  def override_assets_precompile_task!
29
29
  Rake.application.instance_eval do
30
30
  @tasks["assets:precompile:original"] = @tasks.delete("assets:precompile")
31
- Rake::Task.define_task "assets:precompile", [:assets, :precompile] => :environment do
31
+ Rake::Task.define_task "assets:precompile", [:assets, :precompile] => "ember-cli:install_dependencies" do
32
32
  EmberCLI.compile!
33
33
  Rake::Task["assets:precompile:original"].execute
34
34
  end
@@ -16,6 +16,7 @@ module EmberCLI
16
16
 
17
17
  rake_tasks do
18
18
  require "sprockets/rails/task"
19
+ load "tasks/ember-cli.rake"
19
20
  Helpers.override_assets_precompile_task!
20
21
  end
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module EmberCLI
2
- VERSION = "0.0.18".freeze
2
+ VERSION = "0.1.0".freeze
3
3
  end
@@ -0,0 +1,6 @@
1
+ namespace "ember-cli" do
2
+ desc "Installs each EmberCLI app's dependencies"
3
+ task install_dependencies: :environment do
4
+ EmberCLI.install_dependencies!
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-cli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-09 00:00:00.000000000 Z
12
+ date: 2015-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -61,6 +61,7 @@ files:
61
61
  - lib/generators/ember-cli/init/USAGE
62
62
  - lib/generators/ember-cli/init/init_generator.rb
63
63
  - lib/generators/ember-cli/init/templates/initializer.rb
64
+ - lib/tasks/ember-cli.rake
64
65
  homepage: https://github.com/rwz/ember-cli-rails
65
66
  licenses:
66
67
  - MIT