bridgetown-core 0.21.3 → 0.21.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bridgetown-core/concerns/site/content.rb +10 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/generators/prototype_generator.rb +3 -3
- data/lib/bridgetown-core/reader.rb +10 -5
- data/lib/bridgetown-core/utils.rb +16 -22
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/site_template/frontend/javascript/index.js.erb +3 -3
- data/lib/site_template/package.json.erb +6 -3
- data/lib/site_template/start.js +3 -3
- 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: 45adfcd2a3d839fa9857ba0458db4090ef70e0c89cb9015d5813d5e2c7969224
|
4
|
+
data.tar.gz: 9e4a491aad2846485a35aa3114fdc656fe6577bcb46559117c1f908aaced9f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a376dd395a1e6c217479441a15edaca9be963b246b54d19ed07ead07e148838b84ada1dd077b6e8a62e07979cad979b13f36f7579af5a110f67d470a7df1d8db
|
7
|
+
data.tar.gz: aba8119209faee49d7180e29f1526e8e0aaf0726e164fb0ee384736e451f709f52be13ab897ef49500316b1e782d1f719fa8879ecb09281a684fb4c80ff897a0
|
@@ -220,5 +220,15 @@ class Bridgetown::Site
|
|
220
220
|
def add_generated_page(generated_page)
|
221
221
|
generated_pages << generated_page
|
222
222
|
end
|
223
|
+
|
224
|
+
# Loads and memoizes the parsed Webpack manifest file (if available)
|
225
|
+
# @return [Hash]
|
226
|
+
def frontend_manifest
|
227
|
+
@frontend_manifest ||= begin
|
228
|
+
manifest_file = in_root_dir(".bridgetown-webpack", "manifest.json")
|
229
|
+
|
230
|
+
JSON.parse(File.read(manifest_file)) if File.exist?(manifest_file)
|
231
|
+
end
|
232
|
+
end
|
223
233
|
end
|
224
234
|
end
|
@@ -79,11 +79,11 @@ module Bridgetown
|
|
79
79
|
# @return [String, nil]
|
80
80
|
def validate_search_term(prototype_page)
|
81
81
|
# @type [String]
|
82
|
-
search_term = prototype_page.data["prototype"]["term"]
|
83
|
-
return nil unless search_term.
|
82
|
+
search_term = prototype_page.data["prototype"]["term"].to_s
|
83
|
+
return nil unless search_term.present?
|
84
84
|
|
85
85
|
if prototype_page.data["prototype"]["collection"]
|
86
|
-
@configured_collection = prototype_page.data["prototype"]["collection"]
|
86
|
+
@configured_collection = prototype_page.data["prototype"]["collection"].to_s
|
87
87
|
end
|
88
88
|
|
89
89
|
unless site.collections[@configured_collection]
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class Reader
|
5
|
+
# @return [Bridgetown::Site]
|
5
6
|
attr_reader :site
|
6
7
|
|
7
8
|
def initialize(site)
|
@@ -17,12 +18,13 @@ module Bridgetown
|
|
17
18
|
read_directories
|
18
19
|
read_included_excludes
|
19
20
|
sort_files!
|
20
|
-
read_collections
|
21
21
|
site.data = if site.uses_resource?
|
22
|
+
site.collections.data.read
|
22
23
|
site.collections.data.merge_data_resources
|
23
24
|
else
|
24
25
|
DataReader.new(site).read
|
25
26
|
end
|
27
|
+
read_collections
|
26
28
|
Bridgetown::PluginManager.source_manifests.map(&:content).compact.each do |plugin_content_dir|
|
27
29
|
PluginContentReader.new(site, plugin_content_dir).read
|
28
30
|
end
|
@@ -30,15 +32,17 @@ module Bridgetown
|
|
30
32
|
|
31
33
|
def read_collections
|
32
34
|
site.collections.each_value do |collection|
|
33
|
-
|
34
|
-
|
35
|
+
next if site.uses_resource? && collection.data?
|
36
|
+
next if !site.uses_resource? && collection.legacy_reader?
|
37
|
+
|
38
|
+
collection.read
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
# Sorts posts, pages, and static files.
|
39
43
|
def sort_files!
|
40
|
-
site.collections.
|
41
|
-
site.
|
44
|
+
site.collections.posts.docs.sort! unless site.uses_resource?
|
45
|
+
site.generated_pages.sort_by!(&:name)
|
42
46
|
site.static_files.sort_by!(&:relative_path)
|
43
47
|
end
|
44
48
|
|
@@ -197,6 +201,7 @@ module Bridgetown
|
|
197
201
|
dir = File.dirname(entry_path).sub(site.source, "")
|
198
202
|
file = Array(File.basename(entry_path))
|
199
203
|
if Utils.has_yaml_header?(entry_path)
|
204
|
+
# TODO: does this need to get incorporated into the resource engine?
|
200
205
|
site.pages.concat(PageReader.new(site, dir).read(file))
|
201
206
|
else
|
202
207
|
retrieve_static_files(dir, file)
|
@@ -354,28 +354,19 @@ module Bridgetown
|
|
354
354
|
# @raise [WebpackAssetError] if unable to find css or js in the manifest
|
355
355
|
# file
|
356
356
|
def parse_webpack_manifest_file(site, asset_type)
|
357
|
-
|
358
|
-
return "MISSING_WEBPACK_MANIFEST" unless File.exist?(manifest_file)
|
357
|
+
return log_webpack_asset_error("Webpack manifest") if site.frontend_manifest.nil?
|
359
358
|
|
360
|
-
|
359
|
+
asset_path = if %w(js css).include?(asset_type)
|
360
|
+
site.frontend_manifest["main.#{asset_type}"]
|
361
|
+
else
|
362
|
+
site.frontend_manifest.find do |item, _|
|
363
|
+
item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
|
364
|
+
end&.last
|
365
|
+
end
|
361
366
|
|
362
|
-
|
363
|
-
asset_path = nil
|
364
|
-
if known_assets.include?(asset_type)
|
365
|
-
asset_path = manifest["main.#{asset_type}"]
|
366
|
-
log_webpack_asset_error(asset_type) && return if asset_path.nil?
|
367
|
-
else
|
368
|
-
asset_path = manifest.find do |item, _|
|
369
|
-
item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
|
370
|
-
end&.last
|
371
|
-
end
|
367
|
+
return log_webpack_asset_error(asset_type) if asset_path.nil?
|
372
368
|
|
373
|
-
|
374
|
-
static_frontend_path(site, ["js", asset_path])
|
375
|
-
else
|
376
|
-
Bridgetown.logger.error("Unknown Webpack asset type", asset_type)
|
377
|
-
nil
|
378
|
-
end
|
369
|
+
static_frontend_path site, ["js", asset_path]
|
379
370
|
end
|
380
371
|
|
381
372
|
def static_frontend_path(site, additional_parts = [])
|
@@ -389,10 +380,13 @@ module Bridgetown
|
|
389
380
|
end
|
390
381
|
|
391
382
|
def log_webpack_asset_error(asset_type)
|
392
|
-
|
393
|
-
|
383
|
+
Bridgetown.logger.warn(
|
384
|
+
"Webpack:",
|
385
|
+
"There was an error parsing your #{asset_type} file. \
|
386
|
+
Please check your #{asset_type} file for any errors."
|
387
|
+
)
|
394
388
|
|
395
|
-
|
389
|
+
"MISSING_WEBPACK_MANIFEST_FILE"
|
396
390
|
end
|
397
391
|
|
398
392
|
def default_github_branch_name(repo_url)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
<%- if options["use-postcss"] -%>
|
2
2
|
import "index.css"
|
3
|
-
|
3
|
+
<%- else -%>
|
4
4
|
import "index.scss"
|
5
|
-
|
5
|
+
<%- end -%>
|
6
6
|
|
7
7
|
// Import all javascript files from src/_components
|
8
8
|
const componentsContext = require.context("bridgetownComponents", true, /.js$/)
|
@@ -20,18 +20,21 @@
|
|
20
20
|
"esbuild-loader": "^2.13.1",
|
21
21
|
"file-loader": "^6.2.0",
|
22
22
|
"mini-css-extract-plugin": "^1.3.1",
|
23
|
-
|
23
|
+
<%- if options["use-postcss"] -%>
|
24
24
|
"postcss": "^8.3.0",
|
25
25
|
"postcss-flexbugs-fixes": "^4.1.0",
|
26
26
|
"postcss-loader": "^4.3.0",
|
27
27
|
"postcss-preset-env": "^6.7.0",
|
28
|
-
|
28
|
+
<%- else -%>
|
29
29
|
"sass": "^1.32.8",
|
30
30
|
"sass-loader": "^8.0.2",
|
31
|
-
|
31
|
+
<%- end -%>
|
32
32
|
"webpack": "^5.39.1",
|
33
33
|
"webpack-cli": "^4.7.2",
|
34
34
|
"webpack-manifest-plugin": "^3.1.1",
|
35
35
|
"webpack-merge": "^5.8.0"
|
36
|
+
},
|
37
|
+
"resolutions": {
|
38
|
+
"postcss-focus-within": "^4.0.0"
|
36
39
|
}
|
37
40
|
}
|
data/lib/site_template/start.js
CHANGED
@@ -8,9 +8,9 @@ const port = 4001
|
|
8
8
|
// Concurrently
|
9
9
|
/////////////////
|
10
10
|
concurrently([
|
11
|
-
{ command: "yarn webpack-dev", name: "Webpack", prefixColor: "yellow"},
|
12
|
-
{ command: "sleep 4; yarn serve --port " + port, name: "Bridgetown", prefixColor: "green"},
|
13
|
-
{ command: "sleep 8; yarn sync", name: "Live", prefixColor: "blue"}
|
11
|
+
{ command: "yarn webpack-dev", name: "Webpack", prefixColor: "yellow" },
|
12
|
+
{ command: "sleep 4; yarn serve --port " + port, name: "Bridgetown", prefixColor: "green" },
|
13
|
+
{ command: "sleep 8; yarn sync", name: "Live", prefixColor: "blue" }
|
14
14
|
], {
|
15
15
|
restartTries: 3,
|
16
16
|
killOthers: ['failure', 'success'],
|
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: 0.21.
|
4
|
+
version: 0.21.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|