Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
047e994439 | |||
3544586761 | |||
d443a51c97 | |||
9c690bce64 | |||
1d5469eb73 | |||
d2fbde701e |
@@ -6,8 +6,8 @@ on:
|
||||
- '**'
|
||||
|
||||
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
|
||||
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}}
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
@@ -6,8 +6,8 @@ on:
|
||||
- '*'
|
||||
|
||||
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
|
||||
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}}
|
||||
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@@ -17,4 +16,4 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
#------# custom
|
142
.gitlab-ci.yml
142
.gitlab-ci.yml
@@ -1,142 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- 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 node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- 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
|
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
|
@@ -1,19 +1,31 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"@gitzone/npmts"
|
||||
],
|
||||
"npmGlobalTools": ["@gitzone/npmts"],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "consolecolor",
|
||||
"description": "a simple module to deal with console colors",
|
||||
"description": "A module for applying color styles to console output.",
|
||||
"npmPackagename": "@push.rocks/consolecolor",
|
||||
"license": "MIT"
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
package.json
36
package.json
@@ -1,40 +1,44 @@
|
||||
{
|
||||
"name": "@push.rocks/consolecolor",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"private": false,
|
||||
"description": "colors for beautylog",
|
||||
"description": "A module for applying color styles to console output.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"test": "(tstest test/ --verbose --testlog --timeout 20)",
|
||||
"build": "(tsbuild --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitlab.com/push.rocks/consolecolor.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/push.rocks/consolecolor/issues"
|
||||
"url": "https://code.foss.global/push.rocks/consolecolor/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/push.rocks/consolecolor#readme",
|
||||
"homepage": "https://code.foss.global/push.rocks/consolecolor#readme",
|
||||
"dependencies": {
|
||||
"ansi-256-colors": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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"
|
||||
"@git.zone/tstest": "^2.3.2",
|
||||
"@types/node": "^22.0.0"
|
||||
},
|
||||
"type": "module",
|
||||
"browserslist": [
|
||||
@@ -51,5 +55,9 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
],
|
||||
"pnpm": {
|
||||
"overrides": {}
|
||||
},
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
|
11923
pnpm-lock.yaml
generated
11923
pnpm-lock.yaml
generated
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 @@
|
||||
|
229
readme.md
229
readme.md
@@ -1,45 +1,214 @@
|
||||
# consolecolor
|
||||
# @push.rocks/consolecolor
|
||||
|
||||
colors for beautylog
|
||||
🎨 **Beautiful terminal colors for Node.js** - Make your console output pop with vibrant ANSI colors!
|
||||
|
||||
## Availabililty
|
||||
## Install
|
||||
|
||||
[](https://www.npmjs.com/package/consolecolor)
|
||||
[](https://GitLab.com/pushrocks/consolecolor)
|
||||
[](https://github.com/pushrocks/consolecolor)
|
||||
[](https://pushrocks.gitlab.io/consolecolor/)
|
||||
```bash
|
||||
pnpm install @push.rocks/consolecolor
|
||||
# or
|
||||
npm install @push.rocks/consolecolor
|
||||
```
|
||||
|
||||
## Status for master
|
||||
## What it does
|
||||
|
||||
[](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/)
|
||||
`@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
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
### 🚀 Quick Start
|
||||
|
||||
```javascript
|
||||
import * as consolecolor from 'consolecolor';
|
||||
```typescript
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
|
||||
let myColoredString = consolecolor.coloredString(
|
||||
'This string has a blue font and a green background',
|
||||
'blue',
|
||||
'green'
|
||||
);
|
||||
// Simple colored text
|
||||
const blueText = consolecolor.coloredString('Hello World!', 'blue');
|
||||
console.log(blueText);
|
||||
|
||||
console.log(myColoredString);
|
||||
// Text with background color
|
||||
const alertMessage = consolecolor.coloredString('WARNING', 'red', 'white');
|
||||
console.log(alertMessage);
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
### 🎨 Available Colors
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
The module supports these vibrant colors:
|
||||
|
||||
[](https://push.rocks)
|
||||
- `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.
|
18
test/test.ts
18
test/test.ts
@@ -1,14 +1,20 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
|
||||
import * as consolecolor from '../ts/index.js';
|
||||
|
||||
tap.test('should produce a blue font', async () => {
|
||||
console.log(consolecolor.coloredString('this is a blue font, no background', 'blue'));
|
||||
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')
|
||||
consolecolor.coloredString(
|
||||
'this is a red font with green background',
|
||||
'red',
|
||||
'green',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -20,7 +26,7 @@ tap.test('should produce different font colors', async () => {
|
||||
consolecolor.coloredString('orange', 'orange'),
|
||||
consolecolor.coloredString('green', 'green'),
|
||||
consolecolor.coloredString('pink', 'pink'),
|
||||
consolecolor.coloredString('cyan', 'cyan')
|
||||
consolecolor.coloredString('cyan', 'cyan'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -32,8 +38,8 @@ tap.test('should produce different background colors', async () => {
|
||||
consolecolor.coloredString('orange', 'white', 'orange'),
|
||||
consolecolor.coloredString('green', 'white', 'green'),
|
||||
consolecolor.coloredString('pink', 'white', 'pink'),
|
||||
consolecolor.coloredString('cyan', 'white', 'cyan')
|
||||
consolecolor.coloredString('cyan', 'white', 'cyan'),
|
||||
);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
|
@@ -4,5 +4,5 @@
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/consolecolor',
|
||||
version: '2.0.2',
|
||||
description: 'colors for beautylog'
|
||||
}
|
||||
description: 'colors for beautylog',
|
||||
};
|
||||
|
@@ -57,7 +57,7 @@ let coloredFont = (stringArg: string, colorArg: TColorName) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@@ -65,12 +65,12 @@ let coloredBackground = (stringArg: string, colorArg: TColorName) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* color a string with xterm
|
||||
* color a string for the terminal
|
||||
*/
|
||||
export let coloredString = (
|
||||
stringArg: string,
|
||||
colorFontArg: TColorName,
|
||||
colorBackgroundArg?: TColorName
|
||||
colorBackgroundArg?: TColorName,
|
||||
): string => {
|
||||
let returnString = coloredFont(stringArg, colorFontArg);
|
||||
if (colorBackgroundArg) {
|
||||
|
@@ -6,9 +6,9 @@
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
"exclude": ["dist_*/**/*.d.ts"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user