bridgetown-core 0.13.0 → 0.15.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/bin/bridgetown +9 -48
  4. data/bridgetown-core.gemspec +6 -2
  5. data/lib/bridgetown-core.rb +13 -3
  6. data/lib/bridgetown-core/cleaner.rb +1 -0
  7. data/lib/bridgetown-core/commands/apply.rb +73 -0
  8. data/lib/bridgetown-core/commands/base.rb +45 -0
  9. data/lib/bridgetown-core/commands/build.rb +91 -86
  10. data/lib/bridgetown-core/commands/clean.rb +30 -29
  11. data/lib/bridgetown-core/commands/concerns/actions.rb +123 -0
  12. data/lib/bridgetown-core/commands/concerns/build_options.rb +76 -0
  13. data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +18 -0
  14. data/lib/bridgetown-core/commands/concerns/summarizable.rb +13 -0
  15. data/lib/bridgetown-core/commands/console.rb +46 -39
  16. data/lib/bridgetown-core/commands/doctor.rb +126 -127
  17. data/lib/bridgetown-core/commands/new.rb +120 -158
  18. data/lib/bridgetown-core/commands/plugins.rb +206 -0
  19. data/lib/bridgetown-core/commands/registrations.rb +16 -0
  20. data/lib/bridgetown-core/commands/serve.rb +214 -215
  21. data/lib/bridgetown-core/{convertible.rb → concerns/convertible.rb} +3 -6
  22. data/lib/bridgetown-core/concerns/site/configurable.rb +153 -0
  23. data/lib/bridgetown-core/concerns/site/content.rb +111 -0
  24. data/lib/bridgetown-core/concerns/site/extensible.rb +56 -0
  25. data/lib/bridgetown-core/concerns/site/processable.rb +74 -0
  26. data/lib/bridgetown-core/concerns/site/renderable.rb +49 -0
  27. data/lib/bridgetown-core/concerns/site/writable.rb +31 -0
  28. data/lib/bridgetown-core/configuration.rb +2 -9
  29. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +0 -3
  30. data/lib/bridgetown-core/document.rb +1 -1
  31. data/lib/bridgetown-core/drops/page_drop.rb +1 -1
  32. data/lib/bridgetown-core/drops/site_drop.rb +1 -1
  33. data/lib/bridgetown-core/excerpt.rb +4 -1
  34. data/lib/bridgetown-core/external.rb +17 -21
  35. data/lib/bridgetown-core/filters.rb +10 -0
  36. data/lib/bridgetown-core/generators/prototype_generator.rb +3 -1
  37. data/lib/bridgetown-core/hooks.rb +62 -62
  38. data/lib/bridgetown-core/layout.rb +10 -4
  39. data/lib/bridgetown-core/liquid_renderer.rb +1 -0
  40. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
  41. data/lib/bridgetown-core/liquid_renderer/file_system.rb +3 -1
  42. data/lib/bridgetown-core/page.rb +11 -19
  43. data/lib/bridgetown-core/plugin.rb +2 -0
  44. data/lib/bridgetown-core/plugin_manager.rb +88 -21
  45. data/lib/bridgetown-core/reader.rb +5 -0
  46. data/lib/bridgetown-core/readers/data_reader.rb +5 -2
  47. data/lib/bridgetown-core/readers/layout_reader.rb +9 -2
  48. data/lib/bridgetown-core/readers/plugin_content_reader.rb +48 -0
  49. data/lib/bridgetown-core/renderer.rb +38 -28
  50. data/lib/bridgetown-core/site.rb +20 -463
  51. data/lib/bridgetown-core/tags/include.rb +12 -0
  52. data/lib/bridgetown-core/tags/render_content.rb +29 -16
  53. data/lib/bridgetown-core/tags/with.rb +15 -0
  54. data/lib/bridgetown-core/utils.rb +45 -27
  55. data/lib/bridgetown-core/utils/ruby_exec.rb +1 -4
  56. data/lib/bridgetown-core/version.rb +2 -2
  57. data/lib/bridgetown-core/watcher.rb +21 -10
  58. data/lib/site_template/Gemfile.erb +19 -0
  59. data/lib/site_template/package.json +1 -0
  60. data/lib/site_template/plugins/{.keep → builders/.keep} +0 -0
  61. data/lib/site_template/plugins/site_builder.rb +4 -0
  62. data/lib/site_template/src/_components/footer.html +3 -0
  63. data/lib/site_template/src/_components/head.html +9 -0
  64. data/lib/site_template/src/{_includes → _components}/navbar.html +1 -0
  65. data/lib/site_template/src/_layouts/default.html +3 -3
  66. data/lib/site_template/src/posts.md +15 -0
  67. data/lib/site_template/start.js +1 -1
  68. data/lib/site_template/webpack.config.js +3 -3
  69. metadata +90 -18
  70. data/lib/bridgetown-core/command.rb +0 -106
  71. data/lib/bridgetown-core/commands/help.rb +0 -34
  72. data/lib/site_template/src/_components/.keep +0 -0
  73. data/lib/site_template/src/_includes/footer.html +0 -3
  74. data/lib/site_template/src/_includes/head.html +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5434399f502bf037e77a019dfda4b2deae10b6a532349ec21b32977a224ca448
4
- data.tar.gz: cae6a4eb2d435bfd0e85f18320e76a90619c872ccf69f44c9ac2e13e987e1fe7
3
+ metadata.gz: 0731d836363a7cc613e8a42a833fb1d45e50f293558cd78238d9b214b73e2d99
4
+ data.tar.gz: 2597ac785d145bcd26083d08e803d4f0937165d8150bfb05eea5b9ba90ad6e4f
5
5
  SHA512:
6
- metadata.gz: 5344308e24f519099a33af769a1c5dd908d1fd54f10aaec4c81f4254c9ff772787f1a2e4b9f0d488a21167cc98c6a1c526df1fd2e7d6ee4e86cf33afc4efe2bd
7
- data.tar.gz: f2eedc957c8782b03e08f0834b88981e40f6539ac65899096bcfc1c1e4ed196b4046859530d5e281dee2b1455ac4e01e7b8a63dfdf29e3ad36e8725d1ed00f64
6
+ metadata.gz: 7bead893392ffe25b85bcef0419201fa5a8752793f9b8812ac26e512ab35e2638d888ec02c64c672e7930c509afbe0fffa2c98b40316351028951469e63c9310
7
+ data.tar.gz: e8083bd29fb64deef6f0fe17b028cb1aa373944cfcb15fe0ce686b03f6db6e12bcdbcb25842e4a508b2979facb9655cfe358fac685f7c2af4c44e2a6edb65c1c
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  $LOAD_PATH.unshift File.expand_path("lib", __dir__)
4
6
  require "bridgetown-core/version"
5
7
 
6
- task :spec => :test
8
+ task spec: :test
7
9
  require "rake/testtask"
8
10
  Rake::TestTask.new(:test) do |test|
9
11
  test.libs << "lib" << "test"
@@ -6,56 +6,17 @@ STDOUT.sync = true
6
6
  $LOAD_PATH.unshift File.expand_path("../../bridgetown/lib", __dir__)
7
7
 
8
8
  require "bridgetown"
9
- require "mercenary"
10
9
 
11
10
  Bridgetown::PluginManager.require_from_bundler
12
11
 
13
- Bridgetown::Deprecator.process(ARGV)
12
+ # Support NO_COLOR: https://no-color.org
13
+ # TODO: need to change behavior of Colorator gem
14
+ ENV["THOR_SHELL"] = "Basic" if ENV["NO_COLOR"]
14
15
 
15
- Mercenary.program(:bridgetown) do |p|
16
- p.version "#{Bridgetown::VERSION.magenta} \"#{Bridgetown::CODE_NAME.yellow}\""
17
- p.description "Bridgetown is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
18
- p.syntax "bridgetown <subcommand> [options]"
16
+ output_version = if ARGV[0] == "-v"
17
+ puts "bridgetown #{Bridgetown::VERSION} \"#{Bridgetown::CODE_NAME}\""
18
+ true
19
+ end
19
20
 
20
- # TODO: it seems wonky to include build options in this top-level
21
- # exe. Should probably remove most things here and relocated to
22
- # individual comments. …in fact there are duplicate option listings
23
- # if you do bridgetown build --help — ouch!
24
- p.option "source", "-s", "--source [DIR]", "Source directory (defaults to src)"
25
- p.option "destination", "-d", "--destination [DIR]",
26
- "Destination directory (defaults to output)"
27
- p.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array,
28
- "Plugins directory (defaults to plugins)"
29
- p.option "layouts_dir", "--layouts DIR", String,
30
- "Layouts directory (defaults to src/_layouts)"
31
- p.option "profile", "--profile", "Generate a Liquid rendering profile"
32
-
33
- # TODO: this is not the way to bring in extra command gems!
34
- # Bridgetown::External.require_if_present(Bridgetown::External.blessed_gems) do |g, ver_constraint|
35
- # cmd = g.split("-").last
36
- # p.command(cmd.to_sym) do |c|
37
- # c.syntax cmd
38
- # c.action do
39
- # Bridgetown.logger.abort_with "You must install the '#{g}' gem" \
40
- # " version #{ver_constraint} to use the 'bridgetown #{cmd}' command."
41
- # end
42
- # end
43
- # end
44
-
45
- Bridgetown::Command.subclasses.each { |c| c.init_with_program(p) }
46
-
47
- p.action do |args, _|
48
- if args.empty?
49
- Bridgetown.logger.error "A subcommand is required."
50
- puts p
51
- abort
52
- else
53
- subcommand = args.first
54
- unless p.has_command? subcommand
55
- Bridgetown.logger.abort_with "fatal: 'bridgetown #{args.first}' could not" \
56
- " be found. You may need to install the bridgetown-#{args.first} gem" \
57
- " or a related gem to be able to use this subcommand."
58
- end
59
- end
60
- end
61
- end
21
+ require "bridgetown-core/commands/base"
22
+ Bridgetown::Commands::Base.start unless output_version
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.license = "MIT"
9
9
  s.author = "Bridgetown Team"
10
10
  s.email = "maintainers@bridgetownrb.com"
11
- s.homepage = "https://bridgetownrb.com"
11
+ s.homepage = "https://www.bridgetownrb.com"
12
12
  s.summary = "A Webpack-aware, Ruby-based static site generator for the modern Jamstack era"
13
13
  s.description = "Bridgetown is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
14
14
 
@@ -31,17 +31,21 @@ Gem::Specification.new do |s|
31
31
  s.required_ruby_version = ">= 2.5.0"
32
32
  s.required_rubygems_version = ">= 2.7.0"
33
33
 
34
+ s.add_runtime_dependency("activesupport", "~> 6.0")
34
35
  s.add_runtime_dependency("addressable", "~> 2.4")
35
36
  s.add_runtime_dependency("colorator", "~> 1.0")
36
37
  s.add_runtime_dependency("faraday", "~> 1.0")
38
+ s.add_runtime_dependency("faraday_middleware", "~> 1.0")
37
39
  s.add_runtime_dependency("i18n", "~> 1.0")
38
40
  s.add_runtime_dependency("kramdown", "~> 2.1")
39
41
  s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
40
42
  s.add_runtime_dependency("liquid", "~> 4.0")
43
+ s.add_runtime_dependency("liquid-component", ">= 0.1")
44
+ s.add_runtime_dependency("liquid-render-tag", "~> 0.2")
41
45
  s.add_runtime_dependency("listen", "~> 3.0")
42
- s.add_runtime_dependency("mercenary", "~> 0.4.0")
43
46
  s.add_runtime_dependency("pathutil", "~> 0.9")
44
47
  s.add_runtime_dependency("rouge", "~> 3.0")
45
48
  s.add_runtime_dependency("safe_yaml", "~> 1.0")
46
49
  s.add_runtime_dependency("terminal-table", "~> 1.8")
50
+ s.add_runtime_dependency("thor", "~> 1.0")
47
51
  end
@@ -29,14 +29,19 @@ require "csv"
29
29
  require "json"
30
30
 
31
31
  # 3rd party
32
+ require "active_support/core_ext/hash/indifferent_access"
33
+ require "active_support/core_ext/string/inflections"
32
34
  require "pathutil"
33
35
  require "addressable/uri"
34
36
  require "safe_yaml/load"
35
37
  require "liquid"
38
+ require "liquid-render-tag"
39
+ require "liquid-component"
36
40
  require "kramdown"
37
41
  require "colorator"
38
42
  require "i18n"
39
43
  require "faraday"
44
+ require "thor"
40
45
 
41
46
  SafeYAML::OPTIONS[:suppress_warnings] = true
42
47
 
@@ -49,7 +54,7 @@ module Bridgetown
49
54
  autoload :Cleaner, "bridgetown-core/cleaner"
50
55
  autoload :Collection, "bridgetown-core/collection"
51
56
  autoload :Configuration, "bridgetown-core/configuration"
52
- autoload :Convertible, "bridgetown-core/convertible"
57
+ autoload :Convertible, "bridgetown-core/concerns/convertible"
53
58
  autoload :Deprecator, "bridgetown-core/deprecator"
54
59
  autoload :Document, "bridgetown-core/document"
55
60
  autoload :EntryFilter, "bridgetown-core/entry_filter"
@@ -65,6 +70,7 @@ module Bridgetown
65
70
  autoload :LayoutReader, "bridgetown-core/readers/layout_reader"
66
71
  autoload :PostReader, "bridgetown-core/readers/post_reader"
67
72
  autoload :PageReader, "bridgetown-core/readers/page_reader"
73
+ autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
68
74
  autoload :StaticFileReader, "bridgetown-core/readers/static_file_reader"
69
75
  autoload :LogAdapter, "bridgetown-core/log_adapter"
70
76
  autoload :Page, "bridgetown-core/page"
@@ -86,16 +92,15 @@ module Bridgetown
86
92
  autoload :Watcher, "bridgetown-core/watcher"
87
93
 
88
94
  # extensions
95
+ require "bridgetown-core/commands/registrations"
89
96
  require "bridgetown-core/plugin"
90
97
  require "bridgetown-core/converter"
91
98
  require "bridgetown-core/generator"
92
- require "bridgetown-core/command"
93
99
  require "bridgetown-core/liquid_extensions"
94
100
  require "bridgetown-core/filters"
95
101
 
96
102
  require "bridgetown-core/drops/drop"
97
103
  require "bridgetown-core/drops/document_drop"
98
- require_all "bridgetown-core/commands"
99
104
  require_all "bridgetown-core/converters"
100
105
  require_all "bridgetown-core/converters/markdown"
101
106
  require_all "bridgetown-core/drops"
@@ -134,6 +139,11 @@ module Bridgetown
134
139
  end
135
140
  end
136
141
 
142
+ # Conveinence method to register a new Thor command
143
+ def register_command(&block)
144
+ Bridgetown::Commands::Registrations.register(&block)
145
+ end
146
+
137
147
  # Public: Set the TZ environment variable to use the timezone specified
138
148
  #
139
149
  # timezone - the IANA Time Zone
@@ -24,6 +24,7 @@ module Bridgetown
24
24
  def obsolete_files
25
25
  out = (existing_files - new_files - new_dirs + replaced_files).to_a
26
26
  Bridgetown::Hooks.trigger :clean, :on_obsolete, out
27
+ @new_files = @new_dirs = nil
27
28
  out
28
29
  end
29
30
 
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Commands
5
+ class Apply < Thor::Group
6
+ include Thor::Actions
7
+ include Actions
8
+ extend Summarizable
9
+
10
+ Registrations.register do
11
+ register(Apply, "apply", "apply", Apply.summary)
12
+ end
13
+
14
+ def self.banner
15
+ "bridgetown apply PATH or URL"
16
+ end
17
+ summary "Applies an automation to the current site"
18
+
19
+ def self.source_root
20
+ Dir.pwd
21
+ end
22
+
23
+ def self.exit_on_failure?
24
+ true
25
+ end
26
+
27
+ def apply_automation
28
+ @source_paths = [Dir.pwd]
29
+
30
+ if options[:apply]
31
+ apply_after_new_command
32
+ else
33
+ apply_in_pwd
34
+ end
35
+ rescue SystemExit => e
36
+ Bridgetown.logger.error "Problem occurred while running automation:"
37
+ e.backtrace[0..3].each do |backtrace_line|
38
+ Bridgetown.logger.info backtrace_line if backtrace_line.include?(":in `apply'")
39
+ end
40
+ raise e
41
+ end
42
+
43
+ protected
44
+
45
+ def apply_after_new_command
46
+ # Coming from the new command, so set up proper bundler env
47
+ Bundler.with_clean_env do
48
+ self.destination_root = New.created_site_dir
49
+ inside(New.created_site_dir) do
50
+ apply_from_url options[:apply]
51
+ end
52
+ end
53
+ end
54
+
55
+ def apply_in_pwd
56
+ # Running standalone
57
+ automation_command = args.empty? ? "bridgetown.automation.rb" : args[0]
58
+
59
+ if args.empty? && !File.exist?("bridgetown.automation.rb")
60
+ raise ArgumentError, "You must specify a path or a URL," \
61
+ " or add bridgetown.automation.rb to the" \
62
+ " current folder."
63
+ end
64
+
65
+ Bundler.with_clean_env do
66
+ apply_from_url automation_command
67
+ end
68
+ rescue ArgumentError => e
69
+ Bridgetown.logger.warn "Oops!", e.message
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_all "bridgetown-core/commands/concerns"
4
+ require_all "bridgetown-core/commands"
5
+
6
+ module Bridgetown
7
+ module Commands
8
+ class Base < Thor
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
13
+ Registrations.registrations.each do |block|
14
+ instance_exec(&block)
15
+ end
16
+
17
+ class << self
18
+ # Override single character commands if necessary
19
+ def find_command_possibilities(subcommand)
20
+ if subcommand == "c"
21
+ ["console"]
22
+ else
23
+ super
24
+ end
25
+ end
26
+ end
27
+
28
+ desc "help <command>", "Show detailed command usage information and exit"
29
+ def help(subcommand = nil)
30
+ if subcommand && respond_to?(subcommand)
31
+ klass = Kernel.const_get("Bridgetown::Commands::#{subcommand.capitalize}")
32
+ klass.start(["-h"])
33
+ else
34
+ puts "Bridgetown v#{Bridgetown::VERSION.magenta} \"#{Bridgetown::CODE_NAME.yellow}\"" \
35
+ " is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
36
+ puts ""
37
+ puts "Usage:"
38
+ puts " bridgetown <command> [options]"
39
+ puts ""
40
+ super
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -2,106 +2,111 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Commands
5
- class Build < Command
6
- class << self
7
- # Create the Mercenary command for the Bridgetown CLI for this Command
8
- def init_with_program(prog)
9
- prog.command(:build) do |c|
10
- c.syntax "build [options]"
11
- c.description "Build your site"
12
- c.alias :b
5
+ class Build < Thor::Group
6
+ extend BuildOptions
7
+ extend Summarizable
8
+ include ConfigurationOverridable
13
9
 
14
- add_build_options(c)
10
+ Registrations.register do
11
+ register(Build, "build", "build", Build.summary)
12
+ end
15
13
 
16
- c.action do |_, options|
17
- options["serving"] = false
18
- process_with_graceful_fail(c, options, self)
19
- end
20
- end
21
- end
14
+ def self.banner
15
+ "bridgetown build [options]"
16
+ end
17
+ summary "Build your site and save to destination folder"
22
18
 
23
- # Build your bridgetown site
24
- # Continuously watch if `watch` is set to true in the config.
25
- def process(options)
26
- # Adjust verbosity quickly
27
- Bridgetown.logger.adjust_verbosity(options)
19
+ class_option :watch,
20
+ type: :boolean,
21
+ aliases: "-w",
22
+ desc: "Watch for changes and rebuild"
28
23
 
29
- Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
30
- " (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
24
+ # Build your bridgetown site
25
+ # Continuously watch if `watch` is set to true in the config.
26
+ def build
27
+ Bridgetown.logger.adjust_verbosity(options)
31
28
 
32
- options = configuration_from_options(options)
33
- @site = Bridgetown::Site.new(options)
29
+ Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
30
+ " (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
34
31
 
35
- if options.fetch("skip_initial_build", false)
36
- Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
37
- " This may result in an out-of-date site."
38
- else
39
- build(options)
40
- end
32
+ config_options = Serve.loaded_config || configuration_with_overrides(options)
33
+ config_options["serving"] = false unless config_options["serving"]
34
+ @site = Bridgetown::Site.new(config_options)
41
35
 
42
- if options.fetch("detach", false)
43
- Bridgetown.logger.info "Auto-regeneration:",
44
- "disabled when running server detached."
45
- elsif options.fetch("watch", false)
46
- watch(options)
47
- else
48
- Bridgetown.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
49
- end
36
+ if config_options.fetch("skip_initial_build", false)
37
+ Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
38
+ " This may result in an out-of-date site."
39
+ else
40
+ build_site(config_options)
50
41
  end
51
42
 
52
- # Build your Bridgetown site.
53
- #
54
- # options - A Hash of options passed to the command or loaded from config
55
- #
56
- # Returns nothing.
57
- def build(options)
58
- t = Time.now
59
- display_folder_paths(options)
60
- if options["unpublished"]
61
- Bridgetown.logger.info "Unpublished mode:",
62
- "enabled. Processing documents marked unpublished"
63
- end
64
- incremental = options["incremental"]
65
- Bridgetown.logger.info "Incremental build:",
66
- (incremental ? "enabled" : "disabled. Enable with --incremental")
67
- Bridgetown.logger.info "Generating…"
68
- process_site(@site)
69
- Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
70
- " #{(Time.now - t).ceil(2)} seconds."
43
+ if config_options.fetch("detach", false)
44
+ Bridgetown.logger.info "Auto-regeneration:",
45
+ "disabled when running server detached."
46
+ elsif config_options.fetch("watch", false)
47
+ watch_site(config_options)
48
+ else
49
+ Bridgetown.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
71
50
  end
51
+ end
72
52
 
73
- # Private: Watch for file changes and rebuild the site.
74
- #
75
- # options - A Hash of options passed to the command or loaded from config
76
- #
77
- # Returns nothing.
78
- def watch(options)
79
- # Warn Windows users that they might need to upgrade.
80
- if Utils::Platforms.bash_on_windows?
81
- Bridgetown.logger.warn "",
82
- "Auto-regeneration may not work on some Windows versions."
83
- Bridgetown.logger.warn "",
84
- "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
85
- Bridgetown.logger.warn "",
86
- "If it does not work, please upgrade Bash on Windows or "\
87
- "run Bridgetown with --no-watch."
88
- end
53
+ protected
89
54
 
90
- Bridgetown::Watcher.watch(@site, options)
55
+ # Build your Bridgetown site.
56
+ #
57
+ # options - A Hash of options passed to the command or loaded from config
58
+ #
59
+ # Returns nothing.
60
+ def build_site(config_options)
61
+ t = Time.now
62
+ display_folder_paths(config_options)
63
+ if config_options["unpublished"]
64
+ Bridgetown.logger.info "Unpublished mode:",
65
+ "enabled. Processing documents marked unpublished"
91
66
  end
67
+ incremental = config_options["incremental"]
68
+ Bridgetown.logger.info "Incremental build:",
69
+ (incremental ? "enabled" : "disabled. Enable with --incremental")
70
+ Bridgetown.logger.info "Generating…"
71
+ @site.process
72
+ Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
73
+ " #{(Time.now - t).ceil(2)} seconds."
74
+ end
75
+
76
+ # Watch for file changes and rebuild the site.
77
+ #
78
+ # options - A Hash of options passed to the command or loaded from config
79
+ #
80
+ # Returns nothing.
81
+ def watch_site(config_options)
82
+ # Warn Windows users that they might need to upgrade.
83
+ if Utils::Platforms.bash_on_windows?
84
+ Bridgetown.logger.warn "",
85
+ "Auto-regeneration may not work on some Windows versions."
86
+ Bridgetown.logger.warn "",
87
+ "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
88
+ Bridgetown.logger.warn "",
89
+ "If it does not work, please upgrade Bash on Windows or "\
90
+ "run Bridgetown with --no-watch."
91
+ end
92
+
93
+ Bridgetown::Watcher.watch(@site, config_options)
94
+ end
92
95
 
93
- # Private: display the source and destination folder paths
94
- #
95
- # options - A Hash of options passed to the command
96
- #
97
- # Returns nothing.
98
- def display_folder_paths(options)
99
- source = File.expand_path(options["source"])
100
- destination = File.expand_path(options["destination"])
101
- plugins_dir = File.expand_path(options["plugins_dir"])
102
- Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
103
- Bridgetown.logger.info "Source:", source
104
- Bridgetown.logger.info "Destination:", destination
96
+ # Display the source and destination folder paths
97
+ #
98
+ # options - A Hash of options passed to the command
99
+ #
100
+ # Returns nothing.
101
+ def display_folder_paths(config_options)
102
+ source = File.expand_path(config_options["source"])
103
+ destination = File.expand_path(config_options["destination"])
104
+ Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
105
+ Bridgetown.logger.info "Source:", source
106
+ Bridgetown.logger.info "Destination:", destination
107
+ # TODO: work with arrays
108
+ if config_options["plugins_dir"].is_a?(String)
109
+ plugins_dir = File.expand_path(config_options["plugins_dir"])
105
110
  Bridgetown.logger.info "Custom Plugins:", plugins_dir if Dir.exist?(plugins_dir)
106
111
  end
107
112
  end