fix(wechat): repair share preview on disk for sanitized delivery artifacts
Memind CI / Test, build, and release guards (push) Failing after 6s
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:
@@ -8,17 +8,25 @@ export function evaluatePageGenerateSendableArtifacts({
|
||||
confirmedArtifacts = [],
|
||||
repairContext = {},
|
||||
} = {}) {
|
||||
const sendable = selectSendableHtmlArtifacts({ verifiedArtifacts, confirmedArtifacts });
|
||||
const verified = sendable.filter((artifact) => verifyPageArtifactContent(artifact).ok);
|
||||
const publishDir = String(repairContext.publishDir ?? '').trim();
|
||||
const previewOptions = { publishDir };
|
||||
const sendable = selectSendableHtmlArtifacts({
|
||||
verifiedArtifacts,
|
||||
confirmedArtifacts,
|
||||
publishDir,
|
||||
});
|
||||
const verified = sendable.filter((artifact) =>
|
||||
verifyPageArtifactContent(artifact, previewOptions).ok,
|
||||
);
|
||||
const candidates = verified.length > 0 ? verified : sendable;
|
||||
const ready = filterSharePreviewReadyArtifacts(candidates);
|
||||
const ready = filterSharePreviewReadyArtifacts(candidates, previewOptions);
|
||||
if (ready.length > 0) return ready;
|
||||
|
||||
const repaired = [];
|
||||
for (const artifact of candidates) {
|
||||
if (!verifyPageArtifactContent(artifact).ok) continue;
|
||||
if (!verifyPageArtifactContent(artifact, previewOptions).ok) continue;
|
||||
const result = repairArtifactSharePreview(artifact, repairContext);
|
||||
if (result.ok && verifyArtifactSharePreview(artifact).ok) {
|
||||
if (result.ok && verifyArtifactSharePreview(artifact, previewOptions).ok) {
|
||||
repaired.push(artifact);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +50,10 @@ export function resolvePageGenerateOutcome({
|
||||
}) {
|
||||
const context = {
|
||||
topic: String(topic || repairContext.topic || '').trim(),
|
||||
publishDir: String(repairContext.publishDir ?? '').trim(),
|
||||
...repairContext,
|
||||
};
|
||||
const previewOptions = { publishDir: context.publishDir };
|
||||
const sendable = evaluatePageGenerateSendableArtifacts({
|
||||
verifiedArtifacts,
|
||||
confirmedArtifacts,
|
||||
@@ -71,11 +81,21 @@ export function resolvePageGenerateOutcome({
|
||||
}
|
||||
|
||||
const previewCandidates = filterSharePreviewReadyArtifacts(
|
||||
selectSendableHtmlArtifacts({ verifiedArtifacts, confirmedArtifacts }),
|
||||
selectSendableHtmlArtifacts({
|
||||
verifiedArtifacts,
|
||||
confirmedArtifacts,
|
||||
publishDir: context.publishDir,
|
||||
}),
|
||||
previewOptions,
|
||||
);
|
||||
if (previewCandidates.length === 0 && confirmedArtifacts.length > 0) {
|
||||
const previewIssue = verifyArtifactSharePreview(
|
||||
selectSendableHtmlArtifacts({ verifiedArtifacts, confirmedArtifacts })[0] ?? confirmedArtifacts[0],
|
||||
selectSendableHtmlArtifacts({
|
||||
verifiedArtifacts,
|
||||
confirmedArtifacts,
|
||||
publishDir: context.publishDir,
|
||||
})[0] ?? confirmedArtifacts[0],
|
||||
previewOptions,
|
||||
);
|
||||
return {
|
||||
action: 'fail',
|
||||
|
||||
Reference in New Issue
Block a user