lightning_sites 0.1.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 +7 -0
- data/lib/lightning_sites.rb +224 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c9a1569774bfe05b1e01f959bd6f4d3b7b5c05c
|
4
|
+
data.tar.gz: 446b60d2624050b0f5fee04f4ffd69c72f1f1651
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f520f1fb6820e5c9b4af36593a5161795eb99956b0be7218e9a1ee01977d3fdb61631273017e1935e6268197baab42e17efa486c8f20c231a383cf018ee0569
|
7
|
+
data.tar.gz: b59b4879258829763ae9fbc6ace052da43a652451f954ca072e23aaca77f9f8db9521fa8b5f7e25905277965602d6fc2029eff204163f53aaab1f0c0573d3079
|
@@ -0,0 +1,224 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
# http://stackoverflow.com/a/11320444/300224
|
4
|
+
Rake::TaskManager.record_task_metadata = true
|
5
|
+
|
6
|
+
##
|
7
|
+
## EVERY SITE MUST DEFINE THESE VARIABLES:
|
8
|
+
##
|
9
|
+
@source_dir = 'source' # Editable source code
|
10
|
+
@build_dir = 'build' # Built HTML code
|
11
|
+
##
|
12
|
+
##
|
13
|
+
## REQUIRED VARIABLES FOR DEPLOYMENT:
|
14
|
+
##
|
15
|
+
## @production_dir A local or remote directory (rsync format) to deploy to
|
16
|
+
## Good example: 'horseslov@172.16.11.23:/www'
|
17
|
+
## @production_backup_targets Hash of {name => what_should_backup_to_there}
|
18
|
+
## Good example: {'logs' => 'horseslov@172.16.11.23:/logs', ...}
|
19
|
+
@production_backup_dir = 'production_backups'
|
20
|
+
|
21
|
+
##
|
22
|
+
## COLOR SCHEME
|
23
|
+
##
|
24
|
+
## ...
|
25
|
+
##
|
26
|
+
|
27
|
+
module LightningSites
|
28
|
+
# Your code goes here...
|
29
|
+
end
|
30
|
+
|
31
|
+
# Note: this stuff works even if only your SOURCE_DIR is checked into git
|
32
|
+
namespace :git do
|
33
|
+
def source_dir_is_git?
|
34
|
+
return false if !File.directory?(@source_dir)
|
35
|
+
return system("cd #{@source_dir} && git rev-parse --git-dir > /dev/null 2> /dev/null")
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Incorporate changes from the remote repository into the current branch"
|
39
|
+
task :pull do
|
40
|
+
puts 'Pulling git'.blue
|
41
|
+
sh "cd '#{@source_dir}'; git pull"
|
42
|
+
puts 'Pulled'.green
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Displays paths that have differences between the index file and the current HEAD commit"
|
46
|
+
task :status do
|
47
|
+
if !source_dir_is_git?
|
48
|
+
puts "There is no git directory, skipping"
|
49
|
+
next
|
50
|
+
end
|
51
|
+
puts 'Here are differences between git\'s index file and the current HEAD commit'.blue
|
52
|
+
sh "cd #{@source_dir} && git status --short"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Print the modified date for all files under source control"
|
56
|
+
task :stale_report do
|
57
|
+
if !source_dir_is_git?
|
58
|
+
puts "There is no git directory, skipping"
|
59
|
+
next
|
60
|
+
end
|
61
|
+
puts 'Modified File'.blue
|
62
|
+
sh "cd #{@source_dir} && git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --date=short --format='%ad {}' {}"
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Save the commit hash to VERSION in the build directory"
|
66
|
+
task :save_version do
|
67
|
+
if !source_dir_is_git?
|
68
|
+
puts "There is no git directory, skipping"
|
69
|
+
next
|
70
|
+
end
|
71
|
+
hash = `cd #{@source_dir} && git rev-parse HEAD`.chomp
|
72
|
+
local_changes = `git diff --shortstat`.chomp.length
|
73
|
+
File.write("#{@build_dir}/VERSION", local_changes ? "#{hash}*\n" : "#{hash}*")
|
74
|
+
puts 'Saved git version to VERSION file'.green
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
## don't use this right now
|
79
|
+
namespace :jekyll do
|
80
|
+
desc "Build Jekyll site"
|
81
|
+
task :build do
|
82
|
+
puts 'Building Jekyll'.blue
|
83
|
+
sh "jekyll build --incremental --source '#{@source_dir}' --destination '#{@build_dir}'"
|
84
|
+
puts 'Built'.green
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Run a Jekyll test server"
|
88
|
+
task :test do
|
89
|
+
puts 'Running test server'.blue
|
90
|
+
sh "jekyll serve --source '#{@source_dir}' --destination '#{@build_dir}'"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Interact with a production environment
|
95
|
+
namespace :rsync do
|
96
|
+
desc "Copy the source directory to the build directory"
|
97
|
+
task :copy_build do
|
98
|
+
puts 'Copying source directory to build directory'.blue
|
99
|
+
rsync_opts = '--archive --delete --exclude .git'
|
100
|
+
from = "#{@source_dir}/"
|
101
|
+
to = "#{@build_dir}/"
|
102
|
+
sh "rsync #{rsync_opts} '#{from}' '#{to}'"
|
103
|
+
puts 'Copied'.green
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "Bring deployed web server files local"
|
107
|
+
task :pull do
|
108
|
+
raise '@production_dir is not defined' unless defined? @production_dir
|
109
|
+
raise '@build_dir is not defined' unless defined? @build_dir
|
110
|
+
puts 'Pulling website'.blue
|
111
|
+
rsync_opts = '-vr --delete --exclude .git --exclude cache'
|
112
|
+
remote = "#{@production_dir}/"
|
113
|
+
local = "#{@build_dir}/"
|
114
|
+
sh "rsync #{rsync_opts} '#{remote}' '#{local}'"
|
115
|
+
puts 'Pulled'.green
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "Push local files to production web server"
|
119
|
+
task :push do
|
120
|
+
raise '@production_dir is not defined' unless defined? @production_dir
|
121
|
+
raise '@build_dir is not defined' unless defined? @build_dir
|
122
|
+
puts 'Pushing website'.blue
|
123
|
+
rsync_opts = '-r -c -v --ignore-times --chmod=ugo=rwX --delete --exclude .git --exclude cache'
|
124
|
+
remote = "#{@production_dir}/"
|
125
|
+
local = "#{@build_dir}/"
|
126
|
+
sh "rsync #{rsync_opts} '#{local}' '#{remote}'"
|
127
|
+
puts 'Pushed'.green
|
128
|
+
end
|
129
|
+
|
130
|
+
desc "Backup production"
|
131
|
+
task :backup do
|
132
|
+
raise '@production_backup_dir is not defined' unless defined? @production_backup_dir
|
133
|
+
raise '@production_backup_targets is not defined' unless defined? @production_backup_targets
|
134
|
+
puts "Backing up production".blue
|
135
|
+
rsync_opts = '-vaL --delete --exclude .git'
|
136
|
+
@production_backup_targets.each do |local_dir, remote_dir|
|
137
|
+
remote = "#{remote_dir}"
|
138
|
+
local = "#{@production_backup_dir}/#{local_dir}/"
|
139
|
+
sh 'mkdir', '-p', local
|
140
|
+
sh "rsync #{rsync_opts} '#{remote}' '#{local}'"
|
141
|
+
end
|
142
|
+
puts "Backup complete".green
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# beta stuff
|
147
|
+
namespace :seo do
|
148
|
+
desc "Find 404s"
|
149
|
+
task :find_404 do
|
150
|
+
puts "Finding 404 errors".blue
|
151
|
+
sh 'zgrep', '-r', ' 404 ', "#{@production_backup_dir}/logs"
|
152
|
+
# sh "zgrep -r ' 404 ' '#{@production_backup_dir}/logs'"
|
153
|
+
puts "Found".green
|
154
|
+
end
|
155
|
+
|
156
|
+
desc "Find 301s"
|
157
|
+
task :find_301 do
|
158
|
+
puts "Finding 301 errors".blue
|
159
|
+
sh "zgrep -r ' 301 ' '#{@production_backup_dir}/logs'"
|
160
|
+
puts "Found".green
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# testing stuff for built html folder
|
165
|
+
namespace :html do
|
166
|
+
desc "Checks HTML with htmlproofer, excludes offsite broken link checking"
|
167
|
+
task :check_onsite do
|
168
|
+
puts "⚡️ Checking HTML".blue
|
169
|
+
sh "bundle exec htmlproofer --disable-external --check-html --checks-to-ignore ScriptCheck,LinkCheck,HtmlCheck #{@build_dir} > /dev/null || true"
|
170
|
+
puts "☀️ Checked HTML".green
|
171
|
+
end
|
172
|
+
|
173
|
+
desc "Checks links with htmlproofer"
|
174
|
+
task :check_links do
|
175
|
+
puts "⚡️ Checking links".blue
|
176
|
+
sh "bundle exec htmlproofer --checks-to-ignore ScriptCheck,ImageCheck #{@build_dir} || true"
|
177
|
+
puts "☀️ Checked HTML".green
|
178
|
+
end
|
179
|
+
|
180
|
+
desc "Find all external links"
|
181
|
+
task :find_external_links do
|
182
|
+
puts "⚡️ Finding all external links".blue
|
183
|
+
sh "egrep -oihR '\\b(https?|ftp|file)://[-A-Z0-9+@/%=~_|!:,.;]*[A-Z0-9+@/%=~_|]' #{@build_dir} || true"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
desc "Delete all built code"
|
188
|
+
task :clean do
|
189
|
+
puts "Deleting all built code".red
|
190
|
+
FileUtils.rm_rf(@build_dir)
|
191
|
+
FileUtils.rm_rf(@production_backup_dir)
|
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)
|
201
|
+
puts "Deleting complete".green
|
202
|
+
end
|
203
|
+
|
204
|
+
desc "Show all the tasks"
|
205
|
+
task :default do
|
206
|
+
puts ''
|
207
|
+
puts '⚡️ THIS RAKEFILE USES LIGHTNING SITES'.blue
|
208
|
+
puts ''
|
209
|
+
|
210
|
+
# http://stackoverflow.com/a/1290119/300224
|
211
|
+
Rake::Task["git:status"].invoke
|
212
|
+
|
213
|
+
puts ''
|
214
|
+
puts 'Here are all available namespaced rake tasks:'.blue
|
215
|
+
Rake::application.options.show_tasks = :tasks # this solves sidewaysmilk problem
|
216
|
+
Rake::application.options.show_task_pattern = /:/
|
217
|
+
Rake::application.display_tasks_and_comments
|
218
|
+
|
219
|
+
puts ''
|
220
|
+
puts 'Here are all available local rake tasks:'.blue
|
221
|
+
Rake::application.options.show_tasks = :tasks # this solves sidewaysmilk problem
|
222
|
+
Rake::application.options.show_task_pattern = /^[^:]*$/
|
223
|
+
Rake::application.display_tasks_and_comments
|
224
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lightning_sites
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- William Entriken
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: html-proofer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: Lightning Sites gives you beautifully simple deployment for your ~/Sites
|
84
|
+
folders, inspired by Fastlane. We support all deployment setups.
|
85
|
+
email:
|
86
|
+
- github.com@phor.net
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- lib/lightning_sites.rb
|
92
|
+
homepage: https://github.com/fulldecent/Sites
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.5.1
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Lightning deployment for your ~/Sites folders
|
116
|
+
test_files: []
|
117
|
+
has_rdoc:
|