ember-cli-rails 0.4.3 → 0.5.0
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/CHANGELOG.md +31 -0
- data/README.md +183 -115
- data/app/controller/ember-cli/ember_controller.rb +9 -0
- data/app/helpers/ember_rails_helper.rb +13 -9
- data/app/views/ember_cli/ember/index.html.erb +5 -0
- data/lib/ember-cli-rails.rb +11 -25
- data/lib/ember-cli/app.rb +47 -295
- data/lib/ember-cli/build_monitor.rb +56 -0
- data/lib/ember-cli/capture.rb +15 -15
- data/lib/ember-cli/command.rb +63 -0
- data/lib/ember-cli/configuration.rb +34 -3
- data/lib/ember-cli/constraint.rb +9 -0
- data/lib/ember-cli/controller_extension.rb +13 -0
- data/lib/ember-cli/engine.rb +14 -3
- data/lib/ember-cli/errors.rb +4 -0
- data/lib/ember-cli/helpers.rb +5 -11
- data/lib/ember-cli/html_page.rb +8 -15
- data/lib/ember-cli/path_set.rb +44 -29
- data/lib/ember-cli/route_helpers.rb +25 -0
- data/lib/ember-cli/shell.rb +84 -0
- data/lib/ember-cli/sprockets.rb +44 -0
- data/lib/ember-cli/version.rb +1 -1
- data/lib/generators/ember-cli/heroku/heroku_generator.rb +10 -0
- data/lib/tasks/ember-cli.rake +1 -1
- metadata +26 -7
- data/app/controllers/ember_tests_controller.rb +0 -31
- data/config/routes.rb +0 -3
- data/lib/ember-cli/asset_resolver.rb +0 -54
- data/lib/ember-cli/middleware.rb +0 -18
- data/lib/ember-cli/runner.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f7a15bd1d1e7f77df7e98e35264d3f0bc65eb85
|
4
|
+
data.tar.gz: 75608b21cf7b54146116bc3b6303573ff9b32623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ec528e85b8ca4698a61b91645f6631d8afe9473357351ef435860cf4eb8c5023802fca59238ae4d35dd91475b2033e8f555a163d1ab554dac064d458900111
|
7
|
+
data.tar.gz: cf291820f9befdc3ccc18a598301b3893489b1111ae381d5ff486db54279dcfc72cf38721510f175f04e801c1047c96c16e9bee1b984d68d8176889c2275595b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,37 @@
|
|
1
1
|
master
|
2
2
|
------
|
3
3
|
|
4
|
+
0.5.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
* Deprecate `include_ember_index_html` in favor of the renamed
|
8
|
+
`render_ember_app`.
|
9
|
+
* Always pass `--environment test` to Rails-generated `ember test` commands.
|
10
|
+
[#277]
|
11
|
+
* No longer check dependencies within the app. Defer to EmberCLI's `stderr`
|
12
|
+
streaming. [#267]
|
13
|
+
* Remove `enable` configuration in favor of using `mount_ember_app`. [#261]
|
14
|
+
* Introduce `mount_ember_app` route helper [#263]
|
15
|
+
* Remove support for viewing Ember tests through Rails. Instead, use `ember
|
16
|
+
test` or `ember test --serve` from within the Ember directory. [#264]
|
17
|
+
* Remove `build_timeout` configuration [#259]
|
18
|
+
* Disable JS minification when generating Heroku setup [#238]
|
19
|
+
* `BuildError#message` includes first line of backtrace. [#256]
|
20
|
+
* Symlink `dist/` directly to Asset Pipeline [#250]
|
21
|
+
* Merge EmberCLI-generated `manifest.json` into Sprocket's [#250]
|
22
|
+
* `manifest.json`. Since we now defer to EmberCLI, we no longer need to
|
23
|
+
manually resolve asset URLs. [#250]
|
24
|
+
|
25
|
+
[#277]: https://github.com/thoughtbot/ember-cli-rails/pull/277
|
26
|
+
[#267]: https://github.com/thoughtbot/ember-cli-rails/pull/267
|
27
|
+
[#264]: https://github.com/thoughtbot/ember-cli-rails/pull/264
|
28
|
+
[#263]: https://github.com/thoughtbot/ember-cli-rails/pull/263
|
29
|
+
[#259]: https://github.com/thoughtbot/ember-cli-rails/pull/259
|
30
|
+
[#238]: https://github.com/thoughtbot/ember-cli-rails/pull/238
|
31
|
+
[#256]: https://github.com/thoughtbot/ember-cli-rails/pull/256
|
32
|
+
[#250]: https://github.com/thoughtbot/ember-cli-rails/pull/250
|
33
|
+
[#261]: https://github.com/thoughtbot/ember-cli-rails/pull/261
|
34
|
+
|
4
35
|
0.4.3
|
5
36
|
-----
|
6
37
|
|
data/README.md
CHANGED
@@ -21,124 +21,170 @@ You should still be able leverage the asset pipeline, and all the conveniences
|
|
21
21
|
that Rails offers. And you should get all the new goodies like ES6 modules and
|
22
22
|
Ember CLI addons too! Without further ado, let's get in there!
|
23
23
|
|
24
|
+
**EmberCLI-Rails Supports EmberCLI 1.13.x and later.**
|
25
|
+
|
24
26
|
## Installation
|
25
27
|
|
26
|
-
|
28
|
+
Add the following to your `Gemfile`:
|
27
29
|
|
28
30
|
```ruby
|
29
31
|
gem "ember-cli-rails"
|
30
32
|
```
|
31
33
|
|
32
|
-
Then
|
33
|
-
|
34
|
+
Then run `bundle install`:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
$ bundle install
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
First, generate the gem's initializer:
|
34
43
|
|
35
|
-
```
|
36
|
-
rails generate ember-cli:init
|
44
|
+
```bash
|
45
|
+
$ rails generate ember-cli:init
|
37
46
|
```
|
38
47
|
|
39
|
-
This will
|
48
|
+
This will create the following initializer:
|
40
49
|
|
41
50
|
```ruby
|
42
|
-
|
51
|
+
# config/initializers/ember.rb
|
52
|
+
|
53
|
+
EmberCli.configure do |c|
|
43
54
|
c.app :frontend
|
44
55
|
end
|
45
56
|
```
|
46
57
|
|
47
|
-
|
58
|
+
The initializer assumes that your Ember application exists in
|
59
|
+
`Rails.root.join("frontend")`.
|
48
60
|
|
49
|
-
|
61
|
+
If this is not the case, you could
|
62
|
+
|
63
|
+
* move your existing Ember application into `Rails.root.join("frontend")`
|
64
|
+
* configure `frontend` to look for the Ember application in its current
|
65
|
+
directory:
|
66
|
+
|
67
|
+
```rb
|
68
|
+
c.app :frontend, path: "~/projects/my-ember-app"
|
69
|
+
```
|
70
|
+
|
71
|
+
* generate a new Ember project:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
$ ember new frontend
|
75
|
+
```
|
50
76
|
|
51
|
-
|
52
|
-
|
77
|
+
**Initializer options**
|
78
|
+
|
79
|
+
- `name` - this represents the name of the Ember CLI application.
|
53
80
|
|
54
81
|
- `path` - the path where your Ember CLI application is located. The default
|
55
82
|
value is the name of your app in the Rails root.
|
56
83
|
|
57
|
-
- `enable` - a lambda that accepts each request's path. The default value is a
|
58
|
-
lambda that returns `true`.
|
59
|
-
|
60
84
|
```ruby
|
61
|
-
|
62
|
-
c.app :adminpanel # path
|
85
|
+
EmberCli.configure do |c|
|
86
|
+
c.app :adminpanel # path defaults to `Rails.root.join("adminpanel")`
|
63
87
|
c.app :frontend,
|
64
|
-
path: "/path/to/your/ember-cli-app/on/disk"
|
65
|
-
enable: -> path { path.starts_with?("/app/") }
|
88
|
+
path: "/path/to/your/ember-cli-app/on/disk"
|
66
89
|
end
|
67
90
|
```
|
68
91
|
|
69
|
-
|
92
|
+
Next, install the [ember-cli-rails-addon][addon]:
|
70
93
|
|
71
|
-
```
|
72
|
-
cd frontend
|
73
|
-
ember
|
94
|
+
```bash
|
95
|
+
$ cd path/to/frontend
|
96
|
+
$ npm install --save-dev ember-cli-rails-addon
|
74
97
|
```
|
75
98
|
|
76
|
-
|
99
|
+
Be sure that the addon's [`MAJOR` and `MINOR` version][semver] matches the gem's
|
100
|
+
`MAJOR` and `MINOR` versions.
|
77
101
|
|
78
|
-
|
79
|
-
|
102
|
+
For instance, if you're using the `0.5.x` version of the gem, specify
|
103
|
+
`~> 0.5.0` ion in your Ember app's `package.json`:
|
104
|
+
|
105
|
+
```json
|
106
|
+
{
|
107
|
+
"devDependencies": {
|
108
|
+
"ember-cli-rails-addon": "~> 0.5.0"
|
109
|
+
}
|
110
|
+
}
|
80
111
|
```
|
81
112
|
|
82
|
-
|
113
|
+
[addon]: https://github.com/rondale-sc/ember-cli-rails-addon/
|
114
|
+
[semver]: http://semver.org/
|
83
115
|
|
84
|
-
|
116
|
+
Next, configure Rails to route requests to the `frontend` Ember application:
|
85
117
|
|
86
|
-
|
87
|
-
|
118
|
+
```rb
|
119
|
+
# config/routes.rb
|
88
120
|
|
89
|
-
|
90
|
-
|
91
|
-
c.app :frontend
|
92
|
-
c.app :admin_panel, path: "/somewhere/else"
|
121
|
+
Rails.application.routes.draw do
|
122
|
+
mount_ember_app :frontend, to: "/"
|
93
123
|
end
|
94
124
|
```
|
95
125
|
|
96
|
-
|
126
|
+
Ember requests will be set `params[:ember_app]` to the name of the application.
|
127
|
+
In the above example, `params[:ember_app] == :frontend`.
|
97
128
|
|
98
|
-
|
99
|
-
|
129
|
+
**Routing options**
|
130
|
+
|
131
|
+
* `to` - The path to handle as an Ember application. This will only apply to
|
132
|
+
`format: :html` requests. Additionally, this will handle child routes as well.
|
133
|
+
For instance, mounting `mount_ember_app :frontend, to: "/frontend"` will handle a
|
134
|
+
`format: :html` request to `/frontend/posts`.
|
135
|
+
* `controller` - Defaults to `"ember_cli/ember"`
|
136
|
+
* `action` - Defaults to `"index"`
|
137
|
+
|
138
|
+
You should now be able to boot your Rails application, navigate to the `root`
|
139
|
+
route, and see your EmberCLI app!
|
140
|
+
|
141
|
+
## Configuring the Ember controller
|
142
|
+
|
143
|
+
By default, routes defined by `ember_app` will be rendered with the internal
|
144
|
+
`EmberCli::EmberController`. The `EmberCli::EmberController` renders the Ember
|
145
|
+
application's `index.html` and injects the Rails-generated CSRF tags into the
|
146
|
+
`<head>`.
|
147
|
+
|
148
|
+
To override this behavior, specify the `controller` and `action` options:
|
100
149
|
|
101
150
|
```rb
|
102
|
-
#
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
151
|
+
# config/routes
|
152
|
+
|
153
|
+
Rails.application.routes.draw do
|
154
|
+
mount_ember_app :frontend, to: "/", controller: "application", action: "index"
|
107
155
|
end
|
108
156
|
```
|
109
157
|
|
110
|
-
To
|
111
|
-
|
112
|
-
|
158
|
+
To serve the EmberCLI generated `index.html`, use the `render_ember_app`
|
159
|
+
helper in your view:
|
113
160
|
|
114
161
|
```erb
|
115
|
-
<!--
|
116
|
-
<%=
|
162
|
+
<!-- app/views/application/index.html.erb -->
|
163
|
+
<%= render_ember_app :frontend %>
|
117
164
|
```
|
118
165
|
|
119
166
|
To inject markup into page, pass in a block that accepts the `head`, and
|
120
167
|
(optionally) the `body`:
|
121
168
|
|
122
169
|
```erb
|
123
|
-
<!--
|
124
|
-
<%=
|
170
|
+
<!-- app/views/application/index.html.erb -->
|
171
|
+
<%= render_ember_app :frontend do |head| %>
|
125
172
|
<% head.append do %>
|
126
173
|
<%= csrf_meta_tags %>
|
127
174
|
<% end %>
|
128
175
|
<% end %>
|
129
176
|
```
|
130
177
|
|
131
|
-
|
132
|
-
|
133
|
-
*NOTE*
|
178
|
+
When serving the EmberCLI generated `index.html`, don't use Rails' layout HTML:
|
134
179
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
180
|
+
```rb
|
181
|
+
# app/controllers/application.rb
|
182
|
+
class ApplicationController < ActionController::Base
|
183
|
+
def index
|
184
|
+
render layout: false
|
185
|
+
end
|
186
|
+
end
|
187
|
+
```
|
142
188
|
|
143
189
|
### Rendering the EmberCLI generated JS and CSS
|
144
190
|
|
@@ -146,44 +192,43 @@ In addition to rendering the EmberCLI generated `index.html`, you can inject the
|
|
146
192
|
`<script>` and `<link>` tags into your Rails generated views:
|
147
193
|
|
148
194
|
```erb
|
149
|
-
<!--
|
195
|
+
<!-- app/views/application/index.html.erb -->
|
150
196
|
<%= include_ember_script_tags :frontend %>
|
151
197
|
<%= include_ember_stylesheet_tags :frontend %>
|
152
198
|
```
|
153
199
|
|
154
|
-
###
|
200
|
+
### Multiple Ember CLI apps
|
155
201
|
|
156
|
-
|
202
|
+
In the initializer you may specify multiple Ember CLI apps, each of which can be
|
203
|
+
referenced with the view helper independently. You'd accomplish this like so:
|
157
204
|
|
158
|
-
|
205
|
+
```ruby
|
206
|
+
EmberCLI.configure do |c|
|
207
|
+
c.app :frontend
|
208
|
+
c.app :admin_panel, path: "/somewhere/else"
|
209
|
+
end
|
210
|
+
```
|
211
|
+
|
212
|
+
Rendering Ember applications at routes other than `/` requires additional setup
|
213
|
+
to avoid an Ember `UnrecognizedURLError`.
|
214
|
+
|
215
|
+
For instance, if you had Ember applications named `:frontend` and
|
216
|
+
`:admin_panel` and you wanted to serve them at `/frontend` and `/admin_panel`,
|
217
|
+
you would set up the following Rails routes:
|
159
218
|
|
160
219
|
```rb
|
161
220
|
# /config/routes.rb
|
162
221
|
Rails.application.routes.draw do
|
163
|
-
|
164
|
-
|
165
|
-
get 'admin_panel' => 'admin_panel#index'
|
166
|
-
end
|
167
|
-
|
168
|
-
# /app/controllers/frontend_controller.rb
|
169
|
-
class FrontendController < ActionController::Base
|
170
|
-
def index
|
171
|
-
render :index
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
# /app/controllers/admin_panel_controller.rb
|
176
|
-
class AdminPanelController < ActionController::Base
|
177
|
-
def index
|
178
|
-
render :index
|
179
|
-
end
|
222
|
+
mount_ember_app :frontend, to: "/frontend"
|
223
|
+
mount_ember_app :admin_panel, to: "/admin_panel"
|
180
224
|
end
|
181
225
|
```
|
182
226
|
|
183
|
-
|
227
|
+
You must modify each Ember app's `baseURL` to point to the correct route:
|
184
228
|
|
185
229
|
```javascript
|
186
|
-
|
230
|
+
// app/frontend/config/environment.js
|
231
|
+
|
187
232
|
module.exports = function(environment) {
|
188
233
|
var ENV = {
|
189
234
|
modulePrefix: 'frontend',
|
@@ -193,7 +238,8 @@ module.exports = function(environment) {
|
|
193
238
|
}
|
194
239
|
}
|
195
240
|
|
196
|
-
|
241
|
+
// app/admin_panel/config/environment.js
|
242
|
+
|
197
243
|
module.exports = function(environment) {
|
198
244
|
var ENV = {
|
199
245
|
modulePrefix: 'admin_panel',
|
@@ -203,7 +249,9 @@ module.exports = function(environment) {
|
|
203
249
|
}
|
204
250
|
}
|
205
251
|
```
|
206
|
-
|
252
|
+
|
253
|
+
Finally, configure each app's `router.js` file so that `rootURL` refers to the
|
254
|
+
new `baseURL`:
|
207
255
|
|
208
256
|
```javascript
|
209
257
|
/* app/frontend/app/router.js */
|
@@ -212,7 +260,8 @@ var Router = Ember.Router.extend({
|
|
212
260
|
location: config.locationType
|
213
261
|
});
|
214
262
|
```
|
215
|
-
|
263
|
+
|
264
|
+
Repeat the process for `admin_panel/app/router.js`.
|
216
265
|
|
217
266
|
## CSRF Tokens
|
218
267
|
|
@@ -222,47 +271,38 @@ Without it you'll receive a `422 Unprocessable Entity` error, specifically: `Act
|
|
222
271
|
In order to add that token to your requests, you need to add into your template:
|
223
272
|
|
224
273
|
```erb
|
225
|
-
<!--
|
226
|
-
|
227
|
-
|
274
|
+
<!-- app/views/application/index.html.erb -->
|
275
|
+
<%= render_ember_app :frontend do |head| %>
|
276
|
+
<% head.append do %>
|
277
|
+
<%= csrf_meta_tags %>
|
278
|
+
<% end %>
|
279
|
+
<% end %>
|
228
280
|
```
|
229
281
|
|
230
|
-
|
282
|
+
The default `EmberCli::EmberController` and its accompanying view handle this
|
283
|
+
for you by default.
|
231
284
|
|
232
|
-
|
285
|
+
However, if you specify your own controller, make sure to append CSRF tags to
|
286
|
+
your view's `<head>`.
|
233
287
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
import $ from 'jquery';
|
288
|
+
The [ember-cli-rails-addon][addon] addon will inject an initializer into your
|
289
|
+
app to set outgoing requests' `X-CSRF-TOKEN` header to the value injected by
|
290
|
+
Rails.
|
238
291
|
|
239
|
-
|
240
|
-
headers: {
|
241
|
-
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content')
|
242
|
-
}
|
243
|
-
});
|
244
|
-
```
|
292
|
+
### Integrating with Rake
|
245
293
|
|
246
|
-
|
294
|
+
EmberCLI Rails exposes the `ember:test` Rake task to execute Ember's test suite.
|
247
295
|
|
248
|
-
|
296
|
+
If you're using Rake to run your test suite, make sure to configure your test
|
297
|
+
task to depend on `ember:test`.
|
249
298
|
|
250
|
-
|
251
|
-
|
299
|
+
For example, to configure a bare `rake` command to run both RSpec and Ember test
|
300
|
+
suites, configure the `default` task to depend on both `spec` and `ember:test`.
|
252
301
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
root "application#index"
|
257
|
-
end
|
302
|
+
```rb
|
303
|
+
task default: [:spec, "ember:test"]
|
258
304
|
```
|
259
305
|
|
260
|
-
Ember tests are served based on the route you mount the Engine on (in this
|
261
|
-
example, `/ember-tests`) and the name of the Ember app.
|
262
|
-
|
263
|
-
For example, to view tests of the `frontend` app, visit
|
264
|
-
`http://localhost:3000/ember-tests/frontend`.
|
265
|
-
|
266
306
|
## Serving from multi-process servers in development
|
267
307
|
|
268
308
|
If you're using a multi-process server ([Puma], [Unicorn], etc.) in development,
|
@@ -326,6 +366,21 @@ $ heroku config:unset SKIP_EMBER
|
|
326
366
|
|
327
367
|
You should be ready to deploy.
|
328
368
|
|
369
|
+
The generator will disable Rails' JavaScript compression by declaring:
|
370
|
+
|
371
|
+
```rb
|
372
|
+
config.assets.js_compressor = nil
|
373
|
+
```
|
374
|
+
|
375
|
+
This is recommended, but might not work for projects that have both Asset
|
376
|
+
Pipeline and EmberCLI generated JavaScript.
|
377
|
+
|
378
|
+
To reverse this change, reconfigure Sprockets to use the `uglifier` gem:
|
379
|
+
|
380
|
+
```rb
|
381
|
+
config.assets.js_compressor = :uglifier
|
382
|
+
```
|
383
|
+
|
329
384
|
**NOTE** Run the generator each time you introduce additional EmberCLI
|
330
385
|
applications into the project.
|
331
386
|
|
@@ -404,6 +459,19 @@ environment, you can manually set the `config.use_ember_middleware` and
|
|
404
459
|
`config.use_ember_live_recompilation` flags in the environment-specific config
|
405
460
|
file.
|
406
461
|
|
462
|
+
### `ASSET_HOST`
|
463
|
+
|
464
|
+
Used by [the addon][addon] during fingerprinting.
|
465
|
+
|
466
|
+
When compiling an Ember app named `"frontend"` from within Rails,
|
467
|
+
the addon will prepend the generated asset paths with:
|
468
|
+
|
469
|
+
${ASSET_HOST}/assets/frontend/
|
470
|
+
|
471
|
+
### `CDN_HOST`
|
472
|
+
|
473
|
+
Behaves the same way as `ASSET_HOST`, acting as a fallback.
|
474
|
+
|
407
475
|
### `RAILS_ENV`
|
408
476
|
|
409
477
|
While being managed by EmberCLI Rails, EmberCLI process will have
|
@@ -450,7 +518,7 @@ from the Ember distribution. You can do so by setting the `exclude_ember_deps`
|
|
450
518
|
option like so:
|
451
519
|
|
452
520
|
```ruby
|
453
|
-
|
521
|
+
EmberCli.configure do |c|
|
454
522
|
c.app :frontend, exclude_ember_deps: "jquery"
|
455
523
|
c.app :admin_panel, exclude_ember_deps: ["jquery", "handlebars"]
|
456
524
|
end
|