Comparing version 1.0.0-alpha.1 to 2.0.0-alpha.0
@@ -1,8 +0,7 @@ | ||
import EMOJIS from './constants/emojis' | ||
import SYMBOLS from './constants/symbols' | ||
import emoji from 'node-emoji' | ||
declare const Bahle: Bahle.Bahle | ||
declare const Bhala: Bhala.Bhala | ||
// eslint-disable-next-line @typescript-eslint/no-redeclare | ||
declare namespace Bahle { | ||
declare namespace Bhala { | ||
export type OutputOptions = { | ||
@@ -12,23 +11,15 @@ isColorless?: boolean | ||
export interface Bahle { | ||
EMO: typeof EMOJIS | ||
SYM: typeof SYMBOLS | ||
export interface Bhala { | ||
EMO: typeof emoji.emoji | ||
debug(message: string, icon?: string, options?: OutputOptions): void | ||
debug(message: string, options?: OutputOptions): void | ||
error(message: string, icon?: string, options?: OutputOptions): void | ||
error(message: string, options?: OutputOptions): void | ||
info(message: string, icon?: string, options?: OutputOptions): void | ||
info(message: string, options?: OutputOptions): void | ||
log(message: string, icon?: string, options?: OutputOptions): void | ||
log(message: string, options?: OutputOptions): void | ||
warn(message: string, icon?: string, options?: OutputOptions): void | ||
warn(message: string, options?: OutputOptions): void | ||
debug(...messages: string[]): void | ||
error(...messages: string[]): void | ||
event(...messages: string[]): void | ||
info(...messages: string[]): void | ||
log(...messages: string[]): void | ||
success(...messages: string[]): void | ||
warn(...messages: string[]): void | ||
} | ||
} | ||
export = Bahle | ||
export = Bhala |
@@ -7,48 +7,66 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const emojis_1 = __importDefault(require("./constants/emojis")); | ||
const symbols_1 = __importDefault(require("./constants/symbols")); | ||
class Bahle { | ||
constructor(EMO = emojis_1.default, SYM = symbols_1.default) { | ||
const child_process_1 = require("child_process"); | ||
const node_emoji_1 = __importDefault(require("node-emoji")); | ||
const os_1 = __importDefault(require("os")); | ||
class Bhala { | ||
constructor(EMO = node_emoji_1.default.emoji) { | ||
this.EMO = EMO; | ||
this.SYM = SYM; | ||
this.canEmoji = !this.isCmd() && process.env.CI === undefined; | ||
} | ||
generateOutput(message, args, colorize) { | ||
if (message === undefined) | ||
return undefined; | ||
const input = `${message}`; | ||
generateOutput(messages, defaultColorizer, defaultPrefixIcon, defaultPrefixText) { | ||
if (!Array.isArray(messages) || messages.length === 0) { | ||
return ''; | ||
} | ||
const outputChunks = []; | ||
const maybeIcon = args[0]; | ||
const hasIcon = maybeIcon !== undefined && typeof maybeIcon === 'string' && maybeIcon.length > 0; | ||
if (hasIcon) { | ||
const coloredIcon = colorize(maybeIcon); | ||
outputChunks.push(coloredIcon); | ||
} | ||
const coloredInput = colorize(`${input}`); | ||
outputChunks.push(coloredInput); | ||
outputChunks.push(this.canEmoji ? defaultPrefixIcon : defaultColorizer(defaultPrefixText)); | ||
outputChunks.push(...(this.canEmoji ? messages.map(message => defaultColorizer(`${message}`)) : messages)); | ||
const output = outputChunks.join(` `); | ||
return output; | ||
} | ||
debug(message, ...args) { | ||
const output = this.generateOutput(message, args, chalk_1.default.gray); | ||
isCmd() { | ||
if (os_1.default.platform() !== 'win32') { | ||
return false; | ||
} | ||
try { | ||
const result = (0, child_process_1.spawnSync)(`ls`, { | ||
env: process.env, | ||
stdio: 'pipe', | ||
}); | ||
return result.error !== undefined; | ||
} | ||
catch (err) { | ||
return true; | ||
} | ||
} | ||
debug(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.gray, this.EMO.pushpin, 'debug -'); | ||
console.debug(output); | ||
} | ||
error(message, ...args) { | ||
const output = this.generateOutput(message, args, chalk_1.default.red); | ||
error(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.red, this.EMO.x, 'error -'); | ||
console.error(output); | ||
} | ||
info(message, ...args) { | ||
const output = this.generateOutput(message, args, chalk_1.default.blue); | ||
event(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.magenta, this.EMO.calendar, 'event -'); | ||
console.log(output); | ||
} | ||
info(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.cyan, this.EMO.information_source, 'info -'); | ||
console.info(output); | ||
} | ||
log(message, ...args) { | ||
const output = this.generateOutput(message, args, chalk_1.default.green); | ||
log(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.white, this.EMO.memo, 'log -'); | ||
console.log(output); | ||
} | ||
warn(message, ...args) { | ||
const output = this.generateOutput(message, args, chalk_1.default.yellow); | ||
success(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.green, this.EMO.heavy_check_mark, 'success -'); | ||
console.log(output); | ||
} | ||
warn(...messages) { | ||
const output = this.generateOutput(messages, chalk_1.default.yellow, this.EMO.warning, 'warning -'); | ||
console.warn(output); | ||
} | ||
} | ||
const bhala = new Bahle(); | ||
const bhala = new Bhala(); | ||
exports.default = bhala; | ||
module.exports = bhala; |
@@ -1,23 +0,18 @@ | ||
import EMOJIS from './constants/emojis'; | ||
import SYMBOLS from './constants/symbols'; | ||
declare const Bahle: Bahle.Bahle; | ||
declare namespace Bahle { | ||
import emoji from 'node-emoji'; | ||
declare const Bhala: Bhala.Bhala; | ||
declare namespace Bhala { | ||
type OutputOptions = { | ||
isColorless?: boolean; | ||
}; | ||
interface Bahle { | ||
EMO: typeof EMOJIS; | ||
SYM: typeof SYMBOLS; | ||
debug(message: string, icon?: string, options?: OutputOptions): void; | ||
debug(message: string, options?: OutputOptions): void; | ||
error(message: string, icon?: string, options?: OutputOptions): void; | ||
error(message: string, options?: OutputOptions): void; | ||
info(message: string, icon?: string, options?: OutputOptions): void; | ||
info(message: string, options?: OutputOptions): void; | ||
log(message: string, icon?: string, options?: OutputOptions): void; | ||
log(message: string, options?: OutputOptions): void; | ||
warn(message: string, icon?: string, options?: OutputOptions): void; | ||
warn(message: string, options?: OutputOptions): void; | ||
interface Bhala { | ||
EMO: typeof emoji.emoji; | ||
debug(...messages: string[]): void; | ||
error(...messages: string[]): void; | ||
event(...messages: string[]): void; | ||
info(...messages: string[]): void; | ||
log(...messages: string[]): void; | ||
success(...messages: string[]): void; | ||
warn(...messages: string[]): void; | ||
} | ||
} | ||
export = Bahle; | ||
export = Bhala; |
@@ -0,1 +1,2 @@ | ||
import emoji from 'node-emoji'; | ||
export declare type OutputOptions = { | ||
@@ -5,12 +6,10 @@ isColorless?: boolean; | ||
export interface Bhala { | ||
debug(message: string, icon?: string, options?: OutputOptions): void; | ||
debug(message: string, options?: OutputOptions): void; | ||
error(message: string, icon?: string, options?: OutputOptions): void; | ||
error(message: string, options?: OutputOptions): void; | ||
info(message: string, icon?: string, options?: OutputOptions): void; | ||
info(message: string, options?: OutputOptions): void; | ||
log(message: string, icon?: string, options?: OutputOptions): void; | ||
log(message: string, options?: OutputOptions): void; | ||
warn(message: string, icon?: string, options?: OutputOptions): void; | ||
warn(message: string, options?: OutputOptions): void; | ||
EMO: typeof emoji.emoji; | ||
debug(...messages: string[]): void; | ||
error(...messages: string[]): void; | ||
event(...messages: string[]): void; | ||
info(...messages: string[]): void; | ||
log(...messages: string[]): void; | ||
success(...messages: string[]): void; | ||
warn(...messages: string[]): void; | ||
} |
{ | ||
"name": "bhala", | ||
"version": "1.0.0-alpha.1", | ||
"version": "2.0.0-alpha.0", | ||
"license": "MIT", | ||
@@ -15,7 +15,8 @@ "description": "A pretty (!), powerful and customizable logging library for Node.js.", | ||
"scripts": { | ||
"build": "npm run clean && tsc && cpy --rename=index.d.ts ./src/declaration.ts ./dist && del-cli ./dist/declaration.js", | ||
"clean": "del-cli ./dist", | ||
"dev": "npm run build && wait-on ./dist/index.js && concurrently \"npm:dev:watch\" \"npm:dev:simulate\"", | ||
"build": "npm run clean && tsc && cp ./src/declaration.ts ./dist/index.d.ts && rm ./dist/declaration.js", | ||
"clean": "rm -Rf ./dist", | ||
"clean:dev": "rimraf ./dist", | ||
"dev": "concurrently \"npm:dev:watch\" \"npm:dev:simulate\"", | ||
"dev:simulate": "nodemon --watch ./dist --watch ./examples/demo.js ./examples/demo.js", | ||
"dev:watch": "tsc -p ./tsconfig.dev.json -w", | ||
"dev:watch": "tsc -w", | ||
"test": "npm run test:lint", | ||
@@ -27,15 +28,18 @@ "test:lint": "eslint . --ext .js,.ts", | ||
"dependencies": { | ||
"chalk": "4.1.2" | ||
"chalk": "4.1.2", | ||
"node-emoji": "1.11.0" | ||
}, | ||
"devDependencies": { | ||
"@ivangabriele/eslint-config-typescript-base": "1.3.0", | ||
"@ivangabriele/eslint-config-typescript-base": "1.5.0", | ||
"@ivangabriele/prettier-config": "1.1.0", | ||
"@types/node": "14.17.11", | ||
"concurrently": "6.2.1", | ||
"cpy-cli": "3.1.1", | ||
"del-cli": "4.0.1", | ||
"jest": "27.0.6", | ||
"nodemon": "2.0.12", | ||
"@types/node": "14.17.29", | ||
"@types/node-emoji": "1.8.1", | ||
"@types/prettier": "2.4.1", | ||
"@types/shelljs": "0.8.9", | ||
"concurrently": "6.3.0", | ||
"jest": "27.3.1", | ||
"nodemon": "2.0.14", | ||
"rimraf": "3.0.2", | ||
"shelljs": "0.8.4", | ||
"typescript": "4.3.5", | ||
"typescript": "4.4.4", | ||
"wait-on": "6.0.0" | ||
@@ -42,0 +46,0 @@ }, |
@@ -39,18 +39,29 @@ <p align="center"> | ||
- [Table of Contents](#table-of-contents) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Settings](#settings) | ||
- [API](#api) | ||
- [Contants](#contants) | ||
- [`EMO`](#emo) | ||
- [`SYM`](#sym) | ||
- [Methods](#methods) | ||
- [`debug()`](#debug) | ||
- [`error()`](#error) | ||
- [`event()`](#event) | ||
- [`info()`](#info) | ||
- [`log()`](#log) | ||
- [`success()`](#success) | ||
- [`warn()`](#warn) | ||
- [Options](#options) | ||
- [`OutputOptions`](#outputoptions) | ||
- [Name](#name) | ||
## Install | ||
```sh | ||
npm i -E bhala | ||
``` | ||
or: | ||
```sh | ||
yarn add -E bhala | ||
``` | ||
## Usage | ||
@@ -64,4 +75,9 @@ | ||
## Settings | ||
```js | ||
import ß from 'bhala'; | ||
ß.log('Here is a wonderful log.'); | ||
ß.event('Here is a wonderful event.'); | ||
``` | ||
## API | ||
@@ -73,13 +89,10 @@ | ||
#### `SYM` | ||
List of emoji keys that should named like you do in Markdown, i.e.: `computer` for `:computer:`. | ||
### Methods | ||
All method `options` can be customized globally | ||
#### `debug()` | ||
```ts | ||
ß.log(message: string, isColorless?: boolean, options) | ||
ß.log(message: string, icon?: string, isColorless?: boolean) | ||
ß.debug(...messages: string[]) | ||
``` | ||
@@ -90,42 +103,33 @@ | ||
```ts | ||
ß.log(message: string, isColorless?: boolean, options) | ||
ß.log(message: string, icon?: string, isColorless?: boolean) | ||
ß.error(...messages: string[]) | ||
``` | ||
#### `info()` | ||
#### `event()` | ||
```ts | ||
ß.log(message: string, isColorless?: boolean, options) | ||
ß.log(message: string, icon?: string, isColorless?: boolean) | ||
ß.event(...messages: string[]) | ||
``` | ||
#### `log()` | ||
#### `info()` | ||
```ts | ||
ß.log(message: string, isColorless?: boolean, options) | ||
ß.log(message: string, icon?: string, isColorless?: boolean) | ||
ß.warn(...messages: string[]) | ||
``` | ||
#### `warn()` | ||
#### `log()` | ||
```ts | ||
ß.log(message: string, options: OutputOptions) | ||
ß.log(message: string, icon?: string, isColorless?: boolean) | ||
ß.log(...messages: string[]) | ||
``` | ||
**Examples** | ||
#### `success()` | ||
```ts | ||
ß.log("Some") | ||
// Output: | ||
ß.success(...messages: string[]) | ||
``` | ||
### Options | ||
#### `warn()` | ||
#### `OutputOptions` | ||
```ts | ||
type OutputOptions = { | ||
isColorless?: boolean | ||
} | ||
ß.warn(...messages: string[]) | ||
``` | ||
@@ -132,0 +136,0 @@ |
Sorry, the diff of this file is too big to display
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
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
141
85342
2
13
9
2825
2
1
+ Addednode-emoji@1.11.0
+ Addedlodash@4.17.21(transitive)
+ Addednode-emoji@1.11.0(transitive)