@contentstack/cli-cm-import 1.15.8 → 1.16.1
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 +3 -1
- package/lib/commands/cm/stacks/import.js +4 -0
- package/lib/config/index.js +3 -1
- package/lib/import/module-importer.js +4 -0
- package/lib/import/modules/entries.js +0 -3
- package/lib/types/default-config.d.ts +1 -0
- package/lib/types/import-config.d.ts +1 -0
- package/lib/utils/extension-helper.js +5 -0
- package/lib/utils/import-config-handler.js +3 -0
- package/oclif.manifest.json +7 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -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.
|
|
50
|
+
@contentstack/cli-cm-import/1.16.1 linux-x64 node-v18.20.4
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -79,6 +79,7 @@ FLAGS
|
|
|
79
79
|
-k, --stack-api-key=<value> API key of the target stack
|
|
80
80
|
-m, --module=<value> [optional] specific module name
|
|
81
81
|
-y, --yes [optional] Override marketplace prompts
|
|
82
|
+
--exclude-global-modules Excludes the branch-independent module from the import operation
|
|
82
83
|
--import-webhook-status=<option> [default: disable] [optional] Webhook state
|
|
83
84
|
<options: disable|current>
|
|
84
85
|
--replace-existing Replaces the existing module in the target stack.
|
|
@@ -128,6 +129,7 @@ FLAGS
|
|
|
128
129
|
-k, --stack-api-key=<value> API key of the target stack
|
|
129
130
|
-m, --module=<value> [optional] specific module name
|
|
130
131
|
-y, --yes [optional] Override marketplace prompts
|
|
132
|
+
--exclude-global-modules Excludes the branch-independent module from the import operation
|
|
131
133
|
--import-webhook-status=<option> [default: disable] [optional] Webhook state
|
|
132
134
|
<options: disable|current>
|
|
133
135
|
--replace-existing Replaces the existing module in the target stack.
|
|
@@ -129,6 +129,10 @@ ImportCommand.flags = {
|
|
|
129
129
|
'skip-audit': cli_utilities_1.flags.boolean({
|
|
130
130
|
description: 'Skips the audit fix.',
|
|
131
131
|
}),
|
|
132
|
+
'exclude-global-modules': cli_utilities_1.flags.boolean({
|
|
133
|
+
description: 'Excludes the branch-independent module from the import operation',
|
|
134
|
+
default: false
|
|
135
|
+
}),
|
|
132
136
|
};
|
|
133
137
|
ImportCommand.aliases = ['cm:import'];
|
|
134
138
|
ImportCommand.usage = 'cm:stacks:import [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]';
|
package/lib/config/index.js
CHANGED
|
@@ -394,6 +394,8 @@ const config = {
|
|
|
394
394
|
returnResponse: true,
|
|
395
395
|
noTerminalOutput: false,
|
|
396
396
|
config: { basePath: '' }, // To overwrite any build-in config. And this config is equal to --config flag.
|
|
397
|
-
}
|
|
397
|
+
},
|
|
398
|
+
//'taxonomies', 'environments', 'marketplace_apps', workflows, custom-roles --> Add this incase need to extend to the other global modules
|
|
399
|
+
globalModules: ['webhooks'],
|
|
398
400
|
};
|
|
399
401
|
exports.default = config;
|
|
@@ -86,6 +86,10 @@ class ModuleImporter {
|
|
|
86
86
|
async importAllModules() {
|
|
87
87
|
// use the algorithm to determine the parallel and sequential execution of modules
|
|
88
88
|
for (let moduleName of this.importConfig.modules.types) {
|
|
89
|
+
if (this.importConfig.globalModules.includes(moduleName) && this.importConfig['exclude-global-modules']) {
|
|
90
|
+
(0, utils_1.log)(this.importConfig, `Skipping the import of the global module '${moduleName}', as it already exists in the stack.`, 'warn');
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
89
93
|
await this.importByModuleByName(moduleName);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
@@ -331,9 +331,6 @@ class EntriesImport extends base_class_1.default {
|
|
|
331
331
|
if (this.jsonRteCTsWithRef.indexOf(cTUid) > -1) {
|
|
332
332
|
entry = (0, utils_1.removeEntryRefsFromJSONRTE)(entry, contentType.schema);
|
|
333
333
|
}
|
|
334
|
-
if (this.rteCTs.indexOf(cTUid) > -1) {
|
|
335
|
-
entry = (0, utils_1.removeEntryRefsFromJSONRTE)(entry, contentType.schema);
|
|
336
|
-
}
|
|
337
334
|
if (this.rteCTsWithRef.indexOf(cTUid) > -1) {
|
|
338
335
|
entry = (0, utils_1.removeEntryRefsFromJSONRTE)(entry, contentType.schema);
|
|
339
336
|
}
|
|
@@ -16,6 +16,7 @@ const lookupExtension = function (config, schema, preserveStackVersion, installe
|
|
|
16
16
|
const fs = new cli_utilities_1.FsUtility({ basePath: config.backupDir });
|
|
17
17
|
const extensionPath = (0, node_path_1.join)(config.backupDir, 'mapper/extensions', 'uid-mapping.json');
|
|
18
18
|
const globalfieldsPath = (0, node_path_1.join)(config.backupDir, 'mapper/globalfields', 'uid-mapping.json');
|
|
19
|
+
const marketPlaceAppsPath = (0, node_path_1.join)(config.backupDir, 'mapper/marketplace_apps', 'uid-mapping.json');
|
|
19
20
|
for (let i in schema) {
|
|
20
21
|
if (schema[i].data_type === 'group') {
|
|
21
22
|
(0, exports.lookupExtension)(config, schema[i].schema, preserveStackVersion, installedExtensions);
|
|
@@ -72,10 +73,14 @@ const lookupExtension = function (config, schema, preserveStackVersion, installe
|
|
|
72
73
|
else if (schema[i].data_type === 'json' && schema[i].hasOwnProperty('plugins') && schema[i].plugins.length > 0) {
|
|
73
74
|
const newPluginUidsArray = [];
|
|
74
75
|
const data = fs.readFile(extensionPath);
|
|
76
|
+
const marketPlaceAppsData = fs.readFile(marketPlaceAppsPath);
|
|
75
77
|
schema[i].plugins.forEach((extension_key_value) => {
|
|
76
78
|
if (data && data.hasOwnProperty(extension_key_value)) {
|
|
77
79
|
newPluginUidsArray.push(data[extension_key_value]);
|
|
78
80
|
}
|
|
81
|
+
else if (marketPlaceAppsData && marketPlaceAppsData.extension_uid && marketPlaceAppsData.extension_uid.hasOwnProperty(extension_key_value)) {
|
|
82
|
+
newPluginUidsArray.push(marketPlaceAppsData.extension_uid[extension_key_value]);
|
|
83
|
+
}
|
|
79
84
|
});
|
|
80
85
|
schema[i].plugins = newPluginUidsArray;
|
|
81
86
|
}
|
|
@@ -88,6 +88,9 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
88
88
|
config.target_stack = config.apiKey;
|
|
89
89
|
config.replaceExisting = importCmdFlags['replace-existing'];
|
|
90
90
|
config.skipExisting = importCmdFlags['skip-existing'];
|
|
91
|
+
if (importCmdFlags['exclude-global-modules']) {
|
|
92
|
+
config['exclude-global-modules'] = importCmdFlags['exclude-global-modules'];
|
|
93
|
+
}
|
|
91
94
|
return config;
|
|
92
95
|
};
|
|
93
96
|
exports.default = setupConfig;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.16.1",
|
|
3
3
|
"commands": {
|
|
4
4
|
"cm:stacks:import": {
|
|
5
5
|
"id": "cm:stacks:import",
|
|
@@ -149,6 +149,12 @@
|
|
|
149
149
|
"type": "boolean",
|
|
150
150
|
"description": "Skips the audit fix.",
|
|
151
151
|
"allowNo": false
|
|
152
|
+
},
|
|
153
|
+
"exclude-global-modules": {
|
|
154
|
+
"name": "exclude-global-modules",
|
|
155
|
+
"type": "boolean",
|
|
156
|
+
"description": "Excludes the branch-independent module from the import operation",
|
|
157
|
+
"allowNo": false
|
|
152
158
|
}
|
|
153
159
|
},
|
|
154
160
|
"args": {}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import",
|
|
3
3
|
"description": "Contentstack CLI plugin to import content into stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.16.1",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.6.
|
|
8
|
+
"@contentstack/cli-audit": "~1.6.3",
|
|
9
9
|
"@contentstack/cli-command": "~1.2.18",
|
|
10
|
-
"@contentstack/cli-utilities": "~1.6.
|
|
10
|
+
"@contentstack/cli-utilities": "~1.6.3",
|
|
11
11
|
"@contentstack/management": "~1.15.3",
|
|
12
12
|
"@oclif/core": "^3.26.5",
|
|
13
13
|
"big-json": "^3.2.0",
|