Skip to content

Commit 9a49615

Browse files
fix(contentful-export): fix drafts exporting
1 parent b435706 commit 9a49615

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

dist/usageParams.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ var opts = yargs.version(packageFile.version || 'Version only available on insta
1414
demand: true
1515
}).option('preview-token', {
1616
describe: 'Preview API token for the space to be exported.',
17-
type: 'string',
18-
demand: true
17+
type: 'string'
1918
}).option('export-dir', {
2019
describe: 'Defines the path for storing the export json file (default path is the current directory)',
2120
type: 'string'

lib/run-contentful-export.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ export default function runContentfulExport (usageParams) {
1717
opts.sourceSpace = opts.sourceSpace || usageParams.spaceId
1818
opts.sourceManagementToken = opts.sourceManagementToken || usageParams.managementToken
1919
}
20-
if (opts.includeDrafts) {
21-
opts.deliveryHost = 'preview.contentful.com'
22-
opts.sourceDeliveryToken = opts.previewToken
23-
}
2420
const clients = createClients(opts)
2521
return getFullSourceSpace({
2622
managementClient: clients.source.management,
2723
spaceId: clients.source.spaceId,
28-
maxAllowedLimit: opts.maxAllowedLimit
24+
maxAllowedLimit: opts.maxAllowedLimit,
25+
includeDrafts: opts.includeDrafts
2926
})
3027
.then((response) => {
3128
if (opts.downloadAssets) {

lib/usageParams.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ const opts = yargs
1515
type: 'string',
1616
demand: true
1717
})
18-
.option('preview-token', {
19-
describe: 'Preview API token for the space to be exported.',
20-
type: 'string',
21-
demand: true
22-
})
2318
.option('export-dir', {
2419
describe: 'Defines the path for storing the export json file (default path is the current directory)',
2520
type: 'string'
2621
})
22+
.option('include-drafts', {
23+
describe: 'include drafts drafts in the exported entries',
24+
type: 'boolean',
25+
default: false
26+
})
2727
.option('download-assets', {
2828
describe: 'With this flags assets will also be downloaded',
2929
type: 'boolean'
@@ -32,10 +32,6 @@ const opts = yargs
3232
describe: 'How many item per page per request default 1000',
3333
type: 'number'
3434
})
35-
.options('include-drafts', {
36-
describe: 'Export Drafts entiries',
37-
type: 'boolean'
38-
})
3935
.config('config', 'Configuration file with required values')
4036
.check(function (argv) {
4137
if (!argv.spaceId) {
@@ -50,15 +46,6 @@ const opts = yargs
5046
)
5147
process.exit(1)
5248
}
53-
if (argv.includeDrafts && !argv.previewToken) {
54-
log.error('Please provide a preview API token to be able to get draft or set --include-drafts false')
55-
process.exit(1)
56-
}
57-
if (!argv.includeDrafts && argv.previewToken) {
58-
log.error('Please make sure to specify --include-drafts to be able to get drafts')
59-
process.exit(1)
60-
}
61-
6249
return true
6350
})
6451
.argv

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "contentful-export",
3+
"version": "0.0.0-placeholder",
34
"description": "this tool allows you to export a space to a JSON dump",
45
"bin": {
56
"contentful-export": "./bin/contentful-export"
@@ -43,7 +44,7 @@
4344
"bluebird": "^3.3.3",
4445
"fs-extra": "^0.30.0",
4546
"request": "^2.78.0",
46-
"contentful-batch-libs": "4.7.0",
47+
"contentful-batch-libs": "~4.7.2",
4748
"json-stringify-safe": "^5.0.1",
4849
"lodash": "^4.0.0",
4950
"npmlog": "^4.0.0",

0 commit comments

Comments
 (0)