Files
wp-asciiplayer/scripts/verify-build.mjs
T
LamGC f04600c37b Refresh player with native block editor preview and local assets
Preserve shortcode rendering, normalize options, bundle the player locally,
and add reproducible packaging and WordPress integration tests.
2026-10-12 17:56:08 +08:00

18 lines
1.2 KiB
JavaScript

import { readFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
const hash = (data) => createHash('sha256').update(data).digest('hex');
const asset = await readFile('build/index.asset.php', 'utf8');
if (asset.includes('react-jsx-runtime')) throw new Error('Automatic JSX runtime would break the WordPress 6.3 baseline.');
for (const dependency of ['wp-blocks', 'wp-block-editor', 'wp-element', 'wp-compose']) {
if (!asset.includes(`'${dependency}'`)) throw new Error(`Missing editor dependency: ${dependency}`);
}
for (const [destination, original] of [
['build/player.js', 'node_modules/asciinema-player/dist/bundle/asciinema-player.min.js'],
['build/player.css', 'node_modules/asciinema-player/dist/bundle/asciinema-player.css'],
]) {
if (hash(await readFile(destination)) !== hash(await readFile(original))) throw new Error(`Vendor file mismatch: ${destination}`);
}
const metadata = JSON.parse(await readFile('build/block.json', 'utf8'));
if (metadata.apiVersion !== 3 || metadata.name !== 'lamgc/asciiplayer') throw new Error('Unexpected block metadata.');
console.log('Verified WordPress 6.3-compatible JSX dependencies, block metadata, and exact local vendor files.');