UNPKG

@nx/plugin

Version:

This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.

48 lines (47 loc) 2.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeOptions = normalizeOptions; const devkit_1 = require("@nx/devkit"); const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils"); const generator_prompts_1 = require("@nx/js/src/utils/generator-prompts"); const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); async function normalizeOptions(host, options) { const linter = await (0, generator_prompts_1.normalizeLinterOption)(host, options.linter); const unitTestRunner = await (0, generator_prompts_1.normalizeUnitTestRunnerOption)(host, options.unitTestRunner, ['jest', 'vitest']); const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host); const nxJson = (0, devkit_1.readNxJson)(host); const addPlugin = options.addPlugin ?? (isTsSolutionSetup && process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false); await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library'); const { projectName, projectRoot, importPath } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, { name: options.name, projectType: 'library', directory: options.directory, importPath: options.importPath, rootProject: options.rootProject, }); options.rootProject = projectRoot === '.'; const projectDirectory = projectRoot; const parsedTags = options.tags ? options.tags.split(',').map((s) => s.trim()) : []; return { ...options, bundler: options.compiler ?? 'tsc', fileName: projectName, projectName: isTsSolutionSetup && !options.name ? importPath : projectName, projectRoot, projectDirectory, parsedTags, importPath, publishable: options.publishable ?? false, linter, unitTestRunner, // We default to generate a project.json file if the new setup is not being used useProjectJson: options.useProjectJson ?? !isTsSolutionSetup, addPlugin, isTsSolutionSetup, }; }