@contentstack/cli-utilities 2.0.0-beta.2 → 2.0.0-beta.4
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/lib/chalk.d.ts +9 -0
- package/lib/chalk.js +60 -0
- package/lib/cli-ux.js +23 -10
- package/lib/config-handler.js +4 -4
- package/lib/constants/logging.js +2 -2
- package/lib/content-type-utils.d.ts +2 -2
- package/lib/content-type-utils.js +10 -8
- package/lib/contentstack-management-sdk.js +9 -3
- package/lib/contentstack-marketplace-sdk.js +1 -1
- package/lib/fs-utility/core.d.ts +0 -1
- package/lib/fs-utility/core.js +2 -3
- package/lib/fs-utility/helper.js +2 -3
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +4 -4
- package/lib/http-client/client.d.ts +2 -2
- package/lib/http-client/client.js +19 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -1
- package/lib/inquirer-table-prompt.d.ts +49 -28
- package/lib/inquirer-table-prompt.js +144 -136
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/logger/log.js +3 -3
- package/lib/logger/session-path.d.ts +5 -0
- package/lib/logger/session-path.js +17 -2
- package/lib/progress-summary/cli-progress-manager.js +39 -35
- package/lib/progress-summary/summary-manager.js +29 -30
- package/lib/proxy-helper.d.ts +42 -1
- package/lib/proxy-helper.js +148 -7
- package/package.json +6 -6
|
@@ -1,120 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
69
|
-
this.rows.
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return
|
|
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
|
-
|
|
80
|
-
this.
|
|
81
|
-
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
|
|
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(
|
|
95
|
+
this.done(raw);
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
|
-
|
|
95
|
-
this.
|
|
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
|
|
99
|
-
this.horizontalPointer = this.horizontalPointer > 0 ? this.horizontalPointer - 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
|
|
104
|
-
this.horizontalPointer = this.horizontalPointer <
|
|
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
|
-
|
|
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
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
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
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
139
|
-
let
|
|
140
|
-
let bottomContent = '';
|
|
140
|
+
getMessage() {
|
|
141
|
+
let msg = this.question.message || 'Select';
|
|
141
142
|
if (!this.spaceKeyPressed) {
|
|
142
|
-
|
|
143
|
-
'(Press ' +
|
|
144
|
-
|
|
143
|
+
msg +=
|
|
144
|
+
' (Press ' +
|
|
145
|
+
(0, chalk_1.getChalk)().cyan.bold('<space>') +
|
|
145
146
|
' to select, ' +
|
|
146
|
-
|
|
147
|
-
'
|
|
148
|
-
|
|
149
|
-
'
|
|
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
|
|
153
|
-
head: [
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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.
|
|
160
|
-
const isSelected = this.status !== 'answered' && this.pointer === rowIndex && this.horizontalPointer ===
|
|
161
|
-
const
|
|
162
|
-
columnValues.push(`${isSelected ? '[' : ' '} ${
|
|
163
|
-
}
|
|
164
|
-
const chalkModifier = this.status !== 'answered' && this.pointer === rowIndex ?
|
|
165
|
-
table.push({
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
|
|
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
|
-
|
|
180
|
+
out.write(message);
|
|
181
|
+
this.lastHeight = lines;
|
|
174
182
|
}
|
|
175
183
|
}
|
|
176
184
|
module.exports = TablePrompt;
|
package/lib/logger/log.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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:
|
|
@@ -102,7 +103,6 @@ function getLogPath() {
|
|
|
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 =
|
|
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"));
|
|
@@ -49,6 +50,10 @@ function createSessionMetadataFile(sessionPath, metadata) {
|
|
|
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
|
-
|
|
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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const chalk_1 =
|
|
4
|
+
const chalk_1 = require("../chalk");
|
|
5
5
|
const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
6
6
|
const cli_progress_1 = tslib_1.__importDefault(require("cli-progress"));
|
|
7
7
|
const summary_manager_1 = tslib_1.__importDefault(require("./summary-manager"));
|
|
@@ -46,11 +46,11 @@ class CLIProgressManager {
|
|
|
46
46
|
return;
|
|
47
47
|
const safeBranchName = branchName || 'main';
|
|
48
48
|
const branchInfo = headerTitle || `${safeBranchName === null || safeBranchName === void 0 ? void 0 : safeBranchName.toUpperCase()} CONTENT`;
|
|
49
|
-
console.log('\n' + chalk_1.
|
|
49
|
+
console.log('\n' + (0, chalk_1.getChalk)().bold('='.repeat(80)));
|
|
50
50
|
if (branchInfo) {
|
|
51
|
-
console.log(chalk_1.
|
|
51
|
+
console.log((0, chalk_1.getChalk)().bold.white(` ${branchInfo}`));
|
|
52
52
|
}
|
|
53
|
-
console.log(chalk_1.
|
|
53
|
+
console.log((0, chalk_1.getChalk)().bold('='.repeat(80)) + '\n');
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Print the final summary for all modules using strategies.
|
|
@@ -58,9 +58,13 @@ class CLIProgressManager {
|
|
|
58
58
|
* so output is pure timestamped log lines (per documentation).
|
|
59
59
|
*/
|
|
60
60
|
static printGlobalSummary() {
|
|
61
|
+
var _a;
|
|
61
62
|
if (!CLIProgressManager.globalSummary) {
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
65
|
+
if ((_a = __1.configHandler.get('log')) === null || _a === void 0 ? void 0 : _a.showConsoleLogs) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
64
68
|
// Apply strategy-based corrections before printing
|
|
65
69
|
CLIProgressManager.applyStrategyCorrections();
|
|
66
70
|
// Print the final summary
|
|
@@ -240,20 +244,20 @@ class CLIProgressManager {
|
|
|
240
244
|
this.multiBar = new cli_progress_1.default.MultiBar({
|
|
241
245
|
clearOnComplete: false,
|
|
242
246
|
hideCursor: true,
|
|
243
|
-
format: ' {label} |' + chalk_1.
|
|
247
|
+
format: ' {label} |' + (0, chalk_1.getChalk)().cyan('{bar}') + '| {percentage}% | {value}/{total} | {status}',
|
|
244
248
|
barCompleteChar: '\u2588',
|
|
245
249
|
barIncompleteChar: '\u2591',
|
|
246
250
|
}, cli_progress_1.default.Presets.shades_classic);
|
|
247
251
|
if (!this.showConsoleLogs) {
|
|
248
|
-
console.log(chalk_1.
|
|
252
|
+
console.log((0, chalk_1.getChalk)().bold.cyan(`\n${this.moduleName}:`));
|
|
249
253
|
}
|
|
250
254
|
}
|
|
251
255
|
else if (this.total > 0) {
|
|
252
256
|
if (!this.showConsoleLogs) {
|
|
253
|
-
console.log(chalk_1.
|
|
257
|
+
console.log((0, chalk_1.getChalk)().bold.cyan(`\n${this.moduleName}:`));
|
|
254
258
|
}
|
|
255
259
|
this.progressBar = new cli_progress_1.default.SingleBar({
|
|
256
|
-
format: ' {label} |' + chalk_1.
|
|
260
|
+
format: ' {label} |' + (0, chalk_1.getChalk)().cyan('{bar}') + '| {percentage}% | {value}/{total} | {status}',
|
|
257
261
|
barCompleteChar: '\u2588',
|
|
258
262
|
barIncompleteChar: '\u2591',
|
|
259
263
|
hideCursor: true,
|
|
@@ -261,13 +265,13 @@ class CLIProgressManager {
|
|
|
261
265
|
const formattedName = this.formatModuleName(this.moduleName);
|
|
262
266
|
const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
|
|
263
267
|
this.progressBar.start(this.total, 0, {
|
|
264
|
-
label: chalk_1.
|
|
265
|
-
status: chalk_1.
|
|
268
|
+
label: (0, chalk_1.getChalk)().gray(` └─ ${displayName}`.padEnd(25)),
|
|
269
|
+
status: (0, chalk_1.getChalk)().gray('Starting...'),
|
|
266
270
|
percentage: ' 0',
|
|
267
271
|
});
|
|
268
272
|
}
|
|
269
273
|
else {
|
|
270
|
-
this.spinner = (0, ora_1.default)(`${chalk_1.
|
|
274
|
+
this.spinner = (0, ora_1.default)(`${(0, chalk_1.getChalk)().bold(this.moduleName)}: Processing...`).start();
|
|
271
275
|
}
|
|
272
276
|
}
|
|
273
277
|
/**
|
|
@@ -289,8 +293,8 @@ class CLIProgressManager {
|
|
|
289
293
|
const displayName = this.formatProcessName(processName);
|
|
290
294
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
291
295
|
process.progressBar = this.multiBar.create(total, 0, {
|
|
292
|
-
label: chalk_1.
|
|
293
|
-
status: chalk_1.
|
|
296
|
+
label: (0, chalk_1.getChalk)().gray(indentedLabel),
|
|
297
|
+
status: (0, chalk_1.getChalk)().gray('Pending'),
|
|
294
298
|
percentage: ' 0',
|
|
295
299
|
});
|
|
296
300
|
}
|
|
@@ -326,8 +330,8 @@ class CLIProgressManager {
|
|
|
326
330
|
const displayName = this.formatProcessName(processName);
|
|
327
331
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
328
332
|
process.progressBar.update(0, {
|
|
329
|
-
label: chalk_1.
|
|
330
|
-
status: chalk_1.
|
|
333
|
+
label: (0, chalk_1.getChalk)().yellow(indentedLabel),
|
|
334
|
+
status: (0, chalk_1.getChalk)().yellow('Processing'),
|
|
331
335
|
percentage: ' 0',
|
|
332
336
|
});
|
|
333
337
|
}
|
|
@@ -356,12 +360,12 @@ class CLIProgressManager {
|
|
|
356
360
|
const percentage = Math.round((totalProcessed / process.total) * 100);
|
|
357
361
|
const formattedPercentage = this.formatPercentage(percentage);
|
|
358
362
|
const statusText = success
|
|
359
|
-
? chalk_1.
|
|
360
|
-
: chalk_1.
|
|
363
|
+
? (0, chalk_1.getChalk)().green(`✓ Complete (${process.successCount}/${process.current})`)
|
|
364
|
+
: (0, chalk_1.getChalk)().red(`✗ Failed (${process.successCount}/${process.current})`);
|
|
361
365
|
const displayName = this.formatProcessName(processName);
|
|
362
366
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
363
367
|
process.progressBar.update(process.total, {
|
|
364
|
-
label: success ? chalk_1.
|
|
368
|
+
label: success ? (0, chalk_1.getChalk)().green(indentedLabel) : (0, chalk_1.getChalk)().red(indentedLabel),
|
|
365
369
|
status: statusText,
|
|
366
370
|
percentage: formattedPercentage,
|
|
367
371
|
});
|
|
@@ -382,8 +386,8 @@ class CLIProgressManager {
|
|
|
382
386
|
const displayName = this.formatProcessName(processName);
|
|
383
387
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
384
388
|
process.progressBar.update(process.current, {
|
|
385
|
-
label: chalk_1.
|
|
386
|
-
status: chalk_1.
|
|
389
|
+
label: (0, chalk_1.getChalk)().yellow(indentedLabel),
|
|
390
|
+
status: (0, chalk_1.getChalk)().yellow(message),
|
|
387
391
|
percentage: formattedPercentage,
|
|
388
392
|
});
|
|
389
393
|
}
|
|
@@ -394,13 +398,13 @@ class CLIProgressManager {
|
|
|
394
398
|
const formattedName = this.formatModuleName(this.moduleName);
|
|
395
399
|
const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
|
|
396
400
|
this.progressBar.update(this.progressBar.getProgress() * this.total, {
|
|
397
|
-
label: chalk_1.
|
|
398
|
-
status: chalk_1.
|
|
401
|
+
label: (0, chalk_1.getChalk)().yellow(` └─ ${displayName}`.padEnd(25)),
|
|
402
|
+
status: (0, chalk_1.getChalk)().yellow(message),
|
|
399
403
|
percentage: formattedPercentage,
|
|
400
404
|
});
|
|
401
405
|
}
|
|
402
406
|
else if (this.spinner) {
|
|
403
|
-
this.spinner.text = `${chalk_1.
|
|
407
|
+
this.spinner.text = `${(0, chalk_1.getChalk)().bold(this.moduleName)}: ${message}`;
|
|
404
408
|
}
|
|
405
409
|
}
|
|
406
410
|
return this;
|
|
@@ -444,8 +448,8 @@ class CLIProgressManager {
|
|
|
444
448
|
const displayName = this.formatProcessName(targetProcess);
|
|
445
449
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
446
450
|
process.progressBar.increment(1, {
|
|
447
|
-
label: chalk_1.
|
|
448
|
-
status: chalk_1.
|
|
451
|
+
label: (0, chalk_1.getChalk)().cyan(indentedLabel),
|
|
452
|
+
status: (0, chalk_1.getChalk)().cyan(statusText),
|
|
449
453
|
percentage: formattedPercentage,
|
|
450
454
|
});
|
|
451
455
|
}
|
|
@@ -461,10 +465,10 @@ class CLIProgressManager {
|
|
|
461
465
|
// Show completion status when finished, otherwise show running count
|
|
462
466
|
const statusText = totalProcessed >= this.total
|
|
463
467
|
? this.failureCount === 0
|
|
464
|
-
? chalk_1.
|
|
465
|
-
: chalk_1.
|
|
466
|
-
: chalk_1.
|
|
467
|
-
const labelColor = totalProcessed >= this.total ? (this.failureCount === 0 ? chalk_1.
|
|
468
|
+
? (0, chalk_1.getChalk)().green(`✓ Complete (${this.successCount}/${totalProcessed})`)
|
|
469
|
+
: (0, chalk_1.getChalk)().yellow(`✓ Complete (${this.successCount}/${totalProcessed})`)
|
|
470
|
+
: (0, chalk_1.getChalk)().cyan(`${this.successCount}✓ ${this.failureCount}✗`);
|
|
471
|
+
const labelColor = totalProcessed >= this.total ? (this.failureCount === 0 ? (0, chalk_1.getChalk)().green : (0, chalk_1.getChalk)().yellow) : (0, chalk_1.getChalk)().cyan;
|
|
468
472
|
const formattedName = this.formatModuleName(this.moduleName);
|
|
469
473
|
const displayName = formattedName.length > 20 ? formattedName.substring(0, 17) + '...' : formattedName;
|
|
470
474
|
this.progressBar.increment(1, {
|
|
@@ -475,7 +479,7 @@ class CLIProgressManager {
|
|
|
475
479
|
}
|
|
476
480
|
else if (this.spinner) {
|
|
477
481
|
const total = this.successCount + this.failureCount;
|
|
478
|
-
this.spinner.text = `${chalk_1.
|
|
482
|
+
this.spinner.text = `${(0, chalk_1.getChalk)().bold(this.moduleName)}: ${total} items (${this.successCount}✓ ${this.failureCount}✗)`;
|
|
479
483
|
}
|
|
480
484
|
}
|
|
481
485
|
}
|
|
@@ -520,13 +524,13 @@ class CLIProgressManager {
|
|
|
520
524
|
}
|
|
521
525
|
if (!this.enableNestedProgress) {
|
|
522
526
|
// Simple summary for single progress
|
|
523
|
-
this.log('\n' + chalk_1.
|
|
524
|
-
this.log(`✓ Success: ${chalk_1.
|
|
525
|
-
this.log(`✗ Failures: ${chalk_1.
|
|
527
|
+
this.log('\n' + (0, chalk_1.getChalk)().bold(`${this.moduleName} Summary:`));
|
|
528
|
+
this.log(`✓ Success: ${(0, chalk_1.getChalk)().green(this.successCount)}`);
|
|
529
|
+
this.log(`✗ Failures: ${(0, chalk_1.getChalk)().red(this.failureCount)}`);
|
|
526
530
|
return;
|
|
527
531
|
}
|
|
528
532
|
// Detailed summary for nested progress
|
|
529
|
-
this.log('\n' + chalk_1.
|
|
533
|
+
this.log('\n' + (0, chalk_1.getChalk)().bold(`${this.moduleName} Detailed Summary:`));
|
|
530
534
|
for (const [processName, process] of this.processes) {
|
|
531
535
|
const status = process.status === 'completed'
|
|
532
536
|
? '✓'
|
|
@@ -546,5 +550,5 @@ class CLIProgressManager {
|
|
|
546
550
|
return this.failureCount;
|
|
547
551
|
}
|
|
548
552
|
}
|
|
549
|
-
exports.default = CLIProgressManager;
|
|
550
553
|
CLIProgressManager.globalSummary = null;
|
|
554
|
+
exports.default = CLIProgressManager;
|