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.
- package/LICENSE +339 -0
- package/README.md +484 -0
- package/fonts/3d.json +658 -0
- package/fonts/block.json +481 -0
- package/fonts/chrome.json +304 -0
- package/fonts/grid.json +481 -0
- package/fonts/huge.json +776 -0
- package/fonts/pallet.json +481 -0
- package/fonts/shade.json +599 -0
- package/fonts/simple.json +363 -0
- package/fonts/simple3d.json +540 -0
- package/fonts/simpleBlock.json +540 -0
- package/fonts/slick.json +481 -0
- package/fonts/tiny.json +245 -0
- package/package.json +117 -0
- package/src/AddChar.js +51 -0
- package/src/AddLetterSpacing.js +59 -0
- package/src/AddLine.js +58 -0
- package/src/AddShortcuts.js +40 -0
- package/src/AlignText.js +68 -0
- package/src/Chalk.js +40 -0
- package/src/CharLength.js +55 -0
- package/src/CheckInput.js +192 -0
- package/src/CleanInput.js +47 -0
- package/src/Color.js +118 -0
- package/src/Colorize.js +84 -0
- package/src/Config.js +1 -0
- package/src/Debugging.js +108 -0
- package/src/DisplayHelp.js +50 -0
- package/src/DisplayVersion.js +31 -0
- package/src/GetFirstCharacterPosition.js +38 -0
- package/src/GetFont.js +49 -0
- package/src/GetLongestLine.js +31 -0
- package/src/Gradient.js +549 -0
- package/src/Log.js +42 -0
- package/src/Options.js +162 -0
- package/src/ParseArgs.js +82 -0
- package/src/RemoveChar.js +0 -0
- package/src/Render.js +257 -0
- package/src/RenderConsole.js +102 -0
- package/src/Say.js +50 -0
- package/src/Size.js +42 -0
- package/src/UpperCaseFirst.js +35 -0
- package/src/bin.js +16 -0
- package/src/constants.js +255 -0
- package/src/index.js +98 -0
package/fonts/tiny.json
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiny",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"homepage": "https://github.com/dominikwilkowski/cfonts",
|
|
5
|
+
"colors": 1,
|
|
6
|
+
"lines": 2,
|
|
7
|
+
"buffer": [
|
|
8
|
+
"",
|
|
9
|
+
""
|
|
10
|
+
],
|
|
11
|
+
"letterspace": [
|
|
12
|
+
" ",
|
|
13
|
+
" "
|
|
14
|
+
],
|
|
15
|
+
"chars": {
|
|
16
|
+
"A": [
|
|
17
|
+
"▄▀█",
|
|
18
|
+
"█▀█"
|
|
19
|
+
],
|
|
20
|
+
"B": [
|
|
21
|
+
"█▄▄",
|
|
22
|
+
"█▄█"
|
|
23
|
+
],
|
|
24
|
+
"C": [
|
|
25
|
+
"█▀▀",
|
|
26
|
+
"█▄▄"
|
|
27
|
+
],
|
|
28
|
+
"D": [
|
|
29
|
+
"█▀▄",
|
|
30
|
+
"█▄▀"
|
|
31
|
+
],
|
|
32
|
+
"E": [
|
|
33
|
+
"█▀▀",
|
|
34
|
+
"██▄"
|
|
35
|
+
],
|
|
36
|
+
"F": [
|
|
37
|
+
"█▀▀",
|
|
38
|
+
"█▀ "
|
|
39
|
+
],
|
|
40
|
+
"G": [
|
|
41
|
+
"█▀▀",
|
|
42
|
+
"█▄█"
|
|
43
|
+
],
|
|
44
|
+
"H": [
|
|
45
|
+
"█ █",
|
|
46
|
+
"█▀█"
|
|
47
|
+
],
|
|
48
|
+
"I": [
|
|
49
|
+
"█",
|
|
50
|
+
"█"
|
|
51
|
+
],
|
|
52
|
+
"J": [
|
|
53
|
+
" █",
|
|
54
|
+
"█▄█"
|
|
55
|
+
],
|
|
56
|
+
"K": [
|
|
57
|
+
"█▄▀",
|
|
58
|
+
"█ █"
|
|
59
|
+
],
|
|
60
|
+
"L": [
|
|
61
|
+
"█ ",
|
|
62
|
+
"█▄▄"
|
|
63
|
+
],
|
|
64
|
+
"M": [
|
|
65
|
+
"█▀▄▀█",
|
|
66
|
+
"█ ▀ █"
|
|
67
|
+
],
|
|
68
|
+
"N": [
|
|
69
|
+
"█▄ █",
|
|
70
|
+
"█ ▀█"
|
|
71
|
+
],
|
|
72
|
+
"O": [
|
|
73
|
+
"█▀█",
|
|
74
|
+
"█▄█"
|
|
75
|
+
],
|
|
76
|
+
"P": [
|
|
77
|
+
"█▀█",
|
|
78
|
+
"█▀▀"
|
|
79
|
+
],
|
|
80
|
+
"Q": [
|
|
81
|
+
"█▀█",
|
|
82
|
+
"▀▀█"
|
|
83
|
+
],
|
|
84
|
+
"R": [
|
|
85
|
+
"█▀█",
|
|
86
|
+
"█▀▄"
|
|
87
|
+
],
|
|
88
|
+
"S": [
|
|
89
|
+
"█▀▀",
|
|
90
|
+
"▄▄█"
|
|
91
|
+
],
|
|
92
|
+
"T": [
|
|
93
|
+
"▀█▀",
|
|
94
|
+
" █ "
|
|
95
|
+
],
|
|
96
|
+
"U": [
|
|
97
|
+
"█ █",
|
|
98
|
+
"█▄█"
|
|
99
|
+
],
|
|
100
|
+
"V": [
|
|
101
|
+
"█ █",
|
|
102
|
+
"▀▄▀"
|
|
103
|
+
],
|
|
104
|
+
"W": [
|
|
105
|
+
"█ █ █",
|
|
106
|
+
"▀▄▀▄▀"
|
|
107
|
+
],
|
|
108
|
+
"X": [
|
|
109
|
+
"▀▄▀",
|
|
110
|
+
"█ █"
|
|
111
|
+
],
|
|
112
|
+
"Y": [
|
|
113
|
+
"█▄█",
|
|
114
|
+
" █ "
|
|
115
|
+
],
|
|
116
|
+
"Z": [
|
|
117
|
+
"▀█",
|
|
118
|
+
"█▄"
|
|
119
|
+
],
|
|
120
|
+
"0": [
|
|
121
|
+
"▞█▚",
|
|
122
|
+
"▚█▞"
|
|
123
|
+
],
|
|
124
|
+
"1": [
|
|
125
|
+
"▄█",
|
|
126
|
+
" █"
|
|
127
|
+
],
|
|
128
|
+
"2": [
|
|
129
|
+
"▀█",
|
|
130
|
+
"█▄"
|
|
131
|
+
],
|
|
132
|
+
"3": [
|
|
133
|
+
"▀▀█",
|
|
134
|
+
"▄██"
|
|
135
|
+
],
|
|
136
|
+
"4": [
|
|
137
|
+
"█ █",
|
|
138
|
+
"▀▀█"
|
|
139
|
+
],
|
|
140
|
+
"5": [
|
|
141
|
+
"█▀",
|
|
142
|
+
"▄█"
|
|
143
|
+
],
|
|
144
|
+
"6": [
|
|
145
|
+
"█▄▄",
|
|
146
|
+
"█▄█"
|
|
147
|
+
],
|
|
148
|
+
"7": [
|
|
149
|
+
"▀▀█",
|
|
150
|
+
" █"
|
|
151
|
+
],
|
|
152
|
+
"8": [
|
|
153
|
+
"███",
|
|
154
|
+
"█▄█"
|
|
155
|
+
],
|
|
156
|
+
"9": [
|
|
157
|
+
"█▀█",
|
|
158
|
+
"▀▀█"
|
|
159
|
+
],
|
|
160
|
+
"!": [
|
|
161
|
+
"█",
|
|
162
|
+
"▄"
|
|
163
|
+
],
|
|
164
|
+
"?": [
|
|
165
|
+
"▀█",
|
|
166
|
+
" ▄"
|
|
167
|
+
],
|
|
168
|
+
".": [
|
|
169
|
+
" ",
|
|
170
|
+
"▄"
|
|
171
|
+
],
|
|
172
|
+
"+": [
|
|
173
|
+
"▄█▄",
|
|
174
|
+
" ▀ "
|
|
175
|
+
],
|
|
176
|
+
"-": [
|
|
177
|
+
"▄▄",
|
|
178
|
+
" "
|
|
179
|
+
],
|
|
180
|
+
"_": [
|
|
181
|
+
" ",
|
|
182
|
+
"▄▄"
|
|
183
|
+
],
|
|
184
|
+
"=": [
|
|
185
|
+
"▀▀",
|
|
186
|
+
"▀▀"
|
|
187
|
+
],
|
|
188
|
+
"@": [
|
|
189
|
+
"▛█▜",
|
|
190
|
+
"▙▟▃"
|
|
191
|
+
],
|
|
192
|
+
"#": [
|
|
193
|
+
"▟▄▙",
|
|
194
|
+
"▜▀▛"
|
|
195
|
+
],
|
|
196
|
+
"$": [
|
|
197
|
+
"▖█▗",
|
|
198
|
+
"▘█▝"
|
|
199
|
+
],
|
|
200
|
+
"%": [
|
|
201
|
+
"▀ ▄▀",
|
|
202
|
+
"▄▀ ▄"
|
|
203
|
+
],
|
|
204
|
+
"&": [
|
|
205
|
+
"▄▄█",
|
|
206
|
+
"█▄█"
|
|
207
|
+
],
|
|
208
|
+
"(": [
|
|
209
|
+
"▄▀",
|
|
210
|
+
"▀▄"
|
|
211
|
+
],
|
|
212
|
+
")": [
|
|
213
|
+
"▀▄",
|
|
214
|
+
"▄▀"
|
|
215
|
+
],
|
|
216
|
+
"/": [
|
|
217
|
+
" ▄▀",
|
|
218
|
+
"▄▀ "
|
|
219
|
+
],
|
|
220
|
+
":": [
|
|
221
|
+
"▀",
|
|
222
|
+
"▄"
|
|
223
|
+
],
|
|
224
|
+
";": [
|
|
225
|
+
" ",
|
|
226
|
+
"▄▀"
|
|
227
|
+
],
|
|
228
|
+
",": [
|
|
229
|
+
" ",
|
|
230
|
+
"█"
|
|
231
|
+
],
|
|
232
|
+
"'": [
|
|
233
|
+
"▀",
|
|
234
|
+
" "
|
|
235
|
+
],
|
|
236
|
+
"\"": [
|
|
237
|
+
"▛ ▜",
|
|
238
|
+
" "
|
|
239
|
+
],
|
|
240
|
+
" ": [
|
|
241
|
+
" ",
|
|
242
|
+
" "
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cfonts-node",
|
|
3
|
+
"description": "Set of available fonts for nodejs projects",
|
|
4
|
+
"version": "2.10.1",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Yuval Moshe"
|
|
7
|
+
},
|
|
8
|
+
"licenses": [
|
|
9
|
+
{
|
|
10
|
+
"type": "GPL-2.0"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=10"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prepublish": "yarn build && yarn test",
|
|
18
|
+
"test": "yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts",
|
|
19
|
+
"test:fonts": "node ./test/fonttest.js",
|
|
20
|
+
"test:watch": "jest --watchAll --coverage",
|
|
21
|
+
"test:unit": "npx cross-env FORCE_COLOR=3 jest",
|
|
22
|
+
"test:types": "yarn types:clean && tsc -p tsconfig.json",
|
|
23
|
+
"test:lint": "eslint src/",
|
|
24
|
+
"build": "yarn build:lib && yarn build:bin",
|
|
25
|
+
"postinstall": "npm run fonts-assist",
|
|
26
|
+
"fonts-assist": "node ./src/Config.js",
|
|
27
|
+
"build:bin": "npx mkdirp bin && mv lib/bin.js bin/index.js",
|
|
28
|
+
"build:lib": "npx mkdirp lib && babel src --out-dir lib",
|
|
29
|
+
"types:clean": "find lib/ -type f -name '*.d.ts' -exec rm {} +",
|
|
30
|
+
"watch": "yarn build:lib && onchange 'src/**/*' -- yarn build:lib",
|
|
31
|
+
"coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls",
|
|
32
|
+
"nuke": "rm -rf lib && rm -rf node_modules && rm yarn.lock"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@babel/cli": "^7.15.4",
|
|
36
|
+
"@babel/core": "^7.15.5",
|
|
37
|
+
"@babel/preset-env": "^7.15.6",
|
|
38
|
+
"@types/node": "latest",
|
|
39
|
+
"coveralls": "^3.1.1",
|
|
40
|
+
"eslint": "^7.32.0",
|
|
41
|
+
"jest-cli": "^27.2.0",
|
|
42
|
+
"onchange": "^7.1.0",
|
|
43
|
+
"typescript": "^4.4.3"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"axios": "^0.26.1",
|
|
47
|
+
"chalk": "^4.1.2",
|
|
48
|
+
"window-size": "^1.1.1"
|
|
49
|
+
},
|
|
50
|
+
"jest": {
|
|
51
|
+
"displayName": "CFonts",
|
|
52
|
+
"testEnvironment": "node",
|
|
53
|
+
"testRegex": "\\.spec.js$",
|
|
54
|
+
"collectCoverageFrom": [
|
|
55
|
+
"src/*.js"
|
|
56
|
+
],
|
|
57
|
+
"setupFiles": [
|
|
58
|
+
"<rootDir>/test/env.js"
|
|
59
|
+
],
|
|
60
|
+
"coverageThreshold": {
|
|
61
|
+
"global": {
|
|
62
|
+
"branches": 95,
|
|
63
|
+
"functions": 100,
|
|
64
|
+
"lines": 95,
|
|
65
|
+
"statements": 95
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"env": {
|
|
71
|
+
"node": true,
|
|
72
|
+
"commonjs": true,
|
|
73
|
+
"es6": true
|
|
74
|
+
},
|
|
75
|
+
"extends": "eslint:recommended",
|
|
76
|
+
"globals": {
|
|
77
|
+
"Atomics": "readonly",
|
|
78
|
+
"SharedArrayBuffer": "readonly"
|
|
79
|
+
},
|
|
80
|
+
"parserOptions": {
|
|
81
|
+
"ecmaVersion": 2018
|
|
82
|
+
},
|
|
83
|
+
"rules": {
|
|
84
|
+
"no-async-promise-executor": "off",
|
|
85
|
+
"no-console": "off",
|
|
86
|
+
"no-unused-vars": [
|
|
87
|
+
"error",
|
|
88
|
+
{
|
|
89
|
+
"argsIgnorePattern": "_"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"browserslist": [
|
|
95
|
+
"node >= 10"
|
|
96
|
+
],
|
|
97
|
+
"keywords": [
|
|
98
|
+
"font",
|
|
99
|
+
"banner",
|
|
100
|
+
"logo",
|
|
101
|
+
"CLI",
|
|
102
|
+
"console",
|
|
103
|
+
"ascii",
|
|
104
|
+
"pretty"
|
|
105
|
+
],
|
|
106
|
+
"files": [
|
|
107
|
+
"lib/*.js",
|
|
108
|
+
"bin/*",
|
|
109
|
+
"fonts/*",
|
|
110
|
+
"src/*"
|
|
111
|
+
],
|
|
112
|
+
"main": "lib/index.js",
|
|
113
|
+
"bin": {
|
|
114
|
+
"cfonts": "./bin/index.js"
|
|
115
|
+
},
|
|
116
|
+
"license": "GPL-2.0"
|
|
117
|
+
}
|
package/src/AddChar.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
* AddChar
|
|
12
|
+
* Add a new character to the output array
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { Debugging } = require('./Debugging.js');
|
|
19
|
+
const { Colorize } = require('./Colorize.js');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Add a new character to the output array
|
|
24
|
+
*
|
|
25
|
+
* @param {string} CHAR - The character to be added
|
|
26
|
+
* @param {array} output - The output array the line shall be appended to
|
|
27
|
+
* @param {number} fontLines - The number of lines this font has per character
|
|
28
|
+
* @param {object} fontChars - An object with all character arrays
|
|
29
|
+
* @param {number} fontColors - The amount of colors allowed for this font
|
|
30
|
+
* @param {object} colors - Our options
|
|
31
|
+
*
|
|
32
|
+
* @return {array} - The output array with new line
|
|
33
|
+
*/
|
|
34
|
+
const AddChar = ( CHAR, output, fontLines, fontChars, fontColors, colors ) => {
|
|
35
|
+
Debugging.report( `Running AddChar with "${ CHAR }"`, 1 );
|
|
36
|
+
|
|
37
|
+
let lines = output.length - fontLines; // last line is fontLines tall and is located at the bottom of the output array
|
|
38
|
+
|
|
39
|
+
for( let i = lines; i < output.length; i++ ) { // iterate over last line
|
|
40
|
+
let index = i - lines;
|
|
41
|
+
|
|
42
|
+
output[ i ] += Colorize( fontChars[ CHAR ][ index ], fontColors, colors );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
module.exports = exports = {
|
|
50
|
+
AddChar,
|
|
51
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
* AddLetterSpacing
|
|
12
|
+
* Add letter spacing for the next character
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { Debugging } = require('./Debugging.js');
|
|
19
|
+
const { Colorize } = require('./Colorize.js');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Add letter spacing for the next character
|
|
25
|
+
*
|
|
26
|
+
* @param {array} output - The output array the line shall be appended to
|
|
27
|
+
* @param {number} fontLines - The number of lines this font has per character
|
|
28
|
+
* @param {array} fontLetterspace - A space between the letters
|
|
29
|
+
* @param {number} fontColors - The amount of colors allowed for this font
|
|
30
|
+
* @param {array} colors - The user defined colors
|
|
31
|
+
* @param {number} letterSpacing - The user defined letter spacing
|
|
32
|
+
*
|
|
33
|
+
* @return {array} - The output array with space
|
|
34
|
+
*/
|
|
35
|
+
const AddLetterSpacing = ( output, fontLines, fontLetterspace, fontColors, colors, letterSpacing ) => {
|
|
36
|
+
Debugging.report( `Running AddLetterSpacing`, 1 );
|
|
37
|
+
|
|
38
|
+
let lines = output.length - fontLines; // last line is fontLines tall and is located at the bottom of the output array
|
|
39
|
+
|
|
40
|
+
for( let i = lines; i < output.length; i++ ) { // iterate over last line
|
|
41
|
+
let index = i - lines;
|
|
42
|
+
let space = Colorize( fontLetterspace[ index ], fontColors, colors );
|
|
43
|
+
|
|
44
|
+
if( space.length === 0 && letterSpacing > 0 ) {
|
|
45
|
+
Debugging.report( `AddLetterSpacing: Adding space to letter spacing`, 1 );
|
|
46
|
+
|
|
47
|
+
space = ' ';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
output[ i ] += space.repeat( letterSpacing );
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return output;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
module.exports = exports = {
|
|
58
|
+
AddLetterSpacing,
|
|
59
|
+
};
|
package/src/AddLine.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
* AddLine
|
|
12
|
+
* Add a new line to the output array
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { Debugging } = require('./Debugging.js');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Add a new line to the output array
|
|
23
|
+
*
|
|
24
|
+
* @param {array} output - The output array the line shall be appended to
|
|
25
|
+
* @param {number} fontLines - The number of lines this font has per character
|
|
26
|
+
* @param {array} FontBuffer - An array of the space we add at the beginning of each line
|
|
27
|
+
* @param {number} lineHeight - The user defined line height
|
|
28
|
+
*
|
|
29
|
+
* @return {array} - The output array with new line
|
|
30
|
+
*/
|
|
31
|
+
const AddLine = ( output, fontLines, FontBuffer, lineHeight ) => {
|
|
32
|
+
Debugging.report( `Running AddLine`, 1 );
|
|
33
|
+
|
|
34
|
+
if( output.length === 0 ) {
|
|
35
|
+
lineHeight = 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let lines = fontLines + output.length + lineHeight;
|
|
39
|
+
let length = output.length;
|
|
40
|
+
|
|
41
|
+
for( let i = length; i < lines; i++ ) {
|
|
42
|
+
let index = i - length;
|
|
43
|
+
|
|
44
|
+
if( index > lineHeight ) {
|
|
45
|
+
output[ i ] = FontBuffer[ ( index - lineHeight ) ];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
output[ i ] = '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return output;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
module.exports = exports = {
|
|
57
|
+
AddLine,
|
|
58
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* AddShortcuts
|
|
12
|
+
* Flatten the shortcuts in our cli options object
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Flatten the shortcuts in our cli options object
|
|
21
|
+
*
|
|
22
|
+
* @param {object} options - An object objects with a short key
|
|
23
|
+
*
|
|
24
|
+
* @return {object} - All short keys flattened into first level
|
|
25
|
+
*/
|
|
26
|
+
const AddShortcuts = ( options ) => {
|
|
27
|
+
const flatOptions = Object.assign( {}, options );
|
|
28
|
+
|
|
29
|
+
Object.keys( flatOptions ).forEach( option => {
|
|
30
|
+
flatOptions[ option ]._name = option;
|
|
31
|
+
flatOptions[ flatOptions[ option ].short ] = flatOptions[ option ];
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return flatOptions;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
module.exports = exports = {
|
|
39
|
+
AddShortcuts,
|
|
40
|
+
};
|
package/src/AlignText.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
* AlignText
|
|
12
|
+
* Calculate the spaces to be added to the left of each line to align them either center or right
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const { Debugging } = require('./Debugging.js');
|
|
19
|
+
const { Size } = require('./Size.js');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Calculate the spaces to be added to the left of each line to align them either center or right
|
|
24
|
+
*
|
|
25
|
+
* @param {array} output - The output array the line shall be appended to
|
|
26
|
+
* @param {number} lineLength - The current line length
|
|
27
|
+
* @param {number} characterLines - The amount of line breaks in one character
|
|
28
|
+
* @param {string} align - The alignment of the text, only `center` and `right` will do anything
|
|
29
|
+
* @param {object} size - The size of the terminal as an object, default: Size
|
|
30
|
+
* @param {number} size.width - The width of the terminal
|
|
31
|
+
* @param {number} size.height - The height of the terminal
|
|
32
|
+
*
|
|
33
|
+
* @return {array} - The output array with space added on the left for alignment
|
|
34
|
+
*/
|
|
35
|
+
const AlignText = ( output, lineLength, characterLines, align, size = Size ) => {
|
|
36
|
+
Debugging.report( `Running AlignText`, 1 );
|
|
37
|
+
|
|
38
|
+
let space = 0;
|
|
39
|
+
|
|
40
|
+
if( align === 'center' ) { // calculate the size for center alignment
|
|
41
|
+
space = Math.floor( ( size.width - lineLength ) / 2 );
|
|
42
|
+
|
|
43
|
+
Debugging.report( `AlignText: Center lineLength: ${ lineLength }, size.width: ${ size.width }, space: ${ space }`, 2 );
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if( align === 'right' ) { // calculate the size for right alignment
|
|
47
|
+
space = size.width - lineLength;
|
|
48
|
+
|
|
49
|
+
Debugging.report( `AlignText: Right lineLength: ${ lineLength }, size.width: ${ size.width }, space: ${ space }`, 2 );
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if( space > 0 ) { // only add if there is something to add
|
|
54
|
+
let lines = output.length - characterLines; // last line is characterLines tall and is located at the bottom of the output array
|
|
55
|
+
const spaces = ' '.repeat( space );
|
|
56
|
+
|
|
57
|
+
for( let i = lines; i < output.length; i++ ) { // iterate over last line (which can be several line breaks long)
|
|
58
|
+
output[ i ] = spaces + output[ i ];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return output;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
module.exports = exports = {
|
|
67
|
+
AlignText,
|
|
68
|
+
};
|
package/src/Chalk.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
* Chalk
|
|
12
|
+
* We pass on the FORCE_COLOR env var to chalk so we can force it in ci
|
|
13
|
+
*
|
|
14
|
+
**************************************************************************************************************************************************************/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const chalkOriginal = require(`chalk`);
|
|
19
|
+
|
|
20
|
+
// all possible level of chalk: https://github.com/chalk/chalk#chalklevel
|
|
21
|
+
const level = {
|
|
22
|
+
'0': 0, // All colors disabled
|
|
23
|
+
'1': 1, // Basic 16 colors support
|
|
24
|
+
'2': 2, // ANSI 256 colors support
|
|
25
|
+
'3': 3, // Truecolor 16 million colors support
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// We pass on the FORCE_COLOR env var to chalk so we can force it in ci
|
|
29
|
+
const Chalk = new chalkOriginal.Instance({
|
|
30
|
+
...(
|
|
31
|
+
process.env.FORCE_COLOR
|
|
32
|
+
? { level: level[ process.env.FORCE_COLOR ] }
|
|
33
|
+
: null
|
|
34
|
+
)
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
module.exports = exports = {
|
|
39
|
+
Chalk,
|
|
40
|
+
};
|