@contentstack/cli-cm-import 2.0.0-beta.14 → 2.0.0-beta.15

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/2.0.0-beta.14 linux-x64 node-v22.22.1
50
+ @contentstack/cli-cm-import/2.0.0-beta.15 linux-x64 node-v22.22.2
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -16,7 +16,7 @@ class ImportCommand extends cli_command_1.Command {
16
16
  const { flags } = await this.parse(ImportCommand);
17
17
  importConfig = await (0, utils_1.setupImportConfig)(flags);
18
18
  // Prepare the context object
19
- (0, cli_utilities_1.createLogContext)(((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'cm:stacks:export', importConfig.apiKey, importConfig.authenticationMethod);
19
+ (0, cli_utilities_1.createLogContext)(((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'cm:stacks:import', importConfig.apiKey, importConfig.authenticationMethod);
20
20
  const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod);
21
21
  importConfig.context = Object.assign({}, context);
22
22
  //log.info(`Using Cli Version: ${this.context?.cliVersion}`, importConfig.context);
@@ -37,7 +37,7 @@ class ImportCommand extends cli_command_1.Command {
37
37
  cli_utilities_1.CLIProgressManager.initializeGlobalSummary(`IMPORT`, flags.branch, 'Importing content...');
38
38
  }
39
39
  const moduleImporter = new import_1.ModuleImporter(managementAPIClient, importConfig);
40
- const result = await moduleImporter.start();
40
+ await moduleImporter.start();
41
41
  backupDir = importConfig.backupDir;
42
42
  //Note: Final summary is now handled by summary manager
43
43
  cli_utilities_1.CLIProgressManager.printGlobalSummary();
@@ -53,8 +53,8 @@ class ContentTypesImport extends base_class_1.default {
53
53
  this.createdGFs = [];
54
54
  this.pendingGFs = [];
55
55
  this.pendingExts = [];
56
- this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMIES, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
57
- this.extPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.contentDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.EXTENSIONS, constants_1.PATH_CONSTANTS.FILES.PENDING_EXTENSIONS);
56
+ this.taxonomiesPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.TAXONOMIES, constants_1.PATH_CONSTANTS.FILES.SUCCESS);
57
+ this.extPendingPath = path.join((0, cli_utilities_1.sanitizePath)(importConfig.backupDir), constants_1.PATH_CONSTANTS.MAPPER, constants_1.PATH_CONSTANTS.MAPPER_MODULES.EXTENSIONS, constants_1.PATH_CONSTANTS.FILES.PENDING_EXTENSIONS);
58
58
  }
59
59
  async start() {
60
60
  var _a;
@@ -26,7 +26,6 @@ export default interface ImportConfig extends DefaultConfig, ExternalConfig {
26
26
  contentTypes?: string[];
27
27
  branches?: branch[];
28
28
  branchEnabled?: boolean;
29
- branchDir?: string;
30
29
  branchAlias?: string;
31
30
  moduleName?: Modules;
32
31
  master_locale: masterLocale;
@@ -11,8 +11,8 @@ async function backupHandler(importConfig) {
11
11
  cli_utilities_1.log.debug(`Using existing backup directory: ${importConfig.useBackedupDir}`);
12
12
  return importConfig.useBackedupDir;
13
13
  }
14
- const sourceDir = importConfig.branchDir || importConfig.contentDir;
15
- cli_utilities_1.log.debug(`Using source directory for backup: ${sourceDir} (branchDir: ${importConfig.branchDir}, contentDir: ${importConfig.contentDir})`);
14
+ const sourceDir = importConfig.contentDir;
15
+ cli_utilities_1.log.debug(`Using source directory for backup: ${sourceDir}, contentDir: ${importConfig.contentDir})`);
16
16
  let backupDirPath;
17
17
  const subDir = isSubDirectory(importConfig, sourceDir);
18
18
  if (subDir) {
@@ -88,7 +88,6 @@ const setupConfig = async (importCmdFlags) => {
88
88
  }
89
89
  if (importCmdFlags['branch']) {
90
90
  config.branchName = importCmdFlags['branch'];
91
- config.branchDir = config.contentDir;
92
91
  }
93
92
  if (importCmdFlags['module']) {
94
93
  config.moduleName = importCmdFlags['module'];
@@ -1,12 +1,4 @@
1
1
  import { ImportConfig } from '../types';
2
- /**
3
- * Selects a branch from directory structure when multiple branches are found
4
- * @param contentDir - The content directory path
5
- * @returns Promise<{ branchPath: string } | null>
6
- */
7
- export declare const selectBranchFromDirectory: (contentDir: string) => Promise<{
8
- branchPath: string;
9
- } | null>;
10
2
  /**
11
3
  * Resolves the import path based on directory structure and user configuration
12
4
  * @param importConfig - The import configuration object
@@ -1,60 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = exports.selectBranchFromDirectory = void 0;
3
+ exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
5
+ const path = tslib_1.__importStar(require("node:path"));
6
6
  const cli_utilities_1 = require("@contentstack/cli-utilities");
7
7
  const config_1 = tslib_1.__importDefault(require("../config"));
8
- const interactive_1 = require("./interactive");
9
8
  const file_helper_1 = require("./file-helper");
10
- /**
11
- * Selects a branch from directory structure when multiple branches are found
12
- * @param contentDir - The content directory path
13
- * @returns Promise<{ branchPath: string } | null>
14
- */
15
- const selectBranchFromDirectory = async (contentDir) => {
16
- cli_utilities_1.log.debug('Selecting branch directory from directory structure');
17
- const branchesJsonPath = path.join(contentDir, 'branches.json');
18
- if (!(0, file_helper_1.fileExistsSync)(branchesJsonPath)) {
19
- cli_utilities_1.log.debug('No branches.json found - not a branch-enabled export');
20
- return null;
21
- }
22
- try {
23
- const branchesData = await (0, file_helper_1.readFile)(branchesJsonPath);
24
- const branches = branchesData || [];
25
- if (!branches || !Array.isArray(branches) || branches.length === 0) {
26
- cli_utilities_1.log.debug('No branches found in branches.json - not a branch-enabled export');
27
- return null;
28
- }
29
- if (branches.length === 1) {
30
- const singleBranch = branches[0];
31
- const branchPath = path.join(contentDir, singleBranch.uid);
32
- if (!(0, file_helper_1.fileExistsSync)(branchPath)) {
33
- cli_utilities_1.log.warn(`Branch path does not exist: ${branchPath}, not a valid branch export`);
34
- return null;
35
- }
36
- cli_utilities_1.log.debug(`Single branch detected: ${singleBranch.uid} - auto-resolving to: ${branchPath}`);
37
- return { branchPath };
38
- }
39
- else {
40
- cli_utilities_1.log.debug(`Multiple branches detected: ${branches.map((b) => b.uid).join(', ')}`);
41
- const branchNames = branches.map((b) => b.uid);
42
- const selectedBranch = await (0, interactive_1.askBranchSelection)(branchNames);
43
- const selectedBranchPath = path.join(contentDir, selectedBranch);
44
- if (!(0, file_helper_1.fileExistsSync)(selectedBranchPath)) {
45
- cli_utilities_1.log.warn(`Selected branch path does not exist: ${selectedBranchPath}, not a valid branch export`);
46
- return null;
47
- }
48
- cli_utilities_1.log.debug(`User selected branch directory: ${selectedBranch} - using path: ${selectedBranchPath}`);
49
- return { branchPath: selectedBranchPath };
50
- }
51
- }
52
- catch (error) {
53
- cli_utilities_1.log.error(`Error selecting branch directory from directory structure: ${error}`);
54
- throw error;
55
- }
56
- };
57
- exports.selectBranchFromDirectory = selectBranchFromDirectory;
58
9
  /**
59
10
  * Resolves the import path based on directory structure and user configuration
60
11
  * @param importConfig - The import configuration object
@@ -68,31 +19,12 @@ const resolveImportPath = async (importConfig, stackAPIClient) => {
68
19
  if (!(0, file_helper_1.fileExistsSync)(contentDir)) {
69
20
  throw new Error(`Content directory does not exist: ${contentDir}`);
70
21
  }
71
- if (importConfig.branchName) {
72
- cli_utilities_1.log.debug(`User specified branch: ${importConfig.branchName}`);
73
- const currentDirName = path.basename(contentDir);
74
- if (currentDirName === importConfig.branchName) {
75
- cli_utilities_1.log.debug(`Already in correct branch directory: ${contentDir}`);
76
- return contentDir;
77
- }
78
- const branchPath = path.join(contentDir, importConfig.branchName);
79
- if ((0, file_helper_1.fileExistsSync)(branchPath)) {
80
- cli_utilities_1.log.debug(`Navigating to specified branch directory: ${branchPath}`);
81
- return branchPath;
82
- }
83
- cli_utilities_1.log.debug(`Branch directory not found: ${branchPath}, using contentDir as-is`);
84
- return contentDir;
85
- }
86
22
  const moduleTypes = config_1.default.modules.types;
87
23
  const hasModuleFolders = moduleTypes.some((moduleType) => (0, file_helper_1.fileExistsSync)(path.join(contentDir, moduleType)));
88
24
  if (hasModuleFolders) {
89
- cli_utilities_1.log.debug('Found module folders ');
25
+ cli_utilities_1.log.debug('Found module folders at export root');
90
26
  return contentDir;
91
27
  }
92
- const branchSelection = await (0, exports.selectBranchFromDirectory)(contentDir);
93
- if (branchSelection) {
94
- return branchSelection.branchPath;
95
- }
96
28
  cli_utilities_1.log.debug('No specific structure detected - using contentDir as-is');
97
29
  return contentDir;
98
30
  };
@@ -108,9 +40,8 @@ const updateImportConfigWithResolvedPath = async (importConfig, resolvedPath) =>
108
40
  cli_utilities_1.log.warn(`Resolved path does not exist: ${resolvedPath}, skipping config update`);
109
41
  return;
110
42
  }
111
- importConfig.branchDir = resolvedPath;
112
43
  importConfig.contentDir = resolvedPath;
113
- cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}, branchDir: ${importConfig.branchDir}`);
44
+ cli_utilities_1.log.debug(`Import config updated - contentDir: ${importConfig.contentDir}`);
114
45
  };
115
46
  exports.updateImportConfigWithResolvedPath = updateImportConfigWithResolvedPath;
116
47
  /**
@@ -1,5 +1,5 @@
1
1
  export { setupBranchConfig } from './setup-branch';
2
- export { selectBranchFromDirectory, resolveImportPath, updateImportConfigWithResolvedPath, executeImportPathLogic } from './import-path-resolver';
2
+ export { resolveImportPath, updateImportConfigWithResolvedPath, executeImportPathLogic } from './import-path-resolver';
3
3
  export * as interactive from './interactive';
4
4
  export { default as setupImportConfig } from './import-config-handler';
5
5
  export * as fileHelper from './file-helper';
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = exports.selectBranchFromDirectory = exports.setupBranchConfig = void 0;
3
+ exports.PROCESS_STATUS = exports.PROCESS_NAMES = exports.MODULE_NAMES = exports.MODULE_CONTEXTS = exports.lookUpTerms = exports.lookUpTaxonomy = exports.restoreJsonRteEntryRefs = exports.removeEntryRefsFromJSONRTE = exports.removeUidsFromJsonRteFields = exports.lookupEntries = exports.lookupExtension = exports.removeReferenceFields = exports.suppressSchemaReference = exports.schemaTemplate = exports.ifAppAlreadyExist = exports.getAllStackSpecificApps = exports.confirmToCloseProcess = exports.makeRedirectUrlCall = exports.handleNameConflict = exports.getConfirmationToCreateApps = exports.getOrgUid = exports.getDeveloperHubUrl = exports.lookupAssets = exports.uploadAssetHelper = exports.unlinkFileLogger = exports.log = exports.backupHandler = exports.fsUtil = exports.fileHelper = exports.setupImportConfig = exports.interactive = exports.executeImportPathLogic = exports.updateImportConfigWithResolvedPath = exports.resolveImportPath = exports.setupBranchConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  var setup_branch_1 = require("./setup-branch");
6
6
  Object.defineProperty(exports, "setupBranchConfig", { enumerable: true, get: function () { return setup_branch_1.setupBranchConfig; } });
7
7
  var import_path_resolver_1 = require("./import-path-resolver");
8
- Object.defineProperty(exports, "selectBranchFromDirectory", { enumerable: true, get: function () { return import_path_resolver_1.selectBranchFromDirectory; } });
9
8
  Object.defineProperty(exports, "resolveImportPath", { enumerable: true, get: function () { return import_path_resolver_1.resolveImportPath; } });
10
9
  Object.defineProperty(exports, "updateImportConfigWithResolvedPath", { enumerable: true, get: function () { return import_path_resolver_1.updateImportConfigWithResolvedPath; } });
11
10
  Object.defineProperty(exports, "executeImportPathLogic", { enumerable: true, get: function () { return import_path_resolver_1.executeImportPathLogic; } });
@@ -168,5 +168,5 @@
168
168
  ]
169
169
  }
170
170
  },
171
- "version": "2.0.0-beta.14"
171
+ "version": "2.0.0-beta.15"
172
172
  }
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "2.0.0-beta.14",
4
+ "version": "2.0.0-beta.15",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-audit": "~2.0.0-beta.9",
9
- "@contentstack/cli-command": "~2.0.0-beta.5",
10
- "@contentstack/cli-utilities": "~2.0.0-beta.5",
11
- "@contentstack/cli-variants": "~2.0.0-beta.11",
8
+ "@contentstack/cli-audit": "~2.0.0-beta.10",
9
+ "@contentstack/cli-command": "~2.0.0-beta.6",
10
+ "@contentstack/cli-utilities": "~2.0.0-beta.7",
11
+ "@contentstack/cli-variants": "~2.0.0-beta.12",
12
12
  "@oclif/core": "^4.3.0",
13
13
  "big-json": "^3.2.0",
14
14
  "bluebird": "^3.7.2",
15
15
  "chalk": "^5.6.2",
16
16
  "debug": "^4.4.3",
17
17
  "fs-extra": "^11.3.3",
18
- "lodash": "^4.17.23",
18
+ "lodash": "^4.18.1",
19
19
  "marked": "^4.3.0",
20
20
  "merge": "^2.1.1",
21
21
  "mkdirp": "^1.0.4",