@sanity/export 3.41.1 → 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/package.json +3 -2
- package/src/export.js +6 -1
- package/src/util/pipeAsync.js +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/export",
|
|
3
|
-
"version": "3.41.
|
|
3
|
+
"version": "3.41.2",
|
|
4
4
|
"description": "Export Sanity documents and assets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
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",
|
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
|
-
|
|
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
|
+
}
|