@contentstack/cli-cm-import 1.19.3 → 1.19.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
@@ -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.3 linux-x64 node-v18.20.5
50
+ @contentstack/cli-cm-import/1.19.5 linux-x64 node-v22.14.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -75,13 +75,14 @@ FLAGS
75
75
  the branch name, then by default the content will be imported to the main branch.
76
76
  -a, --alias=<value> The management token of the destination stack where you will import the content.
77
77
  -b, --backup-dir=<value> [optional] Backup directory name when using specific module.
78
- -c, --config=<value> [optional] Path of config file.
78
+ -c, --config=<value> [optional] The path of the configuration JSON file containing all the options for
79
+ a single run.
79
80
  -d, --data-dir=<value> The path or the location in your file system where the content, you intend to
80
81
  import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
81
82
  export folder has branches involved, then the path should point till the
82
83
  particular branch. For example, “-d
83
84
  "C:\Users\Name\Desktop\cli\content\branch_name"
84
- -k, --stack-api-key=<value> API key of the target stack
85
+ -k, --stack-api-key=<value> API Key of the target stack
85
86
  -m, --module=<value> [optional] Specify the module to import into the target stack. If not specified,
86
87
  the import command will import all the modules into the stack. The available
87
88
  modules are assets, content-types, entries, environments, extensions,
@@ -89,12 +90,12 @@ FLAGS
89
90
  custom-roles, and taxonomies.
90
91
  -y, --yes [optional] Force override all Marketplace prompts.
91
92
  --exclude-global-modules Excludes the branch-independent module from the import operation.
92
- --import-webhook-status=<option> [default: disable] [optional] This webhook state keeps the same state of webhooks
93
- as the source stack.
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>
94
95
  <options: disable|current>
95
- --personalize-project-name=<value> Personalize project name.
96
+ --personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
96
97
  --replace-existing Replaces the existing module in the target stack.
97
- --skip-app-recreation [optional] Skip private apps recreation if already exist
98
+ --skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
98
99
  --skip-audit Skips the audit fix that occurs during an import operation.
99
100
  --skip-existing Skips the module exists warning messages.
100
101
 
@@ -136,13 +137,14 @@ FLAGS
136
137
  the branch name, then by default the content will be imported to the main branch.
137
138
  -a, --alias=<value> The management token of the destination stack where you will import the content.
138
139
  -b, --backup-dir=<value> [optional] Backup directory name when using specific module.
139
- -c, --config=<value> [optional] Path of config file.
140
+ -c, --config=<value> [optional] The path of the configuration JSON file containing all the options for
141
+ a single run.
140
142
  -d, --data-dir=<value> The path or the location in your file system where the content, you intend to
141
143
  import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
142
144
  export folder has branches involved, then the path should point till the
143
145
  particular branch. For example, “-d
144
146
  "C:\Users\Name\Desktop\cli\content\branch_name"
145
- -k, --stack-api-key=<value> API key of the target stack
147
+ -k, --stack-api-key=<value> API Key of the target stack
146
148
  -m, --module=<value> [optional] Specify the module to import into the target stack. If not specified,
147
149
  the import command will import all the modules into the stack. The available
148
150
  modules are assets, content-types, entries, environments, extensions,
@@ -150,12 +152,12 @@ FLAGS
150
152
  custom-roles, and taxonomies.
151
153
  -y, --yes [optional] Force override all Marketplace prompts.
152
154
  --exclude-global-modules Excludes the branch-independent module from the import operation.
153
- --import-webhook-status=<option> [default: disable] [optional] This webhook state keeps the same state of webhooks
154
- as the source stack.
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>
155
157
  <options: disable|current>
156
- --personalize-project-name=<value> Personalize project name.
158
+ --personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
157
159
  --replace-existing Replaces the existing module in the target stack.
158
- --skip-app-recreation [optional] Skip private apps recreation if already exist
160
+ --skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
159
161
  --skip-audit Skips the audit fix that occurs during an import operation.
160
162
  --skip-existing Skips the module exists warning messages.
161
163
 
@@ -55,7 +55,7 @@ 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',
@@ -65,7 +65,7 @@ ImportCommand.flags = {
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',
@@ -108,7 +108,7 @@ ImportCommand.flags = {
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] This webhook state keeps the same state of webhooks as the source stack.',
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',
@@ -119,7 +119,7 @@ ImportCommand.flags = {
119
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,7 +132,7 @@ 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
138
  description: 'Skips the audit fix that occurs during an import operation.',
@@ -428,7 +428,7 @@ const config = {
428
428
  getEncryptionKeyMaxRetry: 3,
429
429
  // useBackedupDir: '',
430
430
  // backupConcurrency: 10,
431
- onlyTSModules: ['taxonomies'],
431
+ onlyTSModules: ['taxonomies', 'personalize'],
432
432
  auditConfig: {
433
433
  noLog: false,
434
434
  skipConfirm: true,
@@ -757,26 +757,34 @@ class EntriesImport extends base_class_1.default {
757
757
  let apiContentDuplicate = [];
758
758
  apiContentDuplicate = apiContent.flatMap((content) => {
759
759
  var _a;
760
- return (_a = content === null || content === void 0 ? void 0 : content.publish_details) === null || _a === void 0 ? void 0 : _a.map((publish) => (Object.assign(Object.assign({}, content), { locale: publish.locale, publish_details: [publish] })));
760
+ if (((_a = content === null || content === void 0 ? void 0 : content.publish_details) === null || _a === void 0 ? void 0 : _a.length) > 0) {
761
+ return content.publish_details.map((publish) => (Object.assign(Object.assign({}, content), { locale: publish.locale, publish_details: [publish] })));
762
+ }
763
+ return []; // Return an empty array if publish_details is empty
761
764
  });
762
765
  apiContent = apiContentDuplicate;
763
- await this.makeConcurrentCall({
764
- apiContent,
765
- processName,
766
- indexerCount,
767
- currentIndexer: +index,
768
- apiParams: {
769
- reject: onReject,
770
- resolve: onSuccess,
771
- entity: 'publish-entries',
772
- includeParamOnCompletion: true,
773
- serializeData: this.serializePublishEntries.bind(this),
774
- additionalInfo: { contentType, locale, cTUid },
775
- },
776
- concurrencyLimit: this.importConcurrency,
777
- }).then(() => {
778
- (0, utils_1.log)(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
779
- });
766
+ if ((apiContent === null || apiContent === void 0 ? void 0 : apiContent.length) === 0) {
767
+ continue;
768
+ }
769
+ else {
770
+ await this.makeConcurrentCall({
771
+ apiContent,
772
+ processName,
773
+ indexerCount,
774
+ currentIndexer: +index,
775
+ apiParams: {
776
+ reject: onReject,
777
+ resolve: onSuccess,
778
+ entity: 'publish-entries',
779
+ includeParamOnCompletion: true,
780
+ serializeData: this.serializePublishEntries.bind(this),
781
+ additionalInfo: { contentType, locale, cTUid },
782
+ },
783
+ concurrencyLimit: this.importConcurrency,
784
+ }).then(() => {
785
+ (0, utils_1.log)(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
786
+ });
787
+ }
780
788
  }
781
789
  }
782
790
  }
@@ -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.3",
2
+ "version": "1.19.5",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
@@ -28,7 +28,7 @@
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": {
@@ -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": {
@@ -107,7 +107,7 @@
107
107
  "import-webhook-status": {
108
108
  "name": "import-webhook-status",
109
109
  "type": "option",
110
- "description": "[optional] This webhook state keeps the same state of webhooks as the source stack.",
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": [
@@ -127,7 +127,7 @@
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,7 +147,7 @@
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
  },
package/package.json CHANGED
@@ -1,53 +1,45 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.19.3",
4
+ "version": "1.19.5",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~1.7.3",
9
- "@contentstack/cli-command": "~1.3.2",
10
- "@contentstack/cli-utilities": "~1.8.0",
11
- "@contentstack/management": "~1.18.3",
12
- "@contentstack/cli-variants": "~1.1.3",
8
+ "@contentstack/cli-audit": "~1.7.5",
9
+ "@contentstack/cli-command": "~1.3.3",
10
+ "@contentstack/cli-utilities": "~1.8.2",
11
+ "@contentstack/management": "~1.18.4",
12
+ "@contentstack/cli-variants": "~1.1.5",
13
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.3.7",
17
+ "debug": "^4.4.0",
18
18
  "fs-extra": "^11.2.0",
19
19
  "lodash": "^4.17.21",
20
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.8.1",
25
24
  "uuid": "^9.0.1",
26
25
  "winston": "^3.17.0"
27
26
  },
28
27
  "devDependencies": {
29
- "@oclif/test": "^4.1.0",
28
+ "@oclif/test": "^4.1.6",
30
29
  "@types/big-json": "^3.2.5",
31
30
  "@types/bluebird": "^3.5.42",
32
- "@types/chai": "^4.3.20",
33
31
  "@types/fs-extra": "^11.0.4",
34
32
  "@types/mkdirp": "^1.0.2",
35
33
  "@types/mocha": "^8.2.3",
36
34
  "@types/node": "^14.18.63",
37
- "@types/sinon": "^10.0.20",
38
35
  "@types/tar": "^6.1.13",
39
36
  "@types/uuid": "^9.0.8",
40
37
  "@typescript-eslint/eslint-plugin": "^5.62.0",
41
- "chai": "^4.5.0",
42
38
  "eslint": "^8.57.1",
43
39
  "eslint-config-oclif": "^4.0.0",
44
- "globby": "^10.0.2",
45
40
  "mocha": "^10.8.2",
46
41
  "nyc": "^15.1.0",
47
42
  "oclif": "^3.17.2",
48
- "rimraf": "^2.7.1",
49
- "sinon": "^19.0.2",
50
- "tmp": "^0.2.3",
51
43
  "ts-node": "^10.9.2",
52
44
  "typescript": "^4.9.5"
53
45
  },