contentful_bootstrap 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/contentful_bootstrap +15 -8
- data/lib/contentful_bootstrap/commands.rb +34 -1
- data/lib/contentful_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e77ad4fd678b1dc7f168dc9335cccf1acd8284d
|
4
|
+
data.tar.gz: 94f63823bd9899ef377501f6600a6640a8a34000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cc6feca791ae952b4cec20beab02c16fd09b5158a88b79ec7fa0a94f5096b6536ab420201b422ec23f3f74340e9ae4ee168aaf4becd60beab86186d258751dd
|
7
|
+
data.tar.gz: 5cc98562634701de40c3cc480f9b5d809df25e235b4d43cc95fae90da6798b664d30c070865e5368680a2fbac347b4a7b0bd775e929c33f8a55264f232696f3e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
## Unreleased
|
3
3
|
|
4
|
+
## v0.0.5
|
5
|
+
### Added
|
6
|
+
* API Token Generation
|
7
|
+
* `generate_token` command added to binary
|
8
|
+
* Better Formatting of current steps
|
9
|
+
* Space and Access Token Values displayed at end of command
|
10
|
+
|
4
11
|
## v0.0.4
|
5
12
|
### Added
|
6
13
|
* Added support for users with multiple Organizations
|
data/bin/contentful_bootstrap
CHANGED
@@ -17,40 +17,47 @@ end
|
|
17
17
|
subcommands = {
|
18
18
|
'init' => OptionParser.new do |opts|
|
19
19
|
opts.banner = "Usage: init <space_name> [--template TEMPLATE_NAME]"
|
20
|
-
opts.on("-t", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
21
|
-
options[:
|
20
|
+
opts.on("-t TEMPLATE", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
21
|
+
options[:name] = t
|
22
22
|
end
|
23
23
|
end,
|
24
24
|
'create_space' => OptionParser.new do |opts|
|
25
25
|
opts.banner = "Usage: init <space_name> [--template TEMPLATE_NAME]"
|
26
|
-
opts.on("-t", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
27
|
-
options[:
|
26
|
+
opts.on("-t TEMPLATE", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
27
|
+
options[:name] = t
|
28
|
+
end
|
29
|
+
end,
|
30
|
+
'generate_token' => OptionParser.new do |opts|
|
31
|
+
opts.banner = "Usage: generate_token <space_id> [--name TOKEN_NAME]"
|
32
|
+
opts.on("-n NAME", "--name TEMPLATE", "Specify Token Name") do |n|
|
33
|
+
options[:name] = n
|
28
34
|
end
|
29
35
|
end
|
30
36
|
}
|
31
37
|
|
32
38
|
global.order!
|
33
39
|
command = ARGV.shift
|
34
|
-
|
40
|
+
space = ARGV.shift
|
35
41
|
|
36
42
|
if subcommands.has_key? command
|
37
43
|
subcommands[command].order!
|
38
44
|
|
39
|
-
if
|
45
|
+
if space.nil? || space.empty?
|
40
46
|
puts "Usage: contentful_bootstrap <command> <space_name> [--template TEMPLATE_NAME]"
|
41
47
|
puts
|
42
48
|
puts "You must provide a valid space name. Exiting!"
|
43
49
|
exit
|
44
50
|
end
|
45
51
|
|
46
|
-
ContentfulBootstrap::Commands.new.send(command,
|
52
|
+
ContentfulBootstrap::Commands.new.send(command, space, options.fetch(:name, nil))
|
47
53
|
else
|
48
|
-
puts "Usage: contentful_bootstrap <command> <
|
54
|
+
puts "Usage: contentful_bootstrap <command> <space> [options]"
|
49
55
|
puts
|
50
56
|
puts <<-HELP
|
51
57
|
Subcommand not available or missing
|
52
58
|
Available commands are:
|
53
59
|
init
|
54
60
|
create_space
|
61
|
+
generate_token
|
55
62
|
HELP
|
56
63
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "net/http"
|
2
2
|
require "contentful/management"
|
3
|
+
require "contentful/management/request"
|
4
|
+
require "contentful/management/error"
|
3
5
|
require "contentful_bootstrap/token"
|
4
6
|
require "contentful_bootstrap/server"
|
5
7
|
require "contentful_bootstrap/support"
|
@@ -18,6 +20,8 @@ module ContentfulBootstrap
|
|
18
20
|
puts "OAuth token found, moving on!"
|
19
21
|
end
|
20
22
|
|
23
|
+
puts
|
24
|
+
|
21
25
|
create_space(space_name, template_name)
|
22
26
|
end
|
23
27
|
|
@@ -34,7 +38,9 @@ module ContentfulBootstrap
|
|
34
38
|
organization_id = gets.chomp
|
35
39
|
space = Contentful::Management::Space.create(name: space_name, organization_id: organization_id)
|
36
40
|
end
|
41
|
+
|
37
42
|
puts "Space '#{space_name}' created!"
|
43
|
+
puts
|
38
44
|
|
39
45
|
return if template_name.nil?
|
40
46
|
|
@@ -46,6 +52,33 @@ module ContentfulBootstrap
|
|
46
52
|
else
|
47
53
|
puts "Template '#{template_name}' not found. Valid templates are '#{templates.keys.map(&:to_s).join('\', \'')}'"
|
48
54
|
end
|
55
|
+
|
56
|
+
token = generate_token(space)
|
57
|
+
puts
|
58
|
+
puts "Space ID: '#{space.id}'"
|
59
|
+
puts "Access Token: '#{token}'"
|
60
|
+
puts
|
61
|
+
puts "You can now insert those values into your configuration blocks"
|
62
|
+
end
|
63
|
+
|
64
|
+
def generate_token(space, token_name = "Bootstrap Token")
|
65
|
+
management_client_init
|
66
|
+
|
67
|
+
if space.is_a?(String)
|
68
|
+
space = Contentful::Management::Space.find(space)
|
69
|
+
end
|
70
|
+
|
71
|
+
puts "Creating Delivery API Token"
|
72
|
+
|
73
|
+
response = Contentful::Management::Request.new(
|
74
|
+
"/#{space.id}/api_keys",
|
75
|
+
'name' => token_name,
|
76
|
+
'description' => "Created with 'contentful_bootstrap.rb'"
|
77
|
+
).post
|
78
|
+
fail response if response.object.is_a?(Contentful::Management::Error)
|
79
|
+
token = response.object["accessToken"]
|
80
|
+
|
81
|
+
puts "Token '#{token_name}' created! - '#{token}'"
|
49
82
|
end
|
50
83
|
|
51
84
|
private
|
@@ -54,7 +87,7 @@ module ContentfulBootstrap
|
|
54
87
|
end
|
55
88
|
|
56
89
|
def get_token
|
57
|
-
silence_stderr do # Don't show any
|
90
|
+
silence_stderr do # Don't show any WEBrick related stuff
|
58
91
|
server = Server.new
|
59
92
|
|
60
93
|
server.start
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Litvak Bruno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|