@contentstack/cli-cm-import 1.28.0 → 1.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import/1.28.0 linux-x64 node-v22.19.0
50
+ @contentstack/cli-cm-import/1.28.1 linux-x64 node-v22.19.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -1,4 +1,4 @@
1
- import { ContentstackClient, Logger } from '@contentstack/cli-utilities';
1
+ import { ContentstackClient } from '@contentstack/cli-utilities';
2
2
  import { ImportConfig, Modules } from '../types';
3
3
  declare class ModuleImporter {
4
4
  private managementAPIClient;
@@ -20,6 +20,6 @@ declare class ModuleImporter {
20
20
  * @returns The function `auditImportData()` returns a boolean value. It returns `true` if there is a
21
21
  * fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
22
22
  */
23
- auditImportData(logger: Logger): Promise<boolean>;
23
+ auditImportData(): Promise<boolean>;
24
24
  }
25
25
  export default ModuleImporter;
@@ -41,13 +41,11 @@ class ModuleImporter {
41
41
  // To support the old config
42
42
  this.importConfig.data = backupDir;
43
43
  }
44
- // NOTE init log
45
- const logger = (0, utils_1.initLogger)(this.importConfig);
46
44
  // NOTE audit and fix the import content.
47
45
  if (!this.importConfig.skipAudit &&
48
46
  (!this.importConfig.moduleName ||
49
47
  ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'].includes(this.importConfig.moduleName))) {
50
- if (!(await this.auditImportData(logger))) {
48
+ if (!(await this.auditImportData())) {
51
49
  return { noSuccessMsg: true };
52
50
  }
53
51
  }
@@ -120,7 +118,7 @@ class ModuleImporter {
120
118
  * @returns The function `auditImportData()` returns a boolean value. It returns `true` if there is a
121
119
  * fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
122
120
  */
123
- async auditImportData(logger) {
121
+ async auditImportData() {
124
122
  const basePath = (0, path_1.resolve)(this.importConfig.cliLogsPath || this.importConfig.backupDir, 'logs', 'audit');
125
123
  const auditConfig = this.importConfig.auditConfig;
126
124
  auditConfig.config.basePath = basePath;
@@ -151,7 +149,7 @@ class ModuleImporter {
151
149
  if (result) {
152
150
  const { hasFix, config } = result;
153
151
  if (hasFix) {
154
- logger.log((0, messages_1.$t)(messages_1.default.FINAL_REPORT_PATH, { path: config.reportPath }), 'warn');
152
+ cli_utilities_1.log.warn((0, messages_1.$t)(messages_1.default.FINAL_REPORT_PATH, { path: config.reportPath }), this.importConfig.context);
155
153
  if (this.importConfig.forceStopMarketplaceAppsPrompt ||
156
154
  (await cli_utilities_1.cliux.inquire({
157
155
  type: 'confirm',
@@ -41,7 +41,7 @@ async function backupHandler(importConfig) {
41
41
  }
42
42
  if (backupDirPath) {
43
43
  cli_utilities_1.log.debug(`Starting content copy to backup directory: ${backupDirPath}`);
44
- cli_utilities_1.cliux.print('Copying content to the backup directory...');
44
+ cli_utilities_1.log.info('Copying content to the backup directory...', importConfig.context);
45
45
  return new Promise((resolve, reject) => {
46
46
  return (0, fs_extra_1.copy)(sourceDir, backupDirPath, (error) => {
47
47
  if (error) {
@@ -35,13 +35,6 @@ const setupConfig = async (importCmdFlags) => {
35
35
  config.contentDir = path.resolve(config.contentDir);
36
36
  //Note to support the old key
37
37
  config.data = config.contentDir;
38
- if ((0, file_helper_1.fileExistsSync)(path.join(config.contentDir, 'export-info.json'))) {
39
- config.contentVersion =
40
- ((await (0, file_helper_1.readFile)(path.join(config.contentDir, 'export-info.json'))) || {}).contentVersion || 2;
41
- }
42
- else {
43
- config.contentVersion = 1;
44
- }
45
38
  const managementTokenAlias = importCmdFlags['management-token-alias'] || importCmdFlags['alias'];
46
39
  if (managementTokenAlias) {
47
40
  const { token, apiKey } = (_a = cli_utilities_1.configHandler.get(`tokens.${managementTokenAlias}`)) !== null && _a !== void 0 ? _a : {};
@@ -19,7 +19,7 @@ export declare const resolveImportPath: (importConfig: ImportConfig, stackAPICli
19
19
  * @param importConfig - The import configuration object
20
20
  * @param resolvedPath - The resolved path
21
21
  */
22
- export declare const updateImportConfigWithResolvedPath: (importConfig: ImportConfig, resolvedPath: string) => void;
22
+ export declare const updateImportConfigWithResolvedPath: (importConfig: ImportConfig, resolvedPath: string) => Promise<void>;
23
23
  /**
24
24
  * Executes the complete import path resolution logic
25
25
  * @param importConfig - The import configuration object
@@ -107,7 +107,7 @@ exports.resolveImportPath = resolveImportPath;
107
107
  * @param importConfig - The import configuration object
108
108
  * @param resolvedPath - The resolved path
109
109
  */
110
- const updateImportConfigWithResolvedPath = (importConfig, resolvedPath) => {
110
+ const updateImportConfigWithResolvedPath = async (importConfig, resolvedPath) => {
111
111
  cli_utilities_1.log.debug(`Updating import config with resolved path: ${resolvedPath}`);
112
112
  if (!(0, file_helper_1.fileExistsSync)(resolvedPath)) {
113
113
  cli_utilities_1.log.warn(`Resolved path does not exist: ${resolvedPath}, skipping config update`);
@@ -116,7 +116,17 @@ const updateImportConfigWithResolvedPath = (importConfig, resolvedPath) => {
116
116
  importConfig.branchDir = resolvedPath;
117
117
  importConfig.contentDir = resolvedPath;
118
118
  importConfig.data = resolvedPath;
119
- cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data}`);
119
+ const exportInfoPath = path.join(resolvedPath, 'export-info.json');
120
+ if ((0, file_helper_1.fileExistsSync)(exportInfoPath)) {
121
+ const exportInfo = await (0, file_helper_1.readFile)(exportInfoPath);
122
+ importConfig.contentVersion = (exportInfo === null || exportInfo === void 0 ? void 0 : exportInfo.contentVersion) || 2;
123
+ cli_utilities_1.log.debug(`Content version set to ${importConfig.contentVersion} from ${exportInfoPath}`);
124
+ }
125
+ else {
126
+ importConfig.contentVersion = 1;
127
+ cli_utilities_1.log.debug(`No export-info.json found at ${exportInfoPath}, setting content version to 1`);
128
+ }
129
+ cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}, data: ${importConfig.data}, contentVersion: ${importConfig.contentVersion}`);
120
130
  };
121
131
  exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
122
132
  /**
@@ -128,7 +138,7 @@ exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
128
138
  const executeImportPathLogic = async (importConfig, stackAPIClient) => {
129
139
  cli_utilities_1.log.debug('Executing import path resolution logic');
130
140
  const resolvedPath = await (0, exports.resolveImportPath)(importConfig, stackAPIClient);
131
- (0, exports.updateImportConfigWithResolvedPath)(importConfig, resolvedPath);
141
+ await (0, exports.updateImportConfigWithResolvedPath)(importConfig, resolvedPath);
132
142
  return resolvedPath;
133
143
  };
134
144
  exports.executeImportPathLogic = executeImportPathLogic;
@@ -212,5 +212,5 @@
212
212
  ]
213
213
  }
214
214
  },
215
- "version": "1.28.0"
215
+ "version": "1.28.1"
216
216
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.28.0",
4
+ "version": "1.28.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {