jekyll-browsersync 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/jekyll-browsersync.rb +10 -0
- data/lib/jekyll-browsersync/command.rb +47 -105
- data/lib/jekyll-browsersync/version.rb +3 -1
- metadata +21 -10
- data/LICENSE +0 -19
- data/README.md +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3daf4e2e9f728e4d3c2f7b7b583d50b4e69bef505d3df61ecf9af403d1b02bed
|
4
|
+
data.tar.gz: 0a752341328b67d3c4b2869107687f065b4a046b7c012faa01f3d6d693e14557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4753f6aa2535427f22bd0c31fb274cefe62ee509967d2c5c63614d8e1bcb3ec395ea298543895b574fb24de05f66c52f8b36bb815d84483e12e52f41a30f549d
|
7
|
+
data.tar.gz: b9e0c73c16d932b4f0350deb4e641f9f0c2066f8f255cc1580e4649cdcd56a6dc8396426e913db0481d176e778220004f18cec705c57b06f4c6fe2880e82ea8d
|
data/lib/jekyll-browsersync.rb
CHANGED
@@ -1,125 +1,67 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pty"
|
4
|
+
require "tty-which"
|
2
5
|
|
3
6
|
module Mlo
|
4
7
|
module Jekyll
|
5
8
|
module BrowserSync
|
6
9
|
class Command < ::Jekyll::Command
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
"host" => ["host", "-H", "--host [HOST]", "Host to bind to"],
|
12
|
-
"open_url" => ["-o", "--open-url", "Launch your site in a browser"],
|
13
|
-
"port" => ["-P", "--port [PORT]", "Port to listen on"],
|
14
|
-
"show_dir_listing" => ["--show-dir-listing",
|
15
|
-
"Show a directory listing instead of loading your index file."],
|
16
|
-
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
|
17
|
-
"Skips the initial site build which occurs before the server is started."],
|
18
|
-
"ui_port" => ["--ui-port [PORT]",
|
19
|
-
"The port for Browsersync UI to run on"],
|
20
|
-
"browsersync" => ["--browser-sync [PATH]",
|
21
|
-
"Specify the path to the Browsersync binary if in custom location."],
|
22
|
-
}.freeze
|
23
|
-
|
24
|
-
def init_with_program(prog)
|
25
|
-
prog.command("browsersync") do |cmd|
|
26
|
-
cmd.syntax "browsersync [options]"
|
27
|
-
cmd.description 'Serve a Jekyll site using Browsersync.'
|
28
|
-
cmd.alias :'browser-sync'
|
29
|
-
cmd.alias :bs
|
30
|
-
|
31
|
-
add_build_options(cmd)
|
32
|
-
|
33
|
-
COMMAND_OPTIONS.each do |key, val|
|
34
|
-
cmd.option key, *val
|
35
|
-
end
|
36
|
-
|
37
|
-
cmd.action do |args, opts|
|
38
|
-
puts args.inspect
|
39
|
-
opts['serving'] = true
|
40
|
-
opts['watch'] = true unless opts.key?('watch')
|
41
|
-
opts['incremental'] = true unless opts.key?('incremental')
|
42
|
-
opts['port'] = 4000 unless opts.key?('port')
|
43
|
-
opts['host'] = '127.0.0.1' unless opts.key?('host')
|
44
|
-
opts['ui_port'] = 3001 unless opts.key?('ui_port')
|
45
|
-
opts['browsersync'] = locate_browsersync unless opts.key?('browsersync')
|
46
|
-
|
47
|
-
validate!(opts)
|
48
|
-
|
49
|
-
config = opts['config']
|
50
|
-
::Jekyll::Commands::Build.process(opts)
|
51
|
-
opts['config'] = config
|
52
|
-
Command.process(opts, args)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def process(opts, args)
|
58
|
-
opts = configuration_from_options(opts)
|
59
|
-
destination = opts['destination']
|
10
|
+
def self.init_with_program(prog)
|
11
|
+
prog.command(:browsersync) do |c|
|
12
|
+
c.syntax "browsersync [options]"
|
13
|
+
c.description "Serve the site using Browsersync"
|
60
14
|
|
61
|
-
|
62
|
-
args << "--files #{destination}"
|
63
|
-
args << "--port #{opts['port']}"
|
64
|
-
args << "--host #{opts['host']}"
|
65
|
-
args << "--ui-port #{opts['ui_port']}"
|
66
|
-
args << '--https' if opts['https']
|
67
|
-
args << '--no-open' unless opts['open_url']
|
68
|
-
args << '--directory' if opts['show_dir_listing']
|
15
|
+
options.each { |opt| c.option(*opt) }
|
69
16
|
|
70
|
-
|
17
|
+
add_build_options(c)
|
71
18
|
|
72
|
-
|
73
|
-
trap("INT") { Process.kill 'INT', pid }
|
74
|
-
|
75
|
-
::Jekyll.logger.info "Server address:", server_address(opts)
|
76
|
-
::Jekyll.logger.info "UI address:", server_address(opts, 'ui')
|
77
|
-
|
78
|
-
begin
|
79
|
-
stdout.each { |line| ::Jekyll.logger.debug line.rstrip }
|
80
|
-
rescue
|
81
|
-
end
|
82
|
-
end
|
19
|
+
c.action { |args, options| process(args, options) }
|
83
20
|
end
|
21
|
+
end
|
84
22
|
|
85
|
-
|
23
|
+
def self.options
|
24
|
+
[
|
25
|
+
["host", "-H", "--host [HOST]", "Host to bind to"],
|
26
|
+
["port", "-P", "--port [PORT]", "Port to listen on"],
|
27
|
+
["open", "-o", "--open", "Launch your site in a browser"],
|
28
|
+
["browsersync", "-e", "--cli [PATH]", "Path to browsersync CLI"],
|
29
|
+
]
|
30
|
+
end
|
86
31
|
|
87
|
-
|
88
|
-
|
89
|
-
|
32
|
+
def self.process(args = [], options = {})
|
33
|
+
config = configuration_from_options(options)
|
34
|
+
config["serving"] = true
|
35
|
+
config["watch"] = true unless config.key?("watch")
|
36
|
+
|
37
|
+
cli = config["browsersync"] || self.browsersync()
|
38
|
+
args << "--server #{config["destination"]}"
|
39
|
+
args << "--files #{config["destination"]}"
|
40
|
+
args << "--port #{config["port"]}"
|
41
|
+
args << "--host #{config["host"]}"
|
42
|
+
args << "--no-open" unless config["open"]
|
43
|
+
cmd = "#{cli} start #{args.join(" ")}"
|
44
|
+
|
45
|
+
if `#{cli} --version 2>/dev/null`.empty?
|
46
|
+
raise "Unable to locate browser-sync binary."
|
90
47
|
end
|
91
48
|
|
92
|
-
|
93
|
-
def validate!(opts)
|
94
|
-
browsersync_version = `#{opts['browsersync']} --version 2>/dev/null`
|
49
|
+
::Jekyll::Commands::Build.process(config)
|
95
50
|
|
96
|
-
|
51
|
+
PTY.spawn(cmd) do |stdout, stdin, pid|
|
52
|
+
trap("INT") { Process.kill "INT", pid }
|
53
|
+
|
54
|
+
begin
|
55
|
+
stdout.each { |line| ::Jekyll.logger.info(line.rstrip) }
|
56
|
+
rescue
|
57
|
+
end
|
97
58
|
end
|
59
|
+
end
|
98
60
|
|
99
|
-
|
100
|
-
format("%{protocol}://%{address}:%{port}%{baseurl}", {
|
101
|
-
:protocol => opts['https'] ? 'https' : 'http',
|
102
|
-
:address => opts['host'],
|
103
|
-
:port => server == 'ui' ? opts['ui_port'] : opts['port'],
|
104
|
-
:baseurl => opts['baseurl'] ? "#{opts["baseurl"]}/" : '',
|
105
|
-
})
|
106
|
-
end
|
61
|
+
private
|
107
62
|
|
108
|
-
|
109
|
-
|
110
|
-
# See: http://stackoverflow.com/a/5471032/1264736
|
111
|
-
#
|
112
|
-
# which('ruby') #=> /usr/bin/ruby
|
113
|
-
def which(cmd)
|
114
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
115
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
116
|
-
exts.each { |ext|
|
117
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
118
|
-
return exe if File.executable?(exe) && !File.directory?(exe)
|
119
|
-
}
|
120
|
-
end
|
121
|
-
return nil
|
122
|
-
end
|
63
|
+
def self.browsersync
|
64
|
+
File.exists?(DEFAULT_BROWSERSYNC_PATH) ? DEFAULT_BROWSERSYNC_PATH : TTY::Which.which("browser-sync")
|
123
65
|
end
|
124
66
|
end
|
125
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-browsersync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Loberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -17,9 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
|
-
- - "
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '5.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +27,23 @@ dependencies:
|
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: tty-which
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.4.1
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
30
44
|
- - "~>"
|
31
45
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
46
|
+
version: 0.4.1
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: bundler
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,8 +79,6 @@ executables: []
|
|
65
79
|
extensions: []
|
66
80
|
extra_rdoc_files: []
|
67
81
|
files:
|
68
|
-
- LICENSE
|
69
|
-
- README.md
|
70
82
|
- lib/jekyll-browsersync.rb
|
71
83
|
- lib/jekyll-browsersync/command.rb
|
72
84
|
- lib/jekyll-browsersync/version.rb
|
@@ -82,15 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
94
|
requirements:
|
83
95
|
- - ">="
|
84
96
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
97
|
+
version: 2.3.0
|
86
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
99
|
requirements:
|
88
100
|
- - ">="
|
89
101
|
- !ruby/object:Gem::Version
|
90
102
|
version: '0'
|
91
103
|
requirements: []
|
92
|
-
|
93
|
-
rubygems_version: 2.5.1
|
104
|
+
rubygems_version: 3.0.3
|
94
105
|
signing_key:
|
95
106
|
specification_version: 4
|
96
107
|
summary: Add live reloading to Jekyll using Browsersync.
|
data/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2016 Matthew Loberg
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Jekyll Browsersync
|
2
|
-
|
3
|
-
Add live reloading to your Jekyll development using [Browsersync](https://www.browsersync.io/).
|
4
|
-
|
5
|
-
## Requirements
|
6
|
-
|
7
|
-
* Jekyll >= 3
|
8
|
-
* [Browsersync](https://www.browsersync.io/) installed
|
9
|
-
* globally (`npm install -g browser-sync` ) **OR**
|
10
|
-
* locally (`npm install browser-sync`)
|
11
|
-
|
12
|
-
## Installation
|
13
|
-
|
14
|
-
Add this line to your application's Gemfile:
|
15
|
-
|
16
|
-
gem 'jekyll-browsersync', group: [:jekyll_plugins]
|
17
|
-
|
18
|
-
Then install it
|
19
|
-
|
20
|
-
$ bundle
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
Once you have it installed, you should have a new `browsersync` command under Jekyll.
|
25
|
-
|
26
|
-
$ bundle exec jekyll browsersync
|
27
|
-
|
28
|
-
If you have Browsersync installed in a custom location, you can specify this with the
|
29
|
-
`--browser-sync` option.
|
30
|
-
|
31
|
-
$ bundle exec jekyll browser-sync --browser-sync ~/bin/browser-sync
|
32
|
-
|
33
|
-
If you would like to serve the site using https, use the `--https` option.
|
34
|
-
|
35
|
-
$ bundle exec jekyll bs --https
|
36
|
-
|
37
|
-
If you have any other options you would like passed to the Browsersync command,
|
38
|
-
pass them as arguments.
|
39
|
-
|
40
|
-
$ bundle exec jekyll browsersync -- --no-notify
|
41
|
-
|
42
|
-
## Contributing
|
43
|
-
|
44
|
-
1. Fork it (https://github.com/mloberg/jekyll-browsersync/fork)
|
45
|
-
2. Create your feature branch (`git checkout -b feature/my-awesome-feature`)
|
46
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
-
4. Push to the branch (`git push origin feature/my-awesome-feature`)
|
48
|
-
5. Create new Pull Request
|
49
|
-
|
50
|
-
## TODO
|
51
|
-
|
52
|
-
* Write tests
|