Compare commits
No commits in common. "1363787086e9e97ce8fe1e384e6e1ce2ded94878" and "8b70f735fc5dc1f3914b0a284b1366c503a59278" have entirely different histories.
1363787086
...
8b70f735fc
22 changed files with 323 additions and 326 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
28
dist/palette.toml
vendored
28
dist/palette.toml
vendored
|
@ -2,88 +2,88 @@ name = "verdigris"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
sourcecode = "https://git.basking.monster/gaiety/verdigris"
|
sourcecode = "https://git.basking.monster/gaiety/verdigris"
|
||||||
|
|
||||||
[author]
|
[author]
|
||||||
name = "Gaiety"
|
name = "Gaiety"
|
||||||
email = "ava+verdigris@gaiety.me"
|
email = "ava+verdigris@gaiety.me"
|
||||||
url = "https://gaiety.me"
|
url = "https://gaiety.me"
|
||||||
|
|
||||||
[colors]
|
[colors]
|
||||||
|
|
||||||
[colors.pit]
|
[colors.pit]
|
||||||
name = "Pit"
|
name = "Pit"
|
||||||
l = 10
|
l = 10
|
||||||
c = 3.5
|
c = 3.5
|
||||||
h = 225
|
h = 225
|
||||||
hex = "#00040B"
|
hex = "#00040B"
|
||||||
|
|
||||||
[colors.depths]
|
[colors.depths]
|
||||||
name = "Depths"
|
name = "Depths"
|
||||||
l = 30
|
l = 30
|
||||||
c = 3.5
|
c = 3.5
|
||||||
h = 225
|
h = 225
|
||||||
hex = "#19323B"
|
hex = "#19323B"
|
||||||
|
|
||||||
[colors.stope]
|
[colors.stope]
|
||||||
name = "Stope"
|
name = "Stope"
|
||||||
l = 50
|
l = 50
|
||||||
c = 3.5
|
c = 3.5
|
||||||
h = 225
|
h = 225
|
||||||
hex = "#4E6872"
|
hex = "#4E6872"
|
||||||
|
|
||||||
[colors.text]
|
[colors.text]
|
||||||
name = "Text"
|
name = "Text"
|
||||||
l = 90
|
l = 90
|
||||||
c = 3.5
|
c = 3.5
|
||||||
h = 225
|
h = 225
|
||||||
hex = "#C6E4F0"
|
hex = "#C6E4F0"
|
||||||
|
|
||||||
[colors.orange]
|
[colors.orange]
|
||||||
name = "Orange"
|
name = "Orange"
|
||||||
l = 80
|
l = 80
|
||||||
c = 14
|
c = 14
|
||||||
h = 45
|
h = 45
|
||||||
hex = "#FF9F6F"
|
hex = "#FF9F6F"
|
||||||
|
|
||||||
[colors.teal]
|
[colors.teal]
|
||||||
name = "Teal"
|
name = "Teal"
|
||||||
l = 80
|
l = 80
|
||||||
c = 14
|
c = 14
|
||||||
h = 180
|
h = 180
|
||||||
hex = "#23DBC1"
|
hex = "#23DBC1"
|
||||||
|
|
||||||
[colors.red]
|
[colors.red]
|
||||||
name = "Red"
|
name = "Red"
|
||||||
l = 80
|
l = 80
|
||||||
c = 7
|
c = 7
|
||||||
h = 22.5
|
h = 22.5
|
||||||
hex = "#E8ADA9"
|
hex = "#E8ADA9"
|
||||||
|
|
||||||
[colors.yellow]
|
[colors.yellow]
|
||||||
name = "Yellow"
|
name = "Yellow"
|
||||||
l = 80
|
l = 80
|
||||||
c = 7
|
c = 7
|
||||||
h = 56.25
|
h = 56.25
|
||||||
hex = "#E1B392"
|
hex = "#E1B392"
|
||||||
|
|
||||||
[colors.green]
|
[colors.green]
|
||||||
name = "Green"
|
name = "Green"
|
||||||
l = 80
|
l = 80
|
||||||
c = 7
|
c = 7
|
||||||
h = 157.5
|
h = 157.5
|
||||||
hex = "#98CCAC"
|
hex = "#98CCAC"
|
||||||
|
|
||||||
[colors.blue]
|
[colors.blue]
|
||||||
name = "Blue"
|
name = "Blue"
|
||||||
l = 80
|
l = 80
|
||||||
c = 7
|
c = 7
|
||||||
h = 225
|
h = 225
|
||||||
hex = "#8CC8E0"
|
hex = "#8CC8E0"
|
||||||
|
|
||||||
[colors.purple]
|
[colors.purple]
|
||||||
name = "Purple"
|
name = "Purple"
|
||||||
l = 80
|
l = 80
|
||||||
c = 7
|
c = 7
|
||||||
h = 292.5
|
h = 292.5
|
||||||
hex = "#BEB6E8"
|
hex = "#BEB6E8"
|
||||||
|
|
6
dist/palette.yml
vendored
6
dist/palette.yml
vendored
|
@ -2,12 +2,12 @@ name: "verdigris"
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
license: "GPL-3.0-only"
|
license: "GPL-3.0-only"
|
||||||
sourcecode: "https://git.basking.monster/gaiety/verdigris"
|
sourcecode: "https://git.basking.monster/gaiety/verdigris"
|
||||||
|
|
||||||
author:
|
author:
|
||||||
name: "Gaiety"
|
name: "Gaiety"
|
||||||
email: "ava+verdigris@gaiety.me"
|
email: "ava+verdigris@gaiety.me"
|
||||||
url: "https://gaiety.me"
|
url: "https://gaiety.me"
|
||||||
|
|
||||||
common:
|
common:
|
||||||
pit: "#00040B"
|
pit: "#00040B"
|
||||||
depths: "#19323B"
|
depths: "#19323B"
|
||||||
|
@ -19,4 +19,4 @@ common:
|
||||||
yellow: "#E1B392"
|
yellow: "#E1B392"
|
||||||
green: "#98CCAC"
|
green: "#98CCAC"
|
||||||
blue: "#8CC8E0"
|
blue: "#8CC8E0"
|
||||||
purple: "#BEB6E8"
|
purple: "#BEB6E8"
|
2
index.ts
2
index.ts
|
@ -6,7 +6,6 @@ import previewSnippet from './src/preview/cli-snippet'
|
||||||
import buildTOML from './src/build/toml'
|
import buildTOML from './src/build/toml'
|
||||||
import buildYAML from './src/build/yaml'
|
import buildYAML from './src/build/yaml'
|
||||||
import buildKitty from './ports/kitty/src/build'
|
import buildKitty from './ports/kitty/src/build'
|
||||||
import buildNeovim from './ports/neovim/src/build'
|
|
||||||
|
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ program
|
||||||
|
|
||||||
if (options.verbose) console.info('Building Ports...')
|
if (options.verbose) console.info('Building Ports...')
|
||||||
log(options.verbose, await buildKitty(), timer)
|
log(options.verbose, await buildKitty(), timer)
|
||||||
// log(options.verbose, await buildNeovim(), timer)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
program.parse();
|
program.parse();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"chalk": "^5.6.2",
|
"chalk": "^5.6.2",
|
||||||
"color-convert": "^3.1.2",
|
"color-convert": "^3.1.2",
|
||||||
"commander": "^14.0.1",
|
"commander": "^14.0.1",
|
||||||
"handlebars": "^4.7.8"
|
"estilo": "^2.1.3",
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
|
|
38
ports/kitty/dist/kitty.conf
vendored
38
ports/kitty/dist/kitty.conf
vendored
|
@ -25,25 +25,6 @@ cursor_trail_color #E1B392
|
||||||
url_color #8CC8E0
|
url_color #8CC8E0
|
||||||
####################
|
####################
|
||||||
|
|
||||||
#########################
|
|
||||||
# window border colors and terminal bell colors
|
|
||||||
active_border_color #23DBC1
|
|
||||||
inactive_border_color #4E6872
|
|
||||||
bell_border_color #FF9F6F
|
|
||||||
# visual_bell_color none
|
|
||||||
####################
|
|
||||||
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Tab bar colors
|
|
||||||
active_tab_foreground #C6E4F0
|
|
||||||
active_tab_background #19323B
|
|
||||||
inactive_tab_foreground #C6E4F0
|
|
||||||
inactive_tab_background #4E6872
|
|
||||||
# tab_bar_background #00040B
|
|
||||||
# tab_bar_margin_color none
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Marks colors
|
# Marks colors
|
||||||
# mark1_foreground black
|
# mark1_foreground black
|
||||||
|
@ -54,6 +35,23 @@ inactive_tab_background #4E6872
|
||||||
# mark3_background #f274bc
|
# mark3_background #f274bc
|
||||||
####################
|
####################
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# Tab bar colors
|
||||||
|
active_tab_foreground #C6E4F0
|
||||||
|
active_tab_background #19323B
|
||||||
|
inactive_tab_foreground #C6E4F0
|
||||||
|
inactive_tab_background #4E6872
|
||||||
|
# tab_bar_background #{pit.toHex()}
|
||||||
|
# tab_bar_margin_color none
|
||||||
|
####################
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# window border colors and terminal bell colors
|
||||||
|
active_border_color #23DBC1
|
||||||
|
inactive_border_color #4E6872
|
||||||
|
bell_border_color #FF9F6F
|
||||||
|
# visual_bell_color none
|
||||||
|
####################
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# The basic 16 colors
|
# The basic 16 colors
|
||||||
|
@ -88,4 +86,4 @@ color14 #23DBC1
|
||||||
#: white
|
#: white
|
||||||
color7 #C6E4F0
|
color7 #C6E4F0
|
||||||
color15 #C6E4F0
|
color15 #C6E4F0
|
||||||
####################
|
####################
|
6
ports/kitty/dist/palette.toml
vendored
Normal file
6
ports/kitty/dist/palette.toml
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#########################
|
||||||
|
# verdigris for kitty
|
||||||
|
# 0.0.1
|
||||||
|
# GPL-3.0-only
|
||||||
|
# https://git.basking.monster/gaiety/verdigris
|
||||||
|
####################
|
|
@ -1,3 +1,3 @@
|
||||||
import buildKitty from './src/build'
|
import BuildKitty from './src/build'
|
||||||
|
|
||||||
await buildKitty()
|
await BuildKitty()
|
||||||
|
|
|
@ -1,17 +1,31 @@
|
||||||
import appRoot from 'app-root-path'
|
import appRoot from 'app-root-path'
|
||||||
import { renderToFile } from "../../../src/helpers/file"
|
import { rmFile, mkFilePath, appendToFile } from "../../../src/helpers/file"
|
||||||
import getData from './data'
|
import { headerInfo, colorsBasic, colorsURLs, colorsCursor, colorsMarks, colorsTabBar, colorsBordersAndAlerts, colorsBasic16 } from './data'
|
||||||
|
|
||||||
const templateFile = appRoot + '/ports/kitty/src/templates/kitty.conf.hbs'
|
const file = appRoot + '/ports/kitty/dist/kitty.conf'
|
||||||
const outputFile = appRoot + '/ports/kitty/dist/kitty.conf'
|
|
||||||
|
const appendToKittyConf = async (content: string) => await appendToFile(file, content)
|
||||||
|
|
||||||
export default async function(isVerbose = false): Promise<string> {
|
export default async function(isVerbose = false): Promise<string> {
|
||||||
|
if (isVerbose) console.info('Kitty: Removing previous build', file)
|
||||||
try {
|
try {
|
||||||
await renderToFile(templateFile, outputFile, getData(), isVerbose)
|
await rmFile(file)
|
||||||
|
|
||||||
return outputFile
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
console.info('Kitty: Previous build already removed')
|
||||||
}
|
}
|
||||||
|
if (isVerbose) console.info('Kitty: Ensuring path and file exist', file)
|
||||||
|
await mkFilePath(file)
|
||||||
|
if (isVerbose) console.info('Kitty: Writing header info to file', file)
|
||||||
|
await appendToKittyConf(headerInfo())
|
||||||
|
if (isVerbose) console.info('Kitty: Writing color palette into file', file)
|
||||||
|
await appendToKittyConf(colorsBasic())
|
||||||
|
await appendToKittyConf(colorsCursor())
|
||||||
|
await appendToKittyConf(colorsURLs())
|
||||||
|
await appendToKittyConf(colorsMarks())
|
||||||
|
await appendToKittyConf(colorsTabBar())
|
||||||
|
await appendToKittyConf(colorsBordersAndAlerts())
|
||||||
|
await appendToKittyConf(colorsBasic16())
|
||||||
|
|
||||||
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,136 @@
|
||||||
import { name, version } from '../info.toml'
|
import { name, version } from '../info.toml'
|
||||||
import { license, url } from '../../../package.json'
|
import { license, url } from '../../../package.json'
|
||||||
import colors from '../../../src/palette'
|
import {
|
||||||
import type { Colors } from '../../../src/palette'
|
pit,
|
||||||
import Color from '../../../src/helpers/color'
|
depths,
|
||||||
|
stope,
|
||||||
|
text,
|
||||||
|
orange,
|
||||||
|
teal,
|
||||||
|
red,
|
||||||
|
yellow,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
purple,
|
||||||
|
} from '../../../src/palette'
|
||||||
|
|
||||||
export default function(): any {
|
export function headerInfo(): string {
|
||||||
return {
|
return `#########################
|
||||||
name,
|
# ${name} for kitty
|
||||||
version,
|
# ${version}
|
||||||
license,
|
# ${license}
|
||||||
url,
|
# ${url}
|
||||||
...flattenColorsToHex(),
|
####################
|
||||||
}
|
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
function flattenColorsToHex(): Colors {
|
export function colorsBasic(): string {
|
||||||
return colors.reduce((acc, color) => {
|
return `#########################
|
||||||
return {
|
# The basic colors
|
||||||
[color.nameSnakeCase]: color.toHex(),
|
foreground ${text.toHex()}
|
||||||
...acc,
|
background ${pit.toHex()}
|
||||||
}
|
selection_foreground ${depths.toHex()}
|
||||||
}, {})
|
selection_background ${text.toHex()}
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function colorsCursor(): string {
|
||||||
|
return `#########################
|
||||||
|
# Cursor colors
|
||||||
|
cursor ${text.toHex()}
|
||||||
|
cursor_text_color ${depths.toHex()}
|
||||||
|
cursor_trail_color ${yellow.toHex()}
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorsURLs(): string {
|
||||||
|
return `#########################
|
||||||
|
# URL colors
|
||||||
|
url_color ${blue.toHex()}
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorsBordersAndAlerts(): string {
|
||||||
|
return `#########################
|
||||||
|
# window border colors and terminal bell colors
|
||||||
|
active_border_color ${teal.toHex()}
|
||||||
|
inactive_border_color ${stope.toHex()}
|
||||||
|
bell_border_color ${orange.toHex()}
|
||||||
|
# visual_bell_color none
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorsTabBar(): string {
|
||||||
|
return `#########################
|
||||||
|
# Tab bar colors
|
||||||
|
active_tab_foreground ${text.toHex()}
|
||||||
|
active_tab_background ${depths.toHex()}
|
||||||
|
inactive_tab_foreground ${text.toHex()}
|
||||||
|
inactive_tab_background ${stope.toHex()}
|
||||||
|
# tab_bar_background #{pit.toHex()}
|
||||||
|
# tab_bar_margin_color none
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorsMarks(): string {
|
||||||
|
return `#########################
|
||||||
|
# Marks colors
|
||||||
|
# mark1_foreground black
|
||||||
|
# mark1_background #98d3cb
|
||||||
|
# mark2_foreground black
|
||||||
|
# mark2_background #f2dcd3
|
||||||
|
# mark3_foreground black
|
||||||
|
# mark3_background #f274bc
|
||||||
|
####################
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorsBasic16(): string {
|
||||||
|
return `#########################
|
||||||
|
# The basic 16 colors
|
||||||
|
#: black
|
||||||
|
color0 ${pit.toHex()}
|
||||||
|
color8 ${stope.toHex()}
|
||||||
|
|
||||||
|
#: red
|
||||||
|
color1 ${red.toHex()}
|
||||||
|
color9 ${red.toHex()}
|
||||||
|
|
||||||
|
#: green
|
||||||
|
color2 ${green.toHex()}
|
||||||
|
color10 ${green.toHex()}
|
||||||
|
|
||||||
|
#: yellow
|
||||||
|
color3 ${yellow.toHex()}
|
||||||
|
color11 ${yellow.toHex()}
|
||||||
|
|
||||||
|
#: blue
|
||||||
|
color4 ${blue.toHex()}
|
||||||
|
color12 ${blue.toHex()}
|
||||||
|
|
||||||
|
#: magenta
|
||||||
|
color5 ${purple.toHex()}
|
||||||
|
color13 ${purple.toHex()}
|
||||||
|
|
||||||
|
#: cyan
|
||||||
|
color6 ${teal.toHex()}
|
||||||
|
color14 ${teal.toHex()}
|
||||||
|
|
||||||
|
#: white
|
||||||
|
color7 ${text.toHex()}
|
||||||
|
color15 ${text.toHex()}
|
||||||
|
####################`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
#########################
|
|
||||||
# {{name}} for kitty
|
|
||||||
# {{version}}
|
|
||||||
# {{license}}
|
|
||||||
# {{url}}
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# The basic colors
|
|
||||||
foreground {{text}}
|
|
||||||
background {{pit}}
|
|
||||||
selection_foreground {{depths}}
|
|
||||||
selection_background {{text}}
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Cursor colors
|
|
||||||
cursor {{text}}
|
|
||||||
cursor_text_color {{depths}}
|
|
||||||
cursor_trail_color {{yellow}}
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# URL colors
|
|
||||||
url_color {{blue}}
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# window border colors and terminal bell colors
|
|
||||||
active_border_color {{teal}}
|
|
||||||
inactive_border_color {{stope}}
|
|
||||||
bell_border_color {{orange}}
|
|
||||||
# visual_bell_color none
|
|
||||||
####################
|
|
||||||
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Tab bar colors
|
|
||||||
active_tab_foreground {{text}}
|
|
||||||
active_tab_background {{depths}}
|
|
||||||
inactive_tab_foreground {{text}}
|
|
||||||
inactive_tab_background {{stope}}
|
|
||||||
# tab_bar_background {{pit}}
|
|
||||||
# tab_bar_margin_color none
|
|
||||||
####################
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Marks colors
|
|
||||||
# mark1_foreground black
|
|
||||||
# mark1_background #98d3cb
|
|
||||||
# mark2_foreground black
|
|
||||||
# mark2_background #f2dcd3
|
|
||||||
# mark3_foreground black
|
|
||||||
# mark3_background #f274bc
|
|
||||||
####################
|
|
||||||
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# The basic 16 colors
|
|
||||||
#: black
|
|
||||||
color0 {{pit}}
|
|
||||||
color8 {{stope}}
|
|
||||||
|
|
||||||
#: red
|
|
||||||
color1 {{red}}
|
|
||||||
color9 {{red}}
|
|
||||||
|
|
||||||
#: green
|
|
||||||
color2 {{green}}
|
|
||||||
color10 {{green}}
|
|
||||||
|
|
||||||
#: yellow
|
|
||||||
color3 {{yellow}}
|
|
||||||
color11 {{yellow}}
|
|
||||||
|
|
||||||
#: blue
|
|
||||||
color4 {{blue}}
|
|
||||||
color12 {{blue}}
|
|
||||||
|
|
||||||
#: magenta
|
|
||||||
color5 {{purple}}
|
|
||||||
color13 {{purple}}
|
|
||||||
|
|
||||||
#: cyan
|
|
||||||
color6 {{teal}}
|
|
||||||
color14 {{teal}}
|
|
||||||
|
|
||||||
#: white
|
|
||||||
color7 {{text}}
|
|
||||||
color15 {{text}}
|
|
||||||
####################
|
|
|
@ -1 +0,0 @@
|
||||||
https://neovim.io/doc/user/syntax.html
|
|
|
@ -1,3 +0,0 @@
|
||||||
import buildNeovim from './src/build'
|
|
||||||
|
|
||||||
await buildNeovim()
|
|
|
@ -1,38 +0,0 @@
|
||||||
import appRoot from 'app-root-path'
|
|
||||||
import { rmFile, mkFilePath, appendToFile } from "../../../src/helpers/file"
|
|
||||||
import { common } from '../../../dist/palette.yml'
|
|
||||||
import { spawn } from 'bun'
|
|
||||||
|
|
||||||
const file = appRoot + '/ports/neovim/estilos/palettes/verdigris.yml'
|
|
||||||
const appendToEstilosPalette = async (content: string) => await appendToFile(file, content)
|
|
||||||
|
|
||||||
export default async function(isVerbose = false) {
|
|
||||||
if (isVerbose) console.info('Neovim: Removing previous build', file)
|
|
||||||
try {
|
|
||||||
await rmFile(file)
|
|
||||||
} catch (error) {
|
|
||||||
console.info('Neovim: Previous build already removed')
|
|
||||||
}
|
|
||||||
if (isVerbose) console.info('Neovim: Ensuring path and file exist', file)
|
|
||||||
await mkFilePath(file)
|
|
||||||
if (isVerbose) console.info('Neovim: Writing color palette into file', file)
|
|
||||||
await appendToEstilosPalette(colors())
|
|
||||||
if (isVerbose) console.info('Neovim: Running estilo to compile `.vim`', file)
|
|
||||||
await runEstilo(isVerbose)
|
|
||||||
|
|
||||||
return appRoot + '/ports/neovim/colors/verdigris.vim'
|
|
||||||
}
|
|
||||||
|
|
||||||
function colors(): string {
|
|
||||||
return Object
|
|
||||||
.keys(common)
|
|
||||||
.reduce((acc, key) => acc += `${key}: "${common[key]}"\n`, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function runEstilo(isVerbose: boolean) {
|
|
||||||
const proc = spawn(['bun', 'estilo', 'render', appRoot + '/ports/neovim/'], {
|
|
||||||
cwd: appRoot.toString(),
|
|
||||||
});
|
|
||||||
const output = await proc.stdout.text();
|
|
||||||
if (isVerbose) console.info(output)
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
name = "{{name}}"
|
|
||||||
version = "{{version}}"
|
|
||||||
license = "{{license}}"
|
|
||||||
sourcecode = "{{url}}"
|
|
||||||
|
|
||||||
[author]
|
|
||||||
name = "{{author.name}}"
|
|
||||||
email = "{{author.email}}"
|
|
||||||
url = "{{author.url}}"
|
|
||||||
|
|
||||||
[colors]
|
|
||||||
|
|
||||||
{{#each colors}}
|
|
||||||
[colors.{{this.nameSnakeCase}}]
|
|
||||||
name = "{{this.name}}"
|
|
||||||
l = {{this.l}}
|
|
||||||
c = {{this.c}}
|
|
||||||
h = {{this.h}}
|
|
||||||
hex = "{{this.hex}}"
|
|
||||||
|
|
||||||
{{/each}}
|
|
|
@ -1,14 +0,0 @@
|
||||||
name: "{{name}}"
|
|
||||||
version: "{{version}}"
|
|
||||||
license: "{{license}}"
|
|
||||||
sourcecode: "{{url}}"
|
|
||||||
|
|
||||||
author:
|
|
||||||
name: "{{author.name}}"
|
|
||||||
email: "{{author.email}}"
|
|
||||||
url: "{{author.url}}"
|
|
||||||
|
|
||||||
common:
|
|
||||||
{{#each colors}}
|
|
||||||
{{this.nameSnakeCase}}: "{{this.hex}}"
|
|
||||||
{{/each}}
|
|
|
@ -1,42 +1,70 @@
|
||||||
import { name, version, license, url, author } from '../../package.json'
|
import { name, version, license, url, author } from '../../package.json'
|
||||||
import appRoot from 'app-root-path'
|
import appRoot from 'app-root-path'
|
||||||
import { renderToFile } from "../helpers/file"
|
import { rmFile, mkFilePath, appendToFile } from "../helpers/file"
|
||||||
import colors from '../palette'
|
import colors from '../palette'
|
||||||
import Color from '../helpers/color'
|
import type color from '../helpers/color'
|
||||||
|
import { toSnakeCase } from '../helpers/string'
|
||||||
|
|
||||||
const templateFile = appRoot + '/src/build/templates/toml.hbs'
|
const file = appRoot + '/dist/palette.toml'
|
||||||
const outputFile = appRoot + '/dist/palette.toml'
|
const appendToTOML = async (content: string) => await appendToFile(file, content)
|
||||||
|
|
||||||
export default async function(isVerbose = false): Promise<string> {
|
export default async function(isVerbose = false): Promise<string> {
|
||||||
|
if (isVerbose) console.info('Removing previous build', file)
|
||||||
try {
|
try {
|
||||||
await renderToFile(templateFile, outputFile, getData(), isVerbose)
|
await rmFile(file)
|
||||||
|
|
||||||
return outputFile
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
console.info('TOML: Previous build already removed')
|
||||||
}
|
}
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData(): any {
|
function headerTOML(): string {
|
||||||
return {
|
return `name = "${name}"
|
||||||
name,
|
version = "${version}"
|
||||||
version,
|
license = "${license}"
|
||||||
license,
|
sourcecode = "${url}"
|
||||||
url,
|
`
|
||||||
author,
|
|
||||||
colors: colors.map(getDataColors)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataColors(color: Color): any {
|
function authorTOML(): string {
|
||||||
const { name, nameSnakeCase, l, c, h } = color
|
const { name, email, url } = author
|
||||||
|
|
||||||
return {
|
return `
|
||||||
name,
|
[author]
|
||||||
nameSnakeCase,
|
name = "${name}"
|
||||||
l,
|
email = "${email}"
|
||||||
c,
|
url = "${url}"
|
||||||
h,
|
`
|
||||||
hex: color.toHex()
|
}
|
||||||
}
|
|
||||||
|
function colorHeaderTOML(): string {
|
||||||
|
return `
|
||||||
|
[colors]
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorTOML(color: color): string {
|
||||||
|
const { name, l, c, h } = color
|
||||||
|
return `
|
||||||
|
[colors.${toSnakeCase(name)}]
|
||||||
|
name = "${name}"
|
||||||
|
l = ${l}
|
||||||
|
c = ${c}
|
||||||
|
h = ${h}
|
||||||
|
hex = "${color.toHex()}"
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,62 @@
|
||||||
import { name, version, license, url, author } from '../../package.json'
|
import { name, version, license, url, author } from '../../package.json'
|
||||||
import appRoot from 'app-root-path'
|
import appRoot from 'app-root-path'
|
||||||
|
import { rmFile, mkFilePath, appendToFile } from "../helpers/file"
|
||||||
|
import { toSnakeCase } from '../helpers/string'
|
||||||
import colors from '../palette'
|
import colors from '../palette'
|
||||||
import Color from '../helpers/color'
|
import type color from '../helpers/color'
|
||||||
import { renderToFile } from '../helpers/file'
|
|
||||||
|
|
||||||
const templateFile = appRoot + '/src/build/templates/yaml.hbs'
|
const file = appRoot + '/dist/palette.yml'
|
||||||
const outputFile = appRoot + '/dist/palette.yml'
|
const appendToYAML = async (content: string) => await appendToFile(file, content)
|
||||||
|
|
||||||
export default async function(isVerbose = false): Promise<string> {
|
export default async function(isVerbose = false): Promise<string> {
|
||||||
|
if (isVerbose) console.info('Removing previous build', file)
|
||||||
try {
|
try {
|
||||||
await renderToFile(templateFile, outputFile, getData(), isVerbose)
|
await rmFile(file)
|
||||||
|
|
||||||
return outputFile
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
console.info('YAML: Previous build already removed')
|
||||||
}
|
}
|
||||||
|
if (isVerbose) console.info('Ensuring path and file exist', file)
|
||||||
|
await mkFilePath(file)
|
||||||
|
if (isVerbose) console.info('Writing header info to file', file)
|
||||||
|
await appendToYAML(headerYAML())
|
||||||
|
if (isVerbose) console.info('Writing author info to file', file)
|
||||||
|
await appendToYAML(authorYAML())
|
||||||
|
if (isVerbose) console.info('Writing color palette to file', file)
|
||||||
|
await appendToYAML(colorHeaderYAML())
|
||||||
|
for (let index = 0; index < colors.length; index++) {
|
||||||
|
const color = colors[index]
|
||||||
|
if (isVerbose) console.info(`${color.name}…`, file)
|
||||||
|
await appendToYAML(colorYAML(color))
|
||||||
|
}
|
||||||
|
|
||||||
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData(): any {
|
function headerYAML(): string {
|
||||||
return {
|
return `name: "${name}"
|
||||||
name,
|
version: "${version}"
|
||||||
version,
|
license: "${license}"
|
||||||
license,
|
sourcecode: "${url}"
|
||||||
url,
|
`
|
||||||
author,
|
|
||||||
colors: colors.map(getDataColors)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDataColors(color: Color): any {
|
function authorYAML(): string {
|
||||||
const { nameSnakeCase } = color
|
const { name, email, url } = author
|
||||||
|
|
||||||
return {
|
return `
|
||||||
nameSnakeCase,
|
author:
|
||||||
hex: color.toHex()
|
name: "${name}"
|
||||||
}
|
email: "${email}"
|
||||||
|
url: "${url}"
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorHeaderYAML(): string {
|
||||||
|
return `
|
||||||
|
common:`
|
||||||
|
}
|
||||||
|
|
||||||
|
function colorYAML(color: color): string {
|
||||||
|
return `
|
||||||
|
${toSnakeCase(color.name)}: "${color.toHex()}"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import convert from 'color-convert'
|
import convert from 'color-convert'
|
||||||
import { toSnakeCase } from './string'
|
|
||||||
|
|
||||||
export interface OklchInterface {
|
export interface OklchInterface {
|
||||||
l: number,
|
l: number,
|
||||||
|
@ -32,8 +31,6 @@ export default class {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
get nameSnakeCase() { return toSnakeCase(this.#name) }
|
|
||||||
|
|
||||||
get l() { return this.#l }
|
get l() { return this.#l }
|
||||||
set l(value: number) {
|
set l(value: number) {
|
||||||
if (this._isLValid(value)) this.#l = value
|
if (this._isLValid(value)) this.#l = value
|
||||||
|
|
|
@ -1,36 +1,25 @@
|
||||||
import { compile } from 'handlebars';
|
import { appendFile, mkdir, rm } from 'node:fs/promises';
|
||||||
import { appendFile, mkdir, rm, readFile, writeFile } from 'node:fs/promises';
|
|
||||||
import { dirname } from 'node:path'
|
import { dirname } from 'node:path'
|
||||||
|
|
||||||
const log = (isVerbose = true, ...rest: any[]) => {
|
export async function mkFilePath(file: string) {
|
||||||
if (isVerbose) console.info(...rest)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mkFilePath(file: string, isVerbose = false) {
|
|
||||||
try {
|
try {
|
||||||
log(isVerbose, 'Ensuring path and file exist', file)
|
|
||||||
await mkdir(dirname(file), { recursive: true })
|
await mkdir(dirname(file), { recursive: true })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function renderToFile(
|
export async function rmFile(file: string) {
|
||||||
templateFile: string, outputFile: string, data: any, isVerbose = false
|
|
||||||
): Promise<string> {
|
|
||||||
try {
|
try {
|
||||||
await mkFilePath(outputFile, isVerbose)
|
await rm(file)
|
||||||
|
} catch (error) {
|
||||||
log(isVerbose, 'Reading in template', templateFile)
|
throw error
|
||||||
const template = (await readFile(templateFile)).toString()
|
}
|
||||||
|
}
|
||||||
log(isVerbose, 'Compiling template', templateFile, 'with data', data)
|
|
||||||
const result = compile(template)(data)
|
export async function appendToFile(file: string, content: string) {
|
||||||
|
try {
|
||||||
log(isVerbose, 'Saving result', outputFile)
|
await appendFile(file, content)
|
||||||
await writeFile(outputFile, result)
|
|
||||||
|
|
||||||
return result
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
13
src/palette.toml
Normal file
13
src/palette.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
name = "verdigris"
|
||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[author]
|
||||||
|
name = "Gaiety"
|
||||||
|
email = "ava+verdigris@gaiety.me"
|
||||||
|
|
||||||
|
[colors]
|
||||||
|
|
||||||
|
[colors.bg]
|
||||||
|
l = 0.2
|
||||||
|
c = 0.02
|
||||||
|
h =
|
|
@ -91,20 +91,6 @@ export const purple = new Color('Purple', {
|
||||||
h: absDegrees(hueLevels.teal + (hueOffset * 5)),
|
h: absDegrees(hueLevels.teal + (hueOffset * 5)),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Colors = {
|
|
||||||
pit: string;
|
|
||||||
depths: string;
|
|
||||||
stope: string;
|
|
||||||
text: string;
|
|
||||||
orange: string;
|
|
||||||
teal: string;
|
|
||||||
red: string;
|
|
||||||
yellow: string;
|
|
||||||
green: string;
|
|
||||||
blue: string;
|
|
||||||
purple: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
pit,
|
pit,
|
||||||
depths,
|
depths,
|
||||||
|
|
Loading…
Add table
Reference in a new issue