Files
Harvey_Team_Page/scripts/check-release.mjs
T
FastD 0ac596086a Release wave: no data collection, contact by email, deploy from src/
- Remove the request form, consent checkbox, honeypot, success dialog,
  form.js, analytics.js, the Yandex Metrica id and the cookie banner (D23).
- Contact is a mailto card to harveymonsterteam@gmail.com; privacy.html
  rewritten for "no data collected"; Google Fonts replaced by four
  self-hosted WOFF2 files, so the page makes no third-party request.
- Drop `summary` from the case contract: the project dialog shows the case
  body only, the planet plaque uses tagline, and a project without shots
  opens one honest slot instead of three fake ones.
- Restore the original voice and punctuation in 12 cards, strip internal
  wording from published copy, fix stale counts (20 projects, 5 releases).
- Deploy = contents of src/: api/ moved to archive/api/, new release gate
  scripts/check-release.mjs, deploy guide docs/deploy.md.
- Sync docs: AGENTS.md (D23, D8, R4 closed, structure), design/spec.md
  section 10.31, DESIGN.md, PRODUCT.md, INDEX.md, inventory.
2026-11-15 17:34:40 +03:00

77 lines
3.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// check-release.mjs — гейт релиза: выгрузка = содержимое src/ и ничего больше.
// Проверяет: локальные пути из index.html и data/*.js существуют внутри src/,
// в поставляемых файлах нет запрещённых ссылок (Work_files, /api, внешние шрифты,
// сборщики аналитики, поля ввода), у скриптов стоит метка версии.
//
// Запуск: node scripts/check-release.mjs [YYYYMMDD]
// Exit 0 — можно выгружать; exit 1 — список нарушений.
import { readFileSync, existsSync, readdirSync, statSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const SRC = join(ROOT, 'src');
const STAMP = process.argv[2] || '';
const errors = [];
function walk(dir) {
return readdirSync(dir).flatMap((f) => {
const p = join(dir, f);
return statSync(p).isDirectory() ? walk(p) : [p];
});
}
const files = walk(SRC);
const text = files.filter((f) => /\.(html|js|css|md)$/.test(f));
const rel = (f) => f.slice(ROOT.length + 1).replace(/\\/g, '/');
// 1. Запрещённые ссылки в поставляемых файлах.
const BANNED = [
[/Work_files/i, 'ссылка на Work_files (вне docroot)'],
[/contact\.php/i, 'PHP-эндпоинт формы'],
[/HM_YM_ID|mc\.yandex\.ru/i, 'Яндекс.Метрика'],
[/(fonts|ajax)\.googleapis\.com|fonts\.gstatic\.com/i, 'внешние шрифты'],
[/localhost|127\.0\.0\.1/i, 'локальный адрес'],
[/<form\b/i, 'поле ввода / форма'],
];
for (const f of text) {
const body = readFileSync(f, 'utf8');
for (const [re, why] of BANNED) {
if (re.test(body)) errors.push(`${rel(f)}: ${why}`);
}
}
// README в docroot тоже уходит на сервер: путь за пределы src/ оттуда убирается (остальное в них
// законно — команды с 127.0.0.1, имена исходников).
for (const f of files.filter((p) => /\.md$/.test(p))) {
if (/Work_files/i.test(readFileSync(f, 'utf8'))) {
errors.push(`${rel(f)}: ссылка на Work_files (вне docroot)`);
}
}
// 2. Каждый локальный путь страницы и данных существует внутри src/.
const index = readFileSync(join(SRC, 'index.html'), 'utf8');
const paths = new Set();
for (const m of index.matchAll(/(?:href|src)="([^"]+)"/g)) paths.add(m[1]);
for (const f of files.filter((p) => /data[\\/].*\.js$/.test(p))) {
for (const m of readFileSync(f, 'utf8').matchAll(/"(assets\/[^"]+)"/g)) paths.add(m[1]);
}
for (const raw of paths) {
const p = raw.split('?')[0];
if (!p || /^(https?:|mailto:|tel:|#|\/\/|data:)/.test(p)) continue;
const target = join(SRC, p.split('#')[0]);
if (!existsSync(target)) errors.push(`index.html: путь не найден — ${p}`);
}
// 3. Метка версии у скриптов: без неё сервер отдаёт сутки старый js (src/.htaccess, js/css = 1 day).
for (const m of index.matchAll(/<script src="([^"]+\.js)(?:\?v=(\d+))?"/g)) {
if (!m[2]) errors.push(`index.html: нет ?v= у ${m[1]}`);
else if (STAMP && m[2] !== STAMP) errors.push(`index.html: ${m[1]} ?v=${m[2]}, ожидается ${STAMP}`);
}
if (errors.length) {
console.log('FAIL');
for (const e of errors) console.log(' -', e);
process.exit(1);
}
console.log(`PASS: ${files.length} файлов, ${paths.size} путей, метка ${STAMP || 'не проверялась'}; выгрузка = src/`);