Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
047e994439 | |||
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 | |||
1d789532e3 | |||
ae6940bc31 | |||
8b6e5211e0 | |||
fa09d9d8a2 |
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: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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 @ship.zone/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 @ship.zone/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 @ship.zone/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
|
17
.gitignore
vendored
17
.gitignore
vendored
@@ -1,6 +1,19 @@
|
||||
node_modules
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
pages/
|
||||
public/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
#------# custom
|
@@ -1,59 +0,0 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command npmpage --publish gitlab
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
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)
|
26
changelog.md
Normal file
26
changelog.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [2.0.3] - 2025-08-08
|
||||
|
||||
### Fixed
|
||||
- Enhanced readme documentation with comprehensive examples and improved formatting
|
||||
- Updated CI/CD workflow configurations
|
||||
- Updated dependencies to latest versions
|
||||
- Removed obsolete gitlab-ci.yml configuration
|
||||
|
||||
## [2.0.2] - Previous Release
|
||||
|
||||
### Fixed
|
||||
- Core updates and improvements
|
||||
|
||||
## [2.0.1] - Previous Release
|
||||
|
||||
### Fixed
|
||||
- CI build arguments configuration
|
||||
|
||||
## [2.0.0] - Previous Release
|
||||
|
||||
### Changed
|
||||
- Major version update with organizational restructuring
|
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: 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,eyJ2ZXJzaW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SxDQUFDLENBQUE7SUFDdkMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsT0FBTyxDQUFDLENBQUMsRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFBO0FBQzVFLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ1EsUUFBQSxhQUFhLEdBQUcsQ0FBQyxTQUFpQixFQUFFLFlBQXdCLEVBQUUsa0JBQStCO0lBQ3BHLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxTQUFTLEVBQUUsWUFBWSxDQUFDLENBQUE7SUFDdkQsRUFBRSxDQUFDLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1FBQ3JCLFlBQVksR0FBRyxpQkFBaUIsQ0FBQyxZQUFZLEVBQUUsa0JBQWtCLENBQUMsQ0FBQTtJQUN0RSxDQUFDO0lBQ0QsWUFBWSxHQUFHLFlBQVksR0FBRyxVQUFVLENBQUMsS0FBSyxDQUFBO0lBQzlDLE1BQU0sQ0FBQyxZQUFZLENBQUE7QUFDdkIsQ0FBQyxDQUFBIn0=
|
31
npmextra.json
Normal file
31
npmextra.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
65
package.json
65
package.json
@@ -1,34 +1,63 @@
|
||||
{
|
||||
"name": "beautycolor",
|
||||
"version": "1.0.2",
|
||||
"description": "colors for beautylog",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/consolecolor",
|
||||
"version": "2.0.3",
|
||||
"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/ --verbose --testlog --timeout 20)",
|
||||
"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://code.foss.global/push.rocks/consolecolor/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/beautycolor#README",
|
||||
"homepage": "https://code.foss.global/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": "^2.3.2",
|
||||
"@types/node": "^22.0.0"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"pnpm": {
|
||||
"overrides": {}
|
||||
},
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
|
9188
pnpm-lock.yaml
generated
Normal file
9188
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 @@
|
||||
|
214
readme.md
Normal file
214
readme.md
Normal file
@@ -0,0 +1,214 @@
|
||||
# @push.rocks/consolecolor
|
||||
|
||||
🎨 **Beautiful terminal colors for Node.js** - Make your console output pop with vibrant ANSI colors!
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
pnpm install @push.rocks/consolecolor
|
||||
# or
|
||||
npm install @push.rocks/consolecolor
|
||||
```
|
||||
|
||||
## What it does
|
||||
|
||||
`@push.rocks/consolecolor` transforms your boring console output into a vibrant, colorful experience. Perfect for CLI tools, logging systems, or any Node.js application that needs to make terminal output more readable and visually appealing.
|
||||
|
||||
## Usage
|
||||
|
||||
### 🚀 Quick Start
|
||||
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
|
||||
// Simple colored text
|
||||
const blueText = consolecolor.coloredString('Hello World!', 'blue');
|
||||
console.log(blueText);
|
||||
|
||||
// Text with background color
|
||||
const alertMessage = consolecolor.coloredString('WARNING', 'red', 'white');
|
||||
console.log(alertMessage);
|
||||
```
|
||||
|
||||
### 🎨 Available Colors
|
||||
|
||||
The module supports these vibrant colors:
|
||||
|
||||
- `black` - Deep black ⚫
|
||||
- `blue` - Bright blue 🔵
|
||||
- `brown` - Warm brown 🟤
|
||||
- `cyan` - Cool cyan 🟦
|
||||
- `green` - Fresh green 🟢
|
||||
- `orange` - Vibrant orange 🟠
|
||||
- `pink` - Soft pink 🩷
|
||||
- `red` - Bold red 🔴
|
||||
- `white` - Pure white ⚪
|
||||
|
||||
### 📚 API Reference
|
||||
|
||||
#### `coloredString(text, fontColor, backgroundColor?)`
|
||||
|
||||
Creates a colored string for terminal output.
|
||||
|
||||
**Parameters:**
|
||||
- `text` (string): The text to colorize
|
||||
- `fontColor` (TColorName): The color for the text
|
||||
- `backgroundColor` (TColorName, optional): The background color
|
||||
|
||||
**Returns:** A string with ANSI color codes
|
||||
|
||||
```typescript
|
||||
// Basic usage
|
||||
const simpleColored = consolecolor.coloredString('Status: OK', 'green');
|
||||
|
||||
// With background
|
||||
const highlighted = consolecolor.coloredString('CRITICAL', 'white', 'red');
|
||||
```
|
||||
|
||||
### 💡 Real-World Examples
|
||||
|
||||
#### Creating a Logger with Color-Coded Severity
|
||||
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
|
||||
class ColorLogger {
|
||||
info(message: string) {
|
||||
console.log(consolecolor.coloredString(`ℹ INFO: ${message}`, 'cyan'));
|
||||
}
|
||||
|
||||
success(message: string) {
|
||||
console.log(consolecolor.coloredString(`✔ SUCCESS: ${message}`, 'green'));
|
||||
}
|
||||
|
||||
warning(message: string) {
|
||||
console.log(consolecolor.coloredString(`⚠ WARNING: ${message}`, 'orange', 'black'));
|
||||
}
|
||||
|
||||
error(message: string) {
|
||||
console.log(consolecolor.coloredString(`✖ ERROR: ${message}`, 'red', 'white'));
|
||||
}
|
||||
}
|
||||
|
||||
const logger = new ColorLogger();
|
||||
logger.info('Application started');
|
||||
logger.success('Database connected');
|
||||
logger.warning('Memory usage above 80%');
|
||||
logger.error('Failed to write to disk');
|
||||
```
|
||||
|
||||
#### Progress Indicator with Colors
|
||||
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
|
||||
function showProgress(step: number, total: number, status: 'pending' | 'running' | 'done') {
|
||||
const percentage = Math.round((step / total) * 100);
|
||||
const progressBar = '█'.repeat(percentage / 5) + '░'.repeat(20 - percentage / 5);
|
||||
|
||||
let statusColor: 'orange' | 'blue' | 'green' = 'orange';
|
||||
if (status === 'running') statusColor = 'blue';
|
||||
if (status === 'done') statusColor = 'green';
|
||||
|
||||
const output = consolecolor.coloredString(
|
||||
`[${progressBar}] ${percentage}% - ${status}`,
|
||||
statusColor
|
||||
);
|
||||
|
||||
process.stdout.write('\r' + output);
|
||||
}
|
||||
|
||||
// Usage
|
||||
showProgress(5, 10, 'running');
|
||||
```
|
||||
|
||||
#### Colorful Data Table
|
||||
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
|
||||
function printColorfulTable(data: Array<{name: string, status: string, value: number}>) {
|
||||
// Header
|
||||
console.log(consolecolor.coloredString('━'.repeat(50), 'cyan'));
|
||||
console.log(
|
||||
consolecolor.coloredString('Name', 'white') + '\t\t' +
|
||||
consolecolor.coloredString('Status', 'white') + '\t\t' +
|
||||
consolecolor.coloredString('Value', 'white')
|
||||
);
|
||||
console.log(consolecolor.coloredString('━'.repeat(50), 'cyan'));
|
||||
|
||||
// Data rows
|
||||
data.forEach(row => {
|
||||
const statusColor = row.status === 'active' ? 'green' :
|
||||
row.status === 'pending' ? 'orange' : 'red';
|
||||
const valueColor = row.value > 80 ? 'green' :
|
||||
row.value > 40 ? 'orange' : 'red';
|
||||
|
||||
console.log(
|
||||
row.name + '\t\t' +
|
||||
consolecolor.coloredString(row.status, statusColor) + '\t\t' +
|
||||
consolecolor.coloredString(row.value.toString(), valueColor)
|
||||
);
|
||||
});
|
||||
|
||||
console.log(consolecolor.coloredString('━'.repeat(50), 'cyan'));
|
||||
}
|
||||
|
||||
// Example usage
|
||||
printColorfulTable([
|
||||
{ name: 'Service A', status: 'active', value: 95 },
|
||||
{ name: 'Service B', status: 'pending', value: 60 },
|
||||
{ name: 'Service C', status: 'failed', value: 15 }
|
||||
]);
|
||||
```
|
||||
|
||||
### 🔧 TypeScript Support
|
||||
|
||||
This module is written in TypeScript and provides full type definitions out of the box:
|
||||
|
||||
```typescript
|
||||
import type { TColorName, IRGB } from '@push.rocks/consolecolor';
|
||||
|
||||
// TColorName type for color validation
|
||||
const myColor: TColorName = 'blue'; // ✅ Valid
|
||||
// const invalid: TColorName = 'purple'; // ❌ TypeScript error
|
||||
|
||||
// IRGB interface for RGB values
|
||||
const customRGB: IRGB = { r: 5, g: 3, b: 1 }; // Used internally
|
||||
```
|
||||
|
||||
### 🎯 Use Cases
|
||||
|
||||
- **CLI Tools**: Make your command-line tools more user-friendly with color-coded output
|
||||
- **Logging Systems**: Differentiate log levels with distinct colors
|
||||
- **Build Scripts**: Highlight errors, warnings, and success messages
|
||||
- **Development Tools**: Color-code test results, linting output, or deployment statuses
|
||||
- **Data Visualization**: Create simple colored charts and graphs in the terminal
|
||||
- **Interactive CLIs**: Guide users with colored prompts and responses
|
||||
|
||||
### 🚦 Best Practices
|
||||
|
||||
1. **Use colors consistently** - Establish a color scheme (e.g., red for errors, green for success)
|
||||
2. **Consider accessibility** - Not everyone can distinguish all colors equally
|
||||
3. **Provide non-color alternatives** - Use symbols alongside colors (✔, ✖, ⚠)
|
||||
4. **Test in different terminals** - Colors may appear differently across terminal emulators
|
||||
5. **Keep it readable** - Avoid color combinations that are hard to read
|
||||
|
||||
## 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('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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiw2Q0FBNEM7QUFFNUMsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixFQUFFLENBQUMsNEJBQTRCLEVBQUU7UUFDN0IsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLG9DQUFvQyxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUE7SUFDeEYsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsbURBQW1ELEVBQUU7UUFDcEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLDBDQUEwQyxFQUFFLEtBQUssRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFBO0lBQ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Q0FBQTtJQUNMLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
73
test/test.ts
73
test/test.ts
@@ -1,32 +1,45 @@
|
||||
import 'typings-test'
|
||||
import { expect, tap } from '@git.zone/tstest/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('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')
|
||||
)
|
||||
})
|
||||
})
|
||||
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'),
|
||||
);
|
||||
});
|
||||
|
||||
export default 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',
|
||||
};
|
111
ts/index.ts
111
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: 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}
|
||||
}
|
||||
}
|
||||
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
|
||||
* colors the back of a string for the terminal
|
||||
*/
|
||||
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
|
||||
* color a string for the terminal
|
||||
*/
|
||||
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,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": ["dist_*/**/*.d.ts"]
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user