contentful_bootstrap 3.10.0 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +9 -5
- data/.rubocop_todo.yml +34 -76
- data/CHANGELOG.md +7 -0
- data/Guardfile +20 -4
- data/README.md +6 -6
- data/bin/contentful_bootstrap +46 -42
- data/contentful_bootstrap.gemspec +6 -3
- data/lib/contentful/bootstrap/command_runner.rb +3 -1
- data/lib/contentful/bootstrap/commands/base.rb +15 -15
- data/lib/contentful/bootstrap/commands/create_space.rb +5 -6
- data/lib/contentful/bootstrap/commands/generate_json.rb +13 -2
- data/lib/contentful/bootstrap/commands/generate_token.rb +6 -6
- data/lib/contentful/bootstrap/commands/update_space.rb +2 -2
- data/lib/contentful/bootstrap/generator.rb +5 -4
- data/lib/contentful/bootstrap/support.rb +1 -1
- data/lib/contentful/bootstrap/templates/base.rb +22 -25
- data/lib/contentful/bootstrap/templates/json_template.rb +49 -56
- data/lib/contentful/bootstrap/templates/links/base.rb +1 -1
- data/lib/contentful/bootstrap/token.rb +1 -1
- data/lib/contentful/bootstrap/version.rb +1 -1
- data/spec/contentful/bootstrap/command_runner_spec.rb +2 -2
- data/spec/contentful/bootstrap/commands/base_spec.rb +3 -15
- data/spec/contentful/bootstrap/commands/create_space_spec.rb +2 -2
- data/spec/contentful/bootstrap/commands/generate_json_spec.rb +1 -1
- data/spec/contentful/bootstrap/commands/generate_token_spec.rb +1 -1
- data/spec/contentful/bootstrap/commands/update_space_spec.rb +36 -8
- data/spec/contentful/bootstrap/generator_spec.rb +17 -2
- data/spec/contentful/bootstrap/templates/base_spec.rb +10 -8
- data/spec/contentful/bootstrap/templates/blog_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/catalogue_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/gallery_spec.rb +9 -1
- data/spec/contentful/bootstrap/templates/json_template_spec.rb +17 -9
- data/spec/fixtures/json_fixtures/environment_template.json +47 -0
- data/spec/fixtures/vcr_fixtures/asset_no_transform.yml +119 -4
- data/spec/fixtures/vcr_fixtures/check_created_space.yml +1 -1
- data/spec/fixtures/vcr_fixtures/check_original_staging_environment_status.yml +201 -0
- data/spec/fixtures/vcr_fixtures/check_staging_environment_status.yml +81 -0
- data/spec/fixtures/vcr_fixtures/check_update_space_localized.yml +2 -2
- data/spec/fixtures/vcr_fixtures/check_update_space_with_draft_content.yml +4 -4
- data/spec/fixtures/vcr_fixtures/create_space_with_blog_template.yml +153 -38
- data/spec/fixtures/vcr_fixtures/create_space_with_catalogue_template.yml +196 -81
- data/spec/fixtures/vcr_fixtures/create_space_with_gallery_template.yml +165 -50
- data/spec/fixtures/vcr_fixtures/generate_json.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_content_types_only.yml +1 -1
- data/spec/fixtures/vcr_fixtures/generate_json_environments.yml +447 -0
- data/spec/fixtures/vcr_fixtures/generate_json_multi_ct.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_preview.yml +5 -5
- data/spec/fixtures/vcr_fixtures/generate_json_single_ct.yml +5 -5
- data/spec/fixtures/vcr_fixtures/issue_22.yml +142 -27
- data/spec/fixtures/vcr_fixtures/no_ids.yml +126 -11
- data/spec/fixtures/vcr_fixtures/update_existing_asset.yml +130 -15
- data/spec/fixtures/vcr_fixtures/update_space_localized.yml +134 -19
- data/spec/fixtures/vcr_fixtures/update_with_environment.yml +2531 -0
- metadata +55 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a0377b3978c29173e7cb2740be951072f39fa912080de68bfbb9c0471902088
|
4
|
+
data.tar.gz: 9b8be65f9b642b96a73a4470ad5d6f13fd338d09a75ee961a7e74b5e9a004308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 355d7bc2e47d9f35f9fb28e49dc0988127bd0e9b908d7138966facd123f97cd1a8828df24f094b314473ca8ad7935b2d3166e2409afa2737b798d7dd33486361
|
7
|
+
data.tar.gz: 84039265f10136ea387e9ece1079f581356585d04f3c9facff7b214167c01214771b4a1d0c7c618fbf03b822649f4a041bc9a1223d708cfe1a6a8953d0767c60
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
3
4
|
Exclude:
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
5
|
+
- contentful_bootstrap.gemspec
|
6
|
+
- spec/**/*
|
7
|
+
- examples/**/*
|
8
|
+
- Guardfile
|
9
|
+
- Gemfile
|
10
|
+
- Rakefile
|
7
11
|
|
8
12
|
Style/Documentation:
|
9
13
|
Exclude:
|
data/.rubocop_todo.yml
CHANGED
@@ -1,58 +1,52 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-04-17 14:00:32 +0200 using RuboCop version 0.55.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
|
9
|
+
Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
10
12
|
Metrics/AbcSize:
|
11
|
-
Max:
|
13
|
+
Max: 62
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Max: 39
|
17
|
+
CountComments: false
|
12
18
|
|
13
|
-
# Offense count: 4
|
14
|
-
# Configuration parameters: CountComments.
|
15
19
|
Metrics/ClassLength:
|
16
20
|
Max: 176
|
21
|
+
CountComments: false
|
17
22
|
|
18
|
-
# Offense count: 1
|
19
23
|
Metrics/CyclomaticComplexity:
|
20
24
|
Max: 7
|
21
25
|
|
22
|
-
# Offense count: 16
|
23
|
-
# Configuration parameters: AllowURI, URISchemes.
|
24
26
|
Metrics/LineLength:
|
25
|
-
Max:
|
27
|
+
Max: 167
|
28
|
+
Exclude:
|
29
|
+
- 'lib/contentful/bootstrap/templates/blog.rb'
|
30
|
+
- 'lib/contentful/bootstrap/templates/catalogue.rb'
|
31
|
+
- 'lib/contentful/bootstrap/templates/gallery.rb'
|
32
|
+
- 'bin/contentful_bootstrap'
|
26
33
|
|
27
|
-
# Offense count: 19
|
28
|
-
# Configuration parameters: CountComments.
|
29
34
|
Metrics/MethodLength:
|
30
35
|
Max: 88
|
36
|
+
CountComments: false
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
Max: 9
|
38
|
+
Metrics/ParameterLists:
|
39
|
+
Max: 8
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
39
|
-
Style/BlockDelimiters:
|
40
|
-
Exclude:
|
41
|
-
- 'spec/contentful/bootstrap/generator_spec.rb'
|
42
|
-
|
43
|
-
# Offense count: 2
|
44
|
-
Style/ClassVars:
|
45
|
-
Exclude:
|
46
|
-
- 'lib/contentful/bootstrap/token.rb'
|
41
|
+
Metrics/PerceivedComplexity:
|
42
|
+
Max: 8
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
Style/DeprecatedHashMethods:
|
44
|
+
Naming/MethodName:
|
45
|
+
EnforcedStyle: snake_case
|
51
46
|
Exclude:
|
52
|
-
- '
|
47
|
+
- 'lib/contentful/bootstrap/server.rb'
|
53
48
|
|
54
|
-
# Offense count:
|
55
|
-
# Configuration parameters: Exclude.
|
49
|
+
# Offense count: 6
|
56
50
|
Style/Documentation:
|
57
51
|
Exclude:
|
58
52
|
- 'spec/**/*'
|
@@ -72,52 +66,16 @@ Style/Documentation:
|
|
72
66
|
- 'lib/contentful/bootstrap/templates/links/entry.rb'
|
73
67
|
- 'lib/contentful/bootstrap/token.rb'
|
74
68
|
- 'lib/contentful/bootstrap/version.rb'
|
69
|
+
- 'lib/contentful/bootstrap/command_runner.rb'
|
70
|
+
- 'lib/contentful/bootstrap/commands/base.rb'
|
71
|
+
- 'lib/contentful/bootstrap/commands/create_space.rb'
|
72
|
+
- 'lib/contentful/bootstrap/commands/generate_json.rb'
|
73
|
+
- 'lib/contentful/bootstrap/commands/generate_token.rb'
|
74
|
+
- 'lib/contentful/bootstrap/commands/update_space.rb'
|
75
75
|
|
76
|
-
# Offense count: 1
|
77
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
78
76
|
Style/FormatString:
|
79
77
|
Exclude:
|
80
|
-
- 'lib/contentful/bootstrap/commands.rb'
|
78
|
+
- 'lib/contentful/bootstrap/commands/create_space.rb'
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
# Configuration parameters: MaxLineLength.
|
85
|
-
Style/IfUnlessModifier:
|
86
|
-
Exclude:
|
87
|
-
- 'bin/contentful_bootstrap'
|
88
|
-
|
89
|
-
# Offense count: 3
|
90
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
91
|
-
Style/MethodName:
|
92
|
-
Enabled: false
|
93
|
-
|
94
|
-
# Offense count: 2
|
95
|
-
Style/MultilineBlockChain:
|
96
|
-
Exclude:
|
97
|
-
- 'lib/contentful/bootstrap/generator.rb'
|
98
|
-
|
99
|
-
# Offense count: 1
|
100
|
-
# Cop supports --auto-correct.
|
101
|
-
# Configuration parameters: PreferredDelimiters.
|
102
|
-
Style/PercentLiteralDelimiters:
|
103
|
-
Exclude:
|
104
|
-
- 'contentful_bootstrap.gemspec'
|
105
|
-
|
106
|
-
# Offense count: 68
|
107
|
-
# Cop supports --auto-correct.
|
108
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
109
|
-
Style/StringLiterals:
|
110
|
-
Enabled: false
|
111
|
-
|
112
|
-
# Offense count: 1
|
113
|
-
# Cop supports --auto-correct.
|
114
|
-
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
115
|
-
Style/TrailingComma:
|
116
|
-
Exclude:
|
117
|
-
- 'bin/contentful_bootstrap'
|
118
|
-
|
119
|
-
# Offense count: 1
|
120
|
-
# Cop supports --auto-correct.
|
121
|
-
Style/UnneededPercentQ:
|
122
|
-
Exclude:
|
123
|
-
- 'contentful_bootstrap.gemspec'
|
80
|
+
Style/FormatStringToken:
|
81
|
+
EnforcedStyle: unannotated
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## v3.11.0
|
6
|
+
### Added
|
7
|
+
* Added `--environment` support to `update_space` and `generate_json`.
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
* Updated to the new CMA and CDA SDK versions.
|
11
|
+
|
5
12
|
## v3.10.0
|
6
13
|
### Added
|
7
14
|
* Added `--content-type-ids` filter to `generate_json` command to allow selecting which content types to import.
|
data/Guardfile
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
group :green_red_refactor, halt_on_fail: true do
|
2
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
3
|
+
require "guard/rspec/dsl"
|
4
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
5
|
+
|
6
|
+
# Feel free to open issues for suggestions and improvements
|
7
|
+
|
8
|
+
# RSpec files
|
9
|
+
rspec = dsl.rspec
|
10
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
12
|
+
watch(rspec.spec_files)
|
13
|
+
|
14
|
+
# Ruby files
|
15
|
+
ruby = dsl.ruby
|
16
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
17
|
+
end
|
18
|
+
|
19
|
+
guard :rubocop, cmd: "rubocop" do
|
20
|
+
end
|
5
21
|
end
|
data/README.md
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
A small CLI tool for getting started with Contentful
|
6
6
|
|
7
7
|
## Contentful
|
8
|
-
[Contentful](
|
9
|
-
mobile apps and connected devices. It allows you to create, edit & manage content in the cloud
|
10
|
-
and publish it anywhere via a powerful API. Contentful offers tools for managing editorial
|
11
|
-
teams and enabling cooperation between organizations.
|
8
|
+
[[Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.
|
12
9
|
|
13
10
|
## What does `contentful_bootstrap` do?
|
14
11
|
`contentful_bootstrap` let's you set up a new Contentful environment with a single command.
|
@@ -38,13 +35,13 @@ $ contentful_bootstrap generate_token <space_id> [--name token_name] [--config C
|
|
38
35
|
You can also generate JSON Templates from existing spaces by doing:
|
39
36
|
|
40
37
|
```bash
|
41
|
-
$ contentful_bootstrap generate_json <space_id> <delivery_api_access_token> [--output-file OUTPUT PATH] [--content-type-ids ct_id_1,ct_id_2] [--content-types-only] [--use-preview] [--quiet]
|
38
|
+
$ contentful_bootstrap generate_json <space_id> <delivery_api_access_token> [--environment ENVIRONMENT_ID] [--output-file OUTPUT PATH] [--content-type-ids ct_id_1,ct_id_2] [--content-types-only] [--use-preview] [--quiet]
|
42
39
|
```
|
43
40
|
|
44
41
|
You can update existing spaces from JSON Templates by doing:
|
45
42
|
|
46
43
|
```bash
|
47
|
-
$ contentful_bootstrap update_space <space_id> -j template_path [--mark-processed] [--skip-content-types] [--no-publish] [--quiet]
|
44
|
+
$ contentful_bootstrap update_space <space_id> -j template_path [--environment ENVIRONMENT_ID] [--mark-processed] [--skip-content-types] [--no-publish] [--quiet]
|
48
45
|
```
|
49
46
|
|
50
47
|
### Built-in templates
|
@@ -102,6 +99,7 @@ To Update an existing Space
|
|
102
99
|
```ruby
|
103
100
|
options = {
|
104
101
|
json_template: "/path/to/template.json", # Will use the JSON file specified as a Template
|
102
|
+
environment: "master", # Will update the specified environment, will NOT create the environment if it doesn't exist, defaults to "master"
|
105
103
|
locale: "es-AR", # Will create the space with the specified locale code as default locale, defaults to "en-US"
|
106
104
|
mark_processed: false, # if true will mark all resources as 'bootstrapProcessed and will be avoided on future update_space calls
|
107
105
|
trigger_oauth: true, # if true will trigger OAuth process
|
@@ -137,6 +135,7 @@ To Generate a JSON Template from an exising Space
|
|
137
135
|
Contentful::Bootstrap::CommandRunner.new.generate_json(
|
138
136
|
"space_id",
|
139
137
|
access_token: "delivery_or_preview_api_access_token",
|
138
|
+
environment: "master", # Will fetch content from the specified environment, defaults to "master"
|
140
139
|
use_preview: false, # if true will fetch from the Preview API instead of Delivery API
|
141
140
|
filename: nil, # path to file in which to store JSON
|
142
141
|
content_types_only: false, # if true will not fetch Entries and Assets
|
@@ -152,6 +151,7 @@ Additionally, you can send an options hash with the following keys:
|
|
152
151
|
```ruby
|
153
152
|
options = {
|
154
153
|
access_token: "access_token" # REQUIRED
|
154
|
+
environment: "master", # Will fetch content from the specified environment, defaults to "master"
|
155
155
|
use_preview: false, # if true will fetch from the Preview API instead of Delivery API
|
156
156
|
filename: "template.json", # Will save the JSON to the specified file
|
157
157
|
content_types_only: false, # if true will not fetch Entries and Assets
|
data/bin/contentful_bootstrap
CHANGED
@@ -7,105 +7,111 @@ options = {}
|
|
7
7
|
|
8
8
|
subcommands = {
|
9
9
|
'create_space' => OptionParser.new do |opts|
|
10
|
-
opts.banner =
|
11
|
-
opts.on(
|
10
|
+
opts.banner = 'Usage: create_space <space_name> [--template TEMPLATE_NAME] [--json-template JSON_PATH] [--locale LOCALE] [--mark-processed] [--config CONFIG_PATH]'
|
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
|
-
opts.on(
|
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(
|
17
|
+
opts.on('-l LOCALE', '--locale LOCALE', 'Set the Default Locale for the Space', "Defaults to 'en-US'") do |l|
|
18
18
|
options[:locale] = l
|
19
19
|
end
|
20
|
-
opts.on('-m', '--mark-processed',
|
20
|
+
opts.on('-m', '--mark-processed', 'Mark Processed Items on JSON Templates') do |m|
|
21
21
|
options[:mark_processed] = m
|
22
22
|
end
|
23
|
-
opts.on(
|
23
|
+
opts.on('-c CONFIG_PATH', '--config CONFIG_PATH', 'Specify Configuration Path') do |c|
|
24
24
|
options[:config_path] = c
|
25
25
|
end
|
26
|
-
opts.on(
|
26
|
+
opts.on('-q', '--quiet', "Don't output to STDOUT") do |q|
|
27
27
|
options[:quiet] = q
|
28
28
|
end
|
29
|
-
opts.on(
|
29
|
+
opts.on('-n', '--no-publish', "Don't publish") do |n|
|
30
30
|
options[:no_publish] = n
|
31
31
|
end
|
32
|
-
opts.on_tail(
|
32
|
+
opts.on_tail('-h', '--help', 'Print this message') do
|
33
33
|
puts opts
|
34
34
|
end
|
35
35
|
end,
|
36
36
|
'update_space' => OptionParser.new do |opts|
|
37
|
-
opts.banner =
|
38
|
-
opts.on(
|
37
|
+
opts.banner = 'Usage: update_space <space_id> --json-template JSON_PATH [--environment ENVIRONMENT_ID] [--locale LOCALE] [--mark-processed] [--config CONFIG_PATH]'
|
38
|
+
opts.on('-j JSON_PATH', '--json-template JSON_PATH', 'Specify JSON Template Path') do |j|
|
39
39
|
options[:json_template] = j
|
40
40
|
end
|
41
|
-
opts.on(
|
41
|
+
opts.on('-e ENVIRONMENT_ID', '--environment ENVIRONMENT_ID', 'Specify target environment ID', "Defaults to 'master'") do |e|
|
42
|
+
options[:environment] = e
|
43
|
+
end
|
44
|
+
opts.on('-l LOCALE', '--locale LOCALE', 'Set the Default Locale for the Space', "Defaults to 'en-US'") do |l|
|
42
45
|
options[:locale] = l
|
43
46
|
end
|
44
|
-
opts.on('-m', '--mark-processed',
|
47
|
+
opts.on('-m', '--mark-processed', 'Mark Processed Items on JSON Templates') do |m|
|
45
48
|
options[:mark_processed] = m
|
46
49
|
end
|
47
|
-
opts.on('-T', '--skip-content-types',
|
50
|
+
opts.on('-T', '--skip-content-types', 'Skip Content Types on Space update') do |t|
|
48
51
|
options[:skip_content_types] = t
|
49
52
|
end
|
50
|
-
opts.on(
|
53
|
+
opts.on('-c CONFIG_PATH', '--config CONFIG_PATH', 'Specify Configuration Path') do |c|
|
51
54
|
options[:config_path] = c
|
52
55
|
end
|
53
|
-
opts.on(
|
56
|
+
opts.on('-n', '--no-publish', "Don't publish") do |n|
|
54
57
|
options[:no_publish] = n
|
55
58
|
end
|
56
|
-
opts.on(
|
59
|
+
opts.on('-q', '--quiet', "Don't output to STDOUT") do |q|
|
57
60
|
options[:quiet] = q
|
58
61
|
end
|
59
|
-
opts.on_tail(
|
62
|
+
opts.on_tail('-h', '--help', 'Print this message') do
|
60
63
|
puts opts
|
61
64
|
end
|
62
65
|
end,
|
63
66
|
'generate_token' => OptionParser.new do |opts|
|
64
|
-
opts.banner =
|
65
|
-
opts.on(
|
67
|
+
opts.banner = 'Usage: generate_token <space_id> [--name TOKEN_NAME] [--config CONFIG_PATH]'
|
68
|
+
opts.on('-n NAME', '--name TOKEN_NAME', 'Specify Token Name') do |n|
|
66
69
|
options[:name] = n
|
67
70
|
end
|
68
|
-
opts.on(
|
71
|
+
opts.on('-c CONFIG_PATH', '--config CONFIG_PATH', 'Specify Configuration Path') do |c|
|
69
72
|
options[:config_path] = c
|
70
73
|
end
|
71
|
-
opts.on(
|
74
|
+
opts.on('-q', '--quiet', "Don't output to STDOUT") do |q|
|
72
75
|
options[:quiet] = q
|
73
76
|
end
|
74
|
-
opts.on_tail(
|
77
|
+
opts.on_tail('-h', '--help', 'Print this message') do
|
75
78
|
puts opts
|
76
79
|
end
|
77
80
|
end,
|
78
81
|
'generate_json' => OptionParser.new do |opts|
|
79
|
-
opts.banner =
|
80
|
-
opts.on(
|
82
|
+
opts.banner = 'Usage: generate_json <space_id> <access_token> [--environment ENVIRONMENT_ID] [--output-file OUTPUT_PATH] [--content-types-only] [--use-preview] [--content-type-ids <ID_1>, <ID_2>]'
|
83
|
+
opts.on('-e ENVIRONMENT_ID', '--environment ENVIRONMENT_ID', 'Specify target environment ID', "Defaults to 'master'") do |e|
|
84
|
+
options[:environment] = e
|
85
|
+
end
|
86
|
+
opts.on('-t', '--content-types-only', 'Only fetch Content Types') do |t|
|
81
87
|
options[:content_types_only] = t
|
82
88
|
end
|
83
|
-
opts.on(
|
89
|
+
opts.on('-p', '--use-preview', 'Use Preview API') do |p|
|
84
90
|
options[:use_preview] = p
|
85
91
|
end
|
86
|
-
opts.on(
|
92
|
+
opts.on('-i', '--content-type-ids <ID_1>,<ID_2>', ::Array, 'Array of content type IDs to import') do |ids|
|
87
93
|
options[:content_type_ids] = ids
|
88
94
|
end
|
89
|
-
opts.on(
|
95
|
+
opts.on('-o OUTPUT_PATH', '--output-file OUTPUT_PATH', 'Specify Output File') do |f|
|
90
96
|
options[:filename] = f
|
91
97
|
end
|
92
|
-
opts.on(
|
98
|
+
opts.on('-q', '--quiet', "Don't output to STDOUT") do |q|
|
93
99
|
options[:quiet] = q
|
94
100
|
end
|
95
|
-
opts.on_tail(
|
101
|
+
opts.on_tail('-h', '--help', 'Print this message') do
|
96
102
|
puts opts
|
97
103
|
end
|
98
|
-
end
|
104
|
+
end
|
99
105
|
}
|
100
106
|
|
101
107
|
global = OptionParser.new do |opts|
|
102
|
-
opts.banner =
|
103
|
-
opts.separator
|
108
|
+
opts.banner = 'Usage: contentful_bootstrap <command> <space_name> [options]'
|
109
|
+
opts.separator ''
|
104
110
|
opts.separator <<-HELP
|
105
111
|
Available commands are:
|
106
112
|
\t#{subcommands.keys.sort.join("\n\t")}
|
107
113
|
HELP
|
108
|
-
opts.on_tail(
|
114
|
+
opts.on_tail('-v', '--version', 'Show Version') do
|
109
115
|
puts "Contentful Bootstrap: #{Contentful::Bootstrap::VERSION}"
|
110
116
|
exit(0)
|
111
117
|
end
|
@@ -114,10 +120,10 @@ end
|
|
114
120
|
global.order!
|
115
121
|
command = ARGV.shift
|
116
122
|
|
117
|
-
is_help = ARGV.include?(
|
123
|
+
is_help = ARGV.include?('-h') || ARGV.include?('--help')
|
118
124
|
space = ARGV.shift unless is_help
|
119
125
|
|
120
|
-
options[:access_token] = ARGV.shift if command ==
|
126
|
+
options[:access_token] = ARGV.shift if command == 'generate_json' && !is_help
|
121
127
|
|
122
128
|
if subcommands.key? command
|
123
129
|
subcommands[command].order!
|
@@ -128,23 +134,21 @@ if subcommands.key? command
|
|
128
134
|
exit(1)
|
129
135
|
end
|
130
136
|
|
131
|
-
if is_help
|
132
|
-
exit
|
133
|
-
end
|
137
|
+
exit if is_help
|
134
138
|
|
135
139
|
if space.nil? || space.empty?
|
136
140
|
ARGV << '-h'
|
137
141
|
subcommands[command].order!
|
138
142
|
puts
|
139
|
-
puts
|
143
|
+
puts 'Required Arguments not specified. Exiting!'
|
140
144
|
exit
|
141
145
|
end
|
142
146
|
|
143
147
|
options[:trigger_oauth] = true
|
144
148
|
|
145
|
-
Contentful::Bootstrap::CommandRunner.new(options.fetch(:config_path,
|
149
|
+
Contentful::Bootstrap::CommandRunner.new(options.fetch(:config_path, '')).send(command, space, options)
|
146
150
|
else
|
147
|
-
puts
|
151
|
+
puts 'Usage: contentful_bootstrap <command> <space> [options]'
|
148
152
|
puts
|
149
153
|
puts <<-HELP
|
150
154
|
Subcommand not available or missing
|