bridgetown-core 1.2.0.beta2 → 1.2.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 +0 -1
- data/lib/bridgetown-core/collection.rb +8 -1
- data/lib/bridgetown-core/commands/base.rb +2 -0
- data/lib/bridgetown-core/commands/concerns/actions.rb +41 -3
- data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +1 -1
- data/lib/bridgetown-core/configuration.rb +19 -10
- 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/esbuild-plugins.js +1 -1
- data/lib/bridgetown-core/configurations/lit.rb +10 -8
- data/lib/bridgetown-core/configurations/stimulus.rb +2 -2
- data/lib/bridgetown-core/configurations/tailwindcss.rb +4 -75
- data/lib/bridgetown-core/drops/drop.rb +1 -1
- data/lib/bridgetown-core/helpers.rb +8 -2
- data/lib/bridgetown-core/model/repo_origin.rb +4 -1
- data/lib/bridgetown-core/rack/roda.rb +2 -0
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +1 -1
- 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 -3
- data/lib/roda/plugins/method_override.rb +48 -0
- data/lib/site_template/config/initializers.rb +1 -1
- data/lib/site_template/package.json.erb +5 -2
- metadata +3 -4
- data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +0 -9
- data/lib/bridgetown-core/configurations/tailwindcss/postcss.config.js +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08e8af225c97352ea9bcd919e789a97324fb28e6b2db3c6b48855f9a28cc3174'
|
4
|
+
data.tar.gz: 6919f66af92cccfac42de96d715a5607be949d8718cbb1d445525a305fd9c337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff56bf0f74c78ca29f34f975ef53b21c3ca909dfd3089a73e83765cd573d9d330c7434f17192088d1ee009e60d39b52312de43758de061139e3f0e606bc9f82
|
7
|
+
data.tar.gz: 00ddd1d66a630f5e9ba30d693fc5df8feefaa455343bbb6c13100e87f0428b1ea33d2ff50b160ae1f1857294aebdf594d26111feb815d4f9249d00737c0cfe0e
|
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
|
+
# 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|
|
283
288
|
model.locale = locale
|
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]
|
@@ -52,13 +52,51 @@ module Bridgetown
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
55
|
+
def add_gem(gemname, group: nil, version: nil)
|
56
|
+
options = +""
|
57
|
+
options += " -v \"#{version}\"" if version
|
58
|
+
options += " -g #{group}" if group
|
59
|
+
run "bundle add #{gemname}#{options}",
|
58
60
|
env: { "BUNDLE_GEMFILE" => File.join(destination_root, "Gemfile") }
|
59
61
|
rescue SystemExit
|
60
62
|
say_status :run, "Gem not added due to bundler error", :red
|
61
63
|
end
|
64
|
+
alias_method :add_bridgetown_plugin, :add_gem
|
65
|
+
|
66
|
+
def add_initializer(name, data = "")
|
67
|
+
say_status :initializer, name
|
68
|
+
data = yield if block_given?
|
69
|
+
data = data.indent(2).lstrip
|
70
|
+
data = " #{data}" unless data.start_with?(",")
|
71
|
+
data += "\n" unless data.chars.last == "\n"
|
72
|
+
|
73
|
+
init_file = File.join("config", "initializers.rb")
|
74
|
+
unless File.exist?(init_file)
|
75
|
+
create_file("config/initializers.rb", verbose: true) do
|
76
|
+
File.read(File.expand_path("../../../site_template/config/initializers.rb", __dir__))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
inject_into_file init_file, %( init :"#{name}"#{data}),
|
81
|
+
before: %r!^end$!, verbose: false, force: false
|
82
|
+
end
|
83
|
+
|
84
|
+
def ruby_configure(name, data = "")
|
85
|
+
say_status :configure, name
|
86
|
+
data = yield if block_given?
|
87
|
+
data = data.indent(2)
|
88
|
+
data += "\n" unless data.chars.last == "\n"
|
89
|
+
|
90
|
+
init_file = File.join("config", "initializers.rb")
|
91
|
+
unless File.exist?(init_file)
|
92
|
+
create_file("config/initializers.rb", verbose: true) do
|
93
|
+
File.read(File.expand_path("../../../site_template/config/initializers.rb", __dir__))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
inject_into_file init_file, data,
|
98
|
+
before: %r!^end$!, verbose: false, force: false
|
99
|
+
end
|
62
100
|
|
63
101
|
def add_yarn_for_gem(gemname)
|
64
102
|
say_status :add_yarn, gemname
|
@@ -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",
|
@@ -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
|
@@ -147,6 +148,8 @@ module Bridgetown
|
|
147
148
|
dsl.instance_variable_set(:@context, context)
|
148
149
|
dsl.instance_exec(dsl, &init_init.block)
|
149
150
|
|
151
|
+
setup_load_paths! appending: true
|
152
|
+
|
150
153
|
self
|
151
154
|
end
|
152
155
|
|
@@ -323,16 +326,18 @@ module Bridgetown
|
|
323
326
|
self
|
324
327
|
end
|
325
328
|
|
326
|
-
def setup_load_paths! # rubocop:todo Metrics
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
329
|
+
def setup_load_paths!(appending: false) # rubocop:todo Metrics
|
330
|
+
unless appending
|
331
|
+
self[:root_dir] = File.expand_path(self[:root_dir])
|
332
|
+
self[:source] = File.expand_path(self[:source], self[:root_dir])
|
333
|
+
self[:destination] = File.expand_path(self[:destination], self[:root_dir])
|
334
|
+
|
335
|
+
if self[:plugins_use_zeitwerk]
|
336
|
+
autoload_paths.unshift({
|
337
|
+
path: self[:plugins_dir],
|
338
|
+
eager: true,
|
339
|
+
})
|
340
|
+
end
|
336
341
|
end
|
337
342
|
|
338
343
|
autoload_paths.map! do |load_path|
|
@@ -349,6 +354,10 @@ module Bridgetown
|
|
349
354
|
File.expand_path(collapsed_path, root_dir)
|
350
355
|
end
|
351
356
|
|
357
|
+
additional_watch_paths.map! do |collapsed_path|
|
358
|
+
File.expand_path(collapsed_path, root_dir)
|
359
|
+
end
|
360
|
+
|
352
361
|
self
|
353
362
|
end
|
354
363
|
|
@@ -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."
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// any additional configuration to the `plugins` array below.
|
4
4
|
|
5
5
|
// This plugin will let you import `.lit.css` files as sidecar stylesheets.
|
6
|
-
// Read https://
|
6
|
+
// Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
|
7
7
|
const { litCssPlugin } = require("esbuild-plugin-lit-css")
|
8
8
|
const postcssrc = require("postcss-load-config")
|
9
9
|
const postcss = require("postcss")
|
@@ -11,9 +11,9 @@ end
|
|
11
11
|
|
12
12
|
say_status :lit, "Installing Lit + SSR Plugin..."
|
13
13
|
|
14
|
-
|
14
|
+
add_gem "bridgetown-lit-renderer"
|
15
15
|
|
16
|
-
run "yarn add lit esbuild-plugin-lit-css bridgetown-lit-renderer
|
16
|
+
run "yarn add lit esbuild-plugin-lit-css bridgetown-lit-renderer"
|
17
17
|
|
18
18
|
copy_file in_templates_dir("lit-ssr.config.js"), "config/lit-ssr.config.js"
|
19
19
|
copy_file in_templates_dir("lit-components-entry.js"), "config/lit-components-entry.js"
|
@@ -35,10 +35,10 @@ gsub_file "esbuild.config.js", %r{const esbuildOptions = {}\n} do |_match|
|
|
35
35
|
const esbuildOptions = {
|
36
36
|
plugins: [...plugins],
|
37
37
|
// Uncomment the following to opt into `.global.css` & `.lit.css` nomenclature.
|
38
|
-
// Read https://
|
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
|
}
|
@@ -56,10 +56,10 @@ unless found_match
|
|
56
56
|
//
|
57
57
|
// You might also want to include the following in your esbuild config to opt into
|
58
58
|
// `.global.css` & `.lit.css` nomenclature.
|
59
|
-
// Read https://
|
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
|
@@ -78,10 +78,12 @@ insert_into_file "frontend/javascript/index.js",
|
|
78
78
|
before: 'import components from "bridgetownComponents/**/*.{js,jsx,js.rb,css}"' do
|
79
79
|
<<~JS
|
80
80
|
// To opt into `.global.css` & `.lit.css` nomenclature, change the `css` extension below to `global.css`.
|
81
|
-
// Read https://
|
81
|
+
// Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
|
82
82
|
JS
|
83
83
|
end
|
84
84
|
|
85
|
+
add_initializer :"bridgetown-lit-renderer"
|
86
|
+
|
85
87
|
if found_match
|
86
88
|
say_status :lit, "Lit is now configured!"
|
87
89
|
say_status :lit,
|
@@ -92,4 +94,4 @@ else
|
|
92
94
|
end
|
93
95
|
|
94
96
|
say "Check out the example `happy-days.lit.js` file in `src/_components`", :blue
|
95
|
-
say 'For further reading, check out "https://
|
97
|
+
say 'For further reading, check out "https://www.bridgetownrb.com/docs/components/lit"', :blue
|
@@ -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
|
@@ -1,77 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@logger.error "\nError:".red, "🚨 #{error_message}"
|
9
|
-
@logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
|
10
|
-
|
11
|
-
return
|
12
|
-
end
|
13
|
-
|
14
|
-
say_status :tailwind, "Installing Tailwind CSS..."
|
15
|
-
|
16
|
-
confirm = ask "This configuration will ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
|
17
|
-
return unless confirm.casecmp?("Y")
|
18
|
-
|
19
|
-
run "yarn add -D tailwindcss"
|
20
|
-
run "npx tailwindcss init"
|
21
|
-
|
22
|
-
gsub_file "tailwind.config.js", "content: [],", <<~JS.strip
|
23
|
-
content: [
|
24
|
-
'./src/**/*.{html,md,liquid,erb,serb,rb}',
|
25
|
-
'./frontend/javascript/**/*.js',
|
26
|
-
],
|
27
|
-
JS
|
28
|
-
|
29
|
-
copy_file in_templates_dir("postcss.config.js"), "postcss.config.js", force: true
|
30
|
-
|
31
|
-
if File.exist?("frontend/styles/index.css")
|
32
|
-
prepend_to_file "frontend/styles/index.css",
|
33
|
-
File.read(in_templates_dir("css_imports.css"))
|
34
|
-
else
|
35
|
-
say "\nPlease add the following lines to your CSS index file:"
|
36
|
-
say File.read(in_templates_dir("/css_imports.css"))
|
37
|
-
end
|
38
|
-
|
39
|
-
create_file "frontend/styles/jit-refresh.css", "/* #{Time.now.to_i} */"
|
40
|
-
|
41
|
-
insert_into_file "Rakefile",
|
42
|
-
after: %r{ task :(build|dev) do\n} do
|
43
|
-
<<-JS
|
44
|
-
sh "touch frontend/styles/jit-refresh.css"
|
45
|
-
JS
|
46
|
-
end
|
47
|
-
|
48
|
-
if File.exist?(".gitignore")
|
49
|
-
append_to_file ".gitignore" do
|
50
|
-
<<~FILES
|
51
|
-
|
52
|
-
frontend/styles/jit-refresh.css
|
53
|
-
FILES
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
create_builder "tailwind_jit.rb" do
|
58
|
-
<<~RUBY
|
59
|
-
class Builders::TailwindJit < SiteBuilder
|
60
|
-
def build
|
61
|
-
hook :site, :pre_reload do |_, paths|
|
62
|
-
# Don't trigger refresh if it's a frontend-only change
|
63
|
-
next if paths.length == 1 && paths.first.ends_with?("manifest.json")
|
64
|
-
|
65
|
-
# Save out a comment file to trigger Tailwind's JIT
|
66
|
-
refresh_file = site.in_root_dir("frontend", "styles", "jit-refresh.css")
|
67
|
-
File.write refresh_file, "/* \#{Time.now.to_i} */"
|
68
|
-
throw :halt # don't continue the build, wait for watcher rebuild
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
RUBY
|
73
|
-
end
|
74
|
-
|
75
|
-
say_status :tailwind, "Tailwind CSS is now configured."
|
76
|
-
|
77
|
-
# rubocop:enable all
|
3
|
+
say_status :tailwind, "The Tailwind CSS automation now lives in its own community-maintained repo:"
|
4
|
+
say "https://github.com/bridgetownrb/tailwindcss-automation"
|
5
|
+
say ""
|
6
|
+
say "Tailwind CSS not installed."
|
@@ -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
|
@@ -63,7 +63,7 @@ module Bridgetown
|
|
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
|
@@ -47,6 +47,8 @@ module Bridgetown
|
|
47
47
|
|
48
48
|
SiteContext = Struct.new(:registers) # for use by Liquid-esque URL helpers
|
49
49
|
|
50
|
+
plugin :method_override
|
51
|
+
plugin :all_verbs
|
50
52
|
plugin :hooks
|
51
53
|
plugin :common_logger, Bridgetown::Rack::Logger.new($stdout), method: :info
|
52
54
|
plugin :json
|
@@ -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
|
@@ -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
@@ -136,7 +136,7 @@ module Bridgetown
|
|
136
136
|
alias_method :env, :environment
|
137
137
|
|
138
138
|
def begin!
|
139
|
-
ENV["RACK_ENV"]
|
139
|
+
ENV["RACK_ENV"] ||= environment
|
140
140
|
|
141
141
|
Bridgetown::Current.preloaded_configuration = Bridgetown::Configuration::Preflight.new
|
142
142
|
Bridgetown::PluginManager.setup_bundler
|
@@ -230,11 +230,13 @@ module Bridgetown
|
|
230
230
|
|
231
231
|
def load_tasks
|
232
232
|
require "bridgetown-core/commands/base"
|
233
|
+
unless Bridgetown::Current.preloaded_configuration
|
234
|
+
Bridgetown::Current.preloaded_configuration = Bridgetown::Configuration::Preflight.new
|
235
|
+
end
|
233
236
|
Bridgetown::PluginManager.setup_bundler(skip_yarn: true)
|
237
|
+
|
234
238
|
if Bridgetown::Current.preloaded_configuration.is_a?(Bridgetown::Configuration::Preflight)
|
235
239
|
Bridgetown::Current.preloaded_configuration = Bridgetown.configuration
|
236
|
-
else
|
237
|
-
Bridgetown::Current.preloaded_configuration ||= Bridgetown.configuration
|
238
240
|
end
|
239
241
|
load File.expand_path("bridgetown-core/tasks/bridgetown_tasks.rake", __dir__)
|
240
242
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Roda
|
4
|
+
module RodaPlugins
|
5
|
+
# This is a simplified Roda plugin version of the Rack middleware:
|
6
|
+
# https://github.com/rack/rack/blob/v2.2.2/lib/rack/method_override.rb
|
7
|
+
module MethodOverride
|
8
|
+
def self.configure(app, opts = {})
|
9
|
+
app.opts[:method_override_param] = opts[:method_override_param] || "_method"
|
10
|
+
end
|
11
|
+
|
12
|
+
module RequestMethods
|
13
|
+
HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS PATCH LINK UNLINK).freeze
|
14
|
+
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE"
|
15
|
+
ALLOWED_METHODS = %w(POST).freeze
|
16
|
+
|
17
|
+
def initialize(scope, env)
|
18
|
+
super
|
19
|
+
return unless _allowed_methods.include?(env[Rack::REQUEST_METHOD])
|
20
|
+
|
21
|
+
method = _method_override(env)
|
22
|
+
return unless HTTP_METHODS.include?(method)
|
23
|
+
|
24
|
+
env[Rack::RACK_METHODOVERRIDE_ORIGINAL_METHOD] = env[Rack::REQUEST_METHOD]
|
25
|
+
env[Rack::REQUEST_METHOD] = method
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def _method_override(env)
|
31
|
+
method = _method_override_param ||
|
32
|
+
env[HTTP_METHOD_OVERRIDE_HEADER]
|
33
|
+
method.to_s.upcase
|
34
|
+
end
|
35
|
+
|
36
|
+
def _allowed_methods
|
37
|
+
ALLOWED_METHODS
|
38
|
+
end
|
39
|
+
|
40
|
+
def _method_override_param
|
41
|
+
params[scope.class.opts[:method_override_param]]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
register_plugin :method_override, MethodOverride
|
47
|
+
end
|
48
|
+
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
|
@@ -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.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -441,8 +441,6 @@ files:
|
|
441
441
|
- lib/bridgetown-core/configurations/shoelace.rb
|
442
442
|
- lib/bridgetown-core/configurations/stimulus.rb
|
443
443
|
- lib/bridgetown-core/configurations/tailwindcss.rb
|
444
|
-
- lib/bridgetown-core/configurations/tailwindcss/css_imports.css
|
445
|
-
- lib/bridgetown-core/configurations/tailwindcss/postcss.config.js
|
446
444
|
- lib/bridgetown-core/configurations/turbo.rb
|
447
445
|
- lib/bridgetown-core/configurations/turbo/turbo_transitions.js
|
448
446
|
- lib/bridgetown-core/configurations/vercel.rb
|
@@ -548,6 +546,7 @@ files:
|
|
548
546
|
- lib/roda/plugins/bridgetown_boot.rb
|
549
547
|
- lib/roda/plugins/bridgetown_ssr.rb
|
550
548
|
- lib/roda/plugins/initializers.rb
|
549
|
+
- lib/roda/plugins/method_override.rb
|
551
550
|
- lib/site_template/.gitignore
|
552
551
|
- lib/site_template/Gemfile.erb
|
553
552
|
- lib/site_template/README.md
|