@contentstack/cli-cm-export 1.11.2 → 1.11.4

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
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
48
48
  $ csdx COMMAND
49
49
  running command...
50
50
  $ csdx (--version)
51
- @contentstack/cli-cm-export/1.11.2 linux-x64 node-v18.20.2
51
+ @contentstack/cli-cm-export/1.11.4 linux-x64 node-v18.20.3
52
52
  $ csdx --help [COMMAND]
53
53
  USAGE
54
54
  $ csdx COMMAND
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const path = tslib_1.__importStar(require("path"));
5
5
  const utils_1 = require("../../utils");
6
6
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
7
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
8
  class ContentTypesExport extends base_class_1.default {
8
9
  constructor({ exportConfig, stackAPIClient }) {
9
10
  super({ exportConfig, stackAPIClient });
@@ -19,7 +20,7 @@ class ContentTypesExport extends base_class_1.default {
19
20
  if (Array.isArray(this.exportConfig.contentTypes) && this.exportConfig.contentTypes.length > 0) {
20
21
  this.qs.uid = { $in: this.exportConfig.contentTypes };
21
22
  }
22
- this.contentTypesDirPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.contentTypesConfig.dirName);
23
+ this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.contentTypesConfig.dirName));
23
24
  this.contentTypes = [];
24
25
  }
25
26
  async start() {
@@ -67,7 +68,7 @@ class ContentTypesExport extends base_class_1.default {
67
68
  }
68
69
  async writeContentTypes(contentTypes) {
69
70
  function write(contentType) {
70
- return utils_1.fsUtil.writeFile(path.join(this.contentTypesDirPath, `${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`), contentType);
71
+ return utils_1.fsUtil.writeFile(path.join((0, cli_utilities_1.sanitizePath)(this.contentTypesDirPath), (0, cli_utilities_1.sanitizePath)(`${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`)), contentType);
71
72
  }
72
73
  await (0, utils_1.executeTask)(contentTypes, write.bind(this), { concurrency: this.exportConfig.writeConcurrency });
73
74
  return utils_1.fsUtil.writeFile(path.join(this.contentTypesDirPath, 'schema.json'), contentTypes);
@@ -5,15 +5,16 @@ const path = tslib_1.__importStar(require("path"));
5
5
  const cli_utilities_1 = require("@contentstack/cli-utilities");
6
6
  const utils_1 = require("../../utils");
7
7
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
8
+ const cli_utilities_2 = require("@contentstack/cli-utilities");
8
9
  class EntriesExport extends base_class_1.default {
9
10
  constructor({ exportConfig, stackAPIClient }) {
10
11
  super({ exportConfig, stackAPIClient });
11
12
  this.stackAPIClient = stackAPIClient;
12
13
  this.exportConfig = exportConfig;
13
14
  this.entriesConfig = exportConfig.modules.entries;
14
- this.entriesDirPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.entriesConfig.dirName);
15
- this.localesFilePath = path.resolve(exportConfig.data, exportConfig.branchName || '', exportConfig.modules.locales.dirName, exportConfig.modules.locales.fileName);
16
- this.schemaFilePath = path.resolve(exportConfig.data, exportConfig.branchName || '', exportConfig.modules.content_types.dirName, 'schema.json');
15
+ this.entriesDirPath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(this.entriesConfig.dirName));
16
+ this.localesFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.fileName));
17
+ this.schemaFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.data), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.content_types.dirName), 'schema.json');
17
18
  }
18
19
  async start() {
19
20
  var _a;
@@ -80,7 +81,7 @@ class EntriesExport extends base_class_1.default {
80
81
  .find();
81
82
  if (Array.isArray(entriesSearchResponse.items) && entriesSearchResponse.items.length > 0) {
82
83
  if (options.skip === 0) {
83
- const entryBasePath = path.join(this.entriesDirPath, options.contentType, options.locale);
84
+ const entryBasePath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale));
84
85
  await utils_1.fsUtil.makeDirectory(entryBasePath);
85
86
  this.entriesFileHelper = new cli_utilities_1.FsUtility({
86
87
  moduleName: 'entries',
@@ -93,7 +94,7 @@ class EntriesExport extends base_class_1.default {
93
94
  }
94
95
  this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true });
95
96
  if (this.entriesConfig.exportVersions) {
96
- let versionedEntryPath = path.join(this.entriesDirPath, options.contentType, options.locale, 'versions');
97
+ let versionedEntryPath = path.join((0, cli_utilities_2.sanitizePath)(this.entriesDirPath), (0, cli_utilities_2.sanitizePath)(options.contentType), (0, cli_utilities_2.sanitizePath)(options.locale), 'versions');
97
98
  utils_1.fsUtil.makeDirectory(versionedEntryPath);
98
99
  await this.fetchEntriesVersions(entriesSearchResponse.items, {
99
100
  locale: options.locale,
@@ -110,7 +111,7 @@ class EntriesExport extends base_class_1.default {
110
111
  }
111
112
  async fetchEntriesVersions(entries, options) {
112
113
  const onSuccess = ({ response, apiData: entry }) => {
113
- utils_1.fsUtil.writeFile(path.join(options.versionedEntryPath, `${entry.uid}.json`), response);
114
+ utils_1.fsUtil.writeFile(path.join((0, cli_utilities_2.sanitizePath)(options.versionedEntryPath), (0, cli_utilities_2.sanitizePath)(`${entry.uid}.json`)), response);
114
115
  (0, utils_1.log)(this.exportConfig, `Exported versioned entries of type '${options.contentType}' locale '${options.locale}'`, 'success');
115
116
  };
116
117
  const onReject = ({ error, apiData: { uid } = undefined }) => {
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const path = tslib_1.__importStar(require("path"));
5
5
  const utils_1 = require("../../utils");
6
6
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
7
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
8
  class GlobalFieldsExport extends base_class_1.default {
8
9
  constructor({ exportConfig, stackAPIClient }) {
9
10
  super({ exportConfig, stackAPIClient });
@@ -15,7 +16,7 @@ class GlobalFieldsExport extends base_class_1.default {
15
16
  include_count: true,
16
17
  limit: this.globalFieldsConfig.limit,
17
18
  };
18
- this.globalFieldsDirPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.globalFieldsConfig.dirName);
19
+ this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.globalFieldsConfig.dirName));
19
20
  this.globalFields = [];
20
21
  }
21
22
  async start() {
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const path = tslib_1.__importStar(require("path"));
5
5
  const utils_1 = require("../../utils");
6
6
  const base_class_1 = tslib_1.__importDefault(require("./base-class"));
7
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
7
8
  class LocaleExport extends base_class_1.default {
8
9
  constructor({ exportConfig, stackAPIClient }) {
9
10
  super({ exportConfig, stackAPIClient });
@@ -17,7 +18,7 @@ class LocaleExport extends base_class_1.default {
17
18
  BASE: this.localeConfig.requiredKeys,
18
19
  },
19
20
  };
20
- this.localesPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.localeConfig.dirName);
21
+ this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.localeConfig.dirName));
21
22
  this.locales = {};
22
23
  this.masterLocale = {};
23
24
  }
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const mkdirp = require('mkdirp');
@@ -10,7 +10,7 @@ const Promise = require('bluebird');
10
10
  const _ = require('lodash');
11
11
  const chalk = require('chalk');
12
12
  const progress = require('progress-stream');
13
- const { HttpClient, configHandler } = require('@contentstack/cli-utilities');
13
+ const { HttpClient, configHandler, validateUids, sanitizePath, validateFileName } = require('@contentstack/cli-utilities');
14
14
  const { fileHelper, log, formatError } = require('../../utils');
15
15
  let { default: config } = require('../../config');
16
16
  module.exports = class ExportAssets {
@@ -244,9 +244,11 @@ module.exports = class ExportAssets {
244
244
  return reject(new Error('Asset Max download retry limit exceeded! ' + uid));
245
245
  }
246
246
  if (version <= 0) {
247
- const assetVersionInfoFile = path.resolve(self.assetsFolderPath, uid, '_contentstack_' + uid + '.json');
248
- fileHelper.writeFileSync(assetVersionInfoFile, assetVersionInfo);
249
- return resolve();
247
+ if (validateUids(uid)) {
248
+ const assetVersionInfoFile = path.resolve(sanitizePath(self.assetsFolderPath), sanitizePath(uid), '_contentstack_' + sanitizePath(uid) + '.json');
249
+ fileHelper.writeFileSync(assetVersionInfoFile, assetVersionInfo);
250
+ return resolve();
251
+ }
250
252
  }
251
253
  const queryrequestOption = {
252
254
  version: version,
@@ -286,8 +288,11 @@ module.exports = class ExportAssets {
286
288
  downloadAsset(asset) {
287
289
  const self = this;
288
290
  return new Promise(async (resolve, reject) => {
289
- const assetFolderPath = path.resolve(self.assetsFolderPath, asset.uid);
290
- const assetFilePath = path.resolve(assetFolderPath, asset.filename);
291
+ if (!validateUids(asset.uid) && !validateFileName(asset.filename)) {
292
+ reject(`UIDs not valid`);
293
+ }
294
+ const assetFolderPath = path.resolve(sanitizePath(self.assetsFolderPath), sanitizePath(asset.uid));
295
+ const assetFilePath = path.resolve(sanitizePath(assetFolderPath), sanitizePath(asset.filename));
291
296
  if (fs.existsSync(assetFilePath)) {
292
297
  log(self.config, 'Skipping download of { title: ' + asset.filename + ', uid: ' + asset.uid + ' }, as they already exist', 'success');
293
298
  return resolve();
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const chalk = require('chalk');
3
3
  const { fileHelper, executeTask, formatError, log } = require('../../utils');
4
+ const { sanitizePath } = require('@contentstack/cli-utilities');
4
5
  class ContentTypesExport {
5
6
  constructor(exportConfig, stackAPIClient) {
6
7
  this.stackAPIClient = stackAPIClient;
@@ -16,7 +17,7 @@ class ContentTypesExport {
16
17
  if (Array.isArray(this.exportConfig.contentTypes) && this.exportConfig.contentTypes.length > 0) {
17
18
  this.qs.uid = { $in: this.exportConfig.contentTypes };
18
19
  }
19
- this.contentTypesPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.contentTypesConfig.dirName);
20
+ this.contentTypesPath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName) || '', sanitizePath(this.contentTypesConfig.dirName));
20
21
  this.contentTypes = [];
21
22
  this.fetchConcurrency = this.contentTypesConfig.fetchConcurrency || this.exportConfig.fetchConcurrency;
22
23
  this.writeConcurrency = this.contentTypesConfig.writeConcurrency || this.exportConfig.writeConcurrency;
@@ -66,7 +67,7 @@ class ContentTypesExport {
66
67
  }
67
68
  async writeContentTypes(contentTypes) {
68
69
  function write(contentType) {
69
- return fileHelper.writeFile(path.join(this.contentTypesPath, `${contentType.uid === 'schema' ? 'schema|1' : contentType.uid}.json`), contentType);
70
+ return fileHelper.writeFile(path.join(sanitizePath(this.contentTypesPath), `${sanitizePath(contentType.uid === 'schema' ? 'schema|1' : contentType.uid)}.json`), contentType);
70
71
  }
71
72
  await executeTask(contentTypes, write.bind(this), { concurrency: this.writeConcurrency });
72
73
  return fileHelper.writeFile(path.join(this.contentTypesPath, 'schema.json'), contentTypes);
@@ -2,14 +2,15 @@ const path = require('path');
2
2
  const chalk = require('chalk');
3
3
  const { values } = require('lodash');
4
4
  const { executeTask, formatError, fileHelper, log } = require('../../utils');
5
+ const { sanitizePath } = require('@contentstack/cli-utilities');
5
6
  class EntriesExport {
6
7
  constructor(exportConfig, stackAPIClient) {
7
8
  this.stackAPIClient = stackAPIClient;
8
9
  this.exportConfig = exportConfig;
9
10
  this.entriesConfig = exportConfig.modules.entries;
10
- this.entriesRootPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.entriesConfig.dirName);
11
- this.localesFilePath = path.resolve(exportConfig.data, exportConfig.branchName || '', exportConfig.modules.locales.dirName, exportConfig.modules.locales.fileName);
12
- this.schemaFilePath = path.resolve(exportConfig.data, exportConfig.branchName || '', exportConfig.modules.content_types.dirName, 'schema.json');
11
+ this.entriesRootPath = path.resolve((sanitizePath(exportConfig.data)), sanitizePath(exportConfig.branchName || ''), sanitizePath(this.entriesConfig.dirName));
12
+ this.localesFilePath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''), sanitizePath(exportConfig.modules.locales.dirName), sanitizePath(exportConfig.modules.locales.fileName));
13
+ this.schemaFilePath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''), sanitizePath(exportConfig.modules.content_types.dirName), 'schema.json');
13
14
  this.fetchConcurrency = this.entriesConfig.fetchConcurrency || exportConfig.fetchConcurrency;
14
15
  this.writeConcurrency = this.entriesConfig.writeConcurrency || exportConfig.writeConcurrency;
15
16
  }
@@ -37,7 +38,7 @@ class EntriesExport {
37
38
  let versionedEntryPath = path.join(this.entriesRootPath, requestOption.locale, requestOption.content_type, entry.uid);
38
39
  await fileHelper.makeDirectory(versionedEntryPath);
39
40
  if (versionedEntries.length > 0) {
40
- const write = (versionedEntry) => fileHelper.writeFile(path.join(versionedEntryPath, 'version-' + versionedEntry._version + '.json'), versionedEntry);
41
+ const write = (versionedEntry) => fileHelper.writeFile(path.join(sanitizePath(versionedEntryPath), 'version-' + sanitizePath(versionedEntry._version) + '.json'), versionedEntry);
41
42
  await executeTask(versionedEntries, write.bind(this), { concurrency: this.writeConcurrency });
42
43
  log(this.exportConfig, `Exported versioned entries of type '${requestOption.content_type}' locale '${requestOption.locale}'`, 'success');
43
44
  }
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const mkdirp = require('mkdirp');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -9,6 +9,7 @@ const mkdirp = require('mkdirp');
9
9
  const { merge } = require('lodash');
10
10
  const { formatError, log, fileHelper } = require('../../utils');
11
11
  const { default: config } = require('../../config');
12
+ const { sanitizePath } = require('@contentstack/cli-utilities');
12
13
  module.exports = class ExportGlobalFields {
13
14
  constructor(exportConfig, stackAPIClient) {
14
15
  this.limit = 100;
@@ -29,7 +30,7 @@ module.exports = class ExportGlobalFields {
29
30
  };
30
31
  this.config = merge(config, exportConfig);
31
32
  this.stackAPIClient = stackAPIClient;
32
- this.globalfieldsFolderPath = path.resolve(this.config.data, this.config.branchName || '', this.globalfieldsConfig.dirName);
33
+ this.globalfieldsFolderPath = path.resolve(sanitizePath(this.config.data), sanitizePath(this.config.branchName || ''), sanitizePath(this.globalfieldsConfig.dirName));
33
34
  }
34
35
  start() {
35
36
  const self = this;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const chalk = require('chalk');
3
3
  const { formatError, log, fileHelper } = require('../../utils');
4
+ const { sanitizePath } = require('@contentstack/cli-utilities');
4
5
  class LocaleExport {
5
6
  constructor(exportConfig, stackAPIClient) {
6
7
  this.stackAPIClient = stackAPIClient;
@@ -14,7 +15,7 @@ class LocaleExport {
14
15
  BASE: this.localeConfig.requiredKeys,
15
16
  },
16
17
  };
17
- this.localesPath = path.resolve(exportConfig.data, exportConfig.branchName || '', this.localeConfig.dirName);
18
+ this.localesPath = path.resolve(sanitizePath(exportConfig.data), sanitizePath(exportConfig.branchName || ''), sanitizePath(this.localeConfig.dirName));
18
19
  this.locales = {};
19
20
  this.masterLocale = {};
20
21
  this.fetchConcurrency = this.localeConfig.fetchConcurrency || this.exportConfig.fetchConcurrency;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const _ = require('lodash');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  const path = require('path');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  import { ExternalConfig } from '../types';
@@ -4,7 +4,7 @@
4
4
  /* eslint-disable no-empty */
5
5
  /*!
6
6
  * Contentstack Import
7
- * Copyright (c) 2019 Contentstack LLC
7
+ * Copyright (c) 2024 Contentstack LLC
8
8
  * MIT Licensed
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  import { ExternalConfig, ExportConfig } from '../types';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * Contentstack Export
4
- * Copyright (c) 2019 Contentstack LLC
4
+ * Copyright (c) 2024 Contentstack LLC
5
5
  * MIT Licensed
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,6 +11,7 @@ const promise_limit_1 = tslib_1.__importDefault(require("promise-limit"));
11
11
  const path = tslib_1.__importStar(require("path"));
12
12
  const cli_utilities_1 = require("@contentstack/cli-utilities");
13
13
  const file_helper_1 = require("./file-helper");
14
+ const cli_utilities_2 = require("@contentstack/cli-utilities");
14
15
  const validateConfig = function (config) {
15
16
  if (!config.host || !config.cdn) {
16
17
  throw new Error('Host/CDN end point is missing from config');
@@ -82,8 +83,8 @@ exports.executeTask = executeTask;
82
83
  const writeExportMetaFile = (exportConfig, metaFilePath) => {
83
84
  const exportMeta = {
84
85
  contentVersion: exportConfig.contentVersion,
85
- logsPath: path.join(exportConfig.exportDir, 'logs', 'export'),
86
+ logsPath: path.join((0, cli_utilities_2.sanitizePath)(exportConfig.exportDir), 'logs', 'export'),
86
87
  };
87
- file_helper_1.fsUtil.writeFile(path.join(metaFilePath || exportConfig.exportDir, 'export-info.json'), exportMeta);
88
+ file_helper_1.fsUtil.writeFile(path.join((0, cli_utilities_2.sanitizePath)(metaFilePath || exportConfig.exportDir), 'export-info.json'), exportMeta);
88
89
  };
89
90
  exports.writeExportMetaFile = writeExportMetaFile;
@@ -10,7 +10,7 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
10
10
  const readFileSync = function (filePath, parse) {
11
11
  let data;
12
12
  parse = typeof parse === 'undefined' ? true : parse;
13
- filePath = path.resolve(filePath);
13
+ filePath = path.resolve((0, cli_utilities_1.sanitizePath)(filePath));
14
14
  if (fs.existsSync(filePath)) {
15
15
  data = parse ? JSON.parse(fs.readFileSync(filePath, 'utf8')) : data;
16
16
  }
@@ -20,7 +20,7 @@ exports.readFileSync = readFileSync;
20
20
  // by default file type is json
21
21
  const readFile = async (filePath, options = { type: 'json' }) => {
22
22
  return new Promise((resolve, reject) => {
23
- filePath = path.resolve(filePath);
23
+ filePath = path.resolve((0, cli_utilities_1.sanitizePath)(filePath));
24
24
  fs.readFile(filePath, 'utf-8', (error, data) => {
25
25
  if (error) {
26
26
  reject(error);
@@ -39,7 +39,7 @@ const readLargeFile = function (filePath, options = {}) {
39
39
  if (typeof filePath !== 'string') {
40
40
  return;
41
41
  }
42
- filePath = path.resolve(filePath);
42
+ filePath = path.resolve((0, cli_utilities_1.sanitizePath)(filePath));
43
43
  if (fs.existsSync(filePath)) {
44
44
  return new Promise((resolve, reject) => {
45
45
  const readStream = fs.createReadStream(filePath, { encoding: 'utf-8' });
@@ -80,7 +80,7 @@ const writeLargeFile = function (filePath, data) {
80
80
  if (typeof filePath !== 'string' || typeof data !== 'object') {
81
81
  return;
82
82
  }
83
- filePath = path.resolve(filePath);
83
+ filePath = path.resolve((0, cli_utilities_1.sanitizePath)(filePath));
84
84
  return new Promise((resolve, reject) => {
85
85
  const stringifyStream = big_json_1.default.createStringifyStream({
86
86
  body: data,
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Contentstack Export
3
- * Copyright (c) 2019 Contentstack LLC
3
+ * Copyright (c) 2024 Contentstack LLC
4
4
  * MIT Licensed
5
5
  */
6
6
  import { ExportConfig } from '../types';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * Contentstack Export
4
- * Copyright (c) 2019 Contentstack LLC
4
+ * Copyright (c) 2024 Contentstack LLC
5
5
  * MIT Licensed
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,6 +10,7 @@ const tslib_1 = require("tslib");
10
10
  const winston = tslib_1.__importStar(require("winston"));
11
11
  const path = tslib_1.__importStar(require("path"));
12
12
  const mkdirp_1 = tslib_1.__importDefault(require("mkdirp"));
13
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
13
14
  const slice = Array.prototype.slice;
14
15
  const ansiRegexPattern = [
15
16
  '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
@@ -55,18 +56,18 @@ let successTransport;
55
56
  let errorTransport;
56
57
  function init(_logPath) {
57
58
  if (!logger || !errorLogger) {
58
- const logsDir = path.resolve(_logPath, 'logs', 'export');
59
+ const logsDir = path.resolve((0, cli_utilities_1.sanitizePath)(_logPath), 'logs', 'export');
59
60
  // Create dir if doesn't already exist
60
61
  mkdirp_1.default.sync(logsDir);
61
62
  successTransport = {
62
- filename: path.join(logsDir, 'success.log'),
63
+ filename: path.join((0, cli_utilities_1.sanitizePath)(logsDir), 'success.log'),
63
64
  maxFiles: 20,
64
65
  maxsize: 1000000,
65
66
  tailable: true,
66
67
  level: 'info',
67
68
  };
68
69
  errorTransport = {
69
- filename: path.join(logsDir, 'error.log'),
70
+ filename: path.join((0, cli_utilities_1.sanitizePath)(logsDir), 'error.log'),
70
71
  maxFiles: 20,
71
72
  maxsize: 1000000,
72
73
  tailable: true,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const path = tslib_1.__importStar(require("path"));
5
5
  const file_helper_1 = require("./file-helper");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
7
  const setupBranches = async (config, stackAPIClient) => {
7
8
  if (typeof config !== 'object') {
8
9
  throw new Error('Invalid config to setup the branch');
@@ -42,7 +43,7 @@ const setupBranches = async (config, stackAPIClient) => {
42
43
  }
43
44
  (0, file_helper_1.makeDirectory)(config.exportDir);
44
45
  // create branch info file
45
- (0, file_helper_1.writeFileSync)(path.join(config.exportDir, 'branches.json'), branches);
46
+ (0, file_helper_1.writeFileSync)(path.join((0, cli_utilities_1.sanitizePath)(config.exportDir), 'branches.json'), branches);
46
47
  // add branches list in the
47
48
  config.branches = branches;
48
49
  };
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const path_1 = tslib_1.__importDefault(require("path"));
5
5
  const file_helper_1 = require("./file-helper");
6
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
6
7
  async function setupExportDir(exportConfig) {
7
8
  (0, file_helper_1.makeDirectory)(exportConfig.exportDir);
8
9
  if (exportConfig.branches) {
9
- return Promise.all(exportConfig.branches.map((branch) => (0, file_helper_1.makeDirectory)(path_1.default.join(exportConfig.exportDir, branch.uid))));
10
+ return Promise.all(exportConfig.branches.map((branch) => (0, file_helper_1.makeDirectory)(path_1.default.join((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(branch.uid)))));
10
11
  }
11
12
  }
12
13
  exports.default = setupExportDir;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.2",
2
+ "version": "1.11.4",
3
3
  "commands": {
4
4
  "cm:stacks:export": {
5
5
  "id": "cm:stacks:export",
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export",
3
3
  "description": "Contentstack CLI plugin to export content from stack",
4
- "version": "1.11.2",
4
+ "version": "1.11.4",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.2.16",
9
- "@contentstack/cli-utilities": "~1.6.0",
10
- "@oclif/core": "^2.9.3",
8
+ "@contentstack/cli-command": "~1.2.18",
9
+ "@contentstack/cli-utilities": "~1.6.2",
10
+ "@oclif/core": "^3.26.5",
11
11
  "async": "^3.2.4",
12
12
  "big-json": "^3.2.0",
13
13
  "bluebird": "^3.7.2",
@@ -24,8 +24,8 @@
24
24
  "winston": "^3.7.2"
25
25
  },
26
26
  "devDependencies": {
27
- "@contentstack/cli-auth": "~1.3.17",
28
- "@contentstack/cli-config": "~1.6.1",
27
+ "@contentstack/cli-auth": "~1.3.18",
28
+ "@contentstack/cli-config": "~1.6.4",
29
29
  "@contentstack/cli-dev-dependencies": "~1.2.4",
30
30
  "@oclif/plugin-help": "^5.1.19",
31
31
  "@oclif/test": "^2.5.6",