Skip to content

Commit f9f05d1

Browse files
authored
Merge pull request #2391 from contentstack/fix/DX-4421
fix: taxonomy import & entries publishing issue
2 parents 6a80ab3 + b557f07 commit f9f05d1

37 files changed

Lines changed: 1039 additions & 404 deletions

packages/contentstack-audit/src/audit-base-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
237237

238238
// Extract logConfig and showConsoleLogs once before the loop to reuse throughout
239239
const logConfig = configHandler.get('log') || {};
240-
const showConsoleLogs = logConfig.showConsoleLogs ?? true;
240+
const showConsoleLogs = logConfig.showConsoleLogs ?? false;
241241

242242
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
243243
// Update audit context with current module

packages/contentstack-export/src/commands/cm/stacks/export.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
configHandler,
1212
log,
1313
handleAndLogError,
14-
getLogPath,
14+
getSessionLogPath,
1515
CLIProgressManager,
1616
clearProgressModuleSetting,
1717
} from '@contentstack/cli-utilities';
@@ -102,26 +102,28 @@ export default class ExportCommand extends Command {
102102
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
103103
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
104104
await moduleExporter.start();
105+
const sessionLogPath = getSessionLogPath();
105106
log.success(
106107
`The content of the stack ${exportConfig.apiKey} has been exported successfully!`,
107108
);
108109
log.info(`The exported content has been stored at '${exportDir}'`, exportConfig.context);
109-
log.success(`The log has been stored at '${getLogPath()}'`, exportConfig.context);
110+
log.success(`The log has been stored at '${sessionLogPath}'`, exportConfig.context);
110111

111112
// Print comprehensive summary at the end
112113
if (!exportConfig.branches) CLIProgressManager.printGlobalSummary();
113114
if (!configHandler.get('log')?.showConsoleLogs) {
114-
cliux.print(`The log has been stored at '${getLogPath()}'`, { color: 'green' });
115+
cliux.print(`The log has been stored at '${sessionLogPath}'`, { color: 'green' });
115116
}
116117
// Clear progress module setting now that export is complete
117118
clearProgressModuleSetting();
118119
} catch (error) {
119120
// Clear progress module setting even on error
120121
clearProgressModuleSetting();
121122
handleAndLogError(error);
123+
const sessionLogPath = getSessionLogPath();
122124
if (!configHandler.get('log')?.showConsoleLogs) {
123125
cliux.print(`Error: ${error}`, { color: 'red' });
124-
cliux.print(`The log has been stored at '${getLogPath()}'`, { color: 'green' });
126+
cliux.print(`The log has been stored at '${sessionLogPath}'`, { color: 'green' });
125127
}
126128
}
127129
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
export const PATH_CONSTANTS = {
2+
/** Root mapper directory (contains module-specific mapper subdirs) */
3+
MAPPER: 'mapper',
4+
5+
/** Common mapper file names */
6+
FILES: {
7+
SUCCESS: 'success.json',
8+
FAILS: 'fails.json',
9+
UID_MAPPING: 'uid-mapping.json',
10+
URL_MAPPING: 'url-mapping.json',
11+
UID_MAPPER: 'uid-mapper.json',
12+
SCHEMA: 'schema.json',
13+
SETTINGS: 'settings.json',
14+
MODIFIED_SCHEMAS: 'modified-schemas.json',
15+
UNIQUE_MAPPING: 'unique-mapping.json',
16+
TAXONOMIES: 'taxonomies.json',
17+
ENVIRONMENTS: 'environments.json',
18+
PENDING_EXTENSIONS: 'pending_extensions.js',
19+
PENDING_GLOBAL_FIELDS: 'pending_global_fields.js',
20+
INDEX: 'index.json',
21+
FOLDER_MAPPING: 'folder-mapping.json',
22+
VERSIONED_ASSETS: 'versioned-assets.json',
23+
},
24+
25+
/** Module subdirectory names within mapper */
26+
MAPPER_MODULES: {
27+
ASSETS: 'assets',
28+
ENTRIES: 'entries',
29+
CONTENT_TYPES: 'content_types',
30+
TAXONOMIES: 'taxonomies',
31+
TAXONOMY_TERMS: 'terms',
32+
GLOBAL_FIELDS: 'global_fields',
33+
EXTENSIONS: 'extensions',
34+
WORKFLOWS: 'workflows',
35+
WEBHOOKS: 'webhooks',
36+
LABELS: 'labels',
37+
ENVIRONMENTS: 'environments',
38+
MARKETPLACE_APPS: 'marketplace_apps',
39+
CUSTOM_ROLES: 'custom-roles',
40+
LANGUAGES: 'languages',
41+
},
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+
} as const;
60+
61+
export type PathConstants = typeof PATH_CONSTANTS;

packages/contentstack-export/src/export/modules/assets.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
handleAndLogError,
2121
messageHandler,
2222
} from '@contentstack/cli-utilities';
23+
import { PATH_CONSTANTS } from '../../constants';
2324

2425
import config from '../../config';
2526
import { ModuleClassParams } from '../../types';
@@ -242,7 +243,7 @@ export default class ExportAssets extends BaseClass {
242243
fs = new FsUtility({
243244
metaHandler,
244245
moduleName: 'assets',
245-
indexFileName: 'assets.json',
246+
indexFileName: this.assetConfig.fileName,
246247
basePath: this.assetsRootPath,
247248
chunkFileSize: this.assetConfig.chunkFileSize,
248249
metaPickKeys: merge(['uid', 'url', 'filename', 'parent_uid'], this.assetConfig.assetsMetaKeys),
@@ -326,7 +327,7 @@ export default class ExportAssets extends BaseClass {
326327
if (!fs && !isEmpty(response)) {
327328
fs = new FsUtility({
328329
moduleName: 'assets',
329-
indexFileName: 'versioned-assets.json',
330+
indexFileName: PATH_CONSTANTS.FILES.VERSIONED_ASSETS,
330331
chunkFileSize: this.assetConfig.chunkFileSize,
331332
basePath: pResolve(this.assetsRootPath, 'versions'),
332333
metaPickKeys: merge(['uid', 'url', 'filename', '_version', 'parent_uid'], this.assetConfig.assetsMetaKeys),

packages/contentstack-export/src/export/modules/base-class.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import chunk from 'lodash/chunk';
55
import isEmpty from 'lodash/isEmpty';
66
import entries from 'lodash/entries';
77
import isEqual from 'lodash/isEqual';
8-
import { log, CLIProgressManager, configHandler } from '@contentstack/cli-utilities';
8+
import { log, CLIProgressManager, configHandler, getSessionLogPath } from '@contentstack/cli-utilities';
99

1010
import { ExportConfig, ModuleClassParams } from '../../types';
1111

@@ -109,7 +109,7 @@ export default abstract class BaseClass {
109109
* - moduleName: The module name to generate the message (e.g., 'Assets', 'Entries')
110110
* If not provided, uses this.currentModuleName
111111
* - customSuccessMessage: Optional custom success message. If not provided, generates: "{moduleName} have been exported successfully!"
112-
* - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been exported with some errors. Please check the logs for details."
112+
* - customWarningMessage: Optional custom warning message. If not provided, generates: "{moduleName} have been exported with some errors. Please check the logs at: {sessionLogPath}"
113113
* - context: Optional context for logging
114114
*/
115115
protected completeProgressWithMessage(options?: CompleteProgressOptions): void {
@@ -120,7 +120,8 @@ export default abstract class BaseClass {
120120

121121
// Generate default messages if not provided
122122
const successMessage = options?.customSuccessMessage || `${name} have been exported successfully!`;
123-
const warningMessage = options?.customWarningMessage || `${name} have been exported with some errors. Please check the logs for details.`;
123+
const sessionLogPath = getSessionLogPath();
124+
const warningMessage = options?.customWarningMessage || `${name} have been exported with some errors. Please check the logs at: ${sessionLogPath}`;
124125

125126
this.completeProgress(true);
126127

packages/contentstack-export/src/export/modules/content-types.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import * as path from 'path';
2-
import { ContentstackClient, handleAndLogError, messageHandler, log, sanitizePath } from '@contentstack/cli-utilities';
2+
import {
3+
ContentstackClient,
4+
handleAndLogError,
5+
messageHandler,
6+
log,
7+
sanitizePath,
8+
} from '@contentstack/cli-utilities';
9+
import { PATH_CONSTANTS } from '../../constants';
310

411
import BaseClass from './base-class';
512
import { ExportConfig, ModuleClassParams } from '../../types';
@@ -156,7 +163,7 @@ export default class ContentTypesExport extends BaseClass {
156163
concurrency: this.exportConfig.writeConcurrency,
157164
});
158165

159-
const schemaFilePath = path.join(this.contentTypesDirPath, 'schema.json');
166+
const schemaFilePath = path.join(this.contentTypesDirPath, PATH_CONSTANTS.FILES.SCHEMA);
160167
log.debug(`Writing aggregate schema to: ${schemaFilePath}`, this.exportConfig.context);
161168

162169
return fsUtil.writeFile(schemaFilePath, contentTypes);

packages/contentstack-export/src/export/modules/entries.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import * as path from 'path';
2-
import { ContentstackClient, FsUtility, handleAndLogError, messageHandler, log } from '@contentstack/cli-utilities';
2+
import {
3+
ContentstackClient,
4+
FsUtility,
5+
handleAndLogError,
6+
messageHandler,
7+
log,
8+
sanitizePath,
9+
} from '@contentstack/cli-utilities';
10+
import { PATH_CONSTANTS } from '../../constants';
311
import { Export, ExportProjects } from '@contentstack/cli-variants';
4-
import { sanitizePath } from '@contentstack/cli-utilities';
512

613
import {
714
fsUtil,
@@ -55,7 +62,7 @@ export default class EntriesExport extends BaseClass {
5562
sanitizePath(exportConfig.exportDir),
5663
sanitizePath(exportConfig.branchName || ''),
5764
sanitizePath(exportConfig.modules.content_types.dirName),
58-
'schema.json',
65+
PATH_CONSTANTS.FILES.SCHEMA,
5966
);
6067
this.projectInstance = new ExportProjects(this.exportConfig);
6168
this.exportConfig.context.module = MODULE_CONTEXTS.ENTRIES;
@@ -313,7 +320,7 @@ export default class EntriesExport extends BaseClass {
313320
await fsUtil.makeDirectory(entryBasePath);
314321
this.entriesFileHelper = new FsUtility({
315322
moduleName: 'entries',
316-
indexFileName: 'index.json',
323+
indexFileName: PATH_CONSTANTS.FILES.INDEX,
317324
basePath: entryBasePath,
318325
chunkFileSize: this.entriesConfig.chunkFileSize,
319326
keepMetadata: false,

packages/contentstack-export/src/export/modules/stack.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import find from 'lodash/find';
22
import { resolve as pResolve } from 'node:path';
3-
import { handleAndLogError, isAuthenticated, managementSDKClient, log } from '@contentstack/cli-utilities';
3+
import {
4+
handleAndLogError,
5+
isAuthenticated,
6+
managementSDKClient,
7+
log,
8+
} from '@contentstack/cli-utilities';
9+
import { PATH_CONSTANTS } from '../../constants';
410

511
import BaseClass from './base-class';
612
import {
@@ -265,7 +271,7 @@ export default class ExportStack extends BaseClass {
265271
return this.stack
266272
.settings()
267273
.then((resp: any) => {
268-
fsUtil.writeFile(pResolve(this.stackFolderPath, 'settings.json'), resp);
274+
fsUtil.writeFile(pResolve(this.stackFolderPath, PATH_CONSTANTS.FILES.SETTINGS), resp);
269275

270276
// Track progress for stack settings completion
271277
this.progressManager?.tick(true, 'stack settings', null, PROCESS_NAMES.STACK_SETTINGS);

0 commit comments

Comments
 (0)