bridgetown-core 1.2.0.beta2 → 1.2.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bridgetown-core/commands/concerns/actions.rb +40 -3
- data/lib/bridgetown-core/configuration.rb +14 -10
- data/lib/bridgetown-core/configurations/lit/esbuild-plugins.js +1 -1
- data/lib/bridgetown-core/configurations/lit.rb +8 -6
- data/lib/bridgetown-core/configurations/tailwindcss.rb +4 -75
- data/lib/bridgetown-core/rack/roda.rb +2 -0
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core.rb +1 -1
- data/lib/roda/plugins/method_override.rb +48 -0
- 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: 4b1d92b4942102e7a3aba18f3a617d905bdb13bf7193a816cd444e26340935c7
|
4
|
+
data.tar.gz: 6fdc5319169d9b2cc712680c0d73c12ea71364610172f7af5764d068c555457e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e82b661568cedb825c2de4c327b759169dad229e23a64bd256d28fa37cd64108901143ff882afe3b9db7393427a3863a33017bf414ccbe53c5ea12d148ba2cb
|
7
|
+
data.tar.gz: 2f957ec8ade498fcce3667604779db33f4a5b71778e8c5d449afec3c56b224aa8c034d0c5eb0894d68c23b049a0db9a36c9db84bf05e76a1c1dd5dc59acc7683
|
@@ -52,13 +52,50 @@ 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 += "\n" unless data.chars.last == "\n"
|
71
|
+
|
72
|
+
init_file = File.join("config", "initializers.rb")
|
73
|
+
unless File.exist?(init_file)
|
74
|
+
create_file("config/initializers.rb", verbose: true) do
|
75
|
+
File.read(File.expand_path("../../../site_template/config/initializers.rb", __dir__))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
inject_into_file init_file, %( init :"#{name}"#{data}),
|
80
|
+
before: %r!^end$!, verbose: false, force: false
|
81
|
+
end
|
82
|
+
|
83
|
+
def ruby_configure(name, data = "")
|
84
|
+
say_status :configure, name
|
85
|
+
data = yield if block_given?
|
86
|
+
data = data.indent(2)
|
87
|
+
data += "\n" unless data.chars.last == "\n"
|
88
|
+
|
89
|
+
init_file = File.join("config", "initializers.rb")
|
90
|
+
unless File.exist?(init_file)
|
91
|
+
create_file("config/initializers.rb", verbose: true) do
|
92
|
+
File.read(File.expand_path("../../../site_template/config/initializers.rb", __dir__))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
inject_into_file init_file, data,
|
97
|
+
before: %r!^end$!, verbose: false, force: false
|
98
|
+
end
|
62
99
|
|
63
100
|
def add_yarn_for_gem(gemname)
|
64
101
|
say_status :add_yarn, gemname
|
@@ -147,6 +147,8 @@ module Bridgetown
|
|
147
147
|
dsl.instance_variable_set(:@context, context)
|
148
148
|
dsl.instance_exec(dsl, &init_init.block)
|
149
149
|
|
150
|
+
setup_load_paths! appending: true
|
151
|
+
|
150
152
|
self
|
151
153
|
end
|
152
154
|
|
@@ -323,16 +325,18 @@ module Bridgetown
|
|
323
325
|
self
|
324
326
|
end
|
325
327
|
|
326
|
-
def setup_load_paths! # rubocop:todo Metrics
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
328
|
+
def setup_load_paths!(appending: false) # rubocop:todo Metrics
|
329
|
+
unless appending
|
330
|
+
self[:root_dir] = File.expand_path(self[:root_dir])
|
331
|
+
self[:source] = File.expand_path(self[:source], self[:root_dir])
|
332
|
+
self[:destination] = File.expand_path(self[:destination], self[:root_dir])
|
333
|
+
|
334
|
+
if self[:plugins_use_zeitwerk]
|
335
|
+
autoload_paths.unshift({
|
336
|
+
path: self[:plugins_dir],
|
337
|
+
eager: true,
|
338
|
+
})
|
339
|
+
end
|
336
340
|
end
|
337
341
|
|
338
342
|
autoload_paths.map! do |load_path|
|
@@ -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,7 +35,7 @@ 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
41
|
filter: /(?:index|\.global)\.css$/,
|
@@ -56,7 +56,7 @@ 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
62
|
filter: /(?:index|\.global)\.css$/,
|
@@ -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
|
@@ -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."
|
@@ -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
|
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
|
@@ -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
|
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.beta3
|
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-10-
|
11
|
+
date: 2022-10-09 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
|