@contentstack/cli-cm-import-setup 1.0.0-beta.1 → 1.0.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 +35 -15
- package/lib/commands/cm/stacks/import-setup.js +18 -10
- package/lib/config/index.js +1 -1
- package/lib/import/import-setup.js +5 -2
- package/lib/import/modules/assets.js +6 -6
- package/lib/import/modules/content-types.js +2 -2
- package/lib/import/modules/entries.js +2 -2
- package/lib/import/modules/extensions.js +4 -4
- package/lib/import/modules/global-fields.d.ts +6 -0
- package/lib/import/modules/global-fields.js +20 -0
- package/lib/import/modules/marketplace-apps.js +3 -3
- package/lib/import/modules/taxonomies.js +2 -2
- package/lib/utils/common-helper.d.ts +2 -0
- package/lib/utils/common-helper.js +31 -0
- package/lib/utils/import-config-handler.js +1 -8
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/interactive.js +2 -2
- package/oclif.manifest.json +20 -11
- 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.0.0
|
|
50
|
+
@contentstack/cli-cm-import-setup/1.0.0 linux-x64 node-v18.20.6
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -63,52 +63,72 @@ USAGE
|
|
|
63
63
|
|
|
64
64
|
## `csdx cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]`
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
Helps to generate mappers and backup folder for importing (overwriting) specific modules
|
|
67
67
|
|
|
68
68
|
```
|
|
69
69
|
USAGE
|
|
70
70
|
$ csdx cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]
|
|
71
71
|
|
|
72
72
|
FLAGS
|
|
73
|
-
-
|
|
74
|
-
|
|
73
|
+
-B, --branch=<value> The name of the branch where you want to import your content. If you don't mention the
|
|
74
|
+
branch name, then by default the content will be imported to the main branch.
|
|
75
|
+
-a, --alias=<value> The management token of the destination stack where you will import the content.
|
|
76
|
+
-d, --data-dir=<value> The path or the location in your file system where the content, you intend to import, is
|
|
77
|
+
stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the export folder has
|
|
78
|
+
branches involved, then the path should point till the particular branch. For example,
|
|
79
|
+
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
75
80
|
-k, --stack-api-key=<value> API key of the target stack
|
|
76
|
-
--
|
|
77
|
-
|
|
81
|
+
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
|
|
82
|
+
are global-fields, content-types, entries
|
|
83
|
+
<options: global-fields|content-types|entries>
|
|
78
84
|
|
|
79
85
|
DESCRIPTION
|
|
80
|
-
|
|
86
|
+
Helps to generate mappers and backup folder for importing (overwriting) specific modules
|
|
81
87
|
|
|
82
88
|
ALIASES
|
|
83
89
|
$ csdx cm:import-setup
|
|
84
90
|
|
|
85
91
|
EXAMPLES
|
|
86
|
-
$ csdx cm:stacks:import-setup --stack-api-key <
|
|
92
|
+
$ csdx cm:stacks:import-setup --stack-api-key <target_stack_api_key> --data-dir <path/of/export/destination/dir> --modules <module_name, module_name>
|
|
93
|
+
|
|
94
|
+
$ csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name>
|
|
95
|
+
|
|
96
|
+
$ csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name> -b <branch_name>
|
|
87
97
|
```
|
|
88
98
|
|
|
89
99
|
## `csdx cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]`
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
Helps to generate mappers and backup folder for importing (overwriting) specific modules
|
|
92
102
|
|
|
93
103
|
```
|
|
94
104
|
USAGE
|
|
95
105
|
$ csdx cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]
|
|
96
106
|
|
|
97
107
|
FLAGS
|
|
98
|
-
-
|
|
99
|
-
|
|
108
|
+
-B, --branch=<value> The name of the branch where you want to import your content. If you don't mention the
|
|
109
|
+
branch name, then by default the content will be imported to the main branch.
|
|
110
|
+
-a, --alias=<value> The management token of the destination stack where you will import the content.
|
|
111
|
+
-d, --data-dir=<value> The path or the location in your file system where the content, you intend to import, is
|
|
112
|
+
stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the export folder has
|
|
113
|
+
branches involved, then the path should point till the particular branch. For example,
|
|
114
|
+
“-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
100
115
|
-k, --stack-api-key=<value> API key of the target stack
|
|
101
|
-
--
|
|
102
|
-
|
|
116
|
+
--module=<option>... [optional] Specify the modules/module to import into the target stack. currently options
|
|
117
|
+
are global-fields, content-types, entries
|
|
118
|
+
<options: global-fields|content-types|entries>
|
|
103
119
|
|
|
104
120
|
DESCRIPTION
|
|
105
|
-
|
|
121
|
+
Helps to generate mappers and backup folder for importing (overwriting) specific modules
|
|
106
122
|
|
|
107
123
|
ALIASES
|
|
108
124
|
$ csdx cm:import-setup
|
|
109
125
|
|
|
110
126
|
EXAMPLES
|
|
111
|
-
$ csdx cm:stacks:import-setup --stack-api-key <
|
|
127
|
+
$ csdx cm:stacks:import-setup --stack-api-key <target_stack_api_key> --data-dir <path/of/export/destination/dir> --modules <module_name, module_name>
|
|
128
|
+
|
|
129
|
+
$ csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name>
|
|
130
|
+
|
|
131
|
+
$ csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name> -b <branch_name>
|
|
112
132
|
```
|
|
113
133
|
|
|
114
134
|
_See code: [src/commands/cm/stacks/import-setup.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-import-setup/src/commands/cm/stacks/import-setup.ts)_
|
|
@@ -18,18 +18,20 @@ class ImportSetupCommand extends cli_command_1.Command {
|
|
|
18
18
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(importSetupConfig);
|
|
19
19
|
const importSetup = new import_1.ImportSetup(importSetupConfig, managementAPIClient);
|
|
20
20
|
await importSetup.start();
|
|
21
|
-
(0, utils_1.log)(importSetupConfig, `
|
|
22
|
-
(0, utils_1.log)(importSetupConfig, `The backup folder created at '${(0, cli_utilities_1.pathValidator)(node_path_1.default.join(importSetupConfig.backupDir))}'
|
|
21
|
+
(0, utils_1.log)(importSetupConfig, `Backup folder and mapper files have been successfully created for the stack using the API key ${importSetupConfig.apiKey}.`, 'success');
|
|
22
|
+
(0, utils_1.log)(importSetupConfig, `The backup folder has been created at '${(0, cli_utilities_1.pathValidator)(node_path_1.default.join(importSetupConfig.backupDir))}'.`, 'success');
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
|
-
(0, utils_1.log)({ data: '' }, `Failed to create backup folder and mapper files
|
|
25
|
+
(0, utils_1.log)({ data: '' }, `Failed to create the backup folder and mapper files: ${(0, cli_utilities_1.formatError)(error)}`, 'error');
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.default = ImportSetupCommand;
|
|
30
|
-
ImportSetupCommand.description = cli_utilities_1.messageHandler.parse('
|
|
30
|
+
ImportSetupCommand.description = cli_utilities_1.messageHandler.parse('Helps to generate mappers and backup folder for importing (overwriting) specific modules');
|
|
31
31
|
ImportSetupCommand.examples = [
|
|
32
|
-
`csdx cm:stacks:import-setup --stack-api-key <
|
|
32
|
+
`csdx cm:stacks:import-setup --stack-api-key <target_stack_api_key> --data-dir <path/of/export/destination/dir> --modules <module_name, module_name>`,
|
|
33
|
+
`csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name>`,
|
|
34
|
+
`csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name> -b <branch_name>`,
|
|
33
35
|
];
|
|
34
36
|
ImportSetupCommand.flags = {
|
|
35
37
|
'stack-api-key': cli_utilities_1.flags.string({
|
|
@@ -38,15 +40,21 @@ ImportSetupCommand.flags = {
|
|
|
38
40
|
}),
|
|
39
41
|
'data-dir': cli_utilities_1.flags.string({
|
|
40
42
|
char: 'd',
|
|
41
|
-
description:
|
|
43
|
+
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"`,
|
|
42
44
|
}),
|
|
43
45
|
alias: cli_utilities_1.flags.string({
|
|
44
46
|
char: 'a',
|
|
45
|
-
description: '
|
|
47
|
+
description: 'The management token of the destination stack where you will import the content.',
|
|
46
48
|
}),
|
|
47
|
-
|
|
48
|
-
options: ['
|
|
49
|
-
description: '[optional]
|
|
49
|
+
module: cli_utilities_1.flags.string({
|
|
50
|
+
options: ['global-fields', 'content-types', 'entries'],
|
|
51
|
+
description: '[optional] Specify the modules/module to import into the target stack. currently options are global-fields, content-types, entries',
|
|
52
|
+
multiple: true,
|
|
53
|
+
}),
|
|
54
|
+
branch: cli_utilities_1.flags.string({
|
|
55
|
+
char: 'B',
|
|
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
|
+
parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
|
|
50
58
|
}),
|
|
51
59
|
};
|
|
52
60
|
ImportSetupCommand.aliases = ['cm:import-setup'];
|
package/lib/config/index.js
CHANGED
|
@@ -24,7 +24,7 @@ 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
|
|
27
|
+
const utils_2 = require("../utils");
|
|
28
28
|
class ImportSetup {
|
|
29
29
|
constructor(config, managementAPIClient) {
|
|
30
30
|
this.dependencyTree = {};
|
|
@@ -78,7 +78,7 @@ class ImportSetup {
|
|
|
78
78
|
await moduleInstance.start();
|
|
79
79
|
}
|
|
80
80
|
catch (error) {
|
|
81
|
-
(0, utils_1.log)(this.config, `Error importing '${moduleName}'
|
|
81
|
+
(0, utils_1.log)(this.config, `Error occurred while importing '${moduleName}'`, 'error');
|
|
82
82
|
throw error;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -100,6 +100,9 @@ class ImportSetup {
|
|
|
100
100
|
if (backupDir) {
|
|
101
101
|
this.config.backupDir = backupDir;
|
|
102
102
|
}
|
|
103
|
+
if (this.config.branchName) {
|
|
104
|
+
await (0, utils_2.validateBranch)(this.stackAPIClient, this.config, this.config.branchName);
|
|
105
|
+
}
|
|
103
106
|
await this.generateDependencyTree();
|
|
104
107
|
await this.runModuleImports();
|
|
105
108
|
}
|
|
@@ -29,10 +29,10 @@ class AssetImportSetup extends base_setup_1.default {
|
|
|
29
29
|
try {
|
|
30
30
|
utils_1.fsUtil.makeDirectory(this.mapperDirPath);
|
|
31
31
|
await this.fetchAndMapAssets();
|
|
32
|
-
(0, utils_1.log)(this.config, `
|
|
32
|
+
(0, utils_1.log)(this.config, `The required setup files for the asset have been generated successfully.`, 'success');
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
|
-
(0, utils_1.log)(this.config, `Error generating asset mapper: ${(0, cli_utilities_1.formatError)(error)}
|
|
35
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the asset mapper: ${(0, cli_utilities_1.formatError)(error)}.`, 'error');
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
@@ -51,20 +51,20 @@ class AssetImportSetup extends base_setup_1.default {
|
|
|
51
51
|
if (items.length === 1) {
|
|
52
52
|
this.assetUidMapper[uid] = items[0].uid;
|
|
53
53
|
this.assetUrlMapper[url] = items[0].url;
|
|
54
|
-
(0, utils_1.log)(this.config, `Mapped asset: '${title}'`, 'info');
|
|
54
|
+
(0, utils_1.log)(this.config, `Mapped asset successfully: '${title}'`, 'info');
|
|
55
55
|
}
|
|
56
56
|
else if (items.length > 1) {
|
|
57
57
|
this.duplicateAssets[uid] = items.map((asset) => {
|
|
58
58
|
return { uid: asset.uid, title: asset.title, url: asset.url };
|
|
59
59
|
});
|
|
60
|
-
(0, utils_1.log)(this.config, `Multiple assets found with title '${title}'
|
|
60
|
+
(0, utils_1.log)(this.config, `Multiple assets found with the title '${title}'.`, 'info');
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
(0, utils_1.log)(this.config, `Asset with title '${title}' not found in the stack!`, 'info');
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const onReject = ({ error, apiData: { title } = undefined }) => {
|
|
67
|
-
(0, utils_1.log)(this.config,
|
|
67
|
+
(0, utils_1.log)(this.config, `Failed to map the asset '${title}'.`, 'error');
|
|
68
68
|
(0, utils_1.log)(this.config, (0, cli_utilities_1.formatError)(error), 'error');
|
|
69
69
|
};
|
|
70
70
|
/* eslint-disable @typescript-eslint/no-unused-vars, guard-for-in */
|
|
@@ -95,7 +95,7 @@ class AssetImportSetup extends base_setup_1.default {
|
|
|
95
95
|
}
|
|
96
96
|
if (!(0, lodash_1.isEmpty)(this.duplicateAssets)) {
|
|
97
97
|
utils_1.fsUtil.writeFile(this.duplicateAssetPath, this.duplicateAssets);
|
|
98
|
-
(0, utils_1.log)(this.config, `Duplicate asset files
|
|
98
|
+
(0, utils_1.log)(this.config, `Duplicate asset files are stored at: ${this.duplicateAssetPath}.`, 'info');
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -10,10 +10,10 @@ class ContentTypesImportSetup extends base_setup_1.default {
|
|
|
10
10
|
async start() {
|
|
11
11
|
try {
|
|
12
12
|
await this.setupDependencies();
|
|
13
|
-
(0, utils_1.log)(this.config, `
|
|
13
|
+
(0, utils_1.log)(this.config, `The required setup files for content types have been generated successfully.`, 'success');
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
|
-
(0, utils_1.log)(this.config, `Error generating ${error.message}
|
|
16
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the content type mapper: ${error.message}.`, 'error');
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -10,10 +10,10 @@ class EntriesImportSetup extends base_setup_1.default {
|
|
|
10
10
|
async start() {
|
|
11
11
|
try {
|
|
12
12
|
await this.setupDependencies();
|
|
13
|
-
(0, utils_1.log)(this.config, `
|
|
13
|
+
(0, utils_1.log)(this.config, `The required setup files for entries have been generated successfully.`, 'success');
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
|
-
(0, utils_1.log)(this.config, `Error generating ${error.message}
|
|
16
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the entry mapper: ${error.message}.`, 'error');
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -28,20 +28,20 @@ class ExtensionImportSetup {
|
|
|
28
28
|
for (const extension of Object.values(extensions)) {
|
|
29
29
|
const targetExtension = await this.getExtension(extension);
|
|
30
30
|
if (!targetExtension) {
|
|
31
|
-
(0, utils_1.log)(this.config, `Extension with title '${extension.title}' not found in the stack
|
|
31
|
+
(0, utils_1.log)(this.config, `Extension with the title '${extension.title}' not found in the stack.`, 'info');
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
34
|
this.extensionMapper[extension.uid] = targetExtension.uid;
|
|
35
35
|
}
|
|
36
36
|
await utils_1.fsUtil.writeFile(this.extUidMapperPath, this.extensionMapper);
|
|
37
|
-
(0, utils_1.log)(this.config, `
|
|
37
|
+
(0, utils_1.log)(this.config, `The required setup files for extensions have been generated successfully.`, 'success');
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
(0, utils_1.log)(this.config, 'No extensions found in the content folder
|
|
40
|
+
(0, utils_1.log)(this.config, 'No extensions found in the content folder.', 'error');
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
|
-
(0, utils_1.log)(this.config, `Error generating extension mapper: ${(0, cli_utilities_1.formatError)(error)}
|
|
44
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the extension mapper: ${(0, cli_utilities_1.formatError)(error)}.`, 'error');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
async getExtension(extension) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const base_setup_1 = tslib_1.__importDefault(require("./base-setup"));
|
|
6
|
+
class GlobalFieldsImportSetup extends base_setup_1.default {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super(options);
|
|
9
|
+
}
|
|
10
|
+
async start() {
|
|
11
|
+
try {
|
|
12
|
+
await this.setupDependencies();
|
|
13
|
+
(0, utils_1.log)(this.config, `The required setup files for global fields have been generated successfully.`, 'success');
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the global field mapper: ${error.message}.`, 'error');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = GlobalFieldsImportSetup;
|
|
@@ -30,14 +30,14 @@ class marketplaceAppImportSetup {
|
|
|
30
30
|
const targetMarketplaceApps = await this.getMarketplaceApps();
|
|
31
31
|
this.createMapper(sourceMarketplaceApps, targetMarketplaceApps);
|
|
32
32
|
await utils_1.fsUtil.writeFile((0, path_1.join)(this.marketplaceAppsUidMapperPath, 'uid-mapping.json'), this.marketplaceAppMapper);
|
|
33
|
-
(0, utils_1.log)(this.config, `
|
|
33
|
+
(0, utils_1.log)(this.config, `The required setup files for Marketplace apps have been generated successfully.`, 'success');
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
(0, utils_1.log)(this.config, 'No
|
|
36
|
+
(0, utils_1.log)(this.config, 'No Marketplace apps found in the content folder.', 'info');
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
|
-
(0, utils_1.log)(this.config, `Error generating
|
|
40
|
+
(0, utils_1.log)(this.config, `Error occurred while generating the Marketplace app mapper: ${error.message}.`, 'error');
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
async getMarketplaceApps() {
|
|
@@ -51,10 +51,10 @@ class TaxonomiesImportSetup {
|
|
|
51
51
|
if (this.termsMapper !== undefined && !(0, isEmpty_1.default)(this.termsMapper)) {
|
|
52
52
|
utils_1.fsUtil.writeFile(this.termsSuccessPath, this.termsMapper);
|
|
53
53
|
}
|
|
54
|
-
(0, utils_1.log)(this.config, `
|
|
54
|
+
(0, utils_1.log)(this.config, `The required setup files for taxonomies have been generated successfully.`, 'success');
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
(0, utils_1.log)(this.config, 'No taxonomies found in the content folder
|
|
57
|
+
(0, utils_1.log)(this.config, 'No taxonomies found in the content folder.', 'info');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
catch (error) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateBranch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const validateBranch = async (stackAPIClient, config, branch) => {
|
|
8
|
+
return new Promise(async (resolve, reject) => {
|
|
9
|
+
try {
|
|
10
|
+
const data = await stackAPIClient.branch(branch).fetch();
|
|
11
|
+
if (data && typeof data === 'object') {
|
|
12
|
+
if (data.error_message) {
|
|
13
|
+
(0, utils_1.log)(config, chalk_1.default.red(data.error_message), 'error');
|
|
14
|
+
(0, utils_1.log)(config, chalk_1.default.red('No branch found with the name ' + branch), 'error');
|
|
15
|
+
reject({ message: 'No branch found with the name ' + branch, error: data.error_message });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
resolve(data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
reject({ message: 'No branch found with the name ' + branch, error: {} });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
(0, utils_1.log)(config, chalk_1.default.red('No branch found with the name ' + branch), 'error');
|
|
27
|
+
reject({ message: 'No branch found with the name ' + branch, error });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.validateBranch = validateBranch;
|
|
@@ -74,15 +74,8 @@ const setupConfig = async (importCmdFlags) => {
|
|
|
74
74
|
// config.skipPrivateAppRecreationIfExist = importCmdFlags['skip-app-recreation'];
|
|
75
75
|
if (importCmdFlags['branch']) {
|
|
76
76
|
config.branchName = importCmdFlags['branch'];
|
|
77
|
-
config.branchDir = path.join((0, cli_utilities_1.sanitizePath)(config.contentDir), (0, cli_utilities_1.sanitizePath)(config.branchName));
|
|
78
|
-
}
|
|
79
|
-
const selectedModule = importCmdFlags['modules'] || (await (0, interactive_1.askSelectedModules)());
|
|
80
|
-
if (selectedModule === 'both') {
|
|
81
|
-
config.selectedModules = ['content-types', 'entries'];
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
config.selectedModules = [selectedModule];
|
|
85
77
|
}
|
|
78
|
+
config.selectedModules = importCmdFlags['module'] || [await (0, interactive_1.askSelectedModules)()];
|
|
86
79
|
if (importCmdFlags['backup-dir']) {
|
|
87
80
|
config.useBackedupDir = importCmdFlags['backup-dir'];
|
|
88
81
|
}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -14,3 +14,4 @@ var logger_1 = require("./logger");
|
|
|
14
14
|
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_1.log; } });
|
|
15
15
|
Object.defineProperty(exports, "unlinkFileLogger", { enumerable: true, get: function () { return logger_1.unlinkFileLogger; } });
|
|
16
16
|
tslib_1.__exportStar(require("./log"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./common-helper"), exports);
|
package/lib/utils/interactive.js
CHANGED
|
@@ -19,11 +19,11 @@ const askSelectedModules = async () => {
|
|
|
19
19
|
return cli_utilities_1.cliux.inquire({
|
|
20
20
|
type: 'list',
|
|
21
21
|
name: 'selectedModule',
|
|
22
|
-
message: 'Please select a module to generate the mapper files',
|
|
22
|
+
message: 'Please select a module to generate the mapper files.',
|
|
23
23
|
choices: [
|
|
24
|
+
{ name: 'Global Fields', value: 'global-fields' },
|
|
24
25
|
{ name: 'Content types', value: 'content-types' },
|
|
25
26
|
{ name: 'Entries', value: 'entries' },
|
|
26
|
-
{ name: 'Both', value: 'both' },
|
|
27
27
|
],
|
|
28
28
|
});
|
|
29
29
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0
|
|
2
|
+
"version": "1.0.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"cm:stacks:import-setup": {
|
|
5
5
|
"id": "cm:stacks:import-setup",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Helps to generate mappers and backup folder for importing (overwriting) specific modules",
|
|
7
7
|
"strict": true,
|
|
8
8
|
"usage": "cm:stacks:import-setup [-k <value>] [-d <value>] [-a <value>] [--modules <value,value>]",
|
|
9
9
|
"pluginName": "@contentstack/cli-cm-import-setup",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"hiddenAliases": [],
|
|
16
16
|
"examples": [
|
|
17
|
-
"csdx cm:stacks:import-setup --stack-api-key <
|
|
17
|
+
"csdx cm:stacks:import-setup --stack-api-key <target_stack_api_key> --data-dir <path/of/export/destination/dir> --modules <module_name, module_name>",
|
|
18
|
+
"csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name>",
|
|
19
|
+
"csdx cm:stacks:import-setup -k <target_stack_api_key> -d <path/of/export/destination/dir> --modules <module_name, module_name> -b <branch_name>"
|
|
18
20
|
],
|
|
19
21
|
"flags": {
|
|
20
22
|
"stack-api-key": {
|
|
@@ -28,26 +30,33 @@
|
|
|
28
30
|
"name": "data-dir",
|
|
29
31
|
"type": "option",
|
|
30
32
|
"char": "d",
|
|
31
|
-
"description": "path
|
|
33
|
+
"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\"",
|
|
32
34
|
"multiple": false
|
|
33
35
|
},
|
|
34
36
|
"alias": {
|
|
35
37
|
"name": "alias",
|
|
36
38
|
"type": "option",
|
|
37
39
|
"char": "a",
|
|
38
|
-
"description": "
|
|
40
|
+
"description": "The management token of the destination stack where you will import the content.",
|
|
39
41
|
"multiple": false
|
|
40
42
|
},
|
|
41
|
-
"
|
|
42
|
-
"name": "
|
|
43
|
+
"module": {
|
|
44
|
+
"name": "module",
|
|
43
45
|
"type": "option",
|
|
44
|
-
"description": "[optional]
|
|
45
|
-
"multiple":
|
|
46
|
+
"description": "[optional] Specify the modules/module to import into the target stack. currently options are global-fields, content-types, entries",
|
|
47
|
+
"multiple": true,
|
|
46
48
|
"options": [
|
|
49
|
+
"global-fields",
|
|
47
50
|
"content-types",
|
|
48
|
-
"entries"
|
|
49
|
-
"both"
|
|
51
|
+
"entries"
|
|
50
52
|
]
|
|
53
|
+
},
|
|
54
|
+
"branch": {
|
|
55
|
+
"name": "branch",
|
|
56
|
+
"type": "option",
|
|
57
|
+
"char": "B",
|
|
58
|
+
"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.",
|
|
59
|
+
"multiple": false
|
|
51
60
|
}
|
|
52
61
|
},
|
|
53
62
|
"args": {}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"winston": "^3.17.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@oclif/test": "^4.1.
|
|
26
|
+
"@oclif/test": "^4.1.6",
|
|
27
27
|
"@types/big-json": "^3.2.5",
|
|
28
28
|
"@types/bluebird": "^3.5.42",
|
|
29
29
|
"@types/chai": "^4.3.20",
|