bridgetown-core 2.0.0.beta6 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d84ce34a5f59d6f344056c29003ebaca94ae161ad2ac6b0e65c431e55a83c85
4
- data.tar.gz: f09f1457b4a8afe31f15822ce0a453a4cbd049f30dc62cec82871f1d310bf43d
3
+ metadata.gz: 9889270f38c2b3d048f01c752698f114a7658cc04395dd7661c72bd0b56a7192
4
+ data.tar.gz: f08f67a0089dbe1cd2e2ace89b4cbff51a70caaf1d46982a0ab85982616e23bb
5
5
  SHA512:
6
- metadata.gz: 8b49a0456bcb39c02a6ca661f16ce30f693845d0460f30a00971785962d23402de1c3c96aa03c07dbf7c15dc9a3ddcb6fab3ccb2638a7e8226cd9ccf8ad1a7ce
7
- data.tar.gz: ce6c40abf5657a8c290899765384089793e5c01c54cb1122183d0523585c50ac4d9df422ac24e9cce04ad23f40107baaf255e2b84176752d19d4205316aa85ce
6
+ metadata.gz: d21d3bca29c9bb0cccf17fabdd1a66a00b720e72fd1803f48e33dcb8e210f492d16a7d5a517b26b5094bde1ae0507a0f86f9496fe0af810a8e2467908066c646
7
+ data.tar.gz: c5db97ee273e4f62bfeec5cb63251734bfffc6282eb87bf80a3e79e7c3b8716d5f9fee2b4233185233cae66b71da7aae93d9cab7ccbe2aeba35cd791527c5bd8
@@ -97,7 +97,7 @@ module Bridgetown
97
97
  ai.ipv4? && !ai.ipv4_loopback?
98
98
  end&.ip_address
99
99
  scheme = config_options.bind&.split("://")&.first == "ssl" ? "https" : "http"
100
- port = ENV.fetch("BRIDGETOWN_PORT", config_options.port)
100
+ port = config_options.port
101
101
  Bridgetown.logger.info ""
102
102
  Bridgetown.logger.info "Now serving at:", "#{scheme}://localhost:#{port}".magenta
103
103
  Bridgetown.logger.info "", "#{scheme}://#{external_ip}:#{port}".magenta if external_ip
@@ -16,6 +16,11 @@ module Bridgetown
16
16
  end
17
17
  summary "Creates a new Bridgetown site scaffold in PATH"
18
18
 
19
+ argument :path,
20
+ type: :string,
21
+ required: false, # we're changing for path in new_site method
22
+ desc: "PATH where new Bridgetown site will be created"
23
+
19
24
  class_option :apply,
20
25
  aliases: "-a",
21
26
  banner: "PATH|URL",
@@ -60,9 +65,9 @@ module Bridgetown
60
65
  end
61
66
 
62
67
  def new_site
63
- raise ArgumentError, "You must specify a path." if args.empty?
68
+ raise ArgumentError, "You must specify a path." if path.nil? || path.empty?
64
69
 
65
- new_site_path = File.expand_path(args.join(" "), Dir.pwd)
70
+ new_site_path = File.expand_path(path, Dir.pwd)
66
71
  @site_name = new_site_path.split(File::SEPARATOR).last
67
72
 
68
73
  if preserve_source_location?(new_site_path, options)
@@ -77,7 +82,7 @@ module Bridgetown
77
82
 
78
83
  say_status :create, new_site_path
79
84
  create_site new_site_path
80
- after_install new_site_path, args.join(" "), options
85
+ after_install new_site_path, path, options
81
86
  rescue ArgumentError => e
82
87
  say_status :alert, e.message, :red
83
88
  ensure
@@ -42,7 +42,6 @@ module Bridgetown
42
42
  class_option :port,
43
43
  aliases: "-P",
44
44
  type: :numeric,
45
- default: 4000,
46
45
  desc: "Serve your site on the specified port. Defaults to 4000."
47
46
  class_option :bind,
48
47
  aliases: "-B",
@@ -72,7 +71,7 @@ module Bridgetown
72
71
 
73
72
  # Load Bridgetown configuration into thread memory
74
73
  bt_options = configuration_with_overrides(options)
75
- port = ENV.fetch("BRIDGETOWN_PORT", bt_options.port)
74
+ bt_options.port = port = load_env_and_determine_port(bt_options, options)
76
75
  # TODO: support Puma serving HTTPS directly?
77
76
  bt_bound_url = "http://#{bt_options.bind}:#{port}"
78
77
 
@@ -125,6 +124,22 @@ module Bridgetown
125
124
  "config.ru" :
126
125
  File.expand_path("../rack/default_config.ru", __dir__)
127
126
  end
127
+
128
+ def load_env_and_determine_port(config, options)
129
+ initializer_file = File.join(config.root_dir, "config", "initializers.rb")
130
+ if File.exist?(initializer_file) &&
131
+ File.read(initializer_file) =~ (%r!^[\s]*init[\s]*:dotenv!)
132
+ require "dotenv"
133
+ Bridgetown.load_dotenv(root: config.root_dir)
134
+ end
135
+
136
+ # Options ordering for "who wins" is:
137
+ # 1. CLI
138
+ # 2. BRIDGETOWN_PORT env var
139
+ # 3. YAML config (if present)
140
+ # 4. 4000
141
+ options[:port] || ENV.fetch("BRIDGETOWN_PORT", config.port || 4000)
142
+ end
128
143
  end
129
144
  end
130
145
  end
@@ -3,6 +3,8 @@
3
3
  module Bridgetown
4
4
  class Configuration
5
5
  class ConfigurationDSL < Bridgetown::FrontMatter::RubyFrontMatter
6
+ include Bridgetown::Refinements::Helper
7
+
6
8
  attr_reader :context
7
9
 
8
10
  # @yieldself [ConfigurationDSL]
@@ -4,21 +4,20 @@
4
4
 
5
5
  // This plugin will let you import `.lit.css` files as sidecar stylesheets.
6
6
  // Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
7
- const { litCssPlugin } = require("esbuild-plugin-lit-css")
8
- const postcssrc = require("postcss-load-config")
9
- const postcss = require("postcss")
7
+ import { litCssPlugin } from "esbuild-plugin-lit-css"
8
+ import postcss from "postcss"
10
9
 
11
- module.exports = {
12
- plugins: [
13
- litCssPlugin({
14
- filter: /\.lit\.css$/,
15
- transform: async (css, { filePath }) => {
16
- const postCssConfig = await postcssrc()
17
- const postCssProcessor = postcss([...postCssConfig.plugins])
10
+ const postcssrc = (await import("postcss-load-config")).default
18
11
 
19
- const results = await postCssProcessor.process(css, { ...postCssConfig.options, from: filePath })
20
- return results.css
21
- }
22
- }),
23
- ]
24
- }
12
+ export const plugins = [
13
+ litCssPlugin({
14
+ filter: /\.lit\.css$/,
15
+ transform: async (css, { filePath }) => {
16
+ const postCssConfig = await postcssrc()
17
+ const postCssProcessor = postcss([...postCssConfig.plugins])
18
+
19
+ const results = await postCssProcessor.process(css, { ...postCssConfig.options, from: filePath })
20
+ return results.css
21
+ }
22
+ }),
23
+ ]
@@ -1,5 +1,5 @@
1
- const build = require("bridgetown-lit-renderer/build")
2
- const { plugins } = require("./esbuild-plugins.js")
1
+ import build from "bridgetown-lit-renderer/build"
2
+ import { plugins } from "./esbuild-plugins.js"
3
3
 
4
4
  const esbuildOptions = { plugins }
5
5
 
@@ -11,19 +11,19 @@ end
11
11
 
12
12
  say_status :lit, "Installing Lit + SSR Plugin..."
13
13
 
14
- add_gem "bridgetown-lit-renderer", version: "2.1.0.beta2"
14
+ add_gem "bridgetown-lit-renderer", version: "3.0.0"
15
15
 
16
- add_npm_package "lit esbuild-plugin-lit-css bridgetown-lit-renderer@2.1.0-beta2"
16
+ add_npm_package "lit esbuild-plugin-lit-css bridgetown-lit-renderer@3.0.0"
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"
20
20
  copy_file in_templates_dir("esbuild-plugins.js"), "config/esbuild-plugins.js"
21
21
 
22
22
  insert_into_file "esbuild.config.js",
23
- after: 'const build = require("./config/esbuild.defaults.js")' do
23
+ after: 'import build from "./config/esbuild.defaults.js"' do
24
24
  <<~JS
25
25
 
26
- const { plugins } = require("./config/esbuild-plugins.js")
26
+ import { plugins } from "./config/esbuild-plugins.js"
27
27
  JS
28
28
  end
29
29
 
@@ -1,13 +1,10 @@
1
1
  services:
2
2
  - type: web
3
3
  name: <%= @render_service_name %>
4
- env: static
4
+ runtime: static
5
5
  buildCommand: bin/bridgetown deploy
6
6
  staticPublishPath: ./output
7
7
  pullRequestPreviewsEnabled: true
8
- envVars:
9
- - key: BRIDGETOWN_ENV
10
- value: production
11
8
  headers:
12
9
  - path: /*
13
10
  name: X-Frame-Options
@@ -27,3 +24,42 @@ services:
27
24
  - path: /*
28
25
  name: Cache-Control
29
26
  value: "public, max-age=86400, s-max-age=86400"
27
+ envVars:
28
+ - key: BRIDGETOWN_ENV
29
+ value: production
30
+ ###########
31
+ # Uncomment and modify the following for hybrid deployments, database support, etc.
32
+ # Use the `routes` rewrite feature to "poke holes" through your static CDN to specific
33
+ # route handlers in your Roda server application.
34
+ ###########
35
+ #
36
+ # - key: DATABASE_URL
37
+ # fromDatabase:
38
+ # name: <%= @render_service_name %>_proddb
39
+ # property: connectionString
40
+ # - fromGroup: <%= @render_service_name %>-prod-envs
41
+ # routes:
42
+ # - type: rewrite
43
+ # source: /account/*
44
+ # destination: https://<%= @render_service_name %>-api.onrender.com/account/*
45
+ # - type: rewrite
46
+ # source: /auth/*
47
+ # destination: https://<%= @render_service_name %>-api.onrender.com/auth/*
48
+ # - type: web
49
+ # name: <%= @render_service_name %>-api
50
+ # plan: standard
51
+ # runtime: ruby
52
+ # buildCommand: bundle install && npm install && bin/bridgetown frontend:build
53
+ # startCommand: bin/bridgetown start
54
+ # envVars:
55
+ # - key: BRIDGETOWN_ENV
56
+ # value: production
57
+ # - key: DATABASE_URL
58
+ # fromDatabase:
59
+ # name: <%= @render_service_name %>_proddb
60
+ # property: connectionString
61
+ # - fromGroup: <%= @render_service_name %>-prod-envs
62
+ # databases:
63
+ # - name: <%= @render_service_name %>_proddb
64
+ # plan: starter
65
+ # databaseName: <%= @render_service_name %>_production
@@ -3,4 +3,11 @@
3
3
  @render_service_name = ask "What would like to call your Render service?"
4
4
  template in_templates_dir("render.yaml.erb"), "render.yaml"
5
5
 
6
- say "All done. Just create a new blueprint from the Render dashboard and connect this repo."
6
+ say_status :render, "Your render.yaml file is now configured!"
7
+ say ""
8
+ say "Verify its contents and once ready, create a new blueprint from the Render dashboard"
9
+ say "and connect your repo."
10
+ say ""
11
+ say "Optionally, if you're setting up a backend API and database, create a environment group"
12
+ say "on Render called [yourservicehere]-prod-envs for sharing environment variables between"
13
+ say "multiple servers."
@@ -6,6 +6,7 @@ module Bridgetown
6
6
  class RubyTemplateView
7
7
  class Helpers
8
8
  using Bridgetown::Refinements
9
+ include Bridgetown::Refinements::Helper
9
10
  include Bridgetown::Filters
10
11
  include Bridgetown::Filters::FromLiquid
11
12
  include ::Streamlined::Helpers
@@ -127,12 +128,10 @@ module Bridgetown
127
128
  # Provide backwards compatibility via Streamlined helper
128
129
  alias_method :attributes_from_options, :html_attributes
129
130
 
130
- # Delegates to <tt>I18n#translate</tt> but also performs two additional
131
- # functions.
131
+ # Delegates to `I18n#translate` but with some additional smarts.
132
132
  #
133
- # First, if the key starts with a period <tt>translate</tt> will scope
134
- # the key by the current view. Calling <tt>translate(".foo")</tt> from
135
- # the <tt>people/index.html.erb</tt> template is equivalent to calling
133
+ # You can scope to the current view. Calling <tt>translate(".foo")</tt> from
134
+ # the <tt>people/index.erb</tt> template is equivalent to calling
136
135
  # <tt>translate("people.index.foo")</tt>. This makes it less
137
136
  # repetitive to translate many keys within the same view and provides
138
137
  # a convention to scope keys consistently.
@@ -148,14 +147,14 @@ module Bridgetown
148
147
  #
149
148
  # @return [String] the translated string
150
149
  # @see I18n
151
- def translate(key, **options) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
150
+ def translate(key, **options)
152
151
  return key.map { |k| translate(k, **options) } if key.is_a?(Array)
153
152
 
154
153
  key = key&.to_s
155
154
 
156
155
  if key&.start_with?(".")
157
- view_path = view&.page&.relative_path&.to_s&.split(".")&.first
158
- key = "#{view_path.tr("/", ".")}#{key}" if view_path.present?
156
+ view_path = Bridgetown::Filters::URLFilters.strip_extname(view.resource.relative_path)
157
+ key = "#{view_path.tr("_/", " .").lstrip}#{key}"
159
158
  end
160
159
 
161
160
  return I18n.translate(key, **options) unless %r{(?:_|\b)html\z}.match?(key)
@@ -264,14 +263,19 @@ module Bridgetown
264
263
  end
265
264
  end
266
265
 
267
- # TODO: docu
266
+ # Output a declarative shadow DOM tag to wrap the input argument or block
267
+ #
268
+ # @param input [String] content to wrap if block isn't provided
269
+ # @return [String]
268
270
  def dsd(input = nil, &block)
269
271
  tmpl_content = block.nil? ? input.to_s : view.capture(&block)
270
272
 
271
273
  Bridgetown::Utils.dsd_tag(tmpl_content)
272
274
  end
273
275
 
274
- # TODO: docu
276
+ # Load a sidecar CSS file with a .dsd.css extension and output a style tag
277
+ #
278
+ # @return [String]
275
279
  def dsd_style
276
280
  tmpl_path = caller_locations(1, 2).find do |loc|
277
281
  loc.label.include?("method_missing").!
@@ -292,7 +296,8 @@ module Bridgetown
292
296
  style_tag.html_safe
293
297
  end
294
298
 
295
- # TODO: docu
299
+ # If you need to access signals without creating a tracking dependency, wrap a
300
+ # block of code in this helper
296
301
  def bypass_tracking(...) = Signalize.untracked(...)
297
302
  end
298
303
  end
@@ -102,7 +102,7 @@ module Bridgetown
102
102
 
103
103
  # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
104
104
 
105
- # Iterates through loaded gems and finds npm-add gemspec metadata.
105
+ # Iterates through loaded gems and finds npm_add gemspec metadata.
106
106
  # If that exact package hasn't been installed, execute npm i
107
107
  #
108
108
  # @return [Bundler::SpecSet]
@@ -134,7 +134,7 @@ module Bridgetown
134
134
  end
135
135
 
136
136
  def self.find_npm_dependency(loaded_gem)
137
- npm_metadata = loaded_gem.to_spec&.metadata&.dig("npm-add") ||
137
+ npm_metadata = loaded_gem.to_spec&.metadata&.dig("npm_add") ||
138
138
  loaded_gem.to_spec&.metadata&.dig("yarn-add")
139
139
  npm_dependency = npm_metadata&.match(NPM_DEPENDENCY_REGEXP)
140
140
  return nil if npm_dependency&.length != 3 || npm_dependency[2] == ""
@@ -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, "bridgetown frontend:dev"
14
+ Bridgetown::Utils::Aux.run_process "Frontend", :blue, "bridgetown frontend:dev"
15
15
 
16
16
  if sidecar
17
17
  # give FE bundler time to boot before returning control to the start command
@@ -102,6 +102,8 @@ class Roda
102
102
  end
103
103
 
104
104
  module InstanceMethods
105
+ include Bridgetown::Refinements::Helper
106
+
105
107
  def initialize_bridgetown_context
106
108
  if self.class.opts[:bridgetown_site]
107
109
  # The site had previously been initialized via the bridgetown_ssr plugin
@@ -157,9 +159,15 @@ class Roda
157
159
  scope.initialize_bridgetown_root
158
160
 
159
161
  base_path = Bridgetown::Current.preloaded_configuration.base_path.delete_prefix("/")
160
- on(base_path.empty? ? true : base_path) do
162
+
163
+ if base_path.empty?
161
164
  ssg # static file server
162
165
  Bridgetown::Rack::Routes.load_all scope
166
+ else
167
+ on(base_path) do
168
+ ssg # static file server
169
+ Bridgetown::Rack::Routes.load_all scope
170
+ end
163
171
  end
164
172
  end
165
173
  end
@@ -2,9 +2,10 @@
2
2
  #
3
3
  # Learn more at: https://puma.io
4
4
  # Bridgetown configuration documentation:
5
- # https://edge.bridgetownrb.com/docs/configuration/puma
5
+ # https://www.bridgetownrb.com/docs/configuration/puma
6
6
 
7
- # This port number can be overriden by a bind configuration option
7
+ # This port number typically gets overridden by Bridgetown's boot & config loader
8
+ # so you probably don't want to touch the number here
8
9
  #
9
10
  port ENV.fetch("BRIDGETOWN_PORT") { 4000 }
10
11
 
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: 2.0.0.beta6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-30 00:00:00.000000000 Z
11
+ date: 2025-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - '='
66
66
  - !ruby/object:Gem::Version
67
- version: 2.0.0.beta6
67
+ version: 2.0.0
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - '='
73
73
  - !ruby/object:Gem::Version
74
- version: 2.0.0.beta6
74
+ version: 2.0.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: csv
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -668,9 +668,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
668
668
  version: 3.1.0
669
669
  required_rubygems_version: !ruby/object:Gem::Requirement
670
670
  requirements:
671
- - - ">"
671
+ - - ">="
672
672
  - !ruby/object:Gem::Version
673
- version: 1.3.1
673
+ version: '0'
674
674
  requirements: []
675
675
  rubygems_version: 3.3.26
676
676
  signing_key: