@contentstack/cli-cm-import 2.0.0-beta.1 → 2.0.0-beta.11
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/LICENSE +1 -1
- package/README.md +50 -96
- package/lib/commands/cm/stacks/import.d.ts +0 -1
- package/lib/commands/cm/stacks/import.js +13 -46
- package/lib/config/index.js +7 -0
- package/lib/constants/index.d.ts +57 -0
- package/lib/constants/index.js +59 -0
- package/lib/import/module-importer.js +4 -4
- package/lib/import/modules/assets.js +18 -9
- package/lib/import/modules/base-class.d.ts +21 -4
- package/lib/import/modules/base-class.js +31 -1
- package/lib/import/modules/composable-studio.d.ts +44 -0
- package/lib/import/modules/composable-studio.js +235 -0
- package/lib/import/modules/content-types.d.ts +2 -0
- package/lib/import/modules/content-types.js +52 -13
- package/lib/import/modules/custom-roles.js +10 -10
- package/lib/import/modules/entries.d.ts +2 -0
- package/lib/import/modules/entries.js +41 -36
- package/lib/import/modules/environments.js +6 -6
- package/lib/import/modules/extensions.js +7 -7
- package/lib/import/modules/global-fields.d.ts +1 -1
- package/lib/import/modules/global-fields.js +10 -10
- package/lib/import/modules/labels.js +6 -6
- package/lib/import/modules/locales.d.ts +1 -1
- package/lib/import/modules/locales.js +8 -8
- package/lib/import/modules/marketplace-apps.js +6 -6
- package/lib/import/modules/personalize.js +2 -3
- package/lib/import/modules/stack.js +5 -5
- package/lib/import/modules/taxonomies.d.ts +26 -3
- package/lib/import/modules/taxonomies.js +180 -63
- package/lib/import/modules/variant-entries.js +5 -5
- package/lib/import/modules/webhooks.js +6 -6
- package/lib/import/modules/workflows.d.ts +1 -1
- package/lib/import/modules/workflows.js +7 -7
- package/lib/types/default-config.d.ts +6 -0
- package/lib/types/index.d.ts +37 -11
- package/lib/utils/asset-helper.js +1 -1
- package/lib/utils/common-helper.d.ts +1 -1
- package/lib/utils/common-helper.js +8 -7
- package/lib/utils/content-type-helper.d.ts +1 -1
- package/lib/utils/content-type-helper.js +3 -3
- package/lib/utils/extension-helper.js +5 -4
- package/lib/utils/file-helper.js +1 -1
- package/lib/utils/import-config-handler.js +7 -13
- package/lib/utils/import-path-resolver.js +2 -8
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +2 -2
- package/lib/utils/login-handler.d.ts +1 -1
- package/lib/utils/login-handler.js +4 -4
- package/lib/utils/marketplace-app-helper.js +9 -6
- package/lib/utils/taxonomies-helper.js +1 -1
- package/messages/index.json +10 -1
- package/oclif.manifest.json +4 -48
- package/package.json +16 -18
package/LICENSE
CHANGED
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/2.0.0-beta.
|
|
50
|
+
@contentstack/cli-cm-import/2.0.0-beta.11 linux-x64 node-v22.22.0
|
|
51
51
|
$ csdx --help [COMMAND]
|
|
52
52
|
USAGE
|
|
53
53
|
$ csdx COMMAND
|
|
@@ -58,127 +58,81 @@ USAGE
|
|
|
58
58
|
# Commands
|
|
59
59
|
|
|
60
60
|
<!-- commands -->
|
|
61
|
-
* [`csdx cm:stacks:import [
|
|
62
|
-
* [`csdx cm:stacks:import [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]`](#csdx-cmstacksimport--c-value--k-value--d-value--a-value---module-value---backup-dir-value---branch-value---import-webhook-status-disablecurrent)
|
|
61
|
+
* [`csdx cm:stacks:import [--config <value>] [--stack-api-key <value>] [--data-dir <value>] [--alias <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]`](#csdx-cmstacksimport---config-value---stack-api-key-value---data-dir-value---alias-value---module-value---backup-dir-value---branch-value---import-webhook-status-disablecurrent)
|
|
63
62
|
|
|
64
|
-
## `csdx cm:stacks:import [
|
|
63
|
+
## `csdx cm:stacks:import [--config <value>] [--stack-api-key <value>] [--data-dir <value>] [--alias <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]`
|
|
65
64
|
|
|
66
65
|
Import content from a stack
|
|
67
66
|
|
|
68
67
|
```
|
|
69
68
|
USAGE
|
|
70
|
-
$ csdx cm:
|
|
71
|
-
[--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]
|
|
69
|
+
$ csdx cm:stacks:import [--config <value>] [--stack-api-key <value>] [--data-dir <value>] [--alias <value>]
|
|
70
|
+
[--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]
|
|
72
71
|
|
|
73
72
|
FLAGS
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
main branch.
|
|
77
|
-
-a, --alias=<value> The management token of the destination stack where you will import the
|
|
78
|
-
content.
|
|
79
|
-
-b, --backup-dir=<value> [optional] Backup directory name when using specific module.
|
|
80
|
-
-c, --config=<value> [optional] The path of the configuration JSON file containing all the options
|
|
81
|
-
for a single run.
|
|
82
|
-
-d, --data-dir=<value> The path or the location in your file system where the content, you intend to
|
|
83
|
-
import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
|
|
84
|
-
export folder has branches involved, then the path should point till the
|
|
85
|
-
particular branch. For example, “-d
|
|
86
|
-
"C:\Users\Name\Desktop\cli\content\branch_name"
|
|
87
|
-
-k, --stack-api-key=<value> API Key of the target stack
|
|
88
|
-
-m, --module=<value> [optional] Specify the module to import into the target stack. If not
|
|
89
|
-
specified, the import command will import all the modules into the stack. The
|
|
90
|
-
available modules are assets, content-types, entries, environments,
|
|
91
|
-
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
92
|
-
workflows, custom-roles, personalize projects, and taxonomies.
|
|
93
|
-
-y, --yes [optional] Force override all Marketplace prompts.
|
|
94
|
-
--branch-alias=<value> Specify the branch alias where you want to import your content. If not
|
|
95
|
-
specified, the content is imported into the main branch by default.
|
|
96
|
-
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
97
|
-
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
98
|
-
same state of webhooks as the source stack. <options: disable|current>
|
|
99
|
-
<options: disable|current>
|
|
100
|
-
--personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
|
|
101
|
-
--replace-existing Replaces the existing module in the target stack.
|
|
102
|
-
--skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
|
|
103
|
-
--skip-assets-publish Skips asset publishing during the import process.
|
|
104
|
-
--skip-audit Skips the audit fix that occurs during an import operation.
|
|
105
|
-
--skip-entries-publish Skips entry publishing during the import process
|
|
106
|
-
--skip-existing Skips the module exists warning messages.
|
|
73
|
+
-a, --alias=<value>
|
|
74
|
+
The management token of the destination stack where you will import the content.
|
|
107
75
|
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
-c, --config=<value>
|
|
77
|
+
[optional] The path of the configuration JSON file containing all the options for a single run.
|
|
110
78
|
|
|
111
|
-
|
|
112
|
-
|
|
79
|
+
-d, --data-dir=<value>
|
|
80
|
+
The path or the location in your file system where the content, you intend to import, is stored. For example, -d
|
|
81
|
+
"C:\Users\Name\Desktop\cli\content". If the export folder has branches involved, then the path should point till the
|
|
82
|
+
particular branch. For example, “-d "C:\Users\Name\Desktop\cli\content\branch_name"
|
|
113
83
|
|
|
114
|
-
|
|
115
|
-
|
|
84
|
+
-k, --stack-api-key=<value>
|
|
85
|
+
API Key of the target stack
|
|
116
86
|
|
|
117
|
-
|
|
87
|
+
-y, --yes
|
|
88
|
+
[optional] Force override all Marketplace prompts.
|
|
118
89
|
|
|
119
|
-
|
|
90
|
+
--backup-dir=<value>
|
|
91
|
+
[optional] Backup directory name when using specific module.
|
|
120
92
|
|
|
121
|
-
|
|
93
|
+
--branch=<value>
|
|
94
|
+
The name of the branch where you want to import your content. If you don't mention the branch name, then by default
|
|
95
|
+
the content will be imported to the main branch.
|
|
122
96
|
|
|
123
|
-
|
|
97
|
+
--branch-alias=<value>
|
|
98
|
+
Specify the branch alias where you want to import your content. If not specified, the content is imported into the
|
|
99
|
+
main branch by default.
|
|
124
100
|
|
|
125
|
-
|
|
101
|
+
--exclude-global-modules
|
|
102
|
+
Excludes the branch-independent module from the import operation.
|
|
126
103
|
|
|
127
|
-
|
|
104
|
+
--import-webhook-status=<option>
|
|
105
|
+
[default: disable] [default: disable] (optional) This webhook state keeps the same state of webhooks as the source
|
|
106
|
+
stack. <options: disable|current>
|
|
107
|
+
<options: disable|current>
|
|
128
108
|
|
|
129
|
-
|
|
130
|
-
|
|
109
|
+
--module=<value>
|
|
110
|
+
[optional] Specify the module to import into the target stack. If not specified, the import command will import all
|
|
111
|
+
the modules into the stack. The available modules are assets, content-types, entries, environments, extensions,
|
|
112
|
+
marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects,
|
|
113
|
+
taxonomies, and composable-studio.
|
|
131
114
|
|
|
132
|
-
|
|
115
|
+
--personalize-project-name=<value>
|
|
116
|
+
(optional) Provide a unique name for the Personalize project.
|
|
133
117
|
|
|
134
|
-
|
|
118
|
+
--replace-existing
|
|
119
|
+
Replaces the existing module in the target stack.
|
|
135
120
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
$ csdx cm:stacks:import [-c <value>] [-k <value>] [-d <value>] [-a <value>] [--module <value>] [--backup-dir
|
|
139
|
-
<value>] [--branch <value>] [--import-webhook-status disable|current]
|
|
121
|
+
--skip-assets-publish
|
|
122
|
+
Skips asset publishing during the import process.
|
|
140
123
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
for a single run.
|
|
150
|
-
-d, --data-dir=<value> The path or the location in your file system where the content, you intend to
|
|
151
|
-
import, is stored. For example, -d "C:\Users\Name\Desktop\cli\content". If the
|
|
152
|
-
export folder has branches involved, then the path should point till the
|
|
153
|
-
particular branch. For example, “-d
|
|
154
|
-
"C:\Users\Name\Desktop\cli\content\branch_name"
|
|
155
|
-
-k, --stack-api-key=<value> API Key of the target stack
|
|
156
|
-
-m, --module=<value> [optional] Specify the module to import into the target stack. If not
|
|
157
|
-
specified, the import command will import all the modules into the stack. The
|
|
158
|
-
available modules are assets, content-types, entries, environments,
|
|
159
|
-
extensions, marketplace-apps, global-fields, labels, locales, webhooks,
|
|
160
|
-
workflows, custom-roles, personalize projects, and taxonomies.
|
|
161
|
-
-y, --yes [optional] Force override all Marketplace prompts.
|
|
162
|
-
--branch-alias=<value> Specify the branch alias where you want to import your content. If not
|
|
163
|
-
specified, the content is imported into the main branch by default.
|
|
164
|
-
--exclude-global-modules Excludes the branch-independent module from the import operation.
|
|
165
|
-
--import-webhook-status=<option> [default: disable] [default: disable] (optional) This webhook state keeps the
|
|
166
|
-
same state of webhooks as the source stack. <options: disable|current>
|
|
167
|
-
<options: disable|current>
|
|
168
|
-
--personalize-project-name=<value> (optional) Provide a unique name for the Personalize project.
|
|
169
|
-
--replace-existing Replaces the existing module in the target stack.
|
|
170
|
-
--skip-app-recreation (optional) Skips the recreation of private apps if they already exist.
|
|
171
|
-
--skip-assets-publish Skips asset publishing during the import process.
|
|
172
|
-
--skip-audit Skips the audit fix that occurs during an import operation.
|
|
173
|
-
--skip-entries-publish Skips entry publishing during the import process
|
|
174
|
-
--skip-existing Skips the module exists warning messages.
|
|
124
|
+
--skip-audit
|
|
125
|
+
Skips the audit fix that occurs during an import operation.
|
|
126
|
+
|
|
127
|
+
--skip-entries-publish
|
|
128
|
+
Skips entry publishing during the import process
|
|
129
|
+
|
|
130
|
+
--skip-existing
|
|
131
|
+
Skips the module exists warning messages.
|
|
175
132
|
|
|
176
133
|
DESCRIPTION
|
|
177
134
|
Import content from a stack
|
|
178
135
|
|
|
179
|
-
ALIASES
|
|
180
|
-
$ csdx cm:import
|
|
181
|
-
|
|
182
136
|
EXAMPLES
|
|
183
137
|
$ csdx cm:stacks:import --stack-api-key <stack_api_key> --data-dir <path/of/export/destination/dir>
|
|
184
138
|
|
|
@@ -6,6 +6,7 @@ const import_1 = require("../../../import");
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
class ImportCommand extends cli_command_1.Command {
|
|
8
8
|
async run() {
|
|
9
|
+
var _a, _b;
|
|
9
10
|
// setup import config
|
|
10
11
|
// initialize the importer
|
|
11
12
|
// start import
|
|
@@ -15,6 +16,7 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
15
16
|
const { flags } = await this.parse(ImportCommand);
|
|
16
17
|
importConfig = await (0, utils_1.setupImportConfig)(flags);
|
|
17
18
|
// Prepare the context object
|
|
19
|
+
(0, cli_utilities_1.createLogContext)(((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'cm:stacks:export', importConfig.apiKey, importConfig.authenticationMethod);
|
|
18
20
|
const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod);
|
|
19
21
|
importConfig.context = Object.assign({}, context);
|
|
20
22
|
//log.info(`Using Cli Version: ${this.context?.cliVersion}`, importConfig.context);
|
|
@@ -25,6 +27,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
25
27
|
importConfig.developerHubBaseUrl = this.developerHubUrl;
|
|
26
28
|
if (this.personalizeUrl)
|
|
27
29
|
importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
|
|
30
|
+
if (this.composableStudioUrl)
|
|
31
|
+
importConfig.modules['composable-studio'].apiBaseUrl = this.composableStudioUrl;
|
|
28
32
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(importConfig);
|
|
29
33
|
if (flags.branch) {
|
|
30
34
|
cli_utilities_1.CLIProgressManager.initializeGlobalSummary(`IMPORT-${flags.branch}`, flags.branch, `Importing content into "${flags.branch}" branch...`);
|
|
@@ -35,12 +39,7 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
35
39
|
const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
|
|
36
40
|
const result = await moduleImporter.start();
|
|
37
41
|
backupDir = importConfig.backupDir;
|
|
38
|
-
|
|
39
|
-
const successMessage = importConfig.stackName
|
|
40
|
-
? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`
|
|
41
|
-
: `The content has been imported to the stack ${importConfig.apiKey} successfully!`;
|
|
42
|
-
cli_utilities_1.log.success(successMessage, importConfig.context);
|
|
43
|
-
}
|
|
42
|
+
//Note: Final summary is now handled by summary manager
|
|
44
43
|
cli_utilities_1.CLIProgressManager.printGlobalSummary();
|
|
45
44
|
this.logSuccessAndBackupMessages(backupDir, importConfig);
|
|
46
45
|
// Clear progress module setting now that import is complete
|
|
@@ -56,8 +55,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
56
55
|
logAndPrintErrorDetails(error, importConfig) {
|
|
57
56
|
var _a;
|
|
58
57
|
cli_utilities_1.cliux.print('\n');
|
|
59
|
-
const
|
|
60
|
-
const logMsg = `The log has been stored at '${
|
|
58
|
+
const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
|
|
59
|
+
const logMsg = `The log has been stored at '${sessionLogPath}'`;
|
|
61
60
|
const backupDir = importConfig === null || importConfig === void 0 ? void 0 : importConfig.backupDir;
|
|
62
61
|
const backupDirMsg = backupDir
|
|
63
62
|
? `The backup content has been stored at '${backupDir}'`
|
|
@@ -74,8 +73,8 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
74
73
|
logSuccessAndBackupMessages(backupDir, importConfig) {
|
|
75
74
|
var _a;
|
|
76
75
|
cli_utilities_1.cliux.print('\n');
|
|
77
|
-
const
|
|
78
|
-
const logMsg = `The log has been stored at '${
|
|
76
|
+
const sessionLogPath = (0, cli_utilities_1.getSessionLogPath)();
|
|
77
|
+
const logMsg = `The log has been stored at '${sessionLogPath}'`;
|
|
79
78
|
const backupDirMsg = `The backup content has been stored at '${backupDir}'`;
|
|
80
79
|
cli_utilities_1.log.success(logMsg, importConfig.context);
|
|
81
80
|
cli_utilities_1.log.info(backupDirMsg, importConfig.context);
|
|
@@ -92,6 +91,7 @@ class ImportCommand extends cli_command_1.Command {
|
|
|
92
91
|
command: ((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'cm:stacks:import',
|
|
93
92
|
module: '',
|
|
94
93
|
userId: cli_utilities_1.configHandler.get('userUid') || '',
|
|
94
|
+
email: cli_utilities_1.configHandler.get('email') || '',
|
|
95
95
|
sessionId: (_c = this.context) === null || _c === void 0 ? void 0 : _c.sessionId,
|
|
96
96
|
apiKey: apiKey || '',
|
|
97
97
|
orgId: cli_utilities_1.configHandler.get('oauthOrgUid') || '',
|
|
@@ -116,21 +116,10 @@ ImportCommand.flags = {
|
|
|
116
116
|
char: 'c',
|
|
117
117
|
description: '[optional] The path of the configuration JSON file containing all the options for a single run.',
|
|
118
118
|
}),
|
|
119
|
-
'stack-uid': cli_utilities_1.flags.string({
|
|
120
|
-
char: 's',
|
|
121
|
-
description: 'API key of the target stack.',
|
|
122
|
-
hidden: true,
|
|
123
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['-s', '--stack-uid'], ['-k', '--stack-api-key']),
|
|
124
|
-
}),
|
|
125
119
|
'stack-api-key': cli_utilities_1.flags.string({
|
|
126
120
|
char: 'k',
|
|
127
121
|
description: 'API Key of the target stack',
|
|
128
122
|
}),
|
|
129
|
-
data: cli_utilities_1.flags.string({
|
|
130
|
-
description: 'path and location where data is stored',
|
|
131
|
-
hidden: true,
|
|
132
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['--data'], ['--data-dir']),
|
|
133
|
-
}),
|
|
134
123
|
'data-dir': cli_utilities_1.flags.string({
|
|
135
124
|
char: 'd',
|
|
136
125
|
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"`,
|
|
@@ -139,36 +128,19 @@ ImportCommand.flags = {
|
|
|
139
128
|
char: 'a',
|
|
140
129
|
description: 'The management token of the destination stack where you will import the content.',
|
|
141
130
|
}),
|
|
142
|
-
'management-token-alias': cli_utilities_1.flags.string({
|
|
143
|
-
description: 'alias of the management token',
|
|
144
|
-
hidden: true,
|
|
145
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['--management-token-alias'], ['-a', '--alias']),
|
|
146
|
-
}),
|
|
147
|
-
'auth-token': cli_utilities_1.flags.boolean({
|
|
148
|
-
char: 'A',
|
|
149
|
-
description: 'to use auth token',
|
|
150
|
-
hidden: true,
|
|
151
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['-A', '--auth-token']),
|
|
152
|
-
}),
|
|
153
131
|
module: cli_utilities_1.flags.string({
|
|
154
132
|
required: false,
|
|
155
|
-
|
|
156
|
-
description: '[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects, and taxonomies.',
|
|
157
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['-m'], ['--module']),
|
|
133
|
+
description: '[optional] Specify the module to import into the target stack. If not specified, the import command will import all the modules into the stack. The available modules are assets, content-types, entries, environments, extensions, marketplace-apps, global-fields, labels, locales, webhooks, workflows, custom-roles, personalize projects, taxonomies, and composable-studio.',
|
|
158
134
|
}),
|
|
159
135
|
'backup-dir': cli_utilities_1.flags.string({
|
|
160
|
-
char: 'b',
|
|
161
136
|
description: '[optional] Backup directory name when using specific module.',
|
|
162
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['-b'], ['--backup-dir']),
|
|
163
137
|
}),
|
|
164
138
|
branch: cli_utilities_1.flags.string({
|
|
165
|
-
char: 'B',
|
|
166
139
|
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.",
|
|
167
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['-B'], ['--branch']),
|
|
168
140
|
exclusive: ['branch-alias'],
|
|
169
141
|
}),
|
|
170
142
|
'branch-alias': cli_utilities_1.flags.string({
|
|
171
|
-
description:
|
|
143
|
+
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.',
|
|
172
144
|
exclusive: ['branch'],
|
|
173
145
|
}),
|
|
174
146
|
'import-webhook-status': cli_utilities_1.flags.string({
|
|
@@ -182,10 +154,6 @@ ImportCommand.flags = {
|
|
|
182
154
|
required: false,
|
|
183
155
|
description: '[optional] Force override all Marketplace prompts.',
|
|
184
156
|
}),
|
|
185
|
-
'skip-app-recreation': cli_utilities_1.flags.boolean({
|
|
186
|
-
description: '(optional) Skips the recreation of private apps if they already exist.',
|
|
187
|
-
parse: (0, cli_utilities_1.printFlagDeprecation)(['--skip-app-recreation']),
|
|
188
|
-
}),
|
|
189
157
|
'replace-existing': cli_utilities_1.flags.boolean({
|
|
190
158
|
required: false,
|
|
191
159
|
description: 'Replaces the existing module in the target stack.',
|
|
@@ -215,5 +183,4 @@ ImportCommand.flags = {
|
|
|
215
183
|
default: false,
|
|
216
184
|
}),
|
|
217
185
|
};
|
|
218
|
-
ImportCommand.
|
|
219
|
-
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]';
|
|
186
|
+
ImportCommand.usage = 'cm:stacks:import [--config <value>] [--stack-api-key <value>] [--data-dir <value>] [--alias <value>] [--module <value>] [--backup-dir <value>] [--branch <value>] [--import-webhook-status disable|current]';
|
package/lib/config/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const config = {
|
|
|
33
33
|
'stack',
|
|
34
34
|
'assets',
|
|
35
35
|
'taxonomies',
|
|
36
|
+
'composable-studio',
|
|
36
37
|
'extensions',
|
|
37
38
|
'marketplace-apps',
|
|
38
39
|
'global-fields',
|
|
@@ -199,6 +200,12 @@ const config = {
|
|
|
199
200
|
locale: 'en-us',
|
|
200
201
|
},
|
|
201
202
|
},
|
|
203
|
+
'composable-studio': {
|
|
204
|
+
dirName: 'composable_studio',
|
|
205
|
+
fileName: 'composable_studio.json',
|
|
206
|
+
apiBaseUrl: 'https://composable-studio-api.contentstack.com',
|
|
207
|
+
apiVersion: 'v1',
|
|
208
|
+
},
|
|
202
209
|
},
|
|
203
210
|
languagesCode: [
|
|
204
211
|
'af-za',
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare const PATH_CONSTANTS: {
|
|
2
|
+
/** Root mapper directory (contains module-specific mapper subdirs) */
|
|
3
|
+
readonly MAPPER: "mapper";
|
|
4
|
+
/** Common mapper file names */
|
|
5
|
+
readonly FILES: {
|
|
6
|
+
readonly SUCCESS: "success.json";
|
|
7
|
+
readonly FAILS: "fails.json";
|
|
8
|
+
readonly UID_MAPPING: "uid-mapping.json";
|
|
9
|
+
readonly URL_MAPPING: "url-mapping.json";
|
|
10
|
+
readonly UID_MAPPER: "uid-mapper.json";
|
|
11
|
+
readonly SCHEMA: "schema.json";
|
|
12
|
+
readonly SETTINGS: "settings.json";
|
|
13
|
+
readonly MODIFIED_SCHEMAS: "modified-schemas.json";
|
|
14
|
+
readonly UNIQUE_MAPPING: "unique-mapping.json";
|
|
15
|
+
readonly TAXONOMIES: "taxonomies.json";
|
|
16
|
+
readonly ENVIRONMENTS: "environments.json";
|
|
17
|
+
readonly PENDING_EXTENSIONS: "pending_extensions.js";
|
|
18
|
+
readonly PENDING_GLOBAL_FIELDS: "pending_global_fields.js";
|
|
19
|
+
readonly INDEX: "index.json";
|
|
20
|
+
readonly FOLDER_MAPPING: "folder-mapping.json";
|
|
21
|
+
readonly VERSIONED_ASSETS: "versioned-assets.json";
|
|
22
|
+
};
|
|
23
|
+
/** Module subdirectory names within mapper */
|
|
24
|
+
readonly MAPPER_MODULES: {
|
|
25
|
+
readonly ASSETS: "assets";
|
|
26
|
+
readonly ENTRIES: "entries";
|
|
27
|
+
readonly CONTENT_TYPES: "content_types";
|
|
28
|
+
readonly TAXONOMIES: "taxonomies";
|
|
29
|
+
readonly TAXONOMY_TERMS: "terms";
|
|
30
|
+
readonly GLOBAL_FIELDS: "global_fields";
|
|
31
|
+
readonly EXTENSIONS: "extensions";
|
|
32
|
+
readonly WORKFLOWS: "workflows";
|
|
33
|
+
readonly WEBHOOKS: "webhooks";
|
|
34
|
+
readonly LABELS: "labels";
|
|
35
|
+
readonly ENVIRONMENTS: "environments";
|
|
36
|
+
readonly MARKETPLACE_APPS: "marketplace_apps";
|
|
37
|
+
readonly CUSTOM_ROLES: "custom-roles";
|
|
38
|
+
readonly LANGUAGES: "languages";
|
|
39
|
+
};
|
|
40
|
+
/** Content directory names (used in both import and export) */
|
|
41
|
+
readonly CONTENT_DIRS: {
|
|
42
|
+
readonly ASSETS: "assets";
|
|
43
|
+
readonly ENTRIES: "entries";
|
|
44
|
+
readonly CONTENT_TYPES: "content_types";
|
|
45
|
+
readonly TAXONOMIES: "taxonomies";
|
|
46
|
+
readonly GLOBAL_FIELDS: "global_fields";
|
|
47
|
+
readonly EXTENSIONS: "extensions";
|
|
48
|
+
readonly WEBHOOKS: "webhooks";
|
|
49
|
+
readonly WORKFLOWS: "workflows";
|
|
50
|
+
readonly LABELS: "labels";
|
|
51
|
+
readonly ENVIRONMENTS: "environments";
|
|
52
|
+
readonly STACK: "stack";
|
|
53
|
+
readonly LOCALES: "locales";
|
|
54
|
+
readonly MARKETPLACE_APPS: "marketplace_apps";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type PathConstants = typeof PATH_CONSTANTS;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PATH_CONSTANTS = void 0;
|
|
4
|
+
exports.PATH_CONSTANTS = {
|
|
5
|
+
/** Root mapper directory (contains module-specific mapper subdirs) */
|
|
6
|
+
MAPPER: 'mapper',
|
|
7
|
+
/** Common mapper file names */
|
|
8
|
+
FILES: {
|
|
9
|
+
SUCCESS: 'success.json',
|
|
10
|
+
FAILS: 'fails.json',
|
|
11
|
+
UID_MAPPING: 'uid-mapping.json',
|
|
12
|
+
URL_MAPPING: 'url-mapping.json',
|
|
13
|
+
UID_MAPPER: 'uid-mapper.json',
|
|
14
|
+
SCHEMA: 'schema.json',
|
|
15
|
+
SETTINGS: 'settings.json',
|
|
16
|
+
MODIFIED_SCHEMAS: 'modified-schemas.json',
|
|
17
|
+
UNIQUE_MAPPING: 'unique-mapping.json',
|
|
18
|
+
TAXONOMIES: 'taxonomies.json',
|
|
19
|
+
ENVIRONMENTS: 'environments.json',
|
|
20
|
+
PENDING_EXTENSIONS: 'pending_extensions.js',
|
|
21
|
+
PENDING_GLOBAL_FIELDS: 'pending_global_fields.js',
|
|
22
|
+
INDEX: 'index.json',
|
|
23
|
+
FOLDER_MAPPING: 'folder-mapping.json',
|
|
24
|
+
VERSIONED_ASSETS: 'versioned-assets.json',
|
|
25
|
+
},
|
|
26
|
+
/** Module subdirectory names within mapper */
|
|
27
|
+
MAPPER_MODULES: {
|
|
28
|
+
ASSETS: 'assets',
|
|
29
|
+
ENTRIES: 'entries',
|
|
30
|
+
CONTENT_TYPES: 'content_types',
|
|
31
|
+
TAXONOMIES: 'taxonomies',
|
|
32
|
+
TAXONOMY_TERMS: 'terms',
|
|
33
|
+
GLOBAL_FIELDS: 'global_fields',
|
|
34
|
+
EXTENSIONS: 'extensions',
|
|
35
|
+
WORKFLOWS: 'workflows',
|
|
36
|
+
WEBHOOKS: 'webhooks',
|
|
37
|
+
LABELS: 'labels',
|
|
38
|
+
ENVIRONMENTS: 'environments',
|
|
39
|
+
MARKETPLACE_APPS: 'marketplace_apps',
|
|
40
|
+
CUSTOM_ROLES: 'custom-roles',
|
|
41
|
+
LANGUAGES: 'languages',
|
|
42
|
+
},
|
|
43
|
+
/** Content directory names (used in both import and export) */
|
|
44
|
+
CONTENT_DIRS: {
|
|
45
|
+
ASSETS: 'assets',
|
|
46
|
+
ENTRIES: 'entries',
|
|
47
|
+
CONTENT_TYPES: 'content_types',
|
|
48
|
+
TAXONOMIES: 'taxonomies',
|
|
49
|
+
GLOBAL_FIELDS: 'global_fields',
|
|
50
|
+
EXTENSIONS: 'extensions',
|
|
51
|
+
WEBHOOKS: 'webhooks',
|
|
52
|
+
WORKFLOWS: 'workflows',
|
|
53
|
+
LABELS: 'labels',
|
|
54
|
+
ENVIRONMENTS: 'environments',
|
|
55
|
+
STACK: 'stack',
|
|
56
|
+
LOCALES: 'locales',
|
|
57
|
+
MARKETPLACE_APPS: 'marketplace_apps',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -37,8 +37,6 @@ class ModuleImporter {
|
|
|
37
37
|
const backupDir = await (0, utils_1.backupHandler)(this.importConfig);
|
|
38
38
|
if (backupDir) {
|
|
39
39
|
this.importConfig.backupDir = backupDir;
|
|
40
|
-
// To support the old config
|
|
41
|
-
this.importConfig.data = backupDir;
|
|
42
40
|
}
|
|
43
41
|
// NOTE audit and fix the import content.
|
|
44
42
|
if (!this.importConfig.skipAudit &&
|
|
@@ -47,6 +45,10 @@ class ModuleImporter {
|
|
|
47
45
|
if (!(await this.auditImportData())) {
|
|
48
46
|
return { noSuccessMsg: true };
|
|
49
47
|
}
|
|
48
|
+
// Audit overwrote the global summary with 'AUDIT'. Re-initialize for IMPORT so the final
|
|
49
|
+
// summary shows "IMPORT completed successfully!" and only import module stats.
|
|
50
|
+
const branchName = this.importConfig.branchName || '';
|
|
51
|
+
cli_utilities_1.CLIProgressManager.initializeGlobalSummary(branchName ? `IMPORT-${branchName}` : 'IMPORT', branchName, 'Importing content...');
|
|
50
52
|
}
|
|
51
53
|
if (!this.importConfig.master_locale) {
|
|
52
54
|
let masterLocalResponse = await (0, utils_1.masterLocalDetails)(this.stackAPIClient);
|
|
@@ -66,8 +68,6 @@ class ModuleImporter {
|
|
|
66
68
|
}
|
|
67
69
|
async importByModuleByName(moduleName) {
|
|
68
70
|
cli_utilities_1.log.info(`Starting import of ${moduleName} module`, this.importConfig.context);
|
|
69
|
-
// import the modules by name
|
|
70
|
-
// calls the module runner which inturn calls the module itself
|
|
71
71
|
return (0, modules_1.default)({
|
|
72
72
|
stackAPIClient: this.stackAPIClient,
|
|
73
73
|
importConfig: this.importConfig,
|
|
@@ -13,6 +13,7 @@ const includes_1 = tslib_1.__importDefault(require("lodash/includes"));
|
|
|
13
13
|
const uuid_1 = require("uuid");
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
16
17
|
const config_1 = tslib_1.__importDefault(require("../../config"));
|
|
17
18
|
const utils_1 = require("../../utils");
|
|
18
19
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
@@ -26,14 +27,14 @@ class ImportAssets extends base_class_1.default {
|
|
|
26
27
|
this.assetsFolderMap = {};
|
|
27
28
|
this.importConfig.context.module = utils_1.MODULE_CONTEXTS.ASSETS;
|
|
28
29
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ASSETS];
|
|
29
|
-
this.assetsPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
30
|
-
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir,
|
|
31
|
-
this.assetUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
32
|
-
this.assetUrlMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
33
|
-
this.assetFolderUidMapperPath = (0, node_path_1.join)(this.mapperDirPath,
|
|
30
|
+
this.assetsPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.CONTENT_DIRS.ASSETS);
|
|
31
|
+
this.mapperDirPath = (0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.ASSETS);
|
|
32
|
+
this.assetUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.UID_MAPPING);
|
|
33
|
+
this.assetUrlMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.URL_MAPPING);
|
|
34
|
+
this.assetFolderUidMapperPath = (0, node_path_1.join)(this.mapperDirPath, constants_1.PATH_CONSTANTS.FILES.FOLDER_MAPPING);
|
|
34
35
|
this.assetsRootPath = (0, node_path_1.join)(this.importConfig.backupDir, this.assetConfig.dirName);
|
|
35
36
|
this.fs = new cli_utilities_1.FsUtility({ basePath: this.mapperDirPath });
|
|
36
|
-
this.environments = this.fs.readFile((0, node_path_1.join)(this.importConfig.backupDir,
|
|
37
|
+
this.environments = this.fs.readFile((0, node_path_1.join)(this.importConfig.backupDir, constants_1.PATH_CONSTANTS.CONTENT_DIRS.ENVIRONMENTS, constants_1.PATH_CONSTANTS.FILES.ENVIRONMENTS), true);
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* @method start
|
|
@@ -141,7 +142,9 @@ class ImportAssets extends base_class_1.default {
|
|
|
141
142
|
*/
|
|
142
143
|
async importAssets(isVersion = false) {
|
|
143
144
|
const processName = isVersion ? 'import versioned assets' : 'import assets';
|
|
144
|
-
const indexFileName = isVersion
|
|
145
|
+
const indexFileName = isVersion
|
|
146
|
+
? constants_1.PATH_CONSTANTS.FILES.VERSIONED_ASSETS
|
|
147
|
+
: this.assetConfig.fileName;
|
|
145
148
|
const basePath = isVersion ? (0, node_path_1.join)(this.assetsPath, 'versions') : this.assetsPath;
|
|
146
149
|
const progressProcessName = isVersion ? utils_1.PROCESS_NAMES.ASSET_VERSIONS : utils_1.PROCESS_NAMES.ASSET_UPLOAD;
|
|
147
150
|
cli_utilities_1.log.debug(`Importing ${processName} from ${basePath}`, this.importConfig.context);
|
|
@@ -259,7 +262,10 @@ class ImportAssets extends base_class_1.default {
|
|
|
259
262
|
* @returns {Promise<void>} Promise<void>
|
|
260
263
|
*/
|
|
261
264
|
async publish() {
|
|
262
|
-
const fs = new cli_utilities_1.FsUtility({
|
|
265
|
+
const fs = new cli_utilities_1.FsUtility({
|
|
266
|
+
basePath: this.assetsPath,
|
|
267
|
+
indexFileName: this.assetConfig.fileName,
|
|
268
|
+
});
|
|
263
269
|
if ((0, isEmpty_1.default)(this.assetsUidMap)) {
|
|
264
270
|
cli_utilities_1.log.debug('Loading asset UID mappings from file', this.importConfig.context);
|
|
265
271
|
this.assetsUidMap = fs.readFile(this.assetUidMapperPath, true);
|
|
@@ -416,7 +422,10 @@ class ImportAssets extends base_class_1.default {
|
|
|
416
422
|
return count;
|
|
417
423
|
}
|
|
418
424
|
async countPublishableAssets() {
|
|
419
|
-
const fsUtil = new cli_utilities_1.FsUtility({
|
|
425
|
+
const fsUtil = new cli_utilities_1.FsUtility({
|
|
426
|
+
basePath: this.assetsPath,
|
|
427
|
+
indexFileName: this.assetConfig.fileName,
|
|
428
|
+
});
|
|
420
429
|
let count = 0;
|
|
421
430
|
for (const _ of (0, values_1.default)(fsUtil.indexFileContent)) {
|
|
422
431
|
const chunkData = await fsUtil.readChunkFiles.next().catch(() => ({}));
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CLIProgressManager } from '@contentstack/cli-utilities';
|
|
1
|
+
import { ManagementStack, CLIProgressManager } from '@contentstack/cli-utilities';
|
|
3
2
|
import { ImportConfig, ModuleClassParams } from '../../types';
|
|
4
3
|
export type AdditionalKeys = {
|
|
5
4
|
backupDir: string;
|
|
6
5
|
};
|
|
6
|
+
export type CompleteProgressOptions = {
|
|
7
|
+
moduleName?: string;
|
|
8
|
+
customSuccessMessage?: string;
|
|
9
|
+
customWarningMessage?: string;
|
|
10
|
+
context?: Record<string, any>;
|
|
11
|
+
};
|
|
7
12
|
export type ApiModuleType = 'create-assets' | 'replace-assets' | 'publish-assets' | 'create-assets-folder' | 'create-extensions' | 'update-extensions' | 'create-locale' | 'update-locale' | 'create-gfs' | 'create-cts' | 'update-cts' | 'update-gfs' | 'create-environments' | 'create-labels' | 'update-labels' | 'create-webhooks' | 'create-workflows' | 'create-custom-role' | 'create-entries' | 'update-entries' | 'publish-entries' | 'delete-entries' | 'create-taxonomies' | 'create-terms' | 'import-taxonomy';
|
|
8
13
|
export type ApiOptions = {
|
|
9
14
|
uid?: string;
|
|
10
15
|
url?: string;
|
|
11
16
|
entity: ApiModuleType;
|
|
12
17
|
apiData?: Record<any, any> | any;
|
|
18
|
+
queryParam?: Record<any, any>;
|
|
13
19
|
resolve: (value: any) => Promise<void> | void;
|
|
14
20
|
reject: (error: any) => Promise<void> | void;
|
|
15
21
|
additionalInfo?: Record<any, any>;
|
|
@@ -34,13 +40,13 @@ export type CustomPromiseHandlerInput = {
|
|
|
34
40
|
};
|
|
35
41
|
export type CustomPromiseHandler = (input: CustomPromiseHandlerInput) => Promise<any>;
|
|
36
42
|
export default abstract class BaseClass {
|
|
37
|
-
readonly client:
|
|
43
|
+
readonly client: ManagementStack;
|
|
38
44
|
importConfig: ImportConfig;
|
|
39
45
|
modulesConfig: any;
|
|
40
46
|
protected progressManager: CLIProgressManager | null;
|
|
41
47
|
protected currentModuleName: string;
|
|
42
48
|
constructor({ importConfig, stackAPIClient }: Omit<ModuleClassParams, 'moduleName'>);
|
|
43
|
-
get stack():
|
|
49
|
+
get stack(): ManagementStack;
|
|
44
50
|
static printFinalSummary(): void;
|
|
45
51
|
/**
|
|
46
52
|
* Create simple progress manager
|
|
@@ -54,6 +60,17 @@ export default abstract class BaseClass {
|
|
|
54
60
|
* Complete progress manager
|
|
55
61
|
*/
|
|
56
62
|
protected completeProgress(success?: boolean, error?: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Complete progress and log success/warning message based on errors
|
|
65
|
+
* Checks the progress manager's failure count to determine if errors occurred
|
|
66
|
+
* @param options - Options object containing:
|
|
67
|
+
* - moduleName: The module name to generate the message (e.g., 'Content types', 'Entries')
|
|
68
|
+
* If not provided, uses this.currentModuleName
|
|
69
|
+
* - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been imported successfully!"
|
|
70
|
+
* - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been imported with some errors. Please check the logs at: {sessionLogPath}"
|
|
71
|
+
* - context: Optional context for logging
|
|
72
|
+
*/
|
|
73
|
+
protected completeProgressWithMessage(options?: CompleteProgressOptions): void;
|
|
57
74
|
protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
|
|
58
75
|
/**
|
|
59
76
|
* @method delay
|