@sanity/export 3.41.0 → 3.41.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,11 @@ exportDataset({
42
42
 
43
43
  // Run 12 concurrent asset downloads
44
44
  assetConcurrency: 12,
45
+
46
+ // What mode to use when exporting documents, can be eiter `stream`(default) or `cursor`.
47
+ // Cursor mode might help when dealing with large datasets, but might yield inconsistent results if the dataset is mutated during export.
48
+ // Default: 'stream'
49
+ mode: 'stream',
45
50
  })
46
51
  ```
47
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "3.41.0",
3
+ "version": "3.41.2",
4
4
  "description": "Export Sanity documents and assets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -38,10 +38,11 @@
38
38
  "lodash": "^4.17.21",
39
39
  "mississippi": "^4.0.0",
40
40
  "p-queue": "^2.3.0",
41
- "rimraf": "^3.0.2",
41
+ "rimraf": "^6.0.1",
42
42
  "split2": "^4.2.0",
43
43
  "tar": "^7.0.1",
44
- "yaml": "^2.4.2"
44
+ "yaml": "^2.4.2",
45
+ "json-stream-stringify": "^2.0.2"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@jest/globals": "^29.7.0",
@@ -2,7 +2,7 @@ const crypto = require('crypto')
2
2
  const {mkdirSync, createWriteStream} = require('fs')
3
3
  const path = require('path')
4
4
  const {parse: parseUrl, format: formatUrl} = require('url')
5
- const {omit, noop} = require('lodash')
5
+ const {omit} = require('lodash')
6
6
  const miss = require('mississippi')
7
7
  const PQueue = require('p-queue')
8
8
  const pkg = require('../package.json')
package/src/export.js CHANGED
@@ -5,8 +5,10 @@ const zlib = require('zlib')
5
5
  const archiver = require('archiver')
6
6
  const miss = require('mississippi')
7
7
  const split = require('split2')
8
+ const JsonStreamStringify = require('json-stream-stringify')
8
9
  const AssetHandler = require('./AssetHandler')
9
10
  const debug = require('./debug')
11
+ const pipeAsync = require('./util/pipeAsync')
10
12
  const filterDocumentTypes = require('./filterDocumentTypes')
11
13
  const filterDrafts = require('./filterDrafts')
12
14
  const filterSystemDocuments = require('./filterSystemDocuments')
@@ -43,6 +45,7 @@ async function exportDataset(opts) {
43
45
  const tmpDir = path.join(os.tmpdir(), prefix)
44
46
  fs.mkdirSync(tmpDir, {recursive: true})
45
47
  const dataPath = path.join(tmpDir, 'data.ndjson')
48
+ const assetsPath = path.join(tmpDir, 'assets.json')
46
49
 
47
50
  const cleanup = () =>
48
51
  rimraf(tmpDir).catch((err) => {
@@ -209,7 +212,9 @@ async function exportDataset(opts) {
209
212
  update: true,
210
213
  })
211
214
 
212
- archive.append(JSON.stringify(assetMap), {name: 'assets.json', prefix})
215
+ const assetsStream = fs.createWriteStream(assetsPath)
216
+ await pipeAsync(new JsonStreamStringify(assetMap), assetsStream)
217
+ archive.file(assetsPath, {name: 'assets.json', prefix})
213
218
  clearInterval(progressInterval)
214
219
  } catch (assetErr) {
215
220
  clearInterval(progressInterval)
@@ -0,0 +1,17 @@
1
+ const miss = require('mississippi')
2
+
3
+ module.exports = async (readable, writable) => {
4
+ return new Promise((resolve, reject) => {
5
+ try {
6
+ miss.pipe(readable, writable, (jsonErr) => {
7
+ if (jsonErr) {
8
+ reject(jsonErr)
9
+ } else {
10
+ resolve()
11
+ }
12
+ })
13
+ } catch (assetErr) {
14
+ reject(assetErr)
15
+ }
16
+ })
17
+ }
@@ -1,4 +1 @@
1
- const {promisify} = require('util')
2
- const rimrafCb = require('rimraf')
3
-
4
- module.exports = promisify(rimrafCb)
1
+ module.exports = require('rimraf').rimraf