@contentstack/cli-cm-import-setup 1.5.0 → 1.6.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 +5 -1
- package/lib/commands/cm/stacks/import-setup.js +5 -0
- package/lib/import/import-setup.js +1 -4
- 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 +31 -0
- package/oclif.manifest.json +14 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup
|
|
|
47
47
|
$ csdx COMMAND
|
|
48
48
|
running command...
|
|
49
49
|
$ csdx (--version)
|
|
50
|
-
@contentstack/cli-cm-import-setup/1.
|
|
50
|
+
@contentstack/cli-cm-import-setup/1.6.1 linux-x64 node-v22.20.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -78,6 +78,8 @@ FLAGS
|
|
|
78
78
|
branches involved, then the path should point till the particular branch. For example,
|
|
79
79
|
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
80
80
|
-k, --stack-api-key=<value> API key of the target stack
|
|
81
|
+
--branch-alias=<value> Specify the branch alias where you want to import your content. If not specified, the
|
|
82
|
+
content is imported into the main branch by default.
|
|
81
83
|
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
|
|
82
84
|
are global-fields, content-types, entries
|
|
83
85
|
<options: global-fields|content-types|entries>
|
|
@@ -113,6 +115,8 @@ FLAGS
|
|
|
113
115
|
branches involved, then the path should point till the particular branch. For example,
|
|
114
116
|
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
115
117
|
-k, --stack-api-key=<value> API key of the target stack
|
|
118
|
+
--branch-alias=<value> Specify the branch alias where you want to import your content. If not specified, the
|
|
119
|
+
content is imported into the main branch by default.
|
|
116
120
|
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
|
|
117
121
|
are global-fields, content-types, entries
|
|
118
122
|
<options: global-fields|content-types|entries>
|
|
@@ -55,6 +55,11 @@ ImportSetupCommand.flags = {
|
|
|
55
55
|
char: 'B',
|
|
56
56
|
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.",
|
|
57
57
|
parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
|
|
58
|
+
exclusive: ['branch-alias']
|
|
59
|
+
}),
|
|
60
|
+
'branch-alias': cli_utilities_1.flags.string({
|
|
61
|
+
description: "Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
|
|
62
|
+
exclusive: ['branch'],
|
|
58
63
|
}),
|
|
59
64
|
};
|
|
60
65
|
ImportSetupCommand.aliases = ['cm:import-setup'];
|
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const utils_1 = require("../utils");
|
|
27
|
-
const utils_2 = require("../utils");
|
|
28
27
|
class ImportSetup {
|
|
29
28
|
constructor(config, managementAPIClient) {
|
|
30
29
|
this.dependencyTree = {};
|
|
@@ -107,9 +106,7 @@ class ImportSetup {
|
|
|
107
106
|
if (backupDir) {
|
|
108
107
|
this.config.backupDir = backupDir;
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
await (0, utils_2.validateBranch)(this.stackAPIClient, this.config, this.config.branchName);
|
|
112
|
-
}
|
|
109
|
+
await (0, utils_1.setupBranchConfig)(this.config, this.stackAPIClient);
|
|
113
110
|
await this.generateDependencyTree();
|
|
114
111
|
await this.runModuleImports();
|
|
115
112
|
}
|
|
@@ -75,6 +75,9 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
75
75
|
if (importCmdFlags['branch']) {
|
|
76
76
|
config.branchName = importCmdFlags['branch'];
|
|
77
77
|
}
|
|
78
|
+
if (importCmdFlags['branch-alias']) {
|
|
79
|
+
config.branchAlias = importCmdFlags['branch-alias'];
|
|
80
|
+
}
|
|
78
81
|
config.selectedModules = importCmdFlags['module'] || [await (0, interactive_1.askSelectedModules)()];
|
|
79
82
|
if (importCmdFlags['backup-dir']) {
|
|
80
83
|
config.useBackedupDir = importCmdFlags['backup-dir'];
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
|
|
3
|
+
exports.setupBranchConfig = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
exports.interactive = tslib_1.__importStar(require("./interactive"));
|
|
6
6
|
var import_config_handler_1 = require("./import-config-handler");
|
|
@@ -15,3 +15,5 @@ Object.defineProperty(exports, "log", { enumerable: true, get: function () { ret
|
|
|
15
15
|
Object.defineProperty(exports, "unlinkFileLogger", { enumerable: true, get: function () { return logger_1.unlinkFileLogger; } });
|
|
16
16
|
tslib_1.__exportStar(require("./log"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./common-helper"), exports);
|
|
18
|
+
var setup_branch_1 = require("./setup-branch");
|
|
19
|
+
Object.defineProperty(exports, "setupBranchConfig", { enumerable: true, get: function () { return setup_branch_1.setupBranchConfig; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
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(`The stack is branch-enabled, and branches exist. By default, content will be imported into the main branch.`);
|
|
23
|
+
config.branchName = 'main';
|
|
24
|
+
cli_utilities_1.log.debug(`Setting default target branch to 'main'`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
cli_utilities_1.log.debug('Failed to fetch branches', { error });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.setupBranchConfig = setupBranchConfig;
|
package/oclif.manifest.json
CHANGED
|
@@ -51,10 +51,23 @@
|
|
|
51
51
|
"branch": {
|
|
52
52
|
"char": "B",
|
|
53
53
|
"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.",
|
|
54
|
+
"exclusive": [
|
|
55
|
+
"branch-alias"
|
|
56
|
+
],
|
|
54
57
|
"name": "branch",
|
|
55
58
|
"hasDynamicHelp": false,
|
|
56
59
|
"multiple": false,
|
|
57
60
|
"type": "option"
|
|
61
|
+
},
|
|
62
|
+
"branch-alias": {
|
|
63
|
+
"description": "Specify the branch alias where you want to import your content. If not specified, the content is imported into the main branch by default.",
|
|
64
|
+
"exclusive": [
|
|
65
|
+
"branch"
|
|
66
|
+
],
|
|
67
|
+
"name": "branch-alias",
|
|
68
|
+
"hasDynamicHelp": false,
|
|
69
|
+
"multiple": false,
|
|
70
|
+
"type": "option"
|
|
58
71
|
}
|
|
59
72
|
},
|
|
60
73
|
"hasDynamicHelp": false,
|
|
@@ -75,5 +88,5 @@
|
|
|
75
88
|
]
|
|
76
89
|
}
|
|
77
90
|
},
|
|
78
|
-
"version": "1.
|
|
91
|
+
"version": "1.6.1"
|
|
79
92
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-import-setup",
|
|
3
3
|
"description": "Contentstack CLI plugin to setup the mappers and configurations for the import command",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-command": "~1.6.1",
|
|
9
|
-
"@contentstack/cli-utilities": "~1.
|
|
9
|
+
"@contentstack/cli-utilities": "~1.15.0",
|
|
10
10
|
"@oclif/core": "^4.3.0",
|
|
11
11
|
"big-json": "^3.2.0",
|
|
12
12
|
"chalk": "^4.1.2",
|