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.

39 lines (38 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeSchema = normalizeSchema; 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 normalizeSchema(host, schema) { const linter = await (0, generator_prompts_1.normalizeLinterOption)(host, schema.linter); const unitTestRunner = await (0, generator_prompts_1.normalizeUnitTestRunnerOption)(host, schema.unitTestRunner, ['jest']); if (!schema.directory) { throw new Error(`Please provide the --directory option. It should be the directory containing the project '${schema.project}'.`); } const { projectName, names: projectNames, projectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, { name: schema.name, projectType: 'library', directory: schema.directory, }); const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host); const nxJson = (0, devkit_1.readNxJson)(host); const addPlugin = schema.addPlugin ?? (isTsSolutionSetup && process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false); return { ...schema, bundler: schema.compiler ?? 'tsc', projectName, projectRoot, name: projectNames.projectSimpleName, linter, unitTestRunner, // We default to generate a project.json file if the new setup is not being used useProjectJson: schema.useProjectJson ?? !isTsSolutionSetup, addPlugin, isTsSolutionSetup, }; }