UNPKG

@nx/next

Version:

The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides: - Scaffolding for creating, building, serving, linting, and testing Next.js applications. - Integration wit

59 lines (58 loc) 2.69 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 assertion_1 = require("@nx/react/src/utils/assertion"); const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup"); async function normalizeOptions(host, options) { await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application'); const { projectName, names: projectNames, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, { name: options.name, projectType: 'application', directory: options.directory, rootProject: options.rootProject, }); options.rootProject = appProjectRoot === '.'; const nxJson = (0, devkit_1.readNxJson)(host); const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false; options.addPlugin ??= addPlugin; const isTsSolutionSetup = options.useTsSolution || (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host); const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath; const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`; const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`; const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [projectNames.projectFileName] : [])); const parsedTags = options.tags ? options.tags.split(',').map((s) => s.trim()) : []; const fileName = 'index'; const appDir = options.appDir ?? true; const src = options.src ?? true; const styledModule = /^(css|scss|less|tailwind)$/.test(options.style) ? null : options.style; (0, assertion_1.assertValidStyle)(options.style); return { ...options, appDir, src, appProjectRoot, e2eProjectName, e2eProjectRoot, e2eTestRunner: options.e2eTestRunner || 'playwright', fileName, linter: options.linter || 'eslint', outputPath, parsedTags, projectName: appProjectName, projectSimpleName: projectNames.projectSimpleName, style: options.style || 'css', swc: options.swc ?? true, styledModule, unitTestRunner: options.unitTestRunner || 'jest', importPath, isTsSolutionSetup, useProjectJson: options.useProjectJson ?? !isTsSolutionSetup, }; }