bridgetown-core 1.2.0.beta3 → 1.2.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b1d92b4942102e7a3aba18f3a617d905bdb13bf7193a816cd444e26340935c7
4
- data.tar.gz: 6fdc5319169d9b2cc712680c0d73c12ea71364610172f7af5764d068c555457e
3
+ metadata.gz: '08e8af225c97352ea9bcd919e789a97324fb28e6b2db3c6b48855f9a28cc3174'
4
+ data.tar.gz: 6919f66af92cccfac42de96d715a5607be949d8718cbb1d445525a305fd9c337
5
5
  SHA512:
6
- metadata.gz: 7e82b661568cedb825c2de4c327b759169dad229e23a64bd256d28fa37cd64108901143ff882afe3b9db7393427a3863a33017bf414ccbe53c5ea12d148ba2cb
7
- data.tar.gz: 2f957ec8ade498fcce3667604779db33f4a5b71778e8c5d449afec3c56b224aa8c034d0c5eb0894d68c23b049a0db9a36c9db84bf05e76a1c1dd5dc59acc7683
6
+ metadata.gz: 6ff56bf0f74c78ca29f34f975ef53b21c3ca909dfd3089a73e83765cd573d9d330c7434f17192088d1ee009e60d39b52312de43758de061139e3f0e606bc9f82
7
+ data.tar.gz: 00ddd1d66a630f5e9ba30d693fc5df8feefaa455343bbb6c13100e87f0428b1ea33d2ff50b160ae1f1857294aebdf594d26111feb815d4f9249d00737c0cfe0e
data/.rubocop.yml CHANGED
@@ -25,7 +25,6 @@ AllCops:
25
25
 
26
26
  Lint/ConstantDefinitionInBlock:
27
27
  Exclude:
28
- - test/test_filters.rb
29
28
  - test/test_liquid_extensions.rb
30
29
  - test/test_site.rb
31
30
 
@@ -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
- site.config.available_locales.each do |locale|
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]
@@ -108,6 +108,8 @@ module Bridgetown
108
108
  end
109
109
  end
110
110
  end
111
+ rescue LoadError
112
+ nil
111
113
  end
112
114
  end
113
115
  end
@@ -67,6 +67,7 @@ module Bridgetown
67
67
  say_status :initializer, name
68
68
  data = yield if block_given?
69
69
  data = data.indent(2).lstrip
70
+ data = " #{data}" unless data.start_with?(",")
70
71
  data += "\n" unless data.chars.last == "\n"
71
72
 
72
73
  init_file = File.join("config", "initializers.rb")
@@ -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
@@ -353,6 +354,10 @@ module Bridgetown
353
354
  File.expand_path(collapsed_path, root_dir)
354
355
  end
355
356
 
357
+ additional_watch_paths.map! do |collapsed_path|
358
+ File.expand_path(collapsed_path, root_dir)
359
+ end
360
+
356
361
  self
357
362
  end
358
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 ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
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
- deploy:
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: bin/bridgetown deploy
29
+ run: bin/bridgetown deploy
30
30
 
31
- - name: Deploy
32
- uses: peaceiris/actions-gh-pages@v3
31
+ - name: Upload build artifact
32
+ uses: actions/upload-pages-artifact@v1
33
33
  with:
34
- github_token: ${{ secrets.GITHUB_TOKEN }}
35
- publish_dir: ./output
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 the branch `gh-pages`."
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."
@@ -38,7 +38,7 @@ gsub_file "esbuild.config.js", %r{const esbuildOptions = {}\n} do |_match|
38
38
  // Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
39
39
  /*
40
40
  postCssPluginConfig: {
41
- filter: /(?:index|\.global)\.css$/,
41
+ filter: /(?:index|\\.global)\\.css$/,
42
42
  },
43
43
  */
44
44
  }
@@ -59,7 +59,7 @@ unless found_match
59
59
  // Read https://www.bridgetownrb.com/docs/components/lit#sidecar-css-files for documentation.
60
60
  /*
61
61
  postCssPluginConfig: {
62
- filter: /(?:index|\.global)\.css$/,
62
+ filter: /(?:index|\\.global)\\.css$/,
63
63
  },
64
64
  */
65
65
  JS
@@ -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(/[_\-]controller\..*$/, "")
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, /\.js$/)
51
+ const context = require.context("./controllers", true, /\\.js$/)
52
52
  Stimulus.load(definitionsFromContext(context))
53
53
  JS
54
54
  end
@@ -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.mergable?(self[key]) && Utils.mergable?(other[key])
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
@@ -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, "bundle exec bridgetown frontend:dev"
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 mergable?(value)
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"] || "master"
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
- "master"
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 mergable?(old_val) && mergable?(new_val)
514
+ elsif mergeable?(old_val) && mergeable?(new_val)
512
515
  deep_merge_hashes(old_val, new_val)
513
516
  else
514
517
  new_val
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.2.0.beta3"
4
+ VERSION = "1.2.0.beta4"
5
5
  CODE_NAME = "Bonny Slope"
6
6
  end
@@ -42,7 +42,12 @@ module Bridgetown
42
42
  #
43
43
  # @param (see #watch)
44
44
  def load_paths_to_watch(site, options)
45
- (site.plugin_manager.plugins_path + options.autoload_paths).uniq.select do |path|
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
@@ -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
@@ -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/documentation/configuration/initializers/
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.14.39",
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"<%= "," if frontend_bundling_option == "webpack" || !postcss_option %>
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.beta3
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-10-09 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel