refactor: move SIP generator to src, use yarn
This commit is contained in:
parent
26fe0a4789
commit
41832efd7a
8 changed files with 2898 additions and 4158 deletions
11
Makefile
11
Makefile
|
@ -1,11 +0,0 @@
|
||||||
LOG_INFO=$(shell date +"%H:%M:%S") \e[0;34mINFO\e[0m
|
|
||||||
LOG_ERROR=$(shell date +"%H:%M:%S") \e[1;31mERROR\e[0m
|
|
||||||
LOG_WARNING=$(shell date +"%H:%M:%S") \e[0;33mWARNING\e[0m
|
|
||||||
LOG_SUCCESS=$(shell date +"%H:%M:%S") \e[0;32mSUCCESS\e[0m
|
|
||||||
|
|
||||||
|
|
||||||
.DEFAULT_GOAL := publish
|
|
||||||
|
|
||||||
publish:
|
|
||||||
@echo -e "$(LOG_INFO) Publishing to NPM..."
|
|
||||||
@npm publish --access public
|
|
71
builder.js
71
builder.js
|
@ -1,71 +0,0 @@
|
||||||
import {variants,labels} from "./index.js"
|
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
const argv = process.argv.slice(2)
|
|
||||||
let theme = ""
|
|
||||||
|
|
||||||
let format = argv[0]
|
|
||||||
let out_file = argv[1]
|
|
||||||
|
|
||||||
function append(str) {
|
|
||||||
theme = theme + str
|
|
||||||
}
|
|
||||||
|
|
||||||
function write(msg) {
|
|
||||||
process.stdout.write(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
function capitalize_first_letter(str) {
|
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function write_result(content=theme) {
|
|
||||||
if (out_file != undefined) {
|
|
||||||
try {
|
|
||||||
fs.writeFileSync(out_file, content);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log(content)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (format) {
|
|
||||||
case 'css':
|
|
||||||
append(":root {\n")
|
|
||||||
for (let label in labels) {
|
|
||||||
for (let palette in variants) {
|
|
||||||
append("\t--ctp-" + palette + "-" + label + ": " + variants[palette][label]["hex"] + ";\n")
|
|
||||||
append("\t--ctp-" + palette + "-" + label + "-rgb" + ": " + variants[palette][label]["rgb"] + ";\n")
|
|
||||||
append("\t--ctp-" + palette + "-" + label + "-hsl" + ": " + variants[palette][label]["hsl"] + ";\n")
|
|
||||||
append("\t--ctp-" + palette + "-" + label + "-raw" + ": " + variants[palette][label]["raw"] + ";\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
append("}")
|
|
||||||
write_result()
|
|
||||||
break
|
|
||||||
case 'json':
|
|
||||||
append(JSON.stringify(variants))
|
|
||||||
write_result()
|
|
||||||
break
|
|
||||||
case 'markdown':
|
|
||||||
for (let palette in variants) {
|
|
||||||
append("| | Labels | Hex | RGB | HSL |\n")
|
|
||||||
append("| ----------------------------------------------------------------------- | ---------- | --------- | --------------- | --------------- |\n")
|
|
||||||
for (let label in labels) {
|
|
||||||
append(`| <img src="assets/palette/circles/.png" height="23" width="23"/> |`)
|
|
||||||
append(`${capitalize_first_letter(label)}` + "| ")
|
|
||||||
append(`\`${labels[label][palette]["hex"]} \`` + "| ")
|
|
||||||
append(`\`${labels[label][palette]["rgb"]} \`` + "| ")
|
|
||||||
append(`\`${labels[label][palette]["hsl"]} \`` + "| ")
|
|
||||||
append("\n")
|
|
||||||
}
|
|
||||||
append("\n")
|
|
||||||
}
|
|
||||||
write_result()
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
console.log('Wrong parameter')
|
|
||||||
break
|
|
||||||
}
|
|
4075
package-lock.json
generated
4075
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -63,6 +63,9 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^4.2.0",
|
"ava": "^4.2.0",
|
||||||
"esbuild": "^0.14.42",
|
"esbuild": "^0.14.42",
|
||||||
"standard-version": "^9.5.0"
|
"standard-version": "^9.5.0",
|
||||||
|
"ts-node": "^10.9.1",
|
||||||
|
"tsup": "^6.7.0",
|
||||||
|
"typescript": "^5.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
index.d.ts → src/index.d.ts
vendored
0
index.d.ts → src/index.d.ts
vendored
52
src/scripts/build_sip.mjs
Normal file
52
src/scripts/build_sip.mjs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import fs from "fs/promises";
|
||||||
|
import crypto from "crypto";
|
||||||
|
import { variants } from "@catppuccin/palette";
|
||||||
|
import url from "url";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
const dateString = new Date()
|
||||||
|
.toISOString()
|
||||||
|
.replace(/T/, " ")
|
||||||
|
.replace(/\..+/, "");
|
||||||
|
|
||||||
|
Object.entries(variants).map(([name, palette]) => {
|
||||||
|
name = `Catppuccin ${name.charAt(0).toUpperCase() + name.slice(1)}`;
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
cloud: true,
|
||||||
|
updatedAt: dateString,
|
||||||
|
sip: {
|
||||||
|
version: "2.6",
|
||||||
|
build: "260",
|
||||||
|
},
|
||||||
|
id: crypto.randomUUID().toUpperCase(),
|
||||||
|
readOnly: false,
|
||||||
|
createdAt: dateString,
|
||||||
|
dock: false,
|
||||||
|
name: name,
|
||||||
|
index: 1,
|
||||||
|
originalName: name,
|
||||||
|
like: false,
|
||||||
|
colors: Object.entries(palette).map(([key, value]) => {
|
||||||
|
const hex = palette[key].hex;
|
||||||
|
const r = parseInt(hex.substring(1, 3), 16) / 255;
|
||||||
|
const g = parseInt(hex.substring(3, 5), 16) / 255;
|
||||||
|
const b = parseInt(hex.substring(5, 7), 16) / 255;
|
||||||
|
|
||||||
|
return {
|
||||||
|
alpha: 1,
|
||||||
|
red: r,
|
||||||
|
green: g,
|
||||||
|
blue: b,
|
||||||
|
name: key,
|
||||||
|
createdAt: dateString,
|
||||||
|
id: crypto.randomUUID().toUpperCase(),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
lock: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const outFile = path.resolve(__dirname, `../../sip/${name}.palette`);
|
||||||
|
fs.writeFile(outFile, JSON.stringify(data, null, 2));
|
||||||
|
});
|
Loading…
Reference in a new issue