netlify 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -95
- data/lib/netlify.rb +1 -0
- data/lib/netlify/client.rb +4 -0
- data/lib/netlify/deploy.rb +0 -1
- data/lib/netlify/deploy_key.rb +7 -0
- data/lib/netlify/deploy_keys.rb +7 -0
- data/lib/netlify/model.rb +1 -1
- data/lib/netlify/site.rb +33 -2
- data/lib/netlify/sites.rb +2 -0
- data/lib/netlify/version.rb +1 -1
- data/netlify.gemspec +26 -0
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 437996fb50a44a765375a8b7f176fc5b4e2e8b14
|
4
|
+
data.tar.gz: 902fce5832eba704da8714fc7d24a5d77e0d4d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9e999d347c6c0e23a5381f5a35235a6da6c5509befa1fc52fbc14b4c4f32b439da8215c7e9ff9df57049a71441be93b67a512575dca27380d462c8f3872df5
|
7
|
+
data.tar.gz: 96c84262f78082f8d127131ad2ebb9effbcd8a66eda35fbf2aae37784198a8055e9290ee5480a9d54fcdf45df789c411bf565a350555d331154afb7fb8274740
|
data/README.md
CHANGED
@@ -197,50 +197,33 @@ deploy = site.deploys.create(:dir => "/tmp/my-site", :draft => true)
|
|
197
197
|
|
198
198
|
This will upload and process a deploy. You can view the deploy at `deploy.deploy_url` and make it the live version of the site with `deploy.publish`.
|
199
199
|
|
200
|
+
Continuous Deployment
|
201
|
+
=====================
|
200
202
|
|
201
|
-
|
202
|
-
=====
|
203
|
-
|
204
|
-
Access all users you have access to
|
205
|
-
|
206
|
-
```ruby
|
207
|
-
Netlify.users.all
|
208
|
-
```
|
209
|
-
|
210
|
-
Access a specific user
|
203
|
+
You can also configure continuous deployment for a new or existing site from the Ruby client.
|
211
204
|
|
212
|
-
|
213
|
-
Netlify.users.get(id)
|
214
|
-
```
|
205
|
+
You'll need a Github access token (this will never get sent to Netlify) in addition to your Netlify token. Make sure this access token have the permission to add a deploy key and a web hook to your repository.
|
215
206
|
|
216
|
-
Create a
|
207
|
+
Create a new site with continuous deployment:
|
217
208
|
|
218
209
|
```ruby
|
219
|
-
|
210
|
+
client.sites.create(:github => {
|
211
|
+
:repo => "netlify/example",
|
212
|
+
:dir => "build",
|
213
|
+
:cmd => "middleman build",
|
214
|
+
:access_token => GITHUB_ACCESS_TOKEN
|
215
|
+
})
|
220
216
|
```
|
221
217
|
|
222
|
-
|
218
|
+
Configure continuous deployment for an existing site:
|
223
219
|
|
224
220
|
```ruby
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
Netlify.users.get(id).destroy
|
232
|
-
```
|
233
|
-
|
234
|
-
Get all sites for a user
|
235
|
-
|
236
|
-
```ruby
|
237
|
-
Netlify.users.get(id).sites
|
238
|
-
```
|
239
|
-
|
240
|
-
Get all form submissions for a user
|
241
|
-
|
242
|
-
```ruby
|
243
|
-
Netlify.users.get(id).submissions
|
221
|
+
site.configure_github!(
|
222
|
+
:repo => "netlify/example",
|
223
|
+
:dir => "build",
|
224
|
+
:cmd => "middleman build",
|
225
|
+
:access_token => GITHUB_ACCESS_TOKEN
|
226
|
+
)
|
244
227
|
```
|
245
228
|
|
246
229
|
Forms
|
@@ -361,63 +344,3 @@ Remove a snippet
|
|
361
344
|
site.snippet.get(id).destroy
|
362
345
|
end
|
363
346
|
```
|
364
|
-
|
365
|
-
DNS Zones
|
366
|
-
=========
|
367
|
-
|
368
|
-
Resellers can manage DNS Zones through the ruby client. To use this feature your access token must belong to a reseller administrator.
|
369
|
-
|
370
|
-
Create a DNS Zone
|
371
|
-
|
372
|
-
```ruby
|
373
|
-
Netlify.dns_zones.create(:name => "www.example.com", :user_id => "1234")
|
374
|
-
```
|
375
|
-
|
376
|
-
Get all DNS Zones
|
377
|
-
|
378
|
-
```ruby
|
379
|
-
Netlify.dns_zones.all
|
380
|
-
```
|
381
|
-
|
382
|
-
Delete a DNS Zone
|
383
|
-
|
384
|
-
```ruby
|
385
|
-
dns_zone.destroy
|
386
|
-
```
|
387
|
-
|
388
|
-
Get all dns records for a zone
|
389
|
-
|
390
|
-
```ruby
|
391
|
-
dns_zone.dns_records.all
|
392
|
-
```
|
393
|
-
|
394
|
-
Adding a new record (supported types: A, CNAME, TXT, MX)
|
395
|
-
|
396
|
-
```ruby
|
397
|
-
dns_zone.dns_records.create(:hostname => "www", :type => "CNAME", :value => "Netlify.com", :ttl => "500")
|
398
|
-
```
|
399
|
-
|
400
|
-
Deleting a record
|
401
|
-
|
402
|
-
```ruby
|
403
|
-
dns_record.destroy
|
404
|
-
```
|
405
|
-
|
406
|
-
Access Tokens
|
407
|
-
=============
|
408
|
-
|
409
|
-
Resellers can create and revoke access tokens on behalf of their users. To use this feature your access token must belong to a reseller administrator.
|
410
|
-
|
411
|
-
Create access token:
|
412
|
-
|
413
|
-
```ruby
|
414
|
-
Netlify.access_tokens.create(:user => {:email => "test@example.com", :uid => 123})
|
415
|
-
```
|
416
|
-
|
417
|
-
The user must have either an email or a uid or both. Both email and uid must be unique within your reseller account. The uid would typically correspond to your internal database id for the user. If the users doesn't exist, a new user will be created on the fly.
|
418
|
-
|
419
|
-
Revoke access token:
|
420
|
-
|
421
|
-
```ruby
|
422
|
-
Netlify.access_tokens.get("token-string").destroy
|
423
|
-
```
|
data/lib/netlify.rb
CHANGED
data/lib/netlify/client.rb
CHANGED
data/lib/netlify/deploy.rb
CHANGED
data/lib/netlify/model.rb
CHANGED
data/lib/netlify/site.rb
CHANGED
@@ -4,8 +4,8 @@ require 'uri'
|
|
4
4
|
module Netlify
|
5
5
|
class Site < Model
|
6
6
|
fields :id, :state, :premium, :claimed, :name, :custom_domain, :url,
|
7
|
-
:admin_url, :deploy_id, :deploy_url, :screenshot_url, :created_at, :updated_at,
|
8
|
-
:password, :notification_email, :user_id, :error_message, :required
|
7
|
+
:admin_url, :deploy_id, :build_id, :deploy_url, :screenshot_url, :created_at, :updated_at,
|
8
|
+
:password, :notification_email, :user_id, :error_message, :required, :deploy_hook
|
9
9
|
|
10
10
|
def ready?
|
11
11
|
state == "current"
|
@@ -32,6 +32,37 @@ module Netlify
|
|
32
32
|
self
|
33
33
|
end
|
34
34
|
|
35
|
+
def configure_github!(options)
|
36
|
+
raise Client::NetlifyError, "You must specify a Github access_token" unless options[:access_token]
|
37
|
+
raise Client::NetlifyError, "You must specify a Github repo" unless options[:repo]
|
38
|
+
require "github_api"
|
39
|
+
|
40
|
+
_, user, repo = *options[:repo].match(/^([^\/]+)\/([^\/]+)$/)
|
41
|
+
unless user && repo
|
42
|
+
raise Client::NetlifyError, "Invalid github repo #{options[:repo]}"
|
43
|
+
end
|
44
|
+
|
45
|
+
github = Github.new(:oauth_token => options[:access_token])
|
46
|
+
deploy_key = client.deploy_keys.create({})
|
47
|
+
github.repos.keys.create(user, repo, title: "Netlify", key: deploy_key.public_key)
|
48
|
+
response = client.request(:put, path, :body => {
|
49
|
+
:github => {
|
50
|
+
:repo => options[:repo],
|
51
|
+
:deploy_key_id => deploy_key.id,
|
52
|
+
:dir => options[:dir],
|
53
|
+
:cmd => options[:cmd],
|
54
|
+
:branch => options[:branch],
|
55
|
+
:env => options[:env]
|
56
|
+
}
|
57
|
+
})
|
58
|
+
process(response.parsed)
|
59
|
+
github.repos.hooks.create(user, repo, name: "web", active: true, events: ["push"], config: {
|
60
|
+
url: deploy_hook,
|
61
|
+
content_type: 'json'
|
62
|
+
})
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
35
66
|
def destroy!
|
36
67
|
client.request(:delete, path)
|
37
68
|
true
|
data/lib/netlify/sites.rb
CHANGED
data/lib/netlify/version.rb
CHANGED
data/netlify.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'Netlify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "netlify"
|
8
|
+
gem.version = Netlify::VERSION
|
9
|
+
gem.authors = ["Mathias Biilmann Christensen"]
|
10
|
+
gem.email = ["mathias@Netlify.com"]
|
11
|
+
gem.description = %q{API Client for Netlify}
|
12
|
+
gem.summary = %q{API Client for Netlify}
|
13
|
+
gem.homepage = "https://www.netlify.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "oauth2", ">= 0.9.2"
|
21
|
+
gem.add_dependency "slop"
|
22
|
+
gem.add_dependency "highline"
|
23
|
+
gem.add_dependency "github_api"
|
24
|
+
gem.add_development_dependency "minitest"
|
25
|
+
gem.add_development_dependency "webmock"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netlify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Biilmann Christensen
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: github_api
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: minitest
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,6 +112,8 @@ files:
|
|
98
112
|
- lib/netlify/client.rb
|
99
113
|
- lib/netlify/collection_proxy.rb
|
100
114
|
- lib/netlify/deploy.rb
|
115
|
+
- lib/netlify/deploy_key.rb
|
116
|
+
- lib/netlify/deploy_keys.rb
|
101
117
|
- lib/netlify/deploys.rb
|
102
118
|
- lib/netlify/dns_record.rb
|
103
119
|
- lib/netlify/dns_records.rb
|
@@ -118,6 +134,7 @@ files:
|
|
118
134
|
- lib/netlify/user.rb
|
119
135
|
- lib/netlify/users.rb
|
120
136
|
- lib/netlify/version.rb
|
137
|
+
- netlify.gemspec
|
121
138
|
- test/client_test.rb
|
122
139
|
- test/files/site-dir.zip
|
123
140
|
- test/files/site-dir/index.html
|