@sanity/export 2.30.2-shopify.2 → 3.0.0-dev-preview.7

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.
@@ -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);
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var defaults = require('lodash/defaults');
3
+ const defaults = require('lodash/defaults');
4
4
 
5
- var clientMethods = ['getUrl', 'config'];
6
- var booleanFlags = ['assets', 'raw', 'compress', 'drafts'];
7
- var exportDefaults = {
5
+ const clientMethods = ['getUrl', 'config'];
6
+ const booleanFlags = ['assets', 'raw', 'compress', 'drafts'];
7
+ const exportDefaults = {
8
8
  compress: true,
9
9
  drafts: true,
10
10
  assets: true,
@@ -12,7 +12,7 @@ var exportDefaults = {
12
12
  };
13
13
 
14
14
  function validateOptions(opts) {
15
- var options = defaults({}, opts, exportDefaults);
15
+ const 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
- var missing = clientMethods.find(key => typeof options.client[key] !== 'function');
29
+ const 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
- var clientConfig = options.client.config();
35
+ const 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,18 +1,19 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "2.30.2-shopify.2+c78e70728",
3
+ "version": "3.0.0-dev-preview.7+856da7f1d5",
4
4
  "description": "Export Sanity documents and assets",
5
- "main": "lib/export.js",
5
+ "main": "./lib/export.js",
6
+ "types": "./lib/dts/src/export.d.ts",
6
7
  "engines": {
7
- "node": ">=12.0.0"
8
+ "node": ">=14.0.0"
8
9
  },
9
10
  "author": "Sanity.io <hello@sanity.io>",
10
11
  "license": "MIT",
11
12
  "scripts": {
12
- "build": "babel src --copy-files --out-dir lib",
13
- "clean": "rimraf lib dest",
14
- "prebuild": "npm run clean",
15
- "test": "jest"
13
+ "build": "../../../bin/pkg-utils transpile --target node",
14
+ "clean": "rimraf lib",
15
+ "test": "jest",
16
+ "watch": "../../../bin/pkg-utils transpile --target node --watch"
16
17
  },
17
18
  "keywords": [
18
19
  "sanity",
@@ -26,15 +27,14 @@
26
27
  "dependencies": {
27
28
  "archiver": "^5.0.0",
28
29
  "debug": "^3.2.7",
29
- "fs-extra": "^7.0.0",
30
30
  "get-it": "^5.2.1",
31
- "lodash": "^4.17.15",
31
+ "lodash": "^4.17.21",
32
32
  "mississippi": "^4.0.0",
33
33
  "p-queue": "^2.3.0",
34
+ "rimraf": "^3.0.2",
34
35
  "split2": "^3.2.2"
35
36
  },
36
37
  "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": "c78e7072844ba209ec77b3c01e5ee3b1494cb276"
52
+ "gitHead": "856da7f1d599ffd8d8c35afdbb5f1577e0573e6e"
53
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)
package/jest.config.js DELETED
@@ -1,6 +0,0 @@
1
- const createConfig = require('../../../createJestConfig')
2
-
3
- module.exports = createConfig({
4
- displayName: require('./package.json').name,
5
- testEnvironment: 'node',
6
- })