MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / main

Function main

telemetry-dashboard/scripts/render-check.mjs:231–504  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229}
230
231async function main() {
232 const browserPath = findBrowser();
233 if (!browserPath) {
234 console.log('render-check: no Chromium found — skipping.');
235 console.log(' Set CHROME_BIN, or install Chrome; the shell smoke suites cover the rest.');
236 return 0;
237 }
238 console.log(`Browser: ${browserPath}`);
239
240 console.log('Seeding the local D1 fixture…');
241 const seed = run('./scripts/seed-fixture.sh', [], { stdio: 'inherit' });
242 const seeded = await new Promise((resolve) => seed.on('exit', resolve));
243 if (seeded !== 0) throw new Error('seeding failed');
244
245 console.log(`Starting wrangler dev on :${PORT}…`);
246 run('npx', ['wrangler', 'dev', '--port', String(PORT), '--ip', '127.0.0.1']);
247 await waitFor('wrangler dev', async () => (await fetch(`${BASE}/robots.txt`)).ok);
248
249 const password = readFileSync(join(root, '.dev.vars'), 'utf8').match(/^ADMIN_PASSWORD="(.*)"$/m)?.[1];
250 if (!password) throw new Error('no ADMIN_PASSWORD in .dev.vars');
251 const login = await fetch(`${BASE}/login`, {
252 method: 'POST',
253 body: new URLSearchParams({ password }),
254 redirect: 'manual',
255 });
256 const cookie = login.headers.getSetCookie().find((c) => c.startsWith('cg_admin_session='));
257 if (!cookie) throw new Error('login did not set a session cookie');
258 const [name, value] = cookie.split(';')[0].split('=');
259
260 profileDir = mkdtempSync(join(tmpdir(), 'cg-dash-profile-'));
261 // chrome-headless-shell is headless by construction and rejects the flag;
262 // a full Chrome needs it.
263 const headlessFlag = browserPath.includes('headless') ? [] : ['--headless=new'];
264 run(browserPath, [
265 ...headlessFlag,
266 '--disable-gpu',
267 '--no-first-run',
268 '--no-default-browser-check',
269 '--remote-debugging-port=0',
270 `--user-data-dir=${profileDir}`,
271 'about:blank',
272 ]);
273
274 let devtoolsPort = null;
275 await waitFor('the browser', () => {
276 const portFile = join(profileDir, 'DevToolsActivePort');
277 if (!existsSync(portFile)) return false;
278 devtoolsPort = Number(readFileSync(portFile, 'utf8').split('\n')[0]);
279 return Number.isFinite(devtoolsPort) && devtoolsPort > 0;
280 }, 30);
281
282 const version = await (await fetch(`http://127.0.0.1:${devtoolsPort}/json/version`)).json();
283 const cdp = await CDP.connect(version.webSocketDebuggerUrl);
284 const { targetId } = await cdp.send('Target.createTarget', { url: 'about:blank' });
285 const { sessionId } = await cdp.send('Target.attachToTarget', { targetId, flatten: true });
286
287 await cdp.send('Page.enable', {}, sessionId);
288 await cdp.send('Runtime.enable', {}, sessionId);

Callers 1

render-check.mjsFile · 0.70

Calls 15

findBrowserFunction · 0.85
NumberInterface · 0.85
sameFunction · 0.85
shortDayFunction · 0.85
apiGetFunction · 0.85
mapMethod · 0.80
fromMethod · 0.80
runFunction · 0.70
waitForFunction · 0.70
utcDayFunction · 0.70
checkFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected