Skip to content

Commit ba19486

Browse files
committed
docs: update README with ESM instructions
1 parent abafd99 commit ba19486

File tree

1 file changed

+55
-10
lines changed

1 file changed

+55
-10
lines changed

README.md

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ This is a library that helps you backup your Content Model, Content and Assets o
1414
To import your exported data, please refer to the [contentful-import](https://github.com/contentful/contentful-import) repository.
1515

1616
## :exclamation: Usage as CLI
17+
1718
> We moved the CLI version of this tool into our [Contentful CLI](https://github.com/contentful/contentful-cli). This allows our users to use and install only one single CLI tool to get the full Contentful experience.
1819
>
1920
> Please have a look at the [Contentful CLI export command documentation](https://github.com/contentful/contentful-cli/tree/master/docs/space/export) to learn more about how to use this as command line tool.
2021
21-
2222
## :cloud: Pre-requisites && Installation
2323

2424
### Pre-requisites
@@ -33,6 +33,8 @@ npm install contentful-export
3333

3434
## :hand: Usage
3535

36+
### CommonJS
37+
3638
```javascript
3739
const contentfulExport = require('contentful-export')
3840

@@ -51,6 +53,21 @@ contentfulExport(options)
5153
})
5254
```
5355

56+
### ESM
57+
58+
```javascript
59+
import { default as contentfulExport } from 'contentful-export'
60+
61+
const options = {
62+
spaceId: '<space_id>',
63+
managementToken: '<content_management_api_key>',
64+
...
65+
}
66+
67+
// contentfulExport returns a Promise so you can use async/await, etc.
68+
await contentfulExport(options)
69+
```
70+
5471
### Querying
5572

5673
To scope your export, you are able to pass query parameters. All search parameters of our API are supported as documented in our [API documentation](https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters).
@@ -108,15 +125,19 @@ contentfulExport(options)
108125
### Basics
109126

110127
#### `spaceId` [string] [required]
128+
111129
ID of the space with source data
112130

113131
#### `environmentId` [string] [default: 'master']
132+
114133
ID of the environment in the source space
115134

116135
#### `managementToken` [string] [required]
136+
117137
Contentful management API token for the space to be exported
118138

119139
#### `deliveryToken` [string]
140+
120141
Contentful Content Delivery API (CDA) token for the space to be exported.
121142

122143
Providing `deliveryToken` will export both entries and assets from the
@@ -145,17 +166,21 @@ Note: Tags are only available on the Contentful Management API, so they will not
145166
### Output
146167

147168
#### `exportDir` [string] [default: current process working directory]
169+
148170
Defines the path for storing the export JSON file
149171

150172
#### `saveFile` [boolean] [default: true]
173+
151174
Save the export as a JSON file
152175

153176
#### `contentFile` [string]
177+
154178
The filename for the exported data
155179

156180
### Filtering
157181

158182
#### `includeDrafts` [boolean] [default: false]
183+
159184
Include drafts in the exported entries.
160185

161186
The `deliveryToken` option is ignored
@@ -164,67 +189,87 @@ If you want to include drafts, there's no point of getting them through the
164189
Content Delivery API.
165190

166191
#### `includeArchived` [boolean] [default: false]
192+
167193
Include archived entries in the exported entries
168194

169195
#### `skipContentModel` [boolean] [default: false]
196+
170197
Skip exporting content models
171198

172199
#### `skipEditorInterfaces` [boolean] [default: false]
200+
173201
Skip exporting editor interfaces
174202

175203
#### `skipContent` [boolean] [default: false]
204+
176205
Skip exporting assets and entries.
177206

178207
#### `skipRoles` [boolean] [default: false]
208+
179209
Skip exporting roles and permissions
180210

181211
#### `skipTags` [boolean] [default: false]
212+
182213
Skip exporting tags
183214

184215
#### `skipWebhooks` [boolean] [default: false]
216+
185217
Skip exporting webhooks
186218

187219
#### `stripTags` [boolean] [default: false]
220+
188221
Untag assets and entries
189222

190223
#### `contentOnly` [boolean] [default: false]
224+
191225
Only export entries and assets
192226

193227
#### `queryEntries` [array]
228+
194229
Only export entries that match these queries
195230

196231
#### `queryAssets` [array]
232+
197233
Only export assets that match these queries
198234

199235
#### `downloadAssets` [boolean]
236+
200237
Download actual asset files
201238

202239
### Connection
203240

204241
#### `host` [string] [default: 'api.contentful.com']
242+
205243
The Management API host
206244

207245
#### `hostDelivery` [string] [default: 'cdn.contentful.com']
246+
208247
The Delivery API host
209248

210249
#### `proxy` [string]
250+
211251
Proxy configuration in HTTP auth format: `host:port` or `user:password@host:port`
212252

213253
#### `rawProxy` [boolean]
254+
214255
Pass proxy config to Axios instead of creating a custom httpsAgent
215256

216257
#### `maxAllowedLimit` [number] [default: 1000]
258+
217259
The number of items per page per request
218260

219261
#### `headers` [object]
220-
Additional headers to attach to the requests.
262+
263+
Additional headers to attach to the requests.
221264

222265
### Other
223266

224267
#### `errorLogFile` [string]
268+
225269
Full path to the error log file
226270

227271
#### `useVerboseRenderer` [boolean] [default: false]
272+
228273
Display progress in new lines instead of displaying a busy spinner and the status in the same line. Useful for CI.
229274

230275
## :rescue_worker_helmet: Troubleshooting
@@ -259,15 +304,15 @@ contentfulExport({
259304
If a space is configured to use the [embargoed assets feature](https://www.contentful.com/help/media/embargoed-assets/), certain options will need to be set to use the export/import tooling. When exporting content, the `downloadAssets` option must be set to `true`. This will download the asset files to your local machine. Then, when importing content ([using `contentful-import`](https://github.com/contentful/contentful-import)), the `uploadAssets` option must be set to `true` and the `assetsDirectory` must be set to the directory that contains all of the exported asset folders.
260305

261306
```javascript
262-
const contentfulExport = require('contentful-export')
307+
const contentfulExport = require("contentful-export");
263308

264309
const options = {
265-
spaceId: '<space_id>',
266-
managementToken: '<content_management_api_key>',
267-
downloadAssets: true
268-
}
310+
spaceId: "<space_id>",
311+
managementToken: "<content_management_api_key>",
312+
downloadAssets: true,
313+
};
269314

270-
contentfulExport(options)
315+
contentfulExport(options);
271316
```
272317

273318
## :card_file_box: Exported data structure
@@ -287,7 +332,7 @@ This is an overview of the exported data:
287332
}
288333
```
289334

290-
*Note:* Tags feature is not available for all users. If you do not have access to this feature, the tags array will always be empty.
335+
_Note:_ Tags feature is not available for all users. If you do not have access to this feature, the tags array will always be empty.
291336

292337
## :warning: Limitations
293338

@@ -300,7 +345,7 @@ This is an overview of the exported data:
300345
Read the [releases](https://github.com/contentful/contentful-export/releases) page for more information.
301346

302347
## :scroll: License
303-
348+
304349
This project is licensed under MIT license
305350

306351
[1]: https://www.contentful.com

0 commit comments

Comments
 (0)