contentful_bootstrap 3.6.1 → 3.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 145e81e1443e293e56393c88c8609c4520abf6b5
4
- data.tar.gz: 7ab10aa65b840cb8d00bd463e035ad8b0745484c
3
+ metadata.gz: 82634cc77febe8735ad7eaa0d876764cb6826df9
4
+ data.tar.gz: a6773a570d9487e7b0254d9d96026c5a9db2938c
5
5
  SHA512:
6
- metadata.gz: 98bfc62b2a1eb07ab126fb1ab63bfdb7afdaf1d1315b95ec2e6b8b77a06ddfaba54bd99758cba01fc2ad09620fb0839c36bde47091946cbd3cd0d47de23ed544
7
- data.tar.gz: 90ac5afb07bda160a8384a79d7a739bd9d775a1c7f90c16854d77c391b4b635c04ec12e57c92ceced10451715f2476b7b32568df106e1042091c71bfdd542105
6
+ metadata.gz: e621ae7ea0351fbea39c571193305bc053bcb19898bff47015775f2174389dc3f4e4e59546969fad7381df089d2cc7d8078e0fa2c80def6f9038c20c784246cc
7
+ data.tar.gz: bee10a5bbd3d2bb58200211e4761ee8c6e1344bc7f0d88ce8e48c1d14222bd9ee656d64300b07128234ea1e03b5aae664b4dee635db4796d0211d191ea1e6432
data/.travis.yml CHANGED
@@ -1,10 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.7
4
3
  - 2.2.3
5
4
  - 2.3.1
6
5
  - 2.4.0
7
- - 2.0.0
8
6
  notifications:
9
7
  slack:
10
8
  secure: Pw7UFAHD2fSAUtjf0P/W0Wg91TVTMAV8Gl04B/XhFrYpjVtifsGxWipOBDvJr9S7ep2UFbR3YbBABRWAJAigoDHvwEaf6eytEFT9LGsMwmPQOtb5NlJt0+Qhvys3sZUM0KskBORQ+Etz1M0O4e9baC5Tz1V8GzI/lNxIbpIM7dwQU18st+9sUTjBh6UFJDRXd0Qm28VAHk7fjlhpdKVH+5F4iEnFfRw414wVja8kPVmVDHCEqHPWS1JyHIj4eU8E50yBi3WjC60eE2TjAsCA9wc9gzvxb4tN5vXyuIVtqopPW4JPIBCaIv+j07biNAiLrTccQ5vv9RD9NTPmXANX9LyF/qD9I+itFl8xLatnwy1JXtPpi/S+OlQj6lluF17F+3c8g64vVgTYXyCDgCqpzSTj/KsTfwC9PkVGh8bmZMLtfUyd4IiMw8qiXt2opEmv90K1aodcixrpL2Db/OS2aSo4djRfMrjMlUN7tGM7hg9yQfAaZQKCPjof4C/XGG9me9FX+BvnNf9Xl6/t6uHFnkBfF969UX7gk7tzkwyyqpOp/FQ+6c+EiZF7wnVotbW49FBgEmZN62JsXSquDBlDfWrALeX4y9dZ+uYrWBd4q47N+kZUtogwf3f3gj0pE+K1XmKV549HkiHZ9MHcFtOwNu7KrCFMmUSPGIUKSotbg/c=
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v3.7.0
6
+ ### Fixed
7
+ * Fixed `skip_content_types` option on `update_space` [#59](https://github.com/contentful/contentful-bootstrap.rb/pull/59)
8
+
9
+ ### Added
10
+ * Added `--locale` option to `create_space` and `update_space` in order to create Spaces on a locale different to `en-US`
11
+
5
12
  ## v3.6.1
6
13
 
7
14
  ### Changed
data/README.md CHANGED
@@ -26,7 +26,7 @@ $ gem install contentful_bootstrap
26
26
  You can create spaces by doing:
27
27
 
28
28
  ```bash
29
- $ contentful_bootstrap create_space <space_name> [--template template_name] [--json-template template_path] [--mark-processed] [--config CONFIG_PATH] [--quiet]
29
+ $ contentful_bootstrap create_space <space_name> [--template template_name] [--json-template template_path] [--locale locale_code] [--mark-processed] [--config CONFIG_PATH] [--quiet]
30
30
  ```
31
31
 
32
32
  You can also generate new Delivery API Tokens by doing:
@@ -87,6 +87,7 @@ Additionally, you can send an options hash with the following keys:
87
87
  options = {
88
88
  template: "blog", # Will use one of the predefined templates and create Content Types, Assets and Entries
89
89
  json_template: "/path/to/template.json", # Will use the JSON file specified as a Template
90
+ locale: "es-AR", # Will create the space with the specified locale code as default locale, defaults to "en-US"
90
91
  mark_processed: false, # if true will mark all resources as 'bootstrapProcessed' and will be avoided for update_space calls (doesnt affect create_space)
91
92
  trigger_oauth: true, # if true will trigger OAuth process
92
93
  quiet: false, # if true will not output to STDOUT
@@ -100,6 +101,7 @@ To Update an existing Space
100
101
  ```ruby
101
102
  options = {
102
103
  json_template: "/path/to/template.json", # Will use the JSON file specified as a Template
104
+ locale: "es-AR", # Will create the space with the specified locale code as default locale, defaults to "en-US"
103
105
  mark_processed: false, # if true will mark all resources as 'bootstrapProcessed and will be avoided on future update_space calls
104
106
  trigger_oauth: true, # if true will trigger OAuth process
105
107
  skip_content_types: false, # if true will avoid creating the content types
@@ -7,13 +7,16 @@ options = {}
7
7
 
8
8
  subcommands = {
9
9
  'create_space' => OptionParser.new do |opts|
10
- opts.banner = "Usage: create_space <space_name> [--template TEMPLATE_NAME] [--json-template JSON_PATH] [--mark-processed] [--config CONFIG_PATH]"
10
+ opts.banner = "Usage: create_space <space_name> [--template TEMPLATE_NAME] [--json-template JSON_PATH] [--locale LOCALE] [--mark-processed] [--config CONFIG_PATH]"
11
11
  opts.on("-t TEMPLATE", "--template TEMPLATE", "Specify Template", "Available Templates: blog, catalogue, gallery") do |t|
12
12
  options[:template] = t
13
13
  end
14
14
  opts.on("-j JSON_PATH", "--json-template JSON_PATH", "Specify JSON Template Path") do |j|
15
15
  options[:json_template] = j
16
16
  end
17
+ opts.on("-l LOCALE", "--locale LOCALE", "Set the Default Locale for the Space", "Defaults to 'en-US'") do |l|
18
+ options[:locale] = l
19
+ end
17
20
  opts.on('-m', '--mark-processed', "Mark Processed Items on JSON Templates") do |m|
18
21
  options[:mark_processed] = m
19
22
  end
@@ -28,10 +31,13 @@ subcommands = {
28
31
  end
29
32
  end,
30
33
  'update_space' => OptionParser.new do |opts|
31
- opts.banner = "Usage: update_space <space_id> --json-template JSON_PATH [--mark-processed] [--config CONFIG_PATH]"
34
+ opts.banner = "Usage: update_space <space_id> --json-template JSON_PATH [--locale LOCALE] [--mark-processed] [--config CONFIG_PATH]"
32
35
  opts.on("-j JSON_PATH", "--json-template JSON_PATH", "Specify JSON Template Path") do |j|
33
36
  options[:json_template] = j
34
37
  end
38
+ opts.on("-l LOCALE", "--locale LOCALE", "Set the Default Locale for the Space", "Defaults to 'en-US'") do |l|
39
+ options[:locale] = l
40
+ end
35
41
  opts.on('-m', '--mark-processed', "Mark Processed Items on JSON Templates") do |m|
36
42
  options[:mark_processed] = m
37
43
  end
@@ -37,6 +37,7 @@ module Contentful
37
37
  def management_client_init
38
38
  @client ||= ::Contentful::Management::Client.new(
39
39
  @token.read,
40
+ default_locale: options.fetch(:locale, "en-US"),
40
41
  raise_errors: true,
41
42
  integration_name: 'bootstrap',
42
43
  integration_version: ::Contentful::Bootstrap::VERSION
@@ -13,6 +13,7 @@ module Contentful
13
13
  @template_name = options.fetch(:template, nil)
14
14
  @json_template = options.fetch(:json_template, nil)
15
15
  @mark_processed = options.fetch(:mark_processed, false)
16
+ @locale = options.fetch(:locale, "en-US")
16
17
 
17
18
  super(token, space, options)
18
19
  end
@@ -45,7 +46,8 @@ module Contentful
45
46
  new_space = nil
46
47
  begin
47
48
  options = {
48
- name: @space
49
+ name: @space,
50
+ defaultLocale: @locale
49
51
  }
50
52
  options[:organization_id] = @token.read_organization_id unless @token.read_organization_id.nil?
51
53
  management_client_init
@@ -61,6 +63,7 @@ module Contentful
61
63
  output 'Your Organization ID has been stored as the default organization.'
62
64
  new_space = client.spaces.create(
63
65
  name: @space,
66
+ defaultLocale: @locale,
64
67
  organization_id: organization_id
65
68
  )
66
69
  end
@@ -37,6 +37,7 @@ module Contentful
37
37
  protected
38
38
 
39
39
  def fetch_space
40
+ management_client_init
40
41
  client.spaces.find(@space)
41
42
  rescue Contentful::Management::NotFound
42
43
  output 'Space Not Found. Exiting!'
@@ -48,7 +49,7 @@ module Contentful
48
49
  def update_json_template(space)
49
50
  if ::File.exist?(@json_template)
50
51
  output "Updating from JSON Template '#{@json_template}'"
51
- Templates::JsonTemplate.new(space, @json_template, @mark_processed, false, @skip_content_types).run
52
+ Templates::JsonTemplate.new(space, @json_template, @mark_processed, true, false, @skip_content_types).run
52
53
  output "JSON Template '#{@json_template}' updated!"
53
54
  else
54
55
  output "JSON Template '#{@json_template}' does not exist. Please check that you specified the correct file name."
@@ -1,6 +1,6 @@
1
1
  module Contentful
2
2
  module Bootstrap
3
- VERSION = '3.6.1'
3
+ VERSION = '3.7.0'
4
4
 
5
5
  def self.major_version
6
6
  VERSION.split('.').first.to_i
@@ -46,6 +46,7 @@ describe Contentful::Bootstrap::Commands::Base do
46
46
  allow_any_instance_of(described_class).to receive(:configuration)
47
47
  expect(Contentful::Management::Client).to receive(:new).with(
48
48
  token.read,
49
+ default_locale: 'en-US',
49
50
  raise_errors: true,
50
51
  integration_name: 'bootstrap',
51
52
  integration_version: Contentful::Bootstrap::VERSION
@@ -59,6 +59,34 @@ describe Contentful::Bootstrap::Commands::CreateSpace do
59
59
  end
60
60
  end
61
61
 
62
+ describe 'localization' do
63
+ it 'can create a space with a different locale' do
64
+ allow(Contentful::Bootstrap::Support).to receive(:gets).and_return('y')
65
+ allow(Contentful::Bootstrap::Support).to receive(:gets).and_return('n')
66
+
67
+ command = described_class.new(token, 'B.rb - locale creation', locale: 'es-AR')
68
+
69
+ vcr('space_with_different_locale') {
70
+ command.run
71
+ }
72
+
73
+ vcr('check_created_space') {
74
+ client = ::Contentful::Client.new(
75
+ space: 'vsy1ouf6jdcq',
76
+ access_token: '90e1b4964c3631cc9c751c42339814635623b001a53aec5aad23377299445433',
77
+ dynamic_entries: :auto,
78
+ raise_errors: true
79
+ )
80
+
81
+ space = client.space
82
+
83
+ expect(space.name).to eq("B.rb - locale creation")
84
+ expect(space.locales.first.code).to eq "es-AR"
85
+ expect(space.locales.first.default).to be_truthy
86
+ }
87
+ end
88
+ end
89
+
62
90
  describe 'issues' do
63
91
  it 'Importing asset array values does not work #22' do
64
92
  json_path = File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'issue_22.json'))
@@ -101,7 +129,7 @@ describe Contentful::Bootstrap::Commands::CreateSpace do
101
129
  expect(subject.client).to receive(:spaces).and_call_original
102
130
  space_proxy_double = Object.new
103
131
  expect(subject.client).to receive(:spaces) { space_proxy_double }
104
- expect(space_proxy_double).to receive(:create).with(name: 'foo', organization_id: 'foobar') { space_double }
132
+ expect(space_proxy_double).to receive(:create).with(name: 'foo', defaultLocale: 'en-US', organization_id: 'foobar') { space_double }
105
133
 
106
134
  subject.run
107
135
  }
@@ -52,12 +52,34 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
52
52
  expect(subject).to receive(:fetch_space) { space_double }
53
53
  expect(mock_template).to receive(:run)
54
54
 
55
- expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', mark_processed, false, false) { mock_template }
55
+ expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', mark_processed, true, false, false) { mock_template }
56
56
 
57
57
  subject.run
58
58
  end
59
59
  end
60
60
  end
61
+
62
+ it 'can update localized spaces' do
63
+ vcr('update_space_localized') {
64
+ json_path = File.expand_path(File.join('spec', 'fixtures', 'json_fixtures', 'update_space_localized.json'))
65
+ subject = described_class.new(token, 'vsy1ouf6jdcq', locale: 'es-AR', json_template: json_path, mark_processed: false, trigger_oauth: false, quiet: true)
66
+
67
+ subject.run
68
+ }
69
+
70
+ vcr('check_update_space_localized') {
71
+ client = Contentful::Client.new(
72
+ space: 'vsy1ouf6jdcq',
73
+ access_token: '90e1b4964c3631cc9c751c42339814635623b001a53aec5aad23377299445433',
74
+ dynamic_entries: :auto,
75
+ raise_errors: true
76
+ )
77
+
78
+ entries = client.entries(locale: 'es-AR')
79
+
80
+ expect(entries.map(&:text)).to eq ['Foo', 'Bar']
81
+ }
82
+ end
61
83
  end
62
84
 
63
85
  context 'with skip_content_types set to true' do
@@ -71,7 +93,7 @@ describe Contentful::Bootstrap::Commands::UpdateSpace do
71
93
  expect(subject).to receive(:fetch_space) { space_double }
72
94
  expect(mock_template).to receive(:run)
73
95
 
74
- expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', false, false, true) { mock_template }
96
+ expect(::Contentful::Bootstrap::Templates::JsonTemplate).to receive(:new).with(space_double, 'bar', false, true, false, true) { mock_template }
75
97
 
76
98
  subject.run
77
99
  end
@@ -0,0 +1,40 @@
1
+ {
2
+ "version": 3,
3
+ "contentTypes": [
4
+ {
5
+ "id": "test",
6
+ "name": "Test",
7
+ "displayField": "text",
8
+ "fields": [
9
+ {
10
+ "id": "text",
11
+ "name": "Text",
12
+ "type": "Symbol"
13
+ }
14
+ ]
15
+ }
16
+ ],
17
+ "assets": [
18
+
19
+ ],
20
+ "entries": {
21
+ "test": [
22
+ {
23
+ "sys": {
24
+ "id": "test_1"
25
+ },
26
+ "fields": {
27
+ "text": "Foo"
28
+ }
29
+ },
30
+ {
31
+ "sys": {
32
+ "id": "test_2"
33
+ },
34
+ "fields": {
35
+ "text": "Bar"
36
+ }
37
+ }
38
+ ]
39
+ }
40
+ }
@@ -0,0 +1,177 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://cdn.contentful.com/spaces/vsy1ouf6jdcq/content_types?limit=1000
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful.rb/2.1.3; platform ruby/2.4.1; os macOS/16;
12
+ Authorization:
13
+ - Bearer 90e1b4964c3631cc9c751c42339814635623b001a53aec5aad23377299445433
14
+ Content-Type:
15
+ - application/vnd.contentful.delivery.v1+json
16
+ Accept-Encoding:
17
+ - gzip
18
+ Connection:
19
+ - close
20
+ Host:
21
+ - cdn.contentful.com
22
+ User-Agent:
23
+ - http.rb/2.2.2
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Access-Control-Allow-Headers:
30
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Experimental-Feature
31
+ Access-Control-Allow-Methods:
32
+ - GET,HEAD,OPTIONS
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Expose-Headers:
36
+ - Etag
37
+ Access-Control-Max-Age:
38
+ - '86400'
39
+ Cache-Control:
40
+ - max-age=0
41
+ Content-Type:
42
+ - application/vnd.contentful.delivery.v1+json
43
+ Etag:
44
+ - '"c283f5e14b648b925eac46aa3ee07ca3"'
45
+ Server:
46
+ - Contentful
47
+ X-Content-Type-Options:
48
+ - nosniff
49
+ X-Contentful-Request-Id:
50
+ - d1e40cd5d4cfb17b8122b3b8256bf31a
51
+ Content-Length:
52
+ - '98'
53
+ Accept-Ranges:
54
+ - bytes
55
+ Date:
56
+ - Fri, 18 Aug 2017 21:03:09 GMT
57
+ Via:
58
+ - 1.1 varnish
59
+ Age:
60
+ - '0'
61
+ Connection:
62
+ - close
63
+ X-Served-By:
64
+ - cache-atl6236-ATL
65
+ X-Cache:
66
+ - MISS
67
+ X-Cache-Hits:
68
+ - '0'
69
+ X-Timer:
70
+ - S1503090189.214686,VS0,VE206
71
+ Vary:
72
+ - Accept-Encoding
73
+ body:
74
+ encoding: ASCII-8BIT
75
+ string: |
76
+ {
77
+ "sys": {
78
+ "type": "Array"
79
+ },
80
+ "total": 0,
81
+ "skip": 0,
82
+ "limit": 1000,
83
+ "items": []
84
+ }
85
+ http_version:
86
+ recorded_at: Fri, 18 Aug 2017 21:03:09 GMT
87
+ - request:
88
+ method: get
89
+ uri: https://cdn.contentful.com/spaces/vsy1ouf6jdcq
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers:
94
+ X-Contentful-User-Agent:
95
+ - sdk contentful.rb/2.1.3; platform ruby/2.4.1; os macOS/16;
96
+ Authorization:
97
+ - Bearer 90e1b4964c3631cc9c751c42339814635623b001a53aec5aad23377299445433
98
+ Content-Type:
99
+ - application/vnd.contentful.delivery.v1+json
100
+ Accept-Encoding:
101
+ - gzip
102
+ Connection:
103
+ - close
104
+ Host:
105
+ - cdn.contentful.com
106
+ User-Agent:
107
+ - http.rb/2.2.2
108
+ response:
109
+ status:
110
+ code: 200
111
+ message: OK
112
+ headers:
113
+ Access-Control-Allow-Headers:
114
+ - Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Experimental-Feature
115
+ Access-Control-Allow-Methods:
116
+ - GET,HEAD,OPTIONS
117
+ Access-Control-Allow-Origin:
118
+ - "*"
119
+ Access-Control-Expose-Headers:
120
+ - Etag
121
+ Access-Control-Max-Age:
122
+ - '86400'
123
+ Cache-Control:
124
+ - max-age=0
125
+ Content-Type:
126
+ - application/vnd.contentful.delivery.v1+json
127
+ Etag:
128
+ - '"41e2e178aad9b651bb9c230458dacaa0"'
129
+ Server:
130
+ - Contentful
131
+ X-Content-Type-Options:
132
+ - nosniff
133
+ X-Contentful-Request-Id:
134
+ - 07c944a494b440cb72fbfc4a8aaee17b
135
+ Content-Length:
136
+ - '229'
137
+ Accept-Ranges:
138
+ - bytes
139
+ Date:
140
+ - Fri, 18 Aug 2017 21:03:10 GMT
141
+ Via:
142
+ - 1.1 varnish
143
+ Age:
144
+ - '0'
145
+ Connection:
146
+ - close
147
+ X-Served-By:
148
+ - cache-atl6239-ATL
149
+ X-Cache:
150
+ - MISS
151
+ X-Cache-Hits:
152
+ - '0'
153
+ X-Timer:
154
+ - S1503090190.215703,VS0,VE174
155
+ Vary:
156
+ - Accept-Encoding
157
+ body:
158
+ encoding: ASCII-8BIT
159
+ string: |
160
+ {
161
+ "sys": {
162
+ "type": "Space",
163
+ "id": "vsy1ouf6jdcq"
164
+ },
165
+ "name": "B.rb - locale creation",
166
+ "locales": [
167
+ {
168
+ "code": "es-AR",
169
+ "default": true,
170
+ "name": "es-AR",
171
+ "fallbackCode": null
172
+ }
173
+ ]
174
+ }
175
+ http_version:
176
+ recorded_at: Fri, 18 Aug 2017 21:03:10 GMT
177
+ recorded_with: VCR 2.9.3