ember-cli-rails 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -10
- data/lib/ember-cli-rails.rb +6 -14
- data/lib/ember-cli/app.rb +94 -3
- data/lib/ember-cli/configuration.rb +5 -1
- data/lib/ember-cli/middleware.rb +28 -0
- data/lib/ember-cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580f5c9e269dae3296f0550c842ace8dde54ad3d
|
4
|
+
data.tar.gz: 37badb9926e0d597a9bfd764c69d3958b95296b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7640726999ea40bb413500cade7fd2ebe310d81a5b1aa54252761763c7746e2e525d9fa3372e56abdab4f02fbdd130fe99f12c23b81948ecd54ddbf6236a72c0
|
7
|
+
data.tar.gz: 98fb575c245a29ea5e69b2cd7efae1ae56e881f972caa60830e66b10cf6770aaa775ad7b610ae896149d8ecc8fa07947011b9b6321913f04c891e4b5a9973caf
|
data/README.md
CHANGED
@@ -58,18 +58,13 @@ EmberCLI.configure do |c|
|
|
58
58
|
end
|
59
59
|
```
|
60
60
|
|
61
|
-
Once you've updated your initializer to taste, you need to
|
62
|
-
|
63
|
-
`Brocfile.js` inside your EmberCLI app and add `{storeConfigInMeta: false}`.
|
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).
|
64
63
|
|
65
|
-
|
64
|
+
For each of your EmberCLI applications install the addon with:
|
66
65
|
|
67
|
-
```
|
68
|
-
|
69
|
-
|
70
|
-
var app = new EmberApp({storeConfigInMeta: false});
|
71
|
-
|
72
|
-
// etc...
|
66
|
+
```sh
|
67
|
+
npm install --save-dev ember-cli-rails-addon@0.0.3
|
73
68
|
```
|
74
69
|
|
75
70
|
And that's it!
|
data/lib/ember-cli-rails.rb
CHANGED
@@ -7,6 +7,7 @@ module EmberCLI
|
|
7
7
|
autoload :Configuration, "ember-cli/configuration"
|
8
8
|
autoload :ViewHelpers, "ember-cli/view_helpers"
|
9
9
|
autoload :Helpers, "ember-cli/helpers"
|
10
|
+
autoload :Middleware, "ember-cli/middleware"
|
10
11
|
|
11
12
|
def configure
|
12
13
|
yield configuration
|
@@ -26,20 +27,7 @@ module EmberCLI
|
|
26
27
|
|
27
28
|
def enable!
|
28
29
|
prepare!
|
29
|
-
|
30
|
-
Rails.application.singleton_class.class_eval do
|
31
|
-
alias_method :call_without_ember_cli, :call
|
32
|
-
|
33
|
-
def call(env)
|
34
|
-
@_ember_cli_enabled ||= begin
|
35
|
-
EmberCLI.compile!
|
36
|
-
EmberCLI.run! if Rails.env.development?
|
37
|
-
true
|
38
|
-
end
|
39
|
-
|
40
|
-
call_without_ember_cli(env)
|
41
|
-
end
|
42
|
-
end
|
30
|
+
Rails.configuration.middleware.use Middleware
|
43
31
|
end
|
44
32
|
|
45
33
|
def run!
|
@@ -56,6 +44,10 @@ module EmberCLI
|
|
56
44
|
each_app &:stop
|
57
45
|
end
|
58
46
|
|
47
|
+
def wait!
|
48
|
+
each_app &:wait
|
49
|
+
end
|
50
|
+
|
59
51
|
def root
|
60
52
|
@root ||= Rails.root.join("tmp", "ember-cli-#{uid}")
|
61
53
|
end
|
data/lib/ember-cli/app.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
+
require "timeout"
|
2
|
+
|
1
3
|
module EmberCLI
|
2
4
|
class App
|
5
|
+
ADDON_VERSION = "0.0.3"
|
6
|
+
EMBER_CLI_VERSION = "~> 0.1.3"
|
7
|
+
|
3
8
|
attr_reader :name, :options, :pid
|
4
9
|
|
5
10
|
def initialize(name, options={})
|
@@ -32,20 +37,92 @@ module EmberCLI
|
|
32
37
|
%W[#{name}/vendor #{name}/#{ember_app_name}]
|
33
38
|
end
|
34
39
|
|
40
|
+
def wait
|
41
|
+
Timeout.timeout(build_timeout) do
|
42
|
+
sleep 0.1 while lockfile.exist?
|
43
|
+
end
|
44
|
+
rescue Timeout::Error
|
45
|
+
suggested_timeout = build_timeout + 5
|
46
|
+
|
47
|
+
warn <<-MSG.strip_heredoc
|
48
|
+
============================= WARNING! =============================
|
49
|
+
|
50
|
+
Seems like Ember #{name} application takes more than #{build_timeout}
|
51
|
+
seconds to compile.
|
52
|
+
|
53
|
+
To prevent race conditions consider adjusting build timeout
|
54
|
+
configuration in your ember initializer:
|
55
|
+
|
56
|
+
EmberCLI.configure do |config|
|
57
|
+
config.build_timeout = #{suggested_timeout} # in seconds
|
58
|
+
end
|
59
|
+
|
60
|
+
Alternatively, you can set build timeout per application like this:
|
61
|
+
|
62
|
+
EmberCLI.configure do |config|
|
63
|
+
config.app :#{name}, build_timeout: #{suggested_timeout}
|
64
|
+
end
|
65
|
+
|
66
|
+
============================= WARNING! =============================
|
67
|
+
MSG
|
68
|
+
end
|
69
|
+
|
35
70
|
private
|
36
71
|
|
37
72
|
delegate :ember_path, to: :configuration
|
38
73
|
delegate :tee_path, to: :configuration
|
39
74
|
delegate :configuration, to: :EmberCLI
|
40
75
|
|
76
|
+
def build_timeout
|
77
|
+
options.fetch(:build_timeout){ configuration.build_timeout }
|
78
|
+
end
|
79
|
+
|
80
|
+
def lockfile
|
81
|
+
tmp_path.join("build.lock")
|
82
|
+
end
|
83
|
+
|
41
84
|
def prepare
|
42
85
|
@prepared ||= begin
|
86
|
+
check_addon!
|
87
|
+
check_ember_cli_version!
|
88
|
+
FileUtils.touch lockfile
|
43
89
|
symlink_to_assets_root
|
44
90
|
add_assets_to_precompile_list
|
45
91
|
true
|
46
92
|
end
|
47
93
|
end
|
48
94
|
|
95
|
+
def check_ember_cli_version!
|
96
|
+
version = dev_dependencies.fetch("ember-cli").split("-").first
|
97
|
+
version = Gem::Version.new(version)
|
98
|
+
requirement = Gem::Requirement.new(EMBER_CLI_VERSION)
|
99
|
+
|
100
|
+
unless requirement.satisfied_by?(version)
|
101
|
+
fail <<-MSG.strip_heredoc
|
102
|
+
EmberCLI Rails require ember-cli NPM package version to be
|
103
|
+
#{requirement} to work properly. Please update your package.json
|
104
|
+
accordingly and run:
|
105
|
+
|
106
|
+
$ npm install
|
107
|
+
|
108
|
+
MSG
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def check_addon!
|
113
|
+
unless dev_dependencies["ember-cli-rails-addon"] == ADDON_VERSION
|
114
|
+
fail <<-MSG.strip_heredoc
|
115
|
+
EmberCLI Rails requires your Ember app to have an addon.
|
116
|
+
|
117
|
+
Please run:
|
118
|
+
|
119
|
+
$ npm install --save-dev ember-cli-rails-addon@#{ADDON_VERSION}`
|
120
|
+
|
121
|
+
in you Ember application root: #{app_path}
|
122
|
+
MSG
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
49
126
|
def symlink_to_assets_root
|
50
127
|
symlink_path = dist_path.join("assets")
|
51
128
|
assets_path.join(name).make_symlink symlink_path unless symlink_path.exist?
|
@@ -65,9 +142,7 @@ module EmberCLI
|
|
65
142
|
end
|
66
143
|
|
67
144
|
def ember_app_name
|
68
|
-
@ember_app_name ||= options.fetch(:name)
|
69
|
-
JSON.parse(app_path.join("package.json").read).fetch("name")
|
70
|
-
end
|
145
|
+
@ember_app_name ||= options.fetch(:name){ package_json.fetch(:name) }
|
71
146
|
end
|
72
147
|
|
73
148
|
def app_path
|
@@ -77,6 +152,14 @@ module EmberCLI
|
|
77
152
|
end
|
78
153
|
end
|
79
154
|
|
155
|
+
def tmp_path
|
156
|
+
@tmp_path ||= begin
|
157
|
+
path = app_path.join("tmp")
|
158
|
+
path.mkdir unless path.exist?
|
159
|
+
path
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
80
163
|
def log_path
|
81
164
|
Rails.root.join("log", "ember-#{name}.#{Rails.env}.log")
|
82
165
|
end
|
@@ -92,5 +175,13 @@ module EmberCLI
|
|
92
175
|
def environment
|
93
176
|
Helpers.non_production?? "development" : "production"
|
94
177
|
end
|
178
|
+
|
179
|
+
def package_json
|
180
|
+
@package_json ||= JSON.parse(app_path.join("package.json").read).with_indifferent_access
|
181
|
+
end
|
182
|
+
|
183
|
+
def dev_dependencies
|
184
|
+
package_json.fetch("devDependencies", {})
|
185
|
+
end
|
95
186
|
end
|
96
187
|
end
|
@@ -0,0 +1,28 @@
|
|
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
|
data/lib/ember-cli/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.10
|
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: 2014-12-
|
12
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/ember-cli/app.rb
|
54
54
|
- lib/ember-cli/configuration.rb
|
55
55
|
- lib/ember-cli/helpers.rb
|
56
|
+
- lib/ember-cli/middleware.rb
|
56
57
|
- lib/ember-cli/railtie.rb
|
57
58
|
- lib/ember-cli/version.rb
|
58
59
|
- lib/ember-cli/view_helpers.rb
|