nanoc 4.11.13 → 4.11.18

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +790 -744
  3. data/lib/nanoc.rb +4 -2
  4. data/lib/nanoc/data_sources/filesystem.rb +12 -6
  5. data/lib/nanoc/extra.rb +1 -0
  6. data/lib/nanoc/extra/core_ext.rb +0 -1
  7. data/lib/nanoc/extra/link_collector.rb +1 -1
  8. data/lib/nanoc/extra/srcset_parser.rb +79 -0
  9. data/lib/nanoc/filters/colorize_syntax/colorizers.rb +1 -1
  10. data/lib/nanoc/filters/erb.rb +1 -5
  11. data/lib/nanoc/filters/relativize_paths.rb +62 -10
  12. data/lib/nanoc/filters/sass/functions.rb +1 -1
  13. data/lib/nanoc/helpers/rendering.rb +5 -4
  14. data/lib/nanoc/orig_cli.rb +0 -5
  15. data/lib/nanoc/rule_dsl.rb +1 -0
  16. data/lib/nanoc/rule_dsl/action_provider.rb +1 -1
  17. data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
  18. data/lib/nanoc/rule_dsl/errors.rb +25 -0
  19. data/lib/nanoc/rule_dsl/rules_loader.rb +1 -1
  20. data/lib/nanoc/version.rb +1 -1
  21. metadata +37 -33
  22. data/lib/nanoc/base.rb +0 -13
  23. data/lib/nanoc/base/changes_stream.rb +0 -53
  24. data/lib/nanoc/base/errors.rb +0 -65
  25. data/lib/nanoc/checking.rb +0 -14
  26. data/lib/nanoc/checking/check.rb +0 -93
  27. data/lib/nanoc/checking/checks.rb +0 -14
  28. data/lib/nanoc/checking/checks/css.rb +0 -16
  29. data/lib/nanoc/checking/checks/external_links.rb +0 -151
  30. data/lib/nanoc/checking/checks/html.rb +0 -16
  31. data/lib/nanoc/checking/checks/internal_links.rb +0 -95
  32. data/lib/nanoc/checking/checks/mixed_content.rb +0 -37
  33. data/lib/nanoc/checking/checks/stale.rb +0 -41
  34. data/lib/nanoc/checking/checks/w3c_validator.rb +0 -31
  35. data/lib/nanoc/checking/dsl.rb +0 -27
  36. data/lib/nanoc/checking/issue.rb +0 -16
  37. data/lib/nanoc/checking/loader.rb +0 -50
  38. data/lib/nanoc/checking/runner.rb +0 -136
  39. data/lib/nanoc/deploying.rb +0 -10
  40. data/lib/nanoc/deploying/deployer.rb +0 -45
  41. data/lib/nanoc/deploying/deployers.rb +0 -11
  42. data/lib/nanoc/deploying/deployers/fog.rb +0 -220
  43. data/lib/nanoc/deploying/deployers/git.rb +0 -112
  44. data/lib/nanoc/deploying/deployers/rsync.rb +0 -68
  45. data/lib/nanoc/extra/core_ext/pathname.rb +0 -27
  46. data/lib/nanoc/orig_cli/commands/check.rb +0 -43
  47. data/lib/nanoc/orig_cli/commands/deploy.rb +0 -126
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Deploying::Deployers
4
- # A deployer that deploys a site using [Git](https://git-scm.com).
5
- #
6
- # @example A deployment configuration for GitHub Pages:
7
- #
8
- # deploy:
9
- # default:
10
- # kind: git
11
- # remote: git@github.com:myself/myproject.git
12
- # branch: gh-pages
13
- # forced: true
14
- #
15
- class Git < ::Nanoc::Deploying::Deployer
16
- identifier :git
17
-
18
- module Errors
19
- class Generic < ::Nanoc::Core::Error
20
- end
21
-
22
- class OutputDirDoesNotExist < Generic
23
- def initialize(path)
24
- super("The directory to deploy, #{path}, does not exist.")
25
- end
26
- end
27
-
28
- class OutputDirIsNotAGitRepo < Generic
29
- def initialize(path)
30
- super("The directory to deploy, #{path}, is not a Git repository.")
31
- end
32
- end
33
-
34
- class RemoteDoesNotExist < Generic
35
- def initialize(remote)
36
- super("The remote to deploy to, #{remote}, does not exist.")
37
- end
38
- end
39
-
40
- class BranchDoesNotExist < Generic
41
- def initialize(branch)
42
- super("The branch to deploy, #{branch}, does not exist.")
43
- end
44
- end
45
- end
46
-
47
- def run
48
- unless File.exist?(source_path)
49
- raise Errors::OutputDirDoesNotExist.new(source_path)
50
- end
51
-
52
- remote = config.fetch(:remote, 'origin')
53
- branch = config.fetch(:branch, 'master')
54
- forced = config.fetch(:forced, false)
55
-
56
- puts "Deploying via Git to branch “#{branch}” on remote “#{remote}”…"
57
-
58
- Dir.chdir(source_path) do
59
- unless File.exist?('.git')
60
- raise Errors::OutputDirIsNotAGitRepo.new(source_path)
61
- end
62
-
63
- # Verify existence of remote, if remote is not a URL
64
- if remote_is_name?(remote)
65
- begin
66
- run_cmd(%W[git config --get remote.#{remote}.url])
67
- rescue TTY::Command::ExitError
68
- raise Errors::RemoteDoesNotExist.new(remote)
69
- end
70
- end
71
-
72
- # If the branch exists then switch to it, otherwise prompt the user to create one.
73
- begin
74
- run_cmd_unless_dry(%W[git checkout #{branch}])
75
- rescue TTY::Command::ExitError
76
- raise Errors::BranchDoesNotExist.new(branch)
77
- end
78
-
79
- return if clean_repo?
80
-
81
- msg = "Automated commit at #{Time.now.utc} by Nanoc #{Nanoc::VERSION}"
82
- author = 'Nanoc <>'
83
- run_cmd_unless_dry(%w[git add -A])
84
- run_cmd_unless_dry(%W[git commit -a --author #{author} -m #{msg}])
85
-
86
- if forced
87
- run_cmd_unless_dry(%W[git push -f #{remote} #{branch}])
88
- else
89
- run_cmd_unless_dry(%W[git push #{remote} #{branch}])
90
- end
91
- end
92
- end
93
-
94
- private
95
-
96
- def remote_is_name?(remote)
97
- remote !~ /:\/\/|@.+:/
98
- end
99
-
100
- def run_cmd(cmd, dry_run: false)
101
- TTY::Command.new(printer: :null).run(*cmd, dry_run: dry_run)
102
- end
103
-
104
- def run_cmd_unless_dry(cmd)
105
- run_cmd(cmd, dry_run: dry_run)
106
- end
107
-
108
- def clean_repo?
109
- TTY::Command.new(printer: :null).run('git status --porcelain').out.empty?
110
- end
111
- end
112
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Deploying::Deployers
4
- # A deployer that deploys a site using rsync.
5
- #
6
- # The configuration has should include a `:dst` value, a string containing
7
- # the destination to where rsync should upload its data. It will likely be
8
- # in `host:path` format. It should not end with a slash. For example,
9
- # `"example.com:/var/www/sites/mysite/html"`.
10
- #
11
- # @example A deployment configuration with public and staging configurations
12
- #
13
- # deploy:
14
- # public:
15
- # kind: rsync
16
- # dst: "ectype:sites/stoneship/public"
17
- # staging:
18
- # kind: rsync
19
- # dst: "ectype:sites/stoneship-staging/public"
20
- # options: [ "-glpPrtvz" ]
21
- #
22
- # @api private
23
- class Rsync < ::Nanoc::Deploying::Deployer
24
- identifier :rsync
25
-
26
- # Default rsync options
27
- DEFAULT_OPTIONS = [
28
- '--group',
29
- '--links',
30
- '--perms',
31
- '--partial',
32
- '--progress',
33
- '--recursive',
34
- '--times',
35
- '--verbose',
36
- '--compress',
37
- '--exclude=".hg"',
38
- '--exclude=".svn"',
39
- '--exclude=".git"',
40
- ].freeze
41
-
42
- # @see Nanoc::Deploying::Deployer#run
43
- def run
44
- # Get params
45
- src = source_path + '/'
46
- dst = config[:dst]
47
- options = config[:options] || DEFAULT_OPTIONS
48
-
49
- # Validate
50
- raise 'No dst found in deployment configuration' if dst.nil?
51
- raise 'dst requires no trailing slash' if dst[-1, 1] == '/'
52
-
53
- # Run
54
- if dry_run
55
- warn 'Performing a dry-run; no actions will actually be performed'
56
- run_shell_cmd(['echo', 'rsync', options, src, dst].flatten)
57
- else
58
- run_shell_cmd(['rsync', options, src, dst].flatten)
59
- end
60
- end
61
-
62
- private
63
-
64
- def run_shell_cmd(cmd)
65
- TTY::Command.new(printer: :null).run(*cmd)
66
- end
67
- end
68
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc::Extra
4
- # @api private
5
- module PathnameExtensions
6
- def __nanoc_components
7
- components = []
8
- tmp = self
9
- loop do
10
- old = tmp
11
- components << File.basename(tmp)
12
- tmp = File.dirname(tmp)
13
- break if old == tmp
14
- end
15
- components.reverse
16
- end
17
-
18
- def __nanoc_include_component?(component)
19
- __nanoc_components.include?(component)
20
- end
21
- end
22
- end
23
-
24
- # @api private
25
- class ::Pathname
26
- include ::Nanoc::Extra::PathnameExtensions
27
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- usage 'check [options] [names]'
4
- summary 'run issue checks'
5
- description "
6
- Run issue checks on the current site. If the `--all` option is passed, all available issue checks will be run. By default, the issue checks marked for deployment will be run.
7
- "
8
-
9
- flag :a, :all, 'run all checks'
10
- flag :L, :list, 'list all checks'
11
- flag :d, :deploy, '(deprecated)'
12
-
13
- module Nanoc::OrigCLI::Commands
14
- class Check < ::Nanoc::CLI::CommandRunner
15
- def run
16
- site = load_site
17
-
18
- runner = Nanoc::Checking::Runner.new(site)
19
-
20
- if options[:list]
21
- runner.list_checks
22
- return
23
- end
24
-
25
- success =
26
- if options[:all]
27
- runner.run_all
28
- elsif options[:deploy]
29
- runner.run_for_deploy
30
- elsif arguments.any?
31
- runner.run_specific(arguments)
32
- else
33
- runner.run_for_deploy
34
- end
35
-
36
- unless success
37
- raise Nanoc::Core::TrivialError, 'One or more checks failed'
38
- end
39
- end
40
- end
41
- end
42
-
43
- runner Nanoc::OrigCLI::Commands::Check
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- usage 'deploy [target] [options]'
4
- summary 'deploy the compiled site'
5
- description "
6
- Deploys the compiled site. The compiled site contents in the output directory will be uploaded to the destination, which is specified using the `--target` option.
7
- "
8
-
9
- option :t, :target, 'specify the location to deploy to (default: `default`)', argument: :required
10
- flag :C, :'no-check', 'do not run the issue checks marked for deployment'
11
- flag :L, :list, 'list available locations to deploy to'
12
- flag :D, :'list-deployers', 'list available deployers'
13
- option :n, :'dry-run', 'show what would be deployed'
14
-
15
- module Nanoc::OrigCLI::Commands
16
- class Deploy < ::Nanoc::CLI::CommandRunner
17
- def run
18
- @site = load_site
19
- Nanoc::Core::Compiler.new_for(@site).run_until_preprocessed
20
-
21
- if options[:'list-deployers']
22
- list_deployers
23
- elsif options[:list]
24
- list_deploy_configs
25
- else
26
- deploy
27
- end
28
- end
29
-
30
- private
31
-
32
- def list_deployers
33
- deployers = Nanoc::Deploying::Deployer.all
34
- deployer_names = deployers.map(&:identifier).sort
35
- puts 'Available deployers:'
36
- deployer_names.each do |name|
37
- puts " #{name}"
38
- end
39
- end
40
-
41
- def list_deploy_configs
42
- if deploy_configs.empty?
43
- puts 'No deployment configurations.'
44
- else
45
- puts 'Available deployment configurations:'
46
- deploy_configs.each_key do |name|
47
- puts " #{name}"
48
- end
49
- end
50
- end
51
-
52
- def deploy
53
- deployer = deployer_for(deploy_config)
54
-
55
- checks_successful = options[:'no-check'] ? true : check
56
- return unless checks_successful
57
-
58
- deployer.run
59
- end
60
-
61
- def deploy_config
62
- if deploy_configs.empty?
63
- raise Nanoc::Core::TrivialError, 'The site has no deployment configurations.'
64
- end
65
-
66
- if arguments.length > 1
67
- raise Nanoc::Core::TrivialError, "usage: #{command.usage}"
68
- end
69
-
70
- target_from_arguments = arguments[0]
71
- target_from_options = options.fetch(:target, nil)
72
- if target_from_arguments && target_from_options
73
- raise Nanoc::Core::TrivialError, 'Only one deployment target can be specified on the command line.'
74
- end
75
-
76
- target = target_from_arguments || target_from_options || :default
77
- deploy_configs.fetch(target.to_sym) do
78
- raise Nanoc::Core::TrivialError, "The site has no deployment configuration named `#{target}`."
79
- end
80
- end
81
-
82
- def deployer_for(config)
83
- deployer_class_for_config(config).new(
84
- @site.config.output_dir,
85
- config,
86
- dry_run: options[:'dry-run'],
87
- )
88
- end
89
-
90
- def check
91
- runner = Nanoc::Checking::Runner.new(@site)
92
- if runner.any_enabled_checks?
93
- puts 'Running issue checks…'
94
- is_success = runner.run_for_deploy
95
- if is_success
96
- puts 'No issues found. Deploying!'
97
- else
98
- puts 'Issues found, deploy aborted.'
99
- end
100
- is_success
101
- else
102
- true
103
- end
104
- end
105
-
106
- def deploy_configs
107
- @site.config.fetch(:deploy, {})
108
- end
109
-
110
- def deployer_class_for_config(config)
111
- name = config.fetch(:kind) do
112
- $stderr.puts 'Warning: The specified deploy target does not have a kind attribute. Assuming rsync.'
113
- 'rsync'
114
- end
115
-
116
- deployer_class = Nanoc::Deploying::Deployer.named(name.to_sym)
117
- if deployer_class.nil?
118
- names = Nanoc::Deploying::Deployer.all.map(&:identifier)
119
- raise Nanoc::Core::TrivialError, "The specified deploy target has an unrecognised kind “#{name}” (expected one of #{names.join(', ')})."
120
- end
121
- deployer_class
122
- end
123
- end
124
- end
125
-
126
- runner Nanoc::OrigCLI::Commands::Deploy