Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version key into palette.json #91

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
node_modules/
.DS_STORE
6 changes: 5 additions & 1 deletion mod.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand All @@ -21,3 +21,7 @@ Deno.test("flavors", () => {
);
});
});

Deno.test("version", () => {
assertEquals(version, "1.2.0"); // x-release-please-version
});
24 changes: 16 additions & 8 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions palette.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "1.2.0",
"latte": {
"name": "Latte",
"emoji": "🌻",
Expand Down
9 changes: 9 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"path": "deno.json",
"type": "json",
"jsonpath": "$.version"
},
{
"path": "palette.json",
"type": "json",
"jsonpath": "$.version"
},
{
"type": "generic",
"path": "mod.test.ts"
}
]
}
Expand Down
9 changes: 8 additions & 1 deletion scripts/gen_palette.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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),
);