bridgetown-core 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +1 -0
- data/lib/bridgetown-core/commands/console.rb +10 -2
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +12 -7
- data/lib/bridgetown-core/concerns/localizable.rb +13 -1
- data/lib/bridgetown-core/configurations/netlify/netlify.sh +2 -3
- data/lib/bridgetown-core/configurations/netlify/netlify.toml +1 -12
- data/lib/bridgetown-core/generated_page.rb +1 -1
- data/lib/bridgetown-core/log_writer.rb +3 -9
- data/lib/bridgetown-core/plugin_manager.rb +24 -2
- data/lib/bridgetown-core/rack/boot.rb +13 -2
- data/lib/bridgetown-core/resource/base.rb +1 -1
- data/lib/bridgetown-core/resource/relations.rb +1 -1
- data/lib/bridgetown-core/utils/loaders_manager.rb +1 -3
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/yaml_parser.rb +15 -4
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 556799feca958f64e151dff3c039cc98240bc611a60cf650e3658f50490dcf79
|
4
|
+
data.tar.gz: 74bed3c07355d9b54107ce92334a0cf32a4d8909dd002efdeb4cbf6b0a729128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8617f84687052ac6ed4b2413bbb4418fc3a332395fd647902379e75e4d22857d43a49edb30b8dbbb8aad7fe067412ad6c397fe0a05fd73ab5b3d3ea6866a7c55
|
7
|
+
data.tar.gz: 6c60464867cfb5fe8baf9e86d983a5392075a92f278f30499c68e1a1dec58b3be53991b7725b31de0c445f4afd448ca0056aa1841ecce79b2daa857c5cb43f6f
|
data/bridgetown-core.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_runtime_dependency("addressable", "~> 2.4")
|
37
37
|
s.add_runtime_dependency("amazing_print", "~> 1.2")
|
38
38
|
s.add_runtime_dependency("colorator", "~> 1.0")
|
39
|
+
s.add_runtime_dependency("csv", "~> 3.2")
|
39
40
|
s.add_runtime_dependency("erubi", "~> 1.9")
|
40
41
|
s.add_runtime_dependency("faraday", "~> 2.0")
|
41
42
|
s.add_runtime_dependency("faraday-follow_redirects", "~> 0.3")
|
@@ -66,9 +66,15 @@ module Bridgetown
|
|
66
66
|
type: :boolean,
|
67
67
|
desc: "Print verbose output."
|
68
68
|
|
69
|
-
def console
|
69
|
+
def console # rubocop:disable Metrics
|
70
70
|
require "irb"
|
71
|
-
|
71
|
+
new_history_behavior = false
|
72
|
+
begin
|
73
|
+
require "irb/ext/save-history"
|
74
|
+
rescue LoadError
|
75
|
+
# Code path for Ruby 3.3+
|
76
|
+
new_history_behavior = true
|
77
|
+
end
|
72
78
|
require "amazing_print" unless options[:"bypass-ap"]
|
73
79
|
|
74
80
|
Bridgetown.logger.adjust_verbosity(options)
|
@@ -96,6 +102,7 @@ module Bridgetown
|
|
96
102
|
irb = IRB::Irb.new(workspace)
|
97
103
|
IRB.conf[:IRB_RC]&.call(irb.context)
|
98
104
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
105
|
+
irb.context.io.load_history if new_history_behavior
|
99
106
|
Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
|
100
107
|
Bridgetown.logger.info "",
|
101
108
|
"You can also access #{"collections".cyan} or perform a " \
|
@@ -117,6 +124,7 @@ module Bridgetown
|
|
117
124
|
end
|
118
125
|
ensure
|
119
126
|
IRB.conf[:AT_EXIT].each(&:call)
|
127
|
+
irb.context.io.save_history if new_history_behavior
|
120
128
|
end
|
121
129
|
end
|
122
130
|
end
|
@@ -128,14 +128,19 @@ const importPostCssPlugin = (options, configuration) => ({
|
|
128
128
|
})
|
129
129
|
|
130
130
|
// Process the file through PostCSS
|
131
|
-
|
132
|
-
|
133
|
-
...options.
|
134
|
-
|
135
|
-
|
136
|
-
|
131
|
+
let outputCSS = ""
|
132
|
+
try {
|
133
|
+
const result = await postcss([importPlugin, ...options.plugins]).process(css, {
|
134
|
+
map: true,
|
135
|
+
...options.options,
|
136
|
+
from: args.path,
|
137
|
+
})
|
138
|
+
outputCSS = result.css
|
139
|
+
} catch(err) {
|
140
|
+
console.error(`\nerror: "${err.reason}" while processing CSS file:\n${err.file}:${err.line}:${err.column}\n`)
|
141
|
+
}
|
137
142
|
return {
|
138
|
-
contents:
|
143
|
+
contents: outputCSS,
|
139
144
|
loader: "css",
|
140
145
|
watchFiles: [args.path, ...additionalFilePaths],
|
141
146
|
}
|
@@ -13,12 +13,24 @@ module Bridgetown
|
|
13
13
|
end
|
14
14
|
|
15
15
|
matching_resources = result_set.select do |item|
|
16
|
-
item
|
16
|
+
matches_resource?(item)
|
17
17
|
end
|
18
18
|
|
19
19
|
matching_resources.sort_by do |item|
|
20
20
|
site.config.available_locales.index item.data.locale
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
def matches_resource?(item)
|
25
|
+
if item.relative_path.is_a?(String)
|
26
|
+
item.localeless_path == localeless_path
|
27
|
+
else
|
28
|
+
item.relative_path.parent == relative_path.parent
|
29
|
+
end && item.data.slug == data.slug
|
30
|
+
end
|
31
|
+
|
32
|
+
def localeless_path
|
33
|
+
relative_path.gsub(%r{\A#{data.locale}/}, "")
|
34
|
+
end
|
23
35
|
end
|
24
36
|
end
|
@@ -3,12 +3,11 @@
|
|
3
3
|
|
4
4
|
echo "Updating netlify.toml with references to our built files"
|
5
5
|
|
6
|
-
CSS_PATH=`find output/_bridgetown/static
|
7
|
-
JS_PATH=`find output/_bridgetown/static
|
6
|
+
CSS_PATH=`find output/_bridgetown/static/*.css -type f | sed -e 's,output\/,/,g'`
|
7
|
+
JS_PATH=`find output/_bridgetown/static/*.js -type f | sed -e 's,output\/,/,g'`
|
8
8
|
|
9
9
|
echo "CSS Path: ${CSS_PATH}"
|
10
10
|
echo "JS Path: ${JS_PATH}"
|
11
11
|
|
12
12
|
sed -i s,CSS_PATH,${CSS_PATH},g netlify.toml
|
13
13
|
sed -i s,JS_PATH,${JS_PATH},g netlify.toml
|
14
|
-
sed -i s,NETLIFY_IMAGES_CDN_DOMAIN,${NETLIFY_IMAGES_CDN_DOMAIN},g netlify.toml
|
@@ -6,18 +6,8 @@
|
|
6
6
|
NODE_ENV = "development"
|
7
7
|
BRIDGETOWN_ENV = "production"
|
8
8
|
|
9
|
-
[build.processing]
|
10
|
-
skip_processing = false
|
11
|
-
[build.processing.css]
|
12
|
-
bundle = false
|
13
|
-
minify = true
|
14
|
-
[build.processing.js]
|
15
|
-
bundle = false
|
16
|
-
minify = true
|
17
9
|
[build.processing.html]
|
18
10
|
pretty_urls = true
|
19
|
-
[build.processing.images]
|
20
|
-
compress = true
|
21
11
|
|
22
12
|
[[headers]]
|
23
13
|
for = "*"
|
@@ -34,8 +24,7 @@
|
|
34
24
|
[headers.values]
|
35
25
|
Link = [
|
36
26
|
"<CSS_PATH>; rel=preload; as=style",
|
37
|
-
"<JS_PATH>; rel=preload; as=script"
|
38
|
-
"<https://NETLIFY_IMAGES_CDN_DOMAIN>; rel=preconnect"
|
27
|
+
"<JS_PATH>; rel=preload; as=script"
|
39
28
|
]
|
40
29
|
|
41
30
|
[[headers]]
|
@@ -2,18 +2,12 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class LogWriter < ::Logger
|
5
|
-
def initialize
|
6
|
-
|
7
|
-
@level = DEBUG
|
8
|
-
@default_formatter = Formatter.new
|
9
|
-
@logdev = $stdout
|
10
|
-
@formatter = proc do |_, _, _, msg|
|
11
|
-
msg.to_s
|
12
|
-
end
|
5
|
+
def initialize
|
6
|
+
super($stdout, formatter: proc { |_, _, _, msg| msg.to_s })
|
13
7
|
end
|
14
8
|
|
15
9
|
def enable_prefix
|
16
|
-
|
10
|
+
self.formatter = proc do |_, _, _, msg|
|
17
11
|
"\e[32m[Bridgetown]\e[0m #{msg}"
|
18
12
|
end
|
19
13
|
end
|
@@ -129,6 +129,24 @@ module Bridgetown
|
|
129
129
|
"Required #{required_gems.map(&:name).join(", ")}")
|
130
130
|
end
|
131
131
|
|
132
|
+
def self.package_manager
|
133
|
+
@package_manager ||= if File.exist?("yarn.lock")
|
134
|
+
"yarn"
|
135
|
+
elsif File.exist?("package-lock.json")
|
136
|
+
"npm"
|
137
|
+
elsif File.exist?("pnpm-lock.yaml")
|
138
|
+
"pnpm"
|
139
|
+
else
|
140
|
+
""
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.package_manager_install_command
|
145
|
+
package_manager == "npm" ? "install" : "add"
|
146
|
+
end
|
147
|
+
|
148
|
+
# rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
149
|
+
|
132
150
|
# Iterates through loaded gems and finds yard-add gemspec metadata.
|
133
151
|
# If that exact package hasn't been installed, execute yarn add
|
134
152
|
#
|
@@ -146,18 +164,22 @@ module Bridgetown
|
|
146
164
|
required_gems
|
147
165
|
end
|
148
166
|
|
167
|
+
# all right, time to install the package
|
149
168
|
gems_to_search.each do |loaded_gem|
|
150
169
|
yarn_dependency = find_yarn_dependency(loaded_gem)
|
151
170
|
next unless add_yarn_dependency?(yarn_dependency, package_json)
|
152
171
|
|
153
|
-
|
154
|
-
|
172
|
+
next if package_manager.empty?
|
173
|
+
|
174
|
+
cmd = "#{package_manager} #{package_manager_install_command} #{yarn_dependency.join("@")}"
|
155
175
|
system cmd
|
156
176
|
end
|
157
177
|
|
158
178
|
gems_to_search
|
159
179
|
end
|
160
180
|
|
181
|
+
# rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
182
|
+
|
161
183
|
def self.find_yarn_dependency(loaded_gem)
|
162
184
|
yarn_dependency = loaded_gem.to_spec&.metadata&.dig("yarn-add")&.match(YARN_DEPENDENCY_REGEXP)
|
163
185
|
return nil if yarn_dependency&.length != 3 || yarn_dependency[2] == ""
|
@@ -48,7 +48,7 @@ module Bridgetown
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# @param root [String] root of Bridgetown site, defaults to config value
|
51
|
-
def self.autoload_server_folder( # rubocop:todo Metrics
|
51
|
+
def self.autoload_server_folder( # rubocop:todo Metrics
|
52
52
|
root: Bridgetown::Current.preloaded_configuration.root_dir
|
53
53
|
)
|
54
54
|
server_folder = File.join(root, "server")
|
@@ -62,7 +62,18 @@ module Bridgetown
|
|
62
62
|
loader.do_not_eager_load(File.join(server_folder, "roda_app.rb"))
|
63
63
|
|
64
64
|
unless ENV["BRIDGETOWN_ENV"] == "production"
|
65
|
-
Listen.to(server_folder) do |
|
65
|
+
Listen.to(server_folder) do |modified, added, removed|
|
66
|
+
c = modified + added + removed
|
67
|
+
n = c.length
|
68
|
+
|
69
|
+
Bridgetown.logger.info(
|
70
|
+
"Reloading…",
|
71
|
+
"#{n} file#{"s" if n > 1} changed at #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
|
72
|
+
)
|
73
|
+
c.each do |path|
|
74
|
+
Bridgetown.logger.info "", "- #{path["#{File.dirname(server_folder)}/".length..]}"
|
75
|
+
end
|
76
|
+
|
66
77
|
loader.reload
|
67
78
|
loader.eager_load
|
68
79
|
Bridgetown::Rack::Routes.reload_subclasses
|
@@ -349,7 +349,7 @@ module Bridgetown
|
|
349
349
|
end
|
350
350
|
|
351
351
|
def import_taxonomies_from_data
|
352
|
-
taxonomies.
|
352
|
+
taxonomies.each_value do |metadata|
|
353
353
|
Array(data[metadata.type.key]).each do |term|
|
354
354
|
metadata.terms << TaxonomyTerm.new(
|
355
355
|
resource: self, label: term, type: metadata.type
|
@@ -24,7 +24,7 @@ module Bridgetown
|
|
24
24
|
def relation_types
|
25
25
|
@relation_types ||= begin
|
26
26
|
types = []
|
27
|
-
relation_schema&.
|
27
|
+
relation_schema&.each_value do |collections|
|
28
28
|
types << collections
|
29
29
|
types << Array(collections).map { |item| ActiveSupport::Inflector.pluralize(item) }
|
30
30
|
end
|
@@ -6,12 +6,23 @@ module Bridgetown
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def load_file(filename, **kwargs)
|
9
|
-
|
10
|
-
YAML.safe_load_file(filename, **kwargs)
|
9
|
+
YAML.safe_load_file filename, **merge_permitted_classes(kwargs)
|
11
10
|
end
|
12
11
|
|
13
|
-
def load(yaml)
|
14
|
-
YAML.safe_load yaml,
|
12
|
+
def load(yaml, **kwargs)
|
13
|
+
YAML.safe_load yaml, **merge_permitted_classes(kwargs)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def merge_permitted_classes(kwargs)
|
19
|
+
if kwargs.key?(:permitted_classes)
|
20
|
+
kwargs[:permitted_classes] |= PERMITTED_CLASSES
|
21
|
+
else
|
22
|
+
kwargs[:permitted_classes] = PERMITTED_CLASSES
|
23
|
+
end
|
24
|
+
|
25
|
+
kwargs
|
15
26
|
end
|
16
27
|
end
|
17
28
|
end
|
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.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '1.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: csv
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.2'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.2'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: erubi
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -578,7 +592,7 @@ metadata:
|
|
578
592
|
changelog_uri: https://github.com/bridgetownrb/bridgetown/releases
|
579
593
|
homepage_uri: https://www.bridgetownrb.com
|
580
594
|
rubygems_mfa_required: 'true'
|
581
|
-
post_install_message:
|
595
|
+
post_install_message:
|
582
596
|
rdoc_options:
|
583
597
|
- "--charset=UTF-8"
|
584
598
|
require_paths:
|
@@ -594,8 +608,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
594
608
|
- !ruby/object:Gem::Version
|
595
609
|
version: '0'
|
596
610
|
requirements: []
|
597
|
-
rubygems_version: 3.
|
598
|
-
signing_key:
|
611
|
+
rubygems_version: 3.2.33
|
612
|
+
signing_key:
|
599
613
|
specification_version: 4
|
600
614
|
summary: A next-generation, progressive site generator & fullstack framework, powered
|
601
615
|
by Ruby
|