fix(wechat): repair share preview on disk for sanitized delivery artifacts
Memind CI / Test, build, and release guards (push) Failing after 6s

Production WeChat delivery strips localPath from artifacts, so share-preview
auto-repair never wrote back to HTML. Resolve paths via publishDir +
relativePath, repair at materialize and delivery prep, and pass h5Root from
Portal so page.generate can patch missing meta before sending links.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-02 08:47:51 +08:00
parent 0a71370bf4
commit 1faba62f9b
11 changed files with 238 additions and 75 deletions
+23 -18
View File
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import { artifactFileExists } from './page-artifact.mjs';
import { resolveArtifactLocalPath } from './page-artifact.mjs';
import { hasPlatformBrandMarker } from '../../mindspace-page-tag.mjs';
export { hasPlatformBrandMarker };
@@ -57,26 +58,30 @@ export function verifySharePreviewMeta(html) {
return { ok: true, reason: null };
}
export function verifyArtifactSharePreview(artifact) {
if (!artifactFileExists(artifact)) {
return { ok: false, reason: 'missing_file' };
}
if (!String(artifact?.localPath ?? '').trim()) {
if (
typeof artifact?.sharePreview?.ok ===
'boolean'
) {
return artifact.sharePreview;
export function verifyArtifactSharePreview(artifact, { publishDir = '' } = {}) {
const localPath = resolveArtifactLocalPath(artifact, publishDir);
if (localPath) {
try {
if (fs.existsSync(localPath) && fs.statSync(localPath).isFile()) {
const content = fs.readFileSync(localPath, 'utf8');
return verifySharePreviewMeta(content);
}
} catch {
// Fall back to cached sharePreview metadata below.
}
return {
ok: false,
reason: 'missing_share_preview_evaluation',
};
}
const content = fs.readFileSync(artifact.localPath, 'utf8');
return verifySharePreviewMeta(content);
if (
typeof artifact?.sharePreview?.ok ===
'boolean'
) {
return artifact.sharePreview;
}
return {
ok: false,
reason: 'missing_file',
};
}
export function filterSharePreviewReadyArtifacts(artifacts = []) {
return artifacts.filter((artifact) => verifyArtifactSharePreview(artifact).ok);
export function filterSharePreviewReadyArtifacts(artifacts = [], options = {}) {
return artifacts.filter((artifact) => verifyArtifactSharePreview(artifact, options).ok);
}