UNPKG

@nx/detox

Version:

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

58 lines (57 loc) 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.detoxApplicationGenerator = detoxApplicationGenerator; exports.detoxApplicationGeneratorInternal = detoxApplicationGeneratorInternal; const devkit_1 = require("@nx/devkit"); const js_1 = require("@nx/js"); const init_1 = require("../init/init"); const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry"); const add_linting_1 = require("./lib/add-linting"); const add_project_1 = require("./lib/add-project"); const create_files_1 = require("./lib/create-files"); const normalize_options_1 = require("./lib/normalize-options"); const ensure_dependencies_1 = require("./lib/ensure-dependencies"); const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields"); async function detoxApplicationGenerator(host, schema) { return await detoxApplicationGeneratorInternal(host, { addPlugin: false, useProjectJson: true, ...schema, }); } async function detoxApplicationGeneratorInternal(host, schema) { const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(host, schema.addPlugin); const jsInitTask = await (0, js_1.initGenerator)(host, { addTsPlugin, skipFormat: true, }); const options = await (0, normalize_options_1.normalizeOptions)(host, schema); const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true, }); (0, create_files_1.createFiles)(host, options); (0, add_project_1.addProject)(host, options); (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host, options); const lintingTask = await (0, add_linting_1.addLinting)(host, options); const depsTask = (0, ensure_dependencies_1.ensureDependencies)(host, options); (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.e2eProjectRoot, 'tsconfig.json', { module: 'esnext', moduleResolution: 'bundler', outDir: 'out-tsc/detox', allowJs: true, types: ['node', 'jest', 'detox'], }, options.linter === 'eslint' ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs'] : undefined); if (options.isUsingTsSolutionConfig) { await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot); } (0, sort_fields_1.sortPackageJsonFields)(host, options.e2eProjectRoot); if (!options.skipFormat) { await (0, devkit_1.formatFiles)(host); } return (0, devkit_1.runTasksInSerial)(jsInitTask, initTask, lintingTask, depsTask); } exports.default = detoxApplicationGenerator;