frizz 1.3.3 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/frizz.gemspec +1 -0
- data/lib/frizz/distribution.rb +37 -0
- data/lib/frizz/middleman/tasks.rb +2 -4
- data/lib/frizz/site.rb +10 -4
- data/lib/frizz/sync.rb +12 -0
- data/lib/frizz/version.rb +1 -1
- data/lib/frizz.rb +1 -0
- metadata +21 -4
data/README.md
CHANGED
@@ -8,6 +8,7 @@ some nifty Middleman integrations for managing environments.
|
|
8
8
|
* Sets Content-Type (including CSS files which S3 is notoriously bad at)
|
9
9
|
* Only uploads files that have changed
|
10
10
|
* Removes files that have been deleted locally
|
11
|
+
* Invalidate changed files on CloudFront
|
11
12
|
|
12
13
|
### Middleman Features
|
13
14
|
|
@@ -65,6 +66,17 @@ Specify a different local build dir:
|
|
65
66
|
site = Frizz::Site.new("my-static-site.com", from: "build/public")
|
66
67
|
```
|
67
68
|
|
69
|
+
### Deploy with CloudFront invalidation
|
70
|
+
|
71
|
+
Optionally provide a CloudFront Distribution ID and Frizz will invalidate
|
72
|
+
the cache for any files that changed or were removed in the deploy. Note:
|
73
|
+
invalidating a CloudFront cache can take some time.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
site = Frizz::Site.new("my-bucket", distribution: "DISTRIBUTION_ID")
|
77
|
+
site.deploy!
|
78
|
+
```
|
79
|
+
|
68
80
|
## Usage With Middleman
|
69
81
|
|
70
82
|
Managing more than the basic two environments (dev and build) in a Middleman app
|
@@ -100,6 +112,7 @@ environments:
|
|
100
112
|
host: "staging.example.com"
|
101
113
|
production:
|
102
114
|
host: "example.com"
|
115
|
+
distribution "CLOUDFRONT_DISTRIBUTION_ID"
|
103
116
|
```
|
104
117
|
|
105
118
|
Frizz would give us the following Rake tasks:
|
data/frizz.gemspec
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "cloudfront-invalidator"
|
2
|
+
|
3
|
+
module Frizz
|
4
|
+
class Distribution
|
5
|
+
def initialize(id)
|
6
|
+
@id = id
|
7
|
+
end
|
8
|
+
|
9
|
+
def invalidate!(keys)
|
10
|
+
return unless keys.any?
|
11
|
+
puts "Invalidating distribution cache for: #{keys}".blue
|
12
|
+
|
13
|
+
# $stdout.sync = true
|
14
|
+
print "This can take a while".blue
|
15
|
+
invalidator.invalidate(keys) do |status, time|
|
16
|
+
case status
|
17
|
+
when "InProgress"
|
18
|
+
print ".".blue
|
19
|
+
when "Complete"
|
20
|
+
puts "#{status} in #{time}".green
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :id
|
28
|
+
|
29
|
+
def invalidator
|
30
|
+
@invalidator ||= CloudfrontInvalidator.new(
|
31
|
+
Frizz.configuration.access_key_id,
|
32
|
+
Frizz.configuration.secret_access_key,
|
33
|
+
id
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -34,7 +34,7 @@ module Frizz
|
|
34
34
|
relevant_environments.each do |name, env|
|
35
35
|
desc "Deploy build dir to #{env.name}: #{env.bucket}"
|
36
36
|
task env.name do
|
37
|
-
Frizz::Site.new(env.bucket).deploy!
|
37
|
+
Frizz::Site.new(env.bucket, distribution: env.distribution).deploy!
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -42,9 +42,7 @@ module Frizz
|
|
42
42
|
namespace :release do
|
43
43
|
relevant_environments.each do |name, env|
|
44
44
|
desc "Build and deploy #{env.name}: #{env.bucket}"
|
45
|
-
task env.name => ["frizz:build:#{env.name}"] do
|
46
|
-
Frizz::Site.new(env.bucket).deploy!
|
47
|
-
end
|
45
|
+
task env.name => ["frizz:build:#{env.name}", "frizz:deploy:#{env.name}"] do; end
|
48
46
|
end
|
49
47
|
end
|
50
48
|
end
|
data/lib/frizz/site.rb
CHANGED
@@ -2,17 +2,23 @@ module Frizz
|
|
2
2
|
class Site
|
3
3
|
def initialize(host, options={})
|
4
4
|
@options = { from: "build" }.merge options
|
5
|
-
|
6
|
-
@
|
5
|
+
|
6
|
+
@local = Local.new(path_to_deploy)
|
7
|
+
@remote = Remote.new(host)
|
8
|
+
|
9
|
+
if @options[:distribution]
|
10
|
+
@distribution = Distribution.new(@options[:distribution])
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
14
|
def deploy!
|
10
|
-
|
15
|
+
changes = Sync.new(local, remote).run!
|
16
|
+
distribution.invalidate!(changes) if distribution
|
11
17
|
end
|
12
18
|
|
13
19
|
private
|
14
20
|
|
15
|
-
attr_reader :local, :remote, :options
|
21
|
+
attr_reader :local, :remote, :options, :distribution
|
16
22
|
|
17
23
|
def path_to_deploy
|
18
24
|
File.expand_path(options[:from])
|
data/lib/frizz/sync.rb
CHANGED
@@ -6,28 +6,40 @@ module Frizz
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def run!
|
9
|
+
changes = []
|
10
|
+
|
11
|
+
# Sync existing files
|
9
12
|
remote.files.each do |remote_file|
|
10
13
|
local_path = remote_file.key
|
11
14
|
local_file_md5 = local_index[local_path]
|
12
15
|
|
13
16
|
if local_file_md5.nil?
|
14
17
|
puts "#{local_path}: deleted".red
|
18
|
+
|
15
19
|
remote_file.destroy
|
20
|
+
changes << remote_file.key
|
16
21
|
elsif local_file_md5 == remote_file.etag
|
17
22
|
puts "#{local_path}: unchanged"
|
23
|
+
|
18
24
|
local_index.delete(local_path)
|
19
25
|
else
|
20
26
|
puts "#{local_path}: updated".green
|
27
|
+
|
21
28
|
remote.upload local.file_for(local_path), local_path
|
22
29
|
local_index.delete(local_path)
|
30
|
+
changes << local_path
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
26
34
|
# Upload new files
|
27
35
|
local_index.each do |local_path, md5|
|
28
36
|
puts "#{local_path}: new".green
|
37
|
+
|
29
38
|
remote.upload local.file_for(local_path), local_path
|
39
|
+
changes << local_path
|
30
40
|
end
|
41
|
+
|
42
|
+
changes
|
31
43
|
end
|
32
44
|
|
33
45
|
private
|
data/lib/frizz/version.rb
CHANGED
data/lib/frizz.rb
CHANGED
@@ -5,6 +5,7 @@ module Frizz
|
|
5
5
|
autoload :Site, "frizz/site"
|
6
6
|
autoload :Local, "frizz/local"
|
7
7
|
autoload :Remote, "frizz/remote"
|
8
|
+
autoload :Distribution, "frizz/distribution"
|
8
9
|
autoload :Sync, "frizz/sync"
|
9
10
|
autoload :Configuration, "frizz/configuration"
|
10
11
|
autoload :Environment, "frizz/environment"
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: frizz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.4.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- patbenatar
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -107,6 +107,22 @@ dependencies:
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 1.2.2
|
109
109
|
none: false
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
prerelease: false
|
112
|
+
name: cloudfront-invalidator
|
113
|
+
type: :runtime
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.2.0
|
119
|
+
none: false
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.2.0
|
125
|
+
none: false
|
110
126
|
description: Utility for deploying static sites to S3
|
111
127
|
email:
|
112
128
|
- nick@gophilosophie.com
|
@@ -122,6 +138,7 @@ files:
|
|
122
138
|
- frizz.gemspec
|
123
139
|
- lib/frizz.rb
|
124
140
|
- lib/frizz/configuration.rb
|
141
|
+
- lib/frizz/distribution.rb
|
125
142
|
- lib/frizz/environment.rb
|
126
143
|
- lib/frizz/local.rb
|
127
144
|
- lib/frizz/middleman/extension.rb
|
@@ -144,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
161
|
- !ruby/object:Gem::Version
|
145
162
|
segments:
|
146
163
|
- 0
|
147
|
-
hash:
|
164
|
+
hash: 3629913277282744277
|
148
165
|
version: '0'
|
149
166
|
none: false
|
150
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -153,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
170
|
- !ruby/object:Gem::Version
|
154
171
|
segments:
|
155
172
|
- 0
|
156
|
-
hash:
|
173
|
+
hash: 3629913277282744277
|
157
174
|
version: '0'
|
158
175
|
none: false
|
159
176
|
requirements: []
|