UNPKG

@nx/playwright

Version:

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

33 lines (32 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initGenerator = initGenerator; exports.initGeneratorInternal = initGeneratorInternal; const devkit_1 = require("@nx/devkit"); const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin"); const plugin_1 = require("../../plugins/plugin"); const versions_1 = require("../../utils/versions"); function initGenerator(tree, options) { return initGeneratorInternal(tree, { addPlugin: false, ...options }); } async function initGeneratorInternal(tree, options) { 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)); } if (options.addPlugin) { await (0, add_plugin_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;