Branchwell

Graphley / website · graphley.ai / tools / check-retirement.mjs

Raw 2.3 KB on 6d82912fd34a397e77ef35c57be6d7dcaa5173c1
1import assert from 'node:assert/strict';
2import { readdirSync, readFileSync } from 'node:fs';
3import { onRequest } from '../functions/_middleware.js';
4
5const output = new URL('../dist/', import.meta.url);
6const files = readdirSync(output, { recursive: true });
7assert.ok(!files.some(file => /\.dmg$|(^|\/)appcast.*\.xml$|analytics\.js$/i.test(file)));
8for (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}
12const request = (path, method = 'GET') => new Request('https://graphley.ai' + path, { method });
13for (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}
21for (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}
28for (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}
33assert.ok(!files.some(file => /(^|\/)terms(\/|$)|analytics-consent/.test(file)));
34const fixture = new Response(null, { status: 204 });
35for (const path of ['/api/sync', '/.well-known/apple-app-site-association', '/mcp/', '/privacy/']) {
36 assert.equal(onRequest({ request: request(path), next: () => fixture }), fixture);
37}
38console.log('Retirement notice, deployed files, retired routes, and passthrough checks passed.');