diff --git a/packages/@sanity/cli/test/exportImport.test.ts b/packages/@sanity/cli/test/exportImport.test.ts index 71778370222..3fe13714522 100644 --- a/packages/@sanity/cli/test/exportImport.test.ts +++ b/packages/@sanity/cli/test/exportImport.test.ts @@ -44,6 +44,35 @@ describeCliTest('CLI: `sanity dataset export` / `import`', () => { expect(filesTypes).toContain('.jpg') }) + testConcurrent('export, with mode', async () => { + const result = await runSanityCmdCommand(version, [ + 'dataset', + 'export', + 'production', + testRunArgs.exportTarball, + '--overwrite', + '--mode cursor', + ]) + expect(result.stdout).toMatch(/export finished/i) + expect(result.code).toBe(0) + + const tarballPath = path.join(studiosPath, version, testRunArgs.exportTarball) + + const stats = await stat(tarballPath) + expect(stats.isFile()).toBe(true) + + // We're just checking for the existence of a few files here - the actual export + // functionality is fully tested in `@sanity/export` + const filesTypes: string[] = [] + await tar.t({ + file: tarballPath, + onentry: (entry) => filesTypes.push(path.extname(entry.path)), + }) + + expect(filesTypes).toContain('.ndjson') + expect(filesTypes).toContain('.jpg') + }) + testConcurrent('import', async () => { const result = await runSanityCmdCommand(version, [ 'dataset', diff --git a/packages/sanity/src/_internal/cli/commands/dataset/exportDatasetCommand.ts b/packages/sanity/src/_internal/cli/commands/dataset/exportDatasetCommand.ts index e32b79d2165..278e3334a08 100644 --- a/packages/sanity/src/_internal/cli/commands/dataset/exportDatasetCommand.ts +++ b/packages/sanity/src/_internal/cli/commands/dataset/exportDatasetCommand.ts @@ -20,6 +20,7 @@ Options --types Defines which document types to export --overwrite Overwrite any file with the same name --asset-concurrency Concurrent number of asset downloads + --mode Uses a cursor when exporting, this might be more performant for larger datasets, but might not be as accurate if the dataset is being modified during export. Defaults to stream Examples sanity dataset export moviedb localPath.tar.gz @@ -36,6 +37,7 @@ interface ExportFlags { 'overwrite'?: boolean 'types'?: string 'asset-concurrency'?: string + 'mode'?: string } interface ParsedExportFlags { @@ -46,6 +48,7 @@ interface ParsedExportFlags { overwrite?: boolean types?: string[] assetConcurrency?: number + mode?: string } function parseFlags(rawFlags: ExportFlags): ParsedExportFlags { @@ -78,6 +81,10 @@ function parseFlags(rawFlags: ExportFlags): ParsedExportFlags { flags.overwrite = Boolean(rawFlags.overwrite) } + if (typeof rawFlags.mode !== 'undefined') { + flags.mode = rawFlags.mode + } + return flags }