@barekey/cli 0.5.2 → 0.5.5
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.
- package/dist/output/avatar.js +6 -3
- package/package.json +1 -1
- package/src/output/avatar.ts +8 -3
package/dist/output/avatar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Jimp } from "jimp";
|
|
2
|
-
const DEFAULT_AVATAR_COLUMNS =
|
|
2
|
+
const DEFAULT_AVATAR_COLUMNS = 8;
|
|
3
3
|
const DEFAULT_AVATAR_ROWS = 8;
|
|
4
4
|
function supportsAnsiAvatar() {
|
|
5
5
|
if (!process.stdout.isTTY) {
|
|
@@ -66,7 +66,6 @@ async function renderAvatarLines(imageUrl) {
|
|
|
66
66
|
w: DEFAULT_AVATAR_COLUMNS,
|
|
67
67
|
h: bitmapRows,
|
|
68
68
|
});
|
|
69
|
-
image.circle();
|
|
70
69
|
const { data, width, height } = image.bitmap;
|
|
71
70
|
const lines = [];
|
|
72
71
|
for (let y = 0; y < height; y += 2) {
|
|
@@ -82,10 +81,14 @@ async function renderAvatarLines(imageUrl) {
|
|
|
82
81
|
}
|
|
83
82
|
function joinAvatarAndText(avatarLines, textLines) {
|
|
84
83
|
const totalRows = Math.max(avatarLines.length, textLines.length);
|
|
84
|
+
const textOffset = avatarLines.length > textLines.length
|
|
85
|
+
? Math.floor((avatarLines.length - textLines.length) / 2)
|
|
86
|
+
: 0;
|
|
85
87
|
const renderedRows = [];
|
|
86
88
|
for (let index = 0; index < totalRows; index += 1) {
|
|
87
89
|
const avatarLine = avatarLines[index] ?? " ".repeat(DEFAULT_AVATAR_COLUMNS);
|
|
88
|
-
const
|
|
90
|
+
const textIndex = index - textOffset;
|
|
91
|
+
const textLine = textIndex >= 0 && textIndex < textLines.length ? (textLines[textIndex] ?? "") : "";
|
|
89
92
|
renderedRows.push(textLine.length > 0 ? `${avatarLine} ${textLine}` : avatarLine);
|
|
90
93
|
}
|
|
91
94
|
return renderedRows.join("\n");
|
package/package.json
CHANGED
package/src/output/avatar.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Jimp } from "jimp";
|
|
2
2
|
|
|
3
|
-
const DEFAULT_AVATAR_COLUMNS =
|
|
3
|
+
const DEFAULT_AVATAR_COLUMNS = 8;
|
|
4
4
|
const DEFAULT_AVATAR_ROWS = 8;
|
|
5
5
|
|
|
6
6
|
type Rgba = {
|
|
@@ -92,7 +92,6 @@ async function renderAvatarLines(imageUrl: string): Promise<Array<string>> {
|
|
|
92
92
|
w: DEFAULT_AVATAR_COLUMNS,
|
|
93
93
|
h: bitmapRows,
|
|
94
94
|
});
|
|
95
|
-
image.circle();
|
|
96
95
|
|
|
97
96
|
const { data, width, height } = image.bitmap;
|
|
98
97
|
const lines: Array<string> = [];
|
|
@@ -115,11 +114,17 @@ function joinAvatarAndText(
|
|
|
115
114
|
textLines: Array<string>,
|
|
116
115
|
): string {
|
|
117
116
|
const totalRows = Math.max(avatarLines.length, textLines.length);
|
|
117
|
+
const textOffset =
|
|
118
|
+
avatarLines.length > textLines.length
|
|
119
|
+
? Math.floor((avatarLines.length - textLines.length) / 2)
|
|
120
|
+
: 0;
|
|
118
121
|
const renderedRows: Array<string> = [];
|
|
119
122
|
|
|
120
123
|
for (let index = 0; index < totalRows; index += 1) {
|
|
121
124
|
const avatarLine = avatarLines[index] ?? " ".repeat(DEFAULT_AVATAR_COLUMNS);
|
|
122
|
-
const
|
|
125
|
+
const textIndex = index - textOffset;
|
|
126
|
+
const textLine =
|
|
127
|
+
textIndex >= 0 && textIndex < textLines.length ? (textLines[textIndex] ?? "") : "";
|
|
123
128
|
renderedRows.push(textLine.length > 0 ? `${avatarLine} ${textLine}` : avatarLine);
|
|
124
129
|
}
|
|
125
130
|
|