@contentstack/cli-utilities 1.17.4 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth-handler.js +1 -0
- package/lib/constants/logging.d.ts +1 -0
- package/lib/constants/logging.js +4 -3
- package/lib/content-type-utils.d.ts +7 -0
- package/lib/content-type-utils.js +42 -0
- package/lib/fs-utility/core.js +1 -2
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.js +11 -3
- package/lib/index.d.ts +3 -2
- package/lib/index.js +10 -3
- package/lib/interfaces/index.d.ts +50 -1
- package/lib/logger/cli-error-handler.js +1 -2
- package/lib/logger/log.js +1 -1
- package/lib/logger/logger.js +37 -17
- package/lib/progress-summary/cli-progress-manager.d.ts +127 -0
- package/lib/progress-summary/cli-progress-manager.js +550 -0
- package/lib/progress-summary/index.d.ts +4 -0
- package/lib/progress-summary/index.js +13 -0
- package/lib/progress-summary/progress-strategy.d.ts +25 -0
- package/lib/progress-summary/progress-strategy.js +54 -0
- package/lib/progress-summary/summary-manager.d.ts +28 -0
- package/lib/progress-summary/summary-manager.js +188 -0
- package/package.json +3 -3
- package/lib/flag-deprecation-check.d.ts +0 -7
- package/lib/flag-deprecation-check.js +0 -40
package/lib/auth-handler.js
CHANGED
package/lib/constants/logging.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.levelColors = exports.logLevels = void 0;
|
|
3
|
+
exports.PROGRESS_SUPPORTED_MODULES = exports.levelColors = exports.logLevels = void 0;
|
|
4
4
|
exports.logLevels = {
|
|
5
5
|
error: 0,
|
|
6
6
|
warn: 1,
|
|
7
7
|
info: 2,
|
|
8
8
|
success: 2,
|
|
9
9
|
debug: 3,
|
|
10
|
-
verbose: 4
|
|
10
|
+
verbose: 4,
|
|
11
11
|
};
|
|
12
12
|
// 2. Create color mappings (for console only)
|
|
13
13
|
exports.levelColors = {
|
|
@@ -15,5 +15,6 @@ exports.levelColors = {
|
|
|
15
15
|
warn: 'yellow',
|
|
16
16
|
success: 'green',
|
|
17
17
|
info: 'white',
|
|
18
|
-
debug: 'blue'
|
|
18
|
+
debug: 'blue',
|
|
19
19
|
};
|
|
20
|
+
exports.PROGRESS_SUPPORTED_MODULES = ['export', 'import', 'audit', 'import-setup', 'clone'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads all content type schema files from a directory
|
|
3
|
+
* @param dirPath - Path to content types directory
|
|
4
|
+
* @param ignoredFiles - Files to ignore (defaults to schema.json, .DS_Store, __master.json, __priority.json)
|
|
5
|
+
* @returns Array of content type schemas
|
|
6
|
+
*/
|
|
7
|
+
export declare function readContentTypeSchemas(dirPath: string, ignoredFiles?: string[]): Record<string, unknown>[] | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readContentTypeSchemas = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const fs_utility_1 = require("./fs-utility");
|
|
6
|
+
/**
|
|
7
|
+
* Reads all content type schema files from a directory
|
|
8
|
+
* @param dirPath - Path to content types directory
|
|
9
|
+
* @param ignoredFiles - Files to ignore (defaults to schema.json, .DS_Store, __master.json, __priority.json)
|
|
10
|
+
* @returns Array of content type schemas
|
|
11
|
+
*/
|
|
12
|
+
function readContentTypeSchemas(dirPath, ignoredFiles = ['schema.json', '.DS_Store', '__master.json', '__priority.json', 'field_rules_uid.json']) {
|
|
13
|
+
const fsUtil = new fs_utility_1.FsUtility();
|
|
14
|
+
const files = fsUtil.readdir(dirPath);
|
|
15
|
+
if (!files || files.length === 0) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const contentTypes = [];
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
// Skip if not a JSON file
|
|
21
|
+
if (!file.endsWith('.json')) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
// Skip ignored files
|
|
25
|
+
if (ignoredFiles.includes(file)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const filePath = (0, node_path_1.resolve)(dirPath, file);
|
|
30
|
+
const contentType = fsUtil.readFile(filePath);
|
|
31
|
+
if (contentType) {
|
|
32
|
+
contentTypes.push(contentType);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// Skip files that cannot be parsed
|
|
37
|
+
console.warn(`Failed to read content type file ${file}:`, error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return contentTypes;
|
|
41
|
+
}
|
|
42
|
+
exports.readContentTypeSchemas = readContentTypeSchemas;
|
package/lib/fs-utility/core.js
CHANGED
|
@@ -11,7 +11,6 @@ const node_fs_1 = require("node:fs");
|
|
|
11
11
|
const helper_1 = require("./helper");
|
|
12
12
|
class FsUtility {
|
|
13
13
|
constructor(options = {}) {
|
|
14
|
-
var _a;
|
|
15
14
|
this.isArray = false;
|
|
16
15
|
this.prefixKey = '';
|
|
17
16
|
this.currentFileName = '';
|
|
@@ -35,7 +34,7 @@ class FsUtility {
|
|
|
35
34
|
this.metaPickKeys = metaPickKeys || [];
|
|
36
35
|
this.moduleName = moduleName || 'chunk';
|
|
37
36
|
this.chunkFileSize = chunkFileSize || 10;
|
|
38
|
-
this.keepMetadata = keepMetadata
|
|
37
|
+
this.keepMetadata = keepMetadata !== null && keepMetadata !== void 0 ? keepMetadata : true;
|
|
39
38
|
this.indexFileName = indexFileName || 'index.json';
|
|
40
39
|
this.pageInfo.hasNextPage = (0, keys_1.default)(this.indexFileContent).length > 0;
|
|
41
40
|
this.defaultInitContent = defaultInitContent || this.isArray ? '[' : this.fileExt === 'json' ? '{' : '';
|
package/lib/helpers.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const formatError: (error: any) => string;
|
|
|
27
27
|
* from.
|
|
28
28
|
*/
|
|
29
29
|
export declare const redactObject: (obj: any) => any;
|
|
30
|
+
export declare function clearProgressModuleSetting(): void;
|
|
30
31
|
/**
|
|
31
32
|
* Get authentication method from config
|
|
32
33
|
* @returns Authentication method string ('OAuth', 'Basic Auth', or empty string)
|
package/lib/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLogContext = exports.getAuthenticationMethod = exports.redactObject = exports.formatError = exports.validateRegex = exports.validateFileName = exports.validateUids = exports.sanitizePath = exports.escapeRegExp = exports.validatePath = exports.createDeveloperHubUrl = exports.isManagementTokenValid = exports.getBranchFromAlias = exports.doesBranchExist = exports.isAuthenticated = void 0;
|
|
3
|
+
exports.createLogContext = exports.getAuthenticationMethod = exports.clearProgressModuleSetting = exports.redactObject = exports.formatError = exports.validateRegex = exports.validateFileName = exports.validateUids = exports.sanitizePath = exports.escapeRegExp = exports.validatePath = exports.createDeveloperHubUrl = exports.isManagementTokenValid = exports.getBranchFromAlias = exports.doesBranchExist = exports.isAuthenticated = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const recheck_1 = require("recheck");
|
|
6
6
|
const traverse_1 = tslib_1.__importDefault(require("traverse"));
|
|
@@ -191,8 +191,8 @@ const formatError = function (error) {
|
|
|
191
191
|
// If message is in JSON format, parse it to extract the actual message string
|
|
192
192
|
try {
|
|
193
193
|
const parsedMessage = JSON.parse(message);
|
|
194
|
-
if (typeof parsedMessage === 'object') {
|
|
195
|
-
message = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.message) || message;
|
|
194
|
+
if (typeof parsedMessage === 'object' && parsedMessage !== null) {
|
|
195
|
+
message = (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.message) || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.errorMessage) || (parsedMessage === null || parsedMessage === void 0 ? void 0 : parsedMessage.error) || message;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
catch (e) {
|
|
@@ -244,6 +244,14 @@ const sensitiveKeys = [
|
|
|
244
244
|
/management[-._]?token/i,
|
|
245
245
|
/delivery[-._]?token/i,
|
|
246
246
|
];
|
|
247
|
+
function clearProgressModuleSetting() {
|
|
248
|
+
const logConfig = _1.configHandler.get('log') || {};
|
|
249
|
+
if (logConfig === null || logConfig === void 0 ? void 0 : logConfig.progressSupportedModule) {
|
|
250
|
+
delete logConfig.progressSupportedModule;
|
|
251
|
+
_1.configHandler.set('log', logConfig);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.clearProgressModuleSetting = clearProgressModuleSetting;
|
|
247
255
|
/**
|
|
248
256
|
* Get authentication method from config
|
|
249
257
|
* @returns Authentication method string ('OAuth', 'Basic Auth', or empty string)
|
package/lib/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export { default as authHandler } from './auth-handler';
|
|
|
8
8
|
export { default as configHandler } from './config-handler';
|
|
9
9
|
export { default as managementSDKClient, managementSDKInitiator, ContentstackClient, ContentstackConfig, } from './contentstack-management-sdk';
|
|
10
10
|
export * from './management-types';
|
|
11
|
-
export { default as printFlagDeprecation } from './flag-deprecation-check';
|
|
12
11
|
export * from './http-client';
|
|
13
12
|
export * from './fs-utility';
|
|
13
|
+
export * from './content-type-utils';
|
|
14
14
|
export { default as NodeCrypto } from './encrypter';
|
|
15
15
|
export { Args as args, Flags as flags, Command } from './cli-ux';
|
|
16
16
|
export * from './helpers';
|
|
@@ -26,4 +26,5 @@ export { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/
|
|
|
26
26
|
export { default as TablePrompt } from './inquirer-table-prompt';
|
|
27
27
|
export { Logger };
|
|
28
28
|
export { default as authenticationHandler } from './authentication-handler';
|
|
29
|
-
export { v2Logger as log, cliErrorHandler, handleAndLogError, getLogPath } from './logger/log';
|
|
29
|
+
export { v2Logger as log, cliErrorHandler, handleAndLogError, getLogPath, getSessionLogPath } from './logger/log';
|
|
30
|
+
export { CLIProgressManager, SummaryManager, PrimaryProcessStrategy, ProgressStrategyRegistry, CustomProgressStrategy, DefaultProgressStrategy } from './progress-summary';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.
|
|
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;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
6
6
|
exports.Logger = logger_1.default;
|
|
@@ -24,10 +24,9 @@ var contentstack_management_sdk_1 = require("./contentstack-management-sdk");
|
|
|
24
24
|
Object.defineProperty(exports, "managementSDKClient", { enumerable: true, get: function () { return tslib_1.__importDefault(contentstack_management_sdk_1).default; } });
|
|
25
25
|
Object.defineProperty(exports, "managementSDKInitiator", { enumerable: true, get: function () { return contentstack_management_sdk_1.managementSDKInitiator; } });
|
|
26
26
|
tslib_1.__exportStar(require("./management-types"), exports);
|
|
27
|
-
var flag_deprecation_check_1 = require("./flag-deprecation-check");
|
|
28
|
-
Object.defineProperty(exports, "printFlagDeprecation", { enumerable: true, get: function () { return tslib_1.__importDefault(flag_deprecation_check_1).default; } });
|
|
29
27
|
tslib_1.__exportStar(require("./http-client"), exports);
|
|
30
28
|
tslib_1.__exportStar(require("./fs-utility"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./content-type-utils"), exports);
|
|
31
30
|
var encrypter_1 = require("./encrypter");
|
|
32
31
|
Object.defineProperty(exports, "NodeCrypto", { enumerable: true, get: function () { return tslib_1.__importDefault(encrypter_1).default; } });
|
|
33
32
|
var cli_ux_2 = require("./cli-ux");
|
|
@@ -72,3 +71,11 @@ Object.defineProperty(exports, "log", { enumerable: true, get: function () { ret
|
|
|
72
71
|
Object.defineProperty(exports, "cliErrorHandler", { enumerable: true, get: function () { return log_1.cliErrorHandler; } });
|
|
73
72
|
Object.defineProperty(exports, "handleAndLogError", { enumerable: true, get: function () { return log_1.handleAndLogError; } });
|
|
74
73
|
Object.defineProperty(exports, "getLogPath", { enumerable: true, get: function () { return log_1.getLogPath; } });
|
|
74
|
+
Object.defineProperty(exports, "getSessionLogPath", { enumerable: true, get: function () { return log_1.getSessionLogPath; } });
|
|
75
|
+
var progress_summary_1 = require("./progress-summary");
|
|
76
|
+
Object.defineProperty(exports, "CLIProgressManager", { enumerable: true, get: function () { return progress_summary_1.CLIProgressManager; } });
|
|
77
|
+
Object.defineProperty(exports, "SummaryManager", { enumerable: true, get: function () { return progress_summary_1.SummaryManager; } });
|
|
78
|
+
Object.defineProperty(exports, "PrimaryProcessStrategy", { enumerable: true, get: function () { return progress_summary_1.PrimaryProcessStrategy; } });
|
|
79
|
+
Object.defineProperty(exports, "ProgressStrategyRegistry", { enumerable: true, get: function () { return progress_summary_1.ProgressStrategyRegistry; } });
|
|
80
|
+
Object.defineProperty(exports, "CustomProgressStrategy", { enumerable: true, get: function () { return progress_summary_1.CustomProgressStrategy; } });
|
|
81
|
+
Object.defineProperty(exports, "DefaultProgressStrategy", { enumerable: true, get: function () { return progress_summary_1.DefaultProgressStrategy; } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { logLevels } from
|
|
1
|
+
import { logLevels } from '../constants/logging';
|
|
2
|
+
import ProgressBar from 'cli-progress';
|
|
2
3
|
export interface IPromptOptions {
|
|
3
4
|
prompt?: string;
|
|
4
5
|
type?: 'normal' | 'mask' | 'hide' | 'single';
|
|
@@ -101,3 +102,51 @@ export interface ErrorContextBase {
|
|
|
101
102
|
export type ErrorContext = ErrorContextBase & {
|
|
102
103
|
[key: string]: unknown;
|
|
103
104
|
};
|
|
105
|
+
export interface Failure {
|
|
106
|
+
item: string;
|
|
107
|
+
error: string | null;
|
|
108
|
+
process?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface ProcessProgress {
|
|
111
|
+
name: string;
|
|
112
|
+
total: number;
|
|
113
|
+
current: number;
|
|
114
|
+
status: 'pending' | 'active' | 'completed' | 'failed';
|
|
115
|
+
successCount: number;
|
|
116
|
+
failureCount: number;
|
|
117
|
+
failures: Failure[];
|
|
118
|
+
progressBar?: ProgressBar.SingleBar;
|
|
119
|
+
}
|
|
120
|
+
export interface ProgressManagerOptions {
|
|
121
|
+
showConsoleLogs?: boolean;
|
|
122
|
+
total?: number;
|
|
123
|
+
moduleName?: string;
|
|
124
|
+
enableNestedProgress?: boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface ModuleResult {
|
|
127
|
+
name: string;
|
|
128
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
129
|
+
startTime?: number;
|
|
130
|
+
endTime?: number;
|
|
131
|
+
totalItems: number;
|
|
132
|
+
successCount: number;
|
|
133
|
+
failureCount: number;
|
|
134
|
+
failures: Array<{
|
|
135
|
+
item: string;
|
|
136
|
+
error: string;
|
|
137
|
+
}>;
|
|
138
|
+
processes?: Array<{
|
|
139
|
+
processName: string;
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
143
|
+
export interface SummaryOptions {
|
|
144
|
+
operationName: string;
|
|
145
|
+
context?: any;
|
|
146
|
+
branchName?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface ProgressResult {
|
|
149
|
+
total: number;
|
|
150
|
+
success: number;
|
|
151
|
+
failures: number;
|
|
152
|
+
}
|
|
@@ -114,8 +114,7 @@ class CLIErrorHandler {
|
|
|
114
114
|
if (typeof error === 'object') {
|
|
115
115
|
try {
|
|
116
116
|
const errorObj = error;
|
|
117
|
-
const
|
|
118
|
-
const normalizedError = new Error(message);
|
|
117
|
+
const normalizedError = new Error('Error occurred');
|
|
119
118
|
// Only copy essential properties
|
|
120
119
|
const essentialProps = [
|
|
121
120
|
'code',
|
package/lib/logger/log.js
CHANGED
|
@@ -13,7 +13,7 @@ function createLoggerInstance() {
|
|
|
13
13
|
var _a;
|
|
14
14
|
const logConfig = __1.configHandler.get('log');
|
|
15
15
|
const logLevel = (logConfig === null || logConfig === void 0 ? void 0 : logConfig.level) || 'info';
|
|
16
|
-
const showConsoleLogs = (_a = logConfig === null || logConfig === void 0 ? void 0 : logConfig
|
|
16
|
+
const showConsoleLogs = (_a = logConfig === null || logConfig === void 0 ? void 0 : logConfig.showConsoleLogs) !== null && _a !== void 0 ? _a : false;
|
|
17
17
|
const config = {
|
|
18
18
|
basePath: getLogPath(),
|
|
19
19
|
logLevel: logLevel,
|
package/lib/logger/logger.js
CHANGED
|
@@ -6,6 +6,7 @@ const full_1 = require("klona/full");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const winston = tslib_1.__importStar(require("winston"));
|
|
8
8
|
const logging_1 = require("../constants/logging");
|
|
9
|
+
const __1 = require("..");
|
|
9
10
|
const session_path_1 = require("./session-path");
|
|
10
11
|
class Logger {
|
|
11
12
|
constructor(config) {
|
|
@@ -46,26 +47,45 @@ class Logger {
|
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
createLogger(level, filePath) {
|
|
50
|
+
var _a;
|
|
51
|
+
const transports = [
|
|
52
|
+
new winston.transports.File(Object.assign(Object.assign({}, this.loggerOptions), { filename: `${filePath}/${level}.log`, format: winston.format.combine(winston.format.timestamp(), winston.format.printf((info) => {
|
|
53
|
+
// Apply minimal redaction for files (debugging info preserved)
|
|
54
|
+
const redactedInfo = this.redact(info, false);
|
|
55
|
+
return JSON.stringify(redactedInfo);
|
|
56
|
+
})) })),
|
|
57
|
+
];
|
|
58
|
+
// Determine console logging based on configuration
|
|
59
|
+
let showConsoleLogs = true;
|
|
60
|
+
if (__1.configHandler && typeof __1.configHandler.get === 'function') {
|
|
61
|
+
const logConfig = __1.configHandler.get('log') || {};
|
|
62
|
+
const currentModule = logConfig.progressSupportedModule;
|
|
63
|
+
const hasProgressSupport = currentModule && logging_1.PROGRESS_SUPPORTED_MODULES.includes(currentModule);
|
|
64
|
+
if (hasProgressSupport) {
|
|
65
|
+
// Plugin has progress bars - respect user's explicit setting, or default to false (show progress bars)
|
|
66
|
+
showConsoleLogs = (_a = logConfig.showConsoleLogs) !== null && _a !== void 0 ? _a : false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Plugin doesn't have progress support - always show console logs
|
|
70
|
+
showConsoleLogs = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (showConsoleLogs) {
|
|
74
|
+
transports.push(new winston.transports.Console({
|
|
75
|
+
format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.printf((info) => {
|
|
76
|
+
// Apply full redaction for console (user-facing)
|
|
77
|
+
const redactedInfo = this.redact(info, true);
|
|
78
|
+
const colorizer = winston.format.colorize();
|
|
79
|
+
const levelText = redactedInfo.level.toUpperCase();
|
|
80
|
+
const { timestamp, message } = redactedInfo;
|
|
81
|
+
return colorizer.colorize(redactedInfo.level, `[${timestamp}] ${levelText}: ${message}`);
|
|
82
|
+
})),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
49
85
|
return winston.createLogger({
|
|
50
86
|
levels: logging_1.logLevels,
|
|
51
87
|
level,
|
|
52
|
-
transports
|
|
53
|
-
new winston.transports.File(Object.assign(Object.assign({}, this.loggerOptions), { filename: `${filePath}/${level}.log`, format: winston.format.combine(winston.format.timestamp(), winston.format.printf((info) => {
|
|
54
|
-
// Apply minimal redaction for files (debugging info preserved)
|
|
55
|
-
const redactedInfo = this.redact(info, false);
|
|
56
|
-
return JSON.stringify(redactedInfo);
|
|
57
|
-
})) })),
|
|
58
|
-
new winston.transports.Console({
|
|
59
|
-
format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.printf((info) => {
|
|
60
|
-
// Apply full redaction for console (user-facing)
|
|
61
|
-
const redactedInfo = this.redact(info, true);
|
|
62
|
-
const colorizer = winston.format.colorize();
|
|
63
|
-
const levelText = redactedInfo.level.toUpperCase();
|
|
64
|
-
const { timestamp, message } = redactedInfo;
|
|
65
|
-
return colorizer.colorize(redactedInfo.level, `[${timestamp}] ${levelText}: ${message}`);
|
|
66
|
-
})),
|
|
67
|
-
}),
|
|
68
|
-
],
|
|
88
|
+
transports,
|
|
69
89
|
});
|
|
70
90
|
}
|
|
71
91
|
isSensitiveKey(keyStr, consoleMode = false) {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import SummaryManager from './summary-manager';
|
|
2
|
+
import { ProgressManagerOptions } from '../interfaces';
|
|
3
|
+
interface ProgressCallback {
|
|
4
|
+
onModuleStart?: (moduleName: string) => void;
|
|
5
|
+
onModuleComplete?: (moduleName: string, success: boolean, error?: string) => void;
|
|
6
|
+
onProgress?: (moduleName: string, success: boolean, itemName: string, error?: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export default class CLIProgressManager {
|
|
9
|
+
private static globalSummary;
|
|
10
|
+
private showConsoleLogs;
|
|
11
|
+
private total;
|
|
12
|
+
private moduleName;
|
|
13
|
+
private enableNestedProgress;
|
|
14
|
+
private successCount;
|
|
15
|
+
private failureCount;
|
|
16
|
+
private failures;
|
|
17
|
+
private spinner;
|
|
18
|
+
private progressBar;
|
|
19
|
+
private processes;
|
|
20
|
+
private multiBar;
|
|
21
|
+
private currentProcess;
|
|
22
|
+
private callbacks;
|
|
23
|
+
private branchName;
|
|
24
|
+
constructor({ showConsoleLogs, total, moduleName, enableNestedProgress, }?: ProgressManagerOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Initialize global summary manager for the entire operation
|
|
27
|
+
*/
|
|
28
|
+
static initializeGlobalSummary(operationName: string, branchName: string, headerTitle?: string): SummaryManager;
|
|
29
|
+
/**
|
|
30
|
+
* Display operation header with branch information
|
|
31
|
+
*/
|
|
32
|
+
static displayOperationHeader(branchName: string, headerTitle?: string): void;
|
|
33
|
+
/**
|
|
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).
|
|
37
|
+
*/
|
|
38
|
+
static printGlobalSummary(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if there are any failures in the global summary
|
|
41
|
+
*/
|
|
42
|
+
static hasFailures(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Apply strategy-based corrections to module data
|
|
45
|
+
*/
|
|
46
|
+
private static applyStrategyCorrections;
|
|
47
|
+
/**
|
|
48
|
+
* Clear global summary (for cleanup)
|
|
49
|
+
*/
|
|
50
|
+
static clearGlobalSummary(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Create a simple progress manager (no nested processes)
|
|
53
|
+
*/
|
|
54
|
+
static createSimple(moduleName: string, total?: number, showConsoleLogs?: boolean): CLIProgressManager;
|
|
55
|
+
/**
|
|
56
|
+
* Create a nested progress manager (with sub-processes)
|
|
57
|
+
*/
|
|
58
|
+
static createNested(moduleName: string, showConsoleLogs?: boolean): CLIProgressManager;
|
|
59
|
+
/**
|
|
60
|
+
* Show a loading spinner before initializing progress
|
|
61
|
+
*/
|
|
62
|
+
static withLoadingSpinner<T>(message: string, asyncOperation: () => Promise<T>): Promise<T>;
|
|
63
|
+
private setupGlobalSummaryIntegration;
|
|
64
|
+
/**
|
|
65
|
+
* Register process data with summary manager for strategy calculations
|
|
66
|
+
*/
|
|
67
|
+
private registerProcessDataWithSummary;
|
|
68
|
+
/**
|
|
69
|
+
* Set callbacks for external integration
|
|
70
|
+
*/
|
|
71
|
+
setCallbacks(callbacks: ProgressCallback): void;
|
|
72
|
+
/**
|
|
73
|
+
* Convert module name from UPPERCASE to PascalCase
|
|
74
|
+
*/
|
|
75
|
+
private formatModuleName;
|
|
76
|
+
/**
|
|
77
|
+
* Format process name with smart truncation (modules should use short names)
|
|
78
|
+
*/
|
|
79
|
+
private formatProcessName;
|
|
80
|
+
/**
|
|
81
|
+
* Format percentage for consistent alignment (always 3 characters)
|
|
82
|
+
*/
|
|
83
|
+
private formatPercentage;
|
|
84
|
+
private initializeProgress;
|
|
85
|
+
/**
|
|
86
|
+
* Add a new process to track (for nested progress)
|
|
87
|
+
*/
|
|
88
|
+
addProcess(processName: string, total: number): this;
|
|
89
|
+
/**
|
|
90
|
+
* Update the total for a specific process (for dynamic totals after API calls)
|
|
91
|
+
*/
|
|
92
|
+
updateProcessTotal(processName: string, newTotal: number): this;
|
|
93
|
+
/**
|
|
94
|
+
* Start a specific process
|
|
95
|
+
*/
|
|
96
|
+
startProcess(processName: string): this;
|
|
97
|
+
/**
|
|
98
|
+
* Complete a specific process
|
|
99
|
+
*/
|
|
100
|
+
completeProcess(processName: string, success?: boolean): this;
|
|
101
|
+
/**
|
|
102
|
+
* Update status message
|
|
103
|
+
*/
|
|
104
|
+
updateStatus(message: string, processName?: string): this;
|
|
105
|
+
/**
|
|
106
|
+
* Update progress
|
|
107
|
+
*/
|
|
108
|
+
tick(success?: boolean, itemName?: string, errorMessage?: string | null, processName?: string): this;
|
|
109
|
+
/**
|
|
110
|
+
* Complete the entire module
|
|
111
|
+
*/
|
|
112
|
+
complete(success?: boolean, error?: string): this;
|
|
113
|
+
/**
|
|
114
|
+
* Log message (respects showConsoleLogs mode)
|
|
115
|
+
*/
|
|
116
|
+
log(msg: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Stop all progress indicators
|
|
119
|
+
*/
|
|
120
|
+
stop(): void;
|
|
121
|
+
private printSummary;
|
|
122
|
+
/**
|
|
123
|
+
* Get the current failure count
|
|
124
|
+
*/
|
|
125
|
+
getFailureCount(): number;
|
|
126
|
+
}
|
|
127
|
+
export {};
|