diff --git a/.gitignore b/.gitignore index 1eae0cf..b2665d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ dist/ node_modules/ +.DS_STORE \ No newline at end of file diff --git a/mod.test.ts b/mod.test.ts index d429e9e..90916eb 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -1,6 +1,6 @@ import { assertEquals } from "std/assert/assert_equals.ts"; -import { flavorEntries, flavors } from "@catppuccin/palette"; +import { flavorEntries, flavors, version } from "@catppuccin/palette"; import palette from "@/palette.json" with { type: "json" }; Deno.test("flavorEntries", () => { @@ -21,3 +21,7 @@ Deno.test("flavors", () => { ); }); }); + +Deno.test("version", () => { + assertEquals(version, "1.2.0"); // x-release-please-version +}); diff --git a/mod.ts b/mod.ts index 2df9dc9..e307036 100644 --- a/mod.ts +++ b/mod.ts @@ -187,17 +187,25 @@ export type ColorFormat = Readonly<{ accent: boolean; }>; +const { version: _, ...jsonFlavors } = definitions; + +/** + * The version of the Catppuccin palette + */ +export const version = definitions.version; + /** * All flavors of Catppuccin */ -export const flavors: CatppuccinFlavors = entriesFromObject(definitions) - .reduce((acc, [flavorName, flavor]) => { - acc[flavorName] = { - ...flavor, - colorEntries: entriesFromObject(flavor.colors), - }; - return acc; - }, {} as CatppuccinFlavors); +export const flavors: CatppuccinFlavors = entriesFromObject( + jsonFlavors, +).reduce((acc, [flavorName, flavor]) => { + acc[flavorName] = { + ...flavor, + colorEntries: entriesFromObject(flavor.colors), + }; + return acc; +}, {} as CatppuccinFlavors); /** * A typed `Object.entries()` iterable of all Catppuccin flavors diff --git a/palette.json b/palette.json index 8b5ca96..02eff06 100644 --- a/palette.json +++ b/palette.json @@ -1,4 +1,5 @@ { + "version": "1.2.0", "latte": { "name": "Latte", "emoji": "🌻", diff --git a/release-please-config.json b/release-please-config.json index 8a4a6d7..3ee18b6 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -8,6 +8,15 @@ "path": "deno.json", "type": "json", "jsonpath": "$.version" + }, + { + "path": "palette.json", + "type": "json", + "jsonpath": "$.version" + }, + { + "type": "generic", + "path": "mod.test.ts" } ] } diff --git a/scripts/gen_palette.ts b/scripts/gen_palette.ts index 7e3fffc..8cf9535 100644 --- a/scripts/gen_palette.ts +++ b/scripts/gen_palette.ts @@ -1,6 +1,8 @@ import { join } from "std/path/join.ts"; import tinycolor from "tinycolor2"; +import meta from "../deno.json" with { type: "json" }; + import type { CatppuccinColors, CatppuccinFlavor, @@ -226,7 +228,12 @@ const formatted = entriesFromObject(definitions) const __dirname = new URL(".", import.meta.url).pathname; +const result = { + version: meta.version, + ...formatted, +}; + Deno.writeTextFileSync( join(__dirname, "../palette.json"), - JSON.stringify(formatted, null, 2), + JSON.stringify(result, null, 2), );