@nx/react
Version:
43 lines (42 loc) • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeOptions = normalizeOptions;
const devkit_1 = require("@nx/devkit");
const internal_1 = require("@nx/devkit/internal");
const assertion_1 = require("../../../utils/assertion");
const internal_2 = require("@nx/js/internal");
async function normalizeOptions(tree, options) {
(0, assertion_1.assertValidStyle)(options.style);
const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, internal_1.determineArtifactNameAndDirectoryOptions)(tree, {
path: options.path,
name: options.name,
allowedFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
fileExtension: 'tsx',
});
const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
const { className } = (0, devkit_1.names)(name);
const { sourceRoot: projectSourceRoot, root: projectRoot, projectType, } = project;
if (options.export &&
(0, internal_2.getProjectType)(tree, projectRoot, projectType) === 'application') {
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
}
options.classComponent = options.classComponent ?? false;
options.routing = options.routing ?? false;
options.globalCss = options.globalCss ?? false;
options.inSourceTests = options.inSourceTests ?? false;
//TODO (nicholas): Remove when Next page generator is removed
options.isNextPage = options.isNextPage ?? false;
return {
...options,
directory,
projectName,
hasStyles: options.style !== 'none',
className,
fileName,
filePath,
projectRoot,
projectSourceRoot,
fileExtension,
fileExtensionType,
};
}