bridgetown-core 0.14.0 → 0.15.0.beta4
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/Rakefile +3 -1
- data/bin/bridgetown +9 -23
- data/bridgetown-core.gemspec +3 -1
- data/lib/bridgetown-core.rb +9 -2
- data/lib/bridgetown-core/commands/apply.rb +73 -0
- data/lib/bridgetown-core/commands/base.rb +45 -0
- data/lib/bridgetown-core/commands/build.rb +91 -86
- data/lib/bridgetown-core/commands/clean.rb +30 -29
- data/lib/bridgetown-core/commands/concerns/actions.rb +128 -0
- data/lib/bridgetown-core/commands/concerns/build_options.rb +76 -0
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +18 -0
- data/lib/bridgetown-core/commands/concerns/summarizable.rb +13 -0
- data/lib/bridgetown-core/commands/console.rb +57 -39
- data/lib/bridgetown-core/commands/doctor.rb +126 -126
- data/lib/bridgetown-core/commands/new.rb +120 -155
- data/lib/bridgetown-core/commands/plugins.rb +167 -130
- data/lib/bridgetown-core/commands/registrations.rb +16 -0
- data/lib/bridgetown-core/commands/serve.rb +219 -215
- data/lib/bridgetown-core/concerns/convertible.rb +1 -4
- data/lib/bridgetown-core/concerns/site/renderable.rb +1 -2
- data/lib/bridgetown-core/drops/document_drop.rb +9 -1
- data/lib/bridgetown-core/drops/page_drop.rb +1 -1
- data/lib/bridgetown-core/excerpt.rb +4 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +2 -0
- data/lib/bridgetown-core/liquid_renderer.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
- data/lib/bridgetown-core/liquid_renderer/file_system.rb +3 -1
- data/lib/bridgetown-core/page.rb +3 -18
- data/lib/bridgetown-core/plugin_manager.rb +31 -13
- data/lib/bridgetown-core/renderer.rb +31 -18
- data/lib/bridgetown-core/tags/include.rb +14 -0
- data/lib/bridgetown-core/tags/render_content.rb +39 -16
- data/lib/bridgetown-core/tags/with.rb +15 -0
- data/lib/bridgetown-core/utils.rb +44 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +17 -10
- data/lib/site_template/Gemfile.erb +19 -0
- data/lib/site_template/bridgetown.config.yml +5 -3
- data/lib/site_template/package.json +1 -0
- data/lib/site_template/src/_components/footer.liquid +3 -0
- data/lib/site_template/src/_components/head.liquid +9 -0
- data/lib/site_template/src/{_includes/navbar.html → _components/navbar.liquid} +0 -0
- data/lib/site_template/src/_layouts/default.html +3 -3
- data/lib/site_template/start.js +1 -1
- data/lib/site_template/webpack.config.js +3 -3
- metadata +53 -19
- data/lib/bridgetown-core/command.rb +0 -112
- data/lib/bridgetown-core/commands/help.rb +0 -34
- data/lib/site_template/src/_components/.keep +0 -0
- data/lib/site_template/src/_includes/footer.html +0 -3
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71735e11ccbfa90136e92df69397f7c27555e846a509064e5ec44640e34a807f
|
4
|
+
data.tar.gz: 81f2e343ca9b675dbbc15877129d3c3a1d1e410f020d006fbbcf7ba3032a56a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f9dd7c20e611506bacc39b87bc74bef99281f98e08fb16f05a14b2f7d3e08da8929fe9036146cce3ebdc98cf5aad3466ab6c45f34853a5af7c8c0411827155
|
7
|
+
data.tar.gz: be4dbaa9575a318e31555f9a1d591090fa7c12d4a3a6e53d59d1b3f92783ed910bf62db97c36c6bb1dc3f4acdbf3a2b45991b37fea5be0fd395ae72b86ea62af
|
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 :
|
8
|
+
task spec: :test
|
7
9
|
require "rake/testtask"
|
8
10
|
Rake::TestTask.new(:test) do |test|
|
9
11
|
test.libs << "lib" << "test"
|
data/bin/bridgetown
CHANGED
@@ -6,31 +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
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
output_version = if ARGV[0] == "-v"
|
17
|
+
puts "bridgetown #{Bridgetown::VERSION} \"#{Bridgetown::CODE_NAME}\""
|
18
|
+
true
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
p.action do |args, _|
|
23
|
-
if args.empty?
|
24
|
-
Bridgetown.logger.error "A subcommand is required."
|
25
|
-
puts p
|
26
|
-
abort
|
27
|
-
else
|
28
|
-
subcommand = args.first
|
29
|
-
unless p.has_command? subcommand
|
30
|
-
Bridgetown.logger.abort_with "fatal: 'bridgetown #{args.first}' could not" \
|
31
|
-
" be found. You may need to install the bridgetown-#{args.first} gem" \
|
32
|
-
" or a related gem to be able to use this subcommand."
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
21
|
+
require "bridgetown-core/commands/base"
|
22
|
+
Bridgetown::Commands::Base.start unless output_version
|
data/bridgetown-core.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
|
34
34
|
s.add_runtime_dependency("activesupport", "~> 6.0")
|
35
35
|
s.add_runtime_dependency("addressable", "~> 2.4")
|
36
|
+
s.add_runtime_dependency("awesome_print", "~> 1.8")
|
36
37
|
s.add_runtime_dependency("colorator", "~> 1.0")
|
37
38
|
s.add_runtime_dependency("faraday", "~> 1.0")
|
38
39
|
s.add_runtime_dependency("faraday_middleware", "~> 1.0")
|
@@ -40,11 +41,12 @@ Gem::Specification.new do |s|
|
|
40
41
|
s.add_runtime_dependency("kramdown", "~> 2.1")
|
41
42
|
s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
|
42
43
|
s.add_runtime_dependency("liquid", "~> 4.0")
|
44
|
+
s.add_runtime_dependency("liquid-component", ">= 0.1")
|
43
45
|
s.add_runtime_dependency("liquid-render-tag", "~> 0.2")
|
44
46
|
s.add_runtime_dependency("listen", "~> 3.0")
|
45
|
-
s.add_runtime_dependency("mercenary", "~> 0.4.0")
|
46
47
|
s.add_runtime_dependency("pathutil", "~> 0.9")
|
47
48
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
48
49
|
s.add_runtime_dependency("safe_yaml", "~> 1.0")
|
49
50
|
s.add_runtime_dependency("terminal-table", "~> 1.8")
|
51
|
+
s.add_runtime_dependency("thor", "~> 1.0")
|
50
52
|
end
|
data/lib/bridgetown-core.rb
CHANGED
@@ -30,15 +30,18 @@ require "json"
|
|
30
30
|
|
31
31
|
# 3rd party
|
32
32
|
require "active_support/core_ext/hash/indifferent_access"
|
33
|
+
require "active_support/core_ext/string/inflections"
|
33
34
|
require "pathutil"
|
34
35
|
require "addressable/uri"
|
35
36
|
require "safe_yaml/load"
|
36
37
|
require "liquid"
|
37
38
|
require "liquid-render-tag"
|
39
|
+
require "liquid-component"
|
38
40
|
require "kramdown"
|
39
41
|
require "colorator"
|
40
42
|
require "i18n"
|
41
43
|
require "faraday"
|
44
|
+
require "thor"
|
42
45
|
|
43
46
|
SafeYAML::OPTIONS[:suppress_warnings] = true
|
44
47
|
|
@@ -89,16 +92,15 @@ module Bridgetown
|
|
89
92
|
autoload :Watcher, "bridgetown-core/watcher"
|
90
93
|
|
91
94
|
# extensions
|
95
|
+
require "bridgetown-core/commands/registrations"
|
92
96
|
require "bridgetown-core/plugin"
|
93
97
|
require "bridgetown-core/converter"
|
94
98
|
require "bridgetown-core/generator"
|
95
|
-
require "bridgetown-core/command"
|
96
99
|
require "bridgetown-core/liquid_extensions"
|
97
100
|
require "bridgetown-core/filters"
|
98
101
|
|
99
102
|
require "bridgetown-core/drops/drop"
|
100
103
|
require "bridgetown-core/drops/document_drop"
|
101
|
-
require_all "bridgetown-core/commands"
|
102
104
|
require_all "bridgetown-core/converters"
|
103
105
|
require_all "bridgetown-core/converters/markdown"
|
104
106
|
require_all "bridgetown-core/drops"
|
@@ -137,6 +139,11 @@ module Bridgetown
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
142
|
+
# Conveinence method to register a new Thor command
|
143
|
+
def register_command(&block)
|
144
|
+
Bridgetown::Commands::Registrations.register(&block)
|
145
|
+
end
|
146
|
+
|
140
147
|
# Public: Set the TZ environment variable to use the timezone specified
|
141
148
|
#
|
142
149
|
# timezone - the IANA Time Zone
|
@@ -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 <
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
10
|
+
Registrations.register do
|
11
|
+
register(Build, "build", "build", Build.summary)
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
29
|
+
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
30
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")"
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|