Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
19b620ef62 | |||
5e9bbfaf1b | |||
3357ca8c2b | |||
2db8bc4390 | |||
0818c877ab | |||
85666f8883 | |||
6469012517 | |||
faf3c840fa | |||
32158d7969 | |||
95c672f062 | |||
9043933be5 | |||
166ae81795 | |||
f16fe5a030 | |||
bbfabc7238 | |||
e293ae5cd9 | |||
233fd3f01a | |||
801fd17c77 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
18
.gitignore
vendored
@ -1,6 +1,20 @@
|
||||
node_modules
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
pages/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@ -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
|
||||
- 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
|
||||
- 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
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- 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
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- 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
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
36
README.md
36
README.md
@ -1,36 +0,0 @@
|
||||
# beautycolor
|
||||
colors for beautylog
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/beautycolor)
|
||||
[](https://GitLab.com/pushrocks/beautycolor)
|
||||
[](https://github.com/pushrocks/beautycolor)
|
||||
[](https://pushrocks.gitlab.io/beautycolor/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/beautycolor/commits/master)
|
||||
[](https://GitLab.com/pushrocks/beautycolor/commits/master)
|
||||
[](https://www.npmjs.com/package/beautycolor)
|
||||
[](https://david-dm.org/pushrocks/beautycolor)
|
||||
[](https://www.bithound.io/github/pushrocks/beautycolor/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/beautycolor)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](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)
|
||||
```
|
||||
|
||||
[](https://push.rocks)
|
14
dist/index.d.ts
vendored
14
dist/index.d.ts
vendored
@ -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
56
dist/index.js
vendored
@ -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: 2, b: 5 };
|
||||
case 'brown':
|
||||
return { r: 1, g: 0, b: 0 };
|
||||
case 'cyan':
|
||||
return { r: 2, g: 4, b: 4 };
|
||||
case 'green':
|
||||
return { r: 2, g: 4, b: 1 };
|
||||
case 'orange':
|
||||
return { r: 5, g: 3, b: 1 };
|
||||
case 'pink':
|
||||
return { r: 3, g: 2, b: 4 };
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzI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TyxDQUFDLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFBO0FBQzVFLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsQ0FBQyxTQUFpQixFQUFFLFlBQXdCLEVBQUUsa0JBQStCO0lBQ3BHLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxTQUFTLEVBQUUsWUFBWSxDQUFDLENBQUE7SUFDdkQsRUFBRSxDQUFDLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1FBQ3JCLFlBQVksR0FBRyxpQkFBaUIsQ0FBQyxZQUFZLEVBQUUsa0JBQWtCLENBQUMsQ0FBQTtJQUN0RSxDQUFDO0lBQ0QsWUFBWSxHQUFHLFlBQVksR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBIn0=
|
19
npmextra.json
Normal file
19
npmextra.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
47
package.json
47
package.json
@ -1,15 +1,18 @@
|
||||
{
|
||||
"name": "beautycolor",
|
||||
"version": "1.0.6",
|
||||
"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
5653
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
45
readme.md
Normal file
45
readme.md
Normal file
@ -0,0 +1,45 @@
|
||||
# consolecolor
|
||||
|
||||
colors for beautylog
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/consolecolor)
|
||||
[](https://GitLab.com/pushrocks/consolecolor)
|
||||
[](https://github.com/pushrocks/consolecolor)
|
||||
[](https://pushrocks.gitlab.io/consolecolor/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/consolecolor/commits/master)
|
||||
[](https://GitLab.com/pushrocks/consolecolor/commits/master)
|
||||
[](https://www.npmjs.com/package/consolecolor)
|
||||
[](https://david-dm.org/pushrocks/consolecolor)
|
||||
[](https://www.bithound.io/github/pushrocks/consolecolor/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/consolecolor)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](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)
|
||||
|
||||
[](https://push.rocks)
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
18
test/test.js
18
test/test.js
@ -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('pink', 'pink'), 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('pink', 'white', 'pink'), beautycolor.coloredString('cyan', 'white', 'cyan'));
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiw2Q0FBNEM7QUFFNUMsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixFQUFFLENBQUMsNEJBQTRCLEVBQUU7UUFDN0IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLG9DQUFvQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUE7SUFDeEYsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsbURBQW1ELEVBQUU7UUFDcEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLDBDQUEwQyxFQUFFLEtBQUssRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFBO0lBQ3JHLENBQUMsQ0FBQ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BRSxPQUFPLEVBQUUsTUFBTSxDQUFDLEVBQ2xELFdBQVcsQ0FBQyxhQUFhLENBQUMsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLENBQUMsQ0FDckQsQ0FBQTtJQUNMLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
69
test/test.ts
69
test/test.ts
@ -1,34 +1,39 @@
|
||||
import 'typings-test'
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
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(){
|
||||
console.log(
|
||||
beautycolor.coloredString('blue','blue'),
|
||||
beautycolor.coloredString('brown','brown'),
|
||||
beautycolor.coloredString('red','red'),
|
||||
beautycolor.coloredString('orange','orange'),
|
||||
beautycolor.coloredString('green', 'green'),
|
||||
beautycolor.coloredString('pink', 'pink'),
|
||||
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('pink', 'white', 'pink'),
|
||||
beautycolor.coloredString('cyan', 'white', 'cyan')
|
||||
)
|
||||
})
|
||||
})
|
||||
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(
|
||||
consolecolor.coloredString('this is a red font with green background', 'red', 'green')
|
||||
);
|
||||
});
|
||||
|
||||
tap.test('should produce different font colors', async () => {
|
||||
console.log(
|
||||
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
8
ts/00_commitinfo_data.ts
Normal 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'
|
||||
}
|
107
ts/index.ts
107
ts/index.ts
@ -1,78 +1,81 @@
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* the color translator function
|
||||
*/
|
||||
let colorTranslator = (colorArg: TColorName): IRGB => {
|
||||
switch (colorArg) {
|
||||
case 'black':
|
||||
return {r: 0, g: 0, b: 0}
|
||||
case 'blue':
|
||||
return {r: 0, g: 2, b: 5}
|
||||
case 'brown':
|
||||
return {r: 1, g: 0 , b: 0}
|
||||
case 'cyan':
|
||||
return {r: 2,g: 4, b: 4}
|
||||
case 'green':
|
||||
return {r: 2, g: 4, b: 1}
|
||||
case 'orange':
|
||||
return {r: 5, g: 3, b: 1}
|
||||
case 'pink':
|
||||
return {r: 3, g: 2, b: 4}
|
||||
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}
|
||||
}
|
||||
}
|
||||
switch (colorArg) {
|
||||
case 'black':
|
||||
return { r: 0, g: 0, b: 0 };
|
||||
case 'blue':
|
||||
return { r: 0, g: 2, b: 5 };
|
||||
case 'brown':
|
||||
return { r: 1, g: 0, b: 0 };
|
||||
case 'cyan':
|
||||
return { r: 2, g: 4, b: 4 };
|
||||
case 'green':
|
||||
return { r: 2, g: 4, b: 1 };
|
||||
case 'orange':
|
||||
return { r: 5, g: 3, b: 1 };
|
||||
case 'pink':
|
||||
return { r: 3, g: 2, b: 4 };
|
||||
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: 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)
|
||||
if (colorBackgroundArg) {
|
||||
returnString = coloredBackground(returnString, colorBackgroundArg)
|
||||
}
|
||||
returnString = returnString + ansiColors.reset
|
||||
return returnString
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user