@contentstack/cli-migration 1.6.3 → 1.6.5

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.6.3 darwin-arm64 node-v22.8.0
24
+ @contentstack/cli-migration/1.6.5 darwin-arm64 node-v22.2.0
25
25
  $ csdx --help [COMMAND]
26
26
  USAGE
27
27
  $ csdx COMMAND
@@ -45,14 +45,18 @@ USAGE
45
45
  [--config <value>] [--multiple]
46
46
 
47
47
  FLAGS
48
- -B, --branch=<value> Use this flag to add the branch name where you want to perform the migration.
49
- -a, --alias=<value> Use this flag to add the management token alias.
50
- -k, --stack-api-key=<value> With this flag add the API key of your stack.
51
- --config=<value>... [optional] inline configuration, <key1>:<value1>
52
- --config-file=<value> [optional] Path of the JSON configuration file
53
- --file-path=<value> Use this flag to provide the path of the file of the migration script provided by the
54
- user.
55
- --multiple This flag helps you to migrate multiple content files in a single instance.
48
+ -B, --branch=<value> Use this flag to add the branch name where you want to perform the migration. (target
49
+ branch name)
50
+ -a, --alias=<value> Use this flag to add the management token alias. You must use either the --alias flag or
51
+ the --stack-api-key flag.
52
+ -k, --stack-api-key=<value> Use this flag to add the API key of your stack. You must use either the --stack-api-key
53
+ flag or the --alias flag.
54
+ --config=<value>... [optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes
55
+ the script re-usable.
56
+ --config-file=<value> [optional] Path of the JSON configuration file.
57
+ --file-path=<value> Use this flag to provide the path of the file of the migration script.
58
+ --multiple This flag helps you to migrate multiple content files in a single instance. Mention the
59
+ folder path where your migration script files are stored.
56
60
 
57
61
  DESCRIPTION
58
62
  Contentstack migration script.
@@ -84,14 +88,18 @@ USAGE
84
88
  [--config <value>] [--multiple]
85
89
 
86
90
  FLAGS
87
- -B, --branch=<value> Use this flag to add the branch name where you want to perform the migration.
88
- -a, --alias=<value> Use this flag to add the management token alias.
89
- -k, --stack-api-key=<value> With this flag add the API key of your stack.
90
- --config=<value>... [optional] inline configuration, <key1>:<value1>
91
- --config-file=<value> [optional] Path of the JSON configuration file
92
- --file-path=<value> Use this flag to provide the path of the file of the migration script provided by the
93
- user.
94
- --multiple This flag helps you to migrate multiple content files in a single instance.
91
+ -B, --branch=<value> Use this flag to add the branch name where you want to perform the migration. (target
92
+ branch name)
93
+ -a, --alias=<value> Use this flag to add the management token alias. You must use either the --alias flag or
94
+ the --stack-api-key flag.
95
+ -k, --stack-api-key=<value> Use this flag to add the API key of your stack. You must use either the --stack-api-key
96
+ flag or the --alias flag.
97
+ --config=<value>... [optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes
98
+ the script re-usable.
99
+ --config-file=<value> [optional] Path of the JSON configuration file.
100
+ --file-path=<value> Use this flag to provide the path of the file of the migration script.
101
+ --multiple This flag helps you to migrate multiple content files in a single instance. Mention the
102
+ folder path where your migration script files are stored.
95
103
 
96
104
  DESCRIPTION
97
105
  Contentstack migration script.
package/package.json CHANGED
@@ -1,32 +1,27 @@
1
1
  {
2
2
  "name": "@contentstack/cli-migration",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "author": "@contentstack",
5
5
  "bugs": "https://github.com/contentstack/cli/issues",
6
6
  "dependencies": {
7
- "@contentstack/cli-command": "~1.3.2",
8
- "@contentstack/cli-utilities": "~1.8.0",
7
+ "@contentstack/cli-command": "~1.3.3",
8
+ "@contentstack/cli-utilities": "~1.8.1",
9
9
  "async": "^3.2.6",
10
10
  "callsites": "^3.1.0",
11
11
  "cardinal": "^2.1.1",
12
- "chalk": "^4.1.0",
13
- "dot-object": "^2.1.5",
14
- "dotenv": "^16.4.5",
12
+ "chalk": "^4.1.2",
13
+ "concat-stream": "^2.0.0",
15
14
  "listr": "^0.14.3",
16
- "winston": "^3.15.0"
15
+ "winston": "^3.17.0"
17
16
  },
18
17
  "devDependencies": {
19
- "@oclif/test": "^2.5.6",
18
+ "@oclif/test": "^4.1.6",
20
19
  "chai": "^4.5.0",
21
- "eslint": "^8.18.0",
22
- "globby": "^10.0.2",
23
- "husky": "^8.0.3",
24
- "jsdoc": "^4.0.3",
20
+ "eslint": "^8.57.1",
25
21
  "jsdoc-to-markdown": "^8.0.3",
26
- "mkdirp": "^1.0.4",
27
- "nock": "^13.5.5",
22
+ "nock": "^13.5.6",
28
23
  "nyc": "^15.1.0",
29
- "oclif": "^3.11.3"
24
+ "oclif": "^3.17.2"
30
25
  },
31
26
  "engines": {
32
27
  "node": ">=8.3.0"
@@ -246,33 +246,33 @@ MigrationCommand.description = 'Contentstack migration script.';
246
246
  MigrationCommand.flags = {
247
247
  'stack-api-key': flags.string({
248
248
  char: 'k',
249
- description: 'With this flag add the API key of your stack.',
249
+ description: 'Use this flag to add the API key of your stack. You must use either the --stack-api-key flag or the --alias flag.',
250
250
  exclusive: ['alias'],
251
251
  }),
252
252
  alias: flags.string({
253
253
  char: 'a',
254
- description: 'Use this flag to add the management token alias.',
254
+ description: 'Use this flag to add the management token alias. You must use either the --alias flag or the --stack-api-key flag.',
255
255
  }),
256
256
  'file-path': flags.string({
257
- description: 'Use this flag to provide the path of the file of the migration script provided by the user.',
257
+ description: 'Use this flag to provide the path of the file of the migration script.',
258
258
  }),
259
259
  branch: flags.string({
260
260
  char: 'B',
261
- description: 'Use this flag to add the branch name where you want to perform the migration.',
261
+ description: 'Use this flag to add the branch name where you want to perform the migration. (target branch name)',
262
262
  parse: printFlagDeprecation(['-B'], ['--branch']),
263
263
  }),
264
264
  'config-file': flags.string({
265
- description: '[optional] Path of the JSON configuration file',
265
+ description: '[optional] Path of the JSON configuration file.',
266
266
  }),
267
267
  config: flags.string({
268
- description: '[optional] inline configuration, <key1>:<value1>',
268
+ description: '[optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes the script re-usable.',
269
269
  multiple: true,
270
270
  }),
271
271
  multiple: flags.boolean({
272
- description: 'This flag helps you to migrate multiple content files in a single instance.',
272
+ description: 'This flag helps you to migrate multiple content files in a single instance. Mention the folder path where your migration script files are stored.',
273
273
  }),
274
274
 
275
- //To be deprecated
275
+ // To be deprecated
276
276
  'api-key': flags.string({
277
277
  char: 'k',
278
278
  description: 'With this flag add the API key of your stack.',
@@ -283,15 +283,14 @@ MigrationCommand.flags = {
283
283
  }),
284
284
  authtoken: flags.boolean({
285
285
  char: 'A',
286
- description:
287
- 'Use this flag to use the auth token of the current session. After logging in CLI, an auth token is generated for each new session.',
286
+ description: 'Use this flag to use the auth token of the current session. After logging in CLI, an auth token is generated for each new session.',
288
287
  dependsOn: ['api-key'],
289
288
  exclusive: ['alias'],
290
289
  parse: printFlagDeprecation(['-A', '--authtoken']),
291
290
  hidden: true,
292
291
  }),
293
292
  'management-token-alias': flags.string({
294
- description: 'alias of the management token',
293
+ description: 'Alias of the management token.',
295
294
  exclusive: ['authtoken'],
296
295
  hidden: true,
297
296
  parse: printFlagDeprecation(['--management-token-alias'], ['-a', '--alias']),
@@ -1,5 +1,5 @@
1
1
  const fs = require('fs');
2
- const { execFileSync } = require('child_process');
2
+ const { spawnSync } = require('child_process');
3
3
  const path = require('path');
4
4
  const { sanitizePath } = require('@contentstack/cli-utilities');
5
5
  const os = require('os');
@@ -61,27 +61,22 @@ function installDependencies(dependencies, directory) {
61
61
  if (!internalModules.has(dep)) {
62
62
  const pkg = dep.startsWith('@') ? dep : dep.split('/')[0];
63
63
  if (!installedDependencies.has(pkg)) {
64
- executeShellCommand(`npm i ${pkg}`, directory);
64
+ executeShellCommand(pkg, directory);
65
65
  installedDependencies.add(pkg);
66
66
  }
67
67
  }
68
68
  });
69
69
  }
70
70
 
71
- function executeShellCommand(command, directory = '') {
71
+ function executeShellCommand(pkg, directory = '') {
72
72
  try {
73
- if (command.startsWith('npm i')) {
74
- const [cmd, ...args] = command.split(' ');
75
- execFileSync(cmd, args, { stdio: 'inherit', cwd: directory });
76
- console.log(`Command executed successfully: ${command}`);
77
- } else {
78
- console.log(`Command should only be 'npm i <package-name>'`);
79
- }
73
+ const result = spawnSync(`npm`, ['i', pkg], { stdio: 'inherit', cwd: directory, shell: false });
74
+ if (result?.error) throw result.error;
75
+ console.log(`Command executed successfully: ${command}`);
80
76
  } catch (error) {
81
- console.error(`Command execution failed. Error: ${error.message}`);
77
+ console.error(`Command execution failed. Error: ${error?.message}`);
82
78
  }
83
79
  }
84
-
85
80
  async function installModules(filePath, multiple) {
86
81
  const files = multiple ? [] : [path.basename(filePath)];
87
82
  const dirPath = multiple ? filePath : path.dirname(filePath);