25 Commits

Author SHA1 Message Date
19b620ef62 2.0.2 2024-03-13 20:02:13 +01:00
5e9bbfaf1b fix(core): update 2024-03-13 20:02:12 +01:00
3357ca8c2b switch to new org scheme 2023-07-10 02:41:08 +02:00
2db8bc4390 2.0.1 2018-07-18 00:13:40 +02:00
0818c877ab fix(ci): add build arguments within npmextra.json 2018-07-18 00:13:40 +02:00
85666f8883 2.0.0 2018-07-18 00:12:41 +02:00
6469012517 BREAKING CHANGE(package): change scope and name 2018-07-18 00:12:40 +02:00
faf3c840fa 1.0.11 2017-08-18 12:27:15 +02:00
32158d7969 fic dependencies 2017-08-18 12:27:13 +02:00
95c672f062 1.0.10 2017-08-16 12:14:54 +02:00
9043933be5 fix indention 2017-08-16 12:14:49 +02:00
166ae81795 update test 2017-08-16 10:49:38 +02:00
f16fe5a030 1.0.9 2017-08-16 10:47:22 +02:00
bbfabc7238 add npmextra.json 2017-08-16 10:47:18 +02:00
e293ae5cd9 1.0.8 2017-08-16 10:45:23 +02:00
233fd3f01a update to latest standards 2017-08-16 10:42:48 +02:00
801fd17c77 1.0.7 2017-02-05 21:15:55 +01:00
a5db5eb181 1.0.6 2017-02-05 21:00:38 +01:00
c59061a840 update README 2017-02-05 21:00:25 +01:00
b9c4626a30 1.0.5 2017-01-21 20:30:57 +01:00
aeac61774f improve colors 2017-01-21 20:30:53 +01:00
1d789532e3 1.0.4 2017-01-21 20:27:27 +01:00
ae6940bc31 improve colors 2017-01-21 20:27:25 +01:00
8b6e5211e0 1.0.3 2017-01-21 19:46:56 +01:00
fa09d9d8a2 switch to warmer colors 2017-01-21 19:46:51 +01:00
20 changed files with 6210 additions and 244 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

18
.gitignore vendored
View File

@ -1,6 +1,20 @@
node_modules
.nogit/
# artifacts
coverage/
pages/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,59 +1,142 @@
image: hosttoday/ht-docker-node:npmts
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- trigger
- pages
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci test legacy
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags:
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npmpage --publish gitlab
- npmci command npm install -g typedoc typescript
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,36 +0,0 @@
# beautycolor
colors for beautylog
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/beautycolor)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/beautycolor)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/beautycolor)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/beautycolor/)
## Status for master
[![build status](https://GitLab.com/pushrocks/beautycolor/badges/master/build.svg)](https://GitLab.com/pushrocks/beautycolor/commits/master)
[![coverage report](https://GitLab.com/pushrocks/beautycolor/badges/master/coverage.svg)](https://GitLab.com/pushrocks/beautycolor/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/beautycolor.svg)](https://www.npmjs.com/package/beautycolor)
[![Dependency Status](https://david-dm.org/pushrocks/beautycolor.svg)](https://david-dm.org/pushrocks/beautycolor)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/beautycolor/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/beautycolor/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/beautycolor/badges/code.svg)](https://www.bithound.io/github/pushrocks/beautycolor)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import * as beautycolor from 'beautycolor'
let myColoredString = beautycolor.coloredString(
'This string has a blue font and a green background',
'blue',
'green'
)
console.log(myColoredString)
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

14
dist/index.d.ts vendored
View File

@ -1,14 +0,0 @@
import 'typings-global';
/**
* all the color names that are available for proper xterm translation
*/
export declare type TColorName = 'black' | 'black' | 'blue' | 'brown' | 'cyan' | 'green' | 'orange' | 'pink' | 'red' | 'white';
export interface IRGB {
r: number;
b: number;
g: number;
}
/**
* color a string with xterm
*/
export declare let coloredString: (stringArg: string, colorFontArg: TColorName, colorBackgroundArg?: TColorName) => string;

56
dist/index.js vendored
View File

@ -1,56 +0,0 @@
"use strict";
require("typings-global");
const ansiColors = require("ansi-256-colors");
/**
* the color translator function
*/
let colorTranslator = (colorArg) => {
switch (colorArg) {
case 'black':
return { r: 0, g: 0, b: 0 };
case 'blue':
return { r: 0, g: 1, b: 5 };
case 'brown':
return { r: 1, g: 0, b: 0 };
case 'cyan':
return { r: 0, g: 4, b: 4 };
case 'green':
return { r: 2, g: 5, b: 0 };
case 'orange':
return { r: 5, g: 3, b: 0 };
case 'pink':
return { r: 5, g: 0, b: 5 };
case 'red':
return { r: 5, g: 0, b: 0 };
case 'white':
return { r: 5, g: 5, b: 5 };
default:
return { r: 5, g: 5, b: 5 };
}
};
/**
* colors the font of a string
*/
let coloredFont = (stringArg, colorArg) => {
let rgbCode = colorTranslator(colorArg);
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
};
/**
* colors the back of a string
*/
let coloredBackground = (stringArg, colorArg) => {
let rgbCode = colorTranslator(colorArg);
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
};
/**
* color a string with xterm
*/
exports.coloredString = (stringArg, colorFontArg, colorBackgroundArg) => {
let returnString = coloredFont(stringArg, colorFontArg);
if (colorBackgroundArg) {
returnString = coloredBackground(returnString, colorBackgroundArg);
}
returnString = returnString + ansiColors.reset;
return returnString;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQXNCN0M7O0dBRUc7QUFDSCxJQUFJLGVBQWUsR0FBRyxDQUFDLFFBQW9CO0lBQ3ZDLE1BQU0sQ0FBQyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDZixLQUFLLE9BQU87WUFDUixNQUFNLENBQUMsRUFBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBQyxDQUFBO1FBQzdCLEtBQUssTUFBTTtZQUNQLE1BQU0sQ0FBQyxFQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFDLENBQUE7UUFDN0IsS0FBSyxPQUFPO1lBQ1IsTUFBTSxDQUFDLEVBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFHLENBQUMsRUFBRSxDQUFDLEVBQUMsQ0FBQTtRQUM5QixLQUFLLE1BQU07WUFDUCxNQUFNLENBQUMsRUFBQyxDQUFDLEVBQUUsQ0FBQyxFQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBQyxDQUFBO1FBQzVCLEtBQUssT0FBTztZQUNSLE1BQU0sQ0FBQyxFQUFDL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BQU8sQ0FBQyxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUE7QUFDNUUsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDSCxJQUFJLGlCQUFpQixHQUFHLENBQUMsU0FBaUIsRUFBRSxRQUFvQjtJQUM1RCxJQUFJLE9BQU8sR0FBRyxlQUFlLENBQUMsUUFBUSxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsT0FBTyxDQUFDLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFBO0FBQzVFLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsQ0FBQyxTQUFpQixFQUFFLFlBQXdCLEVBQUUsa0JBQStCO0lBQ3BHLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxTQUFTLEVBQUUsWUFBWSxDQUFDLENBQUE7SUFDdkQsRUFBRSxDQUFDLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1FBQ3JCLFlBQVksR0FBRyxpQkFBaUIsQ0FBQyxZQUFZLEVBQUUsa0JBQWtCLENBQUMsQ0FBQTtJQUN0RSxDQUFDO0lBQ0QsWUFBWSxHQUFHLFlBQVksR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBIn0=

19
npmextra.json Normal file
View File

@ -0,0 +1,19 @@
{
"npmci": {
"npmGlobalTools": [
"@gitzone/npmts"
],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "consolecolor",
"description": "a simple module to deal with console colors",
"npmPackagename": "@push.rocks/consolecolor",
"license": "MIT"
}
}
}

View File

@ -1,15 +1,18 @@
{
"name": "beautycolor",
"version": "1.0.2",
"name": "@push.rocks/consolecolor",
"version": "2.0.2",
"private": false,
"description": "colors for beautylog",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/beautycolor.git"
"url": "git+https://gitlab.com/push.rocks/consolecolor.git"
},
"keywords": [
"color",
@ -20,15 +23,33 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/beautycolor/issues"
"url": "https://gitlab.com/push.rocks/consolecolor/issues"
},
"homepage": "https://gitlab.com/pushrocks/beautycolor#README",
"homepage": "https://gitlab.com/push.rocks/consolecolor#readme",
"dependencies": {
"ansi-256-colors": "^1.1.0",
"typings-global": "^1.0.14"
"ansi-256-colors": "^1.1.0"
},
"devDependencies": {
"smartchai": "^1.0.1",
"typings-test": "^1.0.3"
}
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsrun": "^1.1.9",
"@git.zone/tstest": "^1.0.88",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^10.5.2"
},
"type": "module",
"browserslist": [
"last 1 chrome versions"
],
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

5653
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

45
readme.md Normal file
View File

@ -0,0 +1,45 @@
# consolecolor
colors for beautylog
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/consolecolor)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/consolecolor)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/consolecolor)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/consolecolor/)
## Status for master
[![build status](https://GitLab.com/pushrocks/consolecolor/badges/master/build.svg)](https://GitLab.com/pushrocks/consolecolor/commits/master)
[![coverage report](https://GitLab.com/pushrocks/consolecolor/badges/master/coverage.svg)](https://GitLab.com/pushrocks/consolecolor/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/consolecolor.svg)](https://www.npmjs.com/package/consolecolor)
[![Dependency Status](https://david-dm.org/pushrocks/consolecolor.svg)](https://david-dm.org/pushrocks/consolecolor)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/consolecolor/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/consolecolor/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/consolecolor/badges/code.svg)](https://www.bithound.io/github/pushrocks/consolecolor)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import * as consolecolor from 'consolecolor';
let myColoredString = consolecolor.coloredString(
'This string has a blue font and a green background',
'blue',
'green'
);
console.log(myColoredString);
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,18 +0,0 @@
"use strict";
require("typings-test");
const beautycolor = require("../dist/index");
describe('beautycolor', function () {
it('should produce a blue font', function () {
console.log(beautycolor.coloredString('this is a blue font, no background', 'blue'));
});
it('should produce a red string with green background', function () {
console.log(beautycolor.coloredString('this is a red font with green background', 'red', 'green'));
});
it('should produce different font colors', function () {
console.log(beautycolor.coloredString('blue', 'blue'), beautycolor.coloredString('brown', 'brown'), beautycolor.coloredString('red', 'red'), beautycolor.coloredString('orange', 'orange'), beautycolor.coloredString('green', 'green'), beautycolor.coloredString('cyan', 'cyan'));
});
it('should produce different baclground colors', function () {
console.log(beautycolor.coloredString('blue', 'white', 'blue'), beautycolor.coloredString('brown', 'white', 'brown'), beautycolor.coloredString('red', 'white', 'red'), beautycolor.coloredString('orange', 'white', 'orange'), beautycolor.coloredString('green', 'white', 'green'), beautycolor.coloredString('cyan', 'white', 'cyan'));
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiw2Q0FBNEM7QUFFNUMsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixFQUFFLENBQUMsNEJBQTRCLEVBQUU7UUFDN0IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLG9DQUFvQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUE7SUFDeEYsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsbURBQW1ELEVBQUU7UUFDcEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLDBDQUEwQyxFQUFFLEtBQUssRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFBO0lBQ3JHLENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLHNDQUFzQyxFQUFFO1FBQ3ZDLE9BQU8sQ0FBQyxHQUFHLENBQ1AsV0FBVyxDQUFD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undle';
import * as beautycolor from '../dist/index'
import * as consolecolor from '../ts/index.js';
describe('beautycolor', function(){
it('should produce a blue font', function(){
console.log(beautycolor.coloredString('this is a blue font, no background', 'blue'))
})
it('should produce a red string with green background', function(){
console.log(beautycolor.coloredString('this is a red font with green background', 'red','green'))
})
it('should produce different font colors', function(){
tap.test('should produce a blue font', async () => {
console.log(consolecolor.coloredString('this is a blue font, no background', 'blue'));
});
tap.test('should produce a red string with green background', async () => {
console.log(
beautycolor.coloredString('blue','blue'),
beautycolor.coloredString('brown','brown'),
beautycolor.coloredString('red','red'),
beautycolor.coloredString('orange','orange'),
beautycolor.coloredString('green', 'green'),
beautycolor.coloredString('cyan', 'cyan')
)
})
it('should produce different baclground colors', function(){
consolecolor.coloredString('this is a red font with green background', 'red', 'green')
);
});
tap.test('should produce different font colors', async () => {
console.log(
beautycolor.coloredString('blue', 'white', 'blue'),
beautycolor.coloredString('brown', 'white', 'brown'),
beautycolor.coloredString('red', 'white', 'red'),
beautycolor.coloredString('orange', 'white', 'orange'),
beautycolor.coloredString('green', 'white', 'green'),
beautycolor.coloredString('cyan', 'white', 'cyan')
)
})
})
consolecolor.coloredString('blue', 'blue'),
consolecolor.coloredString('brown', 'brown'),
consolecolor.coloredString('red', 'red'),
consolecolor.coloredString('orange', 'orange'),
consolecolor.coloredString('green', 'green'),
consolecolor.coloredString('pink', 'pink'),
consolecolor.coloredString('cyan', 'cyan')
);
});
tap.test('should produce different background colors', async () => {
console.log(
consolecolor.coloredString('blue', 'white', 'blue'),
consolecolor.coloredString('brown', 'white', 'brown'),
consolecolor.coloredString('red', 'white', 'red'),
consolecolor.coloredString('orange', 'white', 'orange'),
consolecolor.coloredString('green', 'white', 'green'),
consolecolor.coloredString('pink', 'white', 'pink'),
consolecolor.coloredString('cyan', 'white', 'cyan')
);
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/consolecolor',
version: '2.0.2',
description: 'colors for beautylog'
}

View File

@ -1,24 +1,23 @@
import 'typings-global'
import * as ansiColors from 'ansi-256-colors'
import * as ansiColors from 'ansi-256-colors';
/**
* all the color names that are available for proper xterm translation
*/
export type TColorName = 'black' |
'black' |
'blue' |
'brown' |
'cyan' |
'green' |
'orange' |
'pink' |
'red' |
'white'
export type TColorName =
| 'black'
| 'blue'
| 'brown'
| 'cyan'
| 'green'
| 'orange'
| 'pink'
| 'red'
| 'white';
export interface IRGB {
r: number,
b: number,
g: number
r: number;
b: number;
g: number;
}
/**
@ -27,52 +26,56 @@ export interface IRGB {
let colorTranslator = (colorArg: TColorName): IRGB => {
switch (colorArg) {
case 'black':
return {r: 0, g: 0, b: 0}
return { r: 0, g: 0, b: 0 };
case 'blue':
return {r: 0, g: 1, b: 5}
return { r: 0, g: 2, b: 5 };
case 'brown':
return {r: 1, g: 0 , b: 0}
return { r: 1, g: 0, b: 0 };
case 'cyan':
return {r: 0,g: 4, b: 4}
return { r: 2, g: 4, b: 4 };
case 'green':
return {r: 2, g: 5, b: 0}
return { r: 2, g: 4, b: 1 };
case 'orange':
return {r: 5, g: 3, b: 0}
return { r: 5, g: 3, b: 1 };
case 'pink':
return {r: 5, g: 0, b: 5}
return { r: 3, g: 2, b: 4 };
case 'red':
return {r: 5, g: 0, b: 0}
return { r: 5, g: 0, b: 0 };
case 'white':
return {r: 5, g: 5, b: 5}
return { r: 5, g: 5, b: 5 };
default:
return {r: 5, g: 5, b: 5}
}
return { r: 5, g: 5, b: 5 };
}
};
/**
* colors the font of a string
*/
let coloredFont = (stringArg: string, colorArg: TColorName) => {
let rgbCode: IRGB = colorTranslator(colorArg)
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
}
let rgbCode: IRGB = colorTranslator(colorArg);
return ansiColors.fg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
};
/**
* colors the back of a string
*/
let coloredBackground = (stringArg: string, colorArg: TColorName) => {
let rgbCode = colorTranslator(colorArg)
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg
}
let rgbCode = colorTranslator(colorArg);
return ansiColors.bg.getRgb(rgbCode.r, rgbCode.g, rgbCode.b) + stringArg;
};
/**
* color a string with xterm
*/
export let coloredString = (stringArg: string, colorFontArg: TColorName, colorBackgroundArg?: TColorName): string => {
let returnString = coloredFont(stringArg, colorFontArg)
export let coloredString = (
stringArg: string,
colorFontArg: TColorName,
colorBackgroundArg?: TColorName
): string => {
let returnString = coloredFont(stringArg, colorFontArg);
if (colorBackgroundArg) {
returnString = coloredBackground(returnString, colorBackgroundArg)
}
returnString = returnString + ansiColors.reset
return returnString
returnString = coloredBackground(returnString, colorBackgroundArg);
}
returnString = returnString + ansiColors.reset;
return returnString;
};

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}