import assert from 'node:assert/strict'; import {existsSync, readFileSync, readdirSync} from 'node:fs'; import {join} from 'node:path'; const root = process.cwd(); const read = (path) => readFileSync(join(root, path), 'utf8'); const config = read('docusaurus.config.ts'); const packageJson = JSON.parse(read('package.json')); const globalCss = read('src/css/custom.css'); const homepageCss = read('src/pages/index.module.css'); assert.match(config, /defaultMode:\s*'dark'/, 'dark must remain the default theme'); assert.match(config, /disableSwitch:\s*false/, 'theme switch must be enabled'); assert.match(globalCss, /\[data-theme=['"]light['"]\]/, 'global CSS needs an explicit light palette'); assert.match(homepageCss, /:global\(\[data-theme=['"]light['"]\]\)/, 'homepage needs a light palette'); assert.doesNotMatch(globalCss, /html,\s*body\s*\{\s*background:\s*#08101b/, 'document background must not be hard-coded dark'); for (const section of ['projects', 'teams', 'members', 'board', 'governance']) { assert.match(config, new RegExp(`id:\\s*'${section}'`), `${section} docs plugin is missing`); assert.match(config, new RegExp(`sidebarId:\\s*'${section}Sidebar'`), `${section} navbar item does not target its dedicated sidebar`); assert.ok(existsSync(join(root, `sidebars/${section}.ts`)), `${section} sidebar file is missing`); } assert.match(config, /baseUrl:\s*'\/corp-v1\/portal\/'/, 'Pages base URL must follow the renamed repository'); assert.match(config, /projectName:\s*'portal'/, 'Docusaurus project name must be portal'); assert.doesNotMatch(config, /sterring-commitee/, 'legacy repository name must not remain in Docusaurus config'); const board = read('docs/board/index.md'); for (const memberId of ['1518725627845283888', '476287310627864587', '773109855497093191']) { assert.ok(board.includes(memberId), `board page is missing Discord member ${memberId}`); } assert.match(board, /Only these Board members may approve a project kickoff or project closure/i); assert.match(board, /Only these Board members may approve changes to `corp-v1--main`/i); const lifecycle = read('docs/governance/project-lifecycle.md'); assert.match(lifecycle, /Board approval/i, 'project lifecycle must require Board approval'); assert.match(lifecycle, /central project-channel reference skill/i, 'lifecycle must govern central channel-reference skill changes'); assert.match(lifecycle, /project-adopted channel skill/i, 'lifecycle must require project skill synchronization'); for (const section of ['projects', 'teams', 'members']) { const sidebar = read(`sidebars/${section}.ts`); assert.match(sidebar, /label:\s*'Registry'/, `${section} sidebar registry label must be concise`); assert.doesNotMatch(sidebar, /label:\s*'(Projects|Teams|Members) Registry'/, `${section} sidebar must not repeat its section name`); } assert.ok(packageJson.dependencies?.['@easyops-cn/docusaurus-search-local'], 'local search dependency is missing'); assert.match(config, /@easyops-cn\/docusaurus-search-local/, 'local search theme is not configured'); assert.match(config, /indexPages:\s*true/, 'custom pages must be indexed'); for (const route of ['/', 'projects', 'teams', 'members', 'board', 'governance']) { assert.ok(config.includes(`'${route}'`), `search does not include route base ${route}`); } if (existsSync(join(root, 'build'))) { const filename = readdirSync(join(root, 'build')).find((name) => /^search-index(?:-[a-f0-9]+)?\.json$/.test(name)); assert.ok(filename, 'production search index is missing'); const search = readFileSync(join(root, 'build', filename), 'utf8').toLowerCase(); for (const term of ['projects registry', 'teams registry', 'members registry', 'board members', 'project lifecycle', 'corp v1 board']) { assert.ok(search.includes(term), `search index is missing: ${term}`); } } console.log('Portal behavior checks passed.');