d3239ff292
Ensure page sync runs via pageSyncService in remote mode, fall back to workspace HTML when storage assets are missing, and prevent production Portal from linking to loopback Plaza URLs baked in at build time. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const root = path.resolve(new URL('..', import.meta.url).pathname);
|
|
|
|
function read(relativePath) {
|
|
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
|
}
|
|
|
|
function assertIncludes(label, source, snippet) {
|
|
if (!source.includes(snippet)) {
|
|
throw new Error(`${label} is missing required guard snippet:\n${snippet}`);
|
|
}
|
|
}
|
|
|
|
const serverSource = read('server.mjs');
|
|
const pagesSource = read('mindspace-pages.mjs');
|
|
const contractSource = read('mindspace-server-adapter-contract.mjs');
|
|
|
|
assertIncludes(
|
|
'server.mjs syncUserGeneratedPages',
|
|
serverSource,
|
|
'await mindSpacePageSync.syncUserGeneratedPages(userId);',
|
|
);
|
|
if (serverSource.includes("mindSpaceServerRuntime.adapterKind === 'remote'")) {
|
|
throw new Error(
|
|
'server.mjs must not skip page sync in remote mode; use pageSyncService RPC instead',
|
|
);
|
|
}
|
|
|
|
assertIncludes(
|
|
'mindspace-server-adapter-contract.mjs',
|
|
contractSource,
|
|
"pageSyncService: Object.freeze(['syncUserGeneratedPages'])",
|
|
);
|
|
|
|
assertIncludes(
|
|
'mindspace-pages.mjs',
|
|
pagesSource,
|
|
'readPageContentWithWorkspaceFallback',
|
|
);
|
|
assertIncludes(
|
|
'mindspace-pages.mjs workspace fallback',
|
|
pagesSource,
|
|
"snapshot.relative_path ?? null",
|
|
);
|
|
|
|
const publicSiteBasesSource = read('src/utils/public-site-bases.mjs');
|
|
const publicUrlSource = read('src/utils/publicUrl.ts');
|
|
const buildRuntimeSource = read('scripts/build-portal-runtime.mjs');
|
|
|
|
assertIncludes(
|
|
'public-site-bases.mjs loopback guard',
|
|
publicSiteBasesSource,
|
|
'isLoopbackPublicBase',
|
|
);
|
|
assertIncludes(
|
|
'publicUrl.ts uses public-site-bases',
|
|
publicUrlSource,
|
|
"from './public-site-bases.mjs'",
|
|
);
|
|
assertIncludes(
|
|
'build-portal-runtime.mjs production plaza default',
|
|
buildRuntimeSource,
|
|
'https://plaza.tkmind.cn',
|
|
);
|
|
|
|
console.log('mindspace page sync + thumbnail regression guards ok');
|