bridgetown-core 1.2.0.beta3 → 1.2.0.beta5
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/.rubocop.yml +0 -1
- data/lib/bridgetown-core/collection.rb +9 -2
- data/lib/bridgetown-core/commands/base.rb +2 -0
- data/lib/bridgetown-core/commands/concerns/actions.rb +6 -4
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +1 -1
- data/lib/bridgetown-core/commands/start.rb +1 -0
- data/lib/bridgetown-core/concerns/localizable.rb +5 -1
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +1 -1
- data/lib/bridgetown-core/configuration.rb +11 -3
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -1
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +22 -6
- data/lib/bridgetown-core/configurations/gh-pages.rb +1 -1
- data/lib/bridgetown-core/configurations/lit.rb +2 -2
- data/lib/bridgetown-core/configurations/stimulus.rb +2 -2
- data/lib/bridgetown-core/drops/drop.rb +1 -1
- data/lib/bridgetown-core/drops/static_file_drop.rb +1 -1
- data/lib/bridgetown-core/helpers.rb +9 -3
- data/lib/bridgetown-core/model/repo_origin.rb +4 -1
- data/lib/bridgetown-core/plugin_manager.rb +2 -1
- data/lib/bridgetown-core/rack/static_indexes.rb +4 -4
- data/lib/bridgetown-core/resource/base.rb +1 -1
- data/lib/bridgetown-core/static_file.rb +6 -4
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
- data/lib/bridgetown-core/utils/ruby_front_matter.rb +2 -2
- data/lib/bridgetown-core/utils.rb +7 -4
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +6 -1
- data/lib/bridgetown-core.rb +5 -2
- data/lib/site_template/config/initializers.rb +1 -1
- data/lib/site_template/config/puma.rb +4 -0
- data/lib/site_template/package.json.erb +5 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db2117b99eb2b2943920e6cbfe4267b2a668842de44e360df645da6554ea877
|
4
|
+
data.tar.gz: b8e3652ab12db38512546612a74df6939bd841166d9cfae371aa75d6ae8d8265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 446f796d17a209b19afdb9d8f349d1e5197d7f5600598bc21be3c23c73df7d10c125379d739bd608322d404365ca37b4a37cbe9b38fa8bdd22a97c84c41bee7c
|
7
|
+
data.tar.gz: 89293450447e8acb5718cdcdc782124699faa138c559474c5df66609715163fca809d4ed477cf5ee75b905f62e0bcbd540f62a46841b8c58fede225670ae429b
|
data/.rubocop.yml
CHANGED
@@ -271,6 +271,7 @@ module Bridgetown
|
|
271
271
|
# Read in resource from repo path
|
272
272
|
# @param full_path [String]
|
273
273
|
# @param manifest [Bridgetown::Configuration::SourceManifest]
|
274
|
+
# @return [void]
|
274
275
|
def read_resource(full_path, manifest: nil)
|
275
276
|
model_relative_path = relative_model_path_for(full_path, manifest: manifest)
|
276
277
|
model = Bridgetown::Model::Base.find(
|
@@ -279,14 +280,20 @@ module Bridgetown
|
|
279
280
|
)
|
280
281
|
|
281
282
|
if model_is_multi_locale?(model, model_relative_path)
|
282
|
-
|
283
|
-
|
283
|
+
# If the model specifies a locales key, use that to determine the
|
284
|
+
# the locale of each resource, otherwise fall back to `site.config.available_locales`
|
285
|
+
locales = model.locales || site.config.available_locales
|
286
|
+
|
287
|
+
locales.each do |locale|
|
288
|
+
model.locale = locale.to_sym
|
284
289
|
add_resource_from_model model
|
285
290
|
end
|
291
|
+
|
286
292
|
return
|
287
293
|
end
|
288
294
|
|
289
295
|
add_resource_from_model model
|
296
|
+
nil
|
290
297
|
end
|
291
298
|
|
292
299
|
# @param model [Bridgetown::Model::Base]
|
@@ -27,7 +27,7 @@ module Bridgetown
|
|
27
27
|
|
28
28
|
def javascript_import(data = nil, filename: "index.js") # rubocop:todo Metrics/PerceivedComplexity
|
29
29
|
data ||= yield if block_given?
|
30
|
-
data += "\n" unless data
|
30
|
+
data += "\n" unless data[-1] == "\n"
|
31
31
|
|
32
32
|
say_status :javascript_import, filename
|
33
33
|
|
@@ -56,8 +56,9 @@ module Bridgetown
|
|
56
56
|
options = +""
|
57
57
|
options += " -v \"#{version}\"" if version
|
58
58
|
options += " -g #{group}" if group
|
59
|
+
# in_bundle? returns the path to the gemfile
|
59
60
|
run "bundle add #{gemname}#{options}",
|
60
|
-
env: { "BUNDLE_GEMFILE" =>
|
61
|
+
env: { "BUNDLE_GEMFILE" => Bundler::SharedHelpers.in_bundle? }
|
61
62
|
rescue SystemExit
|
62
63
|
say_status :run, "Gem not added due to bundler error", :red
|
63
64
|
end
|
@@ -67,7 +68,8 @@ module Bridgetown
|
|
67
68
|
say_status :initializer, name
|
68
69
|
data = yield if block_given?
|
69
70
|
data = data.indent(2).lstrip
|
70
|
-
data
|
71
|
+
data = " #{data}" unless data.start_with?(",")
|
72
|
+
data += "\n" unless data[-1] == "\n"
|
71
73
|
|
72
74
|
init_file = File.join("config", "initializers.rb")
|
73
75
|
unless File.exist?(init_file)
|
@@ -84,7 +86,7 @@ module Bridgetown
|
|
84
86
|
say_status :configure, name
|
85
87
|
data = yield if block_given?
|
86
88
|
data = data.indent(2)
|
87
|
-
data += "\n" unless data
|
89
|
+
data += "\n" unless data[-1] == "\n"
|
88
90
|
|
89
91
|
init_file = File.join("config", "initializers.rb")
|
90
92
|
unless File.exist?(init_file)
|
@@ -290,7 +290,7 @@ module.exports = async (outputFolder, esbuildOptions) => {
|
|
290
290
|
minify: process.argv.includes("--minify"),
|
291
291
|
sourcemap: true,
|
292
292
|
target: "es2016",
|
293
|
-
entryPoints: ["frontend/javascript/index.js"],
|
293
|
+
entryPoints: ["./frontend/javascript/index.js"],
|
294
294
|
entryNames: "[dir]/[name].[hash]",
|
295
295
|
outdir: path.join(process.cwd(), `${outputFolder}/_bridgetown/static`),
|
296
296
|
publicPath: "/_bridgetown/static",
|
@@ -42,6 +42,7 @@ module Bridgetown
|
|
42
42
|
# Load Bridgetown configuration into thread memory
|
43
43
|
bt_options = configuration_with_overrides(options)
|
44
44
|
|
45
|
+
# Set a local site URL in the config if one is not available
|
45
46
|
if Bridgetown.env.development? && !options["url"]
|
46
47
|
scheme = bt_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
47
48
|
port = bt_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
@@ -12,7 +12,11 @@ module Bridgetown
|
|
12
12
|
[]
|
13
13
|
end
|
14
14
|
|
15
|
-
result_set.select
|
15
|
+
matching_resources = result_set.select do |item|
|
16
|
+
item.relative_path.parent == relative_path.parent && item.data.slug == data.slug
|
17
|
+
end
|
18
|
+
|
19
|
+
matching_resources.sort_by do |item|
|
16
20
|
site.config.available_locales.index item.data.locale
|
17
21
|
end
|
18
22
|
end
|
@@ -73,7 +73,7 @@ module Bridgetown
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def method_missing(key, *value, &block) # rubocop:disable Style/MissingRespondToMissing
|
76
|
-
return get(key) if value.
|
76
|
+
return get(key) if value.empty? && block.nil?
|
77
77
|
|
78
78
|
set(key, value[0], &block)
|
79
79
|
end
|
@@ -43,6 +43,7 @@ module Bridgetown
|
|
43
43
|
"autoload_paths" => [],
|
44
44
|
"eager_load_paths" => [],
|
45
45
|
"autoloader_collapsed_paths" => [],
|
46
|
+
"additional_watch_paths" => [],
|
46
47
|
"plugins_use_zeitwerk" => true,
|
47
48
|
|
48
49
|
# Handling Reading
|
@@ -129,7 +130,7 @@ module Bridgetown
|
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
132
|
-
def run_initializers!(context:)
|
133
|
+
def run_initializers!(context:) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
|
133
134
|
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
134
135
|
return unless File.file?(initializers_file)
|
135
136
|
|
@@ -143,9 +144,11 @@ module Bridgetown
|
|
143
144
|
Bridgetown.logger.debug "Initializing:", "Running initializers with `#{context}' context in:"
|
144
145
|
Bridgetown.logger.debug "", initializers_file
|
145
146
|
self.init_params = {}
|
147
|
+
cached_url = url&.include?("//localhost") ? url : nil
|
146
148
|
dsl = ConfigurationDSL.new(scope: self, data: self)
|
147
149
|
dsl.instance_variable_set(:@context, context)
|
148
150
|
dsl.instance_exec(dsl, &init_init.block)
|
151
|
+
self.url = cached_url if cached_url # restore local development URL if need be
|
149
152
|
|
150
153
|
setup_load_paths! appending: true
|
151
154
|
|
@@ -307,7 +310,8 @@ module Bridgetown
|
|
307
310
|
next_config
|
308
311
|
rescue SystemCallError
|
309
312
|
if @default_config_file ||= nil
|
310
|
-
|
313
|
+
initializers_file = File.join(root_dir, "config", "initializers.rb")
|
314
|
+
Bridgetown.logger.warn "Configuration file:", "none" unless File.file?(initializers_file)
|
311
315
|
{}
|
312
316
|
else
|
313
317
|
Bridgetown.logger.error "Fatal:", "The configuration file '#{file}' could not be found."
|
@@ -353,6 +357,10 @@ module Bridgetown
|
|
353
357
|
File.expand_path(collapsed_path, root_dir)
|
354
358
|
end
|
355
359
|
|
360
|
+
additional_watch_paths.map! do |collapsed_path|
|
361
|
+
File.expand_path(collapsed_path, root_dir)
|
362
|
+
end
|
363
|
+
|
356
364
|
self
|
357
365
|
end
|
358
366
|
|
@@ -395,7 +403,7 @@ module Bridgetown
|
|
395
403
|
|
396
404
|
DEFAULT_EXCLUDES = %w(
|
397
405
|
.sass-cache .bridgetown-cache
|
398
|
-
gemfiles Gemfile Gemfile.lock
|
406
|
+
gemfiles Gemfile Gemfile.lock gems.rb gems.locked
|
399
407
|
node_modules
|
400
408
|
vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/
|
401
409
|
).freeze
|
@@ -11,7 +11,7 @@ unless File.exist?("postcss.config.js")
|
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
14
|
-
confirm = ask "This configuration will
|
14
|
+
confirm = ask "This configuration will overwrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
|
15
15
|
return unless confirm.casecmp?("Y")
|
16
16
|
|
17
17
|
plugins = %w(postcss-mixins postcss-color-mod-function cssnano)
|
@@ -6,7 +6,7 @@ on:
|
|
6
6
|
- main
|
7
7
|
|
8
8
|
jobs:
|
9
|
-
|
9
|
+
build:
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
steps:
|
12
12
|
- uses: actions/checkout@v2
|
@@ -26,10 +26,26 @@ jobs:
|
|
26
26
|
- name: Build
|
27
27
|
env:
|
28
28
|
BRIDGETOWN_ENV: production
|
29
|
-
run:
|
29
|
+
run: bin/bridgetown deploy
|
30
30
|
|
31
|
-
- name:
|
32
|
-
uses:
|
31
|
+
- name: Upload build artifact
|
32
|
+
uses: actions/upload-pages-artifact@v1
|
33
33
|
with:
|
34
|
-
|
35
|
-
|
34
|
+
path: ./output
|
35
|
+
|
36
|
+
deploy:
|
37
|
+
needs: build
|
38
|
+
|
39
|
+
permissions:
|
40
|
+
pages: write
|
41
|
+
id-token: write
|
42
|
+
|
43
|
+
environment:
|
44
|
+
name: github-pages
|
45
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
46
|
+
|
47
|
+
runs-on: ubuntu-latest
|
48
|
+
steps:
|
49
|
+
- name: Deploy to GitHub Pages
|
50
|
+
id: deployment
|
51
|
+
uses: actions/deploy-pages@v1
|
@@ -7,7 +7,7 @@ copy_file in_templates_dir("gh-pages.yml"), ".github/workflows/gh-pages.yml"
|
|
7
7
|
say "🎉 A GitHub action to deploy your site to GitHub pages has been configured!"
|
8
8
|
say ""
|
9
9
|
|
10
|
-
say "🛠️ After pushing the action, go to your repository settings and configure GitHub Pages to deploy from
|
10
|
+
say "🛠️ After pushing the action, go to your repository settings and configure GitHub Pages to deploy from GitHub Actions."
|
11
11
|
say ""
|
12
12
|
|
13
13
|
say "You'll likely also need to set `base_path` in your `bridgetown.config.yml` to your repository's name. If you do this you'll need to use the `relative_url` helper for all links and assets in your HTML."
|
@@ -38,7 +38,7 @@ gsub_file "esbuild.config.js", %r{const esbuildOptions = {}\n} do |_match|
|
|
38
38
|
// Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
|
39
39
|
/*
|
40
40
|
postCssPluginConfig: {
|
41
|
-
filter: /(?:index
|
41
|
+
filter: /(?:index|\\.global)\\.css$/,
|
42
42
|
},
|
43
43
|
*/
|
44
44
|
}
|
@@ -59,7 +59,7 @@ unless found_match
|
|
59
59
|
// Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
|
60
60
|
/*
|
61
61
|
postCssPluginConfig: {
|
62
|
-
filter: /(?:index
|
62
|
+
filter: /(?:index|\\.global)\\.css$/,
|
63
63
|
},
|
64
64
|
*/
|
65
65
|
JS
|
@@ -36,7 +36,7 @@ append_to_file(File.join(javascript_dir, "index.js")) do
|
|
36
36
|
Object.entries(controllers).forEach(([filename, controller]) => {
|
37
37
|
if (filename.includes("_controller.") || filename.includes("-controller.")) {
|
38
38
|
const identifier = filename.replace("./controllers/", "")
|
39
|
-
.replace(/[_
|
39
|
+
.replace(/[_-]controller\\..*$/, "")
|
40
40
|
.replace("_", "-")
|
41
41
|
.replace("/", "--")
|
42
42
|
|
@@ -48,7 +48,7 @@ append_to_file(File.join(javascript_dir, "index.js")) do
|
|
48
48
|
<<~JS
|
49
49
|
|
50
50
|
window.Stimulus = Application.start()
|
51
|
-
const context = require.context("./controllers", true,
|
51
|
+
const context = require.context("./controllers", true, /\\.js$/)
|
52
52
|
Stimulus.load(definitionsFromContext(context))
|
53
53
|
JS
|
54
54
|
end
|
@@ -184,7 +184,7 @@ module Bridgetown
|
|
184
184
|
if block_given?
|
185
185
|
self[key] = yield key, self[key], other[key]
|
186
186
|
else
|
187
|
-
if Utils.
|
187
|
+
if Utils.mergeable?(self[key]) && Utils.mergeable?(other[key])
|
188
188
|
self[key] = Utils.deep_merge_hashes(self[key], other[key])
|
189
189
|
next
|
190
190
|
end
|
@@ -4,7 +4,7 @@ module Bridgetown
|
|
4
4
|
module Drops
|
5
5
|
class StaticFileDrop < Drop
|
6
6
|
extend Forwardable
|
7
|
-
def_delegators :@obj, :name, :extname, :modified_time, :basename
|
7
|
+
def_delegators :@obj, :name, :extname, :date, :modified_time, :basename
|
8
8
|
def_delegator :@obj, :relative_path, :path
|
9
9
|
def_delegator :@obj, :type, :collection
|
10
10
|
|
@@ -59,11 +59,11 @@ module Bridgetown
|
|
59
59
|
# `url` or `relative_url`
|
60
60
|
# @return [String] the permalink URL for the file
|
61
61
|
def url_for(relative_path)
|
62
|
-
if relative_path.respond_to?(:relative_url)
|
62
|
+
if relative_path.respond_to?(:relative_url)
|
63
63
|
return safe(relative_path.relative_url) # new resource engine
|
64
64
|
elsif relative_path.respond_to?(:url)
|
65
65
|
return safe(relative_url(relative_path.url)) # old legacy engine
|
66
|
-
elsif relative_path.to_s.start_with?("/", "http")
|
66
|
+
elsif relative_path.to_s.start_with?("/", "http", "#", "mailto:", "tel:")
|
67
67
|
return safe(relative_path)
|
68
68
|
end
|
69
69
|
|
@@ -97,7 +97,13 @@ module Bridgetown
|
|
97
97
|
# @param options [Hash] key-value pairs of HTML attributes to add to the tag
|
98
98
|
# @return [String] the anchor tag HTML
|
99
99
|
# @raise [ArgumentError] if the file cannot be found
|
100
|
-
def link_to(text, relative_path, options = {})
|
100
|
+
def link_to(text, relative_path = nil, options = {})
|
101
|
+
if block_given?
|
102
|
+
relative_path = text
|
103
|
+
text = yield
|
104
|
+
elsif relative_path.nil?
|
105
|
+
raise ArgumentError, "You must provide a relative path"
|
106
|
+
end
|
101
107
|
segments = attributes_from_options({ href: url_for(relative_path) }.merge(options))
|
102
108
|
|
103
109
|
safe("<a #{segments}>#{text}</a>")
|
@@ -111,7 +111,7 @@ module Bridgetown
|
|
111
111
|
collection.data?
|
112
112
|
end
|
113
113
|
|
114
|
-
def read_file_data # rubocop:todo Metrics/MethodLength
|
114
|
+
def read_file_data # rubocop:todo Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize
|
115
115
|
case original_path.extname.downcase
|
116
116
|
when ".csv"
|
117
117
|
{
|
@@ -130,6 +130,9 @@ module Bridgetown
|
|
130
130
|
}
|
131
131
|
when ".rb"
|
132
132
|
process_ruby_data(File.read(original_path), original_path, 1)
|
133
|
+
when ".json"
|
134
|
+
json_data = JSON.parse(File.read(original_path))
|
135
|
+
json_data.is_a?(Array) ? { rows: json_data } : json_data
|
133
136
|
else
|
134
137
|
yaml_data = YAMLParser.load_file(original_path)
|
135
138
|
yaml_data.is_a?(Array) ? { rows: yaml_data } : yaml_data
|
@@ -61,7 +61,8 @@ module Bridgetown
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.setup_bundler(skip_yarn: false)
|
64
|
-
if !ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] &&
|
64
|
+
if !ENV["BRIDGETOWN_NO_BUNDLER_REQUIRE"] &&
|
65
|
+
(Bundler::SharedHelpers.in_bundle? || Bridgetown.env.test?)
|
65
66
|
require "bundler"
|
66
67
|
|
67
68
|
require_relative "utils/initializers"
|
@@ -14,10 +14,10 @@ Roda::RodaPlugins::Public::RequestMethods.module_eval do
|
|
14
14
|
seg == ".." ? segments.pop : segments << seg
|
15
15
|
end
|
16
16
|
|
17
|
-
path =
|
18
|
-
unless
|
19
|
-
path =
|
20
|
-
if
|
17
|
+
path = File.join(roda_class.opts[:public_root], *segments)
|
18
|
+
unless File.file?(path)
|
19
|
+
path = File.join(path, "index.html")
|
20
|
+
if File.file?(path)
|
21
21
|
segments << "index.html"
|
22
22
|
else
|
23
23
|
segments[segments.size - 1] = "#{segments.last}.html"
|
@@ -373,7 +373,7 @@ module Bridgetown
|
|
373
373
|
found_locale = data.language || data.lang || basename_without_ext.split(".")[1..].last
|
374
374
|
return unless found_locale && site.config.available_locales.include?(found_locale.to_sym)
|
375
375
|
|
376
|
-
found_locale
|
376
|
+
found_locale.to_sym
|
377
377
|
end
|
378
378
|
|
379
379
|
def format_url(url)
|
@@ -73,6 +73,8 @@ module Bridgetown
|
|
73
73
|
@modified_time ||= File.stat(path).mtime
|
74
74
|
end
|
75
75
|
|
76
|
+
alias_method :date, :modified_time
|
77
|
+
|
76
78
|
# Returns last modification time for this file.
|
77
79
|
def mtime
|
78
80
|
modified_time.to_i
|
@@ -119,12 +121,12 @@ module Bridgetown
|
|
119
121
|
@to_liquid ||= Drops::StaticFileDrop.new(self)
|
120
122
|
end
|
121
123
|
|
122
|
-
# Generate "basename without extension" and strip away any trailing periods.
|
123
|
-
# NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`)
|
124
124
|
def basename
|
125
|
-
@basename ||= File.basename(name,
|
125
|
+
@basename ||= File.basename(name, ".*")
|
126
126
|
end
|
127
127
|
|
128
|
+
alias_method :basename_without_ext, :basename
|
129
|
+
|
128
130
|
def relative_path_basename_without_prefix
|
129
131
|
return_path = Pathname.new("")
|
130
132
|
Pathname.new(cleaned_relative_path).each_filename do |filename|
|
@@ -185,7 +187,7 @@ module Bridgetown
|
|
185
187
|
|
186
188
|
# Returns the type of the collection if present, nil otherwise.
|
187
189
|
def type
|
188
|
-
@type ||= @collection
|
190
|
+
@type ||= @collection&.label&.to_sym
|
189
191
|
end
|
190
192
|
|
191
193
|
# Returns the front matter defaults defined for the file's URL and/or type
|
@@ -11,7 +11,7 @@ namespace :frontend do
|
|
11
11
|
task :watcher, :sidecar do |_task, args|
|
12
12
|
# sidecar is when the task is running alongside the start command
|
13
13
|
sidecar = args[:sidecar] == true
|
14
|
-
Bridgetown::Utils::Aux.run_process "Frontend", :yellow, "
|
14
|
+
Bridgetown::Utils::Aux.run_process "Frontend", :yellow, "bridgetown frontend:dev"
|
15
15
|
|
16
16
|
if sidecar
|
17
17
|
# give FE bundler time to boot before returning control to the start command
|
@@ -14,9 +14,9 @@ module Bridgetown
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def method_missing(key, *value, &block) # rubocop:disable Metrics/CyclomaticComplexity, Style/MissingRespondToMissing
|
17
|
-
return super if respond_to?(key) || (value.
|
17
|
+
return super if respond_to?(key) || (value.empty? && block.nil? && !@data.key?(key))
|
18
18
|
|
19
|
-
return get(key) if value.
|
19
|
+
return get(key) if value.empty? && block.nil? && @data.key?(key)
|
20
20
|
|
21
21
|
set(key, value[0], &block)
|
22
22
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
module Utils # rubocop:todo Metrics/ModuleLength
|
5
|
+
extend Gem::Deprecate
|
5
6
|
extend self
|
6
7
|
autoload :Ansi, "bridgetown-core/utils/ansi"
|
7
8
|
autoload :Aux, "bridgetown-core/utils/aux"
|
@@ -62,9 +63,11 @@ module Bridgetown
|
|
62
63
|
target
|
63
64
|
end
|
64
65
|
|
65
|
-
def
|
66
|
+
def mergeable?(value)
|
66
67
|
value.is_a?(Hash) || value.is_a?(Drops::Drop)
|
67
68
|
end
|
69
|
+
alias_method :mergable?, :mergeable?
|
70
|
+
deprecate :mergable?, :mergeable?, 2023, 7
|
68
71
|
|
69
72
|
def duplicable?(obj)
|
70
73
|
case obj
|
@@ -449,10 +452,10 @@ module Bridgetown
|
|
449
452
|
def default_github_branch_name(repo_url)
|
450
453
|
repo_match = Bridgetown::Commands::Actions::GITHUB_REPO_REGEX.match(repo_url)
|
451
454
|
api_endpoint = "https://api.github.com/repos/#{repo_match[1]}"
|
452
|
-
JSON.parse(Faraday.get(api_endpoint).body)["default_branch"] || "
|
455
|
+
JSON.parse(Faraday.get(api_endpoint).body)["default_branch"] || "main"
|
453
456
|
rescue StandardError => e
|
454
457
|
Bridgetown.logger.warn("Unable to connect to GitHub API: #{e.message}")
|
455
|
-
"
|
458
|
+
"main"
|
456
459
|
end
|
457
460
|
|
458
461
|
def live_reload_js(site) # rubocop:disable Metrics/MethodLength
|
@@ -508,7 +511,7 @@ module Bridgetown
|
|
508
511
|
target.merge!(overwrite) do |_key, old_val, new_val|
|
509
512
|
if new_val.nil?
|
510
513
|
old_val
|
511
|
-
elsif
|
514
|
+
elsif mergeable?(old_val) && mergeable?(new_val)
|
512
515
|
deep_merge_hashes(old_val, new_val)
|
513
516
|
else
|
514
517
|
new_val
|
@@ -42,7 +42,12 @@ module Bridgetown
|
|
42
42
|
#
|
43
43
|
# @param (see #watch)
|
44
44
|
def load_paths_to_watch(site, options)
|
45
|
-
|
45
|
+
additional_paths = options.additional_watch_paths
|
46
|
+
[
|
47
|
+
*site.plugin_manager.plugins_path,
|
48
|
+
*options.autoload_paths,
|
49
|
+
*additional_paths,
|
50
|
+
].uniq.select do |path|
|
46
51
|
Dir.exist?(path)
|
47
52
|
end
|
48
53
|
end
|
data/lib/bridgetown-core.rb
CHANGED
@@ -16,6 +16,7 @@ end
|
|
16
16
|
|
17
17
|
# rubygems
|
18
18
|
require "rubygems"
|
19
|
+
require "bundler/shared_helpers"
|
19
20
|
|
20
21
|
# stdlib
|
21
22
|
require "find"
|
@@ -230,11 +231,13 @@ module Bridgetown
|
|
230
231
|
|
231
232
|
def load_tasks
|
232
233
|
require "bridgetown-core/commands/base"
|
234
|
+
unless Bridgetown::Current.preloaded_configuration
|
235
|
+
Bridgetown::Current.preloaded_configuration = Bridgetown::Configuration::Preflight.new
|
236
|
+
end
|
233
237
|
Bridgetown::PluginManager.setup_bundler(skip_yarn: true)
|
238
|
+
|
234
239
|
if Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration::Preflight)
|
235
240
|
Bridgetown::Current.preloaded_configuration = Bridgetown.configuration
|
236
|
-
else
|
237
|
-
Bridgetown::Current.preloaded_configuration ||= Bridgetown.configuration
|
238
241
|
end
|
239
242
|
load File.expand_path("bridgetown-core/tasks/bridgetown_tasks.rake", __dir__)
|
240
243
|
end
|
@@ -39,5 +39,5 @@ Bridgetown.configure do |config|
|
|
39
39
|
#
|
40
40
|
|
41
41
|
# For more documentation on how to configure your site using this initializers file,
|
42
|
-
# visit: https://edge.bridgetownrb.com/
|
42
|
+
# visit: https://edge.bridgetownrb.com/docs/configuration/initializers/
|
43
43
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# Puma is a fast, concurrent web server for Ruby & Rack
|
2
2
|
#
|
3
3
|
# Learn more at: https://puma.io
|
4
|
+
# Bridgetown configuration documentation:
|
5
|
+
# https://edge.bridgetownrb.com/docs/configuration/puma
|
6
|
+
|
7
|
+
# This port number can be overriden by a bind configuration option
|
4
8
|
#
|
5
9
|
port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
|
6
10
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<%- if frontend_bundling_option == "webpack" -%>
|
16
16
|
"css-loader": "^6.7.1",
|
17
17
|
<%- end -%>
|
18
|
-
"esbuild": "^0.
|
18
|
+
"esbuild": "^0.15.12",
|
19
19
|
<%- if frontend_bundling_option == "webpack" -%>
|
20
20
|
"esbuild-loader": "^2.18.0",
|
21
21
|
"mini-css-extract-plugin": "^2.6.0",
|
@@ -31,7 +31,10 @@
|
|
31
31
|
<%- else -%>
|
32
32
|
"postcss-loader": "^6.2.1",
|
33
33
|
<%- end -%>
|
34
|
-
"postcss-preset-env": "^7.4.3"
|
34
|
+
"postcss-preset-env": "^7.4.3",
|
35
|
+
<%- if frontend_bundling_option == "esbuild" -%>
|
36
|
+
"read-cache": "^1.0.0"<%= "," unless postcss_option %>
|
37
|
+
<%- end -%>
|
35
38
|
<%- end -%>
|
36
39
|
<%- unless postcss_option -%>
|
37
40
|
"sass": "^1.50.1",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|