@contentstack/cli-cm-export 1.16.3 → 1.18.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 +1 -1
- package/lib/commands/cm/stacks/export.d.ts +2 -0
- package/lib/commands/cm/stacks/export.js +43 -15
- package/lib/config/index.js +7 -1
- package/lib/export/module-exporter.js +16 -10
- package/lib/export/modules/assets.d.ts +0 -5
- package/lib/export/modules/assets.js +47 -32
- package/lib/export/modules/base-class.d.ts +1 -0
- package/lib/export/modules/base-class.js +16 -2
- package/lib/export/modules/content-types.d.ts +1 -1
- package/lib/export/modules/content-types.js +25 -12
- package/lib/export/modules/custom-roles.js +50 -9
- package/lib/export/modules/entries.d.ts +1 -1
- package/lib/export/modules/entries.js +63 -16
- package/lib/export/modules/environments.js +29 -7
- package/lib/export/modules/extensions.js +30 -7
- package/lib/export/modules/global-fields.js +27 -7
- package/lib/export/modules/index.js +10 -3
- package/lib/export/modules/labels.js +29 -7
- package/lib/export/modules/locales.d.ts +1 -1
- package/lib/export/modules/locales.js +29 -7
- package/lib/export/modules/marketplace-apps.d.ts +2 -1
- package/lib/export/modules/marketplace-apps.js +62 -15
- package/lib/export/modules/personalize.js +23 -6
- package/lib/export/modules/stack.d.ts +1 -0
- package/lib/export/modules/stack.js +74 -9
- package/lib/export/modules/taxonomies.d.ts +0 -1
- package/lib/export/modules/taxonomies.js +40 -30
- package/lib/export/modules/webhooks.js +29 -7
- package/lib/export/modules/workflows.js +38 -10
- package/lib/types/export-config.d.ts +6 -1
- package/lib/types/index.d.ts +11 -0
- package/lib/utils/basic-login.js +7 -8
- package/lib/utils/common-helper.js +3 -4
- package/lib/utils/export-config-handler.js +44 -0
- package/lib/utils/marketplace-app-helper.js +1 -2
- package/lib/utils/setup-branches.js +1 -1
- package/lib/utils/setup-export-dir.js +1 -1
- package/messages/index.json +69 -1
- package/oclif.manifest.json +9 -1
- package/package.json +4 -4
|
@@ -11,8 +11,12 @@ const basic_login_1 = tslib_1.__importDefault(require("./basic-login"));
|
|
|
11
11
|
const lodash_1 = require("lodash");
|
|
12
12
|
const setupConfig = async (exportCmdFlags) => {
|
|
13
13
|
let config = (0, merge_1.default)({}, config_1.default);
|
|
14
|
+
// Track authentication method
|
|
15
|
+
let authenticationMethod = 'unknown';
|
|
16
|
+
cli_utilities_1.log.debug('Setting up export configuration');
|
|
14
17
|
// setup the config
|
|
15
18
|
if (exportCmdFlags['config']) {
|
|
19
|
+
cli_utilities_1.log.debug('Loading external configuration file', { configFile: exportCmdFlags['config'] });
|
|
16
20
|
const externalConfig = await (0, file_helper_1.readFile)(exportCmdFlags['config']);
|
|
17
21
|
config = merge_1.default.recursive(config, externalConfig);
|
|
18
22
|
}
|
|
@@ -30,26 +34,46 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
30
34
|
config.data = config.exportDir;
|
|
31
35
|
const managementTokenAlias = exportCmdFlags['management-token-alias'] || exportCmdFlags['alias'];
|
|
32
36
|
if (managementTokenAlias) {
|
|
37
|
+
cli_utilities_1.log.debug('Using management token alias', { alias: managementTokenAlias });
|
|
33
38
|
const { token, apiKey } = cli_utilities_1.configHandler.get(`tokens.${managementTokenAlias}`) || {};
|
|
34
39
|
config.management_token = token;
|
|
35
40
|
config.apiKey = apiKey;
|
|
41
|
+
authenticationMethod = 'Management Token';
|
|
36
42
|
if (!config.management_token) {
|
|
43
|
+
cli_utilities_1.log.debug('Management token not found for alias', { alias: managementTokenAlias });
|
|
37
44
|
throw new Error(`No management token found on given alias ${managementTokenAlias}`);
|
|
38
45
|
}
|
|
46
|
+
cli_utilities_1.log.debug('Management token configuration successful');
|
|
39
47
|
}
|
|
40
48
|
if (!config.management_token) {
|
|
41
49
|
if (!(0, cli_utilities_1.isAuthenticated)()) {
|
|
50
|
+
cli_utilities_1.log.debug('User not authenticated, checking for basic auth credentials');
|
|
42
51
|
if (config.username && config.password) {
|
|
52
|
+
cli_utilities_1.log.debug('Using basic authentication with username/password');
|
|
43
53
|
await (0, basic_login_1.default)(config);
|
|
54
|
+
authenticationMethod = 'Basic Auth';
|
|
55
|
+
cli_utilities_1.log.debug('Basic authentication successful');
|
|
44
56
|
}
|
|
45
57
|
else {
|
|
58
|
+
cli_utilities_1.log.debug('No authentication method available');
|
|
46
59
|
throw new Error('Please login or provide an alias for the management token');
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
62
|
else {
|
|
63
|
+
// Check if user is authenticated via OAuth
|
|
64
|
+
const isOAuthUser = cli_utilities_1.configHandler.get('authorisationType') === 'OAUTH' || false;
|
|
65
|
+
if (isOAuthUser) {
|
|
66
|
+
authenticationMethod = 'OAuth';
|
|
67
|
+
cli_utilities_1.log.debug('User authenticated via OAuth');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
authenticationMethod = 'Basic Auth';
|
|
71
|
+
cli_utilities_1.log.debug('User authenticated via auth token');
|
|
72
|
+
}
|
|
50
73
|
config.apiKey =
|
|
51
74
|
exportCmdFlags['stack-uid'] || exportCmdFlags['stack-api-key'] || config.source_stack || (await (0, interactive_1.askAPIKey)());
|
|
52
75
|
if (typeof config.apiKey !== 'string') {
|
|
76
|
+
cli_utilities_1.log.debug('Invalid API key received', { apiKey: config.apiKey });
|
|
53
77
|
throw new Error('Invalid API key received');
|
|
54
78
|
}
|
|
55
79
|
}
|
|
@@ -75,6 +99,26 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
75
99
|
if (Array.isArray(config.filteredModules) && config.filteredModules.length > 0) {
|
|
76
100
|
config.modules.types = (0, lodash_1.filter)(config_1.default.modules.types, (module) => (0, lodash_1.includes)(config.filteredModules, module));
|
|
77
101
|
}
|
|
102
|
+
// Handle query flag - can be inline JSON or file path
|
|
103
|
+
if (exportCmdFlags['query']) {
|
|
104
|
+
try {
|
|
105
|
+
const queryInput = exportCmdFlags['query'];
|
|
106
|
+
// Check if it's a file path (contains .json extension or path separators)
|
|
107
|
+
if (queryInput.includes('.json') || queryInput.includes('/') || queryInput.includes('\\')) {
|
|
108
|
+
// Try to read as file path
|
|
109
|
+
config.query = await (0, file_helper_1.readFile)(queryInput);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
config.query = JSON.parse(queryInput);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw new Error(`Invalid query format: ${error.message}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Add authentication details to config for context tracking
|
|
120
|
+
config.authenticationMethod = authenticationMethod;
|
|
121
|
+
cli_utilities_1.log.debug('Export configuration setup completed', Object.assign({}, config));
|
|
78
122
|
return config;
|
|
79
123
|
};
|
|
80
124
|
exports.default = setupConfig;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodeCryptoInstance = exports.getOrgUid = exports.getDeveloperHubUrl = void 0;
|
|
4
4
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
5
|
const getDeveloperHubUrl = async (exportConfig) => {
|
|
7
6
|
return (0, cli_utilities_1.createDeveloperHubUrl)(exportConfig.host);
|
|
8
7
|
};
|
|
@@ -13,7 +12,7 @@ async function getOrgUid(config) {
|
|
|
13
12
|
.stack({ api_key: config.source_stack })
|
|
14
13
|
.fetch()
|
|
15
14
|
.catch((error) => {
|
|
16
|
-
(0,
|
|
15
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, config.context));
|
|
17
16
|
});
|
|
18
17
|
return tempStackData === null || tempStackData === void 0 ? void 0 : tempStackData.org_uid;
|
|
19
18
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path = tslib_1.__importStar(require("path"));
|
|
5
|
-
const file_helper_1 = require("./file-helper");
|
|
6
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
|
+
const file_helper_1 = require("./file-helper");
|
|
7
7
|
const setupBranches = async (config, stackAPIClient) => {
|
|
8
8
|
if (typeof config !== 'object') {
|
|
9
9
|
throw new Error('Invalid config to setup the branch');
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
-
const file_helper_1 = require("./file-helper");
|
|
6
5
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
|
+
const file_helper_1 = require("./file-helper");
|
|
7
7
|
async function setupExportDir(exportConfig) {
|
|
8
8
|
(0, file_helper_1.makeDirectory)(exportConfig.exportDir);
|
|
9
9
|
if (exportConfig.branches) {
|
package/messages/index.json
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"ASSET_EXPORT_COMPLETE": "Asset export process completed successfully",
|
|
3
|
+
"ASSET_FOLDERS_EXPORT_COMPLETE": "Asset folder structure exported successfully",
|
|
4
|
+
"ASSET_METADATA_EXPORT_COMPLETE": "Asset metadata exported successfully",
|
|
5
|
+
"ASSET_VERSIONED_METADATA_EXPORT_COMPLETE": "Versioned asset metadata exported successfully",
|
|
6
|
+
"ASSET_DOWNLOAD_COMPLETE": "Asset download completed successfully",
|
|
7
|
+
"ASSET_DOWNLOAD_SUCCESS": "Asset '%s' (UID: %s) downloaded successfully",
|
|
8
|
+
"ASSET_DOWNLOAD_FAILED": "Failed to download asset '%s' (UID: %s)",
|
|
9
|
+
"ASSET_WRITE_FAILED": "Failed to write asset file '%s' (UID: %s)",
|
|
10
|
+
"ASSET_QUERY_FAILED": "Failed to query asset data from the API",
|
|
11
|
+
"ASSET_VERSIONED_QUERY_FAILED": "Failed to query versioned asset data from the API",
|
|
12
|
+
"ASSET_COUNT_QUERY_FAILED": "Failed to retrieve total asset count",
|
|
13
|
+
|
|
14
|
+
"CONTENT_TYPE_EXPORT_COMPLETE": "Content types exported successfully",
|
|
15
|
+
"CONTENT_TYPE_NO_TYPES": "No content types found",
|
|
16
|
+
"CONTENT_TYPE_EXPORT_FAILED": "Failed to export content types",
|
|
17
|
+
"CONTENT_TYPE_NO_TYPES_RETURNED": "API returned no content types for the given query",
|
|
18
|
+
|
|
19
|
+
"ENVIRONMENT_EXPORT_COMPLETE": "Successfully exported %s environment(s)",
|
|
20
|
+
"ENVIRONMENT_EXPORT_SUCCESS": "Environment '%s' exported successfully",
|
|
21
|
+
"ENVIRONMENT_NOT_FOUND": "No environments found in the current stack",
|
|
22
|
+
|
|
23
|
+
"EXTENSION_EXPORT_COMPLETE": "Successfully exported %s extension(s)",
|
|
24
|
+
"EXTENSION_EXPORT_SUCCESS": "Extension '%s' exported successfully",
|
|
25
|
+
"EXTENSION_NOT_FOUND": "No extensions found in the current stack",
|
|
26
|
+
|
|
27
|
+
"GLOBAL_FIELDS_EXPORT_COMPLETE": "Successfully exported %s global field(s)",
|
|
28
|
+
|
|
29
|
+
"LABELS_EXPORT_COMPLETE": "Successfully exported %s label(s)",
|
|
30
|
+
"LABEL_EXPORT_SUCCESS": "Label '%s' exported successfully",
|
|
31
|
+
"LABELS_NOT_FOUND": "No labels found in the current stack",
|
|
32
|
+
|
|
33
|
+
"LOCALES_EXPORT_COMPLETE": "Successfully exported %s locale(s) including %s master locale(s)",
|
|
34
|
+
|
|
35
|
+
"TAXONOMY_EXPORT_COMPLETE": "Successfully exported %s taxonomy entries",
|
|
36
|
+
"TAXONOMY_EXPORT_SUCCESS": "Taxonomy '%s' exported successfully",
|
|
37
|
+
"TAXONOMY_NOT_FOUND": "No taxonomies found in the current stack",
|
|
38
|
+
|
|
39
|
+
"WEBHOOK_EXPORT_COMPLETE": "Successfully exported %s webhook(s)",
|
|
40
|
+
"WEBHOOK_EXPORT_SUCCESS": "Webhook '%s' exported successfully",
|
|
41
|
+
"WEBHOOK_NOT_FOUND": "No webhooks found in the current stack",
|
|
42
|
+
|
|
43
|
+
"WORKFLOW_EXPORT_COMPLETE": "Successfully exported %s workflow(s)",
|
|
44
|
+
"WORKFLOW_EXPORT_SUCCESS": "Workflow '%s' exported successfully",
|
|
45
|
+
"WORKFLOW_NOT_FOUND": "No workflows found in the current stack",
|
|
46
|
+
|
|
47
|
+
"PERSONALIZE_URL_NOT_SET": "Cannot export Personalize project: URL not configured",
|
|
48
|
+
"PERSONALIZE_SKIPPING_WITH_MANAGEMENT_TOKEN": "Skipping Personalize project export: Management token not supported",
|
|
49
|
+
"PERSONALIZE_MODULE_NOT_IMPLEMENTED": "Module '%s' implementation not found",
|
|
50
|
+
"PERSONALIZE_NOT_ENABLED": "Personalize feature is not enabled for this organization",
|
|
51
|
+
|
|
52
|
+
"MARKETPLACE_APPS_EXPORT_COMPLETE": "Successfully exported %s marketplace app(s)",
|
|
53
|
+
"MARKETPLACE_APP_CONFIG_EXPORT": "Exporting configuration for app '%s'",
|
|
54
|
+
"MARKETPLACE_APP_CONFIG_SUCCESS": "Successfully exported configuration for app '%s'",
|
|
55
|
+
"MARKETPLACE_APP_EXPORT_SUCCESS": "Successfully exported app '%s'",
|
|
56
|
+
"MARKETPLACE_APPS_NOT_FOUND": "No marketplace apps found in the current stack",
|
|
57
|
+
"MARKETPLACE_APP_CONFIG_EXPORT_FAILED": "Failed to export configuration for app '%s'",
|
|
58
|
+
"MARKETPLACE_APP_MANIFEST_EXPORT_FAILED": "Failed to export manifest for app '%s'",
|
|
59
|
+
|
|
60
|
+
"ENTRIES_EXPORT_COMPLETE": "Successfully exported entries (Content Type: %s, Locale: %s)",
|
|
61
|
+
"ENTRIES_EXPORT_SUCCESS": "All entries exported successfully",
|
|
62
|
+
"ENTRIES_VERSIONED_EXPORT_SUCCESS": "Successfully exported versioned entry (Content Type: %s, UID: %s, Locale: %s)",
|
|
63
|
+
"ENTRIES_EXPORT_VERSIONS_FAILED": "Failed to export versions for content type '%s' (UID: %s)",
|
|
64
|
+
|
|
65
|
+
"BRANCH_EXPORT_FAILED": "Failed to export contents from branch (UID: %s)",
|
|
66
|
+
|
|
67
|
+
"ROLES_NO_CUSTOM_ROLES": "No custom roles found in the current stack",
|
|
68
|
+
"ROLES_EXPORTING_ROLE": "Exporting role '%s'"
|
|
69
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -118,6 +118,14 @@
|
|
|
118
118
|
"required": false,
|
|
119
119
|
"allowNo": false,
|
|
120
120
|
"type": "boolean"
|
|
121
|
+
},
|
|
122
|
+
"query": {
|
|
123
|
+
"description": "[optional] Query object (inline JSON or file path) to filter module exports.",
|
|
124
|
+
"hidden": true,
|
|
125
|
+
"name": "query",
|
|
126
|
+
"hasDynamicHelp": false,
|
|
127
|
+
"multiple": false,
|
|
128
|
+
"type": "option"
|
|
121
129
|
}
|
|
122
130
|
},
|
|
123
131
|
"hasDynamicHelp": false,
|
|
@@ -138,5 +146,5 @@
|
|
|
138
146
|
]
|
|
139
147
|
}
|
|
140
148
|
},
|
|
141
|
-
"version": "1.
|
|
149
|
+
"version": "1.18.0"
|
|
142
150
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-export",
|
|
3
3
|
"description": "Contentstack CLI plugin to export content from stack",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.18.0",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~1.
|
|
9
|
-
"@contentstack/cli-variants": "~1.
|
|
8
|
+
"@contentstack/cli-command": "~1.6.0",
|
|
9
|
+
"@contentstack/cli-variants": "~1.3.0",
|
|
10
10
|
"@oclif/core": "^4.3.3",
|
|
11
|
-
"@contentstack/cli-utilities": "~1.
|
|
11
|
+
"@contentstack/cli-utilities": "~1.13.0",
|
|
12
12
|
"async": "^3.2.6",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|