@augment-vir/node-js
Advanced tools
Comparing version 15.3.0 to 15.4.0
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import type { Socket } from 'net'; | ||
export declare enum ColorKey { | ||
@@ -12,12 +14,22 @@ bold = "bold", | ||
export declare const logColors: Readonly<Record<ColorKey, string>>; | ||
export declare enum LogType { | ||
info = "info", | ||
error = "error", | ||
bold = "bold", | ||
mutate = "mutate", | ||
faint = "faint", | ||
success = "success" | ||
type ToLoggingStringInputs = { | ||
colors: ColorKey | ReadonlyArray<ColorKey>; | ||
args: ReadonlyArray<any>; | ||
}; | ||
export declare function toLogString({ colors, args }: ToLoggingStringInputs): string; | ||
export declare enum LogOutputType { | ||
standard = "stdout", | ||
error = "stderr" | ||
} | ||
export declare const log: Record<LogType, (...args: ReadonlyArray<any>) => void>; | ||
export declare const logIf: Record<LogType, (condition: boolean, ...args: ReadonlyArray<any>) => void>; | ||
export type Logger = ReturnType<typeof createLogger>; | ||
export declare function createLogger(logWriters: Record<LogOutputType, Pick<Socket, 'write'>>): { | ||
readonly info: (...args: ReadonlyArray<any>) => void; | ||
readonly error: (...args: ReadonlyArray<any>) => void; | ||
readonly bold: (...args: ReadonlyArray<any>) => void; | ||
readonly mutate: (...args: ReadonlyArray<any>) => void; | ||
readonly faint: (...args: ReadonlyArray<any>) => void; | ||
readonly success: (...args: ReadonlyArray<any>) => void; | ||
}; | ||
export declare const log: Logger; | ||
export declare const logIf: Record<keyof Logger, (condition: boolean, ...args: ReadonlyArray<any>) => void>; | ||
export declare function askQuestion(questionToAsk: string, timeoutMs?: number): Promise<string>; | ||
@@ -32,1 +44,2 @@ export declare function askQuestionUntilConditionMet({ questionToAsk, conditionCallback, invalidInputMessage, tryCountMax, timeoutMs, }: { | ||
}): Promise<string>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.askQuestionUntilConditionMet = exports.askQuestion = exports.logIf = exports.log = exports.LogType = exports.logColors = exports.ColorKey = void 0; | ||
exports.askQuestionUntilConditionMet = exports.askQuestion = exports.logIf = exports.log = exports.createLogger = exports.LogOutputType = exports.toLogString = exports.logColors = exports.ColorKey = void 0; | ||
const common_1 = require("@augment-vir/common"); | ||
@@ -29,3 +29,3 @@ const ansi_colors_1 = require("ansi-colors"); | ||
}; | ||
function toLoggingString({ colors, args }) { | ||
function toLogString({ colors, args }) { | ||
const colorKeysArray = Array.isArray(colors) ? colors : [colors]; | ||
@@ -44,67 +44,69 @@ return (colorKeysArray.map((colorKey) => exports.logColors[colorKey]).join('') + | ||
} | ||
function writeLog(inputs) { | ||
process[inputs.logType].write(toLoggingString(inputs)); | ||
exports.toLogString = toLogString; | ||
var LogOutputType; | ||
(function (LogOutputType) { | ||
LogOutputType["standard"] = "stdout"; | ||
LogOutputType["error"] = "stderr"; | ||
})(LogOutputType || (exports.LogOutputType = LogOutputType = {})); | ||
function createLogger(logWriters) { | ||
function writeLog(inputs) { | ||
logWriters[inputs.logType].write(toLogString(inputs)); | ||
} | ||
const logger = { | ||
info(...args) { | ||
writeLog({ | ||
logType: LogOutputType.standard, | ||
colors: ColorKey.info, | ||
args, | ||
}); | ||
}, | ||
error(...args) { | ||
writeLog({ | ||
logType: LogOutputType.error, | ||
colors: [ | ||
ColorKey.error, | ||
ColorKey.bold, | ||
], | ||
args, | ||
}); | ||
}, | ||
bold(...args) { | ||
writeLog({ | ||
logType: LogOutputType.standard, | ||
colors: ColorKey.bold, | ||
args, | ||
}); | ||
}, | ||
mutate(...args) { | ||
writeLog({ | ||
logType: LogOutputType.standard, | ||
colors: [ | ||
ColorKey.bold, | ||
ColorKey.mutate, | ||
], | ||
args, | ||
}); | ||
}, | ||
faint(...args) { | ||
writeLog({ | ||
logType: LogOutputType.standard, | ||
colors: ColorKey.faint, | ||
args, | ||
}); | ||
}, | ||
success(...args) { | ||
writeLog({ | ||
logType: LogOutputType.standard, | ||
colors: [ | ||
ColorKey.bold, | ||
ColorKey.success, | ||
], | ||
args, | ||
}); | ||
}, | ||
}; | ||
return logger; | ||
} | ||
var LogType; | ||
(function (LogType) { | ||
LogType["info"] = "info"; | ||
LogType["error"] = "error"; | ||
LogType["bold"] = "bold"; | ||
LogType["mutate"] = "mutate"; | ||
LogType["faint"] = "faint"; | ||
LogType["success"] = "success"; | ||
})(LogType || (exports.LogType = LogType = {})); | ||
exports.log = { | ||
[LogType.info]: (...args) => { | ||
writeLog({ | ||
logType: 'stdout', | ||
colors: ColorKey.info, | ||
args, | ||
}); | ||
}, | ||
[LogType.error]: (...args) => { | ||
writeLog({ | ||
logType: 'stderr', | ||
colors: [ | ||
ColorKey.error, | ||
ColorKey.bold, | ||
], | ||
args, | ||
}); | ||
}, | ||
[LogType.bold]: (...args) => { | ||
writeLog({ | ||
logType: 'stdout', | ||
colors: ColorKey.bold, | ||
args, | ||
}); | ||
}, | ||
[LogType.mutate]: (...args) => { | ||
writeLog({ | ||
logType: 'stdout', | ||
colors: [ | ||
ColorKey.bold, | ||
ColorKey.mutate, | ||
], | ||
args, | ||
}); | ||
}, | ||
[LogType.faint]: (...args) => { | ||
writeLog({ | ||
logType: 'stdout', | ||
colors: ColorKey.faint, | ||
args, | ||
}); | ||
}, | ||
[LogType.success]: (...args) => { | ||
writeLog({ | ||
logType: 'stdout', | ||
colors: [ | ||
ColorKey.bold, | ||
ColorKey.success, | ||
], | ||
args, | ||
}); | ||
}, | ||
}; | ||
exports.createLogger = createLogger; | ||
exports.log = createLogger(process); | ||
exports.logIf = (0, common_1.mapObjectValues)(exports.log, (key) => { | ||
@@ -111,0 +113,0 @@ return (condition, ...args) => { |
{ | ||
"name": "@augment-vir/node-js", | ||
"version": "15.3.0", | ||
"version": "15.4.0", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/node-js", | ||
@@ -25,3 +25,3 @@ "bugs": { | ||
"dependencies": { | ||
"@augment-vir/common": "^15.3.0", | ||
"@augment-vir/common": "^15.4.0", | ||
"ansi-colors": "^4.1.3", | ||
@@ -31,6 +31,6 @@ "axios": "^1.4.0", | ||
"ts-node": "^10.9.1", | ||
"type-fest": "^3.12.0" | ||
"type-fest": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@augment-vir/chai": "^15.3.0", | ||
"@augment-vir/chai": "^15.4.0", | ||
"@electrovir/nyc": "^15.1.0-fix0", | ||
@@ -41,3 +41,3 @@ "@istanbuljs/nyc-config-typescript": "^1.0.2", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.3.1", | ||
"@types/node": "^20.4.2", | ||
"chai": "^4.3.7", | ||
@@ -48,3 +48,3 @@ "istanbul-smart-text-reporter": "^1.1.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.3" | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -51,0 +51,0 @@ "publishConfig": { |
37231
848
- Removedtype-fest@3.13.1(transitive)
Updated@augment-vir/common@^15.4.0
Updatedtype-fest@^4.0.0