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 * as React from "react";
|
||||||
import websitePackage from "../package.json";
|
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 releaseBase = `https://github.com/getpaseo/paseo/releases/download/v${desktopVersion}`;
|
||||||
export const macAppleSiliconDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-arm64.dmg`;
|
export const macAppleSiliconDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-arm64.dmg`;
|
||||||
export const macIntelDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-x64.dmg`;
|
export const macIntelDownloadUrl = `${releaseBase}/Paseo-${desktopVersion}-x64.dmg`;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig, type UserConfig } from "vite";
|
||||||
import tsConfigPaths from "vite-tsconfig-paths";
|
import tsConfigPaths from "vite-tsconfig-paths";
|
||||||
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
||||||
import { cloudflare } from "@cloudflare/vite-plugin";
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
||||||
@@ -28,23 +28,44 @@ const sitemapPages = [
|
|||||||
path: routePath,
|
path: routePath,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default defineConfig({
|
async function fetchLatestReleaseVersion(): Promise<string | undefined> {
|
||||||
server: {
|
try {
|
||||||
port: 8082,
|
const res = await fetch(
|
||||||
fs: {
|
"https://api.github.com/repos/getpaseo/paseo/releases/latest",
|
||||||
allow: [repoRoot],
|
{ 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) }),
|
||||||
},
|
},
|
||||||
},
|
server: {
|
||||||
plugins: [
|
port: 8082,
|
||||||
cloudflare({ viteEnvironment: { name: "ssr" } }),
|
fs: {
|
||||||
tsConfigPaths(),
|
allow: [repoRoot],
|
||||||
tanstackStart({
|
|
||||||
pages: sitemapPages,
|
|
||||||
sitemap: {
|
|
||||||
host: siteHost,
|
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
react(),
|
plugins: [
|
||||||
tailwindcss(),
|
cloudflare({ viteEnvironment: { name: "ssr" } }),
|
||||||
],
|
tsConfigPaths(),
|
||||||
|
tanstackStart({
|
||||||
|
pages: sitemapPages,
|
||||||
|
sitemap: {
|
||||||
|
host: siteHost,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
react(),
|
||||||
|
tailwindcss(),
|
||||||
|
],
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user