Skip to content

Commit

Permalink
Merge pull request #4 from HeesuKim0203/release/package
Browse files Browse the repository at this point in the history
Release/package
  • Loading branch information
HeesuKim0203 authored Jan 24, 2024
2 parents 98242c4 + f357e67 commit 7fdd2a8
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 102 deletions.
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
# Better Console
# Vivid Console

## Purpose

Better Console is an ideal tool for those who want to add a splash of color to their console outputs. It enables styling in both Terminal and Web Console environments, making your logs more visually appealing and easier to read.
Vivid Console is an ideal tool for those who want to add a splash of color to their console outputs. It enables styling in both Terminal and Web Console environments, making your logs more visually appealing and easier to read.

## Features
1. Supports ESM, CommonJS, and browser environments.
2. Wide range of colors and backgrounds, customizable for diverse needs.
3. Built-in TypeScript type support for a better development experience.
3. Built-in TypeScript type support for a CC development experience.

## Example

### Terminal
![console](/scripts/public/tsTest.png)

### Web console
![web conosle](/scripts/public/webConsoleTest.png)
![webconosle](/scripts/public/webConsoleTest.PNG)


## Getting Started
To start using Better Console, install the package using npm
To start using Vivid Console, install the package using npm

```bash
npm install better-console
npm install vivid-console
```

This library is compatible with various environments including JavaScript, TypeScript, and browsers, supporting both ES5 and ES6 standards.

### Font Color
```javascript
console.log(CC.color.red("test"))
console.log(VC.color.red("test"))
```

### Background Color
```javascript
console.log(CC.bg.red("test"))
console.log(VC.bg.red("test"))
```

### Font Style
```javascript
console.log(CC.bold("test"))
console.log(VC.bold("test"))
```

### Custom color
You can enter the number of the color you want to use as the first argument.
![](/scripts/public/customColor.png)
```javascript
console.log(CC.colorCustom(146, "test"))
console.log(VC.colorCustom(146, "test"))
```
```javascript
console.log(CC.bgCustom(146, "test"))
console.log(VC.bgCustom(146, "test"))
```

### Custom web console color
For the web, enter css! Some unsupported css.
```javascript
CC.console("color : #999999 ; background : #000000 ;", "test")
VC.console("color : #999999 ; background : #000000 ;", "test")
```

### ES5 Usage
```javascript
var CC = require('better-console');
var VC = require('vivid-console');

console.log("This is a common log");
console.log(CC.bgCustom(146, "Custom background"));
console.log(CC.colorCustom(142, "Custom color"));
console.log(CC.color.red("Red text"));
console.log(CC.bold("Bold text"));
console.log(VC.bgCustom(146, "Custom background"));
console.log(VC.colorCustom(142, "Custom color"));
console.log(VC.color.red("Red text"));
console.log(VC.bold("Bold text"));
```

### ES6 Usage
```typescript
import CC from 'better-console';
import VC from 'vivid-console';

console.log("This is a common log");
console.log(CC.bgCustom(146, "Custom background"));
console.log(CC.colorCustom(142, "Custom color"));
console.log(CC.color.red("Red text"));
console.log(CC.bold("Bold text"));
console.log(VC.bgCustom(146, "Custom background"));
console.log(VC.colorCustom(142, "Custom color"));
console.log(VC.color.red("Red text"));
console.log(VC.bold("Bold text"));
```

### Browser Usage Example
```html
<script src="your-path/better-console/dist/index.bundle.js"></script>
<script src="your-path/vivid-console/dist/index.bundle.js"></script>
<script>
console.log("This is a common log");
console.log(CC.bgCustom(146, "Custom background"));
console.log(CC.colorCustom(142, "Custom color"));
console.log(CC.color.red("Red text"));
console.log(CC.bold("Bold text"));
console.log(VC.bgCustom(146, "Custom background"));
console.log(VC.colorCustom(142, "Custom color"));
console.log(VC.color.red("Red text"));
console.log(VC.bold("Bold text"));
</script>
```

Expand Down
Binary file removed better-console-1.0.0.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions lib/cjs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BCType } from './type';
declare const BC: BCType;
export default BC;
import type { VCType } from './type';
declare const VC: VCType;
export default VC;
//# sourceMappingURL=index.d.ts.map
12 changes: 6 additions & 6 deletions lib/cjs/types/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { baseColors, baseStyles } from './data';
export type BCMethod = (text: string) => string;
export type VCMethod = (text: string) => string;
export type CustomMethod = (num: number, text: string) => string;
export type WebConsoleCustomMethod = (style: string, text: string) => void;
type ListToObject<T extends readonly string[]> = {
[P in T[number]]: BCMethod;
[P in T[number]]: VCMethod;
};
export type ColorType = ListToObject<typeof baseColors>;
export type BCFontStyleType = ListToObject<typeof baseStyles>;
export type BCType = {
[K in keyof BCFontStyleType]: BCFontStyleType[K];
export type VCFontStyleType = ListToObject<typeof baseStyles>;
export type VCType = {
[K in keyof VCFontStyleType]: VCFontStyleType[K];
} & {
color: ColorType;
bg: ColorType;
colorCustom: CustomMethod;
bgCustom: CustomMethod;
console: WebConsoleCustomMethod;
reset: BCMethod;
reset: VCMethod;
};
export {};
//# sourceMappingURL=type.d.ts.map
6 changes: 3 additions & 3 deletions lib/esm/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BCType } from './type';
declare const BC: BCType;
export default BC;
import type { VCType } from './type';
declare const VC: VCType;
export default VC;
//# sourceMappingURL=index.d.ts.map
12 changes: 6 additions & 6 deletions lib/esm/types/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { baseColors, baseStyles } from './data';
export type BCMethod = (text: string) => string;
export type VCMethod = (text: string) => string;
export type CustomMethod = (num: number, text: string) => string;
export type WebConsoleCustomMethod = (style: string, text: string) => void;
type ListToObject<T extends readonly string[]> = {
[P in T[number]]: BCMethod;
[P in T[number]]: VCMethod;
};
export type ColorType = ListToObject<typeof baseColors>;
export type BCFontStyleType = ListToObject<typeof baseStyles>;
export type BCType = {
[K in keyof BCFontStyleType]: BCFontStyleType[K];
export type VCFontStyleType = ListToObject<typeof baseStyles>;
export type VCType = {
[K in keyof VCFontStyleType]: VCFontStyleType[K];
} & {
color: ColorType;
bg: ColorType;
colorCustom: CustomMethod;
bgCustom: CustomMethod;
console: WebConsoleCustomMethod;
reset: BCMethod;
reset: VCMethod;
};
export {};
//# sourceMappingURL=type.d.ts.map
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "better-console",
"name": "vivid-console",
"version": "1.0.0",
"description": "The aim of this project is to enable developers to rapidly and efficiently deploy NPM public packages. This template is designed to allow users to create, manage, and distribute their NPM packages with minimal setup.",
"types": "./lib/cjs/types/index.d.ts",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"browser": {
"better-console": "./dist/index.bundle.js"
"vivid-console": "./dist/index.bundle.js"
},
"scripts": {
"test": "ts-node ./scripts/test.ts && node ./scripts/test.js",
Expand Down Expand Up @@ -45,9 +45,9 @@
},
"repository": {
"type": "git",
"url": "https://github.com/HeesuKim0203/better-console.git"
"url": "https://github.com/HeesuKim0203/vivid-console.git"
},
"dependencies": {
"better-console": "file:better-console-1.0.0.tgz"
"vivid-console": "file:vivid-console-1.0.0.tgz"
}
}
18 changes: 9 additions & 9 deletions scripts/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
</head>
<body>
</body>
<script src="../node_modules/better-console/dist/index.bundle.js"></script>
<script src="../node_modules/vivid-console/dist/index.bundle.js"></script>
<script>

const colorKeys = Object.keys(CC.color)
const colorKeys = Object.keys(VC.color)
for (const key of colorKeys) {
const method = CC.color[key]
const method = VC.color[key]
if (typeof method === 'function') {
console.log(method("test"))
}
}

const bgKeys = Object.keys(CC.bg)
const bgKeys = Object.keys(VC.bg)
for (const key of bgKeys) {
const method = CC.bg[key];
const method = VC.bg[key];
if (typeof method === 'function') {
console.log(method("test"))
}
}

console.log(CC.bold("test"))
console.log(CC.underline("test"))
console.log(CC.italic("test"))
console.log(VC.bold("test"))
console.log(VC.underline("test"))
console.log(VC.italic("test"))

CC.console("color : #999999 ; background : #000000 ;", "test")
VC.console("color : #999999 ; background : #000000 ;", "test")

</script>
</html>
19 changes: 9 additions & 10 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
const CC = require('better-console')

const VC = require('vivid-console')

console.log("common log")

console.log(CC.bgCustom(146, "test"))
console.log(CC.colorCustom(142, "test"))
console.log(VC.bgCustom(146, "test"))
console.log(VC.colorCustom(142, "test"))

console.log(CC.color.red(CC.bgCustom(146, "test")))
console.log(CC.bold(CC.colorCustom(188, "test")))
console.log(VC.color.red(VC.bgCustom(146, "test")))
console.log(VC.bold(VC.colorCustom(188, "test")))

const colorKeys = Object.keys(CC.color)
const colorKeys = Object.keys(VC.color)
for (const key of colorKeys) {
const method = CC.color[key]
const method = VC.color[key]
if (typeof method === 'function') {
console.log(method("test"))
}
}

const bgKeys = Object.keys(CC.bg)
const bgKeys = Object.keys(VC.bg)
for (const key of bgKeys) {
const method = CC.bg[key];
const method = VC.bg[key];
if (typeof method === 'function') {
console.log(method("test"))
}
Expand Down
24 changes: 12 additions & 12 deletions scripts/test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import CC from 'better-console'
import VC from 'vivid-console'
import { baseStyles } from '../src/data'
import type { BCFontStyleType, ColorType } from '../src/type'
import type { VCFontStyleType, ColorType } from '../src/type'

console.log("common log")

console.log(CC.bgCustom(146, "test"))
console.log(CC.colorCustom(142, "test"))
console.log(VC.bgCustom(146, "test"))
console.log(VC.colorCustom(142, "test"))

console.log(CC.color.red(CC.bgCustom(146, "test")))
console.log(CC.bold(CC.colorCustom(188, "test")))
console.log(VC.color.red(VC.bgCustom(146, "test")))
console.log(VC.bold(VC.colorCustom(188, "test")))

const colorKeys = Object.keys(CC.color) as Array<keyof ColorType>
const colorKeys = Object.keys(VC.color) as Array<keyof ColorType>
for (const key of colorKeys) {
const method = CC.color[key]
const method = VC.color[key]
if (typeof method === 'function') {
console.log(method("test"))
}
}

const bgKeys = Object.keys(CC.bg) as Array<keyof ColorType>
const bgKeys = Object.keys(VC.bg) as Array<keyof ColorType>
for (const key of bgKeys) {
const method = CC.bg[key];
const method = VC.bg[key];
if (typeof method === 'function') {
console.log(method("test"))
}
}

const fontStyleKeys = Object.keys(CC) as Array<keyof BCFontStyleType>
const fontStyleKeys = Object.keys(VC) as Array<keyof VCFontStyleType>
for (const key of fontStyleKeys) {
const method = CC[key]
const method = VC[key]
if (typeof method === 'function' && baseStyles.includes(key)) {
console.log(method("test"))
}
Expand Down
Loading

0 comments on commit 7fdd2a8

Please sign in to comment.