Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fileignoreconfig:
- filename: packages/contentstack-export/src/commands/cm/stacks/export.ts
checksum: ece7891cb6fd7edff4a3cd54adb03ba8f7d8d5758f52d98a5c0ff0bd1b071f74
- filename: packages/contentstack-import/src/commands/cm/stacks/import.ts
checksum: c979bcc18cb0d3e5c58f1b27a106b3d89bb6524d47c0cc2b2fd199031ea33279
checksum: 97463e90433387396c1effeef8eed736179b85e3674398fc7ad22c936f7d8393
- filename: packages/contentstack-export/src/export/modules/custom-roles.ts
checksum: 4fc0f5cab039c84d1a12cdae90dcdcaf15ba461b23007635dc997aada75bbb23
- filename: packages/contentstack-import/src/utils/extension-helper.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-config/1.14.0 darwin-arm64 node-v22.14.0
@contentstack/cli-config/1.15.0 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-import/1.26.0 darwin-arm64 node-v22.14.0
@contentstack/cli-cm-import/1.26.1 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
43 changes: 25 additions & 18 deletions packages/contentstack-import/src/commands/cm/stacks/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

import { Context, ImportConfig } from '../../../types';
import { ModuleImporter } from '../../../import';
import { setupImportConfig } from '../../../utils';
import { setupImportConfig } from '../../../utils';

export default class ImportCommand extends Command {
static description = messageHandler.parse('Import content from a stack');
Expand Down Expand Up @@ -149,53 +149,60 @@ export default class ImportCommand extends Command {
let importConfig: ImportConfig = await setupImportConfig(flags);
// Prepare the context object
const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod);
importConfig.context = {...context};
importConfig.context = { ...context };
//log.info(`Using Cli Version: ${this.context?.cliVersion}`, importConfig.context);

// Note setting host to create cma client
importConfig.host = this.cmaHost;
importConfig.region = this.region;
if (this.developerHubUrl) importConfig.developerHubBaseUrl = this.developerHubUrl;
if (this.personalizeUrl) importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;

const managementAPIClient: ContentstackClient = await managementSDKClient(importConfig);

if (!flags.branch) {
try {
// Use stack configuration to check for branch availability
// false positive - no hardcoded secret here
// @ts-ignore-next-line secret-detection
// @ts-ignore-next-line secret-detection
const keyProp = 'api_key';
const branches = await managementAPIClient
.stack({ [keyProp]: importConfig.apiKey })
.branch()
.query()
.find()
.then(({ items }: any) => items);
.stack({ [keyProp]: importConfig.apiKey })
.branch()
.query()
.find()
.then(({ items }: any) => items);
if (branches.length) {
flags.branch = 'main';
}
} catch (error) {
// Branch not enabled, just the let flow continue
}
}

// Set backupDir early so it's available in error handling
backupDir = importConfig.backupDir;

const moduleImporter = new ModuleImporter(managementAPIClient, importConfig);
const result = await moduleImporter.start();
backupDir = importConfig.backupDir;

if (!result?.noSuccessMsg) {
if (!result?.noSuccessMsg) {
const successMessage = importConfig.stackName
? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`
: `The content has been imported to the stack ${importConfig.apiKey} successfully!`;
? `Successfully imported the content to the stack named ${importConfig.stackName} with the API key ${importConfig.apiKey} .`
: `The content has been imported to the stack ${importConfig.apiKey} successfully!`;
log.success(successMessage, importConfig.context);
}

log.success(`The log has been stored at '${getLogPath()}'`, importConfig.context)
log.success(`The log has been stored at '${getLogPath()}'`, importConfig.context);
log.info(`The backup content has been stored at '${backupDir}'`, importConfig.context);
} catch (error) {
handleAndLogError(error);
log.info(`The log has been stored at '${getLogPath()}'`)
log.info(`The backup content has been stored at '${backupDir}'`);
log.info(`The log has been stored at '${getLogPath()}'`);
if (backupDir) {
log.info(`The backup content has been stored at '${backupDir}'`);
} else {
log.info('No backup directory was created due to early termination');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli/1.44.0 darwin-arm64 node-v22.14.0
@contentstack/cli/1.44.1 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
Loading