This repository has been archived by the owner on Mar 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
140 lines (113 loc) · 3.03 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# frozen_string_literal: true
task default: ['build', 'test:run']
# ------------------------------ #
# Dependencies
# ------------------------------ #
desc 'Install all the dependencies'
task install: ['bundle:unset_deployment_mode', 'bundle:unset_without'] do
Rake::Task['bundle:install'].execute
Rake::Task['yarn:install'].execute
end
desc 'Install only the production dependencies'
task install_prod: ['bundle:set_deployment_mode', 'bundle:without_non_prod'] do
Rake::Task['bundle:install'].execute
Rake::Task['yarn:install_prod'].execute
end
desc 'Upgrade all the dependencies'
task :upgrade do
Rake::Task['bundle:update'].execute
Rake::Task['yarn:upgrade'].execute
end
namespace :bundle do
desc 'Install Ruby dependencies using Bundler'
task :install do
sh 'bundle install'
end
desc 'Update Ruby dependencies using Bundler'
task :update do
sh 'bundle update'
end
desc 'Enable deployment mode in Bundler'
task :set_deployment_mode do
sh 'bundle config set deployment \'true\''
end
desc 'Disable deployment mode in Bundler'
task :unset_deployment_mode do
sh 'bundle config unset deployment'
end
desc 'Set the \'without\' option in Bundler for non-production ' \
'dependencies'
task :without_non_prod do
sh 'bundle config set without \'deployment test\''
end
desc 'Unset the \'without\' option in Bundler'
task :unset_without do
sh 'bundle config unset without'
end
end
namespace :yarn do
desc 'Install all the JavaScript dependencies using Yarn'
task :install do
sh 'yarn install'
end
desc 'Install only the production JavaScript dependencies using Yarn'
task :install_prod do
sh 'yarn install --production'
end
desc 'Upgrade the JavaScript dependencies using Yarn'
task :upgrade do
sh 'yarn upgrade'
end
end
# ------------------------------ #
# Build
# ------------------------------ #
desc 'Build the website'
task build: ['install'] do
Rake::Task['jekyll:build'].execute
end
desc 'Build the production-ready website'
task deploy: ['install_prod'] do
Rake::Task['jekyll:build'].execute
end
namespace :jekyll do
desc 'Build the Jekyll website'
task :build do
sh 'bundle exec jekyll build'
end
desc 'Clean the Jekyll website'
task :clean do
sh 'bundle exec jekyll clean'
end
desc 'Serve the Jekyll website locally'
task :serve do
sh 'bundle exec jekyll serve --future --drafts --incremental'
end
end
# ------------------------------ #
# Test
# ------------------------------ #
namespace :test do
desc 'Run all tests'
task :run do
Rake::Task['test:check_html'].execute
end
desc 'Check the HTML syntax'
task :check_html do
require 'html-proofer'
options = {
assume_extension: true,
check_favicon: true,
check_opengraph: true,
only_4xx: true
}
HTMLProofer.check_directory('./_site', options).run
end
end
# ------------------------------ #
# Clean up
# ------------------------------ #
desc 'Delete the build artifacts'
task :cleanup do
Rake::Task['jekyll:clean'].execute
end