Sublime-style Build-n versioning + About box
Build n = commit count, baked at build time into a gitignored version.gen.ts (postinstall + all build scripts regenerate it). About lives in the macOS app menu and as a footer row in the options popover (the cross-platform path), showing build, commit, date and engines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,7 @@ const events = {
|
||||
openEditor: (_ctx: EditorOpenContext) => {},
|
||||
settingsChanged: (_settings: AppSettings) => {},
|
||||
openConnectionManager: () => {},
|
||||
showAbout: () => {},
|
||||
};
|
||||
const rpc = createAppRPC({ registry, engine, store, settings, edits, contextMenu, events });
|
||||
const url = await getMainViewUrl();
|
||||
@@ -104,6 +105,20 @@ events.settingsChanged = (s) => {
|
||||
manager.broadcastSettings(s);
|
||||
};
|
||||
events.openConnectionManager = () => manager.open();
|
||||
|
||||
function showAbout(): void {
|
||||
const { build } = BRANDING;
|
||||
void Utils.showMessageBox({
|
||||
type: "info",
|
||||
title: BRANDING.appName,
|
||||
message: BRANDING.appName,
|
||||
detail: `${BRANDING.buildLabel} (${build.commit}) · ${build.date}\n\nElectrobun ${build.electrobun} · Bun ${Bun.version}`,
|
||||
buttons: ["OK"],
|
||||
defaultId: 0,
|
||||
cancelId: 0,
|
||||
});
|
||||
}
|
||||
events.showAbout = showAbout;
|
||||
// clean editors close with the main window; dirty ones get to ask first,
|
||||
// and the modal manager has nothing to guard
|
||||
win.on("close", () => {
|
||||
@@ -204,6 +219,10 @@ ApplicationMenu.on("application-menu-clicked", (event) => {
|
||||
manager.open();
|
||||
return;
|
||||
}
|
||||
if (action === "about") {
|
||||
showAbout();
|
||||
return;
|
||||
}
|
||||
// the manager is modal to the main window — don't drive main behind it
|
||||
if (manager.isOpen()) return;
|
||||
rpc.send.menuAction({ action });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ApplicationMenu, type ApplicationMenuItemConfig } from "electrobun/bun";
|
||||
import { BRANDING } from "../shared/branding";
|
||||
import type { SavedConnection } from "../shared/types";
|
||||
import type { ConnectionStore } from "./store/connections";
|
||||
|
||||
@@ -32,6 +33,8 @@ export async function applyApplicationMenu(store: ConnectionStore): Promise<void
|
||||
ApplicationMenu.setApplicationMenu([
|
||||
{
|
||||
submenu: [
|
||||
{ label: `About ${BRANDING.appName}`, action: "about" },
|
||||
{ type: "separator" },
|
||||
{ role: "hide" },
|
||||
{ role: "hideOthers" },
|
||||
{ role: "showAll" },
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface AppDeps {
|
||||
openEditor: (ctx: EditorOpenContext) => void;
|
||||
settingsChanged: (settings: AppSettings) => void;
|
||||
openConnectionManager: () => void;
|
||||
showAbout: () => void;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -294,6 +295,12 @@ export function createAppRPC({
|
||||
events.openConnectionManager();
|
||||
return {};
|
||||
}),
|
||||
|
||||
showAbout: () =>
|
||||
wrap(async () => {
|
||||
events.showAbout();
|
||||
return {};
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
// The single place to rebrand the app. Everything (window title, bundle name,
|
||||
// app-data directory, UI header, icon) reads from here.
|
||||
import { BUILD } from "./version.gen";
|
||||
|
||||
export const BRANDING = {
|
||||
appName: "miniSCP",
|
||||
identifier: "es.teknes.miniscp",
|
||||
// Previous app names: their app-data folders are migrated on boot
|
||||
// (see migrateLegacyDataDir in src/bun/store/paths.ts).
|
||||
legacyNames: ["BunSCP"],
|
||||
version: "0.1.0",
|
||||
// Sublime-style versioning: n = commit count (scripts/gen-version.ts).
|
||||
// `version` stays semver-shaped for electrobun's config/updater.
|
||||
version: `0.1.${BUILD.number}`,
|
||||
buildLabel: `Build ${BUILD.number}`,
|
||||
build: BUILD,
|
||||
// macOS build converts this .iconset folder into AppIcon.icns.
|
||||
// Regenerate from assets/icon.png with scripts/gen-iconset.sh.
|
||||
icon: "assets/icon.iconset",
|
||||
|
||||
@@ -137,6 +137,8 @@ export type AppRPC = {
|
||||
moveToTrash: { params: { path: string }; response: Result };
|
||||
/** Native column-picker menu (right-click on the list headers). */
|
||||
showColumnsMenu: { params: { visible: ColumnKey[] }; response: Result };
|
||||
/** Native About box (name, Build n, commit, engine versions). */
|
||||
showAbout: { params: Record<string, never>; response: Result };
|
||||
// editor windows
|
||||
/** Main window only: open (or focus) a native editor window. */
|
||||
openEditor: { params: EditorOpenContext; response: Result };
|
||||
|
||||
Reference in New Issue
Block a user