UNPKG

@nx/angular

Version:

The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: - Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypre

21 lines (20 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateProject = validateProject; exports.validateClassName = validateClassName; const devkit_1 = require("@nx/devkit"); function validateProject(tree, projectName) { const projects = (0, devkit_1.getProjects)(tree); if (!projects.has(projectName)) { throw new Error(`Project "${projectName}" does not exist! Please provide an existing project name.`); } } // The below validation matches that of the Angular CLI: // https://github.com/angular/angular-cli/blob/1316930a1cbad8e71a4454743862cfa9253bef4e/packages/schematics/angular/utility/validation.ts#L25 // See: https://github.com/tc39/proposal-regexp-unicode-property-escapes/blob/fe6d07fad74cd0192d154966baa1e95e7cda78a1/README.md#other-examples const ecmaIdentifierNameRegExp = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u; function validateClassName(className) { if (!ecmaIdentifierNameRegExp.test(className)) { throw new Error(`Class name "${className}" is invalid.`); } }