breakfast 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +24 -19
- data/Rakefile +1 -1
- data/breakfast.gemspec +1 -1
- data/lib/breakfast.rb +3 -4
- data/lib/breakfast/brunch_watcher.rb +10 -6
- data/lib/breakfast/helper.rb +34 -0
- data/lib/breakfast/local_environment.rb +53 -0
- data/lib/breakfast/manifest.rb +1 -1
- data/lib/breakfast/railtie.rb +16 -60
- data/lib/breakfast/status_channel.rb +0 -1
- data/lib/breakfast/version.rb +1 -1
- data/lib/generators/breakfast/install_generator.rb +12 -7
- data/lib/generators/breakfast/templates/app.js +2 -2
- data/lib/generators/breakfast/templates/brunch-config.js +6 -9
- data/lib/generators/breakfast/templates/package.json +0 -11
- data/lib/tasks/breakfast.rake +36 -15
- data/node_package/package.json +1 -1
- metadata +7 -8
- data/lib/breakfast/capistrano.rb +0 -8
- data/lib/breakfast/capistrano/tasks/breakfast.rake +0 -37
- data/lib/breakfast/view_helper.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c796f9a83ba4cb7c5256eddf561ac9eaabaa7f
|
4
|
+
data.tar.gz: 285940c7e59ef3dddcb87da0fc4a7a6b38936656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a2f0c8d57eda1f1b3d690c0df87f413622610d6edc26b9a8e9d3569992a6ca8b1134efe449eb4117bbbf859992fb1e39bdb744e9c3bba4b1d2cc527ce384a4
|
7
|
+
data.tar.gz: 0f2fddfce600930dafeca1412e098bd9d1cd73b6e79e70bc17e569124d5acf4ff93d9d360a134b0980d33847ab9e609cb58ed01642a7bcbd540d46efab7113c5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# CHANGE LOG
|
2
2
|
|
3
|
+
### 0.6.0 - 2017-03-12
|
4
|
+
#### Upgrading to `0.6.0` from `0.5.x`
|
5
|
+
- Update gem with `bundle update breakfast`
|
6
|
+
- Update the JS package with `yarn upgrade breakfast-rails`
|
7
|
+
- If deploying with Capistrano, remove `require "breakfast/capistrano"` from
|
8
|
+
your `Capfile`. Remove any custom Breakfast settings from `config/deploy.rb`.
|
9
|
+
Ensure that you are using [Capistrano Rails](https://github.com/capistrano/rails)
|
10
|
+
and have `require 'capistrano/rails'` or `require 'capistrano/rails/assets'`
|
11
|
+
in your `Capfile`.
|
12
|
+
- If deploying with Heroku, run the following commands:
|
13
|
+
1. heroku buildpacks:clear
|
14
|
+
2. heroku buildpacks:set heroku/nodejs --index 1
|
15
|
+
3. heroku buildpacks:set heroku/ruby --index 2
|
16
|
+
#### Fixed
|
17
|
+
- Puma hanging in clustered mode. Breakfast would fail to cleanly exit on Puma
|
18
|
+
exit, causing the server to hang indefinitely.
|
19
|
+
- Bumped Rails version dependency, can be used with Rails 5.0 and greater.
|
20
|
+
(Allows usage with Rails 5.1)
|
21
|
+
#### Removed
|
22
|
+
- Capistrano rake tasks. Previous behavior has been included into the Rails
|
23
|
+
asset:precompile task. Using the standard [Capistrano Rails](https://github.com/capistrano/rails)
|
24
|
+
gem is all that required now.
|
25
|
+
- Need for a custom Heroku buildpack.
|
26
|
+
|
27
|
+
|
3
28
|
### 0.5.1 - 2017-02-06
|
4
29
|
#### Changed
|
5
30
|
If `public/assets` does not exist Breakfast will now create the folder before
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
<p align="center">
|
2
2
|
<img src="http://breakfast.devlocker.io/images/breakfast-illustration.png" width="400" />
|
3
3
|
</p>
|
4
|
+
|
4
5
|
# Breakfast
|
6
|
+
|
5
7
|
[Breakfast](http://breakfast.devlocker.io/) integrates modern Javascript
|
6
8
|
tooling into your Rails project. Powered by [Brunch.io](http://brunch.io).
|
7
9
|
|
@@ -15,31 +17,34 @@ See the official docs at
|
|
15
17
|
|
16
18
|
View updates in the [CHANGELOG](https://github.com/devlocker/breakfast/blob/master/CHANGELOG.md)
|
17
19
|
|
18
|
-
### Latest
|
19
|
-
####
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#### Added
|
25
|
-
- Adds support for [Yarn](https://yarnpkg.com/).
|
26
|
-
- New installs now require Yarn
|
27
|
-
- Capistrano options `:breakfast_yarn_path` && `:breakfast_yarn_install_command`
|
28
|
-
|
20
|
+
### Latest Release `0.6.0`
|
21
|
+
#### Fixed
|
22
|
+
- Puma hanging in clustered mode. Breakfast would fail to cleanly exit on Puma
|
23
|
+
exit, causing the server to hang indefinitely.
|
24
|
+
- Bumped Rails version dependency, can be used with Rails 5.0 and greater.
|
25
|
+
(Allows usage with Rails 5.1)
|
29
26
|
#### Removed
|
30
|
-
-
|
31
|
-
|
32
|
-
|
27
|
+
- Capistrano rake tasks. Previous behavior has been included into the Rails
|
28
|
+
asset:precompile task. Using the standard [Capistrano Rails](https://github.com/capistrano/rails)
|
29
|
+
gem is all that required now.
|
30
|
+
- Need for a custom Heroku buildpack.
|
33
31
|
|
34
32
|
### Upgrading
|
35
|
-
#### Upgrading to `0.
|
33
|
+
#### Upgrading to `0.6.0` from `0.5.x`
|
36
34
|
- Update gem with `bundle update breakfast`
|
37
|
-
-
|
38
|
-
-
|
39
|
-
|
35
|
+
- Update the JS package with `yarn upgrade breakfast-rails`
|
36
|
+
- If deploying with Capistrano, remove `require "breakfast/capistrano"` from
|
37
|
+
your `Capfile`. Remove any custom Breakfast settings from `config/deploy.rb`.
|
38
|
+
Ensure that you are using [Capistrano Rails](https://github.com/capistrano/rails)
|
39
|
+
and have `require 'capistrano/rails'` or `require 'capistrano/rails/assets'`
|
40
|
+
in your `Capfile`.
|
41
|
+
- If deploying with Heroku, run the following commands:
|
42
|
+
1. heroku buildpacks:clear
|
43
|
+
2. heroku buildpacks:set heroku/nodejs --index 1
|
44
|
+
3. heroku buildpacks:set heroku/ruby --index 2
|
40
45
|
|
41
46
|
*Note* If you are deploying with Capistrano then Yarn is expected to be
|
42
|
-
installed on
|
47
|
+
installed on the hosts your are deploying to.
|
43
48
|
|
44
49
|
### Contributing
|
45
50
|
Bug reports and pull requests are welcome on GitHub at
|
data/Rakefile
CHANGED
data/breakfast.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.12"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
-
spec.add_dependency "rails", "
|
25
|
+
spec.add_dependency "rails", ">= 5.0"
|
26
26
|
spec.add_dependency "actioncable", "~> 5.0"
|
27
27
|
spec.add_dependency "listen", ">= 3.0"
|
28
28
|
end
|
data/lib/breakfast.rb
CHANGED
@@ -4,14 +4,13 @@ require "breakfast/brunch_watcher"
|
|
4
4
|
require "breakfast/compilation_listener"
|
5
5
|
require "breakfast/live_reload_channel"
|
6
6
|
require "breakfast/manifest"
|
7
|
+
require "breakfast/helper"
|
8
|
+
require "breakfast/local_environment"
|
7
9
|
require "breakfast/status_channel"
|
8
|
-
require "breakfast/view_helper"
|
9
10
|
|
10
11
|
module Breakfast
|
11
12
|
STATUS_CHANNEL = "breakfast_status".freeze
|
12
13
|
RELOAD_CHANNEL = "breakfast_live_reload".freeze
|
13
|
-
BUILD_COMMAND = "./node_modules/brunch/bin/brunch build".freeze
|
14
|
-
PRODUCTION_BUILD_COMMAND = "./node_modules/brunch/bin/brunch build --production".freeze
|
15
14
|
end
|
16
15
|
|
17
|
-
require "breakfast/railtie" if defined?(Rails)
|
16
|
+
require "breakfast/railtie" if defined?(::Rails)
|
@@ -4,17 +4,14 @@ module Breakfast
|
|
4
4
|
class BrunchWatcher
|
5
5
|
BRUNCH_COMMAND = "./node_modules/brunch/bin/brunch watch".freeze
|
6
6
|
|
7
|
-
|
8
|
-
new(log: log).run
|
9
|
-
end
|
10
|
-
|
7
|
+
attr_accessor :pid
|
11
8
|
attr_reader :log
|
12
9
|
def initialize(log:)
|
13
10
|
@log = log
|
14
11
|
end
|
15
12
|
|
16
13
|
def run
|
17
|
-
out, writer, pid = PTY.spawn(BRUNCH_COMMAND)
|
14
|
+
out, writer, self.pid = PTY.spawn(BRUNCH_COMMAND)
|
18
15
|
writer.close
|
19
16
|
|
20
17
|
Process.detach(pid)
|
@@ -24,7 +21,7 @@ module Breakfast
|
|
24
21
|
output = out.readpartial(64.kilobytes).strip
|
25
22
|
log.debug output
|
26
23
|
|
27
|
-
output = output.gsub(/\e\[([;\d]+)?m/,
|
24
|
+
output = output.gsub(/\e\[([;\d]+)?m/, "")
|
28
25
|
case output
|
29
26
|
when /compiled/
|
30
27
|
broadcast(status: "success", message: output.split("info: ").last)
|
@@ -41,6 +38,13 @@ module Breakfast
|
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
41
|
+
def terminate
|
42
|
+
Process.kill("TERM", @pid)
|
43
|
+
rescue Errno::ESRCH
|
44
|
+
# NOOP. Process exited cleanly or already terminated. Don't print
|
45
|
+
# exception to STDOUT
|
46
|
+
end
|
47
|
+
|
44
48
|
private
|
45
49
|
|
46
50
|
def broadcast(status:, message:)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Breakfast
|
2
|
+
module Helper
|
3
|
+
def breakfast_autoreload_tag
|
4
|
+
if ::Rails.configuration.breakfast.environments.include?(::Rails.env)
|
5
|
+
content_tag :script do
|
6
|
+
<<-SCRIPT.html_safe
|
7
|
+
require("breakfast-rails").init({
|
8
|
+
host: "#{request.host}",
|
9
|
+
port: #{request.port},
|
10
|
+
strategies: {
|
11
|
+
js: "#{::Rails.configuration.breakfast.js_reload_strategy}",
|
12
|
+
css: "#{::Rails.configuration.breakfast.css_reload_strategy}",
|
13
|
+
html: "#{::Rails.configuration.breakfast.html_reload_strategy}",
|
14
|
+
rb: "#{::Rails.configuration.breakfast.ruby_reload_strategy}"
|
15
|
+
},
|
16
|
+
statusBarLocation: "#{::Rails.configuration.breakfast.status_bar_location}"
|
17
|
+
});
|
18
|
+
SCRIPT
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
include ActionView::Helpers::AssetUrlHelper
|
24
|
+
include ActionView::Helpers::AssetTagHelper
|
25
|
+
|
26
|
+
def compute_asset_path(path, options = {})
|
27
|
+
if ::Rails.configuration.breakfast.digest && ::Rails.configuration.breakfast.manifest.asset(path)
|
28
|
+
path = ::Rails.configuration.breakfast.manifest.asset(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
super(path, options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Breakfast
|
2
|
+
class LocalEnvironment
|
3
|
+
def running_server?
|
4
|
+
possible_servers = %w[
|
5
|
+
rails
|
6
|
+
puma
|
7
|
+
passenger
|
8
|
+
unicorn
|
9
|
+
mongrel
|
10
|
+
webrick
|
11
|
+
rainbows
|
12
|
+
]
|
13
|
+
|
14
|
+
possible_servers.any? do |server|
|
15
|
+
send "detect_#{server}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def detect_rails
|
22
|
+
defined?(::Rails::Server)
|
23
|
+
end
|
24
|
+
|
25
|
+
def detect_puma
|
26
|
+
defined?(::Puma) && File.basename($0) == "puma"
|
27
|
+
end
|
28
|
+
|
29
|
+
def detect_passenger
|
30
|
+
defined?(::PhusionPassenger)
|
31
|
+
end
|
32
|
+
|
33
|
+
def detect_thin
|
34
|
+
defined?(::Thin) && defined?(::Thin::Server)
|
35
|
+
end
|
36
|
+
|
37
|
+
def detect_unicorn
|
38
|
+
defined?(::Unicorn) && defined?(::Unicorn::HttpServer)
|
39
|
+
end
|
40
|
+
|
41
|
+
def detect_mongrel
|
42
|
+
defined?(::Mongrel) && defined?(::Mongrel::HttpServer)
|
43
|
+
end
|
44
|
+
|
45
|
+
def detect_webrick
|
46
|
+
defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
47
|
+
end
|
48
|
+
|
49
|
+
def detect_rainbows
|
50
|
+
defined?(::Rainbows) && defined?(::Rainbows::HttpServer)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/breakfast/manifest.rb
CHANGED
@@ -68,7 +68,7 @@ module Breakfast
|
|
68
68
|
files_to_keep = cache.keys.concat(cache.values)
|
69
69
|
|
70
70
|
if (sprockets_manifest = Dir.entries("#{base_dir}").detect { |entry| entry =~ SPROCKETS_MANIFEST_REGEX })
|
71
|
-
files_to_keep.concat(JSON.parse(File.read("#{base_dir}/#{sprockets_manifest}"))
|
71
|
+
files_to_keep.concat(JSON.parse(File.read("#{base_dir}/#{sprockets_manifest}")).fetch("files", {}).keys)
|
72
72
|
end
|
73
73
|
|
74
74
|
Dir["#{base_dir}/**/*"].each do |path|
|
data/lib/breakfast/railtie.rb
CHANGED
@@ -12,16 +12,16 @@ module Breakfast
|
|
12
12
|
config.breakfast.css_reload_strategy = :hot
|
13
13
|
config.breakfast.ruby_reload_strategy = :off
|
14
14
|
|
15
|
-
config.breakfast.asset_output_folder = Rails.root.join("public", "assets")
|
16
|
-
config.breakfast.source_code_folders = [Rails.root.join("app")]
|
15
|
+
config.breakfast.asset_output_folder = ::Rails.root.join("public", "assets")
|
16
|
+
config.breakfast.source_code_folders = [::Rails.root.join("app")]
|
17
17
|
config.breakfast.environments = %w(development)
|
18
18
|
config.breakfast.status_bar_location = :bottom
|
19
|
-
config.breakfast.digest = !(Rails.env.development? || Rails.env.test?)
|
19
|
+
config.breakfast.digest = !(::Rails.env.development? || ::Rails.env.test?)
|
20
20
|
end
|
21
21
|
|
22
22
|
initializer "breakfast.setup_view_helpers" do |app|
|
23
23
|
ActiveSupport.on_load(:action_view) do
|
24
|
-
include ::Breakfast::
|
24
|
+
include ::Breakfast::Helper
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,14 +34,22 @@ module Breakfast
|
|
34
34
|
config.breakfast.manifest = Breakfast::Manifest.new(base_dir: config.breakfast.asset_output_folder)
|
35
35
|
end
|
36
36
|
|
37
|
-
if config.breakfast.environments.include?(Rails.env) && LocalEnvironment.new.running_server?
|
37
|
+
if config.breakfast.environments.include?(::Rails.env) && Breakfast::LocalEnvironment.new.running_server?
|
38
|
+
|
38
39
|
# Ensure public/assets directory exists
|
39
|
-
FileUtils.mkdir_p(Rails.root.join(
|
40
|
+
FileUtils.mkdir_p(::Rails.root.join("public", "assets"))
|
41
|
+
|
42
|
+
# Start Brunch Process
|
43
|
+
@brunch = Breakfast::BrunchWatcher.new(log: ::Rails.logger)
|
44
|
+
Thread.start do
|
45
|
+
@brunch.run
|
46
|
+
end
|
40
47
|
|
41
|
-
|
42
|
-
|
48
|
+
at_exit do
|
49
|
+
@brunch.terminate
|
43
50
|
end
|
44
51
|
|
52
|
+
# Setup file listeners
|
45
53
|
Breakfast::CompilationListener.start(
|
46
54
|
asset_output_folder: config.breakfast.asset_output_folder,
|
47
55
|
source_code_folders: config.breakfast.source_code_folders
|
@@ -53,56 +61,4 @@ module Breakfast
|
|
53
61
|
ActionView::Helpers::AssetUrlHelper::ASSET_PUBLIC_DIRECTORIES[:image] = "/assets"
|
54
62
|
ActionView::Helpers::AssetUrlHelper::ASSET_PUBLIC_DIRECTORIES[:stylesheet] = "/assets"
|
55
63
|
end
|
56
|
-
|
57
|
-
class LocalEnvironment
|
58
|
-
def running_server?
|
59
|
-
possible_servers = %w[
|
60
|
-
rails
|
61
|
-
puma
|
62
|
-
passenger
|
63
|
-
unicorn
|
64
|
-
mongrel
|
65
|
-
webrick
|
66
|
-
rainbows
|
67
|
-
]
|
68
|
-
|
69
|
-
possible_servers.any? do |server|
|
70
|
-
send "detect_#{server}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def detect_rails
|
77
|
-
defined?(Rails::Server)
|
78
|
-
end
|
79
|
-
|
80
|
-
def detect_puma
|
81
|
-
defined?(::Puma) && File.basename($0) == "puma"
|
82
|
-
end
|
83
|
-
|
84
|
-
def detect_passenger
|
85
|
-
defined?(::PhusionPassenger)
|
86
|
-
end
|
87
|
-
|
88
|
-
def detect_thin
|
89
|
-
defined?(::Thin) && defined?(::Thin::Server)
|
90
|
-
end
|
91
|
-
|
92
|
-
def detect_unicorn
|
93
|
-
defined?(::Unicorn) && defined?(::Unicorn::HttpServer)
|
94
|
-
end
|
95
|
-
|
96
|
-
def detect_mongrel
|
97
|
-
defined?(::Mongrel) && defined?(::Mongrel::HttpServer)
|
98
|
-
end
|
99
|
-
|
100
|
-
def detect_webrick
|
101
|
-
defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
102
|
-
end
|
103
|
-
|
104
|
-
def detect_rainbows
|
105
|
-
defined?(::Rainbows) && defined?(::Rainbows::HttpServer)
|
106
|
-
end
|
107
|
-
end
|
108
64
|
end
|
data/lib/breakfast/version.rb
CHANGED
@@ -2,19 +2,19 @@ require "rails/generators"
|
|
2
2
|
|
3
3
|
module Breakfast
|
4
4
|
module Generators
|
5
|
-
class InstallGenerator < Rails::Generators::Base
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
NODE_VERSION = Gem::Version.new("4.1.0")
|
8
8
|
|
9
9
|
def install
|
10
10
|
if node_prerequisites_installed?
|
11
11
|
create_brunch_config
|
12
|
-
create_package_json
|
12
|
+
create_package_json if using_rails_5_dot_0?
|
13
|
+
install_required_packages
|
13
14
|
create_directory_structure
|
14
15
|
create_app_js_file
|
15
16
|
create_app_scss_file
|
16
17
|
create_gitkeep_files
|
17
|
-
run_yarn_install
|
18
18
|
add_node_modules_to_gitignore
|
19
19
|
|
20
20
|
puts <<-SUCCESS.strip_heredoc
|
@@ -59,6 +59,11 @@ module Breakfast
|
|
59
59
|
copy_file "package.json", "package.json"
|
60
60
|
end
|
61
61
|
|
62
|
+
def install_required_packages
|
63
|
+
run "yarn add actioncable breakfast-rails jquery jquery-ujs turbolinks"
|
64
|
+
run "yarn add --dev brunch babel brunch clean-css-brunch sass-brunch uglify-js-brunch"
|
65
|
+
end
|
66
|
+
|
62
67
|
def create_directory_structure
|
63
68
|
empty_directory "app/frontend/css"
|
64
69
|
empty_directory "app/frontend/images"
|
@@ -79,10 +84,6 @@ module Breakfast
|
|
79
84
|
create_file "app/frontend/vendor/.gitkeep"
|
80
85
|
end
|
81
86
|
|
82
|
-
def run_yarn_install
|
83
|
-
run "yarn install"
|
84
|
-
end
|
85
|
-
|
86
87
|
def add_node_modules_to_gitignore
|
87
88
|
ignore = <<-IGNORE.strip_heredoc
|
88
89
|
# Added by Breakfast Gem
|
@@ -94,6 +95,10 @@ module Breakfast
|
|
94
95
|
|
95
96
|
append_to_file(".gitignore", ignore)
|
96
97
|
end
|
98
|
+
|
99
|
+
def using_rails_5_dot_0?
|
100
|
+
Gem::Version.new(::Rails.version) < Gem::Version.new("5.1")
|
101
|
+
end
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
// Turbolinks - To disable remove the next two lines.
|
2
2
|
// https://github.com/turbolinks/turbolinks
|
3
|
-
import Turbolinks from
|
3
|
+
import Turbolinks from 'turbolinks';
|
4
4
|
Turbolinks.start();
|
5
5
|
|
6
6
|
// Require https://github.com/rails/jquery-ujs
|
7
|
-
import
|
7
|
+
import 'jquery-ujs';
|
8
8
|
|
9
9
|
const App = {
|
10
10
|
init() {
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module.exports = {
|
2
2
|
files: {
|
3
3
|
javascripts: {
|
4
|
-
joinTo:
|
5
|
-
'app.js': /^app\/frontend\/js\//,
|
6
|
-
'vendor.js': /^(?!app\/frontend\/js)/
|
7
|
-
}
|
4
|
+
joinTo: 'app.js'
|
8
5
|
},
|
9
6
|
stylesheets: {
|
10
7
|
joinTo: 'app.css'
|
@@ -22,10 +19,10 @@ module.exports = {
|
|
22
19
|
|
23
20
|
paths: {
|
24
21
|
watched: [
|
25
|
-
|
22
|
+
'app/frontend',
|
26
23
|
],
|
27
24
|
|
28
|
-
public:
|
25
|
+
public: 'public/assets'
|
29
26
|
},
|
30
27
|
|
31
28
|
conventions: {
|
@@ -34,9 +31,9 @@ module.exports = {
|
|
34
31
|
|
35
32
|
npm: {
|
36
33
|
globals: {
|
37
|
-
$:
|
38
|
-
jQuery:
|
39
|
-
breakfast:
|
34
|
+
$: 'jquery',
|
35
|
+
jQuery: 'jquery',
|
36
|
+
breakfast: 'breakfast-rails'
|
40
37
|
}
|
41
38
|
}
|
42
39
|
};
|
@@ -1,18 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"repository": {},
|
3
3
|
"dependencies": {
|
4
|
-
"actioncable": "^5.0.0",
|
5
|
-
"breakfast-rails": "0.5.0",
|
6
|
-
"jquery": "^3.1.0",
|
7
|
-
"jquery-ujs": "^1.2.2",
|
8
|
-
"turbolinks": "^5.0.0"
|
9
4
|
},
|
10
5
|
"devDependencies": {
|
11
|
-
"brunch": "~2.10.5",
|
12
|
-
"babel-brunch": "~6.0.0",
|
13
|
-
"css-brunch": "^2.6.1",
|
14
|
-
"clean-css-brunch": "~1.8.0",
|
15
|
-
"sass-brunch": "~2.9.0",
|
16
|
-
"uglify-js-brunch": "~2.1.0"
|
17
6
|
}
|
18
7
|
}
|
data/lib/tasks/breakfast.rake
CHANGED
@@ -3,43 +3,64 @@ require "breakfast"
|
|
3
3
|
|
4
4
|
namespace :breakfast do
|
5
5
|
namespace :assets do
|
6
|
-
desc "
|
7
|
-
task :
|
8
|
-
|
6
|
+
desc "Prepare assets and digests for production deploy"
|
7
|
+
task compile: [:environment] do
|
8
|
+
Rake::Task["breakfast:assets:build_production"].execute
|
9
|
+
Rake::Task["breakfast:assets:digest"].execute
|
10
|
+
Rake::Task["breakfast:assets:clean"].execute
|
9
11
|
end
|
10
12
|
|
11
13
|
desc "Build assets for production"
|
12
|
-
task :
|
13
|
-
|
14
|
+
task build_production: :environment do
|
15
|
+
system "NODE_ENV=production ./node_modules/brunch/bin/brunch build --production"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Build assets"
|
19
|
+
task build: :environment do
|
20
|
+
system "./node_modules/brunch/bin/brunch build"
|
14
21
|
end
|
15
22
|
|
16
23
|
desc "Add a digest to non-fingerprinted assets"
|
17
|
-
task :
|
18
|
-
if Rails.configuration.breakfast.manifest
|
19
|
-
Rails.configuration.breakfast.manifest.digest!
|
24
|
+
task digest: :environment do
|
25
|
+
if ::Rails.configuration.breakfast.manifest
|
26
|
+
::Rails.configuration.breakfast.manifest.digest!
|
20
27
|
else
|
21
28
|
raise Breakfast::ManifestDisabledError
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
25
32
|
desc "Remove out of date assets"
|
26
|
-
task :
|
27
|
-
if Rails.configuration.breakfast.manifest
|
28
|
-
Rails.configuration.breakfast.manifest.clean!
|
33
|
+
task clean: :environment do
|
34
|
+
if ::Rails.configuration.breakfast.manifest
|
35
|
+
::Rails.configuration.breakfast.manifest.clean!
|
29
36
|
else
|
30
37
|
raise Breakfast::ManifestDisabledError
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
34
41
|
desc "Remove manifest and fingerprinted assets"
|
35
|
-
task :
|
36
|
-
if Rails.configuration.breakfast.manifest
|
37
|
-
Rails.configuration.breakfast.manifest.nuke!
|
42
|
+
task nuke: :environment do
|
43
|
+
if ::Rails.configuration.breakfast.manifest
|
44
|
+
::Rails.configuration.breakfast.manifest.nuke!
|
38
45
|
else
|
39
46
|
raise Breakfast::ManifestDisabledError
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
50
|
+
|
51
|
+
namespace :yarn do
|
52
|
+
desc "Install package.json dependencies with Yarn"
|
53
|
+
task :install do
|
54
|
+
system "yarn"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if Rake::Task.task_defined?("assets:precompile")
|
60
|
+
Rake::Task["assets:precompile"].enhance do
|
61
|
+
Rake::Task["breakfast:yarn:install"].execute
|
62
|
+
Rake::Task["breakfast:assets:compile"].execute
|
63
|
+
end
|
43
64
|
end
|
44
65
|
|
45
66
|
module Breakfast
|
@@ -47,7 +68,7 @@ module Breakfast
|
|
47
68
|
def initialize
|
48
69
|
super(
|
49
70
|
<<~ERROR
|
50
|
-
Rails.configuration.breakfast.manifest is set to false.
|
71
|
+
::Rails.configuration.breakfast.manifest is set to false.
|
51
72
|
Enable it by adding the following in your environment file:
|
52
73
|
|
53
74
|
config.breakfast.manifest.digest = true
|
data/node_package/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakfast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Koperwas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '5.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -115,15 +115,14 @@ files:
|
|
115
115
|
- breakfast.gemspec
|
116
116
|
- lib/breakfast.rb
|
117
117
|
- lib/breakfast/brunch_watcher.rb
|
118
|
-
- lib/breakfast/capistrano.rb
|
119
|
-
- lib/breakfast/capistrano/tasks/breakfast.rake
|
120
118
|
- lib/breakfast/compilation_listener.rb
|
119
|
+
- lib/breakfast/helper.rb
|
121
120
|
- lib/breakfast/live_reload_channel.rb
|
121
|
+
- lib/breakfast/local_environment.rb
|
122
122
|
- lib/breakfast/manifest.rb
|
123
123
|
- lib/breakfast/railtie.rb
|
124
124
|
- lib/breakfast/status_channel.rb
|
125
125
|
- lib/breakfast/version.rb
|
126
|
-
- lib/breakfast/view_helper.rb
|
127
126
|
- lib/generators/breakfast/install_generator.rb
|
128
127
|
- lib/generators/breakfast/templates/app.js
|
129
128
|
- lib/generators/breakfast/templates/app.scss
|
@@ -157,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
156
|
version: '0'
|
158
157
|
requirements: []
|
159
158
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.6.8
|
161
160
|
signing_key:
|
162
161
|
specification_version: 4
|
163
162
|
summary: Integrates Brunch into Rails
|
data/lib/breakfast/capistrano.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
namespace :breakfast do
|
2
|
-
desc "Compile assets for production use"
|
3
|
-
task :compile do
|
4
|
-
on roles fetch(:breakfast_roles) do |host|
|
5
|
-
within release_path do
|
6
|
-
with rails_env: "#{fetch(:rails_env) || fetch(:stage)}" do
|
7
|
-
execute fetch(:breakfast_yarn_path).to_sym, fetch(:breakfast_yarn_install_command)
|
8
|
-
execute :rails, "breakfast:assets:build_production"
|
9
|
-
execute :rails, "breakfast:assets:digest"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Clean out old assets"
|
16
|
-
task :clean do
|
17
|
-
on roles fetch(:breakfast_roles) do |host|
|
18
|
-
within release_path do
|
19
|
-
with rails_env: "#{fetch(:rails_env) || fetch(:stage)}" do
|
20
|
-
execute :rails, "breakfast:assets:clean"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
after "deploy:updated", "breakfast:compile"
|
27
|
-
after "deploy:published", "breakfast:clean"
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
namespace :load do
|
32
|
-
task :defaults do
|
33
|
-
set :breakfast_roles, -> { :web }
|
34
|
-
set :breakfast_yarn_path, "/usr/bin/yarn"
|
35
|
-
set :breakfast_yarn_install_command, "install"
|
36
|
-
end
|
37
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Breakfast
|
2
|
-
module ViewHelper
|
3
|
-
def breakfast_autoreload_tag
|
4
|
-
if Rails.configuration.breakfast.environments.include?(Rails.env)
|
5
|
-
content_tag :script do
|
6
|
-
<<-SCRIPT.html_safe
|
7
|
-
require("breakfast-rails").init({
|
8
|
-
host: "#{request.host}",
|
9
|
-
port: #{request.port},
|
10
|
-
strategies: {
|
11
|
-
js: "#{Rails.configuration.breakfast.js_reload_strategy}",
|
12
|
-
css: "#{Rails.configuration.breakfast.css_reload_strategy}",
|
13
|
-
html: "#{Rails.configuration.breakfast.html_reload_strategy}",
|
14
|
-
rb: "#{Rails.configuration.breakfast.ruby_reload_strategy}"
|
15
|
-
},
|
16
|
-
statusBarLocation: "#{Rails.configuration.breakfast.status_bar_location}"
|
17
|
-
});
|
18
|
-
SCRIPT
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
include ActionView::Helpers::AssetUrlHelper
|
24
|
-
include ActionView::Helpers::AssetTagHelper
|
25
|
-
|
26
|
-
def compute_asset_path(path, options = {})
|
27
|
-
if Rails.configuration.breakfast.digest && Rails.configuration.breakfast.manifest.asset(path)
|
28
|
-
path = Rails.configuration.breakfast.manifest.asset(path)
|
29
|
-
end
|
30
|
-
|
31
|
-
super(path, options)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|