@contentstack/cli-migration 2.0.0-beta → 2.0.0-beta.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Contentstack
3
+ Copyright (c) 2026 Contentstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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/2.0.0-beta darwin-arm64 node-v22.14.0
24
+ @contentstack/cli-migration/2.0.0-beta.1 darwin-arm64 node-v24.12.0
25
25
  $ csdx --help [COMMAND]
26
26
  USAGE
27
27
  $ csdx COMMAND
@@ -33,50 +33,6 @@ USAGE
33
33
 
34
34
  <!-- commands -->
35
35
  * [`csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]`](#csdx-cmstacksmigration--k-value--a-value---file-path-value---branch-value---config-file-value---config-value---multiple)
36
- * [`csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]`](#csdx-cmstacksmigration--k-value--a-value---file-path-value---branch-value---config-file-value---config-value---multiple)
37
-
38
- ## `csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]`
39
-
40
- Contentstack migration script.
41
-
42
- ```
43
- USAGE
44
- $ csdx cm:migration cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>]
45
- [--config-file <value>] [--config <value>] [--multiple]
46
-
47
- FLAGS
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.
60
-
61
- DESCRIPTION
62
- Contentstack migration script.
63
-
64
- ALIASES
65
- $ csdx cm:migration
66
-
67
- EXAMPLES
68
- $ csdx cm:migration --file-path <migration/script/file/path> -k <api-key>
69
-
70
- $ csdx cm:migration --file-path <migration/script/file/path> -k <api-key> --branch <target branch name>
71
-
72
- $ csdx cm:migration --config <key1>:<value1> <key2>:<value2> ... --file-path <migration/script/file/path>
73
-
74
- $ csdx cm:migration --config-file <path/to/json/config/file> --file-path <migration/script/file/path>
75
-
76
- $ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
77
-
78
- $ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>
79
- ```
80
36
 
81
37
  ## `csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]`
82
38
 
@@ -88,12 +44,12 @@ USAGE
88
44
  [--config <value>] [--multiple]
89
45
 
90
46
  FLAGS
91
- -B, --branch=<value> Use this flag to add the branch name where you want to perform the migration. (target
92
- branch name)
93
47
  -a, --alias=<value> Use this flag to add the management token alias. You must use either the --alias flag or
94
48
  the --stack-api-key flag.
95
49
  -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
50
  flag or the --alias flag.
51
+ --branch=<value> Use this flag to add the branch name where you want to perform the migration. (target
52
+ branch name)
97
53
  --config=<value>... [optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes
98
54
  the script re-usable.
99
55
  --config-file=<value> [optional] Path of the JSON configuration file.
@@ -104,13 +60,10 @@ FLAGS
104
60
  DESCRIPTION
105
61
  Contentstack migration script.
106
62
 
107
- ALIASES
108
- $ csdx cm:migration
109
-
110
63
  EXAMPLES
111
- $ csdx cm:migration --file-path <migration/script/file/path> -k <api-key>
64
+ $ csdx cm:migration --file-path <migration/script/file/path> --stack-api-key <stack-api-key>
112
65
 
113
- $ csdx cm:migration --file-path <migration/script/file/path> -k <api-key> --branch <target branch name>
66
+ $ csdx cm:migration --file-path <migration/script/file/path> --stack-api-key <stack-api-key> --branch <target branch name>
114
67
 
115
68
  $ csdx cm:migration --config <key1>:<value1> <key2>:<value2> ... --file-path <migration/script/file/path>
116
69
 
@@ -118,7 +71,7 @@ EXAMPLES
118
71
 
119
72
  $ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
120
73
 
121
- $ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>
74
+ $ csdx cm:migration --alias <management-token-alias> --file-path <migration/script/file/path>
122
75
  ```
123
76
 
124
77
  _See code: [src/commands/cm/stacks/migration.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-migration/src/commands/cm/stacks/migration.js)_
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@contentstack/cli-migration",
3
- "version": "2.0.0-beta",
3
+ "version": "2.0.0-beta.2",
4
4
  "author": "@contentstack",
5
5
  "bugs": "https://github.com/contentstack/cli/issues",
6
6
  "dependencies": {
7
- "@contentstack/cli-command": "~1.6.1",
8
- "@contentstack/cli-utilities": "~1.15.0",
7
+ "@contentstack/cli-command": "~1.7.02",
8
+ "@contentstack/cli-utilities": "~1.17.0",
9
9
  "@oclif/core": "^4.3.0",
10
10
  "@oclif/plugin-help": "^6.2.28",
11
11
  "async": "^3.2.6",
@@ -22,9 +22,12 @@
22
22
  "eslint": "^8.57.1",
23
23
  "eslint-config-oclif": "^6.0.62",
24
24
  "jsdoc-to-markdown": "^8.0.3",
25
+ "mocha": "^10.8.2",
25
26
  "nock": "^13.5.6",
26
27
  "nyc": "^15.1.0",
27
- "oclif": "^4.17.46"
28
+ "oclif": "^4.17.46",
29
+ "sinon": "^19.0.5",
30
+ "sinon-chai": "^3.7.0"
28
31
  },
29
32
  "engines": {
30
33
  "node": ">=8.3.0"
@@ -55,12 +58,8 @@
55
58
  "clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
56
59
  },
57
60
  "csdxConfig": {
58
- "expiredCommands": {
59
- "cm:migration": "csdx cm:stacks:migration"
60
- },
61
61
  "shortCommandName": {
62
- "cm:stacks:migration": "MGRTN",
63
- "cm:migration": "O-MGRTN"
62
+ "cm:stacks:migration": "MGRTN"
64
63
  }
65
64
  }
66
65
  }
@@ -14,7 +14,6 @@ const fs = require('fs');
14
14
  const chalk = require('chalk');
15
15
  const isEmpty = require('lodash/isEmpty');
16
16
  const {
17
- printFlagDeprecation,
18
17
  managementSDKClient,
19
18
  flags,
20
19
  isAuthenticated,
@@ -41,12 +40,12 @@ const {
41
40
 
42
41
  class MigrationCommand extends Command {
43
42
  static examples = [
44
- '$ csdx cm:migration --file-path <migration/script/file/path> -k <api-key>',
45
- '$ csdx cm:migration --file-path <migration/script/file/path> -k <api-key> --branch <target branch name>',
43
+ '$ csdx cm:migration --file-path <migration/script/file/path> --stack-api-key <stack-api-key>',
44
+ '$ csdx cm:migration --file-path <migration/script/file/path> --stack-api-key <stack-api-key> --branch <target branch name>',
46
45
  '$ csdx cm:migration --config <key1>:<value1> <key2>:<value2> ... --file-path <migration/script/file/path>',
47
46
  '$ csdx cm:migration --config-file <path/to/json/config/file> --file-path <migration/script/file/path>',
48
47
  '$ csdx cm:migration --multiple --file-path <migration/scripts/dir/path> ',
49
- '$ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>',
48
+ '$ csdx cm:migration --alias <management-token-alias> --file-path <migration/script/file/path>',
50
49
  ];
51
50
 
52
51
  async run() {
@@ -246,69 +245,37 @@ MigrationCommand.description = 'Contentstack migration script.';
246
245
  MigrationCommand.flags = {
247
246
  'stack-api-key': flags.string({
248
247
  char: 'k',
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.',
248
+ description:
249
+ '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. You must use either the --alias flag or the --stack-api-key flag.',
254
+ description:
255
+ 'Use this flag to add the management token alias. You must use either the --alias flag or the --stack-api-key flag.',
256
+ exclusive: ['stack-api-key'],
255
257
  }),
256
258
  'file-path': flags.string({
257
259
  description: 'Use this flag to provide the path of the file of the migration script.',
258
260
  }),
259
261
  branch: flags.string({
260
- char: 'B',
261
262
  description: 'Use this flag to add the branch name where you want to perform the migration. (target branch name)',
262
- parse: printFlagDeprecation(['-B'], ['--branch']),
263
263
  }),
264
264
  'config-file': flags.string({
265
265
  description: '[optional] Path of the JSON configuration file.',
266
266
  }),
267
267
  config: flags.string({
268
- description: '[optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes the script re-usable.',
268
+ description:
269
+ '[optional] Inline configuration, <key1>:<value1>. Passing an external configuration makes the script re-usable.',
269
270
  multiple: true,
270
271
  }),
271
272
  multiple: flags.boolean({
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
- }),
274
-
275
- // To be deprecated
276
- 'api-key': flags.string({
277
- char: 'k',
278
- description: 'With this flag add the API key of your stack.',
279
- // dependsOn: ['authtoken'],
280
- exclusive: ['alias'],
281
- parse: printFlagDeprecation(['--api-key'], ['-k', '--stack-api-key']),
282
- hidden: true,
283
- }),
284
- authtoken: flags.boolean({
285
- char: 'A',
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.',
287
- dependsOn: ['api-key'],
288
- exclusive: ['alias'],
289
- parse: printFlagDeprecation(['-A', '--authtoken']),
290
- hidden: true,
291
- }),
292
- 'management-token-alias': flags.string({
293
- description: 'Alias of the management token.',
294
- exclusive: ['authtoken'],
295
- hidden: true,
296
- parse: printFlagDeprecation(['--management-token-alias'], ['-a', '--alias']),
297
- }),
298
- filePath: flags.string({
299
- char: 'n',
300
- description: 'Use this flag to provide the path of the file of the migration script provided by the user.',
301
- parse: printFlagDeprecation(['-n', '--filePath'], ['--file-path']),
302
- hidden: true,
303
- }),
304
- multi: flags.boolean({
305
- description: 'This flag helps you to migrate multiple content files in a single instance.',
306
- parse: printFlagDeprecation(['--multi'], ['--multiple']),
307
- hidden: true,
273
+ description:
274
+ 'This flag helps you to migrate multiple content files in a single instance. Mention the folder path where your migration script files are stored.',
308
275
  }),
309
276
  };
310
277
 
311
- MigrationCommand.aliases = ['cm:migration'];
278
+ MigrationCommand.aliases = [];
312
279
 
313
280
  MigrationCommand.usage =
314
281
  'cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [--config-file <value>] [--config <value>] [--multiple]';
@@ -59,9 +59,9 @@ class Field extends Base {
59
59
  * .data_type('text')
60
60
  * .mandatory(false);
61
61
  * };
62
- *
62
+ *
63
63
  * Create a taxonomy field
64
- *
64
+ *
65
65
  * module.exports =({ migration })=> {
66
66
  * const blog = migration.editContentType('blog');
67
67
  *
@@ -333,6 +333,7 @@ class Field extends Base {
333
333
  allKeys.forEach((_key) => {
334
334
  this.buildSchema(_key, field, opts[_key]);
335
335
  });
336
+ return this;
336
337
  }
337
338
  }
338
339