fix: correzioni della revisione finale (testi, visuale, brief, codice)
- testi: «lo Studio» uniforme, «Centro autorizzato CAF», ripetizioni tolte nei servizi e in «Lo studio», valori senza superlativi, meta corrette, testo della mappa di §10.2, numeri e indirizzi con spazi non separabili - visuale: breadcrumb, anello della banda CTA, card dei professionisti, pager e sidebar dei servizi su mobile, pagine legali a colonna singola, pulsante e-mail su una riga, card sedi allineate - dati: fatti della sede di Asti da studio.ts/testi.ts, sede.telefono - 404 e conferma senza canonical; avviso mappa senza JavaScript - controlli: CSP per direttive (endpoint), anno da SOURCE_DATE_EPOCH, URL del sito controllati sulla build locale, import file:// e tar da stdin per Windows, .gitattributes, porta libera corretta - modulo: pattern del telefono valido, avviso visibile, Esc sul sottomenu aperto al passaggio del mouse; contact.php con -f, senza mbstring obbligatorio, fuso Europe/Rome - release: note --shell-safe, ripiego REST automatico, RELEASE_TOKEN; deploy di esempio senza esclusione di contact.php; nginx /privacy/ - DECISIONS D-040–D-044, TODO C4 e riferimenti di riga aggiornati Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
51 files changed
+560
-185
No files matched your search
@@ -1,13 +1,21 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Stampa la sezione di CHANGELOG.md relativa a una versione: diventa il testo della release.
|
||||
* Uso: `node scripts/changelog-notes.mjs v1.0.0` (oppure 1.0.0). Esce con codice 1 se la
|
||||
* sezione non esiste, così non si pubblica una release senza note.
|
||||
* Uso: `node scripts/changelog-notes.mjs v1.0.0 [--shell-safe]` (oppure 1.0.0). Esce con
|
||||
* codice 1 se la sezione non esiste, così non si pubblica una release senza note.
|
||||
*
|
||||
* `--shell-safe` (usato da release.yml): niente caratteri che una shell interpreterebbe se
|
||||
* l'action li inserisse tra virgolette doppie: `codice` → «codice», " → ”, \ e $( → testo.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
const arg = (process.argv[2] ?? process.env.RELEASE_VERSION ?? '').replace(/^refs\/tags\//, '');
|
||||
const args = process.argv.slice(2);
|
||||
const shellSafe = args.includes('--shell-safe');
|
||||
const arg = (args.find((a) => !a.startsWith('--')) ?? process.env.RELEASE_VERSION ?? '').replace(
|
||||
/^refs\/tags\//,
|
||||
'',
|
||||
);
|
||||
const version = arg.replace(/^v/, '');
|
||||
if (!/^\d+\.\d+\.\d+/.test(version)) {
|
||||
console.error('Uso: node scripts/changelog-notes.mjs vX.Y.Z');
|
||||
@@ -36,4 +44,11 @@ if (!body) {
|
||||
console.error(`La sezione ${version} di CHANGELOG.md è vuota.`);
|
||||
process.exit(1);
|
||||
}
|
||||
process.stdout.write(`${body}\n`);
|
||||
const safe = (text) =>
|
||||
text
|
||||
.replace(/`([^`\n]*)`/g, '«$1»')
|
||||
.replace(/`/g, '')
|
||||
.replace(/"/g, '”')
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/\$(?=[({\w])/g, '$ ');
|
||||
process.stdout.write(`${shellSafe ? safe(body) : body}\n`);
|
||||
@@ -8,14 +8,18 @@
|
||||
*/
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { DomUtils, parseDocument } from 'htmlparser2';
|
||||
import { fileToPath, listHtmlFiles, readSitemapPaths } from './lib/pages.mjs';
|
||||
import { root } from './lib/preview-server.mjs';
|
||||
|
||||
const dist = resolve(root, 'dist');
|
||||
const { abilitazioni, professionisti, studio, contactForm } = await import(
|
||||
resolve(root, 'src/data/studio.ts')
|
||||
);
|
||||
// I moduli TypeScript del sito sono importati direttamente (type stripping di Node), con URL
|
||||
// file:// perché su Windows un percorso assoluto non è un URL valido per import().
|
||||
const importSrc = (path) => import(pathToFileURL(resolve(root, path)).href);
|
||||
const { abilitazioni, professionisti, studio, contactForm } = await importSrc('src/data/studio.ts');
|
||||
// stesso anno del footer: SOURCE_DATE_EPOCH, se impostata, altrimenti l'anno corrente
|
||||
const { buildYear } = await importSrc('src/lib/build.ts');
|
||||
|
||||
const SITE = (process.env.SITE_URL || 'https://www.grassoezio.it').replace(/\/+$/, '');
|
||||
const PIVA = `P.IVA ${studio.partitaIva}`;
|
||||
@@ -199,7 +203,7 @@ const COMMERCIALISTA_OK =
|
||||
/giulia|odcec|(ordine|consiglio nazionale) dei dottori commercialisti|\bocc\b|organismo di composizione della crisi/i;
|
||||
const titles = new Map();
|
||||
const descriptions = new Map();
|
||||
const year = String(new Date().getFullYear());
|
||||
const year = String(buildYear);
|
||||
|
||||
for (const page of pages) {
|
||||
const { doc, file, path, html } = page;
|
||||
@@ -242,16 +246,21 @@ for (const page of pages) {
|
||||
if (descriptions.has(desc)) fail(where, `descrizione duplicata di ${descriptions.get(desc)}`);
|
||||
descriptions.set(desc, path);
|
||||
|
||||
if (path !== '/404.html') {
|
||||
const canonical = findOne(
|
||||
(n) => n.name === 'link' && attr(n, 'rel') === 'canonical',
|
||||
doc.children,
|
||||
);
|
||||
// canonical e og:url solo per le pagine indicizzabili (404 e conferma del modulo: nessuno)
|
||||
const canonical = findOne(
|
||||
(n) => n.name === 'link' && attr(n, 'rel') === 'canonical',
|
||||
doc.children,
|
||||
);
|
||||
const ogUrl = findOne((n) => n.name === 'meta' && attr(n, 'property') === 'og:url', doc.children);
|
||||
if (NOINDEX_PAGES.includes(path)) {
|
||||
check(!canonical && !ogUrl, where, 'pagina noindex con canonical o og:url');
|
||||
} else {
|
||||
check(
|
||||
attr(canonical ?? {}, 'href') === `${SITE}${path}`,
|
||||
where,
|
||||
`canonical atteso ${SITE}${path}, trovato ${attr(canonical ?? {}, 'href')}`,
|
||||
);
|
||||
check(attr(ogUrl ?? {}, 'content') === `${SITE}${path}`, where, 'og:url diverso dal canonical');
|
||||
}
|
||||
|
||||
// un solo h1
|
||||
@@ -689,10 +698,6 @@ for (const [re, what] of [
|
||||
/RedirectMatch 301 \^\/privacy\/\?\$ \/privacy-policy\//,
|
||||
'redirect /privacy → /privacy-policy/',
|
||||
],
|
||||
[
|
||||
/Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; font-src 'self'; frame-src https:\/\/www\.google\.com; form-action 'self'; base-uri 'self'; frame-ancestors 'self'"/,
|
||||
'Content-Security-Policy di §9.4',
|
||||
],
|
||||
[/X-Content-Type-Options "nosniff"/, 'X-Content-Type-Options'],
|
||||
[/Referrer-Policy "strict-origin-when-cross-origin"/, 'Referrer-Policy'],
|
||||
[/Permissions-Policy/, 'Permissions-Policy'],
|
||||
@@ -703,6 +708,55 @@ for (const [re, what] of [
|
||||
check(re.test(htaccess), 'dist/.htaccess', `manca: ${what}`);
|
||||
}
|
||||
|
||||
// Content-Security-Policy di §9.4, confrontata per direttive. Con il modulo esterno
|
||||
// (`contactForm.mode = 'endpoint'`) form-action deve ammettere anche l'origine del fornitore.
|
||||
const EXPECTED_CSP = {
|
||||
'default-src': ["'self'"],
|
||||
'img-src': ["'self'", 'data:'],
|
||||
'style-src': ["'self'", "'unsafe-inline'"],
|
||||
'script-src': ["'self'"],
|
||||
'font-src': ["'self'"],
|
||||
'frame-src': ['https://www.google.com'],
|
||||
'form-action': ["'self'"],
|
||||
'base-uri': ["'self'"],
|
||||
'frame-ancestors': ["'self'"],
|
||||
};
|
||||
if (contactForm.mode === 'endpoint' && /^https:\/\//.test(contactForm.endpoint)) {
|
||||
EXPECTED_CSP['form-action'].push(new URL(contactForm.endpoint).origin);
|
||||
}
|
||||
/** Direttive della CSP in forma canonica (direttive e sorgenti in ordine alfabetico). */
|
||||
const canonicalCsp = (directives) =>
|
||||
JSON.stringify(
|
||||
Object.entries(directives)
|
||||
.map(([name, sources]) => [name, [...sources].sort()])
|
||||
.sort(([a], [b]) => a.localeCompare(b)),
|
||||
);
|
||||
const parseCsp = (value) =>
|
||||
Object.fromEntries(
|
||||
value
|
||||
.split(';')
|
||||
.map((d) => d.trim().split(/\s+/))
|
||||
.filter((d) => d[0])
|
||||
.map(([name, ...sources]) => [name, sources]),
|
||||
);
|
||||
const cspLines = [
|
||||
...htaccess.matchAll(/^\s*Header always set Content-Security-Policy "([^"]+)"/gm),
|
||||
];
|
||||
check(
|
||||
cspLines.length === 1,
|
||||
'dist/.htaccess',
|
||||
`attesa una sola Content-Security-Policy attiva, trovate ${cspLines.length}`,
|
||||
);
|
||||
if (cspLines.length === 1) {
|
||||
check(
|
||||
canonicalCsp(parseCsp(cspLines[0][1])) === canonicalCsp(EXPECTED_CSP),
|
||||
'dist/.htaccess',
|
||||
`Content-Security-Policy diversa da quella attesa (§9.4${
|
||||
contactForm.mode === 'endpoint' ? ' + origine del modulo esterno in form-action' : ''
|
||||
}): «${cspLines[0][1]}»`,
|
||||
);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ esito */
|
||||
|
||||
if (errors.length > 0) {
|
||||
|
||||
@@ -14,6 +14,10 @@ import { EXTRA_PAGES, readSitemapPaths } from './lib/pages.mjs';
|
||||
import { root, startPreview } from './lib/preview-server.mjs';
|
||||
|
||||
const external = process.argv.includes('--external');
|
||||
// URL assoluti del sito (canonical, og:url, og:image, JSON-LD): controllati sulla build locale,
|
||||
// non sul dominio di produzione, che prima della pubblicazione ospita ancora il vecchio sito.
|
||||
const SITE = (process.env.SITE_URL || 'https://www.grassoezio.it').replace(/\/+$/, '');
|
||||
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const dist = resolve(root, 'dist');
|
||||
const seeds = [...readSitemapPaths(dist), ...EXTRA_PAGES];
|
||||
|
||||
@@ -32,8 +36,12 @@ try {
|
||||
checkFragments: true,
|
||||
retryErrors: external,
|
||||
retryErrorsCount: 2,
|
||||
urlRewriteExpressions: [
|
||||
{ pattern: new RegExp(`^${escapeRe(SITE)}(?=/|$)`), replacement: base },
|
||||
],
|
||||
linksToSkip: async (link) => {
|
||||
if (link.startsWith(base)) return false;
|
||||
if (new RegExp(`^${escapeRe(SITE)}(?=/|$)`).test(link)) return false; // riscritto su base
|
||||
if (!/^https?:\/\//.test(link)) return true; // mailto:, tel:, data:
|
||||
return !external;
|
||||
},
|
||||
|
||||
@@ -63,11 +63,14 @@ function readZip(file) {
|
||||
return entries;
|
||||
}
|
||||
|
||||
/** Estrazione del tar.gz con `tar` di sistema in una cartella temporanea. */
|
||||
/**
|
||||
* Estrazione del tar.gz con `tar` di sistema in una cartella temporanea. L'archivio arriva da
|
||||
* stdin: su Windows il GNU tar di Git Bash interpreta «C:\…» come host remoto.
|
||||
*/
|
||||
function readTarGz(file) {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sito-studio-grasso-'));
|
||||
try {
|
||||
execFileSync('tar', ['-xzf', file, '-C', dir]);
|
||||
execFileSync('tar', ['-xzf', '-'], { cwd: dir, input: readFileSync(file) });
|
||||
const entries = new Map();
|
||||
for (const rel of listAll(dir)) entries.set(rel, readFileSync(join(dir, rel)));
|
||||
return entries;
|
||||
|
||||
@@ -14,7 +14,11 @@ async function freePort(preferred) {
|
||||
new Promise((ok) => {
|
||||
const srv = createServer();
|
||||
srv.once('error', () => ok(null));
|
||||
srv.listen(port, '127.0.0.1', () => srv.close(() => ok(port)));
|
||||
// con la porta 0 il sistema assegna una porta libera: va letta da address()
|
||||
srv.listen(port, '127.0.0.1', () => {
|
||||
const assigned = srv.address().port;
|
||||
srv.close(() => ok(assigned));
|
||||
});
|
||||
});
|
||||
return (await tryPort(preferred)) ?? (await tryPort(0));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user