bridgetown-core 1.3.3 → 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 +10 -7
- 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 +5 -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 +106 -65
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 390375353b8c9d8064d5ae48c531c73337cb0b55eec6d803e11e327244a6d39f
|
4
|
+
data.tar.gz: 820fbb87dde20f864e6928038310fe5d18bfb4d0490c47e35fcce56843287bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54b13230360699dd9162a1d525b61b0af97e010479016e90b1b75bd798111617f0975e6ea73b7d4e22e13fa91db6cb426887118f203627dbd25c214709ade2b
|
7
|
+
data.tar.gz: dae2470b585eb7ee3cdc2a6b5a9926420a1f47ba09f5f7f7e552c1b037e15067a19b5de84dbf65f5fd02ddb2096f0e4c5e3e2fb9c0b9a88c3f1e683b25486d54
|
data/bin/bridgetown
CHANGED
@@ -5,12 +5,6 @@ STDOUT.sync = true
|
|
5
5
|
|
6
6
|
$LOAD_PATH.unshift File.expand_path("../../bridgetown/lib", __dir__)
|
7
7
|
|
8
|
-
# Used by commands/automations
|
9
|
-
require "active_support"
|
10
|
-
require "active_support/core_ext/array/extract_options"
|
11
|
-
require "active_support/core_ext/string/strip"
|
12
|
-
require "active_support/core_ext/string/indent"
|
13
|
-
|
14
8
|
require "bridgetown"
|
15
9
|
|
16
10
|
# Support NO_COLOR: https://no-color.org
|
data/bin/bt
ADDED
data/bridgetown-core.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
16
|
f.match(%r!^(benchmark|features|script|test)/!)
|
17
17
|
end
|
18
|
-
s.executables = ["bridgetown"]
|
18
|
+
s.executables = ["bridgetown", "bt"] # `bt` is a shortcut to `bridgetown` command
|
19
19
|
s.bindir = "bin"
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
@@ -29,27 +29,30 @@ Gem::Specification.new do |s|
|
|
29
29
|
|
30
30
|
s.rdoc_options = ["--charset=UTF-8"]
|
31
31
|
|
32
|
-
s.required_ruby_version = ">=
|
32
|
+
s.required_ruby_version = ">= 3.1.0"
|
33
33
|
|
34
|
-
s.add_runtime_dependency("activemodel", [">= 6.0", "< 8.0"])
|
35
34
|
s.add_runtime_dependency("activesupport", [">= 6.0", "< 8.0"])
|
36
35
|
s.add_runtime_dependency("addressable", "~> 2.4")
|
37
36
|
s.add_runtime_dependency("amazing_print", "~> 1.2")
|
38
|
-
s.add_runtime_dependency("
|
37
|
+
s.add_runtime_dependency("bridgetown-foundation", Bridgetown::VERSION)
|
39
38
|
s.add_runtime_dependency("csv", "~> 3.2")
|
39
|
+
s.add_runtime_dependency("dry-inflector", ">= 1.0")
|
40
40
|
s.add_runtime_dependency("erubi", "~> 1.9")
|
41
41
|
s.add_runtime_dependency("faraday", "~> 2.0")
|
42
42
|
s.add_runtime_dependency("faraday-follow_redirects", "~> 0.3")
|
43
|
-
s.add_runtime_dependency("hash_with_dot_access", "~> 1.2")
|
44
43
|
s.add_runtime_dependency("i18n", "~> 1.0")
|
45
44
|
s.add_runtime_dependency("kramdown", "~> 2.1")
|
46
45
|
s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
|
47
|
-
s.add_runtime_dependency("liquid", "
|
46
|
+
s.add_runtime_dependency("liquid", [">= 5.0", "< 5.5"])
|
48
47
|
s.add_runtime_dependency("listen", "~> 3.0")
|
48
|
+
s.add_runtime_dependency("rack", ">= 3.0")
|
49
|
+
s.add_runtime_dependency("rackup", "~> 2.0")
|
49
50
|
s.add_runtime_dependency("rake", ">= 13.0")
|
50
51
|
s.add_runtime_dependency("roda", "~> 3.46")
|
51
52
|
s.add_runtime_dependency("rouge", [">= 3.0", "< 5.0"])
|
52
|
-
s.add_runtime_dependency("serbea", "~> 1
|
53
|
+
s.add_runtime_dependency("serbea", "~> 2.1")
|
54
|
+
s.add_runtime_dependency("signalize", "~> 1.3")
|
55
|
+
s.add_runtime_dependency("streamlined", ">= 0.5.2")
|
53
56
|
s.add_runtime_dependency("thor", "~> 1.1")
|
54
57
|
s.add_runtime_dependency("tilt", "~> 2.0")
|
55
58
|
s.add_runtime_dependency("zeitwerk", "~> 2.5")
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class Collection
|
5
|
+
using Bridgetown::Refinements
|
6
|
+
include Enumerable
|
7
|
+
|
5
8
|
# @return [Bridgetown::Site]
|
6
9
|
attr_reader :site
|
7
10
|
|
@@ -20,7 +23,7 @@ module Bridgetown
|
|
20
23
|
end
|
21
24
|
|
22
25
|
def builtin?
|
23
|
-
@is_builtin ||= label.
|
26
|
+
@is_builtin ||= label.within?(%w(posts pages data).freeze)
|
24
27
|
end
|
25
28
|
|
26
29
|
def data?
|
@@ -49,10 +52,10 @@ module Bridgetown
|
|
49
52
|
resources.group_by(&:relative_url).transform_values(&:first)
|
50
53
|
end
|
51
54
|
|
52
|
-
# Iterate over Resources
|
53
|
-
def each(
|
54
|
-
|
55
|
-
|
55
|
+
# Iterate over Resources, support Enumerable
|
56
|
+
def each(...) = resources.each(...)
|
57
|
+
|
58
|
+
def deconstruct = resources.deconstruct
|
56
59
|
|
57
60
|
# Fetch the static files in this collection.
|
58
61
|
# Defaults to an empty array if no static files have been read in.
|
@@ -62,11 +65,6 @@ module Bridgetown
|
|
62
65
|
@static_files ||= []
|
63
66
|
end
|
64
67
|
|
65
|
-
def files
|
66
|
-
Bridgetown::Deprecator.deprecation_message "Collection#files is now Collection#static_files"
|
67
|
-
static_files
|
68
|
-
end
|
69
|
-
|
70
68
|
# Read the allowed resources into the collection's array of resources.
|
71
69
|
#
|
72
70
|
# @return [Bridgetown::Collection] self
|
@@ -77,8 +75,7 @@ module Bridgetown
|
|
77
75
|
|
78
76
|
next if File.basename(file_path).starts_with?("_")
|
79
77
|
|
80
|
-
if label == "data" ||
|
81
|
-
Utils.has_rbfm_header?(full_path)
|
78
|
+
if label == "data" || FrontMatter::Loaders.front_matter?(full_path)
|
82
79
|
read_resource(full_path)
|
83
80
|
else
|
84
81
|
read_static_file(file_path, full_path)
|
@@ -212,10 +209,25 @@ module Bridgetown
|
|
212
209
|
!!metadata.fetch("output", false)
|
213
210
|
end
|
214
211
|
|
215
|
-
# Used by
|
212
|
+
# Used by Resources permalink processors
|
216
213
|
# @return [String]
|
217
214
|
def default_permalink
|
218
|
-
metadata.fetch("permalink",
|
215
|
+
metadata.fetch("permalink", default_configured_permalink)
|
216
|
+
end
|
217
|
+
|
218
|
+
# What the configured permalink should be absent of user overrides
|
219
|
+
# @return [String]
|
220
|
+
def default_configured_permalink
|
221
|
+
@default_configured_permalink ||= case label
|
222
|
+
when "data"
|
223
|
+
nil
|
224
|
+
when "posts"
|
225
|
+
site.config.permalink
|
226
|
+
when "pages"
|
227
|
+
"/:locale/:path/"
|
228
|
+
else
|
229
|
+
"/:locale/:collection/:path/"
|
230
|
+
end
|
219
231
|
end
|
220
232
|
|
221
233
|
# Extract options for this collection from the site configuration.
|
@@ -253,7 +265,7 @@ module Bridgetown
|
|
253
265
|
end
|
254
266
|
end
|
255
267
|
|
256
|
-
merge_environment_specific_metadata(data_contents).
|
268
|
+
merge_environment_specific_metadata(data_contents).as_dots
|
257
269
|
end
|
258
270
|
|
259
271
|
def merge_environment_specific_metadata(data_contents)
|
@@ -273,10 +285,10 @@ module Bridgetown
|
|
273
285
|
# @param manifest [Bridgetown::Configuration::SourceManifest]
|
274
286
|
# @return [void]
|
275
287
|
def read_resource(full_path, manifest: nil)
|
276
|
-
model_relative_path = relative_model_path_for(full_path, manifest:
|
288
|
+
model_relative_path = relative_model_path_for(full_path, manifest:)
|
277
289
|
model = Bridgetown::Model::Base.find(
|
278
|
-
model_id_from_relative_path(model_relative_path, manifest:
|
279
|
-
site:
|
290
|
+
model_id_from_relative_path(model_relative_path, manifest:),
|
291
|
+
site:
|
280
292
|
)
|
281
293
|
|
282
294
|
if model_is_multi_locale?(model, model_relative_path)
|
@@ -31,23 +31,22 @@ module Bridgetown
|
|
31
31
|
def build
|
32
32
|
Bridgetown.logger.adjust_verbosity(options)
|
33
33
|
|
34
|
-
unless caller_locations.find do |loc|
|
35
|
-
loc.to_s.include?("bridgetown-core/commands/start.rb")
|
36
|
-
end
|
37
|
-
self.class.print_startup_message
|
38
|
-
end
|
39
|
-
|
40
34
|
# @type [Bridgetown::Configuration]
|
41
35
|
config_options = configuration_with_overrides(
|
42
36
|
options, Bridgetown::Current.preloaded_configuration
|
43
37
|
)
|
44
38
|
|
45
|
-
|
39
|
+
self.class.print_startup_message unless config_options["start_command"]
|
46
40
|
|
47
|
-
|
41
|
+
Process.setproctitle(
|
42
|
+
"bridgetown #{Bridgetown::VERSION} " \
|
43
|
+
"(#{config_options["start_command"] ? "start" : "build"}) [#{File.basename(Dir.pwd)}]"
|
44
|
+
)
|
45
|
+
|
46
|
+
config_options.run_initializers! context: :static
|
48
47
|
|
49
48
|
if !Bridgetown.env.production? &&
|
50
|
-
!config_options[:skip_frontend] && config_options["
|
49
|
+
!config_options[:skip_frontend] && config_options["start_command"]
|
51
50
|
if Bridgetown::Utils.frontend_bundler_type(config_options[:root_dir]) == :esbuild
|
52
51
|
Bridgetown::Utils.update_esbuild_autogenerated_config config_options
|
53
52
|
end
|
@@ -67,6 +66,7 @@ module Bridgetown
|
|
67
66
|
build_site(config_options)
|
68
67
|
end
|
69
68
|
|
69
|
+
# TODO: remove this logic…I can't find "detach" anywhere
|
70
70
|
if config_options.fetch("detach", false)
|
71
71
|
Bridgetown.logger.info "Auto-regeneration:",
|
72
72
|
"disabled when running server detached."
|
@@ -95,19 +95,6 @@ module Bridgetown
|
|
95
95
|
@site.process
|
96
96
|
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than " \
|
97
97
|
"#{(Time.now - t).ceil(2)} seconds."
|
98
|
-
|
99
|
-
return unless config_options[:using_puma]
|
100
|
-
|
101
|
-
require "socket"
|
102
|
-
external_ip = Socket.ip_address_list.find do |ai|
|
103
|
-
ai.ipv4? && !ai.ipv4_loopback?
|
104
|
-
end&.ip_address
|
105
|
-
scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
106
|
-
port = config_options.bind&.split(":")&.last || ENV["BRIDGETOWN_PORT"] || 4000
|
107
|
-
Bridgetown.logger.info ""
|
108
|
-
Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
|
109
|
-
Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
|
110
|
-
Bridgetown.logger.info ""
|
111
98
|
end
|
112
99
|
|
113
100
|
# Watch for file changes and rebuild the site.
|
@@ -3,10 +3,12 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Commands
|
5
5
|
module Actions
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
using Bridgetown::Refinements
|
7
|
+
|
8
|
+
GITHUB_REGEX = %r!https://github\.com!
|
9
|
+
GITHUB_TREE_REGEX = %r!#{GITHUB_REGEX}/.*/.*/tree/.*/?!
|
10
|
+
GITHUB_BLOB_REGEX = %r!#{GITHUB_REGEX}/.*/.*/blob/!
|
11
|
+
GITHUB_REPO_REGEX = %r!github\.com/(.*?/[^/]*)!
|
10
12
|
|
11
13
|
def create_builder(filename, data = nil)
|
12
14
|
say_status :create_builder, filename
|
@@ -99,14 +101,19 @@ module Bridgetown
|
|
99
101
|
before: %r!^end$!, verbose: false, force: false
|
100
102
|
end
|
101
103
|
|
102
|
-
def
|
103
|
-
say_status :
|
104
|
+
def add_npm_for_gem(gemname)
|
105
|
+
say_status :add_npm, gemname
|
104
106
|
|
105
107
|
Bundler.reset!
|
106
108
|
Bridgetown::PluginManager.load_determined_bundler_environment
|
107
|
-
Bridgetown::PluginManager.
|
109
|
+
Bridgetown::PluginManager.install_npm_dependencies(name: gemname)
|
108
110
|
rescue SystemExit
|
109
|
-
say_status :
|
111
|
+
say_status :add_npm, "Package not added due to NPM error", :red
|
112
|
+
end
|
113
|
+
alias_method :add_yarn_for_gem, :add_npm_for_gem
|
114
|
+
|
115
|
+
def add_npm_package(package_details)
|
116
|
+
run "#{Bridgetown::PluginManager.package_manager} #{Bridgetown::PluginManager.package_manager_install_command} #{package_details}" # rubocop:disable Layout
|
110
117
|
end
|
111
118
|
|
112
119
|
def apply_from_url(url)
|
@@ -7,7 +7,7 @@ module Bridgetown
|
|
7
7
|
desc = "The environment used for this command (aka development, test, production, etc.)"
|
8
8
|
klass.class_option :environment,
|
9
9
|
aliases: "-e",
|
10
|
-
desc:
|
10
|
+
desc:
|
11
11
|
end
|
12
12
|
|
13
13
|
# Create a full Bridgetown configuration with the options passed in as overrides
|
@@ -95,6 +95,9 @@ module Bridgetown
|
|
95
95
|
workspace = IRB::WorkSpace.new
|
96
96
|
workspace.main.define_singleton_method(:site) { Bridgetown::Current.site }
|
97
97
|
workspace.main.define_singleton_method(:collections) { site.collections }
|
98
|
+
workspace.main.define_singleton_method(:helpers) do
|
99
|
+
Bridgetown::RubyTemplateView::Helpers.new
|
100
|
+
end
|
98
101
|
irb = IRB::Irb.new(workspace)
|
99
102
|
IRB.conf[:IRB_RC]&.call(irb.context)
|
100
103
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
@@ -97,11 +97,9 @@ module Bridgetown
|
|
97
97
|
|
98
98
|
def collect_urls(urls, things, destination)
|
99
99
|
things.each do |thing|
|
100
|
-
dest =
|
101
|
-
thing.destination(destination)
|
102
|
-
else
|
100
|
+
dest = thing.method(:destination).arity == 1 ?
|
101
|
+
thing.destination(destination) :
|
103
102
|
thing.destination
|
104
|
-
end
|
105
103
|
if urls[dest]
|
106
104
|
urls[dest] << thing.path
|
107
105
|
else
|
@@ -155,7 +155,7 @@ const sassPlugin = (options) => ({
|
|
155
155
|
// Process .scss and .sass files with Sass
|
156
156
|
build.onLoad({ filter: /\.(sass|scss)$/ }, async (args) => {
|
157
157
|
if (!sass) {
|
158
|
-
console.error("error: Sass is not installed. Try running `
|
158
|
+
console.error("error: Sass is not installed. Try running `npm i sass -D` and then building again.")
|
159
159
|
return
|
160
160
|
}
|
161
161
|
|
@@ -323,9 +323,13 @@ module.exports = async (esbuildOptions, ...args) => {
|
|
323
323
|
bundle: true,
|
324
324
|
loader: {
|
325
325
|
".jpg": "file",
|
326
|
+
".jpeg": "file",
|
326
327
|
".png": "file",
|
327
328
|
".gif": "file",
|
328
329
|
".svg": "file",
|
330
|
+
".avif": "file",
|
331
|
+
".jxl": "file",
|
332
|
+
".webp": "file",
|
329
333
|
".woff": "file",
|
330
334
|
".woff2": "file",
|
331
335
|
".ttf": "file",
|
@@ -18,7 +18,7 @@ unless Bridgetown.environment.test?
|
|
18
18
|
|
19
19
|
gsub_file "package.json", %r! "postcss-focus-within": "^4.0.0",?!, ""
|
20
20
|
|
21
|
-
|
21
|
+
add_npm_package "-D #{required_packages.join(" ")}"
|
22
22
|
|
23
23
|
packages_to_remove = package_json["devDependencies"].slice(*redundant_packages).keys
|
24
24
|
unless packages_to_remove.empty?
|
@@ -5,5 +5,5 @@ copy_file "jsconfig.json"
|
|
5
5
|
say "🎉 esbuild configuration updated successfully!"
|
6
6
|
say "You may need to add `$styles/` to the front of your main CSS imports."
|
7
7
|
say "See https://www.bridgetownrb.com/docs/frontend-assets#esbuild-setup for details."
|
8
|
-
say "⚠️ Don't forget to update the esbuild version in your `package.json` file to \"^0.
|
9
|
-
say "and run `
|
8
|
+
say "⚠️ Don't forget to update the esbuild version in your `package.json` file to \"^0.20.2\""
|
9
|
+
say "and run `npm install`!"
|
@@ -24,7 +24,7 @@ module Bridgetown
|
|
24
24
|
return show_actions if args.empty?
|
25
25
|
|
26
26
|
action = args.first
|
27
|
-
if supported_actions.include?(action)
|
27
|
+
if supported_actions.include?(action.to_sym)
|
28
28
|
perform action
|
29
29
|
else
|
30
30
|
@logger.error "Error:".red, "🚨 Please enter a valid action."
|
@@ -66,7 +66,7 @@ module Bridgetown
|
|
66
66
|
|
67
67
|
longest_action = supported_actions.keys.max_by(&:size).size
|
68
68
|
supported_actions.each do |action, description|
|
69
|
-
say "#{action.ljust(longest_action).
|
69
|
+
say "#{action.to_s.ljust(longest_action).bold.blue}\t# #{description}"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -76,7 +76,7 @@ module Bridgetown
|
|
76
76
|
update: "Updates the Bridgetown esbuild defaults to the latest available version",
|
77
77
|
"migrate-from-webpack":
|
78
78
|
"Removes Webpack from your project and installs/configures esbuild",
|
79
|
-
}
|
79
|
+
}
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -26,21 +26,21 @@ module Bridgetown
|
|
26
26
|
desc: "Comma separated list of bundled configurations to perform"
|
27
27
|
class_option :templates,
|
28
28
|
aliases: "-t",
|
29
|
-
banner: "
|
30
|
-
desc: "Preferred template engine (defaults to
|
29
|
+
banner: "erb|serbea|liquid",
|
30
|
+
desc: "Preferred template engine (defaults to ERB)"
|
31
31
|
class_option :"frontend-bundling",
|
32
32
|
aliases: "-e",
|
33
|
-
banner: "esbuild
|
34
|
-
desc: "Choose
|
33
|
+
banner: "esbuild",
|
34
|
+
desc: "Choose frontend bundling stack (defaults to esbuild)"
|
35
35
|
class_option :force,
|
36
36
|
type: :boolean,
|
37
37
|
desc: "Force creation even if PATH already exists"
|
38
38
|
class_option :"skip-bundle",
|
39
39
|
type: :boolean,
|
40
40
|
desc: "Skip 'bundle install'"
|
41
|
-
class_option :"skip-
|
41
|
+
class_option :"skip-npm",
|
42
42
|
type: :boolean,
|
43
|
-
desc: "Skip '
|
43
|
+
desc: "Skip 'npm install'"
|
44
44
|
class_option :"use-sass",
|
45
45
|
type: :boolean,
|
46
46
|
desc: "Set up a Sass configuration for your stylesheet"
|
@@ -91,7 +91,7 @@ module Bridgetown
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def frontend_bundling_option
|
94
|
-
|
94
|
+
"esbuild"
|
95
95
|
end
|
96
96
|
|
97
97
|
def postcss_option
|
@@ -99,7 +99,8 @@ module Bridgetown
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def disable_postcss?
|
102
|
-
|
102
|
+
# TODO: add option not to use postcss/sass at all
|
103
|
+
false
|
103
104
|
end
|
104
105
|
|
105
106
|
def create_site(new_site_path)
|
@@ -120,50 +121,42 @@ module Bridgetown
|
|
120
121
|
copy_file("frontend/styles/syntax-highlighting.css")
|
121
122
|
|
122
123
|
case options["templates"]
|
123
|
-
when "erb"
|
124
|
-
setup_erb_templates
|
125
124
|
when "serbea"
|
126
125
|
setup_serbea_templates
|
127
|
-
|
126
|
+
when "liquid"
|
128
127
|
setup_liquid_templates
|
128
|
+
else # default if no option specififed
|
129
|
+
setup_erb_templates
|
129
130
|
end
|
130
131
|
|
131
132
|
postcss_option ? configure_postcss : configure_sass
|
132
133
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
invoke(Webpack, ["setup"], {})
|
137
|
-
end
|
134
|
+
return unless frontend_bundling_option == "esbuild"
|
135
|
+
|
136
|
+
invoke(Esbuild, ["setup"], {})
|
138
137
|
end
|
139
138
|
|
140
139
|
def setup_erb_templates
|
141
140
|
directory "TEMPLATES/erb/_layouts", "src/_layouts"
|
142
141
|
directory "TEMPLATES/erb/_components", "src/_components"
|
143
142
|
directory "TEMPLATES/erb/_partials", "src/_partials"
|
144
|
-
gsub_file "bridgetown.config.yml", %r!permalink: pretty\n!, <<~YML
|
145
|
-
permalink: pretty
|
146
|
-
template_engine: erb
|
147
|
-
YML
|
148
143
|
end
|
149
144
|
|
150
145
|
def setup_serbea_templates
|
151
146
|
directory "TEMPLATES/serbea/_layouts", "src/_layouts"
|
152
147
|
directory "TEMPLATES/serbea/_components", "src/_components"
|
153
148
|
directory "TEMPLATES/serbea/_partials", "src/_partials"
|
154
|
-
gsub_file "
|
155
|
-
|
156
|
-
|
157
|
-
YML
|
149
|
+
gsub_file "config/initializers.rb", %r!template_engine "erb"\n!, <<~RUBY
|
150
|
+
template_engine "serbea"
|
151
|
+
RUBY
|
158
152
|
end
|
159
153
|
|
160
154
|
def setup_liquid_templates
|
161
155
|
directory "TEMPLATES/liquid/_layouts", "src/_layouts"
|
162
156
|
directory "TEMPLATES/liquid/_components", "src/_components"
|
163
|
-
gsub_file "
|
164
|
-
|
165
|
-
|
166
|
-
YML
|
157
|
+
gsub_file "config/initializers.rb", %r!template_engine "erb"\n!, <<~RUBY
|
158
|
+
template_engine "liquid"
|
159
|
+
RUBY
|
167
160
|
end
|
168
161
|
|
169
162
|
def configure_sass
|
@@ -172,7 +165,7 @@ module Bridgetown
|
|
172
165
|
end
|
173
166
|
|
174
167
|
def configure_postcss
|
175
|
-
template("postcss.config.js.erb", "postcss.config.js")
|
168
|
+
template("postcss.config.js.erb", "postcss.config.js") unless disable_postcss?
|
176
169
|
copy_file("frontend/styles/index.css")
|
177
170
|
end
|
178
171
|
|
@@ -187,8 +180,8 @@ module Bridgetown
|
|
187
180
|
@skipped_bundle = true # is set to false if bundle install worked
|
188
181
|
bundle_install path unless options["skip-bundle"]
|
189
182
|
|
190
|
-
@
|
191
|
-
|
183
|
+
@skipped_npm = true
|
184
|
+
npm_install path unless options["skip-npm"]
|
192
185
|
|
193
186
|
invoke(Apply, [], options) if options[:apply]
|
194
187
|
invoke(Configure, options[:configure].split(","), {}) if options[:configure]
|
@@ -198,9 +191,9 @@ module Bridgetown
|
|
198
191
|
logger.info ""
|
199
192
|
logger.info "Success!".green, "🎉 Your new Bridgetown site was " \
|
200
193
|
"generated in #{cli_path.cyan}."
|
201
|
-
if options["skip-
|
194
|
+
if options["skip-npm"]
|
202
195
|
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
|
203
|
-
logger.info "You'll probably also want to #{"
|
196
|
+
logger.info "You'll probably also want to #{"npm install".cyan} " \
|
204
197
|
"to load in your frontend assets."
|
205
198
|
else
|
206
199
|
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan} " \
|
@@ -214,7 +207,7 @@ module Bridgetown
|
|
214
207
|
logger.info "You will need to run #{"bundle binstubs bridgetown-core".cyan} manually."
|
215
208
|
end
|
216
209
|
|
217
|
-
logger.info "
|
210
|
+
logger.info "NPM install skipped.".yellow if @skipped_npm
|
218
211
|
end
|
219
212
|
# rubocop:enable Metrics/CyclomaticComplexity
|
220
213
|
# rubocop:enable Metrics/PerceivedComplexity
|
@@ -225,8 +218,8 @@ module Bridgetown
|
|
225
218
|
Bridgetown.with_unbundled_env do
|
226
219
|
inside(path) do
|
227
220
|
run "bundle install", abort_on_failure: true
|
221
|
+
# create binstubs to `bin/bridgetown` and `bin/bt`
|
228
222
|
run "bundle binstubs bridgetown-core"
|
229
|
-
run "cp bin/bridgetown bin/bt"
|
230
223
|
end
|
231
224
|
end
|
232
225
|
end
|
@@ -247,15 +240,15 @@ module Bridgetown
|
|
247
240
|
say_status :alert, "Could not load git. git init skipped.", :red
|
248
241
|
end
|
249
242
|
|
250
|
-
def
|
243
|
+
def npm_install(path)
|
251
244
|
unless Bridgetown.environment.test?
|
252
245
|
inside(path) do
|
253
|
-
run "
|
246
|
+
run "npm install", abort_on_failure: true
|
254
247
|
end
|
255
248
|
end
|
256
|
-
@
|
249
|
+
@skipped_npm = false
|
257
250
|
rescue SystemExit
|
258
|
-
say_status :alert, "Could not load
|
251
|
+
say_status :alert, "Could not load npm. NPM install skipped.", :red
|
259
252
|
end
|
260
253
|
end
|
261
254
|
end
|