import assert from 'node:assert/strict'; import { readdirSync, readFileSync } from 'node:fs'; import { onRequest } from '../functions/_middleware.js'; const output = new URL('../dist/', import.meta.url); const files = readdirSync(output, { recursive: true }); assert.ok(!files.some(file => /\.dmg$|(^|\/)appcast.*\.xml$|analytics\.js$/i.test(file))); for (const file of files.filter(file => file.endsWith('.html') || file === 'llms.txt')) { const text = readFileSync(new URL(file, output), 'utf8').replace('', ''); assert.doesNotMatch(text, /testflight\.apple|mailto:|href="\/download|javascript|analytics\.js| new Request('https://graphley.ai' + path, { method }); for (const path of ['/download', '/download/', '/downloads/Graphley-1.0.3.dmg', '/appcast.xml?cache=1', '/appcast-legacy.xml']) { for (const method of ['GET', 'HEAD']) { const response = onRequest({ request: request(path, method), next: () => assert.fail(path) }); assert.equal(response.status, 410); assert.equal(response.headers.get('cache-control'), 'no-store'); assert.equal(await response.text(), method === 'HEAD' ? '' : 'Graphley is no longer publicly distributed.\n'); } } for (const path of ['/assets/analytics.js', '/assets/analytics.css', '/analytics-consent.gif?choice=granted']) { for (const method of ['GET', 'HEAD']) { const response = onRequest({ request: request(path, method), next: () => assert.fail(path) }); assert.equal(response.status, 410); assert.equal(response.headers.get('set-cookie'), null); } } for (const path of ['/terms', '/terms/', '/terms/index.html']) { const response = onRequest({ request: request(path), next: () => assert.fail(path) }); assert.equal(response.status, 301); assert.equal(response.headers.get('location'), '/privacy/'); } assert.ok(!files.some(file => /(^|\/)terms(\/|$)|analytics-consent/.test(file))); const fixture = new Response(null, { status: 204 }); for (const path of ['/api/sync', '/.well-known/apple-app-site-association', '/mcp/', '/privacy/']) { assert.equal(onRequest({ request: request(path), next: () => fixture }), fixture); } console.log('Retirement notice, deployed files, retired routes, and passthrough checks passed.');