@contentstack/cli-utilities 2.0.0-beta → 2.0.0-beta.10

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.
Files changed (39) hide show
  1. package/lib/auth-handler.d.ts +5 -2
  2. package/lib/auth-handler.js +29 -29
  3. package/lib/chalk.d.ts +15 -0
  4. package/lib/chalk.js +66 -0
  5. package/lib/cli-ux.js +23 -10
  6. package/lib/config-handler.js +4 -4
  7. package/lib/constants/logging.d.ts +1 -1
  8. package/lib/constants/logging.js +3 -3
  9. package/lib/content-type-utils.d.ts +7 -0
  10. package/lib/content-type-utils.js +44 -0
  11. package/lib/contentstack-management-sdk.js +14 -4
  12. package/lib/contentstack-marketplace-sdk.d.ts +2 -2
  13. package/lib/contentstack-marketplace-sdk.js +1 -1
  14. package/lib/fs-utility/core.d.ts +0 -1
  15. package/lib/fs-utility/core.js +2 -6
  16. package/lib/fs-utility/helper.js +2 -3
  17. package/lib/helpers.d.ts +3 -1
  18. package/lib/helpers.js +14 -4
  19. package/lib/http-client/client.d.ts +2 -2
  20. package/lib/http-client/client.js +22 -2
  21. package/lib/http-client/http-response.d.ts +1 -1
  22. package/lib/http-client/http-response.js +1 -0
  23. package/lib/index.d.ts +4 -1
  24. package/lib/index.js +5 -1
  25. package/lib/inquirer-table-prompt.d.ts +49 -28
  26. package/lib/inquirer-table-prompt.js +144 -136
  27. package/lib/interfaces/index.d.ts +3 -1
  28. package/lib/logger/cli-error-handler.js +1 -1
  29. package/lib/logger/log.js +4 -4
  30. package/lib/logger/session-path.d.ts +5 -0
  31. package/lib/logger/session-path.js +18 -3
  32. package/lib/message-handler.d.ts +0 -3
  33. package/lib/message-handler.js +6 -10
  34. package/lib/progress-summary/cli-progress-manager.d.ts +3 -1
  35. package/lib/progress-summary/cli-progress-manager.js +46 -36
  36. package/lib/progress-summary/summary-manager.js +30 -30
  37. package/lib/proxy-helper.d.ts +42 -1
  38. package/lib/proxy-helper.js +183 -32
  39. package/package.json +28 -27
package/lib/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { default as managementSDKClient, managementSDKInitiator, ContentstackCli
10
10
  export * from './management-types';
11
11
  export * from './http-client';
12
12
  export * from './fs-utility';
13
+ export * from './content-type-utils';
13
14
  export { default as NodeCrypto } from './encrypter';
14
15
  export { Args as args, Flags as flags, Command } from './cli-ux';
15
16
  export * from './helpers';
@@ -21,8 +22,10 @@ export * from './path-validator';
21
22
  export { default as CLITable, TableFlags, TableHeader, TableOptions, TableData } from './cli-table';
22
23
  export { App, AppData, Installation, marketplaceSDKClient, MarketplaceSDKInitiator, marketplaceSDKInitiator, ContentstackMarketplaceClient, ContentstackMarketplaceConfig, };
23
24
  export { Args, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toStandardizedId, toConfiguredId, settings, Settings, flush, ux, execute, } from '@oclif/core';
24
- export { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/parser';
25
+ export type { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/parser';
25
26
  export { default as TablePrompt } from './inquirer-table-prompt';
27
+ export { loadChalk, getChalk } from './chalk';
28
+ export type { ChalkInstance } from './chalk';
26
29
  export { Logger };
27
30
  export { default as authenticationHandler } from './authentication-handler';
28
31
  export { v2Logger as log, cliErrorHandler, handleAndLogError, getLogPath, getSessionLogPath } from './logger/log';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultProgressStrategy = exports.CustomProgressStrategy = exports.ProgressStrategyRegistry = exports.PrimaryProcessStrategy = exports.SummaryManager = exports.CLIProgressManager = exports.getSessionLogPath = exports.getLogPath = exports.handleAndLogError = exports.cliErrorHandler = exports.log = exports.authenticationHandler = exports.Logger = exports.TablePrompt = exports.execute = exports.ux = exports.flush = exports.settings = exports.toConfiguredId = exports.toStandardizedId = exports.run = exports.Plugin = exports.Parser = exports.Interfaces = exports.HelpBase = exports.Help = exports.loadHelpClass = exports.Flags = exports.Errors = exports.Config = exports.CommandHelp = exports.Args = exports.marketplaceSDKInitiator = exports.MarketplaceSDKInitiator = exports.marketplaceSDKClient = exports.CLITable = exports.createLogContext = exports.Command = exports.flags = exports.args = exports.NodeCrypto = exports.managementSDKInitiator = exports.managementSDKClient = exports.configHandler = exports.authHandler = exports.messageHandler = exports.CLIError = exports.cliux = exports.LoggerService = void 0;
3
+ exports.DefaultProgressStrategy = exports.CustomProgressStrategy = exports.ProgressStrategyRegistry = exports.PrimaryProcessStrategy = exports.SummaryManager = exports.CLIProgressManager = exports.getSessionLogPath = exports.getLogPath = exports.handleAndLogError = exports.cliErrorHandler = exports.log = exports.authenticationHandler = exports.Logger = exports.getChalk = exports.loadChalk = exports.TablePrompt = exports.execute = exports.ux = exports.flush = exports.settings = exports.toConfiguredId = exports.toStandardizedId = exports.Plugin = exports.Parser = exports.Interfaces = exports.HelpBase = exports.Help = exports.loadHelpClass = exports.Flags = exports.Errors = exports.Config = exports.CommandHelp = exports.Args = exports.marketplaceSDKInitiator = exports.MarketplaceSDKInitiator = exports.marketplaceSDKClient = exports.CLITable = exports.createLogContext = exports.Command = exports.flags = exports.args = exports.NodeCrypto = exports.managementSDKInitiator = exports.managementSDKClient = exports.configHandler = exports.authHandler = exports.messageHandler = exports.CLIError = exports.cliux = exports.LoggerService = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const logger_1 = tslib_1.__importDefault(require("./logger"));
6
6
  exports.Logger = logger_1.default;
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "managementSDKInitiator", { enumerable: true, get
26
26
  tslib_1.__exportStar(require("./management-types"), exports);
27
27
  tslib_1.__exportStar(require("./http-client"), exports);
28
28
  tslib_1.__exportStar(require("./fs-utility"), exports);
29
+ tslib_1.__exportStar(require("./content-type-utils"), exports);
29
30
  var encrypter_1 = require("./encrypter");
30
31
  Object.defineProperty(exports, "NodeCrypto", { enumerable: true, get: function () { return tslib_1.__importDefault(encrypter_1).default; } });
31
32
  var cli_ux_2 = require("./cli-ux");
@@ -63,6 +64,9 @@ Object.defineProperty(exports, "ux", { enumerable: true, get: function () { retu
63
64
  Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return core_1.execute; } });
64
65
  var inquirer_table_prompt_1 = require("./inquirer-table-prompt");
65
66
  Object.defineProperty(exports, "TablePrompt", { enumerable: true, get: function () { return tslib_1.__importDefault(inquirer_table_prompt_1).default; } });
67
+ var chalk_1 = require("./chalk");
68
+ Object.defineProperty(exports, "loadChalk", { enumerable: true, get: function () { return chalk_1.loadChalk; } });
69
+ Object.defineProperty(exports, "getChalk", { enumerable: true, get: function () { return chalk_1.getChalk; } });
66
70
  var authentication_handler_1 = require("./authentication-handler");
67
71
  Object.defineProperty(exports, "authenticationHandler", { enumerable: true, get: function () { return tslib_1.__importDefault(authentication_handler_1).default; } });
68
72
  var log_1 = require("./logger/log");
@@ -1,30 +1,51 @@
1
- declare const Base: any;
2
- declare class TablePrompt extends Base {
3
- /**
4
- * Initialise the prompt
5
- *
6
- * @param {Object} questions
7
- * @param {Object} rl
8
- * @param {Object} answers
9
- */
10
- constructor(questions: any, rl: any, answers: any);
11
- /**
12
- * Start the inquirer session
13
- *
14
- * @param {Function} callback
15
- * @return {TablePrompt}
16
- */
17
- _run(callback: any): this;
18
- getCurrentValue(): any[];
19
- onDownKey(): void;
20
- onEnd(state: any): void;
21
- onError(state: any): void;
22
- onLeftKey(): void;
23
- onRightKey(): void;
24
- selectAllValues(value: any): void;
25
- onSpaceKey(): void;
26
- onUpKey(): void;
27
- paginate(): number[];
28
- render(error?: string): void;
1
+ /**
2
+ * Table prompt for inquirer v12.
3
+ * Standalone implementation (no inquirer/lib) compatible with
4
+ * inquirer 12 legacy adapter: constructor(question, rl, answers) + run() returns Promise.
5
+ */
6
+ import * as readline from 'readline';
7
+ interface ChoiceLike {
8
+ name?: string;
9
+ value?: string;
10
+ }
11
+ interface TableQuestion {
12
+ message?: string;
13
+ name?: string;
14
+ columns?: ChoiceLike[];
15
+ rows?: ChoiceLike[];
16
+ selectAll?: boolean;
17
+ pageSize?: number;
18
+ }
19
+ type ReadLine = readline.Interface & {
20
+ input: NodeJS.ReadableStream;
21
+ output: NodeJS.WritableStream;
22
+ };
23
+ declare class TablePrompt {
24
+ private question;
25
+ private rl;
26
+ private selectAll;
27
+ private columns;
28
+ private rows;
29
+ private pointer;
30
+ private horizontalPointer;
31
+ private values;
32
+ private pageSize;
33
+ private spaceKeyPressed;
34
+ private status;
35
+ private done;
36
+ private lastHeight;
37
+ constructor(question: TableQuestion, rl: ReadLine, _answers: Record<string, unknown>);
38
+ run(): Promise<(string | undefined)[]>;
39
+ private getCurrentValue;
40
+ private onSubmit;
41
+ private onUpKey;
42
+ private onDownKey;
43
+ private onLeftKey;
44
+ private onRightKey;
45
+ private selectAllValues;
46
+ private onSpaceKey;
47
+ private paginate;
48
+ private getMessage;
49
+ private render;
29
50
  }
30
51
  export = TablePrompt;
@@ -1,120 +1,125 @@
1
1
  "use strict";
2
- const chalk = require('chalk');
3
- const figures = require('figures');
4
- const Table = require('cli-table');
5
- const cliCursor = require('cli-cursor');
6
- const Base = require('inquirer/lib/prompts/base');
7
- const observe = require('inquirer/lib/utils/events');
8
- const { map, takeUntil } = require('rxjs/operators');
9
- const Choices = require('inquirer/lib/objects/choices');
10
- class TablePrompt extends Base {
11
- /**
12
- * Initialise the prompt
13
- *
14
- * @param {Object} questions
15
- * @param {Object} rl
16
- * @param {Object} answers
17
- */
18
- constructor(questions, rl, answers) {
19
- super(questions, rl, answers);
20
- this.selectAll = this.opt.selectAll || false;
21
- const formattedRows = this.selectAll
22
- ? [
23
- {
24
- name: 'Select All',
25
- value: 'selectAll',
26
- },
27
- ...(this.opt.rows || []),
28
- ]
29
- : [];
30
- this.columns = new Choices(this.opt.columns, []);
2
+ /**
3
+ * Table prompt for inquirer v12.
4
+ * Standalone implementation (no inquirer/lib) compatible with
5
+ * inquirer 12 legacy adapter: constructor(question, rl, answers) + run() returns Promise.
6
+ */
7
+ const tslib_1 = require("tslib");
8
+ const chalk_1 = require("./chalk");
9
+ const figures_1 = tslib_1.__importDefault(require("figures"));
10
+ const cli_cursor_1 = tslib_1.__importDefault(require("cli-cursor"));
11
+ const cli_table_1 = tslib_1.__importDefault(require("cli-table"));
12
+ function pluckName(c) {
13
+ var _a, _b;
14
+ return (_a = c.name) !== null && _a !== void 0 ? _a : String((_b = c.value) !== null && _b !== void 0 ? _b : '');
15
+ }
16
+ function getValue(c) {
17
+ var _a, _b;
18
+ return (_b = (_a = c.value) !== null && _a !== void 0 ? _a : c.name) !== null && _b !== void 0 ? _b : '';
19
+ }
20
+ class TablePrompt {
21
+ constructor(question, rl, _answers) {
22
+ this.question = question;
23
+ this.rl = rl;
24
+ this.selectAll = Boolean(question.selectAll);
25
+ this.columns = Array.isArray(question.columns) ? question.columns : [];
26
+ this.rows = this.selectAll
27
+ ? [{ name: 'Select All', value: 'selectAll' }, ...(question.rows || [])]
28
+ : Array.isArray(question.rows) ? question.rows : [];
31
29
  this.pointer = 0;
32
30
  this.horizontalPointer = 0;
33
- this.rows = new Choices(formattedRows, []);
34
- this.values = this.columns.filter(() => true).map(() => undefined);
35
- this.pageSize = this.opt.pageSize || 5;
31
+ this.values = this.columns.map(() => undefined);
32
+ this.pageSize = Number(question.pageSize) || 5;
33
+ this.spaceKeyPressed = false;
34
+ this.status = 'idle';
35
+ this.done = null;
36
+ this.lastHeight = 0;
36
37
  }
37
- /**
38
- * Start the inquirer session
39
- *
40
- * @param {Function} callback
41
- * @return {TablePrompt}
42
- */
43
- _run(callback) {
44
- this.done = callback;
45
- const events = observe(this.rl);
46
- const validation = this.handleSubmitEvents(events.line.pipe(map(this.getCurrentValue.bind(this))));
47
- validation.success.forEach(this.onEnd.bind(this));
48
- validation.error.forEach(this.onError.bind(this));
49
- events.keypress.forEach(({ key }) => {
50
- switch (key.name) {
51
- case 'left':
52
- return this.onLeftKey();
53
- case 'right':
54
- return this.onRightKey();
55
- }
38
+ run() {
39
+ return new Promise((resolve) => {
40
+ this.done = (value) => {
41
+ this.status = 'answered';
42
+ cli_cursor_1.default.show();
43
+ resolve(value);
44
+ };
45
+ const onKeypress = (_str, key) => {
46
+ if (this.status === 'answered')
47
+ return;
48
+ if (key.ctrl && key.name === 'c')
49
+ return;
50
+ switch (key.name) {
51
+ case 'up':
52
+ this.onUpKey();
53
+ break;
54
+ case 'down':
55
+ this.onDownKey();
56
+ break;
57
+ case 'left':
58
+ this.onLeftKey();
59
+ break;
60
+ case 'right':
61
+ this.onRightKey();
62
+ break;
63
+ case 'space':
64
+ this.onSpaceKey();
65
+ break;
66
+ case 'enter':
67
+ case 'return':
68
+ this.onSubmit();
69
+ break;
70
+ default:
71
+ return;
72
+ }
73
+ this.render();
74
+ };
75
+ this.rl.input.on('keypress', onKeypress);
76
+ cli_cursor_1.default.hide();
77
+ this.render();
56
78
  });
57
- events.normalizedUpKey.pipe(takeUntil(validation.success)).forEach(this.onUpKey.bind(this));
58
- events.normalizedDownKey.pipe(takeUntil(validation.success)).forEach(this.onDownKey.bind(this));
59
- events.spaceKey.pipe(takeUntil(validation.success)).forEach(this.onSpaceKey.bind(this));
60
- if (this.rl.line) {
61
- this.onKeypress();
62
- }
63
- cliCursor.hide();
64
- this.render();
65
- return this;
66
79
  }
67
80
  getCurrentValue() {
68
- const currentValue = [];
69
- this.rows.forEach((row, rowIndex) => {
70
- currentValue.push(this.values[rowIndex]);
71
- });
72
- return currentValue;
73
- }
74
- onDownKey() {
75
- const length = this.rows.realLength;
76
- this.pointer = this.pointer < length - 1 ? this.pointer + 1 : this.pointer;
77
- this.render();
81
+ const out = [];
82
+ for (let i = 0; i < this.rows.length; i++) {
83
+ out.push(this.values[i]);
84
+ }
85
+ return out;
78
86
  }
79
- onEnd(state) {
80
- this.status = 'answered';
81
- this.spaceKeyPressed = true;
82
- this.render();
83
- this.screen.done();
84
- cliCursor.show();
85
- if (this.selectAll) {
86
- // remove select all row
87
- const [, ...truncatedValue] = state.value;
88
- this.done(truncatedValue);
87
+ onSubmit() {
88
+ if (!this.done)
89
+ return;
90
+ const raw = this.getCurrentValue();
91
+ if (this.selectAll && raw.length > 0) {
92
+ this.done(raw.slice(1));
89
93
  }
90
94
  else {
91
- this.done(state.value);
95
+ this.done(raw);
92
96
  }
93
97
  }
94
- onError(state) {
95
- this.render(state.isValid);
98
+ onUpKey() {
99
+ this.pointer = this.pointer > 0 ? this.pointer - 1 : this.pointer;
100
+ }
101
+ onDownKey() {
102
+ const len = this.rows.length;
103
+ this.pointer = this.pointer < len - 1 ? this.pointer + 1 : this.pointer;
96
104
  }
97
105
  onLeftKey() {
98
- const length = this.columns.realLength;
99
- this.horizontalPointer = this.horizontalPointer > 0 ? this.horizontalPointer - 1 : length - 1;
100
- this.render();
106
+ const len = this.columns.length;
107
+ this.horizontalPointer = this.horizontalPointer > 0 ? this.horizontalPointer - 1 : len - 1;
101
108
  }
102
109
  onRightKey() {
103
- const length = this.columns.realLength;
104
- this.horizontalPointer = this.horizontalPointer < length - 1 ? this.horizontalPointer + 1 : 0;
105
- this.render();
110
+ const len = this.columns.length;
111
+ this.horizontalPointer = this.horizontalPointer < len - 1 ? this.horizontalPointer + 1 : 0;
106
112
  }
107
113
  selectAllValues(value) {
108
- let values = [];
109
- for (let i = 0; i < this.rows.length; i++) {
110
- values.push(value);
111
- }
112
- this.values = values;
114
+ this.values = this.rows.map(() => value);
113
115
  }
114
116
  onSpaceKey() {
115
- var _a;
116
- const value = this.columns.get(this.horizontalPointer).value;
117
- const rowValue = ((_a = this.rows.get(this.pointer)) === null || _a === void 0 ? void 0 : _a.value) || '';
117
+ const col = this.columns[this.horizontalPointer];
118
+ const row = this.rows[this.pointer];
119
+ if (!col)
120
+ return;
121
+ const value = getValue(col);
122
+ const rowValue = row ? getValue(row) : '';
118
123
  if (rowValue === 'selectAll') {
119
124
  this.selectAllValues(value);
120
125
  }
@@ -122,55 +127,58 @@ class TablePrompt extends Base {
122
127
  this.values[this.pointer] = value;
123
128
  }
124
129
  this.spaceKeyPressed = true;
125
- this.render();
126
- }
127
- onUpKey() {
128
- this.pointer = this.pointer > 0 ? this.pointer - 1 : this.pointer;
129
- this.render();
130
130
  }
131
131
  paginate() {
132
- const middleOfPage = Math.floor(this.pageSize / 2);
133
- const firstIndex = Math.max(0, this.pointer - middleOfPage);
134
- const lastIndex = Math.min(firstIndex + this.pageSize - 1, this.rows.realLength - 1);
135
- const lastPageOffset = this.pageSize - 1 - lastIndex + firstIndex;
136
- return [Math.max(0, firstIndex - lastPageOffset), lastIndex];
132
+ const mid = Math.floor(this.pageSize / 2);
133
+ const len = this.rows.length;
134
+ let first = Math.max(0, this.pointer - mid);
135
+ let last = Math.min(first + this.pageSize - 1, len - 1);
136
+ const offset = this.pageSize - 1 - (last - first);
137
+ first = Math.max(0, first - offset);
138
+ return [first, last];
137
139
  }
138
- render(error) {
139
- let message = this.getQuestion();
140
- let bottomContent = '';
140
+ getMessage() {
141
+ let msg = this.question.message || 'Select';
141
142
  if (!this.spaceKeyPressed) {
142
- message +=
143
- '(Press ' +
144
- chalk.cyan.bold('<space>') +
143
+ msg +=
144
+ ' (Press ' +
145
+ (0, chalk_1.getChalk)().cyan.bold('<space>') +
145
146
  ' to select, ' +
146
- chalk.cyan.bold('<Up and Down>') +
147
- ' to move rows, ' +
148
- chalk.cyan.bold('<Left and Right>') +
149
- ' to move columns)';
147
+ (0, chalk_1.getChalk)().cyan.bold('<Up/Down>') +
148
+ ' rows, ' +
149
+ (0, chalk_1.getChalk)().cyan.bold('<Left/Right>') +
150
+ ' columns, ' +
151
+ (0, chalk_1.getChalk)().cyan.bold('<Enter>') +
152
+ ' to confirm)';
150
153
  }
154
+ return msg;
155
+ }
156
+ render() {
151
157
  const [firstIndex, lastIndex] = this.paginate();
152
- const table = new Table({
153
- head: [chalk.reset.dim(`${firstIndex + 1}-${lastIndex} of ${this.rows.realLength - 1}`)].concat(this.columns.pluck('name').map((name) => chalk.reset.bold(name))),
158
+ const table = new cli_table_1.default({
159
+ head: [(0, chalk_1.getChalk)().reset.dim(`${firstIndex + 1}-${lastIndex + 1} of ${this.rows.length}`)].concat(this.columns.map((c) => (0, chalk_1.getChalk)().reset.bold(pluckName(c)))),
154
160
  });
155
- this.rows.forEach((row, rowIndex) => {
156
- if (rowIndex < firstIndex || rowIndex > lastIndex)
157
- return;
161
+ for (let rowIndex = firstIndex; rowIndex <= lastIndex; rowIndex++) {
162
+ const row = this.rows[rowIndex];
163
+ if (!row)
164
+ continue;
158
165
  const columnValues = [];
159
- this.columns.forEach((column, columnIndex) => {
160
- const isSelected = this.status !== 'answered' && this.pointer === rowIndex && this.horizontalPointer === columnIndex;
161
- const value = column.value === this.values[rowIndex] ? figures.radioOn : figures.radioOff;
162
- columnValues.push(`${isSelected ? '[' : ' '} ${value} ${isSelected ? ']' : ' '}`);
163
- });
164
- const chalkModifier = this.status !== 'answered' && this.pointer === rowIndex ? chalk.reset.bold.cyan : chalk.reset;
165
- table.push({
166
- [chalkModifier(row.name)]: columnValues,
167
- });
168
- });
169
- message += '\n\n' + table.toString();
170
- if (error) {
171
- bottomContent = chalk.red('>> ') + error;
166
+ for (let colIndex = 0; colIndex < this.columns.length; colIndex++) {
167
+ const isSelected = this.status !== 'answered' && this.pointer === rowIndex && this.horizontalPointer === colIndex;
168
+ const cellValue = getValue(this.columns[colIndex]) === this.values[rowIndex] ? figures_1.default.radioOn : figures_1.default.radioOff;
169
+ columnValues.push(`${isSelected ? '[' : ' '} ${cellValue} ${isSelected ? ']' : ' '}`);
170
+ }
171
+ const chalkModifier = this.status !== 'answered' && this.pointer === rowIndex ? (0, chalk_1.getChalk)().reset.bold.cyan : (0, chalk_1.getChalk)().reset;
172
+ table.push({ [chalkModifier(pluckName(row))]: columnValues });
173
+ }
174
+ const message = this.getMessage() + '\n\n' + table.toString();
175
+ const lines = message.split('\n').length;
176
+ const out = this.rl.output;
177
+ if (this.lastHeight > 0) {
178
+ out.write('\u001b[' + this.lastHeight + 'A\u001b[0J');
172
179
  }
173
- this.screen.render(message, bottomContent);
180
+ out.write(message);
181
+ this.lastHeight = lines;
174
182
  }
175
183
  }
176
184
  module.exports = TablePrompt;
@@ -17,7 +17,7 @@ export interface InquirePayload {
17
17
  default?: any;
18
18
  message: string;
19
19
  choices?: Array<any>;
20
- transformer?: Function;
20
+ transformer?: (value: any) => any;
21
21
  validate?(input: any, answers?: any): boolean | string | Promise<boolean | string>;
22
22
  selectAll?: boolean;
23
23
  pageSize?: number;
@@ -150,3 +150,5 @@ export interface ProgressResult {
150
150
  success: number;
151
151
  failures: number;
152
152
  }
153
+ export type Answers = Record<string, unknown>;
154
+ export type InquirerQuestion = InquirePayload;
@@ -174,7 +174,7 @@ class CLIErrorHandler {
174
174
  */
175
175
  extractErrorPayload(error) {
176
176
  var _a, _b, _c, _d;
177
- const { name, message, code, status, response, request, config, statusText } = error;
177
+ const { name, code, status, response, request, config, statusText } = error;
178
178
  const payload = {
179
179
  name,
180
180
  message: this.extractClearMessage(error),
package/lib/logger/log.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLogPath = exports.handleAndLogError = exports.cliErrorHandler = exports.v2Logger = exports.getSessionLogPath = void 0;
3
+ exports.cliErrorHandler = exports.v2Logger = exports.getSessionLogPath = void 0;
4
+ exports.handleAndLogError = handleAndLogError;
5
+ exports.getLogPath = getLogPath;
4
6
  const tslib_1 = require("tslib");
5
7
  const fs = tslib_1.__importStar(require("fs"));
6
8
  const os = tslib_1.__importStar(require("os"));
@@ -68,7 +70,6 @@ function handleAndLogError(error, context, errorMessage) {
68
70
  meta: classified.meta,
69
71
  });
70
72
  }
71
- exports.handleAndLogError = handleAndLogError;
72
73
  /**
73
74
  * Get the log path for centralized logging
74
75
  * Priority:
@@ -96,13 +97,12 @@ function getLogPath() {
96
97
  fs.accessSync(cwdPath, fs.constants.W_OK);
97
98
  return cwdPath;
98
99
  }
99
- catch (error) {
100
+ catch (_a) {
100
101
  // If current directory is not writable, fall back to home directory
101
102
  }
102
103
  // 4. Fallback to home directory
103
104
  return path.join(os.homedir(), 'contentstack', 'logs');
104
105
  }
105
- exports.getLogPath = getLogPath;
106
106
  // Re-export getSessionLogPath for external use
107
107
  var session_path_1 = require("./session-path");
108
108
  Object.defineProperty(exports, "getSessionLogPath", { enumerable: true, get: function () { return session_path_1.getSessionLogPath; } });
@@ -5,3 +5,8 @@
5
5
  * @returns The session-specific log directory path
6
6
  */
7
7
  export declare function getSessionLogPath(): string;
8
+ /**
9
+ * Clear the cached session path. Used by tests so each test gets a fresh path.
10
+ * Not needed in normal CLI usage (one process = one command = one cache).
11
+ */
12
+ export declare function clearSessionLogPathCache(): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSessionLogPath = void 0;
3
+ exports.getSessionLogPath = getSessionLogPath;
4
+ exports.clearSessionLogPathCache = clearSessionLogPathCache;
4
5
  const tslib_1 = require("tslib");
5
6
  const fs = tslib_1.__importStar(require("fs"));
6
7
  const os = tslib_1.__importStar(require("os"));
@@ -43,12 +44,16 @@ function createSessionMetadataFile(sessionPath, metadata) {
43
44
  try {
44
45
  fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), 'utf8');
45
46
  }
46
- catch (error) {
47
+ catch (_a) {
47
48
  // Silently fail if metadata file cannot be created
48
49
  // Logging here would cause circular dependency
49
50
  // The session folder and logs will still be created
50
51
  }
51
52
  }
53
+ // Cache session path for the process so multiple callers (e.g. Logger's 5 level
54
+ // loggers, export/import command at end, completeProgressWithMessage per module)
55
+ // get one folder instead of many.
56
+ let cachedSessionPath = null;
52
57
  /**
53
58
  * Get the session-based log path for date-organized logging
54
59
  * Structure: {basePath}/{YYYY-MM-DD}/{command}-{YYYYMMDD-HHMMSS}-{sessionId}/
@@ -56,6 +61,9 @@ function createSessionMetadataFile(sessionPath, metadata) {
56
61
  * @returns The session-specific log directory path
57
62
  */
58
63
  function getSessionLogPath() {
64
+ if (cachedSessionPath) {
65
+ return cachedSessionPath;
66
+ }
59
67
  // Get base log path
60
68
  const basePath = (0, log_1.getLogPath)();
61
69
  // Get current date in YYYY-MM-DD format
@@ -91,6 +99,13 @@ function getSessionLogPath() {
91
99
  const metadata = generateSessionMetadata(__1.configHandler.get('currentCommandId') || commandId, sessionId, now);
92
100
  createSessionMetadataFile(sessionPath, metadata);
93
101
  }
102
+ cachedSessionPath = sessionPath;
94
103
  return sessionPath;
95
104
  }
96
- exports.getSessionLogPath = getSessionLogPath;
105
+ /**
106
+ * Clear the cached session path. Used by tests so each test gets a fresh path.
107
+ * Not needed in normal CLI usage (one process = one command = one cache).
108
+ */
109
+ function clearSessionLogPathCache() {
110
+ cachedSessionPath = null;
111
+ }
@@ -2,9 +2,6 @@
2
2
  * Message handler
3
3
  */
4
4
  declare class Messages {
5
- private messages;
6
- messageFilePath: any;
7
- constructor();
8
5
  init(context: any): void;
9
6
  parse(messageKey: string, ...substitutions: Array<any>): string;
10
7
  }
@@ -3,32 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const fs_1 = tslib_1.__importDefault(require("fs"));
5
5
  const cli_error_1 = tslib_1.__importDefault(require("./cli-error"));
6
+ const STORE_KEY = '__cs_messages__';
6
7
  /**
7
8
  * Message handler
8
9
  */
9
10
  class Messages {
10
- constructor() {
11
- this.messages = {};
12
- }
13
11
  init(context) {
14
12
  if (!context.messageFilePath) {
15
13
  return;
16
14
  }
17
15
  try {
18
- this.messages = JSON.parse(fs_1.default.readFileSync(context.messageFilePath, 'utf-8'));
16
+ const loaded = JSON.parse(fs_1.default.readFileSync(context.messageFilePath, 'utf-8'));
17
+ globalThis[STORE_KEY] = Object.assign(Object.assign({}, globalThis[STORE_KEY]), loaded);
19
18
  }
20
19
  catch (error) {
21
- // create empty messages object if message file is not exist
22
- if (error.code === 'ENOENT') {
23
- this.messages = {};
24
- }
25
- else {
20
+ if (error.code !== 'ENOENT') {
26
21
  throw new cli_error_1.default(`Error: ${error.message}`);
27
22
  }
28
23
  }
29
24
  }
30
25
  parse(messageKey, ...substitutions) {
31
- const msg = this.messages[messageKey];
26
+ const store = globalThis[STORE_KEY] || {};
27
+ const msg = store[messageKey];
32
28
  if (!msg) {
33
29
  return messageKey;
34
30
  }
@@ -31,7 +31,9 @@ export default class CLIProgressManager {
31
31
  */
32
32
  static displayOperationHeader(branchName: string, headerTitle?: string): void;
33
33
  /**
34
- * Print the final summary for all modules using strategies
34
+ * Print the final summary for all modules using strategies.
35
+ * When showConsoleLogs is enabled, skip the Progress Manager summary block
36
+ * so output is pure timestamped log lines (per documentation).
35
37
  */
36
38
  static printGlobalSummary(): void;
37
39
  /**