fix(website): fetch desktop version from latest GitHub release
The download page was showing pre-release versions because it read the version directly from package.json. Now fetches the latest non-prerelease from the GitHub Releases API at build time, with fallback to package.json for local dev.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import * as React from "react";
|
||||
import websitePackage from "../package.json";
|
||||
|
||||
export const desktopVersion = websitePackage.version;
|
||||
declare const __DESKTOP_VERSION__: string | undefined;
|
||||
|
||||
export const desktopVersion =
|
||||
typeof __DESKTOP_VERSION__ !== "undefined" ? __DESKTOP_VERSION__ : websitePackage.version;
|
||||
export const releaseBase = `https://github.com/getpaseo/paseo/releases/download/v${desktopVersion}`;
|
||||
export const macAppleSiliconDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-arm64.dmg`;
|
||||
export const macIntelDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-x64.dmg`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from "node:path";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, type UserConfig } from "vite";
|
||||
import tsConfigPaths from "vite-tsconfig-paths";
|
||||
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
||||
import { cloudflare } from "@cloudflare/vite-plugin";
|
||||
@@ -28,23 +28,44 @@ const sitemapPages = [
|
||||
path: routePath,
|
||||
}));
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
port: 8082,
|
||||
fs: {
|
||||
allow: [repoRoot],
|
||||
async function fetchLatestReleaseVersion(): Promise<string | undefined> {
|
||||
try {
|
||||
const res = await fetch(
|
||||
"https://api.github.com/repos/getpaseo/paseo/releases/latest",
|
||||
{ headers: { Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(5000) },
|
||||
);
|
||||
if (!res.ok) return undefined;
|
||||
const data = (await res.json()) as { tag_name: string };
|
||||
return data.tag_name.replace(/^v/, "");
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig(async (): Promise<UserConfig> => {
|
||||
const latestVersion = await fetchLatestReleaseVersion();
|
||||
|
||||
return {
|
||||
define: {
|
||||
...(latestVersion && { __DESKTOP_VERSION__: JSON.stringify(latestVersion) }),
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
cloudflare({ viteEnvironment: { name: "ssr" } }),
|
||||
tsConfigPaths(),
|
||||
tanstackStart({
|
||||
pages: sitemapPages,
|
||||
sitemap: {
|
||||
host: siteHost,
|
||||
server: {
|
||||
port: 8082,
|
||||
fs: {
|
||||
allow: [repoRoot],
|
||||
},
|
||||
}),
|
||||
react(),
|
||||
tailwindcss(),
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
cloudflare({ viteEnvironment: { name: "ssr" } }),
|
||||
tsConfigPaths(),
|
||||
tanstackStart({
|
||||
pages: sitemapPages,
|
||||
sitemap: {
|
||||
host: siteHost,
|
||||
},
|
||||
}),
|
||||
react(),
|
||||
tailwindcss(),
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user