import Debug from 'debug' import _ from 'lodash' import send from 'send' import type { SpecsStore } from '@packages/server/lib/specs-store' import { getPathToIndex, getPathToDist } from '@packages/resolve-dist' import type { Cfg } from '@packages/server/lib/project-base' import type { Browser } from '@packages/server/lib/browsers/types' interface ServeOptions { config: Cfg getCurrentBrowser: () => Browser specsStore: SpecsStore } const debug = Debug('cypress:server:runner-ct') export const handle = (req, res) => { const pathToFile = getPathToDist('runner-ct', req.params[0]) return send(req, pathToFile) .pipe(res) } export const serve = (req, res, options: ServeOptions) => { const config = { ...options.config, browser: options.getCurrentBrowser(), specs: options.specsStore.specFiles, } as Cfg // TODO: move the component file watchers in here // and update them in memory when they change and serve // them straight to the HTML on load debug('serving runner index.html with config %o', _.pick(config, 'version', 'platform', 'arch', 'projectName')) // base64 before embedding so user-supplied contents can't break out of