@sanity/export 2.29.5-purple-unicorn.856 → 2.29.5-purple-unicorn-remix.958

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.
@@ -11,7 +11,10 @@ const {
11
11
  format: formatUrl
12
12
  } = require('url');
13
13
 
14
- const fse = require('fs-extra');
14
+ const {
15
+ mkdirSync,
16
+ createWriteStream
17
+ } = require('fs');
15
18
 
16
19
  const miss = require('mississippi');
17
20
 
@@ -28,6 +31,8 @@ const requestStream = require('./requestStream');
28
31
 
29
32
  const debug = require('./debug');
30
33
 
34
+ const rimraf = require('./util/rimraf');
35
+
31
36
  const EXCLUDE_PROPS = ['_id', '_type', 'assetId', 'extension', 'mimeType', 'path', 'url'];
32
37
  const ACTION_REMOVE = 'remove';
33
38
  const ACTION_REWRITE = 'rewrite';
@@ -175,8 +180,12 @@ class AssetHandler {
175
180
  /* eslint-disable no-sync */
176
181
 
177
182
 
178
- fse.ensureDirSync(path.join(this.tmpDir, 'files'));
179
- fse.ensureDirSync(path.join(this.tmpDir, 'images'));
183
+ mkdirSync(path.join(this.tmpDir, 'files'), {
184
+ recursive: true
185
+ });
186
+ mkdirSync(path.join(this.tmpDir, 'images'), {
187
+ recursive: true
188
+ });
180
189
  /* eslint-enable no-sync */
181
190
 
182
191
  this.assetDirsCreated = true;
@@ -259,7 +268,7 @@ class AssetHandler {
259
268
  } else if (differs) {
260
269
  const details = [hasHash && (method === 'md5' ? "md5 should be ".concat(remoteMd5, ", got ").concat(md5) : "sha1 should be ".concat(remoteSha1, ", got ").concat(sha1)), contentLength && parseInt(contentLength, 10) !== size && "Asset should be ".concat(contentLength, " bytes, got ").concat(size), "Did not succeed after ".concat(attemptNum, " attempts.")];
261
270
  const detailsString = "Details:\n - ".concat(details.filter(Boolean).join('\n - '));
262
- await fse.unlink(tmpPath);
271
+ await rimraf(tmpPath);
263
272
  this.queue.clear();
264
273
  const error = new Error("Failed to download asset at ".concat(assetDoc.url, ", giving up. ").concat(detailsString));
265
274
  this.reject(error);
@@ -315,7 +324,7 @@ function writeHashedStream(filePath, stream) {
315
324
  sha1.update(chunk);
316
325
  cb(null, chunk);
317
326
  });
318
- return new Promise((resolve, reject) => miss.pipe(stream, hasher, fse.createWriteStream(filePath), err => {
327
+ return new Promise((resolve, reject) => miss.pipe(stream, hasher, createWriteStream(filePath), err => {
319
328
  if (err) {
320
329
  reject(err);
321
330
  return;
package/lib/export.js CHANGED
@@ -6,7 +6,7 @@ const path = require('path');
6
6
 
7
7
  const zlib = require('zlib');
8
8
 
9
- const fse = require('fs-extra');
9
+ const fs = require('fs');
10
10
 
11
11
  const miss = require('mississippi');
12
12
 
@@ -14,6 +14,8 @@ const split = require('split2');
14
14
 
15
15
  const archiver = require('archiver');
16
16
 
17
+ const rimraf = require('./util/rimraf');
18
+
17
19
  const debug = require('./debug');
18
20
 
19
21
  const AssetHandler = require('./AssetHandler');
@@ -51,7 +53,7 @@ function exportDataset(opts) {
51
53
  const prefix = "".concat(opts.dataset, "-export-").concat(slugDate);
52
54
  const tmpDir = path.join(os.tmpdir(), prefix);
53
55
 
54
- const cleanup = () => fse.remove(tmpDir).catch(err => {
56
+ const cleanup = () => rimraf(tmpDir).catch(err => {
55
57
  debug("Error while cleaning up temporary files: ".concat(err.message));
56
58
  });
57
59
 
@@ -68,7 +70,7 @@ function exportDataset(opts) {
68
70
  if (isWritableStream(options.outputPath)) {
69
71
  outputStream = options.outputPath;
70
72
  } else {
71
- outputStream = options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath);
73
+ outputStream = options.outputPath === '-' ? process.stdout : fs.createWriteStream(options.outputPath);
72
74
  }
73
75
 
74
76
  let assetStreamHandler = assetHandler.noop;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ const {
4
+ promisify
5
+ } = require('util');
6
+
7
+ const rimrafCb = require('rimraf');
8
+
9
+ module.exports = promisify(rimrafCb);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "2.29.5-purple-unicorn.856+d39e7c057",
3
+ "version": "2.29.5-purple-unicorn-remix.958+2e3b4bcb7",
4
4
  "description": "Export Sanity documents and assets",
5
5
  "main": "./lib/export.js",
6
6
  "types": "./lib/dts/src/export.d.ts",
@@ -27,15 +27,14 @@
27
27
  "dependencies": {
28
28
  "archiver": "^5.0.0",
29
29
  "debug": "^3.2.7",
30
- "fs-extra": "^7.0.0",
31
30
  "get-it": "^5.2.1",
32
31
  "lodash": "^4.17.21",
33
32
  "mississippi": "^4.0.0",
34
33
  "p-queue": "^2.3.0",
34
+ "rimraf": "^3.0.2",
35
35
  "split2": "^3.2.2"
36
36
  },
37
37
  "devDependencies": {
38
- "rimraf": "^3.0.2",
39
38
  "string-to-stream": "^1.1.0"
40
39
  },
41
40
  "publishConfig": {
@@ -50,5 +49,5 @@
50
49
  "url": "https://github.com/sanity-io/sanity/issues"
51
50
  },
52
51
  "homepage": "https://www.sanity.io/",
53
- "gitHead": "d39e7c0574631659b51086cd87dd041f6b278fa9"
52
+ "gitHead": "2e3b4bcb70a3336c5a75e4ad947760b328d1eb04"
54
53
  }
@@ -1,13 +1,14 @@
1
1
  const path = require('path')
2
2
  const crypto = require('crypto')
3
3
  const {parse: parseUrl, format: formatUrl} = require('url')
4
- const fse = require('fs-extra')
4
+ const {mkdirSync, createWriteStream} = require('fs')
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')
11
12
 
12
13
  const EXCLUDE_PROPS = ['_id', '_type', 'assetId', 'extension', 'mimeType', 'path', 'url']
13
14
  const ACTION_REMOVE = 'remove'
@@ -112,8 +113,8 @@ class AssetHandler {
112
113
  }
113
114
 
114
115
  /* eslint-disable no-sync */
115
- fse.ensureDirSync(path.join(this.tmpDir, 'files'))
116
- fse.ensureDirSync(path.join(this.tmpDir, 'images'))
116
+ mkdirSync(path.join(this.tmpDir, 'files'), {recursive: true})
117
+ mkdirSync(path.join(this.tmpDir, 'images'), {recursive: true})
117
118
  /* eslint-enable no-sync */
118
119
  this.assetDirsCreated = true
119
120
  }
@@ -195,7 +196,7 @@ class AssetHandler {
195
196
 
196
197
  const detailsString = `Details:\n - ${details.filter(Boolean).join('\n - ')}`
197
198
 
198
- await fse.unlink(tmpPath)
199
+ await rimraf(tmpPath)
199
200
  this.queue.clear()
200
201
 
201
202
  const error = new Error(
@@ -306,7 +307,7 @@ function writeHashedStream(filePath, stream) {
306
307
  })
307
308
 
308
309
  return new Promise((resolve, reject) =>
309
- miss.pipe(stream, hasher, fse.createWriteStream(filePath), (err) => {
310
+ miss.pipe(stream, hasher, createWriteStream(filePath), (err) => {
310
311
  if (err) {
311
312
  reject(err)
312
313
  return
package/src/export.js CHANGED
@@ -1,10 +1,11 @@
1
1
  const os = require('os')
2
2
  const path = require('path')
3
3
  const zlib = require('zlib')
4
- const fse = require('fs-extra')
4
+ const fs = require('fs')
5
5
  const miss = require('mississippi')
6
6
  const split = require('split2')
7
7
  const archiver = require('archiver')
8
+ const rimraf = require('./util/rimraf')
8
9
  const debug = require('./debug')
9
10
  const AssetHandler = require('./AssetHandler')
10
11
  const stringifyStream = require('./stringifyStream')
@@ -35,7 +36,7 @@ function exportDataset(opts) {
35
36
  const prefix = `${opts.dataset}-export-${slugDate}`
36
37
  const tmpDir = path.join(os.tmpdir(), prefix)
37
38
  const cleanup = () =>
38
- fse.remove(tmpDir).catch((err) => {
39
+ rimraf(tmpDir).catch((err) => {
39
40
  debug(`Error while cleaning up temporary files: ${err.message}`)
40
41
  })
41
42
 
@@ -54,7 +55,7 @@ function exportDataset(opts) {
54
55
  outputStream = options.outputPath
55
56
  } else {
56
57
  outputStream =
57
- options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath)
58
+ options.outputPath === '-' ? process.stdout : fs.createWriteStream(options.outputPath)
58
59
  }
59
60
 
60
61
  let assetStreamHandler = assetHandler.noop
@@ -0,0 +1,4 @@
1
+ const {promisify} = require('util')
2
+ const rimrafCb = require('rimraf')
3
+
4
+ module.exports = promisify(rimrafCb)