middleman-livereload 3.4.6 → 3.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.devcontainer/Dockerfile +20 -0
- data/.devcontainer/devcontainer.json +35 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +9 -3
- data/Rakefile +7 -1
- data/lib/middleman-livereload/extension_3_1.rb +18 -15
- data/lib/middleman-livereload/reactor.rb +14 -2
- data/lib/middleman-livereload/version.rb +1 -1
- data/lib/middleman-livereload/wss.rb +42 -0
- data/spec/middleman-livereload/wss_spec.rb +77 -0
- data/spec/spec_helper.rb +17 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ac51978c5650bf89df058f304a8dd7a5f42aeb360ca9eb8642ce8619d8f3ad9c
|
4
|
+
data.tar.gz: 6999099989b1fa0fa85096f623b2b10453819e62efa6c5b26584d4008999d68b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74eed67bfc417007cb3998c767a464d998e8b30d521153471abd575b8a247c67c89d159470360f2c622255d8b58f229172e75a38353ade602fe35c2e8e89d67a
|
7
|
+
data.tar.gz: c54f7cf4d6f46337473512d02b664f1b3c25699173b1c559c134017ac94c2342003e908bf2cf191f7d6c819b634dff2922dfe9efb3716472f3ac37f0aea6e9b1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/ruby/.devcontainer/base.Dockerfile
|
2
|
+
|
3
|
+
# [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6, 2.5
|
4
|
+
ARG VARIANT="3"
|
5
|
+
FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
|
6
|
+
|
7
|
+
# [Option] Install Node.js
|
8
|
+
ARG INSTALL_NODE="true"
|
9
|
+
ARG NODE_VERSION="lts/*"
|
10
|
+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
11
|
+
|
12
|
+
# [Optional] Uncomment this section to install additional OS packages.
|
13
|
+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
14
|
+
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
15
|
+
|
16
|
+
# [Optional] Uncomment this line to install additional gems.
|
17
|
+
# RUN gem install <your-gem-names-here>
|
18
|
+
|
19
|
+
# [Optional] Uncomment this line to install global node packages.
|
20
|
+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
@@ -0,0 +1,35 @@
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
2
|
+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/ruby
|
3
|
+
{
|
4
|
+
"name": "Ruby",
|
5
|
+
"build": {
|
6
|
+
"dockerfile": "Dockerfile",
|
7
|
+
"args": {
|
8
|
+
// Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6, 2.5
|
9
|
+
"VARIANT": "2.7",
|
10
|
+
// Options
|
11
|
+
"INSTALL_NODE": "true",
|
12
|
+
"NODE_VERSION": "lts/*"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
|
16
|
+
// Set *default* container specific settings.json values on container create.
|
17
|
+
"settings": {
|
18
|
+
"terminal.integrated.shell.linux": "/bin/bash"
|
19
|
+
},
|
20
|
+
|
21
|
+
// Add the IDs of extensions you want installed when the container is created.
|
22
|
+
"extensions": [
|
23
|
+
"rebornix.Ruby"
|
24
|
+
],
|
25
|
+
|
26
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
27
|
+
// "forwardPorts": [],
|
28
|
+
|
29
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
30
|
+
// "postCreateCommand": "ruby --version",
|
31
|
+
|
32
|
+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
33
|
+
"remoteUser": "vscode"
|
34
|
+
|
35
|
+
}
|
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,8 @@ Disable Flash polyfil for browsers that support native WebSockets.
|
|
47
47
|
|
48
48
|
Array of patterns for paths that must be ignored. These files will not be injected with the LiveReload script.
|
49
49
|
|
50
|
+
`String#match` is used for ignoring, so you can use any valid Ruby regular expression in this array.
|
51
|
+
|
50
52
|
#### `:livereload_css_target`
|
51
53
|
|
52
54
|
CSS file to reload when detecting @imported partial was modified. Default `stylesheets/all.css`).
|
@@ -56,6 +58,10 @@ To opt out set `livereload_css_target: nil`.
|
|
56
58
|
|
57
59
|
Regexp matching filenames that should trigger reload of :livereload_css_target when changed. Default: `Regexp.new('_.*\.css')`.
|
58
60
|
|
61
|
+
#### `:wss_certificate` and `:wss_private_key`
|
62
|
+
|
63
|
+
Support secure sockets (WSS) by passing TLS certificate & private key, for
|
64
|
+
example if you're using `middleman server --https` in development.
|
59
65
|
|
60
66
|
## Build & Dependency Status
|
61
67
|
|
@@ -66,7 +72,7 @@ Regexp matching filenames that should trigger reload of :livereload_css_target w
|
|
66
72
|
|
67
73
|
## Community
|
68
74
|
|
69
|
-
The official community forum is available at:
|
75
|
+
The official community forum is available at: https://forum.middlemanapp.com
|
70
76
|
|
71
77
|
## Bug Reports
|
72
78
|
|
@@ -89,9 +95,9 @@ The best way to get quick responses to your issues and swift fixes to your bugs
|
|
89
95
|
|
90
96
|
Copyright (c) 2010-2013 Thomas Reynolds. MIT Licensed, see [LICENSE] for details.
|
91
97
|
|
92
|
-
[middleman]:
|
98
|
+
[middleman]: https://middlemanapp.com
|
93
99
|
[gem]: https://rubygems.org/gems/middleman-livereload
|
94
|
-
[travis]:
|
100
|
+
[travis]: https://travis-ci.org/middleman/middleman-livereload
|
95
101
|
[gemnasium]: https://gemnasium.com/middleman/middleman-livereload
|
96
102
|
[codeclimate]: https://codeclimate.com/github/middleman/middleman-livereload
|
97
103
|
[LICENSE]: https://github.com/middleman/middleman-livereload/blob/master/LICENSE.md
|
data/Rakefile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
+
begin
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
rescue LoadError
|
8
|
+
end
|
9
|
+
|
4
10
|
require 'cucumber/rake/task'
|
5
11
|
|
6
12
|
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
@@ -14,7 +20,7 @@ end
|
|
14
20
|
|
15
21
|
require 'rake/clean'
|
16
22
|
|
17
|
-
task :test => ["cucumber"]
|
23
|
+
task :test => ["spec", "cucumber"]
|
18
24
|
|
19
25
|
desc "Build HTML documentation"
|
20
26
|
task :doc do
|
@@ -13,6 +13,8 @@ module Middleman
|
|
13
13
|
option :js_host, nil, 'Host to connect LiveReload Javascript to (if different than :host)'
|
14
14
|
option :livereload_css_target, 'stylesheets/all.css', 'CSS file to load when a @imported CSS partials are modified'
|
15
15
|
option :livereload_css_pattern, Regexp.new('_.*\.css'), 'Regexp matching filenames that trigger live reloading target'
|
16
|
+
option :wss_certificate, nil, 'Path to an X.509 certificate to use for the websocket server'
|
17
|
+
option :wss_private_key, nil, 'Path to an RSA private key for the websocket certificate'
|
16
18
|
|
17
19
|
def initialize(app, options_hash={}, &block)
|
18
20
|
super
|
@@ -23,8 +25,6 @@ module Middleman
|
|
23
25
|
return unless app.environment == :development
|
24
26
|
end
|
25
27
|
|
26
|
-
@reactor = nil
|
27
|
-
|
28
28
|
port = options.port.to_i
|
29
29
|
host = options.host
|
30
30
|
js_port = options.js_port || port
|
@@ -35,23 +35,26 @@ module Middleman
|
|
35
35
|
livereload_css_target = options.livereload_css_target
|
36
36
|
livereload_css_pattern = options.livereload_css_pattern
|
37
37
|
|
38
|
+
extension = self
|
39
|
+
|
38
40
|
app.ready do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
reactor = ::Middleman::LiveReload::Reactor.create(options_hash, self)
|
42
|
+
|
43
|
+
ignored = lambda do |file|
|
44
|
+
return true if app.files.respond_to?(:ignored?) && app.files.send(:ignored?, file)
|
45
|
+
ignore.any? { |i| file.to_s.match(i) }
|
43
46
|
end
|
44
47
|
|
45
|
-
files.changed do |file|
|
46
|
-
next if
|
48
|
+
app.files.changed do |file|
|
49
|
+
next if ignored.call(file)
|
47
50
|
|
48
51
|
logger.debug "LiveReload: File changed - #{file}"
|
49
52
|
|
50
53
|
reload_path = "#{Dir.pwd}/#{file}"
|
51
54
|
|
52
|
-
file_url = sitemap.file_to_path(file)
|
55
|
+
file_url = app.sitemap.file_to_path(file)
|
53
56
|
if file_url
|
54
|
-
file_resource = sitemap.find_resource_by_path(file_url)
|
57
|
+
file_resource = app.sitemap.find_resource_by_path(file_url)
|
55
58
|
if file_resource
|
56
59
|
reload_path = file_resource.url
|
57
60
|
end
|
@@ -64,20 +67,20 @@ module Middleman
|
|
64
67
|
reload_path = livereload_css_target
|
65
68
|
end
|
66
69
|
|
67
|
-
|
70
|
+
reactor.reload_browser(reload_path)
|
68
71
|
end
|
69
72
|
|
70
|
-
files.deleted do |file|
|
71
|
-
next if
|
73
|
+
app.files.deleted do |file|
|
74
|
+
next if ignored.call(file)
|
72
75
|
|
73
76
|
logger.debug "LiveReload: File deleted - #{file}"
|
74
77
|
|
75
|
-
|
78
|
+
reactor.reload_browser("#{Dir.pwd}/#{file}")
|
76
79
|
end
|
77
80
|
|
78
81
|
# Use the vendored livereload.js source rather than trying to get it from Middleman
|
79
82
|
# https://github.com/johnbintz/rack-livereload#which-livereload-script-does-it-use
|
80
|
-
use ::Rack::LiveReload, port: js_port, host: js_host, no_swf: no_swf, source: :vendored, ignore: ignore
|
83
|
+
app.use ::Rack::LiveReload, port: js_port, host: js_host, no_swf: no_swf, source: :vendored, ignore: ignore
|
81
84
|
end
|
82
85
|
end
|
83
86
|
end
|
@@ -1,11 +1,22 @@
|
|
1
1
|
require 'em-websocket'
|
2
2
|
require 'json'
|
3
|
+
require 'middleman-livereload/wss'
|
3
4
|
|
4
5
|
module Middleman
|
5
6
|
module LiveReload
|
6
7
|
class Reactor
|
7
8
|
attr_reader :thread, :web_sockets, :app
|
8
9
|
|
10
|
+
def self.create(options, app)
|
11
|
+
if @reactor
|
12
|
+
@reactor.app = app
|
13
|
+
else
|
14
|
+
@reactor = new(options, app)
|
15
|
+
end
|
16
|
+
|
17
|
+
@reactor
|
18
|
+
end
|
19
|
+
|
9
20
|
def initialize(options, app)
|
10
21
|
@app = app
|
11
22
|
@web_sockets = []
|
@@ -41,10 +52,11 @@ module Middleman
|
|
41
52
|
end
|
42
53
|
|
43
54
|
def start_threaded_reactor(options)
|
55
|
+
wss = Wss.new(@options[:wss_certificate], @options[:wss_private_key])
|
44
56
|
Thread.new do
|
45
57
|
EventMachine.run do
|
46
|
-
logger.info "== LiveReload accepting connections from
|
47
|
-
EventMachine.start_server(options[:host], options[:port], EventMachine::WebSocket::Connection,
|
58
|
+
logger.info "== LiveReload accepting connections from #{wss.scheme}://#{options[:host]}:#{options[:port]}"
|
59
|
+
EventMachine.start_server(options[:host], options[:port], EventMachine::WebSocket::Connection, wss.to_options) do |ws|
|
48
60
|
ws.onopen do
|
49
61
|
begin
|
50
62
|
ws.send "!!ver:1.6"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Middleman
|
2
|
+
module LiveReload
|
3
|
+
class Wss
|
4
|
+
def initialize(certificate, private_key)
|
5
|
+
@certificate = certificate
|
6
|
+
@private_key = private_key
|
7
|
+
validate!
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
@certificate && @private_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_options
|
15
|
+
return {} unless valid?
|
16
|
+
{
|
17
|
+
secure: true,
|
18
|
+
tls_options: {
|
19
|
+
private_key_file: @private_key,
|
20
|
+
cert_chain_file: @certificate
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def scheme
|
26
|
+
valid? ? "wss" : "ws"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def present?
|
32
|
+
@certificate || @private_key
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate!
|
36
|
+
if present? && !valid?
|
37
|
+
raise ArgumentError.new, "You must provide both :wss_certificate and :wss_private_key"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "middleman-livereload/wss"
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module LiveReload
|
6
|
+
RSpec.describe Wss do
|
7
|
+
let(:wss) { Wss.new certificate, private_key }
|
8
|
+
|
9
|
+
it "prevents missing certificate or private_key" do
|
10
|
+
expect { Wss.new nil, "y" }.to raise_error(ArgumentError, /both :wss_certificate and :wss_private_key/)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#scheme" do
|
14
|
+
subject { wss.scheme }
|
15
|
+
|
16
|
+
context "no certificate and no private key" do
|
17
|
+
let(:certificate) { nil }
|
18
|
+
let(:private_key) { nil }
|
19
|
+
|
20
|
+
it { is_expected.to eq "ws" }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "certificate and private key" do
|
24
|
+
let(:certificate) { "x" }
|
25
|
+
let(:private_key) { "y" }
|
26
|
+
|
27
|
+
it { is_expected.to eq "wss" }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#to_options" do
|
32
|
+
subject { wss.to_options }
|
33
|
+
|
34
|
+
context "no certificate and no private key" do
|
35
|
+
let(:certificate) { nil }
|
36
|
+
let(:private_key) { nil }
|
37
|
+
|
38
|
+
it { is_expected.to eq Hash.new }
|
39
|
+
end
|
40
|
+
|
41
|
+
context "certificate and private key" do
|
42
|
+
let(:certificate) { "x" }
|
43
|
+
let(:private_key) { "y" }
|
44
|
+
let(:options) do
|
45
|
+
{
|
46
|
+
secure: true,
|
47
|
+
tls_options: {
|
48
|
+
private_key_file: private_key,
|
49
|
+
cert_chain_file: certificate
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
it { is_expected.to eq options }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#valid?" do
|
59
|
+
subject { wss.valid? }
|
60
|
+
|
61
|
+
context "no certificate and no private key" do
|
62
|
+
let(:certificate) { nil }
|
63
|
+
let(:private_key) { nil }
|
64
|
+
|
65
|
+
it { is_expected.to be_falsey }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "certificate and private key" do
|
69
|
+
let(:certificate) { "x" }
|
70
|
+
let(:private_key) { "y" }
|
71
|
+
|
72
|
+
it { is_expected.to be_truthy }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman-core
|
@@ -63,7 +63,10 @@ executables: []
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
+
- ".devcontainer/Dockerfile"
|
67
|
+
- ".devcontainer/devcontainer.json"
|
66
68
|
- ".gitignore"
|
69
|
+
- ".rspec"
|
67
70
|
- ".travis.yml"
|
68
71
|
- CHANGELOG.md
|
69
72
|
- CONTRIBUTING.md
|
@@ -77,8 +80,11 @@ files:
|
|
77
80
|
- lib/middleman-livereload/extension_3_1.rb
|
78
81
|
- lib/middleman-livereload/reactor.rb
|
79
82
|
- lib/middleman-livereload/version.rb
|
83
|
+
- lib/middleman-livereload/wss.rb
|
80
84
|
- lib/middleman_extension.rb
|
81
85
|
- middleman-livereload.gemspec
|
86
|
+
- spec/middleman-livereload/wss_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
82
88
|
homepage: https://github.com/middleman/middleman-livereload
|
83
89
|
licenses:
|
84
90
|
- MIT
|
@@ -98,12 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
104
|
- !ruby/object:Gem::Version
|
99
105
|
version: '0'
|
100
106
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.4.8
|
107
|
+
rubygems_version: 3.1.6
|
103
108
|
signing_key:
|
104
109
|
specification_version: 4
|
105
110
|
summary: LiveReload support for Middleman
|
106
|
-
test_files:
|
107
|
-
- features/.gitkeep
|
108
|
-
- fixtures/.gitkeep
|
109
|
-
has_rdoc:
|
111
|
+
test_files: []
|