bridgetown-core 0.20.0 → 0.21.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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/bridgetown-core.gemspec +0 -1
  3. data/lib/bridgetown-core.rb +11 -22
  4. data/lib/bridgetown-core/cleaner.rb +2 -2
  5. data/lib/bridgetown-core/collection.rb +14 -11
  6. data/lib/bridgetown-core/commands/build.rb +0 -11
  7. data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
  8. data/lib/bridgetown-core/commands/configure.rb +4 -3
  9. data/lib/bridgetown-core/commands/doctor.rb +1 -19
  10. data/lib/bridgetown-core/commands/new.rb +6 -6
  11. data/lib/bridgetown-core/commands/plugins.rb +14 -13
  12. data/lib/bridgetown-core/commands/serve.rb +0 -14
  13. data/lib/bridgetown-core/commands/webpack.rb +75 -0
  14. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
  15. data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
  16. data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
  17. data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
  18. data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +25 -11
  19. data/lib/bridgetown-core/component.rb +183 -0
  20. data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
  21. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  22. data/lib/bridgetown-core/concerns/site/configurable.rb +3 -7
  23. data/lib/bridgetown-core/concerns/site/content.rb +2 -3
  24. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
  25. data/lib/bridgetown-core/concerns/site/processable.rb +5 -4
  26. data/lib/bridgetown-core/concerns/site/writable.rb +1 -1
  27. data/lib/bridgetown-core/concerns/validatable.rb +1 -5
  28. data/lib/bridgetown-core/configuration.rb +22 -14
  29. data/lib/bridgetown-core/configurations/bt-postcss.rb +6 -6
  30. data/lib/bridgetown-core/configurations/netlify.rb +1 -0
  31. data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -6
  32. data/lib/bridgetown-core/converter.rb +9 -0
  33. data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
  34. data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
  35. data/lib/bridgetown-core/converters/markdown.rb +1 -1
  36. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +2 -38
  37. data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
  38. data/lib/bridgetown-core/converters/smartypants.rb +3 -1
  39. data/lib/bridgetown-core/core_ext/psych.rb +19 -0
  40. data/lib/bridgetown-core/document.rb +3 -2
  41. data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
  42. data/lib/bridgetown-core/drops/resource_drop.rb +3 -1
  43. data/lib/bridgetown-core/drops/unified_payload_drop.rb +1 -0
  44. data/lib/bridgetown-core/entry_filter.rb +7 -5
  45. data/lib/bridgetown-core/filters.rb +1 -25
  46. data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
  47. data/lib/bridgetown-core/filters/url_filters.rb +12 -0
  48. data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
  49. data/lib/bridgetown-core/generators/prototype_generator.rb +25 -4
  50. data/lib/bridgetown-core/helpers.rb +48 -9
  51. data/lib/bridgetown-core/layout.rb +52 -20
  52. data/lib/bridgetown-core/model/origin.rb +1 -1
  53. data/lib/bridgetown-core/model/{file_origin.rb → repo_origin.rb} +33 -26
  54. data/lib/bridgetown-core/page.rb +2 -1
  55. data/lib/bridgetown-core/plugin_manager.rb +1 -1
  56. data/lib/bridgetown-core/publisher.rb +2 -2
  57. data/lib/bridgetown-core/reader.rb +13 -11
  58. data/lib/bridgetown-core/readers/data_reader.rb +2 -1
  59. data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
  60. data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
  61. data/lib/bridgetown-core/readers/page_reader.rb +1 -0
  62. data/lib/bridgetown-core/readers/post_reader.rb +5 -4
  63. data/lib/bridgetown-core/regenerator.rb +1 -1
  64. data/lib/bridgetown-core/related_posts.rb +8 -5
  65. data/lib/bridgetown-core/renderer.rb +1 -1
  66. data/lib/bridgetown-core/resource/base.rb +80 -26
  67. data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
  68. data/lib/bridgetown-core/resource/relations.rb +132 -0
  69. data/lib/bridgetown-core/resource/taxonomy_term.rb +10 -1
  70. data/lib/bridgetown-core/resource/taxonomy_type.rb +9 -0
  71. data/lib/bridgetown-core/resource/transformer.rb +18 -14
  72. data/lib/bridgetown-core/ruby_template_view.rb +7 -11
  73. data/lib/bridgetown-core/site.rb +4 -5
  74. data/lib/bridgetown-core/tags/highlight.rb +2 -15
  75. data/lib/bridgetown-core/tags/include.rb +1 -1
  76. data/lib/bridgetown-core/tags/post_url.rb +2 -2
  77. data/lib/bridgetown-core/utils.rb +9 -3
  78. data/lib/bridgetown-core/utils/require_gems.rb +60 -0
  79. data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
  80. data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
  81. data/lib/bridgetown-core/version.rb +2 -2
  82. data/lib/bridgetown-core/watcher.rb +2 -1
  83. data/lib/bridgetown-core/yaml_parser.rb +22 -0
  84. data/lib/site_template/config/.keep +0 -0
  85. data/lib/site_template/package.json.erb +4 -4
  86. data/lib/site_template/plugins/site_builder.rb +1 -1
  87. data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
  88. metadata +21 -23
  89. data/lib/bridgetown-core/external.rb +0 -58
  90. data/lib/bridgetown-core/path_manager.rb +0 -31
  91. data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
  92. data/lib/bridgetown-core/utils/platforms.rb +0 -81
  93. data/lib/bridgetown-core/utils/thread_event.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c58653595832ef2fb9e6bbea3f147a0b3be9edae554d169e974570b84565a507
4
- data.tar.gz: 7af409e9a01570321171cf1afc562c00cacdcc6e0dce98f2b8eac4988a60e8d6
3
+ metadata.gz: b4c0ce7bce739e63c69f338a2b614156fcf1b287f4d0742ae159055bbc64c8a6
4
+ data.tar.gz: 3ecd352f397904b828a924fcc4e58813b8d9c0c37313bd17a7fab4a08600ba64
5
5
  SHA512:
6
- metadata.gz: b21d9c304dd99dd306b70e97e172d1ec172f0d1fa48034610cc3d9e6bc9c40b98e7fe10479226103cb2ff501c22c7c2841f20630235262cc7214661be62bcf3e
7
- data.tar.gz: cab7afb0f441e412850ce648d6e7ca9a3996f106b0800c31ef24a0cf63af9db770498f307da275860c0572d6d6f2a5f1e56570d10349bb11cd4f17f96b3266ee
6
+ metadata.gz: 2d17ec6dea80449358e73cc7c7c0d8ac1b3be7dd9d5a55d4d05771fbe59d7d7f27504c08143cb56b8d97e9c0329245c9f68476bfed2708d8915201c16f6ce1bc
7
+ data.tar.gz: 5ceb50825db51531cad5f9ae141d53a30791ef35ffeb44169911e764ce4ec6bcb082ce54f8a456da275853128dc8cd3768985fd1854001bab9cd0edc0ba057bc
@@ -47,7 +47,6 @@ Gem::Specification.new do |s|
47
47
  s.add_runtime_dependency("liquid-component", ">= 0.1")
48
48
  s.add_runtime_dependency("listen", "~> 3.0")
49
49
  s.add_runtime_dependency("rouge", "~> 3.0")
50
- s.add_runtime_dependency("safe_yaml", "~> 1.0")
51
50
  s.add_runtime_dependency("terminal-table", "~> 1.8")
52
51
  s.add_runtime_dependency("thor", "~> 1.1")
53
52
  s.add_runtime_dependency("tilt", "~> 2.0")
@@ -28,6 +28,7 @@ require "logger"
28
28
  require "set"
29
29
  require "csv"
30
30
  require "json"
31
+ require "yaml"
31
32
 
32
33
  # 3rd party
33
34
  require "active_support"
@@ -38,12 +39,12 @@ require "active_support/core_ext/object/deep_dup"
38
39
  require "active_support/core_ext/object/inclusion"
39
40
  require "active_support/core_ext/string/inflections"
40
41
  require "active_support/core_ext/string/inquiry"
42
+ require "active_support/core_ext/string/output_safety"
41
43
  require "active_support/core_ext/string/starts_ends_with"
42
44
  require "active_support/current_attributes"
43
45
  require "active_support/descendants_tracker"
44
46
  require "hash_with_dot_access"
45
47
  require "addressable/uri"
46
- require "safe_yaml/load"
47
48
  require "liquid"
48
49
  require "liquid-component"
49
50
  require "kramdown"
@@ -61,25 +62,13 @@ module HashWithDotAccess
61
62
  end
62
63
  end
63
64
 
64
- SafeYAML::OPTIONS[:suppress_warnings] = true
65
-
66
65
  # Create our little String subclass for Ruby Front Matter
67
66
  class Rb < String; end
68
- SafeYAML::OPTIONS[:whitelisted_tags] = ["!ruby/string:Rb"]
69
-
70
- if RUBY_VERSION.start_with?("3.0")
71
- # workaround for Ruby 3 preview 2, maybe can remove later
72
- # rubocop:disable Style/GlobalVars
73
- old_verbose = $VERBOSE
74
- $VERBOSE = nil
75
- SafeYAML::SafeToRubyVisitor.const_set(:INITIALIZE_ARITY, 2)
76
- $verbose = old_verbose
77
- # rubocop:enable Style/GlobalVars
78
- end
79
67
 
80
68
  module Bridgetown
81
69
  autoload :Cleaner, "bridgetown-core/cleaner"
82
70
  autoload :Collection, "bridgetown-core/collection"
71
+ autoload :Component, "bridgetown-core/component"
83
72
  autoload :Configuration, "bridgetown-core/configuration"
84
73
  autoload :DataAccessible, "bridgetown-core/concerns/data_accessible"
85
74
  autoload :Deprecator, "bridgetown-core/deprecator"
@@ -88,9 +77,8 @@ module Bridgetown
88
77
  # TODO: we have too many errors! This is silly
89
78
  autoload :Errors, "bridgetown-core/errors"
90
79
  autoload :Excerpt, "bridgetown-core/excerpt"
91
- # TODO: this is a poorly named, unclear class. Relocate to Utils:
92
- autoload :External, "bridgetown-core/external"
93
80
  autoload :FrontmatterDefaults, "bridgetown-core/frontmatter_defaults"
81
+ autoload :FrontMatterImporter, "bridgetown-core/concerns/front_matter_importer"
94
82
  autoload :Hooks, "bridgetown-core/hooks"
95
83
  autoload :Layout, "bridgetown-core/layout"
96
84
  autoload :LayoutPlaceable, "bridgetown-core/concerns/layout_placeable"
@@ -102,16 +90,12 @@ module Bridgetown
102
90
  autoload :LayoutReader, "bridgetown-core/readers/layout_reader"
103
91
  # TODO: remove this when legacy content engine is gone:
104
92
  autoload :PostReader, "bridgetown-core/readers/post_reader"
105
- # TODO: we can merge this back into Reader class:
93
+ # TODO: remove this when legacy content engine is gone:
106
94
  autoload :PageReader, "bridgetown-core/readers/page_reader"
107
95
  autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
108
- # TODO: also merge this:
109
- autoload :StaticFileReader, "bridgetown-core/readers/static_file_reader"
110
96
  autoload :LogAdapter, "bridgetown-core/log_adapter"
111
97
  autoload :Page, "bridgetown-core/page"
112
98
  autoload :GeneratedPage, "bridgetown-core/page"
113
- # TODO: figure out how to get rid of this seemingly banal class:
114
- autoload :PathManager, "bridgetown-core/path_manager"
115
99
  autoload :PluginManager, "bridgetown-core/plugin_manager"
116
100
  autoload :Publishable, "bridgetown-core/concerns/publishable"
117
101
  autoload :Publisher, "bridgetown-core/publisher"
@@ -131,6 +115,7 @@ module Bridgetown
131
115
  autoload :Validatable, "bridgetown-core/concerns/validatable"
132
116
  autoload :VERSION, "bridgetown-core/version"
133
117
  autoload :Watcher, "bridgetown-core/watcher"
118
+ autoload :YAMLParser, "bridgetown-core/yaml_parser"
134
119
 
135
120
  # extensions
136
121
  require "bridgetown-core/commands/registrations"
@@ -148,6 +133,7 @@ module Bridgetown
148
133
  require_all "bridgetown-core/drops"
149
134
  require_all "bridgetown-core/generators"
150
135
  require_all "bridgetown-core/tags"
136
+ require_all "bridgetown-core/core_ext"
151
137
 
152
138
  class << self
153
139
  # Tells you which Bridgetown environment you are building in so
@@ -265,7 +251,7 @@ module Bridgetown
265
251
  end
266
252
 
267
253
  # Conditional optimizations
268
- Bridgetown::External.require_if_present("liquid/c")
254
+ Bridgetown::Utils::RequireGems.require_if_present("liquid/c")
269
255
  end
270
256
  end
271
257
 
@@ -274,6 +260,9 @@ module Bridgetown
274
260
  module Resource; end
275
261
  end
276
262
 
263
+ # This method is available in Ruby 3, monkey patching for older versions
264
+ Psych.extend Bridgetown::CoreExt::Psych::SafeLoadFile unless Psych.respond_to?(:safe_load_file)
265
+
277
266
  loader = Zeitwerk::Loader.new
278
267
  loader.push_dir File.join(__dir__, "bridgetown-core/model"), namespace: Bridgetown::Model
279
268
  loader.push_dir File.join(__dir__, "bridgetown-core/resource"), namespace: Bridgetown::Resource
@@ -101,7 +101,7 @@ module Bridgetown
101
101
  #
102
102
  # Returns a Set with the directory paths
103
103
  def keep_dirs
104
- site.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set
104
+ site.config.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set
105
105
  end
106
106
 
107
107
  # Private: Creates a regular expression from the config's keep_files array
@@ -112,7 +112,7 @@ module Bridgetown
112
112
  #
113
113
  # Returns the regular expression
114
114
  def keep_file_regex
115
- %r!\A#{Regexp.quote(site.dest)}\/(#{Regexp.union(site.keep_files).source})!
115
+ %r!\A#{Regexp.quote(site.dest)}\/(#{Regexp.union(site.config.keep_files).source})!
116
116
  end
117
117
  end
118
118
  end
@@ -78,7 +78,8 @@ module Bridgetown
78
78
  if site.uses_resource?
79
79
  next if File.basename(file_path).starts_with?("_")
80
80
 
81
- if label == "data" || Utils.has_yaml_header?(full_path)
81
+ if label == "data" || Utils.has_yaml_header?(full_path) ||
82
+ Utils.has_rbfm_header?(full_path)
82
83
  read_resource(full_path)
83
84
  else
84
85
  read_static_file(file_path, full_path)
@@ -256,7 +257,7 @@ module Bridgetown
256
257
  sanitized_segment = sanitize_filename.(File.basename(segment, ".*"))
257
258
  hsh = nested.empty? ? data_contents : data_contents.dig(*nested)
258
259
  hsh[sanitized_segment] = if index == segments.length - 1
259
- data_resource.data.array || data_resource.data
260
+ data_resource.data.rows || data_resource.data
260
261
  else
261
262
  {}
262
263
  end
@@ -279,6 +280,16 @@ module Bridgetown
279
280
  data_contents
280
281
  end
281
282
 
283
+ # Read in resource from repo path
284
+ # @param full_path [String]
285
+ def read_resource(full_path)
286
+ id = "repo://#{label}.collection/" + Addressable::URI.escape(
287
+ Pathname(full_path).relative_path_from(Pathname(site.source)).to_s
288
+ )
289
+ resource = Bridgetown::Model::Base.find(id).to_resource.read!
290
+ resources << resource if site.config.unpublished || resource.published?
291
+ end
292
+
282
293
  private
283
294
 
284
295
  def container
@@ -287,15 +298,7 @@ module Bridgetown
287
298
 
288
299
  def read_document(full_path)
289
300
  doc = Document.new(full_path, site: site, collection: self).tap(&:read)
290
- docs << doc if site.unpublished || doc.published?
291
- end
292
-
293
- def read_resource(full_path)
294
- id = "file://#{label}.collection/" + Addressable::URI.escape(
295
- Pathname(full_path).relative_path_from(Pathname(site.source)).to_s
296
- )
297
- resource = Bridgetown::Model::Base.find(id).to_resource.read!
298
- resources << resource if site.unpublished || resource.published?
301
+ docs << doc if site.config.unpublished || doc.published?
299
302
  end
300
303
 
301
304
  def sort_docs!
@@ -79,17 +79,6 @@ module Bridgetown
79
79
  #
80
80
  # Returns nothing.
81
81
  def watch_site(config_options)
82
- # Warn Windows users that they might need to upgrade.
83
- if Utils::Platforms.bash_on_windows?
84
- Bridgetown.logger.warn "",
85
- "Auto-regeneration may not work on some Windows versions."
86
- Bridgetown.logger.warn "",
87
- "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
88
- Bridgetown.logger.warn "",
89
- "If it does not work, please upgrade Bash on Windows or "\
90
- "run Bridgetown with --no-watch."
91
- end
92
-
93
82
  Bridgetown::Watcher.watch(@site, config_options)
94
83
  end
95
84
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Commands
5
+ module GitHelpers
6
+ def initialize_new_repo
7
+ run "git init", abort_on_failure: true
8
+ `git symbolic-ref HEAD refs/heads/main` if user_default_branch.empty?
9
+ end
10
+
11
+ def destroy_existing_repo
12
+ run "rm -rf .git"
13
+ end
14
+
15
+ def user_default_branch
16
+ @user_default_branch ||= `git config init.defaultbranch`.strip
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,6 +4,7 @@ module Bridgetown
4
4
  module Commands
5
5
  class Configure < Thor::Group
6
6
  include Thor::Actions
7
+ include Actions
7
8
  extend Summarizable
8
9
 
9
10
  Registrations.register do
@@ -20,13 +21,13 @@ module Bridgetown
20
21
  end
21
22
 
22
23
  def perform_configurations
23
- logger = Bridgetown.logger
24
+ @logger = Bridgetown.logger
24
25
  list_configurations if args.empty?
25
26
 
26
27
  args.each do |configuration|
27
28
  configure configuration
28
29
  rescue Thor::Error
29
- logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
30
+ @logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
30
31
  end
31
32
  end
32
33
 
@@ -40,7 +41,7 @@ module Bridgetown
40
41
  configuration_file = find_in_source_paths("#{configuration}.rb")
41
42
 
42
43
  inside(New.created_site_dir || Dir.pwd) do
43
- Apply.new.invoke(:apply_automation, [configuration_file])
44
+ apply configuration_file, verbose: false
44
45
  end
45
46
  end
46
47
 
@@ -33,7 +33,6 @@ module Bridgetown
33
33
 
34
34
  def healthy?(site)
35
35
  [
36
- fsnotify_buggy?(site),
37
36
  !conflicting_urls(site),
38
37
  !urls_only_differ_by_case(site),
39
38
  proper_site_url?(site),
@@ -59,7 +58,7 @@ module Bridgetown
59
58
  conflicting_urls = false
60
59
  urls = {}
61
60
  urls = collect_urls(urls, site.pages, site.dest)
62
- urls = collect_urls(urls, site.posts.docs, site.dest)
61
+ urls = collect_urls(urls, site.collections.posts.docs, site.dest)
63
62
  urls.each do |url, paths|
64
63
  next unless paths.size > 1
65
64
 
@@ -70,23 +69,6 @@ module Bridgetown
70
69
  conflicting_urls
71
70
  end
72
71
 
73
- def fsnotify_buggy?(_site)
74
- return true unless Utils::Platforms.osx?
75
-
76
- if Dir.pwd != `pwd`.strip
77
- Bridgetown.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
78
- We have detected that there might be trouble using fsevent on your
79
- operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
80
- for possible work arounds or you can work around it immediately
81
- with `--force-polling`.
82
- STR
83
-
84
- false
85
- end
86
-
87
- true
88
- end
89
-
90
72
  def urls_only_differ_by_case(site)
91
73
  urls_only_differ_by_case = false
92
74
  urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
@@ -4,6 +4,7 @@ module Bridgetown
4
4
  module Commands
5
5
  class New < Thor::Group
6
6
  include Thor::Actions
7
+ include GitHelpers
7
8
  extend Summarizable
8
9
 
9
10
  Registrations.register do
@@ -85,10 +86,10 @@ module Bridgetown
85
86
  )
86
87
  template("Gemfile.erb", "Gemfile")
87
88
  template("package.json.erb", "package.json")
88
- template("webpack.config.js.erb", "webpack.config.js")
89
89
  template("frontend/javascript/index.js.erb", "frontend/javascript/index.js")
90
90
 
91
91
  options["use-postcss"] ? configure_postcss : configure_sass
92
+ invoke(Webpack, ["setup"], {})
92
93
  end
93
94
 
94
95
  def configure_sass
@@ -139,7 +140,7 @@ module Bridgetown
139
140
  # rubocop:enable Metrics/PerceivedComplexity
140
141
 
141
142
  def bundle_install(path)
142
- unless Bridgetown.environment == "test"
143
+ unless Bridgetown.environment.test?
143
144
  require "bundler"
144
145
  Bridgetown.with_unbundled_env do
145
146
  inside(path) do
@@ -155,10 +156,9 @@ module Bridgetown
155
156
  end
156
157
 
157
158
  def git_init(path)
158
- unless Bridgetown.environment == "test"
159
+ unless Bridgetown.environment.test?
159
160
  inside(path) do
160
- run "git init", abort_on_failure: true
161
- run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
161
+ initialize_new_repo
162
162
  end
163
163
  end
164
164
  rescue SystemExit
@@ -166,7 +166,7 @@ module Bridgetown
166
166
  end
167
167
 
168
168
  def yarn_install(path)
169
- unless Bridgetown.environment == "test"
169
+ unless Bridgetown.environment.test?
170
170
  inside(path) do
171
171
  run "yarn install", abort_on_failure: true
172
172
  end
@@ -5,6 +5,7 @@ module Bridgetown
5
5
  class Plugins < Thor
6
6
  include Thor::Actions
7
7
  include ConfigurationOverridable
8
+ include GitHelpers
8
9
 
9
10
  Registrations.register do
10
11
  desc "plugins <command>", "List installed plugins or access plugin content"
@@ -144,15 +145,15 @@ module Bridgetown
144
145
  name = folder_name.dasherize
145
146
  module_name = folder_name.camelize
146
147
 
147
- run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
148
+ # TODO: upon 0.21 release, remove the explicit branch name!
149
+ run "git clone -b switch-to-minitest https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
148
150
  new_gemspec = "#{name}.gemspec"
149
151
 
150
152
  inside name do # rubocop:todo Metrics/BlockLength
151
- run "rm -rf .git"
152
- run "git init"
153
- run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
153
+ destroy_existing_repo
154
+ initialize_new_repo
154
155
 
155
- run "mv bridgetown-sample-plugin.gemspec #{new_gemspec}"
156
+ FileUtils.mv "bridgetown-sample-plugin.gemspec", new_gemspec.to_s
156
157
  gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
157
158
  gsub_file new_gemspec, "bridgetown-sample-plugin", name
158
159
  gsub_file new_gemspec, "sample-plugin", name
@@ -161,21 +162,21 @@ module Bridgetown
161
162
  gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
162
163
  gsub_file "package.json", "bridgetown-sample-plugin", name
163
164
 
164
- run "mv lib/sample-plugin.rb lib/#{name}.rb"
165
+ FileUtils.mv "lib/sample-plugin.rb", "lib/#{name}.rb"
165
166
  gsub_file "lib/#{name}.rb", "sample-plugin", name
166
167
  gsub_file "lib/#{name}.rb", "SamplePlugin", module_name
167
168
 
168
- run "mv lib/sample-plugin lib/#{name}"
169
+ FileUtils.mv "lib/sample-plugin", "lib/#{name}"
169
170
  gsub_file "lib/#{name}/builder.rb", "SamplePlugin", module_name
170
171
  gsub_file "lib/#{name}/version.rb", "SamplePlugin", module_name
171
172
 
172
- run "mv spec/sample-plugin_spec.rb spec/#{name}_spec.rb"
173
- gsub_file "spec/#{name}_spec.rb", "SamplePlugin", module_name
174
- gsub_file "spec/spec_helper.rb", "sample-plugin", name
173
+ FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb"
174
+ gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name
175
+ gsub_file "test/helper.rb", "sample-plugin", name
175
176
 
176
- run "mv components/sample_plugin components/#{folder_name}"
177
- run "mv content/sample_plugin content/#{folder_name}"
178
- run "mv layouts/sample_plugin layouts/#{folder_name}"
177
+ FileUtils.mv "components/sample_plugin", "components/#{folder_name}"
178
+ FileUtils.mv "content/sample_plugin", "content/#{folder_name}"
179
+ FileUtils.mv "layouts/sample_plugin", "layouts/#{folder_name}"
179
180
 
180
181
  gsub_file "layouts/#{folder_name}/layout.html", "sample_plugin", folder_name
181
182
  gsub_file "content/#{folder_name}/example_page.md", "sample_plugin", folder_name
@@ -13,10 +13,6 @@ module Bridgetown
13
13
 
14
14
  class_option :host, aliases: "-H", desc: "Host to bind to"
15
15
  class_option :port, aliases: "-P", desc: "Port to listen on"
16
- class_option :open_url,
17
- aliases: "-o",
18
- type: :boolean,
19
- desc: "Launch your site in a browser"
20
16
  class_option :detach,
21
17
  aliases: "-B",
22
18
  type: :boolean,
@@ -169,16 +165,6 @@ module Bridgetown
169
165
  )
170
166
  end
171
167
 
172
- def launch_browser(server, opts)
173
- address = server_address(server, opts)
174
- return system "start", address if Utils::Platforms.windows?
175
- return system "xdg-open", address if Utils::Platforms.linux?
176
- return system "open", address if Utils::Platforms.osx?
177
-
178
- Bridgetown.logger.error "Refusing to launch browser; " \
179
- "Platform launcher unknown."
180
- end
181
-
182
168
  # Keep in our area with a thread or detach the server as requested
183
169
  # by the user. This method determines what we do based on what you
184
170
  # ask us to do.