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
6 changes: 3 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fileignoreconfig:
- filename: package-lock.json
checksum: e99f717f726226d79c6d484b44fa3d8e758038fbaca671301377741e36802b6d
checksum: 560538910aada20a4c770b19f977bbe62680ca86ec6f5c3eb4b5a61e4f3f1a49
- filename: pnpm-lock.yaml
checksum: d26dfe4137bcd958a79beff8a2867fbbad531f81ef0c8c8a8786e8680b79b52e
checksum: 713cd001a5929ee85ab17eb7ef96c32a2b23878685a3ed74604a6ba6fd579058
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
- filename: packages/contentstack-import-setup/test/config.json
Expand Down Expand Up @@ -86,5 +86,5 @@ fileignoreconfig:
- filename: packages/contentstack-import-setup/src/utils/backup-handler.ts
checksum: 7db02c6f2627400b28fc96d505bf074d477080a45ba13943709d4845b6ca0908
- filename: packages/contentstack-import/src/utils/backup-handler.ts
checksum: 4f7a8bea92ebffbc34a0979b3a63fef327562a899b773481d67a675140cfa4bf
checksum: 0a9accdafce01837166223ed00cd801e2ebb39a4ef952231f67232859a5beea8
version: "1.0"
1,161 changes: 596 additions & 565 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~1.20.1",
"@contentstack/cli-cm-import": "~1.28.0",
"@contentstack/cli-cm-import": "~1.28.1",
"@contentstack/cli-command": "~1.6.1",
"@contentstack/cli-utilities": "~1.14.1",
"@oclif/core": "^4.3.0",
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.28.0 darwin-arm64 node-v22.14.0
@contentstack/cli-cm-import/1.28.1 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.28.0",
"version": "1.28.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
17 changes: 7 additions & 10 deletions packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path';
import { AuditFix } from '@contentstack/cli-audit';
import messages, { $t } from '@contentstack/cli-audit/lib/messages';
import { addLocale, cliux, ContentstackClient, Logger, log } from '@contentstack/cli-utilities';
import { addLocale, cliux, ContentstackClient, log } from '@contentstack/cli-utilities';

import startModuleImport from './modules';
import startJSModuleImport from './modules-js';
Expand All @@ -10,7 +10,6 @@ import {
backupHandler,
masterLocalDetails,
sanitizeStack,
initLogger,
setupBranchConfig,
executeImportPathLogic,
} from '../utils';
Expand All @@ -30,14 +29,15 @@ class ModuleImporter {
}

async start(): Promise<any> {

if (!this.importConfig.management_token) {
const stackDetails: Record<string, unknown> = await this.stackAPIClient.fetch();
this.importConfig.stackName = stackDetails.name as string;
this.importConfig.org_uid = stackDetails.org_uid as string;
}

await this.resolveImportPath();

await setupBranchConfig(this.importConfig, this.stackAPIClient);
if (this.importConfig.branchAlias && this.importConfig.branchName) {
this.stackAPIClient = this.managementAPIClient.stack({
Expand All @@ -58,9 +58,6 @@ class ModuleImporter {
this.importConfig.data = backupDir;
}

// NOTE init log
const logger = initLogger(this.importConfig);

// NOTE audit and fix the import content.
if (
!this.importConfig.skipAudit &&
Expand All @@ -69,7 +66,7 @@ class ModuleImporter {
this.importConfig.moduleName,
))
) {
if (!(await this.auditImportData(logger))) {
if (!(await this.auditImportData())) {
return { noSuccessMsg: true };
}
}
Expand Down Expand Up @@ -152,7 +149,7 @@ class ModuleImporter {
* @returns The function `auditImportData()` returns a boolean value. It returns `true` if there is a
* fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
*/
async auditImportData(logger: Logger) {
async auditImportData() {
const basePath = resolve(this.importConfig.cliLogsPath || this.importConfig.backupDir, 'logs', 'audit');
const auditConfig = this.importConfig.auditConfig;
auditConfig.config.basePath = basePath;
Expand Down Expand Up @@ -189,7 +186,7 @@ class ModuleImporter {
const { hasFix, config } = result;

if (hasFix) {
logger.log($t(messages.FINAL_REPORT_PATH, { path: config.reportPath }), 'warn');
log.warn($t(messages.FINAL_REPORT_PATH, { path: config.reportPath }), this.importConfig.context);

if (
this.importConfig.forceStopMarketplaceAppsPrompt ||
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/utils/backup-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async function backupHandler(importConfig: ImportConfig): Promise

if (backupDirPath) {
log.debug(`Starting content copy to backup directory: ${backupDirPath}`);
cliux.print('Copying content to the backup directory...');
log.info('Copying content to the backup directory...', importConfig.context);

return new Promise((resolve, reject) => {
return copy(sourceDir, backupDirPath, (error: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ const setupConfig = async (importCmdFlags: any): Promise<ImportConfig> => {
config.contentDir = path.resolve(config.contentDir);
//Note to support the old key
config.data = config.contentDir;
if (fileExistsSync(path.join(config.contentDir, 'export-info.json'))) {
config.contentVersion =
((await readFile(path.join(config.contentDir, 'export-info.json'))) || {}).contentVersion || 2;
} else {
config.contentVersion = 1;
}

const managementTokenAlias = importCmdFlags['management-token-alias'] || importCmdFlags['alias'];

Expand Down
16 changes: 13 additions & 3 deletions packages/contentstack-import/src/utils/import-path-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const resolveImportPath = async (importConfig: ImportConfig, stackAPIClie
* @param importConfig - The import configuration object
* @param resolvedPath - The resolved path
*/
export const updateImportConfigWithResolvedPath = (importConfig: ImportConfig, resolvedPath: string): void => {
export const updateImportConfigWithResolvedPath = async (importConfig: ImportConfig, resolvedPath: string): Promise<void> => {
log.debug(`Updating import config with resolved path: ${resolvedPath}`);

if (!fileExistsSync(resolvedPath)) {
Expand All @@ -137,8 +137,18 @@ export const updateImportConfigWithResolvedPath = (importConfig: ImportConfig, r

importConfig.data = resolvedPath;

const exportInfoPath = path.join(resolvedPath, 'export-info.json');
if (fileExistsSync(exportInfoPath)) {
const exportInfo = await readFile(exportInfoPath);
importConfig.contentVersion = exportInfo?.contentVersion || 2;
log.debug(`Content version set to ${importConfig.contentVersion} from ${exportInfoPath}`);
} else {
importConfig.contentVersion = 1;
log.debug(`No export-info.json found at ${exportInfoPath}, setting content version to 1`);
}

log.debug(
`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data}`,
`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data}, contentVersion: ${importConfig.contentVersion}`,
);
};

Expand All @@ -153,7 +163,7 @@ export const executeImportPathLogic = async (importConfig: ImportConfig, stackAP

const resolvedPath = await resolveImportPath(importConfig, stackAPIClient);

updateImportConfigWithResolvedPath(importConfig, resolvedPath);
await updateImportConfigWithResolvedPath(importConfig, resolvedPath);

return resolvedPath;
};
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.28.0",
"@contentstack/cli-cm-import": "~1.28.1",
"@contentstack/cli-command": "~1.6.1",
"@contentstack/cli-utilities": "~1.14.1",
"@contentstack/management": "~1.22.0",
Expand Down
18 changes: 9 additions & 9 deletions 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.47.0 darwin-arm64 node-v22.14.0
@contentstack/cli/1.47.1 darwin-arm64 node-v22.14.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -3705,7 +3705,7 @@ DESCRIPTION
Display help for csdx.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.32/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.33/src/commands/help.ts)_

## `csdx launch`

Expand Down Expand Up @@ -4022,7 +4022,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -4096,7 +4096,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -4145,7 +4145,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -4176,7 +4176,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -4217,7 +4217,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -4245,7 +4245,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -4289,7 +4289,7 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.47/src/commands/plugins/update.ts)_

## `csdx tokens`

Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.47.0",
"version": "1.47.1",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -30,7 +30,7 @@
"@contentstack/cli-cm-clone": "~1.16.1",
"@contentstack/cli-cm-export": "~1.20.1",
"@contentstack/cli-cm-export-to-csv": "~1.9.1",
"@contentstack/cli-cm-import": "~1.28.0",
"@contentstack/cli-cm-import": "~1.28.1",
"@contentstack/cli-cm-import-setup": "1.5.0",
"@contentstack/cli-cm-migrate-rte": "~1.6.1",
"@contentstack/cli-cm-seed": "~1.12.2",
Expand Down
Loading
Loading