@contentstack/cli-cm-import 1.26.3 → 1.27.0
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 +7 -1
- package/lib/commands/cm/stacks/import.js +5 -20
- package/lib/import/module-importer.js +9 -20
- package/lib/types/import-config.d.ts +1 -0
- package/lib/utils/import-config-handler.js +3 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +3 -1
- package/lib/utils/setup-branch.d.ts +3 -0
- package/lib/utils/setup-branch.js +30 -0
- package/oclif.manifest.json +14 -1
- package/package.json +5 -5
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.27.0 linux-x64 node-v22.18.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -91,6 +91,9 @@ FLAGS
|
|
|
91
91
|
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
92
92
|
workflows, custom-roles, personalize projects, and taxonomies.
|
|
93
93
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
94
|
+
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't
|
|
95
|
+
mention the branch alias, then by default the content will be imported to the
|
|
96
|
+
main branch.
|
|
94
97
|
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
95
98
|
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
96
99
|
same state of webhooks as the source stack. <options: disable|current>
|
|
@@ -157,6 +160,9 @@ FLAGS
|
|
|
157
160
|
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
158
161
|
workflows, custom-roles, personalize projects, and taxonomies.
|
|
159
162
|
-y, --yes [optional] Force override all Marketplace prompts.
|
|
163
|
+
--branch-alias=<value> The alias of the branch where you want to import your content. If you don't
|
|
164
|
+
mention the branch alias, then by default the content will be imported to the
|
|
165
|
+
main branch.
|
|
160
166
|
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
161
167
|
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
162
168
|
same state of webhooks as the source stack. <options: disable|current>
|
|
@@ -26,26 +26,6 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
26
26
|
if (this.personalizeUrl)
|
|
27
27
|
importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
|
|
28
28
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(importConfig);
|
|
29
|
-
if (!flags.branch) {
|
|
30
|
-
try {
|
|
31
|
-
// Use stack configuration to check for branch availability
|
|
32
|
-
// false positive - no hardcoded secret here
|
|
33
|
-
// @ts-ignore-next-line secret-detection
|
|
34
|
-
const keyProp = 'api_key';
|
|
35
|
-
const branches = await managementAPIClient
|
|
36
|
-
.stack({ [keyProp]: importConfig.apiKey })
|
|
37
|
-
.branch()
|
|
38
|
-
.query()
|
|
39
|
-
.find()
|
|
40
|
-
.then(({ items }) => items);
|
|
41
|
-
if (branches.length) {
|
|
42
|
-
flags.branch = 'main';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
// Branch not enabled, just the let flow continue
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
29
|
const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
|
|
50
30
|
const result = await moduleImporter.start();
|
|
51
31
|
backupDir = importConfig.backupDir;
|
|
@@ -150,6 +130,11 @@ ImportCommand.flags = {
|
|
|
150
130
|
char: 'B',
|
|
151
131
|
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.",
|
|
152
132
|
parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
|
|
133
|
+
exclusive: ['branch-alias'],
|
|
134
|
+
}),
|
|
135
|
+
'branch-alias': cli_utilities_1.flags.string({
|
|
136
|
+
description: "The alias of the branch where you want to import your content. If you don't mention the branch alias, then by default the content will be imported to the main branch.",
|
|
137
|
+
exclusive: ['branch'],
|
|
153
138
|
}),
|
|
154
139
|
'import-webhook-status': cli_utilities_1.flags.string({
|
|
155
140
|
description: '[default: disable] (optional) This webhook state keeps the same state of webhooks as the source stack. <options: disable|current>',
|
|
@@ -23,8 +23,13 @@ class ModuleImporter {
|
|
|
23
23
|
this.importConfig.stackName = stackDetails.name;
|
|
24
24
|
this.importConfig.org_uid = stackDetails.org_uid;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
await (0, utils_1.setupBranchConfig)(this.importConfig, this.stackAPIClient);
|
|
27
|
+
if (this.importConfig.branchAlias && this.importConfig.branchName) {
|
|
28
|
+
this.stackAPIClient = this.managementAPIClient.stack({
|
|
29
|
+
api_key: this.importConfig.apiKey,
|
|
30
|
+
management_token: this.importConfig.management_token,
|
|
31
|
+
branch_uid: this.importConfig.branchName,
|
|
32
|
+
});
|
|
28
33
|
}
|
|
29
34
|
if (this.importConfig.management_token) {
|
|
30
35
|
await (0, cli_utilities_1.addLocale)(this.importConfig.apiKey, this.importConfig.management_token, this.importConfig.host);
|
|
@@ -40,15 +45,7 @@ class ModuleImporter {
|
|
|
40
45
|
// NOTE audit and fix the import content.
|
|
41
46
|
if (!this.importConfig.skipAudit &&
|
|
42
47
|
(!this.importConfig.moduleName ||
|
|
43
|
-
[
|
|
44
|
-
'content-types',
|
|
45
|
-
'global-fields',
|
|
46
|
-
'entries',
|
|
47
|
-
'extensions',
|
|
48
|
-
'workflows',
|
|
49
|
-
'custom-roles',
|
|
50
|
-
'assets'
|
|
51
|
-
].includes(this.importConfig.moduleName))) {
|
|
48
|
+
['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'].includes(this.importConfig.moduleName))) {
|
|
52
49
|
if (!(await this.auditImportData(logger))) {
|
|
53
50
|
return { noSuccessMsg: true };
|
|
54
51
|
}
|
|
@@ -127,15 +124,7 @@ class ModuleImporter {
|
|
|
127
124
|
}
|
|
128
125
|
else if (this.importConfig.modules.types.length) {
|
|
129
126
|
this.importConfig.modules.types
|
|
130
|
-
.filter((val) => [
|
|
131
|
-
'content-types',
|
|
132
|
-
'global-fields',
|
|
133
|
-
'entries',
|
|
134
|
-
'extensions',
|
|
135
|
-
'workflows',
|
|
136
|
-
'custom-roles',
|
|
137
|
-
'assets'
|
|
138
|
-
].includes(val))
|
|
127
|
+
.filter((val) => ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'].includes(val))
|
|
139
128
|
.forEach((val) => {
|
|
140
129
|
args.push('--modules', val);
|
|
141
130
|
});
|
|
@@ -92,6 +92,9 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
92
92
|
config.forceStopMarketplaceAppsPrompt = importCmdFlags.yes;
|
|
93
93
|
config.importWebhookStatus = importCmdFlags['import-webhook-status'];
|
|
94
94
|
config.skipPrivateAppRecreationIfExist = !importCmdFlags['skip-app-recreation'];
|
|
95
|
+
if (importCmdFlags['branch-alias']) {
|
|
96
|
+
config.branchAlias = importCmdFlags['branch-alias'];
|
|
97
|
+
}
|
|
95
98
|
if (importCmdFlags['branch']) {
|
|
96
99
|
config.branchName = importCmdFlags['branch'];
|
|
97
100
|
config.branchDir = config.contentDir;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
|
|
3
|
+
exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = exports.setupBranchConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
var setup_branch_1 = require("./setup-branch");
|
|
6
|
+
Object.defineProperty(exports, "setupBranchConfig", { enumerable: true, get: function () { return setup_branch_1.setupBranchConfig; } });
|
|
5
7
|
exports.interactive = tslib_1.__importStar(require("./interactive"));
|
|
6
8
|
var import_config_handler_1 = require("./import-config-handler");
|
|
7
9
|
Object.defineProperty(exports, "setupImportConfig", { enumerable: true, get: function () { return tslib_1.__importDefault(import_config_handler_1).default; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupBranchConfig = void 0;
|
|
4
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
const common_helper_1 = require("./common-helper");
|
|
6
|
+
const setupBranchConfig = async (config, stackAPIClient) => {
|
|
7
|
+
if (config.branchName) {
|
|
8
|
+
await (0, common_helper_1.validateBranch)(stackAPIClient, config, config.branchName);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (config.branchAlias) {
|
|
12
|
+
config.branchName = await (0, cli_utilities_1.getBranchFromAlias)(stackAPIClient, config.branchAlias);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const branches = await stackAPIClient
|
|
17
|
+
.branch()
|
|
18
|
+
.query()
|
|
19
|
+
.find()
|
|
20
|
+
.then(({ items }) => items);
|
|
21
|
+
if (branches.length) {
|
|
22
|
+
cli_utilities_1.log.info(`Stack is branch Enabled and Branch is not passed by default import will be done in main branch`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// Here the stack is not branch enabled or any network issue
|
|
27
|
+
cli_utilities_1.log.debug('Failed to fetch branches', { error });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.setupBranchConfig = setupBranchConfig;
|
package/oclif.manifest.json
CHANGED
|
@@ -102,11 +102,24 @@
|
|
|
102
102
|
"branch": {
|
|
103
103
|
"char": "B",
|
|
104
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
|
+
"exclusive": [
|
|
106
|
+
"branch-alias"
|
|
107
|
+
],
|
|
105
108
|
"name": "branch",
|
|
106
109
|
"hasDynamicHelp": false,
|
|
107
110
|
"multiple": false,
|
|
108
111
|
"type": "option"
|
|
109
112
|
},
|
|
113
|
+
"branch-alias": {
|
|
114
|
+
"description": "The alias of the branch where you want to import your content. If you don't mention the branch alias, then by default the content will be imported to the main branch.",
|
|
115
|
+
"exclusive": [
|
|
116
|
+
"branch"
|
|
117
|
+
],
|
|
118
|
+
"name": "branch-alias",
|
|
119
|
+
"hasDynamicHelp": false,
|
|
120
|
+
"multiple": false,
|
|
121
|
+
"type": "option"
|
|
122
|
+
},
|
|
110
123
|
"import-webhook-status": {
|
|
111
124
|
"description": "[default: disable] (optional) This webhook state keeps the same state of webhooks as the source stack. <options: disable|current>",
|
|
112
125
|
"name": "import-webhook-status",
|
|
@@ -199,5 +212,5 @@
|
|
|
199
212
|
]
|
|
200
213
|
}
|
|
201
214
|
},
|
|
202
|
-
"version": "1.
|
|
215
|
+
"version": "1.27.0"
|
|
203
216
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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.27.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-audit": "~1.14.
|
|
9
|
-
"@contentstack/cli-command": "~1.6.
|
|
10
|
-
"@contentstack/cli-utilities": "~1.
|
|
8
|
+
"@contentstack/cli-audit": "~1.14.1",
|
|
9
|
+
"@contentstack/cli-command": "~1.6.1",
|
|
10
|
+
"@contentstack/cli-utilities": "~1.14.0",
|
|
11
11
|
"@contentstack/management": "~1.22.0",
|
|
12
|
-
"@contentstack/cli-variants": "~1.3.
|
|
12
|
+
"@contentstack/cli-variants": "~1.3.1",
|
|
13
13
|
"@oclif/core": "^4.3.0",
|
|
14
14
|
"big-json": "^3.2.0",
|
|
15
15
|
"bluebird": "^3.7.2",
|