Skip to content

Commit 36240ec

Browse files
nullishamysgoudham
andauthored
feat!: auto-generate from palette.json (#3)
This commit rewrites the library to be generated from the palette.json which acts as a source of truth. The project is now a multi-module maven project, with the "processing" module responsible for generating the code used in the "palette" module. Both modules will be published to Maven Central and available as separate JARs. Co-authored-by: sgoudham <[email protected]>
1 parent 0b034e3 commit 36240ec

File tree

25 files changed

+2920
-805
lines changed

25 files changed

+2920
-805
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake;

.github/workflows/build.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout Repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222

2323
- name: Setup Java
24-
uses: actions/setup-java@v3
24+
uses: actions/setup-java@v4
2525
with:
26-
distribution: 'temurin'
26+
distribution: 'adopt'
2727
java-version: '8'
2828
cache: 'maven'
2929

@@ -33,25 +33,14 @@ jobs:
3333
- name: Test
3434
run: mvn test
3535

36-
- name: Retrieve Name & Version
37-
run: |
38-
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
39-
echo "NAME=$(mvn help:evaluate -Dexpression=project.name -q -DforceStdout)" >> $GITHUB_ENV
40-
41-
- name: Archive Jar
42-
uses: actions/upload-artifact@v3
43-
with:
44-
name: ${{ env.NAME }}-${{ env.VERSION }}.jar
45-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}.jar
46-
47-
- name: Archive Javadoc
48-
uses: actions/upload-artifact@v3
36+
- name: Archive Palette Artifacts
37+
uses: actions/upload-artifact@v4
4938
with:
50-
name: ${{ env.NAME }}-${{ env.VERSION }}-javadoc.jar
51-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}-javadoc.jar
39+
name: palette-jars
40+
path: ./palette/target/*.jar
5241

53-
- name: Archive Sources
54-
uses: actions/upload-artifact@v3
42+
- name: Archive Processing Artifacts
43+
uses: actions/upload-artifact@v4
5544
with:
56-
name: ${{ env.NAME }}-${{ env.VERSION }}-sources.jar
57-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}-sources.jar
45+
name: processing-jars
46+
path: ./processing/target/*.jar

.github/workflows/deploy.yml

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout Repository
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- name: Setup Java
16-
uses: actions/setup-java@v3
16+
uses: actions/setup-java@v4
1717
with:
18-
distribution: 'temurin'
18+
distribution: 'adopt'
1919
java-version: '8'
2020
cache: 'maven'
2121
server-id: ossrh
@@ -34,33 +34,10 @@ jobs:
3434
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
3535
run: mvn -B -DskipTests deploy
3636

37-
- name: Get Name & Version
38-
run: |
39-
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
40-
echo "NAME=$(mvn help:evaluate -Dexpression=project.name -q -DforceStdout)" >> $GITHUB_ENV
41-
42-
- name: Archive Jar
43-
uses: actions/upload-artifact@v3
44-
with:
45-
name: ${{ env.NAME }}-${{ env.VERSION }}.jar
46-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}.jar
47-
48-
- name: Archive Javadoc
49-
uses: actions/upload-artifact@v3
50-
with:
51-
name: ${{ env.NAME }}-${{ env.VERSION }}-javadoc.jar
52-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}-javadoc.jar
53-
54-
- name: Archive Sources
55-
uses: actions/upload-artifact@v3
56-
with:
57-
name: ${{ env.NAME }}-${{ env.VERSION }}-sources.jar
58-
path: ./target/${{ env.NAME }}-${{ env.VERSION }}-sources.jar
59-
6037
- name: Create Release
6138
uses: ncipollo/release-action@v1
6239
with:
63-
artifacts: target/*.jar
40+
artifacts: "palette/target/*.jar,processing/target/*.jar"
6441
generateReleaseNotes: true
6542
makeLatest: true
6643
draft: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ build/
3333

3434
### Mac OS ###
3535
.DS_Store
36+
37+
.direnv/

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Project layout
2+
3+
This project uses the Maven Multi Module system to build the various modules. There is the main module, the palette,
4+
which depends on the secondary module 'processing', to do the code generation based on our `palette.json`.
5+
The multi module system is used as it is the easiest way to get our processing module to build at the same time, and then get used
6+
by, the palette module. This also has the benefit of allowing us to publish the processing module independently.
7+
8+
The `palette.json` is vendored for simplicity, and must be manually updated if/when it changes.
9+

README.md

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ package com.catppuccin;
5353

5454
public class Main {
5555
public static void main(String[] args) {
56-
String mocha = Palette.MOCHA.getName(); // mocha
57-
String mochaBaseHex = Palette.MOCHA.getBase().getHex(); // 1e1e2e
58-
int[] mochaBaseRGB = Palette.MOCHA.getBase().getRGBComponents(); // [30, 30, 46]
56+
String mocha = Palette.MOCHA.name(); // mocha
57+
String mochaBaseHex = Palette.MOCHA.base().hex(); // 1e1e2e
58+
int[] mochaBaseRGB = Palette.MOCHA.base().components(); // [30, 30, 46]
5959

6060
// loop through just frappé
6161
for (Pair<String, Color> colourPair : Palette.FRAPPE.toList()) {
62-
String name = colourPair.getKey();
63-
Color colour = colourPair.getValue();
64-
System.out.println(name + ": " + colour.getHex());
62+
String name = colourPair.key();
63+
Color colour = colourPair.value();
64+
System.out.println(name + ": " + colour.hex());
6565
}
6666

6767
// loop through every colour
6868
for (Flavour flavour : Palette.toList()) {
69-
System.out.println("Flavour: " + flavour.getName());
69+
System.out.println("Flavour: " + flavour.name());
7070
for (Pair<String, Color> colourPair : flavour.toList()) {
71-
String name = colourPair.getKey();
72-
Color colour = colourPair.getValue();
73-
System.out.println(name + ": " + colour.getHex());
71+
String name = colourPair.key();
72+
Color colour = colourPair.value();
73+
System.out.println(name + ": " + colour.hex());
7474
}
7575
}
7676
}
@@ -82,35 +82,10 @@ public class Main {
8282
If you are looking to contribute, please read through our
8383
[CONTRIBUTING.md](https://github.com/catppuccin/.github/blob/main/CONTRIBUTING.md) first!
8484

85-
### Development
86-
87-
This project uses the build tool [Maven](https://maven.apache.org/) from the java ecosystem. It is *highly* recommended
88-
to develop using [Intellij IDEA](https://www.jetbrains.com/idea/) as it will allow you to take advantage of its
89-
integration with maven tooling.
90-
91-
The project can be built using the command:
92-
93-
```shell
94-
./mvnw clean package
95-
```
96-
97-
and running tests is as simple as:
98-
99-
```shell
100-
./mvnw test
101-
```
102-
103-
A great 5-minute introduction to Maven can be
104-
found [here](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
105-
106-
### CI / CD
107-
108-
This project has a GitHub actions workflow to automatically build binaries and deploy to maven central. The workflows
109-
are stored at [.github/workflows](.github/workflows)
110-
11185
## 💝 Thanks to
11286

11387
- [Hamothy](https://github.com/sgoudham)
88+
- [nullishamy](https://github.com/nullishamy)
11489

11590
&nbsp;
11691

assets/.gitkeep

Whitespace-only changes.

flake.lock

Lines changed: 130 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
description = "A devShell example";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
rust-overlay.url = "github:oxalica/rust-overlay";
7+
flake-utils.url = "github:numtide/flake-utils";
8+
};
9+
10+
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
11+
flake-utils.lib.eachDefaultSystem (system:
12+
let
13+
overlays = [ (import rust-overlay) ];
14+
pkgs = import nixpkgs {
15+
inherit system overlays;
16+
};
17+
in
18+
with pkgs;
19+
{
20+
devShell = mkShell {
21+
buildInputs = [
22+
openjdk11-bootstrap
23+
];
24+
};
25+
}
26+
);
27+
}

0 commit comments

Comments
 (0)