capistrano-s3 2.0.0 → 2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +5 -0
- data/README.md +27 -1
- data/capistrano-s3.gemspec +1 -1
- data/lib/capistrano/s3/defaults.rb +2 -1
- data/lib/capistrano/s3/publisher.rb +7 -7
- data/lib/capistrano/s3/version.rb +1 -1
- data/lib/capistrano/tasks/capistrano_2.rb +1 -1
- data/lib/capistrano/tasks/capistrano_3.rb +1 -1
- data/spec/publisher_spec.rb +7 -9
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c8e41de2db9b9a9963fb2af782cd766617d488
|
4
|
+
data.tar.gz: 285b3124b1ce5173c1c2185070d808aea545bd03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2099eed41cd7362559ebd64662636f019d32fbad791c4ebd0083c28b42b94d3d8c39485efbe8efc3af6d58b59f327b2f7d82fea719ca0fea654d4cf8a1ca550f
|
7
|
+
data.tar.gz: 23989024c2614fb612e469b02ff315962b31a37a291ef72f770b155dd36f232f1c326c7adfdb5b41b7633f9ac4ee73cfd1b478b1e1b1e205952beb6b0bc668f2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.1.0
|
4
|
+
|
5
|
+
Feature : Add option to specify target_path (#35)
|
6
|
+
Change : Relax mime-types version requirement (#36)
|
7
|
+
|
3
8
|
## v2.0.0
|
4
9
|
|
5
10
|
Major change : AWS SDK dependency was upgragred to 2.6, see migration guide at bottom of README to upgrade from v1.
|
data/README.md
CHANGED
@@ -87,9 +87,25 @@ with:
|
|
87
87
|
set :region, 'eu-west-1'
|
88
88
|
```
|
89
89
|
|
90
|
+
### Deployment path
|
91
|
+
|
92
|
+
You can set `deployment_path` to select the **local** path to deploy relative to the project root. Do not use trailing slash. Default value is: `public`.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
set :deployment_path, 'dist'
|
96
|
+
```
|
97
|
+
|
98
|
+
### Target path
|
99
|
+
|
100
|
+
You can also set a **remote** path relative to the bucket root using `target_path`. Do not use trailing slash. Default value is empty (bucket root).
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
set :target_path, 'app'
|
104
|
+
```
|
105
|
+
|
90
106
|
### Write options
|
91
107
|
|
92
|
-
capistrano-s3 sets files `:content_type` and `:acl` to
|
108
|
+
capistrano-s3 sets files `:content_type` and `:acl` to `public-read`, add or override with:
|
93
109
|
|
94
110
|
```ruby
|
95
111
|
set :bucket_write_options, {
|
@@ -111,6 +127,8 @@ set :redirect_options, {
|
|
111
127
|
}
|
112
128
|
```
|
113
129
|
|
130
|
+
The `redirect_options` parameter takes `target_path` into account, you can use the same paths regardless of its value.
|
131
|
+
|
114
132
|
Valid redirect destination should either start with `http` or `https` scheme,
|
115
133
|
or begin with leading slash `/`.
|
116
134
|
|
@@ -139,6 +157,14 @@ set :distribution_id, "CHANGETHIS"
|
|
139
157
|
set :invalidations, [ "/index.html", "/assets/*" ]
|
140
158
|
```
|
141
159
|
|
160
|
+
The CloudFront invalidation feature takes `target_path` into account. Write your invalidations relatively to your `target_path`. For example to invalidate everything inside the remote `app` folder:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
set :target_path, "app"
|
164
|
+
set :distribution_id, "CHANGETHIS"
|
165
|
+
set :invalidations, [ "/*" ]
|
166
|
+
```
|
167
|
+
|
142
168
|
If you want to wait until the invalidation batch is completed (e.g. on a CI server), you can run `cap <stage> deploy:s3:wait_for_invalidation`. The command will wait indefinitely until the invalidation is completed.
|
143
169
|
|
144
170
|
### Exclude files and directories
|
data/capistrano-s3.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
# Gem dependencies
|
25
25
|
s.add_runtime_dependency 'aws-sdk', '~> 2.6'
|
26
26
|
s.add_runtime_dependency 'capistrano', '>= 2'
|
27
|
-
s.add_runtime_dependency 'mime-types'
|
27
|
+
s.add_runtime_dependency 'mime-types'
|
28
28
|
s.add_runtime_dependency 'net-ssh', '~> 2.9'
|
29
29
|
|
30
30
|
# Development dependencies
|
@@ -3,7 +3,8 @@ module Capistrano
|
|
3
3
|
module Defaults
|
4
4
|
DEFAULTS = {
|
5
5
|
:deployment_path => "public",
|
6
|
-
:
|
6
|
+
:target_path => "",
|
7
|
+
:bucket_write_options => { :acl => 'public-read' },
|
7
8
|
:region => 'us-east-1',
|
8
9
|
:redirect_options => {},
|
9
10
|
:only_gzip => false,
|
@@ -8,7 +8,7 @@ module Capistrano
|
|
8
8
|
LAST_PUBLISHED_FILE = '.last_published'
|
9
9
|
LAST_INVALIDATION_FILE = '.last_invalidation'
|
10
10
|
|
11
|
-
def self.publish!(region, key, secret, bucket, deployment_path, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
11
|
+
def self.publish!(region, key, secret, bucket, deployment_path, target_path, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
12
12
|
deployment_path_absolute = File.expand_path(deployment_path, Dir.pwd)
|
13
13
|
s3 = self.establish_s3_client_connection!(region, key, secret)
|
14
14
|
updated = false
|
@@ -21,7 +21,7 @@ module Capistrano
|
|
21
21
|
path = self.base_file_path(deployment_path_absolute, file)
|
22
22
|
path.gsub!(/^\//, "") # Remove preceding slash for S3
|
23
23
|
|
24
|
-
self.put_object(s3, bucket, path, file, only_gzip, extra_options)
|
24
|
+
self.put_object(s3, bucket, target_path, path, file, only_gzip, extra_options)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,7 +34,7 @@ module Capistrano
|
|
34
34
|
:invalidation_batch => {
|
35
35
|
:paths => {
|
36
36
|
:quantity => invalidations.count,
|
37
|
-
:items => invalidations
|
37
|
+
:items => invalidations.map { |path| File.join('/', target_path, path) }
|
38
38
|
},
|
39
39
|
:caller_reference => SecureRandom.hex
|
40
40
|
}
|
@@ -105,14 +105,14 @@ module Capistrano
|
|
105
105
|
File.mtime(file) < File.mtime(LAST_PUBLISHED_FILE)
|
106
106
|
end
|
107
107
|
|
108
|
-
def self.put_object(s3, bucket, path, file, only_gzip, extra_options)
|
108
|
+
def self.put_object(s3, bucket, target_path, path, file, only_gzip, extra_options)
|
109
109
|
base_name = File.basename(file)
|
110
110
|
mime_type = mime_type_for_file(base_name)
|
111
111
|
options = {
|
112
112
|
:bucket => bucket,
|
113
|
-
:key => path,
|
113
|
+
:key => File.join(target_path, path),
|
114
114
|
:body => open(file),
|
115
|
-
:acl =>
|
115
|
+
:acl => 'public-read',
|
116
116
|
}
|
117
117
|
|
118
118
|
options.merge!(build_redirect_hash(path, extra_options[:redirect]))
|
@@ -126,7 +126,7 @@ module Capistrano
|
|
126
126
|
options.merge!(build_gzip_content_type_hash(file, mime_type))
|
127
127
|
|
128
128
|
# upload as original file name
|
129
|
-
options.merge!(key: self.orig_name(path)) if only_gzip
|
129
|
+
options.merge!(key: File.join(target_path, self.orig_name(path))) if only_gzip
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -23,7 +23,7 @@ module Capistrano
|
|
23
23
|
task :upload_files do
|
24
24
|
extra_options = { :write => bucket_write_options, :redirect => redirect_options }
|
25
25
|
S3::Publisher.publish!(region, access_key_id, secret_access_key,
|
26
|
-
bucket, deployment_path, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
26
|
+
bucket, deployment_path, target_path, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -20,7 +20,7 @@ namespace :deploy do
|
|
20
20
|
task :upload_files do
|
21
21
|
extra_options = { :write => fetch(:bucket_write_options), :redirect => fetch(:redirect_options) }
|
22
22
|
Capistrano::S3::Publisher.publish!(fetch(:region), fetch(:access_key_id), fetch(:secret_access_key),
|
23
|
-
fetch(:bucket), fetch(:deployment_path), fetch(:distribution_id), fetch(:invalidations), fetch(:exclusions), fetch(:only_gzip), extra_options)
|
23
|
+
fetch(:bucket), fetch(:deployment_path), fetch(:target_path), fetch(:distribution_id), fetch(:invalidations), fetch(:exclusions), fetch(:only_gzip), extra_options)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/spec/publisher_spec.rb
CHANGED
@@ -10,12 +10,12 @@ describe Capistrano::S3::Publisher do
|
|
10
10
|
context "on publish!" do
|
11
11
|
it "publish all files" do
|
12
12
|
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
13
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', '
|
13
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], false, {})
|
14
14
|
end
|
15
15
|
|
16
16
|
it "publish only gzip files when option is enabled" do
|
17
17
|
Aws::S3::Client.any_instance.expects(:put_object).times(4)
|
18
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', 'cf123', [], [], true, {})
|
18
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], true, {})
|
19
19
|
end
|
20
20
|
|
21
21
|
context "invalidations" do
|
@@ -23,14 +23,14 @@ describe Capistrano::S3::Publisher do
|
|
23
23
|
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
24
24
|
Aws::CloudFront::Client.any_instance.expects(:create_invalidation).once
|
25
25
|
|
26
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample
|
26
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', ['*'], [], false, {})
|
27
27
|
end
|
28
28
|
|
29
29
|
it "publish all files without invalidations" do
|
30
30
|
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
31
31
|
Aws::CloudFront::Client.any_instance.expects(:create_invalidation).never
|
32
32
|
|
33
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', '
|
33
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], false, {})
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -39,24 +39,22 @@ describe Capistrano::S3::Publisher do
|
|
39
39
|
Aws::S3::Client.any_instance.expects(:put_object).times(7)
|
40
40
|
|
41
41
|
exclude_paths = ['fonts/cantarell-regular-webfont.svg']
|
42
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', 'cf123', [], exclude_paths, false, {})
|
42
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {})
|
43
43
|
end
|
44
44
|
|
45
45
|
it "exclude multiple files" do
|
46
46
|
Aws::S3::Client.any_instance.expects(:put_object).times(6)
|
47
47
|
|
48
48
|
exclude_paths = ['fonts/cantarell-regular-webfont.svg', 'fonts/cantarell-regular-webfont.svg.gz']
|
49
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', 'cf123', [], exclude_paths, false, {})
|
49
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {})
|
50
50
|
end
|
51
51
|
|
52
52
|
it "exclude directory" do
|
53
53
|
Aws::S3::Client.any_instance.expects(:put_object).times(0)
|
54
54
|
|
55
55
|
exclude_paths = ['fonts/**/*']
|
56
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', 'cf123', [], exclude_paths, false, {})
|
56
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {})
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
60
|
-
|
61
59
|
end
|
62
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Doyle
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
t/JsZnAlWYkJIees2SFV5X/t34oeMu04yY2u9y2YBqKovR97m5YF7zqgx0JODV0x
|
37
37
|
ytwUJvEjznBnJV4OoDE=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2017-
|
39
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aws-sdk
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: mime-types
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: net-ssh
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: '0'
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.6.10
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Build and deploy a static website to Amazon S3
|
metadata.gz.sig
CHANGED
Binary file
|