nanoc-live 1.0.0b3 → 1.0.0b8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +30 -0
- data/lib/nanoc/live.rb +7 -4
- data/lib/nanoc/live/command_runners/live.rb +37 -0
- data/lib/nanoc/live/commands/live.rb +1 -21
- data/lib/nanoc/live/live_recompiler.rb +100 -107
- data/lib/nanoc/live/version.rb +1 -1
- metadata +27 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36dc942329928d105b0d7e883eccfadcddb791486c892609ac77c3aef225482
|
4
|
+
data.tar.gz: 1eaeb5142e3e08307c25e249368aec4f6a4b42cdd887de6470f47706bc57f2cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1468703d2fe8b026ea5bc42ceba55204d167f040982cc7a80ac008c70407512adf48c82cc74cbf0e6441ac900a92949885a8c5d04f65fb690ad081cd79392c97
|
7
|
+
data.tar.gz: aa01b3273e3115f0aa0672ac6958eada7d1e21501f975d478dc516d6a3e95388039cc5fa02ff5fc56722d166caa76491d490c7da4381cc0852ec1cd5f5129e80
|
data/NEWS.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Release notes for nanoc-live
|
2
2
|
|
3
|
+
## 1.0.0b8 (2021-01-16)
|
4
|
+
|
5
|
+
Fixes:
|
6
|
+
|
7
|
+
- Fixed issue which could cause nanoc-live to keep running and use 100% CPU (#1538)
|
8
|
+
|
9
|
+
## 1.0.0b7 (2021-01-01)
|
10
|
+
|
11
|
+
Enhancements:
|
12
|
+
|
13
|
+
- Added support for Ruby 3.x
|
14
|
+
|
15
|
+
## 1.0.0b6 (2020-03-07)
|
16
|
+
|
17
|
+
Fixes:
|
18
|
+
|
19
|
+
* Restored compatibility with Nanoc 4.11.14.
|
20
|
+
|
21
|
+
## 1.0.0b5 (2019-11-16)
|
22
|
+
|
23
|
+
Fixes:
|
24
|
+
|
25
|
+
* Restored compatibility with Nanoc 4.11.13.
|
26
|
+
|
27
|
+
## 1.0.0b4 (2019-04-30)
|
28
|
+
|
29
|
+
Fixes:
|
30
|
+
|
31
|
+
* Restored compatibility with most recent version of Nanoc.
|
32
|
+
|
3
33
|
## 1.0.0b3 (2018-08-31)
|
4
34
|
|
5
35
|
Fixes:
|
data/lib/nanoc/live.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'adsf/live'
|
4
4
|
require 'listen'
|
5
5
|
require 'nanoc'
|
6
|
-
require 'nanoc/
|
6
|
+
require 'nanoc/orig_cli'
|
7
7
|
|
8
8
|
module Nanoc
|
9
9
|
module Live
|
@@ -12,9 +12,12 @@ end
|
|
12
12
|
|
13
13
|
require_relative 'live/version'
|
14
14
|
require_relative 'live/live_recompiler'
|
15
|
+
require_relative 'live/command_runners/live'
|
16
|
+
|
17
|
+
root = File.dirname(__FILE__)
|
18
|
+
live_command_path = File.join(root, 'live', 'commands', 'live.rb')
|
19
|
+
command = Cri::Command.load_file(live_command_path, infer_name: true)
|
15
20
|
|
16
21
|
Nanoc::CLI.after_setup do
|
17
|
-
|
18
|
-
live_command_path = File.join(root, 'live', 'commands', 'live.rb')
|
19
|
-
Nanoc::CLI.add_command(Cri::Command.load_file(live_command_path, infer_name: true))
|
22
|
+
Nanoc::CLI.add_command(command)
|
20
23
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
module Live
|
5
|
+
module CommandRunners
|
6
|
+
class Live < ::Nanoc::CLI::CommandRunner
|
7
|
+
def run
|
8
|
+
if defined?(Guard::Nanoc)
|
9
|
+
$stderr.puts '-' * 40
|
10
|
+
$stderr.puts 'NOTE:'
|
11
|
+
$stderr.puts 'You are using the `nanoc live` command provided by `nanoc-live`, but the `guard-nanoc` gem is also installed, which also provides a `nanoc live` command.'
|
12
|
+
if defined?(Bundler)
|
13
|
+
$stderr.puts 'Recommendation: Remove `guard-nanoc` from your Gemfile.'
|
14
|
+
else
|
15
|
+
$stderr.puts 'Recommendation: Uninstall `guard-nanoc`.'
|
16
|
+
end
|
17
|
+
$stderr.puts '-' * 40
|
18
|
+
end
|
19
|
+
|
20
|
+
self.class.enter_site_dir
|
21
|
+
|
22
|
+
Thread.new do
|
23
|
+
Thread.current.abort_on_exception = true
|
24
|
+
if Thread.current.respond_to?(:report_on_exception)
|
25
|
+
Thread.current.report_on_exception = false
|
26
|
+
end
|
27
|
+
|
28
|
+
view_options = options.merge('live-reload': true)
|
29
|
+
Nanoc::CLI::Commands::View.new(view_options, [], self).run
|
30
|
+
end
|
31
|
+
|
32
|
+
Nanoc::Live::LiveRecompiler.new(command_runner: self).run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -13,24 +13,4 @@ required :o, :host, 'specify the host to listen on (default: 127.0.0.1)', def
|
|
13
13
|
required :p, :port, 'specify the port to listen on (default: 3000)', transform: Nanoc::CLI::Transform::Port, default: 3000
|
14
14
|
no_params
|
15
15
|
|
16
|
-
|
17
|
-
class Live < ::Nanoc::CLI::CommandRunner
|
18
|
-
def run
|
19
|
-
self.class.enter_site_dir
|
20
|
-
|
21
|
-
Thread.new do
|
22
|
-
Thread.current.abort_on_exception = true
|
23
|
-
if Thread.current.respond_to?(:report_on_exception)
|
24
|
-
Thread.current.report_on_exception = false
|
25
|
-
end
|
26
|
-
|
27
|
-
view_options = options.merge('live-reload': true)
|
28
|
-
Nanoc::CLI::Commands::View.new(view_options, [], self).run
|
29
|
-
end
|
30
|
-
|
31
|
-
Nanoc::Live::LiveRecompiler.new(command_runner: self).run
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
runner Nanoc::Live::Commands::Live
|
16
|
+
runner Nanoc::Live::CommandRunners::Live
|
@@ -1,135 +1,128 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module Nanoc
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def run
|
10
|
-
run_parent do |site|
|
11
|
-
handle_changes(site, @command_runner)
|
3
|
+
module Nanoc
|
4
|
+
module Live
|
5
|
+
class LiveRecompiler
|
6
|
+
def initialize(command_runner:)
|
7
|
+
@command_runner = command_runner
|
12
8
|
end
|
13
|
-
end
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
site.data_source.layout_changes,
|
21
|
-
gen_config_and_rules_changes,
|
22
|
-
]
|
23
|
-
|
24
|
-
SlowEnumeratorTools.batch(SlowEnumeratorTools.merge(changes))
|
25
|
-
end
|
10
|
+
def run
|
11
|
+
run_parent do |site|
|
12
|
+
handle_changes(site, @command_runner)
|
13
|
+
end
|
14
|
+
end
|
26
15
|
|
27
|
-
|
28
|
-
pipe_write.close
|
16
|
+
private
|
29
17
|
|
30
|
-
site
|
31
|
-
|
32
|
-
|
18
|
+
def gen_changes_for_child(site)
|
19
|
+
changes = [
|
20
|
+
site.data_source.item_changes,
|
21
|
+
site.data_source.layout_changes,
|
22
|
+
gen_config_and_rules_changes,
|
23
|
+
]
|
33
24
|
|
34
|
-
|
35
|
-
parent_enum = Enumerator.new do |y|
|
36
|
-
pipe_read.read
|
37
|
-
y << quit
|
25
|
+
SlowEnumeratorTools.batch(SlowEnumeratorTools.merge(changes))
|
38
26
|
end
|
39
27
|
|
40
|
-
|
41
|
-
|
42
|
-
break if quit.equal?(e)
|
43
|
-
|
44
|
-
$stderr.print 'Reloading site… '
|
45
|
-
$stderr.flush
|
46
|
-
site_loader = Nanoc::Int::SiteLoader.new
|
47
|
-
site = Nanoc::Int::Site.new(
|
48
|
-
config: Nanoc::Int::ConfigLoader.new.new_from_cwd,
|
49
|
-
data_source: site_loader.gen_data_source_for_config(site.config),
|
50
|
-
code_snippets: site.code_snippets,
|
51
|
-
)
|
52
|
-
$stderr.puts 'done'
|
28
|
+
def run_child(pipe_write, pipe_read)
|
29
|
+
pipe_write.close
|
53
30
|
|
31
|
+
site = Nanoc::Core::SiteLoader.new.new_from_cwd
|
32
|
+
changes_enum = gen_changes_for_child(site)
|
54
33
|
yield(site)
|
55
|
-
end
|
56
|
-
|
57
|
-
exit 0
|
58
|
-
rescue Interrupt
|
59
|
-
exit 0
|
60
|
-
end
|
61
34
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
35
|
+
quit = Object.new
|
36
|
+
parent_enum = Enumerator.new do |y|
|
37
|
+
pipe_read.read
|
38
|
+
y << quit
|
39
|
+
end
|
40
|
+
|
41
|
+
puts 'Listening for site changes…'
|
42
|
+
SlowEnumeratorTools.merge([parent_enum, changes_enum]).each do |e|
|
43
|
+
break if quit.equal?(e)
|
44
|
+
|
45
|
+
$stderr.print 'Reloading site… '
|
46
|
+
$stderr.flush
|
47
|
+
site_loader = Nanoc::Core::SiteLoader.new
|
48
|
+
site = Nanoc::Core::Site.new(
|
49
|
+
config: Nanoc::Core::ConfigLoader.new.new_from_cwd,
|
50
|
+
data_source: site_loader.gen_data_source_for_config(site.config),
|
51
|
+
code_snippets: site.code_snippets,
|
52
|
+
)
|
53
|
+
$stderr.puts 'done'
|
54
|
+
|
55
|
+
yield(site)
|
56
|
+
end
|
57
|
+
|
58
|
+
exit 0
|
59
|
+
rescue Interrupt
|
60
|
+
exit 0
|
61
|
+
end
|
75
62
|
|
76
|
-
|
63
|
+
def run_parent
|
64
|
+
# create initial child
|
77
65
|
pipe_read, pipe_write = IO.pipe
|
78
66
|
fork { run_child(pipe_write, pipe_read) { |s| yield(s) } }
|
79
67
|
pipe_read.close
|
80
|
-
end
|
81
|
-
rescue Interrupt
|
82
|
-
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
changes = gen_lib_changes
|
70
|
+
puts 'Listening for lib/ changes…'
|
71
|
+
changes.each do |_e|
|
72
|
+
# stop child
|
73
|
+
pipe_write.write('q')
|
74
|
+
pipe_write.close
|
75
|
+
Process.wait
|
76
|
+
|
77
|
+
# create new child
|
78
|
+
pipe_read, pipe_write = IO.pipe
|
79
|
+
fork { run_child(pipe_write, pipe_read) { |s| yield(s) } }
|
80
|
+
pipe_read.close
|
81
|
+
end
|
82
|
+
rescue Interrupt
|
87
83
|
end
|
88
|
-
end
|
89
84
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
compiler = Nanoc::Int::Compiler.new_for(site)
|
95
|
-
listener = Nanoc::CLI::Commands::CompileListeners::Aggregate.new(
|
96
|
-
command_runner: command_runner,
|
97
|
-
site: site,
|
98
|
-
compiler: compiler,
|
99
|
-
)
|
100
|
-
listener.run_while do
|
101
|
-
compiler.run_until_end
|
85
|
+
def handle_changes(site, command_runner)
|
86
|
+
Nanoc::CLI::ErrorHandler.handle_while(exit_on_error: false) do
|
87
|
+
unsafe_handle_changes(site, command_runner)
|
88
|
+
end
|
102
89
|
end
|
103
90
|
|
104
|
-
|
105
|
-
|
106
|
-
puts
|
107
|
-
end
|
91
|
+
def unsafe_handle_changes(site, command_runner)
|
92
|
+
time_before = Time.now
|
108
93
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
94
|
+
puts 'Compiling site…'
|
95
|
+
compiler = Nanoc::Core::Compiler.new_for(site)
|
96
|
+
listener = Nanoc::CLI::CompileListeners::Aggregate.new(
|
97
|
+
command_runner: command_runner,
|
98
|
+
site: site,
|
99
|
+
compiler: compiler,
|
100
|
+
)
|
101
|
+
listener.run_while do
|
102
|
+
compiler.run_until_end
|
103
|
+
end
|
115
104
|
|
116
|
-
|
117
|
-
|
118
|
-
|
105
|
+
time_after = Time.now
|
106
|
+
puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
|
107
|
+
puts
|
119
108
|
end
|
120
|
-
end
|
121
109
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
110
|
+
def gen_lib_changes
|
111
|
+
Nanoc::Core::ChangesStream.new do |cl|
|
112
|
+
listener = Listen.to('lib') { |*| cl.lib }
|
113
|
+
listener.start
|
114
|
+
sleep
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def gen_config_and_rules_changes
|
119
|
+
Nanoc::Core::ChangesStream.new do |cl|
|
120
|
+
only = /(\/|\A)(nanoc\.yaml|config\.yaml|rules|Rules|rules\.rb|Rules\.rb)\z/
|
121
|
+
|
122
|
+
listener = Listen.to('.', only: only) { |*| cl.unknown }
|
123
|
+
listener.start
|
124
|
+
sleep
|
125
|
+
end
|
133
126
|
end
|
134
127
|
end
|
135
128
|
end
|
data/lib/nanoc/live/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-live
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0b8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adsf-live
|
@@ -25,53 +25,59 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: listen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: nanoc-cli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.11'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 4.11.14
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - "~>"
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
57
|
+
version: '4.11'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 4.11.14
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: nanoc
|
62
|
+
name: nanoc-core
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '4.
|
67
|
+
version: '4.11'
|
62
68
|
- - ">="
|
63
69
|
- !ruby/object:Gem::Version
|
64
|
-
version: 4.
|
70
|
+
version: 4.11.14
|
65
71
|
type: :runtime
|
66
72
|
prerelease: false
|
67
73
|
version_requirements: !ruby/object:Gem::Requirement
|
68
74
|
requirements:
|
69
75
|
- - "~>"
|
70
76
|
- !ruby/object:Gem::Version
|
71
|
-
version: '4.
|
77
|
+
version: '4.11'
|
72
78
|
- - ">="
|
73
79
|
- !ruby/object:Gem::Version
|
74
|
-
version: 4.
|
80
|
+
version: 4.11.14
|
75
81
|
description: Provides support for auto-recompiling Nanoc sites.
|
76
82
|
email: denis+rubygems@denis.ws
|
77
83
|
executables: []
|
@@ -81,31 +87,31 @@ files:
|
|
81
87
|
- NEWS.md
|
82
88
|
- README.md
|
83
89
|
- lib/nanoc/live.rb
|
90
|
+
- lib/nanoc/live/command_runners/live.rb
|
84
91
|
- lib/nanoc/live/commands/live.rb
|
85
92
|
- lib/nanoc/live/live_recompiler.rb
|
86
93
|
- lib/nanoc/live/version.rb
|
87
|
-
homepage:
|
94
|
+
homepage: https://nanoc.ws/
|
88
95
|
licenses:
|
89
96
|
- MIT
|
90
97
|
metadata: {}
|
91
|
-
post_install_message:
|
98
|
+
post_install_message:
|
92
99
|
rdoc_options: []
|
93
100
|
require_paths:
|
94
101
|
- lib
|
95
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
103
|
requirements:
|
97
|
-
- - "
|
104
|
+
- - ">="
|
98
105
|
- !ruby/object:Gem::Version
|
99
|
-
version: '2.
|
106
|
+
version: '2.5'
|
100
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
108
|
requirements:
|
102
109
|
- - ">"
|
103
110
|
- !ruby/object:Gem::Version
|
104
111
|
version: 1.3.1
|
105
112
|
requirements: []
|
106
|
-
|
107
|
-
|
108
|
-
signing_key:
|
113
|
+
rubygems_version: 3.2.5
|
114
|
+
signing_key:
|
109
115
|
specification_version: 4
|
110
116
|
summary: Live recompilation support for Nanoc
|
111
117
|
test_files: []
|