bridgetown-core 2.0.0.beta2 ā 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/bridgetown-core.gemspec +43 -42
- data/lib/bridgetown-core/cache.rb +3 -19
- data/lib/bridgetown-core/cleaner.rb +17 -19
- data/lib/bridgetown-core/collection.rb +6 -5
- data/lib/bridgetown-core/commands/base.rb +7 -0
- data/lib/bridgetown-core/commands/build.rb +35 -22
- data/lib/bridgetown-core/commands/concerns/actions.rb +4 -0
- data/lib/bridgetown-core/commands/console.rb +0 -1
- data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +7 -6
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +14 -13
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
- data/lib/bridgetown-core/commands/esbuild/update.rb +17 -3
- data/lib/bridgetown-core/commands/esbuild.rb +1 -1
- data/lib/bridgetown-core/commands/start.rb +12 -2
- data/lib/bridgetown-core/component.rb +1 -1
- data/lib/bridgetown-core/concerns/intuitive_expectations.rb +67 -0
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/concerns/publishable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/content.rb +4 -1
- data/lib/bridgetown-core/concerns/site/extensible.rb +6 -1
- data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +33 -18
- data/lib/bridgetown-core/concerns/site/localizable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +2 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +3 -0
- data/lib/bridgetown-core/concerns/site/ssr.rb +1 -2
- data/lib/bridgetown-core/concerns/site/writable.rb +1 -0
- data/lib/bridgetown-core/concerns/viewable.rb +46 -0
- data/lib/bridgetown-core/configuration.rb +29 -23
- data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +5 -5
- data/lib/bridgetown-core/configurations/minitesting.rb +24 -64
- data/lib/bridgetown-core/converter.rb +2 -7
- data/lib/bridgetown-core/converters/erb_templates.rb +11 -7
- data/lib/bridgetown-core/converters/identity.rb +3 -11
- data/lib/bridgetown-core/converters/liquid_templates.rb +3 -5
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/markdown.rb +11 -14
- data/lib/bridgetown-core/converters/serbea_templates.rb +10 -8
- data/lib/bridgetown-core/drops/drop.rb +29 -42
- data/lib/bridgetown-core/drops/resource_drop.rb +3 -12
- data/lib/bridgetown-core/errors.rb +2 -8
- data/lib/bridgetown-core/filters/condition_helpers.rb +6 -9
- data/lib/bridgetown-core/filters/date_filters.rb +22 -35
- data/lib/bridgetown-core/filters/grouping_filters.rb +11 -11
- data/lib/bridgetown-core/filters.rb +53 -72
- data/lib/bridgetown-core/front_matter/defaults.rb +14 -19
- data/lib/bridgetown-core/generated_page.rb +6 -6
- data/lib/bridgetown-core/generators/prototype_generator.rb +0 -2
- data/lib/bridgetown-core/helpers.rb +2 -2
- data/lib/bridgetown-core/hooks.rb +0 -1
- data/lib/bridgetown-core/layout.rb +3 -4
- data/lib/bridgetown-core/liquid_extensions.rb +3 -5
- data/lib/bridgetown-core/log_adapter.rb +37 -56
- data/lib/bridgetown-core/plugin_manager.rb +7 -3
- data/lib/bridgetown-core/rack/boot.rb +7 -57
- data/lib/bridgetown-core/rack/default_config.ru +14 -0
- data/lib/bridgetown-core/rack/loader_hooks.rb +83 -0
- data/lib/bridgetown-core/rack/logger.rb +0 -2
- data/lib/bridgetown-core/rack/routes.rb +3 -2
- data/lib/bridgetown-core/resource/base.rb +8 -8
- data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
- data/lib/bridgetown-core/resource/relations.rb +3 -1
- data/lib/bridgetown-core/ruby_template_view.rb +0 -1
- data/lib/bridgetown-core/static_file.rb +15 -20
- data/lib/bridgetown-core/tags/class_map.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +2 -32
- data/lib/bridgetown-core/utils/initializers.rb +2 -2
- data/lib/bridgetown-core/utils/require_gems.rb +1 -3
- data/lib/bridgetown-core/utils.rb +41 -44
- data/lib/bridgetown-core/watcher.rb +2 -3
- data/lib/bridgetown-core.rb +29 -10
- data/lib/roda/plugins/bridgetown_server.rb +13 -25
- data/lib/roda/plugins/bridgetown_ssr.rb +21 -3
- data/lib/roda/plugins/flashier.rb +57 -0
- data/lib/roda/plugins/generic_index.html +127 -0
- data/lib/roda/plugins/ssg.rb +3 -2
- data/lib/site_template/config/initializers.rb +2 -0
- data/lib/site_template/package.json.erb +1 -0
- data/lib/site_template/postcss.config.js.erb +1 -1
- metadata +26 -7
- data/lib/bridgetown-core/commands/doctor.rb +0 -147
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813f0bb565e3342b5eb466d6f3f65575adec5ba64d0a355c29c49f74925ee695
|
4
|
+
data.tar.gz: b8141708de43e8035b04ce2085fded27ddd5f4b5657ed53143c80ccf26927b5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acad0c9039fcad0cf8654b19672b149ef660cc2adb75307a810d9379695a54398c6dbaffb206f850b2272e831b2280853f82b20e35115c0454457e21ec22c055
|
7
|
+
data.tar.gz: 51af878741c57eac002b78b3690887703d0469f851f6b980203f187d5731282feec110d91ad0abafa60fc99d3ba813d39b8174a22931d32daf4eb209511774e1
|
data/.rubocop.yml
CHANGED
data/bridgetown-core.gemspec
CHANGED
@@ -2,58 +2,59 @@
|
|
2
2
|
|
3
3
|
require_relative "../bridgetown-foundation/lib/bridgetown/version"
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown-core"
|
7
|
+
spec.version = Bridgetown::VERSION
|
8
|
+
spec.license = "MIT"
|
9
|
+
spec.author = "Bridgetown Team"
|
10
|
+
spec.email = "maintainers@bridgetownrb.com"
|
11
|
+
spec.homepage = "https://www.bridgetownrb.com"
|
12
|
+
spec.summary = "A next-generation, progressive site generator & fullstack framework, powered by Ruby"
|
13
|
+
spec.description = "Bridgetown is a next-generation, progressive site generator & fullstack framework, powered by Ruby"
|
14
14
|
|
15
|
-
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
16
|
f.match(%r!^(benchmark|features|script|test)/!)
|
17
17
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
spec.executables = ["bridgetown", "bt"] # `bt` is a shortcut to `bridgetown` command
|
19
|
+
spec.bindir = "bin"
|
20
|
+
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
|
22
|
+
spec.metadata = {
|
23
23
|
"source_code_uri" => "https://github.com/bridgetownrb/bridgetown",
|
24
24
|
"bug_tracker_uri" => "https://github.com/bridgetownrb/bridgetown/issues",
|
25
25
|
"changelog_uri" => "https://github.com/bridgetownrb/bridgetown/releases",
|
26
|
-
"homepage_uri" =>
|
26
|
+
"homepage_uri" => spec.homepage,
|
27
27
|
"rubygems_mfa_required" => "true",
|
28
28
|
}
|
29
29
|
|
30
|
-
|
30
|
+
spec.rdoc_options = ["--charset=UTF-8"]
|
31
31
|
|
32
|
-
|
32
|
+
spec.required_ruby_version = ">= 3.1.0"
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
34
|
+
spec.add_dependency("activesupport", [">= 6.0", "< 8.0"])
|
35
|
+
spec.add_dependency("addressable", "~> 2.4")
|
36
|
+
spec.add_dependency("amazing_print", "~> 1.2")
|
37
|
+
spec.add_dependency("bridgetown-foundation", Bridgetown::VERSION)
|
38
|
+
spec.add_dependency("csv", "~> 3.2")
|
39
|
+
spec.add_dependency("dry-inflector", ">= 1.0")
|
40
|
+
spec.add_dependency("erubi", "~> 1.9")
|
41
|
+
spec.add_dependency("faraday", "~> 2.0")
|
42
|
+
spec.add_dependency("faraday-follow_redirects", "~> 0.3")
|
43
|
+
spec.add_dependency("i18n", "~> 1.0")
|
44
|
+
spec.add_dependency("irb", ">= 1.14")
|
45
|
+
spec.add_dependency("kramdown", "~> 2.1")
|
46
|
+
spec.add_dependency("kramdown-parser-gfm", "~> 1.0")
|
47
|
+
spec.add_dependency("liquid", [">= 5.0", "< 5.5"])
|
48
|
+
spec.add_dependency("listen", "~> 3.0")
|
49
|
+
spec.add_dependency("rack", ">= 3.0")
|
50
|
+
spec.add_dependency("rackup", "~> 2.0")
|
51
|
+
spec.add_dependency("rake", ">= 13.0")
|
52
|
+
spec.add_dependency("roda", "~> 3.46")
|
53
|
+
spec.add_dependency("rouge", [">= 3.0", "< 5.0"])
|
54
|
+
spec.add_dependency("serbea", "~> 2.1")
|
55
|
+
spec.add_dependency("signalize", "~> 1.3")
|
56
|
+
spec.add_dependency("streamlined", ">= 0.6.0")
|
57
|
+
spec.add_dependency("thor", "~> 1.1")
|
58
|
+
spec.add_dependency("tilt", "~> 2.0")
|
59
|
+
spec.add_dependency("zeitwerk", "~> 2.5")
|
59
60
|
end
|
@@ -33,8 +33,6 @@ module Bridgetown
|
|
33
33
|
|
34
34
|
# Compare the current config to the cached config
|
35
35
|
# If they are different, clear all caches
|
36
|
-
#
|
37
|
-
# Returns nothing.
|
38
36
|
def clear_if_config_changed(config)
|
39
37
|
config = config.inspect
|
40
38
|
cache = Bridgetown::Cache.new "Bridgetown::Cache"
|
@@ -49,8 +47,6 @@ module Bridgetown
|
|
49
47
|
private
|
50
48
|
|
51
49
|
# Delete all cached items from all caches
|
52
|
-
#
|
53
|
-
# Returns nothing.
|
54
50
|
def delete_cache_files
|
55
51
|
FileUtils.rm_rf(@cache_dir) if disk_cache_enabled
|
56
52
|
end
|
@@ -60,9 +56,7 @@ module Bridgetown
|
|
60
56
|
|
61
57
|
# Get an existing named cache, or create a new one if none exists
|
62
58
|
#
|
63
|
-
# name
|
64
|
-
#
|
65
|
-
# Returns nothing.
|
59
|
+
# @param name [String] name of the cache
|
66
60
|
def initialize(name)
|
67
61
|
@cache = Bridgetown::Cache.base_cache[name] ||= {}
|
68
62
|
@name = name.gsub(%r![^\w\s-]!, "-")
|
@@ -77,7 +71,7 @@ module Bridgetown
|
|
77
71
|
# Retrieve a cached item
|
78
72
|
# Raises if key does not exist in cache
|
79
73
|
#
|
80
|
-
#
|
74
|
+
# @return [Object] cached value
|
81
75
|
def [](key)
|
82
76
|
return @cache[key] if @cache.key?(key)
|
83
77
|
|
@@ -88,8 +82,6 @@ module Bridgetown
|
|
88
82
|
end
|
89
83
|
|
90
84
|
# Add an item to cache
|
91
|
-
#
|
92
|
-
# Returns nothing.
|
93
85
|
def []=(key, value)
|
94
86
|
@cache[key] = value
|
95
87
|
return unless disk_cache_enabled?
|
@@ -112,8 +104,6 @@ module Bridgetown
|
|
112
104
|
end
|
113
105
|
|
114
106
|
# Remove one particular item from the cache
|
115
|
-
#
|
116
|
-
# Returns nothing.
|
117
107
|
def delete(key)
|
118
108
|
@cache.delete(key)
|
119
109
|
File.delete(path_to(hash(key))) if disk_cache_enabled?
|
@@ -121,7 +111,7 @@ module Bridgetown
|
|
121
111
|
|
122
112
|
# Check if `key` already exists in this cache
|
123
113
|
#
|
124
|
-
#
|
114
|
+
# @return [Boolean] true if key exists in the cache, false otherwise
|
125
115
|
def key?(key)
|
126
116
|
# First, check if item is already cached in memory
|
127
117
|
return true if @cache.key?(key)
|
@@ -153,14 +143,11 @@ module Bridgetown
|
|
153
143
|
end
|
154
144
|
|
155
145
|
# Remove all this caches items from disk
|
156
|
-
#
|
157
|
-
# Returns nothing.
|
158
146
|
def delete_cache_files
|
159
147
|
FileUtils.rm_rf(path_to) if disk_cache_enabled?
|
160
148
|
end
|
161
149
|
|
162
150
|
# Load `path` from disk and return the result.
|
163
|
-
# This MUST NEVER be called in Safe Mode
|
164
151
|
# rubocop:disable Security/MarshalLoad
|
165
152
|
def load(path)
|
166
153
|
raise unless disk_cache_enabled?
|
@@ -173,9 +160,6 @@ module Bridgetown
|
|
173
160
|
# rubocop:enable Security/MarshalLoad
|
174
161
|
|
175
162
|
# Given a path and a value, save value to disk at path.
|
176
|
-
# This should NEVER be called in Safe Mode
|
177
|
-
#
|
178
|
-
# Returns nothing.
|
179
163
|
def dump(path, value)
|
180
164
|
return unless disk_cache_enabled?
|
181
165
|
|
@@ -17,9 +17,9 @@ module Bridgetown
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
#
|
20
|
+
# The list of files and directories to be deleted during cleanup process
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# @return [Array<String>] file and directory paths
|
23
23
|
def obsolete_files
|
24
24
|
out = (existing_files - new_files - new_dirs + replaced_files).to_a
|
25
25
|
Bridgetown::Hooks.trigger :clean, :on_obsolete, out
|
@@ -27,10 +27,9 @@ module Bridgetown
|
|
27
27
|
out
|
28
28
|
end
|
29
29
|
|
30
|
-
#
|
31
|
-
# keep_files and hidden files.
|
30
|
+
# The list of existing files, apart from those included in keep_files and hidden files
|
32
31
|
#
|
33
|
-
#
|
32
|
+
# @return [Set<String>] file paths
|
34
33
|
def existing_files
|
35
34
|
files = Set.new
|
36
35
|
regex = keep_file_regex
|
@@ -45,9 +44,9 @@ module Bridgetown
|
|
45
44
|
files
|
46
45
|
end
|
47
46
|
|
48
|
-
#
|
47
|
+
# The list of files to be created when site is built.
|
49
48
|
#
|
50
|
-
#
|
49
|
+
# @return [Set<String>] file paths
|
51
50
|
def new_files
|
52
51
|
@new_files ||= Set.new.tap do |files|
|
53
52
|
site.each_site_file do |item|
|
@@ -60,17 +59,17 @@ module Bridgetown
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
#
|
62
|
+
# The list of directories to be created when site is built.
|
64
63
|
# These are the parent directories of the files in #new_files.
|
65
64
|
#
|
66
|
-
#
|
65
|
+
# @return [Set<String>] directory paths
|
67
66
|
def new_dirs
|
68
67
|
@new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set
|
69
68
|
end
|
70
69
|
|
71
|
-
#
|
70
|
+
# The list of parent directories of a given file
|
72
71
|
#
|
73
|
-
#
|
72
|
+
# @return [Array<String>] directory paths
|
74
73
|
def parent_dirs(file)
|
75
74
|
parent_dir = File.dirname(file)
|
76
75
|
if parent_dir == site.dest
|
@@ -80,29 +79,28 @@ module Bridgetown
|
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
|
-
#
|
84
|
-
# during build
|
82
|
+
# The list of existing files that will be replaced by a directory during build
|
85
83
|
#
|
86
|
-
#
|
84
|
+
# @return [Set<String>] file paths
|
87
85
|
def replaced_files
|
88
86
|
new_dirs.select { |dir| File.file?(dir) }.to_set
|
89
87
|
end
|
90
88
|
|
91
|
-
#
|
89
|
+
# The list of directories that need to be kept because they are
|
92
90
|
# parent directories of files specified in keep_files
|
93
91
|
#
|
94
|
-
#
|
92
|
+
# @return [Set<String>] directory paths
|
95
93
|
def keep_dirs
|
96
94
|
site.config.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set
|
97
95
|
end
|
98
96
|
|
99
|
-
#
|
97
|
+
# Creates a regular expression from the config's keep_files array
|
100
98
|
#
|
101
|
-
#
|
99
|
+
# @example
|
102
100
|
# ['.git','.svn'] with site.dest "/myblog/_site" creates
|
103
101
|
# the following regex: /\A\/myblog\/_site\/(\.git|\/.svn)/
|
104
102
|
#
|
105
|
-
#
|
103
|
+
# @return [Regexp]
|
106
104
|
def keep_file_regex
|
107
105
|
%r!\A#{Regexp.quote(site.dest)}/(#{Regexp.union(site.config.keep_files).source})!
|
108
106
|
end
|
@@ -55,13 +55,13 @@ module Bridgetown
|
|
55
55
|
# Iterate over Resources by delegating to `resources.each` (supports Enumerable)
|
56
56
|
def each(...) = resources.each(...)
|
57
57
|
|
58
|
-
#
|
58
|
+
# Delegates to `resources.last`
|
59
59
|
def last(...) = resources.last(...)
|
60
60
|
|
61
|
-
#
|
61
|
+
# Delegates to `resources.deconstruct`
|
62
62
|
def deconstruct = resources.deconstruct
|
63
63
|
|
64
|
-
#
|
64
|
+
# Delegates to `resources[]`
|
65
65
|
def [](...) = resources.[](...)
|
66
66
|
|
67
67
|
# Fetch the static files in this collection.
|
@@ -184,7 +184,8 @@ module Bridgetown
|
|
184
184
|
#
|
185
185
|
# @return [String]
|
186
186
|
def inspect
|
187
|
-
"#<#{self.class}
|
187
|
+
"#<#{self.class} #{label}: #{resources.count} metadata=#{metadata.inspect} " \
|
188
|
+
"static_files: #{static_files.count}>"
|
188
189
|
end
|
189
190
|
|
190
191
|
# Produce a sanitized label name
|
@@ -400,7 +401,7 @@ module Bridgetown
|
|
400
401
|
|
401
402
|
def model_id_from_relative_path(model_relative_path, manifest: nil)
|
402
403
|
scheme = manifest ? "plugin" : "repo"
|
403
|
-
id =
|
404
|
+
id = "#{scheme}://#{label}.collection/"
|
404
405
|
id += "#{manifest.origin}/" if manifest
|
405
406
|
id += Addressable::URI.escape(model_relative_path).gsub("#", "%23")
|
406
407
|
id
|
@@ -66,6 +66,13 @@ module Bridgetown
|
|
66
66
|
puts "Unknown task: #{cmd.split("[")[0]}\n\nHere's a list of tasks you can run:"
|
67
67
|
display_rake_tasks(rake)
|
68
68
|
end
|
69
|
+
rescue RuntimeError => e
|
70
|
+
# re-raise error unless it's an error through Minitest
|
71
|
+
raise e unless e.message.include?("ruby -Ilib:test")
|
72
|
+
|
73
|
+
Bridgetown.logger.error "test aborted!"
|
74
|
+
Bridgetown.logger.error e.message
|
75
|
+
exit(false)
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
@@ -50,11 +50,7 @@ module Bridgetown
|
|
50
50
|
if Bridgetown::Utils.frontend_bundler_type(config_options[:root_dir]) == :esbuild
|
51
51
|
Bridgetown::Utils.update_esbuild_autogenerated_config config_options
|
52
52
|
end
|
53
|
-
|
54
|
-
Rake.with_application do |rake|
|
55
|
-
rake.load_rakefile
|
56
|
-
rake["frontend:watcher"].invoke(true)
|
57
|
-
end
|
53
|
+
invoke_frontend_watcher_from_rake
|
58
54
|
end
|
59
55
|
|
60
56
|
@site = Bridgetown::Site.new(config_options)
|
@@ -66,11 +62,7 @@ module Bridgetown
|
|
66
62
|
build_site(config_options)
|
67
63
|
end
|
68
64
|
|
69
|
-
|
70
|
-
if config_options.fetch("detach", false)
|
71
|
-
Bridgetown.logger.info "Auto-regeneration:",
|
72
|
-
"disabled when running server detached."
|
73
|
-
elsif config_options.fetch("watch", false)
|
65
|
+
if config_options.fetch("watch", false)
|
74
66
|
watch_site(config_options)
|
75
67
|
else
|
76
68
|
Bridgetown.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
|
@@ -79,11 +71,9 @@ module Bridgetown
|
|
79
71
|
|
80
72
|
protected
|
81
73
|
|
82
|
-
# Build your Bridgetown site
|
83
|
-
#
|
84
|
-
# options - A Hash of options passed to the command or loaded from config
|
74
|
+
# Build your Bridgetown site
|
85
75
|
#
|
86
|
-
#
|
76
|
+
# @param options [Bridgetown::Configuration] options loaded from config and/or CLI
|
87
77
|
def build_site(config_options)
|
88
78
|
t = Time.now
|
89
79
|
display_folder_paths(config_options)
|
@@ -97,32 +87,55 @@ module Bridgetown
|
|
97
87
|
"#{(Time.now - t).ceil(2)} seconds."
|
98
88
|
end
|
99
89
|
|
100
|
-
# Watch for file changes and rebuild the site
|
101
|
-
#
|
102
|
-
# options - A Hash of options passed to the command or loaded from config
|
90
|
+
# Watch for file changes and rebuild the site
|
103
91
|
#
|
104
|
-
#
|
92
|
+
# @param options [Bridgetown::Configuration] options loaded from config and/or CLI
|
105
93
|
def watch_site(config_options)
|
94
|
+
if config_options["url"]&.include?("://localhost")
|
95
|
+
require "socket"
|
96
|
+
external_ip = Socket.ip_address_list.find do |ai|
|
97
|
+
ai.ipv4? && !ai.ipv4_loopback?
|
98
|
+
end&.ip_address
|
99
|
+
scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
|
100
|
+
port = ENV.fetch("BRIDGETOWN_PORT", config_options.port)
|
101
|
+
Bridgetown.logger.info ""
|
102
|
+
Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
|
103
|
+
Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
|
104
|
+
Bridgetown.logger.info ""
|
105
|
+
end
|
106
|
+
|
106
107
|
Bridgetown::Watcher.watch(@site, config_options)
|
107
108
|
end
|
108
109
|
|
109
110
|
# Display the source and destination folder paths
|
110
111
|
#
|
111
|
-
# options
|
112
|
-
#
|
113
|
-
# Returns nothing.
|
112
|
+
# @param options [Bridgetown::Configuration] options loaded from config and/or CLI
|
114
113
|
def display_folder_paths(config_options)
|
115
114
|
source = File.expand_path(config_options["source"])
|
116
115
|
destination = File.expand_path(config_options["destination"])
|
117
116
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
118
117
|
Bridgetown.logger.info "Source:", source
|
119
118
|
Bridgetown.logger.info "Destination:", destination
|
120
|
-
# TODO: work with arrays
|
121
119
|
return unless config_options["plugins_dir"].is_a?(String)
|
122
120
|
|
123
121
|
plugins_dir = File.expand_path(config_options["plugins_dir"])
|
124
122
|
Bridgetown.logger.info "Custom Plugins:", plugins_dir if Dir.exist?(plugins_dir)
|
125
123
|
end
|
124
|
+
|
125
|
+
def invoke_frontend_watcher_from_rake
|
126
|
+
require "rake"
|
127
|
+
Rake.with_application do |rake|
|
128
|
+
begin
|
129
|
+
rake.raw_load_rakefile
|
130
|
+
rescue StandardError => e
|
131
|
+
unless e.message.include?("No Rakefile found")
|
132
|
+
Bridgetown.logger.error "Error Running Rake:", "#{e.message} (#{e.class})"
|
133
|
+
e.backtrace[0..1].each { |backtrace_line| Bridgetown.logger.info backtrace_line }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
rake["frontend:watcher"].invoke(true) if rake.tasks.any? { _1.name == "frontend:watcher" }
|
137
|
+
end
|
138
|
+
end
|
126
139
|
end
|
127
140
|
end
|
128
141
|
end
|
@@ -116,6 +116,10 @@ module Bridgetown
|
|
116
116
|
run "#{Bridgetown::PluginManager.package_manager} #{Bridgetown::PluginManager.package_manager_install_command} #{package_details}" # rubocop:disable Layout
|
117
117
|
end
|
118
118
|
|
119
|
+
def remove_npm_package(package_details)
|
120
|
+
run "#{Bridgetown::PluginManager.package_manager} #{Bridgetown::PluginManager.package_manager_uninstall_command} #{package_details}" # rubocop:disable Layout
|
121
|
+
end
|
122
|
+
|
119
123
|
def apply_from_url(url)
|
120
124
|
apply transform_automation_url(url.dup)
|
121
125
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
|
1
|
+
import build from "./config/esbuild.defaults.js"
|
2
2
|
|
3
3
|
// You can customize this as you wish, perhaps to add new esbuild plugins.
|
4
4
|
//
|
5
5
|
// ```
|
6
|
-
//
|
7
|
-
//
|
6
|
+
// import { copy } from 'esbuild-plugin-copy'
|
7
|
+
//
|
8
8
|
// const esbuildOptions = {
|
9
9
|
// plugins: [
|
10
|
-
//
|
10
|
+
// copy({
|
11
|
+
// resolveFrom: 'cwd',
|
11
12
|
// assets: {
|
12
|
-
// from: [
|
13
|
-
// to: [
|
13
|
+
// from: ['./node_modules/somepackage/files/*')],
|
14
|
+
// to: ['./output/_bridgetown/somepackage/files')],
|
14
15
|
// },
|
15
16
|
// verbose: false
|
16
17
|
// }),
|
@@ -16,19 +16,19 @@ const autogeneratedBridgetownConfig = {
|
|
16
16
|
"islandsDir": "_islands"
|
17
17
|
}
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
import path from "path"
|
20
|
+
import fsLib from "fs"
|
21
21
|
const fs = fsLib.promises
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
import { pathToFileURL, fileURLToPath } from "url"
|
23
|
+
import { glob } from "glob"
|
24
|
+
import postcss from "postcss"
|
25
|
+
import postCssImport from "postcss-import"
|
26
|
+
import readCache from "read-cache"
|
27
27
|
|
28
28
|
// Detect if an NPM package is available
|
29
29
|
const moduleAvailable = name => {
|
30
30
|
try {
|
31
|
-
|
31
|
+
import.meta.resolve(name)
|
32
32
|
return true
|
33
33
|
} catch (e) { }
|
34
34
|
return false
|
@@ -43,7 +43,7 @@ const generateSourceMappingURL = sourceMap => {
|
|
43
43
|
// Import Sass if available
|
44
44
|
let sass
|
45
45
|
if (moduleAvailable("sass")) {
|
46
|
-
sass =
|
46
|
+
sass = (await import("sass")).default
|
47
47
|
}
|
48
48
|
|
49
49
|
// Glob plugin derived from:
|
@@ -288,9 +288,9 @@ const bridgetownConfigured = (bridgetownConfig, outputFolder) => {
|
|
288
288
|
}
|
289
289
|
|
290
290
|
// Load the PostCSS config from postcss.config.js or whatever else is a supported location/format
|
291
|
-
const postcssrc =
|
291
|
+
const postcssrc = (await import("postcss-load-config")).default
|
292
292
|
|
293
|
-
|
293
|
+
export default async (esbuildOptions, ...args) => {
|
294
294
|
let outputFolder;
|
295
295
|
if (typeof esbuildOptions === "string") { // legacy syntax where first argument is output folder
|
296
296
|
outputFolder = esbuildOptions
|
@@ -313,11 +313,12 @@ module.exports = async (esbuildOptions, ...args) => {
|
|
313
313
|
esbuildOptions.plugins.push(bridgetownPreset(bridgetownConfig))
|
314
314
|
if (esbuildOptions.bridgetownConfig) delete esbuildOptions.bridgetownConfig
|
315
315
|
|
316
|
-
const esbuild =
|
316
|
+
const esbuild = (await import("esbuild")).default
|
317
317
|
const entryPoints = esbuildOptions.entryPoints || ["./frontend/javascript/index.js"]
|
318
318
|
if (esbuildOptions.entryPoints) delete esbuildOptions.entryPoints
|
319
319
|
|
320
320
|
const islands = glob.sync(`./${bridgetownConfig.source}/${bridgetownConfig.islandsDir}/*.{js,js.rb}`).map(item => `./${item}`)
|
321
|
+
const islandsAsObject = islands.reduce((obj, str) => obj[str] = str, {})
|
321
322
|
|
322
323
|
esbuild.context({
|
323
324
|
bundle: true,
|
@@ -339,7 +340,7 @@ module.exports = async (esbuildOptions, ...args) => {
|
|
339
340
|
minify: process.argv.includes("--minify"),
|
340
341
|
sourcemap: true,
|
341
342
|
target: "es2020",
|
342
|
-
entryPoints: [...entryPoints, ...islands],
|
343
|
+
entryPoints: Array.isArray(entryPoints) ? [...entryPoints, ...islands] : {...entryPoints, ...islandsAsObject},
|
343
344
|
entryNames: "[dir]/[name].[hash]",
|
344
345
|
outdir: path.join(process.cwd(), `${bridgetownConfig.destination}/_bridgetown/static`),
|
345
346
|
publicPath: "/_bridgetown/static",
|
@@ -25,7 +25,7 @@ unless Bridgetown.environment.test?
|
|
25
25
|
confirm = ask "\nThe following packages will be removed: \n\n#{packages_to_remove.join("\n")}\n\nWould you like to continue? [Yn]"
|
26
26
|
return unless confirm.casecmp?("Y")
|
27
27
|
|
28
|
-
|
28
|
+
remove_npm_package packages_to_remove.join(" ")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -2,8 +2,22 @@
|
|
2
2
|
|
3
3
|
template "esbuild.defaults.js.erb", "config/esbuild.defaults.js", force: true
|
4
4
|
copy_file "jsconfig.json"
|
5
|
-
|
5
|
+
|
6
|
+
unless File.read("package.json").include?('"type": "module"')
|
7
|
+
insert_into_file "package.json",
|
8
|
+
after: '"private": true,' do
|
9
|
+
<<-JS.chomp
|
10
|
+
|
11
|
+
"type": "module",
|
12
|
+
JS
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
gsub_file "postcss.config.js", "module.exports =", "export default"
|
17
|
+
gsub_file "esbuild.config.js", 'const build = require("./config/esbuild.defaults.js")',
|
18
|
+
'import build from "./config/esbuild.defaults.js"'
|
19
|
+
add_npm_package "esbuild@latest glob@latest" unless Bridgetown.env.test?
|
20
|
+
|
21
|
+
say "\nš esbuild configuration updated successfully!"
|
6
22
|
say "You may need to add `$styles/` to the front of your main CSS imports."
|
7
23
|
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.20.2\""
|
9
|
-
say "and run `npm install`!"
|