Skip to content

Commit 3dba9da

Browse files
authored
feat: Better About Array (#265)
1 parent 159dc3f commit 3dba9da

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

apps/array/src/main/index.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
declare const __BUILD_COMMIT__: string | undefined;
2+
declare const __BUILD_DATE__: string | undefined;
3+
14
import dns from "node:dns";
25
import { mkdirSync } from "node:fs";
6+
import os from "node:os";
37
import path from "node:path";
48
import { fileURLToPath } from "node:url";
59
import {
610
app,
711
BrowserWindow,
12+
clipboard,
13+
dialog,
814
ipcMain,
915
Menu,
1016
type MenuItemConstructorOptions,
@@ -116,7 +122,38 @@ function createWindow(): void {
116122
{
117123
label: "Array",
118124
submenu: [
119-
{ role: "about" },
125+
{
126+
label: "About Array",
127+
click: () => {
128+
const commit = __BUILD_COMMIT__ ?? "dev";
129+
const buildDate = __BUILD_DATE__ ?? "dev";
130+
const info = [
131+
`Version: ${app.getVersion()}`,
132+
`Commit: ${commit}`,
133+
`Date: ${buildDate}`,
134+
`Electron: ${process.versions.electron}`,
135+
`Chromium: ${process.versions.chrome}`,
136+
`Node.js: ${process.versions.node}`,
137+
`V8: ${process.versions.v8}`,
138+
`OS: ${process.platform} ${process.arch} ${os.release()}`,
139+
].join("\n");
140+
141+
dialog
142+
.showMessageBox({
143+
type: "info",
144+
title: "About Array",
145+
message: "Array",
146+
detail: info,
147+
buttons: ["Copy", "OK"],
148+
defaultId: 1,
149+
})
150+
.then((result) => {
151+
if (result.response === 0) {
152+
clipboard.writeText(info);
153+
}
154+
});
155+
},
156+
},
120157
{ type: "separator" },
121158
{
122159
label: "Check for Updates...",

apps/array/vite.main.config.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
import { execSync } from "node:child_process";
12
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
23
import path, { join } from "node:path";
34
import { fileURLToPath } from "node:url";
45
import { defineConfig, type Plugin } from "vite";
56
import tsconfigPaths from "vite-tsconfig-paths";
67
import { autoServicesPlugin } from "./vite-plugin-auto-services.js";
78

9+
function getGitCommit(): string {
10+
try {
11+
return execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
12+
} catch {
13+
return "unknown";
14+
}
15+
}
16+
17+
function getBuildDate(): string {
18+
return new Date().toISOString();
19+
}
20+
821
const __dirname = path.dirname(fileURLToPath(import.meta.url));
922

1023
/**
@@ -139,6 +152,10 @@ function copyClaudeExecutable(): Plugin {
139152
}
140153

141154
export default defineConfig({
155+
define: {
156+
__BUILD_COMMIT__: JSON.stringify(getGitCommit()),
157+
__BUILD_DATE__: JSON.stringify(getBuildDate()),
158+
},
142159
plugins: [
143160
tsconfigPaths(),
144161
autoServicesPlugin(join(__dirname, "src/main/services")),

0 commit comments

Comments
 (0)