bridgetown-core 1.0.0.alpha4 → 1.0.0.alpha8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +1 -2
- data/lib/bridgetown-core/cache.rb +1 -1
- data/lib/bridgetown-core/collection.rb +1 -1
- data/lib/bridgetown-core/commands/configure.rb +7 -0
- data/lib/bridgetown-core/commands/new.rb +3 -2
- data/lib/bridgetown-core/commands/start.rb +4 -2
- data/lib/bridgetown-core/component.rb +2 -2
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +1 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +6 -8
- data/lib/bridgetown-core/concerns/site/extensible.rb +2 -1
- data/lib/bridgetown-core/concerns/site/ssr.rb +38 -16
- data/lib/bridgetown-core/configuration.rb +77 -47
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -3
- data/lib/bridgetown-core/configurations/cypress/cypress.json +4 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/fixtures/example.json +5 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/integration/navbar.spec.js +17 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/plugins/index.js +21 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/support/commands.js +25 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/support/index.js +20 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_tasks +33 -0
- data/lib/bridgetown-core/configurations/cypress.rb +13 -0
- data/lib/bridgetown-core/configurations/minitesting.rb +19 -15
- data/lib/bridgetown-core/configurations/netlify/netlify.toml +2 -2
- data/lib/bridgetown-core/configurations/netlify.rb +2 -4
- data/lib/bridgetown-core/configurations/purgecss.rb +2 -2
- data/lib/bridgetown-core/configurations/render/render.yaml.erb +26 -0
- data/lib/bridgetown-core/configurations/render.rb +6 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +3 -5
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/core_ext/psych.rb +1 -5
- data/lib/bridgetown-core/frontmatter_defaults.rb +2 -2
- data/lib/bridgetown-core/liquid_renderer.rb +1 -1
- data/lib/bridgetown-core/model/base.rb +23 -26
- data/lib/bridgetown-core/model/builder_origin.rb +8 -6
- data/lib/bridgetown-core/model/origin.rb +10 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +9 -36
- data/lib/bridgetown-core/rack/boot.rb +46 -23
- data/lib/bridgetown-core/rack/roda.rb +2 -1
- data/lib/bridgetown-core/rack/routes.rb +2 -2
- data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +1 -1
- data/lib/bridgetown-core/renderer.rb +2 -2
- data/lib/bridgetown-core/resource/base.rb +3 -3
- data/lib/bridgetown-core/resource/relations.rb +1 -1
- data/lib/bridgetown-core/resource/taxonomy_term.rb +2 -2
- data/lib/bridgetown-core/resource/taxonomy_type.rb +2 -2
- data/lib/bridgetown-core/ruby_template_view.rb +2 -2
- data/lib/bridgetown-core/site.rb +15 -5
- data/lib/bridgetown-core/utils/loaders_manager.rb +72 -0
- data/lib/bridgetown-core/utils.rb +13 -14
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +16 -7
- data/lib/bridgetown-core/yaml_parser.rb +1 -5
- data/lib/site_template/README.md +1 -1
- data/lib/site_template/Rakefile +3 -3
- metadata +16 -6
- data/lib/bridgetown-core/tags/include.rb +0 -216
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d6ef82d9ee9b28132bda459264d887de83f704a67277a0c9d4046a755e2508
|
4
|
+
data.tar.gz: d39e9bb5399b5d5d7167cc20a81d3ce89fff1626c7ec13847cc5042b48a802e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff214944686584ddbc3ec0f853e60d233af3cc2d34a580141fe3771d76822770c6040429266b967133356588a01aec468b54fcd40d87cdffe844b1b307f48e85
|
7
|
+
data.tar.gz: d6028a5f062ae873bac66ff929315e884844aae412999180484316d774c5480849c854ea731f993419552693058ada6aeb2abef74c5176e98802acb6d1c5a274
|
data/bridgetown-core.gemspec
CHANGED
@@ -28,8 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.rdoc_options = ["--charset=UTF-8"]
|
30
30
|
|
31
|
-
s.required_ruby_version = ">= 2.
|
32
|
-
s.required_rubygems_version = ">= 2.7.0"
|
31
|
+
s.required_ruby_version = ">= 2.7.0"
|
33
32
|
|
34
33
|
s.add_runtime_dependency("activemodel", "~> 6.0")
|
35
34
|
s.add_runtime_dependency("activesupport", "~> 6.0")
|
@@ -144,7 +144,7 @@ module Bridgetown
|
|
144
144
|
@base_dir ||= File.join(Bridgetown::Cache.cache_dir, @name)
|
145
145
|
return @base_dir if hash.nil?
|
146
146
|
|
147
|
-
File.join(@base_dir, hash[0..1], hash[2
|
147
|
+
File.join(@base_dir, hash[0..1], hash[2..]).freeze
|
148
148
|
end
|
149
149
|
|
150
150
|
# Given a key, return a SHA2 hash that can be used for caching this item to disk.
|
@@ -234,7 +234,7 @@ module Bridgetown
|
|
234
234
|
end
|
235
235
|
|
236
236
|
resources.each do |data_resource|
|
237
|
-
segments = data_resource.relative_path.each_filename.to_a[1
|
237
|
+
segments = data_resource.relative_path.each_filename.to_a[1..]
|
238
238
|
nested = []
|
239
239
|
segments.each_with_index do |segment, index|
|
240
240
|
sanitized_segment = sanitize_filename.(File.basename(segment, ".*"))
|
@@ -41,6 +41,7 @@ module Bridgetown
|
|
41
41
|
configuration_file = find_in_source_paths("#{configuration}.rb")
|
42
42
|
|
43
43
|
inside(New.created_site_dir || Dir.pwd) do
|
44
|
+
@templates_dir = File.expand_path("../configurations/#{configuration}", __dir__)
|
44
45
|
apply configuration_file, verbose: false
|
45
46
|
end
|
46
47
|
end
|
@@ -62,6 +63,12 @@ module Bridgetown
|
|
62
63
|
return Dir.glob("*.rb").map { |file| file.sub(".rb", "") }
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
def in_templates_dir(*paths)
|
68
|
+
paths.reduce(@templates_dir) do |base, path|
|
69
|
+
Bridgetown.sanitized_path(base, path.to_s)
|
70
|
+
end
|
71
|
+
end
|
65
72
|
end
|
66
73
|
end
|
67
74
|
end
|
@@ -138,7 +138,7 @@ module Bridgetown
|
|
138
138
|
|
139
139
|
if @skipped_bundle
|
140
140
|
logger.info "Bundle install skipped.".yellow
|
141
|
-
logger.info "You will need to run #{"bundle
|
141
|
+
logger.info "You will need to run #{"bundle binstubs bridgetown-core".cyan} manually."
|
142
142
|
end
|
143
143
|
|
144
144
|
logger.info "Yarn install skipped.".yellow if @skipped_yarn
|
@@ -152,7 +152,8 @@ module Bridgetown
|
|
152
152
|
Bridgetown.with_unbundled_env do
|
153
153
|
inside(path) do
|
154
154
|
run "bundle install", abort_on_failure: true
|
155
|
-
run "bundle
|
155
|
+
run "bundle binstubs bridgetown-core"
|
156
|
+
run "cp bin/bridgetown bin/bt"
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end
|
@@ -30,8 +30,10 @@ module Bridgetown
|
|
30
30
|
Bridgetown::Commands::Build.print_startup_message
|
31
31
|
sleep 0.25
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
begin
|
34
|
+
require("puma/detect")
|
35
|
+
rescue LoadError
|
36
|
+
raise "** Puma server gem not found. Check your Gemfile and Bundler env? **"
|
35
37
|
end
|
36
38
|
|
37
39
|
options = Thor::CoreExt::HashWithIndifferentAccess.new(self.options)
|
@@ -164,9 +164,9 @@ module Bridgetown
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
|
167
|
+
def method_missing(method, *args, **kwargs, &block)
|
168
168
|
if helpers.respond_to?(method.to_sym)
|
169
|
-
helpers.send method.to_sym, *args, &block
|
169
|
+
helpers.send method.to_sym, *args, **kwargs, &block
|
170
170
|
else
|
171
171
|
super
|
172
172
|
end
|
@@ -32,7 +32,7 @@ module Bridgetown
|
|
32
32
|
self.front_matter_line_count = ruby_content[1].lines.size
|
33
33
|
process_ruby_data(ruby_content[1], file_path, 2)
|
34
34
|
elsif Bridgetown::Utils.has_rbfm_header?(file_path)
|
35
|
-
process_ruby_data(File.read(file_path).lines[1
|
35
|
+
process_ruby_data(File.read(file_path).lines[1..].join("\n"), file_path, 2)
|
36
36
|
elsif is_a?(Layout)
|
37
37
|
self.content = file_contents
|
38
38
|
{}
|
@@ -21,7 +21,6 @@ class Bridgetown::Site
|
|
21
21
|
|
22
22
|
configure_cache
|
23
23
|
configure_component_paths
|
24
|
-
configure_include_paths
|
25
24
|
configure_file_read_opts
|
26
25
|
|
27
26
|
self.permalink_style = (config["permalink"] || "pretty").to_sym
|
@@ -156,10 +155,10 @@ class Bridgetown::Site
|
|
156
155
|
Bridgetown::Cache.disable_disk_cache! if config["disable_disk_cache"]
|
157
156
|
end
|
158
157
|
|
159
|
-
def configure_component_paths
|
158
|
+
def configure_component_paths # rubocop:todo Metrics/AbcSize
|
160
159
|
# Loop through plugins paths first
|
161
160
|
plugin_components_load_paths = Bridgetown::PluginManager.source_manifests
|
162
|
-
.
|
161
|
+
.filter_map(&:components)
|
163
162
|
|
164
163
|
local_components_load_paths = config["components_dir"].yield_self do |dir|
|
165
164
|
dir.is_a?(Array) ? dir : [dir]
|
@@ -173,11 +172,10 @@ class Bridgetown::Site
|
|
173
172
|
end
|
174
173
|
end
|
175
174
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
@includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s))
|
175
|
+
config.components_load_paths = plugin_components_load_paths + local_components_load_paths
|
176
|
+
# Because "first constant wins" in Zeitwerk, we need to load the local
|
177
|
+
# source components _before_ we load any from plugins
|
178
|
+
config.autoload_paths += config.components_load_paths.reverse
|
181
179
|
end
|
182
180
|
|
183
181
|
def configure_file_read_opts
|
@@ -3,13 +3,14 @@
|
|
3
3
|
class Bridgetown::Site
|
4
4
|
module Extensible
|
5
5
|
# Load necessary libraries, plugins, converters, and generators.
|
6
|
+
# This is only ever run once for the lifecycle of the site object.
|
6
7
|
# @see Converter
|
7
8
|
# @see Generator
|
8
9
|
# @see PluginManager
|
9
10
|
# @return [void]
|
10
11
|
def setup
|
11
12
|
plugin_manager.require_plugin_files
|
12
|
-
|
13
|
+
loaders_manager.setup_loaders
|
13
14
|
self.converters = instantiate_subclasses(Bridgetown::Converter)
|
14
15
|
self.generators = instantiate_subclasses(Bridgetown::Generator)
|
15
16
|
end
|
@@ -8,29 +8,16 @@ class Bridgetown::Site
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
# Establish an SSR pipeline for a persistent backend process
|
11
|
-
def start_ssr!
|
11
|
+
def start_ssr!(loaders_manager: nil, &block)
|
12
12
|
if Bridgetown::Current.site
|
13
13
|
raise Bridgetown::Errors::FatalException, "Bridgetown SSR already started! " \
|
14
14
|
"Check your Rack app for threading issues"
|
15
15
|
end
|
16
16
|
|
17
17
|
Bridgetown::PluginManager.require_from_bundler
|
18
|
-
site = new(Bridgetown::Current.preloaded_configuration)
|
18
|
+
site = new(Bridgetown::Current.preloaded_configuration, loaders_manager: loaders_manager)
|
19
19
|
site.enable_ssr
|
20
|
-
|
21
|
-
Bridgetown::Hooks.trigger :site, :pre_read, site
|
22
|
-
site.defaults_reader.tap do |d|
|
23
|
-
d.path_defaults.clear
|
24
|
-
d.read
|
25
|
-
end
|
26
|
-
site.layouts = Bridgetown::LayoutReader.new(site).read
|
27
|
-
site.collections.data.tap do |coll|
|
28
|
-
coll.read
|
29
|
-
site.data = coll.merge_data_resources
|
30
|
-
end
|
31
|
-
Bridgetown::Hooks.trigger :site, :post_read, site
|
32
|
-
|
33
|
-
yield(site) if block_given? # provide additional setup hook
|
20
|
+
site.ssr_setup(&block)
|
34
21
|
|
35
22
|
site
|
36
23
|
end
|
@@ -45,6 +32,41 @@ class Bridgetown::Site
|
|
45
32
|
@ssr_enabled = true
|
46
33
|
end
|
47
34
|
|
35
|
+
def ssr_setup(&block) # rubocop:disable Metrics/AbcSize
|
36
|
+
config.serving = true
|
37
|
+
Bridgetown::Hooks.trigger :site, :pre_read, self
|
38
|
+
defaults_reader.tap do |d|
|
39
|
+
d.path_defaults.clear
|
40
|
+
d.read
|
41
|
+
end
|
42
|
+
reader.read_layouts
|
43
|
+
collections.data.tap do |coll|
|
44
|
+
coll.read
|
45
|
+
self.data = coll.merge_data_resources
|
46
|
+
end
|
47
|
+
Bridgetown::Hooks.trigger :site, :post_read, self
|
48
|
+
|
49
|
+
hook = block&.(self) # provide additional setup hook
|
50
|
+
return if Bridgetown.env.production?
|
51
|
+
|
52
|
+
@ssr_reload_hook = hook if hook.is_a?(Proc) && hook.lambda?
|
53
|
+
Bridgetown::Watcher.watch(self, config)
|
54
|
+
end
|
55
|
+
|
56
|
+
def ssr_reload
|
57
|
+
reset soft: true
|
58
|
+
reader.read_layouts
|
59
|
+
|
60
|
+
collections.data.tap do |coll|
|
61
|
+
coll.resources.clear
|
62
|
+
coll.read
|
63
|
+
coll.merge_data_resources.each do |k, v|
|
64
|
+
data[k] = v
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@ssr_reload_hook.() if @ssr_reload_hook.is_a?(Proc)
|
68
|
+
end
|
69
|
+
|
48
70
|
def disable_ssr
|
49
71
|
Bridgetown.logger.info "SSR:", "now disabled."
|
50
72
|
@ssr_enabled = false
|
@@ -11,65 +11,68 @@ module Bridgetown
|
|
11
11
|
# Strings rather than symbols are used for compatibility with YAML.
|
12
12
|
DEFAULTS = {
|
13
13
|
# Where things are
|
14
|
-
"root_dir"
|
15
|
-
"plugins_dir"
|
16
|
-
"source"
|
17
|
-
"destination"
|
18
|
-
"collections_dir"
|
19
|
-
"cache_dir"
|
20
|
-
"layouts_dir"
|
21
|
-
"data_dir"
|
22
|
-
"components_dir"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"taxonomies" => {
|
14
|
+
"root_dir" => Dir.pwd,
|
15
|
+
"plugins_dir" => "plugins",
|
16
|
+
"source" => File.join(Dir.pwd, "src"),
|
17
|
+
"destination" => File.join(Dir.pwd, "output"),
|
18
|
+
"collections_dir" => "",
|
19
|
+
"cache_dir" => ".bridgetown-cache",
|
20
|
+
"layouts_dir" => "_layouts",
|
21
|
+
"data_dir" => "_data",
|
22
|
+
"components_dir" => "_components",
|
23
|
+
"partials_dir" => "_partials",
|
24
|
+
"collections" => {},
|
25
|
+
"taxonomies" => {
|
27
26
|
category: { key: "categories", title: "Category" }, tag: { key: "tags", title: "Tag" },
|
28
27
|
},
|
28
|
+
"autoload_paths" => [],
|
29
|
+
"eager_load_paths" => [],
|
30
|
+
"autoloader_collapsed_paths" => [],
|
31
|
+
"plugins_use_zeitwerk" => true,
|
29
32
|
|
30
33
|
# Handling Reading
|
31
|
-
"include"
|
32
|
-
"exclude"
|
33
|
-
"keep_files"
|
34
|
-
"encoding"
|
35
|
-
"markdown_ext"
|
36
|
-
"strict_front_matter"
|
37
|
-
"slugify_mode"
|
34
|
+
"include" => [".htaccess", "_redirects", ".well-known"],
|
35
|
+
"exclude" => [],
|
36
|
+
"keep_files" => [".git", ".svn", "_bridgetown"],
|
37
|
+
"encoding" => "utf-8",
|
38
|
+
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
39
|
+
"strict_front_matter" => false,
|
40
|
+
"slugify_mode" => "pretty",
|
38
41
|
|
39
42
|
# Filtering Content
|
40
|
-
"future"
|
41
|
-
"unpublished"
|
42
|
-
"ruby_in_front_matter"
|
43
|
+
"future" => false,
|
44
|
+
"unpublished" => false,
|
45
|
+
"ruby_in_front_matter" => true,
|
43
46
|
|
44
47
|
# Conversion
|
45
|
-
"content_engine"
|
46
|
-
"markdown"
|
47
|
-
"highlighter"
|
48
|
-
"excerpt_separator"
|
48
|
+
"content_engine" => "resource",
|
49
|
+
"markdown" => "kramdown",
|
50
|
+
"highlighter" => "rouge",
|
51
|
+
"excerpt_separator" => "\n\n",
|
49
52
|
|
50
53
|
# Serving
|
51
|
-
"port"
|
52
|
-
"host"
|
53
|
-
"base_path"
|
54
|
-
"show_dir_listing"
|
54
|
+
"port" => "4000",
|
55
|
+
"host" => "127.0.0.1",
|
56
|
+
"base_path" => "/",
|
57
|
+
"show_dir_listing" => false,
|
55
58
|
|
56
59
|
# Output Configuration
|
57
|
-
"available_locales"
|
58
|
-
"default_locale"
|
59
|
-
"permalink"
|
60
|
-
"timezone"
|
60
|
+
"available_locales" => [:en],
|
61
|
+
"default_locale" => :en,
|
62
|
+
"permalink" => nil, # default is set according to content engine
|
63
|
+
"timezone" => nil, # use the local timezone
|
61
64
|
|
62
|
-
"quiet"
|
63
|
-
"verbose"
|
64
|
-
"defaults"
|
65
|
+
"quiet" => false,
|
66
|
+
"verbose" => false,
|
67
|
+
"defaults" => [],
|
65
68
|
|
66
|
-
"liquid"
|
69
|
+
"liquid" => {
|
67
70
|
"error_mode" => "warn",
|
68
71
|
"strict_filters" => false,
|
69
72
|
"strict_variables" => false,
|
70
73
|
},
|
71
74
|
|
72
|
-
"kramdown"
|
75
|
+
"kramdown" => {
|
73
76
|
"auto_ids" => true,
|
74
77
|
"toc_levels" => (1..6).to_a,
|
75
78
|
"entity_output" => "as_char",
|
@@ -99,6 +102,7 @@ module Bridgetown
|
|
99
102
|
def from(user_config, starting_defaults = DEFAULTS)
|
100
103
|
Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration[user_config])
|
101
104
|
.merge_environment_specific_options!
|
105
|
+
.setup_load_paths!
|
102
106
|
.setup_locales
|
103
107
|
.add_default_collections
|
104
108
|
.add_default_excludes
|
@@ -110,21 +114,21 @@ module Bridgetown
|
|
110
114
|
override[config_key] || self[config_key] || DEFAULTS[config_key]
|
111
115
|
end
|
112
116
|
|
113
|
-
#
|
117
|
+
# Directory of the top-level root where config files are located
|
114
118
|
#
|
115
|
-
# override
|
119
|
+
# @param override [Hash] options hash which will override value if key is present
|
116
120
|
#
|
117
|
-
#
|
118
|
-
def root_dir(override =
|
121
|
+
# @return [String] path to the Bridgetown root directory
|
122
|
+
def root_dir(override = {})
|
119
123
|
get_config_value_with_override("root_dir", override)
|
120
124
|
end
|
121
125
|
|
122
126
|
# Public: Directory of the Bridgetown source folder
|
123
127
|
#
|
124
|
-
# override
|
128
|
+
# @param override [Hash] options hash which will override value if key is present
|
125
129
|
#
|
126
|
-
#
|
127
|
-
def source(override =
|
130
|
+
# @return [String] path to the Bridgetown source directory
|
131
|
+
def source(override = {})
|
128
132
|
get_config_value_with_override("source", override)
|
129
133
|
end
|
130
134
|
|
@@ -241,6 +245,32 @@ module Bridgetown
|
|
241
245
|
self[k] = self[Bridgetown.environment][k]
|
242
246
|
end
|
243
247
|
delete(Bridgetown.environment)
|
248
|
+
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
def setup_load_paths!
|
253
|
+
if self[:plugins_use_zeitwerk]
|
254
|
+
autoload_paths.unshift({
|
255
|
+
path: self[:plugins_dir],
|
256
|
+
eager: true,
|
257
|
+
})
|
258
|
+
end
|
259
|
+
|
260
|
+
autoload_paths.map! do |load_path|
|
261
|
+
if load_path.is_a?(Hash)
|
262
|
+
expanded = File.expand_path(load_path[:path], root_dir)
|
263
|
+
self[:eager_load_paths] << expanded if load_path[:eager]
|
264
|
+
next expanded
|
265
|
+
end
|
266
|
+
|
267
|
+
File.expand_path(load_path, root_dir)
|
268
|
+
end
|
269
|
+
|
270
|
+
autoloader_collapsed_paths.map! do |collapsed_path|
|
271
|
+
File.expand_path(collapsed_path, root_dir)
|
272
|
+
end
|
273
|
+
|
244
274
|
self
|
245
275
|
end
|
246
276
|
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
# rubocop:disable all
|
4
4
|
|
5
|
-
TEMPLATE_PATH = File.expand_path("./bt-postcss", __dir__)
|
6
|
-
|
7
5
|
unless File.exist?("postcss.config.js")
|
8
6
|
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
9
7
|
|
@@ -21,6 +19,6 @@ plugins = %w(postcss-easy-import postcss-mixins postcss-color-function cssnano)
|
|
21
19
|
say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
|
22
20
|
run "yarn add -D #{plugins.join(' ')}"
|
23
21
|
|
24
|
-
copy_file "
|
22
|
+
copy_file in_templates_dir("postcss.config.js"), "postcss.config.js", force: true
|
25
23
|
|
26
24
|
# rubocop:enable all
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("Testing that links exist in the navbar", () => {
|
2
|
+
beforeEach(() => {
|
3
|
+
cy.visit("/");
|
4
|
+
});
|
5
|
+
it("navbar links appear on all pages", () => {
|
6
|
+
const baseUrl = Cypress.config("baseUrl");
|
7
|
+
|
8
|
+
cy.get('[href="/"]').click();
|
9
|
+
cy.url().should("eq", baseUrl + "/");
|
10
|
+
|
11
|
+
cy.get('[href="/posts"]').click();
|
12
|
+
cy.url().should("eq", baseUrl + "/posts");
|
13
|
+
|
14
|
+
cy.get('[href="/about"]').click();
|
15
|
+
cy.url().should("eq", baseUrl + "/about");
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/// <reference types="cypress" />
|
2
|
+
// ***********************************************************
|
3
|
+
// This example plugins/index.js can be used to load plugins
|
4
|
+
//
|
5
|
+
// You can change the location of this file or turn off loading
|
6
|
+
// the plugins file with the 'pluginsFile' configuration option.
|
7
|
+
//
|
8
|
+
// You can read more here:
|
9
|
+
// https://on.cypress.io/plugins-guide
|
10
|
+
// ***********************************************************
|
11
|
+
|
12
|
+
// This function is called when a project is opened or re-opened (e.g. due to
|
13
|
+
// the project's config changing)
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @type {Cypress.PluginConfig}
|
17
|
+
*/
|
18
|
+
module.exports = (on, config) => {
|
19
|
+
// `on` is used to hook into various events Cypress emits
|
20
|
+
// `config` is the resolved Cypress config
|
21
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// ***********************************************
|
2
|
+
// This example commands.js shows you how to
|
3
|
+
// create various custom commands and overwrite
|
4
|
+
// existing commands.
|
5
|
+
//
|
6
|
+
// For more comprehensive examples of custom
|
7
|
+
// commands please read more here:
|
8
|
+
// https://on.cypress.io/custom-commands
|
9
|
+
// ***********************************************
|
10
|
+
//
|
11
|
+
//
|
12
|
+
// -- This is a parent command --
|
13
|
+
// Cypress.Commands.add("login", (email, password) => { ... })
|
14
|
+
//
|
15
|
+
//
|
16
|
+
// -- This is a child command --
|
17
|
+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
18
|
+
//
|
19
|
+
//
|
20
|
+
// -- This is a dual command --
|
21
|
+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
22
|
+
//
|
23
|
+
//
|
24
|
+
// -- This will overwrite an existing command --
|
25
|
+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// ***********************************************************
|
2
|
+
// This example support/index.js is processed and
|
3
|
+
// loaded automatically before your test files.
|
4
|
+
//
|
5
|
+
// This is a great place to put global configuration and
|
6
|
+
// behavior that modifies Cypress.
|
7
|
+
//
|
8
|
+
// You can change the location of this file or turn off
|
9
|
+
// automatically serving support files with the
|
10
|
+
// 'supportFile' configuration option.
|
11
|
+
//
|
12
|
+
// You can read more here:
|
13
|
+
// https://on.cypress.io/configuration
|
14
|
+
// ***********************************************************
|
15
|
+
|
16
|
+
// Import commands.js using ES2015 syntax:
|
17
|
+
import './commands'
|
18
|
+
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
20
|
+
// require('./commands')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
namespace :cy do
|
2
|
+
desc "Open Cypress test runner"
|
3
|
+
task :open do
|
4
|
+
system "yarn run cypress open"
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Run Cypress tests headless"
|
8
|
+
task :run do
|
9
|
+
system "yarn run cypress run"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Start server and open Cypress test runner"
|
13
|
+
task :test do
|
14
|
+
ENV["BRIDGETOWN_ENV"] = "test"
|
15
|
+
server_pid = fork { Bridgetown::Commands::Start.start }
|
16
|
+
Rake::Task["cy:open"].execute
|
17
|
+
Process.kill "SIGTERM", server_pid
|
18
|
+
sleep 1 # give processes time to clean up
|
19
|
+
puts
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :test do
|
23
|
+
desc "Start server and run Cypress tests headless"
|
24
|
+
task :ci do
|
25
|
+
ENV["BRIDGETOWN_ENV"] = "test"
|
26
|
+
server_pid = fork { Bridgetown::Commands::Start.start }
|
27
|
+
Rake::Task["cy:run"].execute
|
28
|
+
Process.kill "SIGTERM", server_pid
|
29
|
+
sleep 1 # give processes time to clean up
|
30
|
+
puts
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Install packages
|
4
|
+
|
5
|
+
say "Installing Cypress...", :green
|
6
|
+
run "yarn add -D cypress"
|
7
|
+
|
8
|
+
# Copy cypress files and tasks into place
|
9
|
+
cypress_tasks = File.read(in_templates_dir("cypress_tasks"))
|
10
|
+
|
11
|
+
copy_file in_templates_dir("cypress.json"), "cypress.json"
|
12
|
+
inject_into_file("Rakefile", "\n#{cypress_tasks}")
|
13
|
+
directory in_templates_dir("cypress_dir"), "cypress"
|