contentful-importer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +38 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +7 -0
  7. data/Gemfile.lock +87 -0
  8. data/LICENSE +22 -0
  9. data/README.md +327 -0
  10. data/Rakefile +7 -0
  11. data/bin/contentful-importer +85 -0
  12. data/contentful_importer.gemspec +38 -0
  13. data/example_settings/contentful_model.json +288 -0
  14. data/example_settings/contentful_structure.json +78 -0
  15. data/example_settings/files_meaning.txt +15 -0
  16. data/example_settings/settings.yml +16 -0
  17. data/lib/cli.rb +13 -0
  18. data/lib/configuration.rb +36 -0
  19. data/lib/converters/content_types_structure_creator.rb +60 -0
  20. data/lib/converters/contentful_model_to_json.rb +109 -0
  21. data/lib/importer/data_organizer.rb +117 -0
  22. data/lib/importer/mime_content_type.rb +564 -0
  23. data/lib/importer/parallel_importer.rb +429 -0
  24. data/lib/json_schema_validator.rb +64 -0
  25. data/lib/migrator.rb +39 -0
  26. data/lib/version.rb +3 -0
  27. data/spec/fixtures/import_files/assets/image/image_1.json +9 -0
  28. data/spec/fixtures/import_files/assets/image/image_2.json +9 -0
  29. data/spec/fixtures/import_files/assets/image/image_3.json +9 -0
  30. data/spec/fixtures/import_files/assets/image/image_4.json +9 -0
  31. data/spec/fixtures/import_files/collections/job_skills.json +13 -0
  32. data/spec/fixtures/import_files/collections/jobs.json +37 -0
  33. data/spec/fixtures/import_files/collections/profile.json +19 -0
  34. data/spec/fixtures/import_files/collections/user.json +36 -0
  35. data/spec/fixtures/import_files/entries/job_skills/job_skills_1.json +7 -0
  36. data/spec/fixtures/import_files/entries/job_skills/job_skills_10.json +7 -0
  37. data/spec/fixtures/import_files/entries/job_skills/job_skills_2.json +7 -0
  38. data/spec/fixtures/import_files/entries/job_skills/job_skills_3.json +7 -0
  39. data/spec/fixtures/import_files/entries/job_skills/job_skills_4.json +7 -0
  40. data/spec/fixtures/import_files/entries/job_skills/job_skills_5.json +7 -0
  41. data/spec/fixtures/import_files/entries/job_skills/job_skills_6.json +7 -0
  42. data/spec/fixtures/import_files/entries/job_skills/job_skills_7.json +7 -0
  43. data/spec/fixtures/import_files/entries/job_skills/job_skills_8.json +7 -0
  44. data/spec/fixtures/import_files/entries/job_skills/job_skills_9.json +7 -0
  45. data/spec/fixtures/import_files/entries/jobs/jobs_1.json +56 -0
  46. data/spec/fixtures/import_files/entries/jobs/jobs_2.json +55 -0
  47. data/spec/fixtures/import_files/entries/jobs/jobs_4.json +49 -0
  48. data/spec/fixtures/import_files/entries/profile/profile_1.json +12 -0
  49. data/spec/fixtures/import_files/entries/profile/profile_2.json +12 -0
  50. data/spec/fixtures/import_files/entries/user/user_1.json +24 -0
  51. data/spec/fixtures/import_files/entries/user/user_2.json +20 -0
  52. data/spec/fixtures/import_files/logs/log_published_assets.csv +4 -0
  53. data/spec/fixtures/import_files/logs/log_published_entries.csv +23 -0
  54. data/spec/fixtures/import_files/logs/success_assets.csv +4 -0
  55. data/spec/fixtures/import_files/logs/success_published_assets.csv +0 -0
  56. data/spec/fixtures/import_files/logs/success_published_entries.csv +22 -0
  57. data/spec/fixtures/import_files/logs/success_thread_0.csv +12 -0
  58. data/spec/fixtures/import_files/logs/success_thread_1.csv +11 -0
  59. data/spec/fixtures/import_files/threads/0/1TVvxCqoRq0qUYAOQuOqys_2.json +20 -0
  60. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_1.json +7 -0
  61. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_10.json +7 -0
  62. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_2.json +7 -0
  63. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_3.json +7 -0
  64. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_4.json +7 -0
  65. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_5.json +7 -0
  66. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_6.json +7 -0
  67. data/spec/fixtures/import_files/threads/0/2soCP557HGKoOOK0SqmMOm_7.json +7 -0
  68. data/spec/fixtures/import_files/threads/0/6H6pGAV1PUsuoAW26Iu48W_1.json +9 -0
  69. data/spec/fixtures/import_files/threads/0/6H6pGAV1PUsuoAW26Iu48W_2.json +9 -0
  70. data/spec/fixtures/import_files/threads/0/6H6pGAV1PUsuoAW26Iu48W_3.json +9 -0
  71. data/spec/fixtures/import_files/threads/0/6H6pGAV1PUsuoAW26Iu48W_4.json +9 -0
  72. data/spec/fixtures/import_files/threads/0/6H6pGAV1PUsuoAW26Iu48W_5.json +9 -0
  73. data/spec/fixtures/import_files/threads/1/1TVvxCqoRq0qUYAOQuOqys_1.json +24 -0
  74. data/spec/fixtures/import_files/threads/1/1TVvxCqoRq0qUYAOQuOqys_2.json +20 -0
  75. data/spec/fixtures/import_files/threads/1/2soCP557HGKoOOK0SqmMOm_6.json +7 -0
  76. data/spec/fixtures/import_files/threads/1/2soCP557HGKoOOK0SqmMOm_7.json +7 -0
  77. data/spec/fixtures/import_files/threads/1/2soCP557HGKoOOK0SqmMOm_8.json +7 -0
  78. data/spec/fixtures/import_files/threads/1/2soCP557HGKoOOK0SqmMOm_9.json +7 -0
  79. data/spec/fixtures/import_files/threads/1/4L1bg4WQ5aWQMiE82ouag_1.json +56 -0
  80. data/spec/fixtures/import_files/threads/1/4L1bg4WQ5aWQMiE82ouag_2.json +55 -0
  81. data/spec/fixtures/import_files/threads/1/4L1bg4WQ5aWQMiE82ouag_4.json +49 -0
  82. data/spec/fixtures/import_files/threads/1/4WFZh4MwC4Mc0EQWAeOY8A_1.json +12 -0
  83. data/spec/fixtures/import_files/threads/1/4WFZh4MwC4Mc0EQWAeOY8A_2.json +12 -0
  84. data/spec/fixtures/import_files/threads/assets/0/image_1.json +9 -0
  85. data/spec/fixtures/import_files/threads/assets/0/image_2.json +9 -0
  86. data/spec/fixtures/import_files/threads/assets/0/image_3.json +9 -0
  87. data/spec/fixtures/import_files/threads/assets/0/image_4.json +9 -0
  88. data/spec/fixtures/settings/contentful_model.json +252 -0
  89. data/spec/fixtures/settings/contentful_structure.json +73 -0
  90. data/spec/fixtures/settings/contentful_structure_test.json +66 -0
  91. data/spec/fixtures/settings/settings.yml +12 -0
  92. data/spec/fixtures/vcr_cassettes/create_asset.yml +621 -0
  93. data/spec/fixtures/vcr_cassettes/create_entry.yml +122 -0
  94. data/spec/fixtures/vcr_cassettes/create_space.yml +87 -0
  95. data/spec/fixtures/vcr_cassettes/import_assets.yml +2822 -0
  96. data/spec/fixtures/vcr_cassettes/import_content_types.yml +1915 -0
  97. data/spec/fixtures/vcr_cassettes/import_entries.yml +5066 -0
  98. data/spec/fixtures/vcr_cassettes/import_entry.yml +363 -0
  99. data/spec/fixtures/vcr_cassettes/invalid_credentials.yml +69 -0
  100. data/spec/fixtures/vcr_cassettes/publish_an_entry.yml +214 -0
  101. data/spec/fixtures/vcr_cassettes/publish_asset.yml +895 -0
  102. data/spec/fixtures/vcr_cassettes/publish_entries.yml +5121 -0
  103. data/spec/fixtures/vcr_cassettes/valid_credentials.yml +7360 -0
  104. data/spec/lib/configuration_spec.rb +22 -0
  105. data/spec/lib/importer/parallel_importer_spec.rb +161 -0
  106. data/spec/lib/json_schema_validator_spec.rb +63 -0
  107. data/spec/lib/migrator_spec.rb +99 -0
  108. data/spec/spec_helper.rb +12 -0
  109. data/spec/support/db_rows_json.rb +9 -0
  110. data/spec/support/shared_configuration.rb +22 -0
  111. data/spec/support/vcr.rb +16 -0
  112. metadata +436 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b4cb5b28ec76176d942746f1e3d0c1062acbb39
4
+ data.tar.gz: e214eff208d733e53483a1397d5f12cbadbdb5a9
5
+ SHA512:
6
+ metadata.gz: c045429597f9113ee8dc58678b8d8fdea072fe9f17447d2d49ef28c1ead138c2f393294d542874dd80e418f764b40a0c419ebeae2729c11f09daea19aecfef79
7
+ data.tar.gz: 8f889a25905fa8e8903aad4961793e1f16ae17de1f82f028ed70bd8042d0b0f6d811e5fc3f694ad6da95b2d4a232e1d15e8bed7d2d96bfdc7c1a55232f5b6bd7
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /lib/bundler/man/
25
+
26
+ # for a library or gem, you might want to ignore these files since the code is
27
+ # intended to run in multiple environments; otherwise, check them in:
28
+ # Gemfile.lock
29
+ # .ruby-version
30
+ # .ruby-gemset
31
+
32
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
33
+ .rvmrc
34
+
35
+ #RubyMine
36
+ .idea
37
+
38
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --order random
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 2.1.1
5
+ - 2.1
6
+ - 2.0.0
7
+ - 1.9.3
8
+ # - jruby-19mode
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ # Change Log
2
+ ## 0.0.1
3
+ ### Other
4
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+ # Specify your gem's dependencies in contentful_importer.gemspec
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'simplecov', require: false
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ contentful-importer (0.0.1)
5
+ activesupport (~> 4.1)
6
+ api_cache (~> 0.3.0)
7
+ contentful-management (~> 0.5.0)
8
+ escort (~> 0.4.0)
9
+ http (~> 0.6)
10
+ i18n (~> 0.6)
11
+ json-schema (~> 2.5.0)
12
+ multi_json (~> 1)
13
+
14
+ GEM
15
+ remote: https://rubygems.org/
16
+ specs:
17
+ activesupport (4.2.0)
18
+ i18n (~> 0.7)
19
+ json (~> 1.7, >= 1.7.7)
20
+ minitest (~> 5.1)
21
+ thread_safe (~> 0.3, >= 0.3.4)
22
+ tzinfo (~> 1.1)
23
+ addressable (2.3.6)
24
+ api_cache (0.3.0)
25
+ contentful-management (0.5.0)
26
+ http (~> 0.6)
27
+ multi_json (~> 1)
28
+ crack (0.4.2)
29
+ safe_yaml (~> 1.0.0)
30
+ diff-lcs (1.2.5)
31
+ docile (1.1.5)
32
+ escort (0.4.0)
33
+ nesty
34
+ form_data (0.1.0)
35
+ http (0.7.1)
36
+ form_data (~> 0.1.0)
37
+ http_parser.rb (~> 0.6.0)
38
+ http_parser.rb (0.6.0)
39
+ i18n (0.7.0)
40
+ json (1.8.2)
41
+ json-schema (2.5.0)
42
+ addressable (~> 2.3)
43
+ minitest (5.5.1)
44
+ multi_json (1.10.1)
45
+ nesty (1.0.2)
46
+ rake (10.4.2)
47
+ rspec (3.1.0)
48
+ rspec-core (~> 3.1.0)
49
+ rspec-expectations (~> 3.1.0)
50
+ rspec-mocks (~> 3.1.0)
51
+ rspec-core (3.1.7)
52
+ rspec-support (~> 3.1.0)
53
+ rspec-expectations (3.1.2)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.1.0)
56
+ rspec-its (1.1.0)
57
+ rspec-core (>= 3.0.0)
58
+ rspec-expectations (>= 3.0.0)
59
+ rspec-mocks (3.1.3)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-support (3.1.2)
62
+ safe_yaml (1.0.4)
63
+ simplecov (0.9.1)
64
+ docile (~> 1.1.0)
65
+ multi_json (~> 1.0)
66
+ simplecov-html (~> 0.8.0)
67
+ simplecov-html (0.8.0)
68
+ thread_safe (0.3.4)
69
+ tzinfo (1.2.2)
70
+ thread_safe (~> 0.1)
71
+ vcr (2.9.3)
72
+ webmock (1.20.4)
73
+ addressable (>= 2.3.6)
74
+ crack (>= 0.3.2)
75
+
76
+ PLATFORMS
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ bundler (~> 1.6)
81
+ contentful-importer!
82
+ rake
83
+ rspec (~> 3)
84
+ rspec-its (~> 1.1.0)
85
+ simplecov
86
+ vcr (~> 2.9.3)
87
+ webmock (>= 1.20)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Contentful
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,327 @@
1
+ Contentful Generic-importer
2
+ =================
3
+
4
+ ## Description
5
+
6
+ This allows you to import structured JSON data to [Contentful](https://www.contentful.com).
7
+
8
+ You can use one of the following tools to extract your content and make it ready for import:
9
+
10
+ #### Available exporters
11
+
12
+ - [Database](https://github.com/contentful/database-adapter)
13
+ - [Wordpress](https://github.com/contentful/wordpress-adapter)
14
+ - [Drupal](https://github.com/contentful/drupal-adapter)
15
+
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ gem install contentful-importer
21
+ ```
22
+
23
+ This will install the ```contentful-importer``` executable.
24
+
25
+
26
+ ## Usage
27
+
28
+ Before you can import your content to Contentful, you need to extract and prepare it. We currently support the mentioned exporters, but you can also create your own tools.
29
+
30
+ As a first step you should create a `settings.yml` file and fill in your credentials:
31
+
32
+ ```yaml
33
+ #Contentful
34
+ access_token: access_token
35
+ organization_od: organization_id
36
+ ```
37
+
38
+ **A Contentful OAuth access token can be created using the [Contentful Management API - documentation](https://www.contentful.com/developers/documentation/content-management-api/#getting-started)**
39
+
40
+ The Contentful organization id can be found in your account settings.
41
+
42
+ Once you installed the Gem and created the YAML file with the settings you can invoke the tool using:
43
+
44
+ ```bash
45
+ contentful-importer --config-file settings.yml --action
46
+ ```
47
+
48
+ ## Step by step
49
+
50
+ 1. Create YAML file with required parameters (eg. ```settings.yml```):
51
+
52
+ ```yaml
53
+ #PATH to all data
54
+ data_dir: DEFINE_BEFORE_EXPORTING_DATA
55
+
56
+ #Contentful credentials
57
+ access_token: ACCESS_TOKEN
58
+ organization_id: ORGANIZATION_ID
59
+ space_id: DEFINE_AFTER_CREATING_SPACE
60
+ default_locale: DEFINE_LOCALE_CODE
61
+
62
+ ## CONTENTFUL STRUCTURE
63
+ contentful_structure_dir: PATH_TO_CONTENTFUL_STRUCTURE_JSON_FILE
64
+
65
+ ## CONVERT CONTENTFUL MODEL TO CONTENTFUL IMPORT STRUCTURE
66
+ content_model_json:
67
+ converted_model_dir:
68
+ ```
69
+
70
+ 2. Create the contentful_structure.json. First you need to create a content model using the [Contentful web application](www.contentful.com). Then you can download the content model using the content management api and use the content model for the import:
71
+
72
+ ```bash
73
+ curl -X GET \
74
+ -H 'Authorization: Bearer ACCESS_TOKEN' \
75
+ 'https://api.contentful.com/spaces/SPACE_ID/content_types' > contentful_model.json
76
+ ```
77
+
78
+ It will create ```contentful_model.json``` file, which you need to transform into the ```contentful_structure.json``` using:
79
+
80
+ ```bash
81
+ contentful-importer --config-file settings.yml --convert-content-model-to-json
82
+ ```
83
+
84
+ The converted content model will be saved as JSON file in the ```converted_model_dir``` path.
85
+
86
+
87
+ 3. Once you have prepared the `content types`, `assets` and `entries` (for example using one of the existing extraction adapters or creating your own) they can be imported. It can be chosen to use one (default) or two parallel threads to speedup this process.
88
+ There are two steps to import entries and assets.
89
+
90
+ **Entries**
91
+
92
+ ```bash
93
+ contentful-importer --config-file settings.yml --import
94
+ ```
95
+
96
+ or
97
+
98
+ ```bash
99
+ contentful-importer --config-file settings.yml --import --threads 2
100
+ ```
101
+
102
+ **Assets**
103
+
104
+ ```bash
105
+ contentful-importer --config-file settings.yml --import-assets
106
+ ```
107
+
108
+ After each request the `success_number_of_thread.csv` or `success_assets.csv` file is updated. You can find those in `data_dir/logs`.
109
+ If an entry or asset fails to be imported, it will end up in the `failure_number_of_thread.csv` or `assets_failure.csv` including the error message.
110
+
111
+
112
+ 4. Publish entries and assets. After successfully importing the entries and assets to contentful, they need to be published in order to be available through the delivery API.
113
+
114
+ To publish all entries use:
115
+
116
+ ```bash
117
+ contentful-importer --config-file settings.yml --publish-entries
118
+ ```
119
+
120
+ To publish all assets use:
121
+
122
+ ```bash
123
+ contentful-importer --config-file settings.yml --publish-assets
124
+ ```
125
+
126
+ or
127
+
128
+ ```bash
129
+ contentful-importer --config-file settings.yml --publish-assets --threads 2
130
+ ```
131
+
132
+ After each request the ```success_published_entries.csv``` or ```success_published_assets.csv``` file is updated. You can find those in ```data_dir/logs```.
133
+ If an entry or asset fails to be imported, it will end up in the ```failure_published_entries.csv``` or ```failure_published_assets.csv``` including the error message.
134
+
135
+
136
+ ## Actions
137
+
138
+ To display all actions use the `-h` option:
139
+
140
+ ```bash
141
+ contentful-importer -h
142
+ ```
143
+ #### --convert-content-model-to-json
144
+
145
+ If you already have an existing content model for a space it can be downloaded and used for the import:
146
+
147
+ ```bash
148
+ curl -X GET \
149
+ -H 'Authorization: Bearer ACCESS_TOKEN' \
150
+ 'https://api.contentful.com/spaces/SPACE_ID/content_types' > contentful_model.json
151
+ ```
152
+
153
+
154
+ In the **settings.yml** specify the PATH to **contentful_model.json**.
155
+
156
+ ```yaml
157
+ #Dump file with content model.
158
+ content_model_json: example_path/contentful_model.json
159
+ ```
160
+
161
+ and define the PATH where you want to save the converted JSON file:
162
+
163
+ ```yaml
164
+ #File with converted structure of contentful model. Almost ready to import.
165
+ converted_model_dir: example_path/contentful_structure.json
166
+ ```
167
+
168
+ #### --create-contentful-model-from-json
169
+
170
+ Create the content model based on the structure defined in ```contentful_structure.json```.
171
+ This will generate content types files that are ready to be imported.
172
+ Set the `contentful_structure_dir` variable to point to the structure file in your settings file.
173
+
174
+ Path to collections: **data_dir/collections**
175
+
176
+ ```bash
177
+ contentful-importer --config-file settings.yml --create-contentful-model-from-json
178
+ ```
179
+
180
+ This is optional if you intend to create your own content structure as JSON files and not use the web application for it.
181
+
182
+ #### --import-content-types ARGS
183
+
184
+ To import the content types into an existing space use `--space_id SPACE_ID`:
185
+
186
+ ```bash
187
+ contentful-importer --config-file settings.yml --import-content-types --space_id SPACE_ID
188
+ ```
189
+
190
+ To create a new Space and import content types use `--space_name NAME`:
191
+
192
+ ```bash
193
+ contentful-importer --config-file settings.yml --import-content-types --space_name NAME
194
+ ```
195
+
196
+ #### --import
197
+
198
+ Import the entries with a single thread:
199
+
200
+ ```bash
201
+ contentful-importer --config-file settings.yml --import
202
+ ```
203
+
204
+ or using two threads
205
+
206
+ ```bash
207
+ contentful-importer --config-file settings.yml --import --threads 2
208
+ ```
209
+
210
+ #### --import-assets
211
+
212
+ Import the assets:
213
+
214
+ ```bash
215
+ contentful-importer --config-file settings.yml --import-assets
216
+ ```
217
+
218
+ #### --publish-entries
219
+
220
+ To publish all entries:
221
+
222
+ ```bash
223
+ contentful-importer --config-file settings.yml --publish-entries
224
+ ```
225
+ Number of threads that are used in the publishing of entries is dependent on `--threads` argument, which you specified when import data.
226
+
227
+ #### --publish-assets ARGS
228
+
229
+ You can publish all assets with single Thread:
230
+
231
+ ```bash
232
+ contentful-importer --config-file settings.yml --publish-assets
233
+ ```
234
+ or add ```--threads``` argument to use multiple Threads:
235
+
236
+ ```bash
237
+ contentful-importer --config-file settings.yml --publish-assets --threads 2
238
+ ```
239
+
240
+ #### --test-credentials
241
+
242
+ Before importing any content you can verify that your credentials in the **settings.yml** file are correct:
243
+
244
+ ```bash
245
+ contentful-importer --config-file settings.yml --test-credentials
246
+ ```
247
+
248
+ #### --validate-schema
249
+
250
+ After preparing the files to import, you can validate the JSON schema, use command:
251
+
252
+ ```contentful-importer --config-file settings.yml --validate-schema```
253
+
254
+ This comes in handy when you want to create your own extraction adapter.
255
+
256
+ ## Content Model
257
+
258
+ This represents an example content model:
259
+
260
+ ```javascript
261
+ {
262
+ "Comments": {
263
+ "id": "comment",
264
+ "description": "",
265
+ "displayField": "title",
266
+ "fields": {
267
+ "title": "Text",
268
+ "content": "Text"
269
+ }
270
+ },
271
+ "JobAdd": {
272
+ "id": "job_add",
273
+ "description": "Add new job form",
274
+ "displayField": "name",
275
+ "fields": {
276
+ "name": "Text",
277
+ "specification": "Text",
278
+ "Images": {
279
+ "id": "image",
280
+ "link_type": "Asset"
281
+ },
282
+ "Comments": {
283
+ "id": "comments",
284
+ "link_type": "Array",
285
+ "type": "Entry"
286
+ },
287
+ "Skills": {
288
+ "id": "skills",
289
+ "link_type": "Array",
290
+ "type": "Entry"
291
+ }
292
+ }
293
+ }
294
+ ```
295
+ Key names "Images", "Comments", "Skills" are the equivalent of the content type names specified in the file **mapping.json**.
296
+
297
+ Example:
298
+
299
+ ```javascript
300
+ "SkillsTableName": {
301
+ "content_type": "Skills",
302
+ "type": "entry",
303
+ "fields": { ... }
304
+ ```
305
+
306
+
307
+ # Import
308
+
309
+ Before you start importing the content make sure you read [how to use it](https://github.com/contentful/generic-importer.rb#usage) and [tested your credentials](https://github.com/contentful/generic-importer.rb#--test-credentials).
310
+
311
+ #### Space ID
312
+
313
+ After [importing the content types](https://github.com/contentful/generic-importer.rb#--import-content-types-args) to the Space, you need to specify the `space_id` parameter in the settings.
314
+
315
+
316
+ Example:
317
+ ```yml
318
+ space_id: space_id
319
+ ```
320
+
321
+ #### Default locale
322
+
323
+ To specify in which locale you want to create all Entries and Assets, set ```default_locale``` parameter in settings.yml file:
324
+
325
+ ```yml
326
+ default_locale: de-DE
327
+ ```