ember-cli-rails 0.13.2 → 0.14.1
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 +51 -0
- data/LICENSE.txt +0 -0
- data/README.md +42 -18
- data/app/controller/ember_cli/ember_controller.rb +0 -0
- data/app/helpers/ember_rails_helper.rb +0 -0
- 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 +33 -2
- data/lib/ember_cli/build_monitor.rb +4 -3
- data/lib/ember_cli/command.rb +48 -10
- 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 +81 -19
- data/lib/ember_cli/route_helpers.rb +0 -0
- data/lib/ember_cli/runner.rb +0 -0
- 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: 89fb2f98a617de8c232e28b044db803f37f5a0b94147bdff07ebf45be3338d7f
|
|
4
|
+
data.tar.gz: 572e612fcac29c7cb1f4d74a28b40e839a07906a4bdca14d03ba1ba4e44c9577
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 631a8276c052830df276b0a53c4ccb46f2b80a6f71ef346002fe260222bc9f4852efc38ddab155c92af8a67e9efad2ab5c91124af2b34eb7cc942f418d097aeb
|
|
7
|
+
data.tar.gz: 1dbc29b10d0f912dd1f9d19419a00d6df87311d6d9e4d2b9448812848916ad53745e81900b7e538e894da77d58987ed7831a18d47da6b0f6476b8f87b4449af0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
0.14.1
|
|
2
|
+
------
|
|
3
|
+
|
|
4
|
+
* Build a Vite-based application with `vite build`, the command its own
|
|
5
|
+
`build` script runs, rather than with `ember build`. `ember build --help`
|
|
6
|
+
calls itself a "Vestigial command in Vite-based projects" and points at
|
|
7
|
+
that script. What the build writes is unchanged, and so is the classic
|
|
8
|
+
blueprint, which keeps building with `ember build`. The `silent` option
|
|
9
|
+
now quiets a Vite build with `--logLevel error`, which drops the progress
|
|
10
|
+
output and keeps the errors
|
|
11
|
+
* Recognise an application as Vite-based from any of the six names Vite
|
|
12
|
+
resolves its configuration from, rather than only `vite.config.js`,
|
|
13
|
+
`vite.config.mjs` and `vite.config.ts`. An application configured in
|
|
14
|
+
`vite.config.mts`, `vite.config.cts` or `vite.config.cjs` was taken for a
|
|
15
|
+
classic one and served with `ember build --watch`, which a Vite-based
|
|
16
|
+
project rejects
|
|
17
|
+
* Report the whole build failure of a classic application in the
|
|
18
|
+
`EmberCli::BuildError` message, instead of only its first line. Such an
|
|
19
|
+
application builds in the background, and `BuildMonitor` turns what
|
|
20
|
+
`ember build --watch` writes into the exception; the line naming the file
|
|
21
|
+
that failed to build is rarely the first one, so a parse error arrived
|
|
22
|
+
with its message and line number but no way to tell which file it came
|
|
23
|
+
from
|
|
24
|
+
* Pass `--watcher` to `ember build` only when the build watches. The flag
|
|
25
|
+
names the backend that watches the file system, so it did nothing for a
|
|
26
|
+
one-off build
|
|
27
|
+
|
|
28
|
+
0.14.0
|
|
29
|
+
------
|
|
30
|
+
|
|
31
|
+
* Add the `package_manager` option to install an application's NodeJS
|
|
32
|
+
dependencies with pnpm (`package_manager: :pnpm`), yarn, or npm. `pnpm_path`
|
|
33
|
+
implies pnpm the way `yarn_path` implies yarn. The package manager is read
|
|
34
|
+
through the new `EmberCli::App#package_manager` and `EmberCli::App#pnpm?`
|
|
35
|
+
* Deprecate `yarn: true` in favour of `package_manager: :yarn`. The shorthand
|
|
36
|
+
still selects yarn, with a deprecation warning, and will be removed in `1.0`
|
|
37
|
+
* Identify a project with a pnpm application to Heroku's NodeJS buildpack
|
|
38
|
+
from `rails generate ember:heroku`, with a root-level `pnpm-lock.yaml`, and
|
|
39
|
+
pin the package manager version in the generated `package.json` from the
|
|
40
|
+
`packageManager` the Ember applications declare, read through the new
|
|
41
|
+
`EmberCli::App#package_manager_spec`
|
|
42
|
+
* Stop adding `rails_12factor` to the `Gemfile` from `rails generate
|
|
43
|
+
ember:heroku`. Rails serves the twelve-factor behaviour the gem backported
|
|
44
|
+
natively since `5.0`, and every Rails version this gem supports is `>= 5.2`.
|
|
45
|
+
To upgrade, remove `rails_12factor` from your project's `Gemfile`
|
|
46
|
+
* Replace `EmberCli::App#yarn_enabled?` with `EmberCli::App#yarn?`
|
|
47
|
+
* Pin the NodeJS version in the `package.json` that `rails generate
|
|
48
|
+
ember:heroku` writes, from the `engines.node` the Ember applications
|
|
49
|
+
declare, read through the new `EmberCli::App#node_engine`. Applications
|
|
50
|
+
that declare different versions are left unpinned
|
|
51
|
+
|
|
1
52
|
0.13.2
|
|
2
53
|
------
|
|
3
54
|
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
@@ -77,9 +77,14 @@ c.app :frontend, path: "~/projects/my-ember-app"
|
|
|
77
77
|
- `path` - the path where your Ember CLI application is located. The default
|
|
78
78
|
value is the name of your app in the Rails root.
|
|
79
79
|
|
|
80
|
-
- `silent` -
|
|
80
|
+
- `silent` - quiets the build. A classic application is built with
|
|
81
|
+
`ember build --silent`; a Vite-based one with `vite build --logLevel error`,
|
|
82
|
+
which keeps errors while dropping the progress output.
|
|
81
83
|
|
|
82
|
-
- `
|
|
84
|
+
- `package_manager` - the package manager that installs the application's
|
|
85
|
+
NodeJS dependencies: `:npm` (the default), `:yarn`, or `:pnpm`. Name the
|
|
86
|
+
executable with `npm_path`, `yarn_path`, or `pnpm_path` when it is not on
|
|
87
|
+
the `$PATH`.
|
|
83
88
|
|
|
84
89
|
- `dev_server` - configures [Vite's development server](#vite-based-applications)
|
|
85
90
|
for Vite-based applications in `development`. Pass `false` to opt out of it,
|
|
@@ -364,9 +369,7 @@ To configure your EmberCLI-Rails applications for Heroku:
|
|
|
364
369
|
|
|
365
370
|
1. Execute `rails generate ember:heroku`.
|
|
366
371
|
1. Commit the newly generated files.
|
|
367
|
-
1. [Add the NodeJS buildpack][buildpack]
|
|
368
|
-
`bower` dependency's executable file (if your build process requires
|
|
369
|
-
`bower`).
|
|
372
|
+
1. [Add the NodeJS buildpack][buildpack].
|
|
370
373
|
|
|
371
374
|
```sh
|
|
372
375
|
$ heroku buildpacks:clear
|
|
@@ -381,11 +384,30 @@ You are ready to deploy:
|
|
|
381
384
|
$ git push heroku master
|
|
382
385
|
```
|
|
383
386
|
|
|
384
|
-
EmberCLI compilation happens at deploy-time, triggered by the
|
|
387
|
+
EmberCLI compilation happens at deploy-time, triggered by the
|
|
388
|
+
`assets:precompile` rake task. This is the same for both build systems: Vite's
|
|
389
|
+
[development server](#vite-based-applications) only runs in `development`, so
|
|
390
|
+
a Vite-based application deploys exactly like a classic one — `ember build`
|
|
391
|
+
writes to the build directory, and Rails serves the result.
|
|
385
392
|
|
|
386
393
|
**NOTE** Run the generator each time you introduce additional EmberCLI
|
|
387
394
|
applications into the project.
|
|
388
395
|
|
|
396
|
+
**Package manager** — the buildpack installs the package manager the *project
|
|
397
|
+
root's* lockfile names. The generator writes an empty `yarn.lock` or
|
|
398
|
+
`pnpm-lock.yaml` when an application is configured with yarn or pnpm as its
|
|
399
|
+
`package_manager`, and copies the `packageManager` field the Ember
|
|
400
|
+
applications declare into the generated `package.json` so that the buildpack
|
|
401
|
+
installs that version. Without a `packageManager` field the buildpack installs
|
|
402
|
+
the latest pnpm release.
|
|
403
|
+
|
|
404
|
+
**NodeJS version** — the buildpack reads `engines.node` from the *project
|
|
405
|
+
root's* `package.json` (the file the generator writes), not from the Ember
|
|
406
|
+
application's, and builds on the current LTS release when it names no version.
|
|
407
|
+
Make sure the generated file requires a NodeJS that satisfies your Ember
|
|
408
|
+
application's own `engines.node`: applications generated with `ember-cli >=
|
|
409
|
+
6.8` require NodeJS `>= 20.19.0`.
|
|
410
|
+
|
|
389
411
|
[buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
|
|
390
412
|
|
|
391
413
|
#### Slug size
|
|
@@ -400,12 +422,14 @@ A build-pack solution for this is discussed in [Issue #491][#491].
|
|
|
400
422
|
|
|
401
423
|
### Capistrano
|
|
402
424
|
|
|
403
|
-
EmberCLI-Rails
|
|
404
|
-
compilation, triggered by the
|
|
425
|
+
EmberCLI-Rails installs the Ember application's NodeJS dependencies during
|
|
426
|
+
EmberCLI's compilation, triggered by the `assets:precompile` rake task. It runs
|
|
427
|
+
`npm install`, `yarn install`, or `pnpm install`, as the application's
|
|
428
|
+
`package_manager` option names.
|
|
405
429
|
|
|
406
|
-
The
|
|
407
|
-
|
|
408
|
-
|
|
430
|
+
The executables it runs are required to be defined in the deployment SSH
|
|
431
|
+
session's `$PATH`. It is not sufficient to modify the session's `$PATH` in a
|
|
432
|
+
`.bash_profile`.
|
|
409
433
|
|
|
410
434
|
To resolve this issue, prepend the Node installation's `bin` directory to the
|
|
411
435
|
target system's `$PATH`:
|
|
@@ -414,26 +438,26 @@ target system's `$PATH`:
|
|
|
414
438
|
#config/deploy/production.rb
|
|
415
439
|
|
|
416
440
|
set :default_env, {
|
|
417
|
-
"PATH" => "/home/deploy/.nvm/versions/node/
|
|
441
|
+
"PATH" => "/home/deploy/.nvm/versions/node/v22.11.0/bin:$PATH"
|
|
418
442
|
}
|
|
419
443
|
```
|
|
420
444
|
|
|
421
445
|
The system in this example is using `nvm` to configure the node version. If
|
|
422
446
|
you're not using `nvm`, make sure the string you prepend to the `$PATH` variable
|
|
423
|
-
contains the directory or directories that contain the
|
|
424
|
-
|
|
447
|
+
contains the directory or directories that contain the executables above. Point
|
|
448
|
+
it at a NodeJS that satisfies the Ember application's `engines.node`:
|
|
449
|
+
applications generated with `ember-cli >= 6.8` require NodeJS `>= 20.19.0`.
|
|
425
450
|
|
|
426
451
|
#### For faster deployments
|
|
427
452
|
|
|
428
453
|
Place the following in your `deploy/<environment>.rb`
|
|
429
454
|
|
|
430
455
|
```ruby
|
|
431
|
-
set :linked_dirs, %w{<ember-app-name>/node_modules
|
|
456
|
+
set :linked_dirs, %w{<ember-app-name>/node_modules}
|
|
432
457
|
```
|
|
433
458
|
|
|
434
|
-
to avoid rebuilding all the node modules
|
|
435
|
-
|
|
436
|
-
`frontend`).
|
|
459
|
+
to avoid rebuilding all the node modules with every deploy. Replace
|
|
460
|
+
`<ember-app-name>` with the name of your ember app (default is `frontend`).
|
|
437
461
|
|
|
438
462
|
## Override
|
|
439
463
|
|
|
File without changes
|
|
File without changes
|
|
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"
|
|
@@ -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
|
|
@@ -41,6 +41,7 @@ module EmberCli
|
|
|
41
41
|
|
|
42
42
|
def build_errors
|
|
43
43
|
error_lines.
|
|
44
|
+
map(&:chomp).
|
|
44
45
|
reject { |line| is_blank_or_backtrace?(line) }.
|
|
45
46
|
reject { |line| is_deprecation_warning?(line) }.
|
|
46
47
|
reject { |line| is_building_notice?(line) }
|
|
@@ -75,11 +76,11 @@ module EmberCli
|
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
def raise_build_error!
|
|
78
|
-
|
|
79
|
-
message = "#{name.inspect} has failed to build: #{
|
|
79
|
+
errors = build_errors
|
|
80
|
+
message = "#{name.inspect} has failed to build: #{errors.join("\n")}"
|
|
80
81
|
|
|
81
82
|
error = BuildError.new(message)
|
|
82
|
-
error.set_backtrace(
|
|
83
|
+
error.set_backtrace(errors)
|
|
83
84
|
|
|
84
85
|
fail error
|
|
85
86
|
end
|
data/lib/ember_cli/command.rb
CHANGED
|
@@ -14,7 +14,11 @@ module EmberCli
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def build(watch: false)
|
|
17
|
-
|
|
17
|
+
if paths.vite?
|
|
18
|
+
vite_build
|
|
19
|
+
else
|
|
20
|
+
ember_build(watch: watch)
|
|
21
|
+
end
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
# Boots Vite's development server for an application generated with the
|
|
@@ -43,11 +47,53 @@ module EmberCli
|
|
|
43
47
|
options.fetch(:silent) { false }
|
|
44
48
|
end
|
|
45
49
|
|
|
50
|
+
def build_environment
|
|
51
|
+
if EmberCli.env == "production"
|
|
52
|
+
"production"
|
|
53
|
+
else
|
|
54
|
+
"development"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# The Vite-based blueprint (`ember-cli >= 6.8`)
|
|
59
|
+
#
|
|
60
|
+
# Builds the application the way its own `build` script does.
|
|
61
|
+
# `ember build` still drives such a build today, but `ember build --help`
|
|
62
|
+
# calls it a "Vestigial command in Vite-based projects" and has dropped
|
|
63
|
+
# every option but `--environment`, `--suppress-sizes` and
|
|
64
|
+
# `--output-path`.
|
|
65
|
+
#
|
|
66
|
+
# `--emptyOutDir` is needed because the output directory is outside the
|
|
67
|
+
# Ember application, where Vite leaves stale files in place unless asked
|
|
68
|
+
# to clear them.
|
|
69
|
+
def vite_build
|
|
70
|
+
line = Terrapin::CommandLine.new(paths.vite, [
|
|
71
|
+
"build",
|
|
72
|
+
"--mode :mode",
|
|
73
|
+
"--outDir :output_path",
|
|
74
|
+
"--emptyOutDir",
|
|
75
|
+
("--logLevel error" if silent?),
|
|
76
|
+
].compact.join(" "))
|
|
77
|
+
|
|
78
|
+
line.command(
|
|
79
|
+
mode: build_environment,
|
|
80
|
+
output_path: paths.dist,
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# The classic blueprint
|
|
85
|
+
#
|
|
86
|
+
# Builds the application with `ember build`, which watches for changes
|
|
87
|
+
# when asked. A Vite-based project has no equivalent: `ember build` there
|
|
88
|
+
# refuses `--watch`, and its development server watches instead.
|
|
89
|
+
#
|
|
90
|
+
# `--watcher` names the backend that watches, so it rides along only
|
|
91
|
+
# when the build watches.
|
|
46
92
|
def ember_build(watch: false)
|
|
47
93
|
line = Terrapin::CommandLine.new(paths.ember, [
|
|
48
94
|
"build",
|
|
49
95
|
("--watch" if watch),
|
|
50
|
-
("--watcher :watcher" if process_watcher),
|
|
96
|
+
("--watcher :watcher" if watch && process_watcher),
|
|
51
97
|
("--silent" if silent?),
|
|
52
98
|
"--environment :environment",
|
|
53
99
|
"--output-path :output_path",
|
|
@@ -59,13 +105,5 @@ module EmberCli
|
|
|
59
105
|
watcher: process_watcher,
|
|
60
106
|
)
|
|
61
107
|
end
|
|
62
|
-
|
|
63
|
-
def build_environment
|
|
64
|
-
if EmberCli.env == "production"
|
|
65
|
-
"production"
|
|
66
|
-
else
|
|
67
|
-
"development"
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
108
|
end
|
|
71
109
|
end
|
|
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,26 @@ require "ember_cli/helpers"
|
|
|
2
2
|
|
|
3
3
|
module EmberCli
|
|
4
4
|
class PathSet
|
|
5
|
+
PACKAGE_MANAGERS = %i[npm yarn pnpm].freeze
|
|
6
|
+
|
|
7
|
+
# Every name Vite resolves its configuration file from. An application
|
|
8
|
+
# that keeps its configuration under any of them is Vite-based.
|
|
9
|
+
VITE_CONFIG_FILES = %w[
|
|
10
|
+
vite.config.js
|
|
11
|
+
vite.config.mjs
|
|
12
|
+
vite.config.cjs
|
|
13
|
+
vite.config.ts
|
|
14
|
+
vite.config.mts
|
|
15
|
+
vite.config.cts
|
|
16
|
+
].freeze
|
|
17
|
+
|
|
18
|
+
# npm ships with NodeJS, so it has no installation instructions of its own
|
|
19
|
+
# to point at when its executable is missing.
|
|
20
|
+
INSTALL_INSTRUCTIONS = {
|
|
21
|
+
yarn: "https://yarnpkg.com/lang/en/docs/install/",
|
|
22
|
+
pnpm: "https://pnpm.io/installation",
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
5
25
|
def initialize(app:, rails_root:, ember_cli_root:, environment:)
|
|
6
26
|
@app = app
|
|
7
27
|
@rails_root = rails_root
|
|
@@ -35,6 +55,10 @@ module EmberCli
|
|
|
35
55
|
@gemfile ||= root.join("Gemfile")
|
|
36
56
|
end
|
|
37
57
|
|
|
58
|
+
def package_json
|
|
59
|
+
@package_json ||= root.join("package.json")
|
|
60
|
+
end
|
|
61
|
+
|
|
38
62
|
def bower_json
|
|
39
63
|
root.join("bower.json")
|
|
40
64
|
end
|
|
@@ -42,8 +66,7 @@ module EmberCli
|
|
|
42
66
|
# Apps generated with the Vite-based blueprint (`ember-cli >= 6.8`)
|
|
43
67
|
# ship a Vite config file at their root.
|
|
44
68
|
def vite?
|
|
45
|
-
|
|
46
|
-
any? { |config| root.join(config).exist? }
|
|
69
|
+
VITE_CONFIG_FILES.any? { |config| root.join(config).exist? }
|
|
47
70
|
end
|
|
48
71
|
|
|
49
72
|
def ember
|
|
@@ -117,21 +140,59 @@ module EmberCli
|
|
|
117
140
|
|
|
118
141
|
def yarn
|
|
119
142
|
if yarn?
|
|
120
|
-
@yarn ||=
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
@yarn ||= package_manager_executable(:yarn)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def pnpm
|
|
148
|
+
if pnpm?
|
|
149
|
+
@pnpm ||= package_manager_executable(:pnpm)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
124
152
|
|
|
125
|
-
|
|
153
|
+
def node_modules
|
|
154
|
+
@node_modules ||= root.join("node_modules")
|
|
155
|
+
end
|
|
126
156
|
|
|
127
|
-
|
|
157
|
+
# The package manager that installs the application's NodeJS
|
|
158
|
+
# dependencies: the one the `package_manager` option names, else the one
|
|
159
|
+
# whose executable a `yarn_path` or `pnpm_path` option names, else npm.
|
|
160
|
+
# The deprecated `yarn: true` still selects yarn, with a warning.
|
|
161
|
+
def package_manager
|
|
162
|
+
@package_manager ||= begin
|
|
163
|
+
requested = app_options[:package_manager]
|
|
164
|
+
|
|
165
|
+
if requested.present?
|
|
166
|
+
requested.to_s.to_sym.tap do |name|
|
|
167
|
+
unless PACKAGE_MANAGERS.include?(name)
|
|
168
|
+
fail ArgumentError,
|
|
169
|
+
"Unsupported package manager #{requested.inspect} for " \
|
|
170
|
+
"`#{app_name}`; use one of #{PACKAGE_MANAGERS.inspect}"
|
|
171
|
+
end
|
|
128
172
|
end
|
|
173
|
+
elsif app_options[:yarn].present?
|
|
174
|
+
EmberCli.deprecator.warn(
|
|
175
|
+
"The `yarn` option of the `#{app_name}` Ember application is " \
|
|
176
|
+
"deprecated; configure it with `package_manager: :yarn` instead",
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
:yarn
|
|
180
|
+
elsif app_options[:yarn_path].present?
|
|
181
|
+
:yarn
|
|
182
|
+
elsif app_options[:pnpm_path].present?
|
|
183
|
+
:pnpm
|
|
184
|
+
else
|
|
185
|
+
:npm
|
|
129
186
|
end
|
|
130
187
|
end
|
|
131
188
|
end
|
|
132
189
|
|
|
133
|
-
def
|
|
134
|
-
|
|
190
|
+
def yarn?
|
|
191
|
+
package_manager == :yarn
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def pnpm?
|
|
195
|
+
package_manager == :pnpm
|
|
135
196
|
end
|
|
136
197
|
|
|
137
198
|
def tee
|
|
@@ -161,16 +222,17 @@ module EmberCli
|
|
|
161
222
|
end
|
|
162
223
|
end
|
|
163
224
|
|
|
164
|
-
def
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
end
|
|
170
|
-
end
|
|
225
|
+
def package_manager_executable(name)
|
|
226
|
+
path_for_executable(name.to_s).tap do |path|
|
|
227
|
+
unless File.executable?(path.to_s)
|
|
228
|
+
fail DependencyError.new(<<-MSG.strip_heredoc)
|
|
229
|
+
EmberCLI has been configured to install NodeJS dependencies with #{name}, but the #{name} executable is unavailable.
|
|
171
230
|
|
|
172
|
-
|
|
173
|
-
|
|
231
|
+
Install it by following the instructions at #{INSTALL_INSTRUCTIONS.fetch(name)}
|
|
232
|
+
|
|
233
|
+
MSG
|
|
234
|
+
end
|
|
235
|
+
end
|
|
174
236
|
end
|
|
175
237
|
|
|
176
238
|
def app_name
|
|
File without changes
|
data/lib/ember_cli/runner.rb
CHANGED
|
File without changes
|
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.1
|
|
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: []
|