Skip to content

Commit 086ddb1

Browse files
committed
refactor: move twemoji to Rust build.rs and clean up scripts
1 parent 882ed1e commit 086ddb1

File tree

8 files changed

+75
-180
lines changed

8 files changed

+75
-180
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# GitHub OAuth Application Credentials
22
# Create an OAuth app at https://github.com/settings/developers
33
# Set the callback URL to: gitify://auth-callback
4-
54
OAUTH_CLIENT_ID=your_github_oauth_client_id
65
OAUTH_CLIENT_SECRET=your_github_oauth_client_secret
6+
7+
# GitHub Personal Access Token for GraphQL Codegen
8+
GITHUB_TOKEN=your_github_pat

.env.template

Lines changed: 0 additions & 2 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pnpm install
1818
> OAUTH_CLIENT_ID="123" OAUTH_CLIENT_SECRET="456789" pnpm build
1919
> ```
2020
21-
Copy the `.env.template` to `.env` and add update `GITHUB_TOKEN` with a GitHub Personal Access Token. This is used for fetching the latest GitHub GraphQL API schema for `graphql-codegen`.
21+
Copy the `.env.example` to `.env` and update `GITHUB_TOKEN` with a GitHub Personal Access Token. This is used for fetching the latest GitHub GraphQL API schema for `graphql-codegen`.
2222
```shell
2323
GITHUB_TOKEN=<some personal access token>
2424
```

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"build:check": "tsc && vite build",
1111
"preview": "vite preview",
1212
"tauri": "tauri",
13-
"tauri:dev": "node scripts/copy-twemoji.js && tauri dev",
14-
"tauri:build": "node scripts/copy-twemoji.js && tauri build",
15-
"tauri:build:debug": "node scripts/copy-twemoji.js && tauri build --debug",
13+
"tauri:dev": "tauri dev",
14+
"tauri:build": "tauri build",
15+
"tauri:build:debug": "tauri build --debug",
1616
"lint": "biome check --write .",
1717
"lint:check": "biome check .",
1818
"tsc": "tsc --noEmit",

scripts/afterPack.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

scripts/afterSign.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

scripts/copy-twemoji.js

Lines changed: 0 additions & 75 deletions
This file was deleted.

src-tauri/build.rs

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,70 @@
1+
use std::fs;
2+
use std::path::Path;
3+
4+
/// Emoji codepoints used in the app (from constants.ts and utils/errors.ts)
5+
const REQUIRED_EMOJIS: &[&str] = &[
6+
"1f389", // 🎉
7+
"1f38a", // 🎊
8+
"1f3c6", // 🏆
9+
"1f3d6", // 🏖️
10+
"1f44f", // 👏
11+
"1f513", // 🔓
12+
"1f52d", // 🔭
13+
"1f60e", // 😎
14+
"1f62e-200d-1f4a8", // 😮‍💨
15+
"1f633", // 😳
16+
"1f643", // 🙃
17+
"1f648", // 🙈
18+
"1f64c", // 🙌
19+
"1f680", // 🚀
20+
"1f6dc", // 🛜
21+
"1f914", // 🤔
22+
"1f972", // 🥲
23+
"1f973", // 🥳
24+
"1fae0", // 🫠
25+
"2728", // ✨
26+
];
27+
28+
fn copy_twemoji_assets() {
29+
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
30+
let project_root = Path::new(&manifest_dir).parent().unwrap();
31+
32+
let source_dir = project_root.join("node_modules/@discordapp/twemoji/dist/svg");
33+
let target_dir = Path::new(&manifest_dir).join("assets/twemoji");
34+
35+
// Create target directory if it doesn't exist
36+
if !target_dir.exists() {
37+
fs::create_dir_all(&target_dir).expect("Failed to create twemoji assets directory");
38+
}
39+
40+
// Check if source directory exists
41+
if !source_dir.exists() {
42+
println!(
43+
"cargo:warning=Twemoji source directory not found: {}. Run 'pnpm install' first.",
44+
source_dir.display()
45+
);
46+
return;
47+
}
48+
49+
for emoji in REQUIRED_EMOJIS {
50+
let source_file = source_dir.join(format!("{}.svg", emoji));
51+
let target_file = target_dir.join(format!("{}.svg", emoji));
52+
53+
if source_file.exists() {
54+
fs::copy(&source_file, &target_file).unwrap_or_else(|e| {
55+
panic!(
56+
"Failed to copy {}: {}",
57+
source_file.display(),
58+
e
59+
);
60+
});
61+
} else {
62+
println!("cargo:warning=Missing emoji SVG: {}", emoji);
63+
}
64+
}
65+
}
66+
167
fn main() {
2-
tauri_build::build()
68+
copy_twemoji_assets();
69+
tauri_build::build();
370
}

0 commit comments

Comments
 (0)