Skip to content

Commit

Permalink
feat: added colored boxes underneath the info (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
golota60 committed Jun 7, 2021
1 parent 9958f1d commit c1d3020
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"environment",
"info",
"system",
"sysinf"
"sysinf",
"systeminformation"
],
"homepage": "https://github.com/golota60/yayfetch#readme",
"repository": {
Expand Down
119 changes: 115 additions & 4 deletions src/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,54 @@ export const parseRGBStringToNumber = (rgbString: string): RGBColors => {
};
};

const customColorCodes = {
pink: {r: 255, g: 102, b: 147},
orange: {r: 255, g: 170, b: 16},
yellow: {r: 255, g: 245, b: 99},
violet: {r: 186, g: 13, b: 255},
lightgrey: {r: 224, g: 224, b: 224},
darkgrey: {r: 152, g: 152, b: 152},
burgundy: {r: 146, g: 36, b: 36},
darkgreen: {r: 63, g: 163, b: 38},
lightgreen: {r: 95, g: 235, b: 61},
darkyellow: {r: 179, g: 203, b: 0},
deepBlue: {r: 0, g: 47, b: 255},
darkDeepBlue: {r: 0, g: 30, b: 161},
darkViolet: {r: 181, g: 47, b: 191},
darkCyan: {r: 0, g: 171, b: 186}
};

export const uptimeInMinutes = (): number => os.uptime() / 60;

export const returnInPink = (text: string, bolded = false): string =>
bolded ? chalk.rgb(255, 102, 147).bold(text) : chalk.rgb(255, 102, 147)(text);
bolded ?
chalk
.rgb(
customColorCodes.pink.r,
customColorCodes.pink.g,
customColorCodes.pink.b
)
.bold(text) :
chalk.rgb(
customColorCodes.pink.r,
customColorCodes.pink.g,
customColorCodes.pink.b
)(text);

export const returnInOrange = (text: string, bolded = false): string =>
bolded ? chalk.rgb(255, 170, 16).bold(text) : chalk.rgb(255, 170, 16)(text);
bolded ?
chalk
.rgb(
customColorCodes.orange.r,
customColorCodes.orange.g,
customColorCodes.orange.b
)
.bold(text) :
chalk.rgb(
customColorCodes.orange.r,
customColorCodes.orange.g,
customColorCodes.orange.b
)(text);

export const returnInGreen = (text: string, bolded = false): string =>
bolded ? chalk.green.bold(text) : chalk.green(text);
Expand All @@ -74,10 +115,34 @@ export const returnInBlue = (text: string, bolded = false): string =>
bolded ? chalk.blue.bold(text) : chalk.blue(text);

export const returnInYellow = (text: string, bolded = false): string =>
bolded ? chalk.rgb(255, 245, 99).bold(text) : chalk.rgb(255, 245, 99)(text);
bolded ?
chalk
.rgb(
customColorCodes.yellow.r,
customColorCodes.yellow.g,
customColorCodes.yellow.b
)
.bold(text) :
chalk.rgb(
customColorCodes.yellow.r,
customColorCodes.yellow.g,
customColorCodes.yellow.b
)(text);

export const returnInViolet = (text: string, bolded = false): string =>
bolded ? chalk.rgb(186, 13, 255).bold(text) : chalk.rgb(186, 13, 255)(text);
bolded ?
chalk
.rgb(
customColorCodes.violet.r,
customColorCodes.violet.g,
customColorCodes.violet.b
)
.bold(text) :
chalk.rgb(
customColorCodes.violet.r,
customColorCodes.violet.g,
customColorCodes.violet.b
)(text);

export const returnInRainbow = (text: string, bolded = false): string => {
const functionArray = [
Expand Down Expand Up @@ -159,6 +224,52 @@ export const printData = (
}
};

export const getColoredBoxes = () => {
return `${chalk.bgBlack(' ')}${chalk.bgRgb(
customColorCodes.burgundy.r,
customColorCodes.burgundy.g,
customColorCodes.burgundy.b
)(' ')}${chalk.bgRgb(
customColorCodes.darkgreen.r,
customColorCodes.darkgreen.g,
customColorCodes.darkgreen.b
)(' ')}${chalk.bgRgb(
customColorCodes.darkyellow.r,
customColorCodes.darkyellow.g,
customColorCodes.darkyellow.b
)(' ')}${chalk.bgRgb(
customColorCodes.darkDeepBlue.r,
customColorCodes.darkDeepBlue.g,
customColorCodes.darkDeepBlue.b
)(' ')}${chalk.bgRgb(
customColorCodes.darkViolet.r,
customColorCodes.darkViolet.g,
customColorCodes.darkViolet.b
)(' ')}${chalk.bgRgb(
customColorCodes.darkCyan.r,
customColorCodes.darkCyan.g,
customColorCodes.darkCyan.b
)(' ')}${chalk.bgRgb(
customColorCodes.lightgrey.r,
customColorCodes.lightgrey.g,
customColorCodes.lightgrey.b
)(' ')}\n${chalk.bgRgb(
customColorCodes.darkgrey.r,
customColorCodes.darkgrey.g,
customColorCodes.darkgrey.b
)(' ')}${chalk.bgRed(' ')}${chalk.bgRgb(
customColorCodes.lightgreen.r,
customColorCodes.lightgreen.g,
customColorCodes.lightgreen.b
)(' ')}${chalk.bgYellow(' ')}${chalk.bgRgb(
customColorCodes.deepBlue.r,
customColorCodes.deepBlue.g,
customColorCodes.deepBlue.b
)(' ')}${chalk.bgMagenta(' ')}${chalk.bgCyanBright(' ')}${chalk.bgWhite(
' '
)}`;
};

export const yayfetchASCII = `-/-\` \`-//-\` \`-/-
-////\` .//////. \`////-
\`/////\` \`:////////:\` \`/////\`
Expand Down
14 changes: 13 additions & 1 deletion src/yayfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
parseRGBStringToNumber,
printData,
availableColors,
PredefinedColors
PredefinedColors,
getColoredBoxes
} from './helpers/helpers';
import {
getEndianness,
Expand Down Expand Up @@ -184,6 +185,7 @@ const args = yargs
false;
const colorToUse = customColors || predefinedColor;
const hideLogoFlag = Boolean(yargs.argv['hide-logo']);
const coloredBoxes = Boolean(yargs.argv['colored-boxes']);
const customLines = yargs.argv['custom-lines'] as string[];

let infoToPrint: string[];
Expand Down Expand Up @@ -219,6 +221,11 @@ const args = yargs
];
}

if (coloredBoxes) {
/* Empty string to ensure space between boxes */
infoToPrint = [...infoToPrint, '', getColoredBoxes()];
}

printData(
{
logo: returnColoredText(yayfetchASCII, colorToUse),
Expand Down Expand Up @@ -257,6 +264,11 @@ const args = yargs
describe: 'Array of lines you want to add(objects with key, value pairs)',
type: 'array'
})
.option('colored-boxes', {
describe: 'Hides colored boxes underneath the information',
type: 'boolean',
default: true
})
.help()
.version()
.alias('help', 'h')
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,6 @@ astral-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==

async@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720"
integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
Expand Down Expand Up @@ -2741,13 +2736,6 @@ get-value@^2.0.3, get-value@^2.0.6:
resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=

getos@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5"
integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==
dependencies:
async "^3.2.0"

getpass@^0.1.1:
version "0.1.7"
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
Expand Down

0 comments on commit c1d3020

Please sign in to comment.