better logging
This commit is contained in:
parent
215a3a18e4
commit
61b13c8533
5 changed files with 84 additions and 110 deletions
161
dist/palette.toml
vendored
161
dist/palette.toml
vendored
|
@ -12,127 +12,78 @@ url = https://gaiety.me
|
|||
|
||||
[colors.pit]
|
||||
name = "Pit"
|
||||
l = 20
|
||||
c = 3
|
||||
h = 350
|
||||
hex = "#201018"
|
||||
l = 10
|
||||
c = 3.5
|
||||
h = 225
|
||||
hex = "#00040B"
|
||||
|
||||
[colors.depths]
|
||||
name = "Depths"
|
||||
l = 27
|
||||
c = 3
|
||||
h = 350
|
||||
hex = "#322028"
|
||||
l = 30
|
||||
c = 3.5
|
||||
h = 225
|
||||
hex = "#19323B"
|
||||
|
||||
[colors.stope]
|
||||
name = "Stope"
|
||||
l = 34
|
||||
c = 3
|
||||
h = 350
|
||||
hex = "#44323A"
|
||||
l = 50
|
||||
c = 3.5
|
||||
h = 225
|
||||
hex = "#4E6872"
|
||||
|
||||
[colors.text]
|
||||
name = "Text"
|
||||
l = 92
|
||||
c = 3
|
||||
h = 350
|
||||
hex = "#F5DDE7"
|
||||
l = 90
|
||||
c = 3.5
|
||||
h = 225
|
||||
hex = "#C6E4F0"
|
||||
|
||||
[colors.dark_red]
|
||||
name = "Dark Red"
|
||||
l = 82
|
||||
c = 12
|
||||
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
|
||||
[colors.orange]
|
||||
name = "Orange"
|
||||
l = 80
|
||||
c = 14
|
||||
h = 45
|
||||
hex = "#FFAB82"
|
||||
hex = "#FF9F6F"
|
||||
|
||||
[colors.light_orange]
|
||||
name = "Light Orange"
|
||||
l = 92
|
||||
c = 12
|
||||
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
|
||||
[colors.teal]
|
||||
name = "Teal"
|
||||
l = 80
|
||||
c = 14
|
||||
h = 180
|
||||
hex = "#5ADDC7"
|
||||
hex = "#23DBC1"
|
||||
|
||||
[colors.light_teal]
|
||||
name = "Light Teal"
|
||||
l = 92
|
||||
c = 12
|
||||
h = 180
|
||||
hex = "#7EFFE8"
|
||||
[colors.red]
|
||||
name = "Red"
|
||||
l = 80
|
||||
c = 7
|
||||
h = 22.5
|
||||
hex = "#E8ADA9"
|
||||
|
||||
[colors.dark_blue]
|
||||
name = "Dark Blue"
|
||||
l = 82
|
||||
c = 12
|
||||
h = 270
|
||||
hex = "#A6C0FF"
|
||||
[colors.yellow]
|
||||
name = "Yellow"
|
||||
l = 80
|
||||
c = 7
|
||||
h = 56.25
|
||||
hex = "#E1B392"
|
||||
|
||||
[colors.light_blue]
|
||||
name = "Light Blue"
|
||||
l = 92
|
||||
c = 12
|
||||
h = 270
|
||||
hex = "#C5E1FF"
|
||||
[colors.green]
|
||||
name = "Green"
|
||||
l = 80
|
||||
c = 7
|
||||
h = 157.5
|
||||
hex = "#98CCAC"
|
||||
|
||||
[colors.dark_purple]
|
||||
name = "Dark Purple"
|
||||
l = 82
|
||||
c = 12
|
||||
h = 315
|
||||
hex = "#E2ACFA"
|
||||
[colors.blue]
|
||||
name = "Blue"
|
||||
l = 80
|
||||
c = 7
|
||||
h = 225
|
||||
hex = "#8CC8E0"
|
||||
|
||||
[colors.light_purple]
|
||||
name = "Light Purple"
|
||||
l = 92
|
||||
c = 12
|
||||
h = 315
|
||||
hex = "#FFCCFF"
|
||||
[colors.purple]
|
||||
name = "Purple"
|
||||
l = 80
|
||||
c = 7
|
||||
h = 292.5
|
||||
hex = "#BEB6E8"
|
||||
|
15
index.ts
15
index.ts
|
@ -3,9 +3,16 @@ import { Command } from 'commander'
|
|||
import previewList from './src/preview/cli-list'
|
||||
import previewSnippet from './src/preview/cli-snippet'
|
||||
import buildTOML from './src/build/toml'
|
||||
import { nanoseconds } from 'bun';
|
||||
import { timerToSeconds } from './src/helpers/math';
|
||||
|
||||
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
|
||||
.name('verdigris')
|
||||
.description('Mining up the very best Color Palette')
|
||||
|
@ -30,10 +37,12 @@ program
|
|||
.description('compile toml and other consumable formats')
|
||||
.option('-v, --verbose', 'additional logs')
|
||||
.action(async (options) => {
|
||||
if (options.verbose) console.info('Building...')
|
||||
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();
|
||||
|
|
|
@ -7,7 +7,7 @@ import type color from '../helpers/color'
|
|||
const file = appRoot + '/dist/palette.toml'
|
||||
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)
|
||||
await rmFile(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)
|
||||
await appendToTOML(colorTOML(color))
|
||||
}
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
function headerTOML(): string {
|
||||
|
|
|
@ -4,3 +4,9 @@ export function absDegrees(degrees: number): number {
|
|||
if (degrees < 0) return absDegrees(degrees * -1)
|
||||
return degrees
|
||||
}
|
||||
|
||||
export function timerToSeconds([seconds, nanoseconds]: [number, number]): number {
|
||||
const digitRounding = 1000000
|
||||
const toDecimal = 100
|
||||
return seconds + (Math.round(nanoseconds / digitRounding) / toDecimal)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect, test } from 'bun:test'
|
||||
import { absDegrees } from '../../src/helpers/math'
|
||||
import { absDegrees, timerToSeconds } from '../../src/helpers/math'
|
||||
|
||||
test('degrees: 0 is valid', () => {
|
||||
expect(
|
||||
|
@ -64,3 +64,9 @@ test('degrees: if < 0 return equivilent degree within 360', () => {
|
|||
absDegrees(-720)
|
||||
).toBe(360)
|
||||
})
|
||||
|
||||
test('timer to seconds returns simple response', () => {
|
||||
expect(
|
||||
timerToSeconds([1, 23456789])
|
||||
).toBe(1.23)
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue