Detalhes do pacote

acquerello

ShogunPanda42.4kISC3.0.1

Template based terminal coloring made really easy.

colors

readme (leia-me)

acquerello

Version Dependencies Build Coverage

Template based terminal coloring made really easy.

http://sw.cowtech.it/acquerello

Usage

Acquerello allows to add coloring to terminal in a really easy way.

Colorize templates

To colorize a template using template syntax, simply use the colorize function.

import { colorize } from 'acquerello'

console.log(colorize('{{red}}This is in red, {{green underline}}this in green underlined{{-}}, this in red again.'))

The template recognizes styles between double curly braces and the token {{-}} as universal closing tag (which also restores the previous style).

Acquerello supports all colors codes recognized by ansi-style (and therefore by chalk).

The closing tag at the end of the string can be omitted, since acquerello will append the global reset style (\x1b[0m) if any style was set.

If you want to discard the styles to be restored, use the {{reset}} token.

Setting custom styles

If you want to define custom styles, use the addCustomStyle function.

import { colorize, addCustomStyle } from 'acquerello'

addCustomStyle('important')
console.log(colorize('{{important}}This is in red, underlined.{{-}}'))

256 and 16 millions colors support

acquerello supports 256 ANSI codes and 16m RGB colors. Just give it a try:

import { colorize } from 'acquerello'

console.log(colorize('{{ansi:100}}color me{{-}}'))
console.log(colorize('{{bgANSI:3,4,5}}color me{{-}}'))

console.log(colorize('{{rgb:255,0,0}}color me{{-}}'))
console.log(colorize('{{bgRGB:0,255,0}}color me{{-}}'))

console.log(colorize('{{hex:#FF0000}}color me{{-}}'))
console.log(colorize('{{bgHEX:00FF00}}color me{{-}}'))

ANSI, RGB, and HEX can be used in style definitions and templates as well.

Colorize strings

To colorize strings, simply use the applyStyle, passing a list of styles you want to apply.

import { applyStyle } from 'acquerello'

const inRed = applyStyle('Colorized', 'red')
const inRedWithBlueBackground = applyStyle('Colorized', 'red bgBlue')

ESM Only

This package only supports to be directly imported in a ESM context.

For informations on how to use it in a CommonJS context, please check this page.

Contributing to acquerello

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

Copyright

Copyright (C) 2019 and above Shogun (shogun@cowtech.it).

Licensed under the ISC license, which can be found at https://choosealicense.com/licenses/isc.

changelog (log de mudanças)

2024-12-28 / 3.0.1

  • chore: Updated dependencies.
  • chore: Fixed Node.js version in CI.
  • chore: Do not use hidden files for test environment.

2024-10-20 / 3.0.0

  • feat!: Dropped support for Node 18 and updated dependencies.

2024-04-12 / 2.0.8

  • chore: Updated dependencies.
  • chore: Added missing dependency.

2024-02-07 / 2.0.7

  • chore: Updated dependencies.
  • chore: Replaced tap with Node test runner.

2024-01-27 / 2.0.6

  • chore: Fixed build.

2024-01-27 / 2.0.5

2024-01-27 / 2.0.4

  • chore: Updated dependencies.

2024-01-24 / 2.0.3

  • fix: Downgrade @swc/cli.

2024-01-24 / 2.0.2

  • fix: Fixed package.json

2024-01-24 / 2.0.1

  • chore: Updated dependencies.

2023-12-20 / 2.0.0

  • chore: Updated dependencies.
  • chore: Changed TypeScript version.
  • chore: Removed outdated option.

2023-10-23 / 1.1.2

  • fix: Do not use incremental builds.

2023-10-23 / 1.1.1

  • fix: Do not use incremental builds.

2023-10-23 / 1.1.0

  • fix: Fixing build.
  • fix: Fixed tap upgrade.
  • chore: Updated dependencies.
  • chore: Fixed compilation.
  • chore: CI improvement

2022-11-23 / 1.0.12

  • chore: Updated dependencies.
  • chore: Update package.json
  • fix: Fixed build script.

2022-10-12 / 1.0.11

  • chore: Updated dependencies.

2022-10-12 / 1.0.10

  • fix: Updated types layout.
  • chore: Updated compilation configuration.

2022-08-30 / 1.0.9

  • chore: Updated dependencies.

2022-08-29 / 1.0.8

  • chore: Updated dependencies.
  • chore: Use sourcemaps with swc
  • chore: Linted code.

2022-03-07 / 1.0.7

  • chore: Fix CI.
  • chore: Use PNPM on CI.
  • chore: Updated dependencies.

2022-03-07 / 1.0.6

  • chore: Added SWC configuration file.

2022-03-07 / 1.0.5

  • chore: Updated Typescript configuration.

2022-03-07 / 1.0.4

  • chore: Updated build system.

2022-01-26 / 1.0.3

  • chore: Updated dependencies and linted code.
  • chore: Updated dependencies.
  • chore: Removed useless file.

2021-11-17 / 1.0.2

2021-11-16 / 1.0.1

  • fix: Added ESM note in the README.md
  • chore: Allow manual CI triggering.
  • chore: Updated badges.
  • fix: Fixed Typescript configuration.

2021-08-13 / 1.0.0

2021-08-13 / 1.0.0-beta.0

  • chore: Use Node LTS in CI.
  • feat: Only export as ESM.
  • chore: Fine tuned build script.

2021-01-04 / 0.2.0

  • chore: Updated dist files.
  • feat: Also export as ESM.

2021-01-03 / 0.1.4

  • chore: Updated linter config.
  • chore: Updated config.
  • chore: Minor typo.

2021-01-02 / 0.1.3

  • chore: Fixed workflow.
  • chore: Updated code and tools.

2019-11-20 / 0.1.2

  • chore: Minor configuration fix.
  • chore: Switch to GitHub Actions.
  • chore: Linting fixes.

2019-10-08 / 0.1.1

  • chore: Fixed readme.

2019-10-08 / 0.1.0

  • chore: Fixed CodeCov configuration.
  • chore: Fixed reporters.
  • chore: Updated badges.
  • chore: Update CI configuration.
  • chore: Prepare CI.
  • chore: Tested all the code.