Skip to content

Commit

Permalink
[core] Document drafts, types and overwrite flags for export command
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars authored and bjoerge committed Feb 16, 2018
1 parent 1d452dd commit c26fc06
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/@sanity/core/src/commands/dataset/exportDatasetCommand.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import fse from 'fs-extra'
import prettyMs from 'pretty-ms'
import {pathTools} from '@sanity/util'
import exportDataset from '@sanity/export'
import chooseDatasetPrompt from '../../actions/dataset/chooseDatasetPrompt'
Expand All @@ -10,12 +11,16 @@ const helpText = `
Options
--raw Extract only documents, without rewriting asset references
--no-assets Export only non-asset documents and remove references to image assets
--no-drafts Export only published versions of documents
--no-compress Skips compressing tarball entries (still generates a gzip file)
--types Defines which document types to export
--overwrite Overwrite any file with the same name
Examples
sanity export moviedb localPath.tar.gz
sanity export moviedb assetless.tar.gz --no-assets
sanity export staging staging.tar.gz --raw
sanity export staging staging.tar.gz --types products,shops
`

export default {
Expand All @@ -31,6 +36,10 @@ export default {
const flags = args.extOptions
const {absolutify} = pathTools

if (flags.types) {
flags.types = `${flags.types}`.split(',')
}

let dataset = targetDataset ? `${targetDataset}` : null
if (!dataset) {
dataset = await chooseDatasetPrompt(context, {message: 'Select dataset to export'})
Expand Down Expand Up @@ -76,6 +85,7 @@ export default {
currentStep = progress.step
}

const start = Date.now()
try {
await exportDataset({
client,
Expand All @@ -89,6 +99,8 @@ export default {
spinner.fail()
throw err
}

output.print(`Export finished (${prettyMs(Date.now() - start)})`)
}
}

Expand Down

0 comments on commit c26fc06

Please sign in to comment.