@contentstack/cli-cm-import 1.19.2 → 1.19.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  It is Contentstack’s CLI plugin to import content in the stack. To learn how to export and import content in Contentstack, refer to the [Migration guide](https://www.contentstack.com/docs/developers/cli/migration/).
4
4
 
5
- [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)it -m
5
+ [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)it -m
6
6
 
7
7
  <!-- toc -->
8
8
  * [Usage](#usage)
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import/1.19.2 linux-x64 node-v18.20.4
50
+ @contentstack/cli-cm-import/1.19.4 linux-x64 node-v18.20.6
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -71,21 +71,32 @@ USAGE
71
71
  [--branch <value>] [--import-webhook-status disable|current]
72
72
 
73
73
  FLAGS
74
- -B, --branch=<value> [optional] branch name
75
- -a, --alias=<value> alias of the management token
76
- -b, --backup-dir=<value> [optional] backup directory name when using specific module
77
- -c, --config=<value> [optional] path of config file
78
- -d, --data-dir=<value> path and location where data is stored
79
- -k, --stack-api-key=<value> API key of the target stack
80
- -m, --module=<value> [optional] specific module name
81
- -y, --yes [optional] Override marketplace prompts
82
- --exclude-global-modules Excludes the branch-independent module from the import operation
83
- --import-webhook-status=<option> [default: disable] [optional] Webhook state
74
+ -B, --branch=<value> The name of the branch where you want to import your content. If you don't mention
75
+ the branch name, then by default the content will be imported to the main branch.
76
+ -a, --alias=<value> The management token of the destination stack where you will import the content.
77
+ -b, --backup-dir=<value> [optional] Backup directory name when using specific module.
78
+ -c, --config=<value> [optional] The path of the configuration JSON file containing all the options for
79
+ a single run.
80
+ -d, --data-dir=<value> The path or the location in your file system where the content, you intend to
81
+ import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
82
+ export folder has branches involved, then the path should point till the
83
+ particular branch. For example, “-d
84
+ "C:\Users\Name\Desktop\cli\content\branch_name"
85
+ -k, --stack-api-key=<value> API Key of the target stack
86
+ -m, --module=<value> [optional] Specify the module to import into the target stack. If not specified,
87
+ the import command will import all the modules into the stack. The available
88
+ modules are assets, content-types, entries, environments, extensions,
89
+ marketplace-apps, global-fields, labels, locales, webhooks, workflows,
90
+ custom-roles, and taxonomies.
91
+ -y, --yes [optional] Force override all Marketplace prompts.
92
+ --exclude-global-modules Excludes the branch-independent module from the import operation.
93
+ --import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the same
94
+ state of webhooks as the source stack. <options: disable|current>
84
95
  <options: disable|current>
85
- --personalize-project-name=<value> Personalize project name.
96
+ --personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
86
97
  --replace-existing Replaces the existing module in the target stack.
87
- --skip-app-recreation [optional] Skip private apps recreation if already exist
88
- --skip-audit Skips the audit fix.
98
+ --skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
99
+ --skip-audit Skips the audit fix that occurs during an import operation.
89
100
  --skip-existing Skips the module exists warning messages.
90
101
 
91
102
  DESCRIPTION
@@ -122,21 +133,32 @@ USAGE
122
133
  [--branch <value>] [--import-webhook-status disable|current]
123
134
 
124
135
  FLAGS
125
- -B, --branch=<value> [optional] branch name
126
- -a, --alias=<value> alias of the management token
127
- -b, --backup-dir=<value> [optional] backup directory name when using specific module
128
- -c, --config=<value> [optional] path of config file
129
- -d, --data-dir=<value> path and location where data is stored
130
- -k, --stack-api-key=<value> API key of the target stack
131
- -m, --module=<value> [optional] specific module name
132
- -y, --yes [optional] Override marketplace prompts
133
- --exclude-global-modules Excludes the branch-independent module from the import operation
134
- --import-webhook-status=<option> [default: disable] [optional] Webhook state
136
+ -B, --branch=<value> The name of the branch where you want to import your content. If you don't mention
137
+ the branch name, then by default the content will be imported to the main branch.
138
+ -a, --alias=<value> The management token of the destination stack where you will import the content.
139
+ -b, --backup-dir=<value> [optional] Backup directory name when using specific module.
140
+ -c, --config=<value> [optional] The path of the configuration JSON file containing all the options for
141
+ a single run.
142
+ -d, --data-dir=<value> The path or the location in your file system where the content, you intend to
143
+ import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
144
+ export folder has branches involved, then the path should point till the
145
+ particular branch. For example, “-d
146
+ "C:\Users\Name\Desktop\cli\content\branch_name"
147
+ -k, --stack-api-key=<value> API Key of the target stack
148
+ -m, --module=<value> [optional] Specify the module to import into the target stack. If not specified,
149
+ the import command will import all the modules into the stack. The available
150
+ modules are assets, content-types, entries, environments, extensions,
151
+ marketplace-apps, global-fields, labels, locales, webhooks, workflows,
152
+ custom-roles, and taxonomies.
153
+ -y, --yes [optional] Force override all Marketplace prompts.
154
+ --exclude-global-modules Excludes the branch-independent module from the import operation.
155
+ --import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the same
156
+ state of webhooks as the source stack. <options: disable|current>
135
157
  <options: disable|current>
136
- --personalize-project-name=<value> Personalize project name.
158
+ --personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
137
159
  --replace-existing Replaces the existing module in the target stack.
138
- --skip-app-recreation [optional] Skip private apps recreation if already exist
139
- --skip-audit Skips the audit fix.
160
+ --skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
161
+ --skip-audit Skips the audit fix that occurs during an import operation.
140
162
  --skip-existing Skips the module exists warning messages.
141
163
 
142
164
  DESCRIPTION
@@ -55,17 +55,17 @@ ImportCommand.examples = [
55
55
  ImportCommand.flags = {
56
56
  config: cli_utilities_1.flags.string({
57
57
  char: 'c',
58
- description: '[optional] path of config file',
58
+ description: '[optional] The path of the configuration JSON file containing all the options for a single run.',
59
59
  }),
60
60
  'stack-uid': cli_utilities_1.flags.string({
61
61
  char: 's',
62
- description: 'API key of the target stack',
62
+ description: 'API key of the target stack.',
63
63
  hidden: true,
64
64
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-s', '--stack-uid'], ['-k', '--stack-api-key']),
65
65
  }),
66
66
  'stack-api-key': cli_utilities_1.flags.string({
67
67
  char: 'k',
68
- description: 'API key of the target stack',
68
+ description: 'API Key of the target stack',
69
69
  }),
70
70
  data: cli_utilities_1.flags.string({
71
71
  description: 'path and location where data is stored',
@@ -74,11 +74,11 @@ ImportCommand.flags = {
74
74
  }),
75
75
  'data-dir': cli_utilities_1.flags.string({
76
76
  char: 'd',
77
- description: 'path and location where data is stored',
77
+ description: `The path or the location in your file system where the content, you intend to import, is stored. For example, -d "C:\\Users\\Name\\Desktop\\cli\\content". If the export folder has branches involved, then the path should point till the particular branch. For example, “-d "C:\\Users\\Name\\Desktop\\cli\\content\\branch_name"`,
78
78
  }),
79
79
  alias: cli_utilities_1.flags.string({
80
80
  char: 'a',
81
- description: 'alias of the management token',
81
+ description: 'The management token of the destination stack where you will import the content.',
82
82
  }),
83
83
  'management-token-alias': cli_utilities_1.flags.string({
84
84
  description: 'alias of the management token',
@@ -94,21 +94,21 @@ ImportCommand.flags = {
94
94
  module: cli_utilities_1.flags.string({
95
95
  required: false,
96
96
  char: 'm',
97
- description: '[optional] specific module name',
97
+ description: '[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, and taxonomies.',
98
98
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--module']),
99
99
  }),
100
100
  'backup-dir': cli_utilities_1.flags.string({
101
101
  char: 'b',
102
- description: '[optional] backup directory name when using specific module',
102
+ description: '[optional] Backup directory name when using specific module.',
103
103
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-b'], ['--backup-dir']),
104
104
  }),
105
105
  branch: cli_utilities_1.flags.string({
106
106
  char: 'B',
107
- description: '[optional] branch name',
107
+ description: 'The name of the branch where you want to import your content. If you don\'t mention the branch name, then by default the content will be imported to the main branch.',
108
108
  parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
109
109
  }),
110
110
  'import-webhook-status': cli_utilities_1.flags.string({
111
- description: '[optional] Webhook state',
111
+ description: '[default: disable] (optional) This webhook state keeps the same state of webhooks as the source stack. <options: disable|current>',
112
112
  options: ['disable', 'current'],
113
113
  required: false,
114
114
  default: 'disable',
@@ -116,10 +116,10 @@ ImportCommand.flags = {
116
116
  yes: cli_utilities_1.flags.boolean({
117
117
  char: 'y',
118
118
  required: false,
119
- description: '[optional] Override marketplace prompts',
119
+ description: '[optional] Force override all Marketplace prompts.',
120
120
  }),
121
121
  'skip-app-recreation': cli_utilities_1.flags.boolean({
122
- description: '[optional] Skip private apps recreation if already exist',
122
+ description: '(optional) Skips the recreation of private apps if they already exist.',
123
123
  }),
124
124
  'replace-existing': cli_utilities_1.flags.boolean({
125
125
  required: false,
@@ -132,13 +132,13 @@ ImportCommand.flags = {
132
132
  }),
133
133
  'personalize-project-name': cli_utilities_1.flags.string({
134
134
  required: false,
135
- description: 'Personalize project name.',
135
+ description: '(optional) Provide a unique name for the Personalize project.',
136
136
  }),
137
137
  'skip-audit': cli_utilities_1.flags.boolean({
138
- description: 'Skips the audit fix.',
138
+ description: 'Skips the audit fix that occurs during an import operation.',
139
139
  }),
140
140
  'exclude-global-modules': cli_utilities_1.flags.boolean({
141
- description: 'Excludes the branch-independent module from the import operation',
141
+ description: 'Excludes the branch-independent module from the import operation.',
142
142
  default: false,
143
143
  }),
144
144
  };
@@ -217,14 +217,21 @@ class ImportAssets extends base_class_1.default {
217
217
  const serializeData = (apiOptions) => {
218
218
  const { apiData: asset } = apiOptions;
219
219
  const publishDetails = (0, filter_1.default)(asset.publish_details, ({ environment }) => {
220
- return this.environments.hasOwnProperty(environment);
220
+ var _a;
221
+ return (_a = this.environments) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(environment);
221
222
  });
222
- const environments = (0, uniq_1.default)((0, map_1.default)(publishDetails, ({ environment }) => this.environments[environment].name));
223
- const locales = (0, uniq_1.default)((0, map_1.default)(publishDetails, 'locale'));
224
- asset.locales = locales;
225
- asset.environments = environments;
223
+ if (publishDetails.length) {
224
+ const environments = (0, uniq_1.default)((0, map_1.default)(publishDetails, ({ environment }) => this.environments[environment].name));
225
+ const locales = (0, uniq_1.default)((0, map_1.default)(publishDetails, 'locale'));
226
+ if (environments.length === 0 || locales.length === 0) {
227
+ apiOptions.entity = undefined;
228
+ return apiOptions;
229
+ }
230
+ asset.locales = locales;
231
+ asset.environments = environments;
232
+ apiOptions.apiData.publishDetails = { locales, environments };
233
+ }
226
234
  apiOptions.uid = this.assetsUidMap[asset.uid];
227
- apiOptions.apiData.publishDetails = { locales, environments };
228
235
  if (!apiOptions.uid)
229
236
  apiOptions.entity = undefined;
230
237
  return apiOptions;
@@ -210,7 +210,8 @@ class ImportMarketplaceApps {
210
210
  .marketplace(this.importConfig.org_uid)
211
211
  .installation(app.uid)
212
212
  .fetch()
213
- .catch(() => { }); // NOTE Keeping this to avoid Unhandled exception
213
+ .catch(() => { }); // NOTE Keeping this to avoid Unhandled exce
214
+ // ption
214
215
  return !(0, isEmpty_1.default)(installation);
215
216
  }
216
217
  /**
@@ -11,6 +11,7 @@ const _ = tslib_1.__importStar(require("lodash"));
11
11
  const config_1 = tslib_1.__importDefault(require("../config"));
12
12
  const fileHelper = tslib_1.__importStar(require("./file-helper"));
13
13
  const cli_utilities_1 = require("@contentstack/cli-utilities");
14
+ const log_1 = require("./log");
14
15
  // update references in entry object
15
16
  const lookupEntries = function (data, mappedUids, uidMapperPath) {
16
17
  let parent = [];
@@ -212,6 +213,9 @@ const lookupEntries = function (data, mappedUids, uidMapperPath) {
212
213
  entry = entry.replace(uidRegex, escapedMappedUid);
213
214
  mapped.push(uid);
214
215
  }
216
+ else {
217
+ (0, log_1.log)(`Skipping the entry uid ${uid} since the regex is not valid`, 'warn');
218
+ }
215
219
  }
216
220
  else {
217
221
  unmapped.push(uid);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.2",
2
+ "version": "1.19.4",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
@@ -28,14 +28,14 @@
28
28
  "name": "config",
29
29
  "type": "option",
30
30
  "char": "c",
31
- "description": "[optional] path of config file",
31
+ "description": "[optional] The path of the configuration JSON file containing all the options for a single run.",
32
32
  "multiple": false
33
33
  },
34
34
  "stack-uid": {
35
35
  "name": "stack-uid",
36
36
  "type": "option",
37
37
  "char": "s",
38
- "description": "API key of the target stack",
38
+ "description": "API key of the target stack.",
39
39
  "hidden": true,
40
40
  "multiple": false
41
41
  },
@@ -43,7 +43,7 @@
43
43
  "name": "stack-api-key",
44
44
  "type": "option",
45
45
  "char": "k",
46
- "description": "API key of the target stack",
46
+ "description": "API Key of the target stack",
47
47
  "multiple": false
48
48
  },
49
49
  "data": {
@@ -57,14 +57,14 @@
57
57
  "name": "data-dir",
58
58
  "type": "option",
59
59
  "char": "d",
60
- "description": "path and location where data is stored",
60
+ "description": "The path or the location in your file system where the content, you intend to import, is stored. For example, -d \"C:\\Users\\Name\\Desktop\\cli\\content\". If the export folder has branches involved, then the path should point till the particular branch. For example, “-d \"C:\\Users\\Name\\Desktop\\cli\\content\\branch_name\"",
61
61
  "multiple": false
62
62
  },
63
63
  "alias": {
64
64
  "name": "alias",
65
65
  "type": "option",
66
66
  "char": "a",
67
- "description": "alias of the management token",
67
+ "description": "The management token of the destination stack where you will import the content.",
68
68
  "multiple": false
69
69
  },
70
70
  "management-token-alias": {
@@ -86,7 +86,7 @@
86
86
  "name": "module",
87
87
  "type": "option",
88
88
  "char": "m",
89
- "description": "[optional] specific module name",
89
+ "description": "[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, and taxonomies.",
90
90
  "required": false,
91
91
  "multiple": false
92
92
  },
@@ -94,20 +94,20 @@
94
94
  "name": "backup-dir",
95
95
  "type": "option",
96
96
  "char": "b",
97
- "description": "[optional] backup directory name when using specific module",
97
+ "description": "[optional] Backup directory name when using specific module.",
98
98
  "multiple": false
99
99
  },
100
100
  "branch": {
101
101
  "name": "branch",
102
102
  "type": "option",
103
103
  "char": "B",
104
- "description": "[optional] branch name",
104
+ "description": "The name of the branch where you want to import your content. If you don't mention the branch name, then by default the content will be imported to the main branch.",
105
105
  "multiple": false
106
106
  },
107
107
  "import-webhook-status": {
108
108
  "name": "import-webhook-status",
109
109
  "type": "option",
110
- "description": "[optional] Webhook state",
110
+ "description": "[default: disable] (optional) This webhook state keeps the same state of webhooks as the source stack. <options: disable|current>",
111
111
  "required": false,
112
112
  "multiple": false,
113
113
  "options": [
@@ -120,14 +120,14 @@
120
120
  "name": "yes",
121
121
  "type": "boolean",
122
122
  "char": "y",
123
- "description": "[optional] Override marketplace prompts",
123
+ "description": "[optional] Force override all Marketplace prompts.",
124
124
  "required": false,
125
125
  "allowNo": false
126
126
  },
127
127
  "skip-app-recreation": {
128
128
  "name": "skip-app-recreation",
129
129
  "type": "boolean",
130
- "description": "[optional] Skip private apps recreation if already exist",
130
+ "description": "(optional) Skips the recreation of private apps if they already exist.",
131
131
  "allowNo": false
132
132
  },
133
133
  "replace-existing": {
@@ -147,20 +147,20 @@
147
147
  "personalize-project-name": {
148
148
  "name": "personalize-project-name",
149
149
  "type": "option",
150
- "description": "Personalize project name.",
150
+ "description": "(optional) Provide a unique name for the Personalize project.",
151
151
  "required": false,
152
152
  "multiple": false
153
153
  },
154
154
  "skip-audit": {
155
155
  "name": "skip-audit",
156
156
  "type": "boolean",
157
- "description": "Skips the audit fix.",
157
+ "description": "Skips the audit fix that occurs during an import operation.",
158
158
  "allowNo": false
159
159
  },
160
160
  "exclude-global-modules": {
161
161
  "name": "exclude-global-modules",
162
162
  "type": "boolean",
163
- "description": "Excludes the branch-independent module from the import operation",
163
+ "description": "Excludes the branch-independent module from the import operation.",
164
164
  "allowNo": false
165
165
  }
166
166
  },
package/package.json CHANGED
@@ -1,55 +1,47 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.19.2",
4
+ "version": "1.19.4",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~1.7.2",
9
- "@contentstack/cli-command": "~1.3.2",
10
- "@contentstack/cli-utilities": "~1.8.0",
11
- "@contentstack/management": "~1.17.0",
12
- "@contentstack/cli-variants": "~1.1.2",
13
- "@oclif/core": "^3.26.5",
8
+ "@contentstack/cli-audit": "~1.7.5",
9
+ "@contentstack/cli-command": "~1.3.3",
10
+ "@contentstack/cli-utilities": "~1.8.1",
11
+ "@contentstack/management": "~1.18.4",
12
+ "@contentstack/cli-variants": "~1.1.5",
13
+ "@oclif/core": "^3.27.0",
14
14
  "big-json": "^3.2.0",
15
15
  "bluebird": "^3.7.2",
16
16
  "chalk": "^4.1.2",
17
- "debug": "^4.1.0",
18
- "fs-extra": "^11.1.1",
19
- "lodash": "^4.17.20",
20
- "marked": "^4.0.17",
17
+ "debug": "^4.4.0",
18
+ "fs-extra": "^11.2.0",
19
+ "lodash": "^4.17.21",
20
+ "marked": "^4.3.0",
21
21
  "merge": "^2.1.1",
22
22
  "mkdirp": "^1.0.4",
23
23
  "promise-limit": "^2.7.0",
24
- "tslib": "^2.4.1",
25
24
  "uuid": "^9.0.1",
26
- "winston": "^3.7.2"
25
+ "winston": "^3.17.0"
27
26
  },
28
27
  "devDependencies": {
29
- "@oclif/test": "^2.5.6",
30
- "@types/big-json": "^3.2.0",
31
- "@types/bluebird": "^3.5.38",
32
- "@types/chai": "^4.2.18",
33
- "@types/fs-extra": "^11.0.1",
28
+ "@oclif/test": "^4.1.6",
29
+ "@types/big-json": "^3.2.5",
30
+ "@types/bluebird": "^3.5.42",
31
+ "@types/fs-extra": "^11.0.4",
34
32
  "@types/mkdirp": "^1.0.2",
35
- "@types/mocha": "^8.2.2",
36
- "@types/node": "^14.14.32",
37
- "@types/sinon": "^10.0.2",
38
- "@types/tar": "^6.1.3",
39
- "@types/uuid": "^9.0.7",
40
- "@typescript-eslint/eslint-plugin": "^5.48.2",
41
- "chai": "^4.2.0",
42
- "eslint": "^8.18.0",
33
+ "@types/mocha": "^8.2.3",
34
+ "@types/node": "^14.18.63",
35
+ "@types/tar": "^6.1.13",
36
+ "@types/uuid": "^9.0.8",
37
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
38
+ "eslint": "^8.57.1",
43
39
  "eslint-config-oclif": "^4.0.0",
44
- "globby": "^10.0.2",
45
- "mocha": "^10.0.0",
40
+ "mocha": "^10.8.2",
46
41
  "nyc": "^15.1.0",
47
- "oclif": "^3.8.1",
48
- "rimraf": "^2.7.1",
49
- "sinon": "^19.0.0",
50
- "tmp": "^0.2.2",
51
- "ts-node": "^10.9.1",
52
- "typescript": "^4.9.3"
42
+ "oclif": "^3.17.2",
43
+ "ts-node": "^10.9.2",
44
+ "typescript": "^4.9.5"
53
45
  },
54
46
  "scripts": {
55
47
  "build": "npm run clean && npm run compile",