-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(delivery): stop delivered HTML from requesting Google Fonts #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ebcce0f
3c5363d
a8aede4
7fae5aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { test } from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import fs from 'node:fs'; | ||
| import os from 'node:os'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const skillRoot = path.resolve(__dirname, '..'); | ||
| const cli = path.join(skillRoot, 'bin/archify.mjs'); | ||
| const template = fs.readFileSync(path.join(skillRoot, 'assets/template.html'), 'utf8'); | ||
|
|
||
| const FONT_HOST_PATTERNS = [ | ||
| /fonts\.googleapis\.com/i, | ||
| /fonts\.gstatic\.com/i, | ||
| ]; | ||
|
|
||
| function assertNoFontHosts(label, html) { | ||
| for (const pattern of FONT_HOST_PATTERNS) { | ||
| assert.doesNotMatch(html, pattern, `${label} must not request ${pattern}`); | ||
| } | ||
| } | ||
|
|
||
| test('delivered HTML template does not request Google Fonts', () => { | ||
| assertNoFontHosts('archify/assets/template.html', template); | ||
| assert.match(template, /@font-face\s*\{[^}]*local\('JetBrains Mono'\)/); | ||
| }); | ||
|
|
||
| test('deliver output does not request Google Fonts', () => { | ||
| const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-offline-fonts-')); | ||
| const input = path.join(skillRoot, 'examples/web-app.architecture.json'); | ||
| const out = path.join(tmp, 'delivered.html'); | ||
| const result = spawnSync(process.execPath, [cli, 'deliver', 'architecture', input, out, '--json'], { | ||
| cwd: skillRoot, | ||
| encoding: 'utf8', | ||
| }); | ||
| assert.equal(result.status, 0, result.stderr || result.stdout); | ||
| assertNoFontHosts('deliver output', fs.readFileSync(out, 'utf8')); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the authoritative template without regenerating the checked-in examples and
archify.zipleaves this commit unable to pass its repository gates:archify/test/golden.mjsrejects all five stale example renders, while the CIzip-freshnessjob rebuilds and byte-compares the archive. The archive in this commit also still embeds the removed Google Fonts links, so users installing the documented ZIP distribution do not receive the fix; regenerate the golden examples and then rebuildarchify.zip.Useful? React with 👍 / 👎.