archivo del paquete→ .shtukbase/packages/std-keep-a-changelog/checks/cl01_format.ts
checks/cl01_format.ts
24 líneas, 1.4 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // CL-R01: the changelog exists; its first release heading is [Unreleased]; every release heading is
- // `## [version] - YYYY-MM-DD` (optionally ` [YANKED]`) with a real ISO 8601 day.
- import { config, isoDay, logs, PKG } from './kaclib.ts';
- import { finish, norm } from './lib/std.ts';
- const n = norm(PKG, 'CL-R01', 'enforce');
- const out: string[] = [];
- if (n.active) {
- const { logs: ls, missing } = logs(config());
- for (const f of missing) out.push(`${f}: there is no such file — create a changelog with the section "## [Unreleased]"`);
- for (const l of ls) {
- for (const b of l.bad) out.push(`${l.file}:${b.line}: the heading "${b.raw}" is not in the form "## [version] - YYYY-MM-DD" or "## [Unreleased]"`);
- const first = l.releases[0];
- if (!first || !first.unreleased) out.push(`${l.file}:${first?.line ?? 1}: the first section must be "## [Unreleased]"`);
- const un = l.releases.filter((r) => r.unreleased);
- for (const r of un.slice(1)) out.push(`${l.file}:${r.line}: a second Unreleased section`);
- for (const r of l.releases.filter((x) => !x.unreleased)) {
- if (!r.date) out.push(`${l.file}:${r.line}: release ${r.version} has no date — "## [${r.version}] - YYYY-MM-DD"`);
- else if (!isoDay(r.date)) out.push(`${l.file}:${r.line}: the date "${r.date}" of release ${r.version} is not an ISO 8601 day (YYYY-MM-DD)`);
- }
- for (const r of un) if (r.date) out.push(`${l.file}:${r.line}: Unreleased has no date`);
- }
- }
- finish(n, out);