Skip to content
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
18 changes: 18 additions & 0 deletions apps/roam/scripts/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import esbuild from "esbuild";
import fs from "fs";
import path from "path";
import { z } from "zod";

const getVersion = (): string => {
try {
const packageJson = JSON.parse(
fs.readFileSync(path.join(process.cwd(), "package.json"), "utf8"),
) as { version?: string };
return packageJson.version || "-";
} catch (error) {
console.warn("Failed to read version from package.json:", error);
return "-";
}
};

const getBuildDate = (): string => {
return new Date().toISOString().split("T")[0]; // YYYY-MM-DD format
};
let envContents = null;

try {
Expand Down Expand Up @@ -146,6 +162,8 @@ export const compile = ({
"process.env.SUPABASE_URL": `"${dbEnv.SUPABASE_URL}"`,
"process.env.SUPABASE_ANON_KEY": `"${dbEnv.SUPABASE_ANON_KEY}"`,
"process.env.NEXT_API_ROOT": `"${dbEnv.NEXT_API_ROOT || ""}"`,
"window.__DISCOURSE_GRAPH_VERSION__": `"${getVersion()}"`,
"window.__DISCOURSE_GRAPH_BUILD_DATE__": `"${getBuildDate()}"`,
},
sourcemap: process.env.NODE_ENV === "production" ? undefined : "inline",
minify: process.env.NODE_ENV === "production",
Expand Down
29 changes: 18 additions & 11 deletions apps/roam/src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import sendErrorEmail from "~/utils/sendErrorEmail";
import HomePersonalSettings from "./HomePersonalSettings";
import refreshConfigTree from "~/utils/refreshConfigTree";
import { FeedbackWidget } from "~/components/BirdEatsBugs";
import { getVersionWithDate } from "~/utils/getVersion";

type SectionHeaderProps = {
children: React.ReactNode;
Expand Down Expand Up @@ -230,17 +231,23 @@ export const SettingsDialog = ({
/>
</Tabs>
</div>
<Button
icon="send-message"
intent={Intent.PRIMARY}
onClick={() => {
const birdeatsbug = window.birdeatsbug as FeedbackWidget;
birdeatsbug.trigger?.();
}}
className="absolute bottom-4 left-4"
>
Send Feedback
</Button>
<div className="absolute bottom-4 left-4 flex items-center gap-4">
<Button
icon="send-message"
intent={Intent.PRIMARY}
onClick={() => {
const birdeatsbug = window.birdeatsbug as FeedbackWidget;
birdeatsbug.trigger?.();
}}
>
Send Feedback
</Button>
</div>
<div className="absolute bottom-4 right-4">
<span className="text-xs text-gray-500">
v{getVersionWithDate().version}-{getVersionWithDate().buildDate}
</span>
</div>
{/* <Button
icon="cross"
minimal
Expand Down
24 changes: 24 additions & 0 deletions apps/roam/src/utils/getVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Version is injected during build process
declare global {
interface Window {
__DISCOURSE_GRAPH_VERSION__?: string;
__DISCOURSE_GRAPH_BUILD_DATE__?: string;
}
}

export const getVersionWithDate = (): {
version: string;
buildDate: string;
} => {
if (typeof window === "undefined") {
return {
version: "-",
buildDate: "-",
};
}

return {
version: window.__DISCOURSE_GRAPH_VERSION__ || "-",
buildDate: window.__DISCOURSE_GRAPH_BUILD_DATE__ || "-",
};
};