octopress-deploy 1.0.4 → 1.0.5
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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/octopress-deploy/commands.rb +1 -1
- data/lib/octopress-deploy/s3.rb +18 -8
- data/lib/octopress-deploy/version.rb +1 -1
- data/lib/octopress-deploy.rb +1 -1
- data/{.clash.yml → test/_clash.yml} +1 -1
- data/test/_git_deploy_local.yml +1 -1
- data/test/_rsync_deploy_local.yml +1 -1
- data/test/source/index.html +1 -0
- metadata +6 -11
- data/test/.gitignore +0 -1
- data/test/Gemfile +0 -4
- data/test/source/test_file +0 -1
- data/test/test.rb +0 -163
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b40f670b3da0ca63247f292839e1f3ac4078c12
|
4
|
+
data.tar.gz: 2dad3bffc5e0d5a73ebe993d8918c2d63d04fb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea4356aae147e4a0f3de99ca98235b729fd48fc19e53fccecd2896b38e2f86b1c8e91c3652861ebadd52f03b5eee4886540a281352388b8274192bbb5a4cf3f1
|
7
|
+
data.tar.gz: 2c91be9d8efeea20adff8b408fb578394abbcd439315fcaa805d04a95180d77620ceece1ab6d290766908428be0e3ac21c11baa1737b90cf7889fdcc8109efe4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -86,7 +86,7 @@ account access information.
|
|
86
86
|
| `access_key_id` | AWS access key | |
|
87
87
|
| `secret_access_key` | AWS secret key | |
|
88
88
|
| `remote_path` | Directory files should be synced to. | / |
|
89
|
-
| `verbose` | [optional] Display all file actions during deploy. |
|
89
|
+
| `verbose` | [optional] Display all file actions during deploy. | false |
|
90
90
|
| `region` | [optional] Region for your AWS bucket | us-east-1 |
|
91
91
|
| `delete` | Delete files in `remote_path` not found in `site_dir` | false |
|
92
92
|
| `headers` | Set headers for matched files | [] |
|
@@ -74,7 +74,7 @@ module Octopress
|
|
74
74
|
c.option 'secret_access_key', '-s', '--secret KEY', 'Secret access key'
|
75
75
|
c.option 'region', '-r', '--region REGION', 'AWS region (default: us-east-1)'
|
76
76
|
c.option 'remote_path', '-d', '--dir DIR', 'Deploy site into a subdirectory.'
|
77
|
-
c.option 'verbose', '-v', '--verbose', 'Log verbose output when deploying
|
77
|
+
c.option 'verbose', '-v', '--verbose', 'Log verbose output when deploying'
|
78
78
|
c.option 'delete', '--delete', 'Sync file deletion'
|
79
79
|
add_common_init_options(c)
|
80
80
|
|
data/lib/octopress-deploy/s3.rb
CHANGED
@@ -9,7 +9,7 @@ module Octopress
|
|
9
9
|
begin
|
10
10
|
require 'aws-sdk'
|
11
11
|
rescue LoadError
|
12
|
-
abort "Deploying to S3 requires aws-sdk. Install with `gem install aws-sdk`."
|
12
|
+
abort "Deploying to S3 requires the aws-sdk gem. Install with `gem install aws-sdk`."
|
13
13
|
end
|
14
14
|
@options = options
|
15
15
|
@local = options[:site_dir] || '_site'
|
@@ -18,7 +18,7 @@ module Octopress
|
|
18
18
|
@secret_key = options[:secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY']
|
19
19
|
@region = options[:region] || ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
20
20
|
@remote_path = (options[:remote_path] || '/').sub(/^\//,'')
|
21
|
-
@verbose = options[:verbose]
|
21
|
+
@verbose = options[:verbose]
|
22
22
|
@delete = options[:delete]
|
23
23
|
@headers = options[:headers] || []
|
24
24
|
@remote_path = @remote_path.sub(/^\//,'') # remove leading slash
|
@@ -44,12 +44,18 @@ module Octopress
|
|
44
44
|
if !@bucket.exists?
|
45
45
|
abort "Bucket not found: '#{@bucket_name}'. Check your configuration or create a bucket using: `octopress deploy add-bucket`"
|
46
46
|
else
|
47
|
-
puts "Syncing #{@bucket_name}
|
47
|
+
puts "Syncing from S3 bucket: '#{@bucket_name}' to #{@pull_dir}."
|
48
48
|
@bucket.objects.each do |object|
|
49
49
|
path = File.join(@pull_dir, object.key)
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
|
51
|
+
# Path is a directory, not a file
|
52
|
+
if path =~ /\/$/
|
53
|
+
FileUtils.mkdir_p(path) unless File.directory?(path)
|
54
|
+
else
|
55
|
+
dir = File.dirname(path)
|
56
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
57
|
+
File.open(path, 'w') { |f| f.write(object.read) }
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
@@ -81,7 +87,10 @@ module Octopress
|
|
81
87
|
end
|
82
88
|
|
83
89
|
def get_file_with_metadata(file, s3_filename)
|
84
|
-
file_with_options = {
|
90
|
+
file_with_options = {
|
91
|
+
:file => file,
|
92
|
+
:acl => :public_read
|
93
|
+
}
|
85
94
|
|
86
95
|
@headers.each do |conf|
|
87
96
|
if conf.has_key? 'filename' and s3_filename.match(conf['filename'])
|
@@ -220,9 +229,10 @@ module Octopress
|
|
220
229
|
#{"secret_access_key: #{options[:secret_access_key]}".ljust(40)} # Keep it safe; keep it secret. Keep this file in your .gitignore.
|
221
230
|
#{"remote_path: #{options[:remote_path] || '/'}".ljust(40)} # relative path on bucket where files should be copied.
|
222
231
|
#{"region: #{options[:remote_path] || 'us-east-1'}".ljust(40)} # Region where your bucket is located.
|
232
|
+
#{"verbose: true".ljust(40)} # Print out all file operations.
|
223
233
|
|
224
234
|
#{"# delete: #{options[:delete] || 'true'}".ljust(40)} # Remove files from destination which do not match source files.
|
225
|
-
#{"# verbose: #{options[:verbose] || '
|
235
|
+
#{"# verbose: #{options[:verbose] || 'false'}".ljust(40)} # Print out all file operations.
|
226
236
|
CONFIG
|
227
237
|
end
|
228
238
|
|
data/lib/octopress-deploy.rb
CHANGED
@@ -117,7 +117,7 @@ module Octopress
|
|
117
117
|
def self.get_config
|
118
118
|
<<-FILE
|
119
119
|
#{"method: #{@options[:method]}".ljust(40)} # How do you want to deploy? git, rsync or s3.
|
120
|
-
#{"site_dir: #{@options[:site_dir]}".ljust(40)} # Location of your
|
120
|
+
#{"site_dir: #{@options[:site_dir]}".ljust(40)} # Location of your static site files.
|
121
121
|
|
122
122
|
#{get_deployment_method(@options).default_config(@options)}
|
123
123
|
FILE
|
data/test/_git_deploy_local.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
method: git # How do you want to deploy? git, rsync or s3.
|
2
|
-
site_dir: _site # Location of your
|
2
|
+
site_dir: _site # Location of your static site files.
|
3
3
|
|
4
4
|
git_url: /Users/imathis/workspace/octodev/deploy/test/local-git # remote repository url, e.g. git@github.com:username/repo_name
|
5
5
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
method: rsync # How do you want to deploy? git, rsync or s3.
|
2
|
-
site_dir: _site # Location of your
|
2
|
+
site_dir: _site # Location of your static site files.
|
3
3
|
|
4
4
|
user: # The user for your host, e.g. user@host.com
|
5
5
|
remote_path: local-rsync # Destination directory
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a test, ignore the follwing garbage:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorator
|
@@ -115,7 +115,6 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".clash.yml"
|
119
118
|
- ".gitignore"
|
120
119
|
- CHANGELOG.md
|
121
120
|
- Gemfile
|
@@ -130,15 +129,13 @@ files:
|
|
130
129
|
- lib/octopress-deploy/s3.rb
|
131
130
|
- lib/octopress-deploy/version.rb
|
132
131
|
- octopress-deploy.gemspec
|
133
|
-
- test
|
134
|
-
- test/Gemfile
|
132
|
+
- test/_clash.yml
|
135
133
|
- test/_git_deploy_local.yml
|
136
134
|
- test/_rsync_deploy_local.yml
|
137
135
|
- test/garbage.rb
|
138
136
|
- test/source/.hidden
|
139
137
|
- test/source/dir/file
|
140
|
-
- test/source/
|
141
|
-
- test/test.rb
|
138
|
+
- test/source/index.html
|
142
139
|
homepage: https://github.com/octopress/deploy
|
143
140
|
licenses:
|
144
141
|
- MIT
|
@@ -164,12 +161,10 @@ signing_key:
|
|
164
161
|
specification_version: 4
|
165
162
|
summary: Easily deploy any Jekyll or Octopress site using S3, Git, or Rsync.
|
166
163
|
test_files:
|
167
|
-
- test
|
168
|
-
- test/Gemfile
|
164
|
+
- test/_clash.yml
|
169
165
|
- test/_git_deploy_local.yml
|
170
166
|
- test/_rsync_deploy_local.yml
|
171
167
|
- test/garbage.rb
|
172
168
|
- test/source/.hidden
|
173
169
|
- test/source/dir/file
|
174
|
-
- test/source/
|
175
|
-
- test/test.rb
|
170
|
+
- test/source/index.html
|
data/test/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
_s3_deploy.yml
|
data/test/Gemfile
DELETED
data/test/source/test_file
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Ignore the follwing garbage:
|
data/test/test.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
require File.expand_path("../../lib/octopress-deploy.rb", __FILE__)
|
2
|
-
require 'fileutils'
|
3
|
-
require 'find'
|
4
|
-
require 'pry-byebug'
|
5
|
-
|
6
|
-
@has_failed = false
|
7
|
-
@failures = {}
|
8
|
-
|
9
|
-
def setup_tests
|
10
|
-
`rm -rf build` # clean up from previous tests
|
11
|
-
generate_site
|
12
|
-
end
|
13
|
-
|
14
|
-
def generate_site
|
15
|
-
system "cp -r source/ build"
|
16
|
-
Find.find('build').to_a.each do |f|
|
17
|
-
system("echo '#{garbage}' >> #{f}") unless File.directory?(f)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def pout(str)
|
22
|
-
print str
|
23
|
-
$stdout.flush
|
24
|
-
end
|
25
|
-
|
26
|
-
def garbage
|
27
|
-
o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
|
28
|
-
(0...50).map { o[rand(o.length)] }.join
|
29
|
-
end
|
30
|
-
|
31
|
-
def diff_dir(dir1, dir2)
|
32
|
-
dir_files(dir1).each do |f1|
|
33
|
-
if diff = diff_file(f1, f1.sub(dir1, dir2))
|
34
|
-
@failures["#{@testing}: #{f1}"] = diff
|
35
|
-
pout "F".red
|
36
|
-
@has_failed = true
|
37
|
-
else
|
38
|
-
pout ".".green
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def diff_file(file1, file2)
|
44
|
-
if File.exist?(file2)
|
45
|
-
diff = `diff #{file1} #{file2}`
|
46
|
-
if diff.size > 0
|
47
|
-
diff
|
48
|
-
else
|
49
|
-
false
|
50
|
-
end
|
51
|
-
else
|
52
|
-
"File: #{file2}: No such file or directory."
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def dir_files(dir)
|
57
|
-
Find.find(dir).to_a.reject!{|f| File.directory?(f) }
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_remote_git
|
61
|
-
@testing = 'remote git'
|
62
|
-
repo = "git@github.com:octopress/deploy"
|
63
|
-
config = "_git_deploy.yml"
|
64
|
-
|
65
|
-
# Clean up from previous tests
|
66
|
-
#
|
67
|
-
`rm -rf .deploy pull-git`
|
68
|
-
|
69
|
-
# Test remote git deployment
|
70
|
-
#
|
71
|
-
Octopress::Deploy.init_config(method: 'git', config_file: config, force: true, site_dir: 'build', git_branch: 'test_git_deploy', git_url: repo)
|
72
|
-
Octopress::Deploy.push(config_file: config)
|
73
|
-
Octopress::Deploy.pull(dir: 'pull-git', config_file: config)
|
74
|
-
diff_dir('build', 'pull-git')
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_local_git
|
78
|
-
@testing = 'local git'
|
79
|
-
config = "_git_deploy.yml"
|
80
|
-
|
81
|
-
# Clean up from previous tests
|
82
|
-
#
|
83
|
-
`rm -rf .deploy local-git pull-git`
|
84
|
-
`git init --bare local-git`
|
85
|
-
repo = "local-git"
|
86
|
-
|
87
|
-
# Test local git deployment
|
88
|
-
#
|
89
|
-
Octopress::Deploy.init_config(method: 'git', config_file: config, force: true, site_dir: 'build', git_branch: 'test_git_deploy', git_url: File.expand_path(repo), remote_path: 'site')
|
90
|
-
Octopress::Deploy.push(config_file: config)
|
91
|
-
Octopress::Deploy.pull(dir: 'pull-git', config_file: config, git_url: File.expand_path(repo), remote_path: 'site')
|
92
|
-
diff_dir('build', 'pull-git/site')
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_remote_rsync
|
96
|
-
@testing = 'remote rsync'
|
97
|
-
config = '_rsync_deploy.yml'
|
98
|
-
|
99
|
-
# Clean up from previous tests
|
100
|
-
`rm -rf local-rsync pull-rsync`
|
101
|
-
|
102
|
-
# Test remote git deployment
|
103
|
-
#
|
104
|
-
Octopress::Deploy.init_config(method: 'rsync', config_file: config, site_dir: 'build', force: true, user: 'imathis@imathis.com', remote_path: '~/octopress-deploy/rsync/')
|
105
|
-
Octopress::Deploy.push(config_file: config)
|
106
|
-
Octopress::Deploy.pull(dir: 'pull-rsync', config_file: config)
|
107
|
-
diff_dir('build', 'pull-rsync')
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_local_rsync
|
112
|
-
@testing = 'local rsync'
|
113
|
-
config = '_rsync_deploy.yml'
|
114
|
-
|
115
|
-
# Clean up from previous tests
|
116
|
-
`rm -rf local-rsync pull-rsync`
|
117
|
-
|
118
|
-
# Test local git deployment
|
119
|
-
#
|
120
|
-
Octopress::Deploy.init_config(method: 'rsync', config_file: config, site_dir: 'build', force: true, remote_path: 'local-rsync')
|
121
|
-
Octopress::Deploy.push(config_file: config)
|
122
|
-
Octopress::Deploy.pull(dir: 'pull-rsync', config_file: config, user: false, remote_path: 'local-rsync')
|
123
|
-
diff_dir('build', 'pull-rsync')
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_s3
|
127
|
-
@testing = 's3'
|
128
|
-
config = "_s3_deploy.yml"
|
129
|
-
`rm -rf pull-s3`
|
130
|
-
Octopress::Deploy.push(config_file: config)
|
131
|
-
Octopress::Deploy.pull(dir: 'pull-s3', config_file: config)
|
132
|
-
diff_dir('build', 'pull-s3')
|
133
|
-
end
|
134
|
-
|
135
|
-
def print_test_results
|
136
|
-
puts "\n"
|
137
|
-
if @has_failed
|
138
|
-
@failures.each do |name, diff|
|
139
|
-
puts "Failure in #{name}:".red
|
140
|
-
puts "---------"
|
141
|
-
puts diff
|
142
|
-
puts "---------"
|
143
|
-
end
|
144
|
-
abort
|
145
|
-
else
|
146
|
-
puts "All passed!".green
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
|
151
|
-
setup_tests
|
152
|
-
|
153
|
-
# local tests
|
154
|
-
test_local_rsync
|
155
|
-
test_local_git
|
156
|
-
|
157
|
-
# remote tests
|
158
|
-
test_remote_git
|
159
|
-
test_remote_rsync
|
160
|
-
test_s3
|
161
|
-
|
162
|
-
print_test_results
|
163
|
-
|