nanoc-cli 4.14.6 → 4.14.7
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 +4 -4
- data/lib/nanoc/cli/command_runner.rb +4 -2
- data/lib/nanoc/cli/commands/compile.rb +7 -5
- data/lib/nanoc/cli/commands/create-site.rb +10 -11
- data/lib/nanoc/cli/commands/prune.rb +8 -3
- data/lib/nanoc/cli/commands/show-plugins.rb +3 -3
- data/lib/nanoc/cli/commands/view.rb +7 -4
- data/lib/nanoc/cli/compile_listeners/abstract.rb +1 -1
- data/lib/nanoc/cli/compile_listeners/aggregate.rb +6 -8
- data/lib/nanoc/cli/compile_listeners/debug_printer.rb +1 -22
- data/lib/nanoc/cli/compile_listeners/diff_generator.rb +2 -2
- data/lib/nanoc/cli/compile_listeners/file_action_printer.rb +4 -16
- data/lib/nanoc/cli/compile_listeners/timing_recorder.rb +101 -55
- data/lib/nanoc/cli/error_handler.rb +3 -3
- data/lib/nanoc/cli/logger.rb +5 -2
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +1 -1
- data/lib/nanoc/cli/version.rb +1 -1
- data/lib/nanoc/cli.rb +7 -7
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c7021eaff35161ce9760b1b9a68d3889644a0176b81c9a7fc6a3f52f083c1d0
|
|
4
|
+
data.tar.gz: e9915cda1dee1e375c00d603354ceb8d5a560a0fdf8140a3fbfb41d56fed5c45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b49b4d2941ebb911ce20d8c47a38d7f426ebbbe833837d30f3a8058bdc3c5ecc7463372d3484697b85f834cb726b5521ea5021f95578a03e5184ba1b1b4d6c6f
|
|
7
|
+
data.tar.gz: 41ae6d1b8d3ae8996269819545f5931d44049efa5f57ec8a523949864f9e3116062606778f511cd1597d1ad472efc90cee28ace1c76ab94ea636be41d7070d01
|
|
@@ -40,7 +40,8 @@ module Nanoc
|
|
|
40
40
|
def self.enter_site_dir
|
|
41
41
|
dir = find_site_dir
|
|
42
42
|
if dir.nil?
|
|
43
|
-
raise ::Nanoc::Core::TrivialError,
|
|
43
|
+
raise ::Nanoc::Core::TrivialError,
|
|
44
|
+
'The current working directory, nor any of its parents, seems to be a Nanoc site.'
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
return if Dir.getwd == dir
|
|
@@ -57,7 +58,8 @@ module Nanoc
|
|
|
57
58
|
|
|
58
59
|
$stderr.print 'Loading site… '
|
|
59
60
|
$stderr.flush
|
|
60
|
-
|
|
61
|
+
config = Nanoc::Core::ConfigLoader.new.new_from_cwd
|
|
62
|
+
site = Nanoc::Core::SiteLoader.new.new_from_config(config)
|
|
61
63
|
|
|
62
64
|
$stderr.puts 'done'
|
|
63
65
|
site
|
|
@@ -33,16 +33,18 @@ module Nanoc::CLI::Commands
|
|
|
33
33
|
def run_once
|
|
34
34
|
time_before = Time.now
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
config = Nanoc::Core::ConfigLoader.new.new_from_cwd
|
|
37
37
|
|
|
38
|
-
puts 'Compiling site…'
|
|
39
|
-
compiler = Nanoc::Core::Compiler.new_for(@site, focus: options[:focus])
|
|
40
38
|
listener = Nanoc::CLI::CompileListeners::Aggregate.new(
|
|
41
39
|
command_runner: self,
|
|
42
|
-
|
|
43
|
-
compiler:,
|
|
40
|
+
config:,
|
|
44
41
|
)
|
|
45
42
|
listener.run_while do
|
|
43
|
+
puts 'Loading site…'
|
|
44
|
+
site = Nanoc::Core::SiteLoader.new.new_from_config(config)
|
|
45
|
+
|
|
46
|
+
puts 'Compiling site…'
|
|
47
|
+
compiler = Nanoc::Core::Compiler.new_for(site, focus: options[:focus])
|
|
46
48
|
compiler.run_until_end
|
|
47
49
|
end
|
|
48
50
|
|
|
@@ -9,15 +9,6 @@ param :path
|
|
|
9
9
|
|
|
10
10
|
module Nanoc::CLI::Commands
|
|
11
11
|
class CreateSite < ::Nanoc::CLI::CommandRunner
|
|
12
|
-
class << self
|
|
13
|
-
protected
|
|
14
|
-
|
|
15
|
-
# Converts the given array to YAML format
|
|
16
|
-
def array_to_yaml(array)
|
|
17
|
-
'[ ' + array.map { |s| "'" + s + "'" }.join(', ') + ' ]'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
12
|
DEFAULT_GEMFILE = <<~EOS.freeze unless defined? DEFAULT_GEMFILE
|
|
22
13
|
# frozen_string_literal: true
|
|
23
14
|
|
|
@@ -30,7 +21,7 @@ module Nanoc::CLI::Commands
|
|
|
30
21
|
# A list of file extensions that Nanoc will consider to be textual rather than
|
|
31
22
|
# binary. If an item with an extension not in this list is found, the file
|
|
32
23
|
# will be considered as binary.
|
|
33
|
-
text_extensions: #{
|
|
24
|
+
text_extensions: #{JSON.dump(Nanoc::Core::Configuration::DEFAULT_CONFIG[:text_extensions])}
|
|
34
25
|
|
|
35
26
|
prune:
|
|
36
27
|
auto_prune: true
|
|
@@ -43,6 +34,8 @@ module Nanoc::CLI::Commands
|
|
|
43
34
|
DEFAULT_RULES = <<~EOS unless defined? DEFAULT_RULES
|
|
44
35
|
#!/usr/bin/env ruby
|
|
45
36
|
|
|
37
|
+
passthrough '/robots.txt'
|
|
38
|
+
|
|
46
39
|
compile '/**/*.html' do
|
|
47
40
|
layout '/default.*'
|
|
48
41
|
|
|
@@ -73,6 +66,11 @@ module Nanoc::CLI::Commands
|
|
|
73
66
|
layout '/**/*', :erb
|
|
74
67
|
EOS
|
|
75
68
|
|
|
69
|
+
ROBOTS_TXT_ITEM = <<~EOS unless defined? ROBOTS_TXT_ITEM
|
|
70
|
+
User-agent: *
|
|
71
|
+
Allow: /
|
|
72
|
+
EOS
|
|
73
|
+
|
|
76
74
|
DEFAULT_ITEM = <<~EOS unless defined? DEFAULT_ITEM
|
|
77
75
|
---
|
|
78
76
|
title: Home
|
|
@@ -230,7 +228,7 @@ module Nanoc::CLI::Commands
|
|
|
230
228
|
path = arguments[:path]
|
|
231
229
|
|
|
232
230
|
# Check whether site exists
|
|
233
|
-
if File.exist?(path) && (!File.directory?(path) || !(Dir.entries(path) -
|
|
231
|
+
if File.exist?(path) && (!File.directory?(path) || !(Dir.entries(path) - ['.', '..']).empty?) && !options[:force]
|
|
234
232
|
raise(
|
|
235
233
|
Nanoc::Core::TrivialError,
|
|
236
234
|
"The site was not created because '#{path}' already exists. " \
|
|
@@ -250,6 +248,7 @@ module Nanoc::CLI::Commands
|
|
|
250
248
|
write('nanoc.yaml', DEFAULT_CONFIG)
|
|
251
249
|
write('Rules', DEFAULT_RULES)
|
|
252
250
|
write('content/index.html', DEFAULT_ITEM)
|
|
251
|
+
write('content/robots.txt', ROBOTS_TXT_ITEM)
|
|
253
252
|
write('content/stylesheet.css', DEFAULT_STYLESHEET)
|
|
254
253
|
write('layouts/default.html', DEFAULT_LAYOUT)
|
|
255
254
|
end
|
|
@@ -23,7 +23,7 @@ module Nanoc::CLI::Commands
|
|
|
23
23
|
reps = res.fetch(:reps)
|
|
24
24
|
|
|
25
25
|
listener_class = Nanoc::CLI::CompileListeners::FileActionPrinter
|
|
26
|
-
listener = listener_class.new
|
|
26
|
+
listener = listener_class.new
|
|
27
27
|
listener.start_safely
|
|
28
28
|
|
|
29
29
|
if options.key?(:yes)
|
|
@@ -31,9 +31,14 @@ module Nanoc::CLI::Commands
|
|
|
31
31
|
elsif options.key?(:'dry-run')
|
|
32
32
|
Nanoc::Core::Pruner.new(@site.config, reps, exclude: prune_config_exclude, dry_run: true).run
|
|
33
33
|
else
|
|
34
|
-
$stderr.puts 'WARNING: Since the prune command is a destructive
|
|
34
|
+
$stderr.puts 'WARNING: Since the prune command is a destructive ' \
|
|
35
|
+
'command, it requires an additional --yes flag in order to work.'
|
|
35
36
|
$stderr.puts
|
|
36
|
-
$stderr.puts 'Please ensure that the output directory does not
|
|
37
|
+
$stderr.puts 'Please ensure that the output directory does not ' \
|
|
38
|
+
'contain any files (such as images or stylesheets) that ' \
|
|
39
|
+
'are necessary but are not managed by Nanoc. If you ' \
|
|
40
|
+
'want to get a list of all files that would be removed, ' \
|
|
41
|
+
'pass --dry-run.'
|
|
37
42
|
exit 1
|
|
38
43
|
end
|
|
39
44
|
ensure
|
|
@@ -28,10 +28,10 @@ module Nanoc::CLI::Commands
|
|
|
28
28
|
|
|
29
29
|
def run
|
|
30
30
|
# Get list of plugins (before and after)
|
|
31
|
-
plugins_before = PLUGIN_CLASSES.keys.
|
|
31
|
+
plugins_before = PLUGIN_CLASSES.keys.to_h { |c| [c, c.all] }
|
|
32
32
|
site = load_site
|
|
33
33
|
site&.code_snippets
|
|
34
|
-
plugins_after = PLUGIN_CLASSES.keys.
|
|
34
|
+
plugins_after = PLUGIN_CLASSES.keys.to_h { |c| [c, c.all] }
|
|
35
35
|
|
|
36
36
|
# Divide list of plugins into builtin and custom
|
|
37
37
|
plugins_builtin = plugins_before
|
|
@@ -55,7 +55,7 @@ module Nanoc::CLI::Commands
|
|
|
55
55
|
puts
|
|
56
56
|
|
|
57
57
|
# Print plugins organised by subtype
|
|
58
|
-
|
|
58
|
+
[:builtin, :custom].each do |type|
|
|
59
59
|
# Find relevant plugins
|
|
60
60
|
relevant_plugins = plugins_with_this_superclass[type]
|
|
61
61
|
|
|
@@ -8,10 +8,13 @@ description <<~EOS
|
|
|
8
8
|
`adsf` (not `asdf`!).
|
|
9
9
|
EOS
|
|
10
10
|
|
|
11
|
-
option :H, :handler, 'specify the handler to use (webrick/puma/...)',
|
|
12
|
-
|
|
13
|
-
option :
|
|
14
|
-
|
|
11
|
+
option :H, :handler, 'specify the handler to use (webrick/puma/...)',
|
|
12
|
+
argument: :required
|
|
13
|
+
option :o, :host, 'specify the host to listen on',
|
|
14
|
+
default: '127.0.0.1', argument: :required
|
|
15
|
+
option :p, :port, 'specify the port to listen on',
|
|
16
|
+
transform: Nanoc::CLI::Transform::Port, default: 3000, argument: :required
|
|
17
|
+
flag :L, :'live-reload', 'reload on changes'
|
|
15
18
|
no_params
|
|
16
19
|
|
|
17
20
|
module Nanoc::CLI::Commands
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Nanoc::CLI::CompileListeners
|
|
4
4
|
class Aggregate < Abstract
|
|
5
|
-
def initialize(command_runner:,
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
def initialize(command_runner:, config:)
|
|
6
|
+
super()
|
|
7
|
+
|
|
8
|
+
@config = config
|
|
8
9
|
@command_runner = command_runner
|
|
9
10
|
|
|
10
11
|
@listener_classes = self.class.default_listener_classes
|
|
@@ -30,13 +31,10 @@ module Nanoc::CLI::CompileListeners
|
|
|
30
31
|
protected
|
|
31
32
|
|
|
32
33
|
def setup_listeners
|
|
33
|
-
res = @compiler.run_until_reps_built
|
|
34
|
-
reps = res.fetch(:reps)
|
|
35
|
-
|
|
36
34
|
@listeners =
|
|
37
35
|
@listener_classes
|
|
38
|
-
.select { |klass| klass.enable_for?(@command_runner, @
|
|
39
|
-
.map
|
|
36
|
+
.select { |klass| klass.enable_for?(@command_runner, @config) }
|
|
37
|
+
.map(&:new)
|
|
40
38
|
|
|
41
39
|
@listeners.each(&:start_safely)
|
|
42
40
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Nanoc::CLI::CompileListeners
|
|
4
4
|
class DebugPrinter < Abstract
|
|
5
5
|
# @see Listener#enable_for?
|
|
6
|
-
def self.enable_for?(command_runner,
|
|
6
|
+
def self.enable_for?(command_runner, _config)
|
|
7
7
|
command_runner.debug?
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -12,7 +12,6 @@ module Nanoc::CLI::CompileListeners
|
|
|
12
12
|
'content' => :green,
|
|
13
13
|
'filtering' => :yellow,
|
|
14
14
|
'dependency_tracking' => :blue,
|
|
15
|
-
'phase' => :magenta,
|
|
16
15
|
'stage' => :cyan,
|
|
17
16
|
}.freeze
|
|
18
17
|
|
|
@@ -51,26 +50,6 @@ module Nanoc::CLI::CompileListeners
|
|
|
51
50
|
log('dependency_tracking', "Dependency created from #{src.inspect} onto #{dst.inspect}")
|
|
52
51
|
end
|
|
53
52
|
|
|
54
|
-
on(:phase_started) do |phase_name, rep|
|
|
55
|
-
log('phase', "Phase started: #{phase_name} (rep: #{rep})")
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
on(:phase_yielded) do |phase_name, rep|
|
|
59
|
-
log('phase', "Phase yielded: #{phase_name} (rep: #{rep})")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
on(:phase_resumed) do |phase_name, rep|
|
|
63
|
-
log('phase', "Phase resumed: #{phase_name} (rep: #{rep})")
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
on(:phase_ended) do |phase_name, rep|
|
|
67
|
-
log('phase', "Phase ended: #{phase_name} (rep: #{rep})")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
on(:phase_aborted) do |phase_name, rep|
|
|
71
|
-
log('phase', "Phase aborted: #{phase_name} (rep: #{rep})")
|
|
72
|
-
end
|
|
73
|
-
|
|
74
53
|
on(:stage_started) do |stage_name|
|
|
75
54
|
log('stage', "Stage started: #{stage_name}")
|
|
76
55
|
end
|
|
@@ -46,8 +46,8 @@ module Nanoc::CLI::CompileListeners
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
# @see Listener#enable_for?
|
|
49
|
-
def self.enable_for?(command_runner,
|
|
50
|
-
|
|
49
|
+
def self.enable_for?(command_runner, config)
|
|
50
|
+
config[:enable_output_diff] || command_runner.options[:diff]
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# @see Listener#start
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Nanoc::CLI::CompileListeners
|
|
4
4
|
class FileActionPrinter < Abstract
|
|
5
|
-
def initialize
|
|
6
|
-
|
|
5
|
+
def initialize
|
|
6
|
+
super
|
|
7
7
|
|
|
8
8
|
@stopwatches = {}
|
|
9
9
|
end
|
|
@@ -47,9 +47,7 @@ module Nanoc::CLI::CompileListeners
|
|
|
47
47
|
:identical
|
|
48
48
|
end
|
|
49
49
|
level =
|
|
50
|
-
if is_created
|
|
51
|
-
:high
|
|
52
|
-
elsif is_modified
|
|
50
|
+
if is_created || is_modified
|
|
53
51
|
:high
|
|
54
52
|
else
|
|
55
53
|
:low
|
|
@@ -81,17 +79,7 @@ module Nanoc::CLI::CompileListeners
|
|
|
81
79
|
path = path[(Dir.getwd.size + 1)..path.size]
|
|
82
80
|
end
|
|
83
81
|
|
|
84
|
-
Nanoc::CLI::Logger.instance.file(:high, :delete,
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# @see Listener#stop
|
|
89
|
-
def stop
|
|
90
|
-
@reps.reject(&:compiled?).each do |rep|
|
|
91
|
-
raw_paths = rep.raw_paths.values.flatten.uniq
|
|
92
|
-
raw_paths.each do |raw_path|
|
|
93
|
-
log(:low, :skip, raw_path, nil)
|
|
94
|
-
end
|
|
82
|
+
Nanoc::CLI::Logger.instance.file(:high, :delete, "(dry run) #{path}")
|
|
95
83
|
end
|
|
96
84
|
end
|
|
97
85
|
|
|
@@ -2,22 +2,100 @@
|
|
|
2
2
|
|
|
3
3
|
module Nanoc::CLI::CompileListeners
|
|
4
4
|
class TimingRecorder < Abstract
|
|
5
|
+
class Table
|
|
6
|
+
TOP = 1
|
|
7
|
+
MIDDLE = 2
|
|
8
|
+
BOTTOM = 3
|
|
9
|
+
|
|
10
|
+
def initialize(header_row, body_rows, footer_row)
|
|
11
|
+
@header_row = header_row
|
|
12
|
+
@body_rows = body_rows
|
|
13
|
+
@footer_row = footer_row
|
|
14
|
+
|
|
15
|
+
@rows = [header_row] + body_rows + [footer_row]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_s
|
|
19
|
+
columns = @rows.transpose
|
|
20
|
+
column_lengths = columns.map { |c| c.map(&:size).max }
|
|
21
|
+
|
|
22
|
+
[].tap do |lines|
|
|
23
|
+
# header
|
|
24
|
+
lines << separator(column_lengths, TOP)
|
|
25
|
+
lines << row_to_s(@header_row, column_lengths)
|
|
26
|
+
lines << separator(column_lengths, MIDDLE)
|
|
27
|
+
|
|
28
|
+
# body
|
|
29
|
+
rows = sort_rows(@body_rows)
|
|
30
|
+
lines.concat(rows.map { |r| row_to_s(r, column_lengths) })
|
|
31
|
+
|
|
32
|
+
# footer
|
|
33
|
+
lines << separator(column_lengths, MIDDLE)
|
|
34
|
+
lines << row_to_s(@footer_row, column_lengths)
|
|
35
|
+
lines << separator(column_lengths, BOTTOM)
|
|
36
|
+
end.join("\n")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def sort_rows(rows)
|
|
42
|
+
rows.sort_by(&:last).reverse
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def row_to_s(row, column_lengths)
|
|
46
|
+
values = row.zip(column_lengths).map { |text, length| text.rjust(length) }
|
|
47
|
+
"│ #{values[0]} │ #{values.drop(1).join(' ')} │"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def separator(column_lengths, pos)
|
|
51
|
+
(+'').tap do |s|
|
|
52
|
+
s << case pos
|
|
53
|
+
when TOP
|
|
54
|
+
'┌─'
|
|
55
|
+
when MIDDLE
|
|
56
|
+
'├─'
|
|
57
|
+
when BOTTOM
|
|
58
|
+
'└─'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
s << column_lengths.take(1).map { |l| '─' * l }.join('───')
|
|
62
|
+
|
|
63
|
+
s << case pos
|
|
64
|
+
when TOP
|
|
65
|
+
'─┬─'
|
|
66
|
+
when MIDDLE
|
|
67
|
+
'─┼─'
|
|
68
|
+
when BOTTOM
|
|
69
|
+
'─┴─'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
s << column_lengths.drop(1).map { |l| '─' * l }.join('───')
|
|
73
|
+
|
|
74
|
+
s << case pos
|
|
75
|
+
when TOP
|
|
76
|
+
'─┐'
|
|
77
|
+
when MIDDLE
|
|
78
|
+
'─┤'
|
|
79
|
+
when BOTTOM
|
|
80
|
+
'─┘'
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
5
86
|
attr_reader :stages_summary
|
|
6
|
-
attr_reader :phases_summary
|
|
7
87
|
attr_reader :outdatedness_rules_summary
|
|
8
88
|
attr_reader :filters_summary
|
|
9
89
|
|
|
10
90
|
# @see Listener#enable_for?
|
|
11
|
-
def self.enable_for?(_command_runner,
|
|
91
|
+
def self.enable_for?(_command_runner, _config)
|
|
12
92
|
Nanoc::CLI.verbosity >= 1
|
|
13
93
|
end
|
|
14
94
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@reps = reps
|
|
95
|
+
def initialize
|
|
96
|
+
super
|
|
18
97
|
|
|
19
98
|
@stages_summary = DDMetrics::Summary.new
|
|
20
|
-
@phases_summary = DDMetrics::Summary.new
|
|
21
99
|
@outdatedness_rules_summary = DDMetrics::Summary.new
|
|
22
100
|
@filters_summary = DDMetrics::Summary.new
|
|
23
101
|
@load_stores_summary = DDMetrics::Summary.new
|
|
@@ -61,8 +139,6 @@ module Nanoc::CLI::CompileListeners
|
|
|
61
139
|
on(:store_stored) do |duration, klass|
|
|
62
140
|
@store_stores_summary.observe(duration, name: klass.to_s)
|
|
63
141
|
end
|
|
64
|
-
|
|
65
|
-
setup_phase_notifications
|
|
66
142
|
end
|
|
67
143
|
|
|
68
144
|
# @see Listener#stop
|
|
@@ -74,44 +150,11 @@ module Nanoc::CLI::CompileListeners
|
|
|
74
150
|
|
|
75
151
|
protected
|
|
76
152
|
|
|
77
|
-
def setup_phase_notifications
|
|
78
|
-
stopwatches = {}
|
|
79
|
-
|
|
80
|
-
on(:phase_started) do |phase_name, rep|
|
|
81
|
-
stopwatch = stopwatches[[phase_name, rep]] = DDMetrics::Stopwatch.new
|
|
82
|
-
stopwatch.start
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
on(:phase_ended) do |phase_name, rep|
|
|
86
|
-
stopwatch = stopwatches[[phase_name, rep]]
|
|
87
|
-
stopwatch.stop
|
|
88
|
-
|
|
89
|
-
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
on(:phase_yielded) do |phase_name, rep|
|
|
93
|
-
stopwatch = stopwatches[[phase_name, rep]]
|
|
94
|
-
stopwatch.stop
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
on(:phase_resumed) do |phase_name, rep|
|
|
98
|
-
# It probably looks weird that a phase can be resumed even though it was not suspended earlier. This can happen when compilation is suspended, where you’d get the sequence started -> suspended -> started -> resumed.
|
|
99
|
-
stopwatch = stopwatches[[phase_name, rep]]
|
|
100
|
-
stopwatch.start unless stopwatch.running?
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
on(:phase_aborted) do |phase_name, rep|
|
|
104
|
-
stopwatch = stopwatches[[phase_name, rep]]
|
|
105
|
-
stopwatch.stop if stopwatch.running?
|
|
106
|
-
|
|
107
|
-
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
153
|
def table_for_summary(name, summary)
|
|
112
|
-
|
|
154
|
+
header_row = [name.to_s, 'count', 'min', '.50', '.90', '.95', 'max', 'tot']
|
|
113
155
|
|
|
114
|
-
|
|
156
|
+
grand_total = 0.0
|
|
157
|
+
body_rows = summary.map do |label, stats|
|
|
115
158
|
name = label.fetch(:name)
|
|
116
159
|
|
|
117
160
|
count = stats.count
|
|
@@ -122,26 +165,33 @@ module Nanoc::CLI::CompileListeners
|
|
|
122
165
|
tot = stats.sum
|
|
123
166
|
max = stats.max
|
|
124
167
|
|
|
168
|
+
grand_total += tot
|
|
169
|
+
|
|
125
170
|
[name, count.to_s] + [min, p50, p90, p95, max, tot].map { |r| "#{format('%4.2f', r)}s" }
|
|
126
171
|
end
|
|
127
172
|
|
|
128
|
-
[
|
|
173
|
+
footer_row = ['tot', '', '', '', '', '', '', "#{format('%4.2f', grand_total)}s"]
|
|
174
|
+
|
|
175
|
+
Table.new(header_row, body_rows, footer_row)
|
|
129
176
|
end
|
|
130
177
|
|
|
131
178
|
def table_for_summary_durations(name, summary)
|
|
132
|
-
|
|
179
|
+
header_row = [name.to_s, 'tot']
|
|
133
180
|
|
|
134
|
-
|
|
181
|
+
tot = 0.0
|
|
182
|
+
body_rows = summary.map do |label, stats|
|
|
135
183
|
name = label.fetch(:name)
|
|
184
|
+
tot += stats.sum
|
|
136
185
|
[name, "#{format('%4.2f', stats.sum)}s"]
|
|
137
186
|
end
|
|
138
187
|
|
|
139
|
-
[
|
|
188
|
+
footer_row = ['tot', "#{format('%4.2f', tot)}s"]
|
|
189
|
+
|
|
190
|
+
Table.new(header_row, body_rows, footer_row)
|
|
140
191
|
end
|
|
141
192
|
|
|
142
193
|
def print_profiling_feedback
|
|
143
194
|
print_table_for_summary(:filters, @filters_summary)
|
|
144
|
-
print_table_for_summary(:phases, @phases_summary) if Nanoc::CLI.verbosity >= 2
|
|
145
195
|
print_table_for_summary_duration(:stages, @stages_summary) if Nanoc::CLI.verbosity >= 2
|
|
146
196
|
print_table_for_summary(:outdatedness_rules, @outdatedness_rules_summary) if Nanoc::CLI.verbosity >= 2
|
|
147
197
|
print_table_for_summary_duration(:load_stores, @load_stores_summary) if Nanoc::CLI.verbosity >= 2
|
|
@@ -152,18 +202,14 @@ module Nanoc::CLI::CompileListeners
|
|
|
152
202
|
return unless summary.any?
|
|
153
203
|
|
|
154
204
|
puts
|
|
155
|
-
|
|
205
|
+
puts table_for_summary(name, summary)
|
|
156
206
|
end
|
|
157
207
|
|
|
158
208
|
def print_table_for_summary_duration(name, summary)
|
|
159
209
|
return unless summary.any?
|
|
160
210
|
|
|
161
211
|
puts
|
|
162
|
-
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def print_table(rows)
|
|
166
|
-
puts DDMetrics::Table.new(rows)
|
|
212
|
+
puts table_for_summary_durations(name, summary)
|
|
167
213
|
end
|
|
168
214
|
end
|
|
169
215
|
end
|
|
@@ -35,7 +35,7 @@ module Nanoc::CLI
|
|
|
35
35
|
# @return [void]
|
|
36
36
|
def handle_while(exit_on_error:)
|
|
37
37
|
# Set exit handler
|
|
38
|
-
|
|
38
|
+
['INT', 'TERM'].each do |signal|
|
|
39
39
|
Signal.trap(signal) do
|
|
40
40
|
puts
|
|
41
41
|
exit(0)
|
|
@@ -271,7 +271,7 @@ module Nanoc::CLI
|
|
|
271
271
|
stream.puts
|
|
272
272
|
|
|
273
273
|
if verbose
|
|
274
|
-
stream.puts
|
|
274
|
+
stream.puts "===== #{title.upcase}:"
|
|
275
275
|
stream.puts
|
|
276
276
|
end
|
|
277
277
|
end
|
|
@@ -293,7 +293,7 @@ module Nanoc::CLI
|
|
|
293
293
|
def message_for_error(error)
|
|
294
294
|
case error
|
|
295
295
|
when JsonSchema::AggregateError
|
|
296
|
-
"\n
|
|
296
|
+
"\n#{error.errors.map { |e| " * #{e.pointer}: #{e.message}" }.join("\n")}"
|
|
297
297
|
else
|
|
298
298
|
error.message
|
|
299
299
|
end
|
data/lib/nanoc/cli/logger.rb
CHANGED
|
@@ -41,10 +41,13 @@ module Nanoc
|
|
|
41
41
|
# @return [void]
|
|
42
42
|
def file(level, action, name, duration = nil)
|
|
43
43
|
colorizer = Nanoc::CLI::ANSIStringColorizer.new($stdout)
|
|
44
|
-
colored_action = colorizer.c(
|
|
44
|
+
colored_action = colorizer.c(
|
|
45
|
+
format('%9s', action.to_s),
|
|
46
|
+
*ACTION_COLORS[action.to_sym],
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
message = format(
|
|
47
|
-
'%
|
|
50
|
+
' %s %s%s',
|
|
48
51
|
colored_action,
|
|
49
52
|
duration.nil? ? '' : format('[%2.2fs] ', duration),
|
|
50
53
|
name,
|
data/lib/nanoc/cli/version.rb
CHANGED
data/lib/nanoc/cli.rb
CHANGED
|
@@ -63,7 +63,7 @@ module Nanoc
|
|
|
63
63
|
def self.enable_utf8?(io)
|
|
64
64
|
return true unless io.tty?
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
['LC_ALL', 'LC_CTYPE', 'LANG'].any? { |e| ENV.fetch(e, nil) =~ /UTF/i }
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# @return [Boolean] true if color support is present, false if not
|
|
@@ -130,7 +130,7 @@ module Nanoc
|
|
|
130
130
|
@root_command = nil
|
|
131
131
|
|
|
132
132
|
# Add root command
|
|
133
|
-
filename = __dir__
|
|
133
|
+
filename = "#{__dir__}/cli/commands/nanoc.rb"
|
|
134
134
|
@root_command = Cri::Command.load_file(filename, infer_name: true)
|
|
135
135
|
|
|
136
136
|
# Add help command
|
|
@@ -138,7 +138,7 @@ module Nanoc
|
|
|
138
138
|
add_command(help_cmd)
|
|
139
139
|
|
|
140
140
|
# Add other commands
|
|
141
|
-
cmd_filenames = Dir[__dir__
|
|
141
|
+
cmd_filenames = Dir["#{__dir__}/cli/commands/*.rb"]
|
|
142
142
|
cmd_filenames.each do |cmd_filename|
|
|
143
143
|
basename = File.basename(cmd_filename, '.rb')
|
|
144
144
|
|
|
@@ -198,7 +198,7 @@ module Nanoc
|
|
|
198
198
|
def self.recursive_contents_of(path)
|
|
199
199
|
return [] unless File.directory?(path)
|
|
200
200
|
|
|
201
|
-
files, dirs = *Dir[path
|
|
201
|
+
files, dirs = *Dir["#{path}/*"].partition { |e| File.file?(e) }
|
|
202
202
|
dirs.each { |d| files.concat recursive_contents_of(d) }
|
|
203
203
|
files
|
|
204
204
|
end
|
|
@@ -229,8 +229,8 @@ end
|
|
|
229
229
|
|
|
230
230
|
loader = Zeitwerk::Loader.new
|
|
231
231
|
loader.inflector = inflector_class.new
|
|
232
|
-
loader.push_dir(__dir__
|
|
233
|
-
loader.ignore(__dir__
|
|
234
|
-
loader.ignore(__dir__
|
|
232
|
+
loader.push_dir("#{__dir__}/..")
|
|
233
|
+
loader.ignore("#{__dir__}/../nanoc-cli.rb")
|
|
234
|
+
loader.ignore("#{__dir__}/cli/commands")
|
|
235
235
|
loader.setup
|
|
236
236
|
loader.eager_load
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nanoc-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.14.
|
|
4
|
+
version: 4.14.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Defreyne
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - '='
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 4.14.
|
|
60
|
+
version: 4.14.7
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - '='
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 4.14.
|
|
67
|
+
version: 4.14.7
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: pry
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -132,7 +132,7 @@ licenses:
|
|
|
132
132
|
- MIT
|
|
133
133
|
metadata:
|
|
134
134
|
rubygems_mfa_required: 'true'
|
|
135
|
-
source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-cli-v4.14.
|
|
135
|
+
source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-cli-v4.14.7/nanoc-cli
|
|
136
136
|
rdoc_options: []
|
|
137
137
|
require_paths:
|
|
138
138
|
- lib
|