Skip to content

Commit 96245b8

Browse files
authored
Merge pull request #5 from contentstack/fix/branch-support
added branch name in directory
2 parents 2850437 + 2aaf4da commit 96245b8

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ _backup_*
1616
contents/
1717
logs/
1818
oclif.manifest.json
19+
talisman_output.log

.talismanrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ fileignoreconfig:
22
- filename: snyk_output.log
33
checksum: dfa9dc093345f006cc3fb107b8495fcbe79c524db51f44c08d959c656bedf2f7
44
- filename: talisman_output.log
5-
checksum: 50a8928e551f9092dafcf50f531c926ac00e2846c564aafaaab70c1ecaa19490
5+
checksum: d18cb2591eb650ebb3a2d5eb84f57c8f0891cef1987b2a420ab7e29dbe2782a0
6+
- filename: package-lock.json
7+
checksum: 803054eadb6cf0cb4362a175b268ae2d8cbdb2ffc5cbf978d944b4db04a4a562
68
version: '1.0'

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/query-executor.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,17 @@ export class QueryExporter {
8383
const exportedContentTypeUIDs: Set<string> = new Set();
8484

8585
// Step 1: Read initial content types and mark them as exported
86-
const contentTypesFilePath = path.join(this.exportQueryConfig.exportDir, 'content_types', 'schema.json');
87-
const contentTypes: any = fsUtil.readFile(sanitizePath(contentTypesFilePath));
88-
// contentTypes.forEach((ct: any) => exportedContentTypeUIDs.add(ct.uid));
86+
const contentTypesFilePath = path.join(
87+
this.exportQueryConfig.exportDir,
88+
this.exportQueryConfig.branchName || '',
89+
'content_types',
90+
'schema.json',
91+
);
92+
const contentTypes: any = fsUtil.readFile(sanitizePath(contentTypesFilePath)) || [];
93+
if (contentTypes.length === 0) {
94+
log(this.exportQueryConfig, 'No content types found, skipping referenced content types export', 'info');
95+
return;
96+
}
8997

9098
// Step 2: Start with initial batch (all currently exported content types)
9199
let currentBatch = [...contentTypes];

src/utils/content-type-helper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { log } from './logger';
44

55
export class ReferencedContentTypesHandler {
66
private exportQueryConfig: QueryExportConfig;
7-
private contentTypesDir: string;
87

98
constructor(exportQueryConfig: QueryExportConfig) {
109
this.exportQueryConfig = exportQueryConfig;
11-
this.contentTypesDir = path.join(exportQueryConfig.exportDir, 'content-types');
1210
}
1311

1412
/**

src/utils/dependency-resolver.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ export class ContentTypeDependenciesHandler {
1919
taxonomies: Set<string>;
2020
marketplaceApps: Set<string>;
2121
}> {
22-
const contentTypesFilePath = path.join(this.exportQueryConfig.exportDir, 'content_types', 'schema.json');
23-
const allContentTypes = fsUtil.readFile(sanitizePath(contentTypesFilePath)) as any[];
22+
const contentTypesFilePath = path.join(
23+
this.exportQueryConfig.exportDir,
24+
this.exportQueryConfig.branchName || '',
25+
'content_types',
26+
'schema.json',
27+
);
28+
const allContentTypes = (fsUtil.readFile(sanitizePath(contentTypesFilePath)) as any[]) || [];
29+
if (allContentTypes.length === 0) {
30+
log(this.exportQueryConfig, 'No content types found, skipping dependency extraction', 'info');
31+
return {
32+
globalFields: new Set<string>(),
33+
extensions: new Set<string>(),
34+
taxonomies: new Set<string>(),
35+
marketplaceApps: new Set<string>(),
36+
};
37+
}
2438

2539
log(this.exportQueryConfig, `Extracting dependencies from ${allContentTypes.length} content types`, 'info');
2640

src/utils/referenced-asset-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class AssetReferenceHandler {
1111

1212
constructor(exportQueryConfig: QueryExportConfig) {
1313
this.exportQueryConfig = exportQueryConfig;
14-
this.entriesDir = path.join(exportQueryConfig.exportDir, 'entries');
14+
this.entriesDir = path.join(exportQueryConfig.exportDir, exportQueryConfig.branchName || '', 'entries');
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)