From ab60e53cac2d6ab3704c8b91138157085ebee9f2 Mon Sep 17 00:00:00 2001 From: Ava Gaiety W Date: Thu, 18 Sep 2025 20:29:30 -0600 Subject: [PATCH] can output to toml --- .gitignore | 49 ---------------- bun.lockb | Bin 4863 -> 5238 bytes dist/palette.toml | 138 ++++++++++++++++++++++++++++++++++++++++++++ index.ts | 16 ++++- package.json | 9 +++ src/build/toml.ts | 70 ++++++++++++++++++++++ src/helpers/file.ts | 27 +++++++++ 7 files changed, 258 insertions(+), 51 deletions(-) create mode 100644 dist/palette.toml create mode 100644 src/build/toml.ts create mode 100644 src/helpers/file.ts diff --git a/.gitignore b/.gitignore index 9b1ee42..19dc4d8 100644 --- a/.gitignore +++ b/.gitignore @@ -115,59 +115,10 @@ web_modules/ .next out -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - # Stores VSCode versions used for testing VSCode extensions .vscode-test -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - # IntelliJ based IDEs .idea diff --git a/bun.lockb b/bun.lockb index 5fed2ff51eca5bd0b656bc69a3f68a3788a84088..1bcf9f96649427ddf5697f3925c561bcc30a186e 100755 GIT binary patch delta 950 zcmb7CUr1A76u;khx81wD-Mf`WTg$AhVb-S8{DabVX_erF3?hpt+(xBTx^kt!OR#BIyRufA^uLdMkL*5c?fH4CzClxw>#83);$vI)aSO(ee5MVZ3I>C=$jp zGM0}7GOGJ&w^A*S|4TLX$1unA&XS&haQS*D+Hq@YV0!M;!y_f5{;Sf@P5Z{>M?)^h z>By+EuDSD4(R_M*;K|`eQ&@}?Pu;DrYTI)Be)aEBP$dV7XBo(enA!dd& zqFz}Aj~rqaNXV_snwph&GH79isYP=ehs{QxGM0Pz7b?8b3gL>ij2?DrIcroGRsSW& zvTN|#TH`k25tVO3rzYZ@WSU2f)HPhtVnlV(~Eo*J~dS;?xSa!>gx?4f&BK--$)RLb7W{{gh| B!7=~< delta 711 zcmbVKO=uHQ5PtKrF`J*=jVls2QpBJojj-m&)YO_E@FWo|C=_BTnnWTfwLc0~FF7b! zf50#o^`i7%tgHxDh~TLQ3wjavP!O+*7bQ0vXPN{&J1}qNd++=9&Ai!8ynFDGJ#uF4 zUSxeDcYLVx>*H9uUY{_Qx-TD`y?#1**lo|Z+E-1nZK2lWzH?Kd9_X!pA({zFISx_O zD6UcrP^?|LaOE=PyZU$ECpQMx25j$z8#46?uYwuv?wa3Y5=dsJNx6)3h6O8l-^f4} y-x*dw7<4CD$-r+$3FF~p^aT~oKg#V~_5&>HTeE#i!^HXU3Fm!y7@UN8O8y0fh>H;b diff --git a/dist/palette.toml b/dist/palette.toml new file mode 100644 index 0000000..4f32a96 --- /dev/null +++ b/dist/palette.toml @@ -0,0 +1,138 @@ +name = verdigris +version = 0.0.1 +license = GPL-3.0-only +sourcecode = https://git.basking.monster/gaiety/verdigris + +[author] +name = Gaiety +email = ava+verdigris@gaiety.me +url = https://gaiety.me + +[colors] + +[colors.pit] +name = "Pit" +l = 20 +c = 3 +h = 350 +hex = "#201018" + +[colors.depths] +name = "Depths" +l = 27 +c = 3 +h = 350 +hex = "#322028" + +[colors.stope] +name = "Stope" +l = 34 +c = 3 +h = 350 +hex = "#44323A" + +[colors.text] +name = "Text" +l = 92 +c = 3 +h = 350 +hex = "#F5DDE7" + +[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 +h = 45 +hex = "#FFAB82" + +[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 +h = 180 +hex = "#5ADDC7" + +[colors.light_teal] +name = "Light Teal" +l = 92 +c = 12 +h = 180 +hex = "#7EFFE8" + +[colors.dark_blue] +name = "Dark Blue" +l = 82 +c = 12 +h = 270 +hex = "#A6C0FF" + +[colors.light_blue] +name = "Light Blue" +l = 92 +c = 12 +h = 270 +hex = "#C5E1FF" + +[colors.dark_purple] +name = "Dark Purple" +l = 82 +c = 12 +h = 315 +hex = "#E2ACFA" + +[colors.light_purple] +name = "Light Purple" +l = 92 +c = 12 +h = 315 +hex = "#FFCCFF" + \ No newline at end of file diff --git a/index.ts b/index.ts index 541ceff..861b38e 100644 --- a/index.ts +++ b/index.ts @@ -2,6 +2,7 @@ import { Command } from 'commander' import previewList from './src/preview/cli-list' import previewSnippet from './src/preview/cli-snippet' +import buildTOML from './src/build/toml' const program = new Command(); @@ -12,8 +13,8 @@ program program .command('preview') - .description('TODO') - .option('-v, --verbose', 'additional Logs') + .description('stdout some examples') + .option('-v, --verbose', 'additional logs') .option('--no-list', 'do not show colors as a list') .option('--no-snippet', 'do not a code snippet') .action((options) => { @@ -24,5 +25,16 @@ program if (options.snippet) previewSnippet() }); +program + .command('build') + .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`) + }); + program.parse(); diff --git a/package.json b/package.json index b168dca..cbbd4ef 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,17 @@ "name": "verdigris", "module": "index.js", "type": "module", + "license": "GPL-3.0-only", + "version": "0.0.1", + "url": "https://git.basking.monster/gaiety/verdigris", + "author": { + "name": "Gaiety", + "email": "ava+verdigris@gaiety.me", + "url": "https://gaiety.me" + }, "devDependencies": { "@types/bun": "latest", + "app-root-path": "^3.1.0", "chalk": "^5.6.2", "color-convert": "^3.1.2", "commander": "^14.0.1" diff --git a/src/build/toml.ts b/src/build/toml.ts new file mode 100644 index 0000000..ded9724 --- /dev/null +++ b/src/build/toml.ts @@ -0,0 +1,70 @@ +import { name, version, license, url, author } from '../../package.json' +import appRoot from 'app-root-path' +import { rmFile, mkFilePath, appendToFile } from "../helpers/file" +import colors from '../palette' +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) { + if (isVerbose) console.info('Removing previous build', file) + await rmFile(file) + if (isVerbose) console.info('Ensuring path and file exist', file) + await mkFilePath(file) + if (isVerbose) console.info('Writing header info to file', file) + await appendToTOML(headerTOML()) + if (isVerbose) console.info('Writing author info to file', file) + await appendToTOML(authorTOML()) + if (isVerbose) console.info('Writing color palette to file', file) + await appendToTOML(colorHeaderTOML()) + for (let index = 0; index < colors.length; index++) { + const color = colors[index] + if (isVerbose) console.info(`${color.name}…`, file) + await appendToTOML(colorTOML(color)) + } +} + +function headerTOML(): string { + return `name = ${name} +version = ${version} +license = ${license} +sourcecode = ${url} + ` +} + +function authorTOML(): string { + const { name, email, url } = author + + return ` +[author] +name = ${name} +email = ${email} +url = ${url} + ` +} +function colorHeaderTOML(): string { + return ` +[colors] + ` +} + +function colorTOML(color: color): string { + const { name, l, c, h } = color + return ` +[colors.${name.replaceAll(' ', '_').toLowerCase()}] +name = "${name}" +l = ${l} +c = ${c} +h = ${h} +hex = "${color.toHex()}" + ` +} + + +// [colors] +// +// [colors.bg] +// l = 0.2 +// c = 0.02 +// h = diff --git a/src/helpers/file.ts b/src/helpers/file.ts new file mode 100644 index 0000000..b30f0cd --- /dev/null +++ b/src/helpers/file.ts @@ -0,0 +1,27 @@ +import { appendFile, mkdir, rm } from 'node:fs/promises'; +import { dirname } from 'node:path' + +export async function mkFilePath(file: string) { + try { + await mkdir(dirname(file), { recursive: true }) + } catch (error) { + throw error + } +} + +export async function rmFile(file: string) { + try { + await rm(file) + } catch (error) { + throw error + } +} + +export async function appendToFile(file: string, content: string) { + try { + await appendFile(file, content) + } catch (error) { + throw error + } +} +