frizz 1.7.0 → 2.0.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
- data/README.md +21 -3
- data/frizz.gemspec +2 -2
- data/lib/frizz/environment.rb +1 -1
- data/lib/frizz/local.rb +38 -5
- data/lib/frizz/middleman/tasks.rb +7 -1
- data/lib/frizz/remote.rb +33 -16
- data/lib/frizz/site.rb +5 -2
- data/lib/frizz/sync.rb +13 -8
- data/lib/frizz/version.rb +1 -1
- metadata +31 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac81e9f8422a598be934dfc3408700e10c06e24e
|
4
|
+
data.tar.gz: 8bff2ca30a6e00e36c4a0e32132faf230a4f27a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6e88ad4ff8577b2b27774308d68e79e7c211d6ce03e94fc14667c1857740c5fdadf339f57e3fa797281b826ed45ff3440c3b95f791f23dcd7623dafd6847fe
|
7
|
+
data.tar.gz: 0b1c66cd3b000bd6ebe6473fc95571c6478363859f0760c71025cf0c9db44f8b2c1a735792c23ec2a622e9fb4504d045f8ca0182c11c3e3ec345811f8c7f79f2
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@ some nifty Middleman integrations for managing environments.
|
|
9
9
|
* Only uploads files that have changed
|
10
10
|
* Removes files that have been deleted locally
|
11
11
|
* Invalidate changed files on CloudFront
|
12
|
+
* Supports S3 redirects
|
12
13
|
|
13
14
|
### Middleman Features
|
14
15
|
|
@@ -62,14 +63,14 @@ end
|
|
62
63
|
Deploy the contents of `build/` to your bucket named "my-static-site.com":
|
63
64
|
|
64
65
|
```ruby
|
65
|
-
site = Frizz::Site.new("my-static-site.com")
|
66
|
+
site = Frizz::Site.new("my-static-site.com", region: "us-west-2")
|
66
67
|
site.deploy!
|
67
68
|
```
|
68
69
|
|
69
70
|
Specify a different local build dir:
|
70
71
|
|
71
72
|
```ruby
|
72
|
-
site = Frizz::Site.new("my-static-site.com", from: "build/public")
|
73
|
+
site = Frizz::Site.new("my-static-site.com", region: "us-west-2", from: "build/public")
|
73
74
|
```
|
74
75
|
|
75
76
|
### Deploy with CloudFront invalidation
|
@@ -79,7 +80,7 @@ the cache for any files that changed or were removed in the deploy. Note:
|
|
79
80
|
invalidating a CloudFront cache can take some time.
|
80
81
|
|
81
82
|
```ruby
|
82
|
-
site = Frizz::Site.new("my-bucket", distribution: "DISTRIBUTION_ID")
|
83
|
+
site = Frizz::Site.new("my-bucket", region: "us-west-2", distribution: "DISTRIBUTION_ID")
|
83
84
|
site.deploy!
|
84
85
|
```
|
85
86
|
|
@@ -96,6 +97,19 @@ environments:
|
|
96
97
|
- "logs/*"
|
97
98
|
```
|
98
99
|
|
100
|
+
### Redirects
|
101
|
+
|
102
|
+
You can setup [S3 redirects](http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html)
|
103
|
+
in `frizz.yml`:
|
104
|
+
|
105
|
+
```yaml
|
106
|
+
environments:
|
107
|
+
production:
|
108
|
+
redirect_rules:
|
109
|
+
- from: "old/page.html"
|
110
|
+
to: "/new/page.html"
|
111
|
+
```
|
112
|
+
|
99
113
|
## Usage With Middleman
|
100
114
|
|
101
115
|
Managing more than the basic two environments (dev and build) in a Middleman app
|
@@ -129,8 +143,10 @@ With the following `frizz.yml`:
|
|
129
143
|
environments:
|
130
144
|
staging:
|
131
145
|
host: "staging.example.com"
|
146
|
+
region: "us-west-2"
|
132
147
|
production:
|
133
148
|
host: "example.com"
|
149
|
+
region: "us-west-2"
|
134
150
|
distribution "CLOUDFRONT_DISTRIBUTION_ID"
|
135
151
|
```
|
136
152
|
|
@@ -176,10 +192,12 @@ With the following `frizz.yml`:
|
|
176
192
|
environments:
|
177
193
|
staging:
|
178
194
|
host: "staging.example.com"
|
195
|
+
region: "us-west-2"
|
179
196
|
api_root: http://api.staging.example.com/v0
|
180
197
|
welcome_message: I'm A Staging Server
|
181
198
|
production:
|
182
199
|
host: "example.com"
|
200
|
+
region: "us-west-2"
|
183
201
|
api_root: http://api.example.com/v0
|
184
202
|
welcome_message: I'm A Production Server
|
185
203
|
development:
|
data/frizz.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
|
24
|
-
spec.add_dependency "s3", "~> 0.3.13"
|
25
24
|
spec.add_dependency "colorize", "~> 0.6.0"
|
26
25
|
spec.add_dependency "mime-types", "~> 1.25"
|
27
|
-
spec.add_dependency "listen", "
|
26
|
+
spec.add_dependency "listen", "> 2.0", "< 4.0"
|
28
27
|
spec.add_dependency "cloudfront-invalidator", "~> 0.2.0"
|
28
|
+
spec.add_dependency 'aws-sdk', '~> 2.2', '>= 2.2.35'
|
29
29
|
end
|
data/lib/frizz/environment.rb
CHANGED
data/lib/frizz/local.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Frizz
|
2
2
|
class Local
|
3
|
-
def initialize(root_path, ignorance)
|
3
|
+
def initialize(root_path, ignorance, options = {})
|
4
4
|
@root_path = root_path
|
5
5
|
@ignorance = ignorance
|
6
|
+
@options = options
|
6
7
|
end
|
7
8
|
|
8
9
|
def files
|
@@ -12,16 +13,20 @@ module Frizz
|
|
12
13
|
File.new(expand_path(local_path), local_path) unless ignore?(local_path)
|
13
14
|
end.compact
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end.concat(redirect_files)
|
16
17
|
end
|
17
18
|
|
18
19
|
def file_for(local_path)
|
19
|
-
|
20
|
+
if is_redirect?(local_path)
|
21
|
+
Tempfile.new(local_path.gsub(/\.|\//, '-'))
|
22
|
+
else
|
23
|
+
::File.read expand_path(local_path)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
private
|
23
28
|
|
24
|
-
attr_reader :root_path, :ignorance
|
29
|
+
attr_reader :root_path, :ignorance, :options
|
25
30
|
|
26
31
|
def expand_path(local_path)
|
27
32
|
::File.join root_path, local_path
|
@@ -31,17 +36,45 @@ module Frizz
|
|
31
36
|
::File.directory?(path) || ignorance.ignore?(path)
|
32
37
|
end
|
33
38
|
|
39
|
+
def is_redirect?(path)
|
40
|
+
redirect_files.any? { |r| r.key == path }
|
41
|
+
end
|
42
|
+
|
43
|
+
def redirect_files
|
44
|
+
@redirect_files ||= if options[:redirect_rules]
|
45
|
+
options[:redirect_rules].map do |redirect_rule|
|
46
|
+
File.new(
|
47
|
+
expand_path(redirect_rule['from']),
|
48
|
+
redirect_rule['from'],
|
49
|
+
redirect_to: redirect_rule['to']
|
50
|
+
)
|
51
|
+
end
|
52
|
+
else
|
53
|
+
[]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
34
57
|
class File
|
35
58
|
attr_reader :path, :key
|
36
59
|
|
37
|
-
def initialize(path, key)
|
60
|
+
def initialize(path, key, options = {})
|
38
61
|
@path = path
|
39
62
|
@key = key
|
63
|
+
@options = options
|
40
64
|
end
|
41
65
|
|
42
66
|
def checksum
|
67
|
+
return nil if options[:redirect_to]
|
43
68
|
Digest::MD5.file(path)
|
44
69
|
end
|
70
|
+
|
71
|
+
def upload_options
|
72
|
+
options
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
attr_reader :options
|
45
78
|
end
|
46
79
|
end
|
47
80
|
end
|
@@ -35,7 +35,13 @@ module Frizz
|
|
35
35
|
relevant_environments.each do |name, env|
|
36
36
|
desc "Deploy build dir to #{env.name}: #{env.bucket}"
|
37
37
|
task env.name do
|
38
|
-
Frizz::Site.new(
|
38
|
+
Frizz::Site.new(
|
39
|
+
env.bucket,
|
40
|
+
distribution: env.distribution,
|
41
|
+
ignore: env.ignore,
|
42
|
+
redirect_rules: env.redirect_rules,
|
43
|
+
region: env.region
|
44
|
+
).deploy!
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
data/lib/frizz/remote.rb
CHANGED
@@ -1,41 +1,58 @@
|
|
1
|
-
require
|
1
|
+
require 'aws-sdk'
|
2
2
|
require "mime-types"
|
3
3
|
|
4
4
|
module Frizz
|
5
5
|
class Remote
|
6
|
-
def initialize(bucket_name, ignorance)
|
6
|
+
def initialize(bucket_name, ignorance, options = {})
|
7
|
+
@options = options
|
7
8
|
@bucket_name = bucket_name
|
8
9
|
@ignorance = ignorance
|
9
10
|
end
|
10
11
|
|
11
12
|
def files
|
12
|
-
@files ||=
|
13
|
+
@files ||= objects.reject { |o| ignore?(o) }
|
13
14
|
end
|
14
15
|
|
15
|
-
def upload(file, key)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def upload(file, key, options = {})
|
17
|
+
object_options = {
|
18
|
+
bucket: bucket_name,
|
19
|
+
body: file,
|
20
|
+
acl: 'public-read',
|
21
|
+
content_type: MIME::Types.type_for(key).first.content_type,
|
22
|
+
key: key
|
23
|
+
}
|
24
|
+
|
25
|
+
object_options[:website_redirect_location] = options[:redirect_to] if options[:redirect_to]
|
26
|
+
|
27
|
+
client.put_object object_options
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(remote_file)
|
31
|
+
client.delete_object(
|
32
|
+
bucket: bucket_name,
|
33
|
+
key: remote_file.key
|
34
|
+
)
|
21
35
|
end
|
22
36
|
|
23
37
|
private
|
24
38
|
|
25
|
-
attr_reader :bucket_name, :ignorance
|
39
|
+
attr_reader :bucket_name, :ignorance, :options
|
26
40
|
|
27
41
|
def ignore?(object)
|
28
42
|
ignorance.ignore?(object.key)
|
29
43
|
end
|
30
44
|
|
31
|
-
def
|
32
|
-
|
45
|
+
def objects
|
46
|
+
client.list_objects(bucket: bucket_name).contents
|
33
47
|
end
|
34
48
|
|
35
|
-
def
|
36
|
-
@
|
37
|
-
|
38
|
-
|
49
|
+
def client
|
50
|
+
@client ||= Aws::S3::Client.new(
|
51
|
+
region: options[:region],
|
52
|
+
credentials: Aws::Credentials.new(
|
53
|
+
Frizz.configuration.access_key_id,
|
54
|
+
Frizz.configuration.secret_access_key
|
55
|
+
)
|
39
56
|
)
|
40
57
|
end
|
41
58
|
end
|
data/lib/frizz/site.rb
CHANGED
@@ -9,8 +9,11 @@ module Frizz
|
|
9
9
|
@distribution = Distribution.new(@options[:distribution])
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
@
|
12
|
+
local_options = options.select { |k, v| k == :redirect_rules }
|
13
|
+
@local = Local.new(path_to_deploy, ignorance, local_options)
|
14
|
+
|
15
|
+
remote_options = options.select { |k, v| k == :region }
|
16
|
+
@remote = Remote.new(host, ignorance, remote_options)
|
14
17
|
end
|
15
18
|
|
16
19
|
def deploy!
|
data/lib/frizz/sync.rb
CHANGED
@@ -11,31 +11,32 @@ module Frizz
|
|
11
11
|
# Sync existing files
|
12
12
|
remote.files.each do |remote_file|
|
13
13
|
local_path = remote_file.key
|
14
|
-
|
14
|
+
local_file = local_index[local_path]
|
15
|
+
local_file_md5 = local_file && local_file.checksum
|
15
16
|
|
16
17
|
if local_file_md5.nil?
|
17
18
|
puts "#{local_path}: deleted".red
|
18
19
|
|
19
|
-
remote_file
|
20
|
+
remote.delete(remote_file)
|
20
21
|
changes << remote_file.key
|
21
|
-
elsif local_file_md5 == remote_file.etag
|
22
|
+
elsif local_file_md5 == remote_file.etag.gsub('"', '')
|
22
23
|
puts "#{local_path}: unchanged"
|
23
24
|
|
24
25
|
local_index.delete(local_path)
|
25
26
|
else
|
26
27
|
puts "#{local_path}: updated".green
|
27
28
|
|
28
|
-
|
29
|
+
upload(local_path, local_file)
|
29
30
|
local_index.delete(local_path)
|
30
31
|
changes << local_path
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
# Upload new files
|
35
|
-
local_index.each do |local_path,
|
36
|
+
local_index.each do |local_path, local_file|
|
36
37
|
puts "#{local_path}: new".green
|
37
38
|
|
38
|
-
|
39
|
+
upload(local_path, local_file)
|
39
40
|
changes << local_path
|
40
41
|
end
|
41
42
|
|
@@ -48,8 +49,12 @@ module Frizz
|
|
48
49
|
|
49
50
|
def local_index
|
50
51
|
@local_index ||= local.files.each_with_object({}) do |file, obj|
|
51
|
-
obj[file.key] = file
|
52
|
+
obj[file.key] = file
|
52
53
|
end
|
53
54
|
end
|
55
|
+
|
56
|
+
def upload(local_path, local_file)
|
57
|
+
remote.upload local.file_for(local_path), local_path, local_file.upload_options
|
58
|
+
end
|
54
59
|
end
|
55
|
-
end
|
60
|
+
end
|
data/lib/frizz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frizz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- patbenatar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: s3
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.3.13
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.3.13
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: colorize
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +70,22 @@ dependencies:
|
|
84
70
|
name: listen
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">"
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: '2.0'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '4.0'
|
90
79
|
type: :runtime
|
91
80
|
prerelease: false
|
92
81
|
version_requirements: !ruby/object:Gem::Requirement
|
93
82
|
requirements:
|
94
|
-
- - "
|
83
|
+
- - ">"
|
95
84
|
- !ruby/object:Gem::Version
|
96
85
|
version: '2.0'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.0'
|
97
89
|
- !ruby/object:Gem::Dependency
|
98
90
|
name: cloudfront-invalidator
|
99
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +100,26 @@ dependencies:
|
|
108
100
|
- - "~>"
|
109
101
|
- !ruby/object:Gem::Version
|
110
102
|
version: 0.2.0
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: aws-sdk
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.2'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.2.35
|
113
|
+
type: :runtime
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '2.2'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.2.35
|
111
123
|
description: Utility for deploying static sites to S3
|
112
124
|
email:
|
113
125
|
- nick@gophilosophie.com
|
@@ -155,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
167
|
version: '0'
|
156
168
|
requirements: []
|
157
169
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.5.1
|
159
171
|
signing_key:
|
160
172
|
specification_version: 4
|
161
173
|
summary: Utility for deploying static sites to S3
|