refactor: generate procreate via node
This commit is contained in:
parent
1392312ef6
commit
75d3875693
9 changed files with 96 additions and 57 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
/dist/
|
||||
/node_modules/
|
||||
/palettes/
|
||||
/*.tgz
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
"devDependencies": {
|
||||
"ava": "^4.2.0",
|
||||
"esbuild": "^0.14.42",
|
||||
"procreate-swatches": "^0.1.1",
|
||||
"standard-version": "^9.5.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsup": "^6.7.0",
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env deno run --allow-read --allow-write --allow-env
|
||||
import { createSwatchesFile } from "npm:procreate-swatches";
|
||||
|
||||
const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1);
|
||||
|
||||
type Color = {
|
||||
hex: string;
|
||||
rgb: string;
|
||||
hsl: string;
|
||||
};
|
||||
type Palette = Record<string, Color>;
|
||||
|
||||
const library: Palette[] = JSON.parse(
|
||||
await Deno.readTextFile("../palette.json"),
|
||||
);
|
||||
|
||||
for (const palette in library) {
|
||||
const colours: Palette = library[palette];
|
||||
|
||||
const rgbValues = Object.values(colours).map((colour) => [
|
||||
colour.rgb.match(/\d+/g),
|
||||
"rgb",
|
||||
]);
|
||||
|
||||
const name = `Catppuccin ${capitalize(palette)}`;
|
||||
const data: ArrayBuffer = await createSwatchesFile(name, rgbValues);
|
||||
|
||||
Deno.writeFileSync(`./${name}.swatches`, new Uint8Array(data));
|
||||
}
|
|
@ -1,20 +1,39 @@
|
|||
import fs from "fs/promises";
|
||||
import fs from "fs";
|
||||
import crypto from "crypto";
|
||||
import { variants } from "@catppuccin/palette";
|
||||
import url from "url";
|
||||
import path from "path";
|
||||
import { createSwatchesFile } from "procreate-swatches";
|
||||
|
||||
const root = path.resolve(
|
||||
url.fileURLToPath(new URL(".", import.meta.url)),
|
||||
"..",
|
||||
"..",
|
||||
"palettes"
|
||||
"dist"
|
||||
);
|
||||
const dateString = new Date()
|
||||
.toISOString()
|
||||
.replace(/T/, " ")
|
||||
.replace(/\..+/, "");
|
||||
|
||||
const generateGimp = (name, palette) => {
|
||||
const n = Object.keys(palette).length;
|
||||
const head = `GIMP Palette\n#Palette Name: ${name}\n#Colors: ${n}\n`;
|
||||
const pad = (str) => str.toString().padStart(3, " ");
|
||||
const body = Object.values(palette)
|
||||
.map((value) => {
|
||||
const v = [
|
||||
pad(value.rgb.r),
|
||||
pad(value.rgb.g),
|
||||
pad(value.rgb.b),
|
||||
value.hex,
|
||||
];
|
||||
return v.join(" ");
|
||||
})
|
||||
.join("\n");
|
||||
return head + body;
|
||||
};
|
||||
|
||||
const generateSip = (name, palette) => {
|
||||
const data = {
|
||||
cloud: true,
|
||||
|
@ -47,33 +66,30 @@ const generateSip = (name, palette) => {
|
|||
return JSON.stringify(data, null, 2);
|
||||
};
|
||||
|
||||
const generateGimp = (name, palette) => {
|
||||
const n = Object.keys(palette).length;
|
||||
const head = `GIMP Palette\n#Palette Name: ${name}\n#Colors: ${n}\n`;
|
||||
const pad = (str) => str.toString().padStart(3, " ");
|
||||
const palette = Object.values(palette)
|
||||
.map((value) => {
|
||||
const v = [
|
||||
pad(value.rgb.r),
|
||||
pad(value.rgb.g),
|
||||
pad(value.rgb.b),
|
||||
value.hex,
|
||||
];
|
||||
return v.join(" ");
|
||||
})
|
||||
.join("\n");
|
||||
return head + palette;
|
||||
const generateProcreate = async (name, palette) => {
|
||||
const rgbValues = Object.values(palette).map((colour) => [
|
||||
[colour.rgb.r, colour.rgb.g, colour.rgb.b],
|
||||
"rgb",
|
||||
]);
|
||||
return await createSwatchesFile(name, rgbValues);
|
||||
};
|
||||
|
||||
Object.entries(variants).map(([name, palette]) => {
|
||||
Object.entries(variants).map(async ([name, palette]) => {
|
||||
name = `Catppuccin ${name.charAt(0).toUpperCase() + name.slice(1)}`;
|
||||
|
||||
const sip = generateSip(name, palette);
|
||||
const gimp = generateGimp(name, palette);
|
||||
const folders = ["sip", "gimp"];
|
||||
folders.map((folder) => {
|
||||
fs.mkdir(path.join(root, folder), { recursive: true });
|
||||
});
|
||||
fs.writeFile(path.resolve(root, `sip/${name}.palette`), sip);
|
||||
fs.writeFile(path.resolve(root, `gimp/${name}.gpl`), gimp);
|
||||
["gimp", "sip", "procreate"].map((folder) =>
|
||||
fs.mkdirSync(path.join(root, folder), { recursive: true })
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.resolve(root, `sip/${name}.palette`),
|
||||
generateSip(name, palette)
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.resolve(root, `gimp/${name}.gpl`),
|
||||
generateGimp(name, palette)
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.resolve(root, `procreate/${name}.swatches`),
|
||||
await generateProcreate(name, palette)
|
||||
);
|
||||
});
|
||||
|
|
52
yarn.lock
52
yarn.lock
|
@ -221,6 +221,18 @@
|
|||
"@nodelib/fs.scandir" "2.1.5"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@szydlovski/color-convert@^0.1.3":
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@szydlovski/color-convert/-/color-convert-0.1.3.tgz#9b7b2e05d97f02b52f0be599f6ec78fe753de521"
|
||||
integrity sha512-An3T2Q4LEaSjnU8ullD04lCshYA/+6k9avQCs1hmxyuwEA6UHh6Da/ue1+MFxYYG4I9eODct1a/kuFmDyRazlg==
|
||||
|
||||
"@szydlovski/zip@^0.1.0":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@szydlovski/zip/-/zip-0.1.2.tgz#98f960ef8fd6b162dba136078badc28a8d2a58dd"
|
||||
integrity sha512-hoQ3wrEYosEOT3LepTwdX+nhlFqjqioftbHXSmGxm863ZxVJUyp7uedYjIqUoGmKheAAM9EHXFHGydxfZlwUhg==
|
||||
dependencies:
|
||||
jszip "^3.5.0"
|
||||
|
||||
"@tsconfig/node10@^1.0.7":
|
||||
version "1.0.9"
|
||||
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
|
||||
|
@ -1439,6 +1451,11 @@ ignore@^5.2.0:
|
|||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
|
||||
integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==
|
||||
|
||||
immediate@~3.0.5:
|
||||
version "3.0.6"
|
||||
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
|
||||
integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==
|
||||
|
||||
imurmurhash@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
|
||||
|
@ -1628,11 +1645,28 @@ jsonparse@^1.2.0:
|
|||
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
|
||||
integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==
|
||||
|
||||
jszip@^3.5.0:
|
||||
version "3.10.1"
|
||||
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2"
|
||||
integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==
|
||||
dependencies:
|
||||
lie "~3.3.0"
|
||||
pako "~1.0.2"
|
||||
readable-stream "~2.3.6"
|
||||
setimmediate "^1.0.5"
|
||||
|
||||
kind-of@^6.0.3:
|
||||
version "6.0.3"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
|
||||
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
|
||||
|
||||
lie@~3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
|
||||
integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==
|
||||
dependencies:
|
||||
immediate "~3.0.5"
|
||||
|
||||
lilconfig@^2.0.5:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52"
|
||||
|
@ -2026,6 +2060,11 @@ p-try@^2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
|
||||
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==
|
||||
|
||||
pako@~1.0.2:
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
|
||||
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
|
||||
|
||||
parse-json@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0"
|
||||
|
@ -2146,6 +2185,14 @@ process-nextick-args@~2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
|
||||
|
||||
procreate-swatches@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/procreate-swatches/-/procreate-swatches-0.1.1.tgz#212dc3ad7af7139a308f77132bded08bd460d8d2"
|
||||
integrity sha512-8urk7+DmqspwH5/ZYAlSwqrX/L1p3fl/waohI8EKwnELyPfKtf1/2EG6r1AZ0Zh3sctnmDJeui0DMPUm3iwlzQ==
|
||||
dependencies:
|
||||
"@szydlovski/color-convert" "^0.1.3"
|
||||
"@szydlovski/zip" "^0.1.0"
|
||||
|
||||
punycode@^2.1.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
|
||||
|
@ -2325,6 +2372,11 @@ serialize-error@^7.0.1:
|
|||
dependencies:
|
||||
type-fest "^0.13.1"
|
||||
|
||||
setimmediate@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||
integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
|
||||
|
||||
shebang-command@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
|
||||
|
|
Loading…
Reference in a new issue