@contentstack/cli-migration 1.5.4 → 1.5.6

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
@@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration
21
21
  $ csdx COMMAND
22
22
  running command...
23
23
  $ csdx (--version)
24
- @contentstack/cli-migration/1.5.1 darwin-arm64 node-v20.8.0
24
+ @contentstack/cli-migration/1.5.6 darwin-arm64 node-v21.6.2
25
25
  $ csdx --help [COMMAND]
26
26
  USAGE
27
27
  $ csdx COMMAND
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@contentstack/cli-migration",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "author": "@contentstack",
5
5
  "bugs": "https://github.com/contentstack/cli/issues",
6
6
  "dependencies": {
7
- "@contentstack/cli-command": "~1.2.16",
8
- "@contentstack/cli-utilities": "~1.6.0",
7
+ "@contentstack/cli-command": "~1.2.18",
8
+ "@contentstack/cli-utilities": "~1.6.2",
9
9
  "async": "^3.2.4",
10
10
  "callsites": "^3.1.0",
11
11
  "cardinal": "^2.1.1",
@@ -19,6 +19,7 @@ const {
19
19
  flags,
20
20
  isAuthenticated,
21
21
  pathValidator,
22
+ sanitizePath,
22
23
  } = require('@contentstack/cli-utilities');
23
24
 
24
25
  const { ApiError, SchemaValidator, MigrationError, FieldValidator } = require('../../../validators');
@@ -180,7 +181,7 @@ class MigrationCommand extends Command {
180
181
  const file = element;
181
182
  if (extname(file) === '.js') {
182
183
  // eslint-disable-next-line no-await-in-loop
183
- await this.execSingleFile(pathValidator(resolve(filePath, file)), mapInstance);
184
+ await this.execSingleFile(pathValidator(resolve(sanitizePath(filePath), sanitizePath(file))), mapInstance);
184
185
  }
185
186
  }
186
187
  } catch (error) {
@@ -2,10 +2,10 @@
2
2
 
3
3
  const getCallsites = require('callsites');
4
4
  const { parse, resolve } = require('path');
5
- const { pathValidator } = require('@contentstack/cli-utilities');
5
+ const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities');
6
6
 
7
7
  function getFileDirectory(path) {
8
- const parentPath = pathValidator(resolve(path, '../')); // Assuming that will be 2 folders up
8
+ const parentPath = pathValidator(resolve(sanitizePath(path), '../')); // Assuming that will be 2 folders up
9
9
  return parse(parentPath).dir;
10
10
  }
11
11
 
@@ -4,7 +4,7 @@ const { createLogger, format, transports } = require('winston');
4
4
  const { resolve, join } = require('path');
5
5
  const { slice } = Array.prototype;
6
6
  const { stringify } = JSON;
7
- const { pathValidator } = require('@contentstack/cli-utilities');
7
+ const { pathValidator, sanitizePath } = require('@contentstack/cli-utilities');
8
8
 
9
9
  const { combine, label, printf, colorize } = format;
10
10
 
@@ -33,7 +33,7 @@ function init(logFileName) {
33
33
  // Create dir if does not exist
34
34
  makeDir(logsDir);
35
35
 
36
- const logPath = pathValidator(join(logsDir, logFileName + '.log'));
36
+ const logPath = pathValidator(join(sanitizePath(logsDir), sanitizePath(logFileName) + '.log'));
37
37
  const logger = createLogger({
38
38
  format: combine(colorize(), label({ label: 'Migration' }), customFormat),
39
39
  transports: [new transports.File({ filename: logPath })],
@@ -1,14 +1,15 @@
1
1
  const winston = require('winston');
2
2
  const path = require('path');
3
+ const { sanitizePath } = require('@contentstack/cli-utilities');
3
4
  module.exports = class MigrationLogger {
4
5
  constructor(filePath) {
5
- this.filePath = path.join(filePath, 'migration-logs');
6
+ this.filePath = path.join(sanitizePath(filePath), 'migration-logs');
6
7
  this.logger = winston.createLogger({
7
8
  levels: { error: 1 },
8
9
  transports: [
9
10
  new winston.transports.File({
10
11
  level: 'error',
11
- filename: path.join(this.filePath, 'error.logs'),
12
+ filename: path.join(sanitizePath(this.filePath), 'error.logs'),
12
13
  format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
13
14
  }),
14
15
  ],