middleman-cdn 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleman-cdn/cdns/cloudflare.rb +3 -5
- data/lib/middleman-cdn/cdns/cloudfront.rb +7 -6
- data/lib/middleman-cdn/commands.rb +12 -3
- data/lib/middleman-cdn/version.rb +1 -1
- data/middleman-cdn.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e79d37359ea1e80126fd90bee4767bde571842d
|
4
|
+
data.tar.gz: ede9b99ab9222ebf86bb7d3735fc6cacae481fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d22ceecce8e729df8b9e11e8a840ad5c55b051730d1d962bcece2520b890bf92a792c7e920ee85317f3f775c46e5a3d1646f1ee7bbbb317121f31687f51c28
|
7
|
+
data.tar.gz: 87f355883c41f5956f4b6752c8ecb16a02a6228750d11f7f841c4ae5fb164c717d078f0a05189cd79f823dce88414f79e829f993a58e5ef3760a2c9d36c46809
|
@@ -22,8 +22,6 @@ TEXT
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def invalidate(options, files)
|
25
|
-
puts "## Invalidating files on CloudFlare"
|
26
|
-
|
27
25
|
options[:client_api_key] ||= ENV['CLOUDFLARE_CLIENT_API_KEY']
|
28
26
|
options[:email] ||= ENV['CLOUDFLARE_EMAIL']
|
29
27
|
[:client_api_key, :email, :zone, :base_urls].each do |key|
|
@@ -41,12 +39,12 @@ TEXT
|
|
41
39
|
cloudflare = ::CloudFlare::connection(options[:client_api_key], options[:email])
|
42
40
|
begin
|
43
41
|
url = "#{base_url}#{file}"
|
44
|
-
|
42
|
+
::Middleman::Cli::CDN.say_status("cloudflare".yellow + " invalidating #{url}... ", incomplete: true)
|
45
43
|
cloudflare.zone_file_purge(options[:zone], "#{base_url}#{file}")
|
46
44
|
rescue => e
|
47
|
-
|
45
|
+
::Middleman::Cli::CDN.say_status(", " + "error: #{e.message}".light_red, header: false)
|
48
46
|
else
|
49
|
-
|
47
|
+
::Middleman::Cli::CDN.say_status("✓".light_green, header: false)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
@@ -22,8 +22,6 @@ TEXT
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def invalidate(options, files)
|
25
|
-
puts "## Invalidating files on CloudFront"
|
26
|
-
|
27
25
|
options[:access_key_id] ||= ENV['AWS_ACCESS_KEY_ID']
|
28
26
|
options[:secret_access_key] ||= ENV['AWS_SECRET_ACCESS_KEY']
|
29
27
|
[:access_key_id, :secret_access_key, :distribution_id].each do |key|
|
@@ -39,19 +37,22 @@ TEXT
|
|
39
37
|
distribution = cloudfront.distributions.get(options[:distribution_id])
|
40
38
|
|
41
39
|
if files.count <= INVALIDATION_LIMIT
|
42
|
-
|
43
|
-
puts 'Please check the AWS Management Console to see the status of the invalidation.'
|
40
|
+
::Middleman::Cli::CDN.say_status("cloudfront".yellow + " invalidating #{files.count} files... ", incomplete: true)
|
44
41
|
invalidation = distribution.invalidations.create(:paths => files)
|
45
42
|
raise StandardError, %(Invalidation status is #{invalidation.status}. Expected "InProgress") unless invalidation.status == 'InProgress'
|
43
|
+
::Middleman::Cli::CDN.say_status("✓".light_green, header: false)
|
46
44
|
else
|
47
45
|
slices = files.each_slice(INVALIDATION_LIMIT)
|
48
|
-
|
46
|
+
::Middleman::Cli::CDN.say_status("cloudfront".yellow + " invalidating #{files.count} files in #{slices.count} batch(es) ")
|
49
47
|
slices.each_with_index do |slice, i|
|
50
|
-
|
48
|
+
::Middleman::Cli::CDN.say_status("cloudfront".yellow + " invalidating batch #{i + 1}... ", incomplete: true)
|
51
49
|
invalidation = distribution.invalidations.create(:paths => slice)
|
52
50
|
invalidation.wait_for { ready? } unless i == slices.count - 1
|
51
|
+
::Middleman::Cli::CDN.say_status("✓".light_green, header: false)
|
53
52
|
end
|
54
53
|
end
|
54
|
+
::Middleman::Cli::CDN.say_status("cloudfront".yellow + " It might take 10 to 15 minutes until all files are invalidated.")
|
55
|
+
::Middleman::Cli::CDN.say_status("cloudfront".yellow + ' Please check the AWS Management Console to see the status of the invalidation.')
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -32,10 +32,8 @@ module Middleman
|
|
32
32
|
raise Error, "ERROR: You must specify a config for one of the supported CDNs.\n#{example_configuration}"
|
33
33
|
end
|
34
34
|
|
35
|
-
# CloudFront limits the amount of files which can be invalidated by one request to 1000.
|
36
|
-
# If there are more than 1000 files to invalidate, do so sequentially and wait until each validation is ready.
|
37
|
-
# If there are max 1000 files, create the invalidation and return immediately.
|
38
35
|
files = list_files(options.filter)
|
36
|
+
::Middleman::Cli::CDN.say_status("Invalidating #{files.count} files with filter: #{options.filter.source}")
|
39
37
|
return if files.empty?
|
40
38
|
|
41
39
|
cdns_keyed.each do |cdn_key, cdn|
|
@@ -44,6 +42,17 @@ module Middleman
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
45
|
+
def self.say_status(status, incomplete: false, header: true)
|
46
|
+
message = ""
|
47
|
+
message << :cdn.to_s.rjust(12).light_green + " " if header
|
48
|
+
message << status
|
49
|
+
if incomplete
|
50
|
+
print message
|
51
|
+
else
|
52
|
+
puts message
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
47
56
|
protected
|
48
57
|
|
49
58
|
def cdns
|
data/middleman-cdn.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-cdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leigh McCulloch
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: cucumber
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|