ember-cli-rails 0.13.1 → 0.14.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 +34 -0
- data/LICENSE.txt +0 -0
- data/README.md +59 -18
- data/app/controller/ember_cli/ember_controller.rb +0 -0
- data/app/helpers/ember_rails_helper.rb +7 -1
- data/app/views/ember_cli/ember/index.html.erb +0 -0
- data/lib/ember-cli-rails.rb +0 -0
- data/lib/ember_cli/app.rb +54 -4
- data/lib/ember_cli/build_monitor.rb +0 -0
- data/lib/ember_cli/command.rb +0 -0
- data/lib/ember_cli/configuration.rb +0 -0
- data/lib/ember_cli/deploy/dev_server.rb +0 -0
- data/lib/ember_cli/deploy/file.rb +0 -0
- data/lib/ember_cli/dev_server.rb +0 -0
- data/lib/ember_cli/dev_server_proxy.rb +0 -0
- data/lib/ember_cli/ember_constraint.rb +0 -0
- data/lib/ember_cli/engine.rb +8 -0
- data/lib/ember_cli/errors.rb +0 -0
- data/lib/ember_cli/helpers.rb +0 -0
- data/lib/ember_cli/path_set.rb +69 -17
- data/lib/ember_cli/route_helpers.rb +1 -1
- data/lib/ember_cli/runner.rb +3 -1
- data/lib/ember_cli/shell.rb +4 -1
- data/lib/ember_cli/trailing_slash_constraint.rb +0 -0
- data/lib/ember_cli/version.rb +1 -1
- data/lib/ember_cli.rb +5 -0
- data/lib/generators/ember/heroku/USAGE +12 -4
- data/lib/generators/ember/heroku/heroku_generator.rb +39 -9
- data/lib/generators/ember/heroku/templates/package.json.erb +8 -0
- data/lib/generators/ember/heroku/templates/pnpm-lock.yaml.erb +1 -0
- data/lib/generators/ember/heroku/templates/yarn.lock.erb +0 -0
- data/lib/generators/ember/init/USAGE +0 -0
- data/lib/generators/ember/init/init_generator.rb +0 -0
- data/lib/generators/ember/init/templates/initializer.rb +0 -0
- data/lib/tasks/ember-cli.rake +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6524eb048b09d9e7144570bf4c65ede7e324ba40f2ee0631f8c07c9c221be98
|
|
4
|
+
data.tar.gz: a8687bff15afeaefc6261599be718e7d01833237790a9b25c156178f26d692bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9dfcb02b1ad578537c39c1b9758bdd40136bef8deca5470f3ddfa05541dc3bb2030b3f0788ca68b21bae92e2a0f96ccde2fc7392d0e7ef1ea87cd1142217cf7e
|
|
7
|
+
data.tar.gz: 58cfebef2e7e1614beea6a6f93099c98c9f9d0d21964ddd037924e2496aa5015f4f1e19e11fc489e0c4306393f23c693b9704f8837f981e34479dbbeaa69f6ac
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
0.14.0
|
|
2
|
+
------
|
|
3
|
+
|
|
4
|
+
* Add the `package_manager` option to install an application's NodeJS
|
|
5
|
+
dependencies with pnpm (`package_manager: :pnpm`), yarn, or npm. `pnpm_path`
|
|
6
|
+
implies pnpm the way `yarn_path` implies yarn. The package manager is read
|
|
7
|
+
through the new `EmberCli::App#package_manager` and `EmberCli::App#pnpm?`
|
|
8
|
+
* Deprecate `yarn: true` in favour of `package_manager: :yarn`. The shorthand
|
|
9
|
+
still selects yarn, with a deprecation warning, and will be removed in `1.0`
|
|
10
|
+
* Identify a project with a pnpm application to Heroku's NodeJS buildpack
|
|
11
|
+
from `rails generate ember:heroku`, with a root-level `pnpm-lock.yaml`, and
|
|
12
|
+
pin the package manager version in the generated `package.json` from the
|
|
13
|
+
`packageManager` the Ember applications declare, read through the new
|
|
14
|
+
`EmberCli::App#package_manager_spec`
|
|
15
|
+
* Stop adding `rails_12factor` to the `Gemfile` from `rails generate
|
|
16
|
+
ember:heroku`. Rails serves the twelve-factor behaviour the gem backported
|
|
17
|
+
natively since `5.0`, and every Rails version this gem supports is `>= 5.2`.
|
|
18
|
+
To upgrade, remove `rails_12factor` from your project's `Gemfile`
|
|
19
|
+
* Replace `EmberCli::App#yarn_enabled?` with `EmberCli::App#yarn?`
|
|
20
|
+
* Pin the NodeJS version in the `package.json` that `rails generate
|
|
21
|
+
ember:heroku` writes, from the `engines.node` the Ember applications
|
|
22
|
+
declare, read through the new `EmberCli::App#node_engine`. Applications
|
|
23
|
+
that declare different versions are left unpinned
|
|
24
|
+
|
|
25
|
+
0.13.2
|
|
26
|
+
------
|
|
27
|
+
|
|
28
|
+
* Raise `EmberCli::BuildError` when `ember build` or a dependency
|
|
29
|
+
installation fails, instead of exiting the process from inside the gem —
|
|
30
|
+
`rake ember:compile` and `rake ember:install` still exit nonzero
|
|
31
|
+
* Remap the root-relative asset URLs in a Vite build's `index.html` onto the
|
|
32
|
+
mount point when `mount_ember_app` serves the application from a path other
|
|
33
|
+
than `/`, so non-root mounts work without a matching `rootURL`
|
|
34
|
+
|
|
1
35
|
0.13.1
|
|
2
36
|
------
|
|
3
37
|
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
@@ -79,7 +79,10 @@ c.app :frontend, path: "~/projects/my-ember-app"
|
|
|
79
79
|
|
|
80
80
|
- `silent` - this provides `--silent` option for Ember CLI commands to control verbosity of their output.
|
|
81
81
|
|
|
82
|
-
- `
|
|
82
|
+
- `package_manager` - the package manager that installs the application's
|
|
83
|
+
NodeJS dependencies: `:npm` (the default), `:yarn`, or `:pnpm`. Name the
|
|
84
|
+
executable with `npm_path`, `yarn_path`, or `pnpm_path` when it is not on
|
|
85
|
+
the `$PATH`.
|
|
83
86
|
|
|
84
87
|
- `dev_server` - configures [Vite's development server](#vite-based-applications)
|
|
85
88
|
for Vite-based applications in `development`. Pass `false` to opt out of it,
|
|
@@ -142,6 +145,7 @@ end
|
|
|
142
145
|
For instance, mounting `mount_ember_app :frontend, to: "/frontend"` will handle a
|
|
143
146
|
`format: :html` request to `/frontend/posts`.
|
|
144
147
|
*Note:* If you specify a custom path, you must also update the `rootURL` in `frontend/config/environment.js`. See [Mounting multiple Ember applications](#mounting-multiple-ember-applications) for more information.
|
|
148
|
+
*Note:* Requests without `Accept: text/html` — `curl`'s default, most health checkers — skip this route and receive the raw `index.html` from the asset handler.
|
|
145
149
|
* `controller` - Defaults to `"ember_cli/ember"`
|
|
146
150
|
* `action` - Defaults to `"index"`
|
|
147
151
|
|
|
@@ -195,6 +199,8 @@ Rails still renders the application's `index.html`, but reads it from the
|
|
|
195
199
|
development server rather than from disk. The root-relative URLs in that
|
|
196
200
|
document are rewritten to point at the development server, so the browser
|
|
197
201
|
loads the application's modules — and Vite's HMR client — from it directly.
|
|
202
|
+
The rewriting covers every tag the server emits: Vite externalizes even the
|
|
203
|
+
document's inline bootstrapping script.
|
|
198
204
|
Changes to the Ember application are hot-reloaded without reloading the page,
|
|
199
205
|
and without restarting Rails.
|
|
200
206
|
|
|
@@ -238,6 +244,11 @@ end
|
|
|
238
244
|
With `host: "0.0.0.0"`, Rails itself reaches the development server through the
|
|
239
245
|
loopback interface.
|
|
240
246
|
|
|
247
|
+
Vite's default CORS setting allows localhost origins only: to open the page on
|
|
248
|
+
a LAN IP or a custom domain, configure
|
|
249
|
+
[`server.cors`](https://vite.dev/config/server-options#server-cors) in
|
|
250
|
+
`vite.config.*`.
|
|
251
|
+
|
|
241
252
|
The development server's output is written to
|
|
242
253
|
`log/ember-<app>.<environment>.log`.
|
|
243
254
|
|
|
@@ -356,9 +367,7 @@ To configure your EmberCLI-Rails applications for Heroku:
|
|
|
356
367
|
|
|
357
368
|
1. Execute `rails generate ember:heroku`.
|
|
358
369
|
1. Commit the newly generated files.
|
|
359
|
-
1. [Add the NodeJS buildpack][buildpack]
|
|
360
|
-
`bower` dependency's executable file (if your build process requires
|
|
361
|
-
`bower`).
|
|
370
|
+
1. [Add the NodeJS buildpack][buildpack].
|
|
362
371
|
|
|
363
372
|
```sh
|
|
364
373
|
$ heroku buildpacks:clear
|
|
@@ -373,11 +382,30 @@ You are ready to deploy:
|
|
|
373
382
|
$ git push heroku master
|
|
374
383
|
```
|
|
375
384
|
|
|
376
|
-
EmberCLI compilation happens at deploy-time, triggered by the
|
|
385
|
+
EmberCLI compilation happens at deploy-time, triggered by the
|
|
386
|
+
`assets:precompile` rake task. This is the same for both build systems: Vite's
|
|
387
|
+
[development server](#vite-based-applications) only runs in `development`, so
|
|
388
|
+
a Vite-based application deploys exactly like a classic one — `ember build`
|
|
389
|
+
writes to the build directory, and Rails serves the result.
|
|
377
390
|
|
|
378
391
|
**NOTE** Run the generator each time you introduce additional EmberCLI
|
|
379
392
|
applications into the project.
|
|
380
393
|
|
|
394
|
+
**Package manager** — the buildpack installs the package manager the *project
|
|
395
|
+
root's* lockfile names. The generator writes an empty `yarn.lock` or
|
|
396
|
+
`pnpm-lock.yaml` when an application is configured with yarn or pnpm as its
|
|
397
|
+
`package_manager`, and copies the `packageManager` field the Ember
|
|
398
|
+
applications declare into the generated `package.json` so that the buildpack
|
|
399
|
+
installs that version. Without a `packageManager` field the buildpack installs
|
|
400
|
+
the latest pnpm release.
|
|
401
|
+
|
|
402
|
+
**NodeJS version** — the buildpack reads `engines.node` from the *project
|
|
403
|
+
root's* `package.json` (the file the generator writes), not from the Ember
|
|
404
|
+
application's, and builds on the current LTS release when it names no version.
|
|
405
|
+
Make sure the generated file requires a NodeJS that satisfies your Ember
|
|
406
|
+
application's own `engines.node`: applications generated with `ember-cli >=
|
|
407
|
+
6.8` require NodeJS `>= 20.19.0`.
|
|
408
|
+
|
|
381
409
|
[buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
|
|
382
410
|
|
|
383
411
|
#### Slug size
|
|
@@ -392,12 +420,14 @@ A build-pack solution for this is discussed in [Issue #491][#491].
|
|
|
392
420
|
|
|
393
421
|
### Capistrano
|
|
394
422
|
|
|
395
|
-
EmberCLI-Rails
|
|
396
|
-
compilation, triggered by the
|
|
423
|
+
EmberCLI-Rails installs the Ember application's NodeJS dependencies during
|
|
424
|
+
EmberCLI's compilation, triggered by the `assets:precompile` rake task. It runs
|
|
425
|
+
`npm install`, `yarn install`, or `pnpm install`, as the application's
|
|
426
|
+
`package_manager` option names.
|
|
397
427
|
|
|
398
|
-
The
|
|
399
|
-
|
|
400
|
-
|
|
428
|
+
The executables it runs are required to be defined in the deployment SSH
|
|
429
|
+
session's `$PATH`. It is not sufficient to modify the session's `$PATH` in a
|
|
430
|
+
`.bash_profile`.
|
|
401
431
|
|
|
402
432
|
To resolve this issue, prepend the Node installation's `bin` directory to the
|
|
403
433
|
target system's `$PATH`:
|
|
@@ -406,26 +436,26 @@ target system's `$PATH`:
|
|
|
406
436
|
#config/deploy/production.rb
|
|
407
437
|
|
|
408
438
|
set :default_env, {
|
|
409
|
-
"PATH" => "/home/deploy/.nvm/versions/node/
|
|
439
|
+
"PATH" => "/home/deploy/.nvm/versions/node/v22.11.0/bin:$PATH"
|
|
410
440
|
}
|
|
411
441
|
```
|
|
412
442
|
|
|
413
443
|
The system in this example is using `nvm` to configure the node version. If
|
|
414
444
|
you're not using `nvm`, make sure the string you prepend to the `$PATH` variable
|
|
415
|
-
contains the directory or directories that contain the
|
|
416
|
-
|
|
445
|
+
contains the directory or directories that contain the executables above. Point
|
|
446
|
+
it at a NodeJS that satisfies the Ember application's `engines.node`:
|
|
447
|
+
applications generated with `ember-cli >= 6.8` require NodeJS `>= 20.19.0`.
|
|
417
448
|
|
|
418
449
|
#### For faster deployments
|
|
419
450
|
|
|
420
451
|
Place the following in your `deploy/<environment>.rb`
|
|
421
452
|
|
|
422
453
|
```ruby
|
|
423
|
-
set :linked_dirs, %w{<ember-app-name>/node_modules
|
|
454
|
+
set :linked_dirs, %w{<ember-app-name>/node_modules}
|
|
424
455
|
```
|
|
425
456
|
|
|
426
|
-
to avoid rebuilding all the node modules
|
|
427
|
-
|
|
428
|
-
`frontend`).
|
|
457
|
+
to avoid rebuilding all the node modules with every deploy. Replace
|
|
458
|
+
`<ember-app-name>` with the name of your ember app (default is `frontend`).
|
|
429
459
|
|
|
430
460
|
## Override
|
|
431
461
|
|
|
@@ -469,6 +499,9 @@ helper in your view:
|
|
|
469
499
|
The `body` block argument and the corresponding call to `body.append` in the
|
|
470
500
|
example are both optional, and can be omitted.
|
|
471
501
|
|
|
502
|
+
`render_ember_app` emits a complete HTML document, so render it with the
|
|
503
|
+
layout disabled (see below).
|
|
504
|
+
|
|
472
505
|
### Serving Rails-generated CSS
|
|
473
506
|
|
|
474
507
|
For more information on how to work with EmberCLI-generated stylesheets, refer
|
|
@@ -591,7 +624,15 @@ Rails.application.routes.draw do
|
|
|
591
624
|
end
|
|
592
625
|
```
|
|
593
626
|
|
|
594
|
-
|
|
627
|
+
The `index.html` of a Vite build refers to its assets with root-relative URLs.
|
|
628
|
+
When the application is served from the build output, `mount_ember_app` remaps
|
|
629
|
+
those references onto the mount point, where the assets are served — references
|
|
630
|
+
that already carry the mount point, from a `rootURL` configured to match it,
|
|
631
|
+
are left alone. Development-server-backed applications are unaffected: their
|
|
632
|
+
asset URLs point at the development server absolutely.
|
|
633
|
+
|
|
634
|
+
For classic (Broccoli-based) applications, set each Ember application's
|
|
635
|
+
`rootURL` to the mount point:
|
|
595
636
|
|
|
596
637
|
```javascript
|
|
597
638
|
// frontend/config/environment.js
|
|
File without changes
|
|
@@ -8,6 +8,12 @@ module EmberRailsHelper
|
|
|
8
8
|
|
|
9
9
|
head, body = markup_capturer.capture
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
index_html = EmberCli[name].index_html(
|
|
12
|
+
head: head,
|
|
13
|
+
body: body,
|
|
14
|
+
mount_point: params[:ember_mount_point],
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
render html: index_html.html_safe
|
|
12
18
|
end
|
|
13
19
|
end
|
|
File without changes
|
data/lib/ember-cli-rails.rb
CHANGED
|
File without changes
|
data/lib/ember_cli/app.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
1
3
|
require "html_page/renderer"
|
|
2
4
|
require "ember_cli/path_set"
|
|
3
5
|
require "ember_cli/shell"
|
|
@@ -63,11 +65,11 @@ module EmberCli
|
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
67
|
|
|
66
|
-
def index_html(head:, body:)
|
|
68
|
+
def index_html(head:, body:, mount_point: nil)
|
|
67
69
|
html = HtmlPage::Renderer.new(
|
|
68
70
|
head: head,
|
|
69
71
|
body: body,
|
|
70
|
-
content: deploy.index_html,
|
|
72
|
+
content: remap_to_mount_point(deploy.index_html, mount_point),
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
html.render
|
|
@@ -91,14 +93,33 @@ module EmberCli
|
|
|
91
93
|
deploy.mountable?
|
|
92
94
|
end
|
|
93
95
|
|
|
94
|
-
def
|
|
95
|
-
|
|
96
|
+
def package_manager
|
|
97
|
+
paths.package_manager
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def yarn?
|
|
101
|
+
paths.yarn?
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def pnpm?
|
|
105
|
+
paths.pnpm?
|
|
96
106
|
end
|
|
97
107
|
|
|
98
108
|
def bower?
|
|
99
109
|
paths.bower_json.exist?
|
|
100
110
|
end
|
|
101
111
|
|
|
112
|
+
def node_engine
|
|
113
|
+
package_json_value("engines", "node")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# The `packageManager` field of the application's `package.json`, such as
|
|
117
|
+
# `"pnpm@10.0.0"`: the package manager version Corepack and Heroku's
|
|
118
|
+
# NodeJS buildpack install.
|
|
119
|
+
def package_manager_spec
|
|
120
|
+
package_json_value("packageManager")
|
|
121
|
+
end
|
|
122
|
+
|
|
102
123
|
def to_rack
|
|
103
124
|
deploy.to_rack
|
|
104
125
|
end
|
|
@@ -123,6 +144,16 @@ module EmberCli
|
|
|
123
144
|
|
|
124
145
|
private
|
|
125
146
|
|
|
147
|
+
def package_json_value(*keys)
|
|
148
|
+
package_json = paths.package_json
|
|
149
|
+
|
|
150
|
+
if package_json.exist?
|
|
151
|
+
JSON.parse(package_json.read).dig(*keys)
|
|
152
|
+
end
|
|
153
|
+
rescue JSON::ParserError
|
|
154
|
+
nil
|
|
155
|
+
end
|
|
156
|
+
|
|
126
157
|
def development?
|
|
127
158
|
env.to_s == "development"
|
|
128
159
|
end
|
|
@@ -131,6 +162,25 @@ module EmberCli
|
|
|
131
162
|
env.to_s == "test"
|
|
132
163
|
end
|
|
133
164
|
|
|
165
|
+
# The `index.html` of a Vite build refers to its assets with root-relative
|
|
166
|
+
# URLs. When the application is mounted somewhere other than `/`, remap
|
|
167
|
+
# them onto the mount point, where `mount_ember_assets` serves them.
|
|
168
|
+
# References that already carry the mount point — a `rootURL` configured
|
|
169
|
+
# to match it — are left alone.
|
|
170
|
+
def remap_to_mount_point(html, mount_point)
|
|
171
|
+
prefix = mount_point.to_s.chomp("/")
|
|
172
|
+
|
|
173
|
+
if prefix.empty? || !paths.vite?
|
|
174
|
+
return html
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
already_mounted = Regexp.escape(prefix.delete_prefix("/"))
|
|
178
|
+
|
|
179
|
+
html.gsub(%r{(\s)(src|href)=(["'])/(?!/)(?!#{already_mounted}/)}i) do
|
|
180
|
+
"#{$1}#{$2}=#{$3}#{prefix}/"
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
134
184
|
def deploy
|
|
135
185
|
deploy_strategy.new(self)
|
|
136
186
|
end
|
|
File without changes
|
data/lib/ember_cli/command.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/ember_cli/dev_server.rb
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/ember_cli/engine.rb
CHANGED
|
@@ -3,5 +3,13 @@ module EmberCli
|
|
|
3
3
|
initializer "ember-cli-rails.setup" do
|
|
4
4
|
require "ember_cli/route_helpers"
|
|
5
5
|
end
|
|
6
|
+
|
|
7
|
+
# Rails 7.1 and later manage the deprecators of engines with the
|
|
8
|
+
# application's own, so that `config.active_support.deprecation` applies.
|
|
9
|
+
initializer "ember-cli-rails.deprecator" do |app|
|
|
10
|
+
if app.respond_to?(:deprecators)
|
|
11
|
+
app.deprecators[:ember_cli_rails] = EmberCli.deprecator
|
|
12
|
+
end
|
|
13
|
+
end
|
|
6
14
|
end
|
|
7
15
|
end
|
data/lib/ember_cli/errors.rb
CHANGED
|
File without changes
|
data/lib/ember_cli/helpers.rb
CHANGED
|
File without changes
|
data/lib/ember_cli/path_set.rb
CHANGED
|
@@ -2,6 +2,15 @@ require "ember_cli/helpers"
|
|
|
2
2
|
|
|
3
3
|
module EmberCli
|
|
4
4
|
class PathSet
|
|
5
|
+
PACKAGE_MANAGERS = %i[npm yarn pnpm].freeze
|
|
6
|
+
|
|
7
|
+
# npm ships with NodeJS, so it has no installation instructions of its own
|
|
8
|
+
# to point at when its executable is missing.
|
|
9
|
+
INSTALL_INSTRUCTIONS = {
|
|
10
|
+
yarn: "https://yarnpkg.com/lang/en/docs/install/",
|
|
11
|
+
pnpm: "https://pnpm.io/installation",
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
5
14
|
def initialize(app:, rails_root:, ember_cli_root:, environment:)
|
|
6
15
|
@app = app
|
|
7
16
|
@rails_root = rails_root
|
|
@@ -35,6 +44,10 @@ module EmberCli
|
|
|
35
44
|
@gemfile ||= root.join("Gemfile")
|
|
36
45
|
end
|
|
37
46
|
|
|
47
|
+
def package_json
|
|
48
|
+
@package_json ||= root.join("package.json")
|
|
49
|
+
end
|
|
50
|
+
|
|
38
51
|
def bower_json
|
|
39
52
|
root.join("bower.json")
|
|
40
53
|
end
|
|
@@ -117,21 +130,59 @@ module EmberCli
|
|
|
117
130
|
|
|
118
131
|
def yarn
|
|
119
132
|
if yarn?
|
|
120
|
-
@yarn ||=
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
@yarn ||= package_manager_executable(:yarn)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def pnpm
|
|
138
|
+
if pnpm?
|
|
139
|
+
@pnpm ||= package_manager_executable(:pnpm)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
124
142
|
|
|
125
|
-
|
|
143
|
+
def node_modules
|
|
144
|
+
@node_modules ||= root.join("node_modules")
|
|
145
|
+
end
|
|
126
146
|
|
|
127
|
-
|
|
147
|
+
# The package manager that installs the application's NodeJS
|
|
148
|
+
# dependencies: the one the `package_manager` option names, else the one
|
|
149
|
+
# whose executable a `yarn_path` or `pnpm_path` option names, else npm.
|
|
150
|
+
# The deprecated `yarn: true` still selects yarn, with a warning.
|
|
151
|
+
def package_manager
|
|
152
|
+
@package_manager ||= begin
|
|
153
|
+
requested = app_options[:package_manager]
|
|
154
|
+
|
|
155
|
+
if requested.present?
|
|
156
|
+
requested.to_s.to_sym.tap do |name|
|
|
157
|
+
unless PACKAGE_MANAGERS.include?(name)
|
|
158
|
+
fail ArgumentError,
|
|
159
|
+
"Unsupported package manager #{requested.inspect} for " \
|
|
160
|
+
"`#{app_name}`; use one of #{PACKAGE_MANAGERS.inspect}"
|
|
161
|
+
end
|
|
128
162
|
end
|
|
163
|
+
elsif app_options[:yarn].present?
|
|
164
|
+
EmberCli.deprecator.warn(
|
|
165
|
+
"The `yarn` option of the `#{app_name}` Ember application is " \
|
|
166
|
+
"deprecated; configure it with `package_manager: :yarn` instead",
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
:yarn
|
|
170
|
+
elsif app_options[:yarn_path].present?
|
|
171
|
+
:yarn
|
|
172
|
+
elsif app_options[:pnpm_path].present?
|
|
173
|
+
:pnpm
|
|
174
|
+
else
|
|
175
|
+
:npm
|
|
129
176
|
end
|
|
130
177
|
end
|
|
131
178
|
end
|
|
132
179
|
|
|
133
|
-
def
|
|
134
|
-
|
|
180
|
+
def yarn?
|
|
181
|
+
package_manager == :yarn
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def pnpm?
|
|
185
|
+
package_manager == :pnpm
|
|
135
186
|
end
|
|
136
187
|
|
|
137
188
|
def tee
|
|
@@ -161,16 +212,17 @@ module EmberCli
|
|
|
161
212
|
end
|
|
162
213
|
end
|
|
163
214
|
|
|
164
|
-
def
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
end
|
|
170
|
-
end
|
|
215
|
+
def package_manager_executable(name)
|
|
216
|
+
path_for_executable(name.to_s).tap do |path|
|
|
217
|
+
unless File.executable?(path.to_s)
|
|
218
|
+
fail DependencyError.new(<<-MSG.strip_heredoc)
|
|
219
|
+
EmberCLI has been configured to install NodeJS dependencies with #{name}, but the #{name} executable is unavailable.
|
|
171
220
|
|
|
172
|
-
|
|
173
|
-
|
|
221
|
+
Install it by following the instructions at #{INSTALL_INSTRUCTIONS.fetch(name)}
|
|
222
|
+
|
|
223
|
+
MSG
|
|
224
|
+
end
|
|
225
|
+
end
|
|
174
226
|
end
|
|
175
227
|
|
|
176
228
|
def app_name
|
data/lib/ember_cli/runner.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "open3"
|
|
2
2
|
|
|
3
|
+
require "ember_cli/errors"
|
|
4
|
+
|
|
3
5
|
module EmberCli
|
|
4
6
|
class Runner
|
|
5
7
|
def initialize(out:, err:, env: {}, options: {})
|
|
@@ -25,7 +27,7 @@ module EmberCli
|
|
|
25
27
|
def run!(command)
|
|
26
28
|
run(command).tap do |status|
|
|
27
29
|
unless status.success?
|
|
28
|
-
|
|
30
|
+
fail BuildError, "`#{command}` failed with status #{status.exitstatus}"
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
end
|
data/lib/ember_cli/shell.rb
CHANGED
|
@@ -69,8 +69,11 @@ module EmberCli
|
|
|
69
69
|
clean_ember_dependencies!
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
case paths.package_manager
|
|
73
|
+
when :yarn
|
|
73
74
|
run! "#{paths.yarn} install"
|
|
75
|
+
when :pnpm
|
|
76
|
+
run! "#{paths.pnpm} install"
|
|
74
77
|
else
|
|
75
78
|
run! "#{paths.npm} prune && #{paths.npm} install"
|
|
76
79
|
end
|
|
File without changes
|
data/lib/ember_cli/version.rb
CHANGED
data/lib/ember_cli.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "fileutils"
|
|
2
|
+
require "active_support/deprecation"
|
|
2
3
|
require "ember-cli-rails-assets"
|
|
3
4
|
require "ember_cli/engine"
|
|
4
5
|
require "ember_cli/configuration"
|
|
@@ -16,6 +17,10 @@ module EmberCli
|
|
|
16
17
|
Configuration.instance
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
def deprecator
|
|
21
|
+
@deprecator ||= ActiveSupport::Deprecation.new("1.0", "ember-cli-rails")
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
def app(name)
|
|
20
25
|
apps.fetch(name) do
|
|
21
26
|
fail KeyError, "#{name.inspect} app is not defined"
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
Description:
|
|
2
2
|
Configures a project for deploying to Heroku.
|
|
3
3
|
|
|
4
|
-
Once the generator is complete,
|
|
4
|
+
Once the generator is complete, add the buildpacks the deploy needs:
|
|
5
5
|
|
|
6
6
|
$ heroku buildpacks:clear
|
|
7
7
|
$ heroku buildpacks:add --index 1 heroku/nodejs
|
|
8
8
|
$ heroku buildpacks:add --index 2 heroku/ruby
|
|
9
|
+
|
|
10
|
+
`SKIP_EMBER` skips the build wherever it is set. Unset it on the Heroku
|
|
11
|
+
application, so that `assets:precompile` compiles the EmberCLI
|
|
12
|
+
applications at deploy time:
|
|
13
|
+
|
|
9
14
|
$ heroku config:unset SKIP_EMBER
|
|
10
15
|
|
|
11
16
|
Example:
|
|
12
17
|
rails generate ember:heroku
|
|
13
18
|
|
|
14
|
-
This will install the following gems:
|
|
15
|
-
rails_12factor
|
|
16
|
-
|
|
17
19
|
This will create:
|
|
18
20
|
package.json
|
|
21
|
+
|
|
22
|
+
An application configured with `yarn` also creates:
|
|
23
|
+
yarn.lock
|
|
24
|
+
|
|
25
|
+
Run the generator again whenever you add an EmberCLI application: the
|
|
26
|
+
generated `cacheDirectories` names each application's `node_modules`.
|
|
@@ -9,17 +9,53 @@ module EmberCli
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def identify_as_yarn_project
|
|
12
|
-
if EmberCli.any?(&:
|
|
12
|
+
if EmberCli.any?(&:yarn?)
|
|
13
13
|
template "yarn.lock.erb", "yarn.lock"
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def
|
|
18
|
-
|
|
17
|
+
def identify_as_pnpm_project
|
|
18
|
+
if EmberCli.any?(&:pnpm?)
|
|
19
|
+
template "pnpm-lock.yaml.erb", "pnpm-lock.yaml"
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
private
|
|
22
24
|
|
|
25
|
+
def node_engine
|
|
26
|
+
unless defined?(@node_engine)
|
|
27
|
+
@node_engine = shared_declaration("engines.node", &:node_engine)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
@node_engine
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def package_manager_spec
|
|
34
|
+
unless defined?(@package_manager_spec)
|
|
35
|
+
@package_manager_spec = shared_declaration("packageManager", &:package_manager_spec)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
@package_manager_spec
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The value every Ember application declares for a `package.json` field, or nil when they declare different ones:
|
|
42
|
+
# the generated `package.json` can only carry one, and picking either would silently break the other application's build.
|
|
43
|
+
def shared_declaration(field)
|
|
44
|
+
declared = apps.map { |app| yield app }.compact.uniq
|
|
45
|
+
|
|
46
|
+
if declared.size > 1
|
|
47
|
+
say_status(
|
|
48
|
+
:conflict,
|
|
49
|
+
"Ember applications declare different `#{field}` (#{declared.join(", ")}); pin one in package.json by hand",
|
|
50
|
+
:red,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
nil
|
|
54
|
+
else
|
|
55
|
+
declared.first
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
23
59
|
def cache_directories
|
|
24
60
|
all_cached_directories.map do |cached_directory|
|
|
25
61
|
cached_directory.relative_path_from(Rails.root).to_s
|
|
@@ -38,12 +74,6 @@ module EmberCli
|
|
|
38
74
|
[Rails.root.join("node_modules")]
|
|
39
75
|
end
|
|
40
76
|
|
|
41
|
-
def app_paths
|
|
42
|
-
EmberCli.apps.values.map do |app|
|
|
43
|
-
app.root_path.relative_path_from(Rails.root)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
77
|
def apps
|
|
48
78
|
EmberCli.apps.values
|
|
49
79
|
end
|
|
@@ -4,5 +4,13 @@
|
|
|
4
4
|
"bower": "*"
|
|
5
5
|
},
|
|
6
6
|
<% end %>
|
|
7
|
+
<% if package_manager_spec %>
|
|
8
|
+
"packageManager": <%= package_manager_spec.to_json %>,
|
|
9
|
+
<% end %>
|
|
10
|
+
<% if node_engine %>
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": <%= node_engine.to_json %>
|
|
13
|
+
},
|
|
14
|
+
<% end %>
|
|
7
15
|
"cacheDirectories": <%= cache_directories.to_json %>
|
|
8
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/tasks/ember-cli.rake
CHANGED
|
File without changes
|
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.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pavel Pravosud
|
|
@@ -194,6 +194,7 @@ files:
|
|
|
194
194
|
- lib/generators/ember/heroku/USAGE
|
|
195
195
|
- lib/generators/ember/heroku/heroku_generator.rb
|
|
196
196
|
- lib/generators/ember/heroku/templates/package.json.erb
|
|
197
|
+
- lib/generators/ember/heroku/templates/pnpm-lock.yaml.erb
|
|
197
198
|
- lib/generators/ember/heroku/templates/yarn.lock.erb
|
|
198
199
|
- lib/generators/ember/init/USAGE
|
|
199
200
|
- lib/generators/ember/init/init_generator.rb
|
|
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
217
218
|
- !ruby/object:Gem::Version
|
|
218
219
|
version: '0'
|
|
219
220
|
requirements: []
|
|
220
|
-
rubygems_version: 4.0.
|
|
221
|
+
rubygems_version: 4.0.16
|
|
221
222
|
specification_version: 4
|
|
222
223
|
summary: Integration between Ember CLI and Rails
|
|
223
224
|
test_files: []
|