Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export default class ExportAssets extends BaseClass {

this.assetsRootPath = pResolve(
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
(this.assetsRootPath = pResolve(getExportBasePath(this.exportConfig), this.assetConfig.dirName)),
);
log.debug(`Assets root path resolved to: ${this.assetsRootPath}`, this.exportConfig.context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default class ExportPublishingRules extends BaseClass {
async start(): Promise<void> {
this.publishingRulesFolderPath = pResolve(
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.publishingRulesConfig.dirName,
);
log.debug(`Publishing rules folder path: ${this.publishingRulesFolderPath}`, this.exportConfig.context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default class ExportQueryCommand extends Command {
await loadChalk();
try {
const { flags } = await this.parse(ExportQueryCommand);
this.initializeMessageHandler();

// Setup export configuration
const exportQueryConfig = await setupQueryExportConfig(flags);
Expand Down Expand Up @@ -116,8 +115,4 @@ export default class ExportQueryCommand extends Command {
handleAndLogError(error);
}
}

initializeMessageHandler(): void {
messageHandler.init(this.context);
}
}
28 changes: 11 additions & 17 deletions packages/contentstack-query-export/src/core/query-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,8 @@ export class QueryExporter {
log.info('Starting export of referenced content types and dependent modules...', this.exportQueryConfig.context);

try {
const ctPath = path.join(
sanitizePath(this.exportQueryConfig.exportDir),
sanitizePath(this.exportQueryConfig.branchName || ''),
'content_types',
);
const gfPath = path.join(
sanitizePath(this.exportQueryConfig.exportDir),
sanitizePath(this.exportQueryConfig.branchName || ''),
'global_fields',
);
const ctPath = path.join(sanitizePath(this.exportQueryConfig.exportDir), 'content_types');
const gfPath = path.join(sanitizePath(this.exportQueryConfig.exportDir), 'global_fields');

const referencedHandler = new ReferencedContentTypesHandler(this.exportQueryConfig);
const dependenciesHandler = new ContentTypeDependenciesHandler(this.stackAPIClient, this.exportQueryConfig);
Expand Down Expand Up @@ -212,15 +204,21 @@ export class QueryExporter {
}

if (!foundNewCTs && !foundNewGFs) {
log.info('Schema closure complete, no new content types or global fields found', this.exportQueryConfig.context);
log.info(
'Schema closure complete, no new content types or global fields found',
this.exportQueryConfig.context,
);
break;
}
}

// Personalize is a single global module exported once after the closure stabilises.
await this.moduleExporter.exportModule('personalize');

log.success('Referenced content types and dependent modules exported successfully', this.exportQueryConfig.context);
log.success(
'Referenced content types and dependent modules exported successfully',
this.exportQueryConfig.context,
);
} catch (error) {
handleAndLogError(error, this.exportQueryConfig.context, 'Error during schema closure expansion');
throw error;
Expand Down Expand Up @@ -266,11 +264,7 @@ export class QueryExporter {
log.info('Starting export of referenced assets...', this.exportQueryConfig.context);

try {
const assetsDir = path.join(
sanitizePath(this.exportQueryConfig.exportDir),
sanitizePath(this.exportQueryConfig.branchName || ''),
'assets',
);
const assetsDir = path.join(sanitizePath(this.exportQueryConfig.exportDir), 'assets');

const metadataFilePath = path.join(assetsDir, 'metadata.json');
const assetFilePath = path.join(assetsDir, 'assets.json');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ export class ContentTypeDependenciesHandler {
if (schemas !== undefined) {
allSchemas = schemas;
} else {
const contentTypesFilePath = path.join(
sanitizePath(this.exportQueryConfig.exportDir),
sanitizePath(this.exportQueryConfig.branchName || ''),
'content_types',
);
const contentTypesFilePath = path.join(sanitizePath(this.exportQueryConfig.exportDir), 'content_types');
allSchemas = readContentTypeSchemas(contentTypesFilePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ export class AssetReferenceHandler {

constructor(exportQueryConfig: QueryExportConfig) {
this.exportQueryConfig = exportQueryConfig;
this.entriesDir = path.join(
sanitizePath(exportQueryConfig.exportDir),
sanitizePath(exportQueryConfig.branchName || ''),
'entries',
);
this.entriesDir = path.join(sanitizePath(exportQueryConfig.exportDir), 'entries');
}

/**
Expand All @@ -28,7 +24,6 @@ export class AssetReferenceHandler {
log.warn('Entries directory does not exist', this.exportQueryConfig.context);
return [];
}

// Global set to maintain unique asset UIDs across all files
const globalAssetUIDs = new Set<string>();

Expand Down
Loading