lightning_sites 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/lightning_sites.rb +85 -80
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eb48e5d44bd72ee855567318c8be2bc02d0d6de
|
4
|
+
data.tar.gz: a9c29e9ecb2d496f8b54c63417e5cf544dfe22d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23303c02ecd83a909732985cafa913df1c3dd894e8c6b257d61b9935c3dffc68eb424a5555354f1c609eeaf756ce3e6eee8bac21728ac2673843016672aa5319
|
7
|
+
data.tar.gz: 91a2191df18eb191f0a22e53d93b2c74dce31ee46fb5c865cefc5d03c85a4f6875dd2318d89b5168d3bfd58061a4efc8e74fae060cc63f2d861dc52d10fb65a9
|
data/lib/lightning_sites.rb
CHANGED
@@ -3,32 +3,32 @@ require 'colorize'
|
|
3
3
|
# http://stackoverflow.com/a/11320444/300224
|
4
4
|
Rake::TaskManager.record_task_metadata = true
|
5
5
|
|
6
|
-
|
7
|
-
##
|
8
|
-
|
9
|
-
@source_dir = 'source' # Editable source code
|
10
|
-
@build_dir = '
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
6
|
+
################################################################################
|
7
|
+
## Your Rakefile can override these variables
|
8
|
+
################################################################################
|
9
|
+
@source_dir = 'source' # Editable source code, preferrably in git repo
|
10
|
+
@build_dir = 'BUILD' # Built HTML code
|
11
|
+
@backup_dir = 'BACKUPS' # Local home for backups of remote server
|
12
|
+
@remote_dir = '/dev/null' # Your remote server, use rsync format
|
13
|
+
@backup_targets = {} # Hash from local name to remote directory
|
14
|
+
# uses rsync naming format, example:
|
15
|
+
# {
|
16
|
+
# 'www' => 'horseslov@172.16.11.23:/www',
|
17
|
+
# 'logs' => 'horseslov@172.16.11.23:/logs'
|
18
|
+
# }
|
19
|
+
@build_excludes = [ # Files you do NOT want copied from SOURCE to BUILD
|
20
|
+
'Gemfile', # use rsync format
|
21
|
+
'Gemfile.lock',
|
22
|
+
'.bundle',
|
23
|
+
'.git',
|
24
|
+
'/tmp'
|
25
|
+
]
|
26
|
+
|
27
|
+
def create_build_dir (build_dir=@build_dir)
|
28
|
+
FileUtils.mkdir_p build_dir
|
29
|
+
#TODO: output if directory did not exist and we created it
|
29
30
|
end
|
30
31
|
|
31
|
-
# Note: this stuff works even if only your SOURCE_DIR is checked into git
|
32
32
|
namespace :git do
|
33
33
|
def source_dir_is_git?
|
34
34
|
return false if !File.directory?(@source_dir)
|
@@ -37,9 +37,13 @@ namespace :git do
|
|
37
37
|
|
38
38
|
desc "Incorporate changes from the remote repository into the current branch"
|
39
39
|
task :pull do
|
40
|
-
|
40
|
+
if !source_dir_is_git?
|
41
|
+
puts "There is no git directory, skipping"
|
42
|
+
next
|
43
|
+
end
|
44
|
+
puts '⚡️ Pulling git'.blue
|
41
45
|
sh "cd '#{@source_dir}'; git pull"
|
42
|
-
puts 'Pulled'.green
|
46
|
+
puts '✅ Pulled'.green
|
43
47
|
end
|
44
48
|
|
45
49
|
desc "Displays paths that have differences between the index file and the current HEAD commit"
|
@@ -58,8 +62,10 @@ namespace :git do
|
|
58
62
|
puts "There is no git directory, skipping"
|
59
63
|
next
|
60
64
|
end
|
65
|
+
puts '📋 Here is the modification date for each file'.blue
|
66
|
+
sh "cd #{@source_dir} && git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --date=short --format='%ad {}' {}", noop: true
|
61
67
|
puts 'Modified File'.blue
|
62
|
-
sh "cd #{@source_dir} && git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --date=short --format='%ad {}' {}"
|
68
|
+
sh "cd #{@source_dir} && git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --date=short --format='%ad {}' {}", verbose: false
|
63
69
|
end
|
64
70
|
|
65
71
|
desc "Save the commit hash to VERSION in the build directory"
|
@@ -70,7 +76,7 @@ namespace :git do
|
|
70
76
|
end
|
71
77
|
hash = `cd #{@source_dir} && git rev-parse HEAD`.chomp
|
72
78
|
local_changes = `git diff --shortstat`.chomp.length
|
73
|
-
File.write(
|
79
|
+
File.write(@build_dir + '/VERSION', local_changes ? "#{hash}*\n" : "#{hash}*")
|
74
80
|
puts 'Saved git version to VERSION file'.green
|
75
81
|
end
|
76
82
|
end
|
@@ -79,6 +85,7 @@ end
|
|
79
85
|
namespace :jekyll do
|
80
86
|
desc "Build Jekyll site"
|
81
87
|
task :build do
|
88
|
+
create_build_dir
|
82
89
|
puts 'Building Jekyll'.blue
|
83
90
|
sh "jekyll build --incremental --source '#{@source_dir}' --destination '#{@build_dir}'"
|
84
91
|
puts 'Built'.green
|
@@ -86,6 +93,7 @@ namespace :jekyll do
|
|
86
93
|
|
87
94
|
desc "Run a Jekyll test server"
|
88
95
|
task :test do
|
96
|
+
create_build_dir
|
89
97
|
puts 'Running test server'.blue
|
90
98
|
sh "jekyll serve --source '#{@source_dir}' --destination '#{@build_dir}'"
|
91
99
|
end
|
@@ -93,51 +101,51 @@ end
|
|
93
101
|
|
94
102
|
# Interact with a production environment
|
95
103
|
namespace :rsync do
|
96
|
-
desc "Copy the source directory to the build directory"
|
104
|
+
desc "Copy the source directory to the build directory, excluding some files"
|
97
105
|
task :copy_build do
|
98
106
|
puts 'Copying source directory to build directory'.blue
|
99
|
-
rsync_opts =
|
100
|
-
from =
|
101
|
-
to =
|
102
|
-
|
107
|
+
rsync_opts = %w[--archive --delete]
|
108
|
+
from = @source_dir + '/'
|
109
|
+
to = @build_dir + '/'
|
110
|
+
@build_excludes.each do |exclude|
|
111
|
+
rsync_opts << '--exclude'
|
112
|
+
rsync_opts << exclude
|
113
|
+
end
|
114
|
+
sh 'rsync', *rsync_opts, from, to
|
103
115
|
puts 'Copied'.green
|
104
116
|
end
|
105
117
|
|
106
|
-
desc "Bring
|
107
|
-
task :pull do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
sh "rsync #{rsync_opts} '#{remote}' '#{local}'"
|
118
|
+
desc "Bring remote files to build directory (use rsync-style paths)"
|
119
|
+
task :pull, [:remote] do |t, args|
|
120
|
+
args.with_defaults(:remote => @remote_dir)
|
121
|
+
puts 'Pulling website from remote'.blue
|
122
|
+
rsync_opts = %w[-vr --delete]
|
123
|
+
from = args.remote + '/'
|
124
|
+
to = @build_dir + '/'
|
125
|
+
sh 'rsync', *rsync_opts, from, to
|
115
126
|
puts 'Pulled'.green
|
116
127
|
end
|
117
128
|
|
118
|
-
desc "
|
119
|
-
task :push do
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
sh "rsync #{rsync_opts} '#{local}' '#{remote}'"
|
129
|
+
desc "Send build directory to remote server (use rsync-style paths)"
|
130
|
+
task :push, [:remote] do |t, args|
|
131
|
+
args.with_defaults(:remote => @remote_dir)
|
132
|
+
puts 'Pushing website to remote'.blue
|
133
|
+
rsync_opts = %w[-r -c -v --ignore-times --chmod=ugo=rwX --delete]
|
134
|
+
from = @build_dir + '/'
|
135
|
+
to = args.remote + '/'
|
136
|
+
sh 'rsync', *rsync_opts, from, to
|
127
137
|
puts 'Pushed'.green
|
128
138
|
end
|
129
139
|
|
130
|
-
desc "Backup
|
140
|
+
desc "Backup items from remote server"
|
131
141
|
task :backup do
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
sh 'mkdir', '-p', local
|
140
|
-
sh "rsync #{rsync_opts} '#{remote}' '#{local}'"
|
142
|
+
puts "Backing up remote server".blue
|
143
|
+
rsync_opts = %w[-vaL --delete --exclude .git]
|
144
|
+
@backup_targets.each do |local_dir, remote_dir|
|
145
|
+
from = remote_dir
|
146
|
+
to = @backup_dir + '/' + local_dir
|
147
|
+
FileUtils.mkdir_p to
|
148
|
+
sh 'rsync', *rsync_opts, from, to
|
141
149
|
end
|
142
150
|
puts "Backup complete".green
|
143
151
|
end
|
@@ -148,7 +156,7 @@ namespace :seo do
|
|
148
156
|
desc "Find 404s"
|
149
157
|
task :find_404 do
|
150
158
|
puts "Finding 404 errors".blue
|
151
|
-
sh 'zgrep', '-r', ' 404 ', "#{@
|
159
|
+
sh 'zgrep', '-r', ' 404 ', "#{@backup_dir}/logs"
|
152
160
|
# sh "zgrep -r ' 404 ' '#{@production_backup_dir}/logs'"
|
153
161
|
puts "Found".green
|
154
162
|
end
|
@@ -156,24 +164,30 @@ namespace :seo do
|
|
156
164
|
desc "Find 301s"
|
157
165
|
task :find_301 do
|
158
166
|
puts "Finding 301 errors".blue
|
159
|
-
sh "zgrep -r ' 301 ' '#{@
|
167
|
+
sh "zgrep -r ' 301 ' '#{@backup_dir}/logs'"
|
160
168
|
puts "Found".green
|
161
169
|
end
|
162
170
|
end
|
163
171
|
|
164
172
|
# testing stuff for built html folder
|
165
173
|
namespace :html do
|
166
|
-
desc "Checks
|
167
|
-
task :
|
174
|
+
desc "Checks everything with htmlproofer that is reasonable to check"
|
175
|
+
task :check do
|
168
176
|
puts "⚡️ Checking HTML".blue
|
169
|
-
sh "bundle exec htmlproofer --
|
177
|
+
sh "bundle exec htmlproofer --check-sri --check-external-hash --check-html --check-img-http --check-opengraph --enforce-https --timeframe 6w #{@build_dir}" do
|
178
|
+
puts 'Errors found'
|
179
|
+
exit(1)
|
180
|
+
end
|
170
181
|
puts "☀️ Checked HTML".green
|
171
182
|
end
|
172
183
|
|
173
|
-
desc "Checks
|
174
|
-
task :
|
175
|
-
puts "⚡️ Checking links".blue
|
176
|
-
sh "bundle exec htmlproofer --
|
184
|
+
desc "Checks HTML with htmlproofer, skip external links"
|
185
|
+
task :check_onsite do
|
186
|
+
puts "⚡️ Checking HTML, skipping external links".blue
|
187
|
+
sh "bundle exec htmlproofer --disable-external --check-sri --check-html --check-opengraph --enforce-https #{@build_dir}" do
|
188
|
+
puts 'Errors found'
|
189
|
+
exit(1)
|
190
|
+
end
|
177
191
|
puts "☀️ Checked HTML".green
|
178
192
|
end
|
179
193
|
|
@@ -188,16 +202,7 @@ desc "Delete all built code"
|
|
188
202
|
task :clean do
|
189
203
|
puts "Deleting all built code".red
|
190
204
|
FileUtils.rm_rf(@build_dir)
|
191
|
-
FileUtils.rm_rf(@
|
192
|
-
puts "Deleting complete".green
|
193
|
-
end
|
194
|
-
|
195
|
-
desc "Delete everything that can be regenerated"
|
196
|
-
task :distclean do
|
197
|
-
puts "Deleting all built code".red
|
198
|
-
FileUtils.rm_rf(@build_dir)
|
199
|
-
puts "Deleting all productions backups".red
|
200
|
-
FileUtils.rm_rf(@production_backup_dir)
|
205
|
+
FileUtils.rm_rf(@backup_dir)
|
201
206
|
puts "Deleting complete".green
|
202
207
|
end
|
203
208
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightning_sites
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Entriken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|