@contentstack/cli-cm-clone 2.0.0-beta.13 → 2.0.0-beta.14

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
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone
16
16
  $ csdx COMMAND
17
17
  running command...
18
18
  $ csdx (--version)
19
- @contentstack/cli-cm-clone/2.0.0-beta.13 linux-x64 node-v22.22.1
19
+ @contentstack/cli-cm-clone/2.0.0-beta.14 linux-x64 node-v22.22.1
20
20
  $ csdx --help [COMMAND]
21
21
  USAGE
22
22
  $ csdx COMMAND
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const ora_1 = tslib_1.__importDefault(require("ora"));
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
9
9
  const fs = tslib_1.__importStar(require("fs"));
10
10
  const rimraf_1 = require("rimraf");
11
11
  const cli_cm_export_1 = tslib_1.__importDefault(require("@contentstack/cli-cm-export"));
@@ -14,7 +14,7 @@ const cli_cm_import_1 = tslib_1.__importDefault(require("@contentstack/cli-cm-im
14
14
  const prompt = require('prompt');
15
15
  const safe_1 = tslib_1.__importDefault(require("@colors/colors/safe"));
16
16
  const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
17
- const cli_utilities_1 = require("@contentstack/cli-utilities");
17
+ const cli_utilities_2 = require("@contentstack/cli-utilities");
18
18
  const command_helpers_1 = require("../helpers/command-helpers");
19
19
  const constants_1 = require("../../utils/constants");
20
20
  // Override prompt's stop method
@@ -42,7 +42,7 @@ class CloneHandler {
42
42
  message: constants_1.STACK_NAME_PROMPT.message,
43
43
  };
44
44
  process.stdin.setMaxListeners(50);
45
- cli_utilities_1.log.debug('Initializing CloneHandler', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: opt.pathDir, cloneType: opt.cloneType }));
45
+ cli_utilities_2.log.debug('Initializing CloneHandler', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: opt.pathDir, cloneType: opt.cloneType }));
46
46
  }
47
47
  setClient(managementSDKClient) {
48
48
  this.client = managementSDKClient;
@@ -55,12 +55,12 @@ class CloneHandler {
55
55
  choices: [],
56
56
  };
57
57
  return new Promise(async (resolve, reject) => {
58
- cli_utilities_1.log.debug('Fetching organization choices', this.config.cloneContext);
58
+ cli_utilities_2.log.debug('Fetching organization choices', this.config.cloneContext);
59
59
  const spinner = (0, ora_1.default)('Fetching Organization').start();
60
60
  try {
61
61
  let organizations;
62
- const configOrgUid = cli_utilities_1.configHandler.get('oauthOrgUid');
63
- cli_utilities_1.log.debug('Getting organizations', Object.assign(Object.assign({}, this.config.cloneContext), { hasConfigOrgUid: !!configOrgUid }));
62
+ const configOrgUid = cli_utilities_2.configHandler.get('oauthOrgUid');
63
+ cli_utilities_2.log.debug('Getting organizations', Object.assign(Object.assign({}, this.config.cloneContext), { hasConfigOrgUid: !!configOrgUid }));
64
64
  if (configOrgUid) {
65
65
  organizations = await this.client.organization(configOrgUid).fetch();
66
66
  }
@@ -68,7 +68,7 @@ class CloneHandler {
68
68
  organizations = await this.client.organization().fetchAll({ limit: 100 });
69
69
  }
70
70
  spinner.succeed('Fetched Organization');
71
- cli_utilities_1.log.debug('Fetched organizations', this.config.cloneContext);
71
+ cli_utilities_2.log.debug('Fetched organizations', this.config.cloneContext);
72
72
  for (const element of organizations.items || [organizations]) {
73
73
  this.orgUidList[element.name] = element.uid;
74
74
  orgChoice.choices.push(element.name);
@@ -85,19 +85,19 @@ class CloneHandler {
85
85
  return new Promise(async (resolve, reject) => {
86
86
  var _a;
87
87
  const { msg = '', isSource = true } = options || {};
88
- cli_utilities_1.log.debug('Handling organization selection', this.config.cloneContext);
88
+ cli_utilities_2.log.debug('Handling organization selection', this.config.cloneContext);
89
89
  const orgList = await this.getOrganizationChoices(msg).catch(reject);
90
90
  if (orgList) {
91
- cli_utilities_1.log.debug(`Found ${((_a = orgList.choices) === null || _a === void 0 ? void 0 : _a.length) || 0} organization(s) to choose from`, this.config.cloneContext);
91
+ cli_utilities_2.log.debug(`Found ${((_a = orgList.choices) === null || _a === void 0 ? void 0 : _a.length) || 0} organization(s) to choose from`, this.config.cloneContext);
92
92
  const orgSelected = await inquirer_1.default.prompt(orgList);
93
- cli_utilities_1.log.debug(`Organization selected: ${orgSelected.Organization}`, this.config.cloneContext);
93
+ cli_utilities_2.log.debug(`Organization selected: ${orgSelected.Organization}`, this.config.cloneContext);
94
94
  if (isSource) {
95
95
  this.config.sourceOrg = this.orgUidList[orgSelected.Organization];
96
- cli_utilities_1.log.debug(`Source organization UID: ${this.config.sourceOrg}`, this.config.cloneContext);
96
+ cli_utilities_2.log.debug(`Source organization UID: ${this.config.sourceOrg}`, this.config.cloneContext);
97
97
  }
98
98
  else {
99
99
  this.config.targetOrg = this.orgUidList[orgSelected.Organization];
100
- cli_utilities_1.log.debug(`Target organization UID: ${this.config.targetOrg}`, this.config.cloneContext);
100
+ cli_utilities_2.log.debug(`Target organization UID: ${this.config.targetOrg}`, this.config.cloneContext);
101
101
  }
102
102
  resolve(orgSelected);
103
103
  }
@@ -111,15 +111,15 @@ class CloneHandler {
111
111
  choices: [],
112
112
  };
113
113
  return new Promise(async (resolve, reject) => {
114
- cli_utilities_1.log.debug('Fetching stacks', this.config.cloneContext);
114
+ cli_utilities_2.log.debug('Fetching stacks', this.config.cloneContext);
115
115
  const spinner = (0, ora_1.default)('Fetching stacks').start();
116
116
  try {
117
117
  const organization_uid = this.orgUidList[answer.Organization];
118
- cli_utilities_1.log.debug('Querying stacks for organization', Object.assign(Object.assign({}, this.config.cloneContext), { organizationUid: organization_uid }));
118
+ cli_utilities_2.log.debug('Querying stacks for organization', Object.assign(Object.assign({}, this.config.cloneContext), { organizationUid: organization_uid }));
119
119
  const stackList = this.client.stack().query({ organization_uid }).find();
120
120
  stackList
121
121
  .then((stacklist) => {
122
- cli_utilities_1.log.debug('Fetched stacks', Object.assign(Object.assign({}, this.config.cloneContext), { count: stacklist.items ? stacklist.items.length : 0 }));
122
+ cli_utilities_2.log.debug('Fetched stacks', Object.assign(Object.assign({}, this.config.cloneContext), { count: stacklist.items ? stacklist.items.length : 0 }));
123
123
  for (const element of stacklist.items) {
124
124
  this.stackUidList[element.name] = element.api_key;
125
125
  this.masterLocaleList[element.name] = element.master_locale;
@@ -140,7 +140,7 @@ class CloneHandler {
140
140
  });
141
141
  }
142
142
  displayBackOptionMessage() {
143
- process.stdout.write(chalk_1.default.cyan('\nPress shift & left arrow together to undo the operation\n'));
143
+ process.stdout.write((0, cli_utilities_1.getChalk)().cyan('\nPress shift & left arrow together to undo the operation\n'));
144
144
  }
145
145
  setBackKeyPressHandler(backKeyPressHandler) {
146
146
  this.backKeyPressHandler = backKeyPressHandler;
@@ -159,13 +159,13 @@ class CloneHandler {
159
159
  var _a;
160
160
  try {
161
161
  const { org = {}, msg = '', isSource = true } = options || {};
162
- cli_utilities_1.log.debug('Handling stack selection', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, orgName: org.Organization, msg }));
162
+ cli_utilities_2.log.debug('Handling stack selection', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, orgName: org.Organization, msg }));
163
163
  const stackList = await this.getStack(org, msg, isSource).catch(reject);
164
164
  if (stackList) {
165
165
  this.displayBackOptionMessage();
166
- cli_utilities_1.log.debug(`Found ${((_a = stackList.choices) === null || _a === void 0 ? void 0 : _a.length) || 0} stack(s) to choose from`, this.config.cloneContext);
166
+ cli_utilities_2.log.debug(`Found ${((_a = stackList.choices) === null || _a === void 0 ? void 0 : _a.length) || 0} stack(s) to choose from`, this.config.cloneContext);
167
167
  const selectedStack = await inquirer_1.default.prompt(stackList);
168
- cli_utilities_1.log.debug(`Stack selected: ${selectedStack.stack}`, this.config.cloneContext);
168
+ cli_utilities_2.log.debug(`Stack selected: ${selectedStack.stack}`, this.config.cloneContext);
169
169
  if (this.executingCommand != 1) {
170
170
  return reject();
171
171
  }
@@ -173,12 +173,12 @@ class CloneHandler {
173
173
  this.config.sourceStackName = selectedStack.stack;
174
174
  this.master_locale = this.masterLocaleList[selectedStack.stack];
175
175
  this.config.source_stack = this.stackUidList[selectedStack.stack];
176
- cli_utilities_1.log.debug(`Source stack configured`, this.config.cloneContext);
176
+ cli_utilities_2.log.debug(`Source stack configured`, this.config.cloneContext);
177
177
  }
178
178
  else {
179
179
  this.config.target_stack = this.stackUidList[selectedStack.stack];
180
180
  this.config.destinationStackName = selectedStack.stack;
181
- cli_utilities_1.log.debug(`Target stack configured`, this.config.cloneContext);
181
+ cli_utilities_2.log.debug(`Target stack configured`, this.config.cloneContext);
182
182
  }
183
183
  resolve(selectedStack);
184
184
  }
@@ -196,18 +196,18 @@ class CloneHandler {
196
196
  };
197
197
  try {
198
198
  const branch = isSource ? this.config.sourceStackBranch : this.config.targetStackBranch;
199
- cli_utilities_1.log.debug('Validating branch existence', this.config.cloneContext);
199
+ cli_utilities_2.log.debug('Validating branch existence', this.config.cloneContext);
200
200
  spinner = (0, ora_1.default)(`Validation if ${isSource ? 'source' : 'target'} branch exist.!`).start();
201
201
  const isBranchExist = await stackAPIClient
202
202
  .branch(branch)
203
203
  .fetch()
204
204
  .then((data) => data);
205
205
  if (isBranchExist && typeof isBranchExist === 'object') {
206
- cli_utilities_1.log.debug('Branch validation successful', this.config.cloneContext);
206
+ cli_utilities_2.log.debug('Branch validation successful', this.config.cloneContext);
207
207
  completeSpinner(`${isSource ? 'Source' : 'Target'} branch verified.!`);
208
208
  }
209
209
  else {
210
- cli_utilities_1.log.error('Branch not found', this.config.cloneContext);
210
+ cli_utilities_2.log.error('Branch not found', this.config.cloneContext);
211
211
  completeSpinner(`${isSource ? 'Source' : 'Target'} branch not found.!`, 'fail');
212
212
  process.exit();
213
213
  }
@@ -219,16 +219,16 @@ class CloneHandler {
219
219
  }
220
220
  async resolveBranchAliases(isSource = false) {
221
221
  try {
222
- cli_utilities_1.log.debug('Resolving branch aliases', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, alias: isSource ? this.config.sourceStackBranchAlias : this.config.targetStackBranchAlias }));
222
+ cli_utilities_2.log.debug('Resolving branch aliases', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, alias: isSource ? this.config.sourceStackBranchAlias : this.config.targetStackBranchAlias }));
223
223
  if (isSource) {
224
224
  const sourceStack = this.client.stack({ api_key: this.config.source_stack });
225
- this.config.sourceStackBranch = await (0, cli_utilities_1.getBranchFromAlias)(sourceStack, this.config.sourceStackBranchAlias);
226
- cli_utilities_1.log.debug('Source branch alias resolved', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.sourceStackBranchAlias, branch: this.config.sourceStackBranch }));
225
+ this.config.sourceStackBranch = await (0, cli_utilities_2.getBranchFromAlias)(sourceStack, this.config.sourceStackBranchAlias);
226
+ cli_utilities_2.log.debug('Source branch alias resolved', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.sourceStackBranchAlias, branch: this.config.sourceStackBranch }));
227
227
  }
228
228
  else {
229
229
  const targetStack = this.client.stack({ api_key: this.config.target_stack });
230
- this.config.targetStackBranch = await (0, cli_utilities_1.getBranchFromAlias)(targetStack, this.config.targetStackBranchAlias);
231
- cli_utilities_1.log.debug('Target branch alias resolved', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.targetStackBranchAlias, branch: this.config.targetStackBranch }));
230
+ this.config.targetStackBranch = await (0, cli_utilities_2.getBranchFromAlias)(targetStack, this.config.targetStackBranchAlias);
231
+ cli_utilities_2.log.debug('Target branch alias resolved', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.targetStackBranchAlias, branch: this.config.targetStackBranch }));
232
232
  }
233
233
  }
234
234
  catch (error) {
@@ -240,35 +240,35 @@ class CloneHandler {
240
240
  return new Promise(async (resolve, reject) => {
241
241
  let spinner;
242
242
  try {
243
- cli_utilities_1.log.debug('Handling branch selection', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, returnBranch, stackApiKey: isSource ? this.config.source_stack : this.config.target_stack }));
243
+ cli_utilities_2.log.debug('Handling branch selection', Object.assign(Object.assign({}, this.config.cloneContext), { isSource, returnBranch, stackApiKey: isSource ? this.config.source_stack : this.config.target_stack }));
244
244
  const stackAPIClient = this.client.stack({
245
245
  api_key: isSource ? this.config.source_stack : this.config.target_stack,
246
246
  management_token: this.config.management_token,
247
247
  });
248
248
  // NOTE validate if source branch is exist
249
249
  if (isSource && this.config.sourceStackBranch) {
250
- cli_utilities_1.log.debug('Validating source branch exists', Object.assign(Object.assign({}, this.config.cloneContext), { branch: this.config.sourceStackBranch }));
250
+ cli_utilities_2.log.debug('Validating source branch exists', Object.assign(Object.assign({}, this.config.cloneContext), { branch: this.config.sourceStackBranch }));
251
251
  await this.validateIfBranchExist(stackAPIClient, true);
252
252
  return resolve(undefined);
253
253
  }
254
254
  else if (isSource && this.config.sourceStackBranchAlias) {
255
- cli_utilities_1.log.debug('Resolving source branch alias', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.sourceStackBranchAlias }));
255
+ cli_utilities_2.log.debug('Resolving source branch alias', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.sourceStackBranchAlias }));
256
256
  await this.resolveBranchAliases(true);
257
257
  return resolve(undefined);
258
258
  }
259
259
  // NOTE Validate target branch is exist
260
260
  if (!isSource && this.config.targetStackBranch) {
261
- cli_utilities_1.log.debug('Validating target branch exists', Object.assign(Object.assign({}, this.config.cloneContext), { branch: this.config.targetStackBranch }));
261
+ cli_utilities_2.log.debug('Validating target branch exists', Object.assign(Object.assign({}, this.config.cloneContext), { branch: this.config.targetStackBranch }));
262
262
  await this.validateIfBranchExist(stackAPIClient, false);
263
263
  return resolve(undefined);
264
264
  }
265
265
  else if (!isSource && this.config.targetStackBranchAlias) {
266
- cli_utilities_1.log.debug('Resolving target branch alias', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.targetStackBranchAlias }));
266
+ cli_utilities_2.log.debug('Resolving target branch alias', Object.assign(Object.assign({}, this.config.cloneContext), { alias: this.config.targetStackBranchAlias }));
267
267
  await this.resolveBranchAliases();
268
268
  return resolve(undefined);
269
269
  }
270
270
  spinner = (0, ora_1.default)('Fetching Branches').start();
271
- cli_utilities_1.log.debug(`Querying branches for stack: ${isSource ? this.config.source_stack : this.config.target_stack}`, this.config.cloneContext);
271
+ cli_utilities_2.log.debug(`Querying branches for stack: ${isSource ? this.config.source_stack : this.config.target_stack}`, this.config.cloneContext);
272
272
  const result = await stackAPIClient
273
273
  .branch()
274
274
  .query()
@@ -276,7 +276,7 @@ class CloneHandler {
276
276
  .then(({ items }) => items)
277
277
  .catch((_err) => { });
278
278
  const condition = result && Array.isArray(result) && result.length > 0;
279
- cli_utilities_1.log.debug(`Found ${(result === null || result === void 0 ? void 0 : result.length) || 0} branch(es)`, this.config.cloneContext);
279
+ cli_utilities_2.log.debug(`Found ${(result === null || result === void 0 ? void 0 : result.length) || 0} branch(es)`, this.config.cloneContext);
280
280
  // NOTE if want to get only list of branches (Pass param -> returnBranch = true )
281
281
  if (returnBranch) {
282
282
  resolve(condition ? result : []);
@@ -295,11 +295,11 @@ class CloneHandler {
295
295
  }
296
296
  if (isSource) {
297
297
  this.config.sourceStackBranch = branch;
298
- cli_utilities_1.log.debug(`Source branch selected: ${branch}`, this.config.cloneContext);
298
+ cli_utilities_2.log.debug(`Source branch selected: ${branch}`, this.config.cloneContext);
299
299
  }
300
300
  else {
301
301
  this.config.targetStackBranch = branch;
302
- cli_utilities_1.log.debug(`Target branch selected: ${branch}`, this.config.cloneContext);
302
+ cli_utilities_2.log.debug(`Target branch selected: ${branch}`, this.config.cloneContext);
303
303
  }
304
304
  }
305
305
  else {
@@ -341,11 +341,11 @@ class CloneHandler {
341
341
  }
342
342
  async executeExport() {
343
343
  try {
344
- cli_utilities_1.log.debug('Executing export operation', this.config.cloneContext);
344
+ cli_utilities_2.log.debug('Executing export operation', this.config.cloneContext);
345
345
  const exportRes = await this.cloneCommand.execute((0, command_helpers_1.HandleExportCommand)(null, this));
346
346
  await this.cloneCommand.execute((0, command_helpers_1.SetBranchCommand)(null, this));
347
347
  if (exportRes) {
348
- cli_utilities_1.log.debug('Export operation completed, proceeding with destination', this.config.cloneContext);
348
+ cli_utilities_2.log.debug('Export operation completed, proceeding with destination', this.config.cloneContext);
349
349
  this.executeDestination().catch(() => {
350
350
  throw '';
351
351
  });
@@ -362,10 +362,10 @@ class CloneHandler {
362
362
  return new Promise(async (resolve, reject) => {
363
363
  let keyPressHandler;
364
364
  try {
365
- cli_utilities_1.log.debug('Starting clone execution', Object.assign(Object.assign({}, this.config.cloneContext), { sourceStack: this.config.source_stack, targetStack: this.config.target_stack }));
365
+ cli_utilities_2.log.debug('Starting clone execution', Object.assign(Object.assign({}, this.config.cloneContext), { sourceStack: this.config.source_stack, targetStack: this.config.target_stack }));
366
366
  if (!this.config.source_stack) {
367
367
  const orgMsg = 'Choose an organization where your source stack exists:';
368
- cli_utilities_1.log.debug('Source stack not provided, prompting for organization', this.config.cloneContext);
368
+ cli_utilities_2.log.debug('Source stack not provided, prompting for organization', this.config.cloneContext);
369
369
  this.setExectingCommand(0);
370
370
  this.removeBackKeyPressHandler();
371
371
  const org = await this.cloneCommand.execute((0, command_helpers_1.HandleOrgCommand)({ msg: orgMsg, isSource: true }, this));
@@ -397,20 +397,20 @@ class CloneHandler {
397
397
  }
398
398
  }
399
399
  else {
400
- cli_utilities_1.log.debug('Source stack provided, proceeding with branch selection and export', this.config.cloneContext);
400
+ cli_utilities_2.log.debug('Source stack provided, proceeding with branch selection and export', this.config.cloneContext);
401
401
  this.setExectingCommand(2);
402
402
  await this.handleBranchSelection({ api_key: this.config.source_stack });
403
- cli_utilities_1.log.debug('Starting export operation', this.config.cloneContext);
403
+ cli_utilities_2.log.debug('Starting export operation', this.config.cloneContext);
404
404
  const exportRes = await this.cloneCommand.execute((0, command_helpers_1.HandleExportCommand)(null, this));
405
405
  await this.cloneCommand.execute((0, command_helpers_1.SetBranchCommand)(null, this));
406
406
  if (exportRes) {
407
- cli_utilities_1.log.debug('Export completed, proceeding with destination setup', this.config.cloneContext);
407
+ cli_utilities_2.log.debug('Export completed, proceeding with destination setup', this.config.cloneContext);
408
408
  this.executeDestination().catch((error) => {
409
409
  return reject(error);
410
410
  });
411
411
  }
412
412
  }
413
- cli_utilities_1.log.debug('Clone execution completed successfully', this.config.cloneContext);
413
+ cli_utilities_2.log.debug('Clone execution completed successfully', this.config.cloneContext);
414
414
  return resolve();
415
415
  }
416
416
  catch (error) {
@@ -422,10 +422,10 @@ class CloneHandler {
422
422
  return new Promise(async (resolve, reject) => {
423
423
  let keyPressHandler;
424
424
  try {
425
- cli_utilities_1.log.debug('Executing destination setup', this.config.cloneContext);
425
+ cli_utilities_2.log.debug('Executing destination setup', this.config.cloneContext);
426
426
  let canCreateStack = false;
427
427
  if (!this.config.target_stack) {
428
- cli_utilities_1.log.debug('Target stack not provided, prompting for stack creation', this.config.cloneContext);
428
+ cli_utilities_2.log.debug('Target stack not provided, prompting for stack creation', this.config.cloneContext);
429
429
  canCreateStack = await inquirer_1.default.prompt(constants_1.STACK_CREATION_CONFIRMATION);
430
430
  }
431
431
  this.setExectingCommand(0);
@@ -468,7 +468,7 @@ class CloneHandler {
468
468
  else {
469
469
  await this.executeBranchDestinationPrompt(params);
470
470
  }
471
- cli_utilities_1.log.debug('Destination setup completed successfully', this.config.cloneContext);
471
+ cli_utilities_2.log.debug('Destination setup completed successfully', this.config.cloneContext);
472
472
  return resolve();
473
473
  }
474
474
  catch (error) {
@@ -510,7 +510,7 @@ class CloneHandler {
510
510
  async cmdExport() {
511
511
  return new Promise((resolve, reject) => {
512
512
  var _a;
513
- cli_utilities_1.log.debug('Preparing export command', Object.assign(Object.assign({}, this.config.cloneContext), { sourceStack: this.config.source_stack, cloneType: this.config.cloneType }));
513
+ cli_utilities_2.log.debug('Preparing export command', Object.assign(Object.assign({}, this.config.cloneContext), { sourceStack: this.config.source_stack, cloneType: this.config.cloneType }));
514
514
  // Creating export specific config by merging external configurations
515
515
  let exportConfig = Object.assign({}, (0, cloneDeep_1.default)(this.config), Object.assign({}, (_a = this.config) === null || _a === void 0 ? void 0 : _a.export));
516
516
  delete exportConfig.import;
@@ -521,35 +521,35 @@ class CloneHandler {
521
521
  // Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
522
522
  const packageRoot = path.resolve(__dirname, '../../..');
523
523
  const exportDir = path.join(packageRoot, 'contents');
524
- cli_utilities_1.log.debug(`Export directory: ${exportDir}`, this.config.cloneContext);
524
+ cli_utilities_2.log.debug(`Export directory: ${exportDir}`, this.config.cloneContext);
525
525
  const cmd = ['-k', exportConfig.apiKey || exportConfig.source_stack, '-d', exportDir];
526
526
  if (exportConfig.cloneType === 'a') {
527
527
  exportConfig.filteredModules = ['stack'].concat(constants_1.STRUCTURE_LIST);
528
- cli_utilities_1.log.debug(`Filtered modules for structure-only export: ${exportConfig.filteredModules.join(', ')}`, this.config.cloneContext);
528
+ cli_utilities_2.log.debug(`Filtered modules for structure-only export: ${exportConfig.filteredModules.join(', ')}`, this.config.cloneContext);
529
529
  }
530
530
  if (exportConfig.source_alias) {
531
531
  cmd.push('-a', exportConfig.source_alias);
532
- cli_utilities_1.log.debug(`Using source alias: ${exportConfig.source_alias}`, this.config.cloneContext);
532
+ cli_utilities_2.log.debug(`Using source alias: ${exportConfig.source_alias}`, this.config.cloneContext);
533
533
  }
534
534
  if (exportConfig.sourceStackBranch) {
535
535
  cmd.push('--branch', exportConfig.sourceStackBranch);
536
- cli_utilities_1.log.debug(`Using source branch: ${exportConfig.sourceStackBranch}`, this.config.cloneContext);
536
+ cli_utilities_2.log.debug(`Using source branch: ${exportConfig.sourceStackBranch}`, this.config.cloneContext);
537
537
  }
538
538
  if (exportConfig.forceStopMarketplaceAppsPrompt) {
539
539
  cmd.push('-y');
540
- cli_utilities_1.log.debug('Force stop marketplace apps prompt enabled', this.config.cloneContext);
540
+ cli_utilities_2.log.debug('Force stop marketplace apps prompt enabled', this.config.cloneContext);
541
541
  }
542
542
  // dummyConfig.json is in the same directory as this file
543
543
  const configFilePath = path.join(__dirname, 'dummyConfig.json');
544
544
  cmd.push('-c');
545
545
  cmd.push(configFilePath);
546
- cli_utilities_1.log.debug(`Writing export config to: ${configFilePath}`, this.config.cloneContext);
546
+ cli_utilities_2.log.debug(`Writing export config to: ${configFilePath}`, this.config.cloneContext);
547
547
  fs.writeFileSync(configFilePath, JSON.stringify(exportConfig));
548
- cli_utilities_1.log.debug('Export command prepared', Object.assign(Object.assign({}, this.config.cloneContext), { cmd: cmd.join(' '), exportDir, sourceStack: exportConfig.apiKey || exportConfig.source_stack, branch: exportConfig.sourceStackBranch }));
549
- cli_utilities_1.log.debug('Running export command', Object.assign(Object.assign({}, this.config.cloneContext), { cmd }));
548
+ cli_utilities_2.log.debug('Export command prepared', Object.assign(Object.assign({}, this.config.cloneContext), { cmd: cmd.join(' '), exportDir, sourceStack: exportConfig.apiKey || exportConfig.source_stack, branch: exportConfig.sourceStackBranch }));
549
+ cli_utilities_2.log.debug('Running export command', Object.assign(Object.assign({}, this.config.cloneContext), { cmd }));
550
550
  const exportData = cli_cm_export_1.default.run(cmd);
551
551
  exportData.then(() => {
552
- cli_utilities_1.log.debug('Export command completed successfully', this.config.cloneContext);
552
+ cli_utilities_2.log.debug('Export command completed successfully', this.config.cloneContext);
553
553
  resolve(true);
554
554
  }).catch((error) => {
555
555
  reject(error);
@@ -559,7 +559,7 @@ class CloneHandler {
559
559
  async cmdImport() {
560
560
  return new Promise(async (resolve, _reject) => {
561
561
  var _a;
562
- cli_utilities_1.log.debug('Preparing import command', Object.assign(Object.assign({}, this.config.cloneContext), { targetStack: this.config.target_stack, targetBranch: this.config.targetStackBranch }));
562
+ cli_utilities_2.log.debug('Preparing import command', Object.assign(Object.assign({}, this.config.cloneContext), { targetStack: this.config.target_stack, targetBranch: this.config.targetStackBranch }));
563
563
  // Creating export specific config by merging external configurations
564
564
  let importConfig = Object.assign({}, (0, cloneDeep_1.default)(this.config), Object.assign({}, (_a = this.config) === null || _a === void 0 ? void 0 : _a.import));
565
565
  delete importConfig.import;
@@ -569,11 +569,11 @@ class CloneHandler {
569
569
  const cmd = ['-c', configFilePath];
570
570
  if (importConfig.destination_alias) {
571
571
  cmd.push('-a', importConfig.destination_alias);
572
- cli_utilities_1.log.debug(`Using destination alias: ${importConfig.destination_alias}`, this.config.cloneContext);
572
+ cli_utilities_2.log.debug(`Using destination alias: ${importConfig.destination_alias}`, this.config.cloneContext);
573
573
  }
574
574
  if (importConfig.target_stack) {
575
575
  importConfig.apiKey = importConfig.target_stack;
576
- cli_utilities_1.log.debug(`Using target stack api key for import: ${importConfig.target_stack}`, this.config.cloneContext);
576
+ cli_utilities_2.log.debug(`Using target stack api key for import: ${importConfig.target_stack}`, this.config.cloneContext);
577
577
  }
578
578
  if (importConfig.data) {
579
579
  importConfig.contentDir = importConfig.data;
@@ -581,36 +581,36 @@ class CloneHandler {
581
581
  if (!importConfig.contentDir && importConfig.sourceStackBranch && importConfig.pathDir) {
582
582
  const dataPath = path.join(importConfig.pathDir, importConfig.sourceStackBranch);
583
583
  cmd.push('-d', dataPath);
584
- cli_utilities_1.log.debug(`Import data path: ${dataPath}`, this.config.cloneContext);
584
+ cli_utilities_2.log.debug(`Import data path: ${dataPath}`, this.config.cloneContext);
585
585
  }
586
586
  if (importConfig.targetStackBranch) {
587
587
  cmd.push('--branch', importConfig.targetStackBranch);
588
- cli_utilities_1.log.debug(`Using target branch: ${importConfig.targetStackBranch}`, this.config.cloneContext);
588
+ cli_utilities_2.log.debug(`Using target branch: ${importConfig.targetStackBranch}`, this.config.cloneContext);
589
589
  }
590
590
  if (importConfig.importWebhookStatus) {
591
591
  cmd.push('--import-webhook-status', importConfig.importWebhookStatus);
592
- cli_utilities_1.log.debug(`Import webhook status: ${importConfig.importWebhookStatus}`, this.config.cloneContext);
592
+ cli_utilities_2.log.debug(`Import webhook status: ${importConfig.importWebhookStatus}`, this.config.cloneContext);
593
593
  }
594
594
  if (importConfig.skipAudit) {
595
595
  cmd.push('--skip-audit');
596
- cli_utilities_1.log.debug('Skip audit flag enabled', this.config.cloneContext);
596
+ cli_utilities_2.log.debug('Skip audit flag enabled', this.config.cloneContext);
597
597
  }
598
598
  if (importConfig.forceStopMarketplaceAppsPrompt) {
599
599
  cmd.push('-y');
600
- cli_utilities_1.log.debug('Force stop marketplace apps prompt enabled', this.config.cloneContext);
600
+ cli_utilities_2.log.debug('Force stop marketplace apps prompt enabled', this.config.cloneContext);
601
601
  }
602
- cli_utilities_1.log.debug(`Writing import config to: ${configFilePath}`, this.config.cloneContext);
602
+ cli_utilities_2.log.debug(`Writing import config to: ${configFilePath}`, this.config.cloneContext);
603
603
  fs.writeFileSync(configFilePath, JSON.stringify(importConfig));
604
- cli_utilities_1.log.debug('Import command prepared', Object.assign(Object.assign({}, this.config.cloneContext), { cmd: cmd.join(' '), targetStack: importConfig.apiKey || importConfig.target_stack, targetBranch: importConfig.targetStackBranch, dataPath: importConfig.contentDir || (importConfig.pathDir && importConfig.sourceStackBranch ? path.join(importConfig.pathDir, importConfig.sourceStackBranch) : undefined) }));
605
- cli_utilities_1.log.debug('Running import command', Object.assign(Object.assign({}, this.config.cloneContext), { cmd }));
604
+ cli_utilities_2.log.debug('Import command prepared', Object.assign(Object.assign({}, this.config.cloneContext), { cmd: cmd.join(' '), targetStack: importConfig.apiKey || importConfig.target_stack, targetBranch: importConfig.targetStackBranch, dataPath: importConfig.contentDir || (importConfig.pathDir && importConfig.sourceStackBranch ? path.join(importConfig.pathDir, importConfig.sourceStackBranch) : undefined) }));
605
+ cli_utilities_2.log.debug('Running import command', Object.assign(Object.assign({}, this.config.cloneContext), { cmd }));
606
606
  const importData = cli_cm_import_1.default.run(cmd);
607
607
  importData.then(() => {
608
- cli_utilities_1.log.debug('Import command completed successfully', this.config.cloneContext);
609
- cli_utilities_1.log.debug('Clearing import config file', this.config.cloneContext);
608
+ cli_utilities_2.log.debug('Import command completed successfully', this.config.cloneContext);
609
+ cli_utilities_2.log.debug('Clearing import config file', this.config.cloneContext);
610
610
  fs.writeFileSync(configFilePath, JSON.stringify({}));
611
611
  resolve();
612
612
  }).catch((error) => {
613
- cli_utilities_1.log.error('Import command failed', Object.assign(Object.assign({}, this.config.cloneContext), { error }));
613
+ cli_utilities_2.log.error('Import command failed', Object.assign(Object.assign({}, this.config.cloneContext), { error }));
614
614
  throw error;
615
615
  });
616
616
  });
@@ -659,11 +659,11 @@ class CloneHandler {
659
659
  return new Promise(async (resolve, reject) => {
660
660
  try {
661
661
  const { orgUid } = options;
662
- cli_utilities_1.log.debug('Creating new stack', Object.assign(Object.assign({}, this.config.cloneContext), { orgUid, masterLocale: this.master_locale, stackName: this.config.stackName }));
662
+ cli_utilities_2.log.debug('Creating new stack', Object.assign(Object.assign({}, this.config.cloneContext), { orgUid, masterLocale: this.master_locale, stackName: this.config.stackName }));
663
663
  this.displayBackOptionMessage();
664
664
  let inputvalue;
665
665
  if (!this.config.stackName) {
666
- cli_utilities_1.log.debug('Stack name not provided, prompting user', this.config.cloneContext);
666
+ cli_utilities_2.log.debug('Stack name not provided, prompting user', this.config.cloneContext);
667
667
  prompt.start();
668
668
  prompt.message = '';
669
669
  this.setCreateNewStackPrompt(prompt);
@@ -674,21 +674,21 @@ class CloneHandler {
674
674
  inputvalue = { stack: this.config.stackName };
675
675
  }
676
676
  if (this.executingCommand === 0 || !inputvalue) {
677
- cli_utilities_1.log.debug('Stack creation cancelled or invalid input', this.config.cloneContext);
677
+ cli_utilities_2.log.debug('Stack creation cancelled or invalid input', this.config.cloneContext);
678
678
  return reject();
679
679
  }
680
680
  let stack = { name: inputvalue.stack, master_locale: this.master_locale };
681
- cli_utilities_1.log.debug('Creating stack with configuration', this.config.cloneContext);
681
+ cli_utilities_2.log.debug('Creating stack with configuration', this.config.cloneContext);
682
682
  const spinner = (0, ora_1.default)('Creating New stack').start();
683
- cli_utilities_1.log.debug('Sending stack creation API request', this.config.cloneContext);
683
+ cli_utilities_2.log.debug('Sending stack creation API request', this.config.cloneContext);
684
684
  const newStack = this.client.stack().create({ stack }, { organization_uid: orgUid });
685
685
  newStack
686
686
  .then((result) => {
687
- cli_utilities_1.log.debug('Stack created successfully', Object.assign(Object.assign({}, this.config.cloneContext), { stackName: result.name }));
687
+ cli_utilities_2.log.debug('Stack created successfully', Object.assign(Object.assign({}, this.config.cloneContext), { stackName: result.name }));
688
688
  spinner.succeed('New Stack created Successfully name as ' + result.name);
689
689
  this.config.target_stack = result.api_key;
690
690
  this.config.destinationStackName = result.name;
691
- cli_utilities_1.log.debug('Target stack configuration updated', this.config.cloneContext);
691
+ cli_utilities_2.log.debug('Target stack configuration updated', this.config.cloneContext);
692
692
  return resolve(result);
693
693
  })
694
694
  .catch((error) => {
@@ -705,7 +705,7 @@ class CloneHandler {
705
705
  console.clear();
706
706
  return new Promise(async (resolve, reject) => {
707
707
  try {
708
- cli_utilities_1.log.debug('Starting clone type selection', this.config.cloneContext);
708
+ cli_utilities_2.log.debug('Starting clone type selection', this.config.cloneContext);
709
709
  const choices = [
710
710
  'Structure (all modules except entries & assets)',
711
711
  'Structure with content (all modules including entries & assets)',
@@ -723,41 +723,41 @@ class CloneHandler {
723
723
  // Resolve path to package root - go up 3 levels from __dirname (core/util -> package root)
724
724
  const cloneTypePackageRoot = path.resolve(__dirname, '../../..');
725
725
  this.config.contentDir = path.join(cloneTypePackageRoot, 'contents', this.config.sourceStackBranch || '');
726
- cli_utilities_1.log.debug(`Clone content directory: ${this.config.contentDir}`, this.config.cloneContext);
726
+ cli_utilities_2.log.debug(`Clone content directory: ${this.config.contentDir}`, this.config.cloneContext);
727
727
  if (!this.config.cloneType) {
728
- cli_utilities_1.log.debug('Clone type not specified, prompting user for selection', this.config.cloneContext);
728
+ cli_utilities_2.log.debug('Clone type not specified, prompting user for selection', this.config.cloneContext);
729
729
  selectedValue = await inquirer_1.default.prompt(cloneTypeSelection);
730
730
  }
731
731
  else {
732
- cli_utilities_1.log.debug(`Using pre-configured clone type: ${this.config.cloneType}`, this.config.cloneContext);
732
+ cli_utilities_2.log.debug(`Using pre-configured clone type: ${this.config.cloneType}`, this.config.cloneContext);
733
733
  }
734
734
  if (this.config.cloneType === 'a' || selectedValue.type === 'Structure (all modules except entries & assets)') {
735
735
  this.config.modules = constants_1.STRUCTURE_LIST;
736
736
  successMsg = 'Stack clone Structure completed';
737
- cli_utilities_1.log.debug(`Clone type: Structure only. Modules to clone: ${constants_1.STRUCTURE_LIST.join(', ')}`, this.config.cloneContext);
737
+ cli_utilities_2.log.debug(`Clone type: Structure only. Modules to clone: ${constants_1.STRUCTURE_LIST.join(', ')}`, this.config.cloneContext);
738
738
  }
739
739
  else {
740
740
  successMsg = 'Stack clone completed with structure and content';
741
- cli_utilities_1.log.debug('Clone type: Structure with content (all modules)', this.config.cloneContext);
741
+ cli_utilities_2.log.debug('Clone type: Structure with content (all modules)', this.config.cloneContext);
742
742
  }
743
743
  this.cmdImport()
744
744
  .then(async () => {
745
- cli_utilities_1.log.debug('Clone type selection and import completed successfully', this.config.cloneContext);
745
+ cli_utilities_2.log.debug('Clone type selection and import completed successfully', this.config.cloneContext);
746
746
  // Clean up contents directory after import completes
747
747
  if (this.config.pathDir) {
748
748
  const resolvedPath = path.resolve(this.config.pathDir);
749
- cli_utilities_1.log.debug('Cleaning up contents directory after import', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath }));
749
+ cli_utilities_2.log.debug('Cleaning up contents directory after import', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath }));
750
750
  try {
751
751
  await (0, rimraf_1.rimraf)(resolvedPath);
752
- cli_utilities_1.log.debug('Contents directory cleaned up successfully', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath }));
752
+ cli_utilities_2.log.debug('Contents directory cleaned up successfully', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath }));
753
753
  }
754
754
  catch (cleanupError) {
755
- cli_utilities_1.log.debug('Cleanup error (non-fatal)', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath, error: cleanupError === null || cleanupError === void 0 ? void 0 : cleanupError.message, code: cleanupError === null || cleanupError === void 0 ? void 0 : cleanupError.code }));
755
+ cli_utilities_2.log.debug('Cleanup error (non-fatal)', Object.assign(Object.assign({}, this.config.cloneContext), { pathDir: this.config.pathDir, resolvedPath, error: cleanupError === null || cleanupError === void 0 ? void 0 : cleanupError.message, code: cleanupError === null || cleanupError === void 0 ? void 0 : cleanupError.code }));
756
756
  // Don't fail the clone if cleanup fails
757
757
  }
758
758
  }
759
759
  else {
760
- cli_utilities_1.log.debug('No pathDir configured, skipping cleanup', this.config.cloneContext);
760
+ cli_utilities_2.log.debug('No pathDir configured, skipping cleanup', this.config.cloneContext);
761
761
  }
762
762
  resolve(successMsg);
763
763
  })
@@ -165,5 +165,5 @@
165
165
  ]
166
166
  }
167
167
  },
168
- "version": "2.0.0-beta.13"
168
+ "version": "2.0.0-beta.14"
169
169
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-clone",
3
3
  "description": "Contentstack stack clone plugin",
4
- "version": "2.0.0-beta.13",
4
+ "version": "2.0.0-beta.14",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
7
7
  "dependencies": {
8
8
  "@colors/colors": "^1.6.0",
9
- "@contentstack/cli-cm-export": "~2.0.0-beta.12",
10
- "@contentstack/cli-cm-import": "~2.0.0-beta.12",
11
- "@contentstack/cli-command": "~2.0.0-beta.3",
12
- "@contentstack/cli-utilities": "~2.0.0-beta.3",
9
+ "@contentstack/cli-cm-export": "~2.0.0-beta.13",
10
+ "@contentstack/cli-cm-import": "~2.0.0-beta.13",
11
+ "@contentstack/cli-command": "~2.0.0-beta.4",
12
+ "@contentstack/cli-utilities": "~2.0.0-beta.4",
13
13
  "@oclif/core": "^4.3.0",
14
14
  "@oclif/plugin-help": "^6.2.28",
15
- "chalk": "^4.1.2",
15
+ "chalk": "^5.6.2",
16
16
  "inquirer": "12.11.1",
17
17
  "lodash": "^4.17.23",
18
18
  "merge": "^2.1.1",