@contentstack/cli-cm-export 2.0.0-beta.14 → 2.0.0-beta.16
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/config/index.js +5 -0
- package/lib/export/module-exporter.js +5 -4
- package/lib/export/modules/assets.js +45 -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 +4 -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 +1 -1
- package/lib/export/modules/stack.js +11 -10
- 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/default-config.d.ts +9 -0
- package/lib/types/export-config.d.ts +5 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/constants.d.ts +13 -0
- package/lib/utils/constants.js +15 -0
- package/lib/utils/export-config-handler.js +3 -0
- package/lib/utils/file-helper.d.ts +4 -0
- package/lib/utils/file-helper.js +26 -1
- package/lib/utils/get-linked-workspaces.d.ts +13 -0
- package/lib/utils/get-linked-workspaces.js +32 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -1
- package/lib/utils/path-helper.d.ts +6 -0
- package/lib/utils/path-helper.js +11 -0
- package/lib/utils/progress-strategy-registry.js +18 -0
- package/lib/utils/setup-branches.js +0 -6
- package/lib/utils/setup-export-dir.d.ts +1 -1
- package/lib/utils/setup-export-dir.js +1 -6
- package/oclif.manifest.json +1 -1
- package/package.json +9 -8
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.16 linux-x64 node-v22.22.2
|
|
52
52
|
$ csdx --help [COMMAND]
|
|
53
53
|
USAGE
|
|
54
54
|
$ csdx COMMAND
|
package/lib/config/index.js
CHANGED
|
@@ -112,6 +112,11 @@ const config = {
|
|
|
112
112
|
enableDownloadStatus: false,
|
|
113
113
|
includeVersionedAssets: false,
|
|
114
114
|
},
|
|
115
|
+
'asset-management': {
|
|
116
|
+
chunkFileSizeMb: 1,
|
|
117
|
+
apiConcurrency: 5,
|
|
118
|
+
downloadAssetsConcurrency: 5,
|
|
119
|
+
},
|
|
115
120
|
content_types: {
|
|
116
121
|
dirName: 'content_types',
|
|
117
122
|
fileName: 'content_types.json',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const path = tslib_1.__importStar(require("path"));
|
|
5
4
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
5
|
const modules_1 = tslib_1.__importDefault(require("./modules"));
|
|
7
6
|
const utils_1 = require("../utils");
|
|
@@ -36,6 +35,7 @@ class ModuleExporter {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
async exportByBranches() {
|
|
38
|
+
var _a;
|
|
39
39
|
let targetBranch;
|
|
40
40
|
if (this.exportConfig.branchName) {
|
|
41
41
|
// User specified a branch - export only that branch
|
|
@@ -54,7 +54,6 @@ class ModuleExporter {
|
|
|
54
54
|
try {
|
|
55
55
|
this.exportConfig.branchName = targetBranch.uid;
|
|
56
56
|
this.stackAPIClient.stackHeaders.branch = targetBranch.uid;
|
|
57
|
-
this.exportConfig.branchDir = path.join(this.exportConfig.exportDir, targetBranch.uid);
|
|
58
57
|
// Initialize progress manager for the target branch
|
|
59
58
|
cli_utilities_1.CLIProgressManager.clearGlobalSummary();
|
|
60
59
|
cli_utilities_1.CLIProgressManager.initializeGlobalSummary(`EXPORT-${targetBranch.uid}`, targetBranch.uid, `Exporting "${targetBranch.uid}" branch content...`);
|
|
@@ -64,8 +63,10 @@ class ModuleExporter {
|
|
|
64
63
|
cli_utilities_1.log.success(`The content of branch ${targetBranch.uid} has been exported successfully!`, this.exportConfig.context);
|
|
65
64
|
}
|
|
66
65
|
catch (error) {
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const originalMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
|
|
67
|
+
const errorMessage = originalMessage || cli_utilities_1.messageHandler.parse('FAILED_EXPORT_CONTENT_BRANCH', { branch: targetBranch === null || targetBranch === void 0 ? void 0 : targetBranch.uid });
|
|
68
|
+
(0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.exportConfig.context), { branch: targetBranch === null || targetBranch === void 0 ? void 0 : targetBranch.uid }), errorMessage);
|
|
69
|
+
throw new Error(errorMessage);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
async export() {
|
|
@@ -19,6 +19,7 @@ const cli_utilities_2 = require("@contentstack/cli-utilities");
|
|
|
19
19
|
const constants_1 = require("../../constants");
|
|
20
20
|
const config_1 = tslib_1.__importDefault(require("../../config"));
|
|
21
21
|
const base_class_1 = tslib_1.__importDefault(require("./base-class"));
|
|
22
|
+
const cli_asset_management_1 = require("@contentstack/cli-asset-management");
|
|
22
23
|
const utils_1 = require("../../utils");
|
|
23
24
|
class ExportAssets extends base_class_1.default {
|
|
24
25
|
constructor({ exportConfig, stackAPIClient }) {
|
|
@@ -37,7 +38,50 @@ class ExportAssets extends base_class_1.default {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
async start() {
|
|
40
|
-
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
|
+
const linkedWorkspaces = (_a = this.exportConfig.linkedWorkspaces) !== null && _a !== void 0 ? _a : [];
|
|
43
|
+
if (linkedWorkspaces.length > 0) {
|
|
44
|
+
const assetManagementUrl = (_b = this.exportConfig.region) === null || _b === void 0 ? void 0 : _b.assetManagementUrl;
|
|
45
|
+
if (!assetManagementUrl) {
|
|
46
|
+
(0, cli_utilities_2.handleAndLogError)(new Error('Asset Management URL is required for AM 2.0 export. Ensure your region is configured with assetManagementUrl.'), Object.assign(Object.assign({}, this.exportConfig.context), { message: 'Asset Management URL is required for AM 2.0 export. Ensure your region is configured with assetManagementUrl.' }));
|
|
47
|
+
this.completeProgressWithMessage({
|
|
48
|
+
moduleName: 'Asset Management 2.0',
|
|
49
|
+
customWarningMessage: 'Asset Management 2.0 export was skipped: assetManagementUrl is not configured. AM 2.0 assets will not be exported.',
|
|
50
|
+
context: this.exportConfig.context,
|
|
51
|
+
});
|
|
52
|
+
cli_utilities_1.cliux.print('Asset Management URL is required for AM 2.0 export. Ensure your region is configured with assetManagementUrl.', { color: 'yellow' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
cli_utilities_2.log.debug(`Exporting with AM 2.0: ${assetManagementUrl} (linked_workspaces from exportConfig)`, this.exportConfig.context);
|
|
56
|
+
this.exportConfig.org_uid = this.exportConfig.org_uid || (await (0, utils_1.getOrgUid)(this.exportConfig));
|
|
57
|
+
const progress = this.createNestedProgress(this.currentModuleName);
|
|
58
|
+
try {
|
|
59
|
+
const assetManagementModuleConfig = this.exportConfig.modules['asset-management'];
|
|
60
|
+
const exporter = new cli_asset_management_1.ExportSpaces({
|
|
61
|
+
linkedWorkspaces,
|
|
62
|
+
exportDir: this.exportConfig.exportDir,
|
|
63
|
+
branchName: this.exportConfig.branchName || 'main',
|
|
64
|
+
assetManagementUrl,
|
|
65
|
+
org_uid: (_c = this.exportConfig.org_uid) !== null && _c !== void 0 ? _c : '',
|
|
66
|
+
apiKey: this.exportConfig.apiKey,
|
|
67
|
+
context: this.exportConfig.context,
|
|
68
|
+
securedAssets: this.exportConfig.securedAssets,
|
|
69
|
+
chunkFileSizeMb: assetManagementModuleConfig === null || assetManagementModuleConfig === void 0 ? void 0 : assetManagementModuleConfig.chunkFileSizeMb,
|
|
70
|
+
apiConcurrency: assetManagementModuleConfig === null || assetManagementModuleConfig === void 0 ? void 0 : assetManagementModuleConfig.apiConcurrency,
|
|
71
|
+
downloadAssetsConcurrency: assetManagementModuleConfig === null || assetManagementModuleConfig === void 0 ? void 0 : assetManagementModuleConfig.downloadAssetsConcurrency,
|
|
72
|
+
});
|
|
73
|
+
exporter.setParentProgressManager(progress);
|
|
74
|
+
await exporter.start();
|
|
75
|
+
this.completeProgressWithMessage();
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.completeProgress(false, (_d = error === null || error === void 0 ? void 0 : error.message) !== null && _d !== void 0 ? _d : 'Asset Management export failed');
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
cli_utilities_2.log.debug('Using legacy asset export (no linked_workspaces in exportConfig)', this.exportConfig.context);
|
|
84
|
+
this.assetsRootPath = (0, node_path_1.resolve)(this.exportConfig.exportDir, this.exportConfig.branchName || '', (this.assetsRootPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), this.assetConfig.dirName)));
|
|
41
85
|
cli_utilities_2.log.debug(`Assets root path resolved to: ${this.assetsRootPath}`, this.exportConfig.context);
|
|
42
86
|
cli_utilities_2.log.debug('Fetching assets and folders count...', this.exportConfig.context);
|
|
43
87
|
// 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)(
|
|
22
|
+
this.composableStudioPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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)(
|
|
25
|
+
this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)((0, utils_1.getExportBasePath)(exportConfig)), (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)(
|
|
28
|
+
this.rolesFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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,10 @@ 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
|
-
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
17
|
+
const basePath = (0, utils_1.getExportBasePath)(exportConfig);
|
|
18
|
+
this.entriesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(this.entriesConfig.dirName));
|
|
19
|
+
this.localesFilePath = path.resolve((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
20
|
+
this.contentTypesDirPath = path.resolve((0, cli_utilities_1.sanitizePath)(basePath), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.content_types.dirName));
|
|
20
21
|
this.projectInstance = new cli_variants_1.ExportProjects(this.exportConfig);
|
|
21
22
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.ENTRIES;
|
|
22
23
|
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)(
|
|
24
|
+
this.environmentsFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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)(
|
|
25
|
+
this.extensionsFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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)(
|
|
20
|
+
this.globalFieldsDirPath = path.resolve((0, cli_utilities_1.sanitizePath)((0, utils_1.getExportBasePath)(exportConfig)), (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)(
|
|
24
|
+
this.labelsFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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)(
|
|
21
|
+
this.localesPath = path.resolve((0, cli_utilities_1.sanitizePath)((0, utils_1.getExportBasePath)(exportConfig)), (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;
|
|
@@ -72,7 +72,7 @@ class ExportMarketplaceApps extends base_class_1.default {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async setupPaths() {
|
|
75
|
-
this.marketplaceAppPath = (0, node_path_1.resolve)(
|
|
75
|
+
this.marketplaceAppPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), this.marketplaceAppConfig.dirName);
|
|
76
76
|
cli_utilities_1.log.debug(`Marketplace apps folder path: '${this.marketplaceAppPath}'`, this.exportConfig.context);
|
|
77
77
|
await utils_1.fsUtil.makeDirectory(this.marketplaceAppPath);
|
|
78
78
|
cli_utilities_1.log.debug('Created marketplace apps directory', this.exportConfig.context);
|
|
@@ -13,7 +13,7 @@ class ExportStack extends base_class_1.default {
|
|
|
13
13
|
super({ exportConfig, stackAPIClient });
|
|
14
14
|
this.stackConfig = exportConfig.modules.stack;
|
|
15
15
|
this.qs = { include_count: true };
|
|
16
|
-
this.stackFolderPath = (0, node_path_1.resolve)(
|
|
16
|
+
this.stackFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), this.stackConfig.dirName);
|
|
17
17
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.STACK;
|
|
18
18
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.STACK];
|
|
19
19
|
}
|
|
@@ -196,10 +196,7 @@ class ExportStack extends base_class_1.default {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
isStackFetchPayload(data) {
|
|
199
|
-
return
|
|
200
|
-
data !== null &&
|
|
201
|
-
!Array.isArray(data) &&
|
|
202
|
-
('api_key' in data || 'uid' in data));
|
|
199
|
+
return typeof data === 'object' && data !== null && !Array.isArray(data) && ('api_key' in data || 'uid' in data);
|
|
203
200
|
}
|
|
204
201
|
/**
|
|
205
202
|
* Management-token exports cannot use Stack CMA endpoints for full metadata; write api_key from config only.
|
|
@@ -234,13 +231,17 @@ class ExportStack extends base_class_1.default {
|
|
|
234
231
|
await utils_1.fsUtil.makeDirectory(this.stackFolderPath);
|
|
235
232
|
return this.stack
|
|
236
233
|
.settings()
|
|
237
|
-
.then((resp) => {
|
|
238
|
-
var _a;
|
|
239
|
-
|
|
234
|
+
.then(async (resp) => {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
const linked = await (0, utils_1.getLinkedWorkspacesForBranch)(this.stack, this.exportConfig.branchName || 'main', this.exportConfig.context);
|
|
237
|
+
const settings = Object.assign(Object.assign({}, resp), { am_v2: Object.assign(Object.assign({}, ((_a = resp.am_v2) !== null && _a !== void 0 ? _a : {})), { linked_workspaces: linked }) });
|
|
238
|
+
utils_1.fsUtil.writeFile((0, node_path_1.resolve)(this.stackFolderPath, constants_1.PATH_CONSTANTS.FILES.SETTINGS), settings);
|
|
239
|
+
this.exportConfig.linkedWorkspaces = linked;
|
|
240
240
|
// Track progress for stack settings completion
|
|
241
|
-
(
|
|
241
|
+
(_b = this.progressManager) === null || _b === void 0 ? void 0 : _b.tick(true, 'stack settings', null, utils_1.PROCESS_NAMES.STACK_SETTINGS);
|
|
242
|
+
cli_utilities_1.log.debug(`Included ${linked.length} linked workspace(s) in settings`, this.exportConfig.context);
|
|
242
243
|
cli_utilities_1.log.success('Exported stack settings successfully!', this.exportConfig.context);
|
|
243
|
-
return
|
|
244
|
+
return settings;
|
|
244
245
|
})
|
|
245
246
|
.catch((error) => {
|
|
246
247
|
var _a;
|
|
@@ -19,7 +19,7 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
19
19
|
this.applyQueryFilters(this.qs, 'taxonomies');
|
|
20
20
|
this.exportConfig.context.module = utils_1.MODULE_CONTEXTS.TAXONOMIES;
|
|
21
21
|
this.currentModuleName = utils_1.MODULE_NAMES[utils_1.MODULE_CONTEXTS.TAXONOMIES];
|
|
22
|
-
this.localesFilePath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(
|
|
22
|
+
this.localesFilePath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)((0, utils_1.getExportBasePath)(exportConfig)), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.dirName), (0, cli_utilities_1.sanitizePath)(exportConfig.modules.locales.fileName));
|
|
23
23
|
}
|
|
24
24
|
async start() {
|
|
25
25
|
var _a;
|
|
@@ -62,7 +62,7 @@ class ExportTaxonomies extends base_class_1.default {
|
|
|
62
62
|
*/
|
|
63
63
|
async initializeExport() {
|
|
64
64
|
return this.withLoadingSpinner('TAXONOMIES: Analyzing taxonomy structure...', async () => {
|
|
65
|
-
this.taxonomiesFolderPath = (0, node_path_1.resolve)(
|
|
65
|
+
this.taxonomiesFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), this.taxonomiesConfig.dirName);
|
|
66
66
|
cli_utilities_1.log.debug(`Taxonomies folder path: '${this.taxonomiesFolderPath}'`, this.exportConfig.context);
|
|
67
67
|
await utils_1.fsUtil.makeDirectory(this.taxonomiesFolderPath);
|
|
68
68
|
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)(
|
|
24
|
+
this.webhooksFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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)(
|
|
25
|
+
this.webhooksFolderPath = (0, node_path_1.resolve)((0, utils_1.getExportBasePath)(this.exportConfig), 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 }));
|
|
@@ -84,6 +84,15 @@ export default interface DefaultConfig {
|
|
|
84
84
|
includeVersionedAssets: boolean;
|
|
85
85
|
dependencies?: Modules[];
|
|
86
86
|
};
|
|
87
|
+
'asset-management': {
|
|
88
|
+
/** Passed to FsUtility chunkFileSize (MB) when writing chunked export JSON. */
|
|
89
|
+
chunkFileSizeMb: number;
|
|
90
|
+
/** Shared export concurrency fallback used by AM 2.0 export. */
|
|
91
|
+
apiConcurrency: number;
|
|
92
|
+
/** Parallel downloads per AM workspace export. */
|
|
93
|
+
downloadAssetsConcurrency: number;
|
|
94
|
+
dependencies?: Modules[];
|
|
95
|
+
};
|
|
87
96
|
content_types: {
|
|
88
97
|
dirName: string;
|
|
89
98
|
fileName: string;
|
|
@@ -15,7 +15,6 @@ export default interface ExportConfig extends DefaultConfig {
|
|
|
15
15
|
contentTypes?: string[];
|
|
16
16
|
branches?: branch[];
|
|
17
17
|
branchEnabled?: boolean;
|
|
18
|
-
branchDir?: string;
|
|
19
18
|
singleModuleExport?: boolean;
|
|
20
19
|
moduleName?: Modules;
|
|
21
20
|
master_locale: masterLocale;
|
|
@@ -35,6 +34,11 @@ export default interface ExportConfig extends DefaultConfig {
|
|
|
35
34
|
skipStackSettings?: boolean;
|
|
36
35
|
skipDependencies?: boolean;
|
|
37
36
|
authenticationMethod?: string;
|
|
37
|
+
linkedWorkspaces?: Array<{
|
|
38
|
+
uid: string;
|
|
39
|
+
space_uid: string;
|
|
40
|
+
is_default: boolean;
|
|
41
|
+
}>;
|
|
38
42
|
}
|
|
39
43
|
type branch = {
|
|
40
44
|
uid: string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface Region {
|
|
|
25
25
|
cma: string;
|
|
26
26
|
cda: string;
|
|
27
27
|
uiHost: string;
|
|
28
|
+
assetManagementUrl?: string;
|
|
28
29
|
}
|
|
29
30
|
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'composable-studio';
|
|
30
31
|
export type ModuleClassParams = {
|
package/lib/utils/constants.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export declare const PROCESS_NAMES: {
|
|
|
2
2
|
readonly ASSET_FOLDERS: "Folders";
|
|
3
3
|
readonly ASSET_METADATA: "Metadata";
|
|
4
4
|
readonly ASSET_DOWNLOADS: "Downloads";
|
|
5
|
+
/** Used when Assets module runs Asset Management 2.0 path (spaces, metadata, folders, assets, downloads). */
|
|
6
|
+
readonly ASSET_MANAGEMENT_SPACES: "Spaces & assets";
|
|
7
|
+
readonly ASSET_MANAGEMENT_EXPORT: "Asset Management 2.0";
|
|
5
8
|
readonly FETCH_ROLES: "Fetch Roles";
|
|
6
9
|
readonly FETCH_LOCALES: "Fetch Locales";
|
|
7
10
|
readonly PROCESS_MAPPINGS: "Process Mappings";
|
|
@@ -23,6 +26,7 @@ export declare const PROCESS_NAMES: {
|
|
|
23
26
|
};
|
|
24
27
|
export declare const MODULE_CONTEXTS: {
|
|
25
28
|
readonly ASSETS: "assets";
|
|
29
|
+
readonly ASSET_MANAGEMENT: "asset-management";
|
|
26
30
|
readonly CONTENT_TYPES: "content-types";
|
|
27
31
|
readonly CUSTOM_ROLES: "custom-roles";
|
|
28
32
|
readonly ENTRIES: "entries";
|
|
@@ -40,6 +44,7 @@ export declare const MODULE_CONTEXTS: {
|
|
|
40
44
|
};
|
|
41
45
|
export declare const MODULE_NAMES: {
|
|
42
46
|
readonly assets: "Assets";
|
|
47
|
+
readonly "asset-management": "Asset Management 2.0";
|
|
43
48
|
readonly "content-types": "Content Types";
|
|
44
49
|
readonly "custom-roles": "Custom Roles";
|
|
45
50
|
readonly entries: "Entries";
|
|
@@ -69,6 +74,14 @@ export declare const PROCESS_STATUS: {
|
|
|
69
74
|
DOWNLOADING: string;
|
|
70
75
|
FAILED: string;
|
|
71
76
|
};
|
|
77
|
+
"Spaces & assets": {
|
|
78
|
+
EXPORTING: string;
|
|
79
|
+
FAILED: string;
|
|
80
|
+
};
|
|
81
|
+
"Asset Management 2.0": {
|
|
82
|
+
EXPORTING: string;
|
|
83
|
+
FAILED: string;
|
|
84
|
+
};
|
|
72
85
|
"Fetch Roles": {
|
|
73
86
|
FETCHING: string;
|
|
74
87
|
FAILED: string;
|
package/lib/utils/constants.js
CHANGED
|
@@ -6,6 +6,10 @@ exports.PROCESS_NAMES = {
|
|
|
6
6
|
ASSET_FOLDERS: 'Folders',
|
|
7
7
|
ASSET_METADATA: 'Metadata',
|
|
8
8
|
ASSET_DOWNLOADS: 'Downloads',
|
|
9
|
+
/** Used when Assets module runs Asset Management 2.0 path (spaces, metadata, folders, assets, downloads). */
|
|
10
|
+
ASSET_MANAGEMENT_SPACES: 'Spaces & assets',
|
|
11
|
+
// Asset Management 2.0 module
|
|
12
|
+
ASSET_MANAGEMENT_EXPORT: 'Asset Management 2.0',
|
|
9
13
|
// Custom Roles module
|
|
10
14
|
FETCH_ROLES: 'Fetch Roles',
|
|
11
15
|
FETCH_LOCALES: 'Fetch Locales',
|
|
@@ -33,6 +37,7 @@ exports.PROCESS_NAMES = {
|
|
|
33
37
|
};
|
|
34
38
|
exports.MODULE_CONTEXTS = {
|
|
35
39
|
ASSETS: 'assets',
|
|
40
|
+
ASSET_MANAGEMENT: 'asset-management',
|
|
36
41
|
CONTENT_TYPES: 'content-types',
|
|
37
42
|
CUSTOM_ROLES: 'custom-roles',
|
|
38
43
|
ENTRIES: 'entries',
|
|
@@ -51,6 +56,7 @@ exports.MODULE_CONTEXTS = {
|
|
|
51
56
|
// Display names for modules to avoid scattering user-facing strings
|
|
52
57
|
exports.MODULE_NAMES = {
|
|
53
58
|
[exports.MODULE_CONTEXTS.ASSETS]: 'Assets',
|
|
59
|
+
[exports.MODULE_CONTEXTS.ASSET_MANAGEMENT]: 'Asset Management 2.0',
|
|
54
60
|
[exports.MODULE_CONTEXTS.CONTENT_TYPES]: 'Content Types',
|
|
55
61
|
[exports.MODULE_CONTEXTS.CUSTOM_ROLES]: 'Custom Roles',
|
|
56
62
|
[exports.MODULE_CONTEXTS.ENTRIES]: 'Entries',
|
|
@@ -81,6 +87,15 @@ exports.PROCESS_STATUS = {
|
|
|
81
87
|
FAILED: 'Failed to download asset:',
|
|
82
88
|
},
|
|
83
89
|
// Custom Roles
|
|
90
|
+
[exports.PROCESS_NAMES.ASSET_MANAGEMENT_SPACES]: {
|
|
91
|
+
EXPORTING: 'Exporting spaces & assets...',
|
|
92
|
+
FAILED: 'Failed to export spaces & assets.',
|
|
93
|
+
},
|
|
94
|
+
// Asset Management 2.0
|
|
95
|
+
[exports.PROCESS_NAMES.ASSET_MANAGEMENT_EXPORT]: {
|
|
96
|
+
EXPORTING: 'Exporting...',
|
|
97
|
+
FAILED: 'Asset Management export failed.',
|
|
98
|
+
},
|
|
84
99
|
[exports.PROCESS_NAMES.FETCH_ROLES]: {
|
|
85
100
|
FETCHING: 'Fetching custom roles...',
|
|
86
101
|
FAILED: 'Failed to fetch custom roles.',
|
|
@@ -33,6 +33,9 @@ const setupConfig = async (exportCmdFlags) => {
|
|
|
33
33
|
}
|
|
34
34
|
config.exportDir = config.exportDir.replace(/['"]/g, '');
|
|
35
35
|
config.exportDir = path.resolve(config.exportDir);
|
|
36
|
+
if ((0, file_helper_1.isDirectoryNonEmpty)(config.exportDir)) {
|
|
37
|
+
cli_utilities_1.cliux.print('\nThe export directory is not empty. Existing files in this folder may be overwritten.', { color: 'yellow' });
|
|
38
|
+
}
|
|
36
39
|
const managementTokenAlias = exportCmdFlags['management-token-alias'] || exportCmdFlags['alias'];
|
|
37
40
|
if (managementTokenAlias) {
|
|
38
41
|
cli_utilities_1.log.debug('Using management token alias', { alias: managementTokenAlias });
|
|
@@ -11,4 +11,8 @@ export declare const writeFile: (filePath: string, data: any) => Promise<any>;
|
|
|
11
11
|
export declare const writeLargeFile: (filePath: string, data: any) => Promise<any>;
|
|
12
12
|
export declare const makeDirectory: (dir: string) => void;
|
|
13
13
|
export declare const readdir: (dirPath: string) => any;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the path exists, is a directory, and contains at least one entry.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDirectoryNonEmpty(absolutePath: string): boolean;
|
|
14
18
|
export declare const fsUtil: FsUtility;
|
package/lib/utils/file-helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fsUtil = exports.readdir = exports.makeDirectory = exports.writeLargeFile = exports.writeFile = exports.writeFileSync = exports.readLargeFile = exports.readFile = exports.readFileSync = void 0;
|
|
3
|
+
exports.fsUtil = exports.isDirectoryNonEmpty = exports.readdir = exports.makeDirectory = exports.writeLargeFile = exports.writeFile = exports.writeFileSync = exports.readLargeFile = exports.readFile = exports.readFileSync = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -114,6 +114,31 @@ const readdir = function (dirPath) {
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
exports.readdir = readdir;
|
|
117
|
+
/**
|
|
118
|
+
* Returns true if the path exists, is a directory, and contains at least one entry.
|
|
119
|
+
*/
|
|
120
|
+
function isDirectoryNonEmpty(absolutePath) {
|
|
121
|
+
if (!absolutePath || !fs.existsSync(absolutePath)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
let stat;
|
|
125
|
+
try {
|
|
126
|
+
stat = fs.statSync(absolutePath);
|
|
127
|
+
}
|
|
128
|
+
catch (_a) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (!stat.isDirectory()) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
return fs.readdirSync(absolutePath).length > 0;
|
|
136
|
+
}
|
|
137
|
+
catch (_b) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.isDirectoryNonEmpty = isDirectoryNonEmpty;
|
|
117
142
|
exports.fileExistsSync = function (path) {
|
|
118
143
|
return fs.existsSync(path);
|
|
119
144
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LinkedWorkspace } from '@contentstack/cli-asset-management';
|
|
2
|
+
/** Stack client with branch().fetch() for CMA branch details */
|
|
3
|
+
type StackWithBranch = {
|
|
4
|
+
branch: (name: string) => {
|
|
5
|
+
fetch: (params?: Record<string, unknown>) => Promise<unknown>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Fetch branch details with include_settings: true and return linked workspaces (am_v2).
|
|
10
|
+
* Reused by stack export (included in settings.json) and asset-management module.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLinkedWorkspacesForBranch(stack: StackWithBranch, branchName: string, context?: Record<string, unknown>): Promise<LinkedWorkspace[]>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLinkedWorkspacesForBranch = void 0;
|
|
4
|
+
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
5
|
+
/**
|
|
6
|
+
* Fetch branch details with include_settings: true and return linked workspaces (am_v2).
|
|
7
|
+
* Reused by stack export (included in settings.json) and asset-management module.
|
|
8
|
+
*/
|
|
9
|
+
async function getLinkedWorkspacesForBranch(stack, branchName, context) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
cli_utilities_1.log.debug(`Fetching branch details for: ${branchName}`, context);
|
|
12
|
+
try {
|
|
13
|
+
const branch = await stack.branch(branchName).fetch({ include_settings: true });
|
|
14
|
+
const linked = (_b = (_a = branch === null || branch === void 0 ? void 0 : branch.settings) === null || _a === void 0 ? void 0 : _a.am_v2) === null || _b === void 0 ? void 0 : _b.linked_workspaces;
|
|
15
|
+
if (!Array.isArray(linked)) {
|
|
16
|
+
cli_utilities_1.log.debug('No linked_workspaces in branch settings', context);
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
cli_utilities_1.log.info(`Found ${linked.length} linked workspace(s) for branch ${branchName}`, context);
|
|
20
|
+
return linked;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const err = error;
|
|
24
|
+
if ((err === null || err === void 0 ? void 0 : err.status) === 412 || (err === null || err === void 0 ? void 0 : err.errorCode) === 412) {
|
|
25
|
+
cli_utilities_1.log.warn('Branch settings not found, please check if the branches are enabled in your stack', context);
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
(0, cli_utilities_1.handleAndLogError)(error, context, 'Failed to fetch branch settings');
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.getLinkedWorkspacesForBranch = getLinkedWorkspacesForBranch;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ export * as fileHelper from './file-helper';
|
|
|
4
4
|
export { fsUtil } from './file-helper';
|
|
5
5
|
export { default as setupBranches } from './setup-branches';
|
|
6
6
|
export { default as setupExportDir } from './setup-export-dir';
|
|
7
|
+
export { getExportBasePath } from './path-helper';
|
|
7
8
|
export { log, unlinkFileLogger } from './logger';
|
|
8
9
|
export { default as login } from './basic-login';
|
|
9
10
|
export * from './common-helper';
|
|
10
11
|
export * from './marketplace-app-helper';
|
|
12
|
+
export { getLinkedWorkspacesForBranch } from './get-linked-workspaces';
|
|
11
13
|
export { MODULE_CONTEXTS, MODULE_NAMES, PROCESS_NAMES, PROCESS_STATUS } from './constants';
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.login = exports.unlinkFileLogger = exports.log = exports.setupExportDir = exports.setupBranches = exports.fsUtil = exports.fileHelper = exports.setupExportConfig = exports.interactive = void 0;
|
|
3
|
+
exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.getLinkedWorkspacesForBranch = exports.login = exports.unlinkFileLogger = exports.log = exports.getExportBasePath = exports.setupExportDir = exports.setupBranches = exports.fsUtil = exports.fileHelper = exports.setupExportConfig = exports.interactive = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
exports.interactive = tslib_1.__importStar(require("./interactive"));
|
|
6
6
|
var export_config_handler_1 = require("./export-config-handler");
|
|
@@ -12,6 +12,8 @@ var setup_branches_1 = require("./setup-branches");
|
|
|
12
12
|
Object.defineProperty(exports, "setupBranches", { enumerable: true, get: function () { return tslib_1.__importDefault(setup_branches_1).default; } });
|
|
13
13
|
var setup_export_dir_1 = require("./setup-export-dir");
|
|
14
14
|
Object.defineProperty(exports, "setupExportDir", { enumerable: true, get: function () { return tslib_1.__importDefault(setup_export_dir_1).default; } });
|
|
15
|
+
var path_helper_1 = require("./path-helper");
|
|
16
|
+
Object.defineProperty(exports, "getExportBasePath", { enumerable: true, get: function () { return path_helper_1.getExportBasePath; } });
|
|
15
17
|
var logger_1 = require("./logger");
|
|
16
18
|
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_1.log; } });
|
|
17
19
|
Object.defineProperty(exports, "unlinkFileLogger", { enumerable: true, get: function () { return logger_1.unlinkFileLogger; } });
|
|
@@ -19,6 +21,8 @@ var basic_login_1 = require("./basic-login");
|
|
|
19
21
|
Object.defineProperty(exports, "login", { enumerable: true, get: function () { return tslib_1.__importDefault(basic_login_1).default; } });
|
|
20
22
|
tslib_1.__exportStar(require("./common-helper"), exports);
|
|
21
23
|
tslib_1.__exportStar(require("./marketplace-app-helper"), exports);
|
|
24
|
+
var get_linked_workspaces_1 = require("./get-linked-workspaces");
|
|
25
|
+
Object.defineProperty(exports, "getLinkedWorkspacesForBranch", { enumerable: true, get: function () { return get_linked_workspaces_1.getLinkedWorkspacesForBranch; } });
|
|
22
26
|
var constants_1 = require("./constants");
|
|
23
27
|
Object.defineProperty(exports, "MODULE_CONTEXTS", { enumerable: true, get: function () { return constants_1.MODULE_CONTEXTS; } });
|
|
24
28
|
Object.defineProperty(exports, "MODULE_NAMES", { enumerable: true, get: function () { return constants_1.MODULE_NAMES; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExportConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the base path under which module content should be exported.
|
|
4
|
+
* Content is always written directly under this path (no branch subfolder).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getExportBasePath(exportConfig: ExportConfig): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExportBasePath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the base path under which module content should be exported.
|
|
6
|
+
* Content is always written directly under this path (no branch subfolder).
|
|
7
|
+
*/
|
|
8
|
+
function getExportBasePath(exportConfig) {
|
|
9
|
+
return exportConfig.exportDir;
|
|
10
|
+
}
|
|
11
|
+
exports.getExportBasePath = getExportBasePath;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_asset_management_1 = require("@contentstack/cli-asset-management");
|
|
3
4
|
const constants_1 = require("./constants");
|
|
4
5
|
/**
|
|
5
6
|
* Progress Strategy Registrations for Export Modules
|
|
@@ -22,6 +23,23 @@ try {
|
|
|
22
23
|
failures: downloadsProcess.failureCount,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
// Asset Management 2.0 path (process name owned by AM package)
|
|
27
|
+
const amProcess = processes.get(cli_asset_management_1.AM_MAIN_PROCESS_NAME);
|
|
28
|
+
if (amProcess) {
|
|
29
|
+
return {
|
|
30
|
+
total: amProcess.total,
|
|
31
|
+
success: amProcess.successCount,
|
|
32
|
+
failures: amProcess.failureCount,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const spacesProcess = processes.get(constants_1.PROCESS_NAMES.ASSET_MANAGEMENT_SPACES);
|
|
36
|
+
if (spacesProcess) {
|
|
37
|
+
return {
|
|
38
|
+
total: spacesProcess.total,
|
|
39
|
+
success: spacesProcess.successCount,
|
|
40
|
+
failures: spacesProcess.failureCount,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
25
43
|
// Fallback to metadata process if downloads don't exist
|
|
26
44
|
const metadataProcess = processes.get(constants_1.PROCESS_NAMES.ASSET_METADATA);
|
|
27
45
|
if (metadataProcess) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const path = tslib_1.__importStar(require("path"));
|
|
5
|
-
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
3
|
const file_helper_1 = require("./file-helper");
|
|
7
4
|
const setupBranches = async (config, stackAPIClient) => {
|
|
8
5
|
if (typeof config !== 'object') {
|
|
@@ -42,9 +39,6 @@ const setupBranches = async (config, stackAPIClient) => {
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
(0, file_helper_1.makeDirectory)(config.exportDir);
|
|
45
|
-
// create branch info file
|
|
46
|
-
(0, file_helper_1.writeFileSync)(path.join((0, cli_utilities_1.sanitizePath)(config.exportDir), 'branches.json'), branches);
|
|
47
|
-
// add branches list in the
|
|
48
42
|
config.branches = branches;
|
|
49
43
|
};
|
|
50
44
|
exports.default = setupBranches;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ExportConfig } from '../types';
|
|
2
|
-
export default function setupExportDir(exportConfig: ExportConfig): Promise<void
|
|
2
|
+
export default function setupExportDir(exportConfig: ExportConfig): Promise<void>;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
-
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
6
3
|
const file_helper_1 = require("./file-helper");
|
|
7
4
|
async function setupExportDir(exportConfig) {
|
|
8
5
|
(0, file_helper_1.makeDirectory)(exportConfig.exportDir);
|
|
9
|
-
|
|
10
|
-
return Promise.all(exportConfig.branches.map((branch) => (0, file_helper_1.makeDirectory)(path_1.default.join((0, cli_utilities_1.sanitizePath)(exportConfig.exportDir), (0, cli_utilities_1.sanitizePath)(branch.uid)))));
|
|
11
|
-
}
|
|
6
|
+
// Single-branch export: content goes directly under exportDir; no per-branch subdirs.
|
|
12
7
|
}
|
|
13
8
|
exports.default = setupExportDir;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
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.16",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "~2.0.0-beta.
|
|
9
|
-
"@contentstack/cli-utilities": "~2.0.0-beta.
|
|
10
|
-
"@contentstack/cli-variants": "~2.0.0-beta.
|
|
8
|
+
"@contentstack/cli-command": "~2.0.0-beta.6",
|
|
9
|
+
"@contentstack/cli-utilities": "~2.0.0-beta.7",
|
|
10
|
+
"@contentstack/cli-variants": "~2.0.0-beta.12",
|
|
11
|
+
"@contentstack/cli-asset-management": "~1.0.0-beta.0",
|
|
11
12
|
"@oclif/core": "^4.8.0",
|
|
12
13
|
"async": "^3.2.6",
|
|
13
14
|
"big-json": "^3.2.0",
|
|
14
15
|
"bluebird": "^3.7.2",
|
|
15
16
|
"chalk": "^5.6.2",
|
|
16
|
-
"lodash": "^4.
|
|
17
|
+
"lodash": "^4.18.1",
|
|
17
18
|
"merge": "^2.1.1",
|
|
18
19
|
"mkdirp": "^1.0.4",
|
|
19
20
|
"progress-stream": "^2.0.0",
|
|
20
21
|
"promise-limit": "^2.7.0",
|
|
21
|
-
"winston": "^3.
|
|
22
|
+
"winston": "^3.19.0"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@contentstack/cli-auth": "~2.0.0-beta.9",
|
|
25
26
|
"@contentstack/cli-config": "~2.0.0-beta.5",
|
|
26
27
|
"@contentstack/cli-dev-dependencies": "~2.0.0-beta.0",
|
|
27
28
|
"@oclif/plugin-help": "^6.2.28",
|
|
28
|
-
"@oclif/test": "^4.1.
|
|
29
|
+
"@oclif/test": "^4.1.18",
|
|
29
30
|
"@types/big-json": "^3.2.5",
|
|
30
31
|
"@types/chai": "^4.3.11",
|
|
31
32
|
"@types/mkdirp": "^1.0.2",
|
|
@@ -94,4 +95,4 @@
|
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
97
|
"repository": "https://github.com/contentstack/cli"
|
|
97
|
-
}
|
|
98
|
+
}
|