capistrano-s3 2.4.0 → 3.0.0.pre2
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 +2 -1
- data/.github/workflows/build.yml +20 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +59 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +15 -2
- data/Guardfile +18 -0
- data/README.md +2 -2
- data/Rakefile +7 -5
- data/capistrano-s3.gemspec +32 -27
- data/certs/aleksandrs-ledovskis--2025-07-03-2035-07-01.pem +26 -0
- data/lib/capistrano/s3/defaults.rb +11 -9
- data/lib/capistrano/s3/mime_types.rb +7 -5
- data/lib/capistrano/s3/publisher.rb +105 -103
- data/lib/capistrano/s3/version.rb +3 -1
- data/lib/capistrano/s3.rb +5 -3
- data/lib/capistrano/tasks/capistrano_2.rb +18 -5
- data/lib/capistrano/tasks/capistrano_3.rb +22 -5
- data/spec/capistrano/s3/publisher_spec.rb +214 -0
- data/spec/spec_helper.rb +5 -3
- data.tar.gz.sig +4 -1
- metadata +42 -93
- metadata.gz.sig +0 -0
- data/.travis.yml +0 -21
- data/certs/aleksandrs-ledovskis--2018-11-04-2020-11-03.pem +0 -26
- data/certs/j15e.pem +0 -21
- data/spec/publisher_spec.rb +0 -153
data/spec/publisher_spec.rb
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Capistrano::S3::Publisher do
|
4
|
-
before do
|
5
|
-
@root = File.expand_path('../', __FILE__)
|
6
|
-
publish_file = Capistrano::S3::Publisher::LAST_PUBLISHED_FILE
|
7
|
-
FileUtils.rm(publish_file) if File.exist?(publish_file)
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "::files" do
|
11
|
-
subject(:files) { described_class.files(deployment_path, exclusions) }
|
12
|
-
|
13
|
-
let(:deployment_path) { "spec/sample-2" }
|
14
|
-
let(:exclusions) { [] }
|
15
|
-
|
16
|
-
it "includes dot-prefixed/hidden directories" do
|
17
|
-
expect(files).to include("spec/sample-2/.well-known/test.txt")
|
18
|
-
end
|
19
|
-
|
20
|
-
it "includes dot-prefixed/hidden files" do
|
21
|
-
expect(files).to include("spec/sample-2/public/.htaccess")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "on publish!" do
|
26
|
-
it "publish all files" do
|
27
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
28
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], false, {}, 'staging')
|
29
|
-
end
|
30
|
-
|
31
|
-
it "publish only gzip files when option is enabled" do
|
32
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(4)
|
33
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], true, {}, 'staging')
|
34
|
-
end
|
35
|
-
|
36
|
-
context "invalidations" do
|
37
|
-
it "publish all files with invalidations" do
|
38
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
39
|
-
Aws::CloudFront::Client.any_instance.expects(:create_invalidation).once
|
40
|
-
|
41
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', ['*'], [], false, {}, 'staging')
|
42
|
-
end
|
43
|
-
|
44
|
-
it "publish all files without invalidations" do
|
45
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(8)
|
46
|
-
Aws::CloudFront::Client.any_instance.expects(:create_invalidation).never
|
47
|
-
|
48
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], [], false, {}, 'staging')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "exclusions" do
|
53
|
-
it "exclude one files" do
|
54
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(7)
|
55
|
-
|
56
|
-
exclude_paths = ['fonts/cantarell-regular-webfont.svg']
|
57
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {}, 'staging')
|
58
|
-
end
|
59
|
-
|
60
|
-
it "exclude multiple files" do
|
61
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(6)
|
62
|
-
|
63
|
-
exclude_paths = ['fonts/cantarell-regular-webfont.svg', 'fonts/cantarell-regular-webfont.svg.gz']
|
64
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {}, 'staging')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "exclude directory" do
|
68
|
-
Aws::S3::Client.any_instance.expects(:put_object).times(0)
|
69
|
-
|
70
|
-
exclude_paths = ['fonts/**/*']
|
71
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample', '', 'cf123', [], exclude_paths, false, {}, 'staging')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "write options" do
|
76
|
-
it "sets bucket write options to all files" do
|
77
|
-
headers = { cache_control: 'no-cache' }
|
78
|
-
extra_options = { write: headers }
|
79
|
-
|
80
|
-
Aws::S3::Client.any_instance.expects(:put_object).with() { |options| contains(options, headers) }.times(3)
|
81
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-write', '', 'cf123', [], [], false, extra_options, 'staging')
|
82
|
-
end
|
83
|
-
|
84
|
-
it "sets object write options to a single file" do
|
85
|
-
headers = { cache_control: 'no-cache', acl: :private }
|
86
|
-
extra_options = {
|
87
|
-
object_write: {
|
88
|
-
'index.html' => headers
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'index.html' && contains(options, headers) }.once
|
93
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] != 'index.html' && !contains(options, headers) }.twice
|
94
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-write', '', 'cf123', [], [], false, extra_options, 'staging')
|
95
|
-
end
|
96
|
-
|
97
|
-
it "sets object write options to a directory" do
|
98
|
-
asset_headers = { cache_control: 'max-age=3600' }
|
99
|
-
index_headers = { cache_control: 'no-cache' }
|
100
|
-
extra_options = {
|
101
|
-
object_write: {
|
102
|
-
'assets/**' => asset_headers,
|
103
|
-
'index.html' => index_headers
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'index.html' && !contains(options, asset_headers) && contains(options, index_headers) }.once
|
108
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] != 'index.html' && !contains(options, index_headers) && contains(options, asset_headers) }.twice
|
109
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-write', '', 'cf123', [], [], false, extra_options, 'staging')
|
110
|
-
end
|
111
|
-
|
112
|
-
it "sets object write permissions in the order of definition" do
|
113
|
-
asset_headers = { cache_control: 'max-age=3600' }
|
114
|
-
js_headers = { cache_control: 'no-cache' }
|
115
|
-
extra_options = { object_write: { 'assets/**' => asset_headers, 'assets/script.js' => js_headers } }
|
116
|
-
|
117
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'assets/script.js' && !contains(options, asset_headers) && contains(options, js_headers) }.once
|
118
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'assets/style.css' && !contains(options, js_headers) && contains(options, asset_headers) }.once
|
119
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'index.html' && !contains(options, js_headers) && !contains(options, asset_headers) }.once
|
120
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-write', '', 'cf123', [], [], false, extra_options, 'staging')
|
121
|
-
end
|
122
|
-
|
123
|
-
it "overwrites object write permissions with wrong ordering" do
|
124
|
-
js_headers = { cache_control: 'no-cache' }
|
125
|
-
asset_headers = { cache_control: 'max-age=3600' }
|
126
|
-
extra_options = {
|
127
|
-
object_write: {
|
128
|
-
'assets/script.js' => js_headers,
|
129
|
-
'assets/**' => asset_headers
|
130
|
-
}
|
131
|
-
}
|
132
|
-
|
133
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] != 'index.html' && !contains(options, js_headers) && contains(options, asset_headers) }.twice
|
134
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:key] == 'index.html' && !contains(options, js_headers) && !contains(options, asset_headers) }.once
|
135
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-write', '', 'cf123', [], [], false, extra_options, 'staging')
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context "MIME types" do
|
140
|
-
it "sets best match MIME type by default" do
|
141
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:content_type] == 'application/ecmascript' }.once
|
142
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-mime', '', 'cf123', [], [], false, {}, 'staging')
|
143
|
-
end
|
144
|
-
|
145
|
-
it "sets CloudFront preferred MIME type if needed" do
|
146
|
-
extra_options = { prefer_cf_mime_types: true }
|
147
|
-
|
148
|
-
Aws::S3::Client.any_instance.expects(:put_object).with { |options| options[:content_type] == 'application/javascript' }.once
|
149
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', 'spec/sample-mime', '', 'cf123', [], [], false, extra_options, 'staging')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|