bridgetown-core 1.3.4 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bridgetown +0 -6
- data/bin/bt +6 -0
- data/bridgetown-core.gemspec +9 -6
- data/lib/bridgetown-core/cleaner.rb +1 -1
- data/lib/bridgetown-core/collection.rb +30 -18
- data/lib/bridgetown-core/commands/build.rb +9 -22
- data/lib/bridgetown-core/commands/concerns/actions.rb +15 -8
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +1 -1
- data/lib/bridgetown-core/commands/console.rb +3 -0
- data/lib/bridgetown-core/commands/doctor.rb +2 -4
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +1 -1
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
- data/lib/bridgetown-core/commands/esbuild/update.rb +2 -2
- data/lib/bridgetown-core/commands/esbuild.rb +3 -3
- data/lib/bridgetown-core/commands/new.rb +32 -39
- data/lib/bridgetown-core/commands/start.rb +76 -60
- data/lib/bridgetown-core/component.rb +19 -13
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/prioritizable.rb +11 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +7 -18
- data/lib/bridgetown-core/concerns/site/content.rb +10 -9
- data/lib/bridgetown-core/concerns/site/extensible.rb +4 -6
- data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +161 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +31 -7
- data/lib/bridgetown-core/concerns/site/ssr.rb +23 -9
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
- data/lib/bridgetown-core/concerns/transformable.rb +3 -5
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +23 -14
- data/lib/bridgetown-core/configuration.rb +67 -114
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -2
- data/lib/bridgetown-core/configurations/cypress/cypress_tasks +2 -2
- data/lib/bridgetown-core/configurations/cypress.rb +1 -1
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +3 -3
- data/lib/bridgetown-core/configurations/is-land.rb +1 -1
- data/lib/bridgetown-core/configurations/lit.rb +1 -1
- data/lib/bridgetown-core/configurations/open-props.rb +1 -1
- data/lib/bridgetown-core/configurations/purgecss.rb +1 -1
- data/lib/bridgetown-core/configurations/ruby2js.rb +1 -1
- data/lib/bridgetown-core/configurations/shoelace.rb +8 -20
- data/lib/bridgetown-core/configurations/stimulus.rb +17 -36
- data/lib/bridgetown-core/configurations/turbo.rb +1 -2
- data/lib/bridgetown-core/converter.rb +38 -10
- data/lib/bridgetown-core/converters/erb_templates.rb +9 -26
- data/lib/bridgetown-core/converters/identity.rb +1 -1
- data/lib/bridgetown-core/converters/liquid_templates.rb +2 -20
- data/lib/bridgetown-core/converters/ruby_templates.rb +61 -3
- data/lib/bridgetown-core/converters/serbea_templates.rb +12 -24
- data/lib/bridgetown-core/current.rb +19 -17
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/drop.rb +3 -3
- data/lib/bridgetown-core/drops/relations_drop.rb +3 -2
- data/lib/bridgetown-core/drops/site_drop.rb +0 -5
- data/lib/bridgetown-core/entry_filter.rb +4 -6
- data/lib/bridgetown-core/errors.rb +2 -2
- data/lib/bridgetown-core/filters/from_liquid.rb +6 -10
- data/lib/bridgetown-core/filters/localization_filters.rb +1 -1
- data/lib/bridgetown-core/filters/translation_filters.rb +2 -2
- data/lib/bridgetown-core/filters.rb +3 -3
- data/lib/bridgetown-core/front_matter/defaults.rb +225 -0
- data/lib/bridgetown-core/front_matter/importer.rb +34 -0
- data/lib/bridgetown-core/front_matter/loaders/base.rb +29 -0
- data/lib/bridgetown-core/front_matter/loaders/ruby.rb +113 -0
- data/lib/bridgetown-core/front_matter/loaders/yaml.rb +42 -0
- data/lib/bridgetown-core/front_matter/loaders.rb +44 -0
- data/lib/bridgetown-core/{utils/ruby_front_matter.rb → front_matter/ruby.rb} +5 -5
- data/lib/bridgetown-core/front_matter.rb +11 -0
- data/lib/bridgetown-core/generated_page.rb +71 -31
- data/lib/bridgetown-core/generators/prototype_generator.rb +30 -18
- data/lib/bridgetown-core/helpers.rb +36 -47
- data/lib/bridgetown-core/hooks.rb +5 -5
- data/lib/bridgetown-core/inflector.rb +40 -0
- data/lib/bridgetown-core/kramdown/parser/gfm.rb +2 -2
- data/lib/bridgetown-core/layout.rb +3 -3
- data/lib/bridgetown-core/log_adapter.rb +12 -13
- data/lib/bridgetown-core/log_writer.rb +4 -4
- data/lib/bridgetown-core/model/base.rb +17 -17
- data/lib/bridgetown-core/model/builder_origin.rb +5 -3
- data/lib/bridgetown-core/model/origin.rb +1 -3
- data/lib/bridgetown-core/model/repo_origin.rb +12 -14
- data/lib/bridgetown-core/plugin.rb +0 -1
- data/lib/bridgetown-core/plugin_manager.rb +27 -84
- data/lib/bridgetown-core/rack/boot.rb +0 -15
- data/lib/bridgetown-core/rack/routes.rb +30 -90
- data/lib/bridgetown-core/reader.rb +6 -4
- data/lib/bridgetown-core/readers/layout_reader.rb +2 -2
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +2 -2
- data/lib/bridgetown-core/resource/base.rb +112 -29
- data/lib/bridgetown-core/resource/destination.rb +1 -1
- data/lib/bridgetown-core/resource/relations.rb +11 -8
- data/lib/bridgetown-core/resource/taxonomy_type.rb +3 -1
- data/lib/bridgetown-core/resource/transformer.rb +4 -4
- data/lib/bridgetown-core/ruby_template_view.rb +44 -28
- data/lib/bridgetown-core/signals.rb +95 -0
- data/lib/bridgetown-core/site.rb +22 -4
- data/lib/bridgetown-core/slot.rb +5 -5
- data/lib/bridgetown-core/static_file.rb +5 -7
- data/lib/bridgetown-core/tags/asset_path.rb +11 -2
- data/lib/bridgetown-core/tags/find.rb +3 -5
- data/lib/bridgetown-core/tags/highlight.rb +3 -3
- data/lib/bridgetown-core/tags/post_url.rb +1 -1
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +2 -2
- data/lib/bridgetown-core/utils/aux.rb +41 -41
- data/lib/bridgetown-core/utils/loaders_manager.rb +2 -21
- data/lib/bridgetown-core/utils/ruby_exec.rb +17 -0
- data/lib/bridgetown-core/utils.rb +46 -110
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +21 -10
- data/lib/bridgetown-core.rb +35 -49
- data/lib/roda/plugins/bridgetown_server.rb +54 -12
- data/lib/roda/plugins/bridgetown_ssr.rb +13 -2
- data/lib/roda/plugins/ssg.rb +72 -0
- data/lib/site_template/.gitignore +9 -3
- data/lib/site_template/Gemfile.erb +3 -3
- data/lib/site_template/README.md +3 -4
- data/lib/site_template/Rakefile.erb +2 -15
- data/lib/site_template/TEMPLATES/erb/_partials/_head.erb +2 -2
- data/lib/site_template/TEMPLATES/serbea/_partials/_head.serb +2 -2
- data/lib/site_template/config/initializers.rb +60 -22
- data/lib/site_template/config/puma.rb +2 -0
- data/lib/site_template/package.json.erb +2 -27
- data/lib/site_template/src/index.md.erb +3 -3
- data/lib/site_template/tmp/pids/.keep +0 -0
- metadata +98 -63
- data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +0 -12
- data/lib/bridgetown-core/commands/webpack/setup.rb +0 -4
- data/lib/bridgetown-core/commands/webpack/update.rb +0 -24
- data/lib/bridgetown-core/commands/webpack/webpack.config.js +0 -31
- data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +0 -135
- data/lib/bridgetown-core/commands/webpack.rb +0 -82
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +0 -52
- data/lib/bridgetown-core/concerns/liquid_renderable.rb +0 -30
- data/lib/bridgetown-core/core_ext/psych.rb +0 -15
- data/lib/bridgetown-core/drops/url_drop.rb +0 -152
- data/lib/bridgetown-core/frontmatter_defaults.rb +0 -223
- data/lib/bridgetown-core/rack/static_indexes.rb +0 -31
- data/lib/bridgetown-core/url.rb +0 -166
- data/lib/bridgetown-core/utils/ansi.rb +0 -57
- data/lib/site_template/bridgetown.config.yml +0 -33
@@ -8,15 +8,15 @@ class Bridgetown::Site
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
# Establish an SSR pipeline for a persistent backend process
|
11
|
-
def start_ssr!(loaders_manager: nil, &
|
11
|
+
def start_ssr!(loaders_manager: nil, &)
|
12
12
|
if Bridgetown::Current.site
|
13
13
|
raise Bridgetown::Errors::FatalException, "Bridgetown SSR already started! " \
|
14
14
|
"Check your Rack app for threading issues"
|
15
15
|
end
|
16
16
|
|
17
|
-
site = new(Bridgetown::Current.preloaded_configuration, loaders_manager:
|
17
|
+
site = new(Bridgetown::Current.preloaded_configuration, loaders_manager:)
|
18
18
|
site.enable_ssr
|
19
|
-
site.ssr_setup(&
|
19
|
+
site.ssr_setup(&)
|
20
20
|
|
21
21
|
site
|
22
22
|
end
|
@@ -28,11 +28,24 @@ class Bridgetown::Site
|
|
28
28
|
|
29
29
|
def enable_ssr
|
30
30
|
Bridgetown.logger.info "SSR:", "enabled."
|
31
|
+
config.fast_refresh = false # SSR mode and Fast Refresh mode are mututally exclusive
|
31
32
|
@ssr_enabled = true
|
32
33
|
end
|
33
34
|
|
34
35
|
def ssr_setup(&block)
|
35
|
-
|
36
|
+
Bridgetown::Hooks.trigger :site, :pre_read, self
|
37
|
+
ssr_first_read
|
38
|
+
Bridgetown::Hooks.trigger :site, :post_read, self
|
39
|
+
|
40
|
+
block&.call(self) # provide additional setup hook
|
41
|
+
|
42
|
+
return if Bridgetown.env.production?
|
43
|
+
|
44
|
+
Bridgetown::Watcher.watch(self, config, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def ssr_first_read
|
48
|
+
# TODO: this shouldn't be running twice, right?!
|
36
49
|
Bridgetown::Hooks.trigger :site, :pre_read, self
|
37
50
|
defaults_reader.tap do |d|
|
38
51
|
d.path_defaults.clear
|
@@ -43,12 +56,13 @@ class Bridgetown::Site
|
|
43
56
|
coll.read
|
44
57
|
self.data = coll.merge_data_resources
|
45
58
|
end
|
46
|
-
Bridgetown::Hooks.trigger :site, :post_read, self
|
47
|
-
|
48
|
-
block&.call(self) # provide additional setup hook
|
49
|
-
return if Bridgetown.env.production?
|
50
59
|
|
51
|
-
|
60
|
+
# This part is handled via a hook so it is supported by the SSR "soft reset"
|
61
|
+
Bridgetown::Hooks.register_one :site, :post_read, reloadable: false, priority: :high do
|
62
|
+
reader.read_directories
|
63
|
+
reader.sort_files!
|
64
|
+
reader.read_collections
|
65
|
+
end
|
52
66
|
end
|
53
67
|
|
54
68
|
def disable_ssr
|
@@ -15,11 +15,9 @@ module Bridgetown
|
|
15
15
|
converters.each_with_index.inject(
|
16
16
|
(alternate_content || document.content).to_s
|
17
17
|
) do |content, (converter, index)|
|
18
|
-
output =
|
19
|
-
converter.convert
|
20
|
-
|
21
|
-
converter.convert content, document
|
22
|
-
end
|
18
|
+
output = converter.method(:convert).arity == 1 ?
|
19
|
+
converter.convert(content) :
|
20
|
+
converter.convert(content, document)
|
23
21
|
|
24
22
|
yield converter, index, output if block_given?
|
25
23
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class Configuration
|
5
|
-
class ConfigurationDSL < Bridgetown::
|
5
|
+
class ConfigurationDSL < Bridgetown::FrontMatter::RubyFrontMatter
|
6
6
|
attr_reader :context
|
7
7
|
|
8
8
|
# @yieldself [ConfigurationDSL]
|
@@ -11,7 +11,7 @@ module Bridgetown
|
|
11
11
|
@scope.initializers[name.to_sym].completed
|
12
12
|
|
13
13
|
initializer = _setup_initializer(
|
14
|
-
name
|
14
|
+
name:, require_gem:, require_initializer:
|
15
15
|
)
|
16
16
|
|
17
17
|
return unless initializer.nil? || initializer.completed == false
|
@@ -27,36 +27,38 @@ module Bridgetown
|
|
27
27
|
end
|
28
28
|
|
29
29
|
Bridgetown.logger.debug "Initializing:", name
|
30
|
-
@scope.initializers[name.to_sym].block.(
|
30
|
+
@scope.initializers[name.to_sym].block.(
|
31
|
+
self, **@scope.init_params[name].transform_keys(&:to_sym)
|
32
|
+
)
|
31
33
|
initializer.completed = true
|
32
34
|
end
|
33
35
|
|
34
|
-
def only(*context, &
|
36
|
+
def only(*context, &)
|
35
37
|
return unless context.any? { _1 == @context }
|
36
38
|
|
37
|
-
instance_exec(&
|
39
|
+
instance_exec(&)
|
38
40
|
end
|
39
41
|
|
40
|
-
def except(*context, &
|
42
|
+
def except(*context, &)
|
41
43
|
return if context.any? { _1 == @context }
|
42
44
|
|
43
|
-
instance_exec(&
|
45
|
+
instance_exec(&)
|
44
46
|
end
|
45
47
|
|
46
48
|
def hook(
|
47
49
|
owner,
|
48
50
|
event,
|
49
51
|
priority: Bridgetown::Hooks::DEFAULT_PRIORITY,
|
50
|
-
&
|
52
|
+
&
|
51
53
|
)
|
52
|
-
Bridgetown::Hooks.register_one(owner, event, priority
|
54
|
+
Bridgetown::Hooks.register_one(owner, event, priority:, reloadable: false, &)
|
53
55
|
end
|
54
56
|
|
55
57
|
def source_manifest(**kwargs)
|
56
58
|
@scope.source_manifests << SourceManifest.new(**kwargs)
|
57
59
|
end
|
58
60
|
|
59
|
-
def builder(klass = nil, &
|
61
|
+
def builder(klass = nil, &)
|
60
62
|
return klass.register if klass.is_a?(Class) && klass < Bridgetown::Builder
|
61
63
|
|
62
64
|
unless klass.is_a?(Symbol)
|
@@ -64,7 +66,7 @@ module Bridgetown
|
|
64
66
|
end
|
65
67
|
|
66
68
|
Object.const_set(
|
67
|
-
klass, Class.new(Bridgetown::Builder, &
|
69
|
+
klass, Class.new(Bridgetown::Builder, &).tap(&:register)
|
68
70
|
)
|
69
71
|
end
|
70
72
|
|
@@ -72,8 +74,9 @@ module Bridgetown
|
|
72
74
|
@scope.roda_initializers << block
|
73
75
|
end
|
74
76
|
|
75
|
-
def timezone(
|
76
|
-
|
77
|
+
def timezone(new_timezone)
|
78
|
+
@data[:timezone] = new_timezone
|
79
|
+
Bridgetown.set_timezone(new_timezone)
|
77
80
|
end
|
78
81
|
|
79
82
|
def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
|
@@ -109,7 +112,7 @@ module Bridgetown
|
|
109
112
|
|
110
113
|
def reflect(name, require_gem: true, require_initializer: true)
|
111
114
|
initializer = _setup_initializer(
|
112
|
-
name
|
115
|
+
name:, require_gem:, require_initializer:
|
113
116
|
)
|
114
117
|
|
115
118
|
if initializer.nil?
|
@@ -145,6 +148,12 @@ module Bridgetown
|
|
145
148
|
def _in_require_denylist?(name)
|
146
149
|
REQUIRE_DENYLIST.include?(name.to_sym)
|
147
150
|
end
|
151
|
+
|
152
|
+
# Initializers that are part of the Bridgetown boot sequence. Site owners can override
|
153
|
+
# defaults by running any of these manually…init is no-op if the initializer was already run.
|
154
|
+
def _run_builtins!
|
155
|
+
init :streamlined
|
156
|
+
end
|
148
157
|
end
|
149
158
|
end
|
150
159
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
# The primary configuration object for a Bridgetown project
|
5
5
|
class Configuration < HashWithDotAccess::Hash
|
6
|
+
using Bridgetown::Refinements
|
7
|
+
|
6
8
|
REQUIRE_DENYLIST = %i(parse_routes ssr) # rubocop:disable Style/MutableConstant
|
7
9
|
|
8
10
|
Initializer = Struct.new(:name, :block, :completed, keyword_init: true) do
|
@@ -26,69 +28,65 @@ module Bridgetown
|
|
26
28
|
# Strings rather than symbols are used for compatibility with YAML.
|
27
29
|
DEFAULTS = {
|
28
30
|
# Where things are
|
29
|
-
"root_dir"
|
30
|
-
"plugins_dir"
|
31
|
-
"source"
|
32
|
-
"destination"
|
33
|
-
"collections_dir"
|
34
|
-
"cache_dir"
|
35
|
-
"layouts_dir"
|
36
|
-
"components_dir"
|
37
|
-
"islands_dir"
|
38
|
-
"partials_dir"
|
39
|
-
"collections"
|
40
|
-
"taxonomies"
|
31
|
+
"root_dir" => Dir.pwd,
|
32
|
+
"plugins_dir" => "plugins",
|
33
|
+
"source" => "src",
|
34
|
+
"destination" => "output",
|
35
|
+
"collections_dir" => "",
|
36
|
+
"cache_dir" => ".bridgetown-cache",
|
37
|
+
"layouts_dir" => "_layouts",
|
38
|
+
"components_dir" => "_components",
|
39
|
+
"islands_dir" => "_islands",
|
40
|
+
"partials_dir" => "_partials",
|
41
|
+
"collections" => {},
|
42
|
+
"taxonomies" => {
|
41
43
|
category: { key: "categories", title: "Category" }, tag: { key: "tags", title: "Tag" },
|
42
44
|
},
|
43
|
-
"autoload_paths"
|
44
|
-
"inflector"
|
45
|
-
"eager_load_paths"
|
46
|
-
"autoloader_collapsed_paths"
|
47
|
-
"additional_watch_paths"
|
45
|
+
"autoload_paths" => [],
|
46
|
+
"inflector" => Bridgetown::Inflector.new,
|
47
|
+
"eager_load_paths" => [],
|
48
|
+
"autoloader_collapsed_paths" => [],
|
49
|
+
"additional_watch_paths" => [],
|
50
|
+
"defaults" => [],
|
48
51
|
|
49
52
|
# Handling Reading
|
50
|
-
"include"
|
51
|
-
"exclude"
|
52
|
-
"keep_files"
|
53
|
-
"encoding"
|
54
|
-
"markdown_ext"
|
55
|
-
"strict_front_matter"
|
56
|
-
"slugify_mode"
|
53
|
+
"include" => [".htaccess", "_redirects", ".well-known"],
|
54
|
+
"exclude" => [],
|
55
|
+
"keep_files" => [".git", ".svn", "_bridgetown"],
|
56
|
+
"encoding" => "utf-8",
|
57
|
+
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
58
|
+
"strict_front_matter" => false,
|
59
|
+
"slugify_mode" => "pretty",
|
57
60
|
|
58
61
|
# Filtering Content
|
59
|
-
"future"
|
60
|
-
"unpublished"
|
61
|
-
"ruby_in_front_matter"
|
62
|
+
"future" => false,
|
63
|
+
"unpublished" => false,
|
64
|
+
"ruby_in_front_matter" => true,
|
62
65
|
|
63
66
|
# Conversion
|
64
|
-
"
|
65
|
-
"markdown"
|
66
|
-
"highlighter"
|
67
|
-
|
68
|
-
# Serving
|
69
|
-
"port" => "4000",
|
70
|
-
"host" => "127.0.0.1",
|
71
|
-
"base_path" => "/",
|
72
|
-
"show_dir_listing" => false,
|
67
|
+
"template_engine" => "erb",
|
68
|
+
"markdown" => "kramdown",
|
69
|
+
"highlighter" => "rouge",
|
70
|
+
"support_data_as_view_methods" => true,
|
73
71
|
|
74
72
|
# Output Configuration
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"
|
79
|
-
"
|
73
|
+
"base_path" => "/",
|
74
|
+
"available_locales" => [:en],
|
75
|
+
"default_locale" => :en,
|
76
|
+
"prefix_default_locale" => false,
|
77
|
+
"permalink" => "pretty",
|
78
|
+
"timezone" => nil, # use the local timezone
|
80
79
|
|
81
|
-
"quiet"
|
82
|
-
"verbose"
|
83
|
-
"defaults" => [],
|
80
|
+
"quiet" => false,
|
81
|
+
"verbose" => false,
|
84
82
|
|
85
|
-
"liquid"
|
83
|
+
"liquid" => {
|
86
84
|
"error_mode" => "warn",
|
87
85
|
"strict_filters" => false,
|
88
86
|
"strict_variables" => false,
|
89
87
|
},
|
90
88
|
|
91
|
-
"kramdown"
|
89
|
+
"kramdown" => {
|
92
90
|
"auto_ids" => true,
|
93
91
|
"toc_levels" => (1..6).to_a,
|
94
92
|
"entity_output" => "as_char",
|
@@ -101,11 +99,11 @@ module Bridgetown
|
|
101
99
|
"include_extraction_tags" => false,
|
102
100
|
"mark_highlighting" => true,
|
103
101
|
},
|
104
|
-
}.each_with_object(Configuration.new) { |(k, v), hsh| hsh[k] = v.freeze }.freeze
|
105
102
|
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
"development" => {
|
104
|
+
"fast_refresh" => true,
|
105
|
+
},
|
106
|
+
}.each_with_object(Configuration.new) { |(k, v), hsh| hsh[k] = v.freeze }.freeze
|
109
107
|
|
110
108
|
# @return [Hash<Symbol, Initializer>]
|
111
109
|
attr_accessor :initializers
|
@@ -148,6 +146,7 @@ module Bridgetown
|
|
148
146
|
dsl = ConfigurationDSL.new(scope: self, data: self)
|
149
147
|
dsl.instance_variable_set(:@context, context)
|
150
148
|
dsl.instance_exec(dsl, &init_init.block)
|
149
|
+
dsl._run_builtins!
|
151
150
|
self.url = cached_url if cached_url # restore local development URL if need be
|
152
151
|
|
153
152
|
setup_load_paths! appending: true
|
@@ -203,33 +202,8 @@ module Bridgetown
|
|
203
202
|
end
|
204
203
|
alias_method :verbose?, :verbose
|
205
204
|
|
206
|
-
def safe_load_file(filename)
|
207
|
-
|
208
|
-
when %r!\.toml!i
|
209
|
-
Deprecator.deprecation_message(
|
210
|
-
"TOML configurations will no longer be supported in the next version of Bridgetown." \
|
211
|
-
"Use initializers or a .yaml config instead."
|
212
|
-
)
|
213
|
-
Bridgetown::Utils::RequireGems.require_with_graceful_fail("tomlrb") unless defined?(Tomlrb)
|
214
|
-
Tomlrb.load_file(filename)
|
215
|
-
when %r!\.ya?ml!i
|
216
|
-
if File.basename(filename, ".*") == "_config"
|
217
|
-
Deprecator.deprecation_message(
|
218
|
-
"YAML configurations named `_config.y(a)ml' will no longer be supported in the next " \
|
219
|
-
"version of Bridgetown. Rename to `bridgetown.config.yml' instead."
|
220
|
-
)
|
221
|
-
end
|
222
|
-
if File.extname(filename) == ".yaml"
|
223
|
-
Deprecator.deprecation_message(
|
224
|
-
"YAML configurations ending in `.yaml' will no longer be supported in the next " \
|
225
|
-
"version of Bridgetown. Rename to use `.yml' extension instead."
|
226
|
-
)
|
227
|
-
end
|
228
|
-
YAMLParser.load_file(filename) || {}
|
229
|
-
else
|
230
|
-
raise ArgumentError,
|
231
|
-
"No parser for '#{filename}' is available. Use a .y(a)ml file instead."
|
232
|
-
end
|
205
|
+
def safe_load_file(filename)
|
206
|
+
YAMLParser.load_file(filename) || {}
|
233
207
|
rescue Psych::DisallowedClass => e
|
234
208
|
raise "Unable to parse `#{File.basename(filename)}'. #{e.message}"
|
235
209
|
end
|
@@ -251,28 +225,15 @@ module Bridgetown
|
|
251
225
|
# By default only the first matching config file will be loaded, but
|
252
226
|
# multiple configs can be specified via command line.
|
253
227
|
config_files = override["config"]
|
254
|
-
if config_files.to_s.empty?
|
255
|
-
file_lookups = CONFIG_FILE_PREFIXES.map do |prefix|
|
256
|
-
CONFIG_FILE_EXTS.map do |ext|
|
257
|
-
Bridgetown.sanitized_path(root_dir(override), "#{prefix}.#{ext}")
|
258
|
-
end
|
259
|
-
end.flatten.freeze
|
260
|
-
|
261
|
-
found_file = file_lookups.find do |path|
|
262
|
-
File.exist?(path)
|
263
|
-
end
|
264
|
-
|
265
|
-
config_files = found_file || file_lookups.first
|
266
|
-
@default_config_file = true
|
267
|
-
end
|
228
|
+
config_files = "bridgetown.config.yml" if config_files.to_s.empty?
|
268
229
|
Array(config_files)
|
269
230
|
end
|
270
231
|
|
271
|
-
#
|
232
|
+
# Read in a list of configuration files and merge with this hash
|
272
233
|
#
|
273
|
-
# files
|
234
|
+
# @param files [Array<String>]
|
274
235
|
#
|
275
|
-
#
|
236
|
+
# @return [Hash] configuration with the defaults overridden by the values in the
|
276
237
|
# configuration files
|
277
238
|
def read_config_files(files)
|
278
239
|
config = self
|
@@ -293,30 +254,28 @@ module Bridgetown
|
|
293
254
|
config
|
294
255
|
end
|
295
256
|
|
296
|
-
#
|
257
|
+
# Read configuration and return merged Hash
|
297
258
|
#
|
298
|
-
# file
|
259
|
+
# @param file [String] the path to the YAML file to be read in
|
299
260
|
#
|
300
|
-
#
|
261
|
+
# @return [Hash]
|
301
262
|
def read_config_file(file)
|
263
|
+
default_config_file = file == "bridgetown.config.yml"
|
302
264
|
file = File.expand_path(file)
|
303
|
-
|
265
|
+
# We don't care if default config is missing, we can return blank:
|
266
|
+
return {} if !File.exist?(file) && default_config_file
|
267
|
+
|
268
|
+
file_config = safe_load_file(file)
|
304
269
|
|
305
|
-
unless
|
270
|
+
unless file_config.is_a?(Hash)
|
306
271
|
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
|
307
272
|
end
|
308
273
|
|
309
274
|
Bridgetown.logger.debug "Configuration file:", file
|
310
|
-
|
275
|
+
file_config
|
311
276
|
rescue SystemCallError
|
312
|
-
|
313
|
-
|
314
|
-
Bridgetown.logger.warn "Configuration file:", "none" unless File.file?(initializers_file)
|
315
|
-
{}
|
316
|
-
else
|
317
|
-
Bridgetown.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
318
|
-
raise LoadError, "The Configuration file '#{file}' could not be found."
|
319
|
-
end
|
277
|
+
Bridgetown.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
278
|
+
raise LoadError, "missing configuration file"
|
320
279
|
end
|
321
280
|
|
322
281
|
# Merge in environment-specific options, if present
|
@@ -388,18 +347,12 @@ module Bridgetown
|
|
388
347
|
self[:collections][:posts][:output] = true
|
389
348
|
self[:collections][:posts][:sort_direction] ||= "descending"
|
390
349
|
|
391
|
-
self[:permalink] = "pretty" if self[:permalink].blank?
|
392
350
|
self[:collections][:pages] = {} unless self[:collections][:pages]
|
393
351
|
self[:collections][:pages][:output] = true
|
394
|
-
self[:collections][:pages][:permalink] ||= "/:locale/:path/"
|
395
352
|
|
396
353
|
self[:collections][:data] = {} unless self[:collections][:data]
|
397
354
|
self[:collections][:data][:output] = false
|
398
355
|
|
399
|
-
unless self[:collections][:posts][:permalink]
|
400
|
-
self[:collections][:posts][:permalink] = self[:permalink]
|
401
|
-
end
|
402
|
-
|
403
356
|
self
|
404
357
|
end
|
405
358
|
|
@@ -6,7 +6,6 @@ unless File.exist?("postcss.config.js")
|
|
6
6
|
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
7
7
|
|
8
8
|
@logger.error "\nError:".red, "🚨 #{error_message}"
|
9
|
-
@logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
|
10
9
|
|
11
10
|
return
|
12
11
|
end
|
@@ -17,7 +16,7 @@ return unless confirm.casecmp?("Y")
|
|
17
16
|
plugins = %w(postcss-mixins postcss-color-mod-function cssnano)
|
18
17
|
|
19
18
|
say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
|
20
|
-
|
19
|
+
add_npm_package "-D #{plugins.join(' ')}"
|
21
20
|
|
22
21
|
copy_file in_templates_dir("postcss.config.js"), "postcss.config.js", force: true
|
23
22
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
namespace :cy do
|
2
2
|
desc "Open Cypress test runner"
|
3
3
|
task :open do
|
4
|
-
system "
|
4
|
+
system "npm run cypress open"
|
5
5
|
end
|
6
6
|
|
7
7
|
desc "Run Cypress tests headless"
|
8
8
|
task :run do
|
9
|
-
system "
|
9
|
+
system "npm run cypress run"
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "Start server and open Cypress test runner"
|
@@ -13,7 +13,7 @@ say_status :lit, "Installing Lit + SSR Plugin..."
|
|
13
13
|
|
14
14
|
add_gem "bridgetown-lit-renderer", version: "2.1.0.beta2"
|
15
15
|
|
16
|
-
|
16
|
+
add_npm_package "lit esbuild-plugin-lit-css bridgetown-lit-renderer@2.1.0-beta2"
|
17
17
|
|
18
18
|
copy_file in_templates_dir("lit-ssr.config.js"), "config/lit-ssr.config.js"
|
19
19
|
copy_file in_templates_dir("lit-components-entry.js"), "config/lit-components-entry.js"
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
say_status :ruby2js, "Installing Ruby2JS..."
|
13
13
|
|
14
14
|
add_gem "ruby2js"
|
15
|
-
|
15
|
+
add_npm_package "-D @ruby2js/esbuild-plugin"
|
16
16
|
|
17
17
|
insert_into_file "esbuild.config.js",
|
18
18
|
after: 'const build = require("./config/esbuild.defaults.js")' do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
say_status :shoelace, "Installing Shoelace..."
|
4
4
|
|
5
|
-
|
5
|
+
add_npm_package "@shoelace-style/shoelace"
|
6
6
|
|
7
7
|
stylesheet_import = <<~CSS
|
8
8
|
/* Import the base Shoelace stylesheet: */
|
@@ -37,26 +37,14 @@ end
|
|
37
37
|
|
38
38
|
say "Updating frontend build commands...", :magenta
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
JS
|
45
|
-
end
|
46
|
-
gsub_file "package.json", %r{"esbuild": "node}, '"esbuild": "yarn shoelace:copy-assets && node'
|
47
|
-
gsub_file "package.json", %r{"esbuild-dev": "node},
|
48
|
-
'"esbuild-dev": "yarn shoelace:copy-assets && node'
|
49
|
-
else
|
50
|
-
insert_into_file "package.json", before: ' "webpack-build": "webpack' do
|
51
|
-
<<-JS
|
52
|
-
"shoelace:copy-assets": "mkdir -p src/shoelace-assets && cp -r node_modules/@shoelace-style/shoelace/dist/assets src/shoelace-assets",
|
53
|
-
JS
|
54
|
-
end
|
55
|
-
gsub_file "package.json", %r{"webpack-build": "webpack},
|
56
|
-
'"webpack-build": "yarn shoelace:copy-assets && webpack'
|
57
|
-
gsub_file "package.json", %r{"webpack-dev": "webpack},
|
58
|
-
'"webpack-dev": "yarn shoelace:copy-assets && webpack'
|
40
|
+
insert_into_file "package.json", before: ' "esbuild": "node' do
|
41
|
+
<<-JS
|
42
|
+
"shoelace:copy-assets": "mkdir -p src/shoelace-assets && cp -r node_modules/@shoelace-style/shoelace/dist/assets src/shoelace-assets",
|
43
|
+
JS
|
59
44
|
end
|
45
|
+
gsub_file "package.json", %r{"esbuild": "node}, '"esbuild": "npm run shoelace:copy-assets && node'
|
46
|
+
gsub_file "package.json", %r{"esbuild-dev": "node},
|
47
|
+
'"esbuild-dev": "npm run shoelace:copy-assets && node'
|
60
48
|
|
61
49
|
if File.exist?(".gitignore")
|
62
50
|
append_to_file ".gitignore" do
|