Files
Rosea/tools/release/test/copy.test.ts

50 lines
1.9 KiB
TypeScript

import { spawnSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
/**
* The Aula page's words are read by strangers, like a store listing (CLAUDE.md §8), so
* lint:copy must read them (fabrica-release.md F11). The rules themselves are tested in
* @rosea/content; this proves the files are in the list the script checks.
*/
const repo = fileURLToPath(new URL('../../../', import.meta.url));
const tsx = createRequire(join(repo, 'package.json')).resolve('tsx/cli');
function listed(): string[] {
const run = spawnSync(process.execPath, [tsx, join(repo, 'scripts/lint-copy.ts'), '--list'], { cwd: repo, encoding: 'utf8' });
expect(run.status, run.stderr).toBe(0);
return run.stdout.split(/\r?\n/).filter(Boolean);
}
describe('lint:copy reads the Aula page', { timeout: 60_000 }, () => {
it('AULA.md, the brief and every release note are checked', () => {
const files = listed();
expect(files).toContain('AULA.md');
expect(files).toContain('.fabrica/aula/brief.md');
expect(files).toContain('.fabrica/notes/0.1.0.md');
});
it("a release's generated notes are checked when they are there", () => {
const notes = join(repo, 'target/notes/release-notes.md');
const had = existsSync(notes);
if (!had) {
mkdirSync(dirname(notes), { recursive: true });
writeFileSync(notes, '# notes\n');
}
try {
expect(listed()).toContain('target/notes/release-notes.md');
} finally {
if (!had) rmSync(notes);
}
});
it('the game itself is still checked', () => {
const files = listed();
expect(files).toContain('packages/ui/src/copy/en.ts');
expect(files).toContain('docs/LETTER.md');
});
});