ccgather 2.0.15 → 2.0.17
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/index.js +20 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -117,8 +117,11 @@ function createBox(lines, width = 47) {
|
|
|
117
117
|
const bottom = colors.dim(` ${box.bottomLeft}${box.horizontal.repeat(width)}${box.bottomRight}`);
|
|
118
118
|
return [top, ...paddedLines.map((l) => colors.dim(" ") + l), bottom].join("\n");
|
|
119
119
|
}
|
|
120
|
+
function _stripAnsi(str) {
|
|
121
|
+
return str.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
|
|
122
|
+
}
|
|
120
123
|
function getDisplayWidth(str) {
|
|
121
|
-
const stripped =
|
|
124
|
+
const stripped = _stripAnsi(str);
|
|
122
125
|
let width = (0, import_string_width.default)(stripped);
|
|
123
126
|
const emojiRegex = /[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]|✦/gu;
|
|
124
127
|
const emojis = stripped.match(emojiRegex);
|
|
@@ -240,7 +243,7 @@ async function printAnimatedHeader() {
|
|
|
240
243
|
}
|
|
241
244
|
console.log();
|
|
242
245
|
}
|
|
243
|
-
async function slotMachineRank(finalRank, label, medal, iterations = 12) {
|
|
246
|
+
async function slotMachineRank(finalRank, label, medal, iterations = 12, previousRank) {
|
|
244
247
|
const maxRank = Math.max(finalRank * 3, 100);
|
|
245
248
|
for (let i = 0; i < iterations; i++) {
|
|
246
249
|
const fakeRank = Math.floor(Math.random() * maxRank) + 1;
|
|
@@ -250,8 +253,17 @@ async function slotMachineRank(finalRank, label, medal, iterations = 12) {
|
|
|
250
253
|
);
|
|
251
254
|
await sleep(speed);
|
|
252
255
|
}
|
|
256
|
+
let changeText = "";
|
|
257
|
+
if (previousRank && previousRank !== finalRank) {
|
|
258
|
+
const change = previousRank - finalRank;
|
|
259
|
+
if (change > 0) {
|
|
260
|
+
changeText = ` ${colors.success(`\u2191${change}`)}`;
|
|
261
|
+
} else if (change < 0) {
|
|
262
|
+
changeText = ` ${colors.error(`\u2193${Math.abs(change)}`)}`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
253
265
|
process.stdout.write(
|
|
254
|
-
`\r ${medal} ${colors.muted(label)} ${colors.primary.bold(`#${finalRank}`)}
|
|
266
|
+
`\r ${medal} ${colors.muted(label)} ${colors.primary.bold(`#${finalRank}`)}${changeText}
|
|
255
267
|
`
|
|
256
268
|
);
|
|
257
269
|
}
|
|
@@ -304,7 +316,7 @@ var init_ui = __esm({
|
|
|
304
316
|
"use strict";
|
|
305
317
|
import_chalk = __toESM(require("chalk"));
|
|
306
318
|
import_string_width = __toESM(require("string-width"));
|
|
307
|
-
VERSION = true ? "2.0.
|
|
319
|
+
VERSION = true ? "2.0.17" : "0.0.0";
|
|
308
320
|
colors = {
|
|
309
321
|
primary: import_chalk.default.hex("#DA7756"),
|
|
310
322
|
// Claude coral
|
|
@@ -1452,13 +1464,15 @@ async function submit(options) {
|
|
|
1452
1464
|
console.log();
|
|
1453
1465
|
console.log(sectionHeader("\u{1F4CA}", "Your Ranking"));
|
|
1454
1466
|
console.log();
|
|
1467
|
+
const prevGlobalRank = result.previous?.previousGlobalRank;
|
|
1468
|
+
const prevCountryRank = result.previous?.previousCountryRank;
|
|
1455
1469
|
if (result.rank) {
|
|
1456
1470
|
const medal = result.rank === 1 ? "\u{1F947}" : result.rank === 2 ? "\u{1F948}" : result.rank === 3 ? "\u{1F949}" : result.rank <= 10 ? "\u{1F3C5}" : "\u{1F30D}";
|
|
1457
|
-
await slotMachineRank(result.rank, "Global:", medal);
|
|
1471
|
+
await slotMachineRank(result.rank, "Global:", medal, 12, prevGlobalRank);
|
|
1458
1472
|
}
|
|
1459
1473
|
if (result.countryRank) {
|
|
1460
1474
|
const countryMedal = result.countryRank === 1 ? "\u{1F947}" : result.countryRank <= 3 ? "\u{1F3C6}" : "\u{1F3E0}";
|
|
1461
|
-
await slotMachineRank(result.countryRank, "Country:", countryMedal, 10);
|
|
1475
|
+
await slotMachineRank(result.countryRank, "Country:", countryMedal, 10, prevCountryRank);
|
|
1462
1476
|
}
|
|
1463
1477
|
}
|
|
1464
1478
|
console.log();
|