@sanity/export 2.29.5-purple-unicorn-remix.873 → 2.30.2-shopify.0
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/jest.config.js +6 -0
- package/lib/AssetHandler.js +202 -150
- package/lib/export.js +178 -151
- package/lib/filterDocumentTypes.js +2 -2
- package/lib/filterDrafts.js +2 -2
- package/lib/filterSystemDocuments.js +3 -3
- package/lib/getDocumentsStream.js +17 -10
- package/lib/logFirstChunk.js +4 -4
- package/lib/rejectOnApiError.js +1 -1
- package/lib/requestStream.js +61 -40
- package/lib/stringifyStream.js +1 -1
- package/lib/tryParseJson.js +4 -4
- package/lib/validateOptions.js +7 -7
- package/package.json +10 -10
- package/src/AssetHandler.js +5 -6
- package/src/export.js +3 -4
- package/lib/util/rimraf.js +0 -9
- package/src/util/rimraf.js +0 -4
package/lib/validateOptions.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var defaults = require('lodash/defaults');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var clientMethods = ['getUrl', 'config'];
|
|
6
|
+
var booleanFlags = ['assets', 'raw', 'compress', 'drafts'];
|
|
7
|
+
var exportDefaults = {
|
|
8
8
|
compress: true,
|
|
9
9
|
drafts: true,
|
|
10
10
|
assets: true,
|
|
@@ -12,7 +12,7 @@ const exportDefaults = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
function validateOptions(opts) {
|
|
15
|
-
|
|
15
|
+
var options = defaults({}, opts, exportDefaults);
|
|
16
16
|
|
|
17
17
|
if (typeof options.dataset !== 'string' || options.dataset.length < 1) {
|
|
18
18
|
throw new Error("options.dataset must be a valid dataset name");
|
|
@@ -26,13 +26,13 @@ function validateOptions(opts) {
|
|
|
26
26
|
throw new Error('`options.client` must be set to an instance of @sanity/client');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
var missing = clientMethods.find(key => typeof options.client[key] !== 'function');
|
|
30
30
|
|
|
31
31
|
if (missing) {
|
|
32
32
|
throw new Error("`options.client` is not a valid @sanity/client instance - no \"".concat(missing, "\" method found"));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
var clientConfig = options.client.config();
|
|
36
36
|
|
|
37
37
|
if (!clientConfig.token) {
|
|
38
38
|
throw new Error('Client is not instantiated with a `token`');
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/export",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.2-shopify.0+4e3235208",
|
|
4
4
|
"description": "Export Sanity documents and assets",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "./lib/dts/src/export.d.ts",
|
|
5
|
+
"main": "lib/export.js",
|
|
7
6
|
"engines": {
|
|
8
7
|
"node": ">=12.0.0"
|
|
9
8
|
},
|
|
10
9
|
"author": "Sanity.io <hello@sanity.io>",
|
|
11
10
|
"license": "MIT",
|
|
12
11
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
"clean": "rimraf lib",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
12
|
+
"build": "babel src --copy-files --out-dir lib",
|
|
13
|
+
"clean": "rimraf lib dest",
|
|
14
|
+
"prebuild": "npm run clean",
|
|
15
|
+
"test": "jest"
|
|
17
16
|
},
|
|
18
17
|
"keywords": [
|
|
19
18
|
"sanity",
|
|
@@ -27,14 +26,15 @@
|
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"archiver": "^5.0.0",
|
|
29
28
|
"debug": "^3.2.7",
|
|
29
|
+
"fs-extra": "^7.0.0",
|
|
30
30
|
"get-it": "^5.2.1",
|
|
31
|
-
"lodash": "^4.17.
|
|
31
|
+
"lodash": "^4.17.15",
|
|
32
32
|
"mississippi": "^4.0.0",
|
|
33
33
|
"p-queue": "^2.3.0",
|
|
34
|
-
"rimraf": "^3.0.2",
|
|
35
34
|
"split2": "^3.2.2"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
37
|
+
"rimraf": "^2.7.1",
|
|
38
38
|
"string-to-stream": "^1.1.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"url": "https://github.com/sanity-io/sanity/issues"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://www.sanity.io/",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "4e3235208960dc8d16b04a649ddecdc4e7573837"
|
|
53
53
|
}
|
package/src/AssetHandler.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const crypto = require('crypto')
|
|
3
3
|
const {parse: parseUrl, format: formatUrl} = require('url')
|
|
4
|
-
const
|
|
4
|
+
const fse = require('fs-extra')
|
|
5
5
|
const miss = require('mississippi')
|
|
6
6
|
const PQueue = require('p-queue')
|
|
7
7
|
const {omit, noop} = require('lodash')
|
|
8
8
|
const pkg = require('../package.json')
|
|
9
9
|
const requestStream = require('./requestStream')
|
|
10
10
|
const debug = require('./debug')
|
|
11
|
-
const rimraf = require('./util/rimraf')
|
|
12
11
|
|
|
13
12
|
const EXCLUDE_PROPS = ['_id', '_type', 'assetId', 'extension', 'mimeType', 'path', 'url']
|
|
14
13
|
const ACTION_REMOVE = 'remove'
|
|
@@ -113,8 +112,8 @@ class AssetHandler {
|
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/* eslint-disable no-sync */
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
fse.ensureDirSync(path.join(this.tmpDir, 'files'))
|
|
116
|
+
fse.ensureDirSync(path.join(this.tmpDir, 'images'))
|
|
118
117
|
/* eslint-enable no-sync */
|
|
119
118
|
this.assetDirsCreated = true
|
|
120
119
|
}
|
|
@@ -196,7 +195,7 @@ class AssetHandler {
|
|
|
196
195
|
|
|
197
196
|
const detailsString = `Details:\n - ${details.filter(Boolean).join('\n - ')}`
|
|
198
197
|
|
|
199
|
-
await
|
|
198
|
+
await fse.unlink(tmpPath)
|
|
200
199
|
this.queue.clear()
|
|
201
200
|
|
|
202
201
|
const error = new Error(
|
|
@@ -307,7 +306,7 @@ function writeHashedStream(filePath, stream) {
|
|
|
307
306
|
})
|
|
308
307
|
|
|
309
308
|
return new Promise((resolve, reject) =>
|
|
310
|
-
miss.pipe(stream, hasher, createWriteStream(filePath), (err) => {
|
|
309
|
+
miss.pipe(stream, hasher, fse.createWriteStream(filePath), (err) => {
|
|
311
310
|
if (err) {
|
|
312
311
|
reject(err)
|
|
313
312
|
return
|
package/src/export.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const os = require('os')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const zlib = require('zlib')
|
|
4
|
-
const
|
|
4
|
+
const fse = require('fs-extra')
|
|
5
5
|
const miss = require('mississippi')
|
|
6
6
|
const split = require('split2')
|
|
7
7
|
const archiver = require('archiver')
|
|
8
|
-
const rimraf = require('./util/rimraf')
|
|
9
8
|
const debug = require('./debug')
|
|
10
9
|
const AssetHandler = require('./AssetHandler')
|
|
11
10
|
const stringifyStream = require('./stringifyStream')
|
|
@@ -36,7 +35,7 @@ function exportDataset(opts) {
|
|
|
36
35
|
const prefix = `${opts.dataset}-export-${slugDate}`
|
|
37
36
|
const tmpDir = path.join(os.tmpdir(), prefix)
|
|
38
37
|
const cleanup = () =>
|
|
39
|
-
|
|
38
|
+
fse.remove(tmpDir).catch((err) => {
|
|
40
39
|
debug(`Error while cleaning up temporary files: ${err.message}`)
|
|
41
40
|
})
|
|
42
41
|
|
|
@@ -55,7 +54,7 @@ function exportDataset(opts) {
|
|
|
55
54
|
outputStream = options.outputPath
|
|
56
55
|
} else {
|
|
57
56
|
outputStream =
|
|
58
|
-
options.outputPath === '-' ? process.stdout :
|
|
57
|
+
options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath)
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
let assetStreamHandler = assetHandler.noop
|
package/lib/util/rimraf.js
DELETED
package/src/util/rimraf.js
DELETED