Comparing version 3.0.3 to 3.0.4
@@ -0,1 +1,8 @@ | ||
## [3.0.4](https://github.com/ivangabriele/bhala/compare/v3.0.3...v3.0.4) (2022-02-15) | ||
### Bug Fixes | ||
* remove node builtin import ([6a93b2b](https://github.com/ivangabriele/bhala/commit/6a93b2b9ed452e2ee9732c36bf0a6bf0cc226bf8)) | ||
## [3.0.3](https://github.com/ivangabriele/bhala/compare/v3.0.2...v3.0.3) (2022-02-15) | ||
@@ -2,0 +9,0 @@ |
@@ -13,3 +13,2 @@ import * as T from './types'; | ||
private generateOutput; | ||
private isCmd; | ||
private isCi; | ||
@@ -16,0 +15,0 @@ } |
@@ -1,7 +0,179 @@ | ||
import childProcess from 'child_process'; | ||
import { cyan, gray, green, magenta, red, white, yellow } from 'colorette'; | ||
import os from 'os'; | ||
// MIT lisence | ||
// from https://github.com/substack/tty-browserify/blob/1ba769a6429d242f36226538835b4034bf6b7886/index.js | ||
function isatty() { | ||
return false; | ||
} | ||
function ReadStream() { | ||
throw new Error('tty.ReadStream is not implemented'); | ||
} | ||
function WriteStream() { | ||
throw new Error('tty.ReadStream is not implemented'); | ||
} | ||
var tty = { | ||
isatty: isatty, | ||
ReadStream: ReadStream, | ||
WriteStream: WriteStream | ||
}; | ||
var tty$1 = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
isatty: isatty, | ||
ReadStream: ReadStream, | ||
WriteStream: WriteStream, | ||
'default': tty | ||
}); | ||
const env = process.env || {}; | ||
const argv = process.argv || []; | ||
const isDisabled = "NO_COLOR" in env || argv.includes("--no-color"); | ||
const isForced = "FORCE_COLOR" in env || argv.includes("--color"); | ||
const isWindows = process.platform === "win32"; | ||
const isCompatibleTerminal = | ||
tty$1 && isatty && isatty() && env.TERM && env.TERM !== "dumb"; | ||
const isCI = | ||
"CI" in env && | ||
("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env); | ||
const isColorSupported = | ||
!isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI); | ||
const replaceClose = ( | ||
index, | ||
string, | ||
close, | ||
replace, | ||
head = string.substring(0, index) + replace, | ||
tail = string.substring(index + close.length), | ||
next = tail.indexOf(close) | ||
) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace)); | ||
const clearBleed = (index, string, open, close, replace) => | ||
index < 0 | ||
? open + string + close | ||
: open + replaceClose(index, string, close, replace) + close; | ||
const filterEmpty = | ||
(open, close, replace = open, at = open.length + 1) => | ||
(string) => | ||
string || !(string === "" || string === undefined) | ||
? clearBleed( | ||
("" + string).indexOf(close, at), | ||
string, | ||
open, | ||
close, | ||
replace | ||
) | ||
: ""; | ||
const init = (open, close, replace) => | ||
filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace); | ||
const colors = { | ||
reset: init(0, 0), | ||
bold: init(1, 22, "\x1b[22m\x1b[1m"), | ||
dim: init(2, 22, "\x1b[22m\x1b[2m"), | ||
italic: init(3, 23), | ||
underline: init(4, 24), | ||
inverse: init(7, 27), | ||
hidden: init(8, 28), | ||
strikethrough: init(9, 29), | ||
black: init(30, 39), | ||
red: init(31, 39), | ||
green: init(32, 39), | ||
yellow: init(33, 39), | ||
blue: init(34, 39), | ||
magenta: init(35, 39), | ||
cyan: init(36, 39), | ||
white: init(37, 39), | ||
gray: init(90, 39), | ||
bgBlack: init(40, 49), | ||
bgRed: init(41, 49), | ||
bgGreen: init(42, 49), | ||
bgYellow: init(43, 49), | ||
bgBlue: init(44, 49), | ||
bgMagenta: init(45, 49), | ||
bgCyan: init(46, 49), | ||
bgWhite: init(47, 49), | ||
blackBright: init(90, 39), | ||
redBright: init(91, 39), | ||
greenBright: init(92, 39), | ||
yellowBright: init(93, 39), | ||
blueBright: init(94, 39), | ||
magentaBright: init(95, 39), | ||
cyanBright: init(96, 39), | ||
whiteBright: init(97, 39), | ||
bgBlackBright: init(100, 49), | ||
bgRedBright: init(101, 49), | ||
bgGreenBright: init(102, 49), | ||
bgYellowBright: init(103, 49), | ||
bgBlueBright: init(104, 49), | ||
bgMagentaBright: init(105, 49), | ||
bgCyanBright: init(106, 49), | ||
bgWhiteBright: init(107, 49), | ||
}; | ||
const none = (any) => any; | ||
const createColors = ({ useColor = isColorSupported } = {}) => | ||
useColor | ||
? colors | ||
: Object.keys(colors).reduce( | ||
(colors, key) => ({ ...colors, [key]: none }), | ||
{} | ||
); | ||
const { | ||
reset, | ||
bold, | ||
dim, | ||
italic, | ||
underline, | ||
inverse, | ||
hidden, | ||
strikethrough, | ||
black, | ||
red, | ||
green, | ||
yellow, | ||
blue, | ||
magenta, | ||
cyan, | ||
white, | ||
gray, | ||
bgBlack, | ||
bgRed, | ||
bgGreen, | ||
bgYellow, | ||
bgBlue, | ||
bgMagenta, | ||
bgCyan, | ||
bgWhite, | ||
blackBright, | ||
redBright, | ||
greenBright, | ||
yellowBright, | ||
blueBright, | ||
magentaBright, | ||
cyanBright, | ||
whiteBright, | ||
bgBlackBright, | ||
bgRedBright, | ||
bgGreenBright, | ||
bgYellowBright, | ||
bgBlueBright, | ||
bgMagentaBright, | ||
bgCyanBright, | ||
bgWhiteBright, | ||
} = createColors(); | ||
class Bhala { | ||
constructor() { | ||
this.canEmoji = !this.isCmd() && !this.isCi(); | ||
this.canEmoji = !this.isCi(); | ||
} | ||
@@ -53,20 +225,2 @@ debug(...messages) { | ||
} | ||
isCmd() { | ||
if (typeof window !== undefined) { | ||
return false; | ||
} | ||
if (os.platform() !== 'win32') { | ||
return false; | ||
} | ||
try { | ||
const result = childProcess.spawnSync(`ls`, { | ||
env: process.env, | ||
stdio: 'pipe', | ||
}); | ||
return result.error !== undefined; | ||
} | ||
catch (err) { | ||
return true; | ||
} | ||
} | ||
isCi() { | ||
@@ -77,2 +231,3 @@ return typeof process !== undefined && typeof process.env !== undefined && process.env.CI !== undefined; | ||
const B = new Bhala(); | ||
export { B }; |
{ | ||
"name": "bhala", | ||
"description": "A pretty (!), powerful and customizable logging library for Node.js.", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "type": "module", | ||
"scripts": { | ||
"build": "rm -Rf ./dist && tsc", | ||
"build": "rm -Rf ./dist && rollup -c", | ||
"build:watch": "tsc-watch", | ||
@@ -25,5 +25,2 @@ "dev": "yarn build && concurrently \"yarn build:watch\" \"yarn dev:simulate\"", | ||
}, | ||
"dependencies": { | ||
"colorette": "2.0.16" | ||
}, | ||
"devDependencies": { | ||
@@ -36,5 +33,8 @@ "@commitlint/cli": "16.1.0", | ||
"@ivangabriele/semantic-release-config-base": "2.0.2", | ||
"@rollup/plugin-node-resolve": "13.1.3", | ||
"@rollup/plugin-typescript": "8.3.0", | ||
"@types/node": "16.11.24", | ||
"@typescript-eslint/eslint-plugin": "5.10.0", | ||
"@typescript-eslint/parser": "5.10.0", | ||
"colorette": "2.0.16", | ||
"concurrently": "7.0.0", | ||
@@ -55,2 +55,4 @@ "eslint": "7.32.0", | ||
"prettier": "2.5.1", | ||
"rollup": "2.67.2", | ||
"rollup-plugin-node-builtins": "2.1.2", | ||
"tsc-watch": "4.6.0", | ||
@@ -57,0 +59,0 @@ "typescript": "4.4.4", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
13664
0
239
0
0
32
7
- Removedcolorette@2.0.16
- Removedcolorette@2.0.16(transitive)