From 2bfafaa5fed7be05570d26ae233ba7b0fb8af6dc Mon Sep 17 00:00:00 2001 From: Patrick Taylor Date: Wed, 19 Jun 2024 21:57:08 +0100 Subject: [PATCH] =?UTF-8?q?Created=20a=20script=20to=20visualise=20the=20l?= =?UTF-8?q?oading=20progress=20with=20emojis=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/visualise.js | 27 +++++++++++++++++++++++++++ src/config.js | 21 ++++++++++----------- tests/config.spec.js | 23 ++++++++++++----------- 3 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 scripts/visualise.js diff --git a/scripts/visualise.js b/scripts/visualise.js new file mode 100644 index 0000000..cd65540 --- /dev/null +++ b/scripts/visualise.js @@ -0,0 +1,27 @@ +import readline from 'readline' + +import { getProgressConfig } from '../src/config.js' + +const visualise = () => { + const [startChar, endChar, progressLength] = getProgressConfig(new Date('2025-01-01')) + + const display = count => { + const complete = startChar.repeat(count) + const incomplete = endChar.repeat(progressLength - count) + const percent = (count / progressLength * 100).toFixed() + + readline.clearLine(process.stdout, 0) + readline.cursorTo(process.stdout, 0) + process.stdout.write(`${complete}${incomplete} | ${percent}% Testing...`) + + if (count < progressLength) { + setTimeout(() => { + display(count += 1) + }, 100) + } + } + + display(0) +} + +visualise() diff --git a/src/config.js b/src/config.js index 9c75328..2f54a7b 100644 --- a/src/config.js +++ b/src/config.js @@ -1,35 +1,34 @@ import chalk from 'chalk' const dateConfigurations = { - '01-01': ['🎉', 'âŦœī¸'], // New Year's Day - '01-29-2025': ['🐍', 'âŦœī¸'], // Chinese New Year 2025 + '01-01_01-05': ['🎉', 'đŸĒŠ'], // New Year's Day + '01-29-2025': ['🐍', '🧧'], // Chinese New Year 2025 '02-14': ['🌹', 'đŸĨ€'], // Valentine's Day '03-04-2025': ['đŸĨž', 'đŸŊī¸'], // Pancake Day 2025 '03-14': ['đŸĨ§', 'đŸŊī¸'], // Pi Day '03-17': ['🍀', 'âŦœī¸'], // St Patrick's Day - '04-01': ['🃏', 'âŦœī¸'], // April Fool's Day + '04-01': ['🃏', 'đŸ•ŗī¸'], // April Fool's Day '04-10-2025_04-20-2025': ['đŸŖ', 'đŸĨš'], // Easter 2025 '04-22': ['🌎', 'âŦœī¸'], // Earth Day - '05-04': ['⭐ī¸', 'âŦœī¸'], // Star Wars Day - '05-20': ['🐝', 'âŦœī¸'], // World Bee Day + '05-04': ['⭐ī¸', '🌌'], // Star Wars Day + '05-20': ['🐝', '🌸'], // World Bee Day '05-30': ['đŸĨ”', 'âŦœī¸'], // International Day of Potato '06-03': ['🚲', 'âŦœī¸'], // World Bicycle Day '06-05': ['đŸŒŗ', 'âŦœī¸'], // World Environment Day '06-08': ['🌊', 'âŦœī¸'], // World Oceans Day '06-19_06-23': ['☀ī¸', '☁ī¸'], // Summer Solstice (21st June) - '07-04': ['🎆', 'âŦœī¸'], // Independence Day (US) + '07-04': ['🎆', 'âŦ›ī¸'], // Independence Day (US) + '07-01-2024_07-14-2024': ['🎾', 'âŦ›ī¸'], // Wimbledon 2024 (UK) '07-20': ['🌝', '🌚'], // International Moon Day - '07-01-2024_07-14-2024': ['🎾', 'âŦœī¸'], // Wimbledon 2024 (UK) '09-05': ['💖', '🤍'], // International Charity Day - '09-21': ['☎ī¸', 'âŦœī¸'], // International Day of Peace - '10-01': ['☕ī¸', 'âŦœī¸'], // International Coffee Day + '09-21': ['☎ī¸', 'âŦ›ī¸'], // International Day of Peace + '10-01': ['☕ī¸', '🕘'], // International Coffee Day '10-24_10-31': ['🎃', 'đŸĻ‡'], // Halloween '11-28-2024': ['đŸĻƒ', '🍂'], // Thanksgiving (US) '12-01_12-31': ['⛄ī¸', '🧊'], // Winter (Northern Hemisphere) } -const getProgressConfig = () => { - const currentDate = new Date() +const getProgressConfig = (currentDate = new Date()) => { const today = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()).getTime() const matchingConfig = Object.entries(dateConfigurations).find(([dateRange]) => { diff --git a/tests/config.spec.js b/tests/config.spec.js index c9721e6..f81a32f 100644 --- a/tests/config.spec.js +++ b/tests/config.spec.js @@ -10,32 +10,33 @@ jest.mock('chalk', () => ({ describe('getProgressConfig', () => { test.each([ - ['2000-01-01', ['🎉', 'âŦœī¸', 20]], - ['2000-01-02', ['\u2588', ' ', 40]], - ['2025-01-29', ['🐍', 'âŦœī¸', 20]], + ['2000-01-01', ['🎉', 'đŸĒŠ', 20]], + ['2000-01-05', ['🎉', 'đŸĒŠ', 20]], + ['2000-01-06', ['\u2588', ' ', 40]], + ['2025-01-29', ['🐍', '🧧', 20]], ['2000-02-14', ['🌹', 'đŸĨ€', 20]], ['2025-03-04', ['đŸĨž', 'đŸŊī¸', 20]], ['2000-03-14', ['đŸĨ§', 'đŸŊī¸', 20]], ['2000-03-17', ['🍀', 'âŦœī¸', 20]], - ['2000-04-01', ['🃏', 'âŦœī¸', 20]], + ['2000-04-01', ['🃏', 'đŸ•ŗī¸', 20]], ['2025-04-10', ['đŸŖ', 'đŸĨš', 20]], ['2025-04-20', ['đŸŖ', 'đŸĨš', 20]], ['2000-04-22', ['🌎', 'âŦœī¸', 20]], - ['2000-05-04', ['⭐ī¸', 'âŦœī¸', 20]], - ['2000-05-20', ['🐝', 'âŦœī¸', 20]], + ['2000-05-04', ['⭐ī¸', '🌌', 20]], + ['2000-05-20', ['🐝', '🌸', 20]], ['2000-05-30', ['đŸĨ”', 'âŦœī¸', 20]], ['2000-06-03', ['🚲', 'âŦœī¸', 20]], ['2000-06-05', ['đŸŒŗ', 'âŦœī¸', 20]], ['2000-06-08', ['🌊', 'âŦœī¸', 20]], ['2000-06-19', ['☀ī¸', '☁ī¸', 20]], ['2000-06-23', ['☀ī¸', '☁ī¸', 20]], - ['2000-07-04', ['🎆', 'âŦœī¸', 20]], + ['2000-07-04', ['🎆', 'âŦ›ī¸', 20]], + ['2024-07-01', ['🎾', 'âŦ›ī¸', 20]], + ['2024-07-14', ['🎾', 'âŦ›ī¸', 20]], ['2000-07-20', ['🌝', '🌚', 20]], - ['2024-07-01', ['🎾', 'âŦœī¸', 20]], - ['2024-07-14', ['🎾', 'âŦœī¸', 20]], ['2000-09-05', ['💖', '🤍', 20]], - ['2000-09-21', ['☎ī¸', 'âŦœī¸', 20]], - ['2000-10-01', ['☕ī¸', 'âŦœī¸', 20]], + ['2000-09-21', ['☎ī¸', 'âŦ›ī¸', 20]], + ['2000-10-01', ['☕ī¸', '🕘', 20]], ['2000-10-24', ['🎃', 'đŸĻ‡', 20]], ['2000-10-31', ['🎃', 'đŸĻ‡', 20]], ['2024-11-28', ['đŸĻƒ', '🍂', 20]],