UNPKG

@nx/nest

Version:

The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.

70 lines (69 loc) 3.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeOptions = normalizeOptions; exports.toJsLibraryGeneratorOptions = toJsLibraryGeneratorOptions; const devkit_1 = require("@nx/devkit"); const internal_1 = require("@nx/devkit/internal"); const internal_2 = require("@nx/js/internal"); async function normalizeOptions(tree, options) { await (0, internal_1.ensureRootProjectName)(options, 'library'); const { projectName, names: projectNames, projectRoot, importPath, } = await (0, internal_1.determineProjectNameAndRootOptions)(tree, { name: options.name, projectType: 'library', directory: options.directory, importPath: options.importPath, }); const nxJson = (0, devkit_1.readNxJson)(tree); const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false; options.addPlugin ??= addPlugin; const fileName = projectNames.projectFileName; const parsedTags = options.tags ? options.tags.split(',').map((s) => s.trim()) : []; // this helper is called before the jsLibraryGenerator is called, so, if the // TS solution setup is not configured, we additionally check if the TS // solution setup will be configured by the jsLibraryGenerator const isUsingTsSolutionsConfig = (0, internal_2.isUsingTsSolutionSetup)(tree) || (0, internal_2.shouldConfigureTsSolutionSetup)(tree, addPlugin); const normalized = { ...options, strict: options.strict ?? true, controller: options.controller ?? false, fileName, global: options.global ?? false, linter: options.linter ?? 'eslint', parsedTags, prefix: (0, internal_2.getNpmScope)(tree), // we could also allow customizing this projectName: isUsingTsSolutionsConfig && !options.name ? importPath : projectName, projectRoot, importPath, service: options.service ?? false, target: options.target ?? 'es6', testEnvironment: options.testEnvironment ?? 'node', unitTestRunner: options.unitTestRunner ?? 'jest', isUsingTsSolutionsConfig, useProjectJson: options.useProjectJson ?? !isUsingTsSolutionsConfig, }; return normalized; } function toJsLibraryGeneratorOptions(options) { return { name: options.name, bundler: options.buildable || options.publishable ? 'tsc' : 'none', directory: options.directory, importPath: options.importPath, linter: options.linter, publishable: options.publishable, skipFormat: true, skipTsConfig: options.skipTsConfig, skipPackageJson: options.skipPackageJson, strict: options.strict, tags: options.tags, testEnvironment: options.testEnvironment, unitTestRunner: options.unitTestRunner, setParserOptionsProject: options.setParserOptionsProject, addPlugin: options.addPlugin, useProjectJson: options.useProjectJson, }; }