@contentstack/cli-cm-export 2.0.0-beta.4 → 2.0.0-beta.5
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 +1 -1
- package/lib/commands/cm/stacks/export.js +2 -2
- package/lib/export/modules/assets.js +1 -1
- package/lib/export/modules/composable-studio.js +1 -1
- package/lib/export/modules/content-types.js +1 -1
- package/lib/export/modules/custom-roles.js +1 -1
- package/lib/export/modules/entries.js +3 -3
- package/lib/export/modules/environments.js +1 -1
- package/lib/export/modules/extensions.js +1 -1
- package/lib/export/modules/global-fields.js +1 -1
- package/lib/export/modules/labels.js +1 -1
- package/lib/export/modules/locales.js +1 -1
- package/lib/export/modules/marketplace-apps.js +2 -2
- package/lib/export/modules/stack.js +12 -12
- package/lib/export/modules/taxonomies.js +2 -2
- package/lib/export/modules/webhooks.js +1 -1
- package/lib/export/modules/workflows.js +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/utils/basic-login.d.ts +1 -1
- package/lib/utils/basic-login.js +4 -4
- package/lib/utils/common-helper.d.ts +1 -1
- package/lib/utils/common-helper.js +4 -4
- package/lib/utils/export-config-handler.js +2 -6
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +2 -2
- package/lib/utils/marketplace-app-helper.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +8 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
|
|
|
48
48
|
$ csdx COMMAND
|
|
49
49
|
running command...
|
|
50
50
|
$ csdx (--version)
|
|
51
|
-
@contentstack/cli-cm-export/2.0.0-beta.
|
|
51
|
+
@contentstack/cli-cm-export/2.0.0-beta.5 linux-x64 node-v22.22.0
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
|
@@ -16,11 +16,11 @@ class ExportCommand extends cli_command_1.Command {
|
|
|
16
16
|
exportConfig.context = Object.assign({}, context);
|
|
17
17
|
// Assign exportConfig variables
|
|
18
18
|
this.assignExportConfig(exportConfig);
|
|
19
|
-
exportDir = (0, cli_utilities_1.sanitizePath)(exportConfig.cliLogsPath || exportConfig.
|
|
19
|
+
exportDir = (0, cli_utilities_1.sanitizePath)(exportConfig.cliLogsPath || exportConfig.exportDir);
|
|
20
20
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)(exportConfig);
|
|
21
21
|
const moduleExporter = new export_1.ModuleExporter(managementAPIClient, exportConfig);
|
|
22
22
|
await moduleExporter.start();
|
|
23
|
-
cli_utilities_1.log.success(`The content of the stack ${exportConfig.apiKey} has been exported successfully
|
|
23
|
+
cli_utilities_1.log.success(`The content of the stack ${exportConfig.apiKey} has been exported successfully!`);
|
|
24
24
|
cli_utilities_1.log.info(`The exported content has been stored at '${exportDir}'`, exportConfig.context);
|
|
25
25
|
cli_utilities_1.log.success(`The log has been stored at '${(0, cli_utilities_1.getLogPath)()}'`, exportConfig.context);
|
|
26
26
|
// Print comprehensive summary at the end
|
|
@@ -36,7 +36,7 @@ class ExportAssets extends base_class_1.default {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
async start() {
|
|
39
|
-
this.assetsRootPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
39
|
+
this.assetsRootPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.assetConfig.dirName);
|
|
40
40
|
cli_utilities_1.log.debug(`Assets root path resolved to: ${this.assetsRootPath}`, this.exportConfig.context);
|
|
41
41
|
cli_utilities_1.log.debug('Fetching assets and folders count...', this.exportConfig.context);
|
|
42
42
|
// NOTE step 1: Get assets and it's folder count in parallel
|
|
@@ -19,7 +19,7 @@ class ExportComposableStudio {
|
|
|
19
19
|
cli_utilities_1.cliux.print('WARNING!!! To export Studio projects, you must be logged in. Please check csdx auth:login --help to log in', { color: 'yellow' });
|
|
20
20
|
return Promise.resolve();
|
|
21
21
|
}
|
|
22
|
-
this.composableStudioPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
22
|
+
this.composableStudioPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.composableStudioConfig.dirName);
|
|
23
23
|
cli_utilities_1.log.debug(`Studio folder path: ${this.composableStudioPath}`, this.exportConfig.context);
|
|
24
24
|
await utils_1.fsUtil.makeDirectory(this.composableStudioPath);
|
|
25
25
|
cli_utilities_1.log.debug('Created Studio directory', this.exportConfig.context);
|
|
@@ -22,7 +22,7 @@ class ContentTypesExport extends base_class_1.default {
|
|
|
22
22
|
}
|
|
23
23
|
// Add after existing qs setup and before contentTypesDirPath
|
|
24
24
|
this.applyQueryFilters(this.qs, 'content-types');
|
|
25
|
-
this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.
|
|
25
|
+
this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.contentTypesConfig.dirName));
|
|
26
26
|
this.contentTypes = [];
|
|
27
27
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.CONTENT_TYPES;
|
|
28
28
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.CONTENT_TYPES];
|
|
@@ -25,7 +25,7 @@ class ExportCustomRoles extends base_class_1.default {
|
|
|
25
25
|
cli_utilities_1.log.debug('Starting custom roles export process...', this.exportConfig.context);
|
|
26
26
|
const [totalRoles, totalLocales] = await this.withLoadingSpinner('CUSTOM-ROLES: Analyzing roles and locales...', async () => {
|
|
27
27
|
var _a;
|
|
28
|
-
this.rolesFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
28
|
+
this.rolesFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.customRolesConfig.dirName);
|
|
29
29
|
await utils_1.fsUtil.makeDirectory(this.rolesFolderPath);
|
|
30
30
|
this.customRolesLocalesFilepath = (0, node_path_1.resolve)(this.rolesFolderPath, this.customRolesConfig.customRolesLocalesFileName);
|
|
31
31
|
// Get counts for progress tracking
|
|
@@ -14,9 +14,9 @@ class EntriesExport extends base_class_1.default {
|
|
|
14
14
|
this.stackAPIClient = stackAPIClient;
|
|
15
15
|
this.exportConfig = exportConfig;
|
|
16
16
|
this.entriesConfig = exportConfig.modules.entries;
|
|
17
|
-
this.entriesDirPath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.
|
|
18
|
-
this.localesFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.
|
|
19
|
-
this.schemaFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.
|
|
17
|
+
this.entriesDirPath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(this.entriesConfig.dirName));
|
|
18
|
+
this.localesFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
19
|
+
this.schemaFilePath = path.resolve((0, cli_utilities_2.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_2.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_2.sanitizePath)(exportConfig.modules.content_types.dirName), 'schema.json');
|
|
20
20
|
this.projectInstance = new cli_variants_1.ExportProjects(this.exportConfig);
|
|
21
21
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.ENTRIES;
|
|
22
22
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.ENTRIES];
|
|
@@ -21,7 +21,7 @@ class ExportEnvironments extends base_class_1.default {
|
|
|
21
21
|
cli_utilities_1.log.debug('Starting environment export process...', this.exportConfig.context);
|
|
22
22
|
// Setup with loading spinner
|
|
23
23
|
const [totalCount] = await this.withLoadingSpinner('ENVIRONMENTS: Analyzing environments...', async () => {
|
|
24
|
-
this.environmentsFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
24
|
+
this.environmentsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.environmentConfig.dirName);
|
|
25
25
|
await utils_1.fsUtil.makeDirectory(this.environmentsFolderPath);
|
|
26
26
|
cli_utilities_1.log.debug(`Environments folder path: ${this.environmentsFolderPath}`, this.exportConfig.context);
|
|
27
27
|
// Get count for progress tracking
|
|
@@ -22,7 +22,7 @@ class ExportExtensions extends base_class_1.default {
|
|
|
22
22
|
cli_utilities_1.log.debug('Starting extensions export process...', this.exportConfig.context);
|
|
23
23
|
// Setup with loading spinner
|
|
24
24
|
const [totalCount] = await this.withLoadingSpinner('EXTENSIONS: Analyzing extensions...', async () => {
|
|
25
|
-
this.extensionsFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
25
|
+
this.extensionsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.extensionConfig.dirName);
|
|
26
26
|
await utils_1.fsUtil.makeDirectory(this.extensionsFolderPath);
|
|
27
27
|
cli_utilities_1.log.debug(`Extensions folder path: ${this.extensionsFolderPath}`, this.exportConfig.context);
|
|
28
28
|
// Get count for progress tracking
|
|
@@ -17,7 +17,7 @@ class GlobalFieldsExport extends base_class_1.default {
|
|
|
17
17
|
limit: this.globalFieldsConfig.limit,
|
|
18
18
|
include_global_field_schema: true,
|
|
19
19
|
};
|
|
20
|
-
this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.
|
|
20
|
+
this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.globalFieldsConfig.dirName));
|
|
21
21
|
this.globalFields = [];
|
|
22
22
|
this.applyQueryFilters(this.qs, 'global-fields');
|
|
23
23
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.GLOBAL_FIELDS;
|
|
@@ -21,7 +21,7 @@ class ExportLabels extends base_class_1.default {
|
|
|
21
21
|
cli_utilities_1.log.debug('Starting labels export process...', this.exportConfig.context);
|
|
22
22
|
// Setup with loading spinner
|
|
23
23
|
const [totalCount] = await this.withLoadingSpinner('LABELS: Analyzing labels...', async () => {
|
|
24
|
-
this.labelsFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
24
|
+
this.labelsFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.labelConfig.dirName);
|
|
25
25
|
await utils_1.fsUtil.makeDirectory(this.labelsFolderPath);
|
|
26
26
|
cli_utilities_1.log.debug(`Labels folder path: ${this.labelsFolderPath}`, this.exportConfig.context);
|
|
27
27
|
// Get count for progress tracking
|
|
@@ -18,7 +18,7 @@ class LocaleExport extends base_class_1.default {
|
|
|
18
18
|
BASE: this.localeConfig.requiredKeys,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.
|
|
21
|
+
this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.localeConfig.dirName));
|
|
22
22
|
this.locales = {};
|
|
23
23
|
this.masterLocale = {};
|
|
24
24
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.LOCALES;
|
|
@@ -74,14 +74,14 @@ class ExportMarketplaceApps extends base_class_1.default {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
async setupPaths() {
|
|
77
|
-
this.marketplaceAppPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
77
|
+
this.marketplaceAppPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.marketplaceAppConfig.dirName);
|
|
78
78
|
cli_utilities_1.log.debug(`Marketplace apps folder path: '${this.marketplaceAppPath}'`, this.exportConfig.context);
|
|
79
79
|
await utils_1.fsUtil.makeDirectory(this.marketplaceAppPath);
|
|
80
80
|
cli_utilities_1.log.debug('Created marketplace apps directory', this.exportConfig.context);
|
|
81
81
|
this.developerHubBaseUrl = this.exportConfig.developerHubBaseUrl || (await (0, utils_1.getDeveloperHubUrl)(this.exportConfig));
|
|
82
82
|
cli_utilities_1.log.debug(`Developer hub base URL: '${this.developerHubBaseUrl}'`, this.exportConfig.context);
|
|
83
83
|
this.exportConfig.org_uid = await (0, utils_1.getOrgUid)(this.exportConfig);
|
|
84
|
-
this.query = { target_uids: this.exportConfig.
|
|
84
|
+
this.query = { target_uids: this.exportConfig.apiKey };
|
|
85
85
|
cli_utilities_1.log.debug(`Organization UID: '${this.exportConfig.org_uid}'.`, this.exportConfig.context);
|
|
86
86
|
// NOTE init marketplace app sdk
|
|
87
87
|
const host = this.developerHubBaseUrl.split('://').pop();
|
|
@@ -11,7 +11,7 @@ class ExportStack extends base_class_1.default {
|
|
|
11
11
|
super({ exportConfig, stackAPIClient });
|
|
12
12
|
this.stackConfig = exportConfig.modules.stack;
|
|
13
13
|
this.qs = { include_count: true };
|
|
14
|
-
this.stackFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
14
|
+
this.stackFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.stackConfig.dirName);
|
|
15
15
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.STACK;
|
|
16
16
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.STACK];
|
|
17
17
|
}
|
|
@@ -92,18 +92,18 @@ class ExportStack extends base_class_1.default {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async getStack() {
|
|
95
|
-
cli_utilities_1.log.debug(`Fetching stack data for: '${this.exportConfig.
|
|
95
|
+
cli_utilities_1.log.debug(`Fetching stack data for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);
|
|
96
96
|
const tempAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.exportConfig.host });
|
|
97
97
|
cli_utilities_1.log.debug(`Created Management SDK client with host: '${this.exportConfig.host}'.`, this.exportConfig.context);
|
|
98
98
|
return await tempAPIClient
|
|
99
|
-
.stack({ api_key: this.exportConfig.
|
|
99
|
+
.stack({ api_key: this.exportConfig.apiKey })
|
|
100
100
|
.fetch()
|
|
101
101
|
.then((data) => {
|
|
102
|
-
cli_utilities_1.log.debug(`Successfully fetched stack data for: '${this.exportConfig.
|
|
102
|
+
cli_utilities_1.log.debug(`Successfully fetched stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
|
|
103
103
|
return data;
|
|
104
104
|
})
|
|
105
105
|
.catch((error) => {
|
|
106
|
-
cli_utilities_1.log.debug(`Failed to fetch stack data for: '${this.exportConfig.
|
|
106
|
+
cli_utilities_1.log.debug(`Failed to fetch stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
|
|
107
107
|
return {};
|
|
108
108
|
});
|
|
109
109
|
}
|
|
@@ -140,7 +140,7 @@ class ExportStack extends base_class_1.default {
|
|
|
140
140
|
return masterLocalObj;
|
|
141
141
|
}
|
|
142
142
|
else if (skip >= count) {
|
|
143
|
-
cli_utilities_1.log.error(`Locale locale not found in the stack ${this.exportConfig.
|
|
143
|
+
cli_utilities_1.log.error(`Locale locale not found in the stack ${this.exportConfig.apiKey}. Please ensure that the stack has a master locale.`, this.exportConfig.context);
|
|
144
144
|
cli_utilities_1.log.debug('Completed search. Master locale not found.', this.exportConfig.context);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -155,14 +155,14 @@ class ExportStack extends base_class_1.default {
|
|
|
155
155
|
})
|
|
156
156
|
.catch((error) => {
|
|
157
157
|
var _a;
|
|
158
|
-
cli_utilities_1.log.debug(`Error occurred while fetching locales for stack: ${this.exportConfig.
|
|
158
|
+
cli_utilities_1.log.debug(`Error occurred while fetching locales for stack: ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
159
159
|
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, 'locale fetch', (error === null || error === void 0 ? void 0 : error.message) || utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.STACK_LOCALE].FAILED, utils_1.PROCESS_NAMES.STACK_LOCALE);
|
|
160
|
-
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), `Failed to fetch locales for stack ${this.exportConfig.
|
|
160
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context), `Failed to fetch locales for stack ${this.exportConfig.apiKey}`);
|
|
161
161
|
throw error;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
async exportStack() {
|
|
165
|
-
cli_utilities_1.log.debug(`Starting stack export for: '${this.exportConfig.
|
|
165
|
+
cli_utilities_1.log.debug(`Starting stack export for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);
|
|
166
166
|
await utils_1.fsUtil.makeDirectory(this.stackFolderPath);
|
|
167
167
|
cli_utilities_1.log.debug(`Created stack directory at: '${this.stackFolderPath}'`, this.exportConfig.context);
|
|
168
168
|
return this.stack
|
|
@@ -173,14 +173,14 @@ class ExportStack extends base_class_1.default {
|
|
|
173
173
|
cli_utilities_1.log.debug(`Writing stack data to: '${stackFilePath}'`, this.exportConfig.context);
|
|
174
174
|
utils_1.fsUtil.writeFile(stackFilePath, resp);
|
|
175
175
|
// Track progress for stack export completion
|
|
176
|
-
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `stack: ${this.exportConfig.
|
|
177
|
-
cli_utilities_1.log.success(`Stack details exported successfully for stack ${this.exportConfig.
|
|
176
|
+
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(true, `stack: ${this.exportConfig.apiKey}`, null, utils_1.PROCESS_NAMES.STACK_DETAILS);
|
|
177
|
+
cli_utilities_1.log.success(`Stack details exported successfully for stack ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
178
178
|
cli_utilities_1.log.debug('Stack export completed successfully.', this.exportConfig.context);
|
|
179
179
|
return resp;
|
|
180
180
|
})
|
|
181
181
|
.catch((error) => {
|
|
182
182
|
var _a;
|
|
183
|
-
cli_utilities_1.log.debug(`Error occurred while exporting stack: ${this.exportConfig.
|
|
183
|
+
cli_utilities_1.log.debug(`Error occurred while exporting stack: ${this.exportConfig.apiKey}`, this.exportConfig.context);
|
|
184
184
|
(_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.tick(false, 'stack export', (error === null || error === void 0 ? void 0 : error.message) || utils_1.PROCESS_STATUS[utils_1.PROCESS_NAMES.STACK_DETAILS].FAILED, utils_1.PROCESS_NAMES.STACK_DETAILS);
|
|
185
185
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.exportConfig.context));
|
|
186
186
|
});
|
|
@@ -18,13 +18,13 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
18
18
|
this.qs = { include_count: true, limit: this.taxonomiesConfig.limit || 100, skip: 0 };
|
|
19
19
|
this.applyQueryFilters(this.qs, 'taxonomies');
|
|
20
20
|
this.exportConfig.context.module = 'taxonomies';
|
|
21
|
-
this.localesFilePath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.
|
|
21
|
+
this.localesFilePath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
22
22
|
}
|
|
23
23
|
async start() {
|
|
24
24
|
var _a;
|
|
25
25
|
cli_utilities_1.log.debug('Starting export process for taxonomies...', this.exportConfig.context);
|
|
26
26
|
//create taxonomies folder
|
|
27
|
-
this.taxonomiesFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
27
|
+
this.taxonomiesFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.taxonomiesConfig.dirName);
|
|
28
28
|
cli_utilities_1.log.debug(`Taxonomies folder path: '${this.taxonomiesFolderPath}'`, this.exportConfig.context);
|
|
29
29
|
await utils_1.fsUtil.makeDirectory(this.taxonomiesFolderPath);
|
|
30
30
|
cli_utilities_1.log.debug('Created taxonomies directory.', this.exportConfig.context);
|
|
@@ -21,7 +21,7 @@ class ExportWebhooks extends base_class_1.default {
|
|
|
21
21
|
cli_utilities_1.log.debug('Starting webhooks export process...', this.exportConfig.context);
|
|
22
22
|
// Setup with loading spinner
|
|
23
23
|
const [totalCount] = await this.withLoadingSpinner('WEBHOOKS: Analyzing webhooks...', async () => {
|
|
24
|
-
this.webhooksFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
24
|
+
this.webhooksFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.webhookConfig.dirName);
|
|
25
25
|
await utils_1.fsUtil.makeDirectory(this.webhooksFolderPath);
|
|
26
26
|
// Get count for progress tracking
|
|
27
27
|
const countResponse = await this.stack.webhook().fetchAll(Object.assign(Object.assign({}, this.qs), { limit: 1 }));
|
|
@@ -22,7 +22,7 @@ class ExportWorkFlows extends base_class_1.default {
|
|
|
22
22
|
// Setup with loading spinner
|
|
23
23
|
const [totalCount] = await this.withLoadingSpinner('WORKFLOWS: Analyzing workflows...', async () => {
|
|
24
24
|
var _a;
|
|
25
|
-
this.webhooksFolderPath = (0, node_path_1.resolve)(this.exportConfig.
|
|
25
|
+
this.webhooksFolderPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', this.workflowConfig.dirName);
|
|
26
26
|
await utils_1.fsUtil.makeDirectory(this.webhooksFolderPath);
|
|
27
27
|
// Get count for progress tracking
|
|
28
28
|
const countResponse = await this.stack.workflow().fetchAll(Object.assign(Object.assign({}, this.qs), { limit: 1 }));
|
package/lib/types/index.d.ts
CHANGED
package/lib/utils/basic-login.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* eslint-disable no-empty */
|
|
5
5
|
/*!
|
|
6
6
|
* Contentstack Import
|
|
7
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2026 Contentstack LLC
|
|
8
8
|
* MIT Licensed
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -16,7 +16,7 @@ const login = async (config) => {
|
|
|
16
16
|
const response = await client.login({ email: config.email, password: config.password }).catch(Promise.reject);
|
|
17
17
|
if ((_a = response === null || response === void 0 ? void 0 : response.user) === null || _a === void 0 ? void 0 : _a.authtoken) {
|
|
18
18
|
config.headers = {
|
|
19
|
-
api_key: config.
|
|
19
|
+
api_key: config.apiKey,
|
|
20
20
|
access_token: config.access_token,
|
|
21
21
|
authtoken: response.user.authtoken,
|
|
22
22
|
'X-User-Agent': 'contentstack-export/v',
|
|
@@ -30,11 +30,11 @@ const login = async (config) => {
|
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
else if (!config.email && !config.password && config.
|
|
33
|
+
else if (!config.email && !config.password && config.apiKey && config.access_token) {
|
|
34
34
|
cli_utilities_1.log.info(`Content types, entries, assets, labels, global fields, extensions modules will be exported`, config.context);
|
|
35
35
|
cli_utilities_1.log.info(`Email, password, or management token is not set in the config, cannot export Webhook and label modules`, config.context);
|
|
36
36
|
config.headers = {
|
|
37
|
-
api_key: config.
|
|
37
|
+
api_key: config.apiKey,
|
|
38
38
|
access_token: config.access_token,
|
|
39
39
|
'X-User-Agent': 'contentstack-export/v',
|
|
40
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* Contentstack Export
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) 2026 Contentstack LLC
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -13,13 +13,13 @@ const validateConfig = function (config) {
|
|
|
13
13
|
if (!config.host || !config.cdn) {
|
|
14
14
|
throw new Error('Host/CDN end point is missing from config');
|
|
15
15
|
}
|
|
16
|
-
if (config.email && config.password && !config.access_token && !config.
|
|
16
|
+
if (config.email && config.password && !config.access_token && !config.apiKey) {
|
|
17
17
|
throw new Error('Kindly provide access_token or api_token');
|
|
18
18
|
}
|
|
19
19
|
else if (!config.email &&
|
|
20
20
|
!config.password &&
|
|
21
21
|
!config.management_token &&
|
|
22
|
-
config.
|
|
22
|
+
config.apiKey &&
|
|
23
23
|
!config.access_token &&
|
|
24
24
|
!(0, cli_utilities_1.isAuthenticated)()) {
|
|
25
25
|
throw new Error('Kindly provide management_token or email and password');
|
|
@@ -27,7 +27,7 @@ const validateConfig = function (config) {
|
|
|
27
27
|
else if (config.email &&
|
|
28
28
|
config.password &&
|
|
29
29
|
!config.access_token &&
|
|
30
|
-
config.
|
|
30
|
+
config.apiKey &&
|
|
31
31
|
!config.management_token &&
|
|
32
32
|
!(0, cli_utilities_1.isAuthenticated)()) {
|
|
33
33
|
throw new Error('Kindly provide access_token or management_token');
|
|
@@ -23,7 +23,7 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
23
23
|
const externalConfig = await (0, file_helper_1.readFile)(exportCmdFlags['config']);
|
|
24
24
|
config = merge_1.default.recursive(config, externalConfig);
|
|
25
25
|
}
|
|
26
|
-
config.exportDir = (0, cli_utilities_1.sanitizePath)(exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.
|
|
26
|
+
config.exportDir = (0, cli_utilities_1.sanitizePath)(exportCmdFlags['data'] || exportCmdFlags['data-dir'] || config.exportDir || (await (0, interactive_1.askExportDir)()));
|
|
27
27
|
const pattern = /[*$%#<>{}!&?]/g;
|
|
28
28
|
if (pattern.test(config.exportDir)) {
|
|
29
29
|
cli_utilities_1.cliux.print(`\nPlease enter a directory path without any special characters: (*,&,{,},[,],$,%,<,>,?,!)`, {
|
|
@@ -33,8 +33,6 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
33
33
|
}
|
|
34
34
|
config.exportDir = config.exportDir.replace(/['"]/g, '');
|
|
35
35
|
config.exportDir = path.resolve(config.exportDir);
|
|
36
|
-
//Note to support the old key
|
|
37
|
-
config.data = config.exportDir;
|
|
38
36
|
const managementTokenAlias = exportCmdFlags['management-token-alias'] || exportCmdFlags['alias'];
|
|
39
37
|
if (managementTokenAlias) {
|
|
40
38
|
cli_utilities_1.log.debug('Using management token alias', { alias: managementTokenAlias });
|
|
@@ -74,15 +72,13 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
74
72
|
cli_utilities_1.log.debug('User authenticated via auth token');
|
|
75
73
|
}
|
|
76
74
|
config.apiKey =
|
|
77
|
-
exportCmdFlags['stack-uid'] || exportCmdFlags['stack-api-key'] || config.
|
|
75
|
+
exportCmdFlags['stack-uid'] || exportCmdFlags['stack-api-key'] || config.apiKey || (await (0, interactive_1.askAPIKey)());
|
|
78
76
|
if (typeof config.apiKey !== 'string') {
|
|
79
77
|
cli_utilities_1.log.debug('Invalid API key received!', { apiKey: config.apiKey });
|
|
80
78
|
throw new Error('Invalid API key received');
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
|
-
// Note support old config
|
|
85
|
-
config.source_stack = config.apiKey;
|
|
86
82
|
config.forceStopMarketplaceAppsPrompt = exportCmdFlags.yes;
|
|
87
83
|
config.auth_token = cli_utilities_1.configHandler.get('authtoken'); // TBD handle auth token in httpClient & sdk
|
|
88
84
|
config.isAuthenticated = (0, cli_utilities_1.isAuthenticated)();
|
package/lib/utils/logger.d.ts
CHANGED
package/lib/utils/logger.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* Contentstack Export
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) 2026 Contentstack LLC
|
|
5
5
|
* MIT Licensed
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -126,7 +126,7 @@ function init(_logPath) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
const log = async (config, message, type) => {
|
|
129
|
-
const logsPath = (0, cli_utilities_1.sanitizePath)(config.cliLogsPath || config.
|
|
129
|
+
const logsPath = (0, cli_utilities_1.sanitizePath)(config.cliLogsPath || config.exportDir);
|
|
130
130
|
// ignoring the type argument, as we are not using it to create a logfile anymore
|
|
131
131
|
if (type !== 'error') {
|
|
132
132
|
// removed type argument from init method
|
|
@@ -9,7 +9,7 @@ exports.getDeveloperHubUrl = getDeveloperHubUrl;
|
|
|
9
9
|
async function getOrgUid(config) {
|
|
10
10
|
const tempAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: config.host });
|
|
11
11
|
const tempStackData = await tempAPIClient
|
|
12
|
-
.stack({ api_key: config.
|
|
12
|
+
.stack({ api_key: config.apiKey })
|
|
13
13
|
.fetch()
|
|
14
14
|
.catch((error) => {
|
|
15
15
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, config.context));
|
package/oclif.manifest.json
CHANGED
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.5",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~1.7.
|
|
9
|
-
"@
|
|
10
|
-
"@contentstack/cli-variants": "~2.0.0-beta.
|
|
11
|
-
"@
|
|
8
|
+
"@contentstack/cli-command": "~1.7.2",
|
|
9
|
+
"@contentstack/cli-utilities": "~1.17.0",
|
|
10
|
+
"@contentstack/cli-variants": "~2.0.0-beta.4",
|
|
11
|
+
"@oclif/core": "^4.8.0",
|
|
12
12
|
"async": "^3.2.6",
|
|
13
13
|
"big-json": "^3.2.0",
|
|
14
14
|
"bluebird": "^3.7.2",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"winston": "^3.17.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@contentstack/cli-auth": "~
|
|
25
|
-
"@contentstack/cli-config": "~1.
|
|
24
|
+
"@contentstack/cli-auth": "~2.0.0-beta.1",
|
|
25
|
+
"@contentstack/cli-config": "~1.18.0",
|
|
26
26
|
"@contentstack/cli-dev-dependencies": "~1.3.1",
|
|
27
27
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
28
|
"@oclif/test": "^4.1.13",
|
|
@@ -94,4 +94,4 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"repository": "https://github.com/contentstack/cli"
|
|
97
|
-
}
|
|
97
|
+
}
|