ember-cli-rails 0.6.1 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c875893e377992ea0a7935ecff7b435f27f3dd8a
4
- data.tar.gz: 20a40093eb23312813a4932a4471d4464e4c651e
3
+ metadata.gz: f36a51e987ca3f318c486ebb3827e3b033eea0f0
4
+ data.tar.gz: a3b9cd8366e58423d70eab4de81d042f55fc86c7
5
5
  SHA512:
6
- metadata.gz: a39aafa84caed46cd0007c4214e73d68268066a6be1c10a9ed0a9f164c461c68f54600beecbae9c2b14703aaca02f29f25e0546335fc3a484089278468250fc7
7
- data.tar.gz: a07e683152ffe4fb647baad272dda0535eabc8b2aaafb95468a31ca664d8d43ab2cb7ae4671ef57f41bef5171238610b1a3660300ddfddf3a67a4cfde7be587d
6
+ metadata.gz: 15b9f51c70c042c3eb3b7ff915cbf1269a8ebc23bf76c1d30d56242d645a19775596f3086dd02ac5a0923a40a2223db10c6d0e20b84cee0bad80c417d3a26733
7
+ data.tar.gz: 52e7f0822e858e957e4a72277a0e6645eaf9fea6b00c803e52e7673e531edd96e52a5f5f78a562a63876f24be4195e73ca87d1f61f6b952ed947667b4d320d40
@@ -1,6 +1,15 @@
1
1
  master
2
2
  ------
3
3
 
4
+ 0.7.0
5
+ -----
6
+
7
+ * Introduce the `deploy` configuration option.
8
+ * Translate Rails environments other than `test` or `development` to
9
+ `production`, unless an `EMBER_ENV` is specified. [#366]
10
+
11
+ [#366]: https://github.com/thoughtbot/ember-cli-rails/pull/366
12
+
4
13
  0.6.1
5
14
  -----
6
15
 
data/README.md CHANGED
@@ -201,6 +201,38 @@ As long as your [CDN is configured to pull from your Rails application][dns-cdn]
201
201
 
202
202
  [dns-cdn]: https://robots.thoughtbot.com/dns-cdn-origin
203
203
 
204
+ ### Deployment Strategies
205
+
206
+ By default, EmberCLI-Rails will serve the `index.html` file that `ember build`
207
+ produces.
208
+
209
+ If you need to override this behavior (for instance, if you're using
210
+ [`ember-cli-deploy`'s "Lightning Fast Deployment"][lightning] strategy in
211
+ `production`), you can specify the strategy's class in the initializer:
212
+
213
+ ```rb
214
+ EmberCli.configure do |config|
215
+ config.app :frontend, deploy: { production: EmberCli::Deploy::Redis }
216
+ end
217
+ ```
218
+
219
+ This example configures the `frontend` Ember application to retrieve the
220
+ index's HTML from an [`ember-cli-deploy-redis`][ember-cli-deploy-redis]
221
+ -populated Redis entry using the
222
+ [`ember-cli-rails-deploy-redis`][ember-cli-rails-deploy-redis] gem.
223
+
224
+ If you're deploying HTML with a custom strategy in `development` or `test`,
225
+ disable EmberCLI-Rails' build step by setting `ENV["SKIP_EMBER"] = true`.
226
+
227
+ **NOTE:**
228
+
229
+ Specifying a deployment strategy is only supported for applications that use the
230
+ `mount_ember_app` and `render_ember_app` helpers.
231
+
232
+ [ember-cli-deploy-redis]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis
233
+ [ember-cli-rails-deploy-redis]: https://github.com/seanpdoyle/ember-cli-rails-deploy-redis
234
+ [lightning]: https://github.com/ember-cli-deploy/ember-cli-deploy-lightning-pack
235
+
204
236
  ### Heroku
205
237
 
206
238
  To configure your EmberCLI-Rails applications for Heroku:
@@ -492,6 +524,22 @@ EmberCLI runners to clobber each others' work][#94].
492
524
  [Unicorn]: https://rubygems.org/gems/unicorn
493
525
  [#94]: https://github.com/thoughtbot/ember-cli-rails/issues/94#issuecomment-77627453
494
526
 
527
+ ## `SKIP_EMBER`
528
+
529
+ If set on the environment, `SKIP_EMBER` will configure `ember-cli-rails` to skip
530
+ the build step entirely. This is useful if you're using an alternative
531
+ deployment strategy in the `test` or `development` environment. By default,
532
+ `ember-cli-rails` will skip the build step in `production`-like environments.
533
+
534
+ ## `EMBER_ENV`
535
+
536
+ If set on the environment, the value of `EMBER_ENV` will be passed to the
537
+ `ember` process as the value of the `--environment` flag.
538
+
539
+ If `EMBER_ENV` is unspecified, the current Rails environment will be passed to
540
+ the `ember` process, with the exception of non-standard Rails environments,
541
+ which will be replaced with `production`.
542
+
495
543
  ## `RAILS_ENV`
496
544
 
497
545
  While being managed by EmberCLI Rails, EmberCLI process will have
@@ -1,16 +1,13 @@
1
1
  require "fileutils"
2
- require "ember_cli/engine"
3
2
  require "ember-cli-rails-assets"
3
+ require "ember_cli/engine"
4
+ require "ember_cli/configuration"
5
+ require "ember_cli/helpers"
4
6
  require "ember_cli/errors"
5
7
 
6
8
  module EmberCli
7
9
  extend self
8
10
 
9
- autoload :App, "ember_cli/app"
10
- autoload :Configuration, "ember_cli/configuration"
11
- autoload :Helpers, "ember_cli/helpers"
12
- autoload :PathSet, "ember_cli/path_set"
13
-
14
11
  def configure
15
12
  yield configuration
16
13
  end
@@ -53,7 +50,7 @@ module EmberCli
53
50
  end
54
51
 
55
52
  def env
56
- @env ||= Helpers.current_environment.inquiry
53
+ @env ||= Helpers.current_environment
57
54
  end
58
55
 
59
56
  delegate :apps, to: :configuration
@@ -1,6 +1,8 @@
1
- require "ember_cli/shell"
2
1
  require "html_page/renderer"
2
+ require "ember_cli/path_set"
3
+ require "ember_cli/shell"
3
4
  require "ember_cli/build_monitor"
5
+ require "ember_cli/deploy/file"
4
6
 
5
7
  module EmberCli
6
8
  class App
@@ -11,7 +13,6 @@ module EmberCli
11
13
  @options = options
12
14
  @paths = PathSet.new(
13
15
  app: self,
14
- configuration: EmberCli.configuration,
15
16
  environment: Rails.env,
16
17
  rails_root: Rails.root,
17
18
  ember_cli_root: EmberCli.root,
@@ -42,31 +43,25 @@ module EmberCli
42
43
  end
43
44
 
44
45
  def build
45
- if development?
46
- build_and_watch
47
- elsif test?
48
- compile
46
+ unless EmberCli.skip?
47
+ if development?
48
+ build_and_watch
49
+ elsif test?
50
+ compile
51
+ end
52
+
53
+ @build.wait!
49
54
  end
50
-
51
- @build.wait!
52
55
  end
53
56
 
54
57
  def index_html(head:, body:)
55
- if index_file.exist?
56
- html = HtmlPage::Renderer.new(
57
- head: head,
58
- body: body,
59
- content: index_file.read,
60
- )
61
-
62
- html.render
63
- else
64
- @build.check!
58
+ html = HtmlPage::Renderer.new(
59
+ head: head,
60
+ body: body,
61
+ content: deploy.index_html,
62
+ )
65
63
 
66
- raise BuildError.new <<-MSG
67
- EmberCLI failed to generate an `index.html` file.
68
- MSG
69
- end
64
+ html.render
70
65
  end
71
66
 
72
67
  def install_dependencies
@@ -79,12 +74,36 @@ module EmberCli
79
74
  @shell.test
80
75
  end
81
76
 
77
+ def check_for_errors!
78
+ @build.check!
79
+ end
80
+
82
81
  private
83
82
 
84
- delegate :development?, :test?, to: :env
83
+ def development?
84
+ env.to_s == "development"
85
+ end
86
+
87
+ def test?
88
+ env.to_s == "test"
89
+ end
90
+
91
+ def deploy
92
+ deploy_strategy.new(self)
93
+ end
94
+
95
+ def deploy_strategy
96
+ strategy = options.fetch(:deploy, {})
97
+
98
+ if strategy.respond_to?(:fetch)
99
+ strategy.fetch(rails_env, EmberCli::Deploy::File)
100
+ else
101
+ strategy
102
+ end
103
+ end
85
104
 
86
- def index_file
87
- paths.index_file
105
+ def rails_env
106
+ Rails.env.to_s.to_sym
88
107
  end
89
108
 
90
109
  def env
@@ -104,7 +123,7 @@ module EmberCli
104
123
  end
105
124
 
106
125
  def excluded_ember_deps
107
- Array.wrap(options[:exclude_ember_deps]).join(?,)
126
+ Array.wrap(options[:exclude_ember_deps]).join("?")
108
127
  end
109
128
 
110
129
  def env_hash
@@ -1,9 +1,12 @@
1
1
  require "singleton"
2
+ require "ember_cli/app"
2
3
 
3
4
  module EmberCli
4
5
  class Configuration
5
6
  include Singleton
6
7
 
8
+ attr_accessor :watcher
9
+
7
10
  def app(name, **options)
8
11
  app = App.new(name, options)
9
12
  apps.store(name, app)
@@ -12,23 +15,5 @@ module EmberCli
12
15
  def apps
13
16
  @apps ||= HashWithIndifferentAccess.new
14
17
  end
15
-
16
- def bower_path
17
- @bower_path ||= Helpers.which("bower")
18
- end
19
-
20
- def npm_path
21
- @npm_path ||= Helpers.which("npm")
22
- end
23
-
24
- def tee_path
25
- @tee_path ||= Helpers.which("tee")
26
- end
27
-
28
- def bundler_path
29
- @bundler_path ||= Helpers.which("bundler")
30
- end
31
-
32
- attr_accessor :watcher
33
18
  end
34
19
  end
@@ -0,0 +1,35 @@
1
+ require "ember_cli/errors"
2
+
3
+ module EmberCli
4
+ module Deploy
5
+ class File
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def index_html
11
+ if index_file.exist?
12
+ index_file.read
13
+ else
14
+ check_for_error_and_raise!
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :app
21
+
22
+ def check_for_error_and_raise!
23
+ app.check_for_errors!
24
+
25
+ raise BuildError.new <<-MSG
26
+ EmberCLI failed to generate an `index.html` file.
27
+ MSG
28
+ end
29
+
30
+ def index_file
31
+ app.dist_path.join("index.html")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -3,7 +3,7 @@ module EmberCli
3
3
  extend self
4
4
 
5
5
  def which(cmd)
6
- exts = ENV.fetch("PATHEXT", ?;).split(?;, -1).uniq
6
+ exts = ENV.fetch("PATHEXT", ";").split(";", -1).uniq
7
7
 
8
8
  ENV.fetch("PATH").split(File::PATH_SEPARATOR).each do |path|
9
9
  exts.each do |ext|
@@ -16,26 +16,16 @@ module EmberCli
16
16
  end
17
17
 
18
18
  def current_environment
19
- rails_config_for(:ember_cli_rails_mode){ default_environment }.to_s
19
+ ENV.fetch("EMBER_ENV") { default_environment }
20
20
  end
21
21
 
22
22
  private
23
23
 
24
24
  def default_environment
25
- if Rails.env.test?
26
- "test"
27
- elsif Rails.env.production? || !rails_config_for(:consider_all_requests_local)
28
- "production"
29
- else
30
- "development"
31
- end
32
- end
33
-
34
- def rails_config_for(key)
35
- if Rails.configuration.respond_to?(key)
36
- Rails.configuration.public_send(key)
25
+ if Rails.env.match(/test|development/)
26
+ Rails.env
37
27
  else
38
- yield
28
+ "production"
39
29
  end
40
30
  end
41
31
  end
@@ -1,8 +1,9 @@
1
+ require "ember_cli/helpers"
2
+
1
3
  module EmberCli
2
4
  class PathSet
3
- def initialize(app:, rails_root:, ember_cli_root:, environment:, configuration:)
5
+ def initialize(app:, rails_root:, ember_cli_root:, environment:)
4
6
  @app = app
5
- @configuration = configuration
6
7
  @rails_root = rails_root
7
8
  @environment = environment
8
9
  @ember_cli_root = ember_cli_root
@@ -18,10 +19,6 @@ module EmberCli
18
19
  end
19
20
  end
20
21
 
21
- def index_file
22
- dist.join("index.html")
23
- end
24
-
25
22
  def tmp
26
23
  @tmp ||= root.join("tmp").tap(&:mkpath)
27
24
  end
@@ -65,7 +62,7 @@ module EmberCli
65
62
 
66
63
  def bower
67
64
  @bower ||= begin
68
- bower_path = app_options.fetch(:bower_path) { configuration.bower_path }
65
+ bower_path = app_options.fetch(:bower_path) { which("bower") }
69
66
 
70
67
  bower_path.tap do |path|
71
68
  unless Pathname(path).executable?
@@ -82,24 +79,32 @@ module EmberCli
82
79
  end
83
80
 
84
81
  def npm
85
- @npm ||= app_options.fetch(:npm_path) { configuration.npm_path }
82
+ @npm ||= app_options.fetch(:npm_path) { which("npm") }
86
83
  end
87
84
 
88
85
  def tee
89
- @tee ||= app_options.fetch(:tee_path) { configuration.tee_path }
86
+ @tee ||= app_options.fetch(:tee_path) { which("tee") }
90
87
  end
91
88
 
92
89
  def bundler
93
- @bundler ||= app_options.fetch(:bundler_path) do
94
- configuration.bundler_path
95
- end
90
+ @bundler ||= app_options.fetch(:bundler_path) { which("bundler") }
96
91
  end
97
92
 
98
93
  private
99
94
 
100
- attr_reader :app, :configuration, :ember_cli_root, :environment, :rails_root
95
+ attr_reader :app, :ember_cli_root, :environment, :rails_root
101
96
 
102
- delegate :name, :options, to: :app, prefix: true
97
+ def app_name
98
+ app.name
99
+ end
100
+
101
+ def app_options
102
+ app.options
103
+ end
104
+
105
+ def which(executable)
106
+ Helpers.which(executable)
107
+ end
103
108
 
104
109
  def logs
105
110
  rails_root.join("log").tap(&:mkpath)
@@ -1,3 +1,3 @@
1
1
  module EmberCli
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  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.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-19 00:00:00.000000000 Z
13
+ date: 2015-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ember-cli-rails-assets
@@ -94,6 +94,7 @@ files:
94
94
  - lib/ember_cli/build_monitor.rb
95
95
  - lib/ember_cli/command.rb
96
96
  - lib/ember_cli/configuration.rb
97
+ - lib/ember_cli/deploy/file.rb
97
98
  - lib/ember_cli/engine.rb
98
99
  - lib/ember_cli/errors.rb
99
100
  - lib/ember_cli/helpers.rb