chalk-template
Advanced tools
Comparing version 0.1.0 to 0.2.0
114
package.json
{ | ||
"name": "chalk-template", | ||
"version": "0.1.0", | ||
"description": "", | ||
"email": "simon.mollweide@web.de", | ||
"author": "Simon Mollweide <simon.mollweide@web.de>", | ||
"url": "https://github.com/smollweide/chalk-template", | ||
"repository": { | ||
"type": "github", | ||
"url": "https://github.com/smollweide/chalk-template" | ||
}, | ||
"main": "chalk-template.js", | ||
"bugs": { | ||
"url": "https://github.com/smollweide/chalk-template/issues" | ||
}, | ||
"preferGlobal": false, | ||
"private": false, | ||
"license": "MIT", | ||
"homepage": "http://smollweide.github.io/chalk-template/", | ||
"scripts": { | ||
"test": "node_modules/.bin/mocha test.js", | ||
"lint": "npm run lint:js", | ||
"lint:js": "node_modules/.bin/eslint **/*.js" | ||
}, | ||
"engines": { | ||
"node": ">= 4" | ||
}, | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
"color", | ||
"colour", | ||
"colors", | ||
"terminal", | ||
"console", | ||
"string", | ||
"str", | ||
"ansi", | ||
"style", | ||
"styles", | ||
"tty", | ||
"formatting", | ||
"rgb", | ||
"256", | ||
"shell", | ||
"xterm", | ||
"log", | ||
"logging", | ||
"command-line", | ||
"text", | ||
"template", | ||
"tpl" | ||
], | ||
"devDependencies": { | ||
"mocha": "3.2.0" | ||
}, | ||
"dependencies": { | ||
"@namics/eslint-config": "2.1.0", | ||
"chalk": "1.1.3", | ||
"eslint": "3.13.1", | ||
"eslint-plugin-import": "2.2.0", | ||
"for-in": "0.1.6" | ||
} | ||
"name": "chalk-template", | ||
"version": "0.2.0", | ||
"description": "Terminal string styling with tagged template literals", | ||
"license": "MIT", | ||
"repository": "chalk/chalk-template", | ||
"funding": "https://github.com/chalk/chalk-template?sponsor=1", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava test/index.js && cross-env FORCE_COLOR=0 ava test/no-color.js && cross-env FORCE_COLOR=3 TERM=dumb ava test/full-color.js && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"chalk", | ||
"template", | ||
"templates", | ||
"templating", | ||
"ansi", | ||
"styles", | ||
"color", | ||
"colour", | ||
"colors", | ||
"terminal", | ||
"console", | ||
"string", | ||
"tty", | ||
"escape", | ||
"formatting", | ||
"rgb", | ||
"256", | ||
"shell", | ||
"xterm", | ||
"log", | ||
"logging", | ||
"command-line", | ||
"text" | ||
], | ||
"dependencies": { | ||
"chalk": "^4.1.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"cross-env": "^7.0.3", | ||
"tsd": "^0.18.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,39 +0,62 @@ | ||
# chalk-template [![Build Status](https://img.shields.io/travis/smollweide/chalk-template/master.svg)](https://travis-ci.org/smollweide/chalk-template) | ||
# chalk-template | ||
> Simple and easy to use template engine for chalk | ||
> Terminal string styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) | ||
<img src="https://cloud.githubusercontent.com/assets/2912007/22125570/7e92454e-de94-11e6-9398-d5136f498cb1.png" width="631"> | ||
## Install | ||
```console | ||
$ npm install --save chalk-template | ||
```sh | ||
npm install chalk-template | ||
``` | ||
## Usage | ||
```js | ||
const chalk = require('chalk'); | ||
const chalkTemplate = require('chalk-template'); | ||
import chalkTemplate from 'chalk-template'; | ||
import chalk from 'chalk'; | ||
console.log( | ||
chalkTemplate('<bold><red>Title</red></bold><error/>', | ||
{ | ||
error: chalk.bold.red('Error!') | ||
} | ||
) | ||
); | ||
const log = console.log; | ||
log(chalkTemplate` | ||
CPU: {red ${cpu.totalPercent}%} | ||
RAM: {green ${ram.used / ram.total * 100}%} | ||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} | ||
`); | ||
log(chalk.red.bgBlack(chalkTemplate`2 + 3 = {bold ${2 + 3}}`)); | ||
const miles = 18; | ||
const calculateFeet = miles => miles * 5280; | ||
console.log(chalk` | ||
There are {bold 5280 feet} in a mile. | ||
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}. | ||
`); | ||
``` | ||
See [supported styles](https://github.com/chalk/chalk#styles). | ||
## API | ||
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`). | ||
Template styles are chained exactly like normal [Chalk](https://github.com/chalk/chalk) styles. The following two statements are equivalent: | ||
```js | ||
import chalk from 'chalk'; | ||
import chalkTemplate from 'chalk-template'; | ||
console.log(chalk.bold.rgb(10, 100, 200)('Hello!')); | ||
console.log(chalkTemplate`{bold.rgb(10,100,200) Hello!}`); | ||
``` | ||
Note that function styles (`rgb()`, `hex()`, etc.) may not contain spaces between parameters. | ||
All interpolated values (`` chalkTemplate`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped. | ||
## Related | ||
- [chalk](https://github.com/chalk/chalk) - API for this module | ||
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right | ||
- [chalk-cli](https://github.com/chalk/chalk-cli) - Style text from the terminal | ||
## Maintainers | ||
## License | ||
MIT © [Simon Mollweide](https://github.com/smollweide) | ||
- [Sindre Sorhus](https://github.com/sindresorhus) | ||
- [Josh Junon](https://github.com/qix-) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8434
1
141
63
Yes
4
2
1
2
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removed@namics/eslint-config@2.1.0
- Removedeslint@3.13.1
- Removedeslint-plugin-import@2.2.0
- Removedfor-in@0.1.6
- Removed@namics/eslint-config@2.1.0(transitive)
- Removedacorn@3.3.05.7.4(transitive)
- Removedacorn-jsx@3.0.1(transitive)
- Removedajv@4.11.8(transitive)
- Removedajv-keywords@1.5.1(transitive)
- Removedansi-escapes@1.4.0(transitive)
- Removedansi-regex@2.1.13.0.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedarray-buffer-byte-length@1.0.1(transitive)
- Removedarray.prototype.find@2.2.3(transitive)
- Removedarraybuffer.prototype.slice@1.0.3(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedbuiltin-modules@1.1.1(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcaller-path@0.1.0(transitive)
- Removedcallsites@0.2.0(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcircular-json@0.3.3(transitive)
- Removedcli-cursor@1.0.2(transitive)
- Removedcli-width@2.2.1(transitive)
- Removedcliui@3.2.0(transitive)
- Removedco@4.6.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcontains-path@0.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedd@1.0.2(transitive)
- Removeddamerau-levenshtein@1.0.8(transitive)
- Removeddata-view-buffer@1.0.1(transitive)
- Removeddata-view-byte-length@1.0.1(transitive)
- Removeddata-view-byte-offset@1.0.0(transitive)
- Removeddebug@2.6.93.2.7(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddeep-is@0.1.4(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddoctrine@1.5.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedes-abstract@1.23.5(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-shim-unscopables@1.0.2(transitive)
- Removedes-to-primitive@1.2.1(transitive)
- Removedes5-ext@0.10.64(transitive)
- Removedes6-iterator@2.0.3(transitive)
- Removedes6-map@0.1.5(transitive)
- Removedes6-set@0.1.6(transitive)
- Removedes6-symbol@3.1.4(transitive)
- Removedes6-weak-map@2.0.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedescope@3.6.0(transitive)
- Removedeslint@3.13.1(transitive)
- Removedeslint-find-rules@1.14.3(transitive)
- Removedeslint-import-resolver-node@0.2.3(transitive)
- Removedeslint-module-utils@2.12.0(transitive)
- Removedeslint-plugin-import@2.2.0(transitive)
- Removedeslint-plugin-jsx-a11y@3.0.2(transitive)
- Removedeslint-plugin-react@6.10.3(transitive)
- Removedeslint-rule-documentation@1.0.23(transitive)
- Removedesniff@2.0.1(transitive)
- Removedespree@3.5.4(transitive)
- Removedesprima@4.0.1(transitive)
- Removedesrecurse@4.3.0(transitive)
- Removedestraverse@4.3.05.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedevent-emitter@0.3.5(transitive)
- Removedexit-hook@1.1.1(transitive)
- Removedext@1.7.0(transitive)
- Removedfast-levenshtein@2.0.6(transitive)
- Removedfigures@1.7.0(transitive)
- Removedfile-entry-cache@2.0.0(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedflat-cache@1.3.4(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfor-in@0.1.6(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.6(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedget-symbol-description@1.0.2(transitive)
- Removedglob@7.2.3(transitive)
- Removedglobals@9.18.0(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas@1.0.4(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-bigints@1.0.2(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedignore@3.3.10(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinquirer@0.12.0(transitive)
- Removedinternal-slot@1.0.7(transitive)
- Removedinterpret@1.4.0(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-array-buffer@3.0.4(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-bigint@1.0.4(transitive)
- Removedis-boolean-object@1.1.2(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-data-view@1.0.1(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-fullwidth-code-point@1.0.02.0.0(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-negative-zero@2.0.3(transitive)
- Removedis-number-object@1.0.7(transitive)
- Removedis-property@1.0.2(transitive)
- Removedis-regex@1.1.4(transitive)
- Removedis-resolvable@1.1.0(transitive)
- Removedis-shared-array-buffer@1.0.3(transitive)
- Removedis-string@1.0.7(transitive)
- Removedis-symbol@1.0.4(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedis-weakref@1.0.2(transitive)
- Removedisarray@1.0.02.0.5(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-stable-stringify@1.1.1(transitive)
- Removedjsonify@0.0.1(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedjsx-ast-utils@1.4.1(transitive)
- Removedlcid@1.0.0(transitive)
- Removedlevn@0.3.0(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.assign@4.2.0(transitive)
- Removedlodash.cond@4.5.2(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removedmute-stream@0.0.5(transitive)
- Removednatural-compare@1.4.0(transitive)
- Removednext-tick@1.1.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedonce@1.4.0(transitive)
- Removedonetime@1.1.0(transitive)
- Removedoptionator@0.8.3(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-locale@1.4.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-is-absolute@1.0.0(transitive)
- Removedpath-is-inside@1.0.2(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedpkg-up@1.0.0(transitive)
- Removedpluralize@1.2.1(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedprelude-ls@1.1.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedprogress@1.1.8(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreadline2@1.0.1(transitive)
- Removedrechoir@0.6.2(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedrequire-uncached@1.0.3(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-from@1.0.1(transitive)
- Removedrestore-cursor@1.0.1(transitive)
- Removedrimraf@2.6.3(transitive)
- Removedrun-async@0.1.0(transitive)
- Removedrx-lite@3.1.2(transitive)
- Removedsafe-array-concat@1.1.2(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsafe-regex-test@1.0.3(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedshelljs@0.7.8(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedslice-ansi@0.0.4(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@1.0.22.1.1(transitive)
- Removedstring.prototype.trim@1.2.9(transitive)
- Removedstring.prototype.trimend@1.0.8(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.14.0.0(transitive)
- Removedstrip-bom@2.0.03.0.0(transitive)
- Removedstrip-json-comments@2.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtable@3.8.3(transitive)
- Removedtext-table@0.2.0(transitive)
- Removedthrough@2.3.8(transitive)
- Removedtype@2.7.3(transitive)
- Removedtype-check@0.3.2(transitive)
- Removedtyped-array-buffer@1.0.2(transitive)
- Removedtyped-array-byte-length@1.0.1(transitive)
- Removedtyped-array-byte-offset@1.0.2(transitive)
- Removedtyped-array-length@1.0.6(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedunbox-primitive@1.0.2(transitive)
- Removeduser-home@2.0.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwhich-boxed-primitive@1.0.2(transitive)
- Removedwhich-module@1.0.0(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
- Removedwindow-size@0.2.0(transitive)
- Removedword-wrap@1.2.5(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedwrite@0.2.1(transitive)
- Removedxtend@4.0.2(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@5.0.0(transitive)
- Removedyargs-parser@3.2.0(transitive)
Updatedchalk@^4.1.2