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/src/Size.js ADDED
@@ -0,0 +1,42 @@
1
+ /***************************************************************************************************************************************************************
2
+ *
3
+ * cfonts
4
+ *
5
+ * Sexy fonts for the console. (CLI output)
6
+ *
7
+ * @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2
8
+ * @author Dominik Wilkowski hi@dominik-wilkowski.com
9
+ * @repository https://github.com/dominikwilkowski/cfonts
10
+ *
11
+ * Size
12
+ * Abstraction for windows size
13
+ *
14
+ **************************************************************************************************************************************************************/
15
+
16
+ 'use strict';
17
+
18
+ const WinSize = require('window-size');
19
+
20
+
21
+ /**
22
+ * Abstraction for windows size
23
+ *
24
+ * @type {object}
25
+ */
26
+ const Size = {
27
+ width: WinSize
28
+ ? WinSize.width > 0
29
+ ? WinSize.width
30
+ : 80
31
+ : 80,
32
+ height: WinSize
33
+ ? WinSize.height > 0
34
+ ? WinSize.height
35
+ : 24
36
+ : 24,
37
+ };
38
+
39
+
40
+ module.exports = exports = {
41
+ Size,
42
+ };
@@ -0,0 +1,35 @@
1
+ /***************************************************************************************************************************************************************
2
+ *
3
+ * cfonts
4
+ *
5
+ * Sexy fonts for the console. (CLI output)
6
+ *
7
+ * @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2
8
+ * @author Dominik Wilkowski hi@dominik-wilkowski.com
9
+ * @repository https://github.com/dominikwilkowski/cfonts
10
+ *
11
+ * UpperCaseFirst
12
+ * Upper case the first character of an input string
13
+ *
14
+ **************************************************************************************************************************************************************/
15
+
16
+ 'use strict';
17
+
18
+
19
+ /**
20
+ * Upper case the first character of an input string.
21
+ *
22
+ * @author https://github.com/blakeembrey/change-case/tree/master/packages/upper-case-first
23
+ *
24
+ * @param {string} input - A string to be converted
25
+ *
26
+ * @return {string} - A string with the first letter in upper case
27
+ */
28
+ const UpperCaseFirst = input => typeof input === 'string'
29
+ ? input.charAt(0).toUpperCase() + input.substr(1)
30
+ : input;
31
+
32
+
33
+ module.exports = exports = {
34
+ UpperCaseFirst,
35
+ };
package/src/bin.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /***************************************************************************************************************************************************************
3
+ *
4
+ * cfonts
5
+ *
6
+ * Sexy fonts for the console. (CLI output)
7
+ *
8
+ * @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2
9
+ * @author Dominik Wilkowski hi@dominik-wilkowski.com
10
+ * @repository https://github.com/dominikwilkowski/cfonts
11
+ *
12
+ **************************************************************************************************************************************************************/
13
+
14
+ 'use strict';
15
+
16
+ require('../lib/index.js').Cli();
@@ -0,0 +1,255 @@
1
+ /***************************************************************************************************************************************************************
2
+ *
3
+ * cfonts
4
+ *
5
+ * Sexy fonts for the console. (CLI output)
6
+ *
7
+ * @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2
8
+ * @author Dominik Wilkowski hi@dominik-wilkowski.com
9
+ * @repository https://github.com/dominikwilkowski/cfonts
10
+ *
11
+ * Constants
12
+ * CHARS
13
+ * COLORS
14
+ * BGCOLORS
15
+ * GRADIENTCOLORS
16
+ * ALIGNMENT
17
+ * FONTFACES
18
+ * CLIOPTIONS
19
+ * PACKAGE
20
+ * HEXTEST
21
+ *
22
+ **************************************************************************************************************************************************************/
23
+
24
+ 'use strict';
25
+
26
+ const { Chalk } = require('./Chalk.js');
27
+
28
+
29
+ // global defaults
30
+ const CHARS = [
31
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
32
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "|",
33
+ "!", "?", ".", "+", "-", "_", "=", "@", "#", "$", "%", "&", "(", ")", "/", ":", ";", ",", " ", "'", "\"",
34
+ ];
35
+
36
+ const COLORS = {
37
+ system: 'system',
38
+ black: 'black',
39
+ red: 'red',
40
+ green: 'green',
41
+ yellow: 'yellow',
42
+ blue: 'blue',
43
+ magenta: 'magenta',
44
+ cyan: 'cyan',
45
+ white: 'white',
46
+ gray: 'gray',
47
+ redbright: 'redBright',
48
+ greenbright: 'greenBright',
49
+ yellowbright: 'yellowBright',
50
+ bluebright: 'blueBright',
51
+ magentabright: 'magentaBright',
52
+ cyanbright: 'cyanBright',
53
+ whitebright: 'whiteBright',
54
+ };
55
+
56
+ const BGCOLORS = {
57
+ transparent: 'transparent',
58
+ black: 'black',
59
+ red: 'red',
60
+ green: 'green',
61
+ yellow: 'yellow',
62
+ blue: 'blue',
63
+ magenta: 'magenta',
64
+ cyan: 'cyan',
65
+ white: 'white',
66
+ blackbright: 'blackBright',
67
+ redbright: 'redBright',
68
+ greenbright: 'greenBright',
69
+ yellowbright: 'yellowBright',
70
+ bluebright: 'blueBright',
71
+ magentabright: 'magentaBright',
72
+ cyanbright: 'cyanBright',
73
+ whitebright: 'whiteBright',
74
+ };
75
+
76
+ const GRADIENTCOLORS = {
77
+ transparent: 'transparent',
78
+ black: 'black',
79
+ red: 'red',
80
+ green: 'green',
81
+ yellow: 'yellow',
82
+ blue: 'blue',
83
+ magenta: 'magenta',
84
+ cyan: 'cyan',
85
+ white: 'white',
86
+ };
87
+
88
+ const GRADIENTS = {
89
+ lgbt: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
90
+ lgbtq: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
91
+ pride: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
92
+ agender: [ '#000000', '#b9b9b9', '#ffffff', '#b8f483', '#ffffff', '#b9b9b9', '#000000' ],
93
+ aromantic: [ '#3da542', '#a7d379', '#ffffff', '#a9a9a9', '#000000' ],
94
+ asexual: [ '#000000', '#a3a3a3', '#ffffff', '#800080' ],
95
+ bisexual: [ '#d60270', '#d60270', '#9b4f96', '#0038a8', '#0038a8' ],
96
+ genderfluid: [ '#ff75a2', '#ffffff', '#be18d6', '#000000', '#333ebd' ],
97
+ genderqueer: [ '#b57edc', '#ffffff', '#4a8123' ],
98
+ intersex: [ '#ffd800', '#ffd800', '#7902aa', '#ffd800', '#ffd800' ],
99
+ lesbian: [ '#d52d00', '#ff9a56', '#ffffff', '#d362a4', '#a30262' ],
100
+ nonbinary: [ '#fcf434', '#ffffff', '#9c5cd4', '#2c2c2c' ],
101
+ pansexual: [ '#ff218c', '#ffd800', '#21b1ff' ],
102
+ polysexual: [ '#f61cb9', '#07d569', '#1c92f6' ],
103
+ transgender: [ '#5bcefa', '#f5a9b8', '#ffffff', '#f5a9b8', '#5bcefa' ],
104
+ };
105
+
106
+ const ALIGNMENT = [
107
+ 'left',
108
+ 'center',
109
+ 'right',
110
+ 'top',
111
+ 'bottom',
112
+ ];
113
+
114
+ const FONTFACES = {
115
+ console: 'console',
116
+ block: 'block',
117
+ simpleblock: 'simpleBlock',
118
+ simple: 'simple',
119
+ '3d': '3d',
120
+ simple3d: 'simple3d',
121
+ chrome: 'chrome',
122
+ huge: 'huge',
123
+ shade: 'shade',
124
+ slick: 'slick',
125
+ grid: 'grid',
126
+ pallet: 'pallet',
127
+ tiny: 'tiny',
128
+ };
129
+
130
+ const CLIOPTIONS = {
131
+ '--version': {
132
+ description: 'Use to display the version of cfonts',
133
+ example: '--version',
134
+ short: '-v',
135
+ default: false,
136
+ },
137
+ '--help': {
138
+ description: 'Use to display this help',
139
+ example: '--help',
140
+ short: '-h',
141
+ default: false,
142
+ },
143
+ '--font': {
144
+ description: 'Use to define the font face',
145
+ example: `--font block ${ Chalk.green(`( ${ Object.keys( FONTFACES ).map( font => FONTFACES[ font ] ).join(', ') } )`) }`,
146
+ short: '-f',
147
+ options: Object.keys( FONTFACES ).map( color => FONTFACES[ color ] ),
148
+ default: 'block',
149
+ },
150
+ '--colors': {
151
+ description: 'Use to define the font color',
152
+ example: `--colors red ${ Chalk.green(`( ${ Object.keys( COLORS ).map( color => COLORS[ color ] ).join(', ') }, #ff8800, hex-colors etc... )`) }`,
153
+ short: '-c',
154
+ options: true,
155
+ default: 'system',
156
+ },
157
+ '--background': {
158
+ description: 'Use to define background color',
159
+ example: `--background blue ${ Chalk.green(`( ${ Object.keys( BGCOLORS ).map( bgcolor => BGCOLORS[ bgcolor ] ).join(', ') } )`) }`,
160
+ short: '-b',
161
+ options: Object.keys( BGCOLORS ).map( color => BGCOLORS[ color ] ),
162
+ default: 'transparent',
163
+ },
164
+ '--align': {
165
+ description: 'Use to align your text output',
166
+ example: `--align ${ Chalk.green(`( ${ ALIGNMENT.join(', ') } )`) }`,
167
+ short: '-a',
168
+ options: ALIGNMENT,
169
+ default: 'left',
170
+ },
171
+ '--letter-spacing': {
172
+ description: 'Use to define your letter spacing',
173
+ example: '--letter-spacing 2',
174
+ short: '-l',
175
+ options: true,
176
+ default: undefined,
177
+ },
178
+ '--line-height': {
179
+ description: 'Use to define your line height',
180
+ example: '--line-height 5',
181
+ short: '-z',
182
+ options: true,
183
+ default: undefined,
184
+ },
185
+ '--spaceless': {
186
+ description: 'Use to disable the padding around your output',
187
+ example: '--spaceless',
188
+ short: '-s',
189
+ default: false,
190
+ },
191
+ '--max-length': {
192
+ description: 'Use to define the amount of maximum characters per line',
193
+ example: '--max-length 10',
194
+ short: '-m',
195
+ options: true,
196
+ default: 0,
197
+ },
198
+ '--gradient': {
199
+ description: 'Use to define a start and end color of a gradient',
200
+ example: '--gradient red,blue',
201
+ short: '-g',
202
+ options: true,
203
+ default: false,
204
+ },
205
+ '--independent-gradient': {
206
+ description: 'Use to define that a gradient is applied independently for each line',
207
+ example: '--gradient red,blue --independent-gradient',
208
+ short: '-i',
209
+ default: false,
210
+ },
211
+ '--transition-gradient': {
212
+ description: 'Use to define that a gradient is a transition between the colors',
213
+ example: '--gradient red,blue,green --transition-gradient',
214
+ short: '-t',
215
+ default: false,
216
+ },
217
+ '--env': {
218
+ description: 'Use to define what environment you run CFonts in.',
219
+ example: `--env ${ Chalk.green('"node", "browser"') }`,
220
+ short: '-e',
221
+ options: true,
222
+ default: 'node',
223
+ },
224
+ '--debug': {
225
+ description: 'Use to enable debug mode',
226
+ example: '--debug',
227
+ short: '-d',
228
+ default: false,
229
+ },
230
+ '--debug-level': {
231
+ description: 'Use to define the debug level. The higher, the less debug infos',
232
+ example: '--debug-level 2',
233
+ short: '-x',
234
+ options: true,
235
+ default: 1,
236
+ },
237
+ };
238
+
239
+ const PACKAGE = require('../package.json');
240
+
241
+ const HEXTEST = RegExp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$');
242
+
243
+
244
+ module.exports = exports = {
245
+ CHARS,
246
+ COLORS,
247
+ BGCOLORS,
248
+ GRADIENTCOLORS,
249
+ GRADIENTS,
250
+ ALIGNMENT,
251
+ FONTFACES,
252
+ CLIOPTIONS,
253
+ PACKAGE,
254
+ HEXTEST,
255
+ };
package/src/index.js ADDED
@@ -0,0 +1,98 @@
1
+ /***************************************************************************************************************************************************************
2
+ *
3
+ * cfonts
4
+ *
5
+ * Sexy fonts for the console. (CLI output)
6
+ *
7
+ * @license https://github.com/dominikwilkowski/cfonts/blob/released/LICENSE GNU GPLv2
8
+ * @author Dominik Wilkowski hi@dominik-wilkowski.com
9
+ * @repository https://github.com/dominikwilkowski/cfonts
10
+ *
11
+ * Cli
12
+ * Run cli commands
13
+ *
14
+ **************************************************************************************************************************************************************/
15
+
16
+ 'use strict';
17
+
18
+ const { DisplayVersion } = require('./DisplayVersion.js');
19
+ const { DisplayHelp } = require('./DisplayHelp.js');
20
+ const { CLIOPTIONS } = require('./constants.js');
21
+ const { Debugging } = require('./Debugging.js');
22
+ const { ParseArgs } = require('./ParseArgs.js');
23
+ const { Render } = require('./Render.js');
24
+ const { Chalk } = require('./Chalk.js');
25
+ const { Log } = require('./Log.js');
26
+ const { Say } = require('./Say.js');
27
+
28
+
29
+ /**
30
+ * Run cli commands
31
+ *
32
+ * @param {object} inputOptions - All possible options registered for this app
33
+ * @param {array} inputArgs - The arguments given to us in our cli, default: process.argv
34
+ */
35
+ const Cli = ( inputOptions = CLIOPTIONS, inputArgs = process.argv ) => {
36
+ const args = ParseArgs( inputOptions, inputArgs );
37
+
38
+ Debugging.report(
39
+ `OPTIONS:\n` +
40
+ ` CFonts.say("${ args.text }", {\n` +
41
+ ` font: "${ args.font }",\n` +
42
+ ` align: "${ args.align }",\n` +
43
+ ` colors: ${ args.colors ? JSON.stringify( args.colors.split(',') ) : [] },\n` +
44
+ ` background: "${ args.background }",\n` +
45
+ ` letterSpacing: ${ args['letter-spacing'] },\n` +
46
+ ` lineHeight: ${ args['line-height'] },\n` +
47
+ ` space: ${ !args.spaceless },\n` +
48
+ ` maxLength: ${ args['max-length'] },\n` +
49
+ ` gradient: ${ args.gradient },\n` +
50
+ ` independentGradient: ${ args['independent-gradient'] },\n` +
51
+ ` transitionGradient: ${ args['transition-gradient'] },\n` +
52
+ ` env: ${ args.env },\n` +
53
+ ` }, ${ args.debug }, ${ args.debugLevel } );`,
54
+ 3,
55
+ args.debug,
56
+ args.debugLevel
57
+ );
58
+
59
+ if( args.help ) {
60
+ DisplayHelp();
61
+ return;
62
+ }
63
+
64
+ if( args.version ) {
65
+ DisplayVersion();
66
+ return;
67
+ }
68
+
69
+ if( !args.text ) {
70
+ Log.error(
71
+ `Please provide text to convert with ${ Chalk.green(`cfonts "Text"`) }\n` +
72
+ `Run ${ Chalk.green(`cfonts --help`) } for more infos`
73
+ );
74
+ return;
75
+ }
76
+
77
+ Say( args.text, {
78
+ font: args.font,
79
+ align: args.align,
80
+ colors: args.colors ? args.colors.split(',') : [],
81
+ background: args.background,
82
+ letterSpacing: args['letter-spacing'],
83
+ lineHeight: args['line-height'],
84
+ space: !args.spaceless,
85
+ maxLength: args['max-length'],
86
+ gradient: args.gradient,
87
+ independentGradient: args['independent-gradient'],
88
+ transitionGradient: args['transition-gradient'],
89
+ env: args.env,
90
+ }, args.debug, args.debugLevel );
91
+ };
92
+
93
+
94
+ module.exports = exports = {
95
+ render: Render,
96
+ say: Say,
97
+ Cli,
98
+ };