Graphley / website · graphley.ai / tools / check-retirement.mjs
| 1 | import assert from 'node:assert/strict'; |
| 2 | import { readdirSync, readFileSync } from 'node:fs'; |
| 3 | import { onRequest } from '../functions/_middleware.js'; |
| 4 | |
| 5 | const output = new URL('../dist/', import.meta.url); |
| 6 | const files = readdirSync(output, { recursive: true }); |
| 7 | assert.ok(!files.some(file => /\.dmg$|(^|\/)appcast.*\.xml$|analytics\.js$/i.test(file))); |
| 8 | for (const file of files.filter(file => file.endsWith('.html') || file === 'llms.txt')) { |
| 9 | const text = readFileSync(new URL(file, output), 'utf8').replace('<script defer src="/assets/visitor-odometer.v1.js"></script>', ''); |
| 10 | assert.doesNotMatch(text, /testflight\.apple|mailto:|href="\/download|javascript|analytics\.js|<script\b|github\.com|\bDownload for Mac\b/i, file); |
| 11 | } |
| 12 | const request = (path, method = 'GET') => new Request('https://graphley.ai' + path, { method }); |
| 13 | for (const path of ['/download', '/download/', '/downloads/Graphley-1.0.3.dmg', '/appcast.xml?cache=1', '/appcast-legacy.xml']) { |
| 14 | for (const method of ['GET', 'HEAD']) { |
| 15 | const response = onRequest({ request: request(path, method), next: () => assert.fail(path) }); |
| 16 | assert.equal(response.status, 410); |
| 17 | assert.equal(response.headers.get('cache-control'), 'no-store'); |
| 18 | assert.equal(await response.text(), method === 'HEAD' ? '' : 'Graphley is no longer publicly distributed.\n'); |
| 19 | } |
| 20 | } |
| 21 | for (const path of ['/assets/analytics.js', '/assets/analytics.css', '/analytics-consent.gif?choice=granted']) { |
| 22 | for (const method of ['GET', 'HEAD']) { |
| 23 | const response = onRequest({ request: request(path, method), next: () => assert.fail(path) }); |
| 24 | assert.equal(response.status, 410); |
| 25 | assert.equal(response.headers.get('set-cookie'), null); |
| 26 | } |
| 27 | } |
| 28 | for (const path of ['/terms', '/terms/', '/terms/index.html']) { |
| 29 | const response = onRequest({ request: request(path), next: () => assert.fail(path) }); |
| 30 | assert.equal(response.status, 301); |
| 31 | assert.equal(response.headers.get('location'), '/privacy/'); |
| 32 | } |
| 33 | assert.ok(!files.some(file => /(^|\/)terms(\/|$)|analytics-consent/.test(file))); |
| 34 | const fixture = new Response(null, { status: 204 }); |
| 35 | for (const path of ['/api/sync', '/.well-known/apple-app-site-association', '/mcp/', '/privacy/']) { |
| 36 | assert.equal(onRequest({ request: request(path), next: () => fixture }), fixture); |
| 37 | } |
| 38 | console.log('Retirement notice, deployed files, retired routes, and passthrough checks passed.'); |