UNPKG

@scullyio/scully-plugin-playwright

Version:

The playwright renderer is utilizing the [playwright](https://playwright.dev/) engine to render your pages.

43 lines 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.playwrightRender = void 0; const tslib_1 = require("tslib"); const scully_1 = require("@scullyio/scully"); const child_process_1 = require("child_process"); const plugins_scully_plugin_playwright_1 = require("./lib/plugins-scully-plugin-playwright"); const plugins_scully_plugin_playwright_utils_1 = require("./lib/plugins-scully-plugin-playwright-utils"); function runScript(cmd) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { child_process_1.exec(cmd, (err, stdout, stderr) => { if (err) { scully_1.log(stderr); reject(err); } else { resolve(stdout); } }); }); }); } const plugin = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { yield runScript(`npx playwright install`).catch(() => { scully_1.logError(`Playwright install failed. Please fix the above errors in the app, and run Scully again.`); process.exit(0); }); scully_1.log(` ${scully_1.green('✔')} Playwright installation successfully`); }); scully_1.registerPlugin('beforeAll', 'installPWDeps', plugin); /** enable as default routeRenderer */ scully_1.registerPlugin('scullySystem', scully_1.routeRenderer, plugins_scully_plugin_playwright_1.playwrightRenderer, undefined, { replaceExistingPlugin: true }); /** also add as its own thing, perhaps we want to combine later, or use it differently */ scully_1.registerPlugin('enterprise', plugins_scully_plugin_playwright_1.playwrightRender, plugins_scully_plugin_playwright_1.playwrightRenderer); scully_1.registerPlugin('enterprise', 'getPWLaunchedBrowser', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return plugins_scully_plugin_playwright_utils_1.launchedBrowser$; })); scully_1.registerPlugin('beforeAll', 'startLaunching the browser', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { scully_1.logOk('Playwright is being launched'); plugins_scully_plugin_playwright_utils_1.launchedBrowser(); })); var plugins_scully_plugin_playwright_2 = require("./lib/plugins-scully-plugin-playwright"); Object.defineProperty(exports, "playwrightRender", { enumerable: true, get: function () { return plugins_scully_plugin_playwright_2.playwrightRender; } }); //# sourceMappingURL=index.js.map