@nx/angular
Version:
56 lines (55 loc) • 2.47 kB
JavaScript
;
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 test_runners_1 = require("../../../utils/test-runners");
function arePluginsExplicitlyDisabled(host) {
const { useInferencePlugins } = (0, devkit_1.readNxJson)(host);
const addPluginEnvVar = process.env.NX_ADD_PLUGINS;
return useInferencePlugins === false || addPluginEnvVar === 'false';
}
async function normalizeOptions(host, options, isRspack) {
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
const { projectName: appProjectName, projectRoot: appProjectRoot } = 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 e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
const parsedTags = options.tags
? options.tags.split(',').map((s) => s.trim())
: [];
const bundler = options.bundler ?? 'esbuild';
const addPlugin = options.addPlugin ?? (!arePluginsExplicitlyDisabled(host) && isRspack);
// Set defaults and then overwrite with user options
return {
addPlugin,
style: 'css',
routing: true,
inlineStyle: false,
inlineTemplate: false,
skipTests: options.unitTestRunner === test_runners_1.UnitTestRunner.None,
skipFormat: false,
e2eTestRunner: test_runners_1.E2eTestRunner.Playwright,
linter: 'eslint',
strict: true,
standalone: true,
directory: appProjectRoot,
...options,
prefix: options.prefix || 'app',
name: appProjectName,
appProjectRoot,
appProjectSourceRoot: `${appProjectRoot}/src`,
e2eProjectRoot,
e2eProjectName,
parsedTags,
bundler,
outputPath: (0, devkit_1.joinPathFragments)('dist', !options.rootProject ? appProjectRoot : appProjectName),
ssr: options.ssr ?? false,
unitTestRunner: options.unitTestRunner ?? test_runners_1.UnitTestRunner.Jest,
};
}