mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-11-23 03:43:52 +00:00
Hanzo CI/CD / test (linux-amd64) (push) Skipped
Hanzo CI/CD / test (linux-arm64) (push) Skipped
Hanzo CI/CD / test-advisory (push) Skipped
Hanzo CI/CD / test-amd64 (push) Successful in 21m44s
Hanzo CI/CD / cicd (push) Skipped
Hanzo CI/CD / verify (push) Skipped
CI/CD / cicd (push) Successful in 1h5m56s
The build failed on every run: @hanzo/ui/next adds an SVG loader, @svgr/webpack, that the app did not depend on. The app depends on it now. The icon is public/favicon.svg, which the layout's metadata names; an icon file in app/ goes through Next's image pipeline and failed the export. Testing: pnpm build --filter=bot-docs exits 0 and writes out/favicon.svg, the icon link and no whatsapp-bot.jpg; scripts/assets.test.ts holds the pictures and the icon. Risk: low. The deploy has never succeeded. How to revert: revert this commit. Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
import { join, resolve } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const ROOT = resolve(import.meta.dirname, '..');
|
|
const PUBLIC = join(ROOT, 'public');
|
|
const CONTENT = join(ROOT, 'content/docs');
|
|
|
|
const pages = (dir: string): string[] =>
|
|
readdirSync(dir, { withFileTypes: true }).flatMap((e) =>
|
|
e.isDirectory() ? pages(join(dir, e.name)) : /\.mdx?$/.test(e.name) ? [join(dir, e.name)] : [],
|
|
);
|
|
|
|
// A page that names an image the site does not carry is a 404 on every visit and a
|
|
// broken picture where the page put it. The app is a static export, so the files a
|
|
// page can name are `public/`'s, at the root: a relative name is read from the root
|
|
// of the host, as the browser reads `whatsapp-bot.jpg` on /docs.
|
|
describe('the images a docs page names', () => {
|
|
it('are files the export carries', () => {
|
|
const missing: string[] = [];
|
|
for (const page of pages(CONTENT)) {
|
|
const text = readFileSync(page, 'utf8');
|
|
for (const [, src] of text.matchAll(/<img\b[^>]*\bsrc=["']([^"']+)["']/g)) {
|
|
if (/^(?:[a-z]+:|\/\/|data:)/i.test(src)) continue;
|
|
if (!existsSync(join(PUBLIC, src.replace(/^\//, '').split(/[?#]/)[0]!))) {
|
|
missing.push(`${page.slice(CONTENT.length + 1)}: ${src}`);
|
|
}
|
|
}
|
|
}
|
|
expect(missing).toEqual([]);
|
|
});
|
|
|
|
it('has the icon the layout names', () => {
|
|
expect(existsSync(join(PUBLIC, 'favicon.svg'))).toBe(true);
|
|
});
|
|
});
|