import { readFile } from 'node:fs/promises'; import { test } from 'node:test'; import assert from 'node:assert/strict'; import vm from 'node:vm'; import ts from 'typescript'; import astroConfig from '../../apps/website/astro.config.mjs'; /** * Structural checks for the per-OS download pages in the built website. * The build resolves the latest release from the GitHub API and falls back to * the pinned published version, so assertions accept any semver but insist on direct * asset links, canonical URLs, structured data and internal linking. */ const distRoot = new URL('../../dist/apps/website/', import.meta.url); const { version: publishedVersion } = JSON.parse(await readFile(new URL('../../apps/website/released-version.json', import.meta.url), 'utf8')); const SITE = 'https://4gray.github.io/iptvnator'; const readDist = (relativePath) => readFile(new URL(relativePath, distRoot), 'utf8'); const assetLink = (suffix) => new RegExp( `https://github\\.com/4gray/iptvnator/releases/download/v\\d+\\.\\d+\\.\\d+/iptvnator-\\d+\\.\\d+\\.\\d+${suffix}` ); const PAGES = { windows: { path: 'download/windows/index.html', label: 'Windows', assets: ['-windows-x64-setup\\.exe'], operatingSystem: /Windows 10/, }, macos: { path: 'download/macos/index.html', label: 'macOS', assets: ['-mac-arm64\\.dmg', '-mac-x64\\.dmg'], operatingSystem: /macOS/, }, linux: { path: 'download/linux/index.html', label: 'Linux', assets: [ '-linux-x86_64\\.AppImage', '-linux-amd64\\.deb', '-linux-x86_64\\.rpm', '-linux-x64\\.pacman', '-linux-x86_64\\.flatpak', '-linux-arm64\\.AppImage', ], operatingSystem: /Linux/, }, }; function extractJsonLd(html) { const blocks = [...html.matchAll(/