better logging

This commit is contained in:
Ava Gaiety W 2025-09-19 21:08:31 -06:00
parent 215a3a18e4
commit 61b13c8533
5 changed files with 84 additions and 110 deletions

161
dist/palette.toml vendored
View file

@ -12,127 +12,78 @@ url = https://gaiety.me
[colors.pit] [colors.pit]
name = "Pit" name = "Pit"
l = 20 l = 10
c = 3 c = 3.5
h = 350 h = 225
hex = "#201018" hex = "#00040B"
[colors.depths] [colors.depths]
name = "Depths" name = "Depths"
l = 27 l = 30
c = 3 c = 3.5
h = 350 h = 225
hex = "#322028" hex = "#19323B"
[colors.stope] [colors.stope]
name = "Stope" name = "Stope"
l = 34 l = 50
c = 3 c = 3.5
h = 350 h = 225
hex = "#44323A" hex = "#4E6872"
[colors.text] [colors.text]
name = "Text" name = "Text"
l = 92 l = 90
c = 3 c = 3.5
h = 350 h = 225
hex = "#F5DDE7" hex = "#C6E4F0"
[colors.dark_red] [colors.orange]
name = "Dark Red" name = "Orange"
l = 82 l = 80
c = 12 c = 14
h = 0
hex = "#FFA3C1"
[colors.light_red]
name = "Light Red"
l = 92
c = 12
h = 0
hex = "#FFC3E1"
[colors.dark_orange]
name = "Dark Orange"
l = 82
c = 12
h = 45 h = 45
hex = "#FFAB82" hex = "#FF9F6F"
[colors.light_orange] [colors.teal]
name = "Light Orange" name = "Teal"
l = 92 l = 80
c = 12 c = 14
h = 45
hex = "#FFCBA1"
[colors.dark_yellow]
name = "Dark Yellow"
l = 82
c = 12
h = 90
hex = "#E2C162"
[colors.light_yellow]
name = "Light Yellow"
l = 92
c = 12
h = 90
hex = "#FFE183"
[colors.dark_green]
name = "Dark Green"
l = 82
c = 12
h = 135
hex = "#A2D686"
[colors.light_green]
name = "Light Green"
l = 92
c = 12
h = 135
hex = "#C2F7A5"
[colors.dark_teal]
name = "Dark Teal"
l = 82
c = 12
h = 180 h = 180
hex = "#5ADDC7" hex = "#23DBC1"
[colors.light_teal] [colors.red]
name = "Light Teal" name = "Red"
l = 92 l = 80
c = 12 c = 7
h = 180 h = 22.5
hex = "#7EFFE8" hex = "#E8ADA9"
[colors.dark_blue] [colors.yellow]
name = "Dark Blue" name = "Yellow"
l = 82 l = 80
c = 12 c = 7
h = 270 h = 56.25
hex = "#A6C0FF" hex = "#E1B392"
[colors.light_blue] [colors.green]
name = "Light Blue" name = "Green"
l = 92 l = 80
c = 12 c = 7
h = 270 h = 157.5
hex = "#C5E1FF" hex = "#98CCAC"
[colors.dark_purple] [colors.blue]
name = "Dark Purple" name = "Blue"
l = 82 l = 80
c = 12 c = 7
h = 315 h = 225
hex = "#E2ACFA" hex = "#8CC8E0"
[colors.light_purple] [colors.purple]
name = "Light Purple" name = "Purple"
l = 92 l = 80
c = 12 c = 7
h = 315 h = 292.5
hex = "#FFCCFF" hex = "#BEB6E8"

View file

@ -3,9 +3,16 @@ import { Command } from 'commander'
import previewList from './src/preview/cli-list' import previewList from './src/preview/cli-list'
import previewSnippet from './src/preview/cli-snippet' import previewSnippet from './src/preview/cli-snippet'
import buildTOML from './src/build/toml' import buildTOML from './src/build/toml'
import { nanoseconds } from 'bun';
import { timerToSeconds } from './src/helpers/math';
const program = new Command(); const program = new Command();
async function log(isVerbose: true, file: string, timer: [number, number]) {
const time: string = isVerbose ? ` ${timerToSeconds(timer)} seconds` : ''
console.info(`${file}${time}`)
}
program program
.name('verdigris') .name('verdigris')
.description('Mining up the very best Color Palette') .description('Mining up the very best Color Palette')
@ -30,10 +37,12 @@ program
.description('compile toml and other consumable formats') .description('compile toml and other consumable formats')
.option('-v, --verbose', 'additional logs') .option('-v, --verbose', 'additional logs')
.action(async (options) => { .action(async (options) => {
if (options.verbose) console.info('Building...')
const timer = process.hrtime() const timer = process.hrtime()
await buildTOML()
console.info(`Built in ${timer[0]} seconds`) if (options.verbose) console.info('Building Direct Exports...')
log(options.verbose, await buildTOML(), timer)
if (options.verbose) console.info('Building Ports...')
}); });
program.parse(); program.parse();

View file

@ -7,7 +7,7 @@ import type color from '../helpers/color'
const file = appRoot + '/dist/palette.toml' const file = appRoot + '/dist/palette.toml'
const appendToTOML = async (content: string) => await appendToFile(file, content) const appendToTOML = async (content: string) => await appendToFile(file, content)
export default async function(isVerbose = false) { export default async function(isVerbose = false): Promise<string> {
if (isVerbose) console.info('Removing previous build', file) if (isVerbose) console.info('Removing previous build', file)
await rmFile(file) await rmFile(file)
if (isVerbose) console.info('Ensuring path and file exist', file) if (isVerbose) console.info('Ensuring path and file exist', file)
@ -23,6 +23,8 @@ export default async function(isVerbose = false) {
if (isVerbose) console.info(`${color.name}`, file) if (isVerbose) console.info(`${color.name}`, file)
await appendToTOML(colorTOML(color)) await appendToTOML(colorTOML(color))
} }
return file
} }
function headerTOML(): string { function headerTOML(): string {

View file

@ -4,3 +4,9 @@ export function absDegrees(degrees: number): number {
if (degrees < 0) return absDegrees(degrees * -1) if (degrees < 0) return absDegrees(degrees * -1)
return degrees return degrees
} }
export function timerToSeconds([seconds, nanoseconds]: [number, number]): number {
const digitRounding = 1000000
const toDecimal = 100
return seconds + (Math.round(nanoseconds / digitRounding) / toDecimal)
}

View file

@ -1,5 +1,5 @@
import { expect, test } from 'bun:test' import { expect, test } from 'bun:test'
import { absDegrees } from '../../src/helpers/math' import { absDegrees, timerToSeconds } from '../../src/helpers/math'
test('degrees: 0 is valid', () => { test('degrees: 0 is valid', () => {
expect( expect(
@ -64,3 +64,9 @@ test('degrees: if < 0 return equivilent degree within 360', () => {
absDegrees(-720) absDegrees(-720)
).toBe(360) ).toBe(360)
}) })
test('timer to seconds returns simple response', () => {
expect(
timerToSeconds([1, 23456789])
).toBe(1.23)
})