Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
3544586761 | |||
d443a51c97 | |||
9c690bce64 | |||
1d5469eb73 | |||
d2fbde701e | |||
19b620ef62 | |||
5e9bbfaf1b | |||
3357ca8c2b | |||
2db8bc4390 | |||
0818c877ab | |||
85666f8883 | |||
6469012517 | |||
faf3c840fa | |||
32158d7969 | |||
95c672f062 | |||
9043933be5 | |||
166ae81795 | |||
f16fe5a030 | |||
bbfabc7238 | |||
e293ae5cd9 | |||
233fd3f01a | |||
801fd17c77 | |||
a5db5eb181 | |||
c59061a840 | |||
b9c4626a30 | |||
aeac61774f |
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: 1, 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,eyJ2ZXJzaW9uIjozLCJm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BQUE7SUFDdkMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsT0FBTyxDQUFDLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFBO0FBQzVFLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsQ0FBQyxTQUFpQixFQUFFLFlBQXdCLEVBQUUsa0JBQStCO0lBQ3BHLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxTQUFTLEVBQUUsWUFBWSxDQUFDLENBQUE7SUFDdkQsRUFBRSxDQUFDLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1FBQ3JCLFlBQVksR0FBRyxpQkFBaUIsQ0FBQyxZQUFZLEVBQUUsa0JBQWtCLENBQUMsQ0FBQTtJQUN0RSxDQUFDO0lBQ0QsWUFBWSxHQUFHLFlBQVksR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBIn0=
|
33
npmextra.json
Normal file
33
npmextra.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"@gitzone/npmts"
|
||||
],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "consolecolor",
|
||||
"description": "A module for applying color styles to console output.",
|
||||
"npmPackagename": "@push.rocks/consolecolor",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"console log styling",
|
||||
"ANSI colors",
|
||||
"terminal colors",
|
||||
"command line utilities",
|
||||
"node.js",
|
||||
"typescript",
|
||||
"text formatting",
|
||||
"log enhancement",
|
||||
"development tools"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
64
package.json
64
package.json
@ -1,34 +1,60 @@
|
||||
{
|
||||
"name": "beautycolor",
|
||||
"version": "1.0.4",
|
||||
"description": "colors for beautylog",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/consolecolor",
|
||||
"version": "2.0.2",
|
||||
"private": false,
|
||||
"description": "A module for applying color styles to console output.",
|
||||
"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": "https://code.foss.global/push.rocks/consolecolor.git"
|
||||
},
|
||||
"keywords": [
|
||||
"color",
|
||||
"terminal",
|
||||
"beautylog",
|
||||
"push.rocks"
|
||||
"console log styling",
|
||||
"ANSI colors",
|
||||
"terminal colors",
|
||||
"command line utilities",
|
||||
"node.js",
|
||||
"typescript",
|
||||
"text formatting",
|
||||
"log enhancement",
|
||||
"development tools"
|
||||
],
|
||||
"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://code.foss.global/push.rocks/consolecolor",
|
||||
"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
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
98
readme.md
Normal file
98
readme.md
Normal file
@ -0,0 +1,98 @@
|
||||
# @push.rocks/consolecolor
|
||||
|
||||
colors for beautylog
|
||||
|
||||
## Install
|
||||
|
||||
To install `@push.rocks/consolecolor`, you need Node.js installed on your system. If you have Node.js installed, you can add `@push.rocks/consolecolor` to your project by running:
|
||||
|
||||
```bash
|
||||
npm install @push.rocks/consolecolor --save
|
||||
```
|
||||
|
||||
This command will install `@push.rocks/consolecolor` and add it to your project's `package.json` file.
|
||||
|
||||
## Usage
|
||||
|
||||
In this guide, we'll explore how to use `@push.rocks/consolecolor` to colorize your console output in a Node.js application. We'll cover the basics, including coloring text, backgrounds, and combining both for striking effects. This package utilizes TypeScript and ESM syntax for modern, type-safe code examples.
|
||||
|
||||
### Getting Started
|
||||
|
||||
First, ensure you have imported the library in your TypeScript file:
|
||||
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
```
|
||||
|
||||
### Coloring Text
|
||||
|
||||
The foundation of using `@push.rocks/consolecolor` is to change the color of the text output. You can choose from a variety of colors including blue, red, green, and more. Here's how to color a string blue:
|
||||
|
||||
```typescript
|
||||
let blueString = consolecolor.coloredString("This text is blue.", "blue");
|
||||
console.log(blueString);
|
||||
```
|
||||
|
||||
### Adding Background Color
|
||||
|
||||
In addition to coloring text, you can also set the background color of your text for greater emphasis:
|
||||
|
||||
```typescript
|
||||
let redTextOnGreen = consolecolor.coloredString("Red text on a green background.", "red", "green");
|
||||
console.log(redTextOnGreen);
|
||||
```
|
||||
|
||||
### Combining Colors
|
||||
|
||||
You can easily mix and match text and background colors to suit your needs. Here's an example of a more detailed usage, where we add a function to create and log messages of different severities with appropriate coloring:
|
||||
|
||||
```typescript
|
||||
function logMessage(message: string, type: 'info' | 'warning' | 'error') {
|
||||
switch (type) {
|
||||
case 'info':
|
||||
console.log(consolecolor.coloredString(message, 'cyan'));
|
||||
break;
|
||||
case 'warning':
|
||||
console.log(consolecolor.coloredString(message, 'orange', 'black'));
|
||||
break;
|
||||
case 'error':
|
||||
console.log(consolecolor.coloredString(message, 'red', 'white'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
logMessage('An informational message', 'info');
|
||||
logMessage('A warning message', 'warning');
|
||||
logMessage('An error message', 'error');
|
||||
```
|
||||
|
||||
This example defines a `logMessage` function that accepts a message and a message type. It uses `@push.rocks/consolecolor` to color the message according to its severity.
|
||||
|
||||
### Advanced Usage
|
||||
|
||||
Beyond basic coloring, `@push.rocks/consolecolor` allows for intricate customization. For instance, you can create utilities that dynamically select colors based on conditions, enhance logging mechanisms, or implement theme-based console outputs in your Node.js applications.
|
||||
|
||||
Considering the capabilities of `@push.rocks/consolecolor` alongside Node.js's console object, you can create highly readable, colorful console applications that are easier to debug and pleasant to interact with.
|
||||
|
||||
### Conclusion
|
||||
|
||||
`@push.rocks/consolecolor` offers a simple yet powerful API for adding color to Node.js console applications. By following the examples provided, you can enhance the visual appeal and readability of your console output, making development and debugging a more enjoyable experience. For a comprehensive list of all available colors and more advanced features, refer to the official documentation and explore the module's possibilities.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiw2Q0FBNEM7QUFFNUMsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixFQUFFLENBQUMsNEJBQTRCLEVBQUU7UUFDN0IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLG9DQUFvQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUE7SUFDeEYsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsb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QUFFLE9BQU8sRUFBRSxRQUFRLENBQUMsRUFDdEQsV0FBVyxDQUFDLGFBQWEsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLE9BQU8sQ0FBQyxFQUNwRCxXQUFXLENBQUMsYUFBYSxDQUFDLE1BQU0sRUFBRSxPQUFPLEVBQUUsTUFBTSxDQUFDLEVBQ2xELFdBQVcsQ0FBQyxhQUFhLENBQUMsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLENBQUMsQ0FDckQsQ0FBQTtJQUNMLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
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: 1, 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