mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 20:56:19 -08:00
fix(website): inject the fallback version instead of importing package.json
`website:lint` failed on master since the per-OS download pages landed:
`src/lib/downloads.ts` imported the workspace root `package.json` through a
relative path, which `@nx/enforce-module-boundaries` rejects ("external
resources cannot be imported using a relative or absolute path").
The value is only needed as a build-time constant for the offline fallback,
so `astro.config.mjs` now reads the root manifest through the file system
and injects `__IPTVNATOR_VERSION__` via Vite `define`; `downloads.ts` uses
that constant and `src/env.d.ts` declares its type. Verified with
`WEBSITE_SKIP_RELEASE_FETCH=1`: the built download pages link the
`iptvnator-<version>` assets and no define literal leaks into the output.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
2fc1bd5601
commit
70fff19977
3 files changed
+32
-3
No files matched your search
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/// <reference types="astro/client" />
|
||||
|
||||
/**
|
||||
* Repository version from the workspace root `package.json`, injected at
|
||||
* build time by `astro.config.mjs` through Vite `define`. Used by the download
|
||||
* pages' offline fallback (`src/lib/downloads.ts`).
|
||||
*/
|
||||
declare const __IPTVNATOR_VERSION__: string;
|
||||
@@ -1,4 +1,3 @@
|
||||
import rootPackage from '../../../../package.json';
|
||||
import type { DownloadPlatform } from './platforms';
|
||||
|
||||
/**
|
||||
@@ -9,9 +8,13 @@ import type { DownloadPlatform } from './platforms';
|
||||
* exists, and so file sizes and the publish date can be shown. When the API
|
||||
* is unreachable (offline build, rate limit, `WEBSITE_SKIP_RELEASE_FETCH=1`)
|
||||
* the pages fall back to the repository version from the root `package.json`
|
||||
* — injected as `__IPTVNATOR_VERSION__` by `astro.config.mjs`, since a
|
||||
* relative import of the root manifest violates the Nx module boundaries —
|
||||
* and the known asset naming pattern from `electron-builder.json`.
|
||||
*/
|
||||
|
||||
const FALLBACK_VERSION = __IPTVNATOR_VERSION__;
|
||||
|
||||
export const GITHUB_REPO = '4gray/iptvnator';
|
||||
export const REPO_URL = `https://github.com/${GITHUB_REPO}`;
|
||||
export const RELEASES_URL = `${REPO_URL}/releases`;
|
||||
@@ -304,7 +307,7 @@ function normalizeAsset(value: unknown): ReleaseAsset[] {
|
||||
}
|
||||
|
||||
function fallbackRelease(): ResolvedRelease {
|
||||
const version = rootPackage.version;
|
||||
const version = FALLBACK_VERSION;
|
||||
const tag = `v${version}`;
|
||||
const assets = Object.values(DOWNLOAD_OPTIONS)
|
||||
.flat()
|
||||
@@ -323,5 +326,5 @@ function fallbackRelease(): ResolvedRelease {
|
||||
}
|
||||
|
||||
function warnFallback(reason: string): void {
|
||||
console.warn(`[website] Latest release lookup failed (${reason}); using package.json version ${rootPackage.version}.`);
|
||||
console.warn(`[website] Latest release lookup failed (${reason}); using package.json version ${FALLBACK_VERSION}.`);
|
||||
}
|
||||
Reference in new issue
Block a user