Skip to content
Open
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
58 changes: 58 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,62 @@ fileignoreconfig:
checksum: 77bc27f5217c6d69c21bac51afc94d677ad67374c1b39b0575646300eb0decd3
- filename: packages/contentstack-seed/test/seed/contentstack/client.test.ts
checksum: f1bc369c9c3c4a84ddd590864c0f3e8b13be956b8fb8891b6324f44cdcc7d568
- filename: packages/contentstack-export/test/unit/export/modules/environments.test.ts
checksum: 3f219e9ecb060cd590bdd4815cf31f2db81396be49d357eadc8d972e7e0d49a2
- filename: packages/contentstack-import/test/unit/utils/backup-handler.test.ts
checksum: 2743a1d7370a9c1a255549a0c1ad8615618bbe4d30645e18224dcfe813411fa0
- filename: packages/contentstack-export/test/unit/export/modules/global-fields.test.ts
checksum: 9f3577388677fa0fa36bf8b280c2137ec6255392cca784d650080d174444cf99
- filename: packages/contentstack-export/test/unit/export/modules/content-types.test.ts
checksum: 90edb36569d165e88f09c49f1989fc499081d61b8da4a56536e55f8a392ba748
- filename: packages/contentstack-import/test/unit/import/module-importer.test.ts
checksum: 383bd60e12028617e450e291c3d84f87b1990e9f14c0898f77b7f63fb3bd0957
- filename: packages/contentstack-export/test/unit/export/modules/base-class.test.ts
checksum: 8755d3c8a6b4f82780a24d1fa4804f90c6c10796b1fe6a0193ac612d14f8f6bb
- filename: packages/contentstack-export/test/unit/export/modules/assets.test.ts
checksum: 12d899d85de5852337a8df36830bb43829be335fb982629134027ede679357a5
- filename: packages/contentstack-export/test/unit/export/modules/marketplace-apps.test.ts
checksum: 2dfcd63eaf8c1692f37ace4f6d300834d752998e56fed13f8aac750c572197ff
- filename: packages/contentstack-export/test/unit/export/modules/locales.test.ts
checksum: cc1f1cebbfffb1c03f5f98268aec55656e60f5251154592e6234b7ce08b6918e
- filename: packages/contentstack-export/test/unit/export/modules/entries.test.ts
checksum: 12de03aa82ba2c7a58f3b6d39cdcadffc5108b6268d599f14c2c50a38ce1091a
- filename: packages/contentstack-export/test/unit/export/modules/stack.test.ts
checksum: dc28ecf8c9f7e9f4f20af1211d789924ee00e5ae33f0ce05c9caa80768b1a734
- filename: packages/contentstack-export/test/unit/export/modules/taxonomies.test.ts
checksum: f6175a8e89fb9dde4b0ff269d65a9e42c4374ef7efb1b828e54e2ebd7c4379fa
- filename: packages/contentstack-export/test/unit/export/modules/workflows.test.ts
checksum: 9da983731811064de04e60a7ddd05ea558661dd17ac4e0c7da5be6cca8b2749d
- filename: packages/contentstack-export/test/unit/utils/export-config-handler.test.ts
checksum: 18600d1aab9507e3f8ee3caed3e6bd79ee05aff9444a2461fcb2f4d7fe6f27a6
- filename: packages/contentstack-import/test/unit/import/modules/entries.test.ts
checksum: 544e11881bc55ea7a1afc05e067d7b29fb2d165783ccd0ce3ff741ef7106b134
- filename: packages/contentstack-export/src/export/modules/environments.ts
checksum: 9c6e2cd260fba0ffd4deaf38835924642ab5ec2a4140185b3fe7eaec13305acb
- filename: packages/contentstack-import/src/utils/common-helper.ts
checksum: 68b605f9e952b05cbf1e9be04214e48f7409bce1eb5a3440183cea13b8cce49a
- filename: packages/contentstack-export/src/utils/marketplace-app-helper.ts
checksum: f5783ace09260150f63edc65e2d91b40310db60b57f9f56675e49b791bac84c8
- filename: packages/contentstack-import/src/utils/asset-helper.ts
checksum: e34bb0522ca8317408f905ee864e25d43acf52c595acaf397d1f35fcc49cbf4a
- filename: packages/contentstack-import/src/utils/login-handler.ts
checksum: 8bcefa5db69f894f3db49d8bca662dcc30f9247a3c4bf278c0d84d24a42481f6
- filename: packages/contentstack-import/src/utils/marketplace-app-helper.ts
checksum: caba03ffade8217dc8f82217a7f767fa6562fba63421d48f0aa8412b8463e21a
- filename: packages/contentstack-clone/src/lib/util/clone-handler.js
checksum: 3cf5eec54f0940eb269e3576298f1170268105073210af4a842b38fd7e969f43
- filename: packages/contentstack-import/src/import/modules/marketplace-apps.ts
checksum: b232e1c5a2b9dec7d6f01e671fd04eaa09351904ef0d20a8ab10f8ca60a2c365
- filename: packages/contentstack-export/src/export/modules/stack.ts
checksum: c2f1e06199bf55fd6d2ebd493edf9e746eabc00fd7c3b8da2785b024a35c9e7c
- filename: packages/contentstack-export/src/utils/basic-login.ts
checksum: d777e56768b53ecd9e5b0a27f4a59950e0791a5487dbcf4d2666510195e20767
- filename: packages/contentstack-import/test/unit/utils/import-config-handler.test.ts
checksum: 5c0add2367ef71367709a6668f4814f80fedda4cafba1f2149f8ceb136128c18
- filename: packages/contentstack-export/test/unit/utils/marketplace-app-helper.test.ts
checksum: 7378a63f935c67af0b4fe40175d24f5f1c91e2b3dbaeda503e2d060700eadb20
- filename: packages/contentstack-import/test/unit/utils/marketplace-app-helper.test.ts
checksum: 24c05dc08fe6fd2c0f19754a6dea61505f2cb124c7697750f9c27f11084fd4f0
- filename: packages/contentstack-import/test/unit/utils/common-helper.test.ts
checksum: 533043fcc944d91d1bfa084a6ba6e87409986c2931197d145237862f55143374
version: '1.0'
24 changes: 18 additions & 6 deletions packages/contentstack-clone/src/lib/util/clone-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CloneHandler {
cloneCommand = new Clone();
this.pathDir = opt.pathDir;
process.stdin.setMaxListeners(50);
log.debug('Initializing CloneHandler', config.cloneContext, { pathDir: opt.pathDir, cloneType: opt.cloneType });
}
setClient(managementSDKClient) {
client = managementSDKClient;
Expand Down Expand Up @@ -706,9 +705,14 @@ class CloneHandler {
delete exportConfig.import;
delete exportConfig.export;

// Map source_stack to apiKey for export config
if (exportConfig.source_stack) {
exportConfig.apiKey = exportConfig.source_stack;
}

const exportDir = __dirname.split('src')[0] + 'contents';
log.debug(`Export directory: ${exportDir}`, config.cloneContext);
const cmd = ['-k', exportConfig.source_stack, '-d', exportDir];
const cmd = ['-k', exportConfig.apiKey || exportConfig.source_stack, '-d', exportDir];

if (exportConfig.cloneType === 'a') {
exportConfig.filteredModules = ['stack'].concat(structureList);
Expand Down Expand Up @@ -738,7 +742,7 @@ class CloneHandler {
log.debug('Export command prepared', config.cloneContext, {
cmd: cmd.join(' '),
exportDir,
sourceStack: exportConfig.source_stack,
sourceStack: exportConfig.apiKey || exportConfig.source_stack,
branch: exportConfig.sourceStackBranch
});
log.debug('Running export command', config.cloneContext, { cmd });
Expand All @@ -760,14 +764,22 @@ class CloneHandler {
delete importConfig.import;
delete importConfig.export;

// Map target_stack to apiKey and data to contentDir for import config
if (importConfig.target_stack) {
importConfig.apiKey = importConfig.target_stack;
}
if (importConfig.data) {
importConfig.contentDir = importConfig.data;
}

const configFilePath = path.join(__dirname, 'dummyConfig.json');
const cmd = ['-c', configFilePath];

if (importConfig.destination_alias) {
cmd.push('-a', importConfig.destination_alias);
log.debug(`Using destination alias: ${importConfig.destination_alias}`, config.cloneContext);
}
if (!importConfig.data && importConfig.sourceStackBranch) {
if (!importConfig.contentDir && !importConfig.data && importConfig.sourceStackBranch) {
const dataPath = path.join(importConfig.pathDir, importConfig.sourceStackBranch);
cmd.push('-d', dataPath);
log.debug(`Import data path: ${dataPath}`, config.cloneContext);
Expand Down Expand Up @@ -795,9 +807,9 @@ class CloneHandler {
fs.writeFileSync(configFilePath, JSON.stringify(importConfig));
log.debug('Import command prepared', config.cloneContext, {
cmd: cmd.join(' '),
targetStack: importConfig.target_stack,
targetStack: importConfig.apiKey || importConfig.target_stack,
targetBranch: importConfig.targetStackBranch,
dataPath: importConfig.data || path.join(importConfig.pathDir, importConfig.sourceStackBranch)
dataPath: importConfig.contentDir || importConfig.data || path.join(importConfig.pathDir, importConfig.sourceStackBranch)
});
log.debug('Running import command', config.cloneContext, { cmd });
await importCmd.run(cmd);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"contentVersion": 2,
"master_locale": {
"name": "English - United States",
"code": "en-us"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"contentVersion": 2,
"master_locale": {
"name": "English - United States",
"code": "en-us"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class ExportCommand extends Command {
// Assign exportConfig variables
this.assignExportConfig(exportConfig);

exportDir = sanitizePath(exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir);
exportDir = sanitizePath(exportConfig.cliLogsPath || exportConfig.exportDir);
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
await moduleExporter.start();
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-export/src/export/modules/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default class ExportAssets extends BaseClass {
}

async start(): Promise<void> {
this.assetsRootPath = pResolve(
this.exportConfig.data,
this.assetsRootPath = pResolve(
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.assetConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ExportComposableStudio {
}

this.composableStudioPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.composableStudioConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class ContentTypesExport extends BaseClass {
this.applyQueryFilters(this.qs, 'content-types');

this.contentTypesDirPath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(this.contentTypesConfig.dirName),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class ExportCustomRoles extends BaseClass {
'CUSTOM-ROLES: Analyzing roles and locales...',
async () => {
this.rolesFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.customRolesConfig.dirName,
);
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-export/src/export/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ export default class EntriesExport extends BaseClass {
this.exportConfig = exportConfig;
this.entriesConfig = exportConfig.modules.entries;
this.entriesDirPath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(this.entriesConfig.dirName),
);
this.localesFilePath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(exportConfig.modules.locales.dirName),
sanitizePath(exportConfig.modules.locales.fileName),
);
this.schemaFilePath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(exportConfig.modules.content_types.dirName),
'schema.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class ExportEnvironments extends BaseClass {
// Setup with loading spinner
const [totalCount] = await this.withLoadingSpinner('ENVIRONMENTS: Analyzing environments...', async () => {
this.environmentsFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.environmentConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class ExportExtensions extends BaseClass {
// Setup with loading spinner
const [totalCount] = await this.withLoadingSpinner('EXTENSIONS: Analyzing extensions...', async () => {
this.extensionsFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.extensionConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class GlobalFieldsExport extends BaseClass {
include_global_field_schema: true,
};
this.globalFieldsDirPath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(this.globalFieldsConfig.dirName),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class ExportLabels extends BaseClass {
// Setup with loading spinner
const [totalCount] = await this.withLoadingSpinner('LABELS: Analyzing labels...', async () => {
this.labelsFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.labelConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class LocaleExport extends BaseClass {
},
};
this.localesPath = path.resolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(this.localeConfig.dirName),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default class ExportMarketplaceApps extends BaseClass {

async setupPaths(): Promise<void> {
this.marketplaceAppPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.marketplaceAppConfig.dirName,
);
Expand All @@ -133,7 +133,7 @@ export default class ExportMarketplaceApps extends BaseClass {
this.developerHubBaseUrl = this.exportConfig.developerHubBaseUrl || (await getDeveloperHubUrl(this.exportConfig));
log.debug(`Developer hub base URL: '${this.developerHubBaseUrl}'`, this.exportConfig.context);
this.exportConfig.org_uid = await getOrgUid(this.exportConfig);
this.query = { target_uids: this.exportConfig.source_stack };
this.query = { target_uids: this.exportConfig.apiKey };
log.debug(`Organization UID: '${this.exportConfig.org_uid}'.`, this.exportConfig.context);

// NOTE init marketplace app sdk
Expand Down
24 changes: 12 additions & 12 deletions packages/contentstack-export/src/export/modules/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class ExportStack extends BaseClass {
this.stackConfig = exportConfig.modules.stack;
this.qs = { include_count: true };
this.stackFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.stackConfig.dirName,
);
Expand Down Expand Up @@ -130,20 +130,20 @@ export default class ExportStack extends BaseClass {
}

async getStack(): Promise<any> {
log.debug(`Fetching stack data for: '${this.exportConfig.source_stack}'...`, this.exportConfig.context);
log.debug(`Fetching stack data for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);

const tempAPIClient = await managementSDKClient({ host: this.exportConfig.host });
log.debug(`Created Management SDK client with host: '${this.exportConfig.host}'.`, this.exportConfig.context);

return await tempAPIClient
.stack({ api_key: this.exportConfig.source_stack })
.stack({ api_key: this.exportConfig.apiKey })
.fetch()
.then((data: any) => {
log.debug(`Successfully fetched stack data for: '${this.exportConfig.source_stack}'.`, this.exportConfig.context);
log.debug(`Successfully fetched stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
return data;
})
.catch((error: any) => {
log.debug(`Failed to fetch stack data for: '${this.exportConfig.source_stack}'.`, this.exportConfig.context);
log.debug(`Failed to fetch stack data for: '${this.exportConfig.apiKey}'.`, this.exportConfig.context);
return {};
});
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class ExportStack extends BaseClass {
return masterLocalObj;
} else if (skip >= count) {
log.error(
`Locale locale not found in the stack ${this.exportConfig.source_stack}. Please ensure that the stack has a master locale.`,
`Locale locale not found in the stack ${this.exportConfig.apiKey}. Please ensure that the stack has a master locale.`,
this.exportConfig.context,
);
log.debug('Completed search. Master locale not found.', this.exportConfig.context);
Expand All @@ -201,7 +201,7 @@ export default class ExportStack extends BaseClass {
})
.catch((error: any) => {
log.debug(
`Error occurred while fetching locales for stack: ${this.exportConfig.source_stack}`,
`Error occurred while fetching locales for stack: ${this.exportConfig.apiKey}`,
this.exportConfig.context,
);
this.progressManager?.tick(
Expand All @@ -213,14 +213,14 @@ export default class ExportStack extends BaseClass {
handleAndLogError(
error,
{ ...this.exportConfig.context },
`Failed to fetch locales for stack ${this.exportConfig.source_stack}`,
`Failed to fetch locales for stack ${this.exportConfig.apiKey}`,
);
throw error;
});
}

async exportStack(): Promise<any> {
log.debug(`Starting stack export for: '${this.exportConfig.source_stack}'...`, this.exportConfig.context);
log.debug(`Starting stack export for: '${this.exportConfig.apiKey}'...`, this.exportConfig.context);

await fsUtil.makeDirectory(this.stackFolderPath);
log.debug(`Created stack directory at: '${this.stackFolderPath}'`, this.exportConfig.context);
Expand All @@ -235,20 +235,20 @@ export default class ExportStack extends BaseClass {
// Track progress for stack export completion
this.progressManager?.tick(
true,
`stack: ${this.exportConfig.source_stack}`,
`stack: ${this.exportConfig.apiKey}`,
null,
PROCESS_NAMES.STACK_DETAILS,
);

log.success(
`Stack details exported successfully for stack ${this.exportConfig.source_stack}`,
`Stack details exported successfully for stack ${this.exportConfig.apiKey}`,
this.exportConfig.context,
);
log.debug('Stack export completed successfully.', this.exportConfig.context);
return resp;
})
.catch((error: any) => {
log.debug(`Error occurred while exporting stack: ${this.exportConfig.source_stack}`, this.exportConfig.context);
log.debug(`Error occurred while exporting stack: ${this.exportConfig.apiKey}`, this.exportConfig.context);
this.progressManager?.tick(
false,
'stack export',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class ExportTaxonomies extends BaseClass {
this.applyQueryFilters(this.qs, 'taxonomies');
this.exportConfig.context.module = 'taxonomies';
this.localesFilePath = pResolve(
sanitizePath(exportConfig.data),
sanitizePath(exportConfig.exportDir),
sanitizePath(exportConfig.branchName || ''),
sanitizePath(exportConfig.modules.locales.dirName),
sanitizePath(exportConfig.modules.locales.fileName),
Expand All @@ -54,7 +54,7 @@ export default class ExportTaxonomies extends BaseClass {

//create taxonomies folder
this.taxonomiesFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.taxonomiesConfig.dirName,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class ExportWebhooks extends BaseClass {
// Setup with loading spinner
const [totalCount] = await this.withLoadingSpinner('WEBHOOKS: Analyzing webhooks...', async () => {
this.webhooksFolderPath = pResolve(
this.exportConfig.data,
this.exportConfig.exportDir,
this.exportConfig.branchName || '',
this.webhookConfig.dirName,
);
Expand Down
Loading
Loading