UNPKG

@nx/playwright

Version:

The Nx Plugin for Playwright contains executors and generators allowing your workspace to use the powerful Playwright integration testing capabilities.

35 lines (34 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initGenerator = initGenerator; exports.initGeneratorInternal = initGeneratorInternal; const internal_1 = require("@nx/devkit/internal"); const devkit_1 = require("@nx/devkit"); const plugin_1 = require("../../plugins/plugin"); const assert_supported_playwright_version_1 = require("../../utils/assert-supported-playwright-version"); const versions_1 = require("../../utils/versions"); function initGenerator(tree, options) { return initGeneratorInternal(tree, { addPlugin: false, ...options }); } async function initGeneratorInternal(tree, options) { (0, assert_supported_playwright_version_1.assertSupportedPlaywrightVersion)(tree); const tasks = []; const nxJson = (0, devkit_1.readNxJson)(tree); const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false; options.addPlugin ??= addPluginDefault; if (!options.skipPackageJson) { tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/playwright': versions_1.nxVersion, '@playwright/test': versions_1.playwrightVersion, }, undefined, options.keepExistingVersions ?? true)); } if (options.addPlugin) { await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/playwright/plugin', plugin_1.createNodesV2, { targetName: ['e2e', 'playwright:e2e', 'playwright-e2e'] }, options.updatePackageScripts); } if (!options.skipFormat) { await (0, devkit_1.formatFiles)(tree); } return (0, devkit_1.runTasksInSerial)(...tasks); } exports.default = initGenerator;