contentful-export 7.15.0 → 7.16.1

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
@@ -61,7 +61,7 @@ const contentfulExport = require('contentful-export')
61
61
  const options = {
62
62
  spaceId: '<space_id>',
63
63
  managementToken: '<content_management_api_key>',
64
- queryEntries: 'content_type=<content_type_id>'
64
+ queryEntries: ['content_type=<content_type_id>']
65
65
  }
66
66
 
67
67
  contentfulExport(options)
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line
2
4
  const runContentfulExport = require('../dist/index')
5
+ // eslint-disable-next-line
3
6
  const usageParams = require('../dist/usageParams')
4
7
 
5
8
  console.log('We moved the CLI version of this tool into our Contentful CLI.\nThis allows our users to use and install only one single CLI tool to get the full Contentful experience.\nFor more info please visit https://github.com/contentful/contentful-cli/tree/master/docs/space/export')
6
9
 
7
10
  runContentfulExport(usageParams)
8
- .then((result) => {
11
+ .then(() => {
9
12
  process.exit(0)
10
13
  })
11
14
  .catch((err) => {
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var _listrUpdateRenderer = _interopRequireDefault(require("listr-update-renderer
19
19
 
20
20
  var _listrVerboseRenderer = _interopRequireDefault(require("listr-verbose-renderer"));
21
21
 
22
- var _lodash = require("lodash");
22
+ var _lodash = _interopRequireDefault(require("lodash.startcase"));
23
23
 
24
24
  var _mkdirp = _interopRequireDefault(require("mkdirp"));
25
25
 
@@ -104,7 +104,7 @@ function runContentfulExport(params) {
104
104
  skip: ctx => !options.downloadAssets || !Object.prototype.hasOwnProperty.call(ctx.data, 'assets')
105
105
  }, {
106
106
  title: 'Write export log file',
107
- task: ctx => {
107
+ task: () => {
108
108
  return new _listr.default([{
109
109
  title: 'Lookup directory to store the logs',
110
110
  task: ctx => {
@@ -116,7 +116,7 @@ function runContentfulExport(params) {
116
116
  }
117
117
  }, {
118
118
  title: 'Create log directory',
119
- task: ctx => {
119
+ task: () => {
120
120
  return (0, _mkdirp.default)(options.exportDir);
121
121
  },
122
122
  skip: ctx => !ctx.logDirectoryExists
@@ -144,7 +144,7 @@ function runContentfulExport(params) {
144
144
  content: 'Exported entities'
145
145
  }]);
146
146
  resultTypes.forEach(type => {
147
- resultTable.push([(0, _lodash.startCase)(type), ctx.data[type].length]);
147
+ resultTable.push([(0, _lodash.default)(type), ctx.data[type].length]);
148
148
  });
149
149
  console.log(resultTable.toString());
150
150
  } else {
@@ -11,7 +11,7 @@ var _bluebird = _interopRequireDefault(require("bluebird"));
11
11
 
12
12
  var _figures = _interopRequireDefault(require("figures"));
13
13
 
14
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
14
+ var _fs = require("fs");
15
15
 
16
16
  var _nodeFetch = _interopRequireDefault(require("node-fetch"));
17
17
 
@@ -42,10 +42,10 @@ async function downloadAsset({
42
42
  const localFile = _path.default.join(directory, parsedUrl.host, parsedUrl.pathname); // ensure directory exists and create file stream
43
43
 
44
44
 
45
- _fsExtra.default.mkdirsSync(_path.default.dirname(localFile));
46
-
47
- const file = _fsExtra.default.createWriteStream(localFile); // download asset
48
-
45
+ await _fs.promises.mkdir(_path.default.dirname(localFile), {
46
+ recursive: true
47
+ });
48
+ const file = (0, _fs.createWriteStream)(localFile); // download asset
49
49
 
50
50
  const assetRequest = await (0, _nodeFetch.default)(url);
51
51
 
@@ -47,7 +47,7 @@ function getFullSourceSpace({
47
47
  };
48
48
  return new _listr.default([{
49
49
  title: 'Connecting to space',
50
- task: (0, _listr2.wrapTask)((ctx, task) => {
50
+ task: (0, _listr2.wrapTask)(ctx => {
51
51
  return client.getSpace(spaceId).then(space => {
52
52
  ctx.space = space;
53
53
  return space.getEnvironment(environmentId);
@@ -57,7 +57,7 @@ function getFullSourceSpace({
57
57
  })
58
58
  }, {
59
59
  title: 'Fetching content types data',
60
- task: (0, _listr2.wrapTask)((ctx, task) => {
60
+ task: (0, _listr2.wrapTask)(ctx => {
61
61
  return pagedGet({
62
62
  source: ctx.environment,
63
63
  method: 'getContentTypes'
@@ -68,20 +68,20 @@ function getFullSourceSpace({
68
68
  skip: () => skipContentModel
69
69
  }, {
70
70
  title: 'Fetching tags data',
71
- task: (0, _listr2.wrapTask)((ctx, task) => {
71
+ task: (0, _listr2.wrapTask)(ctx => {
72
72
  return pagedGet({
73
73
  source: ctx.environment,
74
74
  method: 'getTags'
75
75
  }).then(extractItems).then(items => {
76
76
  ctx.data.tags = items;
77
- }).catch(e => {
77
+ }).catch(() => {
78
78
  ctx.data.tags = [];
79
79
  });
80
80
  }),
81
81
  skip: () => cdaClient
82
82
  }, {
83
83
  title: 'Fetching editor interfaces data',
84
- task: (0, _listr2.wrapTask)((ctx, task) => {
84
+ task: (0, _listr2.wrapTask)(ctx => {
85
85
  return getEditorInterfaces(ctx.data.contentTypes).then(editorInterfaces => {
86
86
  ctx.data.editorInterfaces = editorInterfaces.filter(editorInterface => {
87
87
  return editorInterface !== null;
@@ -91,7 +91,7 @@ function getFullSourceSpace({
91
91
  skip: ctx => skipContentModel || skipEditorInterfaces || ctx.data.contentTypes.length === 0 && 'Skipped since no content types downloaded'
92
92
  }, {
93
93
  title: 'Fetching content entries data',
94
- task: (0, _listr2.wrapTask)((ctx, task) => {
94
+ task: (0, _listr2.wrapTask)(ctx => {
95
95
  const source = cdaClient || ctx.environment;
96
96
 
97
97
  if (cdaClient) {
@@ -112,7 +112,7 @@ function getFullSourceSpace({
112
112
  skip: () => skipContent
113
113
  }, {
114
114
  title: 'Fetching assets data',
115
- task: (0, _listr2.wrapTask)((ctx, task) => {
115
+ task: (0, _listr2.wrapTask)(ctx => {
116
116
  const source = cdaClient || ctx.environment;
117
117
  queryAssets = queryAssets || {};
118
118
  queryAssets.locale = '*';
@@ -127,7 +127,7 @@ function getFullSourceSpace({
127
127
  skip: () => skipContent
128
128
  }, {
129
129
  title: 'Fetching locales data',
130
- task: (0, _listr2.wrapTask)((ctx, task) => {
130
+ task: (0, _listr2.wrapTask)(ctx => {
131
131
  return pagedGet({
132
132
  source: ctx.environment,
133
133
  method: 'getLocales'
@@ -138,7 +138,7 @@ function getFullSourceSpace({
138
138
  skip: () => skipContentModel
139
139
  }, {
140
140
  title: 'Fetching webhooks data',
141
- task: (0, _listr2.wrapTask)((ctx, task) => {
141
+ task: (0, _listr2.wrapTask)(ctx => {
142
142
  return pagedGet({
143
143
  source: ctx.space,
144
144
  method: 'getWebhooks'
@@ -149,7 +149,7 @@ function getFullSourceSpace({
149
149
  skip: () => skipWebhooks || environmentId !== 'master' && 'Webhooks can only be exported from master environment'
150
150
  }, {
151
151
  title: 'Fetching roles data',
152
- task: (0, _listr2.wrapTask)((ctx, task) => {
152
+ task: (0, _listr2.wrapTask)(ctx => {
153
153
  return pagedGet({
154
154
  source: ctx.space,
155
155
  method: 'getRoles'
@@ -162,7 +162,7 @@ function getFullSourceSpace({
162
162
  }
163
163
 
164
164
  function getEditorInterfaces(contentTypes) {
165
- return _bluebird.default.map(contentTypes, (contentType, index, length) => {
165
+ return _bluebird.default.map(contentTypes, contentType => {
166
166
  return contentType.getEditorInterface().then(editorInterface => {
167
167
  _logging.logEmitter.emit('info', `Fetched editor interface for ${contentType.name}`);
168
168
 
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- const yargs = require('yargs');
8
+ var _yargs = _interopRequireDefault(require("yargs"));
9
9
 
10
- const packageFile = require('../package');
10
+ var _package = _interopRequireDefault(require("../package"));
11
11
 
12
- var _default = yargs.version(packageFile.version || 'Version only available on installed package').usage('Usage: $0 [options]').option('space-id', {
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = _yargs.default.version(_package.default.version || 'Version only available on installed package').usage('Usage: $0 [options]').option('space-id', {
13
15
  describe: 'ID of Space with source data',
14
16
  type: 'string',
15
17
  demand: true
@@ -98,5 +100,6 @@ var _default = yargs.version(packageFile.version || 'Version only available on i
98
100
  type: 'string',
99
101
  describe: 'Pass an additional HTTP Header'
100
102
  }).config('config', 'An optional configuration JSON file containing all the options for a single run').argv;
103
+
101
104
  exports.default = _default;
102
105
  module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-export",
3
- "version": "7.15.0",
3
+ "version": "7.16.1",
4
4
  "description": "this tool allows you to export a space to a JSON dump",
5
5
  "main": "dist/index.js",
6
6
  "types": "types.d.ts",
@@ -14,7 +14,7 @@
14
14
  "build": "npm run clean && babel lib --out-dir dist",
15
15
  "build:watch": "babel lib --out-dir dist --watch",
16
16
  "clean": "rimraf dist && rimraf coverage",
17
- "lint": "eslint lib bin/*",
17
+ "lint": "eslint lib bin/* types.d.ts",
18
18
  "pretest": "npm run lint && npm run build && rimraf ./test/integration/tmp",
19
19
  "test": "npm run test:unit && npm run test:integration",
20
20
  "test:unit": "jest --testPathPattern=test/unit --coverage",
@@ -50,12 +50,11 @@
50
50
  "contentful-batch-libs": "^9.2.1",
51
51
  "contentful-management": "^10.0.0",
52
52
  "figures": "^3.2.0",
53
- "fs-extra": "^10.0.0",
54
53
  "jsonwebtoken": "^8.5.1",
55
54
  "listr": "^0.14.1",
56
55
  "listr-update-renderer": "^0.5.0",
57
56
  "listr-verbose-renderer": "^0.6.0",
58
- "lodash": "^4.17.10",
57
+ "lodash.startcase": "^4.4.0",
59
58
  "mkdirp": "^1.0.3",
60
59
  "moment": "^2.22.2",
61
60
  "node-fetch": "^2.6.7",
@@ -69,14 +68,14 @@
69
68
  "@babel/template": "^7.0.0",
70
69
  "@babel/types": "^7.0.0",
71
70
  "@types/jest": "^27.0.2",
72
- "babel-eslint": "^10.1.0",
71
+ "@typescript-eslint/eslint-plugin": "^5.22.0",
73
72
  "babel-jest": "^28.0.0",
74
73
  "babel-plugin-add-module-exports": "^1.0.2",
75
74
  "cz-conventional-changelog": "^3.3.0",
76
75
  "eslint": "^7.2.0",
77
76
  "eslint-config-standard": "^16.0.1",
78
77
  "eslint-plugin-import": "^2.12.0",
79
- "eslint-plugin-jest": "^26.0.0",
78
+ "eslint-plugin-jest": "^26.1.5",
80
79
  "eslint-plugin-node": "^11.1.0",
81
80
  "eslint-plugin-promise": "^6.0.0",
82
81
  "eslint-plugin-standard": "^5.0.0",
package/types.d.ts CHANGED
@@ -24,14 +24,13 @@ export interface Options {
24
24
  saveFile?: boolean;
25
25
  skipContent?: boolean;
26
26
  skipContentModel?: boolean;
27
- skipEditorInferfaces?: boolean;
27
+ skipEditorInterfaces?: boolean;
28
28
  skipRoles?: boolean;
29
29
  skipWebhooks?: boolean;
30
30
  useVerboseRenderer?: boolean;
31
- };
32
-
31
+ }
33
32
 
34
33
  type ContentfulExportField = 'contentTypes' | 'entries' | 'assets' | 'locales' | 'tags' | 'webhooks' | 'roles' | 'editorInterfaces';
35
34
 
36
- declare const runContentfulExport: (params: Options) => Promise<Record<ContentfulExportField, unknown[]>>;
37
- export default runContentfulExport;
35
+ declare const runContentfulExport: (params: Options) => Promise<Record<ContentfulExportField, unknown[]>>
36
+ export default runContentfulExport