cfonts-node 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cfonts-node might be problematic. Click here for more details.

Files changed (46) hide show
  1. package/LICENSE +339 -0
  2. package/README.md +484 -0
  3. package/fonts/3d.json +658 -0
  4. package/fonts/block.json +481 -0
  5. package/fonts/chrome.json +304 -0
  6. package/fonts/grid.json +481 -0
  7. package/fonts/huge.json +776 -0
  8. package/fonts/pallet.json +481 -0
  9. package/fonts/shade.json +599 -0
  10. package/fonts/simple.json +363 -0
  11. package/fonts/simple3d.json +540 -0
  12. package/fonts/simpleBlock.json +540 -0
  13. package/fonts/slick.json +481 -0
  14. package/fonts/tiny.json +245 -0
  15. package/package.json +117 -0
  16. package/src/AddChar.js +51 -0
  17. package/src/AddLetterSpacing.js +59 -0
  18. package/src/AddLine.js +58 -0
  19. package/src/AddShortcuts.js +40 -0
  20. package/src/AlignText.js +68 -0
  21. package/src/Chalk.js +40 -0
  22. package/src/CharLength.js +55 -0
  23. package/src/CheckInput.js +192 -0
  24. package/src/CleanInput.js +47 -0
  25. package/src/Color.js +118 -0
  26. package/src/Colorize.js +84 -0
  27. package/src/Config.js +1 -0
  28. package/src/Debugging.js +108 -0
  29. package/src/DisplayHelp.js +50 -0
  30. package/src/DisplayVersion.js +31 -0
  31. package/src/GetFirstCharacterPosition.js +38 -0
  32. package/src/GetFont.js +49 -0
  33. package/src/GetLongestLine.js +31 -0
  34. package/src/Gradient.js +549 -0
  35. package/src/Log.js +42 -0
  36. package/src/Options.js +162 -0
  37. package/src/ParseArgs.js +82 -0
  38. package/src/RemoveChar.js +0 -0
  39. package/src/Render.js +257 -0
  40. package/src/RenderConsole.js +102 -0
  41. package/src/Say.js +50 -0
  42. package/src/Size.js +42 -0
  43. package/src/UpperCaseFirst.js +35 -0
  44. package/src/bin.js +16 -0
  45. package/src/constants.js +255 -0
  46. package/src/index.js +98 -0
package/README.md ADDED
@@ -0,0 +1,484 @@
1
+ ```shell
2
+ ██████╗ ███████╗ ██████╗ ███╗ ██╗ ████████╗ ███████╗
3
+ ██╔════╝ ██╔════╝ ██╔═══██╗ ████╗ ██║ ╚══██╔══╝ ██╔════╝
4
+ ██║ █████╗ ██║ ██║ ██╔██╗ ██║ ██║ ███████╗
5
+ ██║ ██╔══╝ ██║ ██║ ██║╚██╗██║ ██║ ╚════██║
6
+ ╚██████╗ ██║ ╚██████╔╝ ██║ ╚████║ ██║ ███████║
7
+ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝
8
+ ```
9
+
10
+ <p align="center">This is a silly little command line tool for sexy fonts in the console. <strong>Give your cli some love.</strong></p>
11
+
12
+ ## Installing
13
+
14
+ To install the CLI app, simply NPM install it globally.
15
+
16
+ ```shell
17
+ $ npm install cfonts-node -g
18
+ ```
19
+
20
+ To use it in your shell:
21
+
22
+ ```shell
23
+ $ cfonts-node "Hello|World\!"
24
+ ```
25
+
26
+ _Remember to escape the `!` character with `\` in the shell_
27
+
28
+ Or use it in your project:
29
+
30
+ ```js
31
+ const CFonts = require('cfonts-node');
32
+
33
+ CFonts.say('Hello|world!', {
34
+ font: 'block', // define the font face
35
+ align: 'left', // define text alignment
36
+ colors: ['system'], // define all colors
37
+ background: 'transparent', // define the background color, you can also use `backgroundColor` here as key
38
+ letterSpacing: 1, // define letter spacing
39
+ lineHeight: 1, // define the line height
40
+ space: true, // define if the output text should have empty lines on top and on the bottom
41
+ maxLength: '0', // define how many character can be on one line
42
+ gradient: false, // define your two gradient colors
43
+ independentGradient: false, // define if you want to recalculate the gradient for each new line
44
+ transitionGradient: false, // define if this is a transition between colors directly
45
+ env: 'node' // define the environment CFonts is being executed in
46
+ });
47
+ ```
48
+
49
+ _All settings are optional and shown here with their default_
50
+
51
+ You can use CFonts in your project without the direct output to the console:
52
+
53
+ ```js
54
+ const CFonts = require('cfonts-node');
55
+
56
+ const prettyFont = CFonts.render('Hello|world!', {/* same settings object as above */});
57
+
58
+ prettyFont.string // the ansi string for sexy console font
59
+ prettyFont.array // returns the array for the output
60
+ prettyFont.lines // returns the lines used
61
+ prettyFont.options // returns the options used
62
+ ```
63
+
64
+
65
+ ## Usage
66
+
67
+ Using the CLI is easy.
68
+
69
+ ```
70
+ Usage: cfonts-node "<value>" [option1] <input1> [option2] <input1>,<input2> [option3] etc...
71
+ ```
72
+
73
+ At any point you can run the *help* command to get a full list of commands and
74
+ how to use them.
75
+
76
+ ```shell
77
+ $ cfonts-node --help
78
+ ```
79
+
80
+
81
+ ## Supported Characters
82
+
83
+ | | | | |
84
+ |-----|-----|-----|-------------|
85
+ | `A` | `P` | `4` | `$` |
86
+ | `B` | `Q` | `5` | `%` |
87
+ | `C` | `R` | `6` | `&` |
88
+ | `D` | `S` | `7` | `(` |
89
+ | `E` | `T` | `8` | `)` |
90
+ | `F` | `U` | `9` | `/` |
91
+ | `G` | `V` | `!` | `:` |
92
+ | `H` | `W` | `?` | `;` |
93
+ | `I` | `X` | `.` | `,` |
94
+ | `J` | `Y` | `+` | `'` |
95
+ | `K` | `Z` | `-` | `"` |
96
+ | `L` | `0` | `_` | ` ` (space) |
97
+ | `M` | `1` | `=` | |
98
+ | `N` | `2` | `@` | |
99
+ | `O` | `3` | `#` | |
100
+
101
+ _The `|` character will be replaced with a line break_
102
+
103
+
104
+ ## Options
105
+
106
+ #### -h, --help
107
+ Type: `<command>`
108
+ Default value: `none`
109
+
110
+ This shows a list of all available options.
111
+
112
+ ```shell
113
+ $ cfonts-node --help
114
+ ```
115
+
116
+ #### -V, --version
117
+ Type: `<command>`
118
+ Default value: `none`
119
+
120
+ This shows the installed version.
121
+
122
+ ```shell
123
+ $ cfonts-node --version
124
+ ```
125
+
126
+ #### text
127
+ Type: `<string>`
128
+ Default value: `""`
129
+
130
+ This is the "text input" to be converted into a nice font.
131
+ The `|` character will be replaced with a line break.
132
+
133
+ ```shell
134
+ $ cfonts-node "Hello world"
135
+ ```
136
+
137
+ #### -f, --font
138
+ Type: `<string>`
139
+ Default value: `"block"`
140
+
141
+ This is the font face you want to use. So far this plugin ships with with following font faces:
142
+
143
+ ```shell
144
+ $ cfonts-node "text" --font "chrome"
145
+ ```
146
+
147
+ #### -a, --align
148
+ Type: `<string>`
149
+ Default value: `"left"`
150
+
151
+ You can align your text in the terminal with this option. Use the keywords below:
152
+
153
+ - `left` _(default)_
154
+ - `center`
155
+ - `right`
156
+ - `top` _(Will be ignored if used with the spaceless option)_
157
+ - `bottom` _(Will be ignored if used with the spaceless option)_
158
+
159
+ ```shell
160
+ $ cfonts-node "text" --align "center"
161
+ ```
162
+
163
+ #### -c, --colors
164
+ Type: `<string list>`
165
+ Default value: `['system']`
166
+
167
+ With this setting you can set the colors for your font.
168
+ Use the below color strings built in by [chalk](https://github.com/chalk/chalk) or a hex color.
169
+ Provide colors in a comma-separated string, eg: `red,blue`. _(no spaces)_
170
+ If you use a hex color make sure you include the `#` prefix. _(In the terminal wrap the hex in quotes)_
171
+ The `system` color falls back to the system color of your terminal.
172
+
173
+ - `system` _(default)_
174
+ - `black`
175
+ - `red`
176
+ - `green`
177
+ - `yellow`
178
+ - `blue`
179
+ - `magenta`
180
+ - `cyan`
181
+ - `white`
182
+ - `gray`
183
+ - `redBright`
184
+ - `greenBright`
185
+ - `yellowBright`
186
+ - `blueBright`
187
+ - `magentaBright`
188
+ - `cyanBright`
189
+ - `whiteBright`
190
+ - `#ff8800` _(any valid hex color)_
191
+ - `#f80` _(short form is supported as well)_
192
+
193
+ ```shell
194
+ $ cfonts-node "text" --colors white,"#f80"
195
+ ```
196
+
197
+ #### -g, --gradient
198
+ Type: `<string list>`
199
+ Default value: `false`
200
+
201
+ With this setting you can set a gradient over your output.
202
+ This setting supersedes the color open.
203
+ The gradient requires two colors, a start color and an end color from left to right.
204
+ _(If you want to set your own colors for the gradient, use the [transition](#-t---transition-gradient) option.)_
205
+ CFonts will then generate a gradient through as many colors as it can find to make the output most impressive.
206
+ Provide two colors in a comma-separated string, eg: `red,blue`. _(no spaces)_
207
+ If you use a hex color make sure you include the `#` prefix. _(In the terminal wrap the hex in quotes)_
208
+
209
+ - `black`
210
+ - `red`
211
+ - `green`
212
+ - `yellow`
213
+ - `blue`
214
+ - `magenta`
215
+ - `cyan`
216
+ - `white`
217
+ - `gray`
218
+ - `grey`
219
+ - `#ff8800` _(any valid hex color)_
220
+ - `#f80` _(short form is supported as well)_
221
+
222
+ ```shell
223
+ $ cfonts "text" --gradient red,"#f80"
224
+ ```
225
+
226
+ #### -i, --independent-gradient
227
+ Type: `<boolean>`
228
+ Default value: `false`
229
+
230
+ Set this option to re-calculate the gradient colors for each new line.
231
+ Only works in combination with the [gradient](#-g---gradient) option.
232
+
233
+ ```shell
234
+ $ cfonts-node "text|next line" --gradient red,"#f80" --independent-gradient
235
+ ```
236
+
237
+
238
+ #### -t, --transition-gradient
239
+ Type: `<boolean>`
240
+ Default value: `false`
241
+
242
+ Set this option to generate your own gradients.
243
+ Each color set in the gradient option will then be transitioned to directly.
244
+ This option allows you to specify more than just two colors for your gradient.
245
+ Only works in combination with the [gradient](#-g---gradient) option.
246
+
247
+ ```shell
248
+ $ cfonts-node "text" --gradient red,"#f80",green,blue --transition-gradient
249
+ ```
250
+
251
+ #### -b, --background
252
+ Type: `<string>`
253
+ Default value: `"transparent"`
254
+
255
+ With this setting you can set the background colors for the output. Use the below color strings built in by [chalk](https://github.com/chalk/chalk).
256
+ Provide the background color from the below supported list, eg: 'white'
257
+
258
+ - `transparent` _(default)_
259
+ - `black`
260
+ - `red`
261
+ - `green`
262
+ - `yellow`
263
+ - `blue`
264
+ - `magenta`
265
+ - `cyan`
266
+ - `white`
267
+ - `blackBright`
268
+ - `redBright`
269
+ - `greenBright`
270
+ - `yellowBright`
271
+ - `blueBright`
272
+ - `magentaBright`
273
+ - `cyanBright`
274
+ - `whiteBright`
275
+
276
+ ```shell
277
+ $ cfonts-node "text" --background "Green"
278
+ ```
279
+
280
+ #### -l, --letter-spacing
281
+ Type: `<integer>`
282
+ Default value: `1`
283
+
284
+ Set this option to widen the space between characters.
285
+
286
+ ```shell
287
+ $ cfonts "text" --letter-spacing 2
288
+ ```
289
+
290
+ #### -z, --line-height
291
+ Type: `<integer>`
292
+ Default value: `1`
293
+
294
+ Set this option to widen the space between lines.
295
+
296
+ ```shell
297
+ $ cfonts-node "text" --line-height 2
298
+ ```
299
+
300
+ #### -s, --spaceless
301
+ Type: `<boolean>`
302
+ Default value: `false`
303
+
304
+ Set this option to false if you don't want the plugin to insert two empty lines on top and on the bottom of the output.
305
+
306
+ ```shell
307
+ $ cfonts-node "text" --spaceless
308
+ ```
309
+
310
+ #### -m, --max-length
311
+ Type: `<integer>`
312
+ Default value: `0`
313
+
314
+ This option sets the maximum characters that will be printed on one line.
315
+ CFonts detects the size of your terminal but you can opt out and determine your own max width.
316
+ `0` means no max width and the text will break at the edge of the terminal window.
317
+
318
+ ```shell
319
+ $ cfonts-node "text" --max-length 15
320
+ ```
321
+
322
+ #### -e, --env
323
+ Type: `<string>`
324
+ Default value: `node`
325
+
326
+ This option lets you use CFonts to generate HTML instead of ANSI code.
327
+ Note that `max-length` won't be automatically detected anymore and you will have to supply it if you want the text to wrap.
328
+ Best used in a node script.
329
+
330
+ ```js
331
+ const CFonts = require('cfonts-node');
332
+ const path = require('path');
333
+ const fs = require('fs');
334
+
335
+ const output = CFonts.render('My text', {
336
+ colors: ['white'],
337
+ gradient: ['cyan', 'red'],
338
+ background: 'black',
339
+ space: false,
340
+ env: 'browser',
341
+ });
342
+
343
+ fs.writeFileSync(
344
+ path.normalize(`${ __dirname }/test.html`),
345
+ output.string,
346
+ {
347
+ encoding: 'utf8',
348
+ }
349
+ );
350
+ ```
351
+
352
+ ## Consistency
353
+ [Chalk](https://github.com/chalk/chalk) detects what colors are supported on your platform.
354
+ It sets a [level of support](https://github.com/chalk/chalk#256-and-truecolor-color-support) automatically.
355
+ In CFonts you can override this by passing in the `FORCE_COLOR` environment variable.
356
+
357
+ ```shell
358
+ FORCE_COLOR=3 cfonts-node "hello world" -c "#0088ff"
359
+ ```
360
+
361
+ ## Contributing
362
+ To build the repo install dependencies via:
363
+ _(Since we ship a `yarn.lock` file please use [`yarn`](https://yarnpkg.com/) for development.)_
364
+
365
+ ```shell
366
+ yarn
367
+ ```
368
+
369
+ and run the watch to continuously transpile the code.
370
+
371
+ ```shell
372
+ yarn watch
373
+ ```
374
+
375
+ Please look at the coding style and work with it, not against it ;)
376
+
377
+
378
+ ## Tests
379
+
380
+ | Platform | Node |
381
+ |----------|--------|
382
+ | Linux | v10 |
383
+ | Linux | v12 |
384
+ | Linux | latest |
385
+ | OSX | v10 |
386
+ | OSX | v12 |
387
+ | OSX | latest |
388
+ | Windows | v10 |
389
+ | Windows | v12 |
390
+ | Windows | latest |
391
+
392
+ ```shell
393
+ npm run test:unit
394
+ ```
395
+
396
+ ### Type tests
397
+ Since the code base uses [JSDocs](https://jsdoc.app/) we use [typescript](https://www.typescriptlang.org/) to test the inferred types from those comments.
398
+ Typescript [supports JSDocs](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
399
+
400
+ ```shell
401
+ npm run test:types
402
+ ```
403
+
404
+ ```shell
405
+ npm run test:fonts
406
+ ```
407
+
408
+ This tool checks:
409
+ - the existence of the font
410
+ - all attributes of a font
411
+ - each character for:
412
+ - existence
413
+ - consistent width
414
+ - consistent lines
415
+
416
+ ### All tests
417
+ Run all tests via:
418
+
419
+ ```shell
420
+ npm run test
421
+ ```
422
+
423
+
424
+ ## Release History
425
+ * 2.10.0 - bumped dependencies, added typescript definitions into npm bundle
426
+ * 2.9.3 - bumped dependencies
427
+ * 2.9.2 - bumped dependencies
428
+ * 2.9.1 - bumped dependencies
429
+ * 2.9.0 - added `top` and `bottom` align options
430
+ * 2.8.6 - bumped dependencies
431
+ * 2.8.5 - renamed branches
432
+ * 2.8.4 - fixed block double quote
433
+ * 2.8.3 - bumped dependencies
434
+ * 2.8.2 - bumped dependencies, added linting, fixed #22 (again)
435
+ * 2.8.1 - bumped dependencies
436
+ * 2.8.0 - added environment support, added font `tiny`
437
+ * 2.7.0 - added font `slick`, `grid` and `pallet`, added double quote to all fonts
438
+ * 2.6.1 - fixed console `maxLength`, `gradient` and `lineHeight`, added more end-to-end tests
439
+ * 2.6.0 - added transition gradients and sets
440
+ * 2.5.2 - fixed jsDocs, added typescript type test
441
+ * 2.5.1 - fixed array output to include everything including colors
442
+ * 2.5.0 - added gradient option, separated code into files, added 100% unit testing coverage
443
+ * 2.4.8 - removed `ansi-styles` from direct dependencies
444
+ * 2.4.7 - fixed bug from adopting chalk v3 and hex colors
445
+ * 2.4.6 - bumped dependencies, removed `change-case` dependency, added `UpperCaseFirst` with tests
446
+ * 2.4.5 - bumped dependencies, moved to relative links for fonts for webpack support (#22)
447
+ * 2.4.4 - bumped dependencies
448
+ * 2.4.3 - bumped dependencies
449
+ * 2.4.2 - bumped dependencies
450
+ * 2.4.1 - updated to babel 7, removed runtime from dependencies
451
+ * 2.4.0 - added font `shade`, added hex color support
452
+ * 2.3.1 - added tests, fixed options, updated dependencies
453
+ * 2.3.0 - added apostrophe support in all fonts
454
+ * 2.2.3 - bumped dependencies
455
+ * 2.2.2 - bumped dependencies
456
+ * 2.2.1 - bumped dependencies
457
+ * 2.2.0 - inside the API you can use line breaks as well as the pipe
458
+ * 2.1.3 - refactored some loops
459
+ * 2.1.2 - made WinSize more robust
460
+ * 2.1.1 - fixed size detection in non-tty environments
461
+ * 2.1.0 - rebuilt cfonts with pure functions, made colors case-insensitive
462
+ * 2.0.1 - fixed terminal width detection
463
+ * 2.0.0 - added tests, split into more pure functions
464
+ * 1.2.0 - added `transparent` and `system` as default background and color option, added `backgroundColor` as alias for `background`, upgraded deps
465
+ * 1.1.3 - fixed help text, removing old -t option
466
+ * 1.1.2 - fixed issue with older commander version #3, updated docs
467
+ * 1.1.1 - moved from `babel-polyfill` to `babel-plugin-transform-runtime`, added files to package.json, added images to docs, fixed dependencies
468
+ * 1.1.0 - transpiled code to support node 0.12.15 and up
469
+ * 1.0.2 - fixed background in `console` font, added comma, added font `huge`, added render method, added candy color
470
+ * 1.0.1 - added `chrome` font, fonttest
471
+ * 1.0.0 - refactor, added alignment and line height option, new cli commands, added `simpleBlock`
472
+ * 0.0.13 - fixed `simple3d`
473
+ * 0.0.12 - fixed `simple3d` and added to grunt test
474
+ * 0.0.11 - added `simple3d` font
475
+ * 0.0.10 - added npmignore, added to docs
476
+ * 0.0.9 - added `console` font
477
+ * 0.0.8 - fixed bugs, docs
478
+ * 0.0.7 - changed to settings object
479
+ * 0.0.6 - added `3d` font
480
+ * 0.0.5 - added grunt test
481
+ * 0.0.4 - fixed `simple` font
482
+ * 0.0.3 - fixes, added `simple` font
483
+ * 0.0.2 - fixed paths
484
+ * 0.0.1 - alpha test