bridgetown-core 2.0.5 → 2.1.0.beta1
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/.rubocop.yml +4 -2
- data/bin/bridgetown +19 -7
- data/bridgetown-core.gemspec +8 -6
- data/lib/bridgetown-core/collection.rb +4 -3
- data/lib/bridgetown-core/command.rb +97 -0
- data/lib/bridgetown-core/commands/application.rb +208 -0
- data/lib/bridgetown-core/commands/apply.rb +17 -29
- data/lib/bridgetown-core/commands/build.rb +9 -16
- data/lib/bridgetown-core/commands/clean.rb +7 -10
- data/lib/bridgetown-core/commands/concerns/{actions.rb → automations.rb} +103 -17
- data/lib/bridgetown-core/commands/concerns/build_options.rb +24 -60
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +2 -4
- data/lib/bridgetown-core/commands/configure.rb +24 -24
- data/lib/bridgetown-core/commands/console.rb +38 -34
- data/lib/bridgetown-core/commands/esbuild.rb +14 -24
- data/lib/bridgetown-core/commands/help.rb +24 -0
- data/lib/bridgetown-core/commands/new.rb +38 -60
- data/lib/bridgetown-core/commands/plugins.rb +237 -211
- data/lib/bridgetown-core/commands/registrations.rb +10 -1
- data/lib/bridgetown-core/commands/start.rb +23 -31
- data/lib/bridgetown-core/commands/thor_shim.rb +94 -0
- data/lib/bridgetown-core/component.rb +3 -3
- data/lib/bridgetown-core/concerns/publishable.rb +1 -3
- data/lib/bridgetown-core/concerns/site/localizable.rb +2 -0
- data/lib/bridgetown-core/configuration/configuration_dsl.rb +2 -2
- data/lib/bridgetown-core/configuration.rb +27 -7
- data/lib/bridgetown-core/converters/erb_templates.rb +31 -21
- data/lib/bridgetown-core/converters/ruby_templates.rb +14 -13
- data/lib/bridgetown-core/converters/serbea_templates.rb +5 -2
- data/lib/bridgetown-core/entry_filter.rb +1 -4
- data/lib/bridgetown-core/front_matter/defaults.rb +1 -1
- data/lib/bridgetown-core/front_matter/importer.rb +7 -1
- data/lib/bridgetown-core/front_matter/loaders.rb +1 -1
- data/lib/bridgetown-core/front_matter/ruby.rb +3 -9
- data/lib/bridgetown-core/generated_page.rb +2 -2
- data/lib/bridgetown-core/generators/prototype_generator.rb +1 -1
- data/lib/bridgetown-core/helpers.rb +10 -11
- data/lib/bridgetown-core/hooks.rb +2 -3
- data/lib/bridgetown-core/locale/en.yml +30 -0
- data/lib/bridgetown-core/model/base.rb +5 -5
- data/lib/bridgetown-core/model/builder_origin.rb +1 -1
- data/lib/bridgetown-core/model/origin.rb +5 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +3 -1
- data/lib/bridgetown-core/model/repo_origin.rb +3 -1
- data/lib/bridgetown-core/rack/routes.rb +1 -1
- data/lib/bridgetown-core/reader.rb +2 -2
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +31 -7
- data/lib/bridgetown-core/resource/base.rb +16 -7
- data/lib/bridgetown-core/resource/destination.rb +1 -1
- data/lib/bridgetown-core/resource/permalink_processor.rb +4 -4
- data/lib/bridgetown-core/static_file.rb +1 -1
- data/lib/bridgetown-core/tags/class_map.rb +0 -2
- data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +8 -11
- data/lib/bridgetown-core/{ruby_template_view.rb → template_view.rb} +108 -4
- data/lib/bridgetown-core/utils/initializers.rb +28 -1
- data/lib/bridgetown-core/utils/loaders_manager.rb +2 -1
- data/lib/bridgetown-core/utils.rb +19 -1
- data/lib/bridgetown-core/watcher.rb +16 -8
- data/lib/bridgetown-core.rb +5 -10
- data/lib/roda/plugins/bridgetown_server.rb +1 -1
- data/lib/site_template/README.md +10 -8
- metadata +84 -70
- data/lib/bridgetown-core/commands/base.rb +0 -123
- data/lib/bridgetown-core/commands/concerns/summarizable.rb +0 -13
- data/lib/bridgetown-core/configurations/.keep +0 -0
- data/lib/bridgetown-core/configurations/stimulus.rb +0 -59
- data/lib/bridgetown-core/configurations/turbo/turbo_transitions.js +0 -48
- data/lib/bridgetown-core/configurations/turbo.rb +0 -35
- data/lib/bridgetown-core/configurations/vercel/vercel.json +0 -45
- data/lib/bridgetown-core/configurations/vercel/vercel_url.rb +0 -12
- data/lib/bridgetown-core/configurations/vercel.rb +0 -4
- data/lib/bridgetown-core/inflector.rb +0 -40
|
@@ -2,263 +2,289 @@
|
|
|
2
2
|
|
|
3
3
|
module Bridgetown
|
|
4
4
|
module Commands
|
|
5
|
-
class Plugins <
|
|
6
|
-
|
|
7
|
-
include ConfigurationOverridable
|
|
8
|
-
include GitHelpers
|
|
9
|
-
|
|
10
|
-
Registrations.register do
|
|
11
|
-
desc "plugins <command>", "List installed plugins or access plugin content"
|
|
12
|
-
subcommand "plugins", Plugins
|
|
13
|
-
end
|
|
5
|
+
class Plugins < Bridgetown::Command
|
|
6
|
+
self.description = "List installed plugins or access plugin content"
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type: :boolean,
|
|
18
|
-
desc: "Print the source path of each plugin"
|
|
19
|
-
def list
|
|
20
|
-
config_options = configuration_with_overrides(options)
|
|
21
|
-
config_options.run_initializers! context: :static
|
|
22
|
-
site = Bridgetown::Site.new(config_options)
|
|
23
|
-
site.reset
|
|
24
|
-
Bridgetown::Hooks.trigger :site, :pre_read, site
|
|
8
|
+
class List < Bridgetown::Command
|
|
9
|
+
include ConfigurationOverridable
|
|
25
10
|
|
|
26
|
-
|
|
11
|
+
self.description = "List information about installed plugins"
|
|
27
12
|
|
|
28
|
-
|
|
13
|
+
def call # rubocop:disable Metrics
|
|
14
|
+
config_options = configuration_with_overrides(@options)
|
|
15
|
+
config_options.run_initializers! context: :static
|
|
16
|
+
site = Bridgetown::Site.new(config_options)
|
|
17
|
+
site.reset
|
|
18
|
+
Bridgetown::Hooks.trigger :site, :pre_read, site
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
plugins_list = config_options.initializers.values.sort_by(&:name)
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
plugin.to_s.end_with?("site_builder.rb") || plugin.to_s == "init (Initializer)"
|
|
34
|
-
end
|
|
22
|
+
pm = site.plugin_manager
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
plugins_list += pm.class.registered_plugins.to_a
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
plugins_list.reject! do |plugin|
|
|
27
|
+
plugin.to_s.end_with?("site_builder.rb") || plugin.to_s == "init (Initializer)"
|
|
28
|
+
end
|
|
40
29
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
Bridgetown.logger.info("Registered Plugins:", plugins_list.length.to_s.yellow.bold)
|
|
31
|
+
|
|
32
|
+
plugins_list.each do |plugin|
|
|
33
|
+
plugin_desc = plugin.to_s
|
|
34
|
+
|
|
35
|
+
if plugin.is_a?(Bridgetown::Configuration::Initializer)
|
|
36
|
+
Bridgetown.logger.info("", plugin_desc)
|
|
37
|
+
Bridgetown.logger.debug(
|
|
38
|
+
"", "PATH: #{plugin.block.source_location[0]}"
|
|
39
|
+
)
|
|
40
|
+
elsif plugin.is_a?(Bundler::StubSpecification) || plugin.is_a?(Gem::Specification)
|
|
41
|
+
Bridgetown.logger.info("", "#{plugin.name} (Rubygem)")
|
|
42
|
+
Bridgetown.logger.debug(
|
|
43
|
+
"", "PATH: #{plugin.full_gem_path}"
|
|
44
|
+
)
|
|
45
|
+
else
|
|
46
|
+
Bridgetown.logger.info("", plugin_desc.sub(site.in_root_dir("/"), ""))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Bridgetown.logger.debug("")
|
|
53
50
|
end
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
unless site.config.source_manifests.empty?
|
|
53
|
+
Bridgetown.logger.info("Source Manifests:", "----")
|
|
54
|
+
end
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
site.config.source_manifests.each do |manifest|
|
|
57
|
+
Bridgetown.logger.info("Origin:", (manifest.origin || "n/a").to_s.green)
|
|
58
|
+
Bridgetown.logger.info("Components:", (manifest.components || "n/a").to_s.cyan)
|
|
59
|
+
Bridgetown.logger.info("Contents:", (
|
|
60
|
+
manifest.contents&.map { |k, v| "#{v} (#{k})" }&.join(", ") || "n/a"
|
|
61
|
+
).to_s.cyan)
|
|
62
|
+
Bridgetown.logger.info("Layouts:", (manifest.layouts || "n/a").to_s.cyan)
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Bridgetown.logger.info("Components:", (manifest.components || "n/a").to_s.cyan)
|
|
65
|
-
Bridgetown.logger.info("Content:", (manifest.content || "n/a").to_s.cyan)
|
|
66
|
-
Bridgetown.logger.info("Layouts:", (manifest.layouts || "n/a").to_s.cyan)
|
|
64
|
+
Bridgetown.logger.info("", "----")
|
|
65
|
+
end
|
|
67
66
|
|
|
68
|
-
Bridgetown.
|
|
69
|
-
|
|
67
|
+
unless Bridgetown.autoload? :Builder
|
|
68
|
+
builders = Bridgetown::Builder.descendants
|
|
69
|
+
Bridgetown.logger.info("Builders:", builders.length.to_s.yellow.bold)
|
|
70
|
+
|
|
71
|
+
builders.sort.each do |builder|
|
|
72
|
+
name = plugin_name_for(builder)
|
|
73
|
+
name_components = name.split("::")
|
|
74
|
+
last_name = name_components.pop
|
|
75
|
+
name_components.push last_name.magenta
|
|
76
|
+
Bridgetown.logger.info("", name_components.join("::"))
|
|
77
|
+
Bridgetown.logger.debug(
|
|
78
|
+
"", "PATH: #{builder_path_for(builder)}"
|
|
79
|
+
)
|
|
80
|
+
Bridgetown.logger.debug("")
|
|
81
|
+
end
|
|
82
|
+
Bridgetown.logger.info("", "----")
|
|
83
|
+
end
|
|
70
84
|
|
|
71
|
-
|
|
72
|
-
builders = Bridgetown::Builder.descendants
|
|
73
|
-
Bridgetown.logger.info("Builders:", builders.length.to_s.yellow.bold)
|
|
85
|
+
Bridgetown.logger.info("Converters:", site.converters.length.to_s.yellow.bold)
|
|
74
86
|
|
|
75
|
-
|
|
76
|
-
name = plugin_name_for(
|
|
87
|
+
site.converters.each do |converter|
|
|
88
|
+
name = plugin_name_for(converter)
|
|
77
89
|
name_components = name.split("::")
|
|
78
90
|
last_name = name_components.pop
|
|
79
91
|
name_components.push last_name.magenta
|
|
80
92
|
Bridgetown.logger.info("", name_components.join("::"))
|
|
81
93
|
Bridgetown.logger.debug(
|
|
82
|
-
"", "PATH:
|
|
94
|
+
"", "PATH: #{converter_path_for(converter)}"
|
|
83
95
|
)
|
|
84
96
|
Bridgetown.logger.debug("")
|
|
85
97
|
end
|
|
98
|
+
|
|
86
99
|
Bridgetown.logger.info("", "----")
|
|
87
|
-
end
|
|
88
100
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
site.converters.each do |converter|
|
|
92
|
-
name = plugin_name_for(converter)
|
|
93
|
-
name_components = name.split("::")
|
|
94
|
-
last_name = name_components.pop
|
|
95
|
-
name_components.push last_name.magenta
|
|
96
|
-
Bridgetown.logger.info("", name_components.join("::"))
|
|
97
|
-
Bridgetown.logger.debug(
|
|
98
|
-
"", "PATH: " + converter_path_for(converter)
|
|
99
|
-
)
|
|
100
|
-
Bridgetown.logger.debug("")
|
|
101
|
-
end
|
|
101
|
+
Bridgetown.logger.info("Generators:", site.generators.length.to_s.yellow.bold)
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
site.generators.each do |generator|
|
|
104
|
+
name = plugin_name_for(generator)
|
|
105
|
+
name_components = name.split("::")
|
|
106
|
+
last_name = name_components.pop
|
|
107
|
+
name_components.push last_name.magenta
|
|
108
|
+
Bridgetown.logger.info("", name_components.join("::"))
|
|
109
|
+
Bridgetown.logger.debug(
|
|
110
|
+
"", "PATH: #{generator_path_for(generator)}"
|
|
111
|
+
)
|
|
112
|
+
Bridgetown.logger.debug("")
|
|
113
|
+
end
|
|
114
|
+
end
|
|
104
115
|
|
|
105
|
-
|
|
116
|
+
protected
|
|
106
117
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
last_name = name_components.pop
|
|
111
|
-
name_components.push last_name.magenta
|
|
112
|
-
Bridgetown.logger.info("", name_components.join("::"))
|
|
113
|
-
Bridgetown.logger.debug(
|
|
114
|
-
"", "PATH: " + generator_path_for(generator)
|
|
115
|
-
)
|
|
116
|
-
Bridgetown.logger.debug("")
|
|
118
|
+
def plugin_name_for(plugin)
|
|
119
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
|
120
|
+
klass.respond_to?(:custom_name) ? klass.custom_name : klass.name
|
|
117
121
|
end
|
|
118
|
-
end
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
set up on your site.\n
|
|
124
|
-
Then look for the origin of the manifest and the folder you'd like to
|
|
125
|
-
open.\n
|
|
126
|
-
So for example, with an origin of SamplePlugin and a folder of
|
|
127
|
-
Layouts, you'd run:\n
|
|
128
|
-
bridgetown plugins cd SamplePlugin/Layouts
|
|
129
|
-
DOC
|
|
130
|
-
desc "cd <origin/dir>", "Open content folder within the plugin origin"
|
|
131
|
-
|
|
132
|
-
# This is super useful if you want to copy files out of plugins to override.
|
|
133
|
-
#
|
|
134
|
-
# Example:
|
|
135
|
-
# bridgetown plugins cd AwesomePlugin/layouts
|
|
136
|
-
# cp -r * $BRIDGETOWN_SITE/src/_layouts
|
|
137
|
-
#
|
|
138
|
-
# Now all the plugin's layouts will be in the site repo directly.
|
|
139
|
-
#
|
|
140
|
-
def cd(arg)
|
|
141
|
-
config_options = configuration_with_overrides(options)
|
|
142
|
-
config_options.run_initializers! context: :static
|
|
143
|
-
|
|
144
|
-
directive = arg.split("/")
|
|
145
|
-
unless directive[1]
|
|
146
|
-
Bridgetown.logger.warn("Oops!", "Your command needs to be in the <origin/dir> format")
|
|
147
|
-
return
|
|
123
|
+
def builder_path_for(plugin)
|
|
124
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
|
125
|
+
klass.instance_method(:build).source_location[0]
|
|
148
126
|
end
|
|
149
127
|
|
|
150
|
-
|
|
151
|
-
|
|
128
|
+
def converter_path_for(plugin)
|
|
129
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
|
130
|
+
klass.instance_method(:convert).source_location[0]
|
|
152
131
|
end
|
|
153
132
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
" #{manifest.origin.to_s.cyan}…")
|
|
158
|
-
Bridgetown.logger.info("Type #{"exit".yellow} when you're done to" \
|
|
159
|
-
" return to your site root.")
|
|
160
|
-
puts
|
|
161
|
-
|
|
162
|
-
# rubocop: disable Style/RedundantCondition
|
|
163
|
-
Dir.chdir dir do
|
|
164
|
-
ENV["BRIDGETOWN_SITE"] = config_options.root_dir
|
|
165
|
-
if ENV["SHELL"]
|
|
166
|
-
system(ENV["SHELL"])
|
|
167
|
-
else
|
|
168
|
-
system("/bin/sh")
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
# rubocop: enable Style/RedundantCondition
|
|
172
|
-
|
|
173
|
-
puts
|
|
174
|
-
Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}")
|
|
175
|
-
else
|
|
176
|
-
Bridgetown.logger.warn("Oops!", "I wasn't able to find the" \
|
|
177
|
-
" #{directive[1]} folder for #{directive[0]}")
|
|
133
|
+
def generator_path_for(plugin)
|
|
134
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
|
135
|
+
klass.instance_method(:generate).source_location[0]
|
|
178
136
|
end
|
|
179
137
|
end
|
|
180
138
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
139
|
+
class New < Bridgetown::Command
|
|
140
|
+
using Bridgetown::Refinements
|
|
141
|
+
include Freyia::Setup
|
|
142
|
+
include Automations
|
|
143
|
+
include GitHelpers
|
|
144
|
+
|
|
145
|
+
self.description = "Create a new plugin"
|
|
146
|
+
|
|
147
|
+
one :name, "(snake_case_name_preferred)", required: true
|
|
148
|
+
|
|
149
|
+
def call # rubocop:disable Metrics
|
|
150
|
+
self.source_paths = [Dir.pwd]
|
|
151
|
+
self.destination_root = Dir.pwd
|
|
152
|
+
|
|
153
|
+
folder_name = name.underscore
|
|
154
|
+
module_name = folder_name.camelize
|
|
155
|
+
|
|
156
|
+
run "git clone https://github.com/bridgetownrb/bridgetown-sample-plugin #{name}"
|
|
157
|
+
new_gemspec = "#{folder_name}.gemspec"
|
|
158
|
+
|
|
159
|
+
inside name do # rubocop:todo Metrics/BlockLength
|
|
160
|
+
destroy_existing_repo
|
|
161
|
+
initialize_new_repo
|
|
162
|
+
|
|
163
|
+
FileUtils.mv "sample_plugin.gemspec", new_gemspec
|
|
164
|
+
gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
|
165
|
+
gsub_file new_gemspec, "bridgetown-sample-plugin", name
|
|
166
|
+
gsub_file new_gemspec, "sample_plugin", folder_name
|
|
167
|
+
gsub_file new_gemspec, "SamplePlugin", module_name
|
|
168
|
+
|
|
169
|
+
gsub_file "package.json", "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
|
170
|
+
gsub_file "package.json", "bridgetown-sample-plugin", name
|
|
171
|
+
gsub_file "package.json", "sample_plugin", folder_name
|
|
172
|
+
|
|
173
|
+
FileUtils.mv "lib/sample_plugin.rb", "lib/#{folder_name}.rb"
|
|
174
|
+
gsub_file "lib/#{folder_name}.rb", "sample_plugin", folder_name
|
|
175
|
+
gsub_file "lib/#{folder_name}.rb", "SamplePlugin", module_name
|
|
176
|
+
|
|
177
|
+
FileUtils.mv "lib/sample_plugin", "lib/#{folder_name}"
|
|
178
|
+
gsub_file "lib/#{folder_name}/builder.rb", "SamplePlugin", module_name
|
|
179
|
+
gsub_file "lib/#{folder_name}/builder.rb", "sample_plugin", folder_name
|
|
180
|
+
gsub_file "lib/#{folder_name}/version.rb", "SamplePlugin", module_name
|
|
181
|
+
|
|
182
|
+
FileUtils.mv "test/test_sample_plugin.rb", "test/test_#{folder_name}.rb"
|
|
183
|
+
gsub_file "test/test_#{folder_name}.rb", "SamplePlugin", module_name
|
|
184
|
+
gsub_file "test/test_#{folder_name}.rb", "sample plugin", module_name
|
|
185
|
+
gsub_file "test/helper.rb", "sample_plugin", folder_name
|
|
186
|
+
gsub_file "test/fixtures/src/index.html", "sample_plugin", folder_name
|
|
187
|
+
gsub_file "test/fixtures/config/initializers.rb", "sample_plugin", folder_name
|
|
188
|
+
|
|
189
|
+
FileUtils.mv "components/sample_plugin", "components/#{folder_name}"
|
|
190
|
+
FileUtils.mv "content/sample_plugin", "content/#{folder_name}"
|
|
191
|
+
FileUtils.mv "layouts/sample_plugin", "layouts/#{folder_name}"
|
|
192
|
+
|
|
193
|
+
gsub_file "layouts/#{folder_name}/layout.html", "sample_plugin", folder_name
|
|
194
|
+
gsub_file "content/#{folder_name}/example_page.md", "sample_plugin", folder_name
|
|
195
|
+
gsub_file "components/#{folder_name}/layout_help.liquid", "sample_plugin", folder_name
|
|
196
|
+
|
|
197
|
+
gsub_file "components/#{folder_name}/plugin_component.rb", "SamplePlugin", module_name
|
|
198
|
+
|
|
199
|
+
gsub_file "frontend/javascript/index.js", "sample_plugin", folder_name
|
|
200
|
+
gsub_file "frontend/javascript/index.js", "SamplePlugin", module_name
|
|
201
|
+
gsub_file "frontend/styles/index.css", "sample_plugin", folder_name
|
|
202
|
+
end
|
|
203
|
+
say ""
|
|
204
|
+
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
|
205
|
+
say_status "Remember:", "Don't forget to rename the SamplePlugin " \
|
|
206
|
+
"code identifiers and paths to your own " \
|
|
207
|
+
"identifier, as well as update your README " \
|
|
208
|
+
"and CHANGELOG files as necessary."
|
|
232
209
|
end
|
|
233
|
-
say ""
|
|
234
|
-
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
|
235
|
-
say_status "Remember:", "Don't forget to rename the SamplePlugin" \
|
|
236
|
-
" code identifiers and paths to your own" \
|
|
237
|
-
" identifier, as well as update your README" \
|
|
238
|
-
" and CHANGELOG files as necessary."
|
|
239
210
|
end
|
|
240
211
|
|
|
241
|
-
|
|
212
|
+
class CD < Bridgetown::Command
|
|
213
|
+
include ConfigurationOverridable
|
|
214
|
+
|
|
215
|
+
self.description = "Open content folder within the plugin origin"
|
|
216
|
+
|
|
217
|
+
one :path, <<~DOC.strip, required: true
|
|
218
|
+
Open a directory (content, layouts, etc.) within the plugin origin. \n
|
|
219
|
+
#{format("%c[0m", 27)}First: run bridgetown plugins list to view source manifests currently
|
|
220
|
+
#{format("%c[0m", 27)}set up on your site.\n
|
|
221
|
+
#{format("%c[0m", 27)}Then: look for the origin of the manifest and the folder you'd like to
|
|
222
|
+
#{format("%c[0m", 27)}open. Your project path is saved as the $BRIDGETOWN_SITE env var.\n
|
|
223
|
+
#{format("%c[0m", 27)}So for example, with an origin of SamplePlugin and a folder of
|
|
224
|
+
#{format("%c[0m", 27)}Layouts, you'd run:\n
|
|
225
|
+
$ bridgetown plugins cd SamplePlugin/Layouts
|
|
226
|
+
$ cp -r * $BRIDGETOWN_SITE/src/_layouts\n\n<path>
|
|
227
|
+
DOC
|
|
228
|
+
|
|
229
|
+
# This is super useful if you want to copy files out of plugins to override.
|
|
230
|
+
#
|
|
231
|
+
# Example:
|
|
232
|
+
# bridgetown plugins cd AwesomePlugin/layouts
|
|
233
|
+
# cp -r * $BRIDGETOWN_SITE/src/_layouts
|
|
234
|
+
#
|
|
235
|
+
# Now all the plugin's layouts will be in the site repo directly.
|
|
236
|
+
#
|
|
237
|
+
def call # rubocop:disable Metrics
|
|
238
|
+
config_options = configuration_with_overrides(@options)
|
|
239
|
+
config_options.run_initializers! context: :static
|
|
240
|
+
|
|
241
|
+
directive = path.split("/")
|
|
242
|
+
unless directive[1]
|
|
243
|
+
Bridgetown.logger.warn("Oops!", "Your command needs to be in the <origin/dir> format")
|
|
244
|
+
return
|
|
245
|
+
end
|
|
242
246
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
end
|
|
247
|
+
manifest = config_options.source_manifests.find do |source_manifest|
|
|
248
|
+
source_manifest.origin.to_s == directive[0]
|
|
249
|
+
end
|
|
247
250
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
if manifest.respond_to?(directive[1].downcase)
|
|
252
|
+
dir = manifest.send(directive[1].downcase)
|
|
253
|
+
Bridgetown.logger.info("Opening the #{dir.green} folder for " \
|
|
254
|
+
"#{manifest.origin.to_s.cyan}…")
|
|
255
|
+
Bridgetown.logger.info("Type #{"exit".yellow} when you're done to " \
|
|
256
|
+
"return to your site root.")
|
|
257
|
+
puts
|
|
258
|
+
|
|
259
|
+
Dir.chdir dir do
|
|
260
|
+
ENV["BRIDGETOWN_SITE"] = config_options.root_dir
|
|
261
|
+
system ENV.fetch("SHELL", "/bin/sh")
|
|
262
|
+
end
|
|
252
263
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
264
|
+
puts
|
|
265
|
+
Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}")
|
|
266
|
+
else
|
|
267
|
+
Bridgetown.logger.warn("Oops!", "I wasn't able to find the " \
|
|
268
|
+
"#{directive[1]} folder for #{directive[0]}")
|
|
269
|
+
end
|
|
270
|
+
end
|
|
256
271
|
end
|
|
257
272
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
273
|
+
nested :command, {
|
|
274
|
+
"list" => List,
|
|
275
|
+
"new" => New,
|
|
276
|
+
"cd" => CD,
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
def call
|
|
280
|
+
if @command
|
|
281
|
+
@command.call
|
|
282
|
+
else
|
|
283
|
+
print_usage
|
|
284
|
+
end
|
|
261
285
|
end
|
|
262
286
|
end
|
|
287
|
+
|
|
288
|
+
register_command :plugins, Plugins
|
|
263
289
|
end
|
|
264
290
|
end
|
|
@@ -7,9 +7,18 @@ module Bridgetown
|
|
|
7
7
|
@registrations ||= []
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def self.register(&block)
|
|
10
|
+
def self.register(klass = nil, name = nil, &block)
|
|
11
|
+
block ||= proc { register(klass, name) }
|
|
12
|
+
|
|
11
13
|
registrations << block
|
|
12
14
|
end
|
|
15
|
+
|
|
16
|
+
def self.load_registrations(command)
|
|
17
|
+
registrations.each do |block|
|
|
18
|
+
command.instance_exec(&block)
|
|
19
|
+
end
|
|
20
|
+
@registrations = []
|
|
21
|
+
end
|
|
13
22
|
end
|
|
14
23
|
end
|
|
15
24
|
end
|
|
@@ -28,45 +28,31 @@ module Bridgetown
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
module Commands
|
|
31
|
-
class Start <
|
|
32
|
-
extend BuildOptions
|
|
33
|
-
extend Summarizable
|
|
31
|
+
class Start < Bridgetown::Command
|
|
34
32
|
include ConfigurationOverridable
|
|
33
|
+
include Freyia::Setup
|
|
35
34
|
include Inclusive
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
self.description = "Start the web server, frontend bundler, and Bridgetown watcher"
|
|
37
|
+
|
|
38
|
+
options do
|
|
39
|
+
BuildOptions.include_options(self)
|
|
40
|
+
option "-P/--port <NUM>",
|
|
41
|
+
"Serve your site on the specified port. Defaults to 4000",
|
|
42
|
+
type: Integer
|
|
43
|
+
option "-B/--bind <IP>", "IP address for the server to bind to", default: "0.0.0.0"
|
|
44
|
+
option "--skip-frontend", "Don't load the frontend bundler (always true for production)"
|
|
45
|
+
option "--skip-live-reload",
|
|
46
|
+
"Don't use the live reload functionality (always true for production)"
|
|
40
47
|
end
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
aliases: "-P",
|
|
44
|
-
type: :numeric,
|
|
45
|
-
desc: "Serve your site on the specified port. Defaults to 4000."
|
|
46
|
-
class_option :bind,
|
|
47
|
-
aliases: "-B",
|
|
48
|
-
type: :string,
|
|
49
|
-
default: "0.0.0.0",
|
|
50
|
-
desc: "URL for the server to bind to."
|
|
51
|
-
class_option :skip_frontend,
|
|
52
|
-
type: :boolean,
|
|
53
|
-
desc: "Don't load the frontend bundler (always true for production)."
|
|
54
|
-
class_option :skip_live_reload,
|
|
55
|
-
type: :boolean,
|
|
56
|
-
desc: "Don't use the live reload functionality (always true for production)."
|
|
57
|
-
|
|
58
|
-
def self.banner
|
|
59
|
-
"bridgetown start [options]"
|
|
60
|
-
end
|
|
61
|
-
summary "Start the web server, frontend bundler, and Bridgetown watcher"
|
|
62
|
-
|
|
63
|
-
def start
|
|
49
|
+
def call # rubocop:disable Metrics
|
|
64
50
|
pid_tracker = packages[Bridgetown::Foundation::Packages::PidTracker]
|
|
65
51
|
Bridgetown.logger.writer.enable_prefix
|
|
66
52
|
Bridgetown::Commands::Build.print_startup_message
|
|
67
53
|
sleep 0.25
|
|
68
54
|
|
|
69
|
-
options =
|
|
55
|
+
options = HashWithDotAccess::Hash.new(self.options)
|
|
70
56
|
options[:start_command] = true
|
|
71
57
|
|
|
72
58
|
# Load Bridgetown configuration into thread memory
|
|
@@ -90,8 +76,8 @@ module Bridgetown
|
|
|
90
76
|
|
|
91
77
|
bt_options.skip_live_reload ||= !server.using_puma?
|
|
92
78
|
|
|
93
|
-
build_args = ["-w"] + ARGV
|
|
94
|
-
build_pid = Process.fork { Bridgetown::Commands::Build.
|
|
79
|
+
build_args = ["-w"] + Array(ARGV[1..])
|
|
80
|
+
build_pid = Process.fork { Bridgetown::Commands::Build[*build_args].() }
|
|
95
81
|
pid_tracker.add_pid(build_pid, file: :bridgetown)
|
|
96
82
|
|
|
97
83
|
after_stop_callback = -> {
|
|
@@ -141,5 +127,11 @@ module Bridgetown
|
|
|
141
127
|
options[:port] || ENV.fetch("BRIDGETOWN_PORT", config.port || 4000)
|
|
142
128
|
end
|
|
143
129
|
end
|
|
130
|
+
|
|
131
|
+
Dev = Start.dup
|
|
132
|
+
Dev.description = "Alias for the start command"
|
|
133
|
+
|
|
134
|
+
register_command :start, Start
|
|
135
|
+
register_command :dev, Dev
|
|
144
136
|
end
|
|
145
137
|
end
|